From 5a4d79d9765dfca8812638b57d5f5fe21f7a06ee Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 16 七月 2024 17:05:25 +0800 Subject: [PATCH] 工单下发更新 --- src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue | 260 +++++++++++++++++++--------------------------------- 1 files changed, 95 insertions(+), 165 deletions(-) diff --git a/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue b/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue index 6b150b6..9b3e0f8 100644 --- a/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue +++ b/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue @@ -4,7 +4,7 @@ * @version: * @Date: 2024-05-25 00:27:00 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-24 22:58:16 + * @LastEditTime: 2024-07-16 16:44:47 --> <template> <div> @@ -70,34 +70,41 @@ <Loading :loading="compState.loading" :tip="compState.tip" /> <WoDrawer @register="registerDrawer" @success="handleSuccess" /> <WoModal @register="registerWo" @success="handleSuccess" :title="title" :mtitle="mtitle" /> - <!-- 鑷畾涔夋ā鎬佹锛屽彲浠ヨ嚜瀹氫箟澶氳〃鍗� --> - <CustModal - @register="registerCust" - @success="custSuccess" - :type="cType" - :detailSlots="dtlSlots" - > - <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� --> - <template #[item.name] v-for="item in dtlSlots" :key="item.name"> - <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]"> - <!-- 鐢ㄦ彃妲借嚜瀹氫箟寮瑰嚭閫夋嫨妗� --> - <template #[name]="{ field }" v-for="name in item.slots" :key="name"> - <a-button - class="mt-1 ml-1" - size="small" - @click="handleCustClick(field)" - :preIcon="item.preIcons[name]" - /> - <GeneralModal - @register="useModalData[name][0]" - @success="(d, u) => handleEntSuccess(d, u, item.name)" - /> - </template> - </BasicForm> - <!-- 鑷畾涔夊唴瀹� --> - <div style="height: 200px" id="lfContainer" v-if="isCustEl[item.name]"></div> - </template> - </CustModal> + <Suspense> + <!-- 鑷畾涔夋ā鎬佹锛屽彲浠ヨ嚜瀹氫箟澶氳〃鍗� --> + <CustModal + @register="registerCust" + @success="custSuccess" + :type="cType" + :detailSlots="dtlSlots" + :entityName="entityName" + > + <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� --> + <template #[item.name] v-for="item in dtlSlots" :key="item.name"> + <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]"> + <!-- 鐢ㄦ彃妲借嚜瀹氫箟寮瑰嚭閫夋嫨妗� --> + <template #[name]="{ field }" v-for="name in item.slots" :key="name"> + <a-button + class="mt-1 ml-1" + size="small" + @click="handleCustClick(field)" + :preIcon="item.preIcons[name]" + /> + <GeneralModal + @register="useModalData[name][0]" + @success="(d, u) => handleEntSuccess(d, u, item.name)" + /> + </template> + </BasicForm> + <!-- 鑷畾涔夊唴瀹� --> + <!-- <div style="height: 200px" id="lfContainer" v-if="isCustEl[item.name]"></div> --> + <div class="h-full" style="height: 380px" v-if="isCustEl[item.name]"> + <FlowChartView :data="routeData" @init="init" /> + </div> + </template> + </CustModal> + <!-- <template #fallback> Loading... </template> --> + </Suspense> <RouteViewModal @register="registerRv" @success="RvItemSuccess" /> </div> </template> @@ -110,6 +117,7 @@ import WoModal from './WoModal.vue'; import GeneralModal from '/@/views/components/GeneralModal.vue'; import RouteViewModal from '/@/views/components/RouteViewModal.vue'; + import { FlowChartView } from '/@/components/FlowChart'; import CustModal from '/@/views/components/CustModal.vue'; import { useDrawer } from '/@/components/Drawer'; import { columns, searchFormSchema } from './biz_mes_wo.data'; @@ -121,15 +129,8 @@ import { SaveEntity, getListByPage } from '/@/api/tigerapi/system'; import { GetSelectSuccess, OpenSelectItem, getFormSchema } from '/@/views/components/data'; import LogicFlow from '@logicflow/core'; - import { getRouteData } from '/@/api/tigerapi/mes/router'; - 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 customEdge from '/@/components/FlowChart/src/customEdge'; - import { BpmnElement } from '@logicflow/extension'; + import { initRoute } from '../../../system/lowcode/data'; + import BIZ_MES_WO from '../../../system/lowcode/entityts/BIZ_MES_WO'; const { t } = useI18n(); const ASteps = Steps; @@ -147,10 +148,10 @@ tip: '鍔犺浇涓�...', }); const lfInstance = ref(null) as Ref<LogicFlow | null>; - const [registerRv, { openModal: openRvModal }] = useModal(); + const [registerRv, { openModal: openRvModal, closeModal }] = useModal(); const [registerWo, { openModal: openWoModal }] = useModal(); const [registerItemAdd, { openModal: openItemModal }] = useModal(); - const [registerCust, { openModal: openCustModal, closeModal }] = useModal(); + const [registerCust, { openModal: openCustModal }] = useModal(); const [registerTable, { getForm, reload }] = useTable({ title: '宸ュ崟淇℃伅', api: getListByPage, @@ -176,9 +177,10 @@ nodes: [], edges: [], }); + const entityName = ref('BIZ_MES_WO'); const formSchema = ref([] as FormSchema[]); - const woSchema = ref([] as FormSchema[]); - const prodSchema = ref([] as FormSchema[]); + const woSchema = ref<FormSchema[]>(getFormSchema('woinfo')); + const prodSchema = ref<FormSchema[]>(getFormSchema('prodinfo')); const isCustEl = ref({ forminfo: false, woinfo: false, @@ -192,43 +194,22 @@ addRot: useModal(), setRot: useModal(), }); - //鑷畾涔夊琛ㄥ崟瀹炰緥 - const useFormData = ref({ - forminfo: useForm({ - labelWidth: 120, - schemas: formSchema, - actionColOptions: { - span: 24, - }, - showActionButtonGroup: false, - }), - woinfo: useForm({ - labelWidth: 120, - schemas: woSchema, - actionColOptions: { - span: 24, - }, - showActionButtonGroup: false, - }), - prodinfo: useForm({ - labelWidth: 120, - schemas: prodSchema, - actionColOptions: { - span: 24, - }, - showActionButtonGroup: false, - }), - // rotinfo: useForm({ - // labelWidth: 120, - // schemas: rotSchema, - // actionColOptions: { - // span: 24, - // }, - // showActionButtonGroup: false, - // }), - }); + + /* 鑾峰彇澶氳〃鍗曞疄渚� */ + const [{ GetUseForm }] = BIZ_MES_WO(); + const useFormData = ref<any>(GetUseForm()); onMounted(async () => {}); + + const currlf = ref(null) as Ref<LogicFlow | null>; + /** + * @description: 宸ヨ壓璺嚎鍒濆鍖� + * @param {*} lf + * @return {*} + */ + async function init(lf, rotId) { + initRoute(lf, rotId, routeData, currlf); + } //鏂板 function addWo() { @@ -266,24 +247,18 @@ }, { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '宸ヨ壓淇℃伅' }, ]; - woSchema.value = getFormSchema('woinfo'); - prodSchema.value = getFormSchema('prodinfo'); // rotSchema.value = getFormSchema('rotinfo'); - //宸ヨ壓璺嚎娓叉煋鍥惧垵濮嬪寲 - if (lfInstance.value != null) { - routeData.value = { - nodes: [], - edges: [], - }; - const lf = unref(lfInstance)!; - lf.render({}); - } + routeData.value = { + nodes: [], + edges: [], + }; + initRoute(currlf, record.ROUTE_CODE, routeData, currlf); selectVals.value['ROUTE_CODE'] = record.ROUTE_CODE; openCustModal(true, { isUpdate: true, ctype: cType, title: '宸ヨ壓閰嶇疆', - width: '1000px', + width: '1200px', formEl: useFormData.value, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы formElName: ['woinfo', 'prodinfo', 'rotinfo'], //琛ㄥ崟鎻掓Ы鍚嶇О锛屾敮鎸佸涓〃鍗� RowKey: '', @@ -294,21 +269,21 @@ values: record, //琛ㄥ崟璁板綍 }); } - + /** * @description: 涓嬪彂 * @param {*} record * @return {*} - */ + */ function handleRelease(record: Recordable) { - if (record.STATUS == 2) { - createErrorModal({ - title: t('璀﹀憡'), - content: t('宸ュ崟宸茬粡涓嬪彂锛屼笉鑳藉啀涓嬪彂锛�'), - getContainer: () => document.body, - }); - return; - } + // if (record.STATUS == 2) { + // createErrorModal({ + // title: t('璀﹀憡'), + // content: t('宸ュ崟宸茬粡涓嬪彂锛屼笉鑳藉啀涓嬪彂锛�'), + // getContainer: () => document.body, + // }); + // return; + // } cType.value = 'BIZ_MES_WO'; dtlSlots.value = [ { @@ -318,7 +293,7 @@ title: '涓嬪彂閰嶇疆', }, ]; - formSchema.value = getFormSchema(cType.value); + // formSchema.value = getFormSchema(cType.value); openCustModal(true, { isUpdate: true, //鏄惁鏇存柊鎿嶄綔 ctype: cType, //鏄摢涓〉闈� @@ -328,17 +303,17 @@ formElName: ['forminfo'], //琛ㄥ崟鎻掓Ы鍚嶇О RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //鎻掓Ы鐨勫脊鍑烘閫夋嫨鐨刢ode fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //淇濆瓨鏂规硶鍚� - initFnName: {}, //鍒濆鍖栨柟娉曞悕 + initFnName: {}, //鍒濆鍖栨柟娉曞悕锛屾病鏈夊氨鐣欑┖{} isCustEl: isCustEl.value, values: record, //琛ㄥ崟璁板綍 }); } - + /** * @description: 鍙栨秷涓嬪彂 * @param {*} record * @return {*} - */ + */ function handleUnRelease(record: Recordable) { if (record.STATUS == 0) { createErrorModal({ @@ -386,12 +361,12 @@ } }); } - + /** * @description: 鍒犻櫎 * @param {*} record * @return {*} - */ + */ function handleDelete(record: Recordable) { DeleteMesWo(record.ID).then((action) => { if (action.IsSuccessed) { @@ -402,20 +377,20 @@ } }); } - + /** * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥� * @param {*} d * @return {*} - */ + */ function custSuccess(d) { reload(); } - + /** * @description: 鐐瑰嚮鎵撳紑鐗╂枡鍒楄〃妗� * @return {*} - */ + */ function handleSelectItem() { openItemModal(true, { title: '鐗╂枡鍒楄〃', @@ -447,7 +422,7 @@ ], tableName: 'BAS_ITEM', rowKey: 'ITEM_CODE', - searchInfo: {TABLE_NAME: 'BAS_ITEM'} + searchInfo: { TABLE_NAME: 'BAS_ITEM' }, }); } @@ -456,20 +431,20 @@ * @param {*} d * @param {*} u * @return {*} - */ + */ function handleItemSuccess(d, u) { getForm().setFieldsValue({ ITEM_CODE: d.values['val'], }); } - + /** * @description: 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� * @param {*} d * @param {*} u * @param {*} item * @return {*} - */ + */ function handleEntSuccess(d, u, item) { var values = GetSelectSuccess(d, u, cType.value); selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� @@ -481,7 +456,10 @@ nodes: [], edges: [], }; - init(selectVals.value['ROUTE_CODE']); + + init(currlf, selectVals.value['ROUTE_CODE']); + const { transformModel, width, height } = unref(currlf).graphModel; + transformModel.focusOn(300, 200, width, height); } } @@ -489,7 +467,7 @@ * @description: 寮瑰嚭閫夋嫨妗� * @param {*} item * @return {*} - */ + */ function handleCustClick(item) { //鎵撳紑鑷畾涔夋ā鎬佹 OpenSelectItem( @@ -500,56 +478,8 @@ selectVals.value['ROUTE_CODE'], ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹� } - function RvItemSuccess(d, u) {} - async function init(rotId) { - LogicFlow.use(BpmnElement); - lfInstance.value = 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'; - }, - }); - const lf = unref(lfInstance)!; - // lf?.setDefaultEdgeType('line'); - lf.register(customEdge); - lf.register(actionRect); - lf.register(TestNode); - lf.register(CollectNode); - lf.register(AssemblyNode); - lf.register(PackingNode); - lf.register(RepairNode); - lf.render({}); - //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋 - var _data = await getRouteData(rotId); - console.log('缁勪欢宸叉寕杞�', _data); - //宸ヨ壓璺嚎鍏ㄤ俊鎭紝鍖呮嫭Node銆丒dge鍜孉ct - // routeConfig.routeData = _data.Data; - if (_data.Data != null) { - //宸ヨ壓璺嚎涓讳俊鎭� - var currRoute = _data.Data.route; - _data.Data.nodes.forEach((n) => { - n.node.properties = JSON.parse(n.node.properties); - routeData.value.nodes.push(n.node); - }); - console.log('111', routeData.value); - _data.Data.edges.forEach((e) => { - e.edge.properties = JSON.parse(e.edge.properties); - routeData.value.edges.push(e.edge); - }); - _data.Data.acts.forEach((act) => { - act.node.properties = JSON.parse(act.node.properties); - routeData.value.nodes.push(act.node); - }); - console.log('init', unref(lf).getGraphData(), JSON.parse(JSON.stringify(routeData.value))); - lf.render(routeData.value); - // lf.graphModel.resize(500, 400); - lf.graphModel.fitView(); - lf.graphModel.translateCenter(); - } + function RvItemSuccess(d, u) { + closeModal(); } </script> -- Gitblit v1.9.3