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

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 });
  },
  beforeSubmit(data) {
    console.log("提交之前处理", data);
  },
  formItems: [
    {
      label: "分类名称",
      prop: "name",
      rules: [{ required: true, message: "分类名称不能为空", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入分类名称",
      },
    },
    {
      label: "分类图片",
      prop: "pic",
      type: "UpImage",
    },
    {
      label: '退菜是否退库存',
      prop: 'refundMode',
      type: 'radio',
      options: [
        { label: "退菜退库存", value: 1 },
        { label: "仅退菜不退库存", value: 2 },
        { label: "每次询问-退菜后弹窗提示，可手动选择", value: 3 },
      ],
      initialValue: 1,
    },
    {
      label: "排序",
      prop: "sort",
      type: "input-number",
      attrs: {
        placeholder: "请输入排序",
      },
      initialValue: 1,
    },
    {
      label: "开关",
      prop: "status",
      type: "switch",
      options: [
        { label: "启用", value: 1 },
        { label: "禁用", value: 0 },
      ],
      attrs: {
        activeValue: 1,
        inactiveValue: 0,
      },
      initialValue: 1,
    }
  ],
};
/** 用户表单类型 */
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);
