import VersionApi, { type editRequest } from "@/api/system/version";
import type { IModalConfig } from "@/components/CURD/types";

const modalConfig: IModalConfig<editRequest> = {
  pageName: "sys:user",
  dialog: {
    title: "编辑版本",
    width: 800,
    draggable: true,
  },
  pk: "id",
  formAction: function (data) {
    return VersionApi.edit({ ...data, url: typeof data.url === "string" ? data.url : data.url[0] });
  },
  beforeSubmit(data) {
    console.log("提交之前处理", data);
  },
  formItems: [
    {
      type: "input",
      label: "版本号",
      prop: "version",
      rules: [{ required: true, message: "请输入版本号", trigger: "blur" }],
      attrs: {
        placeholder: "请输入版本号",
      },
    },

    {
      type: "textarea",
      label: "更新提示内容",
      prop: "message",
      rules: [{ required: true, message: "请输入更新提示内容", trigger: "blur" }],
      attrs: {
        placeholder: "请输入更新提示内容",
      },
    },
    {
      type: "custom",
      label: "版本文件",
      prop: "url",
      rules: [{ required: true, message: "请上传版本文件", trigger: "blur" }],
      attrs: {
        placeholder: "请上传版本文件",
      },
      initialValue: [],
    },
  ],
};

export default reactive(modalConfig);
