faddd
This commit is contained in:
@@ -1,13 +1,34 @@
|
|||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { QueryWhitelistApi } from '#/api/product-manage';
|
import type { FeatureApi } from '#/api/product-manage/feature';
|
||||||
|
|
||||||
export const actionOptions = [
|
export const actionOptions = [
|
||||||
{ label: '创建规则', value: 'create' },
|
{ label: '创建规则', value: 'create' },
|
||||||
{ label: '追加接口', value: 'append' },
|
{ label: '追加接口', value: 'append' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function useConfigFormSchema(): VbenFormSchema[] {
|
export type FeatureOption = { label: string; value: string };
|
||||||
|
|
||||||
|
/** 将模块列表转为下拉选项 */
|
||||||
|
export function buildFeatureOptions(
|
||||||
|
features: FeatureApi.FeatureItem[],
|
||||||
|
): FeatureOption[] {
|
||||||
|
return features.map((item) => ({
|
||||||
|
label: `${item.api_id}(${item.name})`,
|
||||||
|
value: item.api_id,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 司法类模块:名称含「司法」的 feature(与模块列表配置保持一致) */
|
||||||
|
export function getJudicialApiCodes(features: FeatureApi.FeatureItem[]): string[] {
|
||||||
|
return features
|
||||||
|
.filter((item) => item.name.includes('司法'))
|
||||||
|
.map((item) => item.api_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useConfigFormSchema(
|
||||||
|
featureOptions: FeatureOption[] = [],
|
||||||
|
): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
@@ -33,12 +54,17 @@ export function useConfigFormSchema(): VbenFormSchema[] {
|
|||||||
component: 'Select',
|
component: 'Select',
|
||||||
fieldName: 'api_codes',
|
fieldName: 'api_codes',
|
||||||
label: '产品编码',
|
label: '产品编码',
|
||||||
|
defaultValue: [],
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
|
help: '从模块列表多选;可点击下方快捷按钮一键选中司法类模块',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
mode: 'tags',
|
mode: 'multiple',
|
||||||
placeholder: '输入产品编码后回车添加',
|
placeholder: '请选择产品编码',
|
||||||
tokenSeparators: [',', ' '],
|
options: featureOptions,
|
||||||
open: false,
|
optionFilterProp: 'label',
|
||||||
|
showSearch: true,
|
||||||
|
allowClear: true,
|
||||||
|
maxTagCount: 'responsive',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { QueryWhitelistApi } from '#/api/product-manage';
|
import type { QueryWhitelistApi } from '#/api/product-manage';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
|
|
||||||
@@ -13,13 +13,22 @@ import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|||||||
import {
|
import {
|
||||||
appendQueryWhitelist,
|
appendQueryWhitelist,
|
||||||
createQueryWhitelist,
|
createQueryWhitelist,
|
||||||
|
getFeatureList,
|
||||||
getQueryWhitelistOpLogList,
|
getQueryWhitelistOpLogList,
|
||||||
} from '#/api/product-manage';
|
} from '#/api/product-manage';
|
||||||
|
|
||||||
import { useConfigFormSchema, useLogColumns, useLogGridFormSchema } from './data';
|
import {
|
||||||
|
buildFeatureOptions,
|
||||||
|
getJudicialApiCodes,
|
||||||
|
useConfigFormSchema,
|
||||||
|
useLogColumns,
|
||||||
|
useLogGridFormSchema,
|
||||||
|
} from './data';
|
||||||
|
|
||||||
const lastResult = ref<QueryWhitelistApi.OpResponse | null>(null);
|
const lastResult = ref<QueryWhitelistApi.OpResponse | null>(null);
|
||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
|
const featureLoading = ref(false);
|
||||||
|
const judicialApiCodes = ref<string[]>([]);
|
||||||
|
|
||||||
const [ConfigForm, configFormApi] = useVbenForm({
|
const [ConfigForm, configFormApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
@@ -35,6 +44,57 @@ const [ConfigForm, configFormApi] = useVbenForm({
|
|||||||
|
|
||||||
const resultSuccess = computed(() => lastResult.value?.tianyuan_code === 0);
|
const resultSuccess = computed(() => lastResult.value?.tianyuan_code === 0);
|
||||||
|
|
||||||
|
async function loadFeatureOptions() {
|
||||||
|
featureLoading.value = true;
|
||||||
|
try {
|
||||||
|
const res = await getFeatureList({ page: 1, pageSize: 500 });
|
||||||
|
const features = res.items || [];
|
||||||
|
const options = buildFeatureOptions(features);
|
||||||
|
judicialApiCodes.value = getJudicialApiCodes(features);
|
||||||
|
|
||||||
|
await configFormApi.updateSchema([
|
||||||
|
{
|
||||||
|
fieldName: 'api_codes',
|
||||||
|
componentProps: {
|
||||||
|
mode: 'multiple',
|
||||||
|
placeholder: '请选择产品编码',
|
||||||
|
options,
|
||||||
|
optionFilterProp: 'label',
|
||||||
|
showSearch: true,
|
||||||
|
allowClear: true,
|
||||||
|
maxTagCount: 'responsive',
|
||||||
|
loading: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
} catch {
|
||||||
|
message.error('加载模块列表失败,请刷新页面重试');
|
||||||
|
} finally {
|
||||||
|
featureLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function selectJudicialApiCodes() {
|
||||||
|
if (judicialApiCodes.value.length === 0) {
|
||||||
|
message.warning('当前模块列表中未找到司法类模块');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const values = await configFormApi.getValues();
|
||||||
|
const merged = [
|
||||||
|
...new Set([...(values.api_codes || []), ...judicialApiCodes.value]),
|
||||||
|
];
|
||||||
|
await configFormApi.setValues({ api_codes: merged });
|
||||||
|
message.success(`已选中 ${judicialApiCodes.value.length} 个司法类模块`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function clearApiCodes() {
|
||||||
|
await configFormApi.setValues({ api_codes: [] });
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadFeatureOptions();
|
||||||
|
});
|
||||||
|
|
||||||
async function submitAction(action: 'create' | 'append') {
|
async function submitAction(action: 'create' | 'append') {
|
||||||
const { valid } = await configFormApi.validate();
|
const { valid } = await configFormApi.validate();
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
@@ -44,7 +104,7 @@ async function submitAction(action: 'create' | 'append') {
|
|||||||
(code: string) => code && String(code).trim(),
|
(code: string) => code && String(code).trim(),
|
||||||
);
|
);
|
||||||
if (apiCodes.length === 0) {
|
if (apiCodes.length === 0) {
|
||||||
message.warning('请至少添加一个产品编码');
|
message.warning('请至少选择一个产品编码');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +174,19 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
<Col :span="14">
|
<Col :span="14">
|
||||||
<Card title="配置规则">
|
<Card title="配置规则">
|
||||||
<ConfigForm />
|
<ConfigForm />
|
||||||
|
<div class="mt-2 flex flex-wrap gap-2">
|
||||||
|
<Button
|
||||||
|
:loading="featureLoading"
|
||||||
|
size="small"
|
||||||
|
@click="selectJudicialApiCodes"
|
||||||
|
>
|
||||||
|
一键选中司法
|
||||||
|
</Button>
|
||||||
|
<Button size="small" @click="clearApiCodes">清空编码</Button>
|
||||||
|
<span v-if="judicialApiCodes.length" class="text-xs text-gray-400">
|
||||||
|
司法类:{{ judicialApiCodes.join('、') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="mt-4 flex gap-3">
|
<div class="mt-4 flex gap-3">
|
||||||
<Button
|
<Button
|
||||||
:loading="submitting"
|
:loading="submitting"
|
||||||
|
|||||||
Reference in New Issue
Block a user