Commit 765b5b9720fe67cb8671c76cb86634344690fe9f

Authored by xp.Huang
2 parents 6c62f04d a0a6aa17

Merge branch 'fix/DEFECT-2966' into 'main_dev'

fix: 字典名称查询按照下拉框来筛选

See merge request yunteng/thingskit-front!1510
... ... @@ -14,6 +14,7 @@ import { useI18n } from '/@/hooks/web/useI18n';
14 14 enum SysDictApi {
15 15 CONFIG_URL = '/dict',
16 16 CONFIG_ITEM_URL = '/dict_item',
  17 + CONFIG_LIST_DICT = '/dict/all',
17 18 }
18 19
19 20 /**
... ... @@ -45,6 +46,17 @@ export const sysDictPage = (params: SysDictParams) =>
45 46 });
46 47
47 48 /**
  49 + * 获取字典list 用于查询
  50 + */
  51 +
  52 +export const getDictList = (_params?: string) => {
  53 + return defHttp.get<{ code: number; data: SysDict[]; message: string }>({
  54 + url: SysDictApi.CONFIG_LIST_DICT,
  55 + // params,
  56 + });
  57 +};
  58 +
  59 +/**
48 60 * 获取SysDictItem列表
49 61 * @param params 查询参数
50 62 */
... ...
  1 +import { getDictList } from '/@/api/system/dict';
1 2 import { BasicColumn } from '/@/components/Table';
2 3 import { FormSchema } from '/@/components/Table';
3 4 import { useI18n } from '/@/hooks/web/useI18n';
... ... @@ -36,26 +37,46 @@ export const columns: BasicColumn[] = [
36 37 ];
37 38
38 39 export const searchFormSchema: FormSchema[] = [
  40 + // {
  41 + // field: 'dictName',
  42 + // label: t('system.dict.dictName'),
  43 + // component: 'Input',
  44 + // colProps: { span: 6 },
  45 + // componentProps: {
  46 + // maxLength: 32,
  47 + // },
  48 + // dynamicRules: () => {
  49 + // return [
  50 + // {
  51 + // required: false,
  52 + // validator: (_, value) => {
  53 + // if (String(value).length > 32) {
  54 + // return Promise.reject(t('system.dict.textRule32'));
  55 + // }
  56 + // return Promise.resolve();
  57 + // },
  58 + // },
  59 + // ];
  60 + // },
  61 + // },
39 62 {
40 63 field: 'dictName',
41 64 label: t('system.dict.dictName'),
42   - component: 'Input',
  65 + component: 'ApiSelect',
43 66 colProps: { span: 6 },
44 67 componentProps: {
45   - maxLength: 32,
46   - },
47   - dynamicRules: () => {
48   - return [
49   - {
50   - required: false,
51   - validator: (_, value) => {
52   - if (String(value).length > 32) {
53   - return Promise.reject(t('system.dict.textRule32'));
54   - }
55   - return Promise.resolve();
56   - },
57   - },
58   - ];
  68 + api: async () => {
  69 + const { data: values } = await getDictList();
  70 + return (values || []).map((item) => ({
  71 + label: t(item.dictName) ? t(item.dictName) : item.dictName,
  72 + value: item.dictName,
  73 + }));
  74 + },
  75 +
  76 + showSearch: true,
  77 + filterOption: (inputValue: string, options: Record<'label', string>) => {
  78 + return options.label.includes(inputValue);
  79 + },
59 80 },
60 81 },
61 82 {
... ...