Skip to content

ListConfig

参考

js
const listConfig = computed(() => {
  return [
    {
      key: "key",
      head: "key",
      width: 50,
      type: "select",
      fixed: "left",
      multiple: true,
    },
    {
      key: "image",
      head: "头像",
      width: 80,
      type: "image",
      model: "image",
      radius: true,
    },
    {
      key: "name",
      head: "名称",
      width: 100,
      type: "text",
      model: "name",
      orderModel: "name",
    },
    {
      key: "role",
      head: "角色",
      width: 100,
      type: "enum",
      model: "role",
      orderModel: 'role',
      dictList: roleOptions,
    },
    {
      key: "region",
      head: "归属地区",
      width: 120,
      type: "enum",
      model: "region",
      isTree: true,
      dictKey: "value",
      dictLabel: "label",
      orderModel: 'region',
      dictList: regionOptions,
    },
    {
      key: "status",
      head: "在线状态",
      width: 120,
      type: "status",
      model: "status",
      orderModel: 'status',
      dictList: statusOptions,
      color: (row) => {
        if ([1, 2, 3, 4].includes(row.status)) {
          return ["#1f9d68", "#d93f34", "#c97700", "#2a6af5"][row.status - 1];
        }
      },
    },
    {
      key: "tags",
      head: "标签",
      width: 160,
      type: "tags",
      model: (row) => {
        if (!row?.tags || !row?.tags.length) return [];
        return row.tags.map((item) => {
          return tagList.find((tag) => tag.dictKey == item)?.dictLabel ?? item;
        });
      },
    },
    {
      key: "switch",
      width: 120,
      head: "启用状态",
      type: "switch",
      model: "switch",
      orderModel: 'switch',
      changeFun: (val, scope) => {
        scope.row.switch = val;
      },
    },
    {
      key: "createTime",
      head: "创建时间",
      width: 160,
      type: "text",
      model: "createTime",
      orderModel: "createTime",
    },
    {
      key: "option",
      head: "操作",
      type: "option",
      fixed: "right",
      width: 160,
      optionConfig: [
        {
          label: "查看",
          icon: "View",
          clickFun: async ({ row }) => {},
        },
        {
          label: "编辑",
          icon: "Edit",
          clickFun: ({ row }) => {},
        },
        {
          label: "执行",
          icon: "SwitchButton",
          clickFun: ({ row }) => {
          },
        },
        {
          label: "删除",
          icon: "DeleteFilled",
          clickFun: ({ row }) => {
          },
        },
      ],
    },
  ];
});

通用属性说明

属性说明类型默认值
keylist唯一keystring-
width列宽number-
head表头string-
type列类型,不同的类型有不同的属性string-
fixed固定列在左边或者右边string-
model对应列表行数据的属性名Function/string-
orderModel对应列的排序字段Function/string-

text属性说明

属性说明类型默认值
color字体颜色Function/string-
clickFun点击回调函数Function-
isNumFormat是否使用数字格式booleanfalse
customIcon自定义图标Function/string-

tags属性说明

switch属性说明

属性说明类型默认值
active激活属性值string/number/boolean-
inactive非激活属性值string/number/boolean-
disabled是否禁用Function/booleanfalse
size尺寸string-
changeFun值改变时回调函数Function-

status属性说明

属性说明类型默认值
color字体颜色Function/string-
dictList数据字段列表Function/array-
dictKey指定选项的值为选项对象的某个属性值stringdictKey
dictLabel指定节点标签为节点对象的某个属性值stringdictLabel
isTree数据是否是树结构booleanfalse

select属性说明

属性说明类型默认值
multiple是否多选boolean-
selectable是否可以选中Function-
chickFun点击回调Function-
allSelectable是否可全选Function-

price属性说明

属性说明类型默认值
color字体颜色Function/string-
unit单位Function-
currency币种属性Function/string-
clickFun点击回调函数Function-

option属性说明

属性说明类型默认值
optionConfig操作按钮列表,按钮配置可以参考actionarray-

image属性说明

属性说明类型默认值
radius是否是圆形图片booleanfalse

expand属性说明

属性说明类型默认值
component展开行的组件,可以是一个vue组件object-

enum属性说明

属性说明类型默认值
color字体颜色Function/string-
dictList数据字段列表Function/array-
dictKey指定选项的值为选项对象的某个属性值stringdictKey
dictLabel指定节点标签为节点对象的某个属性值stringdictLabel
isTree数据是否是树结构booleanfalse
clickFun点击回调函数Function-

edit属性说明

属性说明类型默认值
editModel用于判断是否是编辑模式的字段Function/stringisEdit
editOption编辑模式下的配置,Form支持的类型,同步支持object-
readOption展示模式下的配置,可以是上面任意一种类型object-