From 5e54b2866eb181e84de9910de06fd013a280a5c9 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 05 三月 2025 16:18:36 +0800 Subject: [PATCH] 保存实体更新 --- src/views/components/bizMesWo.ts | 225 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 196 insertions(+), 29 deletions(-) diff --git a/src/views/components/bizMesWo.ts b/src/views/components/bizMesWo.ts index dc2c34a..cd2420e 100644 --- a/src/views/components/bizMesWo.ts +++ b/src/views/components/bizMesWo.ts @@ -1,3 +1,11 @@ +/* + * @Description: 宸ュ崟鑷畾涔夋柟娉晅s + * @Author: Ben Lin + * @version: + * @Date: 2024-06-05 16:10:24 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-07-16 10:06:44 + */ /* 宸ュ崟鐩稿叧鑷畾涔夋柟娉� */ import { FunctionType } from '/@/api/tigerapi/model/systemModel'; import { GetEnum, SaveEntity, getEntity } from '/@/api/tigerapi/system'; @@ -6,11 +14,27 @@ import { useI18n } from '/@/hooks/web/useI18n'; import { uploadApi } from '/@/api/sys/upload'; import { useLocale } from '/@/locales/useLocale'; -import { unref } from 'vue'; +import { ref, unref } from 'vue'; +import { BIZ_MES_WO_BATCH } from '/@/api/tigerapi/model/mesModel'; +import { buildUUID } from '/@/utils/uuid'; +import LogicFlow from '@logicflow/core'; +import { BpmnElement } from '@logicflow/extension'; +import { getRouteData } from '/@/api/tigerapi/mes/router'; +import customEdge from '/@/components/FlowChart/src/customEdge'; +import actionRect from '/@/components/FlowChart/src/actionRect'; +import TestNode from '/@/components/FlowChart/src/TestNode'; +import CollectNode from '/@/components/FlowChart/src/CollectNode'; +import AssemblyNode from '/@/components/FlowChart/src/AssemblyNode'; +import PackingNode from '/@/components/FlowChart/src/PackingNode'; +import RepairNode from '/@/components/FlowChart/src/RepairNode'; const { t } = useI18n(); const { getLocale } = useLocale(); -/* 鑷畾涔夋柟娉� */ + +/** + * @description: 鑷畾涔夋柟娉� + * @return {*} + */ export const getWoFns: Record<string, FunctionType> = { handleSubmit: async (e, ...args) => { const values = await args[0][0].validate(); @@ -49,29 +73,149 @@ } }); }, - //宸ュ崟閰嶇疆淇濆瓨鏂规硶 + /** + * @description: 宸ュ崟閰嶇疆淇濆瓨鏂规硶 + * @param {*} e + * @param {array} args + * @return {*} + */ SaveCofig: (e, ...args) => { return new Promise((resolve, reject) => { try { - const xx = e['prodinfo']; - resolve(true); + const form = e['prodinfo']; + const wo = e['mValues']; + wo.ROUTE_STATUS = 1; + SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => { + if (action.IsSuccessed) { + resolve(true); + } else { + reject(false); + } + }); } catch { reject(false); - } finally { - args[0][0]({ confirmLoading: false }); } }); }, - //宸ュ崟涓嬪彂淇濆瓨鏂规硶 + /** + * @description: 宸ュ崟涓嬪彂淇濆瓨鏂规硶 + * @param {*} e + * @param {array} args + * @return {*} + */ SaveWoBatch: (e, ...args) => { return new Promise((resolve, reject) => { try { - const xx = e['forminfo']; + const form = e['forminfo']; + const wo = e['mValues']; + wo.ROUTE_CODE = form.ROUTE_CODE; + wo.STATUS = 2; + const woBatch: BIZ_MES_WO_BATCH = { + ID: buildUUID(), + CREATE_TIME: new Date(), + CREATE_USER: useUserStore().getUserInfo.userId as string, + UPDATE_TIME: new Date(), + UPDATE_USER: useUserStore().getUserInfo.userId as string, + GHOST_ROW: false, + AUTH_ORG: '', + AUTH_PROD: useUserStore().getUserInfo.prodCode as string, + AUTH_WH: '', + ORDER_NO: wo.ORDER_NO, + STATUS: wo.STATUS, + ITEM_CODE: wo.ITEM_CODE, + CUST_CODE: wo.CUST_CODE, + FACTORY: wo.FACTORY, + WS_CODE: wo.WS_CODE, + ACT_LINE: form.PLAN_LINE, + STD_WORKER_QTY: wo.STD_WORKER_QTY, + ACT_WORKER_QTY: wo.ACT_WORKER_QTY, + RELEASE_TIME: new Date(), + RELEASE_USER: useUserStore().getUserInfo.userId as string, + PLAN_QTY: wo.PLAN_QTY, + INPUT_QTY: wo.INPUT_QTY, + OUTPUT_QTY: wo.OUTPUT_QTY, + SCRAP_QTY: wo.SCRAP_QTY, + STOCK_IN_QTY: wo.STOCK_IN_QTY, + UPH: wo.UPH, + UPPH: wo.UPPH, + REMARK: wo.REMARK, + ACT_START_TIME: wo.ACT_START_TIME, + ACT_END_TIME: wo.ACT_END_TIME, + }; + SaveEntity(woBatch, false, 'BIZ_MES_WO_BATCH').then((action) => { + if (action.IsSuccessed) { + SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => { + if (action.IsSuccessed) { + resolve(true); + } else { + reject(false); + } + }); + } else { + reject(false); + } + }); + } catch { + reject(false); + } + }); + }, + initRoute: async (e, ...args) => { + const _data = await getRouteData(args[0][0].ROUTE_CODE); + args[0][1] = ref({ + nodes: [], + edges: [], + }); + return new Promise((resolve, reject) => { + try { + LogicFlow.use(BpmnElement); + const lf = new LogicFlow({ + container: document.querySelector('#lfContainer'), + edgeGenerator: (sourceNode) => { + // console.log('a'); + // 璧峰鑺傜偣绫诲瀷 rect 鏃朵娇鐢� 鑷畾涔夌殑杈� custom-edge + if (sourceNode.properties.isReturn) return 'custom-edge'; + // if (sourceNode.type === 'rect') return 'custom-edge'; + // return 'custom-edge'; + }, + }); + lf.register(customEdge); + lf.register(actionRect); + lf.register(TestNode); + lf.register(CollectNode); + lf.register(AssemblyNode); + lf.register(PackingNode); + lf.register(RepairNode); + lf.render({}); + //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋 + console.log('缁勪欢宸叉寕杞�', _data); + //宸ヨ壓璺嚎鍏ㄤ俊鎭紝鍖呮嫭Node銆丒dge鍜孉ct + // routeConfig.routeData = _data.Data; + if (_data.Data != null) { + //宸ヨ壓璺嚎涓讳俊鎭� + const currRoute = _data.Data.route; + _data.Data.nodes.forEach((n) => { + n.node.properties = JSON.parse(n.node.properties); + args[0][1].value.nodes.push(n.node); + }); + console.log('111', args[0][1]); + _data.Data.edges.forEach((e) => { + e.edge.properties = JSON.parse(e.edge.properties); + args[0][1].value.edges.push(e.edge); + }); + _data.Data.acts.forEach((act) => { + act.node.properties = JSON.parse(act.node.properties); + args[0][1].value.nodes.push(act.node); + }); + console.log('init', unref(lf).getGraphData(), JSON.parse(JSON.stringify(args[0][1]))); + lf.render(args[0][1].value); + // lf.graphModel.resize(500, 400); + lf.graphModel.fitView(); + lf.graphModel.translateCenter(); + } resolve(true); } catch { reject(false); - } finally { - args[0][0]({ confirmLoading: false }); } }); }, @@ -190,6 +334,7 @@ rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }], componentProps: { api: uploadApi, + multiple: false, }, }, ]; @@ -244,7 +389,16 @@ component: 'Input', required: true, colProps: { - span: 12, + span: 24, + }, + }, + { + field: 'RELEASE_QTY', + label: '宸ュ崟涓嬪彂鏁伴噺', + component: 'Input', + required: true, + colProps: { + span: 24, }, }, { @@ -253,11 +407,11 @@ component: 'ApiSelect', required: true, colProps: { - span: 12, + span: 24, }, componentProps: { api: getEntity, - params: { entityName: 'MES_LINE', sqlcmd: ' 1=1 ' }, + params: { entityName: 'MES_LINE', sqlcmd: ' 1=1 ', order: '' }, resultField: 'Data.Items', labelField: 'LINE_NAME', valueField: 'LINE_CODE', @@ -269,7 +423,7 @@ component: 'Input', required: true, colProps: { - span: 12, + span: 22, }, }, { @@ -292,21 +446,26 @@ span: 1, }, }, - { - field: 'fieldsc', - component: 'Upload', - label: '鎵撳嵃妯℃澘', - colProps: { - span: 10, - }, - rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }], - componentProps: { - api: uploadApi, - }, - }, + // { + // field: 'fieldsc', + // component: 'Upload', + // label: '鎵撳嵃妯℃澘', + // colProps: { + // span: 10, + // }, + // rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }], + // componentProps: { + // api: uploadApi, + // }, + // }, ]; -//宸ヨ壓璺嚎寮规杩斿洖 +/** + * @description: 宸ヨ壓璺嚎寮规杩斿洖 + * @param {*} d + * @param {*} u + * @return {*} + */ export function woGetSelectSuccess(d, u) { return { ROUTE_CODE: d.values['val'], @@ -314,7 +473,14 @@ }; } -/* 鑷畾涔夋ā鎬佹鎵撳紑鏂规硶 */ +/** + * @description: 鑷畾涔夋ā鎬佹鎵撳紑鏂规硶 + * @param {Fn} openModal + * @param {string} slotName + * @param {Fn} others + * @param {array} args + * @return {*} + */ export function woCustFn(openModal: Fn, slotName: string, others: Fn[], ...args) { switch (slotName) { case 'add': @@ -350,6 +516,7 @@ tableName: 'MES_ROUTE', rowKey: 'ROT_CODE', returnFieldName: 'ROUTE_CODE', //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О + searchInfo: { TABLE_NAME: 'MES_ROUTE' }, }); break; case 'set': -- Gitblit v1.9.3