From c3e294ff76aff4654c7218645c7a13b539f66a36 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 18 六月 2024 20:08:43 +0800 Subject: [PATCH] internal --- src/views/components/bizMesWo.ts | 397 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 363 insertions(+), 34 deletions(-) diff --git a/src/views/components/bizMesWo.ts b/src/views/components/bizMesWo.ts index 540f450..180edf1 100644 --- a/src/views/components/bizMesWo.ts +++ b/src/views/components/bizMesWo.ts @@ -1,46 +1,349 @@ +/* + * @Description: 宸ュ崟鑷畾涔夋柟娉晅s + * @Author: Ben Lin + * @version: + * @Date: 2024-06-05 16:10:24 + * @LastEditors: your name + * @LastEditTime: 2024-06-15 22:43:55 + */ +/* 宸ュ崟鐩稿叧鑷畾涔夋柟娉� */ import { FunctionType } from '/@/api/tigerapi/model/systemModel'; -import { SaveEntity, getEntity } from '/@/api/tigerapi/system'; +import { GetEnum, SaveEntity, getEntity } from '/@/api/tigerapi/system'; import { FormSchema } from '/@/components/Table'; import { useUserStore } from '/@/store/modules/user'; import { useI18n } from '/@/hooks/web/useI18n'; import { uploadApi } from '/@/api/sys/upload'; -import { notification } from 'ant-design-vue'; +import { useLocale } from '/@/locales/useLocale'; +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'; +import { multiply } from 'lodash-es'; const { t } = useI18n(); +const { getLocale } = useLocale(); -export const getFns: Record<string, FunctionType> = { +/** + * @description: 鑷畾涔夋柟娉� + * @return {*} + */ +export const getWoFns: Record<string, FunctionType> = { handleSubmit: async (e, ...args) => { - try { - const values = await args[0][0].validate(); - args[0][1]({ confirmLoading: true }); - values.AUTH_PROD = useUserStore().getUserInfo.prodCode; - // const apiAction = SaveEntity(values, e, 'MES_LINE'); - // apiAction.then((action) => { - // if (action.IsSuccessed) { - // args[0][2](); - // args[0][3]('success'); - // } - // }); - args[0][2](); - args[0][3]('success'); - } finally { - args[0][1]({ confirmLoading: false }); - } + const values = await args[0][0].validate(); + return new Promise((resolve, reject) => { + try { + args[0][1]({ confirmLoading: true }); + values.AUTH_PROD = useUserStore().getUserInfo.prodCode; + // const apiAction = SaveEntity(values, e, 'MES_LINE'); + // apiAction.then((action) => { + // if (action.IsSuccessed) { + // args[0][2](); + // args[0][3]('success'); + // } + // }); + args[0][2](); + args[0][3]('success'); + resolve(true); + } catch { + reject(false); + } finally { + args[0][1]({ confirmLoading: false }); + } + }); }, rvSubmit: (e, ...args) => { - try { - args[0][0]({ confirmLoading: true }); - args[0][1](); - args[0][2]('success'); - } finally { - args[0][0]({ confirmLoading: false }); - } + return new Promise((resolve, reject) => { + try { + args[0][0]({ confirmLoading: true }); + args[0][1](); + args[0][2]('success'); + resolve(true); + } catch { + reject(false); + } finally { + args[0][0]({ confirmLoading: false }); + } + }); + }, + + /** + * @description: 宸ュ崟閰嶇疆淇濆瓨鏂规硶 + * @param {*} e + * @param {array} args + * @return {*} + */ + SaveCofig: (e, ...args) => { + return new Promise((resolve, reject) => { + try { + 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); + } + }); + }, + /** + * @description: 宸ュ崟涓嬪彂淇濆瓨鏂规硶 + * @param {*} e + * @param {array} args + * @return {*} + */ + SaveWoBatch: (e, ...args) => { + return new Promise((resolve, reject) => { + try { + 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); + } + }); }, }; export const woCfgformSchema: FormSchema[] = [ { - field: 'field1', + field: 'ORDER_NO', + component: 'Input', + label: '宸ュ崟鍙�', + colProps: { + span: 8, + }, + componentProps: { + placeholder: '璇疯緭鍏ュ伐鍗曞彿', + onChange: (e: any) => { + console.log(e); + }, + }, + dynamicDisabled: true, + }, + { + field: 'ORDER_TYPE', + component: 'Select', + label: '宸ュ崟绫诲瀷', + colProps: { + span: 8, + }, + defaultValue: 'Normal', + componentProps: { + options: [ + { + label: '姝e父', + value: 'Normal', + }, + { + label: '杩斿伐', + value: 'Rework', + }, + ], + }, + dynamicDisabled: true, + }, + { + field: 'PLAN_QTY', + component: 'Input', + label: '璁″垝鏁伴噺', + colProps: { + span: 8, + }, + dynamicDisabled: true, + }, +]; + +export const prodCfgformSchema: FormSchema[] = [ + { + field: 'ITEM_CODE', + component: 'Input', + label: '鐗╂枡缂栫爜', + required: true, + colProps: { + span: 12, + }, + componentProps: { + placeholder: '璇疯緭鍏ョ墿鏂欑紪鐮�', + onChange: (e: any) => { + console.log(e); + }, + }, + dynamicDisabled: true, + }, + { + field: 'ITEM_TYPE', + component: 'Input', + label: '鐗╂枡绫诲瀷', + colProps: { + span: 12, + }, + }, + { + label: '宸ヨ壓璺嚎', + field: 'ROUTE_CODE', + component: 'Input', + required: true, + colProps: { + span: 12, + }, + }, + { + field: 'addRot', + component: 'Input', + label: '1', + colSlot: 'addRot', + defaultValue: 'MES_ROUTE', + colProps: { + span: 1, + }, + }, + { + field: 'setRot', + component: 'Input', + label: '1', + colSlot: 'setRot', + defaultValue: 'MES_ROUTE', + colProps: { + span: 1, + }, + }, + { + field: 'fieldsc', + component: 'Upload', + label: '鎵撳嵃妯℃澘', + colProps: { + span: 10, + }, + rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }], + componentProps: { + api: uploadApi, + multiple: false, + }, + }, +]; + +export const xxCfgformSchema: FormSchema[] = [ + { + field: 'field10', component: 'Input', label: '瀛楁1', colProps: { @@ -54,7 +357,7 @@ }, }, { - field: 'field2', + field: 'ROUTE_CODE', component: 'Input', label: '瀛楁2', colProps: { @@ -62,7 +365,17 @@ }, }, { - field: 'field3', + field: 'add', + component: 'Input', + label: '1', + colSlot: 'add', + defaultValue: 'MES_ROUTE', + colProps: { + span: 1, + }, + }, + { + field: 'field12', component: 'DatePicker', label: '瀛楁3', colProps: { @@ -129,7 +442,7 @@ { field: 'fieldsc', component: 'Upload', - label: '涓婁紶鎵撳嵃妯℃澘', + label: '鎵撳嵃妯℃澘', colProps: { span: 10, }, @@ -140,7 +453,12 @@ }, ]; -//宸ヨ壓璺嚎寮规杩斿洖 +/** + * @description: 宸ヨ壓璺嚎寮规杩斿洖 + * @param {*} d + * @param {*} u + * @return {*} + */ export function woGetSelectSuccess(d, u) { return { ROUTE_CODE: d.values['val'], @@ -148,10 +466,19 @@ }; } -export function woCustFn(openItemModal: Fn, slotName: string, others: Fn[], ...args) { +/** + * @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': - openItemModal(true, { + case 'addRot': + openModal(true, { title: '宸ヨ壓璺嚎鍒楄〃', schemas: [ { @@ -182,15 +509,17 @@ tableName: 'MES_ROUTE', rowKey: 'ROT_CODE', returnFieldName: 'ROUTE_CODE', //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О + searchInfo: {TABLE_NAME: 'MES_ROUTE' } }); break; case 'set': + case 'setRot': // notification.success({ // message: '鐐瑰嚮浜嗚缃寜閽�', // description: `OK`, // duration: 3, // }); - others[0](true, { rotId: args[0][0], slotName: 'set' }); + others[0](true, { rotId: args[0][0], slotName: slotName }); break; default: () => {}; -- Gitblit v1.9.3