index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div class="m-4 modals">
  3. <div>
  4. <div class="flex items-center justify-between my-4">
  5. <div>
  6. <a-button type="primary" size="large" class="btn-add" @click="handleCreate"
  7. ><template #icon> <Icon icon="icon-xt-add_default|iconfont" /> </template
  8. >新增检测</a-button
  9. >
  10. </div>
  11. <div>
  12. <XTForm :form-data="formData" @change="callForm" />
  13. </div>
  14. </div>
  15. </div>
  16. <BasicTable @register="registerTable">
  17. <template #headerCell="{ column }">
  18. <template v-if="column.key === 'deviceUniqueCode'">
  19. <span>设备编号</span>
  20. </template>
  21. <template v-if="column.key === 'deviceManufacturer'">
  22. <span>设备厂家</span>
  23. </template>
  24. <template v-if="column.key === 'deviceSerialNumber'">
  25. <span>设备型号</span>
  26. </template>
  27. <template v-if="column.key === 'detectionTime'">
  28. <span>检测时间</span>
  29. </template>
  30. <template v-if="column.key === 'intakeBacteria'">
  31. <span>进水口细菌(cfu/ml)<br />正常值≤100<br />干预值>50</span>
  32. </template>
  33. <template v-if="column.key === 'intakeEndotoxin'">
  34. <span>进水口内毒素(Eu/ml)<br />正常值≤0.5<br />干预值>0.25</span>
  35. </template>
  36. <template v-if="column.key === 'outletBacteria'">
  37. <span>出水口细菌(cfu/ml)<br />正常值≤100<br />干预值>50</span>
  38. </template>
  39. <template v-if="column.key === 'outletEndotoxin'">
  40. <span>出水口内毒素(Eu/ml)<br />正常值≤0.5<br />干预值>0.25</span>
  41. </template>
  42. <template v-if="column.key === 'action'">
  43. <span>操作</span>
  44. </template>
  45. </template>
  46. <template #bodyCell="{ column, record }">
  47. <template v-if="column.key === 'disable'">
  48. <span
  49. :class="['table-dot']"
  50. :style="{ backgroundColor: formatDictPreColor(responseTypeOptions, record.disable) }"
  51. />
  52. <span> {{ formatDictValue(responseTypeOptions, record.disable) }}</span>
  53. </template>
  54. <template v-if="column.key === 'supplierCategory'">
  55. <span>
  56. {{ formatDictValue(responsesupplierCategoryOptions, record.supplierCategory) }}</span
  57. >
  58. </template>
  59. <template v-if="column.key === 'intakeBacteria'">
  60. <span v-if="record.intakeBacteriaStatus === '0'">{{ record.intakeBacteria }}</span>
  61. <span v-else :class="record.intakeBacteriaStatus === '2' ? 'upStatus' : 'downStatus'">{{
  62. record.intakeBacteria
  63. }}</span>
  64. </template>
  65. <template v-if="column.key === 'intakeEndotoxin'">
  66. <span v-if="record.intakeEndotoxinStatus === '0'">{{ record.intakeEndotoxin }}</span>
  67. <span v-else :class="record.intakeEndotoxinStatus === '2' ? 'upStatus' : 'downStatus'">{{
  68. record.intakeEndotoxin
  69. }}</span>
  70. </template>
  71. <template v-if="column.key === 'outletBacteria'">
  72. <span v-if="record.outletBacteriaStatus === '0'">{{ record.outletBacteria }}</span>
  73. <span v-else :class="record.outletBacteriaStatus === '2' ? 'upStatus' : 'downStatus'">{{
  74. record.outletBacteria
  75. }}</span>
  76. </template>
  77. <template v-if="column.key === 'outletEndotoxin'">
  78. <span v-if="record.outletEndotoxinStatus === '0'">{{ record.outletEndotoxin }}</span>
  79. <span v-else :class="record.outletEndotoxinStatus === '2' ? 'upStatus' : 'downStatus'">{{
  80. record.outletEndotoxin
  81. }}</span>
  82. </template>
  83. <template v-if="column.key === 'action'">
  84. <TableAction
  85. :actions="[
  86. {
  87. auth: 'biz:consumable:edit',
  88. icon: 'icon-xt-details_edit_default|iconfont',
  89. tooltip: '编辑',
  90. onClick: handleEdit.bind(null, record),
  91. },
  92. ]"
  93. />
  94. </template>
  95. </template>
  96. </BasicTable>
  97. <FormModal @register="registerModal" @success="callSuccess" @cancel="handleCancel" />
  98. </div>
  99. </template>
  100. <script lang="ts" setup>
  101. import { onBeforeMount, ref } from 'vue';
  102. import { BasicTable, useTable, TableAction } from '/@/components/TableCard';
  103. import FormModal from './formModal.vue';
  104. import Icon from '/@/components/Icon';
  105. import { formatDictValue, formatDictPreColor } from '/@/utils';
  106. import { columns } from './data';
  107. import { microbialDetectionWaterQueryPage } from '/@/api/biz/bio/microbialDetectionWaterApi';
  108. import { listDictModel } from '/@/api/common';
  109. import { useModal } from '/@/components/Modal';
  110. import { XTForm } from '/@/components/XTForm/index';
  111. import dayjs from 'dayjs';
  112. // formdata
  113. const formData = [
  114. {
  115. label: '检测时间:',
  116. name: 'shiftDate',
  117. componentType: 'RangePicker',
  118. format: 'YYYY-MM-DD',
  119. valueFormat: 'YYYY-MM-DD',
  120. placeholder: '请选择日期',
  121. width: 240,
  122. },
  123. {
  124. name: 'searchNames',
  125. componentType: 'Input',
  126. prefix: 'icon-xt-search',
  127. placeholder: '请输入设备编号',
  128. width: 240,
  129. },
  130. ];
  131. // tab 切换选中
  132. const tabSelected = ref();
  133. // 操作名称
  134. const searchNames = ref('');
  135. const shiftDate = ref([]);
  136. const responseTypeOptions = ref();
  137. const responsesupplierCategoryOptions = ref();
  138. onBeforeMount(async () => {
  139. responseTypeOptions.value = await listDictModel({ dictCode: 'sys_disable_type' });
  140. responsesupplierCategoryOptions.value = await listDictModel({ dictCode: 'pht' });
  141. });
  142. const [registerModal, { openModal }] = useModal();
  143. const tableSort = ref([
  144. {
  145. field: 'create_time',
  146. direction: 'DESC',
  147. },
  148. ]) as any;
  149. const [registerTable, { reload, clearSelectedRowKeys }] = useTable({
  150. api: microbialDetectionWaterQueryPage,
  151. rowKey: 'id',
  152. columns,
  153. showIndexColumn: false,
  154. bordered: true,
  155. actionColumn: {
  156. width: 200,
  157. title: '操作',
  158. dataIndex: 'action',
  159. },
  160. beforeFetch: handleBeforeFetch,
  161. sortFn: handleSortFn,
  162. });
  163. // 详情按钮事件
  164. function handleEdit(record) {
  165. openModal(true, {
  166. isUpdate: true,
  167. record,
  168. });
  169. }
  170. // 表格点击字段排序
  171. function handleSortFn(sortInfo) {
  172. if (sortInfo?.order && sortInfo?.columnKey) {
  173. // 默认单列排序
  174. tableSort.value = [
  175. {
  176. field: sortInfo.columnKey,
  177. direction: sortInfo.order.replace(/(\w+)(end)/g, '$1').toUpperCase(),
  178. },
  179. ];
  180. }
  181. }
  182. // 表格请求之前,对参数进行处理, 添加默认 排序
  183. async function handleBeforeFetch(params) {
  184. const shiftTimes = [];
  185. if (shiftDate.value && shiftDate.value.length > 0) {
  186. shiftTimes.push(shiftDate.value[0]);
  187. shiftTimes.push(shiftDate.value[1]);
  188. shiftTimes[1] = dayjs(shiftTimes[1]).add(1, 'day').format('YYYY-MM-DD');
  189. }
  190. return {
  191. ...params,
  192. orders: tableSort.value,
  193. name: searchNames.value == '' ? undefined : searchNames.value,
  194. status: tabSelected.value == '' ? undefined : tabSelected.value,
  195. time: shiftTimes.length <= 0 ? undefined : shiftTimes,
  196. };
  197. }
  198. // 新增按钮事件
  199. function handleCreate() {
  200. openModal(true, {
  201. isUpdate: false,
  202. });
  203. }
  204. //取消按钮事件
  205. async function handleCancel() {
  206. clearSelectedRowKeys();
  207. await reload();
  208. }
  209. // 弹窗回调事件
  210. async function callSuccess({ isUpdate, values }) {
  211. console.log(isUpdate);
  212. console.log(values);
  213. await reload();
  214. }
  215. // 查询组件回调
  216. async function callForm(data) {
  217. shiftDate.value = data.shiftDate ? data.shiftDate : '';
  218. searchNames.value = data.searchNames ? data.searchNames : '';
  219. console.log('callForm:::', searchNames.value);
  220. await reload();
  221. }
  222. </script>
  223. <style lang="less" scoped>
  224. .table-dot {
  225. display: inline-block;
  226. width: 10px;
  227. height: 10px;
  228. margin-right: 6px;
  229. border-radius: 50%;
  230. }
  231. ::v-deep(.ant-btn-link) {
  232. color: #3d4155;
  233. }
  234. ::v-deep(.ant-input-prefix) {
  235. color: #8a99ac;
  236. }
  237. .colUpdateAvatar {
  238. display: flex;
  239. justify-content: center;
  240. text-align: center;
  241. line-height: 28px;
  242. }
  243. .colImg {
  244. width: 28px;
  245. height: 28px;
  246. margin-right: 5px;
  247. }
  248. .upStatus {
  249. color: #ff5d39;
  250. }
  251. .downStatus {
  252. color: #ffad26;
  253. }
  254. </style>