From 5d3661fd40aa5fe0f669edb18b1c2aed458fb4e8 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 11 六月 2024 14:03:58 +0800 Subject: [PATCH] 低代码更新,工单更新 --- src/views/tigerprojects/system/lowcode/data.ts | 288 +++++++++ src/views/tigerprojects/system/lowcode/high/index.vue | 294 +++++++++ src/views/tigerprojects/system/lowcode/setting/pageDetail.vue | 432 +++++++++++- src/api/tigerapi/model/mesModel.ts | 33 + src/views/tigerprojects/system/lowcode/normal/normalDrawer.vue | 45 + /dev/null | 154 ---- src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue | 147 ++++ src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts | 45 + src/views/tigerprojects/mes/prod/biz_mes_wo/biz_mes_wo.data.ts | 2 src/layouts/default/menu/index.vue | 27 src/views/components/data.ts | 21 src/views/components/bizMesWo.ts | 183 +++++ src/api/tigerapi/system.ts | 9 src/views/tigerprojects/system/lowcode/normal/index.vue | 107 +++ src/views/components/CustModal.vue | 26 15 files changed, 1,533 insertions(+), 280 deletions(-) diff --git a/src/api/tigerapi/model/mesModel.ts b/src/api/tigerapi/model/mesModel.ts index 8569780..0bb755b 100644 --- a/src/api/tigerapi/model/mesModel.ts +++ b/src/api/tigerapi/model/mesModel.ts @@ -232,6 +232,39 @@ }; export type MesWslistPageParams = BasicPageParams & MES_WORKSHOPParams; +export interface BIZ_MES_WO_BATCH { + ID: string; + CREATE_TIME: Date; + CREATE_USER: string; + UPDATE_TIME: Date; + UPDATE_USER: string; + GHOST_ROW: boolean; + AUTH_ORG: string; + AUTH_PROD: string; + AUTH_WH: string; + ORDER_NO: string; + STATUS: number; + ITEM_CODE: string; + CUST_CODE: string; + FACTORY: string; + WS_CODE: string; + ACT_LINE: string; + ACT_START_TIME: Date; + ACT_END_TIME: Date; + STD_WORKER_QTY: number; + ACT_WORKER_QTY: number; + RELEASE_TIME: Date; + RELEASE_USER: string; + PLAN_QTY: number; + INPUT_QTY: number; + OUTPUT_QTY: number; + SCRAP_QTY: number; + STOCK_IN_QTY: number; + UPH: number; + UPPH: number; + REMARK: string; +} + export type OperPageListGetResultModel = BasicFetchResult<OperListItem>; export type CheckRulePageListGetResultModel = BasicFetchResult<CheckRuleListItem>; export type MeslinePageListGetResultModel = BasicFetchResult<MeslineListItem>; diff --git a/src/api/tigerapi/system.ts b/src/api/tigerapi/system.ts index c5651ec..6166ba1 100644 --- a/src/api/tigerapi/system.ts +++ b/src/api/tigerapi/system.ts @@ -673,7 +673,11 @@ ); }; -/* 閫氱敤鏌ヨ鍒嗛〉 */ +/** + * @description: 閫氱敤鏌ヨ鍒嗛〉 + * @param {T} params + * @return {*} + */ export async function getListByPage<T>(params: T) { const Keys = Object.getOwnPropertyNames(params); let sqlcmd = '1=1 '; @@ -687,7 +691,8 @@ Keys[k] != 'TABLE_NAME' && Keys[k] != 'order' && Keys[k] != 'field' && - Keys[k] != '0' + Keys[k] != '0' && + !Keys[k].toString().endsWith('PSelect_0') ) { if (!isNullOrEmpty(params[Keys[k]].length) && isTimeType(params[Keys[k]][0])) { sqlcmd += ` And ${Keys[k]} > '${params[Keys[k]][0]}'`; diff --git a/src/layouts/default/menu/index.vue b/src/layouts/default/menu/index.vue index cd1e773..974add8 100644 --- a/src/layouts/default/menu/index.vue +++ b/src/layouts/default/menu/index.vue @@ -15,10 +15,11 @@ import { useSplitMenu } from './useLayoutMenu'; import { openWindow } from '/@/utils'; import { propTypes } from '/@/utils/propTypes'; - import { isUrl } from '/@/utils/is'; + import { isNullOrUnDef, isUrl } from '/@/utils/is'; import { useRootSetting } from '/@/hooks/setting/useRootSetting'; import { useAppInject } from '/@/hooks/web/useAppInject'; import { useDesign } from '/@/hooks/web/useDesign'; +import { getEntity } from '/@/api/tigerapi/system'; export default defineComponent({ name: 'LayoutMenu', @@ -110,10 +111,30 @@ * @param menu */ - function handleMenuClick(path: string) { + function handleMenuClick(path: string) { if (path.split('/').length > 1 && path.split('/')[2] == 'LC') { - const id = { ID: path.split('/')[1] }; + getEntity({ + sqlcmd: `ASSEMBLY_NAME ='${path.split('/')[1]}'`, + entityName: 'SYS_LOW_CODE', + }).then((data) => { + var searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON); + let colSlots = [] as string[]; + for (const i in searchForms) { + if(!isNullOrUnDef(searchForms[i]['colSlot'])){ + colSlots.push('form-'+searchForms[i]['colSlot']); + } + } + + var _cruds = JSON.parse(data.Data.Items[0].FORM_JSON); + let crudColSlots = [] as string[]; + for (const i in _cruds) { + if(!isNullOrUnDef(_cruds[i]['colSlot'])){ + crudColSlots.push(_cruds[i]['colSlot']); + } + } + const id = { ID: path.split('/')[1], colSlots: colSlots, crudColSlots: crudColSlots }; go(`/${path.split('/')[1]}/${path.split('/')[2]}/${encodeURI(JSON.stringify(id))}`); + }); } else { go(path); } diff --git a/src/views/components/CustModal.vue b/src/views/components/CustModal.vue index ac65729..f655785 100644 --- a/src/views/components/CustModal.vue +++ b/src/views/components/CustModal.vue @@ -1,3 +1,11 @@ +<!-- + * @Description: 鑷畾涔夊脊鍑烘锛屽彲浠ヨ嚜瀹氫箟澶氫釜琛ㄥ崟 + * @Author: Ben Lin + * @version: + * @Date: 2024-06-05 15:46:07 + * @LastEditors: your name + * @LastEditTime: 2024-06-10 23:48:05 +--> <template> <BasicModal v-bind="$attrs" @@ -42,6 +50,7 @@ const title = ref(''); const width = ref(''); const FnName = ref({}); + const mValues = ref<Recordable>({}); const initFnName = ref({}); const dtlSlots = ref([] as any[]); const formSchema = ref([] as FormSchema[]); @@ -71,13 +80,14 @@ formElName.value = data?.formElName; //寮规涓〃鍗曞悕瀛楁暟缁� useFormData.value = data?.formEl; //寮规涓〃鍗曞疄渚嬫暟缁� FnName.value = data?.fnName; //淇濆瓨鏁版嵁鏂规硶 + mValues.value = data?.values; //涓昏〃鍗曚紶杩囨潵鐨勬暟鎹� //寰幆琛ㄥ崟鍚嶆暟缁勶紝鎿嶄綔鍚勮〃鍗曞瓧娈� formElName.value.forEach((name) => { if (!isNullOrUnDef(useFormData.value[name])) { useFormData.value[name][1].resetFields(); if (unref(isUpdate)) { useFormData.value[name][1].setFieldsValue({ - ...data, + ...mValues.value, }); } } @@ -85,7 +95,13 @@ //鍒濆鍖栨柟娉曡嚜瀹氫箟 if (!isNullOrEmpty(data?.initFnName)) { initFnName.value = data?.initFnName; - custFunction(unref(isUpdate.value), initFnName.value[cType.value], cType.value); + custFunction( + unref(isUpdate.value), + initFnName.value[cType.value], + cType.value, + mValues.value, + data?.others, + ); } }); @@ -97,7 +113,10 @@ // { deep: true }, // ); - /* 寮规纭畾鎸夐挳鏂规硶 */ + /** + * @description: 寮规纭畾鎸夐挳鏂规硶 + * @return {*} + */ async function handleSuccess() { try { var values = {} as any; @@ -109,6 +128,7 @@ } setModalProps({ confirmLoading: true }); //璋冪敤鑷畾涔変繚瀛樻柟娉曚繚瀛樻暟鎹� + values['mValues'] = mValues.value; const action = await custFunction(values, FnName.value[cType.value], cType.value); if (action as boolean) { closeModal(); diff --git a/src/views/components/bizMesWo.ts b/src/views/components/bizMesWo.ts index dc2c34a..9ac2295 100644 --- a/src/views/components/bizMesWo.ts +++ b/src/views/components/bizMesWo.ts @@ -1,3 +1,11 @@ +/* + * @Description: 宸ュ崟鑷畾涔夋柟娉晅s + * @Author: Ben Lin + * @version: + * @Date: 2024-06-05 16:10:24 + * @LastEditors: your name + * @LastEditTime: 2024-06-10 23:49:39 + */ /* 宸ュ崟鐩稿叧鑷畾涔夋柟娉� */ import { FunctionType } from '/@/api/tigerapi/model/systemModel'; import { GetEnum, SaveEntity, getEntity } from '/@/api/tigerapi/system'; @@ -6,11 +14,27 @@ import { useI18n } from '/@/hooks/web/useI18n'; import { uploadApi } from '/@/api/sys/upload'; import { useLocale } from '/@/locales/useLocale'; -import { unref } from 'vue'; +import { ref, unref } from 'vue'; +import { BIZ_MES_WO_BATCH } from '/@/api/tigerapi/model/mesModel'; +import { buildUUID } from '/@/utils/uuid'; +import LogicFlow from '@logicflow/core'; +import { BpmnElement } from '@logicflow/extension'; +import { getRouteData } from '/@/api/tigerapi/mes/router'; +import customEdge from '/@/components/FlowChart/src/customEdge'; +import actionRect from '/@/components/FlowChart/src/actionRect'; +import TestNode from '/@/components/FlowChart/src/TestNode'; +import CollectNode from '/@/components/FlowChart/src/CollectNode'; +import AssemblyNode from '/@/components/FlowChart/src/AssemblyNode'; +import PackingNode from '/@/components/FlowChart/src/PackingNode'; +import RepairNode from '/@/components/FlowChart/src/RepairNode'; const { t } = useI18n(); const { getLocale } = useLocale(); -/* 鑷畾涔夋柟娉� */ + +/** + * @description: 鑷畾涔夋柟娉� + * @return {*} + */ export const getWoFns: Record<string, FunctionType> = { handleSubmit: async (e, ...args) => { const values = await args[0][0].validate(); @@ -49,29 +73,150 @@ } }); }, - //宸ュ崟閰嶇疆淇濆瓨鏂规硶 + + /** + * @description: 宸ュ崟閰嶇疆淇濆瓨鏂规硶 + * @param {*} e + * @param {array} args + * @return {*} + */ SaveCofig: (e, ...args) => { return new Promise((resolve, reject) => { try { - const xx = e['prodinfo']; - resolve(true); + const form = e['prodinfo']; + const wo = e['mValues']; + wo.ROUTE_STATUS = 1; + SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => { + if (action.IsSuccessed) { + resolve(true); + } else { + reject(false); + } + }); } catch { reject(false); - } finally { - args[0][0]({ confirmLoading: false }); } }); }, - //宸ュ崟涓嬪彂淇濆瓨鏂规硶 + /** + * @description: 宸ュ崟涓嬪彂淇濆瓨鏂规硶 + * @param {*} e + * @param {array} args + * @return {*} + */ SaveWoBatch: (e, ...args) => { return new Promise((resolve, reject) => { try { - const xx = e['forminfo']; + const form = e['forminfo']; + const wo = e['mValues']; + wo.ROUTE_CODE = form.ROUTE_CODE; + wo.STATUS = 2; + const woBatch: BIZ_MES_WO_BATCH = { + ID: buildUUID(), + CREATE_TIME: new Date(), + CREATE_USER: useUserStore().getUserInfo.userId as string, + UPDATE_TIME: new Date(), + UPDATE_USER: useUserStore().getUserInfo.userId as string, + GHOST_ROW: false, + AUTH_ORG: '', + AUTH_PROD: useUserStore().getUserInfo.prodCode as string, + AUTH_WH: '', + ORDER_NO: wo.ORDER_NO, + STATUS: wo.STATUS, + ITEM_CODE: wo.ITEM_CODE, + CUST_CODE: wo.CUST_CODE, + FACTORY: wo.FACTORY, + WS_CODE: wo.WS_CODE, + ACT_LINE: form.PLAN_LINE, + STD_WORKER_QTY: wo.STD_WORKER_QTY, + ACT_WORKER_QTY: wo.ACT_WORKER_QTY, + RELEASE_TIME: new Date(), + RELEASE_USER: useUserStore().getUserInfo.userId as string, + PLAN_QTY: wo.PLAN_QTY, + INPUT_QTY: wo.INPUT_QTY, + OUTPUT_QTY: wo.OUTPUT_QTY, + SCRAP_QTY: wo.SCRAP_QTY, + STOCK_IN_QTY: wo.STOCK_IN_QTY, + UPH: wo.UPH, + UPPH: wo.UPPH, + REMARK: wo.REMARK, + ACT_START_TIME: wo.ACT_START_TIME, + ACT_END_TIME: wo.ACT_END_TIME, + }; + SaveEntity(woBatch, false, 'BIZ_MES_WO_BATCH').then((action) => { + if (action.IsSuccessed) { + SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => { + if (action.IsSuccessed) { + resolve(true); + } else { + reject(false); + } + }); + } else { + reject(false); + } + }); + } catch { + reject(false); + } + }); + }, + initRoute: async (e, ...args) => { + const _data = await getRouteData(args[0][0].ROUTE_CODE); + args[0][1] = ref({ + nodes: [], + edges: [], + }); + return new Promise((resolve, reject) => { + try { + LogicFlow.use(BpmnElement); + const lf = new LogicFlow({ + container: document.querySelector('#lfContainer'), + edgeGenerator: (sourceNode) => { + // console.log('a'); + // 璧峰鑺傜偣绫诲瀷 rect 鏃朵娇鐢� 鑷畾涔夌殑杈� custom-edge + if (sourceNode.properties.isReturn) return 'custom-edge'; + // if (sourceNode.type === 'rect') return 'custom-edge'; + // return 'custom-edge'; + }, + }); + lf.register(customEdge); + lf.register(actionRect); + lf.register(TestNode); + lf.register(CollectNode); + lf.register(AssemblyNode); + lf.register(PackingNode); + lf.register(RepairNode); + lf.render({}); + //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋 + console.log('缁勪欢宸叉寕杞�', _data); + //宸ヨ壓璺嚎鍏ㄤ俊鎭紝鍖呮嫭Node銆丒dge鍜孉ct + // routeConfig.routeData = _data.Data; + if (_data.Data != null) { + //宸ヨ壓璺嚎涓讳俊鎭� + const currRoute = _data.Data.route; + _data.Data.nodes.forEach((n) => { + n.node.properties = JSON.parse(n.node.properties); + args[0][1].value.nodes.push(n.node); + }); + console.log('111', args[0][1]); + _data.Data.edges.forEach((e) => { + e.edge.properties = JSON.parse(e.edge.properties); + args[0][1].value.edges.push(e.edge); + }); + _data.Data.acts.forEach((act) => { + act.node.properties = JSON.parse(act.node.properties); + args[0][1].value.nodes.push(act.node); + }); + console.log('init', unref(lf).getGraphData(), JSON.parse(JSON.stringify(args[0][1]))); + lf.render(args[0][1].value); + // lf.graphModel.resize(500, 400); + lf.graphModel.fitView(); + lf.graphModel.translateCenter(); + } resolve(true); } catch { reject(false); - } finally { - args[0][0]({ confirmLoading: false }); } }); }, @@ -306,7 +451,12 @@ }, ]; -//宸ヨ壓璺嚎寮规杩斿洖 +/** + * @description: 宸ヨ壓璺嚎寮规杩斿洖 + * @param {*} d + * @param {*} u + * @return {*} + */ export function woGetSelectSuccess(d, u) { return { ROUTE_CODE: d.values['val'], @@ -314,7 +464,14 @@ }; } -/* 鑷畾涔夋ā鎬佹鎵撳紑鏂规硶 */ +/** + * @description: 鑷畾涔夋ā鎬佹鎵撳紑鏂规硶 + * @param {Fn} openModal + * @param {string} slotName + * @param {Fn} others + * @param {array} args + * @return {*} + */ export function woCustFn(openModal: Fn, slotName: string, others: Fn[], ...args) { switch (slotName) { case 'add': diff --git a/src/views/components/data.ts b/src/views/components/data.ts index cbb4c0b..2213193 100644 --- a/src/views/components/data.ts +++ b/src/views/components/data.ts @@ -1,3 +1,11 @@ +/* + * @Description: 鑷畾涔夊脊鍑烘璇锋暟鎹� + * @Author: Ben Lin + * @version: + * @Date: 2024-06-05 15:50:59 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-10 23:55:12 + */ import { getWoFns, woGetSelectSuccess, @@ -60,7 +68,13 @@ return _formSchema; } -/* 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛 */ +/** + * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛 + * @param {*} d + * @param {*} u + * @param {string} entityName + * @return {*} + */ export function GetSelectSuccess(d, u, entityName: string) { let data = {}; switch (entityName) { @@ -77,7 +91,10 @@ return data; } -/* 鎵撳紑寮瑰嚭閫夋嫨妗� */ +/** + * @description: 鎵撳紑寮瑰嚭閫夋嫨妗� + * @return {*} + */ export function OpenSelectItem( openItemModal: Fn, entityName: string, diff --git a/src/views/tigerprojects/mes/prod/biz_mes_wo/biz_mes_wo.data.ts b/src/views/tigerprojects/mes/prod/biz_mes_wo/biz_mes_wo.data.ts index 76778f5..12b9e0f 100644 --- a/src/views/tigerprojects/mes/prod/biz_mes_wo/biz_mes_wo.data.ts +++ b/src/views/tigerprojects/mes/prod/biz_mes_wo/biz_mes_wo.data.ts @@ -55,7 +55,7 @@ sorter: true, resizable: true, customRender: ({ record }) => { - const status = record.STATUS; + const status = record.ROUTE_STATUS; let text = ''; let color = ''; switch (status) { diff --git a/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue b/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue index 672314f..acd731b 100644 --- a/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue +++ b/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue @@ -1,3 +1,11 @@ +<!-- + * @Description: 宸ュ崟绠$悊椤甸潰 + * @Author: Ben Lin + * @version: + * @Date: 2024-05-25 00:27:00 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-10 23:54:01 +--> <template> <div> <BasicTable @register="registerTable"> @@ -110,7 +118,7 @@ import { useMessage } from '/@/hooks/web/useMessage'; import { useI18n } from '/@/hooks/web/useI18n'; import { useModal } from '/@/components/Modal'; - import { getListByPage } from '/@/api/tigerapi/system'; + import { SaveEntity, getListByPage } from '/@/api/tigerapi/system'; import { GetSelectSuccess, OpenSelectItem, getFormSchema } from '/@/views/components/data'; import LogicFlow from '@logicflow/core'; import { getRouteData } from '/@/api/tigerapi/mes/router'; @@ -121,7 +129,7 @@ import PackingNode from '/@/components/FlowChart/src/PackingNode'; import RepairNode from '/@/components/FlowChart/src/RepairNode'; import customEdge from '/@/components/FlowChart/src/customEdge'; - import { Snapshot, BpmnElement, Menu, DndPanel, SelectionSelect } from '@logicflow/extension'; + import { BpmnElement } from '@logicflow/extension'; const { t } = useI18n(); const ASteps = Steps; @@ -131,7 +139,7 @@ const mtitle = ref('宸ュ崟鍒楄〃'); const dtlSlots = ref([] as any[]); const selectVals = ref({}); - const { createMessage } = useMessage(); + const { createMessage, createErrorModal } = useMessage(); const [registerDrawer, { openDrawer }] = useDrawer(); const compState = reactive({ absolute: false, @@ -171,7 +179,6 @@ const formSchema = ref([] as FormSchema[]); const woSchema = ref([] as FormSchema[]); const prodSchema = ref([] as FormSchema[]); - const rotSchema = ref([] as FormSchema[]); const isCustEl = ref({ forminfo: false, woinfo: false, @@ -262,6 +269,7 @@ woSchema.value = getFormSchema('woinfo'); prodSchema.value = getFormSchema('prodinfo'); // rotSchema.value = getFormSchema('rotinfo'); + //宸ヨ壓璺嚎娓叉煋鍥惧垵濮嬪寲 if (lfInstance.value != null) { routeData.value = { nodes: [], @@ -270,6 +278,7 @@ const lf = unref(lfInstance)!; lf.render({}); } + selectVals.value['ROUTE_CODE'] = record.ROUTE_CODE; openCustModal(true, { isUpdate: true, ctype: cType, @@ -279,13 +288,27 @@ formElName: ['woinfo', 'prodinfo', 'rotinfo'], //琛ㄥ崟鎻掓Ы鍚嶇О锛屾敮鎸佸涓〃鍗� RowKey: '', fnName: { BIZ_MES_WO_Config: 'SaveCofig' }, //淇濆瓨鏂规硶鍚� - initFnName: {}, //鍒濆鍖栨柟娉曞悕 + initFnName: { BIZ_MES_WO_Config: 'initRoute' }, //鍒濆鍖栨柟娉曞悕 isCustEl: isCustEl.value, - ...record, + others: routeData.value, + values: record, //琛ㄥ崟璁板綍 }); } - //涓嬪彂 + + /** + * @description: 涓嬪彂 + * @param {*} record + * @return {*} + */ function handleRelease(record: Recordable) { + if (record.STATUS == 2) { + createErrorModal({ + title: t('璀﹀憡'), + content: t('宸ュ崟宸茬粡涓嬪彂锛屼笉鑳藉啀涓嬪彂锛�'), + getContainer: () => document.body, + }); + return; + } cType.value = 'BIZ_MES_WO'; dtlSlots.value = [ { @@ -307,20 +330,70 @@ fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //淇濆瓨鏂规硶鍚� initFnName: {}, //鍒濆鍖栨柟娉曞悕 isCustEl: isCustEl.value, - ...record, + values: record, //琛ㄥ崟璁板綍 }); } - function custSuccess(d) { - reload(); + + /** + * @description: 鍙栨秷涓嬪彂 + * @param {*} record + * @return {*} + */ + function handleUnRelease(record: Recordable) { + if (record.STATUS == 0) { + createErrorModal({ + title: t('璀﹀憡'), + content: t('宸ュ崟鏄垵濮嬪寲鐘舵�侊紝涓嶈兘鍙栨秷涓嬪彂锛�'), + getContainer: () => document.body, + }); + return; + } + record.STATUS = 0; + SaveEntity(record, true, 'BIZ_MES_WO').then((action) => { + if (action.IsSuccessed) { + createMessage.success(t('宸插彇娑堜笅鍙�')); + reload(); + } else { + createMessage.success(t('鍙栨秷涓嬪彂鎿嶄綔澶辫触')); + } + }); } - //鍙栨秷涓嬪彂 - function handleUnRelease(record: Recordable) {} //鏆傚仠 - function handlePause(record: Recordable) {} - //鍒犻櫎 + function handlePause(record: Recordable) { + if (record.STATUS == 0) { + createErrorModal({ + title: t('璀﹀憡'), + content: t('宸ュ崟鏄垵濮嬪寲鐘舵�侊紝涓嶈兘鏆傚仠锛�'), + getContainer: () => document.body, + }); + return; + } + if (record.STATUS == 5) { + createErrorModal({ + title: t('璀﹀憡'), + content: t('宸ュ崟鏄畬鎴愮姸鎬侊紝涓嶈兘鏆傚仠锛�'), + getContainer: () => document.body, + }); + return; + } + record.STATUS = 4; + SaveEntity(record, true, 'BIZ_MES_WO').then((action) => { + if (action.IsSuccessed) { + createMessage.success(t('宸叉殏鍋�')); + reload(); + } else { + createMessage.success(t('鏆傚仠鎿嶄綔澶辫触')); + } + }); + } + + /** + * @description: 鍒犻櫎 + * @param {*} record + * @return {*} + */ function handleDelete(record: Recordable) { - const apiAction = DeleteMesWo(record.ID); - apiAction.then((action) => { + DeleteMesWo(record.ID).then((action) => { if (action.IsSuccessed) { createMessage.success(t('宸插垹闄�')); reload(); @@ -329,7 +402,20 @@ } }); } - //鐐瑰嚮鎵撳紑鐗╂枡鍒楄〃妗� + + /** + * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥� + * @param {*} d + * @return {*} + */ + function custSuccess(d) { + reload(); + } + + /** + * @description: 鐐瑰嚮鎵撳紑鐗╂枡鍒楄〃妗� + * @return {*} + */ function handleSelectItem() { openItemModal(true, { title: '鐗╂枡鍒楄〃', @@ -364,28 +450,45 @@ }); } + /** + * @description: 寮瑰嚭閫夋嫨鐗╂枡妗嗚繑鍥炴垚鍔熸柟娉� + * @param {*} d + * @param {*} u + * @return {*} + */ function handleItemSuccess(d, u) { getForm().setFieldsValue({ ITEM_CODE: d.values['val'], }); } - /* 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� */ + + /** + * @description: 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ function handleEntSuccess(d, u, item) { var values = GetSelectSuccess(d, u, cType.value); selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� let _val = {}; _val[d.returnFieldName] = values[d.returnFieldName]; useFormData.value[item][1].setFieldsValue(_val); - if (d.returnFieldName == 'ROUTE_CODE') { + if (d.returnFieldName == 'ROUTE_CODE' && cType.value == 'BIZ_MES_WO_Config') { routeData.value = { nodes: [], edges: [], }; - init(selectVals.value['ID']); + init(selectVals.value['ROUTE_CODE']); } } - /* 寮瑰嚭閫夋嫨妗� */ + /** + * @description: 寮瑰嚭閫夋嫨妗� + * @param {*} item + * @return {*} + */ function handleCustClick(item) { //鎵撳紑鑷畾涔夋ā鎬佹 OpenSelectItem( @@ -393,7 +496,7 @@ cType.value, item, [openRvModal], - selectVals.value['ID'], + selectVals.value['ROUTE_CODE'], ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹� } function RvItemSuccess(d, u) {} diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts new file mode 100644 index 0000000..1f84651 --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/data.ts @@ -0,0 +1,288 @@ +/* + * @Description: 閫氱敤浣庝唬鐮佸憟鐜伴〉闈富鏁版嵁 + * @Author: Ben Lin + * @version: + * @Date: 2024-06-02 17:52:35 + * @LastEditors: your name + * @LastEditTime: 2024-06-11 01:59:13 + */ +import { ref } from 'vue'; +import { + DftGrpRelease, + dftGrpActionItem, + dftGrpOpenSelectItem, + dftGrpGetSelectSuccess, + dftGrpactionColumn, +} from './normal/basDefectGrp'; +import { onChangeFns, rsGrpGetSelectSuccess, rsGrpOpenSelectItem } from './normal/basReasonGrp'; +import { DeleteEntity } from '/@/api/tigerapi/system'; +import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table'; +import { useI18n } from '/@/hooks/web/useI18n'; +import { isNullOrEmpty } from '/@/utils/is'; +import { woCustFn, woformSchema } from '/@/views/components/bizMesWo'; +import { useModal } from '/@/components/Modal'; + +const { t } = useI18n(); + +/** + * @description: 浣庝唬鐮侀〉闈㈣幏鍙栨搷浣滃瓧娈电粨鏋凧son锛屽澧炲姞鎸夐挳鍙婃柟娉� + * @param {*} params + * @param {array} args + * @return {*} + */ +export function GetActionsData(params: {}, ...args: Fn[]) { + let data = [ + { + icon: 'clarity:note-edit-line', + onClick: editRecord.bind(null, args[0], params), + }, + { + icon: 'ant-design:delete-outlined', + color: 'error', + popConfirm: { + title: '鏄惁纭鍒犻櫎?', + placement: 'left', + confirm: deleteRecord.bind(null, args[1], params), + }, + }, + ] as ActionItem[]; + switch (params['entityName']) { + case 'BAS_DEFECT_GRP': + const _d = dftGrpActionItem; + _d[0].onClick = DftGrpRelease.bind(null, args, params); + data = [...data, ..._d]; + params.cType.value = 'BIZ_MES_WO'; + params.formSchemas.value[params.cType.value] = getFormSchema(params.cType.value); + params.useFormData.value = { + forminfo: args[3]({ + labelWidth: 120, + schemas: params.formSchemas.value[params.cType.value], + actionColOptions: { + span: 24, + }, + showActionButtonGroup: false, + }), + }; + break; + } + return data; +} + +export function GetUseModalData(type: string) { + let data = {}; + switch (type) { + case 'BAS_DEFECT_GRP': + data = { + add: useModal(), + set: useModal(), + addRot: useModal(), + setRot: useModal(), + }; + break; + } + return data; +} + +function editRecord(fn: Fn, params: {}) { + fn(true, params); +} + +function deleteRecord(fn: Fn, params: {}) { + console.log(params['record']); + //鍒犻櫎 + const apiAction = DeleteEntity(params['record'], params['entityName']); + apiAction.then((action) => { + if (action.IsSuccessed) { + fn(); + } + }); +} + +export function GetActionColumn(entityName: string) { + let data: BasicColumn = {}; + switch (entityName) { + case 'BAS_DEFECT_GRP': + data = dftGrpactionColumn; + break; + default: + data = { + width: 80, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: undefined, + }; + break; + } + return data; +} + +/* 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛 */ +export function GetSelectSuccess(d, u, entityName: string) { + let data = {}; + switch (entityName) { + case 'BAS_DEFECT_GRP': + data = dftGrpGetSelectSuccess(d, u); + break; + case 'BAS_REASON_GRP': + data = rsGrpGetSelectSuccess(d, u); + break; + default: + data = { + ITEM_CODE: d.values['val'], + }; + break; + } + return data; +} + +/** + * @description: 鎵撳紑寮瑰嚭閫夋嫨妗� + * @param {Fn} openItemModal + * @param {string} entityName + * @return {*} + */ +export function OpenSelectItem(openItemModal: Fn, entityName: string) { + switch (entityName) { + case 'BAS_DEFECT_GRP': + dftGrpOpenSelectItem(openItemModal); + break; + case 'BAS_REASON_GRP': + rsGrpOpenSelectItem(openItemModal); + break; + default: + openItemModal(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', + }); + break; + } +} + +/** + * @description: Select 鑷畾涔塷nChange鏂规硶 + * @param {any} e + * @param {string} fnName + * @param {string} entityName + * @return {*} + */ +export function custOnChange(e: any, fnName: string, entityName: string) { + if (!isNullOrEmpty(fnName)) { + switch (entityName) { + case 'BAS_REASON': + onChangeFns[fnName](e); + break; + default: + break; + (e) => {}; + } + } else { + (e) => {}; + } +} + +/** + * @description: 鎵撳紑鑷畾涔夊脊鍑烘鏂规硶 + * @return {*} + */ +export function OpenCustModal( + openItemModal: Fn, + entityName: string, + slotName: string, + others: Fn[], + ...args +) { + switch (entityName) { + case 'BIZ_MES_WO': + case 'BIZ_MES_WO_Config': //鏍规嵁甯﹀叆鐨勫悕绉版墦寮�涓嶅悓鐨勫疄浣撳垪琛� + woCustFn(openItemModal, slotName, others, args); + break; + default: //榛樿鎵撳紑鐗╂枡鍒楄〃 + openItemModal(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', + }); + break; + } +} + +/** + * @description: 鑾峰彇鑷畾涔夊脊鍑烘涓〃鍗曠殑缁撴瀯 + * @param {string} type + * @return {*} + */ +export function getFormSchema(type: string) { + let _formSchema = [] as FormSchema[]; + switch (type) { + case 'BIZ_MES_WO': + _formSchema = woformSchema; + break; + // case 'woinfo': + // _formSchema = woCfgformSchema; + // break; + // case 'prodinfo': + // _formSchema = prodCfgformSchema; + // break; + // case 'xxinfo': + // _formSchema = xxCfgformSchema; + // break; + default: + break; + (e) => {}; + } + return _formSchema; +} diff --git a/src/views/tigerprojects/system/lowcode/high/index.vue b/src/views/tigerprojects/system/lowcode/high/index.vue new file mode 100644 index 0000000..2cb63d2 --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/high/index.vue @@ -0,0 +1,294 @@ +<!-- + * @Description: 浣庝唬鐮侀珮绾у憟鐜伴〉闈� + * @Author: Ben Lin + * @version: + * @Date: 2024-05-30 13:28:20 + * @LastEditors: your name + * @LastEditTime: 2024-06-11 02:02:14 +--> +<template> + <div> + <BasicTable @register="registerTable"> + <template #toolbar> + <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 鏂板 </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" + /> + <NormalModal @register="registerItemAdd" @success="(d, u) => handleItemSuccess(d, u, item)" /> + </template> + </BasicTable> + <normalDrawer @register="registerDrawer" @success="handleSuccess" /> + <CustModal + @register="registerCust" + @success="custSuccess" + :type="cType" + :detailSlots="dtlSlots" + > + <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� --> + <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]" + /> + <NormalModal + @register="useModalData[name][0]" + @success="(d, u) => handleEntSuccess(d, u, item.name)" + /> + </template> + </BasicForm> + <!-- 鑷畾涔夊唴瀹� --> + </template> + </CustModal> + </div> +</template> +<script lang="ts" setup> + import { h, onMounted, ref, unref } from 'vue'; + import { BasicTable, useTable, TableAction, BasicColumn, FormSchema } from '/@/components/Table'; + import { useDrawer } from '/@/components/Drawer'; + import normalDrawer from './normalDrawer.vue'; + import NormalModal from '/@/views/components/NormalModal.vue'; + import { GetEnum, getEntity, getListByPage } from '/@/api/tigerapi/system'; + import { useGlobSetting } from '/@/hooks/setting'; + import { useRoute } from 'vue-router'; + import { Tag, Tooltip } from 'ant-design-vue'; + import CustModal from '/@/views/components/CustModal.vue'; + import { BasicForm, FormActionType, useForm } from '/@/components/Form/index'; + import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; + import { + GetActionColumn, + GetActionsData, + OpenSelectItem, + GetSelectSuccess, + custOnChange, + getFormSchema, + OpenCustModal, + GetUseModalData, + } from './data'; + import { useModal } from '/@/components/Modal'; + import { useLocale } from '/@/locales/useLocale'; + + const { getLocale } = useLocale(); + const route = useRoute(); + const objParams = ref(JSON.parse(decodeURI(route.params?.id as string))); + const entityName = ref(objParams.value.ID); + const globSetting = useGlobSetting(); + const _columns = ref([]); + const _searchFormSchema = ref([]); + const _crudFormSchema = ref([]); + const formSchemas = ref({}); //寮瑰嚭妗嗗琛ㄥ崟缁撴瀯 + const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 + const useFormData = ref({}); + const colSlots = ref<any>(objParams.value.colSlots); //鎸夐挳鎻掓Ы + const crudColSlots = ref<any>(objParams.value.crudColSlots); + const cType = ref(''); + const dtlSlots = ref([] as any[]); + const selectVals = ref({}); + + const [registerCust, { openModal: openCustomModal, closeModal }] = useModal(); + const [registerItemAdd, { openModal: openItemModal }] = useModal(); + const [registerDrawer, { openDrawer }] = useDrawer(); + const [registerTable, { getForm, reload }] = useTable({ + title: '鍒楄〃淇℃伅', + api: getListByPage, + searchInfo: { TABLE_NAME: objParams.value.ID }, + columns: _columns as unknown as BasicColumn[], + formConfig: { + labelWidth: 140, + schemas: _searchFormSchema as unknown as FormSchema[], + }, + useSearchForm: true, + showTableSetting: true, + bordered: true, + canResize: true, + showIndexColumn: false, + actionColumn: GetActionColumn(objParams.value.ID), //鑷畾涔夋搷浣滃垪 + }); + /* 鐢熸垚鍒楄〃涓搷浣滈」鐨勬寜閽� */ + function createActions(record) { + return GetActionsData( + { + record, + isUpdate: true, + entityName: objParams.value.ID, + formJson: _crudFormSchema.value, + cType, + dtlSlots, + formSchemas, + useModalData, + useFormData, + crudColSlots, + }, + openDrawer, + reload, + openCustomModal, + useForm, + useModal, + ); + } + + function handleCreate() { + openDrawer(true, { + isUpdate: false, + entityName: objParams.value.ID, + formJson: _crudFormSchema.value, + crudColSlots, + }); + } + + function handleSuccess() { + reload(); + } + + onMounted(async () => { + /* 鐢╦son鑾峰彇鍒� */ + // _searchFormSchema.value = await fetchJson( + // `${globSetting.downloadUrl}/LowCode/${objParams.value.ID}/${objParams.value.ID}_Searchform.json`, + // ); + // var objs = await fetchJson( + // `${globSetting.downloadUrl}/LowCode/${objParams.value.ID}/${objParams.value.ID}_Baseform.json`, + // ); + // for (const i in objs) { + // if (!isNullOrEmpty(objs[i].customRender)) { + // const func = new Function(objs[i].customRender)(); + // objs[i].customRender = ({ record }) => { + // let texts = func(record); + // return h(Tooltip, { title: texts.text }, () => + // h(Tag, { color: texts.color }, () => texts.text), + // ); + // }; + // } + // } + // _columns.value = objs; + + //鑾峰彇琛ㄥ崟涓彃妲芥覆鏌撶殑鎸夐挳鐐瑰嚮寮瑰嚭妯℃�佺獥鍙g殑瀹炰緥 + useModalData.value = GetUseModalData(objParams.value.ID); + const data = await getEntity({ + sqlcmd: "ASSEMBLY_NAME ='" + objParams.value.ID + "'", + entityName: 'SYS_LOW_CODE', + }); + var searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON); + for (const i in searchForms) { + if ( + !isNullOrEmpty(searchForms[i].componentProps) && + !isNullOrEmpty(searchForms[i].componentProps.api) && + searchForms[i].componentProps.api == 'GetEnum' + ) { + searchForms[i].componentProps.api = GetEnum; + searchForms[ + i + ].componentProps.params.name = `${objParams.value.ID}+${searchForms[i].field}s`; + searchForms[i].componentProps.labelField = unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name'; + } + if ( + !isNullOrEmpty(searchForms[i].componentProps) && + !isNullOrEmpty(searchForms[i].componentProps.api) && + searchForms[i].componentProps.api == 'getEntity' + ) { + searchForms[i].componentProps.api = getEntity; + searchForms[i].componentProps.resultField = 'Data.Items'; + } + onChangeConfig(searchForms[i]); + } + _searchFormSchema.value = searchForms; + var _cruds = JSON.parse(data.Data.Items[0].FORM_JSON); + for (const i in _cruds) { + if ( + !isNullOrEmpty(_cruds[i].componentProps) && + !isNullOrEmpty(_cruds[i].componentProps.api) && + _cruds[i].componentProps.api == 'GetEnum' + ) { + _cruds[i].componentProps.api = GetEnum; + _cruds[i].componentProps.params.name = `${objParams.value.ID}+${_cruds[i].field}s`; + _cruds[i].componentProps.labelField = unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name'; + } + if ( + !isNullOrEmpty(_cruds[i].componentProps) && + !isNullOrEmpty(_cruds[i].componentProps.api) && + _cruds[i].componentProps.api == 'getEntity' + ) { + _cruds[i].componentProps.api = getEntity; + _cruds[i].componentProps.resultField = 'Data.Items'; + } + onChangeConfig(_cruds[i]); + } + _crudFormSchema.value = _cruds; + + var objs = JSON.parse(data.Data.Items[0].BASE_FORM_JSON); + for (const i in objs) { + if (!isNullOrEmpty(objs[i].customRender)) { + const func = new Function(objs[i].customRender)(); + objs[i].customRender = ({ record }) => { + let texts = func(record); + return h(Tooltip, { title: texts.text }, () => + h(Tag, { color: texts.color }, () => texts.text), + ); + }; + } + } + _columns.value = objs; + }); + + /* 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� */ + function handleItemSuccess(d, u, item) { + getForm().setFieldsValue(GetSelectSuccess(d, u, getForm().getFieldsValue()[`${item.replace(/form-/,'').replace(/add/,'')}PSelect_0`])); + } + + /* 寮瑰嚭閫夋嫨妗� */ + function handleSelectItem(item) { + OpenSelectItem(openItemModal, getForm().getFieldsValue()[`${item.replace(/form-/,'').replace(/add/,'')}PSelect_0`]); + } + + /* Select 鑷畾涔塷nChange鏂规硶 */ + function onChangeConfig(obj: any) { + if (obj.component == 'Select') { + var options = obj.componentProps.options; + var onChange = obj.componentProps.onChange; + obj.componentProps = ({ schema, tableAction, formActionType, formModel }) => { + return { + options: options, + onChange: (e) => custOnChange(e, onChange, objParams.value.ID), + }; + }; + } + } + + //寮瑰嚭妗嗙‘瀹氳繑鍥� + function custSuccess(d) { + reload(); + } + + /* 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� */ + function handleEntSuccess(d, u, item) { + var values = GetSelectSuccess(d, u, cType.value); + selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� + let _val = {}; + _val[d.returnFieldName] = values[d.returnFieldName]; + useFormData.value[item][1].setFieldsValue(_val); + } + + /* 鎵撳紑鑷畾涔夋ā鎬佹 */ + function handleCustClick(item) { + OpenCustModal( + useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶 + cType.value, + item, + [], + // selectVals.value['ROUTE_CODE'], + ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹� + } +</script> diff --git a/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts b/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts index bc42916..d139d9e 100644 --- a/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts +++ b/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts @@ -1,18 +1,49 @@ import { ActionItem, BasicColumn } from '/@/components/Table'; import { useMessage } from '/@/hooks/web/useMessage'; import { useI18n } from '/@/hooks/web/useI18n'; +import { getFormSchema } from '/@/views/components/data'; +import { ref } from 'vue'; const { t } = useI18n(); -const { notification } = useMessage(); +const { notification, createErrorModal } = useMessage(); /* 鑷畾涔夋寜閽柟娉� */ -export function DftGrpRelease(reload: Fn, params: {}) { +export function DftGrpRelease(args: Fn[], params: {}) { console.log('鐐瑰嚮浜嗕笅鍙戞寜閽�'); - notification.success({ - message: '鐐瑰嚮浜嗕笅鍙戞寜閽�', - description: `${params.entityName}`, - duration: 3, + // notification.success({ + // message: '鐐瑰嚮浜嗕笅鍙戞寜閽�', + // description: `${params.entityName}`, + // duration: 3, + // }); + // reload(); + // if (params.STATUS == 2) { + // createErrorModal({ + // title: t('璀﹀憡'), + // content: t('宸ュ崟宸茬粡涓嬪彂锛屼笉鑳藉啀涓嬪彂锛�'), + // getContainer: () => document.body, + // }); + // return; + // } + params.dtlSlots.value = [ + { + name: 'forminfo', + slots: ['add', 'set'], + preIcons: { add: 'search|svg', set: 'config|svg' }, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы銆俿lots鏄脊鍑烘鎸夐挳鐨勬彃妲斤紝preIcons鏄彃妲藉搴旂殑鎸夐挳鍥炬爣 + title: '涓嬪彂閰嶇疆', + }, + ]; + + args[2](true, { + isUpdate: true, //鏄惁鏇存柊鎿嶄綔 + ctype: params.cType.value, //鏄摢涓〉闈� + title: '宸ュ崟涓嬪彂', //鏍囬 + width: '900px', //寮瑰嚭妗嗗搴� + formEl: params.useFormData.value, + formElName: ['forminfo'], //琛ㄥ崟鎻掓Ы鍚嶇О + RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //鎻掓Ы鐨勫脊鍑烘閫夋嫨鐨刢ode + fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //淇濆瓨鏂规硶鍚� + initFnName: {}, //鍒濆鍖栨柟娉曞悕 + values: params.record, //琛ㄥ崟璁板綍 }); - reload(); } export const dftGrpactionColumn: BasicColumn = { diff --git a/src/views/tigerprojects/system/lowcode/normal/data.ts b/src/views/tigerprojects/system/lowcode/normal/data.ts deleted file mode 100644 index ee45e1a..0000000 --- a/src/views/tigerprojects/system/lowcode/normal/data.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { - DftGrpRelease, - dftGrpActionItem, - dftGrpOpenSelectItem, - dftGrpGetSelectSuccess, - dftGrpactionColumn, -} from './basDefectGrp'; -import { onChangeFns, rsGrpGetSelectSuccess, rsGrpOpenSelectItem } from './basReasonGrp'; -import { DeleteEntity } from '/@/api/tigerapi/system'; -import { ActionItem, BasicColumn } from '/@/components/Table'; -import { useI18n } from '/@/hooks/web/useI18n'; -import { isNullOrEmpty } from '/@/utils/is'; - -const { t } = useI18n(); - -export function GetActionsData(params: {}, ...args: Fn[]) { - let data = [ - { - icon: 'clarity:note-edit-line', - onClick: editRecord.bind(null, args[0], params), - }, - { - icon: 'ant-design:delete-outlined', - color: 'error', - popConfirm: { - title: '鏄惁纭鍒犻櫎?', - placement: 'left', - confirm: deleteRecord.bind(null, args[1], params), - }, - }, - ] as ActionItem[]; - switch (params['entityName']) { - case 'BAS_DEFECT_GRP': - const _d = dftGrpActionItem; - _d[0].onClick = DftGrpRelease.bind(null, args[1], params); - data = [...data, ..._d]; - break; - } - return data; -} - -function editRecord(fn: Fn, params: {}) { - fn(true, params); -} - -function deleteRecord(fn: Fn, params: {}) { - console.log(params['record']); - //鍒犻櫎 - const apiAction = DeleteEntity(params['record'], params['entityName']); - apiAction.then((action) => { - if (action.IsSuccessed) { - fn(); - } - }); -} - -export function GetActionColumn(entityName: string) { - let data: BasicColumn = {}; - switch (entityName) { - case 'BAS_DEFECT_GRP': - data = dftGrpactionColumn; - break; - default: - data = { - width: 80, - title: '鎿嶄綔', - dataIndex: 'action', - slots: { customRender: 'action' }, - fixed: undefined, - }; - break; - } - return data; -} - -/* 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛 */ -export function GetSelectSuccess(d, u, entityName: string) { - let data = {}; - switch (entityName) { - case 'BAS_DEFECT_GRP': - data = dftGrpGetSelectSuccess(d, u); - break; - case 'BAS_REASON_GRP': - data = rsGrpGetSelectSuccess(d, u); - break; - default: - data = { - ITEM_CODE: d.values['val'], - }; - break; - } - return data; -} - -/* 鎵撳紑寮瑰嚭閫夋嫨妗� */ -export function OpenSelectItem(openItemModal: Fn, entityName: string) { - switch (entityName) { - case 'BAS_DEFECT_GRP': - dftGrpOpenSelectItem(openItemModal); - break; - case 'BAS_REASON_GRP': - rsGrpOpenSelectItem(openItemModal); - break; - default: - openItemModal(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', - }); - break; - } -} - -/* Select 鑷畾涔塷nChange鏂规硶 */ -export function custOnChange(e: any, fnName: string, entityName: string) { - if (!isNullOrEmpty(fnName)) { - switch (entityName) { - case 'BAS_REASON': - onChangeFns[fnName](e); - break; - default: - break; - (e) => {}; - } - } else { - (e) => {}; - } -} diff --git a/src/views/tigerprojects/system/lowcode/normal/index.vue b/src/views/tigerprojects/system/lowcode/normal/index.vue index bc4b764..36a41fc 100644 --- a/src/views/tigerprojects/system/lowcode/normal/index.vue +++ b/src/views/tigerprojects/system/lowcode/normal/index.vue @@ -1,3 +1,11 @@ +<!-- + * @Description: 浣庝唬鐮佸憟鐜伴〉闈� + * @Author: Ben Lin + * @version: + * @Date: 2024-05-30 13:28:20 + * @LastEditors: your name + * @LastEditTime: 2024-06-11 01:27:02 +--> <template> <div> <BasicTable @register="registerTable"> @@ -7,18 +15,45 @@ <template #action="{ record }"> <TableAction :actions="createActions(record)" /> </template> - <template #form-add="{ field }"> + <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" + @click="handleSelectItem(item)" preIcon="search|svg" /> - <NormalModal @register="registerItemAdd" @success="handleItemSuccess" /> + <NormalModal @register="registerItemAdd" @success="(d, u) => handleItemSuccess(d, u, item)" /> </template> </BasicTable> <normalDrawer @register="registerDrawer" @success="handleSuccess" /> + <CustModal + @register="registerCust" + @success="custSuccess" + :type="cType" + :detailSlots="dtlSlots" + > + <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� --> + <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]" + /> + <NormalModal + @register="useModalData[name][0]" + @success="(d, u) => handleEntSuccess(d, u, item.name)" + /> + </template> + </BasicForm> + <!-- 鑷畾涔夊唴瀹� --> + </template> + </CustModal> </div> </template> <script lang="ts" setup> @@ -31,14 +66,19 @@ import { useGlobSetting } from '/@/hooks/setting'; import { useRoute } from 'vue-router'; import { Tag, Tooltip } from 'ant-design-vue'; - import { isNullOrEmpty } from '/@/utils/is'; + import CustModal from '/@/views/components/CustModal.vue'; + import { BasicForm, FormActionType, useForm } from '/@/components/Form/index'; + import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; import { GetActionColumn, GetActionsData, OpenSelectItem, GetSelectSuccess, custOnChange, - } from './data'; + getFormSchema, + OpenCustModal, + GetUseModalData, + } from '../data'; import { useModal } from '/@/components/Modal'; import { useLocale } from '/@/locales/useLocale'; @@ -50,6 +90,16 @@ const _columns = ref([]); const _searchFormSchema = ref([]); const _crudFormSchema = ref([]); + const formSchemas = ref({}); //寮瑰嚭妗嗗琛ㄥ崟缁撴瀯 + const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 + const useFormData = ref({}); + const colSlots = ref<any>(objParams.value.colSlots); //鎸夐挳鎻掓Ы + const crudColSlots = ref<any>(objParams.value.crudColSlots); + const cType = ref(''); + const dtlSlots = ref([] as any[]); + const selectVals = ref({}); + + const [registerCust, { openModal: openCustomModal, closeModal }] = useModal(); const [registerItemAdd, { openModal: openItemModal }] = useModal(); const [registerDrawer, { openDrawer }] = useDrawer(); const [registerTable, { getForm, reload }] = useTable({ @@ -68,7 +118,6 @@ showIndexColumn: false, actionColumn: GetActionColumn(objParams.value.ID), //鑷畾涔夋搷浣滃垪 }); - /* 鐢熸垚鍒楄〃涓搷浣滈」鐨勬寜閽� */ function createActions(record) { return GetActionsData( @@ -77,9 +126,18 @@ isUpdate: true, entityName: objParams.value.ID, formJson: _crudFormSchema.value, + cType, + dtlSlots, + formSchemas, + useModalData, + useFormData, + crudColSlots, }, openDrawer, reload, + openCustomModal, + useForm, + useModal, ); } @@ -88,6 +146,7 @@ isUpdate: false, entityName: objParams.value.ID, formJson: _crudFormSchema.value, + crudColSlots, }); } @@ -115,6 +174,9 @@ // } // } // _columns.value = objs; + + //鑾峰彇琛ㄥ崟涓彃妲芥覆鏌撶殑鎸夐挳鐐瑰嚮寮瑰嚭妯℃�佺獥鍙g殑瀹炰緥 + useModalData.value = GetUseModalData(objParams.value.ID); const data = await getEntity({ sqlcmd: "ASSEMBLY_NAME ='" + objParams.value.ID + "'", entityName: 'SYS_LOW_CODE', @@ -182,13 +244,13 @@ }); /* 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� */ - function handleItemSuccess(d, u) { - getForm().setFieldsValue(GetSelectSuccess(d, u, getForm().getFieldsValue()['0'])); + function handleItemSuccess(d, u, item) { + getForm().setFieldsValue(GetSelectSuccess(d, u, getForm().getFieldsValue()[`${item.replace(/form-/,'').replace(/add/,'')}PSelect_0`])); } /* 寮瑰嚭閫夋嫨妗� */ - function handleSelectItem() { - OpenSelectItem(openItemModal, getForm().getFieldsValue()['0']); + function handleSelectItem(item) { + OpenSelectItem(openItemModal, getForm().getFieldsValue()[`${item.replace(/form-/,'').replace(/add/,'')}PSelect_0`]); } /* Select 鑷畾涔塷nChange鏂规硶 */ @@ -204,4 +266,29 @@ }; } } + + //寮瑰嚭妗嗙‘瀹氳繑鍥� + function custSuccess(d) { + reload(); + } + + /* 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� */ + function handleEntSuccess(d, u, item) { + var values = GetSelectSuccess(d, u, cType.value); + selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� + let _val = {}; + _val[d.returnFieldName] = values[d.returnFieldName]; + useFormData.value[item][1].setFieldsValue(_val); + } + + /* 鎵撳紑鑷畾涔夋ā鎬佹 */ + function handleCustClick(item) { + OpenCustModal( + useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶 + cType.value, + item, + [], + // selectVals.value['ROUTE_CODE'], + ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹� + } </script> diff --git a/src/views/tigerprojects/system/lowcode/normal/normalDrawer.vue b/src/views/tigerprojects/system/lowcode/normal/normalDrawer.vue index 804cbe3..f928472 100644 --- a/src/views/tigerprojects/system/lowcode/normal/normalDrawer.vue +++ b/src/views/tigerprojects/system/lowcode/normal/normalDrawer.vue @@ -1,3 +1,11 @@ +<!-- + * @Description: file content + * @Author: your name + * @version: + * @Date: 2024-05-30 13:28:20 + * @LastEditors: your name + * @LastEditTime: 2024-06-11 01:11:06 +--> <template> <BasicDrawer v-bind="$attrs" @@ -7,7 +15,18 @@ width="600px" @ok="handleSubmit" > - <BasicForm @register="registerForm" /> + <BasicForm @register="registerForm" > + <template #[item]="{ field }" v-for="item in crudColSlots" :key="item"> + <a-button + v-if="field" + class="mt-1 ml-1" + size="small" + @click="handleSelectItem(item)" + preIcon="search|svg" + /> + <NormalModal @register="registerItemAdd" @success="(d, u) => handleItemSuccess(d, u, item)" /> + </template> + </BasicForm> </BasicDrawer> </template> <script lang="ts" setup> @@ -15,14 +34,19 @@ import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; import { useGlobSetting } from '/@/hooks/setting'; + import NormalModal from '/@/views/components/NormalModal.vue'; import { SaveEntity, fetchJson } from '/@/api/tigerapi/system'; + import { useModal } from '/@/components/Modal'; +import { GetSelectSuccess, OpenSelectItem } from '../data'; const emit = defineEmits(['success', 'register']); const globSetting = useGlobSetting(); const isUpdate = ref(true); const entityName = ref(''); const formSchema = ref([]); - const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ + const crudColSlots = ref<any>([]); + const [registerItemAdd, { openModal: openItemModal }] = useModal(); + const [registerForm, { resetFields, setFieldsValue, getFieldsValue, validate }] = useForm({ labelWidth: 140, schemas: formSchema as unknown as FormSchema[], actionColOptions: { @@ -40,6 +64,7 @@ // }_addEditform.json`, // ); formSchema.value = data?.formJson; + crudColSlots.value = data?.crudColSlots; resetFields(); setDrawerProps({ confirmLoading: false }); @@ -70,4 +95,20 @@ setDrawerProps({ confirmLoading: false }); } } + + /** + * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ + function handleItemSuccess(d, u, item) { + setFieldsValue(GetSelectSuccess(d, u, getFieldsValue()[`${item.replace(/add/,'')}PSelect_0`])); + } + + /* 寮瑰嚭閫夋嫨妗� */ + function handleSelectItem(item) { + OpenSelectItem(openItemModal, getFieldsValue()[`${item.replace(/add/,'')}PSelect_0`]); + } </script> diff --git a/src/views/tigerprojects/system/lowcode/setting/pageDetail.vue b/src/views/tigerprojects/system/lowcode/setting/pageDetail.vue index 95e1e2e..bc2fcfc 100644 --- a/src/views/tigerprojects/system/lowcode/setting/pageDetail.vue +++ b/src/views/tigerprojects/system/lowcode/setting/pageDetail.vue @@ -1,3 +1,12 @@ +<!-- + * @Description: 浣庝唬鐮佺敓鎴愰〉闈� + * @Author: Ben Lin + * @version: + * @Date: 2024-05-30 22:00:44 + * @LastEditors: your name + * @LastEditTime: 2024-06-11 01:50:33 +--> +<!-- eslint-disable prettier/prettier --> <template> <PageWrapper class="high-form" @@ -74,6 +83,15 @@ <a-input v-model:value="model[field]" /> </template> <template #[item]="{ model, field }" v-for="item in searchValueFieldSlots" :key="item"> + <a-input v-model:value="model[field]" /> + </template> + <template #[item]="{ model, field }" v-for="item in searchOptionsSlots" :key="item"> + <a-input v-model:value="model[field]" /> + </template> + <template #[item]="{ model, field }" v-for="item in searchOnChangeSlots" :key="item"> + <a-input v-model:value="model[field]" /> + </template> + <template #[item]="{ model, field }" v-for="item in searchPOptionsSlots" :key="item"> <a-input v-model:value="model[field]" /> </template> </BasicForm> @@ -225,6 +243,9 @@ <template #[item]="{ model, field }" v-for="item in crudOnChangeSlots" :key="item"> <a-input v-model:value="model[field]" /> </template> + <template #[item]="{ model, field }" v-for="item in crudPOptionsSlots" :key="item"> + <a-input v-model:value="model[field]" /> + </template> </BasicForm> </a-card> @@ -343,6 +364,9 @@ const searchResultFieldSlots = ref([] as string[]); const searchLabelFieldSlots = ref([] as string[]); const searchValueFieldSlots = ref([] as string[]); + const searchOptionsSlots = ref([] as string[]); + const searchOnChangeSlots = ref([] as string[]); + const searchPOptionsSlots = ref([] as string[]); /* 涓昏〃 */ const MainEntName = ref(''); const mainSelectVals = ref({} as { [key: string]: any }); @@ -368,6 +392,7 @@ const crudValueFieldSlots = ref([] as string[]); const crudOptionsSlots = ref([] as string[]); const crudOnChangeSlots = ref([] as string[]); + const crudPOptionsSlots = ref([] as string[]); const options = ref<SelectTypes['options']>([ { @@ -407,18 +432,24 @@ label: '寮瑰嚭閫夋嫨妗�', }, ]); + + /** + * @description: 瀹炰緥缁勪欢鎸傝浇鏃� + * @return {*} + */ onMounted(() => { if (unref(objParams.value.Update) == '1') { getEntity({ sqlcmd: "ID ='" + objParams.value.ID + "'", entityName: 'SYS_LOW_CODE', }).then((data) => { + /* 鏌ヨ鍔犺浇 */ var searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON); SearchEntName.value = data.Data.Items[0].SEARCH_ASSY_NAME; setFieldsValue({ ASSEMBLY_NAME: data.Data.Items[0].SEARCH_ASSY_NAME }); + searchForms = searchForms.filter((item) => !item['field'].toString().startsWith(SearchEntName.value) && !item['field'].toString().endsWith('PSelect_0')); for (const i in searchForms) { - if (searchForms[i]['field'] != '0') { - condAdd(); + condAdd(); if (searchForms[i]['component'] == 'ApiSelect') { addApiSelectOption(`${SearchEntName.value}${Number(i) + 1}a`, 'search'); setFieldsValue({ @@ -435,59 +466,79 @@ searchForms[i]['componentProps']['valueField'], }); } + if (searchForms[i]['component'] == 'Select') { + addSelectOption(`${SearchEntName.value}${Number(i) + 1}a`, 'search'); + setFieldsValue({ + [`XSelect${SearchEntName.value}${Number(i) + 1}a`]: JSON.stringify( + searchForms[i]['componentProps']['options'], + ), + [`XOnChange${SearchEntName.value}${Number(i) + 1}a`]: + searchForms[i]['componentProps']['onChange'], + }); + } setFieldsValue({ [`${SearchEntName.value}${Number(i) + 1}a`]: searchForms[i]['field'], [`InputNumber${Number(i) + 1}`]: searchForms[i]['colProps'].span, [`Switch${Number(i) + 1}`]: searchForms[i]['ifShow'], }); objInputs.value[`${SearchEntName.value}${Number(i) + 1}a`] = searchForms[i]['label']; - searchSelectVals.value[`${SearchEntName.value}${Number(i) + 1}a`] = searchForms[i][ - 'comp' - ] - ? searchForms[i]['comp'] - : searchForms[i]['component']; - } + searchSelectVals.value[`${SearchEntName.value}${Number(i) + 1}a`] = searchForms[i]['comp']? searchForms[i]['comp']: searchForms[i]['component']; + if(searchForms[i]['comp']){ + addPopSelectOption(`${SearchEntName.value}${Number(i) + 1}a`, 'search'); + setFieldsValue({ + [`PSelect${SearchEntName.value}${Number(i) + 1}a`]: searchForms[i]['entityName'], + }); + } } + /* 澧炲垹鏀瑰姞杞� */ var crudForms = JSON.parse(data.Data.Items[0].FORM_JSON); CrudEntName.value = data.Data.Items[0].CRUD_ASSY_NAME; setFieldsValueCrud({ crudAssemblyName: data.Data.Items[0].CRUD_ASSY_NAME }); + crudForms = crudForms.filter((item) => !item['field'].toString().startsWith(CrudEntName.value) && !item['field'].toString().endsWith('PSelect_0')); for (const i in crudForms) { crudCondAdd(); - if (crudForms[i]['component'] == 'ApiSelect') { - addApiSelectOption(`${CrudEntName.value}${Number(i) + 1}a`, 'crud'); + if (crudForms[i]['component'] == 'ApiSelect') { + addApiSelectOption(`${CrudEntName.value}${Number(i) + 1}a`, 'crud'); + setFieldsValueCrud({ + [`ApiSelect${CrudEntName.value}${Number(i) + 1}a`]: + crudForms[i]['componentProps']['api'], + [`Params${CrudEntName.value}${Number(i) + 1}a`]: JSON.stringify( + crudForms[i]['componentProps']['params'], + ), + [`Result${CrudEntName.value}${Number(i) + 1}a`]: + crudForms[i]['componentProps']['resultField'], + [`Label${CrudEntName.value}${Number(i) + 1}a`]: + crudForms[i]['componentProps']['labelField'], + [`Value${CrudEntName.value}${Number(i) + 1}a`]: + crudForms[i]['componentProps']['valueField'], + }); + } + if (crudForms[i]['component'] == 'Select') { + addSelectOption(`${CrudEntName.value}${Number(i) + 1}a`, 'crud'); + setFieldsValueCrud({ + [`XSelect${CrudEntName.value}${Number(i) + 1}a`]: JSON.stringify( + crudForms[i]['componentProps']['options'], + ), + [`XOnChange${CrudEntName.value}${Number(i) + 1}a`]: + crudForms[i]['componentProps']['onChange'], + }); + } setFieldsValueCrud({ - [`ApiSelect${CrudEntName.value}${Number(i) + 1}a`]: - crudForms[i]['componentProps']['api'], - [`Params${CrudEntName.value}${Number(i) + 1}a`]: JSON.stringify( - crudForms[i]['componentProps']['params'], - ), - [`Result${CrudEntName.value}${Number(i) + 1}a`]: - crudForms[i]['componentProps']['resultField'], - [`Label${CrudEntName.value}${Number(i) + 1}a`]: - crudForms[i]['componentProps']['labelField'], - [`Value${CrudEntName.value}${Number(i) + 1}a`]: - crudForms[i]['componentProps']['valueField'], + [`${CrudEntName.value}${Number(i) + 1}a`]: crudForms[i]['field'], + [`InputNumber${Number(i) + 1}`]: crudForms[i]['colProps'].span, + [`Switch${Number(i) + 1}`]: crudForms[i]['show'], + [`rSwitch${Number(i) + 1}`]: crudForms[i]['required'], }); - } - if (crudForms[i]['component'] == 'Select') { - addSelectOption(`${CrudEntName.value}${Number(i) + 1}a`, 'crud'); - setFieldsValueCrud({ - [`XSelect${CrudEntName.value}${Number(i) + 1}a`]: JSON.stringify( - crudForms[i]['componentProps']['options'], - ), - [`XOnChange${CrudEntName.value}${Number(i) + 1}a`]: - crudForms[i]['componentProps']['onChange'], - }); - } - setFieldsValueCrud({ - [`${CrudEntName.value}${Number(i) + 1}a`]: crudForms[i]['field'], - [`InputNumber${Number(i) + 1}`]: crudForms[i]['colProps'].span, - [`Switch${Number(i) + 1}`]: crudForms[i]['show'], - [`rSwitch${Number(i) + 1}`]: crudForms[i]['required'], - }); - crudInputs.value[`${CrudEntName.value}${Number(i) + 1}a`] = crudForms[i]['label']; - crudSelectVals.value[`${CrudEntName.value}${Number(i) + 1}a`] = crudForms[i]['component']; + crudInputs.value[`${CrudEntName.value}${Number(i) + 1}a`] = crudForms[i]['label']; + crudSelectVals.value[`${CrudEntName.value}${Number(i) + 1}a`] = crudForms[i]['comp']? crudForms[i]['comp']: crudForms[i]['component']; + if(crudForms[i]['comp']){ + addPopSelectOption(`${CrudEntName.value}${Number(i) + 1}a`, 'crud'); + setFieldsValueCrud({ + [`PSelect${CrudEntName.value}${Number(i) + 1}a`]: crudForms[i]['entityName'], + }); + } } + /* 涓昏〃鍔犺浇 */ var objs = JSON.parse(data.Data.Items[0].BASE_FORM_JSON); MainEntName.value = data.Data.Items[0].ASSEMBLY_NAME; setFieldsValueMain({ MainAssemblyName: MainEntName.value }); @@ -506,6 +557,10 @@ } }); + /** + * @description: 鍏ㄩ儴鎻愪氦 + * @return {*} + */ async function submitAll() { try { const [values, crudvalues, mainvalues] = await Promise.all([ @@ -519,9 +574,11 @@ var searchjsons = []; var _json = {}; var _n = 0; + let firstField = ''; for (const k in Keys) { console.log(`${k}:${Keys[k]}`); if (Keys[k].toString().startsWith(getFieldsValue().ASSEMBLY_NAME)) { + firstField = Keys[k]; _json['field'] = isNullOrEmpty(values[Keys[k]]) ? '' : values[Keys[k]]; _json['label'] = objInputs.value[Keys[k]]; _json['defaultValue'] = ''; @@ -533,6 +590,12 @@ resultField: values[`Result${Keys[k]}`], labelField: values[`Label${Keys[k]}`], valueField: values[`Value${Keys[k]}`], + }; + } + if (searchSelectVals.value[Keys[k]] == 'Select') { + _json['componentProps'] = { + options: JSON.parse(values[`XSelect${Keys[k]}`]), + onChange: values[`XOnChange${Keys[k]}`], }; } _n = _n + 4; @@ -550,15 +613,16 @@ if (_json['component'] == 'PoPSelect') { _json['component'] = 'Input'; _json['comp'] = 'PoPSelect'; + _json['entityName'] = values[`PSelect${firstField}`]; searchjsons.push(_json); _json = {}; - _json['field'] = '0'; + _json['field'] = `${firstField}PSelect_0`; _json['label'] = '1'; - _json['defaultValue'] = ''; + _json['defaultValue'] = values[`PSelect${firstField}`]; _json['component'] = 'Input'; _json['colProps'] = { span: 4 }; _json['ifShow'] = true; - _json['colSlot'] = 'add'; + _json['colSlot'] = `${firstField}add`; } searchjsons.push(_json); _json = {}; @@ -612,9 +676,11 @@ var cjsons = []; var cjson = {}; var c = 0; + let cfirstField = ''; for (const k in cKeys) { console.log(`${k}:${cKeys[k]}`); if (cKeys[k].toString().startsWith(getFieldsValueCrud().crudAssemblyName)) { + cfirstField = cKeys[k]; cjson['field'] = isNullOrEmpty(crudvalues[cKeys[k]]) ? '' : crudvalues[cKeys[k]]; cjson['label'] = isNullOrEmpty(crudInputs.value[cKeys[k]]) ? '' @@ -654,6 +720,21 @@ c++; } if (!isNullOrEmpty(cjson) && c == 6) { + //濡傛灉鏄脊鍑洪�夋嫨妗� + if (cjson['component'] == 'PoPSelect') { + cjson['component'] = 'Input'; + cjson['comp'] = 'PoPSelect'; + cjson['entityName'] = crudvalues[`PSelect${cfirstField}`]; + cjsons.push(cjson); + cjson = {}; + cjson['field'] = `${cfirstField}PSelect_0`; + cjson['label'] = '1'; + cjson['defaultValue'] = crudvalues[`PSelect${cfirstField}`]; + cjson['component'] = 'Input'; + cjson['colProps'] = { span: 4 }; + cjson['ifShow'] = true; + cjson['colSlot'] = `${cfirstField}add`; + } cjsons.push(cjson); c = 0; cjson = {}; @@ -691,7 +772,10 @@ } function handleEdit(record: Recordable) {} - + /** + * @description: 鏌ヨ閰嶇疆绫诲悕閫夋嫨鎸夐挳鏂规硶 + * @return {*} + */ function handleSelecNew() { openNewModal(true, { data: 'content', @@ -699,6 +783,10 @@ }); } + /** + * @description: 涓昏〃閰嶇疆绫诲悕閫夋嫨鎸夐挳鏂规硶 + * @return {*} + */ function mainSelectAssy() { openMainModal(true, { data: 'content', @@ -706,6 +794,10 @@ }); } + /** + * @description: 澧炲垹鏀归厤缃被鍚嶉�夋嫨鎸夐挳鏂规硶 + * @return {*} + */ function handleSelectCrud() { openCrudModal(true, { data: 'content', @@ -713,6 +805,12 @@ }); } + /** + * @description: 閫夋嫨绫诲悕寮瑰嚭妗嗚繑鍥炴垚鍔熸柟娉� + * @param {*} d + * @param {*} u + * @return {*} + */ async function mainAssySuccess(d, u) { setFieldsValueMain({ MainAssemblyName: d.values['val'], @@ -748,6 +846,15 @@ crudProperties.value = data.items; CrudEntName.value = d.values['val']; } + /* 閫夋嫨绫诲悕寮瑰嚭妗嗚繑鍥炴垚鍔熸柟娉� End */ + + /** + * @description: 閰嶇疆瀛楁閫夋嫨鏀瑰彉鍚庝簨浠舵柟娉� + * @param {*} value + * @param {*} option + * @param {*} field + * @return {*} + */ function change(value, option, field) { console.log(value, option, field); objInputs.value[field] = option.label; @@ -760,34 +867,78 @@ console.log(value, option, field); crudInputs.value[field] = option.label; } - /* 鏌ヨ缁勪欢閫夋嫨浜嬩欢 */ + /* 閰嶇疆瀛楁閫夋嫨鏀瑰彉鍚庝簨浠舵柟娉� End */ + + /** + * @description: 鏌ヨ缁勪欢閫夋嫨浜嬩欢 + * @param {*} value + * @param {*} option + * @param {*} field + * @return {*} + */ function searchOnChange(value, option, field) { console.log(value, option, field); if (value == 'ApiSelect') { addApiSelectOption(field, 'search'); + delSelectOption(field, 'search'); + delPSelectOption(field, 'search'); } else { delApiSelectOption(field, 'search'); } - // if (value == 'PoPSelect') {} + if (value == 'Select') { + addSelectOption(field, 'search'); + delApiSelectOption(field, 'search'); + delPSelectOption(field, 'search'); + } else { + delSelectOption(field, 'search'); + } + if (value == 'PoPSelect') { + addPopSelectOption(field, 'search'); + delApiSelectOption(field, 'search'); + delSelectOption(field, 'search'); + } else { + delPSelectOption(field, 'search'); + } } - /* 澧炲垹鏀圭粍浠堕�夋嫨浜嬩欢 */ + + /** + * @description: 澧炲垹鏀圭粍浠堕�夋嫨浜嬩欢 + * @param {*} value + * @param {*} option + * @param {*} field + * @return {*} + */ function componentChange(value, option, field) { console.log(value, option, field); if (value == 'ApiSelect') { addApiSelectOption(field, 'crud'); delSelectOption(field, 'crud'); + delPSelectOption(field, 'crud'); } else { delApiSelectOption(field, 'crud'); } if (value == 'Select') { addSelectOption(field, 'crud'); delApiSelectOption(field, 'crud'); + delPSelectOption(field, 'crud'); } else { delSelectOption(field, 'crud'); } - // if (value == 'PoPSelect') {} + if (value == 'PoPSelect') { + addPopSelectOption(field, 'crud'); + delApiSelectOption(field, 'crud'); + delSelectOption(field, 'crud'); + } else { + delPSelectOption(field, 'crud'); + } } + /** + * @description: 閫夋嫨浜咥piSelect缁勪欢閫夐」鍚庯紝澧炲姞鐩稿簲鐨勮緭鍏ラ」 + * @param {*} field + * @param {*} type + * @return {*} + */ function addApiSelectOption(field: string, type: string) { const appendData: FormSchema[] = [ { @@ -838,7 +989,11 @@ } } - /* 澧炲垹鏀笰piSelect鎻掓Ы鏁版嵁娣诲姞 */ + /** + * @description: 澧炲垹鏀笰piSelect鎻掓Ы鏁版嵁娣诲姞 + * @param {*} field + * @return {*} + */ function crudSlotsPush(field: string) { crudApiSlots.value.push(`Api${field}`); crudParamsSlots.value.push(`Params_${field}`); @@ -846,7 +1001,12 @@ crudLabelFieldSlots.value.push(`LabelField${field}`); crudValueFieldSlots.value.push(`ValueField${field}`); } - /* 鏌ヨApiSelect鎻掓Ы鏁版嵁娣诲姞 */ + + /** + * @description: 鏌ヨApiSelect鎻掓Ы鏁版嵁娣诲姞 + * @param {*} field + * @return {*} + */ function searchSlotsPush(field: string) { searchApiSlots.value.push(`Api${field}`); searchParamsSlots.value.push(`Params_${field}`); @@ -855,6 +1015,12 @@ searchValueFieldSlots.value.push(`ValueField${field}`); } + /** + * @description: 鍙栨秷ApiSelect缁勪欢鍚庡垹闄ゆ坊鍔犵殑杈撳叆椤� + * @param {*} field + * @param {*} type + * @return {*} + */ function delApiSelectOption(field: string, type: string) { const removeData: string[] = [ `ApiSelect${field}`, @@ -879,7 +1045,11 @@ } } - /* 澧炲垹鏀规彃妲藉垹闄ら」 */ + /** + * @description: 澧炲垹鏀规彃妲藉垹闄ら」 + * @param {*} field + * @return {*} + */ function crudSlotsSplice(field: string) { crudApiSlots.value = crudApiSlots.value.filter((item) => item !== `Api${field}`); crudParamsSlots.value = crudParamsSlots.value.filter((item) => item !== `Params_${field}`); @@ -893,7 +1063,12 @@ (item) => item !== `ValueField${field}`, ); } - /* 澧炲垹鏀规彃妲藉垹闄ら」 */ + + /** + * @description: 澧炲垹鏀规彃妲藉垹闄ら」 + * @param {*} field + * @return {*} + */ function searchSlotsSplice(field: string) { searchApiSlots.value = searchApiSlots.value.filter((item) => item !== `Api${field}`); searchParamsSlots.value = searchParamsSlots.value.filter((item) => item !== `Params_${field}`); @@ -908,6 +1083,10 @@ ); } + /** + * @description: 涓嬫媺妗哠elect娣诲姞閫夐」 + * @return {*} + */ function addSelectOption(field: string, type: string) { const appendData: FormSchema[] = [ { @@ -928,7 +1107,7 @@ switch (type) { case 'search': appendSchemaByField(appendData, ''); - // searchSelSlotsPush(field); + searchSelSlotsPush(field); break; case 'crud': appendSchemaByFieldCrud(appendData, ''); @@ -937,13 +1116,19 @@ } } + /** + * @description: 鍙栨秷Select缁勪欢鍚庡垹闄ゆ坊鍔犵殑杈撳叆椤� + * @param {*} field + * @param {*} type + * @return {*} + */ function delSelectOption(field: string, type: string) { const removeData: string[] = [`XSelect${field}`, `XOnChange${field}`]; switch (type) { case 'search': //if (!isNullOrEmpty(getFieldsValue()[`XSelect${field}`])) { removeSchemaByField(removeData); - // searchSelSlotsSplice(field); + searchSelSlotsSplice(field); //} break; case 'crud': @@ -955,16 +1140,129 @@ } } - /* 澧炲垹鏀筍elect鎻掓Ы鏁版嵁娣诲姞 */ + /** + * @description: 鏌ヨSelect鎻掓Ы鏁版嵁娣诲姞 + * @param {*} field + * @return {*} + */ + function searchSelSlotsPush(field: string) { + searchOptionsSlots.value.push(`Select_${field}`); + searchOptionsSlots.value.push(`OnChange_${field}`); + } + + /** + * @description: 鏌ヨ鎻掓Ы鍒犻櫎椤� + * @param {*} field + * @return {*} + */ + function searchSelSlotsSplice(field: string) { + searchOptionsSlots.value = searchOptionsSlots.value.filter( + (item) => item !== `Select_${field}`, + ); + searchOptionsSlots.value = searchOptionsSlots.value.filter( + (item) => item !== `OnChange_${field}`, + ); + } + + /** + * @description: 澧炲垹鏀筍elect鎻掓Ы鏁版嵁娣诲姞 + * @param {*} field + * @return {*} + */ function crudSelSlotsPush(field: string) { crudOptionsSlots.value.push(`Select_${field}`); crudOnChangeSlots.value.push(`OnChange_${field}`); } - /* 澧炲垹鏀规彃妲藉垹闄ら」 */ + /** + * @description: 澧炲垹鏀规彃妲藉垹闄ら」 + * @return {*} + */ function crudSelSlotsSplice(field: string) { crudOptionsSlots.value = crudOptionsSlots.value.filter((item) => item !== `Select_${field}`); - crudOnChangeSlots.value = crudOnChangeSlots.value.filter((item) => item !== `Select_${field}`); + crudOnChangeSlots.value = crudOnChangeSlots.value.filter( + (item) => item !== `OnChange_${field}`, + ); + } + + /** + * @description: 寮瑰嚭閫夋嫨妗哖opSelect娣诲姞閫夐」 + * @param {*} field + * @param {*} type + * @return {*} + */ + function addPopSelectOption(field: string, type: string) { + const appendData: FormSchema[] = [ + { + field: `PSelect${field}`, + component: 'Input', + label: `defaultValue`, + slot: `PSelect_${field}`, + colProps: { span: 24 }, + }, + ]; + switch (type) { + case 'search': + appendSchemaByField(appendData, ''); + searchPSelSlotsPush(field); + break; + case 'crud': + appendSchemaByFieldCrud(appendData, ''); + crudPSelSlotsPush(field); + break; + } + } + + /** + * @description: 鏌ヨPopSelect鎻掓Ы鏁版嵁娣诲姞 + * @param {*} field + * @return {*} + */ + function searchPSelSlotsPush(field: string) { + searchPOptionsSlots.value.push(`PSelect_${field}`); + } + + /** + * @description: 澧炲垹鏀筆opSelect鎻掓Ы鏁版嵁娣诲姞 + * @param {*} field + * @return {*} + */ + function crudPSelSlotsPush(field: string) { + crudPOptionsSlots.value.push(`PSelect_${field}`); + } + + function delPSelectOption(field: string, type: string) { + const removeData: string[] = [`PSelect${field}`]; + switch (type) { + case 'search': + removeSchemaByField(removeData); + searchPSelSlotsSplice(field); + break; + case 'crud': + removeSchemaByFieldCrud(removeData); + crudPSelSlotsSplice(field); + break; + } + } + + /** + * @description: 鏌ヨ鎻掓Ы鍒犻櫎椤� + * @param {*} field + * @return {*} + */ + function searchPSelSlotsSplice(field: string) { + searchPOptionsSlots.value = searchPOptionsSlots.value.filter( + (item) => item !== `PSelect_${field}`, + ); + } + + /** + * @description: 澧炲垹鏀规彃妲藉垹闄ら」 + * @param {*} field + * @return {*} + */ + function crudPSelSlotsSplice(field: string) { + crudPOptionsSlots.value = crudPOptionsSlots.value.filter((item) => item !== `PSelect_${field}`); } const n = ref(1); @@ -1027,9 +1325,15 @@ if (searchSlots.value.length == 0) { n.value = 1; } + delApiSelectOption(`${CrudEntName.value}${field}a`, 'search'); + delSelectOption(`${CrudEntName.value}${field}a`, 'search'); + delPSelectOption(`${CrudEntName.value}${field}a`, 'search'); } - /* 涓昏〃閰嶇疆 */ + /** + * @description: 涓昏〃閰嶇疆 + * @return {*} + */ function mainCondAdd() { appendSchemaByFieldMain( [ @@ -1113,7 +1417,10 @@ } } - /* 澧炲垹鏀归厤缃� */ + /** + * @description: 澧炲垹鏀归厤缃� + * @return {*} + */ function crudCondAdd() { appendSchemaByFieldCrud( [ @@ -1179,6 +1486,8 @@ j.value = 1; } delApiSelectOption(`${CrudEntName.value}${field}a`, 'crud'); + delSelectOption(`${CrudEntName.value}${field}a`, 'crud'); + delPSelectOption(`${CrudEntName.value}${field}a`, 'crud'); } function goBack() { @@ -1189,6 +1498,7 @@ <style lang="less" scoped> .high-form { padding-bottom: 48px; - }</style ->: { values: any[]; }: any: { values: any[]; }: any: { values: any[]; }: any: any: any: any: any: + } +</style> +: { values: any[]; }: any: { values: any[]; }: any: { values: any[]; }: any: any: any: any: any: any: any -- Gitblit v1.9.3