feat: 字典配置前端代码.

This commit is contained in:
lijiahang
2023-10-26 19:25:08 +08:00
parent 29e3bde5b6
commit 5d43a9ce88
11 changed files with 36 additions and 88 deletions

View File

@@ -38,7 +38,6 @@ export interface DictValueQueryRequest extends Pagination {
id?: number;
keyId?: number;
keyName?: string;
name?: string;
value?: string;
label?: string;
extra?: string;
@@ -53,7 +52,6 @@ export interface DictValueQueryResponse extends TableData {
keyId?: number;
keyName?: string;
keyDescription?: string;
name?: string;
value?: string;
label?: string;
extra?: string;
@@ -65,9 +63,9 @@ export interface DictValueQueryResponse extends TableData {
}
/**
* 字典配置值枚举查询响应
* 字典配置值选项查询响应
*/
export interface DictValueEnumQueryResponse extends Options {
export interface DictValueOptionsQueryResponse extends Options {
[key: string]: unknown;
}
@@ -96,15 +94,13 @@ export function rollbackDictValue(request: DictValueRollbackRequest) {
/**
* 查询字典配置值
*/
export function getDictValue(keyName: string) {
return axios.get<Array<DictValueQueryResponse>>('/infra/dict-value/list', { params: { keyName } });
}
/**
* 查询字典配置值枚举
*/
export function getDictValueEnum(keyName: string) {
return axios.get<Record<string, DictValueEnumQueryResponse>>('/infra/dict-value/enum', { params: { keyName } });
export function getDictValueList(keys: string[]) {
return axios.get<Record<string, Array<DictValueOptionsQueryResponse>>>('/infra/dict-value/list', {
params: { keys },
paramsSerializer: params => {
return qs.stringify(params, { arrayFormat: 'comma' });
}
});
}
/**

View File

@@ -84,7 +84,7 @@ export const createDefaultOptions = (): Options => {
minimap: {
enabled: false,
},
fontSize: 16,
fontSize: 14,
scrollBeyondLastLine: false,
overviewRulerBorder: false,
colorDecorators: true,

View File

@@ -92,11 +92,10 @@
</template>
<!-- 地址 -->
<template #address="{ record }">
<a-tooltip content="点击复制">
<span class="host-address" @click="copy(record.address)">
<icon-copy /> {{ record.address }}
</span>
</a-tooltip>
<span title="复制">
<icon-copy class="copy-left" @click="copy(record.address)" />
</span>
<span class="span-blue">{{ record.address }}</span>
</template>
<!-- 标签 -->
<template #tags="{ record }">
@@ -252,11 +251,6 @@
<style lang="less" scoped>
.host-address {
cursor: pointer;
color: rgb(var(--arcoblue-6))
}
.row-handle-wrapper {
display: flex;
align-items: center;

View File

@@ -55,9 +55,8 @@
:bordered="false">
<!-- 配置项 -->
<template #keyName="{ record }">
<span class="pointer" @click="copy(record.keyName)">
<icon-copy /> {{ record.keyName }}
</span>
<icon-copy class="copy-left" title="复制" @click="copy(record.keyName)" />
<span>{{ record.keyName }}</span>
</template>
<!-- 配置值类型 -->
<template #valueType="{ record }">

View File

@@ -27,7 +27,7 @@
import { ref } from 'vue';
import useLoading from '@/hooks/loading';
import useVisible from '@/hooks/visible';
import { getDictValueEnum } from '@/api/system/dict-value';
import { getDictValueList } from '@/api/system/dict-value';
const { visible, setVisible } = useVisible();
const { loading, setLoading } = useLoading();
@@ -48,8 +48,8 @@
try {
setLoading(true);
// 查看
const { data } = await getDictValueEnum(keyName);
value.value = JSON.stringify(data, undefined, 4);
const { data } = await getDictValueList([keyName]);
value.value = JSON.stringify(data[keyName], undefined, 4);
} finally {
setLoading(false);
}

View File

@@ -17,7 +17,7 @@ export const definedExtraKeys = [{
/**
* 内置字段
*/
export const innerKeys = ['name', 'value', 'label'];
export const innerKeys = ['value', 'label'];
/**
* 额外参数类型

View File

@@ -15,12 +15,6 @@ const columns = [
align: 'left',
ellipsis: true,
tooltip: true,
}, {
title: '类型',
dataIndex: 'valueType',
slotName: 'valueType',
align: 'left',
width: 150
}, {
title: '配置描述',
dataIndex: 'description',
@@ -28,6 +22,12 @@ const columns = [
align: 'left',
ellipsis: true,
tooltip: true,
}, {
title: '类型',
dataIndex: 'valueType',
slotName: 'valueType',
align: 'left',
width: 150
}, {
title: '额外配置',
dataIndex: 'extraSchema',

View File

@@ -24,15 +24,6 @@
<a-form-item field="keyId" label="配置项">
<dict-key-selector v-model="formModel.keyId" @change="changeKey" />
</a-form-item>
<!-- 配置名称 -->
<a-form-item field="name" label="配置名称">
<a-input v-model="formModel.name" placeholder="请输入配置名称" allow-clear />
<span class="item-extra-block pointer"
title="同步到值"
@click="() => formModel.value = formModel.name">
<icon-caret-down style="font-size: 16px" />
</span>
</a-form-item>
<!-- 配置值 -->
<a-form-item field="value" label="配置值">
<a-input v-model="formModel.value" placeholder="请输入配置值" allow-clear />
@@ -117,7 +108,6 @@
return {
id: undefined,
keyId: undefined,
name: undefined,
value: undefined,
label: undefined,
extra: undefined,

View File

@@ -12,10 +12,6 @@
@change="changeKey"
allow-create />
</a-form-item>
<!-- 配置名称 -->
<a-form-item field="name" label="配置名称" label-col-flex="50px">
<a-input v-model="formModel.name" placeholder="请输入配置名称" allow-clear />
</a-form-item>
<!-- 配置值 -->
<a-form-item field="value" label="配置值" label-col-flex="50px">
<a-input v-model="formModel.value" placeholder="请输入配置值" allow-clear />
@@ -80,23 +76,12 @@
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
@page-size-change="(size) => fetchTableData(1, size)"
:bordered="false">
<!-- 名称 -->
<template #name="{ record }">
<span class="pointer" @click="copy(record.name)">
<icon-copy class="copy-left" />
<a-tooltip :content="record.name">
<span>{{ record.name }}</span>
</a-tooltip>
</span>
</template>
<!-- 值 -->
<template #value="{ record }">
<span class="pointer" @click="copy(record.value)">
<icon-copy class="copy-left" />
<a-tooltip :content="record.value">
<span>{{ record.value }}</span>
</a-tooltip>
</span>
<icon-copy class="copy-left" title="复制" @click="copy(record.value)" />
<a-tooltip :content="record.value">
<span>{{ record.value }}</span>
</a-tooltip>
</template>
<!-- 操作 -->
<template #handle="{ record }">
@@ -163,7 +148,6 @@
id: undefined,
keyId: undefined,
keyName: undefined,
name: undefined,
value: undefined,
label: undefined,
extra: undefined,

View File

@@ -13,14 +13,6 @@ export const keyName = [{
message: '配置项长度不能大于32位'
}] as FieldRule[];
export const name = [{
required: true,
message: '请输入配置名称'
}, {
maxLength: 32,
message: '配置名称长度不能大于32位'
}] as FieldRule[];
export const value = [{
required: true,
message: '请输入配置值'
@@ -50,7 +42,6 @@ export const sort = [{
export default {
keyId,
keyName,
name,
value,
label,
extra,

View File

@@ -19,18 +19,6 @@ const columns = [
render: ({ record }) => {
return `${record.keyName} - ${record.keyDescription}`;
},
}, {
title: '配置名称',
dataIndex: 'name',
slotName: 'name',
align: 'left',
ellipsis: true,
}, {
title: '配置值',
dataIndex: 'value',
slotName: 'value',
align: 'left',
ellipsis: true,
}, {
title: '配置描述',
dataIndex: 'label',
@@ -38,6 +26,12 @@ const columns = [
align: 'left',
ellipsis: true,
tooltip: true,
}, {
title: '配置值',
dataIndex: 'value',
slotName: 'value',
align: 'left',
ellipsis: true,
}, {
title: '额外参数',
dataIndex: 'extra',