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

import type { IModalConfig } from "@/components/CURD/types";

const modalConfig: IModalConfig<UserForm> = {
  pageName: "sys:user",
  dialog: {
    title: "新增模板",
    width: 800,
    draggable: true,
  },
  form: {
    labelWidth: 100,
  },
  formAction: UserAPI.addunit,
  beforeSubmit(data) {

    if (data.pid == '') {
      data.pid = 0
    }
    console.log("提交之前处理", data);
  },
  formItems: [
    {
      label: "规格名称",
      prop: "name",
      rules: [{ required: true, message: "规格名称不能为空", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入规格名称",
      },
    },
    {
      label: "规格级别",
      prop: "level",
      rules: [{ required: true, message: "用户角色不能为空", trigger: "blur" }],
      type: "select",
      attrs: {
        placeholder: "请选择",
      },
      options: [{ label: "一级", value: 1 }, { label: "二级", value: 2 }, { label: "三级", value: 3 }],
      initialValue: [],
    }, {
      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
        }
      },
    }
  ],
};
export interface UserForm { }
// 如果有异步数据会修改配置的，推荐用reactive包裹，而纯静态配置的可以直接导出
export default reactive(modalConfig);
