Skip to content
Power

获取字典选项 useDictionaries

快速高效的,获取接口字典数据

DANGER

获取字典方法为 异步请求 在项目中不可直接使用在主方法内。否则页面会出现卡死情况。

typescript
import useDictionaries from "MTools/dictionaries"; 
import { mTagOptionType } from "PancakeUI/global";

const exOptions = ref({});
nextTick(async () => {
  const Select: mTagOptionType[] = await useDictionaries("table", ["Dealer"]); 
  const bgColor = ["#33b698", "#409eff"];
  for (let index = 0; index < Select.length; index++) {
    Select[index].tagStyle = { bgColor: bgColor[index], textColor: "#fff" };
  }
  exOptions.value = { Select };
});
typescript
import useDictionaries from "MTools/dictionaries-all"; 
import { mSelectOptionType } from "PancakeUI/global";

const exOptions = ref({});
nextTick(async () => {
  const Select: { [x: string]: mSelectOptionType[] } = await useDictionaries([
    {
      key: "aa",
      dictionaryType: "table",
      tableName: "SmartLabelImportExportRecord",
      columnName: "RecordType",
      dictionaryKey: ""
    },
    {
      key: "bb",
      dictionaryType: "system",
      tableName: "",
      columnName: "",
      dictionaryKey: "InvoiceTimeOutCheckTaskIntervalDays"
    }
  ]);

  exOptions.value = Select;
});

入参

字段类型描述
type"system" / "table"获取字典类型
keystring[]字典接口参数
paramssystemParamsType /tableParamsType字典接口参数

tableParamsType

字段类型描述
fieldNamestring
fieldValuestring
conditionalTypestring

systemParamsType

字段类型描述
keysstring

出参 mSelectOptionType

字段类型描述
labelstring选项名
valuestring选项值