import { _ as E } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { B as L } from "./BasicForm-dL_oCSPM.js";
import { v as R, e as U, a as j } from "./documentManagement-CH33LgfO.js";
import { V as q, bk as W, r as p, d as z, c as A, o as G, l as I, w as d, j as M, aH as H, hr as J, i as F, aj as K, ac as Q, __tla as __tla_0 } from "./index-9PRMimni.js";
import { ae as X } from "./template-rpthWlT9.js";
import { u as Y } from "./account-C850CBTF.js";
import { u as Z } from "./useModal-CO65vga3.js";
import { u as ee } from "./useForm-CKmgcynv.js";
let fe, pe;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    let e, te, ne;
    ({ t: e } = q());
    te = W();
    ne = await X();
    pe = [
        {
            field: "status",
            component: "NSelect",
            label: e("document.documentManagement.status"),
            componentProps: {
                placeholder: e("document.documentManagement.status"),
                options: ne,
                clearable: !0,
                labelField: te.getLocale === "en" ? "labelEn" : "label"
            }
        },
        {
            field: "search",
            component: "NInput",
            label: `${e("document.documentManagement.fileName")}/${e("document.documentManagement.fileNo")}`,
            componentProps: {
                placeholder: `${e("document.documentManagement.fileName")}/${e("document.documentManagement.fileNo")}`
            }
        }
    ];
    function oe() {
        const a = p(!1), c = p(!0), m = p("");
        return {
            modalSchemas: [
                {
                    field: "fileNo",
                    component: "NInput",
                    label: e("document.documentManagement.fileNo"),
                    componentProps: {
                        showCount: !0,
                        maxlength: 30,
                        disabled: a
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.inputText") + " " + e("document.documentManagement.fileNo"),
                            trigger: [
                                "blur"
                            ]
                        }
                    ]
                },
                {
                    field: "englishName",
                    component: "NInput",
                    label: e("document.documentManagement.fileName") + "(English)",
                    componentProps: {
                        showCount: !0,
                        maxlength: 200,
                        disabled: a
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.inputText") + " " + e("document.documentManagement.fileName") + "(English)",
                            trigger: [
                                "blur"
                            ]
                        },
                        {
                            level: "warning",
                            trigger: [
                                "blur"
                            ],
                            asyncValidator: async (s, l, u)=>{
                                await R({
                                    englishName: l,
                                    id: m.value
                                }) && u(new Error(`${e("document.documentManagement.fileName")}(English) ${e("document.documentManagement.nameRepeat")}`));
                            }
                        }
                    ]
                },
                {
                    field: "chineseName",
                    component: "NInput",
                    label: e("document.documentManagement.fileName") + "(Chinese)",
                    componentProps: {
                        showCount: !0,
                        maxlength: 100,
                        disabled: a
                    },
                    rules: [
                        {
                            required: !0,
                            message: `${e("common.inputText")} ${e("document.documentManagement.fileName")}(Chinese)`,
                            trigger: [
                                "blur"
                            ]
                        },
                        {
                            level: "warning",
                            trigger: [
                                "blur"
                            ],
                            asyncValidator: async (s, l, u)=>{
                                await R({
                                    chineseName: l,
                                    id: m.value
                                }) && u(new Error(`${e("document.documentManagement.fileName")}(Chinese) ${e("document.documentManagement.nameRepeat")}`));
                            }
                        }
                    ]
                },
                {
                    field: "version",
                    component: "NInput",
                    label: e("document.documentManagement.fileVersion"),
                    componentProps: {
                        showCount: !0,
                        maxlength: 30,
                        disabled: a
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.inputText") + " " + e("document.documentManagement.fileVersion"),
                            trigger: [
                                "blur"
                            ]
                        }
                    ]
                },
                {
                    field: "rev",
                    component: "NInput",
                    label: e("document.documentManagement.rev"),
                    componentProps: {
                        showCount: !0,
                        maxlength: 30,
                        disabled: a
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.inputText") + " " + e("document.documentManagement.rev"),
                            trigger: [
                                "blur"
                            ]
                        }
                    ]
                },
                {
                    field: "effectiveDate",
                    component: "NDatePicker",
                    label: e("document.documentManagement.effectiveDate"),
                    componentProps: {
                        type: "date",
                        valueFormat: "yyyy-MM-dd"
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.chooseText") + " " + e("document.documentManagement.effectiveDate"),
                            trigger: [
                                "change"
                            ]
                        }
                    ]
                },
                {
                    label: e("document.documentManagement.file"),
                    field: "fileUrl",
                    slot: "fileSlot",
                    rules: [
                        {
                            key: "fileUrl",
                            required: c,
                            message: e("common.chooseText") + " " + e("document.documentManagement.file"),
                            trigger: [
                                "change"
                            ]
                        }
                    ]
                }
            ],
            methods: {
                updateReadOnly: (s)=>{
                    a.value = s;
                },
                updateRequired: (s)=>{
                    c.value = s;
                },
                updateFormId: (s)=>{
                    m.value = s;
                }
            }
        };
    }
    fe = z({
        __name: "FormModal",
        props: {
            selectedTreeItem: {}
        },
        emits: [
            "success"
        ],
        setup (a, { expose: c, emit: m }) {
            const v = m, _ = a, { t: s } = q(), [l, { openModal: u, closeModal: f, setSubLoading: g, setProps: S }] = Z({
                title: "",
                width: 800
            }), { modalSchemas: T, methods: h } = oe(), [C, { submit: $, setFieldsValue: P, validate: N }] = ee({
                gridProps: {
                    cols: 2
                },
                layout: "horizontal",
                labelWidth: "800",
                schemas: T,
                showActionButtonGroup: !1
            });
            let t = p();
            function k(n, o, r) {
                S({
                    title: n
                }), u(), t.value = K(o || {}), h.updateFormId(t.value?.id), h.updateReadOnly(r), h.updateRequired(!t.value?.id), Q(()=>{
                    P({
                        ...t.value,
                        status: t.value?.id ? t.value?.status === 1 ? 0 : t.value?.status : t.value?.status ?? 0
                    });
                });
            }
            async function D(n, o, r) {
                const i = new FormData;
                i.append("file", n.file);
                const b = await Y(i);
                o[r] = b.url, N([
                    "fileUrl"
                ]);
            }
            function V(n, o) {
                n[o] = "", N([
                    "fileUrl"
                ]);
            }
            async function O() {
                const n = await $();
                if (!n) {
                    g(!1);
                    return;
                }
                try {
                    t.value?.id ? await U({
                        id: t.value?.id,
                        ...n
                    }) : await j({
                        folderId: _.selectedTreeItem.id,
                        ...n
                    }), f(), g(!1), v("success");
                } catch  {
                    g(!1);
                }
            }
            return c({
                handleOpenModal: k
            }), (n, o)=>{
                const r = J, i = H, b = L, B = E;
                return G(), A(B, {
                    ref: "modalRef",
                    onRegister: I(l),
                    onOnOk: O
                }, {
                    default: d(()=>[
                            M(b, {
                                ref: "formRef",
                                onRegister: I(C)
                            }, {
                                fileSlot: d(({ model: x, field: w })=>[
                                        M(i, {
                                            multiple: "",
                                            "directory-dnd": "",
                                            accept: ".pdf",
                                            headers: {
                                                "Content-Type": "multipart/form-data"
                                            },
                                            max: 1,
                                            "custom-request": ({ file: y })=>D(y, x, w),
                                            onRemove: (y)=>V(x, w),
                                            class: "inline-block"
                                        }, {
                                            default: d(()=>[
                                                    M(r, {
                                                        class: "w-[96px] h-[96px] flex items-center justify-center border border-dashed rounded-[8px] p-0"
                                                    }, {
                                                        default: d(()=>o[0] || (o[0] = [
                                                                F("div", null, [
                                                                    F("i", {
                                                                        class: "iconfont icon-upload1 text-[32px] text-[#7e8984]"
                                                                    })
                                                                ], -1)
                                                            ])),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 2
                                        }, 1032, [
                                            "custom-request",
                                            "onRemove"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { fe as _, pe as s, __tla };
