index.vue 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <el-container class="is-vertical">
  3. <sc-page-header></sc-page-header>
  4. <scTable ref="xGridTable" :apiObj="$API.production.prePlan" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns">
  5. <template #action="{ row }">
  6. <el-button type="primary" link @click="table_bind(row)">
  7. <template #icon><sc-iconify icon="material-symbols:arrow-split"></sc-iconify></template>物料分配
  8. </el-button>
  9. </template>
  10. </scTable>
  11. </el-container>
  12. <plan-detail v-if="dialog" ref="planRef" @success="refreshTable" @closed="dialog = false"></plan-detail>
  13. </template>
  14. <script setup>
  15. import moment from "moment";
  16. import XEUtils from "xe-utils";
  17. import API from "@/api";
  18. import TOOL from "@/utils/tool";
  19. import { mapFormItemInput, mapFormItemSelect, mapFormItemDatePicker, mapFormItemTenant } from "@/components/scTable/helper";
  20. import planDetail from "./detail";
  21. import store from "@/store";
  22. watch(() => store.state.tenant.tenantId, () => refreshTable());
  23. const customerConfig = reactive({
  24. api: { key: "basic.customer", query: { orderBy: "createTime_desc", status: "enable" } },
  25. optionProps: { label: "name", value: "id" },
  26. events: {
  27. change: data => XEUtils.merge(formConfig.data, data)
  28. }
  29. });
  30. const daterangeConfig = reactive({
  31. resetValue: () => [],
  32. props: {
  33. type: "daterange",
  34. startPlaceholder: "开始日期",
  35. endPlaceholder: "结束日期",
  36. format: "YYYY-MM-DD"
  37. }
  38. });
  39. const toolbarConfig = reactive({ export: false });
  40. const formConfig = reactive({
  41. data: {},
  42. items: [
  43. mapFormItemTenant({ events: { change: data => XEUtils.merge(formConfig.data, { ...data, customerId: undefined }) } }),
  44. mapFormItemInput("codeLike", "单据编号"),
  45. mapFormItemSelect("customerId", "客户", customerConfig),
  46. mapFormItemInput("contractNoLike", "合同编号"),
  47. mapFormItemDatePicker("orderDate", "单据日期", daterangeConfig)
  48. ]
  49. });
  50. const paramsColums = reactive([
  51. { column: "orderBy", defaultValue: "orderDate_asc" },
  52. { column: "status", defaultValue: "pending" },
  53. { column: "tenantId" },
  54. { column: "codeLike" },
  55. { column: "customerId" },
  56. { column: "contractNoLike" },
  57. { column: "orderDateBegin", field: "orderDate[0]" },
  58. { column: "orderDateEnd", field: "orderDate[1]" }
  59. ]);
  60. const columns = reactive([
  61. { type: "seq", fixed: "left", width: 60 },
  62. { 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") },
  63. { field: "code", title: "单据编号", fixed: "left", minWidth: 150, sortable: true },
  64. { type: "html", field: "orderDate", title: "单据日期", fixed: "left", minWidth: 120, sortable: true },
  65. { type: "html", field: "customerName", title: "客户", minWidth: 150, sortable: true },
  66. { type: "html", field: "contractNo", title: "合同编号", minWidth: 150, sortable: true },
  67. { type: "html", field: "actualPrice", title: "成交金额", minWidth: 120, sortable: true, formatter: ({ cellValue }) => TOOL.amountFormat(cellValue) || cellValue },
  68. { type: "html", field: "planReceiveDate", title: "预计交期", minWidth: 120, sortable: true },
  69. { title: "操作", fixed: "right", width: 140, slots: { default: "action" } }
  70. ]);
  71. // 显示隐藏 筛选表单
  72. const xGridTable = ref();
  73. const refreshTable = () => (xGridTable.value.searchData(), xGridTable.value.reloadColumn(columns));
  74. const planRef = ref();
  75. const dialog = ref(false);
  76. const table_bind = row => {
  77. dialog.value = true;
  78. nextTick(() => planRef.value?.setData(row));
  79. }
  80. </script>