index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <scTable ref="xGridTable" batchDel :apiObj="$API.car_rinse.record" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns" v-bind="props.options">
  3. <template #default_imgUrl="{ row, column }">
  4. <template v-if="XEUtils.get(row, `folders.${column.field}.entities[0].path`)">
  5. <sc-image style="cursor: pointer;" :fileName="XEUtils.get(row, `folders.${column.field}.entities[0].name`)" :path="XEUtils.get(row, `folders.${column.field}.entities[0].path`)" width="40" height="40"></sc-image>
  6. </template>
  7. </template>
  8. <template #action="{ row }">
  9. <el-button type="primary" link @click="table_edit(row)">
  10. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  11. </el-button>
  12. <el-button type="primary" link @click="table_del(row)">
  13. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  14. </el-button>
  15. </template>
  16. </scTable>
  17. <record-detail v-if="dialog" ref="recordRef" :projectId="props.isTemp ? 1 : TOOL.data.get('PROJECT_ID')" @success="refreshTable" @closed="dialogClose"></record-detail>
  18. </template>
  19. <script setup>
  20. import moment from "moment";
  21. import XEUtils from "xe-utils";
  22. import API from "@/api";
  23. import TOOL from "@/utils/tool";
  24. import { mapFormItemInput, mapFormItemSelect, mapFormItemDatePicker } from "@/components/scTable/helper";
  25. import { dataSource } from "@/utils/basicDic";
  26. import { carWashDic } from "@/views/dataMock/carwash/main";
  27. import recordDetail from "./detail";
  28. const props = defineProps({
  29. options: { type: Object, default: () => {} },
  30. isTemp: { type: Boolean, default: false },
  31. hideHandler: { type: Boolean, default: false }
  32. })
  33. const visible = computed(() => !props.isTemp);
  34. const proConfig = reactive({
  35. visible,
  36. storageKey: "PROJECT",
  37. resetValue: TOOL.data.get("PROJECT_ID"),
  38. optionProps: { label: "projectName", value: "fpiId" },
  39. events: {
  40. change: data => XEUtils.assign(formConfig.data, data)
  41. }
  42. })
  43. const selectConfig = reactive({
  44. options: carWashDic.carType.map((label, value) => ({ label, value })),
  45. events: {
  46. change: data => XEUtils.merge(formConfig.data, data)
  47. }
  48. })
  49. const datetimerangeConfig = reactive({
  50. span: 7,
  51. resetValue: () => [moment().startOf("month").format("YYYY-MM-DD HH:mm:ss"), moment().add(1, "hour").format("YYYY-MM-DD HH:mm:ss")],
  52. props: {
  53. type: "datetimerange",
  54. startPlaceholder: "开始时间",
  55. endPlaceholder: "结束时间",
  56. format: "YYYY-MM-DD HH:mm"
  57. }
  58. })
  59. const toolbarConfig = reactive({
  60. enabled: true,
  61. print: false
  62. })
  63. const formConfig = reactive({
  64. data: {
  65. orderBy: "captureTime_desc",
  66. projectId: TOOL.data.get("PROJECT_ID"),
  67. fpiIdNot: 1,
  68. createTime: [moment().startOf("month").format("YYYY-MM-DD HH:mm:ss"), moment().add(1, "hour").format("YYYY-MM-DD HH:mm:ss")]
  69. },
  70. items: [
  71. mapFormItemSelect("projectId", "所属项目", proConfig),
  72. mapFormItemDatePicker("createTime", "抓拍时间", datetimerangeConfig),
  73. mapFormItemInput("licensePlate", "车牌号", { span: 5 }),
  74. mapFormItemSelect("carType", "车辆类型", selectConfig),
  75. mapFormItemSelect("alarmType", "识别结果", { ...selectConfig, options: carWashDic.alarmType.map((label, value) => ({ label, value })).slice(1) }),
  76. ]
  77. })
  78. const paramsColums = reactive([
  79. { column: "orderBy" },
  80. { column: "fpiId", field: visible.value ? "projectId" : "fpiIdNot" },
  81. visible.value ? { column: "fpiIdNot" } : {},
  82. { column: "licensePlate" },
  83. { column: "carType" },
  84. { column: "alarmType" },
  85. { column: "captureTimeBegin", field: "createTime[0]" },
  86. { column: "captureTimeEnd", field: "createTime[1]" }
  87. ])
  88. const columns = reactive([
  89. { visible: !props.hideHandler, type: "checkbox", fixed: "left", width: 40, align: "center" },
  90. { type: "seq", fixed: "left", width: 60 },
  91. { visible, type: "html", field: "projectName", title: "项目名称", minWidth: 160, sortable: true, formatter: ({ cellValue, row }) => cellValue || XEUtils.get(XEUtils.find(TOOL.data.get("PROJECT"), item => item.fpiId == row.fpiId), "projectName") },
  92. { type: "html", field: "captureTime", title: "抓拍时间", minWidth: 160, sortable: true },
  93. { type: "html", field: "enterTime", title: "车辆入场时间", minWidth: 160, sortable: true },
  94. { type: "html", field: "leaveTime", title: "车辆出场时间", minWidth: 160, sortable: true },
  95. { type: "html", field: "licensePlate", title: "车牌号", minWidth: 120, sortable: true },
  96. { type: "html", field: "licensePlateColor", title: "车牌颜色", minWidth: 120, sortable: true, formatter: ({ cellValue }) => XEUtils.get(carWashDic.plateColor, cellValue, cellValue) },
  97. { type: "html", field: "carType", title: "车辆类型", minWidth: 120, sortable: true, formatter: ({ cellValue }) => XEUtils.get(carWashDic.carType, cellValue, cellValue) },
  98. { type: "html", field: "alarmType", title: "识别结果", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(carWashDic.alarmType, cellValue, cellValue) },
  99. { field: "carrinse/attach", title: "车身清洗图片", minWidth: 110, align: "center", slots: { default: "default_imgUrl" } },
  100. { field: "carrinse/side", title: "后盖密闭图片", minWidth: 110, align: "center", slots: { default: "default_imgUrl" } },
  101. { visible, type: "html", field: "dataSource", title: "数据来源", fixed: "right", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(dataSource, cellValue, cellValue) },
  102. { visible: !props.hideHandler, title: "操作", fixed: "right", width: 140, align: "center", slots: { default: "action" } }
  103. ])
  104. // 显示隐藏 筛选表单
  105. const xGridTable = ref();
  106. const getTableTotal = () => xGridTable.value.getTableData().tableData.length;
  107. const refreshTable = (mode = "add") => {
  108. xGridTable.value.reloadColumn(columns);
  109. xGridTable.value.searchData(mode);
  110. }
  111. const recordRef = ref();
  112. const dialog = ref(false);
  113. const dialogClose = isDel => {
  114. dialog.value = false;
  115. isDel && refreshTable();
  116. }
  117. const table_add = () => {
  118. dialog.value = true;
  119. nextTick(() => recordRef.value?.open());
  120. }
  121. const table_edit = row => {
  122. dialog.value = true;
  123. nextTick(() => recordRef.value?.setData(row));
  124. }
  125. const table_del = ({ id }) => {
  126. ElMessageBox.confirm("是否确认删除该冲洗记录?", "删除警告", {
  127. type: "warning",
  128. confirmButtonText: "确定",
  129. cancelButtonText: "取消"
  130. }).then(() => {
  131. API.car_rinse.record.del({ id }).then(() => {
  132. ElMessage.success("操作成功");
  133. refreshTable();
  134. });
  135. });
  136. }
  137. defineExpose({
  138. table_add,
  139. refreshTable,
  140. getTableTotal
  141. })
  142. </script>