diff --git a/apps/web-antd/src/api/product-manage/index.ts b/apps/web-antd/src/api/product-manage/index.ts index 3b71bfa..17798bf 100644 --- a/apps/web-antd/src/api/product-manage/index.ts +++ b/apps/web-antd/src/api/product-manage/index.ts @@ -1,3 +1,3 @@ export * from './feature'; export * from './product'; -export * from './whitelist'; +export * from './query-whitelist'; diff --git a/apps/web-antd/src/api/product-manage/query-whitelist.ts b/apps/web-antd/src/api/product-manage/query-whitelist.ts new file mode 100644 index 0000000..2d0cb6d --- /dev/null +++ b/apps/web-antd/src/api/product-manage/query-whitelist.ts @@ -0,0 +1,89 @@ +import type { Recordable } from '@vben/types'; + +import { requestClient } from '#/api/request'; + +export namespace QueryWhitelistApi { + export interface Entry { + id: string; + name: string; + id_card_masked: string; + api_codes: string[]; + status: string; + remark: string; + created_at: string; + updated_at: string; + } + + export interface OperationResponse { + code: number; + message: string; + transaction_id: string; + entry?: Entry; + } + + export interface CreateRequest { + name?: string; + id_card: string; + api_codes: string[]; + remark?: string; + } + + export interface AppendRequest { + name?: string; + id_card: string; + api_codes: string[]; + remark?: string; + } + + export interface OpLogItem { + id: string; + admin_user_id: string; + admin_username: string; + action: string; + action_text: string; + name: string; + id_card: string; + id_card_masked: string; + api_codes: string[]; + remark: string; + tianyuan_code: number; + tianyuan_message: string; + transaction_id: string; + entry_id: string; + entry_status: string; + entry_api_codes: string[]; + create_time: string; + } + + export interface OpLogList { + total: number; + items: OpLogItem[]; + } +} + +async function createQueryWhitelist(data: QueryWhitelistApi.CreateRequest) { + return requestClient.post( + '/query-whitelist/create', + data, + ); +} + +async function appendQueryWhitelist(data: QueryWhitelistApi.AppendRequest) { + return requestClient.post( + '/query-whitelist/append', + data, + ); +} + +async function getQueryWhitelistOpLogList(params: Recordable) { + return requestClient.get( + '/query-whitelist/op-log/list', + { params }, + ); +} + +export { + appendQueryWhitelist, + createQueryWhitelist, + getQueryWhitelistOpLogList, +}; diff --git a/apps/web-antd/src/api/product-manage/whitelist.ts b/apps/web-antd/src/api/product-manage/whitelist.ts deleted file mode 100644 index 4ae8ad2..0000000 --- a/apps/web-antd/src/api/product-manage/whitelist.ts +++ /dev/null @@ -1,101 +0,0 @@ -import type { Recordable } from '@vben/types'; - -import { requestClient } from '#/api/request'; - -export namespace WhitelistApi { - export interface WhitelistItem { - id: string; - id_card: string; - feature_id: string; - feature_api_id: string; - feature_name: string; - user_id: string; - amount: number; - status: number; - status_text: string; - create_time: string; - update_time: string; - } - - export interface WhitelistList { - total: number; - items: WhitelistItem[]; - } - - export interface CreateWhitelistRequest { - id_card: string; - feature_id: string; - amount?: number; - status?: number; - } - - export interface BatchCreateWhitelistRequest { - id_card: string; - feature_ids: string[]; - amount?: number; - status?: number; - } - - export interface BatchCreateWhitelistResultItem { - feature_id: string; - feature_api_id: string; - feature_name: string; - action: string; - message?: string; - } - - export interface BatchCreateWhitelistResponse { - success_count: number; - skip_count: number; - fail_count: number; - items: BatchCreateWhitelistResultItem[]; - } - - export interface UpdateWhitelistRequest { - status?: number; - amount?: number; - } -} - -async function getWhitelistList(params: Recordable) { - return requestClient.get('/whitelist/list', { - params, - }); -} - -async function createWhitelist(data: WhitelistApi.CreateWhitelistRequest) { - return requestClient.post<{ id: string }>('/whitelist/create', data); -} - -async function batchCreateWhitelist( - data: WhitelistApi.BatchCreateWhitelistRequest, -) { - return requestClient.post( - '/whitelist/batch-create', - data, - ); -} - -async function updateWhitelist( - id: string, - data: WhitelistApi.UpdateWhitelistRequest, -) { - return requestClient.put<{ success: boolean }>( - `/whitelist/update/${id}`, - data, - ); -} - -async function deleteWhitelist(id: string) { - return requestClient.delete<{ success: boolean }>( - `/whitelist/delete/${id}`, - ); -} - -export { - batchCreateWhitelist, - createWhitelist, - deleteWhitelist, - getWhitelistList, - updateWhitelist, -}; 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 new file mode 100644 index 0000000..4144329 --- /dev/null +++ b/apps/web-antd/src/views/product-manage/query-whitelist/data.ts @@ -0,0 +1,68 @@ +import type { VbenFormSchema } from '#/adapter/form'; + +/** 快捷勾选预设:按模块编号 api_id 匹配 */ +export const QUERY_WHITELIST_QUICK_PRESETS = [ + { + label: '司法涉诉 + 违约失信', + apiIds: ['FLXG7E8F', 'JRZQ8A2D'], + }, + { + label: '司法涉诉', + apiIds: ['FLXG7E8F'], + }, + { + label: '违约失信', + apiIds: ['JRZQ8A2D'], + }, +] as const; + +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id_card', + label: '身份证号', + rules: 'required', + componentProps: { + placeholder: '请输入18位中国大陆身份证号', + maxlength: 18, + }, + }, + { + component: 'Input', + fieldName: 'name', + label: '姓名', + defaultValue: '*', + help: '填 * 表示只按身份证匹配,不校验姓名', + componentProps: { + placeholder: '默认 *,仅按身份证匹配', + }, + }, + { + component: 'Select', + fieldName: 'api_codes', + label: '产品编码', + rules: 'required', + formItemClass: 'items-start', + componentProps: { + mode: 'multiple', + showSearch: true, + optionFilterProp: 'label', + allowClear: true, + placeholder: '请选择要屏蔽的产品编码,支持多选', + options: [], + class: 'w-full', + }, + }, + { + component: 'Input', + fieldName: 'remark', + label: '备注', + componentProps: { + placeholder: '可选,最长500字符', + maxlength: 500, + showCount: true, + }, + }, + ]; +} 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 new file mode 100644 index 0000000..dedd628 --- /dev/null +++ b/apps/web-antd/src/views/product-manage/query-whitelist/list.vue @@ -0,0 +1,296 @@ + + + diff --git a/apps/web-antd/src/views/product-manage/query-whitelist/op-log-data.ts b/apps/web-antd/src/views/product-manage/query-whitelist/op-log-data.ts new file mode 100644 index 0000000..e076199 --- /dev/null +++ b/apps/web-antd/src/views/product-manage/query-whitelist/op-log-data.ts @@ -0,0 +1,109 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { QueryWhitelistApi } from '#/api/product-manage'; + +export function useOpLogGridFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id_card', + label: '身份证号', + }, + { + component: 'Select', + fieldName: 'action', + label: '操作类型', + componentProps: { + allowClear: true, + options: [ + { label: '创建规则', value: 'create' }, + { label: '追加接口', value: 'append' }, + ], + }, + }, + { + component: 'Select', + fieldName: 'tianyuan_code', + label: '业务结果', + componentProps: { + allowClear: true, + options: [ + { label: '成功 (0)', value: 0 }, + { label: '规则已存在 (1013)', value: 1013 }, + { label: '规则不存在 (1014)', value: 1014 }, + ], + }, + }, + ]; +} + +export function useOpLogColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'create_time', + title: '操作时间', + minWidth: 170, + }, + { + field: 'admin_username', + title: '操作人', + minWidth: 100, + }, + { + field: 'action_text', + title: '操作类型', + minWidth: 100, + }, + { + field: 'id_card', + title: '身份证号', + minWidth: 180, + }, + { + field: 'name', + title: '姓名规则', + minWidth: 90, + }, + { + field: 'api_codes', + title: '提交编码', + minWidth: 200, + slots: { default: 'api_codes' }, + }, + { + field: 'tianyuan_code', + title: '业务码', + minWidth: 90, + slots: { default: 'tianyuan_code' }, + }, + { + field: 'tianyuan_message', + title: '返回描述', + minWidth: 160, + }, + { + field: 'entry_api_codes', + title: '当前生效编码', + minWidth: 200, + slots: { default: 'entry_api_codes' }, + }, + { + field: 'transaction_id', + title: '流水号', + minWidth: 200, + }, + { + field: 'remark', + title: '备注', + minWidth: 120, + }, + ]; +} + +export function formatApiCodes(codes?: string[]) { + return codes?.length ? codes.join(', ') : '-'; +} + +export function isTianyuanSuccess(row: QueryWhitelistApi.OpLogItem) { + return row.tianyuan_code === 0; +} diff --git a/apps/web-antd/src/views/product-manage/whitelist/data.ts b/apps/web-antd/src/views/product-manage/whitelist/data.ts deleted file mode 100644 index a3a3cbc..0000000 --- a/apps/web-antd/src/views/product-manage/whitelist/data.ts +++ /dev/null @@ -1,207 +0,0 @@ -import type { VbenFormSchema } from '#/adapter/form'; -import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; -import type { WhitelistApi } from '#/api/product-manage'; - -/** 快捷勾选预设:按模块编号 api_id 匹配 */ -export const WHITELIST_QUICK_PRESETS = [ - { - label: '司法涉诉 + 违约失信', - apiIds: ['FLXG7E8F', 'JRZQ8A2D'], - }, - { - label: '司法涉诉', - apiIds: ['FLXG7E8F'], - }, - { - label: '违约失信', - apiIds: ['JRZQ8A2D'], - }, -] as const; - -export function useFormSchema(): VbenFormSchema[] { - return [ - { - component: 'Input', - fieldName: 'id_card', - label: '身份证号', - rules: 'required', - componentProps: { - placeholder: '请输入被屏蔽对象的身份证号', - }, - }, - { - component: 'Select', - fieldName: 'feature_ids', - label: '屏蔽模块', - rules: 'required', - formItemClass: 'items-start', - componentProps: { - mode: 'multiple', - showSearch: true, - optionFilterProp: 'label', - allowClear: true, - placeholder: '请选择要屏蔽的模块,支持多选', - options: [], - class: 'w-full', - }, - }, - { - component: 'InputNumber', - fieldName: 'amount', - label: '费用(元)', - defaultValue: 0, - componentProps: { - min: 0, - precision: 2, - }, - }, - { - component: 'Select', - fieldName: 'status', - label: '状态', - defaultValue: 1, - componentProps: { - options: [ - { label: '生效', value: 1 }, - { label: '已失效', value: 2 }, - ], - }, - }, - ]; -} - -export function useEditFormSchema(): VbenFormSchema[] { - return [ - { - component: 'Input', - fieldName: 'id_card', - label: '身份证号', - componentProps: { - disabled: true, - }, - }, - { - component: 'Input', - fieldName: 'feature_name', - label: '屏蔽模块', - componentProps: { - disabled: true, - }, - }, - { - component: 'InputNumber', - fieldName: 'amount', - label: '费用(元)', - componentProps: { - min: 0, - precision: 2, - }, - }, - { - component: 'Select', - fieldName: 'status', - label: '状态', - componentProps: { - options: [ - { label: '生效', value: 1 }, - { label: '已失效', value: 2 }, - ], - }, - }, - ]; -} - -export function useGridFormSchema(): VbenFormSchema[] { - return [ - { - component: 'Input', - fieldName: 'id_card', - label: '身份证号', - }, - { - component: 'Input', - fieldName: 'feature_api_id', - label: '模块编号', - }, - { - component: 'Select', - fieldName: 'status', - label: '状态', - componentProps: { - allowClear: true, - options: [ - { label: '生效', value: 1 }, - { label: '已失效', value: 2 }, - ], - }, - }, - ]; -} - -export function useColumns( - onActionClick: OnActionClickFn, -): VxeTableGridOptions['columns'] { - return [ - { - field: 'id_card', - title: '身份证号', - minWidth: 180, - }, - { - field: 'feature_api_id', - title: '模块编号', - minWidth: 140, - }, - { - field: 'feature_name', - title: '模块名称', - minWidth: 160, - }, - { - field: 'amount', - formatter: ({ cellValue }) => `¥${(cellValue || 0).toFixed(2)}`, - title: '费用(元)', - minWidth: 110, - }, - { - field: 'status_text', - title: '状态', - minWidth: 90, - }, - { - field: 'create_time', - title: '创建时间', - minWidth: 180, - }, - { - field: 'update_time', - title: '更新时间', - minWidth: 180, - }, - { - align: 'center', - cellRender: { - attrs: { - nameField: 'id_card', - nameTitle: '白名单', - onClick: onActionClick, - }, - options: [ - { - code: 'edit', - text: '编辑', - }, - { - code: 'delete', - text: '删除', - }, - ], - name: 'CellOperation', - }, - field: 'operation', - fixed: 'right', - title: '操作', - width: 140, - }, - ]; -} diff --git a/apps/web-antd/src/views/product-manage/whitelist/list.vue b/apps/web-antd/src/views/product-manage/whitelist/list.vue deleted file mode 100644 index 63d2a78..0000000 --- a/apps/web-antd/src/views/product-manage/whitelist/list.vue +++ /dev/null @@ -1,114 +0,0 @@ - - - diff --git a/apps/web-antd/src/views/product-manage/whitelist/modules/form.vue b/apps/web-antd/src/views/product-manage/whitelist/modules/form.vue deleted file mode 100644 index ad1f598..0000000 --- a/apps/web-antd/src/views/product-manage/whitelist/modules/form.vue +++ /dev/null @@ -1,186 +0,0 @@ - - - diff --git a/apps/web-antd/vite.config.mts b/apps/web-antd/vite.config.mts index 2ddb088..b923a47 100644 --- a/apps/web-antd/vite.config.mts +++ b/apps/web-antd/vite.config.mts @@ -10,8 +10,8 @@ export default defineConfig(async () => { changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), // mock代理目标地址 - // target: 'http://localhost:8888/api', - target: 'https://www.onecha.cn/api', + target: 'http://localhost:8888/api', + // target: 'https://www.onecha.cn/api', ws: true, }, },