index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <el-container class="is-vertical">
  3. <sc-page-header @add="table_add"></sc-page-header>
  4. <scTable ref="xGridTable" :apiObj="$API.carwash.boxDev" framework="zeroLite" :toolbarConfig="toolbarConfig" :columns="columns" :pagerConfig="pagerConfig">
  5. <template #action="{ row }">
  6. <el-button type="primary" link @click="table_camera(row)">
  7. <template #icon><sc-iconify icon="material-symbols:speed-camera-outline"></sc-iconify></template>摄像头
  8. </el-button>
  9. <el-button type="primary" link @click="table_snap(row)">
  10. <template #icon><sc-iconify icon="mingcute:pic-line"></sc-iconify></template>设备抓拍
  11. </el-button>
  12. <el-button type="primary" link @click="table_edit(row)">
  13. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  14. </el-button>
  15. <el-button type="primary" link @click="table_del(row)">
  16. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  17. </el-button>
  18. </template>
  19. </scTable>
  20. </el-container>
  21. <device-detail v-if="dialog.detail" ref="deviceRef" @success="refreshTable" @closed="dialog.detail = false"></device-detail>
  22. <camera-detail v-if="dialog.camera" ref="cameraRef" @closed="dialog.camera = false"></camera-detail>
  23. <snap-detail v-if="dialog.snap" ref="snapRef" @closed="dialog.snap = false"></snap-detail>
  24. </template>
  25. <script setup>
  26. import XEUtils from "xe-utils";
  27. import API from "@/api";
  28. import TOOL from "@/utils/tool";
  29. import { nodeTypeDic } from "@/utils/basicDic";
  30. import deviceDetail from "./detail";
  31. import cameraDetail from "./camera";
  32. import snapDetail from "./snap";
  33. const toolbarConfig = reactive({
  34. enabled: true,
  35. print: false
  36. });
  37. const pagerConfig = reactive({
  38. queryType: "expands"
  39. });
  40. const columns = reactive([
  41. { type: "seq", width: 60 },
  42. { type: "html", field: "deviceCode", title: "设备编号", minWidth: 160, sortable: true },
  43. { type: "html", field: "features.name", title: "设备名称", minWidth: 160, sortable: true },
  44. { type: "html", field: "deviceType", title: "设备类型", minWidth: 160, sortable: true },
  45. { type: "html", field: "features.minStagnantTime", title: "冲洗时长", minWidth: 100, sortable: true },
  46. { type: "html", field: "features.minPictureSaveTime", title: "图片采集间隔", minWidth: 120, sortable: true },
  47. { type: "html", field: "features.maxWaitingTime", title: "超时等待时间", minWidth: 120, sortable: true },
  48. { type: "html", field: "CreateTime", title: "创建时间", minWidth: 160, sortable: true, formatter: ({ cellValue, row }) => cellValue || TOOL.dateFormat(row.createTime) },
  49. { type: "html", field: "UpdateTime", title: "更新时间", minWidth: 160, sortable: true, formatter: ({ cellValue, row }) => cellValue || TOOL.dateFormat(row.updateTime) },
  50. { title: "操作", fixed: "right", width: 300, align: "center", slots: { default: "action" } }
  51. ])
  52. // 显示隐藏 筛选表单
  53. const xGridTable = ref();
  54. const refreshTable = (mode = "add") => {
  55. xGridTable.value.reloadColumn(columns);
  56. xGridTable.value.searchData(mode);
  57. }
  58. const deviceRef = ref();
  59. const cameraRef = ref();
  60. const snapRef = ref();
  61. const dialog = reactive({
  62. detail: false,
  63. camera: false,
  64. snap: false
  65. });
  66. const table_add = () => {
  67. dialog.detail = true;
  68. nextTick(() => deviceRef.value?.open());
  69. }
  70. const table_edit = row => {
  71. dialog.detail = true;
  72. nextTick(() => deviceRef.value?.setData(row));
  73. }
  74. const table_camera = row => {
  75. dialog.camera = true;
  76. nextTick(() => cameraRef.value?.open(row));
  77. }
  78. const table_snap = row => {
  79. dialog.snap = true;
  80. nextTick(() => snapRef.value?.open(row));
  81. }
  82. const table_del = ({ id }) => {
  83. ElMessageBox.confirm("是否确认删除该设备?", "删除警告", {
  84. type: "warning",
  85. confirmButtonText: "确定",
  86. cancelButtonText: "取消"
  87. }).then(() => {
  88. API.carwash.boxDev.child({ expands: { masterId: id } }).then(res => {
  89. if (res.code == 200) {
  90. if (!(res.datas || []).length) {
  91. API.carwash.boxDev.del([{ id }]).then(res => {
  92. if (res.code == 200) {
  93. ElMessage.success("操作成功");
  94. refreshTable();
  95. } else throw res.message;
  96. }).catch(error => ElMessage.error(error));
  97. } else ElMessage.warning("当前设备存在摄像头,请移除后再试");
  98. } else throw res.message;
  99. }).catch(error => ElMessage.error(error));
  100. });
  101. }
  102. </script>