From 28cd71d5ff26ca539e48a229eed4055df7cae5ad Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 13 六月 2024 23:08:36 +0800 Subject: [PATCH] 打印模板更新 --- /dev/null | 114 ---- src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts | 241 ++++++++++ src/views/tigerprojects/system/lowcode/detail/data.ts | 64 ++ src/components/Upload/src/props.ts | 8 src/views/tigerprojects/system/lowcode/data.ts | 49 + src/views/tigerprojects/system/lowcode/detail/index.vue | 327 +++++++++++++ src/views/tigerprojects/system/lowcode/setting/pageDetail.vue | 6 src/views/components/bizMesWo.ts | 4 src/api/tigerapi/system.ts | 35 - src/views/tigerprojects/system/lowcode/normal/index.vue | 474 +++++++++---------- src/views/components/CustModal.vue | 4 src/views/tigerprojects/system/lowcode/normalDrawer.vue | 106 ++++ 12 files changed, 1,043 insertions(+), 389 deletions(-) diff --git a/src/api/tigerapi/system.ts b/src/api/tigerapi/system.ts index f7d1d9d..7711f3b 100644 --- a/src/api/tigerapi/system.ts +++ b/src/api/tigerapi/system.ts @@ -31,7 +31,7 @@ iSYS_ROLE_PROD, } from './model/systemModel'; import { defHttp } from '/@/utils/http/axios'; -import { isDate, isNullOrEmpty, isTimeType } from '/@/utils/is'; +import { isArray, isDate, isNullOrEmpty, isTimeType } from '/@/utils/is'; import { MES_ROUTE_EDGE, MES_ROUTE_NODE } from './model/router'; export enum Api { @@ -875,30 +875,17 @@ ); }; -/* - * 杞崲宸ヨ壓璺嚎涓烘爲褰son +/** + * @description: 鍒ゆ柇淇濆瓨鐨勫�煎鏋滄槸[]鏁扮粍鐨勶紝灏辩洿鎺ュ彇[0]绗竴涓�硷紝涓�鑸拡瀵逛笂浼犳ā鏉跨殑鍦板潃 + * @param {any} values + * @return {*} */ -function convertRouteToTreeData( - nodes: MES_ROUTE_NODE[], - edges: MES_ROUTE_EDGE[], - parentId: string, - id: string, - pid?: string, -) { - const result: treeParamsListItem[] = []; - let temp: treeParamsListItem[] = []; - const _pid = pid == undefined ? '' : pid; - for (let i = 0; i < nodes.length; i++) { - const currPid = data[i][parentId] == null ? '' : data[i][parentId]; - if (currPid === _pid) { - const obj: treeParamsListItem = data[i]; - obj.PARAM_TYPE = _pid == '' ? '0' : '1'; //澧炲姞绫诲瀷 - temp = convertToTreeData(data, parentId, id, data[i][id]); - if (temp.length > 0) { - obj.children = temp; - } - result.push(obj); +export function formatValues(values: any) { + const Keys = Object.getOwnPropertyNames(values); + for (const k in Keys) { + if(isArray(values[Keys[k]])){ + values[Keys[k]] = values[Keys[k]][0]; } } - return result; + return values; } diff --git a/src/components/Upload/src/props.ts b/src/components/Upload/src/props.ts index d37f68b..6652d27 100644 --- a/src/components/Upload/src/props.ts +++ b/src/components/Upload/src/props.ts @@ -1,3 +1,11 @@ +/* + * @Description: file content + * @Author: your name + * @version: + * @Date: 2024-03-24 11:16:46 + * @LastEditors: your name + * @LastEditTime: 2024-06-13 14:47:33 + */ import type { PropType } from 'vue'; import { FileBasicColumn } from './typing'; diff --git a/src/views/components/CustModal.vue b/src/views/components/CustModal.vue index f655785..c95f031 100644 --- a/src/views/components/CustModal.vue +++ b/src/views/components/CustModal.vue @@ -3,8 +3,8 @@ * @Author: Ben Lin * @version: * @Date: 2024-06-05 15:46:07 - * @LastEditors: your name - * @LastEditTime: 2024-06-10 23:48:05 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-13 09:28:27 --> <template> <BasicModal diff --git a/src/views/components/bizMesWo.ts b/src/views/components/bizMesWo.ts index 9ac2295..8a50584 100644 --- a/src/views/components/bizMesWo.ts +++ b/src/views/components/bizMesWo.ts @@ -4,7 +4,7 @@ * @version: * @Date: 2024-06-05 16:10:24 * @LastEditors: your name - * @LastEditTime: 2024-06-10 23:49:39 + * @LastEditTime: 2024-06-13 14:46:20 */ /* 宸ュ崟鐩稿叧鑷畾涔夋柟娉� */ import { FunctionType } from '/@/api/tigerapi/model/systemModel'; @@ -27,6 +27,7 @@ import AssemblyNode from '/@/components/FlowChart/src/AssemblyNode'; import PackingNode from '/@/components/FlowChart/src/PackingNode'; import RepairNode from '/@/components/FlowChart/src/RepairNode'; +import { multiply } from 'lodash-es'; const { t } = useI18n(); const { getLocale } = useLocale(); @@ -335,6 +336,7 @@ rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }], componentProps: { api: uploadApi, + multiple: false, }, }, ]; diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts index 1f84651..e5549f9 100644 --- a/src/views/tigerprojects/system/lowcode/data.ts +++ b/src/views/tigerprojects/system/lowcode/data.ts @@ -4,7 +4,7 @@ * @version: * @Date: 2024-06-02 17:52:35 * @LastEditors: your name - * @LastEditTime: 2024-06-11 01:59:13 + * @LastEditTime: 2024-06-13 22:44:43 */ import { ref } from 'vue'; import { @@ -21,6 +21,8 @@ import { isNullOrEmpty } from '/@/utils/is'; import { woCustFn, woformSchema } from '/@/views/components/bizMesWo'; import { useModal } from '/@/components/Modal'; +import { useGo } from '/@/hooks/web/usePage'; +import { goDetail, labelActionItem, labelGetSelectSuccess, labelOpenSelectItem } from './detail/basLabelVar'; const { t } = useI18n(); @@ -47,6 +49,7 @@ }, ] as ActionItem[]; switch (params['entityName']) { + /* 涓嶈壇浠g爜缁� */ case 'BAS_DEFECT_GRP': const _d = dftGrpActionItem; _d[0].onClick = DftGrpRelease.bind(null, args, params); @@ -63,6 +66,12 @@ showActionButtonGroup: false, }), }; + break; + /* 鏍囩妯℃澘 */ + case 'BAS_LABEL_TEMP': + const _data = labelActionItem; + _data[0].onClick = goDetail.bind(null, args[5], params['record']) + data = [...data, ..._data]; break; } return data; @@ -83,26 +92,48 @@ return data; } +/** + * @description: 鍏敤缂栬緫鏂规硶 + * @param {Fn} fn + * @param {*} params + * @return {*} + */ function editRecord(fn: Fn, params: {}) { fn(true, params); } +/** + * @description: 鍏敤鍒犻櫎鏂规硶 + * @param {Fn} fn + * @param {*} params + * @return {*} + */ function deleteRecord(fn: Fn, params: {}) { console.log(params['record']); //鍒犻櫎 - const apiAction = DeleteEntity(params['record'], params['entityName']); - apiAction.then((action) => { + DeleteEntity(params['record'], params['entityName']).then((action) => { if (action.IsSuccessed) { fn(); } }); } + + export function GetActionColumn(entityName: string) { let data: BasicColumn = {}; switch (entityName) { case 'BAS_DEFECT_GRP': data = dftGrpactionColumn; + break; + case 'BAS_LABEL_TEMP': + data = { + width: 120, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', + }; break; default: data = { @@ -127,6 +158,9 @@ case 'BAS_REASON_GRP': data = rsGrpGetSelectSuccess(d, u); break; + case 'BAS_LABEL_PV': + data = labelGetSelectSuccess(d, u); + break; default: data = { ITEM_CODE: d.values['val'], @@ -150,6 +184,9 @@ case 'BAS_REASON_GRP': rsGrpOpenSelectItem(openItemModal); break; + case 'BAS_LABEL_PV': + labelOpenSelectItem(openItemModal); + break; default: openItemModal(true, { title: '鐗╂枡鍒楄〃', @@ -201,10 +238,10 @@ break; default: break; - (e) => {}; + (e) => { }; } } else { - (e) => {}; + (e) => { }; } } @@ -282,7 +319,7 @@ // break; default: break; - (e) => {}; + (e) => { }; } return _formSchema; } diff --git a/src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts b/src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts new file mode 100644 index 0000000..ba79727 --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts @@ -0,0 +1,241 @@ +/* + * @Description: file content + * @Author: Ben Lin + * @version: + * @Date: 2024-06-13 16:18:39 + * @LastEditors: your name + * @LastEditTime: 2024-06-13 22:47:11 + */ +import { h, unref } from "vue"; +import { ActionItem, BasicColumn, FormSchema } from "/@/components/Table"; +import { Tag, Tooltip } from "ant-design-vue"; +import { GetEnum } from "/@/api/tigerapi/system"; +import { useLocale } from "/@/locales/useLocale"; +import { useI18n } from '/@/hooks/web/useI18n'; + +const { t } = useI18n(); +const { getLocale } = useLocale(); +export const firstColumns: BasicColumn[] = [ + { + dataIndex: "LABEL_ID", + title: "鏍囩妯℃澘ID", + ifShow: false, + sorter: true, + resizable: true, + }, + { + dataIndex: "VAR_NAME", + title: "鍙橀噺鍚嶇О", + ifShow: true, + sorter: true, + resizable: true, + customRender: () => { } + }, + { + dataIndex: "VAR_TYPE", + title: "鍙橀噺绫诲瀷", + ifShow: true, + sorter: true, + resizable: true, + customRender: ({ record }) => { + let color = ''; let text = ''; + switch (record.VAR_TYPE) { + case 0: + text = '甯搁噺'; + color = 'green'; + break; + case 1: + text = '杩囩▼鍙橀噺'; + color = 'orange'; + break; + case 2: + text = '鏃ユ湡鍙橀噺'; + color = '#4f68b0'; + break; + case 3: + text = '鑷畾涔夊彉閲�'; + color = '#bfbfbf'; + break; + } + return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text),); + } + }, + { + dataIndex: "VAR_VALUE", + title: "鍙橀噺鍊�", + ifShow: true, + sorter: true, + resizable: true, + }, + { + dataIndex: "REMARK", + title: "澶囨敞", + ifShow: true, + sorter: true, + resizable: true, + }]; + +export const secondColumns: BasicColumn[] = []; + +let isShow = true; +export const firstFormSchemas: FormSchema[] = [ + { + field: 'ID', + label: '鍙橀噺ID', + component: 'Input', + colProps: { + span: 20, + }, + show: false, + }, + { + field: 'LABEL_ID', + label: '鏍囩妯℃澘ID', + component: 'Input', + colProps: { + span: 20, + }, + show: false, + }, + { + field: 'VAR_NAME', + label: '鍙橀噺鍚�', + required: true, + component: 'Input', + colProps: { + span: 20, + }, + }, + { + field: 'VAR_TYPE', + label: '鍙橀噺绫诲瀷', + component: 'ApiSelect', + colProps: { + span: 20, + }, + componentProps: { + api: GetEnum, + params: { name: 'BAS_LABEL_VAR+VAR_TYPEs' }, + resultField: 'Data', + labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name', + valueField: 'Value', + onChange: (e) => { + if(e == 1){ + isShow = true; + }else{ + isShow = false; + } + } + }, + }, + { + field: 'VAR_VALUE', + label: '鍙橀噺鍊�', + required: true, + component: 'Input', + colProps: { + span: 20, + }, + }, + { + field:"BAS_LABEL_PV1PSelect_0", + label:"1", + defaultValue:"BAS_LABEL_PV", + component:"Input", + colProps:{"span":4}, + ifShow: ({ values }) => isShow, + colSlot:"BAS_LABEL_PV1add" + }, + { + field: 'REMARK', + label: '澶囨敞', + component: 'Input', + colProps: { + span: 20, + }, + }, +]; +export const secondFormSchemas: FormSchema[] = []; + +export const firstSearchForm: FormSchema[] = [ + { + field: 'VAR_NAME', + label: t('鍙橀噺鍚�'), + colProps: { span: 8 }, + component: 'Input', + }, +]; + +export const labelActionItem: ActionItem[] = [ + { + icon: 'clarity:info-standard-line', + tooltip: '妯℃澘鍙橀噺', + onClick: () => { }, + }, +]; + +/** + * @description: 璺宠浆鍒拌鎯呴〉闈㈡柟娉� + * @param {Fn} go + * @return {*} + */ +export function goDetail(go: Fn, record: Recordable) { + const id = { + ID: 'BAS_LABEL_VAR', + firstTabName: '鏍囩妯℃澘鍙橀噺', + secondTabName:'', //'鏍囩杩囩▼鍙橀噺', + firstTitle: '妯℃澘鍙橀噺', + secondTitle: '', //'杩囩▼鍙橀噺', + contentStr: '杩欓噷鏄爣绛炬ā鏉垮彉閲忕鐞嗛〉闈紝鍙互绠$悊鏍囩鐨勬ā鏉垮彉閲忔垨鑰呮墦鍗拌繃绋嬩腑鐨勫彉閲�', + detailName: `妯℃澘[${record.LABEL_NAME}]`, + others: { LABEL_ID: record.ID }, + colSlots: ['BAS_LABEL_PV1add'], + }; + go(`/BAS_LABEL_VAR/${encodeURI(JSON.stringify(id))}`); +} + +export function labelOpenSelectItem(openItemModal: Fn) { + openItemModal(true, { + title: '杩囩▼鍙橀噺鍒楄〃', + schemas: [ + { + field: 'VAR_CODE', + component: 'Input', + label: '杩囩▼鍙橀噺缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('杩囩▼鍙橀噺缂栫爜'), + dataIndex: 'VAR_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('杩囩▼鍙橀噺鍚嶇О'), + dataIndex: 'VAR_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_LABEL_PV', + rowKey: 'VAR_CODE', + }); + } + + /** + * @description: 閫夋嫨杩囩▼鍙橀噺寮瑰嚭閫夋嫨妗嗘垚鍔熻繑鍥炶祴鍊兼柟娉� + * @param {*} d + * @param {*} u + * @return {*} + */ + export function labelGetSelectSuccess(d, u) { + return { + VAR_VALUE: d.values['val'], + }; + } \ No newline at end of file diff --git a/src/views/tigerprojects/system/lowcode/detail/data.ts b/src/views/tigerprojects/system/lowcode/detail/data.ts new file mode 100644 index 0000000..286eb2e --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/detail/data.ts @@ -0,0 +1,64 @@ +/* + * @Description: file content + * @Author: Ben Lin + * @version: + * @Date: 2024-06-13 10:59:53 + * @LastEditors: your name + * @LastEditTime: 2024-06-13 20:23:02 + */ +import { firstColumns, firstFormSchemas, firstSearchForm, secondColumns, secondFormSchemas } from "./basLabelVar"; +import { BasicColumn, FormSchema } from "/@/components/Table"; + +/** + * @description: 鑾峰彇琛ㄦ牸瀛楁 + * @param {string} entityName + * @param {string} type + * @return {*} + */ +export function GetBaseColumns(entityName: string, type: string) { + let data: BasicColumn[] = []; + switch (entityName) { + case 'BAS_LABEL_VAR': + data =type=='detailfirst'? firstColumns: secondColumns; + break; + default: + break; + } + return data; +} + +/** + * @description: 鑾峰彇澧炲垹鏀硅〃鍗曞瓧娈� + * @param {string} entityName + * @param {string} type + * @return {*} + */ +export function GetFormColumns(entityName: string, type: string) { + let data: FormSchema[] = []; + switch (entityName) { + case 'BAS_LABEL_VAR': + data =type=='detailfirst'? firstFormSchemas: secondFormSchemas; + break; + default: + break; + } + return data; +} + +/** + * @description: 鑾峰彇鏌ヨ琛ㄥ崟瀛楁 + * @param {string} entityName + * @param {string} type + * @return {*} + */ +export function GetSearchFormColumns(entityName: string, type: string) { + let data: FormSchema[] = []; + switch (entityName) { + case 'BAS_LABEL_VAR': + data =type=='detailfirst'? firstSearchForm: secondFormSchemas; + break; + default: + break; + } + return data; +} \ No newline at end of file diff --git a/src/views/tigerprojects/system/lowcode/detail/index.vue b/src/views/tigerprojects/system/lowcode/detail/index.vue new file mode 100644 index 0000000..6a5abae --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/detail/index.vue @@ -0,0 +1,327 @@ +<!-- + * @Description: 浣庝唬鐮佽鎯呭憟鐜伴〉闈� + * @Author: Ben Lin + * @version: + * @Date: 2024-05-30 13:28:20 + * @LastEditors: your name + * @LastEditTime: 2024-06-13 22:08:57 +--> +<template> + <PageWrapper :title="title" :content="contentStr" contentBackground @back="goBack"> + <template #footer> + <a-tabs default-active-key="detail" v-model:activeKey="currentKey" @tabClick="tabClkcallback"> + <a-tab-pane key="detailfirst" :tab="firstTabName" /> + <a-tab-pane key="detailsecond" :tab="secondTabName" /> + </a-tabs> + </template> + <div> + <div v-if="currentKey == 'detailfirst'"> + <BasicTable @register="detailTable"> + <template #toolbar> + <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 鏂板 </a-button> + </template> + <template #action="{ record }"> + <TableAction :actions="[ + { + icon: 'clarity:note-edit-line', + onClick: handleEdit.bind(null, record), + }, + { + icon: 'ant-design:delete-outlined', + color: 'error', + popConfirm: { + title: '鏄惁纭鍒犻櫎?', + placement: 'left', + confirm: handleDelete.bind(null, record), + }, + }, + ]" /> + </template> + <template #[item]="{ field }" v-for="item in colSlots" :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> + </BasicTable> + </div> + <div v-if="currentKey == 'detailsecond'"> + <BasicTable @register="detailsecondTable"> + <template #toolbar> + <a-button type="primary" @click="secondCreate" preIcon="add_02|svg"> 鏂板 </a-button> + </template> + <template #[item]="{ field }" v-for="item in secondColSlots" :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> + </BasicTable> + </div> + </div> + <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> + </PageWrapper> +</template> + +<script lang="ts" setup> +import { ref, reactive } from 'vue'; +import { useRoute } from 'vue-router'; +import { PageWrapper } from '/@/components/Page'; +import { useTabs } from '/@/hooks/web/useTabs'; +import { Tabs } from 'ant-design-vue'; +import { useGo } from '/@/hooks/web/usePage'; +//璇︽儏鍒楄〃 +import { BasicTable, useTable, TableAction } from '/@/components/Table'; +import { GetSelectSuccess, OpenCustModal, OpenSelectItem, custOnChange } from '../data'; +import { useI18n } from '/@/hooks/web/useI18n'; +import { useMessage } from '/@/hooks/web/useMessage'; +import { DeleteEntity, getListByPage } from '/@/api/tigerapi/system'; +import { useDrawer } from '/@/components/Drawer'; +import normalDrawer from '../normalDrawer.vue'; +import NormalModal from '/@/views/components/NormalModal.vue'; +import CustModal from '/@/views/components/CustModal.vue'; +import { BasicForm } from '/@/components/Form/index'; +import { useGlobSetting } from '/@/hooks/setting'; +import { useModal } from '/@/components/Modal'; +import { GetBaseColumns, GetFormColumns, GetSearchFormColumns } from './data'; + +const { t: bt } = useI18n(''); +const { createMessage } = useMessage(); +const route = useRoute(); +const objParams = ref(JSON.parse(decodeURI(route.params?.id as string))); +const ATabs = ref(Tabs); +const ATabPane = ref(Tabs.TabPane); +var ITEM_CODE = ref(''); +const go = useGo(); +const title = ref(objParams.value.title); +const firstTitle = ref(objParams.value.firstTitle); +const secondTitle = ref(objParams.value.secondTitle); +const contentStr = ref(objParams.value.contentStr); +const firstTabName = ref(objParams.value.firstTabName); +const secondTabName = ref(objParams.value.secondTabName); +const entityName = ref(objParams.value.ID); +const detailName = ref(objParams.value.detailName); +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 secondColSlots = ref<any>(objParams.value.secondColSlots); //鎸夐挳鎻掓Ы +const crudColSlots = ref<any>(objParams.value.colSlots); +const cType = ref(''); +const dtlSlots = ref([] as any[]); +const selectVals = ref({}); +//鑾峰彇JobId +const BILLCODE = ref(route.params?.BillCode); +const [registerCust] = useModal(); +const [registerItemAdd, { openModal: openItemModal }] = useModal(); +const [registerDrawer, { openDrawer }] = useDrawer(); +const [detailTable, { reload: reloadFirst }] = useTable({ + title: `${firstTitle.value}鍒楄〃`, + api: getListByPage, + searchInfo: { TABLE_NAME: entityName.value, ...objParams.value.others}, + columns: GetBaseColumns(entityName.value, 'detailfirst'), + useSearchForm: true, + showTableSetting: true, + bordered: true, + canResize: true, + showIndexColumn: false, + formConfig: { + labelWidth: 120, + schemas: GetSearchFormColumns(entityName.value, 'detailfirst'), + }, + actionColumn: { + width: 80, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', //undefined, + }, + // searchInfo: { BILLCODE }, +}); +const [detailsecondTable, { getForm, reload }] = useTable({ + title: `${secondTitle.value}鍒楄〃`, + api: getListByPage, + columns: GetBaseColumns(entityName.value, 'detailsecond'), + formConfig: { + labelWidth: 120, + schemas: GetFormColumns(entityName.value, 'detailsecond'), + model: { ITEM_CODE: ITEM_CODE }, + }, + useSearchForm: true, + // searchInfo: { BILLCODE }, + showTableSetting: false, + bordered: true, + canResize: true, + showIndexColumn: false, +}); + +function handleCreate() { + openDrawer(true, { + isUpdate: false, + entityName: objParams.value.ID, + formJson: GetFormColumns(entityName.value, 'detailfirst'), + crudColSlots, + others: objParams.value.others, + }); +} + +function secondCreate() { + openDrawer(true, { + isUpdate: false, + entityName: objParams.value.ID, + formJson: _crudFormSchema.value, + crudColSlots, + }); +} + +// 姝ゅ鍙互寰楀埌鐢ㄦ埛ID +//const BILLCODE = ref(route.params?.BILLCODE.split(',')[1]); +var currentKey = ref('detailfirst'); +const { setTitle } = useTabs(); +// TODO +// 鏈〉浠g爜浠呬綔婕旂ず锛屽疄闄呭簲褰撻�氳繃userId浠庢帴鍙h幏寰楃敤鎴风殑鐩稿叧璧勬枡 + +// 璁剧疆Tab鐨勬爣棰橈紙涓嶄細褰卞搷椤甸潰鏍囬锛� +setTitle(`璇︽儏锛�${detailName.value}`); + +// 椤甸潰宸︿晶鐐瑰嚮杩斿洖閾炬帴鏃剁殑鎿嶄綔 +function goBack() { + // 鏈緥鐨勬晥鏋滄椂鐐瑰嚮杩斿洖濮嬬粓璺宠浆鍒拌处鍙峰垪琛ㄩ〉锛屽疄闄呭簲鐢ㄦ椂鍙繑鍥炰笂涓�椤� + go('/CheckRule'); +} +const tabClkcallback = (val: string) => { + if (val == 'detailfirst') { + ITEM_CODE.value = ''; + } +}; + +/** + * @description: detailfirst tab涓殑琛ㄦ牸缂栬緫璁板綍寮瑰嚭渚ц竟妗嗘柟娉� + * @param {*} record + * @return {*} + */ +function handleEdit(record: Recordable) { + openDrawer(true, { + record, + isUpdate: true, + entityName: objParams.value.ID, + formJson: GetFormColumns(entityName.value, 'detailfirst'), + crudColSlots, + }); +} + +/** + * @description: detailfirst tab涓殑琛ㄦ牸鍒犻櫎璁板綍鏂规硶 + * @param {*} record + * @return {*} + */ +function handleDelete(record: Recordable) { + console.log(record); + //鍒犻櫎 + DeleteEntity(record, entityName.value).then((action) => { + if (action.IsSuccessed) { + reloadFirst(); + } + }); +} + +/** + * @description: detailfirst tab涓鍒犳敼鎴愬姛杩斿洖鏂规硶 + * @return {*} + */ +function handleSuccess() { + reloadFirst(); +} + +/** + * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ +function handleItemSuccess(d, u, item) { + getForm().setFieldsValue(GetSelectSuccess(d, u, getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`])); +} + +/** + * @description: 寮瑰嚭閫夋嫨妗� + * @param {*} item + * @return {*} + */ +function handleSelectItem(item) { + OpenSelectItem(openItemModal, getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]); +} + +/** + * @description: Select 鑷畾涔塷nChange鏂规硶 + * @param {*} obj + * @return {*} + */ +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), + }; + }; + } +} + +/** + * @description: 鑷畾涔夊脊鍑烘纭畾杩斿洖 + * @param {*} d + * @return {*} + */ +function custSuccess(d) { + reload(); +} + +/** + * @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); +} + +/** + * @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> diff --git a/src/views/tigerprojects/system/lowcode/normal/index.vue b/src/views/tigerprojects/system/lowcode/normal/index.vue index 36a41fc..6f8550a 100644 --- a/src/views/tigerprojects/system/lowcode/normal/index.vue +++ b/src/views/tigerprojects/system/lowcode/normal/index.vue @@ -4,7 +4,7 @@ * @version: * @Date: 2024-05-30 13:28:20 * @LastEditors: your name - * @LastEditTime: 2024-06-11 01:27:02 + * @LastEditTime: 2024-06-13 14:54:54 --> <template> <div> @@ -16,39 +16,20 @@ <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" - /> + <!-- <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" - > + <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)" - /> + <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> <!-- 鑷畾涔夊唴瀹� --> @@ -57,238 +38,249 @@ </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'; +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'; +import { uploadApi } from '/@/api/sys/upload'; +import { useGo } from '/@/hooks/web/usePage'; - 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 { getLocale } = useLocale(); +const route = useRoute(); +const go = useGo(); +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, +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, + go, + ); +} - 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 handleCreate() { + openDrawer(true, { + isUpdate: false, + entityName: objParams.value.ID, + formJson: _crudFormSchema.value, + crudColSlots, }); +} - /* 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� */ - function handleItemSuccess(d, u, item) { - getForm().setFieldsValue(GetSelectSuccess(d, u, getForm().getFieldsValue()[`${item.replace(/form-/,'').replace(/add/,'')}PSelect_0`])); +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]); } - - /* 寮瑰嚭閫夋嫨妗� */ - function handleSelectItem(item) { - OpenSelectItem(openItemModal, getForm().getFieldsValue()[`${item.replace(/form-/,'').replace(/add/,'')}PSelect_0`]); + _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'; + } + if (_cruds[i].component == 'Upload') { + _cruds[i].componentProps = {}; + _cruds[i].componentProps.api = uploadApi; + _cruds[i].componentProps.multiple = false; + _cruds[i].componentProps.maxNumber = 1; + _cruds[i].rules = [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }]; + } + onChangeConfig(_cruds[i]); } + _crudFormSchema.value = _cruds; - /* 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), - }; + 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 custSuccess(d) { - reload(); - } +/* 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� */ +function handleItemSuccess(d, u, item) { + getForm().setFieldsValue(GetSelectSuccess(d, u, getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`])); +} - /* 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� */ - 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 handleSelectItem(item) { + OpenSelectItem(openItemModal, getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]); +} - /* 鎵撳紑鑷畾涔夋ā鎬佹 */ - function handleCustClick(item) { - OpenCustModal( - useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶 - cType.value, - item, - [], - // selectVals.value['ROUTE_CODE'], - ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹� +/* 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/normalDrawer.vue b/src/views/tigerprojects/system/lowcode/normal/normalDrawer.vue deleted file mode 100644 index f928472..0000000 --- a/src/views/tigerprojects/system/lowcode/normal/normalDrawer.vue +++ /dev/null @@ -1,114 +0,0 @@ -<!-- - * @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" - @register="registerDrawer" - showFooter - :title="getTitle" - width="600px" - @ok="handleSubmit" - > - <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> - import { ref, computed, unref, onMounted } from 'vue'; - 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 crudColSlots = ref<any>([]); - const [registerItemAdd, { openModal: openItemModal }] = useModal(); - const [registerForm, { resetFields, setFieldsValue, getFieldsValue, validate }] = useForm({ - labelWidth: 140, - schemas: formSchema as unknown as FormSchema[], - actionColOptions: { - span: 24, - }, - showActionButtonGroup: false, - }); - - const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { - isUpdate.value = !!data?.isUpdate; - entityName.value = data?.entityName; - // formSchema.value = await fetchJson( - // `${globSetting.downloadUrl}/LowCode/${unref(entityName)}/${ - // entityName.value - // }_addEditform.json`, - // ); - formSchema.value = data?.formJson; - crudColSlots.value = data?.crudColSlots; - resetFields(); - setDrawerProps({ confirmLoading: false }); - - if (unref(isUpdate)) { - setFieldsValue({ - ...data.record, - }); - } - }); - - const getTitle = computed(() => (!unref(isUpdate) ? '鏂板' : '缂栬緫')); - - onMounted(async () => {}); - async function handleSubmit() { - try { - const values = await validate(); - setDrawerProps({ confirmLoading: true }); - // TODO custom api - //淇濆瓨 - const apiAction = SaveEntity(values, unref(isUpdate), unref(entityName)); - apiAction.then((action) => { - if (action.IsSuccessed) { - closeDrawer(); - emit('success'); - } - }); - } finally { - 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/normalDrawer.vue b/src/views/tigerprojects/system/lowcode/normalDrawer.vue new file mode 100644 index 0000000..a9d5af9 --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/normalDrawer.vue @@ -0,0 +1,106 @@ +<!-- + * @Description: file content + * @Author: your name + * @version: + * @Date: 2024-05-30 13:28:20 + * @LastEditors: your name + * @LastEditTime: 2024-06-13 20:36:33 +--> +<template> + <BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :title="getTitle" width="600px" @ok="handleSubmit"> + <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> +import { ref, computed, unref, onMounted } from 'vue'; +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, formatValues } from '/@/api/tigerapi/system'; +import { useModal } from '/@/components/Modal'; +import { GetSelectSuccess, OpenSelectItem } from './data'; +import { isArray, isNullOrEmpty } from '/@/utils/is'; + +const emit = defineEmits(['success', 'register']); +const globSetting = useGlobSetting(); +const isUpdate = ref(true); +const entityName = ref(''); +const formSchema = ref([]); +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: { + span: 24, + }, + showActionButtonGroup: false, +}); + +const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { + isUpdate.value = !!data?.isUpdate; + entityName.value = data?.entityName; + // formSchema.value = await fetchJson( + // `${globSetting.downloadUrl}/LowCode/${unref(entityName)}/${ + // entityName.value + // }_addEditform.json`, + // ); + formSchema.value = data?.formJson; + crudColSlots.value = data?.crudColSlots; + resetFields(); + setDrawerProps({ confirmLoading: false }); + + if (unref(isUpdate)) { + setFieldsValue({ + ...data.record, + }); + }else{ + if(!isNullOrEmpty(data?.others)){} + setFieldsValue(data?.others); + } +}); + +const getTitle = computed(() => (!unref(isUpdate) ? '鏂板' : '缂栬緫')); + +onMounted(async () => { }); +async function handleSubmit() { + try { + let values = await validate(); + //鍒ゆ柇淇濆瓨鐨勫�煎鏋滄槸[]鏁扮粍鐨勶紝灏辩洿鎺ュ彇[0]绗竴涓�硷紝涓�鑸拡瀵逛笂浼犳ā鏉跨殑鍦板潃 + values = formatValues(values); + setDrawerProps({ confirmLoading: true }); + // TODO custom api + //淇濆瓨 + SaveEntity(values, unref(isUpdate), unref(entityName)).then((action) => { + if (action.IsSuccessed) { + closeDrawer(); + emit('success'); + } + }); + } finally { + 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 bc2fcfc..df75d40 100644 --- a/src/views/tigerprojects/system/lowcode/setting/pageDetail.vue +++ b/src/views/tigerprojects/system/lowcode/setting/pageDetail.vue @@ -4,7 +4,7 @@ * @version: * @Date: 2024-05-30 22:00:44 * @LastEditors: your name - * @LastEditTime: 2024-06-11 01:50:33 + * @LastEditTime: 2024-06-13 14:21:16 --> <!-- eslint-disable prettier/prettier --> <template> @@ -420,6 +420,10 @@ label: 'Checkbox', }, { + value: 'Upload', + label: '鏂囦欢涓婁紶', + }, + { value: 'RangePicker', label: '鏃堕棿閫夋嫨鍣�', }, -- Gitblit v1.9.3