index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div>
  3. <div class="flex justify-between mb-4">
  4. <div>
  5. <a-button type="primary" size="large" class="btn-add" @click="handleCreate"
  6. ><template #icon> <Icon icon="icon-xt-add_default|iconfont" /> </template
  7. >新增检查</a-button
  8. >
  9. </div>
  10. <div>
  11. <XTForm :form-data="formData" @change="callForm" />
  12. </div>
  13. </div>
  14. <BasicTable @register="registerTable">
  15. <template #bodyCell="{ column, record }">
  16. <template v-if="column.key === 'examinerTime'">
  17. {{ dayjs(record.examinerTime).format('YYYY-MM-DD') }}
  18. </template>
  19. <template v-for="item in dataFiled" :key="item">
  20. <template v-if="item === 'systemDisinfection' || item === 'filterReplacement'">
  21. <template v-if="column.key === item">
  22. <span>{{ record.checkContent[item] === 1 ? '是' : '否' }}</span>
  23. </template>
  24. </template>
  25. <template v-else>
  26. <template v-if="column.key === item">
  27. <span>{{ record.checkContent[item] === 1 ? '合格' : '不合格' }}</span>
  28. </template>
  29. </template>
  30. </template>
  31. </template>
  32. </BasicTable>
  33. <FormDrawer @register="registerDrawer" @success="callSuccess" />
  34. <!-- @cancel="handleCancel" -->
  35. </div>
  36. </template>
  37. <script lang="ts" setup>
  38. import { onBeforeMount, reactive, ref } from 'vue';
  39. import { XTForm } from '/@/components/XTForm/index';
  40. import { useDrawer } from '/@/components/Drawer';
  41. import FormDrawer from './formDrawer.vue';
  42. import { BasicTable, useTable } from '/@/components/Table';
  43. import Icon from '/@/components/Icon/index';
  44. import { columns, dataFiled } from './data';
  45. import { waterTreatmentQueryPage } from '/@/api/biz/engineer/waterTreatmentApi';
  46. import dayjs from 'dayjs';
  47. const props = defineProps({
  48. info: {
  49. type: Object,
  50. default: () => {},
  51. },
  52. });
  53. const [registerDrawer, { openDrawer }] = useDrawer();
  54. const tableSort = ref([
  55. {
  56. field: 'create_time',
  57. direction: 'DESC',
  58. },
  59. ]) as any;
  60. // formdata
  61. const formData = [
  62. {
  63. name: 'patrolTime',
  64. label: '检查时间',
  65. componentType: 'RangePicker',
  66. placeholder: '请选择检查时间',
  67. format: 'YYYY-MM-DD',
  68. valueFormat: 'YYYY-MM-DD',
  69. },
  70. ];
  71. const formValue = reactive({
  72. patrolTime: [],
  73. maintainCompany: '',
  74. });
  75. const [registerTable, { reload }] = useTable({
  76. api: waterTreatmentQueryPage,
  77. rowKey: 'id',
  78. columns,
  79. showIndexColumn: false,
  80. bordered: true,
  81. striped: false,
  82. // actionColumn: {
  83. // width: 100,
  84. // title: '操作',
  85. // dataIndex: 'action',
  86. // },
  87. beforeFetch: handleBeforeFetch,
  88. });
  89. onBeforeMount(async () => {});
  90. // 新增按钮事件
  91. function handleCreate() {
  92. openDrawer(true, {
  93. isUpdate: false,
  94. record: { id: props.info.id },
  95. });
  96. }
  97. // 表格请求之前,对参数进行处理, 添加默认 排序
  98. function handleBeforeFetch(params) {
  99. return {
  100. ...params,
  101. orders: tableSort.value,
  102. deviceId: props.info?.id,
  103. maintainTime:
  104. formValue.patrolTime && formValue.patrolTime.length > 0
  105. ? [
  106. formValue.patrolTime[0],
  107. dayjs(formValue.patrolTime[1]).add(1, 'day').format('YYYY-MM-DD'),
  108. ]
  109. : undefined,
  110. maintainCompany: formValue.maintainCompany,
  111. };
  112. }
  113. // 弹窗回调事件
  114. async function callSuccess() {
  115. await reload();
  116. }
  117. // 查询回调
  118. async function callForm(data) {
  119. formValue.maintainCompany = data.maintainCompany || '';
  120. formValue.patrolTime = data.patrolTime || [];
  121. await reload();
  122. }
  123. </script>
  124. <style lang="less" scoped>
  125. ::v-deep(.ant-btn-link) {
  126. color: rgb(61 65 85 / 100%);
  127. }
  128. ::v-deep(.ant-input) {
  129. border-color: #c2ccd4;
  130. border-radius: 4px;
  131. }
  132. ::v-deep(.ant-input-affix-wrapper) {
  133. border-color: #c2ccd4;
  134. border-radius: 4px;
  135. }
  136. ::v-deep(.ant-picker) {
  137. border-color: #c2ccd4;
  138. border-radius: 4px;
  139. }
  140. ::v-deep(.ant-table-tbody > tr > td) {
  141. border-right: 0 !important;
  142. border-left: 0 !important;
  143. border-bottom: 1px solid #f0f0f0;
  144. }
  145. ::v-deep(.ant-table-wrapper table) {
  146. border: 0;
  147. }
  148. ::v-deep(.ant-table-cell-fix-right-first::after, .ant-table-cell-fix-right-last::after) {
  149. content: '';
  150. top: auto;
  151. width: 0;
  152. }
  153. .btn-add {
  154. width: 120px;
  155. border-radius: 4px;
  156. }
  157. </style>