| | |
| | | * @version: |
| | | * @Date: 2024-06-19 20:34:27 |
| | | * @LastEditors: Ben Lin |
| | | * @LastEditTime: 2024-06-26 21:49:44 |
| | | * @LastEditTime: 2024-06-27 15:49:17 |
| | | */ |
| | | |
| | | import { Ref, ref, unref } from 'vue'; |
| | | import { GetRoutePTree } from '/@/api/tigerapi/mes/router'; |
| | | import { GetRoutePTree, RouteToCust, RouteToProd } from '/@/api/tigerapi/mes/router'; |
| | | import { GetEnum, convertToTree, getEntity } from '/@/api/tigerapi/system'; |
| | | import { useLocale } from '/@/locales/useLocale'; |
| | | import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; |
| | | import { useI18n } from '/@/hooks/web/useI18n'; |
| | | import { NavItem } from '/@/api/tigerapi/model/basModel'; |
| | | import { useMessage } from '/@/hooks/web/useMessage'; |
| | | import { useModal } from '/@/components/Modal'; |
| | | import { V_MES_ROUTE_PTREE } from '/@/api/tigerapi/model/router'; |
| | | |
| | | const { t } = useI18n(); |
| | | const { createErrorModal } = useMessage(); |
| | | const { getLocale } = useLocale(); |
| | | function _default() { |
| | | const isNormal = (type: number) => type === 0; |
| | |
| | | fetchTreeData: async (type: string, itemCode: string) => { |
| | | let data = { title: '', treeData: [] as any[], fieldNames: {} }; |
| | | let prodTreeData = await GetRoutePTree(itemCode); |
| | | data.treeData = convertToTree(prodTreeData, 'pid', 'id', 'root'); |
| | | // 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'); |
| | | data.title = '工艺路线'; |
| | | data.fieldNames = { key: 'id', title: 'name' }; |
| | | data.fieldNames = { key: 'tid', title: 'name' }; |
| | | return data; |
| | | }, |
| | | GetCrudForm: () => { |
| | |
| | | value = { |
| | | pkgRULE_CODE: d.values['val'], |
| | | }; |
| | | case 'addRoute': |
| | | if (isNullOrEmpty(args[1]['CODE'])) { |
| | | createErrorModal({ |
| | | title: t('sys.api.errorTip'), |
| | | content: '产品为空,不能添加工艺路线,请点击左侧选择产品', |
| | | }); |
| | | return; |
| | | } |
| | | let codes = d.values.id.split(','); |
| | | var i; |
| | | for (i = 0; i < codes.length; i++) { |
| | | if (d.which == 'addRoute') { |
| | | RouteToProd({ rotId: codes[i], prodCode: args[1]['CODE'] }); |
| | | } else { |
| | | RouteToCust({ rotId: codes[i], prodCode: args[1]['CODE'], custCode: '' }); |
| | | } |
| | | } |
| | | |
| | | args[2](); |
| | | break; |
| | | case 'addCustomer': |
| | | if (isNullOrEmpty(args[1]['CODE'])) { |
| | | createErrorModal({ |
| | | title: t('sys.api.errorTip'), |
| | | content: '产品为空,不能添加工艺路线,请点击左侧选择产品', |
| | | }); |
| | | return; |
| | | } |
| | | let rotIds = d.ROT_ID.split(','); |
| | | var i; |
| | | for (i = 0; i < rotIds.length; i++) { |
| | | RouteToCust({ rotId: rotIds[i], prodCode: args[1]['CODE'], custCode: d.CUST_CODE }); |
| | | } |
| | | |
| | | args[2](); |
| | | break; |
| | | } |
| | | return value; |
| | | }, |
| | | /** |
| | | * @description: 获取模态框应用列表 |
| | | * @return {*} |
| | | */ |
| | | GetUseModals: () => { |
| | | return { |
| | | addRoute: useModal(), |
| | | addCustomer: useModal(), |
| | | }; |
| | | }, |
| | | /** |
| | | * @description: 获取标题信息 |
| | |
| | | color: '#1fdaca', |
| | | url: '/addRoute', |
| | | action: 'addRoute', |
| | | isStep: false, |
| | | }, |
| | | { |
| | | title: '添加客户工艺路线', |
| | |
| | | color: '#bf0c2c', |
| | | url: '/addCustomer', |
| | | action: 'addCustomer', |
| | | isStep: true, |
| | | }, |
| | | ] as NavItem[]; |
| | | }, |
| | |
| | | * @param {any} action |
| | | * @return {*} |
| | | */ |
| | | naveChangeItem: (action: any, ...args) => { |
| | | navChangeItem: (action: any, ...args) => { |
| | | switch (action) { |
| | | case 'addRoute': |
| | | args[0](true, { |
| | | title: '工艺路线列表', |
| | | schemas: [ |
| | |
| | | searchInfo: { TABLE_NAME: 'MES_ROUTE' }, |
| | | which: action, |
| | | }); |
| | | break; |
| | | case 'addCustomer': |
| | | args[0](true, { |
| | | title: '请完成以下步骤', |
| | | }); |
| | | break; |
| | | } |
| | | }, |
| | | }; |
| | | |