dict的使用方法,请大佬帮忙解答

发布于 2022-04-29 14:43:11

image.png

            field: 'dept',
            title: '所在部门',
            dict: {
              data: [{
                value: 1,
                label: '开启',
              }]
            }

求助,应该怎么写这个

查看更多

关注者
0
被浏览
581
1 个回答
hongzai
hongzai 认证专家 2022-04-29
life is coding,外包,远程协助,咨询添加微信:H0nGzA1

参考框架的部门字段crud

{
      title: '数据归属部门',
      key: 'dept_belong_id',
      show: showData.dept_belong_id.showTable,
      width: 150,
      search: {
        disabled: true
      },
      type: 'table-selector',
      dict: {
        cache: true,
        url: '/api/system/dept/?limit=999&status=1',
        isTree: true,
        value: 'id', // 数据字典中value字段的属性名
        label: 'name', // 数据字典中label字段的属性名
        children: 'children', // 数据字典中children字段的属性名
        getData: (url, dict, {
          _,
          component
        }) => {
          return request({
            url: url,
          }).then(ret => {
            return ret.data.data
          })
        }
      },
      form: {
        disabled: !showData.dept_belong_id.showForm,
        component: {
          props: {
            elProps: {
              treeConfig: {
                transform: true,
                rowField: 'id',
                parentField: 'parent',
                expandAll: true
              },
              columns: [
                {
                  field: 'name',
                  title: '部门名称',
                  treeNode: true
                },
                {
                  field: 'status',
                  title: '状态'
                },
                {
                  field: 'parent_name',
                  title: '父级部门'
                }
              ]
            }
          }
        },
        helper: {
          render(h) {
            return (< el-alert title="默认不填则为当前创建用户的部门ID" type="info" />
            )
          }
        }
      }
    },

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览