字典页面半成
This commit is contained in:
parent
811a6a3ad2
commit
44f1d52e85
@ -1,5 +1,6 @@
|
||||
import { $t } from '@/locales';
|
||||
import { transformRecordToNumberOption } from '@/utils/common';
|
||||
import { type Api } from '@/typings/api';
|
||||
|
||||
export const yesOrNoRecord: Record<Api.Common.YesOrNo, App.I18n.I18nKey> = {
|
||||
'0': 'common.yesOrNo.no',
|
||||
@ -24,9 +25,7 @@ export const isImportantRecord: Record<Api.Common.EnableStatusNumber, App.I18n.I
|
||||
|
||||
export const isImportantOptions = transformRecordToNumberOption(isImportantRecord, true);
|
||||
|
||||
|
||||
|
||||
export const podsType: Record<Api.Dashboard.DashboardPodsType, App.I18n.I18nKey> = {
|
||||
export const podsType: Record<Api.Dashboard.DashboardPodsType, App.I18n.I18nKey> = {
|
||||
1: 'page.pods.type.client',
|
||||
2: 'page.pods.type.server'
|
||||
};
|
||||
@ -83,13 +82,6 @@ export const groupConfigStatusRecord: Record<Api.GroupConfig.GroupStatusType, Ap
|
||||
0: 'common.status.disable',
|
||||
1: 'common.status.enable'
|
||||
};
|
||||
// 网站类别
|
||||
export const groupConfigTypeRecord: Record<number, App.I18n.I18nKey> = {
|
||||
1: 'page.groupConfig.typeDict.government',
|
||||
2: 'page.groupConfig.typeDict.usMilitary',
|
||||
3: 'page.groupConfig.typeDict.usNavy',
|
||||
}
|
||||
export const groupConfigTypeOptions = transformRecordToNumberOption(groupConfigTypeRecord);
|
||||
|
||||
export const groupConfigStatusOptions = transformRecordToNumberOption(groupConfigStatusRecord, true);
|
||||
|
||||
@ -427,7 +419,6 @@ export const jobExecutorEnum: Workflow.JobTagType = {
|
||||
// CategoryType
|
||||
export const categoryTypeRecord: Record<string, App.I18n.I18nKey> = {
|
||||
0: 'page.category.type.website',
|
||||
1: 'page.category.type.literature',
|
||||
}
|
||||
1: 'page.category.type.literature'
|
||||
};
|
||||
export const categoryTypeOptions = transformRecordToNumberOption(categoryTypeRecord);
|
||||
|
||||
|
@ -506,6 +506,27 @@ const local: App.I18n.Schema = {
|
||||
addCategory: '新增分类',
|
||||
editCategory: '编辑分类'
|
||||
},
|
||||
dictionary: {
|
||||
title:'字典',
|
||||
dictionId:'字典编号',
|
||||
dictionaryName: '字典名称',
|
||||
dictionaryType: '字典类型',
|
||||
dictionaryStatus: '状态',
|
||||
remark:'备注',
|
||||
createTime: '创建时间',
|
||||
form:{
|
||||
dictionaryNamePlaceHolder: '请输入字典名称',
|
||||
dictionaryName: '字典名称',
|
||||
dictionaryTypePlaceHolder: '请输入字典名称',
|
||||
dictionaryType: '字典类型',
|
||||
dictionaryStatusPlaceHolder: '请输入字典名称',
|
||||
dictionaryStatus: '状态',
|
||||
createTime: '创建时间'
|
||||
},
|
||||
addDictionary: '新增字典',
|
||||
editDictionary: '编辑字典'
|
||||
|
||||
},
|
||||
namespace: {
|
||||
title: '命名空间',
|
||||
name: '名称',
|
||||
|
69
src/service/api/dictionary.ts
Normal file
69
src/service/api/dictionary.ts
Normal file
@ -0,0 +1,69 @@
|
||||
import { request } from '../request';
|
||||
|
||||
/** get dictConfig list */
|
||||
export function fetchGetDictionaryConfigList(params?: Api.DictionaryConfig.DictionaryConfigSearchParams) {
|
||||
return request<Api.DictionaryConfig.DictionaryConfigList>({
|
||||
url: '/dict/list',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchGetAllDictionaryNameList(params?: Api.DictionaryConfig.DictionaryConfigSearchParams) {
|
||||
return request<string[]>({
|
||||
url: '/dict/all/dict-name/list',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
/** add dictConfig */
|
||||
export function fetchAddDictionaryConfig(data: Api.DictionaryConfig.DictionaryConfigRequestVO) {
|
||||
return request<boolean>({
|
||||
url: '/dict',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** edit dictConfig */
|
||||
export function fetchEditDictionaryConfig(data: Api.DictionaryConfig.DictionaryConfigRequestVO) {
|
||||
return request<boolean>({
|
||||
url: '/dict',
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchUpdateDictionaryStatus(data: Api.DictionaryConfig.DictionaryConfigRequestVO) {
|
||||
return request<boolean>({
|
||||
url: '/dict/status',
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** get partition table list */
|
||||
// export function fetchGetPartitionTableList() {
|
||||
// return request<number[]>({
|
||||
// url: '/dict/partition-table/list',
|
||||
// method: 'get'
|
||||
// });
|
||||
// }
|
||||
|
||||
/** get all dict config list */
|
||||
export function fetchGetAllDictionaryConfigList(data: string[]) {
|
||||
return request<Api.DictionaryConfig.DictionaryConfig[]>({
|
||||
url: '/dict/all/dict-config/list',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** delete dict by id */
|
||||
export function fetchDeleteDictionary(dictName: string) {
|
||||
return request<boolean>({
|
||||
url: `/dict/${dictName}`,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
@ -14,3 +14,4 @@ export * from './job';
|
||||
export * from './job-batch';
|
||||
export * from './user';
|
||||
export * from './category';
|
||||
export * from './dictionary';
|
||||
|
41
src/typings/api.d.ts
vendored
41
src/typings/api.d.ts
vendored
@ -1058,7 +1058,6 @@ declare namespace Api {
|
||||
isImportant: Common.EnableStatusNumber;
|
||||
};
|
||||
|
||||
|
||||
/** JobTask list */
|
||||
type JobList = Common.PaginatingQueryRecord<Job>;
|
||||
|
||||
@ -1361,18 +1360,12 @@ declare namespace Api {
|
||||
throwable: string;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* category Category
|
||||
*
|
||||
* backend api module: "Category"
|
||||
*/
|
||||
namespace Category {
|
||||
|
||||
|
||||
type CategoryType = '网站' | '文献';
|
||||
|
||||
type RowData = Category & {
|
||||
@ -1396,9 +1389,35 @@ declare namespace Api {
|
||||
}
|
||||
|
||||
interface Result {
|
||||
status: 1,
|
||||
message: string,
|
||||
data: RowData[]
|
||||
status: 1;
|
||||
message: string;
|
||||
data: RowData[];
|
||||
}
|
||||
}
|
||||
namespace DictionaryConfig {
|
||||
type CommonSearchParams = Pick<Common.PaginatingCommonParams, 'page' | 'size'>;
|
||||
type DictionaryConfig = Common.CommonRecord<{
|
||||
dictName: string;
|
||||
dictType: string;
|
||||
dictStatus: string;
|
||||
createTime: string;
|
||||
}>;
|
||||
type DictionaryConfigSearchParams = CommonType.RecordNullable<
|
||||
Pick<Api.DictionaryConfig.DictionaryConfig, 'dictName' | 'dictType' | 'dictStatus' | 'createTime'> &
|
||||
CommonSearchParams
|
||||
>;
|
||||
type DictionaryConfigList = {
|
||||
dictId: number;
|
||||
dictName: string;
|
||||
dictType: string;
|
||||
dictStatus: string;
|
||||
createTime: string;
|
||||
};
|
||||
type DictionaryConfigRequestVO = {
|
||||
dictName: string;
|
||||
dictType: string;
|
||||
dictStatus: string;
|
||||
createTime: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ async function reset() {
|
||||
|
||||
<template>
|
||||
<NCard :bordered="false" size="small" class="card-wrapper">
|
||||
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
|
||||
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
|
||||
<NGrid responsive="screen" cols="24" item-responsive :y-gap="12">
|
||||
<!-- 搜索 -->
|
||||
<NFormItemGi span="24 s:12 m:6" :label="$t('page.category.form.categoryName')" path="categoryName" class="pr-24px">
|
||||
|
@ -1,209 +1,243 @@
|
||||
<script setup lang="tsx">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { NButton, NPopconfirm } from 'naive-ui';
|
||||
import { ref } from 'vue';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import { fetchDeleteDictionary, fetchGetDictionaryConfigList, fetchUpdateDictionaryStatus } from '@/service/api';
|
||||
import { $t } from '@/locales';
|
||||
import { fetchGetCategoryList } from '@/service/api';
|
||||
import { useFormOperate } from "./modules/dictionaryTable";
|
||||
import CategorySearch from './modules/dictionary.vue';
|
||||
import CategoryOperateDrawer from './modules/dictionary-operate-drawer.vue';
|
||||
import CategoryHeaderOperation from "./modules/dictionary-header-operation.vue";
|
||||
import { NButton, NPopconfirm, DataTableColumns } from 'naive-ui';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { downloadFetch } from '@/utils/download';
|
||||
import DictionaryOperateDrawer from './modules/dictionary-operate-drawer.vue';
|
||||
import DictionaryDetailDrawer from './modules/dictionary-detail-drawer.vue';
|
||||
import DictionarySearch from './modules/dictionary-search.vue';
|
||||
const { hasAuth } = useAuth();
|
||||
const appStore = useAppStore();
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const {data} = await fetchGetCategoryList();
|
||||
tableData.value = data as RowData[];
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch category list:', error);
|
||||
}
|
||||
/** 详情页属性数据 */
|
||||
const detailData = ref<Api.DictionaryConfig.DictionaryConfig | null>();
|
||||
/** 详情页可见状态 */
|
||||
const { bool: detailVisible, setTrue: openDetail } = useBoolean(false);
|
||||
|
||||
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
|
||||
apiFn: fetchGetDictionaryConfigList,
|
||||
apiParams: {
|
||||
page: 1,
|
||||
size: 10,
|
||||
dictName: '',
|
||||
dictStatus: '',
|
||||
dictType: '',
|
||||
createTime: ''
|
||||
},
|
||||
columns: () => [
|
||||
{
|
||||
key: 'dictId',
|
||||
title: $t('page.dictionary.dictionId'),
|
||||
align: 'center',
|
||||
width: 64
|
||||
},
|
||||
{
|
||||
key: 'dictName',
|
||||
title: $t('page.dictionary.dictionaryName'),
|
||||
align: 'left',
|
||||
width: 200,
|
||||
render: row => {
|
||||
function showDetailDrawer() {
|
||||
detailData.value = row || null;
|
||||
openDetail();
|
||||
}
|
||||
|
||||
return (
|
||||
<n-button text tag="a" type="primary" onClick={showDetailDrawer} class="ws-normal">
|
||||
{row.groupName}
|
||||
</n-button>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'dictType',
|
||||
title: $t('page.dictionary.dictionaryType'),
|
||||
align: 'left',
|
||||
width: 200,
|
||||
render: row => {
|
||||
if (row.type === null) {
|
||||
return null;
|
||||
}
|
||||
// const label = $t(groupConfigTypeRecord[row.type!]);
|
||||
return <p>政府部门/美国军方/美国海军</p>;
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'groupStatus',
|
||||
title: $t('page.groupConfig.groupStatus'),
|
||||
align: 'center',
|
||||
width: 200,
|
||||
render: row => {
|
||||
const fetchFn = async (groupStatus: Api.Common.EnableStatusNumber, callback: (flag: boolean) => void) => {
|
||||
const status = row.groupStatus === 1 ? 0 : 1;
|
||||
const { error } = await fetchUpdateDictionaryStatus({ groupName: row.groupName, groupStatus: status });
|
||||
if (!error) {
|
||||
row.groupStatus = groupStatus;
|
||||
window.$message?.success($t('common.updateSuccess'));
|
||||
}
|
||||
callback(!error);
|
||||
};
|
||||
return (
|
||||
<StatusSwitch v-model:value={row.groupStatus} onSubmitted={fetchFn} disabled={hasAuth('R_USER') as boolean} />
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'idGeneratorMode',
|
||||
title: $t('page.dictionary.remark'),
|
||||
align: 'center',
|
||||
width: 200,
|
||||
render: row => {
|
||||
if (row.idGeneratorMode === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const label = $t(groupConfigIdModeRecord[row.idGeneratorMode!]);
|
||||
|
||||
// return <NTag type="primary">{label}</NTag>;
|
||||
return '用户性别列表';
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'groupPartition',
|
||||
title: $t('page.dictionary.createTime'),
|
||||
align: 'center',
|
||||
minWidth: 60
|
||||
},
|
||||
{
|
||||
key: 'operate',
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
width: 300,
|
||||
render: row => {
|
||||
if (hasAuth('R_USER')) {
|
||||
return <></>;
|
||||
}
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="primary" text ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<n-divider vertical />
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.groupName!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" text ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
type RowData = Api.Category.Category & {
|
||||
children?: RowData[];
|
||||
};
|
||||
|
||||
let loading = ref(false)
|
||||
// 数据
|
||||
// let tableData = ref<RowData[]>([]);
|
||||
const tableData = ref<RowData[]>([
|
||||
{
|
||||
id: 1,
|
||||
parentId: 0,
|
||||
categoryName: 'Root 1',
|
||||
level: '1',
|
||||
createTime: '2023-10-10',
|
||||
categoryType: '网站',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
parentId: 1,
|
||||
categoryName: 'Child 1-1',
|
||||
level: '2',
|
||||
createTime: '2023-10-11',
|
||||
categoryType: '文献',
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
// 表行
|
||||
const columns2 = (): DataTableColumns<RowData> => [
|
||||
{
|
||||
title: $t('page.category.form.categoryName'),
|
||||
key: 'categoryName',
|
||||
|
||||
},
|
||||
{
|
||||
title: $t('page.category.form.categoryType'),
|
||||
align: 'center',
|
||||
key: 'categoryType',
|
||||
width: '25%',
|
||||
},
|
||||
{
|
||||
title: $t('page.category.form.createTime'),
|
||||
align: 'center',
|
||||
key: 'createTime',
|
||||
width: '25%',
|
||||
},
|
||||
{
|
||||
title: $t('common.action'),
|
||||
key: 'index',
|
||||
align: 'center',
|
||||
width: '20%',
|
||||
render: row => (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="primary" text ghost size="small" onClick={() => Add(row!)}>
|
||||
{$t('common.add')}
|
||||
</NButton>
|
||||
<n-divider vertical />
|
||||
<NButton type="warning" text ghost size="small" onClick={() => Edit(row!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<n-divider vertical />
|
||||
<NPopconfirm
|
||||
onPositiveClick={() => Delete(row.id!)}
|
||||
>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" text ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
]
|
||||
const rowKey = (row: RowData) => row.id
|
||||
|
||||
const getData = async () => {
|
||||
console.log("666")
|
||||
loading.value = true;
|
||||
// 模拟延迟
|
||||
const {data} = await fetchGetCategoryList();
|
||||
tableData.value = data as RowData[];
|
||||
loading.value = false;
|
||||
// 模拟获取数据
|
||||
};
|
||||
const saveData = async (data: RowData) => {
|
||||
// 模拟保存数据
|
||||
console.log('保存表单数据', data);
|
||||
};
|
||||
const {
|
||||
drawerVisible, // 抽屉是否可见
|
||||
drawerVisible,
|
||||
operateType,
|
||||
editingData,
|
||||
handleAdd, // 添加操作
|
||||
handleEdit, // 编辑操作
|
||||
} = useFormOperate({
|
||||
getData, // 操作表单后会执行此方法
|
||||
saveData
|
||||
});
|
||||
handleAdd,
|
||||
handleEdit,
|
||||
checkedRowKeys,
|
||||
onDeleted
|
||||
// closeDrawer
|
||||
} = useTableOperate(data, getData);
|
||||
|
||||
// 表头添加操作
|
||||
const headAdd = () => {
|
||||
handleAdd(-1);
|
||||
}
|
||||
const refresh = () => {
|
||||
console.log("你点击了刷新按钮")
|
||||
getData()
|
||||
}
|
||||
// 行添加操作
|
||||
const Add = (item: RowData) => {
|
||||
handleAdd(item.parentId);
|
||||
console.log("你点击了添加", item.id)
|
||||
}
|
||||
// 行编辑操作
|
||||
const Edit = (item: RowData) => {
|
||||
handleEdit(item);
|
||||
console.log("你点击了编辑", item.id)
|
||||
}
|
||||
// 行删除操作
|
||||
const Delete = (id: number) => {
|
||||
console.log("你点击了删除按钮", id)
|
||||
function edit(id: string) {
|
||||
handleEdit(id);
|
||||
}
|
||||
|
||||
const checkedRowKeys = reactive<number[]>([]);
|
||||
const mobilePagination = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
async function handleDelete(groupName: string) {
|
||||
const { error } = await fetchDeleteDictionary(groupName);
|
||||
if (error) return;
|
||||
onDeleted();
|
||||
}
|
||||
|
||||
function body(): Api.DictionaryConfig.ExportDictionaryConfig {
|
||||
return {
|
||||
groupName: searchParams.groupName,
|
||||
groupStatus: searchParams.groupStatus,
|
||||
groupIds: checkedRowKeys.value
|
||||
};
|
||||
}
|
||||
|
||||
function handleExport() {
|
||||
downloadFetch('/group/export', body(), $t('page.groupConfig.title'));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
||||
<!-- 查询组件 -->
|
||||
<CategorySearch
|
||||
@update="getData"
|
||||
/>
|
||||
<DeleteAlert />
|
||||
<NCard
|
||||
:title="$t('page.category.title')"
|
||||
:bordered="false" size="small"
|
||||
header-class="view-card-header"
|
||||
class="sm:flex-1-hidden card-wrapper">
|
||||
<!-- 表头选项 -->
|
||||
<template #header-extra>
|
||||
<CategoryHeaderOperation
|
||||
:disabled-delete="false"
|
||||
:loading="loading"
|
||||
:show-delete="false"
|
||||
@add="headAdd"
|
||||
@refresh="refresh"
|
||||
/>
|
||||
</template>
|
||||
<!-- 表格内容 -->
|
||||
<!-- <n-data-table
|
||||
virtual-scroll
|
||||
:max-height="490"
|
||||
:columns="columns2()"
|
||||
:data="tableData"
|
||||
:row-key="rowKey"
|
||||
default-expand-all
|
||||
/> -->
|
||||
<NDataTable
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
:columns="columns2()"
|
||||
:data="tableData"
|
||||
:flex-height="!appStore.isMobile"
|
||||
:scroll-x="962"
|
||||
:loading="loading"
|
||||
remote
|
||||
:row-key="row => row.id"
|
||||
:pagination="mobilePagination"
|
||||
class="sm:h-full"
|
||||
/>
|
||||
<!-- 侧边栏 -->
|
||||
<CategoryOperateDrawer
|
||||
v-model:visible="drawerVisible"
|
||||
:operate-type="operateType"
|
||||
:row-data="editingData"
|
||||
@submitted="getData"
|
||||
/>
|
||||
</NCard>
|
||||
</div>
|
||||
|
||||
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
||||
<DictionarySearch v-model:model="searchParams" @reset="resetSearchParams" @search="getData" />
|
||||
<DeleteAlert />
|
||||
<NCard
|
||||
:title="$t('page.groupConfig.title')"
|
||||
:bordered="false"
|
||||
size="small"
|
||||
header-class="view-card-header"
|
||||
class="sm:flex-1-hidden card-wrapper"
|
||||
>
|
||||
<template #header-extra>
|
||||
<TableHeaderOperation
|
||||
v-model:columns="columnChecks"
|
||||
:loading="loading"
|
||||
:show-add="hasAuth('R_ADMIN')"
|
||||
:show-delete="false"
|
||||
@add="handleAdd"
|
||||
@refresh="getData"
|
||||
>
|
||||
<template #addAfter>
|
||||
<FileUpload v-if="hasAuth('R_ADMIN')" action="/group/import" accept="application/json" @refresh="getData" />
|
||||
<NPopconfirm @positive-click="handleExport">
|
||||
<template #trigger>
|
||||
<NButton size="small" ghost type="primary" :disabled="checkedRowKeys.length === 0 && hasAuth('R_USER')">
|
||||
<template #icon>
|
||||
<IconPajamasExport class="text-icon" />
|
||||
</template>
|
||||
{{ $t('common.export') }}
|
||||
</NButton>
|
||||
</template>
|
||||
<template #default>
|
||||
{{
|
||||
checkedRowKeys.length === 0
|
||||
? $t('common.exportAll')
|
||||
: $t('common.exportPar', { num: checkedRowKeys.length })
|
||||
}}
|
||||
</template>
|
||||
</NPopconfirm>
|
||||
</template>
|
||||
</TableHeaderOperation>
|
||||
</template>
|
||||
<NDataTable
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
:flex-height="!appStore.isMobile"
|
||||
:scroll-x="962"
|
||||
:loading="loading"
|
||||
remote
|
||||
:row-key="row => row.id"
|
||||
:pagination="mobilePagination"
|
||||
class="sm:h-full"
|
||||
/>
|
||||
<DictionaryOperateDrawer
|
||||
v-model:visible="drawerVisible"
|
||||
:operate-type="operateType"
|
||||
:row-data="editingData"
|
||||
@submitted="getData"
|
||||
/>
|
||||
<DictionaryDetailDrawer v-model:visible="detailVisible" :row-data="detailData" />
|
||||
</NCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
51
src/views/dictionary/modules/dictionary-detail-drawer.vue
Normal file
51
src/views/dictionary/modules/dictionary-detail-drawer.vue
Normal file
@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import { groupConfigIdModeRecord, groupConfigStatusRecord, yesOrNoRecord } from '@/constants/business';
|
||||
import { $t } from '@/locales';
|
||||
import { tagColor } from '@/utils/common';
|
||||
|
||||
defineOptions({
|
||||
name: 'GroupDetailDrawer'
|
||||
});
|
||||
|
||||
interface Props {
|
||||
/** row data */
|
||||
rowData?: Api.GroupConfig.GroupConfig | null;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
|
||||
const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<OperateDrawer v-model="visible" :title="$t('page.groupConfig.detail')">
|
||||
<NDescriptions label-placement="top" bordered :column="2">
|
||||
<NDescriptionsItem :label="$t('page.groupConfig.groupName')" :span="2">
|
||||
{{ rowData?.groupName }}
|
||||
</NDescriptionsItem>
|
||||
|
||||
<NDescriptionsItem :label="$t('page.groupConfig.token')" :span="2">{{ rowData?.token }}</NDescriptionsItem>
|
||||
<NDescriptionsItem :label="$t('page.groupConfig.groupStatus')" :span="1">
|
||||
<NTag :type="tagColor(rowData?.groupStatus!)">{{ $t(groupConfigStatusRecord[rowData?.groupStatus!]) }}</NTag>
|
||||
</NDescriptionsItem>
|
||||
<NDescriptionsItem :label="$t('page.groupConfig.idGeneratorMode')" :span="1">
|
||||
<NTag :type="tagColor(rowData?.idGeneratorMode!)">
|
||||
{{ $t(groupConfigIdModeRecord[rowData?.idGeneratorMode!]) }}
|
||||
</NTag>
|
||||
</NDescriptionsItem>
|
||||
<NDescriptionsItem :label="$t('page.groupConfig.groupPartition')" :span="1">
|
||||
{{ rowData?.groupPartition }}
|
||||
</NDescriptionsItem>
|
||||
<NDescriptionsItem :label="$t('page.groupConfig.initScene')" :span="1">
|
||||
<NTag :type="tagColor(rowData?.initScene!)">{{ $t(yesOrNoRecord[rowData?.initScene!]) }}</NTag>
|
||||
</NDescriptionsItem>
|
||||
<NDescriptionsItem :label="$t('page.groupConfig.description')" :span="2">
|
||||
{{ rowData?.description }}
|
||||
</NDescriptionsItem>
|
||||
</NDescriptions>
|
||||
</OperateDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
96
src/views/dictionary/modules/dictionary-search.vue
Normal file
96
src/views/dictionary/modules/dictionary-search.vue
Normal file
@ -0,0 +1,96 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { NButton, NCard, NForm, NFormItemGi, NGrid, NInput, NSelect, NSpace } from 'naive-ui';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { translateOptions } from '@/utils/common';
|
||||
import { categoryTypeOptions } from '@/constants/business';
|
||||
const appStore = useAppStore();
|
||||
|
||||
const model = ref({
|
||||
categoryName: '',
|
||||
categoryStatus: null
|
||||
});
|
||||
|
||||
const btnSpan = computed(() => (appStore.isMobile ? '7' : '7'));
|
||||
|
||||
interface Emits {
|
||||
(e: 'update'): void;
|
||||
}
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
function search() {
|
||||
console.log('搜索:', model.value.categoryName);
|
||||
// 在这里添加搜索逻辑
|
||||
emit('update');
|
||||
}
|
||||
|
||||
function reset() {
|
||||
model.value.categoryName = '';
|
||||
model.value.categoryStatus = null;
|
||||
// 在这里添加重置逻辑
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NCard :bordered="false" size="small" class="card-wrapper">
|
||||
<NForm :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
|
||||
<NGrid responsive="screen" cols="36" item-responsive :y-gap="12">
|
||||
<!-- 搜索 -->
|
||||
<NFormItemGi span="m:7" :label="$t('page.dictionary.form.dictionaryName')" path="categoryName" class="pr-0px">
|
||||
<NInput
|
||||
v-model:value="model.categoryName"
|
||||
:placeholder="$t('page.dictionary.form.dictionaryName')"
|
||||
clearable
|
||||
/>
|
||||
</NFormItemGi>
|
||||
<!-- 搜索 -->
|
||||
<NFormItemGi span="m:7" :label="$t('page.dictionary.form.dictionaryType')" path="categoryName" class="pr-0px">
|
||||
<NInput
|
||||
v-model:value="model.categoryName"
|
||||
:placeholder="$t('page.dictionary.form.dictionaryType')"
|
||||
clearable
|
||||
/>
|
||||
</NFormItemGi>
|
||||
<!-- 下拉 -->
|
||||
<NFormItemGi
|
||||
span="m:7"
|
||||
:label="$t('page.dictionary.form.dictionaryStatus')"
|
||||
path="categoryStatus"
|
||||
class="pr-0px"
|
||||
>
|
||||
<NSelect
|
||||
v-model:value="model.categoryStatus"
|
||||
:placeholder="$t('page.dictionary.form.dictionaryStatus')"
|
||||
:options="translateOptions(categoryTypeOptions)"
|
||||
clearable
|
||||
/>
|
||||
</NFormItemGi>
|
||||
<!-- 搜索 -->
|
||||
<NFormItemGi span="m:7" :label="$t('page.dictionary.form.createTime')" path="categoryName" class="pr-0px">
|
||||
<NInput v-model:value="model.categoryName" :placeholder="$t('page.dictionary.form.createTime')" clearable />
|
||||
</NFormItemGi>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<NFormItemGi :y-gap="8" :span="btnSpan" class="pr-0px lg:p-t-0 md:p-t-16px">
|
||||
<NSpace class="min-w-100px 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>
|
||||
</NCard>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
@ -1,72 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { $t } from '@/locales';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { NCard, NForm, NFormItemGi, NGrid, NInput, NSelect, NButton, NSpace } from 'naive-ui';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { translateOptions } from '@/utils/common';
|
||||
import { categoryTypeOptions } from '@/constants/business';
|
||||
const appStore = useAppStore();
|
||||
|
||||
const model = ref({
|
||||
categoryName: '',
|
||||
categoryStatus: null,
|
||||
});
|
||||
|
||||
const btnSpan = computed(() => appStore.isMobile ? '24' : '12');
|
||||
|
||||
interface Emits {
|
||||
(e: 'update'): void;
|
||||
}
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
function search() {
|
||||
console.log('搜索:', model.value.categoryName);
|
||||
// 在这里添加搜索逻辑
|
||||
emit('update');
|
||||
}
|
||||
|
||||
function reset() {
|
||||
model.value.categoryName = '';
|
||||
model.value.categoryStatus = null;
|
||||
// 在这里添加重置逻辑
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NCard :bordered="false" size="small" class="card-wrapper">
|
||||
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
|
||||
<NGrid responsive="screen" cols="24" item-responsive :y-gap="12">
|
||||
<!-- 搜索 -->
|
||||
<NFormItemGi span="24 s:12 m:6" :label="$t('page.category.form.categoryName')" path="categoryName" class="pr-24px">
|
||||
<NInput v-model:value="model.categoryName" :placeholder="$t('page.category.form.categoryName')" clearable />
|
||||
</NFormItemGi>
|
||||
<!-- 下拉 -->
|
||||
<NFormItemGi span="24 s:12 m:6" :label="$t('page.category.form.categoryType')" path="categoryStatus" class="pr-24px">
|
||||
<NSelect v-model:value="model.categoryStatus" :placeholder="$t('page.category.form.categoryType')"
|
||||
:options="translateOptions(categoryTypeOptions)" clearable />
|
||||
</NFormItemGi>
|
||||
<!-- 按钮 -->
|
||||
<NFormItemGi :y-gap="8" :span="btnSpan" class="pr-24px lg:p-t-0 md:p-t-16px">
|
||||
<NSpace class="min-w-172px 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>
|
||||
</NCard>
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
@ -6,7 +6,7 @@ import { fetchDeleteGroup, fetchGetGroupConfigList, fetchUpdateGroupStatus } fro
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import { groupConfigIdModeRecord, groupConfigTypeRecord, yesOrNoRecord } from '@/constants/business';
|
||||
import { groupConfigIdModeRecord, yesOrNoRecord } from '@/constants/business';
|
||||
import { tagColor } from '@/utils/common';
|
||||
import StatusSwitch from '@/components/common/status-switch.vue';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
|
Loading…
Reference in New Issue
Block a user