| | |
| | | > |
| | | <!-- 用插槽自定义多表单 --> |
| | | <template #[item.name] v-for="item in dtlSlots" :key="item.name"> |
| | | <BasicForm @register="useFormData[item.name][0]"> |
| | | <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]"> |
| | | <!-- 用插槽自定义弹出选择框 --> |
| | | <template #[name]="{ field }" v-for="name in item.slots" :key="name"> |
| | | <a-button |
| | |
| | | /> |
| | | </template> |
| | | </BasicForm> |
| | | <!-- 自定义内容 --> |
| | | <div style="height: 200px" id="lfContainer" v-if="isCustEl[item.name]"></div> |
| | | </template> |
| | | </CustModal> |
| | | <RouteViewModal @register="registerRv" @success="RvItemSuccess" /> |
| | | </div> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { reactive, unref, h, onMounted, ref, nextTick } from 'vue'; |
| | | import { reactive, unref, h, onMounted, ref, nextTick, Ref } from 'vue'; |
| | | import { Steps, Step, Layout, LayoutContent } from 'ant-design-vue'; |
| | | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| | | import { BasicForm, FormSchema, FormActionType, useForm } from '/@/components/Form/index'; |
| | | import WoDrawer from './WoDrawer.vue'; |
| | |
| | | import { useModal } from '/@/components/Modal'; |
| | | import { 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 { Snapshot, BpmnElement, Menu, DndPanel, SelectionSelect } from '@logicflow/extension'; |
| | | |
| | | const { t } = useI18n(); |
| | | const ASteps = Steps; |
| | | const AStep = Step; |
| | | const cType = ref(''); |
| | | const title = ref('工单导入'); |
| | | const mtitle = ref('工单列表'); |
| | |
| | | loading: false, |
| | | tip: '加载中...', |
| | | }); |
| | | const lfInstance = ref(null) as Ref<LogicFlow | null>; |
| | | const [registerRv, { openModal: openRvModal }] = useModal(); |
| | | const [registerWo, { openModal: openWoModal }] = useModal(); |
| | | const [registerItemAdd, { openModal: openItemModal }] = useModal(); |
| | |
| | | bordered: true, |
| | | showIndexColumn: false, |
| | | }); |
| | | const routeData = ref({ |
| | | nodes: [], |
| | | edges: [], |
| | | }); |
| | | const formSchema = ref([] as FormSchema[]); |
| | | const woSchema = ref([] as FormSchema[]); |
| | | const prodSchema = ref([] as FormSchema[]); |
| | | const xxSchema = ref([] as FormSchema[]); |
| | | const rotSchema = ref([] as FormSchema[]); |
| | | const isCustEl = ref({ |
| | | forminfo: false, |
| | | woinfo: false, |
| | | prodinfo: false, |
| | | rotinfo: true, |
| | | }); |
| | | //表单中插槽渲染按钮打开模态框useModal方法 |
| | | const useModalData = ref({ |
| | | add: useModal(), |
| | |
| | | }, |
| | | showActionButtonGroup: false, |
| | | }), |
| | | xxinfo: useForm({ |
| | | labelWidth: 120, |
| | | schemas: xxSchema, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | showActionButtonGroup: false, |
| | | }), |
| | | // rotinfo: useForm({ |
| | | // labelWidth: 120, |
| | | // schemas: rotSchema, |
| | | // actionColOptions: { |
| | | // span: 24, |
| | | // }, |
| | | // showActionButtonGroup: false, |
| | | // }), |
| | | }); |
| | | |
| | | onMounted(() => {}); |
| | | onMounted(async () => {}); |
| | | |
| | | //新增 |
| | | function addWo() { |
| | |
| | | preIcons: { addRot: 'search|svg', setRot: 'config|svg' }, |
| | | title: '产品信息', |
| | | }, |
| | | { name: 'xxinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: 'XXX' }, |
| | | { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '工艺信息' }, |
| | | ]; |
| | | woSchema.value = getFormSchema('woinfo'); |
| | | prodSchema.value = getFormSchema('prodinfo'); |
| | | xxSchema.value = getFormSchema('xxinfo'); |
| | | // rotSchema.value = getFormSchema('rotinfo'); |
| | | if (lfInstance.value != null) { |
| | | routeData.value = { |
| | | nodes: [], |
| | | edges: [], |
| | | }; |
| | | const lf = unref(lfInstance)!; |
| | | lf.render({}); |
| | | } |
| | | openCustModal(true, { |
| | | isUpdate: true, |
| | | ctype: cType, |
| | | title: '工艺配置', |
| | | width: '1000px', |
| | | formEl: useFormData.value, //如果是多个表单,增加多个插槽 |
| | | formElName: ['woinfo', 'prodinfo', 'xxinfo'], |
| | | formElName: ['woinfo', 'prodinfo', 'rotinfo'], //表单插槽名称,支持多个表单 |
| | | RowKey: '', |
| | | fnName: { BIZ_MES_WO_Config: 'SaveCofig' }, //保存方法名 |
| | | initFnName: {}, //初始化方法名 |
| | | isCustEl: isCustEl.value, |
| | | ...record, |
| | | }); |
| | | } |
| | |
| | | title: '工单下发', //标题 |
| | | width: '900px', //弹出框宽度 |
| | | formEl: useFormData.value, |
| | | formElName: ['forminfo'], |
| | | formElName: ['forminfo'], //表单插槽名称 |
| | | RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //插槽的弹出框选择的code |
| | | fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //保存方法名 |
| | | initFnName: {}, //初始化方法名 |
| | | isCustEl: isCustEl.value, |
| | | ...record, |
| | | }); |
| | | } |
| | |
| | | let _val = {}; |
| | | _val[d.returnFieldName] = values[d.returnFieldName]; |
| | | useFormData.value[item][1].setFieldsValue(_val); |
| | | if (d.returnFieldName == 'ROUTE_CODE') { |
| | | routeData.value = { |
| | | nodes: [], |
| | | edges: [], |
| | | }; |
| | | init(selectVals.value['ID']); |
| | | } |
| | | } |
| | | |
| | | /* 弹出选择框 */ |
| | |
| | | ); //[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、Edge和Act |
| | | // 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(); |
| | | } |
| | | } |
| | | </script> |