import UserAPI from "@/api/product/specificationsconfig";

import type { IModalConfig } from "@/components/CURD/types";
import { DeviceEnum } from "@/enums/DeviceEnum";
import { useAppStore } from "@/store";

const modalConfig: IModalConfig<UserForm> = {
  pageName: "sys:user",
  // component: "drawer",
  dialog: {
    title: "编辑单位",
    width: 800,
    draggable: true,
  },

  pk: "id",
  formAction: function (data) {
    return UserAPI.update({ ...data, sort: '1' });
  },
  beforeSubmit(data) {
    console.log("提交之前处理", data);
  },
  formItems: [
    {
      label: "规格名称",
      prop: "name",
      rules: [{ required: true, message: "规格名称不能为空", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入规格名称",
      },
    },
    {
      label: "规格级别",
      prop: "level",
      type: "select",
      attrs: {
        placeholder: "请选择",
      },
      options: [{ label: "一级", value: 1 }, { label: "二级", value: 2 }, { label: "三级", value: 3 }],
      initialValue: [],
      hidden: true
    },
    {
      label: "上级规格",
      prop: "pid",
      type: "tree-select",
      attrs: {
        placeholder: "请选择上级规格",
        data: [],
        filterable: true,
        "check-strictly": true,
        "render-after-expand": false,
        props: {
          label: 'name', // 指定节点显示的文本字段为 name
          value: 'id'    // 指定节点的值字段为 id
        }
      },
    }
  ],
};
/** 用户表单类型 */
interface UserForm {
  /** 用户头像 */
  avatar?: string;
  /** 部门ID */
  deptId?: number;
  /** 邮箱 */
  email?: string;
  /** 性别 */
  gender?: number;
  /** 用户ID */
  id?: number;
  /** 手机号 */
  mobile?: string;
  /** 昵称 */
  nickname?: string;
  /** 角色ID集合 */
  roleIds?: number[];
  /** 用户状态(1:正常;0:禁用) */
  status?: number;
  /** 用户名 */
  username?: string;
}

export default reactive(modalConfig);
