import Api from "@/api/product/vendor";
import { returnOptions, switchAttr } from "./config";
import type { IModalConfig } from "@/components/CURD/types";

const modalConfig: IModalConfig = {
  pageName: "sys:user",
  dialog: {
    title: "添加供应商",
    width: 800,
    draggable: true,
  },
  form: {
    labelWidth: 140,
  },
  formAction: function (data) {
    return Api.add({ ...data });
  },
  beforeSubmit(data) {
    console.log("提交之前处理", data);
  },
  formItems: [
    {
      label: "名称",
      prop: "name",
      rules: [{ required: true, message: "请输入名称", trigger: "blur" }],
      attrs: {
        placeholder: "请输入名称",
      },
    },
    {
      label: "联系人名字",
      prop: "contactName",
      rules: [{ required: false, message: "请输入联系人名字", trigger: "blur" }],
      attrs: {
        placeholder: "请输入联系人名字",
      },
    },
    {
      label: "联系人电话",
      prop: "telephone",
      rules: [{ required: false, message: "请输入联系人名字", trigger: "blur" }],
      attrs: {
        placeholder: "请输入联系人名字",
      },
    },
    {
      label: "供应商地址",
      prop: "address",
      rules: [{ required: false, message: "请输入供应商地址", trigger: "blur" }],
      attrs: {
        placeholder: "请输入供应商地址",
      },
    },
    {
      label: "备注",
      prop: "remark",
      rules: [{ required: false, message: "请输入备注", trigger: "blur" }],
      attrs: {
        placeholder: "请输入备注",
      },
    },
    {
      label: "排序",
      prop: "sort",
      rules: [{ required: true, message: "请输入排序", trigger: "blur" }],
      type: "input-number",
      attrs: {
        placeholder: "请输入排序",
      },
    },
  ],
};

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