From 2acdb4e99bed8d95d4bff4101649fb1d893db3a2 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@local>
Date: 星期二, 03 十一月 2026 22:46:23 +0800
Subject: [PATCH] fix(bpm): 简易流程设计器始终显示,去掉空状态提示
---
src/views/mes/pro/mps/modules/from-sale-order.vue | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 205 insertions(+), 0 deletions(-)
diff --git a/src/views/mes/pro/mps/modules/from-sale-order.vue b/src/views/mes/pro/mps/modules/from-sale-order.vue
new file mode 100644
index 0000000..5452622
--- /dev/null
+++ b/src/views/mes/pro/mps/modules/from-sale-order.vue
@@ -0,0 +1,205 @@
+<script lang="ts" setup>
+import type { TableColumnsType } from 'ant-design-vue';
+
+import type { PendingProductionItem } from '#/api/erp/sale/order';
+
+import { computed, ref } from 'vue';
+
+import { useVbenModal } from '@vben/common-ui';
+
+import { Alert, InputNumber, message, Spin, Table, Tag } from 'ant-design-vue';
+
+import {
+ generateMpsFromSaleOrder,
+ getPendingProductionList,
+} from '#/api/erp/sale/order';
+
+const emit = defineEmits(['success']);
+
+interface RowItem extends PendingProductionItem {
+ /** 璁″垝鐢熶骇鏁伴噺锛堝彲缂栬緫锛� */
+ planQuantity?: number;
+ /** 鏄惁鍕鹃�� */
+ selected?: boolean;
+}
+
+const loading = ref(false);
+const submitting = ref(false);
+const list = ref<RowItem[]>([]);
+
+const columns: TableColumnsType = [
+ { title: '閿�鍞鍗曞彿', dataIndex: 'saleOrderNo', width: 150, fixed: 'left' },
+ { title: '瀹㈡埛', dataIndex: 'customerName', width: 130, ellipsis: true },
+ { title: '浜у搧缂栫爜', dataIndex: 'productCode', width: 120 },
+ { title: '浜у搧鍚嶇О', dataIndex: 'productName', width: 140, ellipsis: true },
+ { title: '瑙勬牸', dataIndex: 'productSpecification', width: 100 },
+ { title: '璁㈣喘鏁伴噺', dataIndex: 'orderCount', width: 100, align: 'right' },
+ { title: '璁㈠崟鏃ユ湡', dataIndex: 'orderTime', width: 160 },
+ {
+ title: '鍙敤搴撳瓨',
+ dataIndex: 'stockQuantity',
+ width: 100,
+ align: 'right',
+ },
+ {
+ title: '寤鸿鐢熶骇',
+ dataIndex: 'suggestQuantity',
+ width: 110,
+ align: 'right',
+ },
+ { title: '璁″垝鏁伴噺', dataIndex: 'planQuantity', width: 130, key: 'plan' },
+];
+
+/** 宸插嬀閫夌殑琛� */
+const selectedRows = computed(() => list.value.filter((r) => r.selected));
+
+/** 鍚堣璁″垝鏁伴噺 */
+const totalPlanQuantity = computed(() =>
+ selectedRows.value.reduce((sum, r) => sum + (r.planQuantity ?? 0), 0),
+);
+
+/** 搴撳瓨鍏呰冻锛堟棤闇�鐢熶骇锛夌殑琛屾暟 */
+const enoughStockCount = computed(
+ () => list.value.filter((r) => (r.suggestQuantity ?? 0) <= 0).length,
+);
+
+function handleSelectAll(checked: boolean) {
+ list.value.forEach((row) => {
+ // 搴撳瓨澶熺殑榛樿涓嶅嬀閫夛紝浣嗗厑璁告墜宸ュ嬀閫夛紙瀹㈡埛鍙兘瑕佹眰澶囪揣锛�
+ row.selected = checked;
+ });
+}
+
+async function loadList() {
+ loading.value = true;
+ try {
+ const data = await getPendingProductionList();
+ list.value = (data ?? []).map((item) => {
+ const suggest = item.suggestQuantity ?? 0;
+ return {
+ ...item,
+ // 榛樿鍕鹃�夐渶瑕佺敓浜х殑锛堝缓璁敓浜� > 0锛�
+ selected: suggest > 0,
+ planQuantity: suggest > 0 ? suggest : undefined,
+ };
+ });
+ } finally {
+ loading.value = false;
+ }
+}
+
+const [Modal, modalApi] = useVbenModal({
+ async onConfirm() {
+ const items = selectedRows.value
+ .filter((r) => (r.planQuantity ?? 0) > 0)
+ .map((r) => ({
+ saleOrderItemId: r.saleOrderItemId!,
+ quantity: r.planQuantity!,
+ }));
+ if (items.length === 0) {
+ message.warning('璇疯嚦灏戝嬀閫変竴鏉″苟濉啓澶т簬 0 鐨勮鍒掓暟閲�');
+ return;
+ }
+ submitting.value = true;
+ try {
+ const count = await generateMpsFromSaleOrder(items);
+ emit('success');
+ message.success(`宸茬敓鎴� ${count} 鏉$敓浜ц鍒抈);
+ await modalApi.close();
+ } finally {
+ submitting.value = false;
+ }
+ },
+ async onOpenChange(isOpen: boolean) {
+ if (!isOpen) {
+ list.value = [];
+ return;
+ }
+ await loadList();
+ },
+});
+</script>
+
+<template>
+ <Modal title="浠庨攢鍞鍗曠敓鎴愮敓浜ц鍒�" class="w-4/5">
+ <Spin :spinning="loading || submitting">
+ <div class="mx-4 flex flex-col gap-3">
+ <Alert
+ type="info"
+ show-icon
+ message="鎸夈�屽彲鐢ㄥ簱瀛樸�嶅垽鏂槸鍚﹂渶瑕佺敓浜э細搴撳瓨鍏呰冻鐨勫彲涓嶅畨鎺掞紝寤鸿鐢熶骇鏁伴噺 = 璁㈣喘鏁伴噺 鈭� 鍙敤搴撳瓨銆傚嬀閫夊悗鍙洿鎺ヤ慨鏀硅鍒掓暟閲忋��"
+ />
+
+ <div class="flex items-center gap-4 text-gray-600">
+ <span>鍏� <b>{{ list.length }}</b> 鏉″緟瀹夋帓鏄庣粏</span>
+ <span v-if="enoughStockCount > 0" class="text-green-600">
+ 鍏朵腑 {{ enoughStockCount }} 鏉″簱瀛樺厖瓒�
+ </span>
+ <span>
+ 宸查�� <b>{{ selectedRows.length }}</b> 鏉★紝鍚堣璁″垝鏁伴噺
+ <b>{{ totalPlanQuantity }}</b>
+ </span>
+ </div>
+
+ <Table
+ :data-source="list"
+ :columns="columns"
+ :pagination="false"
+ :row-selection="{
+ selectedRowKeys: selectedRows.map((r) => r.saleOrderItemId),
+ onSelect: (record: RowItem, checked: boolean) => {
+ record.selected = checked;
+ if (checked && !record.planQuantity) {
+ record.planQuantity =
+ (record.suggestQuantity ?? 0) > 0
+ ? record.suggestQuantity
+ : undefined;
+ }
+ },
+ onSelectAll: (checked: boolean) => handleSelectAll(checked),
+ }"
+ :scroll="{ y: 420, x: 1400 }"
+ row-key="saleOrderItemId"
+ size="small"
+ >
+ <template #bodyCell="{ column, record }">
+ <template v-if="column.dataIndex === 'stockQuantity'">
+ <span
+ :class="
+ (record.stockQuantity ?? 0) > 0
+ ? 'font-semibold text-green-600'
+ : 'text-red-500'
+ "
+ >
+ {{ record.stockQuantity ?? 0 }}
+ </span>
+ </template>
+ <template v-else-if="column.dataIndex === 'suggestQuantity'">
+ <Tag
+ v-if="(record.suggestQuantity ?? 0) > 0"
+ color="warning"
+ >
+ {{ record.suggestQuantity }}
+ </Tag>
+ <Tag v-else color="success">搴撳瓨澶�</Tag>
+ </template>
+ <template v-else-if="column.key === 'plan'">
+ <InputNumber
+ v-model:value="record.planQuantity"
+ :min="0"
+ :precision="3"
+ class="w-full"
+ placeholder="濉啓璁″垝鏁伴噺"
+ @change="
+ (val: any) => {
+ record.selected = (val ?? 0) > 0;
+ }
+ "
+ />
+ </template>
+ </template>
+ </Table>
+ </div>
+ </Spin>
+ </Modal>
+</template>
--
Gitblit v1.9.3