import { ref } from 'vue';

export const formConfig = (disabled: Boolean) => {
  return ref([
    { label: '企业名称', field: 'orgName', show: false },
    {
      label: '部门名称',
      field: 'deptName',
      component: 'NsInput',
      componentProps: {
        disabled: disabled,
        placeholder: '请输入部门名称',
        maxLength: 20,
        onKeydown: (e) => e.keyCode === 32 && e.preventDefault(),
      },
      rules: [
        {
          required: true,
          message: '请输入部门名称',
        },
      ],
    },
    // {
    //   label: '上级部门',
    //   field: 'department',
    //   component: 'NsSelect',
    //   componentProps: {
    //     disabled: true,
    //     options: [
    //       {
    //         label: '部门1',
    //         value: 1,
    //       },
    //       {
    //         label: '部门2',
    //         value: 2,
    //       },
    //     ],
    //   },
    // },
    {
      label: '部门编码',
      field: 'deptCode',
      component: 'NsInput',
      componentProps: {
        disabled: disabled,
        placeholder: '请输入部门编码',
        onKeydown: (e) => e.keyCode === 32 && e.preventDefault(),
        maxLength: 20,
      },
      rules: [
        {
          required: true,
          message: '请输入部门编码',
        },
      ],
    },
    {
      label: '排序',
      field: 'sort',
      component: 'NsInputNumber',
      componentProps: {
        disabled: disabled,
        placeholder: '请输入排序',
        maxLength: 2,
        min: 0,
        max: 99,
        precision: 0,
      },
    },
    {
      field: 'remark',
      label: '备注',
      component: 'NsTextarea',
      componentProps: {
        disabled: disabled,
        placeholder: '请输入',
        maxLength: 300,
      },
    },
  ]);
};

export const formConfig2 = (disabled2: Boolean) => {
  return ref([
    { label: '部门名称', field: 'deptName', show: false },

    {
      label: '角色名称',
      field: 'zhName',
      component: 'NsInput',
      componentProps: {
        disabled: disabled2,
        placeholder: '请输入角色名称',
        onKeydown: (e) => e.keyCode === 32 && e.preventDefault(),
        maxLength: 20,
      },
      rules: [
        {
          required: true,
          message: '请输入角色名称',
        },
      ],
    },
    // {
    //   label: '上级领导',
    //   field: 'department',
    //   component: 'NsSelect',
    //   componentProps: {
    //     disabled: true,
    //   },
    // },
    {
      label: '节点编码',
      field: 'roleCode',
      component: 'NsInput',
      componentProps: {
        disabled: disabled2,
        placeholder: '请输入节点编码',
        onKeydown: (e) => e.keyCode === 32 && e.preventDefault(),
        maxLength: 20,
      },
      rules: [
        {
          required: true,
          message: '请输入节点编码',
        },
      ],
    },
    {
      label: '是否部门领导',
      field: 'isLeader',
      component: 'NsRadioGroup',
      defaultValue: 1,
      componentProps: {
        disabled: disabled2,
        radioType: 'radio',
        options: [
          { label: '是', value: 0 },
          { label: '否', value: 1 },
        ],
      },
      rules: [
        {
          required: true,
          message: '请选择是否部门领导',
        },
      ],
    },
    {
      field: 'remark',
      label: '备注',
      component: 'NsTextarea',
      componentProps: {
        disabled: disabled2,
        placeholder: '请输入',
        maxLength: 300,
      },
    },
  ]);
};
