import ShopStaffApi, { type addRequest } from "@/api/account/shopStaff";
import type { IModalConfig } from "@/components/CURD/types";
import { discountTypeOptions } from './config'
const modalConfig: IModalConfig<addRequest> = {
  pageName: "sys:user",
  dialog: {
    title: "添加员工",
    width: 800,
    draggable: true,
  },
  form: {
    labelWidth: 140,
  },
  formAction: function (data) {
    return ShopStaffApi.add(data);
  },
  beforeSubmit(data) {
    console.log("提交之前处理", data);
  },
  formItems: [
    {
      label: "基本信息设置",
      prop: "",
      type: "title",
      slotName: "title",
    },
    {
      label: "角色",
      prop: "roleId",
      rules: [{ required: true, message: "请选择角色", trigger: "blur" }],
      type: "select",
      attrs: {
        placeholder: "请选择角色",
      },
      col: {
        xs: 24,
        sm: 12,
      },
      options: []
    },
    {
      label: "员工姓名",
      prop: "name",
      rules: [{ required: false, message: "请输入员工姓名", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入员工姓名",
      },
      col: {
        xs: 24,
        sm: 12,
      },
    },
    {
      label: "员工编号",
      prop: "code",
      rules: [{ required: true, message: "请输入员工编号", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入员工编号",
      },
      col: {
        xs: 24,
        sm: 12,
      },
    },
    {
      label: "手机号",
      prop: "phone",
      rules: [{
        required: true,
        pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
        message: "请输入正确的手机号码",
        trigger: "blur",
      }],
      type: "input",
      attrs: {
        placeholder: "请输入手机号",
      },
      col: {
        xs: 24,
        sm: 12,
      },
    },
    {
      label: "登录账号",
      prop: "accountName",
      rules: [{ required: true, message: "请输入登录账号", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入登录账号",
      },
      col: {
        xs: 24,
        sm: 12,
      },
    },
    {
      label: "登录密码",
      prop: "accountPwd",
      rules: [{ required: true, message: "请输入登录密码", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入登录密码",
      },
      col: {
        xs: 24,
        sm: 12,
      },
    },


    {
      label: "优惠类型",
      prop: "discountType",
      rules: [{ required: false, message: "请选择优惠类型", trigger: "blur" }],
      type: "radio-button",
      col: {
        xs: 24,
        sm: 12,
      },
      options: discountTypeOptions,
    },
    {
      label: "最大优惠金额",
      prop: "maxDiscountAmount",
      rules: [{ required: false, message: "请输入最大优惠金额", trigger: "blur" }],
      col: {
        xs: 24,
        sm: 12,
      },
    },
    {
      label: "是否启用",
      prop: "status",
      type: "radio",
      options: [
        { label: "正常", value: 1 },
        { label: "禁用", value: 0 },
      ],
      initialValue: 1,
      col: {
        xs: 24,
        sm: 12,
      },
    },

    {
      label: "是否允许管理端登录",
      prop: "isManage",
      type: "radio",
      options: [
        { label: "正常", value: 1 },
        { label: "禁用", value: 0 },
      ],
      initialValue: 1,
    },
    {
      label: "是否允许pc登录",
      prop: "isPc",
      type: "radio",
      options: [
        { label: "正常", value: 1 },
        { label: "禁用", value: 0 },
      ],
      initialValue: 1,
    },



  ],
};

// 如果有异步数据会修改配置的，推荐用reactive包裹，而纯静态配置的可以直接导出
export default reactive(modalConfig);
