优化、改造部分代码:

1.登录时是否输入租户码默认是需要输入。
2.切换租户的部分逻辑抽取成独立工具类。
3.表单编辑模块整合部分代码,将两个tabpane抽出来成独立文件。
4.修正bug-表单的列表配置为空时编辑页面报错,现改成为空时赋值{}。
5.系统数据迁移复制功能:去掉一些无用的代码;改成多租户时才允许以租户模式导入。
This commit is contained in:
suguangxu
2025-06-13 15:12:51 +08:00
parent 3add60c772
commit 202022a3a5
18 changed files with 742 additions and 616 deletions

View File

@ -41,7 +41,7 @@ VITE_GLOB_API_URL_PREFIX =
#租户开关 #租户开关
# VITE_GLOB_TENANT_ENABLED = true # VITE_GLOB_TENANT_ENABLED = true
#是否需要输入租户 #登录时是否需要输入租户
# VITE_GLOB_TENANT_INPUT_REQUIRED = true # VITE_GLOB_TENANT_INPUT_REQUIRED = true
# 屏蔽通知消息的轮询 # 屏蔽通知消息的轮询

View File

@ -36,3 +36,9 @@ VITE_GLOB_API_URL_PREFIX =
# 屏蔽通知消息的轮询 # 屏蔽通知消息的轮询
VITE_GLOB_DISABLE_NEWS = true VITE_GLOB_DISABLE_NEWS = true
#租户开关
# VITE_GLOB_TENANT_ENABLED = true
#登录时是否需要输入租户码
# VITE_GLOB_TENANT_INPUT_REQUIRED = true

View File

@ -38,7 +38,7 @@ VITE_GLOB_API_URL_PREFIX =
VITE_USE_PWA = false VITE_USE_PWA = false
#租户开关 #租户开关
VITE_GLOB_TENANT_ENABLED = true VITE_GLOB_TENANT_ENABLED = true
#是否需要输入租户 #登录时是否需要输入租户
# VITE_GLOB_TENANT_INPUT_REQUIRED = true # VITE_GLOB_TENANT_INPUT_REQUIRED = true
# 屏蔽通知消息的轮询 # 屏蔽通知消息的轮询

View File

@ -36,3 +36,9 @@ VITE_GLOB_API_URL_PREFIX =
# 打包是否开启pwa功能 # 打包是否开启pwa功能
VITE_USE_PWA = false VITE_USE_PWA = false
#租户开关
# VITE_GLOB_TENANT_ENABLED = true
#登录时是否需要输入租户码
# VITE_GLOB_TENANT_INPUT_REQUIRED = true

View File

@ -27,31 +27,20 @@
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { Tooltip } from 'ant-design-vue'; import { Tooltip } from 'ant-design-vue';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import { changeTenant } from '/@/api/system/tenant';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import {useMessage} from "/@/hooks/web/useMessage"; import {useMessage} from "/@/hooks/web/useMessage";
import {useTabs} from "/@/hooks/web/useTabs"; import {useTenantManager} from "/@/utils/tenantManager";
import {router} from "/@/router";
import {setupRouterGuard} from "/@/router/guard";
import {usePermissionStore} from "/@/store/modules/permission";
import {useMenuSetting} from "/@/hooks/setting/useMenuSetting";
import {useAppInject} from "/@/hooks/web/useAppInject";
import {useAppStore} from "/@/store/modules/app";
const userStore = useUserStore(); const userStore = useUserStore();
const { t } = useI18n(); const { t } = useI18n();
const { userInfo } = storeToRefs(userStore); const { userInfo } = storeToRefs(userStore);
const { closeAll } = useTabs(router);
const permissionStore = usePermissionStore();
const { getShowTopMenu } = useMenuSetting();
const { getIsMobile } = useAppInject();
const appStore = useAppStore();
const formInfo: any = ref({ const formInfo: any = ref({
tenants: [], tenants: [],
tenantId: '', tenantId: '',
tenantCode: '', tenantCode: '',
tenantName: '', tenantName: '',
}); });
const {toggleLocal}=useTenantManager();
getDropMenuList(); getDropMenuList();
watch( watch(
() => userInfo.value, () => userInfo.value,
@ -73,21 +62,9 @@
}); });
} }
} }
async function toggleLocale(lang: string) {
appStore.setPageLoadingAction(true); async function switchTenant(tenantCode: string) {
let res = await changeTenant(lang); await toggleLocal({tenantCode:tenantCode, goHome:true,tabCloseAction:"closeAll"});
permissionStore.setDynamicAddedRoute(false);
await userStore.afterLoginAction(true);
closeAll();
await setupRouterGuard(router);
await permissionStore.changeSubsystem(getShowTopMenu.value, getIsMobile.value);
if(permissionStore.getSubSysList.length>0){
permissionStore.setSubSystem(permissionStore.getSubSysList[0].id);
}else{
permissionStore.setSubSystem("");
}
//appStore.setPageLoadingAction(false);
//location.reload();
} }
function handleMenuEvent(menu: DropMenu) { function handleMenuEvent(menu: DropMenu) {
@ -100,7 +77,7 @@
title: () => h('span', t('温馨提醒')), title: () => h('span', t('温馨提醒')),
content: () => h('span', t('是否确认切换租户?未保存的数据可能会丢失!')), content: () => h('span', t('是否确认切换租户?未保存的数据可能会丢失!')),
onOk: async () => { onOk: async () => {
toggleLocale(menu.event as string); switchTenant(menu.event as string);
}, },
okText: () => t('确认'), okText: () => t('确认'),
cancelText: () => t('取消'), cancelText: () => t('取消'),

View File

@ -20,6 +20,7 @@
import { debounce} from 'lodash-es'; import { debounce} from 'lodash-es';
import {CustomFormConfig, GeneratorConfig} from '/@/model/generator/generatorConfig'; import {CustomFormConfig, GeneratorConfig} from '/@/model/generator/generatorConfig';
import { CodeEditor,MODE } from '/@/components/CodeEditor'; import { CodeEditor,MODE } from '/@/components/CodeEditor';
import {ListConfig} from "/@/model/generator/listConfig";
const { t } = useI18n(); const { t } = useI18n();
const { notification } = useMessage(); const { notification } = useMessage();
@ -35,7 +36,6 @@
}); });
const handleListConfigChange=debounce((v)=>{ const handleListConfigChange=debounce((v)=>{
try{ try{
let jsonObject = JSON.parse(v); let jsonObject = JSON.parse(v);
@ -43,6 +43,7 @@
generatorConfig.listConfig.columnConfigs= jsonObject.columnConfigs; generatorConfig.listConfig.columnConfigs= jsonObject.columnConfigs;
generatorConfig.listConfig.buttonConfigs= jsonObject.buttonConfigs; generatorConfig.listConfig.buttonConfigs= jsonObject.buttonConfigs;
}catch(e){ }catch(e){
console.log(e);
notification.error({ notification.error({
message: t('提示'), message: t('提示'),
description: t('列表配置json格式有误'), description: t('列表配置json格式有误'),
@ -54,6 +55,7 @@
try{ try{
generatorConfig.formJson= JSON.parse(v); generatorConfig.formJson= JSON.parse(v);
}catch(e){ }catch(e){
console.error(e);
notification.error({ notification.error({
message: t('提示'), message: t('提示'),
description: t('表单配置json格式有误'), description: t('表单配置json格式有误'),
@ -62,32 +64,17 @@
},1000); },1000);
const handleRenderConfigChange=debounce((v)=>{ const handleRenderConfigChange=debounce((v)=>{
/* try{
let jsonObject = JSON.parse(v);
generatorConfig.renderConfig.formProps= jsonObject.formProps;
}catch(e){
notification.error({
message: t('提示'),
description: t('渲染覆盖配置json格式有误'),
});
}*/
customFormConfig.renderConfig=v; customFormConfig.renderConfig=v;
},1000); },1000);
const initStep =()=> { const initStep =()=> {
listConfigObject.value=JSON.stringify({ listConfigObject.value=JSON.stringify({
queryConfigs:generatorConfig.listConfig.queryConfigs, queryConfigs:generatorConfig.listConfig.queryConfigs||[],
columnConfigs:generatorConfig.listConfig.columnConfigs, columnConfigs:generatorConfig.listConfig.columnConfigs||[],
buttonConfigs:generatorConfig.listConfig.buttonConfigs buttonConfigs:generatorConfig.listConfig.buttonConfigs||[]
}, null, 2); }, null, 2);
formConfigObject.value=JSON.stringify(generatorConfig.formJson, null, 2); formConfigObject.value=JSON.stringify(generatorConfig.formJson, null, 2);
/* renderConfigObject.value=JSON.stringify({
searchFormSchema:generatorConfig.renderConfig.searchFormSchema||{},
columns:generatorConfig.renderConfig.columns||{},
formProps:generatorConfig.renderConfig.formProps||{}
}, null, 2);*/
renderConfigObject.value= customFormConfig.renderConfig||''; renderConfigObject.value= customFormConfig.renderConfig||'';
} }
@ -98,15 +85,17 @@
generatorConfig.listConfig.columnConfigs= jsonObject.columnConfigs; generatorConfig.listConfig.columnConfigs= jsonObject.columnConfigs;
generatorConfig.listConfig.buttonConfigs= jsonObject.buttonConfigs; generatorConfig.listConfig.buttonConfigs= jsonObject.buttonConfigs;
}catch(e){ }catch(e){
console.error(e);
notification.error({ notification.error({
message: t('提示'), message: t('提示'),
description: t('表配置json格式有误'), description: t('表配置json格式有误'),
}); });
return false; return false;
} }
try{ try{
generatorConfig.formJson= JSON.parse(formConfigObject.value); generatorConfig.formJson= JSON.parse(formConfigObject.value);
}catch(e){ }catch(e){
console.error(e);
notification.error({ notification.error({
message: t('提示'), message: t('提示'),
description: t('表单配置json格式有误'), description: t('表单配置json格式有误'),
@ -114,18 +103,6 @@
return false; return false;
} }
/* try{
let jsonObject = JSON.parse(renderConfigObject.value);
generatorConfig.renderConfig.formProps=jsonObject.formProps ;
}catch(e){
console.log(e);
notification.error({
message: t('提示'),
description: t('渲染覆盖配置json格式有误'),
});
return false;
}*/
customFormConfig.renderConfig=renderConfigObject.value; customFormConfig.renderConfig=renderConfigObject.value;
return true; return true;

View File

@ -0,0 +1,50 @@
import { useUserStore } from '/@/store/modules/user';
import {useAppStore} from "/@/store/modules/app";
import {usePermissionStore} from "/@/store/modules/permission";
import {setupRouterGuard} from "/@/router/guard";
import { changeTenant } from '/@/api/system/tenant';
import {useMenuSetting} from "/@/hooks/setting/useMenuSetting";
import {useAppInject} from "/@/hooks/web/useAppInject";
import {useTabs} from "/@/hooks/web/useTabs";
import { useRouter } from 'vue-router';
export interface SwitchTenantPatams {
tenantCode: string;
goHome: boolean;
tabCloseAction:String;
}
export function useTenantManager() {
const { getShowTopMenu } = useMenuSetting();
const router = useRouter();
const {closeAll, closeOther} = useTabs(router);
const userStore = useUserStore();
const appStore = useAppStore();
const permissionStore = usePermissionStore();
const { getIsMobile } = useAppInject();
const toggleLocal= async (param:SwitchTenantPatams)=>{
appStore.setPageLoadingAction(true);
await changeTenant(param.tenantCode);
permissionStore.setDynamicAddedRoute(false);
await userStore.afterLoginAction(param.goHome);
let tabCloseAction = param.tabCloseAction;
if (tabCloseAction == 'closeAll') {
closeAll();
} else if (tabCloseAction == 'closeOther') {
closeOther();
}
await setupRouterGuard(router);
await permissionStore.changeSubsystem(getShowTopMenu.value, getIsMobile.value);
if (permissionStore.getSubSysList.length > 0) {
permissionStore.setSubSystem(permissionStore.getSubSysList[0].id);
} else {
permissionStore.setSubSystem("");
}
}
return {toggleLocal }
}

View File

@ -397,7 +397,6 @@
rtSchema.push(item); rtSchema.push(item);
} }
} }
// alert("xx"+customFormConfig.formType);
return rtSchema; return rtSchema;
}; };

View File

@ -67,6 +67,7 @@
import { FormJson } from '/@/model/generator/codeGenerator'; import { FormJson } from '/@/model/generator/codeGenerator';
import { FormEventColumnConfig } from '/@/model/generator/formEventConfig'; import { FormEventColumnConfig } from '/@/model/generator/formEventConfig';
import { changeCompsApiConfig, changeEventApiConfig, getMainTable } from '/@/utils/event/design'; import { changeCompsApiConfig, changeEventApiConfig, getMainTable } from '/@/utils/event/design';
import {ListConfig} from "/@/model/generator/listConfig";
const { t } = useI18n(); const { t } = useI18n();
const current = ref(0); const current = ref(0);
@ -149,7 +150,7 @@
customFormConfig.category = data.category; customFormConfig.category = data.category;
customFormConfig.formDesignType = data.formDesignType; customFormConfig.formDesignType = data.formDesignType;
customFormConfig.formJson = JSON.parse(data.formJson); customFormConfig.formJson = JSON.parse(data.formJson);
customFormConfig.listConfig = JSON.parse(data.listConfig); customFormConfig.listConfig = JSON.parse(data.listConfig)||{} as ListConfig;
customFormConfig.renderConfig =data.renderConfig; customFormConfig.renderConfig =data.renderConfig;
customFormConfig.remark = data.remark; customFormConfig.remark = data.remark;

View File

@ -54,6 +54,7 @@
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import DesignLogo from '/@/components/ModalPanel/src/DesignLogo.vue'; import DesignLogo from '/@/components/ModalPanel/src/DesignLogo.vue';
import useGlobalFlag from '/@/hooks/core/useGlobalFlag'; import useGlobalFlag from '/@/hooks/core/useGlobalFlag';
import {ListConfig} from "/@/model/generator/listConfig";
const { t } = useI18n(); const { t } = useI18n();
const current = ref(0); const current = ref(0);
@ -137,7 +138,7 @@
customFormConfig.category = data.category; customFormConfig.category = data.category;
customFormConfig.formDesignType = data.formDesignType; customFormConfig.formDesignType = data.formDesignType;
customFormConfig.formJson = JSON.parse(data.formJson); customFormConfig.formJson = JSON.parse(data.formJson);
customFormConfig.listConfig = JSON.parse(data.listConfig); customFormConfig.listConfig = JSON.parse(data.listConfig)||{} as ListConfig;
customFormConfig.renderConfig =data.renderConfig; customFormConfig.renderConfig =data.renderConfig;
customFormConfig.remark = data.remark; customFormConfig.remark = data.remark;

View File

@ -54,6 +54,7 @@
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import DesignLogo from '/@/components/ModalPanel/src/DesignLogo.vue'; import DesignLogo from '/@/components/ModalPanel/src/DesignLogo.vue';
import {ListConfig} from "/@/model/generator/listConfig";
const { t } = useI18n(); const { t } = useI18n();
const current = ref(0); const current = ref(0);
@ -148,7 +149,7 @@
customFormConfig.category = data.category; customFormConfig.category = data.category;
customFormConfig.formDesignType = data.formDesignType; customFormConfig.formDesignType = data.formDesignType;
customFormConfig.formJson = JSON.parse(data.formJson); customFormConfig.formJson = JSON.parse(data.formJson);
customFormConfig.listConfig = JSON.parse(data.listConfig); customFormConfig.listConfig = JSON.parse(data.listConfig)||{} as ListConfig;
customFormConfig.renderConfig =data.renderConfig; customFormConfig.renderConfig =data.renderConfig;
customFormConfig.remark = data.remark; customFormConfig.remark = data.remark;

View File

@ -2,97 +2,10 @@
<PageWrapper dense contentFullHeight fixed-height contentClass="flex"> <PageWrapper dense contentFullHeight fixed-height contentClass="flex">
<a-tabs v-model:activeKey="activeKey" class="custom-tab white"> <a-tabs v-model:activeKey="activeKey" class="custom-tab white">
<a-tab-pane key="1" tab="零代码表单"> <a-tab-pane key="1" tab="零代码表单">
<div style="display:flex;background-color:white"> <ZeroCodeTypeTabPane ref="zeroCodeTypeTabPaneRef" :dicId="dicId"/>
<div
class="w-1/3 xl:w-1/4 overflow-hidden bg-white h-full"
:style="{ 'border-right': '1px solid #e5e7eb' }"
>
<BasicTree
:title="t('表单分类')"
:clickRowToExpand="true"
:treeData="treeData"
:fieldNames="{ key: 'id', title: 'name' }"
@select="handleSelect"
/>
</div>
<BasicTable @register="registerTable" class="w-2/3 xl:w-3/4">
<template #toolbar>
<div class="toolbar-defined">
<a-button type="primary" @click="handleCreate" v-auth="'form-design:add'">
<template #icon><PlusOutlined /></template>
{{ t('新增') }}
</a-button>
<a-button @click="handleDelete" v-auth="'form-design:batchDelete'">{{
t('批量删除')
}}</a-button>
<a-button @click="previewForm" v-auth="'form-design:previewForm'">{{
t('预览表单')
}}</a-button>
<a-button @click="queryHistory">{{ t('历史记录') }}</a-button>
<a-button @click="handleCategory" v-auth="'form-design:classifyMGT'">{{
t('分类管理')
}}</a-button>
<a-button @click="handleCodeGenerator" v-auth="'form-design:generatedCode'">{{
t('生成代码')
}}</a-button>
</div>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
auth: 'form-design:edit',
onClick: handleEdit.bind(null, record,1),
},
{
icon: 'ant-design:delete-outlined',
auth: 'form-design:delete',
color: 'error',
onClick: handleDelete.bind(null, record),
},
]"
/>
</template>
</BasicTable>
</div>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="生成器表单"> <a-tab-pane key="2" tab="生成器表单">
<div style="display:flex;background-color:white"> <GeneratorTypeTabPane ref="generatorTypeTabPaneRef"/>
<div
class="w-1/3 xl:w-1/4 overflow-hidden bg-white h-full"
:style="{ 'border-right': '1px solid #e5e7eb' }"
>
<BasicTree
:title="t('生成器类型')"
:clickRowToExpand="true"
:treeData="treeData02"
:fieldNames="{ key: 'id', title: 'name' }"
@select="handleSelect02"
/>
</div>
<BasicTable @register="registerTable02" class="w-2/3 xl:w-3/4">
<template #toolbar>
<div class="toolbar-defined">
<a-button @click="previewForm02" v-auth="'form-design:previewForm'">{{
t('预览表单')
}}</a-button>
<a-button @click="queryHistory02">{{ t('历史记录') }}</a-button>
</div>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
auth: 'form-design:edit',
onClick: handleEdit.bind(null, record,0),
}
]"
/>
</template>
</BasicTable>
</div>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
@ -126,13 +39,7 @@
</PageWrapper> </PageWrapper>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { BasicTable, useTable, TableAction, FormSchema, BasicColumn } from '/@/components/Table'; import { h, onMounted, ref, createVNode, reactive, computed,provide } from 'vue';
import {
getFormTemplatePage,
deleteFormTemplate,
updateFormTemplateStatus,
getFormTemplate,
} from '/@/api/form/design';
import { PageWrapper } from '/@/components/Page'; import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
@ -144,147 +51,26 @@
import CodeFirstModal from './components/components/CodeFirstModal.vue'; import CodeFirstModal from './components/components/CodeFirstModal.vue';
import SimpleTemplateModal from './components/components/SimpleTemplateModal.vue'; import SimpleTemplateModal from './components/components/SimpleTemplateModal.vue';
import CodeGeneratorModal from './components/CodeGeneratorModal.vue'; import CodeGeneratorModal from './components/CodeGeneratorModal.vue';
import { h, onMounted, ref, createVNode, reactive, computed,provide } from 'vue';
import { BasicTree, TreeItem } from '/@/components/Tree';
import { getDicDetailList } from '/@/api/system/dic';
import { FormTypeEnum } from '/@/enums/formtypeEnum';
import { Switch, Modal } from 'ant-design-vue';
import { PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import ZeroCodeTypeTabPane from './tabpanes/ZeroCodeTypeTabPane.vue';
import GeneratorTypeTabPane from './tabpanes/GeneratorTypeTabPane.vue';
const { t } = useI18n(); const { t } = useI18n();
const treeData = ref<TreeItem[]>([]);
const treeData02 = ref<TreeItem[]>([
{ "id":'0',name:'数据优先模板'},
{ "id":'1',name:'界面优先模板'},
{ "id":'2',name:'简易模板'}
]);
const formType=ref('');
const selectId = ref('');
const selectedKeys = ref<string[]>([]);
const selectedKeys02 = ref<string[]>([]);
const dicId = '1419276800524424444'; const dicId = '1419276800524424444';
const activeKey = ref('1'); const activeKey = ref('1');
const zeroCodeTypeTabPaneRef=ref();
const generatorTypeTabPaneRef=ref();
const state = reactive({ const state = reactive({
isShowDataFirst: true, isShowDataFirst: true,
isShowCodeFirst: true, isShowCodeFirst: true,
isShowSimpleTemplate: true, isShowSimpleTemplate: true,
isShowCodeGenerator: true, isShowCodeGenerator: true,
}); });
const searchFormSchema: FormSchema[] = [
{
field: 'keyword',
label: t('关键字'),
component: 'Input',
componentProps: {
placeholder: t('请输入关键字'),
},
},
];
const columns: BasicColumn[] = [
{
dataIndex: 'name',
title: t('名称'),
align: 'left',
},
{
dataIndex: 'categoryName',
title: t('分类'),
align: 'left',
},
{
dataIndex: 'enabledMark',
title: t('状态'),
width: 120,
align: 'left',
customRender: ({ record }) => {
if (!Reflect.has(record, 'pendingStatus')) {
record.pendingStatus = false;
}
return h(Switch, {
checked: record.enabledMark === 1,
checkedChildren: t('已启用'),
unCheckedChildren: t('已禁用'),
loading: record.pendingStatus,
onChange(checked: boolean) {
record.pendingStatus = true;
const newStatus = checked ? 1 : 0;
const { createMessage } = useMessage();
updateFormTemplateStatus(record.id, newStatus)
.then(() => {
record.enabledMark = newStatus;
createMessage.success(t('已成功修改状态'));
})
.catch(() => {
createMessage.error(t('修改状态失败'));
})
.finally(() => {
record.pendingStatus = false;
});
},
});
},
},
{
dataIndex: 'createUserName',
title: t('创建人'),
align: 'left',
},
{
dataIndex: 'createDate',
title: t('创建时间'),
align: 'left',
},
{
dataIndex: 'remark',
align: 'left',
title: t('备注'),
},
];
const columns02: BasicColumn[] = [
{
dataIndex: 'name',
title: t('名称'),
align: 'left',
},
{
dataIndex: 'formDesignType',
title: t('模板类型'),
width: 120,
align: 'left',
customRender: ({ record }) => {
if(record.formDesignType==0){
return "数据优先模板";
}else if(record.formDesignType==1){
return "界面优先模板";
}else if(record.formDesignType==2){
return "简易模板";
}else{
return '';
}
},
},
{
dataIndex: 'createUserName',
title: t('创建人'),
align: 'left',
},
{
dataIndex: 'createDate',
title: t('创建时间'),
align: 'left',
},
{
dataIndex: 'remark',
align: 'left',
title: t('备注'),
},
];
const { notification } = useMessage(); const { notification } = useMessage();
const formType=ref();
const [registerDesignModal, { openModal: openDesignModal }] = useModal(); const [registerDesignModal, { openModal: openDesignModal }] = useModal();
const [registerHistoryModal, { openModal: openHistoryModal }] = useModal(); const [registerHistoryModal, { openModal: openHistoryModal }] = useModal();
@ -294,199 +80,26 @@
const [registerCodeFirst, { openModal: openCodeFirstModal }] = useModal(); const [registerCodeFirst, { openModal: openCodeFirstModal }] = useModal();
const [registerSimpleTemplate, { openModal: openSimpleTemplateModal }] = useModal(); const [registerSimpleTemplate, { openModal: openSimpleTemplateModal }] = useModal();
const [registerCodeGenerator, { openModal: openCodeGeneratorModal }] = useModal(); const [registerCodeGenerator, { openModal: openCodeGeneratorModal }] = useModal();
const formConfig = {
rowProps: {
gutter: 16,
},
schemas: searchFormSchema,
fieldMapToTime: [],
showResetButton: false,
};
const [registerTable, { reload, setSelectedRowKeys }] = useTable({
api: getFormTemplatePage,
rowKey: 'id',
title: '表单列表',
columns,
formConfig,
beforeFetch: (params) => {
//发送请求默认新增 左边树结构所选id
return { ...params, category: selectId.value, type: FormTypeEnum.CUSTOM_FORM };
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 80,
title: t('操作'),
dataIndex: 'action',
slots: { customRender: 'action' },
},
rowSelection: {
onChange: onSelectChange,
},
customRow02,
tableSetting: {
size: false,
setting: false,
},
});
const [registerTable02, { reload:reload02, setSelectedRowKeys:setSelectedRowKeys02}] = useTable({ provide('openDesignModal', openDesignModal);
api: getFormTemplatePage, provide('openHistoryModal', openHistoryModal);
rowKey: 'id', provide('openCategoryModal', openCategoryModal);
title: '表单列表', provide('openPreviewModal', openPreviewModal);
columns:columns02, provide('openDataFirstModal', openDataFirstModal);
formConfig, provide('openCodeFirstModal', openCodeFirstModal);
beforeFetch: (params) => { provide('openSimpleTemplateModal', openSimpleTemplateModal);
//发送请求默认新增 左边树结构所选id provide('openCodeGeneratorModal', openCodeGeneratorModal);
return { ...params, category: selectId.value, type: FormTypeEnum.SYSTEM_FORM };
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 80,
title: t('操作'),
dataIndex: 'action',
slots: { customRender: 'action' },
},
rowSelection: {
onChange: onSelectChange02,
},
customRow,
tableSetting: {
size: false,
setting: false,
},
});
const formId = computed(() => { provide<number>('formType', formType);
return selectedKeys.value && selectedKeys.value.length provide('noticeInfo', noticeInfo);
? selectedKeys.value[selectedKeys.value.length - 1]
: '';
});
const formId02 = computed(() => {
return selectedKeys02.value && selectedKeys02.value.length
? selectedKeys02.value[selectedKeys02.value.length - 1]
: '';
});
function onSelectChange(rowKeys: string[]) {
selectedKeys.value = rowKeys;
setSelectedRowKeys(selectedKeys.value);
}
function onSelectChange02(rowKeys: string[]) {
selectedKeys02.value = rowKeys;
setSelectedRowKeys02(selectedKeys02.value);
}
function customRow(record: Recordable) {
return {
onClick: () => {
let selectedRowKeys = [...selectedKeys.value];
if (selectedRowKeys.indexOf(record.id) >= 0) {
let index = selectedRowKeys.indexOf(record.id);
selectedRowKeys.splice(index, 1);
} else {
selectedRowKeys.push(record.id);
}
selectedKeys.value = selectedRowKeys;
setSelectedRowKeys(selectedRowKeys);
},
};
}
function customRow02(record: Recordable) {
return {
onClick: () => {
let selectedRowKeys = [...selectedKeys02.value];
if (selectedRowKeys.indexOf(record.id) >= 0) {
let index = selectedRowKeys.indexOf(record.id);
selectedRowKeys02.splice(index, 1);
} else {
selectedRowKeys02.push(record.id);
}
selectedKeys02.value = selectedRowKeys;
setSelectedRowKeys02(selectedRowKeys);
},
};
}
function handleCreate() {
openDesignModal(true, {
title: t('添加表单'),
});
}
function handleEdit(record: Recordable,fType:number) {
formType.value=fType;
switch (record.formDesignType) {
case 0:
openDataFirstModal(true, {
id: record.id,
isUpdate: true,
});
break;
case 1:
openCodeFirstModal(true, {
id: record.id,
isUpdate: true,
});
break;
case 2:
openSimpleTemplateModal(true, {
id: record.id,
isUpdate: true,
});
break;
default:
notification.error({
message: t('提示'),
description: '该表单缺少模板类型',
});
}
}
function handleDelete(record: Recordable = {}) {
const ids = record.id ? [record.id] : selectedKeys.value;
if (!ids.length) {
noticeInfo('删除');
return;
}
Modal.confirm({
title: t('提示'),
icon: createVNode(ExclamationCircleOutlined),
content: t('确定要删除所选项吗?'),
onOk() {
deleteFormTemplate(ids).then(() => {
reload();
notification.success({
message: t('提示'),
description: t('删除成功'),
});
});
},
onCancel() {},
okText: t('确认'),
cancelText: t('取消'),
});
}
provide<Ref<number>>('formType', formType);
function handleCodeGenerator() {
if (!formId.value) {
noticeInfo('生成');
return;
}
openCodeGeneratorModal(true, { formId: formId.value });
}
function handleSuccess() { function handleSuccess() {
reload(); if(activeKey.value=='1'){
zeroCodeTypeTabPaneRef.value.reload();
}else if(activeKey.value=='2'){
generatorTypeTabPaneRef.value.reload();
}
} }
function handleClose(modal) { function handleClose(modal) {
@ -496,66 +109,6 @@
}, 100); }, 100);
} }
function handleSelect(selectIds) {
selectId.value = selectIds[0];
reload({ searchInfo: { category: selectIds[0] } });
}
function handleSelect02(selectIds) {
selectId.value = selectIds[0];
reload02({ searchInfo: { category: selectIds[0] } });
}
function handleCategory() {
openCategoryModal(true, { title: t('表单分类管理') });
}
async function fetch() {
treeData.value = (await getDicDetailList({
itemId: dicId,
})) as unknown as TreeItem[];
}
async function previewForm() {
if (!formId.value) {
noticeInfo('预览');
return;
}
const templateJson = await getFormTemplate(formId.value);
openPreviewModal(true, { title: t('预览'), formJson: templateJson.formJson });
}
async function previewForm02() {
if (!formId02.value) {
noticeInfo('预览');
return;
}
const templateJson = await getFormTemplate(formId02.value);
openPreviewModal(true, { title: t('预览'), formJson: templateJson.formJson });
}
async function queryHistory() {
if (!formId.value) {
notification.warning({
message: t('提示'),
description: t(`请先选中一行后再查看当前表单历史记录!`),
});
return;
}
openHistoryModal(true, { title: t('历史记录'), formId: formId.value });
}
async function queryHistory02() {
if (!formId02.value) {
notification.warning({
message: t('提示'),
description: t(`请先选中一行后再查看当前表单历史记录!`),
});
return;
}
openHistoryModal(true, { title: t('历史记录'), formId: formId02.value });
}
function noticeInfo(info: string) { function noticeInfo(info: string) {
notification.warning({ notification.warning({
message: t('提示'), message: t('提示'),
@ -563,9 +116,6 @@
}); //提示消息 }); //提示消息
} }
onMounted(() => {
fetch();
});
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.toolbar-defined { .toolbar-defined {

View File

@ -0,0 +1,255 @@
<template>
<div style="display:flex;background-color:white">
<div
class="w-1/3 xl:w-1/4 overflow-hidden bg-white h-full"
:style="{ 'border-right': '1px solid #e5e7eb' }"
>
<BasicTree
:title="t('生成器类型')"
:clickRowToExpand="true"
:treeData="treeData"
:fieldNames="{ key: 'id', title: 'name' }"
@select="handleSelect"
/>
</div>
<BasicTable @register="registerTable" class="w-2/3 xl:w-3/4">
<template #toolbar>
<div class="toolbar-defined">
<a-button @click="previewForm" v-auth="'form-design:previewForm'">{{
t('预览表单')
}}</a-button>
<a-button @click="queryHistory">{{ t('历史记录') }}</a-button>
</div>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
auth: 'form-design:edit',
onClick: handleEdit.bind(null, record,0),
}
]"
/>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" setup>
import { h, onMounted, ref, createVNode, reactive, computed,provide,inject } from 'vue';
import { BasicTable, useTable, TableAction, FormSchema, BasicColumn } from '/@/components/Table';
import {
getFormTemplatePage,
deleteFormTemplate,
updateFormTemplateStatus,
getFormTemplate,
} from '/@/api/form/design';
import { FormTypeEnum } from '/@/enums/formtypeEnum';
import { BasicTree, TreeItem } from '/@/components/Tree';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
const { notification } = useMessage();
const { t } = useI18n();
const treeData = ref<TreeItem[]>([
{ "id":'0',name:'数据优先模板'},
{ "id":'1',name:'界面优先模板'},
{ "id":'2',name:'简易模板'}
]);
const selectId = ref('');
const selectedKeys = ref<string[]>([]);
const searchFormSchema: FormSchema[] = [
{
field: 'keyword',
label: t('关键字'),
component: 'Input',
componentProps: {
placeholder: t('请输入关键字'),
},
},
];
const columns: BasicColumn[] = [
{
dataIndex: 'name',
title: t('名称'),
align: 'left',
},
{
dataIndex: 'formDesignType',
title: t('模板类型'),
width: 120,
align: 'left',
customRender: ({ record }) => {
if(record.formDesignType==0){
return "数据优先模板";
}else if(record.formDesignType==1){
return "界面优先模板";
}else if(record.formDesignType==2){
return "简易模板";
}else{
return '';
}
},
},
{
dataIndex: 'createUserName',
title: t('创建人'),
align: 'left',
},
{
dataIndex: 'createDate',
title: t('创建时间'),
align: 'left',
},
{
dataIndex: 'remark',
align: 'left',
title: t('备注'),
},
];
const formConfig = {
rowProps: {
gutter: 16,
},
schemas: searchFormSchema,
fieldMapToTime: [],
showResetButton: false,
};
const [registerTable, { reload:reload, setSelectedRowKeys:setSelectedRowKeys}] = useTable({
api: getFormTemplatePage,
rowKey: 'id',
title: '表单列表',
columns:columns,
formConfig,
beforeFetch: (params) => {
//发送请求默认新增 左边树结构所选id
return { ...params, category: selectId.value, type: FormTypeEnum.SYSTEM_FORM };
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 80,
title: t('操作'),
dataIndex: 'action',
slots: { customRender: 'action' },
},
rowSelection: {
onChange: onSelectChange,
},
customRow,
tableSetting: {
size: false,
setting: false,
},
});
const formId = computed(() => {
return selectedKeys.value && selectedKeys.value.length
? selectedKeys.value[selectedKeys.value.length - 1]
: '';
});
const openDesignModal = inject('openDesignModal');
const openHistoryModal = inject('openHistoryModal');
const openCategoryModal = inject('openCategoryModal');
const openPreviewModal = inject('openPreviewModal');
const openDataFirstModal = inject('openDataFirstModal');
const openCodeFirstModal = inject('openCodeFirstModal');
const openSimpleTemplateModal = inject('openSimpleTemplateModal');
const openCodeGeneratorModal = inject('openCodeGeneratorModal');
const formType = inject('formType');
const noticeInfo = inject('noticeInfo');
function onSelectChange(rowKeys: string[]) {
selectedKeys.value = rowKeys;
setSelectedRowKeys(selectedKeys.value);
}
function customRow(record: Recordable) {
return {
onClick: () => {
let selectedRowKeys = [...selectedKeys.value];
if (selectedRowKeys.indexOf(record.id) >= 0) {
let index = selectedRowKeys.indexOf(record.id);
selectedRowKeys.splice(index, 1);
} else {
selectedRowKeys.push(record.id);
}
selectedKeys.value = selectedRowKeys;
setSelectedRowKeys(selectedRowKeys);
},
};
}
function handleEdit(record: Recordable,fType:number) {
formType.value=fType;
switch (record.formDesignType) {
case 0:
openDataFirstModal(true, {
id: record.id,
isUpdate: true,
});
break;
case 1:
openCodeFirstModal(true, {
id: record.id,
isUpdate: true,
});
break;
case 2:
openSimpleTemplateModal(true, {
id: record.id,
isUpdate: true,
});
break;
default:
notification.error({
message: t('提示'),
description: '该表单缺少模板类型',
});
}
}
function handleSelect(selectIds) {
selectId.value = selectIds[0];
reload({ searchInfo: { category: selectIds[0] } });
}
async function previewForm() {
if (!formId.value) {
noticeInfo('预览');
return;
}
const templateJson = await getFormTemplate(formId.value);
openPreviewModal(true, { title: t('预览'), formJson: templateJson.formJson });
}
async function queryHistory() {
if (!formId.value) {
notification.warning({
message: t('提示'),
description: t(`请先选中一行后再查看当前表单历史记录!`),
});
return;
}
openHistoryModal(true, { title: t('历史记录'), formId: formId.value });
}
defineExpose({
reload
});
</script>
<style lang="less" scoped>
</style>

View File

@ -0,0 +1,356 @@
<template>
<div style="display:flex;background-color:white">
<div
class="w-1/3 xl:w-1/4 overflow-hidden bg-white h-full"
:style="{ 'border-right': '1px solid #e5e7eb' }"
>
<BasicTree
:title="t('表单分类')"
:clickRowToExpand="true"
:treeData="treeData"
:fieldNames="{ key: 'id', title: 'name' }"
@select="handleSelect"
/>
</div>
<BasicTable @register="registerTable" class="w-2/3 xl:w-3/4">
<template #toolbar>
<div class="toolbar-defined">
<a-button type="primary" @click="handleCreate" v-auth="'form-design:add'">
<template #icon><PlusOutlined /></template>
{{ t('新增') }}
</a-button>
<a-button @click="handleDelete" v-auth="'form-design:batchDelete'">{{
t('批量删除')
}}</a-button>
<a-button @click="previewForm" v-auth="'form-design:previewForm'">{{
t('预览表单')
}}</a-button>
<a-button @click="queryHistory">{{ t('历史记录') }}</a-button>
<a-button @click="handleCategory" v-auth="'form-design:classifyMGT'">{{
t('分类管理')
}}</a-button>
<a-button @click="handleCodeGenerator" v-auth="'form-design:generatedCode'">{{
t('生成代码')
}}</a-button>
</div>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
auth: 'form-design:edit',
onClick: handleEdit.bind(null, record,1),
},
{
icon: 'ant-design:delete-outlined',
auth: 'form-design:delete',
color: 'error',
onClick: handleDelete.bind(null, record),
},
]"
/>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" setup>
import { h, onMounted, ref, createVNode, reactive, computed,provide,inject } from 'vue';
import { BasicTable, useTable, TableAction, FormSchema, BasicColumn } from '/@/components/Table';
import {
getFormTemplatePage,
deleteFormTemplate,
updateFormTemplateStatus,
getFormTemplate,
} from '/@/api/form/design';
import { BasicTree, TreeItem } from '/@/components/Tree';
import { FormTypeEnum } from '/@/enums/formtypeEnum';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDicDetailList } from '/@/api/system/dic';
import { Switch, Modal } from 'ant-design-vue';
import { useI18n } from '/@/hooks/web/useI18n';
const props = defineProps({
dicId:String
})
const { notification } = useMessage();
const { t } = useI18n();
const treeData = ref<TreeItem[]>([]);
const selectId = ref('');
const selectedKeys = ref<string[]>([]);
const searchFormSchema: FormSchema[] = [
{
field: 'keyword',
label: t('关键字'),
component: 'Input',
componentProps: {
placeholder: t('请输入关键字'),
},
},
];
const columns: BasicColumn[] = [
{
dataIndex: 'name',
title: t('名称'),
align: 'left',
},
{
dataIndex: 'categoryName',
title: t('分类'),
align: 'left',
},
{
dataIndex: 'enabledMark',
title: t('状态'),
width: 120,
align: 'left',
customRender: ({ record }) => {
if (!Reflect.has(record, 'pendingStatus')) {
record.pendingStatus = false;
}
return h(Switch, {
checked: record.enabledMark === 1,
checkedChildren: t('已启用'),
unCheckedChildren: t('已禁用'),
loading: record.pendingStatus,
onChange(checked: boolean) {
record.pendingStatus = true;
const newStatus = checked ? 1 : 0;
const { createMessage } = useMessage();
updateFormTemplateStatus(record.id, newStatus)
.then(() => {
record.enabledMark = newStatus;
createMessage.success(t('已成功修改状态'));
})
.catch(() => {
createMessage.error(t('修改状态失败'));
})
.finally(() => {
record.pendingStatus = false;
});
},
});
},
},
{
dataIndex: 'createUserName',
title: t('创建人'),
align: 'left',
},
{
dataIndex: 'createDate',
title: t('创建时间'),
align: 'left',
},
{
dataIndex: 'remark',
align: 'left',
title: t('备注'),
},
];
const formConfig = {
rowProps: {
gutter: 16,
},
schemas: searchFormSchema,
fieldMapToTime: [],
showResetButton: false,
};
const [registerTable, { reload, setSelectedRowKeys }] = useTable({
api: getFormTemplatePage,
rowKey: 'id',
title: '表单列表',
columns,
formConfig,
beforeFetch: (params) => {
//发送请求默认新增 左边树结构所选id
return { ...params, category: selectId.value, type: FormTypeEnum.CUSTOM_FORM };
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 80,
title: t('操作'),
dataIndex: 'action',
slots: { customRender: 'action' },
},
rowSelection: {
onChange: onSelectChange,
},
customRow,
tableSetting: {
size: false,
setting: false,
},
});
const formId = computed(() => {
return selectedKeys.value && selectedKeys.value.length
? selectedKeys.value[selectedKeys.value.length - 1]
: '';
});
const openDesignModal = inject('openDesignModal');
const openHistoryModal = inject('openHistoryModal');
const openCategoryModal = inject('openCategoryModal');
const openPreviewModal = inject('openPreviewModal');
const openDataFirstModal = inject('openDataFirstModal');
const openCodeFirstModal = inject('openCodeFirstModal');
const openSimpleTemplateModal = inject('openSimpleTemplateModal');
const openCodeGeneratorModal = inject('openCodeGeneratorModal');
const formType = inject('formType');
const noticeInfo = inject('noticeInfo');
function onSelectChange(rowKeys: string[]) {
selectedKeys.value = rowKeys;
setSelectedRowKeys(selectedKeys.value);
}
function customRow(record: Recordable) {
return {
onClick: () => {
let selectedRowKeys = [...selectedKeys.value];
if (selectedRowKeys.indexOf(record.id) >= 0) {
let index = selectedRowKeys.indexOf(record.id);
selectedRowKeys.splice(index, 1);
} else {
selectedRowKeys.push(record.id);
}
selectedKeys.value = selectedRowKeys;
setSelectedRowKeys(selectedRowKeys);
},
};
}
function handleCreate() {
openDesignModal(true, {
title: t('添加表单'),
});
}
function handleEdit(record: Recordable,fType:number) {
formType.value=fType;
switch (record.formDesignType) {
case 0:
openDataFirstModal(true, {
id: record.id,
isUpdate: true,
});
break;
case 1:
openCodeFirstModal(true, {
id: record.id,
isUpdate: true,
});
break;
case 2:
openSimpleTemplateModal(true, {
id: record.id,
isUpdate: true,
});
break;
default:
notification.error({
message: t('提示'),
description: '该表单缺少模板类型',
});
}
}
function handleDelete(record: Recordable = {}) {
const ids = record.id ? [record.id] : selectedKeys.value;
if (!ids.length) {
noticeInfo('删除');
return;
}
Modal.confirm({
title: t('提示'),
icon: createVNode(ExclamationCircleOutlined),
content: t('确定要删除所选项吗?'),
onOk() {
deleteFormTemplate(ids).then(() => {
reload();
notification.success({
message: t('提示'),
description: t('删除成功'),
});
});
},
onCancel() {},
okText: t('确认'),
cancelText: t('取消'),
});
}
function handleSelect(selectIds) {
selectId.value = selectIds[0];
reload({ searchInfo: { category: selectIds[0] } });
}
function handleCodeGenerator() {
if (!formId.value) {
noticeInfo('生成');
return;
}
openCodeGeneratorModal(true, { formId: formId.value });
}
async function previewForm() {
if (!formId.value) {
noticeInfo('预览');
return;
}
const templateJson = await getFormTemplate(formId.value);
openPreviewModal(true, { title: t('预览'), formJson: templateJson.formJson });
}
async function queryHistory() {
if (!formId.value) {
notification.warning({
message: t('提示'),
description: t(`请先选中一行后再查看当前表单历史记录!`),
});
return;
}
openHistoryModal(true, { title: t('历史记录'), formId: formId.value });
}
async function fetch() {
treeData.value = (await getDicDetailList({
itemId: props.dicId,
})) as unknown as TreeItem[];
}
function handleCategory() {
openCategoryModal(true, { title: t('表单分类管理') });
}
onMounted(() => {
fetch();
});
defineExpose({
reload
});
</script>
<style lang="less" scoped>
</style>

View File

@ -34,7 +34,7 @@
</Input> </Input>
</FormItem> </FormItem>
<FormItem v-if="getAppEnvConfig().VITE_GLOB_TENANT_ENABLED && getAppEnvConfig().VITE_GLOB_TENANT_INPUT_REQUIRED && loginType =='pw'" name="tenantCode" class="enter-x"> <FormItem v-if="getAppEnvConfig().VITE_GLOB_TENANT_ENABLED && getAppEnvConfig().VITE_GLOB_TENANT_INPUT_REQUIRED!=='false' && loginType =='pw'" name="tenantCode" class="enter-x">
<label class="form-title"> {{ t('租户码') }}</label> <label class="form-title"> {{ t('租户码') }}</label>
<Input <Input
size="large" size="large"

View File

@ -39,11 +39,6 @@
code:"租户", code:"租户",
name:'租户' name:'租户'
}, },
/* {
checked:false,
code:"用户",
name:'用户'
}, */
{ {
checked:false, checked:false,
code:'角色', code:'角色',
@ -54,11 +49,7 @@
code:'岗位', code:'岗位',
name:'岗位' name:'岗位'
}, },
/* {
checked:false,
code:'部门',
name:'部门'
}, */
{ {
checked:false, checked:false,
code:'用户组', code:'用户组',
@ -95,11 +86,6 @@
code:'桌面配置', code:'桌面配置',
name:'桌面配置' name:'桌面配置'
}, },
{
checked:false,
code:'自定义接口',
name:'自定义接口'
},
{ {
checked:false, checked:false,
code:'角色-菜单授权', code:'角色-菜单授权',
@ -110,26 +96,6 @@
code:'角色-自定义接口授权', code:'角色-自定义接口授权',
name:'权限:角色-自定义接口授权' name:'权限:角色-自定义接口授权'
}, },
/* {
checked:false,
code:'用户-角色授权',
name:'权限:用户-角色授权'
},
{
checked:false,
code:'用户-用户组授权',
name:'权限:用户-用户组授权'
},
{
checked:false,
code:'用户-岗位授权',
name:'权限:用户-岗位授权'
},
{
checked:false,
code:'用户-部门授权',
name:'权限:用户-部门授权'
}, */
{ {
checked:false, checked:false,
code:'租户-菜单授权', code:'租户-菜单授权',

View File

@ -2,7 +2,7 @@
<div class="import"> <div class="import">
<div class="import-log"><span @click.stop="showLogsDialog">查看导入日志</span></div> <div class="import-log"><span @click.stop="showLogsDialog">查看导入日志</span></div>
<div class="import-type-wrapper"> <div class="import-type-wrapper">
<ImportSystemConfig importType="tenantMode"> <ImportSystemConfig importType="tenantMode" v-if="getAppEnvConfig().VITE_GLOB_TENANT_ENABLED">
<span class="item-action">租户模式导入</span> <span class="item-action">租户模式导入</span>
</ImportSystemConfig> </ImportSystemConfig>
<ImportSystemConfig importType="overrideMode"> <ImportSystemConfig importType="overrideMode">
@ -51,6 +51,7 @@
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import ImportSystemConfig from './ImportSystemConfig.vue'; import ImportSystemConfig from './ImportSystemConfig.vue';
import { getLogList,getLogDetails} from '/@/api/system/dataMigration'; import { getLogList,getLogDetails} from '/@/api/system/dataMigration';
import {getAppEnvConfig} from "/@/utils/env";
const { t } = useI18n(); const { t } = useI18n();

View File

@ -37,24 +37,13 @@
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
import {useMessage} from "/@/hooks/web/useMessage"; import {useMessage} from "/@/hooks/web/useMessage";
import { changeTenant } from '/@/api/system/tenant'; import {useTenantManager} from "/@/utils/tenantManager";
import {useAppStore} from "/@/store/modules/app";
import {setupRouterGuard} from "/@/router/guard";
import {usePermissionStore} from "/@/store/modules/permission";
import {useTabs} from "/@/hooks/web/useTabs";
import {useMenuSetting} from "/@/hooks/setting/useMenuSetting";
import {useAppInject} from "/@/hooks/web/useAppInject";
const router = useRouter(); const router = useRouter();
const { currentRoute } = router; const { currentRoute } = router;
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStore();
const userStore = useUserStore(); const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore); const { userInfo } = storeToRefs(userStore);
const { closeOther } = useTabs(router);
const permissionStore = usePermissionStore();
const { getShowTopMenu } = useMenuSetting();
const { getIsMobile } = useAppInject();
const configColumns: BasicColumn[] = [ const configColumns: BasicColumn[] = [
@ -135,6 +124,8 @@
} }
}); });
const {toggleLocal}=useTenantManager();
onMounted(() => { onMounted(() => {
bus.on(FLOW_PROCESSED, onFlowProcessed); bus.on(FLOW_PROCESSED, onFlowProcessed);
}); });
@ -151,7 +142,7 @@
); );
const onRowDblClick = (record, index) => { const onRowDblClick = (record, index) => {
const {tenantId,tenantCode,tenantName} = record; const {tenantId,tenantCode,tenantName} = record;
let tenantEnabled=getAppEnvConfig().VITE_TENANT_ENABLED; let tenantEnabled=getAppEnvConfig().VITE_GLOB_TENANT_ENABLED;
if(tenantEnabled =='true'&&tenantId){ if(tenantEnabled =='true'&&tenantId){
let currentTenantId=userInfo.value.tenantId; let currentTenantId=userInfo.value.tenantId;
if(tenantId!=currentTenantId){ if(tenantId!=currentTenantId){
@ -166,7 +157,7 @@
]), ]),
width:'600px', width:'600px',
onOk: async () => { onOk: async () => {
toggleLocale(tenantCode).then(()=>{ switchTenant(tenantCode).then(()=>{
openDetailPage(record,true); openDetailPage(record,true);
}) })
@ -206,19 +197,8 @@
reload(); reload();
} }
async function toggleLocale(tenantCode: string) { async function switchTenant(tenantCode: string) {
appStore.setPageLoadingAction(true); await toggleLocal({tenantCode:tenantCode, goHome:false,tabCloseAction:"closeOther"});
await changeTenant(tenantCode);
permissionStore.setDynamicAddedRoute(false);
await userStore.afterLoginAction(false);
closeOther();
await setupRouterGuard(router);
await permissionStore.changeSubsystem(getShowTopMenu.value, getIsMobile.value);
if(permissionStore.getSubSysList.length>0){
permissionStore.setSubSystem(permissionStore.getSubSysList[0].id);
}else{
permissionStore.setSubSystem("");
}
} }
</script> </script>