| | |
| | | * @version: |
| | | * @Date: 2024-06-19 20:34:27 |
| | | * @LastEditors: Ben Lin |
| | | * @LastEditTime: 2024-07-29 23:10:18 |
| | | * @LastEditTime: 2024-10-22 11:40:44 |
| | | */ |
| | | |
| | | import { Tag, Tooltip } from 'ant-design-vue'; |
| | | import { ActionItem, BasicColumn, FormSchema, useTable } from '/@/components/Table'; |
| | | import { useI18n } from '/@/hooks/web/useI18n'; |
| | | import { h, Ref, unref } from 'vue'; |
| | | import { h, ref, Ref, unref } from 'vue'; |
| | | import { AddAfterDelete, getEntity, GetEnum } from '/@/api/tigerapi/system'; |
| | | import { useLocale } from '/@/locales/useLocale'; |
| | | import { useDrawer } from '/@/components/Drawer'; |
| | | import { formatTime } from '/@/utils/dateUtil'; |
| | | import { custDel, EditOperation, Search } from '../data'; |
| | | import { buildUUID } from '/@/utils/uuid'; |
| | | import { CustModalParams, FunctionType } from '/@/api/tigerapi/model/systemModel'; |
| | | import { useModal } from '/@/components/Modal'; |
| | | import { SaveLabelTemplate } from '/@/api/tigerapi/mes/label'; |
| | | import { BAS_LABEL_TEMP, BAS_LABEL_VAR, BAS_LABEL_VAR_WO, BasLabelTempInput } from '/@/api/tigerapi/model/mesModel'; |
| | | import { |
| | | BAS_LABEL_TEMP, |
| | | BAS_LABEL_VAR, |
| | | BAS_LABEL_VAR_WO, |
| | | BasLabelTempInput, |
| | | } from '/@/api/tigerapi/model/mesModel'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | import { cloneDeep } from 'lodash-es'; |
| | | |
| | | const { getLocale } = useLocale(); |
| | | |
| | | const { t } = useI18n(); |
| | | |
| | | let newRow = {}; |
| | | function _default() { |
| | | const ActionColumn: BasicColumn = { |
| | | width: 80, |
| | |
| | | * @description: 高级表单和详情页面返回主页面的url |
| | | * @return {*} |
| | | */ |
| | | GetHomeUrl: () => { |
| | | return `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: [], crudColSlots: [] }))}`; |
| | | GetHomeUrl: (params: {}) => { |
| | | return `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: params['colSlots'], crudColSlots: [] }))}`; |
| | | }, |
| | | /** |
| | | * @description: 获取主信息 |
| | | * @return {*} |
| | | */ |
| | | GetBaseForm: () => { |
| | | GetBaseForm: (type, ...args) => { |
| | | return [ |
| | | { |
| | | field: 'LABEL_CODE', |
| | |
| | | colProps: { |
| | | span: 8, |
| | | }, |
| | | dynamicDisabled: true, |
| | | }, |
| | | { |
| | | label: '标签模板名称', |
| | |
| | | valueField: 'Value', |
| | | }, |
| | | }, |
| | | { |
| | | field: 'TEMP_PATH', |
| | | label: '标签模板相对路径', |
| | | component: 'Upload', |
| | | isexist: 'N', |
| | | show: true, |
| | | required: true, |
| | | colProps: { |
| | | span: 8, |
| | | }, |
| | | }, |
| | | // { |
| | | // field: 'TEMP_PATH', |
| | | // label: '标签模板相对路径', |
| | | // component: 'Upload', |
| | | // isexist: 'N', |
| | | // show: true, |
| | | // required: true, |
| | | // colProps: { |
| | | // span: 8, |
| | | // }, |
| | | // componentProps: ({ formModel }) => { |
| | | // return { |
| | | // resultField: 'data3.url', |
| | | // multiple: false, |
| | | // uploadParams: { entityName: type }, |
| | | // api: (file, progress) => { |
| | | // console.log(formModel); |
| | | // return new Promise((resolve) => { |
| | | // uploadApi(file, progress).then((uploadApiResponse) => { |
| | | // const webSocketStore = useWebSocketStore(); |
| | | // if (webSocketStore.GetSocketState == 1) { |
| | | // webSocketStore.sendMessage( |
| | | // `wsSubStrings ${formModel['ID']}_#_${uploadApiResponse.data.url}`, |
| | | // ); |
| | | // } |
| | | // resolve({ |
| | | // code: 200, |
| | | // data3: { |
| | | // url: uploadApiResponse.data.url, |
| | | // }, |
| | | // }); |
| | | // }); |
| | | // }); |
| | | // }, |
| | | // }; |
| | | // }, |
| | | // }, |
| | | { |
| | | field: 'PROD_CODE', |
| | | label: '产品编码', |
| | | component: 'Input', |
| | | isexist: 'N', |
| | | show: true, |
| | | required: true, |
| | | // required: true, |
| | | colProps: { |
| | | span: 7, |
| | | }, |
| | |
| | | field: 'REMARK', |
| | | component: 'Input', |
| | | colProps: { |
| | | span: 24, |
| | | span: 8, |
| | | }, |
| | | }, |
| | | { |
| | | label: '标签模板相对路径', |
| | | field: 'TEMP_PATH', |
| | | required: true, |
| | | component: 'Input', |
| | | colProps: { |
| | | span: 16, |
| | | }, |
| | | }, |
| | | { |
| | |
| | | GetNewRow: (type: string) => { |
| | | let values = {}; |
| | | switch (type) { |
| | | case 'BAS_LABEL_VAR_WO': |
| | | case 'BAS_LABEL_VAR': |
| | | values = { |
| | | ID: buildUUID(), |
| | | LABEL_ID: '', |
| | | VAR_NAME: '', |
| | | VAR_TYPE: '', |
| | | VAR_VALUE: '', |
| | | BARCODE_RULE: '', |
| | | REMARK: '', |
| | | }; |
| | | break; |
| | | case 'BAS_LABEL_VAR_WO': |
| | | values = newRow; |
| | | break; |
| | | } |
| | | return values; |
| | |
| | | GetBaseCards: (type: string) => { |
| | | return [ |
| | | { |
| | | name: 'BaseForm', |
| | | name: 'BaseForm', //第一个卡片名称必需是BaseForm |
| | | slots: [], |
| | | preIcons: {}, |
| | | title: '模板信息', |
| | |
| | | { |
| | | BAS_LABEL_VAR: useDrawer(), |
| | | }, |
| | | { BAS_LABEL_VAR_WO: useDrawer() }, |
| | | // { BAS_LABEL_VAR_WO: useDrawer() }, |
| | | ]; |
| | | } /** |
| | | }, |
| | | /** |
| | | * @description: 获取表格use列表 |
| | | * @param {string} type |
| | | * @param {array} args |
| | | * @return {*} |
| | | */, |
| | | */ |
| | | GetUseTables: (data: Ref<{}>, ...args) => { |
| | | // _data = data; |
| | | return { |
| | | BAS_LABEL_VAR: useTable({ |
| | | title: '列表信息', |
| | | dataSource: data.value['BAS_LABEL_VAR'], |
| | | columns: GetBaseColumns('BAS_LABEL_VAR', args[0]), |
| | | columns: GetBaseColumns('BAS_LABEL_VAR', args[0], data), |
| | | maxHeight: 520, |
| | | formConfig: { |
| | | labelWidth: 140, |
| | |
| | | // rowSelection: { |
| | | // type: 'radio', //'checkbox' |
| | | // }, |
| | | // actionColumn: { |
| | | // width: 130, |
| | | // title: '操作', |
| | | // dataIndex: 'action', |
| | | // slots: { customRender: 'action' }, |
| | | // fixed: 'right', |
| | | // }, //自定义操作列 |
| | | actionColumn: { |
| | | width: 130, |
| | | title: '操作', |
| | | dataIndex: 'action', |
| | | slots: { customRender: 'action' }, |
| | | fixed: 'right', |
| | | }, //自定义操作列 |
| | | }), |
| | | BAS_LABEL_VAR_WO: useTable({ |
| | | title: '列表信息', |
| | | dataSource: data.value['BAS_LABEL_VAR_WO'], |
| | | columns: baseColumns['BAS_LABEL_VAR_WO'], |
| | | maxHeight: 550, |
| | | columns: GetBaseColumns('BAS_LABEL_VAR_WO', args[0], data), |
| | | scroll: { y: 500 }, |
| | | formConfig: { |
| | | labelWidth: 140, |
| | | schemas: searchForms['BAS_LABEL_VAR_WO'], |
| | |
| | | }, //自定义操作列 |
| | | }), |
| | | }; |
| | | }, |
| | | /** |
| | | * @description: 自定义初始化方法 |
| | | * @param {Ref} data |
| | | * @param {Ref} keyFieldValues |
| | | * @param {string} type |
| | | * @param {any} useTables |
| | | * @return {*} |
| | | */ |
| | | CustInitData: (data: Ref<any[]>, keyFieldValues: Ref<{}>, type: string, useTables: any) => { |
| | | if (type == 'BAS_LABEL_VAR_WO') { |
| | | if (data.value['BAS_LABEL_VAR_WO'].length > 0) { |
| | | /* 初始化数据,行转列 */ |
| | | let varwos: any[] = []; |
| | | const map = new Map<string, any>(); |
| | | data.value['BAS_LABEL_VAR_WO'].map((curr) => { |
| | | if (!map.has(curr.WORK_ORDER)) { |
| | | const newObj = {}; |
| | | newObj['WORK_ORDER'] = curr.WORK_ORDER; |
| | | map.set(curr.WORK_ORDER, newObj); |
| | | } |
| | | const acc = map.get(curr.WORK_ORDER); |
| | | Object.keys(curr).forEach((key) => { |
| | | if (key != 'VAR_NAME' && key != 'VAR_VALUE') { |
| | | acc[key] = curr[key]; |
| | | } else if (key == 'VAR_NAME') { |
| | | acc[`DEFAULT_VALUE_${curr.VAR_NAME}`] = curr.DEFAULT_VALUE; |
| | | acc[`VAR_N_${curr.VAR_NAME}`] = curr.VAR_VALUE; |
| | | } |
| | | }); |
| | | // varwos.push(acc); |
| | | }); |
| | | map.forEach((x) => { |
| | | varwos.push(x); |
| | | }); |
| | | data.value['BAS_LABEL_VAR_WO'] = varwos; |
| | | } |
| | | useTables[type][1].setProps({ |
| | | dataSource: data.value['BAS_LABEL_VAR_WO'], |
| | | columns: GetBaseColumns('BAS_LABEL_VAR_WO', null, data), |
| | | scroll: { y: 500 }, |
| | | useSearchForm: false, |
| | | showTableSetting: false, |
| | | bordered: true, |
| | | canResize: true, |
| | | showIndexColumn: false, |
| | | actionColumn: { |
| | | width: 130, |
| | | title: '操作', |
| | | dataIndex: 'action', |
| | | slots: { customRender: 'action' }, |
| | | fixed: 'right', |
| | | }, |
| | | }); |
| | | useTables[type][1].reload(); |
| | | } |
| | | }, |
| | | /** |
| | | * @description: 提交所有 |
| | |
| | | LABEL_CODE: label.LABEL_CODE, |
| | | LABEL_NAME: label.LABEL_NAME, |
| | | TEMP_TYPE: label.TEMP_TYPE, |
| | | TEMP_PATH: label.TEMP_PATH[0], |
| | | TEMP_PATH: label.TEMP_PATH, |
| | | CUST_CODE: label.CUST_CODE, |
| | | PROD_CODE: label.PROD_CODE, |
| | | REMARK: '' |
| | | REMARK: '', |
| | | } as unknown as BAS_LABEL_TEMP, |
| | | LabelVars: {} as unknown as BAS_LABEL_VAR[], |
| | | LabelVarWos: {} as unknown as BAS_LABEL_VAR_WO[], |
| | | LabelVars: [] as unknown as BAS_LABEL_VAR[], |
| | | LabelVarWos: [] as unknown as BAS_LABEL_VAR_WO[], |
| | | }; |
| | | drawers.forEach((d) => { |
| | | let where = `${d['code']} = '${keyFieldValues.value[d['code']]}'`; |
| | |
| | | data.value[d['name']].map((item) => { |
| | | item.ID = buildUUID(); |
| | | }); |
| | | if(d.name == 'BAS_LABEL_VAR'){ |
| | | input.LabelVars = data.value[d['name']]; |
| | | if (d.name == 'BAS_LABEL_VAR') { |
| | | input.LabelVars = data.value[d['name']]; |
| | | } |
| | | if(d.name == 'BAS_LABEL_VAR_WO'){ |
| | | input.LabelVarWos = data.value[d['name']]; |
| | | if (d.name == 'BAS_LABEL_VAR_WO') { |
| | | let varwos: any[] = []; |
| | | data.value[d['name']].map((curr) => { |
| | | const vKeys: any[] = []; |
| | | Object.keys(curr).forEach((key) => { |
| | | if (key.startsWith('VAR_N_')) { |
| | | vKeys.push(key); |
| | | } |
| | | // if (key.startsWith('VAR_N_')) { |
| | | // acc['VAR_NAME'] = key.replace('VAR_N_', ''); |
| | | // acc['VAR_VALUE'] = curr[key]; |
| | | // } else if (key.startsWith('DEFAULT_VALUE_')) { |
| | | // acc['DEFAULT_VALUE'] = curr[key]; acc[key] = curr[key]; |
| | | // } |
| | | }); |
| | | vKeys.forEach((k) => { |
| | | let acc = {}; |
| | | Object.keys(curr).forEach((key) => { |
| | | if (key == k) { |
| | | acc['VAR_NAME'] = key.replace('VAR_N_', ''); |
| | | acc['VAR_VALUE'] = curr[key]; |
| | | } else if (key == `DEFAULT_VALUE_${k.replace('VAR_N_', '')}`) { |
| | | acc['DEFAULT_VALUE'] = curr[key]; |
| | | } else if ( |
| | | !key.startsWith('VAR_N_') && |
| | | !key.startsWith('DEFAULT_VALUE_') && |
| | | key != 'DEFAULT_VALUE' |
| | | ) { |
| | | acc[key] = curr[key]; |
| | | } |
| | | }); |
| | | acc['ID'] = buildUUID(); |
| | | varwos.push(acc); |
| | | }); |
| | | }); |
| | | input.LabelVarWos = varwos; |
| | | } |
| | | }); |
| | | SaveLabelTemplate(input).then((action) => { |
| | |
| | | // break; |
| | | } |
| | | }, |
| | | /** |
| | | * @description: 编辑单元格完成后自定义方法 |
| | | * @param {Recordable} param1 |
| | | * @param {*} type |
| | | * @param {any} useTables |
| | | * @return {*} |
| | | */ |
| | | CustEditEnd: ({ record, index, key, value }: Recordable, type, ...args) => { |
| | | console.log(key, value); |
| | | const useTables = args[0]; |
| | | const data = args[1]; |
| | | let varWodata: any[] = []; |
| | | if ( |
| | | (record['VAR_TYPE'] == 1 && record['VAR_VALUE'] != 'PV-WorkOrder-Plan') || |
| | | record['VAR_TYPE'] != 1 |
| | | ) { |
| | | data.value['BAS_LABEL_VAR_WO'].forEach((x) => { |
| | | let acc: any = {}; |
| | | Object.keys(x).map((key) => { |
| | | if (key != `VAR_N_${record['VAR_NAME']}`) { |
| | | acc[key] = x[key]; |
| | | } |
| | | }); |
| | | varWodata.push(acc); |
| | | }); |
| | | data.value['BAS_LABEL_VAR_WO'] = varWodata; |
| | | } else { |
| | | varWodata = data.value['BAS_LABEL_VAR_WO']; |
| | | } |
| | | switch (type) { |
| | | case 'BAS_LABEL_VAR': |
| | | useTables['BAS_LABEL_VAR_WO'][1].setProps({ |
| | | dataSource: varWodata, |
| | | columns: GetBaseColumns('BAS_LABEL_VAR_WO', null, data), |
| | | scroll: { y: 500 }, |
| | | useSearchForm: false, |
| | | showTableSetting: false, |
| | | bordered: true, |
| | | canResize: true, |
| | | showIndexColumn: false, |
| | | actionColumn: { |
| | | width: 130, |
| | | title: '操作', |
| | | dataIndex: 'action', |
| | | slots: { customRender: 'action' }, |
| | | fixed: 'right', |
| | | }, |
| | | }); |
| | | useTables['BAS_LABEL_VAR_WO'][1].reload(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }, |
| | | }; |
| | | |
| | | /* 以下是内部方法,不export */ |
| | |
| | | } |
| | | }); |
| | | }, |
| | | /** |
| | | * @desc 保存方法 |
| | | */ |
| | | SaveRow: (param: CustModalParams) => { |
| | | return new Promise((resolve, reject) => { |
| | | try { |
| | | param.data.value[param.cType] = param.data.value[param.cType].map((d) => { |
| | | if (d.ID == param.values['ID']) { |
| | | d.VAR_NAME = param.values['VAR_NAME']; |
| | | d.VAR_TYPE = param.values['VAR_TYPE']; |
| | | d.VAR_VALUE = param.values['VAR_VALUE']; |
| | | d.BARCODE_RULE = param.values['BARCODE_RULE']; |
| | | d.REMARK = param.values['REMARK']; |
| | | } |
| | | return d; |
| | | }); |
| | | } catch { |
| | | reject(false); |
| | | } |
| | | }); |
| | | }, |
| | | }; |
| | | |
| | | let columns: BasicColumn[] = []; |
| | |
| | | * @param {string} type |
| | | * @return {*} |
| | | */ |
| | | function GetBaseColumns(type: string, emit) { |
| | | function GetBaseColumns(type: string, emit, data: Ref<{}>) { |
| | | columns = [ |
| | | { |
| | | dataIndex: 'LABEL_ID', |
| | |
| | | title: '变量名称', |
| | | ifShow: true, |
| | | sorter: true, |
| | | editRow: true, |
| | | resizable: true, |
| | | customRender: () => {}, |
| | | }, |
| | | { |
| | | dataIndex: 'VAR_TYPE', |
| | | title: '变量类型', |
| | | edit: true, |
| | | editRow: true, |
| | | editRule: true, |
| | | ifShow: true, |
| | | sorter: true, |
| | |
| | | labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name', |
| | | valueField: 'Value', |
| | | onChange: (e, v) => { |
| | | if (e == 1) { |
| | | if (e == 1 || e == 4) { |
| | | const where = |
| | | e == 1 |
| | | ? { TABLE_NAME: 'BAS_LABEL_PV', VAR_TYPE: 0 } |
| | | : { TABLE_NAME: 'BAS_LABEL_PV', VAR_TYPE: 1 }; |
| | | emit('opencust', { |
| | | data: column.record, |
| | | name: 'BAS_LABEL_VAR', |
| | |
| | | ], |
| | | tableName: 'BAS_LABEL_PV', |
| | | rowKey: 'VAR_CODE', |
| | | searchInfo: { TABLE_NAME: 'BAS_LABEL_PV' }, |
| | | searchInfo: where, |
| | | }, |
| | | }); |
| | | } |
| | |
| | | text = '自定义变量'; |
| | | color = '#bfbfbf'; |
| | | break; |
| | | case 4: |
| | | text = '条码生成'; |
| | | color = '#b442df'; |
| | | break; |
| | | } |
| | | return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text)); |
| | | }, |
| | |
| | | { |
| | | dataIndex: 'VAR_VALUE', |
| | | title: '变量值', |
| | | edit: true, |
| | | editRow: true, |
| | | // editable: true, |
| | | editRule: true, |
| | | ifShow: (column) => true, |
| | |
| | | resizable: true, |
| | | }, |
| | | { |
| | | dataIndex: 'BARCODE_RULE', |
| | | title: '条码生成规则', |
| | | ifShow: true, |
| | | editRow: true, |
| | | editRule: true, |
| | | sorter: true, |
| | | resizable: true, |
| | | editComponent: 'ApiSelect', |
| | | editComponentProps: (column) => { |
| | | return { |
| | | api: getEntity, |
| | | params: { entityName: 'BAS_CODE_RULE', sqlcmd: ' 1=1 ' }, |
| | | resultField: 'Data.Items', |
| | | labelField: 'RULE_NAME', |
| | | valueField: 'RULE_CODE', |
| | | }; |
| | | }, |
| | | }, |
| | | { |
| | | dataIndex: 'REMARK', |
| | | title: '备注', |
| | | ifShow: true, |
| | | editRow: true, |
| | | sorter: true, |
| | | resizable: true, |
| | | }, |
| | | ], |
| | | ] as BasicColumn[]; |
| | | break; |
| | | case 'BAS_LABEL_VAR_WO': |
| | | const _columns = [ |
| | | { |
| | | dataIndex: 'LABEL_ID', |
| | | title: '标签模板ID', |
| | | ifShow: false, |
| | | sorter: true, |
| | | resizable: true, |
| | | }, |
| | | { |
| | | title: '工单号', |
| | | dataIndex: 'WORK_ORDER', |
| | | width: 280, |
| | | edit: true, |
| | | editRule: true, |
| | | // editable: true, |
| | | ifShow: true, |
| | | }, |
| | | ] as BasicColumn[]; |
| | | newRow = { |
| | | ID: buildUUID(), |
| | | LABEL_ID: |
| | | data.value['BAS_LABEL_VAR'].length > 0 ? data.value['BAS_LABEL_VAR'][0].LABEL_ID : '', |
| | | WORK_ORDER: '', |
| | | }; |
| | | data.value['BAS_LABEL_VAR'].map((x) => { |
| | | if (x.VAR_TYPE == 1 && x.VAR_VALUE == 'PV-WorkOrder-Plan') { |
| | | newRow[`${x.VAR_NAME}_DEFAULT_VALUE`] = ''; |
| | | newRow[x.VAR_NAME] = ''; |
| | | _columns.push( |
| | | { |
| | | title: `(变量)${x.VAR_NAME}默认值`, |
| | | dataIndex: `DEFAULT_VALUE_${x.VAR_NAME}`, |
| | | width: 280, |
| | | // edit: true, |
| | | // editRule: true, |
| | | resizable: true, |
| | | ifShow: true, |
| | | }, |
| | | { |
| | | title: `(变量)${x.VAR_NAME}`, |
| | | dataIndex: `VAR_N_${x.VAR_NAME}`, |
| | | width: 280, |
| | | edit: true, |
| | | editRule: true, |
| | | resizable: true, |
| | | ifShow: true, |
| | | }, |
| | | ); |
| | | } |
| | | }); |
| | | _columns.push({ |
| | | title: `备注`, |
| | | dataIndex: 'REMARK', |
| | | width: 280, |
| | | edit: true, |
| | | editRule: true, |
| | | resizable: true, |
| | | ifShow: true, |
| | | }); |
| | | columns = _columns; |
| | | break; |
| | | } |
| | | return columns; |
| | |
| | | dataIndex: 'WORK_ORDER', |
| | | edit: true, |
| | | editRule: true, |
| | | editable: true, |
| | | // editable: true, |
| | | ifShow: true, |
| | | }, |
| | | { |
| | |
| | | title: '变量名称', |
| | | edit: true, |
| | | editRule: true, |
| | | editable: true, |
| | | // editable: true, |
| | | ifShow: true, |
| | | sorter: true, |
| | | resizable: true, |
| | |
| | | title: '变量值', |
| | | edit: true, |
| | | editRule: true, |
| | | editable: true, |
| | | // editable: true, |
| | | ifShow: true, |
| | | sorter: true, |
| | | resizable: true, |