index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <scTable ref="xGridTable" :apiObj="$API.car_rinse.carInfo" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns">
  3. <template #action="{ row }">
  4. <el-button type="primary" link @click="table_edit(row)">
  5. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  6. </el-button>
  7. <el-button type="primary" link @click="table_del(row)">
  8. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  9. </el-button>
  10. </template>
  11. </scTable>
  12. <info-detail v-if="dialog" ref="infoRef" @success="refreshTable" @closed="dialog = false"></info-detail>
  13. </template>
  14. <script setup>
  15. import XEUtils from "xe-utils";
  16. import API from "@/api";
  17. import TOOL from "@/utils/tool";
  18. import { mapFormItemInput, mapFormItemSelect } from "@/components/scTable/helper";
  19. import { carWashDic } from "@/views/dataMock/carwash/main";
  20. import infoDetail from "./detail";
  21. const proConfig = reactive({
  22. storageKey: "PROJECT",
  23. resetValue: TOOL.data.get("PROJECT_ID"),
  24. optionProps: { label: "projectName", value: "fpiId" },
  25. events: {
  26. change: data => XEUtils.assign(formConfig.data, data)
  27. }
  28. })
  29. const selectConfig = reactive({
  30. options: carWashDic.carType.map((label, value) => ({ label, value })),
  31. events: {
  32. change: data => XEUtils.merge(formConfig.data, data)
  33. }
  34. })
  35. const toolbarConfig = reactive({
  36. enabled: true,
  37. print: false
  38. })
  39. const formConfig = reactive({
  40. data: {
  41. projectId: TOOL.data.get("PROJECT_ID"),
  42. projectIdNot: 1
  43. },
  44. items: [
  45. mapFormItemSelect("projectId", "所属项目", proConfig),
  46. mapFormItemInput("plateNumberLike", "车牌号"),
  47. mapFormItemSelect("vehicleType", "车辆类型", selectConfig),
  48. mapFormItemSelect("vehicleColor", "车辆颜色", { ...selectConfig, options: carWashDic.carColor.map((label, value) => ({ label, value })) }),
  49. mapFormItemSelect("isSupervise", "使用状态", { ...selectConfig, options: carWashDic.isSupervise.map(({ label, value }) => ({ label, value: XEUtils.toValueString(value) })) })
  50. ]
  51. })
  52. const paramsColums = reactive([
  53. { column: "projectId" },
  54. { column: "projectIdNot" },
  55. { column: "plateNumberLike" },
  56. { column: "vehicleType" },
  57. { column: "vehicleColor" },
  58. { column: "isSupervise" }
  59. ])
  60. const columns = reactive([
  61. { type: "seq", width: 60 },
  62. { 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.projectId), "projectName") },
  63. { type: "html", field: "plateNumber", title: "车牌号", minWidth: 120, sortable: true },
  64. { type: "html", field: "vehicleType", title: "车辆类型", minWidth: 120, sortable: true, formatter: ({ cellValue }) => XEUtils.get(carWashDic.carType, cellValue, "/") },
  65. { type: "html", field: "vehicleColor", title: "车辆颜色", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(carWashDic.carColor, cellValue, "/") },
  66. { type: "html", field: "status", title: "使用状态", minWidth: 100, sortable: true, formatter: ({ cellValue, row }) => cellValue || XEUtils.get(XEUtils.find(carWashDic.isSupervise, item => item.value == row.isSupervise), "label", "/") },
  67. { type: "html", field: "createTime", title: "创建时间", minWidth: 160, sortable: true },
  68. { title: "操作", width: 140, fixed: "right", slots: { default: "action" } }
  69. ])
  70. // 显示隐藏 筛选表单
  71. const xGridTable = ref();
  72. const refreshTable = (mode = "add") => {
  73. xGridTable.value.reloadColumn(columns);
  74. xGridTable.value.searchData(mode);
  75. }
  76. const infoRef = ref();
  77. const dialog = ref(false);
  78. const table_add = () => {
  79. dialog.value = true;
  80. nextTick(() => infoRef.value?.open());
  81. }
  82. const table_edit = row => {
  83. dialog.value = true;
  84. nextTick(() => infoRef.value?.setData(row));
  85. }
  86. const table_del = ({ id }) => {
  87. ElMessageBox.confirm("是否确认删除该车辆信息?", "删除警告", {
  88. type: "warning",
  89. confirmButtonText: "确定",
  90. cancelButtonText: "取消"
  91. }).then(() => {
  92. API.car_rinse.carInfo.del({ id }).then(() => {
  93. ElMessage.success("操作成功");
  94. refreshTable();
  95. });
  96. });
  97. }
  98. defineExpose({
  99. table_add
  100. })
  101. </script>