index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <el-container class="is-vertical">
  3. <sc-page-header @add="table_add"></sc-page-header>
  4. <scTable ref="xGridTable" :apiObj="$API.outsourcing.order" :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. <el-button v-if="row.status == 'processing'" type="primary" link @click="table_receipt(row)">
  10. <template #icon><sc-iconify icon="tabler:package-import"></sc-iconify></template>收货
  11. </el-button>
  12. <template v-if="row.status == 'pending'">
  13. <el-button type="primary" link @click="table_edit(row)">
  14. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  15. </el-button>
  16. <el-button type="primary" link @click="table_del(row)">
  17. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  18. </el-button>
  19. </template>
  20. </template>
  21. </scTable>
  22. </el-container>
  23. <order-detail v-if="dialog.detail" ref="orderRef" @success="refreshTable" @closed="dialogClose"></order-detail>
  24. <order-desc v-if="dialog.desc" ref="orderDescRef" @closed="dialog.desc = false"></order-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 { outsourcingDic } from "@/utils/basicDic";
  32. import { mapFormItemInput, mapFormItemSelect, mapFormItemDatePicker, mapFormItemTenant } from "@/components/scTable/helper";
  33. import orderDetail from "./detail";
  34. import orderDesc from "./desc";
  35. import store from "@/store";
  36. watch(() => store.state.tenant.tenantId, () => refreshTable());
  37. const daterangeConfig = reactive({
  38. resetValue: () => [],
  39. props: {
  40. type: "daterange",
  41. startPlaceholder: "开始日期",
  42. endPlaceholder: "结束日期",
  43. format: "YYYY-MM-DD"
  44. }
  45. });
  46. const formConfig = reactive({
  47. data: {},
  48. items: [
  49. mapFormItemTenant({ events: { change: data => XEUtils.merge(formConfig.data, data) } }),
  50. mapFormItemInput("nameLike", "计划主题"),
  51. mapFormItemInput("codeLike", "计划编号"),
  52. mapFormItemDatePicker("createTime", "创建日期", daterangeConfig)
  53. ]
  54. });
  55. const paramsColums = reactive([
  56. { column: "orderBy", defaultValue: "createTime_desc" },
  57. { column: "tenantId" },
  58. { column: "nameLike" },
  59. { column: "codeLike" },
  60. { column: "createTimeBegin", field: "createTime[0]" },
  61. { column: "createTimeEnd", field: "createTime[1]" }
  62. ]);
  63. const columns = reactive([
  64. { type: "seq", fixed: "left", width: 60 },
  65. { visible: computed(() => store.state.tenant.tenantId === "0"), type: "html", field: "tenantName", title: "所属租户", fixed: "left", minWidth: 200, sortable: true, formatter: ({ cellValue, row }) => cellValue || XEUtils.get(XEUtils.find(store.state.tenant.tenants, item => item.id == row.tenantId), "name") },
  66. { type: "html", field: "name", title: "委外主题", fixed: "left", minWidth: 150, sortable: true },
  67. { field: "code", title: "委外编号", fixed: "left", minWidth: 150, sortable: true, className: "vxe-table-link-cell", slots: { default: "code_link" } },
  68. { field: "status", title: "委外状态", minWidth: 120, editRender: { name: "$cell-tag", options: outsourcingDic.orderStatus } },
  69. { type: "html", field: "supplierName", title: "加工厂商", fixed: "left", minWidth: 150, sortable: true },
  70. { type: "html", field: "orderDate", title: "委外日期", minWidth: 120, sortable: true },
  71. { visible: false, type: "html", field: "createTime", title: "创建日期", minWidth: 120, sortable: true, formatter: ({ cellValue }) => TOOL.dateFormat(cellValue, "YYYY-MM-DD") || cellValue },
  72. { title: "操作", fixed: "right", width: 140, slots: { default: "action" } }
  73. ]);
  74. // 显示隐藏 筛选表单
  75. const xGridTable = ref();
  76. const refreshTable = (mode = "add") => (xGridTable.value.searchData(mode), xGridTable.value.reloadColumn(columns));
  77. const orderRef = ref();
  78. const orderDescRef = ref();
  79. const dialog = reactive({
  80. detail: false,
  81. desc: false,
  82. receipt: false
  83. });
  84. const table_add = () => {
  85. dialog.detail = true;
  86. nextTick(() => orderRef.value?.setData());
  87. }
  88. const table_edit = row => {
  89. dialog.detail = true;
  90. nextTick(() => orderRef.value?.setData(row, "edit"));
  91. }
  92. const table_detail = row => {
  93. dialog.desc = true;
  94. nextTick(() => orderDescRef.value?.setData(row));
  95. }
  96. const table_receipt = row => {
  97. // 收货日期、是否需要质检
  98. }
  99. const table_del = ({ id }) => {
  100. ElMessageBox.confirm("是否确认删除该委外订单?", "删除警告", {
  101. type: "warning",
  102. confirmButtonText: "确定",
  103. cancelButtonText: "取消"
  104. }).then(() => {
  105. API.outsourcing.order.del({ id }).then(() => {
  106. ElMessage.success("操作成功");
  107. refreshTable();
  108. });
  109. }).catch(() => {});
  110. }
  111. const dialogClose = isDel => {
  112. dialog.detail = false;
  113. isDel && refreshTable();
  114. }
  115. </script>