index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <el-container class="is-vertical">
  3. <sc-page-header v-if="!hidePageHeader" @add="table_add"></sc-page-header>
  4. <scTable ref="xGridTable" :apiObj="$API.workmanship.route" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns" v-bind="options">
  5. <template #code_link="{ row }">
  6. <vxe-text status="primary" @click="table_detail(row)">{{ row.code }}</vxe-text>
  7. </template>
  8. <template #version_link="{ items, row }">
  9. <vxe-text v-if="row.isHaveHistory" status="primary" @click="table_history(row)">{{ row.version }}</vxe-text>
  10. <span v-else v-html="XEUtils.first(items).version" class="vxe-cell--html"></span>
  11. </template>
  12. <template #action="{ row }">
  13. <el-button type="primary" link @click="table_edit(row, 'upgrade')">
  14. <template #icon><sc-iconify icon="material-symbols:move-up"></sc-iconify></template>版本升级
  15. </el-button>
  16. <el-button v-if="row.isHaveHistory" type="primary" link @click="table_regrade(row)">
  17. <template #icon><sc-iconify icon="material-symbols:move-down"></sc-iconify></template>版本回退
  18. </el-button>
  19. <el-button type="primary" link @click="table_edit(row)">
  20. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  21. </el-button>
  22. <el-button v-if="row.status == 'enable'" type="primary" link @click="table_change(row)">
  23. <template #icon><sc-iconify icon="material-symbols:lock-outline"></sc-iconify></template>停用
  24. </el-button>
  25. <el-button v-else type="primary" link @click="table_change(row)">
  26. <template #icon><sc-iconify icon="material-symbols:lock-open-outline"></sc-iconify></template>启用
  27. </el-button>
  28. <el-button v-if="!row.isHaveHistory" type="primary" link @click="table_del(row)">
  29. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  30. </el-button>
  31. </template>
  32. </scTable>
  33. </el-container>
  34. <process-detail v-if="dialog.detail" ref="processRef" @success="refreshTable" @closed="dialogClose"></process-detail>
  35. <process-desc v-if="dialog.desc" ref="processDescRef" @closed="dialog.desc = false"></process-desc>
  36. <version-history v-if="dialog.history" ref="historyRef" @closed="dialog.history = false"></version-history>
  37. </template>
  38. <script setup>
  39. import moment from "moment";
  40. import XEUtils from "xe-utils";
  41. import API from "@/api";
  42. import TOOL from "@/utils/tool";
  43. import { statusDic, workmanshipDic, objectToArray } from "@/utils/basicDic";
  44. import { mapFormItemInput, mapFormItemSelect, mapFormItemDatePicker } from "@/components/scTable/helper";
  45. import processDetail from "./detail";
  46. import processDesc from "./desc";
  47. import versionHistory from "./history";
  48. const props = defineProps({
  49. hidePageHeader: { type: Boolean, default: false },
  50. hideHandler: { type: Boolean, default: false },
  51. paramsColums: { type: Array, default: () => [] },
  52. options: { type: Object, default: () => ({}) }
  53. });
  54. const toolbarConfig = reactive({
  55. enabled: true,
  56. export: true
  57. });
  58. const selectConfig = reactive({
  59. visible: !props.hideHandler,
  60. options: objectToArray(statusDic),
  61. events: {
  62. change: data => XEUtils.merge(formConfig.data, data)
  63. }
  64. });
  65. const daterangeConfig = reactive({
  66. resetValue: () => [],
  67. props: {
  68. type: "daterange",
  69. startPlaceholder: "开始日期",
  70. endPlaceholder: "结束日期",
  71. format: "YYYY-MM-DD"
  72. }
  73. });
  74. const formConfig = reactive({
  75. data: {},
  76. items: [
  77. mapFormItemInput("nameLike", "工艺路线名称"),
  78. mapFormItemInput("codeLike", "工艺路线编号"),
  79. mapFormItemSelect("status", "工艺路线状态", selectConfig),
  80. mapFormItemDatePicker("createTime", "创建日期", daterangeConfig)
  81. ]
  82. });
  83. const paramsColums = reactive([
  84. { column: "orderBy", defaultValue: "code_asc" },
  85. { column: "parentId", defaultValue: "0" },
  86. { column: "nameLike" },
  87. { column: "codeLike" },
  88. { column: "status" },
  89. { column: "createTimeBegin", field: "createTime[0]" },
  90. { column: "createTimeEnd", field: "createTime[1]" },
  91. ...props.paramsColums
  92. ]);
  93. const columns = reactive([
  94. { type: "seq", fixed: "left", width: 60 },
  95. { type: "html", field: "name", title: "工艺路线名称", fixed: "left", minWidth: 150, sortable: true },
  96. { field: "code", title: "工艺路线编号", fixed: "left", minWidth: 150, sortable: true, className: "vxe-table-link-cell", slots: { default: "code_link" } },
  97. { visible: !props.hideHandler, field: "status", title: "工艺路线状态", minWidth: 120, editRender: { name: "$cell-tag", options: statusDic } },
  98. { visible: false, type: "html", field: "timeUnit", title: "时间单位", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(workmanshipDic.timeUnit, cellValue, cellValue) },
  99. { type: "html", field: "", title: "质检方案", minWidth: 160, sortable: true },
  100. { type: "html", field: "createTime", title: "创建日期", minWidth: 120, sortable: true, formatter: ({ cellValue }) => TOOL.dateFormat(cellValue, "YYYY-MM-DD") || cellValue },
  101. { type: "html", field: "version", title: "版本号", minWidth: 120, sortable: true, className: "vxe-table-link-cell", slots: { default: "version_link" } },
  102. { visible: false, type: "html", field: "remark", title: "概要", minWidth: 300, sortable: true },
  103. { visible: !props.hideHandler, title: "操作", fixed: "right", width: 320, slots: { default: "action" } }
  104. ]);
  105. // 显示隐藏 筛选表单
  106. const xGridTable = ref();
  107. const refreshTable = (mode = "add") => xGridTable.value.searchData(mode);
  108. const processRef = ref();
  109. const processDescRef = ref();
  110. const historyRef = ref();
  111. const dialog = reactive({
  112. detail: false,
  113. desc: false,
  114. history: false
  115. });
  116. const table_add = () => {
  117. dialog.detail = true;
  118. nextTick(() => processRef.value?.open());
  119. }
  120. const table_edit = (row, mode = "edit") => {
  121. dialog.detail = true;
  122. nextTick(() => processRef.value?.setData(row, mode));
  123. }
  124. const table_detail = row => {
  125. dialog.desc = true;
  126. nextTick(() => processDescRef.value?.setData(row));
  127. }
  128. const table_history = row => {
  129. dialog.history = true;
  130. nextTick(() => historyRef.value?.setData(row));
  131. }
  132. const table_del = ({ id }) => {
  133. ElMessageBox.confirm("是否确认删除该工艺路线?", "删除警告", {
  134. type: "warning",
  135. confirmButtonText: "确定",
  136. cancelButtonText: "取消"
  137. }).then(() => {
  138. API.workmanship.route.del({ id }).then(() => {
  139. ElMessage.success("操作成功");
  140. refreshTable();
  141. });
  142. }).catch(() => {});
  143. }
  144. const table_regrade = ({ id }) => {
  145. ElMessageBox.confirm("是否确认回退该工艺路线的版本?", "回退警告", {
  146. type: "warning",
  147. confirmButtonText: "确定",
  148. cancelButtonText: "取消"
  149. }).then(() => {
  150. API.workmanship.route.regrade({ id }).then(() => {
  151. ElMessage.success("操作成功");
  152. refreshTable();
  153. });
  154. }).catch(() => {});
  155. }
  156. const table_change = row => {
  157. const status = row.status == "enable" && "disable" || "enable";
  158. const msg = row.status == "enable" && "停用" || "启用";
  159. ElMessageBox.confirm(`是否确认${msg}该工艺路线?`, `${msg}警告`, {
  160. type: "warning",
  161. confirmButtonText: "确定",
  162. cancelButtonText: "取消"
  163. }).then(() => {
  164. API.workmanship.route.edit({ id: row.id, status }).then(() => {
  165. ElMessage.success("操作成功");
  166. refreshTable();
  167. });
  168. }).catch(() => {});
  169. }
  170. const dialogClose = isDel => {
  171. dialog.detail = false;
  172. isDel && refreshTable();
  173. }
  174. </script>