From 347dbd615c0d94b8d74edef44db5543bc6351f27 Mon Sep 17 00:00:00 2001 From: Mrxs <18278715334@163.com> Date: Fri, 19 Jun 2026 12:40:56 +0800 Subject: [PATCH] faddd --- .../product-manage/query-whitelist/data.ts | 38 +++++++-- .../product-manage/query-whitelist/list.vue | 79 ++++++++++++++++++- 2 files changed, 108 insertions(+), 9 deletions(-) diff --git a/apps/web-antd/src/views/product-manage/query-whitelist/data.ts b/apps/web-antd/src/views/product-manage/query-whitelist/data.ts index a369c8e..a6a8dc0 100644 --- a/apps/web-antd/src/views/product-manage/query-whitelist/data.ts +++ b/apps/web-antd/src/views/product-manage/query-whitelist/data.ts @@ -1,13 +1,34 @@ import type { VbenFormSchema } from '#/adapter/form'; 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 = [ { label: '创建规则', value: 'create' }, { 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 [ { component: 'Input', @@ -33,12 +54,17 @@ export function useConfigFormSchema(): VbenFormSchema[] { component: 'Select', fieldName: 'api_codes', label: '产品编码', + defaultValue: [], rules: 'required', + help: '从模块列表多选;可点击下方快捷按钮一键选中司法类模块', componentProps: { - mode: 'tags', - placeholder: '输入产品编码后回车添加', - tokenSeparators: [',', ' '], - open: false, + mode: 'multiple', + placeholder: '请选择产品编码', + options: featureOptions, + optionFilterProp: 'label', + showSearch: true, + allowClear: true, + maxTagCount: 'responsive', }, }, { diff --git a/apps/web-antd/src/views/product-manage/query-whitelist/list.vue b/apps/web-antd/src/views/product-manage/query-whitelist/list.vue index 6873523..0a48960 100644 --- a/apps/web-antd/src/views/product-manage/query-whitelist/list.vue +++ b/apps/web-antd/src/views/product-manage/query-whitelist/list.vue @@ -2,7 +2,7 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { QueryWhitelistApi } from '#/api/product-manage'; -import { computed, ref } from 'vue'; +import { computed, onMounted, ref } from 'vue'; import { Page } from '@vben/common-ui'; @@ -13,13 +13,22 @@ import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { appendQueryWhitelist, createQueryWhitelist, + getFeatureList, getQueryWhitelistOpLogList, } from '#/api/product-manage'; -import { useConfigFormSchema, useLogColumns, useLogGridFormSchema } from './data'; +import { + buildFeatureOptions, + getJudicialApiCodes, + useConfigFormSchema, + useLogColumns, + useLogGridFormSchema, +} from './data'; const lastResult = ref(null); const submitting = ref(false); +const featureLoading = ref(false); +const judicialApiCodes = ref([]); const [ConfigForm, configFormApi] = useVbenForm({ commonConfig: { @@ -35,6 +44,57 @@ const [ConfigForm, configFormApi] = useVbenForm({ 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') { const { valid } = await configFormApi.validate(); if (!valid) return; @@ -44,7 +104,7 @@ async function submitAction(action: 'create' | 'append') { (code: string) => code && String(code).trim(), ); if (apiCodes.length === 0) { - message.warning('请至少添加一个产品编码'); + message.warning('请至少选择一个产品编码'); return; } @@ -114,6 +174,19 @@ const [Grid, gridApi] = useVbenVxeGrid({ +
+ + + + 司法类:{{ judicialApiCodes.join('、') }} + +