index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <el-container class="is-vertical">
  3. <sc-page-header @add="table_add"></sc-page-header>
  4. <scTable ref="xGridTable" :apiObj="$API.basic.qualityPlan" :formConfig="formConfig" :paramsColums="paramsColums" :columns="columns">
  5. <template #code_link="{ row }">
  6. <vxe-text status="primary" @click="table_detail(row)">{{ row.code }}</vxe-text>
  7. </template>
  8. <template #action="{ row }">
  9. <template v-if="row.reviewStatus == 'pending'">
  10. <el-button type="primary" link @click="table_edit(row)">
  11. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  12. </el-button>
  13. <el-button v-if="$TOOL.data.get('USER_INFO').id == row.reviewUserId" type="primary" link @click="table_detail(row, 'approval')">
  14. <template #icon><sc-iconify icon="material-symbols:approval-outline"></sc-iconify></template>审批
  15. </el-button>
  16. </template>
  17. <el-button type="primary" link @click="table_del(row)">
  18. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  19. </el-button>
  20. </template>
  21. </scTable>
  22. </el-container>
  23. <plan-detail v-if="dialog.detail" ref="planRef" @success="refreshTable" @closed="dialogClose"></plan-detail>
  24. <plan-desc v-if="dialog.desc" ref="planDescRef" @success="refreshTable" @closed="dialog.desc = false"></plan-desc>
  25. </template>
  26. <script setup>
  27. import moment from "moment";
  28. import XEUtils from "xe-utils";
  29. import API from "@/api";
  30. import TOOL from "@/utils/tool";
  31. import { reviewStatusDic, qualityPlanTypeDic } from "@/utils/basicDic";
  32. import { mapFormItemInput, mapFormItemSelect, mapFormItemDatePicker, mapFormItemTenant } from "@/components/scTable/helper";
  33. import planDetail from "./detail";
  34. import planDesc from "./desc";
  35. import store from "@/store";
  36. watch(() => store.state.tenant.tenantId, () => refreshTable());
  37. const selectConfig = reactive({
  38. options: reviewStatusDic,
  39. events: {
  40. change: data => XEUtils.merge(formConfig.data, data)
  41. }
  42. });
  43. const daterangeConfig = reactive({
  44. resetValue: () => [],
  45. props: {
  46. type: "daterange",
  47. startPlaceholder: "开始日期",
  48. endPlaceholder: "结束日期",
  49. format: "YYYY-MM-DD"
  50. }
  51. });
  52. const formConfig = reactive({
  53. data: {},
  54. items: [
  55. mapFormItemTenant({ events: { change: data => XEUtils.merge(formConfig.data, data) } }),
  56. mapFormItemInput("nameLike", "方案名称"),
  57. mapFormItemInput("codeLike", "方案编号"),
  58. mapFormItemSelect("reviewStatus", "审批状态", selectConfig),
  59. mapFormItemSelect("type", "方案类型", { ...selectConfig, options: qualityPlanTypeDic }),
  60. mapFormItemDatePicker("createTime", "创建日期", daterangeConfig)
  61. ]
  62. });
  63. const paramsColums = reactive([
  64. { column: "orderBy", defaultValue: "createTime_desc" },
  65. { column: "tenantId" },
  66. { column: "nameLike" },
  67. { column: "codeLike" },
  68. { column: "reviewStatus" },
  69. { column: "type" },
  70. { column: "createTimeBegin", field: "createTime[0]" },
  71. { column: "createTimeEnd", field: "createTime[1]" }
  72. ]);
  73. const columns = reactive([
  74. { type: "seq", fixed: "left", width: 60 },
  75. { visible: computed(() => store.state.tenant.tenantId === "0"), type: "html", field: "tenantName", title: "所属租户", minWidth: 200, sortable: true, formatter: ({ cellValue, row }) => cellValue || XEUtils.get(XEUtils.find(store.state.tenant.tenants, item => item.id == row.tenantId), "name") },
  76. { type: "html", field: "name", title: "方案名称", fixed: "left", minWidth: 150, sortable: true },
  77. { field: "code", title: "方案编号", fixed: "left", minWidth: 150, sortable: true, className: "vxe-table-link-cell", slots: { default: "code_link" } },
  78. { visible: false, type: "html", field: "inspectUserName", title: "质检人员", minWidth: 120, sortable: true },
  79. { type: "html", field: "type", title: "方案类型", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(qualityPlanTypeDic, cellValue, cellValue) },
  80. { visible: false, type: "html", field: "sampleRate", title: "抽检比例", minWidth: 120, sortable: true },
  81. { visible: false, type: "html", field: "passedRate", title: "合格率", minWidth: 120, sortable: true },
  82. { visible: false, type: "html", field: "reviewUserName", title: "审批人员", minWidth: 120, sortable: true },
  83. { field: "reviewStatus", title: "审批状态", minWidth: 100, editRender: { name: "$cell-tag", options: reviewStatusDic } },
  84. { type: "html", field: "createTime", title: "创建日期", minWidth: 120, sortable: true, formatter: ({ cellValue }) => TOOL.dateFormat(cellValue, "YYYY-MM-DD") || cellValue },
  85. { visible: false, type: "html", field: "remark", title: "概要", minWidth: 300, sortable: true },
  86. { title: "操作", fixed: "right", width: 220, slots: { default: "action" } }
  87. ]);
  88. // 显示隐藏 筛选表单
  89. const xGridTable = ref();
  90. const refreshTable = (mode = "add") => (xGridTable.value.searchData(mode), xGridTable.value.reloadColumn(columns));
  91. const planRef = ref();
  92. const planDescRef = ref();
  93. const dialog = reactive({
  94. detail: false,
  95. desc: false
  96. });
  97. const table_add = () => {
  98. dialog.detail = true;
  99. nextTick(() => planRef.value?.open());
  100. }
  101. const table_edit = row => {
  102. dialog.detail = true;
  103. nextTick(() => planRef.value?.setData(row));
  104. }
  105. const table_detail = (row, mode = "detail") => {
  106. dialog.desc = true;
  107. nextTick(() => planDescRef.value?.setData(row, mode));
  108. }
  109. const table_del = ({ id }) => {
  110. ElMessageBox.confirm("是否确认删除该质检方案?", "删除警告", {
  111. type: "warning",
  112. confirmButtonText: "确定",
  113. cancelButtonText: "取消"
  114. }).then(() => {
  115. API.basic.qualityPlan.del({ id }).then(() => {
  116. ElMessage.success("操作成功");
  117. refreshTable();
  118. });
  119. }).catch(() => {});
  120. }
  121. const dialogClose = isDel => {
  122. dialog.detail = false;
  123. isDel && refreshTable();
  124. }
  125. </script>