import { _ as V } 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 { u as D } from "./useForm-CKmgcynv.js";
import { O as $, au as A } from "./template-rpthWlT9.js";
import { V as R, bk as G, d as z, u as H, r as x, c as W, o as j, l as s, w as l, j as p, aH as K, ds as J, cO as Q, fm as X, cq as Y, aI as Z, p as b, A as v, B as ee, bR as se, R as te, ac as oe, __tla as __tla_0 } from "./index-9PRMimni.js";
import { c as ae } from "./componentSetting-DVhNDBTO.js";
import { u as ne } from "./useModal-CO65vga3.js";
let _e;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const le = G(), { t: h } = R(), ie = await $();
    function re() {
        return {
            schemas: [
                {
                    field: "shipId",
                    component: "NSelect",
                    label: h("hsqe.auditInspection.vesselInspection.formVessel"),
                    componentProps: {
                        placeholder: h("hsqe.auditInspection.vesselInspection.formVesselHint"),
                        options: ie,
                        "value-field": "id",
                        "label-field": le.getLocale === "en" ? "shipNameEn" : "shipName"
                    },
                    giProps: {
                        span: 2
                    }
                },
                {
                    field: "pdfUrl",
                    label: h("hsqe.report.file"),
                    slot: "templateUpload",
                    giProps: {
                        span: 2
                    }
                }
            ]
        };
    }
    _e = z({
        __name: "Modal",
        emits: [
            "success",
            "changeResult"
        ],
        setup (T, { expose: M, emit: U }) {
            const C = U, { t } = R(), { schemas: w } = re(), m = H(), [I, { openModal: O, closeModal: g, setProps: q, setSubLoading: u }] = ne({
                title: t("common.uploadText"),
                subBtuText: t("common.okText"),
                cancelText: t("common.cancelText"),
                width: 650
            }), [y, { getFieldsValue: B }] = D({
                schemas: w,
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 2,
                    xGap: 15
                },
                showActionButtonGroup: !1
            }), _ = x(""), i = x([]);
            async function F(e) {
                O(), _.value = e;
            }
            function k({ event: e }, a, d, S) {
                try {
                    const o = se("(" + e.target.response + ")"), { infoField: f } = ae.upload.apiSetting, { code: r } = o, c = o.msg || o.message || "上传失败", n = o[f];
                    r === te.SUCCESS ? a[d] = n.url : m.error(c);
                } catch  {}
            }
            async function E() {
                await oe();
            }
            async function N() {
                let e = B(), a = {
                    ...e,
                    templateCode: _.value
                };
                e.shipId === "" || !e.shipId ? (m.error(t("hsqe.report.errorShip")), u(!1)) : e.pdfUrl === "" || !e.pdfUrl ? (m.error(t("hsqe.report.errorUrl")), u(!1)) : (await A(a), C("success"), u(!1), g());
            }
            function P() {
                g();
            }
            return M({
                showModal: F,
                setProps: q,
                getData: E
            }), (e, a)=>{
                const d = ee, S = Z, o = K, f = V;
                return j(), W(f, {
                    ref: "modalRef",
                    onRegister: s(I),
                    class: "basicModal basicFormModal",
                    onOnOk: N,
                    onOnClose: P
                }, {
                    default: l(()=>[
                            p(s(L), {
                                onRegister: s(y),
                                "label-placement": "top"
                            }, {
                                templateUpload: l(({ model: r, field: c })=>[
                                        p(o, {
                                            action: `${s(Y)().urlPrefix}/files`,
                                            headers: {
                                                timestamp: new Date().getTime(),
                                                authorization: `${s(Q).get(s(X))}`
                                            },
                                            max: 1,
                                            "file-list": s(i),
                                            "onUpdate:fileList": a[0] || (a[0] = (n)=>J(i) ? i.value = n : null),
                                            onFinish: ({ event: n })=>k({
                                                    event: n
                                                }, r, c, s(i)),
                                            onRemove: (n)=>r[c] = null,
                                            class: "uploadStyle",
                                            "file-list-style": {
                                                margin: 0,
                                                flex: 1
                                            }
                                        }, {
                                            default: l(()=>[
                                                    p(S, {
                                                        trigger: "hover"
                                                    }, {
                                                        trigger: l(()=>[
                                                                p(d, null, {
                                                                    default: l(()=>[
                                                                            b(v(s(t)("hsqe.rs.uploadText")), 1)
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        default: l(()=>[
                                                                b(" " + v(s(t)("hsqe.rs.uploadText")), 1)
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 2
                                        }, 1032, [
                                            "action",
                                            "headers",
                                            "file-list",
                                            "onFinish",
                                            "onRemove"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { _e as _, __tla };
