import ParamsApi, { type addRequest } from "@/api/system/params";
import type { IModalConfig } from "@/components/CURD/types";
import { paramTypeOptions } from './config'
const modalConfig: IModalConfig<addRequest> = {
  pageName: "sys:user",
  dialog: {
    title: "编辑系统参数",
    width: 800,
    draggable: true,
  },
  form: {
    labelWidth: 140,
  },
  formAction: function (data) {
    return ParamsApi.edit(data);
  },
  beforeSubmit(data) {
    console.log("提交之前处理", data);
  },
  formItems: [
    {
      label: "参数编码",
      prop: "paramCode",
      rules: [{ required: true, message: "请输入参数编码", trigger: "blur" }],
      type: "input",
      disabled: true,
      attrs: {
        placeholder: "请输入参数编码",
      },
    },
    {
      label: "参数值",
      prop: "paramValue",
      rules: [{ required: true, message: "请输入参数值", trigger: "blur" }],
      type: "input",
      attrs: {
        placeholder: "请输入参数值",
      },
    },
    {
      label: "参数类型",
      prop: "paramType",
      rules: [{ required: true, message: "请选择参数类型", trigger: "blur" }],
      type: "select",
      attrs: {
        placeholder: "请选择参数类型",
      },
      col: {
        xs: 24,
        sm: 12,
      },
      options: paramTypeOptions,
    },
    {
      type: "textarea",
      label: "备注",
      prop: "remark",
      rules: [{ required: true, message: "请输入备注", trigger: "blur" }],
      attrs: {
        placeholder: "请输入备注",
      },
    },
  ],
};

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