import VersionApi, { type payType } from "@/api/account/payType";


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

const modalConfig: IModalConfig<payType> = {
  pageName: "sys:user",
  dialog: {
    title: "编辑收银方式",
    width: 800,
    draggable: true,
  },
  form: {
    labelWidth: 140,
  },
  formAction: function (data) {
    return VersionApi.edit({ ...data });
  },
  beforeSubmit(data) {
    console.log("提交之前处理", data);
  },
  formItems: [

    {
      label: "收银类型",
      prop: "payType",
      rules: [{ required: true, message: "请选择收银类型", trigger: "blur" }],
      type: "select",
      attrs: {
        placeholder: "请选择收银类型",
      },
      options: returnOptions("payType"),
      col: {
        xs: 24,
        sm: 12,
      },
    },
    {
      type: "input",
      label: "收银名称",
      prop: "payName",
      rules: [{ required: true, message: "请输入收银名称", trigger: "blur" }],
      attrs: {
        placeholder: "请输入收银名称",
      },
      col: {
        xs: 24,
        sm: 12,
      },
    },
    {
      type: "switch",
      label: "是否是系统级支付",
      prop: "isSystem",
      attrs: { ...switchAttr },
      col: {
        xs: 24,
        sm: 12,
      },
      initialValue: 0

    },
    {
      type: "switch",
      label: "是否快捷展示",
      prop: "isShowShortcut",
      attrs: { ...switchAttr },

      col: {
        xs: 24,
        sm: 12,
      },
      initialValue: 0

    }, {
      type: "switch",
      label: "是否允许退款",
      prop: "isRefundable",
      attrs: { ...switchAttr },

      col: {
        xs: 24,
        sm: 12,
      },
      initialValue: 0
    },
    {
      type: "switch",
      label: "是否打开钱箱",
      prop: "isOpenCashDrawer",
      attrs: { ...switchAttr },
      col: {
        xs: 24,
        sm: 12,
      },
      initialValue: 0

    },
    {
      type: "radio",
      label: "是否虚拟",
      prop: "isIdeal",
      col: {
        xs: 24,
        sm: 12,
      },
      initialValue: 1,
      options: returnOptions('isIdeal')
    },
    {
      type: "switch",
      label: "是否显示",
      attrs: { ...switchAttr },
      prop: "isDisplay",
      initialValue: 0
    },

    {
      type: "input-number",
      label: "排序",
      prop: "sorts",
    },
    {
      type: "UpImage",
      label: "图标",
      prop: "icon",
    },
  ],
};

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