From a42c6f16bbb177dfcc754d53d925afddead38eba Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 12 十一月 2024 22:51:26 +0800 Subject: [PATCH] 包装规则中查询更新,判断存在更新 --- src/views/tigerprojects/system/lowcode/high/dtl.vue | 27 src/layouts/default/menu/index.vue | 2 src/views/tigerprojects/system/lowcode/entityts/TestDemo.ts | 1937 +++++++++++++++++++++++++++++++++++++++++ src/views/tigerprojects/system/lowcode/composition/mainTable.vue | 549 +++++++++++ src/views/tigerprojects/wms/createqrcode/index.vue | 22 src/views/tigerprojects/system/lowcode/composition/LeftTable.vue | 203 ++++ src/store/modules/websocket.ts | 40 src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts | 4 8 files changed, 2,764 insertions(+), 20 deletions(-) diff --git a/src/layouts/default/menu/index.vue b/src/layouts/default/menu/index.vue index 0eaaf6f..b0f37b2 100644 --- a/src/layouts/default/menu/index.vue +++ b/src/layouts/default/menu/index.vue @@ -140,7 +140,7 @@ (path.split('/').length > 2 && path.split('/')[2] == 'High') || path.split('/')[2] == 'CP' ) { - const id = { Name: path.split('/')[1] }; + const id = { Name: path.split('/')[1], Title: `${path.split('/')[1]}`,}; go(`/${path.split('/')[1]}/${path.split('/')[2]}/${encodeURI(JSON.stringify(id))}`); } else { go(path); diff --git a/src/store/modules/websocket.ts b/src/store/modules/websocket.ts index 9155521..5930bd7 100644 --- a/src/store/modules/websocket.ts +++ b/src/store/modules/websocket.ts @@ -19,6 +19,8 @@ socketError: number; heartTime: any; HeartTimeOut: number; + printTag: string; + printJson: string; } export const useWebSocketStore = defineStore({ @@ -33,6 +35,8 @@ socketError: 0, heartTime: null, HeartTimeOut: 30000, + printTag: '', + printJson: '' }), getters: { GetSocket(state) { @@ -43,6 +47,12 @@ }, GetSocketState(state) { return state.readyState; + }, + GetPrintTag(state) { + return state.printTag; + }, + GetPrintJson(state) { + return state.printJson; }, }, actions: { @@ -60,13 +70,21 @@ // 鐩戝惉娑堟伅浜嬩欢 this.socket.onmessage = (event) => { console.log(event.data, 'event2'); - const message = JSON.parse(event.data); - if (message.Data == 'heartbeat') { - this.resetHeart(); - console.log('蹇冭烦'); - } else { - console.log('WebSocket娑堟伅: ', message); - this.SetMessage(message); + const d = JSON.parse(event.data); + switch (d.Data) { + case 'heartbeat': + this.resetHeart(); + console.log('蹇冭烦'); + break; + case 'PrintJS': + const json = JSON.parse(d.Message) + this.SetPrintTag(json.Tag); + this.SetPrintJson(json.Message); + break; + default: + console.log('WebSocket娑堟伅: ', d.Message); + this.SetMessage(d.Message); + break; } }; @@ -91,6 +109,12 @@ }, SetMessage(message: string) { this.socketMessage = message; + }, + SetPrintTag(tag: string) { + this.printTag = tag; + }, + SetPrintJson(json: string) { + this.printJson = json; }, SetSocket(socket: WebSocket) { this.socket = socket; @@ -120,7 +144,7 @@ 'wsApply ' + JSON.stringify({ Data: 'ping', - Message: 'BS绔績璺冲彂閫�' + Message: 'BS绔績璺冲彂閫�', }), ); this.socketHeart = this.socketHeart + 1; diff --git a/src/views/tigerprojects/system/lowcode/composition/LeftTable.vue b/src/views/tigerprojects/system/lowcode/composition/LeftTable.vue new file mode 100644 index 0000000..03f5acd --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/composition/LeftTable.vue @@ -0,0 +1,203 @@ +<!-- + * @Description: 閫氱敤缁勫悎椤甸潰锛屽乏杈规槸琛ㄦ牸锛屽彸杈规槸鑷畾涔� + * @Author: Ben Lin + * @version: + * @Date: 2024-06-18 23:30:30 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-10-21 23:03:27 +--> +<template> + <div> + <Suspense class="w-1/4 xl:w-1/5"> + <mainTable /> + </Suspense> + <Suspense> + <div class="w-3/4 xl:w-4/5 p-5"> + <CarGridNav v-if="showNav" :configType="configType" :nodes="nodes"> + <template #[item] v-for="item in otherSlots" :key="item"> + <!-- 鑷畾涔夊唴瀹� --> + <div class="h-full" style="height: 400px"> + <FlowChartView :data="routeData" @init="init" /> + </div> + </template> + </CarGridNav> + <Config + v-if="showConfig" + :configType="configType" + :OtherTableName="OtherTableName" + @success="configSuccess" + /> + </div> + </Suspense> + <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> + <!-- 鑷畾涔夊唴瀹� --> + </template> + </CustModal> + </Suspense> + </div> +</template> +<script lang="ts" setup> + import { useModal } from '@/components/Modal'; + import GeneralModal from '/@/views/components/GeneralModal.vue'; + import CarGridNav from './CarGridNav.vue'; + import Config from './Config.vue'; + import mainTable from './mainTable.vue'; + import CustModal from '/@/views/components/CustModal.vue'; + import { OpenCustModal, initRoute } from '../data'; + import { Ref, onMounted, provide, ref } from 'vue'; + import { FlowChartView } from '/@/components/FlowChart'; + import { useRoute } from 'vue-router'; + import { BasicForm } from '/@/components/Form/index'; + import { useTabs } from '/@/hooks/web/useTabs'; + import { useMessage } from '/@/hooks/web/useMessage'; + import LogicFlow from '@logicflow/core'; + + defineOptions({ name: '宸ュ崟宸ヨ壓缁戝畾' }); + + const { notification } = useMessage(); + const route = useRoute(); + const { setTitle } = useTabs(); + // const objParams = ref(JSON.parse(decodeURI(route.params?.id as string))); //ref(JSON.parse(history.state.obj)) + const routeParams = ref(JSON.parse(decodeURI(route.params?.id as string))); + // 浠巗essionStorage涓鍙栧弬鏁板苟杞崲鍥炲璞� + const savedParams = sessionStorage.getItem(`${routeParams.value.sName}_params`); + const objParams = savedParams ? ref(JSON.parse(decodeURI(savedParams))) : ref({}); + const entityName = ref(routeParams.value.Name); + const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 + const useFormData = ref({}); + const cType = ref(''); + const dtlSlots = ref([] as any[]); + const otherSlots = ref<any[]>([]); + const selectVals = ref({}); + const isMounted = ref(false); + const showNav = ref(false); + const showConfig = ref(false); + const configType = ref(''); + const OtherTableName = ref(''); + const nodes = ref([]); + const routeData = ref({ + nodes: [], + edges: [], + }); + const keyFieldValues = ref<any>(null); + const custImport = ref<any>(null); + const [registerCust] = useModal(); + provide<Ref<any>>('objParams', objParams); + provide<Ref<any>>('selectedNodes', nodes); + setTitle(objParams.value.Title); //璁剧疆鏍囩椤垫爣棰� + + + // function handleAdd(){ + // console.log('handleAdd'); + // } + + onMounted(async () => { + isMounted.value = false; + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + custImport.value = await import(`../entityts/${entityName.value}.ts`); + if (custImport.value['default']) { + otherSlots.value = custImport.value['default']()[0]['GetSlots'](); + } + isMounted.value = true; + } catch (e) { + console.log(e); + } + }); + + const currlf = ref(null) as Ref<LogicFlow | null>; + /** + * @description: 宸ヨ壓璺嚎鍒濆鍖栵紝鐗规畩椤甸潰鑷畾涔夊唴瀹� + * @param {*} lf + * @return {*} + */ + async function init(lf, rotId) { + initRoute(lf, rotId, routeData, currlf, objParams.value.rotType); + } + + + + /** + * @description: 淇濆瓨閰嶇疆鎴愬姛杩斿洖鏂规硶 + * @return {*} + */ + function configSuccess() { + notification.success({ message: '鎴愬姛淇濆瓨琛屼负閰嶇疆鏁版嵁' }); + } + + /** + * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥� + * @param {*} d + * @return {*} + */ + function custSuccess(d) { + // reload(); + } + + /** + * @description: 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ + function handleEntSuccess(d, u, item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import(`../entityts/${cType.value}.ts`).then((m) => { + const [{ GetSelectSuccess }] = m.default(); + var values = GetSelectSuccess(d, u); + selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� + let _val = {}; + d.returnFieldName.map((x) => { + _val[x] = values[x]; + }); + useFormData.value[item][1].setFieldsValue(_val); + }); + } catch (e) {} + } + + /** + * @description: 鎵撳紑鑷畾涔夋ā鎬佹 + * @param {*} item + * @return {*} + */ + function handleCustClick(item) { + OpenCustModal( + useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶 + cType.value, + item, + [], + // selectVals.value['ROUTE_CODE'], + ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹� + } +</script> +<style lang="less"> +.vben-page-wrapper .vben-page-wrapper-content { + margin: 1px; +} +</style> diff --git a/src/views/tigerprojects/system/lowcode/composition/mainTable.vue b/src/views/tigerprojects/system/lowcode/composition/mainTable.vue new file mode 100644 index 0000000..ad98fbf --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/composition/mainTable.vue @@ -0,0 +1,549 @@ +<template> + <div> + <BasicTable @register="registerTable"> + <template #toolbar> + <!-- 鏍规嵁鑿滃崟璁剧疆鐨勬寜閽紝鑷姩鐢熸垚 --> + <a-button + type="primary" + v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)" + @click="handleCreate(item['DO_METHOD'])" + :preIcon="item['ICON_URL']" + :key="item" + > + {{ item['FUNC_NAME'] }} + </a-button> + </template> + <template #action="{ record }"> + <TableAction :actions="createActions(record)" /> + </template> + <template #[item]="{ field }" v-for="item in colSlots" :key="item"> + <!-- <template #form-BAS_REASON3aadd="{ field }"> --> + <a-button + v-if="field" + class="mt-1 ml-1" + size="small" + @click="handleSelectItem(item)" + preIcon="search|svg" + /> + <GeneralModal + @register="useModalInTableForm[item]" + @success="(d, u) => handleItemSuccess(d, u, item)" + /> + </template> + </BasicTable> + <Suspense> + <CustModal + @register="registerCust" + @success="custSuccess" + @cancel="custCancel" + :type="cType" + :entityName="entityName" + @modal-inner="getdtlSlots" + > + <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� --> + <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 class="h-full" style="height: 380px" v-if="isCustEl[item.name]"> + <FlowChartView :data="routeData" @init="init" /> + <RouteViewModal @register="registerRv" @success="RvItemSuccess" /> + </div> + </template> + </CustModal> + </Suspense> + <normalDrawer @register="registerDrawer" @success="handleSuccess" /> + </div> +</template> +<script lang="ts" setup> + import { Ref, inject, nextTick, onMounted, ref, unref, watch } from 'vue'; + import { BasicTable, useTable, TableAction, BasicColumn, FormSchema } from '/@/components/Table'; + import { BasicForm, useForm } from '/@/components/Form/index'; + import { useDrawer } from '/@/components/Drawer'; + import GeneralModal from '/@/views/components/GeneralModal.vue'; + import normalDrawer from '../normalDrawer.vue'; + import CustModal from '/@/views/components/CustModal.vue'; + import RouteViewModal from '/@/views/components/RouteViewModal.vue'; + import { FlowChartView } from '/@/components/FlowChart'; + import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; + import { useModal } from '/@/components/Modal'; + import { useGo } from '/@/hooks/web/usePage'; + import { getListByPage } from '/@/api/tigerapi/system'; + import { useI18n } from '/@/hooks/web/useI18n'; + import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel'; + import { getRoleButtons } from '/@/api/sys/menu'; + import { useUserStore } from '/@/store/modules/user'; + import { useRouter } from 'vue-router'; + import { afterFetchFn, GenerateActionButton, initRoute, SearchInfoFn } from '../data'; + import LogicFlow from '@logicflow/core'; + import { isFunction } from 'xe-utils'; + import { CustModalParams } from '/@/api/tigerapi/model/systemModel'; + import { useQueryStore } from '/@/store/modules/queryInpage'; + + const { t } = useI18n(); + const { currentRoute } = useRouter(); + const route = unref(currentRoute); + const useQuery = useQueryStore(); + const props = defineProps({ + useTableData: { type: Object as PropType<{}>, default: { table: [] } }, + crudColSlots: { type: Object as PropType<any> }, + }); + const objParams = inject('objParams') as Ref<any>; + const savedParams = inject('savedParams') as Ref<any>; + const colSlots = ref(objParams.value['colSlots']); + const _columns = inject('_columns') as Ref<any[]>; + const _searchFormSchema = inject('_searchFormSchema') as Ref<any[]>; + const _crudFormSchema = inject('_crudFormSchema') as Ref<any[]>; + const buttons = ref<[]>(await getRoleButtons(currentRoute.value.meta.menuCode as string)); + const isExistSql = inject('isExistSql') as Ref<string>; + const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>; + const AuthOption = inject('AuthOption') as Ref<{}>; + const entityName = ref(objParams.value['ID']); + const go = useGo(); + const [registerDrawer, { openDrawer }] = useDrawer(); + const [registerRv, { openModal: openRvModal, closeModal: RvcloseModal }] = useModal(); + const [registerCust, { openModal: openCustModal }] = useModal(); + const [registerCrud, { openModal: openCrudModal }] = useModal(); + const cType = ref(''); + const formSchemas = ref({}); //寮瑰嚭妗嗗琛ㄥ崟缁撴瀯 + const routeData = ref({ + nodes: [], + edges: [], + }); + const selectVals = ref({}); + const custImport = ref<any[]>([]); + const EntityCustFunction = ref([ + { + ActionItem(params, data, ...args) {}, + KeyFieldValues(val, id) {}, + OpenSelectItem(openItemModal: Fn, ...args) {}, + GetSelectSuccess(d, u, ...args) {}, + GetUseForm(...args) {}, + CustFunc(param: CustModalParams) {}, + } as EntityCustFunctionType, + ]); + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + custImport.value = await import(`../entityts/${objParams.value['ID']}.ts`); + } catch (e) { + console.log(e); + } + const [ + { + ActionItem: nActionItem, + KeyFieldValues, + GetUseForm, + GetUseModals, + GetCustData, + OpenSelectItem: OpenSelectCust, + GetSelectSuccess, + CustFunc, + }, + ActionColumn, + ] = isNullOrUnDef(custImport.value['default']) + ? EntityCustFunction.value + : custImport.value['default'](); + + keyFieldValues.value = isNullOrUnDef(KeyFieldValues) + ? {} + : KeyFieldValues(objParams.value['CODE'], objParams.value['ID']); + const dtlSlots = ref<any[]>([]); + const useformdata = GetUseForm && isFunction(GetUseForm) ? GetUseForm() : {}; + const useFormData = ref<any>(useformdata); + /* 鑷畾涔夋ā鎬佺獥鍙d腑琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 */ + const modals = GetUseModals && isFunction(GetUseModals) ? GetUseModals() : { useModalData: {} }; + const useModalData = ref(modals['useModalData']); + /* 琛ㄦ牸鍐呯殑鎻掓Ы娓叉煋鐨勫脊鍑洪�夋嫨妗嗗垪琛� */ + const useModalInTableForm = ref<any>({}); + colSlots.value.map((x) => { + useModalInTableForm.value[x] = useModal(); + }); + /* 鑾峰彇鑷畾涔夋暟鎹� */ + const custData = GetCustData && isFunction(GetCustData) ? GetCustData() : { isCustEl: {} }; + const isCustEl = ref(custData['isCustEl']); + const [registerTable, { getForm, reload, setProps }] = useTable({ + title: '鍒楄〃淇℃伅', + api: getListByPage, + searchInfo: { + TABLE_NAME: objParams.value['ID'], + option: + AuthOption.value['BY_ORG'] == 'Y' + ? { + //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁� + UserId: useUserStore().getUserInfo.userId, + ByOrg: true, + CurOrg: useUserStore().getUserInfo.orgCode, + } + : '', + }, + beforeFetch: (t) => SearchInfoFn(t, route.name, AuthOption.value['BY_ORG'] == 'Y'), + afterFetch: afterFetch, + columns: _columns as unknown as BasicColumn[], + formConfig: { + labelWidth: 140, + schemas: _searchFormSchema as unknown as FormSchema[], + submitFunc: () => Search(), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠� + resetFunc: () => useQuery.resetFunc(route.name, getForm(), AuthOption.value['BY_ORG'] == 'Y'), + }, + useSearchForm: true, + showTableSetting: true, + bordered: true, + canResize: true, + showIndexColumn: false, + actionColumn: ActionColumn + ? ActionColumn + : { + width: 120, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', + }, //鑷畾涔夋搷浣滃垪 + }); + + watch( + () => AuthOption.value, + (newVal, oldVal) => { + nextTick(() => { + if (!isNullOrEmpty(newVal.BY_ORG) && !isNullOrUnDef(savedParams.value['params'])) { + getForm().setFieldsValue(savedParams.value['params']); + setProps({ + searchInfo: { + TABLE_NAME: objParams.value['ID'], + option: + AuthOption.value['BY_ORG'] == 'Y' + ? { + //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁� + UserId: useUserStore().getUserInfo.userId, + ByOrg: true, + CurOrg: useUserStore().getUserInfo.orgCode, + } + : '', + }, + }); + reload(); + } + }); + }, + { deep: true, immediate: true }, + ); + + onMounted(async () => { + if (!isNullOrUnDef(savedParams) && !isNullOrUnDef(savedParams.value['params'])) { + getForm().setFieldsValue(savedParams.value['params']); + reload(); + } + // if ( + // !isNullOrUnDef(useQuery.getCurSearchInfo['searchInfo']) && + // useQuery.getCurSearchInfo['name'] == route.name + // ) { + // getForm().resetFields(); + // const searchInfo = useQuery.getCurSearchInfo['searchInfo']; + // await getForm().setFieldsValue(searchInfo); + // } + }); + + /** + * @description: 鏌ヨ鎻愪氦 + * @return {*} + */ + async function Search() { + useQuery.submitFunc(route.name, getForm(), AuthOption.value['BY_ORG'] == 'Y').then(() => { + reload(); + }); + } + + /** + * @description: 璇锋眰涔嬪悗瀵硅繑鍥炲�艰繘琛屽鐞� + * @param {*} t + * @return {*} + */ + function afterFetch(t) { + afterFetchFn(t, route.name, getForm()); + } + + const currlf = ref(null) as Ref<LogicFlow | null>; + /** + * @description: 宸ヨ壓璺嚎鍒濆鍖� + * @param {*} lf + * @return {*} + */ + async function init(lf, rotId) { + initRoute(lf, rotId, routeData, currlf, null); + } + + /** + * @description: 鐢熸垚鍒楄〃涓搷浣滈」鐨勬寜閽� + * @param {*} record + * @return {*} + */ + function createActions(record) { + const params = { + record, + isUpdate: true, + entityName: objParams.value['ID'], + formJson: _crudFormSchema.value, + cType, + dtlSlots, + formSchemas, + useModalData, + useFormData, + crudColSlots: objParams.value['crudColSlots'], + routeData, + currlf, + selectVals, + colSlots, + ifSave: true, + sName: objParams.value['sName'], + }; + + /* 鏍规嵁鑿滃崟璁剧疆鐨勬寜閽嚜鍔ㄧ敓鎴愭搷浣滃垪涓殑鎸夐挳 */ + const actionItem = GenerateActionButton(params, buttons, openDrawer, reload); + if (isNullOrUnDef(custImport.value['default'])) { + return actionItem; + } + /* 鏍规嵁鍔ㄦ�佸姞杞界殑瀹炰綋绫诲悕.ts涓殑ActionItem鏂规硶锛屾覆鏌撴搷浣滃垪涓殑鎸夐挳鏂规硶 */ + return nActionItem( + params, + actionItem, + openDrawer, + reload, + null, + useForm, + useModal, + go, + setProps, + openCustModal, + openCrudModal, + ); + } + + /** + * @description: 鑾峰彇澶氳〃鍗曟彃妲藉垪琛� + * @param {*} d + * @return {*} + */ + function getdtlSlots(d, callback) { + dtlSlots.value = d; + callback(); + // setTimeout(() => { + // callback(); + // }, 100); + } + + /** + * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓� + * @return {*} + */ + function handleCreate(fnName: string) { + if (isNullOrUnDef(custImport.value['default'])) { + /* 濡傛灉鍔ㄦ�佸姞杞界殑瀹炰綋绫�.ts涓嶅瓨鍦紝鍒欑洿鎺ユ墦寮�渚ц竟妗� */ + openDrawer(true, { + isUpdate: false, //鏄柊澧炶繕鏄紪杈戯紝false-鏂板|true-缂栬緫 + entityName: entityName.value, //瀹炰綋绫诲悕 + formJson: _crudFormSchema.value, //鏂板缂栬緫鐨勮〃鍗曠粨鏋� + crudColSlots: objParams.value['crudColSlots'], //鏂板缂栬緫鐨勮〃鍗曚腑鐨勬彃妲藉垪琛� + isExistSql: isExistSql.value, //鏄惁瀛樺湪妫�鏌ql锛屾瘮濡�: XXX_CODE = '12345' + ifSave: true, //鏄惁鎻愪氦琛ㄥ崟鏃朵繚瀛樺埌鏁版嵁搴擄紝鍚�-鏆傚瓨|鏄�-淇濆瓨 + }); + } else { + /* 濡傛灉鍔ㄦ�佸姞杞界殑瀹炰綋绫�.ts瀛樺湪锛屾牴鎹�.ts鏂囦欢涓殑鏂规硶鏉ユ墽琛屾搷浣� */ + const [{ CreateAction }] = custImport.value['default'](); + const result = CreateAction(entityName.value, colSlots.value); + switch (result.action) { + case 'go' /* 璺宠浆椤甸潰 */: + // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage + sessionStorage.setItem( + `${result.params.Name}_params`, + encodeURI(JSON.stringify(result.params)), + ); + go( + `/${result.url}/${encodeURI(JSON.stringify({ sName: result.params.Name, Name: result.params.Name }))}`, + ); + break; + case 'drawer' /* 鎵撳紑渚ц竟妗� */: + openDrawer(true, { + isUpdate: false, //鏄柊澧炶繕鏄紪杈戯紝false-鏂板|true-缂栬緫 + entityName: entityName.value, //瀹炰綋绫诲悕 + formJson: _crudFormSchema.value, //鏂板缂栬緫鐨勮〃鍗曠粨鏋� + crudColSlots: objParams.value['crudColSlots'], //鏂板缂栬緫鐨勮〃鍗曚腑鐨勬彃妲藉垪琛� + isExistSql: isExistSql.value, //鏄惁瀛樺湪妫�鏌ql锛屾瘮濡�: XXX_CODE = '12345' + ifSave: true, //鏄惁鎻愪氦琛ㄥ崟鏃朵繚瀛樺埌鏁版嵁搴擄紝鍚�-鏆傚瓨|鏄�-淇濆瓨 + }); + break; + } + } + } + + /** + * @description: 鏂板缂栬緫杩斿洖鎴愬姛鏂规硶 + * @param {*} d + * @param {*} u + * @return {*} + */ + function handleSuccess(d, u) { + if (CustFunc && isFunction(CustFunc)) { + CustFunc({ + values: d, + }); + } + reload(); + } + + /** + * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ + function handleItemSuccess(d, u, item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import( + `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}.ts` + ) + .then((m) => { + const [{ GetSelectSuccess: GetSelectSuccess2 }] = m.default(); + getForm().setFieldsValue(GetSelectSuccess2(d, u, objParams.value['ID'])); + }) + .catch(() => { + getForm().setFieldsValue({ + ITEM_CODE: d.values['val'], + }); + }); + } catch (e) {} + } + + /** + * @description: 寮瑰嚭閫夋嫨妗� + * @param {*} item + * @return {*} + */ + function handleSelectItem(item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import( + `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}.ts` + ) + .then((m) => { + const [{ OpenSelectItem }] = m.default(); + OpenSelectItem(useModalInTableForm.value[item][1].openModal); + }) + .catch(() => { + useModalInTableForm.value[item][1].openModal(true, { + title: '鐗╂枡鍒楄〃', + schemas: [ + { + field: 'ITEM_CODE', + component: 'Input', + label: '鐗╂枡缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('鐗╂枡缂栫爜'), + dataIndex: 'ITEM_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('鐗╂枡鍚嶇О'), + dataIndex: 'ITEM_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_ITEM', + rowKey: 'ITEM_CODE', + searchInfo: { TABLE_NAME: 'BAS_ITEM' }, + }); + }); + } catch (e) {} + } + + /** + * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥� + * @param {*} d + * @return {*} + */ + function custSuccess(d) { + reload(); + } + + /** + * @description: 寮瑰嚭妗嗗彇娑堣繑鍥� + * @param {*} reload + * @return {*} + */ + function custCancel() { + reload(); + } + + /** + * @description: 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ + function handleEntSuccess(d, u, item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + var values = GetSelectSuccess(d, u); + selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� + let _val = {}; + d.returnFieldName.map((x) => { + _val[x] = values[x]; + }); + useFormData.value[item][1].setFieldsValue(_val); + /* 閽堝宸ュ崟鐨勬柟娉� */ + if (d.returnFieldName.filter((x) => x == 'ROUTE_CODE') && item == 'prodinfo') { + routeData.value = { + nodes: [], + edges: [], + }; + + init(currlf, selectVals.value['ROUTE_CODE']); + const { transformModel, width, height } = unref(currlf).graphModel; + transformModel.focusOn(565, 200, width, height); + } + } catch (e) {} + } + + /** + * @description: 鎵撳紑琛ㄥ崟涓殑妯℃�佹 + * @param {*} item + * @return {*} + */ + function handleCustClick(item) { + OpenSelectCust( + useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶 + item, + openRvModal, + selectVals, + ); + } + + function RvItemSuccess(d, u) { + RvcloseModal(); + } +</script> diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts index 8e21676..b3a19e9 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts @@ -287,6 +287,10 @@ } break; case 'BAS_PKG_PROD': + data = d.data.value[d.type].filter((item) => item.ITEM_CODE.includes(d.values.ITEM_CODE)); + if (isNullOrEmpty(d.values.ITEM_CODE)) { + data = d.data.value[d.type]; + } break; } return data; diff --git a/src/views/tigerprojects/system/lowcode/entityts/TestDemo.ts b/src/views/tigerprojects/system/lowcode/entityts/TestDemo.ts new file mode 100644 index 0000000..d98a382 --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/entityts/TestDemo.ts @@ -0,0 +1,1937 @@ +/* + * @Description: 娴嬭瘯Demo + * @Author: Ben Lin + * @version: + * @Date: 2024-06-19 20:34:27 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-10-23 23:55:56 + */ + +import { Ref, unref } from 'vue'; +import { + DeleteWoRoute, + GetWoPTree, + ProdRouteToWo, + SP_MES_WO2CUST, +} from '/@/api/tigerapi/mes/router'; +import { GetEnum, SaveEntity, 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 { 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 { AddOrEditLabelVarByWorkOrder, UpdateWoStatus } from '/@/api/tigerapi/mes/wo'; +import { useForm } from '/@/components/Form'; +import { BAS_LABEL_VAR_WO, MesRotTree } from '/@/api/tigerapi/model/mesModel'; +import { buildUUID } from '/@/utils/uuid'; +import { mesApi } from '/@/api/tigerapi/mes/mesApi'; +import { useProdRouteStore } from '/@/store/modules/prodRoute'; +import { useWebSocketStore } from '/@/store/modules/websocket'; +import { useGlobSetting } from '/@/hooks/setting'; + +const { t } = useI18n(); +const { createErrorModal } = useMessage(); +const useProdRoute = useProdRouteStore(); +const { getLocale } = useLocale(); +const globSetting = useGlobSetting(); +function _default() { + /* 瀹氫箟鍙橀噺 */ + const isNormal = (type: number) => type === 0; + const isScan = (type: number) => type === 1; + const isAssy = (type: number) => type === 2; + const isTest = (type: number) => type === 3; + const isAudit = (type: number) => type === 4; + const isPrint = (type: number) => type === 5; + const isPackage = (type: number) => type === 6; + /** + * @description: 浜у搧缁戝畾宸ヨ壓璺嚎鐨勪竴浜涜嚜瀹氫箟鏂规硶 + * @return {*} + */ + const methods = { + /** + * @description: 鑾峰彇鏍戝舰鍥炬爣 + * @param {Recordable} params + * @return {*} + */ + CreateIcon: (params: Recordable<any>) => { + let icon = ''; + switch (params['type']) { + case 'WorkOrder': + icon = 'workorder|svg'; + break; + case 'Route': + icon = 'route|svg'; + break; + case 'Node': + icon = 'node|svg'; + break; + case 'Action': + icon = 'rot_action|svg'; + break; + case 'Customer': + icon = 'customer|svg'; + break; + } + return icon; + }, + /** + * @description: 楂樼骇琛ㄥ崟鍜岃鎯呴〉闈㈣繑鍥炰富椤甸潰鐨剈rl + * @return {*} + */ + GetHomeUrl: (params: {}) => { + return `/BIZ_MES_WO/LC/${encodeURI(JSON.stringify({ ID: 'BIZ_MES_WO', colSlots: params['colSlots'], crudColSlots: [] }))}`; + }, + /** + * @description: 鑾峰彇鏍戝舰鏁版嵁 + * @param {string} type + * @return {*} + */ + fetchTreeData: async (type: string, wo: string) => { + let data = { title: '', treeData: [] as any[], fieldNames: {} }; + let prodTreeData = await GetWoPTree({ wo: wo }); + let _treeData = convertToTree(prodTreeData, 'pid', 'tid', 'root'); + if (_treeData.length == 0) { + _treeData.push({ + pid: 'root', + tid: '', + id: '', + wo: wo, + prod: '', + name: wo, + type: 'WorkOrder', + cust: '', + code: '', + seq: 0, + }); + } + data.title = '宸ュ崟宸ヨ壓璺嚎'; + data.fieldNames = { key: 'tid', title: 'name' }; + if (!useProdRoute.changeToCPPage || !useProdRoute.curProdRotTree.some((q) => q.name == wo)) { + /* 淇濆瓨宸ヨ壓鏍戝舰鏁版嵁鍒扮姸鎬佺鐞� */ + useProdRoute.setCurProdRotTree({ + name: wo, + treeInfo: _treeData as unknown as MesRotTree[], + }); + } + useProdRoute.setWo(wo); + useProdRoute.setname(wo); + if (useProdRoute.curProdRotTree.some((q) => q.name == wo)) { + data.treeData = useProdRoute.curProdRotTree.filter((q) => q.name == wo)[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; + }, + /** + * @description: 鑾峰彇閰嶇疆椤硅〃鍗曞瓧娈碉紝鏍规嵁鏍戝舰鑺傜偣type涓嶅悓鑰屼笉鍚� + * @param {string} type + * @return {*} + */ + GetCrudForm: (type: string) => { + let form: FormSchema[] = []; + switch (type) { + case 'Action': + form = actionFormShema; + break; + case 'Node': + form = nodeFormShema; + break; + default: + form = crudForms[type]; + break; + } + return form; + }, + /** + * @description: 鑾峰彇琛ㄥ崟涓殑瀛楁鎻掓Ы鍒楄〃 + * @return {*} + */ + GetCrudColSlots: () => { + 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: 'template|svg' }, + ]; + }, + /** + * @description: 鑾峰彇琛ㄦ牸use鍒楄〃 + * @param {string} type + * @param {array} args + * @return {*} + */ + GetUseTables: (data: Ref<{}>, ...args) => { + return { + BAS_PKG_DTL: useTable({ + title: '鍒楄〃淇℃伅', + // api: getListByPage, + // searchInfo: { TABLE_NAME: 'V_BAS_PKG_DTL' }, + dataSource: data.value['BAS_PKG_DTL'], + columns: GetBaseColumns('BAS_PKG_DTL', args[0], data), + // maxHeight: 520, + useSearchForm: false, + showTableSetting: false, + bordered: true, + isCanResizeParent: true, + // canResize: true, + showIndexColumn: false, + // rowSelection: { + // type: 'radio', //'checkbox' + // }, + actionColumn: { + width: 100, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', + }, //鑷畾涔夋搷浣滃垪 + }), + ItemCode: useTable({ + title: '鍒楄〃淇℃伅', + // api: getListByPage, + // searchInfo: { TABLE_NAME: 'V_BAS_PKG_DTL' }, + dataSource: data.value['ItemCode'], + columns: GetBaseColumns('ItemCode', args[0], data), + // maxHeight: 520, + useSearchForm: false, + showTableSetting: false, + bordered: true, + isCanResizeParent: true, + // canResize: true, + showIndexColumn: false, + // rowSelection: { + // type: 'radio', //'checkbox' + // }, + actionColumn: { + width: 100, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', + }, //鑷畾涔夋搷浣滃垪 + }), + }; + }, + GetUseForm: () => { + return { + Action: useForm({ + labelWidth: 145, + schemas: methods.GetCrudForm('Action'), + actionColOptions: { + offset: 8, + span: 24, + }, + wrapperCol: { + span: 15, + }, + showActionButtonGroup: true, + submitButtonOptions: { + text: '淇濆瓨', + }, + }), + Node: useForm({ + labelWidth: 145, + schemas: methods.GetCrudForm('Node'), + actionColOptions: { + offset: 8, + span: 24, + }, + wrapperCol: { + span: 15, + }, + showActionButtonGroup: true, + submitButtonOptions: { + text: '淇濆瓨', + }, + }), + }; + }, + /** + * @description: 鍒囨崲鑺傜偣鏃朵簨浠舵柟娉� + * @return {*} + */ + nodeChange: (params: { useForms: Ref<any>; objParams: Ref<any>; selectedNodes: any[] }) => + new Promise<any>(async (resolve, reject) => { + let result = { isShow: {} }; + let sqlcmd = ' 1=1 '; + if (!isNullOrEmpty(params['objParams'].value['CODE'])) { + sqlcmd += `And WORK_ORDER = '${params['objParams'].value['CODE']}'`; + } + if (!isNullOrEmpty(params['selectedNodes'][0].id)) { + sqlcmd += + params['selectedNodes'][0].type == 'Action' + ? `And ACT_ID = '${params['selectedNodes'][0].id}'` + : `And NODE_ID = '${params['selectedNodes'][0].id}'`; + } + try { + const res = await getEntity({ + sqlcmd: sqlcmd, + entityName: + params['selectedNodes'][0].type == 'Action' ? 'MES_WO_ACTION' : 'MES_WO_OPER', + order: '', + }); + const setFieldsValue = params['useForms'].value['Action'][1]['setFieldsValue']; + const setFieldsValueNode = params['useForms'].value['Node'][1]['setFieldsValue']; + const resetFields = params['useForms'].value['Action'][1]['resetFields']; + const resetFieldsNode = params['useForms'].value['Node'][1]['resetFields']; + if (params['selectedNodes'][0].type == 'Action') { + resetFields(); + setFieldsValue({ + ID: res.Data.Items[0].ID, + ACT_ID: res.Data.Items[0].ACT_ID, + ROT_ID: res.Data.Items[0].ROT_ID, + NODE_ID: res.Data.Items[0].NODE_ID, + IS_ACTIVE: res.Data.Items[0].IS_ACTIVE, + ITEM_CODE: res.Data.Items[0].ITEM_CODE, + RULE_CODE: res.Data.Items[0].RULE_CODE, + TEST_CODE: res.Data.Items[0].TEST_CODE, + SAPL_CODE: res.Data.Items[0].SAPL_CODE, + LABEL_CODE: res.Data.Items[0].LABEL_CODE, + PKG_CODE: res.Data.Items[0].PKG_CODE, + ACT_CODE: res.Data.Items[0].ACT_CODE, + REMARK: res.Data.Items[0].REMARK, + WORK_ORDER: params['objParams'].value['CODE'], + ACT_TYPE: res.Data.Items[0].ACT_TYPE, + CUST_CODE: params['selectedNodes'][0].cust, + PROD_CODE: params['selectedNodes'][0].prod, + OPTION_1: res.Data.Items[0].OPTION_1, + OPTION_2: res.Data.Items[0].OPTION_2, + }); + /* 濡傛灉鏄寘瑁呰鍒� */ + if (res.Data.Items[0].ACT_TYPE == 6) { + result['name'] = 'BAS_PKG_DTL'; + result['isShow'] = { + BAS_PKG_DTL: isNullOrEmpty(res.Data.Items[0].PKG_CODE) ? false : true, + ItemCode: false, + }; + const ents = await getEntity({ + sqlcmd: `RULE_CODE ='${res.Data.Items[0].PKG_CODE}'`, + entityName: 'V_BAS_PKG_DTL', + order: '', + }); + result['BAS_PKG_DTL'] = isNullOrEmpty(res.Data.Items[0].OPTION_1) + ? ents.Data.Items + : JSON.parse(res.Data.Items[0].OPTION_1); + /* 濡傛灉OPTION_1瀛楁涓虹┖灏辨妸鍖呰淇℃伅杞琂SON瀛樺埌OPTION_1瀛楁 */ + res.Data.Items[0].OPTION_1 = JSON.stringify(result['BAS_PKG_DTL']); + } + /* 濡傛灉鏄粍瑁呬笂鏂� */ + if (res.Data.Items[0].ACT_TYPE == 2) { + result['name'] = 'ItemCode'; + result['ItemCode'] = JSON.parse(res.Data.Items[0].OPTION_1); + result['isShow'] = { + BAS_PKG_DTL: false, + ItemCode: true, + }; + } + result['Action'] = res.Data.Items; + } + if (params['selectedNodes'][0].type == 'Node') { + resetFieldsNode(); + const wonode = await getEntity({ + sqlcmd: `WORK_ORDER ='${params['objParams'].value['CODE']}' AND ID = '${res.Data.Items[0].NODE_ID}'`, + entityName: 'MES_WO_NODE', + order: '', + }); + const values = { + ID: res.Data.Items[0].ID, + OPER_CODE: res.Data.Items[0].OPER_CODE, + ROT_ID: res.Data.Items[0].ROT_ID, + NODE_ID: res.Data.Items[0].NODE_ID, + NODE_NAME: res.Data.Items[0].NODE_NAME, + IS_ACTIVE: isNullOrEmpty(res.Data.Items[0].IS_ACTIVE) + ? 'N' + : res.Data.Items[0].IS_ACTIVE, + IS_CALC_FPY: isNullOrEmpty(res.Data.Items[0].IS_CALC_FPY) + ? 'N' + : res.Data.Items[0].IS_CALC_FPY, + CAN_SKIP: isNullOrEmpty(res.Data.Items[0].CAN_SKIP) + ? 'N' + : res.Data.Items[0].CAN_SKIP, + IS_INPUT: + wonode.Data.Items[0].IS_FIRST_NODE == 'Y' + ? 'Y' + : isNullOrEmpty(res.Data.Items[0].IS_INPUT) + ? 'N' + : res.Data.Items[0].IS_INPUT, + IS_OUTPUT: isNullOrEmpty(res.Data.Items[0].IS_OUTPUT) + ? 'N' + : res.Data.Items[0].IS_OUTPUT, + ALLOW_DFT_IN: isNullOrEmpty(res.Data.Items[0].ALLOW_DFT_IN) + ? 'N' + : res.Data.Items[0].ALLOW_DFT_IN, + IF_DFT_OFFLINE: isNullOrEmpty(res.Data.Items[0].IF_DFT_OFFLINE) + ? 'N' + : res.Data.Items[0].IF_DFT_OFFLINE, + REMARK: res.Data.Items[0].REMARK, + WORK_ORDER: params['objParams'].value['CODE'], + CUST_CODE: params['selectedNodes'][0].cust, + PROD_CODE: params['selectedNodes'][0].prod, + }; + setFieldsValueNode(values); + /* 榛樿淇濆瓨 */ + SaveEntity(values, true, 'MES_WO_OPER'); + + result['name'] = 'Node'; + result['isShow'] = { + BAS_PKG_DTL: false, + ItemCode: false, + }; + } + useProdRoute.setcurDtl(result); + resolve(result); + } catch (e) { + reject(e); + } + }), + /** + * @description: 鑷畾涔夋彁浜ゆ柟娉� + * @return {*} + */ + SubmitFunc: (values: Recordable<any>, type: string, emit) => { + let entityName = ''; + switch (type) { + case 'Action': + entityName = 'MES_WO_ACTION'; + break; + case 'Node': + entityName = 'MES_WO_OPER'; + break; + } + 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 + * @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; + break; + case 'assyadd': + config = itemCodeModalCfg; + break; + case 'testadd': + config = itemCodeModalCfg; + break; + case 'printadd': + config = printModalCfg; + break; + case 'pkgadd': + config = pkgModalCfg; + break; + } + if (args[0] == 'labeladd') { + openCrudModal(true, { + isUpdate: true, //鏄惁鏇存柊鎿嶄綔 + entityName: 'WoRouteBinding', //鏄摢涓〉闈� + ctype: 'BAS_LABEL_VAR_WO', //瀹炰綋鍚嶇О + title: '妯℃澘缁存姢', //鏍囬 + width: '1024px', //寮瑰嚭妗嗗搴� + ItemColumns: TemplateBasColumn, //寮瑰嚭妗嗕腑琛ㄦ牸瀛楁缁撴瀯 + schemas: [], //鏌ヨ鏉′欢瀛楁缁撴瀯 + others: { WORK_ORDER: OrderNo }, //闇�瑕佸甫鍒板脊鍑虹獥鍙d腑鐨勬暟鎹� + 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 + * @return {*} + */ + GetSelectSuccess: async (d, u, ...args) => { + let value = {}; + switch (args[0]) { + case 'scanadd': + value = { + value: { + RULE_CODE: d.values['val'], + }, + isShow: { BAS_PKG_DTL: false, ItemCode: false }, + }; + break; + case 'assyadd': + const items = d.values['val'].split(','); + let data: any[] = []; + if (!isNullOrEmpty(items) && items.length > 0) { + items.map((x) => { + data.push({ + ITEM_CODE: x, + RULE_CODE: '', + IsBatchItem: 'N', + QTY: 1, + }); + }); + } + value = { + value: { + ITEM_CODE: d.values['val'], + }, + isShow: { BAS_PKG_DTL: false, ItemCode: true }, + data: data, + name: 'ItemCode', + }; + break; + case 'printadd': + value = { + value: { + LABEL_CODE: d.values['val'], + }, + isShow: { BAS_PKG_DTL: false, ItemCode: false }, + }; + break; + case 'labeladd': + break; + case 'pkgadd': + const ents = await getEntity({ + sqlcmd: `RULE_CODE ='${d.values['val']}'`, + entityName: 'V_BAS_PKG_DTL', + order: '', + }); + value = { + value: { + PKG_CODE: d.values['val'], + }, + isShow: { BAS_PKG_DTL: true, ItemCode: false }, + data: ents.Data.Items, + name: 'BAS_PKG_DTL', + }; + break; + case 'addRoute': + if (isNullOrEmpty(args[1]['CODE'])) { + createErrorModal({ + title: t('sys.api.errorTip'), + content: '浜у搧涓虹┖锛屼笉鑳芥坊鍔犲伐鑹鸿矾绾匡紝璇风偣鍑诲乏渚ч�夋嫨浜у搧', + }); + return; + } + /* 鏇存柊宸ュ崟鐘舵�佸苟鐢熸垚宸ュ崟鐨勫伐鑹鸿矾绾� */ + ProdRouteToWo({ + rotId: d.values.id, + wo: args[1]['CODE'], + rotCode: '', + options: { + //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁� + UserId: useUserStore().getUserInfo.userId, + ByOrg: true, + CurOrg: useUserStore().getUserInfo.orgCode, + }, + }).then((action) => { + if (action.IsSuccessed) { + args[2](); + } else { + createErrorModal({ + title: t('sys.api.errorTip'), + content: t(action.LocaleMsg), + }); + } + }); + break; + case 'addCustomer': + if (isNullOrEmpty(args[1]['CODE'])) { + createErrorModal({ + title: t('sys.api.errorTip'), + content: '宸ュ崟涓虹┖锛屼笉鑳芥坊鍔犲伐鑹鸿矾绾匡紝璇风偣鍑诲乏渚ч�夋嫨宸ュ崟', + }); + return; + } + SP_MES_WO2CUST({ wo: args[1]['CODE'] }); + + args[2](); + break; + } + return value; + }, + /** + * @description: 鑾峰彇妯℃�佹搴旂敤鍒楄〃 + * @return {*} + */ + GetUseModals: () => { + return { + addRoute: useModal(), + addCustomer: useModal(), + editRoute: useModal(), + scanadd: useModal(), + assyadd: useModal(), + 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(), + }; + }, + /** + * @description: 鑾峰彇鏍囬淇℃伅 + * @param {string} type + * @return {*} + */ + GetTitle: (type: string, item) => { + return { + configTitle: type == 'Action' ? '琛屼负閰嶇疆' : '宸ュ簭閰嶇疆', + navTitle: type == 'Product' ? '娣诲姞宸ヨ壓璺嚎' : '宸ヨ壓璺嚎缁存姢', + tableTitle: type == 'Action' ? (item == 'ItemCode' ? '涓婃枡鍒楄〃' : '鍖呰灞傜骇鍒楄〃') : '', + }; + }, + /** + * @description: 鏍规嵁閫変腑鐨勬爲鑺傜偣杩斿洖涓婚〉闈紝鑷畾涔夋柟娉曪紝杩欓噷鏄垽鏂鍒囨崲鍝釜缁勪欢 + * @param {Ref} selectedNodes + * @return {*} + */ + SelectNode: (selectedNodes: Ref<any[]>, code: string) => { + let result = { + showConfig: false, + showNav: false, + type: selectedNodes.value[0].type, + nodes: selectedNodes.value, + showOtherTable: { BAS_PKG_DTL: false, ItemCode: false }, + }; + if (isNullOrUnDef(selectedNodes)) { + return result; + } + if (selectedNodes.value[0].type == 'WorkOrder' || selectedNodes.value[0].type == 'Route') { + result.showNav = true; + result.showConfig = false; + result.showOtherTable = { BAS_PKG_DTL: false, ItemCode: 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 }; + } + } + useProdRoute.setCurSelectedNodes({ name: code, SelectedNodes: selectedNodes.value }); + return result; + }, + /** + * @description: 鑾峰彇瀵艰埅椤� + * @return {*} + */ + GetNavItems: (type: string) => { + let item: NavItem[] = []; + switch (type) { + case 'WorkOrder': + item = [ + { + title: '娣诲姞浜у搧宸ヨ壓璺嚎', + icon: 'add_green|svg', + color: '#1fdaca', + url: '/addRoute', + action: 'addRoute', + isStep: false, + isCustEl: false, + }, + // { + // title: '娣诲姞瀹㈡埛宸ヨ壓璺嚎', + // icon: 'add_customer|svg', + // color: '#bf0c2c', + // url: '/addCustomer', + // action: 'addCustomer', + // isStep: true, + // }, + ]; + break; + case 'Route': + item = [ + { + title: '缂栬緫宸ヨ壓璺嚎', + icon: 'clarity:note-edit-line', + color: '#1fdaca', + url: '/editRoute', + action: 'editRoute', + isStep: false, + isCustEl: false, + }, + ]; + break; + } + return item; + }, + /** + * @description: 瀵艰埅椤甸潰鍒囨崲鎸夐挳鏃惰皟鐢ㄦ柟娉� + * @param {any} action + * @return {*} + */ + navChangeItem: (action: any, ...args) => { + switch (action) { + case 'addRoute': + args[0](true, { + title: '宸ヨ壓璺嚎鍒楄〃', + schemas: [ + { + field: 'ROT_CODE', + component: 'Input', + label: '宸ヨ壓璺嚎缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('宸ヨ壓璺嚎缂栫爜'), + dataIndex: 'ROT_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('宸ヨ壓璺嚎鍚嶇О'), + dataIndex: 'ROT_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'MES_ROUTE', + rowKey: 'ROT_CODE', + returnFieldName: ['ROUTE_CODE'], //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О + searchInfo: { TABLE_NAME: 'MES_ROUTE' }, + which: action, + }); + break; + case 'addCustomer': + if (isNullOrEmpty(args[2][0]['wo'])) { + createErrorModal({ + title: t('sys.api.errorTip'), + content: '宸ュ崟涓虹┖锛屼笉鑳芥坊鍔犲伐鑹鸿矾绾匡紝璇风偣鍑诲乏渚ч�夋嫨宸ュ崟', + }); + return; + } + SP_MES_WO2CUST({ wo: args[2][0]['wo'] }); + break; + case 'editRoute': + args[1](true, { + rotId: args[2][0].wo, + slotName: '', + rotType: 'Wo', + prodCode: args[3], + custCode: args[2][0].cust, + }); + break; + } + }, + /** + * @description: 鑾峰彇鍗$墖鍐呴厤缃垪琛紝浠ュ惊鐜樉绀哄涓崱鐗囧苟閰嶇疆澶氫釜鎻掓Ы + * @return {*} + */ + GetBaseCards: (type: string) => { + let reusts: any[] = []; + switch (type) { + case 'WorkOrder': + reusts = []; + break; + case 'Route': + reusts = [ + { + name: 'RotInfo', + slots: [], + preIcons: {}, + title: '宸ヨ壓璺嚎鍥�', + entityName: '', + }, + ]; + break; + } + return reusts; + }, + /** + * @description: 鑾峰彇鎻掓Ы鍒楄〃 + * @return {*} + */ + GetSlots: () => { + return ['RotInfo']; + }, + /** + * @description: 鐢熸垚html + * @return {*} + */ + GenerateHtml: (type: string | null) => { + const newElement = document.createElement('div'); + // newElement.textContent = 'New Element =>'+type; + // newElement.style.height = '250px'; + newElement.id = 'lfContainer'; + newElement.className = 'h-full'; + // newElement.style.color = 'blue'; + // newElement.style.fontSize = '16px'; + return newElement; + }, + /** + * @description: 鑷畾涔夋柟娉� + * @param {string} type + * @param {array} args + * @return {*} + */ + CustFunc: async (param: CustModalParams) => { + 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'], + ); + 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; + case 'BAS_LABEL_VAR_WO': + param.values['WORK_ORDER'] = param.others['WORK_ORDER']; + param.values['ID'] = buildUUID(); + + const apiaction = await AddOrEditLabelVarByWorkOrder( + param.values as unknown as BAS_LABEL_VAR_WO, + ); + if (apiaction.IsSuccessed) { + const webSocketStore = useWebSocketStore(); + if (webSocketStore.GetSocketState == 1) { + webSocketStore.sendMessage( + `wsGetNew ${param.values['LABEL_ID']}_#_${param.values['WORK_ORDER']}`, + ); + } + } + case 'delete': + const webSocketStore = useWebSocketStore(); + if (webSocketStore.GetSocketState == 1) { + webSocketStore.sendMessage( + `wsGetNew ${param.values['LABEL_ID']}_#_${param.values['WORK_ORDER']}`, + ); + } + break; + } + resolve('OK'); + } catch (e) { + reject(e); + } + }); + }, + /** + * @description: 鑾峰彇鍙抽敭鑿滃崟鍒楄〃 + * @param {EventDataNode} node + * @return {*} + */ + GetRightMenuList: (node: EventDataNode, ...args): ContextMenuItem[] => { + const emit = args[0]; + const menu = [ + // { + // label: '鏂板', + // handler: () => { + // console.log('鐐瑰嚮浜嗘柊澧�', node); + // }, + // icon: 'bi:plus', + // }, + { + label: '鍒犻櫎', + handler: () => { + console.log('鐐瑰嚮浜嗗垹闄�', node); + DeleteWoRoute({ rotId: '', rotCode: node.code, wo: node.wo }).then((action) => { + if (action.IsSuccessed) { + emit('deletenode', node); + } else { + createErrorModal({ + title: t('sys.api.errorTip'), + content: t(action.LocaleMsg), + }); + } + }); + }, + icon: 'bx:bxs-folder-open', + }, + ]; + return node.type == 'Route' ? menu : []; + }, + }; + + /* 浠ヤ笅鏄唴閮ㄦ柟娉曪紝涓峞xport锛屼緵涓婇潰鐨勬柟娉曡皟鐢� */ + + let columns: BasicColumn[] = []; + /** + * @description: 鑾峰彇琛ㄦ牸瀛楁Json + * @param {string} type + * @return {*} + */ + function GetBaseColumns(type: string, emit, data: Ref<{}>) { + switch (type) { + case 'BAS_PKG_DTL': + columns = [ + { + dataIndex: 'PKG_RULE_ID', + title: '鍖呰瑙勫垯ID', + ifShow: false, + sorter: true, + resizable: true, + }, + { + dataIndex: 'PKG_CODE', + title: '鍖呰缂栫爜', + ifShow: false, + sorter: true, + resizable: true, + customRender: () => {}, + }, + { + dataIndex: 'PKG_NAME', + title: '鍖呰鍚嶇О', + ifShow: true, + sorter: true, + resizable: true, + customRender: () => {}, + }, + { + dataIndex: 'PKG_QTY', + title: '鍖呰鏁伴噺', + ifShow: true, + sorter: true, + resizable: true, + customRender: () => {}, + }, + { + dataIndex: 'PKG_LEVEL', + title: '鍖呰灞傜骇', + ifShow: true, + sorter: true, + resizable: true, + customRender: () => {}, + }, + { + dataIndex: 'LABEL_CODE', + title: '鏍囩妯℃澘缂栫爜', + // edit: true, + // editRule: true, + ifShow: true, + sorter: true, + resizable: true, + // editComponent: 'Input', + // editComponentProps: (column) => { + // return { + // onClick: (event) => { + // console.log(column); + // }, + // }; + // }, + // customCell: (record, rowIndex) => { + // return { + // onClick: (event) => { + // console.log(record); + // }, + // }; + // }, + }, + { + dataIndex: 'LABEL_ID', + title: '鏍囩妯℃澘ID', + ifShow: false, + customRender: () => {}, + }, + ] as BasicColumn[]; + break; + case 'ItemCode': + /* + public string ITEM_CODE { get; set; } + public string RULE_CODE { get; set; } + /// <summary> + /// 鏄惁鎵规鐗╂枡 + /// </summary> + public bool IsBatchItem { get; set; } + /// <summary> + /// 涓婃枡鏁伴噺 + /// </summary> + public int QTY { get; set; } + */ + columns = [ + { + dataIndex: 'ITEM_CODE', + title: '鐗╂枡缂栫爜', + ifShow: true, + sorter: true, + resizable: true, + }, + { + dataIndex: 'RULE_CODE', + title: '瑙勫垯缂栫爜', + ifShow: true, + sorter: true, + resizable: true, + customRender: () => {}, + }, + { + dataIndex: 'IsBatchItem', + title: '鏄惁鎵规鐗╂枡', + ifShow: true, + sorter: true, + resizable: true, + customRender: () => {}, + }, + { + dataIndex: 'QTY', + title: '涓婃枡鏁伴噺', + ifShow: true, + sorter: true, + resizable: true, + customRender: () => {}, + }, + // { + // dataIndex: 'LABEL_CODE', + // title: '鏍囩妯℃澘缂栫爜', + // // edit: true, + // // editRule: true, + // ifShow: true, + // sorter: true, + // resizable: true, + // // editComponent: 'Input', + // // editComponentProps: (column) => { + // // return { + // // onClick: (event) => { + // // console.log(column); + // // }, + // // }; + // // }, + // // customCell: (record, rowIndex) => { + // // return { + // // onClick: (event) => { + // // console.log(record); + // // }, + // // }; + // // }, + // }, + ] as BasicColumn[]; + break; + } + return columns; + } + + /** + * @description: 寮瑰嚭閫夋嫨妗�-鐗╂枡閫夋嫨妗嗛厤缃� + * @return {*} + */ + const itemCodeModalCfg = { + title: '鐗╂枡鍒楄〃', + schemas: [ + { + field: 'ITEM_CODE', + component: 'Input', + label: '鐗╂枡缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('鐗╂枡缂栫爜'), + dataIndex: 'ITEM_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('鐗╂枡鍚嶇О'), + dataIndex: 'ITEM_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_ITEM', + rowKey: 'ITEM_CODE', + searchInfo: { TABLE_NAME: 'BAS_ITEM' }, + }; + + /** + * @description: 寮瑰嚭閫夋嫨妗�-瑙勫垯閫夋嫨妗嗛厤缃� + * @return {*} + */ + const ruleModalCfg = { + title: '瑙勫垯鍒楄〃', + schemas: [ + { + field: 'RULE_CODE', + component: 'Input', + label: '瑙勫垯缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('瑙勫垯缂栫爜'), + dataIndex: 'RULE_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('瑙勫垯鍚嶇О'), + dataIndex: 'RULE_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_CODE_RULE', + rowKey: 'RULE_CODE', + searchInfo: { TABLE_NAME: 'BAS_CODE_RULE' }, + }; + + /** + * @description: 寮瑰嚭閫夋嫨妗�-鎵撳嵃妯℃澘閫夋嫨妗嗛厤缃� + * @return {*} + */ + const printModalCfg = { + title: '鎵撳嵃妯℃澘鍒楄〃', + schemas: [ + { + field: 'LABEL_CODE', + component: 'Input', + label: '妯℃澘缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('妯℃澘缂栫爜'), + dataIndex: 'LABEL_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('妯℃澘鍚嶇О'), + dataIndex: 'LABEL_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_LABEL_TEMP', + rowKey: 'LABEL_CODE', + searchInfo: { TABLE_NAME: 'BAS_LABEL_TEMP' }, + }; + + const pkgModalCfg = { + title: '鍖呰瑙勫垯鍒楄〃', + schemas: [ + { + field: 'RULE_CODE', + component: 'Input', + label: '鍖呰瑙勫垯缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('鍖呰瑙勫垯缂栫爜'), + dataIndex: 'RULE_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('鍖呰瑙勫垯鍚嶇О'), + dataIndex: 'RULE_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_PKG_RULE', + rowKey: 'RULE_CODE', + searchInfo: { TABLE_NAME: 'BAS_PKG_RULE' }, + }; + + /** + * @description: 琛屼负閰嶇疆琛ㄥ崟瀛楁 + * @return {*} + */ + const actionFormShema: FormSchema[] = [ + { + field: 'WORK_ORDER', + label: '宸ュ崟鍙�', + component: 'Input', + dynamicDisabled: ({ values }) => { + return true; + }, + colProps: { span: 12 }, + }, + { + field: 'PROD_CODE', + label: 'PROD_CODE', + component: 'Input', + show: false, + }, + { + field: 'ID', + label: 'ID', + component: 'Input', + show: false, + }, + { + field: 'ACT_ID', + label: 'ACT_ID', + component: 'Input', + show: false, + }, + { + field: 'ROT_ID', + label: 'ROT_ID', + component: 'Input', + show: false, + }, + { + field: 'ACT_CODE', + label: 'ACT_CODE', + component: 'Input', + show: false, + }, + { + field: 'NODE_ID', + label: 'NODE_ID', + component: 'Input', + show: false, + }, + { + field: 'CUST_CODE', + label: '瀹㈡埛缂栫爜', + component: 'Input', + dynamicDisabled: ({ values }) => { + return true; + }, + colProps: { span: 12 }, + }, + { + field: 'ACT_TYPE', + label: '琛屼负绫诲瀷', + component: 'ApiSelect', + colProps: { span: 12 }, + defaultValue: 0, + componentProps: { + api: GetEnum, + params: { name: 'MES_WO_ACTION+ACT_TYPEs' }, + resultField: 'Data', + labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name', + valueField: 'Value', + // onChange: (e, v) => { + // alert(e) + // console.log('ApiSelect====>:', e, v); + // }, + }, + }, + { + field: 'IS_ACTIVE', + label: '鏄惁鍚敤', + required: true, + component: 'Select', + colProps: { span: 12 }, + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + field: 'RULE_CODE', + label: '鎵爜楠岃瘉', + component: 'Input', + colProps: { span: 11 }, + ifShow: ({ values }) => isScan(values.ACT_TYPE), + }, + { + field: '0', + label: '1', + defaultValue: '', + component: 'Input', + colProps: { span: 1, pull: window.screen.width == 1366 ? -1 : 1 }, + ifShow: ({ values }) => isScan(values.ACT_TYPE), + colSlot: 'scanadd', + }, + { + field: 'ITEM_CODE', + label: '缁勮涓婃枡', + colProps: { span: 11 }, + component: 'Input', + ifShow: ({ values }) => isAssy(values.ACT_TYPE), + }, + { + field: '00', + label: '1', + defaultValue: '', + component: 'Input', + colProps: { span: 1, pull: window.screen.width == 1366 ? -1 : 1 }, + ifShow: ({ values }) => isAssy(values.ACT_TYPE), + colSlot: 'assyadd', + }, + { + field: 'TEST_CODE', + label: '浜у搧娴嬭瘯', + colProps: { span: 11 }, + component: 'Input', + ifShow: ({ values }) => isTest(values.ACT_TYPE), + }, + { + field: 'test0', + label: '1', + defaultValue: '', + component: 'Input', + colProps: { span: 1, pull: window.screen.width == 1366 ? -1 : 1 }, + ifShow: ({ values }) => isTest(values.ACT_TYPE), + colSlot: 'testadd', + }, + { + field: 'SAPL_CODE', + label: '浜у搧鎶芥', + colProps: { span: 11 }, + component: 'Input', + ifShow: ({ values }) => isAudit(values.ACT_TYPE), + }, + { + field: 'audit0', + label: '1', + defaultValue: '', + component: 'Input', + colProps: { span: 1, pull: window.screen.width == 1366 ? -1 : 1 }, + ifShow: ({ values }) => isAudit(values.ACT_TYPE), + colSlot: 'auditadd', + }, + { + field: 'LABEL_CODE', + label: '鏍囩鎵撳嵃', + colProps: { span: 9 }, + component: 'Input', + ifShow: ({ values }) => isPrint(values.ACT_TYPE), + }, + { + field: 'print0', + label: '1', + defaultValue: '', + component: 'Input', + colProps: { span: 2 }, //{ span: 2, pull: window.screen.width == 1366 ? -1 : 1 }, + 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', + label: '鍖呰瑙勫垯', + colProps: window.screen.width == 2560 ? { span: 10 } : { span: 11 }, + component: 'Input', + ifShow: ({ values }) => isPackage(values.ACT_TYPE), + }, + { + field: 'pkg0', + label: '1', + defaultValue: '', + component: 'Input', + colProps: + window.screen.width == 2560 + ? { span: 2, pull: 1 } + : { span: 1, pull: window.screen.width == 1366 ? -1 : 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', + label: '澶囨敞', + component: 'Input', + colProps: { span: 12 }, + }, + { + field: 'OPTION_1', + label: '琛屼负閫夐」1', + component: 'Input', + colProps: { span: 12 }, + show: false, + }, + ]; + + /** + * @description: 宸ュ簭閰嶇疆琛ㄥ崟瀛楁 + * @return {*} + */ + const nodeFormShema: FormSchema[] = [ + { + field: 'WORK_ORDER', + label: '宸ュ崟鍙�', + component: 'Input', + dynamicDisabled: ({ values }) => { + return true; + }, + colProps: { span: 12 }, + }, + { + field: 'PROD_CODE', + label: 'PROD_CODE', + component: 'Input', + show: false, + }, + { + field: 'ID', + label: 'ID', + component: 'Input', + show: false, + }, + { + field: 'ACT_ID', + label: 'ACT_ID', + component: 'Input', + show: false, + }, + { + field: 'ROT_ID', + label: 'ROT_ID', + component: 'Input', + show: false, + }, + { + field: 'NODE_ID', + label: 'NODE_ID', + component: 'Input', + show: false, + }, + { + field: 'NODE_NAME', + label: '宸ュ簭鑺傜偣鍚嶇О', + component: 'Input', + }, + { + field: 'CUST_CODE', + label: '瀹㈡埛缂栫爜', + component: 'Input', + dynamicDisabled: ({ values }) => { + return true; + }, + colProps: { span: 12 }, + }, + { + field: 'OPER_CODE', + label: '宸ュ簭缂栫爜', + component: 'Input', + }, + { + field: 'IS_ACTIVE', + label: '鏄惁鍚敤', + required: true, + component: 'Select', + colProps: { span: 12 }, + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + field: 'IS_CALC_FPY', + label: '鏄惁璁$畻鐩撮�氱巼', + required: true, + component: 'Select', + colProps: { span: 12 }, + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + field: 'CAN_SKIP', + label: '鏄惁鍏佽璺崇珯', + required: true, + component: 'Select', + colProps: { span: 12 }, + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + field: 'IS_INPUT', + label: '鏄惁鎶曞叆绔�', + required: true, + component: 'Select', + colProps: { span: 12 }, + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + field: 'IS_OUTPUT', + label: '鏄惁浜у嚭绔�', + required: true, + component: 'Select', + colProps: { span: 12 }, + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + field: 'ALLOW_DFT_IN', + label: '鏄惁鍏佽涓嶈壇鍝佽繘绔�', + required: true, + component: 'Select', + colProps: { span: 12 }, + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + field: 'IF_DFT_OFFLINE', + label: '鍒ゆ柇涓嶈壇鍚庢槸鍚︿笅绾�', + required: true, + defaultValue: 'N', + component: 'Select', + colProps: { span: 12 }, + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + ifShow: ({ values }) => values.OPER_CODE == 'TestNode', + }, + { + field: 'REMARK', + label: '澶囨敞', + component: 'Input', + colProps: { span: 12 }, + }, + ]; + + const crudForms = { + BAS_PKG_DTL: [ + { + label: '鍖呰瑙勫垯ID', + field: 'PKG_RULE_ID', + component: 'Input', + colProps: { + span: 24, + }, + dynamicDisabled: ({ values }) => { + return true; + }, + }, + { + label: '鍖呰灞傜骇', + field: 'PKG_LEVEL', + component: 'Input', + colProps: { + span: 24, + }, + dynamicDisabled: ({ values }) => { + return true; + }, + }, + { + field: 'PKG_CODE', + label: '鍖呰/杞藉叿缂栫爜', + component: 'Input', + colProps: { + span: 24, + }, + dynamicDisabled: ({ values }) => { + return true; + }, + }, + { + label: '鍖呰鏁伴噺', + field: 'PKG_QTY', + component: 'Input', + colProps: { + span: 24, + }, + dynamicDisabled: ({ values }) => { + return true; + }, + }, + { + field: 'LABEL_CODE', + label: '妯℃澘缂栫爜', + component: 'Input', + show: true, + // required: true, + colProps: { + span: 22, + }, + }, + { + field: 'BAS_LABEL_TEMP1PSelect_0', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+PSelect_0锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝PSelect_0杩欐槸涓浐瀹氬悗缂� + label: '1', + defaultValue: 'BAS_LABEL_TEMP', + component: 'Input', + colProps: { span: 2 }, + colSlot: 'BAS_LABEL_TEMP1add', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+add锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝add杩欐槸涓浐瀹氬悗缂� + }, + { + label: '鍖呰鍚嶇О', + field: 'PKG_NAME', + component: 'Input', + colProps: { + span: 24, + }, + show: false, + }, + { + label: '澶囨敞', + field: 'REMARK', + component: 'Input', + colProps: { + span: 24, + }, + dynamicDisabled: ({ values }) => { + return true; + }, + }, + { + label: 'ID', + field: 'ID', + component: 'Input', + colProps: { + span: 24, + }, + show: false, + }, + ] as FormSchema[], + ItemCode: [ + { + label: '鐗╂枡缂栫爜', + field: 'ITEM_CODE', + component: 'Input', + colProps: { + span: 24, + }, + dynamicDisabled: ({ values }) => { + return false; + }, + }, + { + field: 'RULE_CODE', + label: '瑙勫垯缂栫爜', + component: 'Input', + colProps: { + span: 22, + }, + dynamicDisabled: ({ values }) => { + return false; + }, + }, + { + field: 'BAS_CODE_RULE1PSelect_0', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+PSelect_0锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝PSelect_0杩欐槸涓浐瀹氬悗缂� + label: '1', + defaultValue: 'BAS_CODE_RULE', + component: 'Input', + colProps: { span: 2 }, + colSlot: 'BAS_CODE_RULE1add', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+add锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝add杩欐槸涓浐瀹氬悗缂� + }, + { + label: '鏄惁鎵规鐗╂枡', + field: 'IsBatchItem', + colProps: { + span: 24, + }, + component: 'Select', + componentProps: { + options: [ + { + label: '鏄�', + value: 'Y', + key: 'Y', + }, + { + label: '鍚�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + label: '涓婃枡鏁伴噺', + field: 'QTY', + component: 'Input', + colProps: { + span: 24, + }, + dynamicDisabled: ({ values }) => { + return false; + }, + }, + ] as FormSchema[], + }; + + /** + * @description: 妯℃澘缁存姢 + * @param {*} args + * @param {Recordable} params + * @return {*} + */ + function handleTemplate(args, params: Recordable) { + const openCrudModal = args[0]; + const OrderNo = args[2]; + openCrudModal(true, { + isUpdate: true, //鏄惁鏇存柊鎿嶄綔 + entityName: 'WoRouteBinding', //鏄摢涓〉闈� + ctype: 'BAS_LABEL_VAR_WO', //瀹炰綋鍚嶇О + title: '妯℃澘缁存姢', //鏍囬 + width: '1024px', //寮瑰嚭妗嗗搴� + ItemColumns: TemplateBasColumn, //寮瑰嚭妗嗕腑琛ㄦ牸瀛楁缁撴瀯 + schemas: [], //鏌ヨ鏉′欢瀛楁缁撴瀯 + others: { WORK_ORDER: OrderNo }, //闇�瑕佸甫鍒板脊鍑虹獥鍙d腑鐨勬暟鎹� + searchInfo: { + TABLE_NAME: 'BAS_LABEL_VAR_WO', //瀹炰綋鍚嶇О + LabelId: params['record'].LABEL_ID, //妯℃澘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: 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]; +} + +export default _default; diff --git a/src/views/tigerprojects/system/lowcode/high/dtl.vue b/src/views/tigerprojects/system/lowcode/high/dtl.vue index 4dd220c..975bbed 100644 --- a/src/views/tigerprojects/system/lowcode/high/dtl.vue +++ b/src/views/tigerprojects/system/lowcode/high/dtl.vue @@ -49,6 +49,7 @@ import { useI18n } from '/@/hooks/web/useI18n'; import { Card } from 'ant-design-vue'; import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel'; + import { useMessage } from '/@/hooks/web/useMessage'; const { t } = useI18n(); const ACard = Card; @@ -67,6 +68,7 @@ const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>; const go = useGo(); + const { createErrorModal } = useMessage(); const [registerItemAdd, { openModal: openItemModal }] = useModal(); const cType = ref(''); const dtlSlots = ref([] as any[]); @@ -183,7 +185,7 @@ useFormData, crudColSlots: isNullOrUnDef(objParams.value['crudColSlots']) ? [] - : objParams.value['crudColSlots'][item['name']], //鎻掓Ы鍒楄〃 + : objParams.value['crudColSlots'][item['name']], //鎻掓Ы鍒楄〃 data, name: item.name, //drawers鍒楄〃閲岄潰鐨刵ame锛岃〃绀烘槸鍝竴涓疄浣擄紝涔熷氨鏄珮绾ц〃鍗曚腑琛ㄦ牸鐨勫悕瀛� keyName: item.keyName, //瀹為檯鐢ㄦ潵纭畾鍔ㄦ�佸紩鍏ュ疄浣�.ts鐨勫疄浣撳悕绉� @@ -305,14 +307,21 @@ function handleSuccess(d, u, item) { if (!isNullOrUnDef(custImport.value)) { /* 鑷畾涔夌紪杈戞柟娉曪紝鏍规嵁瀹炰綋鍚嶅幓璋冪敤 */ - EditOperation(data, d, u, item); - useTables[item][1].setProps({ - dataSource: [], - }); - useTables[item][1].setProps({ - dataSource: data.value[item], - }); - useTables[item][1].reload(); + if (data.value[item].some((q) => q.ITEM_CODE == d.ITEM_CODE)) { + createErrorModal({ + title: t('sys.api.errorTip'), + content: t(`鏂欏彿[${d.ITEM_CODE}]宸茬粡瀛樺湪`), + }); + } else { + EditOperation(data, d, u, item); + useTables[item][1].setProps({ + dataSource: [], + }); + useTables[item][1].setProps({ + dataSource: data.value[item], + }); + useTables[item][1].reload(); + } } } diff --git a/src/views/tigerprojects/wms/createqrcode/index.vue b/src/views/tigerprojects/wms/createqrcode/index.vue index c074b91..2ff0333 100644 --- a/src/views/tigerprojects/wms/createqrcode/index.vue +++ b/src/views/tigerprojects/wms/createqrcode/index.vue @@ -27,7 +27,7 @@ </template> --> </a-list> </div> - <div class="w-2/4 xl:w-4/6 p-5" v-if="show"> + <div class="w-2/4 xl:w-4/6 p-5"> <!-- <CollapseContainer title="浜岀淮鐮�" class="text-center qrcode-demo-item"></CollapseContainer> --> <div class="mb-4 pt-4 text-center" style="width: 99%; background-color: white"> <QrCode @@ -46,7 +46,7 @@ </PageWrapper> </template> <script lang="ts" setup> - import { ref } from 'vue'; + import { onMounted, onUnmounted, ref } from 'vue'; import { List, ListItem, ListItemMeta } from 'ant-design-vue'; import { QrCode } from '/@/components/Qrcode/index'; import LogoImg from '/@/assets/images/logo.png'; @@ -57,6 +57,8 @@ import { useQrhisStore } from '/@/store/modules/qrhis'; import { storeToRefs } from 'pinia'; import { buildUUID } from '/@/utils/uuid'; + import printJS from 'print-js'; + import { useWebSocketStore } from '/@/store/modules/websocket'; const AList = List; const AListItem = ListItem; @@ -81,6 +83,7 @@ ]; let qrDatas: any[] = []; + const usewebSocket = useWebSocketStore(); const useQrhis = useQrhisStore(); const { hisData } = storeToRefs(useQrhis); const { createMessage } = useMessage(); @@ -135,6 +138,17 @@ createMessage.error('杈撳叆鐨勬潯鐮佷负绌�'); } } + const unsubscribe = usewebSocket.$subscribe((mutation, state) => { + if (state.printTag == qrCodeUrl.value) { + jsonPrint(state.printJson); + usewebSocket.SetPrintTag(''); + } + }); + + // 褰撶粍浠跺嵏杞芥椂鍙栨秷璁㈤槄 + onUnmounted(() => { + unsubscribe(); + }); /** * @description: 鏄剧ず浜岀淮鐮� @@ -168,6 +182,10 @@ }, pageSize: 10, }; + + function jsonPrint(option) { + printJS(option); + } </script> <style scoped> .qrcode-demo-item { -- Gitblit v1.9.3