mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-23 23:39:47 +08:00
feat:整合字典管理
This commit is contained in:
2
docs/template/soy.index.vue.vm
vendored
2
docs/template/soy.index.vue.vm
vendored
@ -138,7 +138,7 @@ async function edit(#foreach($column in $columns)#if($column.isPk == '1')$column
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
download('/${moduleName}/${businessName}/export', searchParams, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`);
|
||||
download('/${moduleName}/${businessName}/export', searchParams, `${functionName}_#[[${new Date().getTime()}]]#.xlsx`);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -6,24 +6,39 @@ import { useDict } from '@/hooks/business/dict';
|
||||
defineOptions({ name: 'DictTag' });
|
||||
|
||||
interface Props {
|
||||
value: string;
|
||||
dictCode: string;
|
||||
value?: string;
|
||||
dictCode?: string;
|
||||
immediate?: boolean;
|
||||
dictData?: Api.System.DictData;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
immediate: false
|
||||
immediate: false,
|
||||
dictData: undefined,
|
||||
dictCode: '',
|
||||
value: ''
|
||||
});
|
||||
|
||||
const attrs: TagProps = useAttrs();
|
||||
const { transformDictData } = useDict(props.dictCode, props.immediate);
|
||||
const dictData = computed(() => transformDictData(props.value));
|
||||
const attrs = useAttrs() as TagProps;
|
||||
|
||||
const dictTagData = computed(() => {
|
||||
if (props.dictData) {
|
||||
return props.dictData;
|
||||
}
|
||||
|
||||
if (props.dictCode && props.value) {
|
||||
const { transformDictData } = useDict(props.dictCode, props.immediate);
|
||||
return transformDictData(props.value);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NTag v-if="dictData" :class="dictData.cssClass" :type="dictData.listClass" v-bind="attrs">
|
||||
{{ dictData.dictLabel }}
|
||||
<NTag v-if="dictTagData" :class="dictTagData.cssClass" :type="dictTagData.listClass" v-bind="attrs">
|
||||
{{ dictTagData.dictLabel }}
|
||||
</NTag>
|
||||
</template>
|
||||
|
||||
|
@ -169,7 +169,11 @@ const local: App.I18n.Schema = {
|
||||
system_menu: 'Menu Management',
|
||||
tool: 'System Tools',
|
||||
tool_gen: 'Code Generation',
|
||||
system_user: 'User Management'
|
||||
system_user: 'User Management',
|
||||
system_dict: 'Dict Management',
|
||||
system_dict_data: 'DictData MAnagement',
|
||||
system_dict_type: 'DictType Management',
|
||||
system_tenant: 'Tenant Management'
|
||||
},
|
||||
page: {
|
||||
login: {
|
||||
|
@ -169,7 +169,11 @@ const local: App.I18n.Schema = {
|
||||
system_menu: '菜单管理',
|
||||
tool: '系统工具',
|
||||
tool_gen: '代码生成',
|
||||
system_user: '用户管理'
|
||||
system_user: '用户管理',
|
||||
system_dict: '字典管理',
|
||||
system_dict_data: '字典数据管理',
|
||||
system_dict_type: '字典类型管理',
|
||||
system_tenant: '租户管理'
|
||||
},
|
||||
page: {
|
||||
login: {
|
||||
|
@ -21,6 +21,9 @@ export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<Ro
|
||||
"iframe-page": () => import("@/views/_builtin/iframe-page/[url].vue"),
|
||||
login: () => import("@/views/_builtin/login/index.vue"),
|
||||
home: () => import("@/views/home/index.vue"),
|
||||
system_dict_data: () => import("@/views/system/dict/data/index.vue"),
|
||||
system_dict: () => import("@/views/system/dict/index.vue"),
|
||||
system_dict_type: () => import("@/views/system/dict/type/index.vue"),
|
||||
system_menu: () => import("@/views/system/menu/index.vue"),
|
||||
system_tenant: () => import("@/views/system/tenant/index.vue"),
|
||||
system_user: () => import("@/views/system/user/index.vue"),
|
||||
|
@ -86,6 +86,35 @@ export const generatedRoutes: GeneratedRoute[] = [
|
||||
order: 1
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'system_dict',
|
||||
path: '/system/dict',
|
||||
component: 'view.system_dict',
|
||||
meta: {
|
||||
title: 'system_dict',
|
||||
i18nKey: 'route.system_dict'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'system_dict_data',
|
||||
path: '/system/dict/data',
|
||||
component: 'view.system_dict_data',
|
||||
meta: {
|
||||
title: 'system_dict_data',
|
||||
i18nKey: 'route.system_dict_data'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'system_dict_type',
|
||||
path: '/system/dict/type',
|
||||
component: 'view.system_dict_type',
|
||||
meta: {
|
||||
title: 'system_dict_type',
|
||||
i18nKey: 'route.system_dict_type'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'system_menu',
|
||||
path: '/system/menu',
|
||||
|
@ -170,6 +170,9 @@ const routeMap: RouteMap = {
|
||||
"iframe-page": "/iframe-page/:url",
|
||||
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?",
|
||||
"system": "/system",
|
||||
"system_dict": "/system/dict",
|
||||
"system_dict_data": "/system/dict/data",
|
||||
"system_dict_type": "/system/dict/type",
|
||||
"system_menu": "/system/menu",
|
||||
"system_tenant": "/system/tenant",
|
||||
"system_user": "/system/user",
|
||||
|
36
src/service/api/system/dict-data.ts
Normal file
36
src/service/api/system/dict-data.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { request } from '@/service/request';
|
||||
|
||||
/** 获取字典数据列表 */
|
||||
export function fetchGetDictDataList(params?: Api.System.DictDataSearchParams) {
|
||||
return request<Api.System.DictDataList>({
|
||||
url: '/system/dict/data/list',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
/** 新增字典数据 */
|
||||
export function fetchCreateDictData(data: Api.System.DictDataOperateParams) {
|
||||
return request<boolean>({
|
||||
url: '/system/dict/data',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** 修改字典数据 */
|
||||
export function fetchUpdateDictData(data: Api.System.DictDataOperateParams) {
|
||||
return request<boolean>({
|
||||
url: '/system/dict/data',
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** 批量删除字典数据 */
|
||||
export function fetchBatchDeleteDictData(dictCodes: CommonType.IdType[]) {
|
||||
return request<boolean>({
|
||||
url: `/system/dict/data/${dictCodes.join(',')}`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
@ -15,3 +15,37 @@ export function fetchGetDictTypeOption() {
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
/** 获取字典类型列表 */
|
||||
export function fetchGetDictTypeList(params?: Api.System.DictTypeSearchParams) {
|
||||
return request<Api.System.DictTypeList>({
|
||||
url: '/system/dict/type/list',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
/** 新增字典类型 */
|
||||
export function fetchCreateDictType(data: Api.System.DictTypeOperateParams) {
|
||||
return request<boolean>({
|
||||
url: '/system/dict/type',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** 修改字典类型 */
|
||||
export function fetchUpdateDictType(data: Api.System.DictTypeOperateParams) {
|
||||
return request<boolean>({
|
||||
url: '/system/dict/type',
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** 批量删除字典类型 */
|
||||
export function fetchBatchDeleteDictType(dictIds: CommonType.IdType[]) {
|
||||
return request<boolean>({
|
||||
url: `/system/dict/type/${dictIds.join(',')}`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
||||
/** Init auth route */
|
||||
async function initAuthRoute() {
|
||||
// check if user info is initialized
|
||||
if (!authStore.userInfo.userId) {
|
||||
if (!authStore.userInfo.user?.userId) {
|
||||
await authStore.initUserInfo();
|
||||
}
|
||||
|
||||
|
41
src/typings/api/system.api.d.ts
vendored
41
src/typings/api/system.api.d.ts
vendored
@ -232,7 +232,7 @@ declare namespace Api {
|
||||
/** 字典类型 */
|
||||
type DictType = Common.CommonRecord<{
|
||||
/** 字典主键 */
|
||||
dictId: number;
|
||||
dictId: CommonType.IdType;
|
||||
/** 字典名称 */
|
||||
dictName: string;
|
||||
/** 字典类型 */
|
||||
@ -241,12 +241,25 @@ declare namespace Api {
|
||||
remark: string;
|
||||
}>;
|
||||
|
||||
/** dict type search params */
|
||||
type DictTypeSearchParams = CommonType.RecordNullable<
|
||||
Pick<Api.System.DictType, 'dictName' | 'dictType'> & Api.Common.CommonSearchParams
|
||||
>;
|
||||
|
||||
/** dict type operate params */
|
||||
type DictTypeOperateParams = CommonType.RecordNullable<
|
||||
Pick<Api.System.DictType, 'dictId' | 'dictName' | 'dictType' | 'remark'>
|
||||
>;
|
||||
|
||||
/** dict type list */
|
||||
type DictTypeList = Api.Common.PaginatingQueryRecord<DictType>;
|
||||
|
||||
/** 字典数据 */
|
||||
type DictData = Common.CommonRecord<{
|
||||
/** 样式属性(其他样式扩展) */
|
||||
cssClass: string;
|
||||
/** 字典编码 */
|
||||
dictCode: number;
|
||||
dictCode: CommonType.IdType;
|
||||
/** 字典标签 */
|
||||
dictLabel: string;
|
||||
/** 字典排序 */
|
||||
@ -263,6 +276,30 @@ declare namespace Api {
|
||||
remark: string;
|
||||
}>;
|
||||
|
||||
/** dict data search params */
|
||||
type DictDataSearchParams = CommonType.RecordNullable<
|
||||
Pick<Api.System.DictData, 'dictLabel' | 'dictType'> & Api.Common.CommonSearchParams
|
||||
>;
|
||||
|
||||
/** dict data operate params */
|
||||
type DictDataOperateParams = CommonType.RecordNullable<
|
||||
Pick<
|
||||
Api.System.DictData,
|
||||
| 'dictCode'
|
||||
| 'dictSort'
|
||||
| 'dictLabel'
|
||||
| 'dictValue'
|
||||
| 'dictType'
|
||||
| 'cssClass'
|
||||
| 'listClass'
|
||||
| 'isDefault'
|
||||
| 'remark'
|
||||
>
|
||||
>;
|
||||
|
||||
/** dict data list */
|
||||
type DictDataList = Api.Common.PaginatingQueryRecord<DictData>;
|
||||
|
||||
/** dept */
|
||||
type Dept = Api.Common.CommonRecord<{
|
||||
/** 部门id */
|
||||
|
2
src/typings/components.d.ts
vendored
2
src/typings/components.d.ts
vendored
@ -39,6 +39,7 @@ declare module 'vue' {
|
||||
IconIcRoundUpload: typeof import('~icons/ic/round-upload')['default']
|
||||
IconLocalBanner: typeof import('~icons/local/banner')['default']
|
||||
IconLocalLogo: typeof import('~icons/local/logo')['default']
|
||||
'IconMaterialSymbols:syncRounded': typeof import('~icons/material-symbols/sync-rounded')['default']
|
||||
IconMaterialSymbolsHelpOutline: typeof import('~icons/material-symbols/help-outline')['default']
|
||||
IconMdiArrowDownThin: typeof import('~icons/mdi/arrow-down-thin')['default']
|
||||
IconMdiArrowUpThin: typeof import('~icons/mdi/arrow-up-thin')['default']
|
||||
@ -103,6 +104,7 @@ declare module 'vue' {
|
||||
NSelect: typeof import('naive-ui')['NSelect']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NSpin: typeof import('naive-ui')['NSpin']
|
||||
NSplit: typeof import('naive-ui')['NSplit']
|
||||
NStatistic: typeof import('naive-ui')['NStatistic']
|
||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||
NTab: typeof import('naive-ui')['NTab']
|
||||
|
6
src/typings/elegant-router.d.ts
vendored
6
src/typings/elegant-router.d.ts
vendored
@ -24,6 +24,9 @@ declare module "@elegant-router/types" {
|
||||
"iframe-page": "/iframe-page/:url";
|
||||
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?";
|
||||
"system": "/system";
|
||||
"system_dict": "/system/dict";
|
||||
"system_dict_data": "/system/dict/data";
|
||||
"system_dict_type": "/system/dict/type";
|
||||
"system_menu": "/system/menu";
|
||||
"system_tenant": "/system/tenant";
|
||||
"system_user": "/system/user";
|
||||
@ -90,6 +93,9 @@ declare module "@elegant-router/types" {
|
||||
| "iframe-page"
|
||||
| "login"
|
||||
| "home"
|
||||
| "system_dict_data"
|
||||
| "system_dict"
|
||||
| "system_dict_type"
|
||||
| "system_menu"
|
||||
| "system_tenant"
|
||||
| "system_user"
|
||||
|
218
src/views/system/dict/data/index.vue
Normal file
218
src/views/system/dict/data/index.vue
Normal file
@ -0,0 +1,218 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm } from 'naive-ui';
|
||||
import { fetchBatchDeleteDictData, fetchGetDictDataList } from '@/service/api/system/dict-data';
|
||||
import { $t } from '@/locales';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useDownload } from '@/hooks/business/download';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import DictTag from '@/components/custom/dict-tag.vue';
|
||||
import { emitter } from '../mitt';
|
||||
import DictDataOperateDrawer from './modules/dict-data-operate-drawer.vue';
|
||||
import DictDataSearch from './modules/dict-data-search.vue';
|
||||
defineOptions({
|
||||
name: 'DictDataList'
|
||||
});
|
||||
|
||||
const appStore = useAppStore();
|
||||
const { download } = useDownload();
|
||||
const { hasAuth } = useAuth();
|
||||
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
getData,
|
||||
getDataByPage,
|
||||
loading,
|
||||
mobilePagination,
|
||||
searchParams,
|
||||
resetSearchParams
|
||||
} = useTable({
|
||||
apiFn: fetchGetDictDataList,
|
||||
apiParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
|
||||
// the value can not be undefined, otherwise the property in Form will not be reactive
|
||||
dictLabel: null,
|
||||
dictType: null
|
||||
},
|
||||
columns: () => [
|
||||
{
|
||||
type: 'selection',
|
||||
align: 'center',
|
||||
width: 48
|
||||
},
|
||||
{
|
||||
key: 'dictLabel',
|
||||
title: '字典标签',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
},
|
||||
render(row) {
|
||||
return <DictTag size="small" dictData={row} />;
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'dictValue',
|
||||
title: '字典键值',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'dictSort',
|
||||
title: '字典排序',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'remark',
|
||||
title: '备注',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'createTime',
|
||||
title: '创建时间',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'operate',
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
width: 160,
|
||||
render: row => {
|
||||
const editBtn = () => {
|
||||
if (!hasAuth('system:dict:edit')) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.dictCode!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
);
|
||||
};
|
||||
|
||||
const deleteBtn = () => {
|
||||
if (!hasAuth('system:dict:remove')) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.dictCode!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
{editBtn()}
|
||||
{deleteBtn()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted } =
|
||||
useTableOperate(data, getData);
|
||||
|
||||
async function handleBatchDelete() {
|
||||
// request
|
||||
const { error } = await fetchBatchDeleteDictData(checkedRowKeys.value);
|
||||
if (error) return;
|
||||
onBatchDeleted();
|
||||
}
|
||||
|
||||
async function handleDelete(dictCode: CommonType.IdType) {
|
||||
// request
|
||||
const { error } = await fetchBatchDeleteDictData([dictCode]);
|
||||
if (error) return;
|
||||
onDeleted();
|
||||
}
|
||||
|
||||
async function edit(dictCode: CommonType.IdType) {
|
||||
handleEdit('dictCode', dictCode);
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
download('/system/dict/data/export', searchParams, `字典数据_${new Date().getTime()}.xlsx`);
|
||||
}
|
||||
|
||||
emitter.on('rowClick', async (value: string) => {
|
||||
searchParams.dictType = value;
|
||||
await getData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
||||
<DictDataSearch v-model:model="searchParams" @reset="resetSearchParams" @search="getDataByPage" />
|
||||
<NCard title="字典数据列表" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
|
||||
<template #header-extra>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
:disabled-delete="checkedRowKeys.length === 0"
|
||||
:loading="loading"
|
||||
:show-add="hasAuth('system:dictData:add')"
|
||||
:show-delete="hasAuth('system:dictData:remove')"
|
||||
:show-export="hasAuth('system:dictData:export')"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@export="handleExport"
|
||||
@refresh="getData"
|
||||
/>
|
||||
</template>
|
||||
<NDataTable
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
size="small"
|
||||
:flex-height="!appStore.isMobile"
|
||||
:scroll-x="608"
|
||||
:loading="loading"
|
||||
remote
|
||||
:row-key="row => row.dictCode"
|
||||
:pagination="mobilePagination"
|
||||
class="sm:h-full"
|
||||
/>
|
||||
<DictDataOperateDrawer
|
||||
v-model:visible="drawerVisible"
|
||||
:operate-type="operateType"
|
||||
:row-data="editingData"
|
||||
@submitted="getDataByPage"
|
||||
/>
|
||||
</NCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
169
src/views/system/dict/data/modules/dict-data-operate-drawer.vue
Normal file
169
src/views/system/dict/data/modules/dict-data-operate-drawer.vue
Normal file
@ -0,0 +1,169 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, watch } from 'vue';
|
||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
import { $t } from '@/locales';
|
||||
import { fetchCreateDictData, fetchUpdateDictData } from '@/service/api/system/dict-data';
|
||||
|
||||
defineOptions({
|
||||
name: 'DictDataOperateDrawer'
|
||||
});
|
||||
|
||||
interface Props {
|
||||
/** the type of operation */
|
||||
operateType: NaiveUI.TableOperateType;
|
||||
/** the edit row data */
|
||||
rowData?: Api.System.DictData | null;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Emits {
|
||||
(e: 'submitted'): void;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
});
|
||||
|
||||
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||
const { createRequiredRule } = useFormRules();
|
||||
|
||||
const title = computed(() => {
|
||||
const titles: Record<NaiveUI.TableOperateType, string> = {
|
||||
add: '新增字典数据',
|
||||
edit: '编辑字典数据'
|
||||
};
|
||||
return titles[props.operateType];
|
||||
});
|
||||
|
||||
type Model = Api.System.DictDataOperateParams;
|
||||
|
||||
const model: Model = reactive(createDefaultModel());
|
||||
|
||||
function createDefaultModel(): Model {
|
||||
return {
|
||||
dictSort: null,
|
||||
dictLabel: '',
|
||||
dictValue: '',
|
||||
dictType: '',
|
||||
cssClass: '',
|
||||
listClass: null,
|
||||
isDefault: '',
|
||||
remark: ''
|
||||
};
|
||||
}
|
||||
|
||||
type RuleKey = Extract<keyof Model, 'dictCode' | 'dictLabel' | 'dictValue'>;
|
||||
|
||||
const rules: Record<RuleKey, App.Global.FormRule> = {
|
||||
dictCode: createRequiredRule('字典编码不能为空'),
|
||||
dictLabel: createRequiredRule('字典标签不能为空'),
|
||||
dictValue: createRequiredRule('字典键值不能为空')
|
||||
};
|
||||
|
||||
function handleUpdateModelWhenEdit() {
|
||||
if (props.operateType === 'add') {
|
||||
Object.assign(model, createDefaultModel());
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.operateType === 'edit' && props.rowData) {
|
||||
Object.assign(model, props.rowData);
|
||||
}
|
||||
}
|
||||
|
||||
function closeDrawer() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await validate();
|
||||
|
||||
// request
|
||||
if (props.operateType === 'add') {
|
||||
const { dictSort, dictLabel, dictValue, dictType, cssClass, listClass, isDefault, remark } = model;
|
||||
const { error } = await fetchCreateDictData({
|
||||
dictSort,
|
||||
dictLabel,
|
||||
dictValue,
|
||||
dictType,
|
||||
cssClass,
|
||||
listClass,
|
||||
isDefault,
|
||||
remark
|
||||
});
|
||||
if (error) return;
|
||||
}
|
||||
|
||||
if (props.operateType === 'edit') {
|
||||
const { dictCode, dictSort, dictLabel, dictValue, dictType, cssClass, listClass, isDefault, remark } = model;
|
||||
const { error } = await fetchUpdateDictData({
|
||||
dictCode,
|
||||
dictSort,
|
||||
dictLabel,
|
||||
dictValue,
|
||||
dictType,
|
||||
cssClass,
|
||||
listClass,
|
||||
isDefault,
|
||||
remark
|
||||
});
|
||||
if (error) return;
|
||||
}
|
||||
|
||||
window.$message?.success($t('common.updateSuccess'));
|
||||
closeDrawer();
|
||||
emit('submitted');
|
||||
}
|
||||
|
||||
watch(visible, () => {
|
||||
if (visible.value) {
|
||||
handleUpdateModelWhenEdit();
|
||||
restoreValidation();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NDrawer v-model:show="visible" :title="title" display-directive="show" :width="800" class="max-w-90%">
|
||||
<NDrawerContent :title="title" :native-scrollbar="false" closable>
|
||||
<NForm ref="formRef" :model="model" :rules="rules">
|
||||
<NFormItem label="字典排序" path="dictSort">
|
||||
<NInputNumber v-model:value="model.dictSort" placeholder="请输入字典排序" />
|
||||
</NFormItem>
|
||||
<NFormItem label="字典标签" path="dictLabel">
|
||||
<NInput v-model:value="model.dictLabel" placeholder="请输入字典标签" />
|
||||
</NFormItem>
|
||||
<NFormItem label="字典键值" path="dictValue">
|
||||
<NInput v-model:value="model.dictValue" placeholder="请输入字典键值" />
|
||||
</NFormItem>
|
||||
<NFormItem label="字典类型" path="dictType">
|
||||
<NInput v-model:value="model.dictType" placeholder="请输入字典类型" />
|
||||
</NFormItem>
|
||||
<NFormItem label="样式属性(其他样式扩展)" path="cssClass">
|
||||
<NInput v-model:value="model.cssClass" placeholder="请输入样式属性(其他样式扩展)" />
|
||||
</NFormItem>
|
||||
<NFormItem label="表格回显样式" path="listClass">
|
||||
<NInput v-model:value="model.listClass" placeholder="请输入表格回显样式" />
|
||||
</NFormItem>
|
||||
<NFormItem label="是否默认(Y是 N否)" path="isDefault">
|
||||
<NInput v-model:value="model.isDefault" placeholder="请输入是否默认(Y是 N否)" />
|
||||
</NFormItem>
|
||||
<NFormItem label="备注" path="remark">
|
||||
<NInput v-model:value="model.remark" :rows="3" type="textarea" placeholder="请输入备注" />
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
<template #footer>
|
||||
<NSpace :size="16">
|
||||
<NButton @click="closeDrawer">{{ $t('common.cancel') }}</NButton>
|
||||
<NButton type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</NButton>
|
||||
</NSpace>
|
||||
</template>
|
||||
</NDrawerContent>
|
||||
</NDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@/service/api/system/dict-data
|
63
src/views/system/dict/data/modules/dict-data-search.vue
Normal file
63
src/views/system/dict/data/modules/dict-data-search.vue
Normal file
@ -0,0 +1,63 @@
|
||||
<script setup lang="ts">
|
||||
import { $t } from '@/locales';
|
||||
import { useNaiveForm } from '@/hooks/common/form';
|
||||
|
||||
defineOptions({
|
||||
name: 'DictDataSearch'
|
||||
});
|
||||
|
||||
interface Emits {
|
||||
(e: 'reset'): void;
|
||||
(e: 'search'): void;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||
|
||||
const model = defineModel<Api.System.DictDataSearchParams>('model', { required: true });
|
||||
|
||||
async function reset() {
|
||||
await restoreValidation();
|
||||
emit('reset');
|
||||
}
|
||||
|
||||
async function search() {
|
||||
await validate();
|
||||
emit('search');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NCard :bordered="false" size="small" class="card-wrapper">
|
||||
<NCollapse>
|
||||
<NCollapseItem :title="$t('common.search')" name="user-search">
|
||||
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
|
||||
<NGrid responsive="self" item-responsive>
|
||||
<NFormItemGi span="12 s:12 m:6" label="字典标签" path="dictLabel" class="pr-24px">
|
||||
<NInput v-model:value="model.dictLabel" placeholder="请输入字典标签" />
|
||||
</NFormItemGi>
|
||||
<NFormItemGi span="24" class="pr-24px">
|
||||
<NSpace class="w-full" justify="end">
|
||||
<NButton @click="reset">
|
||||
<template #icon>
|
||||
<icon-ic-round-refresh class="text-icon" />
|
||||
</template>
|
||||
{{ $t('common.reset') }}
|
||||
</NButton>
|
||||
<NButton type="primary" ghost @click="search">
|
||||
<template #icon>
|
||||
<icon-ic-round-search class="text-icon" />
|
||||
</template>
|
||||
{{ $t('common.search') }}
|
||||
</NButton>
|
||||
</NSpace>
|
||||
</NFormItemGi>
|
||||
</NGrid>
|
||||
</NForm>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</NCard>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
18
src/views/system/dict/index.vue
Normal file
18
src/views/system/dict/index.vue
Normal file
@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { onUnmounted } from 'vue';
|
||||
|
||||
import DictTypeList from './type/index.vue';
|
||||
import DictDataList from './data/index.vue';
|
||||
import { emitter } from './mitt';
|
||||
|
||||
onUnmounted(() => emitter.off('rowClick'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full flex gap-16px">
|
||||
<DictTypeList class="w-1/2" />
|
||||
<DictDataList class="w-1/2" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
8
src/views/system/dict/mitt.ts
Normal file
8
src/views/system/dict/mitt.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import mitt from 'mitt';
|
||||
|
||||
/** dictType: string */
|
||||
type Events = {
|
||||
rowClick: string;
|
||||
};
|
||||
|
||||
export const emitter = mitt<Events>();
|
217
src/views/system/dict/type/index.vue
Normal file
217
src/views/system/dict/type/index.vue
Normal file
@ -0,0 +1,217 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm } from 'naive-ui';
|
||||
import { ref } from 'vue';
|
||||
import { fetchBatchDeleteDictType, fetchGetDictTypeList } from '@/service/api/system/dict';
|
||||
import { $t } from '@/locales';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useDownload } from '@/hooks/business/download';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import type { TableDataWithIndex } from '~/packages/hooks/src';
|
||||
import { emitter } from '../mitt';
|
||||
import DictTypeOperateDrawer from './modules/dict-type-operate-drawer.vue';
|
||||
import DictTypeSearch from './modules/dict-type-search.vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'DictTypeList'
|
||||
});
|
||||
|
||||
const appStore = useAppStore();
|
||||
const { download } = useDownload();
|
||||
const { hasAuth } = useAuth();
|
||||
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
data,
|
||||
getData,
|
||||
getDataByPage,
|
||||
loading,
|
||||
mobilePagination,
|
||||
searchParams,
|
||||
resetSearchParams
|
||||
} = useTable({
|
||||
apiFn: fetchGetDictTypeList,
|
||||
apiParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
|
||||
// the value can not be undefined, otherwise the property in Form will not be reactive
|
||||
dictName: null,
|
||||
dictType: null
|
||||
},
|
||||
columns: () => [
|
||||
{
|
||||
type: 'selection',
|
||||
align: 'center',
|
||||
width: 48
|
||||
},
|
||||
{
|
||||
key: 'dictName',
|
||||
title: '字典名称',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'dictType',
|
||||
title: '字典类型',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'remark',
|
||||
title: '备注',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'createTime',
|
||||
title: '创建时间',
|
||||
align: 'center',
|
||||
minWidth: 80,
|
||||
resizable: true,
|
||||
ellipsis: {
|
||||
tooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'operate',
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
width: 160,
|
||||
render: row => {
|
||||
const editBtn = () => {
|
||||
if (!hasAuth('system:dict:edit')) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.dictId!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
);
|
||||
};
|
||||
|
||||
const deleteBtn = () => {
|
||||
if (!hasAuth('system:dict:remove')) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.dictId!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
{editBtn()}
|
||||
{deleteBtn()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted } =
|
||||
useTableOperate(data, getData);
|
||||
|
||||
const lastDictType = ref('');
|
||||
const rowClick = (row: TableDataWithIndex<Api.System.DictType>) => {
|
||||
return {
|
||||
style: 'cursor: pointer;',
|
||||
onClick: () => {
|
||||
if (lastDictType.value === row.dictType) {
|
||||
return;
|
||||
}
|
||||
emitter.emit('rowClick', row.dictType);
|
||||
lastDictType.value = row.dictType;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
async function handleBatchDelete() {
|
||||
// request
|
||||
const { error } = await fetchBatchDeleteDictType(checkedRowKeys.value);
|
||||
if (error) return;
|
||||
onBatchDeleted();
|
||||
}
|
||||
|
||||
async function handleDelete(dictId: CommonType.IdType) {
|
||||
// request
|
||||
const { error } = await fetchBatchDeleteDictType([dictId]);
|
||||
if (error) return;
|
||||
onDeleted();
|
||||
}
|
||||
|
||||
async function edit(dictId: CommonType.IdType) {
|
||||
handleEdit('dictId', dictId);
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
download('/system/dict/type/export', searchParams, `字典类型_${new Date().getTime()}.xlsx`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
||||
<DictTypeSearch v-model:model="searchParams" @reset="resetSearchParams" @search="getDataByPage" />
|
||||
<NCard title="字典类型列表" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
|
||||
<template #header-extra>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
:disabled-delete="checkedRowKeys.length === 0"
|
||||
:loading="loading"
|
||||
:show-add="hasAuth('system:dict:add')"
|
||||
:show-delete="hasAuth('system:dict:remove')"
|
||||
:show-export="hasAuth('system:dict:export')"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@export="handleExport"
|
||||
@refresh="getData"
|
||||
/>
|
||||
</template>
|
||||
<NDataTable
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
size="small"
|
||||
:flex-height="!appStore.isMobile"
|
||||
:scroll-x="528"
|
||||
:loading="loading"
|
||||
remote
|
||||
:row-key="row => row.dictId"
|
||||
:pagination="mobilePagination"
|
||||
class="sm:h-full"
|
||||
:row-props="rowClick"
|
||||
/>
|
||||
<DictTypeOperateDrawer
|
||||
v-model:visible="drawerVisible"
|
||||
:operate-type="operateType"
|
||||
:row-data="editingData"
|
||||
@submitted="getDataByPage"
|
||||
/>
|
||||
</NCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
127
src/views/system/dict/type/modules/dict-type-operate-drawer.vue
Normal file
127
src/views/system/dict/type/modules/dict-type-operate-drawer.vue
Normal file
@ -0,0 +1,127 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, watch } from 'vue';
|
||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
import { $t } from '@/locales';
|
||||
import { fetchCreateDictType, fetchUpdateDictType } from '@/service/api/system/dict';
|
||||
|
||||
defineOptions({
|
||||
name: 'DictTypeOperateDrawer'
|
||||
});
|
||||
|
||||
interface Props {
|
||||
/** the type of operation */
|
||||
operateType: NaiveUI.TableOperateType;
|
||||
/** the edit row data */
|
||||
rowData?: Api.System.DictType | null;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Emits {
|
||||
(e: 'submitted'): void;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
});
|
||||
|
||||
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||
const { createRequiredRule } = useFormRules();
|
||||
|
||||
const title = computed(() => {
|
||||
const titles: Record<NaiveUI.TableOperateType, string> = {
|
||||
add: '新增字典类型',
|
||||
edit: '编辑字典类型'
|
||||
};
|
||||
return titles[props.operateType];
|
||||
});
|
||||
|
||||
type Model = Api.System.DictTypeOperateParams;
|
||||
|
||||
const model: Model = reactive(createDefaultModel());
|
||||
|
||||
function createDefaultModel(): Model {
|
||||
return {
|
||||
dictName: '',
|
||||
dictType: '',
|
||||
remark: ''
|
||||
};
|
||||
}
|
||||
|
||||
type RuleKey = Extract<keyof Model, 'dictId'>;
|
||||
|
||||
const rules: Record<RuleKey, App.Global.FormRule> = {
|
||||
dictId: createRequiredRule('字典主键不能为空')
|
||||
};
|
||||
|
||||
function handleUpdateModelWhenEdit() {
|
||||
if (props.operateType === 'add') {
|
||||
Object.assign(model, createDefaultModel());
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.operateType === 'edit' && props.rowData) {
|
||||
Object.assign(model, props.rowData);
|
||||
}
|
||||
}
|
||||
|
||||
function closeDrawer() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await validate();
|
||||
|
||||
// request
|
||||
if (props.operateType === 'add') {
|
||||
const { dictName, dictType, remark } = model;
|
||||
const { error } = await fetchCreateDictType({ dictName, dictType, remark });
|
||||
if (error) return;
|
||||
}
|
||||
|
||||
if (props.operateType === 'edit') {
|
||||
const { dictId, dictName, dictType, remark } = model;
|
||||
const { error } = await fetchUpdateDictType({ dictId, dictName, dictType, remark });
|
||||
if (error) return;
|
||||
}
|
||||
|
||||
window.$message?.success($t('common.updateSuccess'));
|
||||
closeDrawer();
|
||||
emit('submitted');
|
||||
}
|
||||
|
||||
watch(visible, () => {
|
||||
if (visible.value) {
|
||||
handleUpdateModelWhenEdit();
|
||||
restoreValidation();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NDrawer v-model:show="visible" :title="title" display-directive="show" :width="800" class="max-w-90%">
|
||||
<NDrawerContent :title="title" :native-scrollbar="false" closable>
|
||||
<NForm ref="formRef" :model="model" :rules="rules">
|
||||
<NFormItem label="字典名称" path="dictName">
|
||||
<NInput v-model:value="model.dictName" placeholder="请输入字典名称" />
|
||||
</NFormItem>
|
||||
<NFormItem label="字典类型" path="dictType">
|
||||
<NInput v-model:value="model.dictType" placeholder="请输入字典类型" />
|
||||
</NFormItem>
|
||||
<NFormItem label="备注" path="remark">
|
||||
<NInput v-model:value="model.remark" :rows="3" type="textarea" placeholder="请输入备注" />
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
<template #footer>
|
||||
<NSpace :size="16">
|
||||
<NButton @click="closeDrawer">{{ $t('common.cancel') }}</NButton>
|
||||
<NButton type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</NButton>
|
||||
</NSpace>
|
||||
</template>
|
||||
</NDrawerContent>
|
||||
</NDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
66
src/views/system/dict/type/modules/dict-type-search.vue
Normal file
66
src/views/system/dict/type/modules/dict-type-search.vue
Normal file
@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import { $t } from '@/locales';
|
||||
import { useNaiveForm } from '@/hooks/common/form';
|
||||
|
||||
defineOptions({
|
||||
name: 'DictTypeSearch'
|
||||
});
|
||||
|
||||
interface Emits {
|
||||
(e: 'reset'): void;
|
||||
(e: 'search'): void;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||
|
||||
const model = defineModel<Api.System.DictTypeSearchParams>('model', { required: true });
|
||||
|
||||
async function reset() {
|
||||
await restoreValidation();
|
||||
emit('reset');
|
||||
}
|
||||
|
||||
async function search() {
|
||||
await validate();
|
||||
emit('search');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NCard :bordered="false" size="small" class="card-wrapper">
|
||||
<NCollapse>
|
||||
<NCollapseItem :title="$t('common.search')" name="user-search">
|
||||
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
|
||||
<NGrid responsive="self" item-responsive>
|
||||
<NFormItemGi span="12 s:12 m:6" label="字典名称" path="dictName" class="pr-24px">
|
||||
<NInput v-model:value="model.dictName" placeholder="请输入字典名称" />
|
||||
</NFormItemGi>
|
||||
<NFormItemGi span="12 s:12 m:6" label="字典类型" path="dictType" class="pr-24px">
|
||||
<NInput v-model:value="model.dictType" placeholder="请输入字典名称" />
|
||||
</NFormItemGi>
|
||||
<NFormItemGi span="24" class="pr-24px">
|
||||
<NSpace class="w-full" justify="end">
|
||||
<NButton @click="reset">
|
||||
<template #icon>
|
||||
<icon-ic-round-refresh class="text-icon" />
|
||||
</template>
|
||||
{{ $t('common.reset') }}
|
||||
</NButton>
|
||||
<NButton type="primary" ghost @click="search">
|
||||
<template #icon>
|
||||
<icon-ic-round-search class="text-icon" />
|
||||
</template>
|
||||
{{ $t('common.search') }}
|
||||
</NButton>
|
||||
</NSpace>
|
||||
</NFormItemGi>
|
||||
</NGrid>
|
||||
</NForm>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</NCard>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
@ -192,7 +192,7 @@ async function handleSyncTenantDict() {
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
download('/system/tenant/export', searchParams, '租户列表.xlsx');
|
||||
download('/system/tenant/export', searchParams, `租户列表_${new Date().getTime()}.xlsx`);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { useLoading } from '@sa/hooks';
|
||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
import { $t } from '@/locales';
|
||||
import { fetchCreateTenant, fetchUpdateTenant } from '@/service/api/system/tenant';
|
||||
import { fetchGetTenantPackageSelectList } from '@/service/api/system/tenantPackage';
|
||||
import { fetchGetTenantPackageSelectList } from '@/service/api/system/tenant-package';
|
||||
|
||||
defineOptions({
|
||||
name: 'TenantOperateDrawer'
|
||||
@ -72,7 +72,7 @@ type RuleKey = Extract<
|
||||
const rules: Record<RuleKey, App.Global.FormRule | App.Global.FormRule[]> = {
|
||||
id: createRequiredRule('id不能为空'),
|
||||
contactUserName: createRequiredRule('联系人不能为空'),
|
||||
contactPhone: [createRequiredRule('联系电话不能为空'), patternRules.phone],
|
||||
contactPhone: [createRequiredRule('联系电话不能为空'), { ...patternRules.phone, trigger: ['blur', 'change'] }],
|
||||
companyName: createRequiredRule('企业名称不能为空'),
|
||||
packageId: createRequiredRule('租户套餐不能为空'),
|
||||
accountCount: createRequiredRule('用户数量不能为空'),
|
||||
@ -320,3 +320,4 @@ watch(visible, () => {
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@/service/api/system/tenant-package
|
Reference in New Issue
Block a user