| | |
| | | * @version: |
| | | * @Date: 2024-06-19 20:34:27 |
| | | * @LastEditors: Ben Lin |
| | | * @LastEditTime: 2024-08-13 20:27:09 |
| | | * @LastEditTime: 2024-10-22 09:28:36 |
| | | */ |
| | | |
| | | import { Ref, h, ref, render, unref } from 'vue'; |
| | |
| | | GetRoutePTree, |
| | | RouteToCust, |
| | | RouteToProd, |
| | | SetDefaultRoute, |
| | | } from '/@/api/tigerapi/mes/router'; |
| | | import { GetEnum, SaveEntity, convertToTree, getEntity } from '/@/api/tigerapi/system'; |
| | | import { useLocale } from '/@/locales/useLocale'; |
| | |
| | | import { NavItem } from '/@/api/tigerapi/model/basModel'; |
| | | import { useMessage } from '/@/hooks/web/useMessage'; |
| | | import { useModal } from '/@/components/Modal'; |
| | | import { BasicColumn, FormSchema, useTable } from '/@/components/Table'; |
| | | import { ActionItem, BasicColumn, FormSchema, useTable } from '/@/components/Table'; |
| | | import { CustModalParams } from '/@/api/tigerapi/model/systemModel'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | import { EventDataNode } from 'ant-design-vue/lib/tree'; |
| | | import { ContextMenuItem } from '/@/components/TigerTree'; |
| | | import { useForm } from '/@/components/Form'; |
| | | import { mesApi } from '/@/api/tigerapi/mes/mesApi'; |
| | | import { BAS_LABEL_VAR_WO, MesRotTree } from '/@/api/tigerapi/model/mesModel'; |
| | | import { buildUUID } from '/@/utils/uuid'; |
| | | import { AddOrEditLabelVarByWorkOrder } from '/@/api/tigerapi/mes/wo'; |
| | | import { useProdRouteStore } from '/@/store/modules/prodRoute'; |
| | | |
| | | const { t } = useI18n(); |
| | | const { createErrorModal } = useMessage(); |
| | | const { getLocale } = useLocale(); |
| | | const useProdRoute = useProdRouteStore(); |
| | | function _default() { |
| | | /* 定义变量 */ |
| | | const isNormal = (type: number) => type === 0; |
| | |
| | | * @description: 高级表单和详情页面返回主页面的url |
| | | * @return {*} |
| | | */ |
| | | GetHomeUrl: () => { |
| | | return `/V_BAS_PROD/LC/${encodeURI(JSON.stringify({ ID: 'V_BAS_PROD', colSlots: [], crudColSlots: [] }))}`; |
| | | GetHomeUrl: (params) => { |
| | | return `/V_BAS_PROD_R/LC/${encodeURI(JSON.stringify({ ID: 'V_BAS_PROD_R', colSlots: [], crudColSlots: [], sName: params['sName'] }))}`; |
| | | }, |
| | | /** |
| | | * @description: 获取树形数据 |
| | |
| | | */ |
| | | fetchTreeData: async (type: string, itemCode: string) => { |
| | | let data = { title: '', treeData: [] as any[], fieldNames: {} }; |
| | | let prodTreeData = await GetRoutePTree({ |
| | | let prodTreeData = (await GetRoutePTree({ |
| | | prodCode: itemCode, |
| | | orgCode: useUserStore().getUserInfo.orgCode, |
| | | }); |
| | | // let uniqueArr = prodTreeData.reduce((acc, current) => { |
| | | // if (!acc.some((x) => x.pid == current.pid && x.id == current.id && x.seq == current.seq && x.type == current.type)) { |
| | | // acc.push(current); |
| | | // } |
| | | // return acc; |
| | | // }, [] as V_MES_ROUTE_PTREE[]); |
| | | data.treeData = convertToTree(prodTreeData, 'pid', 'tid', 'root'); |
| | | })) as unknown as MesRotTree[]; |
| | | let _treeData = convertToTree(prodTreeData, 'pid', 'tid', 'root'); |
| | | data.title = '工艺路线'; |
| | | data.fieldNames = { key: 'tid', title: 'name' }; |
| | | if ( |
| | | !useProdRoute.changeToCPPage || |
| | | !useProdRoute.curProdRotTree.some((q) => q.name == itemCode) |
| | | ) { |
| | | /* 保存工艺树形数据到状态管理 */ |
| | | useProdRoute.setCurProdRotTree({ |
| | | name: itemCode, |
| | | treeInfo: _treeData as unknown as MesRotTree[], |
| | | }); |
| | | } |
| | | useProdRoute.setItemCode(itemCode); |
| | | if (useProdRoute.curProdRotTree.some((q) => q.name == itemCode)) { |
| | | data.treeData = useProdRoute.curProdRotTree.filter((q) => q.name == itemCode)[0].treeInfo; |
| | | } |
| | | return data; |
| | | }, |
| | | /** |
| | | * @description: 操作字段自定义按钮,必需要有的方法 |
| | | * @return {*} |
| | | */ |
| | | ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => { |
| | | data.push({ |
| | | icon: 'template|svg', |
| | | tooltip: '模板维护', |
| | | onClick: handleTemplate.bind(null, args, params), |
| | | name: '模板维护', |
| | | }); |
| | | return data; |
| | | }, |
| | | /** |
| | |
| | | * @return {*} |
| | | */ |
| | | GetCrudColSlots: () => { |
| | | return ['scanadd', 'assyadd', 'testadd', 'auditadd', 'printadd', 'pkgadd']; |
| | | return [ |
| | | { name: 'scanadd', icon: 'search|svg' }, |
| | | { name: 'assyadd', icon: 'search|svg' }, |
| | | { name: 'testadd', icon: 'search|svg' }, |
| | | { name: 'auditadd', icon: 'search|svg' }, |
| | | { name: 'printadd', icon: 'search|svg' }, |
| | | { name: 'pkgadd', icon: 'search|svg' }, |
| | | { name: 'labeladd', icon: 'search|svg' }, |
| | | ]; |
| | | }, |
| | | /** |
| | | * @description: 切换节点时事件方法 |
| | |
| | | ACT_TYPE: res.Data.Items[0].ACT_TYPE, |
| | | CUST_CODE: params['selectedNodes'][0].cust, |
| | | OPTION_1: res.Data.Items[0].OPTION_1, |
| | | OPTION_2: res.Data.Items[0].OPTION_2, |
| | | }); |
| | | /* 如果是包装规则 */ |
| | | if (res.Data.Items[0].ACT_TYPE == 6) { |
| | |
| | | ItemCode: false, |
| | | }; |
| | | } |
| | | useProdRoute.setcurDtl(result); |
| | | resolve(result); |
| | | } catch (e) { |
| | | reject(e); |
| | |
| | | } |
| | | values.AUTH_ORG = useUserStore().getUserInfo.orgCode; |
| | | values.AUTH_PROD = useUserStore().getUserInfo.prodCode; |
| | | if (type == 'Action') { |
| | | values.OPTION_1 = JSON.stringify(useProdRoute.getcurDtl['BAS_PKG_DTL']); |
| | | } |
| | | SaveEntity(values, true, entityName).then((action) => { |
| | | if (action.IsSuccessed) { |
| | | emit('success'); |
| | |
| | | /** |
| | | * @description: 弹出选择框打开方法 |
| | | * @param {Fn} openItemModal |
| | | * @param {array} args |
| | | * @return {*} |
| | | */ |
| | | OpenSelectItem: (openItemModal: Fn, ...args) => { |
| | | let config = {}; |
| | | const openCrudModal = args[1]; |
| | | const record = args[2]; |
| | | const OrderNo = args[3]; |
| | | switch (args[0]) { |
| | | case 'scanadd': |
| | | config = ruleModalCfg; |
| | |
| | | config = pkgModalCfg; |
| | | break; |
| | | } |
| | | openItemModal(true, config); |
| | | if (args[0] == 'labeladd') { |
| | | openCrudModal(true, { |
| | | isUpdate: true, //是否更新操作 |
| | | entityName: 'ProdRouteBinding', //是哪个页面 |
| | | ctype: 'BAS_LABEL_VAR_WO', //实体名称 |
| | | title: '模板维护', //标题 |
| | | width: '1024px', //弹出框宽度 |
| | | ItemColumns: TemplateBasColumn, //弹出框中表格字段结构 |
| | | schemas: [], //查询条件字段结构 |
| | | others: { WORK_ORDER: OrderNo }, //需要带到弹出窗口中的数据 |
| | | searchInfo: { |
| | | TABLE_NAME: 'BAS_LABEL_VAR_WO', //实体名称 |
| | | LabelId: record.LABEL_CODE, //模板ID |
| | | WorkOrder: OrderNo, //工单号 |
| | | apiUrl: mesApi.GetLabelVarByWorkOrder, //自定义获取数据分页的api,不用默认的基础方法 |
| | | // sqlcmd: ` (WORK_ORDER = '${OrderNo}' OR WORK_ORDER = '' OR WORK_ORDER IS NULL)`, |
| | | // option: |
| | | // { |
| | | // //根据据点查询,必需带这个参数 |
| | | // UserId: useUserStore().getUserInfo.userId, |
| | | // ByOrg: true, |
| | | // CurOrg: useUserStore().getUserInfo.orgCode, |
| | | // }, |
| | | }, |
| | | values: record, //表单记录 |
| | | }); |
| | | } else { |
| | | openItemModal(true, config); |
| | | } |
| | | }, |
| | | /** |
| | | * @description: 弹出选择框选择成功返回 |
| | | * @param {*} d |
| | | * @param {*} u |
| | | * @param {array} args |
| | | * @return {*} |
| | | */ |
| | | GetSelectSuccess: async (d, u, ...args) => { |
| | |
| | | testadd: useModal(), |
| | | auditadd: useModal(), |
| | | printadd: useModal(), |
| | | labeladd: useModal(), |
| | | pkgadd: useModal(), |
| | | }; |
| | | }, |
| | | /** |
| | | * @description: 获取在增删改表单中的模态框应用列表 |
| | | * @return {*} |
| | | */ |
| | | GetUseCrudModals: () => { |
| | | return { |
| | | addRoute: useModal(), |
| | | addCustomer: useModal(), |
| | | editRoute: useModal(), |
| | | scanadd: useModal(), |
| | | assyadd: useModal(), |
| | | testadd: useModal(), |
| | | auditadd: useModal(), |
| | | printadd: useModal(), |
| | | labeladd: useModal(), |
| | | pkgadd: useModal(), |
| | | }; |
| | | }, |
| | |
| | | // searchInfo: { TABLE_NAME: 'V_BAS_PKG_DTL' }, |
| | | dataSource: data.value['BAS_PKG_DTL'], |
| | | columns: GetBaseColumns('BAS_PKG_DTL', args[0], data), |
| | | maxHeight: 520, |
| | | // maxHeight: 520, |
| | | // scroll: { y: window.screen.width == 1366? 400: 450 }, |
| | | isCanResizeParent: true, |
| | | useSearchForm: false, |
| | | showTableSetting: false, |
| | | bordered: true, |
| | | canResize: true, |
| | | // canResize: false, |
| | | showIndexColumn: false, |
| | | // rowSelection: { |
| | | // type: 'radio', //'checkbox' |
| | |
| | | }), |
| | | }; |
| | | }, |
| | | /** |
| | | * @description: 获取行为或者节点的配置表单结构,使用useForm() |
| | | * @return {*} |
| | | */ |
| | | GetUseForm: () => { |
| | | return { |
| | | Action: useForm({ |
| | |
| | | /** |
| | | * @description: 获取标题信息 |
| | | * @param {string} type |
| | | * @param {*} item |
| | | * @return {*} |
| | | */ |
| | | GetTitle: (type: string, item) => { |
| | |
| | | * @param {Ref} selectedNodes |
| | | * @return {*} |
| | | */ |
| | | SelectNode: (selectedNodes: Ref<any[]>) => { |
| | | SelectNode: (selectedNodes: Ref<any[]>, code: string) => { |
| | | let result = { |
| | | showConfig: false, |
| | | showNav: false, |
| | |
| | | if (selectedNodes.value[0].type == 'Action' || selectedNodes.value[0].type == 'Node') { |
| | | result.showNav = false; |
| | | result.showConfig = true; |
| | | if (selectedNodes.value[0].type == 'Action') { |
| | | result.showOtherTable = { BAS_PKG_DTL: false, ItemCode: false }; |
| | | } else { |
| | | result.showOtherTable = { BAS_PKG_DTL: false, ItemCode: false }; |
| | | } |
| | | result.showOtherTable = { BAS_PKG_DTL: false, ItemCode: false }; |
| | | } |
| | | /* 保存当前选择的节点数据到状态管理 */ |
| | | useProdRoute.setCurSelectedNodes({ name: code, SelectedNodes: selectedNodes.value }); |
| | | return result; |
| | | }, |
| | | /** |
| | | * @description: 获取导航项 |
| | | * @param {string} type |
| | | * @return {*} |
| | | */ |
| | | GetNavItems: (type: string) => { |
| | |
| | | url: '/addRoute', |
| | | action: 'addRoute', |
| | | isStep: false, |
| | | isCustEl: false, |
| | | }, |
| | | { |
| | | title: '添加客户工艺路线', |
| | |
| | | url: '/addCustomer', |
| | | action: 'addCustomer', |
| | | isStep: true, |
| | | isCustEl: false, |
| | | }, |
| | | ]; |
| | | break; |
| | | case 'Route': |
| | | item = [ |
| | | { |
| | | title: '编辑工艺路线', |
| | | icon: 'clarity:note-edit-line', |
| | | title: '编辑工艺路线', //标题 |
| | | icon: 'clarity:note-edit-line', //图标 |
| | | color: '#1fdaca', //字体颜色 |
| | | url: '/editRoute', //导航地址 |
| | | action: 'editRoute', //导航执行的方法,如果按这个action来执行,上面的url就无效 |
| | | isStep: false, //是否是步骤 |
| | | isCustEl: false, //是否是自定义html内容 |
| | | }, |
| | | { |
| | | title: '设置默认工艺路线', |
| | | icon: '', |
| | | color: '#1fdaca', |
| | | url: '/editRoute', |
| | | action: 'editRoute', |
| | | url: '', |
| | | action: '', |
| | | isStep: false, |
| | | isCustEl: true, |
| | | }, |
| | | ]; |
| | | break; |
| | |
| | | /** |
| | | * @description: 导航页面切换按钮时调用方法 |
| | | * @param {any} action |
| | | * @param {array} args |
| | | * @return {*} |
| | | */ |
| | | navChangeItem: (action: any, ...args) => { |
| | | const openRvModal = args[1]; |
| | | const openModal = args[0]; |
| | | switch (action) { |
| | | case 'addRoute': |
| | | args[0](true, { |
| | | openModal(true, { |
| | | title: '工艺路线列表', |
| | | schemas: [ |
| | | { |
| | |
| | | }); |
| | | break; |
| | | case 'addCustomer': |
| | | args[0](true, { |
| | | openModal(true, { |
| | | title: '请完成以下步骤', |
| | | }); |
| | | break; |
| | | case 'editRoute': |
| | | args[1](true, { rotId: args[2][0].id, slotName: '', prodCode:args[3],custCode:args[2][0].cust }); |
| | | openRvModal(true, { |
| | | rotId: args[2][0].id, |
| | | slotName: '', |
| | | prodCode: args[3], |
| | | custCode: args[2][0].cust, |
| | | }); |
| | | break; |
| | | } |
| | | }, |
| | |
| | | * @return {*} |
| | | */ |
| | | CustFunc: async (param: CustModalParams) => { |
| | | switch (param['ctype']) { |
| | | case 'BAS_PKG_DTL': |
| | | // const ents = await getEntity({ |
| | | // sqlcmd: `PKG_RULE_ID ='${param.values['PKG_RULE_ID']}'`, |
| | | // entityName: 'V_BAS_PKG_DTL', |
| | | // order: '', |
| | | // }); |
| | | // param.data.value['Table'] = ents.Data.Items; |
| | | param.data.value['BAS_PKG_DTL'].map((x) => { |
| | | if (x.PKG_CODE == param.values['PKG_CODE']) { |
| | | x.LABEL_CODE = param.values['LABEL_CODE']; |
| | | } |
| | | }); |
| | | param.data.value['Action'][0]['OPTION_1'] = JSON.stringify( |
| | | param.data.value['BAS_PKG_DTL'], |
| | | ); |
| | | break; |
| | | case 'ItemCode': |
| | | param.data.value['ItemCode'].map((x) => { |
| | | if (x.ITEM_CODE == param.values['ITEM_CODE']) { |
| | | x.IsBatchItem = param.values['IsBatchItem']; |
| | | x.RULE_CODE = param.values['RULE_CODE']; |
| | | } |
| | | }); |
| | | param.data.value['Action'][0]['OPTION_1'] = JSON.stringify( |
| | | param.data.value['ItemCode'], |
| | | ); |
| | | break; |
| | | } |
| | | return new Promise<any>(async (resolve, reject) => { |
| | | try { |
| | | switch (param['ctype']) { |
| | | case 'BAS_PKG_DTL': |
| | | // const ents = await getEntity({ |
| | | // sqlcmd: `PKG_RULE_ID ='${param.values['PKG_RULE_ID']}'`, |
| | | // entityName: 'V_BAS_PKG_DTL', |
| | | // order: '', |
| | | // }); |
| | | // param.data.value['Table'] = ents.Data.Items; |
| | | param.data.value['BAS_PKG_DTL'].map((x) => { |
| | | if (x.PKG_CODE == param.values['PKG_CODE']) { |
| | | x.LABEL_CODE = param.values['LABEL_CODE']; |
| | | x.LABEL_ID = param.values['LABEL_CODE']; |
| | | } |
| | | }); |
| | | param.data.value['Action'][0]['OPTION_1'] = JSON.stringify( |
| | | param.data.value['BAS_PKG_DTL'], |
| | | ); |
| | | resolve('OK'); |
| | | break; |
| | | case 'ItemCode': |
| | | param.data.value['ItemCode'].map((x) => { |
| | | if (x.ITEM_CODE == param.values['ITEM_CODE']) { |
| | | x.IsBatchItem = param.values['IsBatchItem']; |
| | | x.RULE_CODE = param.values['RULE_CODE']; |
| | | } |
| | | }); |
| | | param.data.value['Action'][0]['OPTION_1'] = JSON.stringify( |
| | | param.data.value['ItemCode'], |
| | | ); |
| | | resolve('OK'); |
| | | break; |
| | | case 'BAS_LABEL_VAR_WO': |
| | | param.values['WORK_ORDER'] = param.others['WORK_ORDER']; |
| | | param.values['ID'] = buildUUID(); |
| | | var action = await AddOrEditLabelVarByWorkOrder( |
| | | param.values as unknown as BAS_LABEL_VAR_WO, |
| | | ); |
| | | resolve(action); |
| | | case 'isDefault': |
| | | /* 设置默认工艺路线 */ |
| | | var action = await useProdRoute.setDefaulRoute(param); |
| | | resolve(action); |
| | | } |
| | | } catch (e) { |
| | | reject(e); |
| | | } |
| | | }); |
| | | }, |
| | | /** |
| | | * @description: 获取右键菜单列表 |
| | |
| | | // }, |
| | | // }; |
| | | // }, |
| | | }, |
| | | { |
| | | dataIndex: 'LABEL_ID', |
| | | title: '标签模板ID', |
| | | ifShow: false, |
| | | customRender: () => {}, |
| | | }, |
| | | ] as BasicColumn[]; |
| | | break; |
| | |
| | | { |
| | | field: 'LABEL_CODE', |
| | | label: '标签打印', |
| | | colProps: { span: 11 }, |
| | | colProps: { span: 9 }, |
| | | component: 'Input', |
| | | ifShow: ({ values }) => isPrint(values.ACT_TYPE), |
| | | }, |
| | |
| | | label: '1', |
| | | defaultValue: '', |
| | | component: 'Input', |
| | | colProps: { span: 1, pull: 1 }, |
| | | colProps: { span: 2 }, |
| | | ifShow: ({ values }) => isPrint(values.ACT_TYPE), |
| | | colSlot: 'printadd', |
| | | }, |
| | | { |
| | | field: 'print1', |
| | | label: '1', |
| | | defaultValue: '', |
| | | component: 'Input', |
| | | colProps: { span: 1, pull: window.screen.width == 1366 ? -1 : 1 }, |
| | | ifShow: ({ values }) => isPrint(values.ACT_TYPE), |
| | | colSlot: 'labeladd', |
| | | }, |
| | | { |
| | | field: 'PKG_CODE', |
| | |
| | | colProps: { span: 1, pull: 1 }, |
| | | ifShow: ({ values }) => isPackage(values.ACT_TYPE), |
| | | colSlot: 'pkgadd', |
| | | }, |
| | | { |
| | | field: 'OPTION_2', |
| | | label: '是否称重', |
| | | required: true, |
| | | component: 'Select', |
| | | colProps: { span: 12 }, |
| | | ifShow: ({ values }) => isPackage(values.ACT_TYPE), |
| | | componentProps: { |
| | | options: [ |
| | | { |
| | | label: '是', |
| | | value: 'Y', |
| | | key: 'Y', |
| | | }, |
| | | { |
| | | label: '否', |
| | | value: 'N', |
| | | key: 'N', |
| | | }, |
| | | ], |
| | | }, |
| | | }, |
| | | { |
| | | field: 'REMARK', |
| | |
| | | ] as FormSchema[], |
| | | }; |
| | | |
| | | /** |
| | | * @description: 模板维护 |
| | | * @param {*} args |
| | | * @param {Recordable} params |
| | | * @return {*} |
| | | */ |
| | | function handleTemplate(args, params: Recordable) { |
| | | const openCrudModal = args[0]; |
| | | // const OrderNo = args[2]; |
| | | const ProdCode = args[2]; |
| | | openCrudModal(true, { |
| | | isUpdate: true, //是否更新操作 |
| | | entityName: 'ProdRouteBinding', //是哪个页面 |
| | | ctype: 'BAS_LABEL_VAR_WO', //实体名称 |
| | | title: '模板维护', //标题 |
| | | width: '1024px', //弹出框宽度 |
| | | ItemColumns: TemplateBasColumn, //弹出框中表格字段结构 |
| | | schemas: [], //查询条件字段结构 |
| | | others: { WORK_ORDER: '', PROD_CODE: ProdCode }, //需要带到弹出窗口中的数据 |
| | | searchInfo: { |
| | | TABLE_NAME: 'BAS_LABEL_VAR_WO', //实体名称 |
| | | LabelId: params['record'].LABEL_ID, //模板ID |
| | | WorkOrder: '', //工单号 |
| | | ProdCode: ProdCode, |
| | | CustCode: '', |
| | | apiUrl: mesApi.GetLabelVarByWorkOrder, //自定义获取数据分页的api,不用默认的基础方法 |
| | | }, |
| | | values: params['record'], //表单记录 |
| | | }); |
| | | } |
| | | |
| | | /* 下发界面中的表单列表 */ |
| | | const TemplateBasColumn = [ |
| | | { |
| | | dataIndex: 'LABEL_ID', |
| | | title: '标签模板ID', |
| | | ifShow: false, |
| | | sorter: true, |
| | | resizable: true, |
| | | }, |
| | | { |
| | | title: '工单号', |
| | | dataIndex: 'WORK_ORDER', |
| | | width: 280, |
| | | editRow: true, |
| | | // editable: true, |
| | | ifShow: false, |
| | | }, |
| | | { |
| | | title: '变量名', |
| | | dataIndex: 'VAR_NAME', |
| | | }, |
| | | { |
| | | title: '变量值', |
| | | dataIndex: 'VAR_VALUE', |
| | | editRow: true, |
| | | editRule: true, |
| | | }, |
| | | { |
| | | title: '默认值', |
| | | dataIndex: 'DEFAULT_VALUE', |
| | | // editRow: true, |
| | | // editRule: true, |
| | | }, |
| | | ] as BasicColumn[]; |
| | | |
| | | return [methods]; |
| | | } |
| | | |