import { B as _ } from "./BasicForm-dL_oCSPM.js";
import { u as C } from "./useForm-CKmgcynv.js";
import { _ as R } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { u as E } from "./useModal-CO65vga3.js";
import { k as N } from "./certificate-6_B4mutd.js";
import { V as g, bk as B, d as F, u as I, ar as M, r as u, aw as L, c as A, o as O, l as o, w as z, i as D, j as G, ac as W, __tla as __tla_0 } from "./index-9PRMimni.js";
import { b as j, c as $, d as H } from "./survey-50B41bWV.js";
let oe;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    let J, e, K, Q;
    J = B();
    ({ t: e } = g());
    K = await N();
    Q = [
        {
            field: "no",
            component: "NInput",
            label: e("hsqe.certificate.no"),
            giProps: {
                span: 2
            },
            componentProps: {
                placeholder: e("hsqe.certificate.no")
            },
            rules: [
                {
                    required: !0,
                    message: e("hsqe.certificate.no"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        },
        {
            field: "vesselType",
            component: "NSelect",
            label: e("hsqe.certificate.VesselType"),
            defaultValue: "",
            giProps: {
                span: 2
            },
            componentProps: {
                placeholder: e("hsqe.certificate.VesselType"),
                options: K,
                "label-field": J.getLocale === "en" ? "name" : "chineseName",
                "value-field": "id"
            },
            rules: [
                {
                    required: !0,
                    type: "number",
                    message: e("hsqe.certificate.VesselType"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        },
        {
            field: "englishType",
            component: "NInput",
            label: e("hsqe.Survey.SurveyTypeEnglish"),
            giProps: {
                span: 2
            },
            componentProps: {
                placeholder: e("hsqe.Survey.SurveyTypeEnglish")
            },
            rules: [
                {
                    required: !0,
                    message: e("hsqe.Survey.SurveyTypeEnglish"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        },
        {
            field: "active",
            component: "NRadioGroup",
            label: e("hsqe.certificate.Active"),
            defaultValue: 0,
            componentProps: {
                options: [
                    {
                        label: e("hsqe.certificate.Active"),
                        value: 0
                    },
                    {
                        label: e("hsqe.certificate.Inactive"),
                        value: 1
                    }
                ]
            }
        },
        {
            field: "fillingExplanation",
            component: "NInput",
            label: e("hsqe.Survey.FillingExplanation"),
            giProps: {
                span: 2
            },
            componentProps: {
                placeholder: e("hsqe.Survey.FillingExplanation"),
                type: "textarea"
            },
            rules: [
                {
                    required: !1,
                    message: e("hsqe.Survey.FillingExplanation"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        }
    ];
    oe = F({
        __name: "CreateModal",
        props: {
            title: {},
            isEdit: {}
        },
        emits: [
            "success"
        ],
        setup (h, { expose: v, emit: q }) {
            const { t: s } = g(), c = I(), y = M(), p = h, f = q, r = u(), b = u(p.title), i = u(!1), [x, { submit: T, setFieldsValue: d, getFieldsValue: m }] = C({
                gridProps: {
                    cols: 2
                },
                collapsed: !1,
                collapsedRows: 12,
                labelWidth: 80,
                layout: "horizontal",
                submitButtonText: s("common.okText"),
                showActionButtonGroup: !1,
                schemas: Q
            }), [S, { openModal: w, closeModal: l, setSubLoading: n, setProps: P }] = E({
                title: b,
                subBtuText: s("common.okText"),
                cancelText: s("common.cancelText"),
                width: 650
            });
            async function k(t) {
                if (r.value = t, await W(), t) {
                    const a = await j(t);
                    d({
                        ...a
                    });
                }
            }
            async function V() {
                if (await T()) {
                    const { isEdit: a } = p;
                    r.value ? (await H({
                        ...m(),
                        id: r.value
                    }), c.success(s(a ? "hsqe.certificate.editsuccess" : "hsqe.certificate.addsuccess")), f("success"), l(), n(!1)) : (n(!1), y.success({
                        title: s("hsqe.certificate.warning"),
                        content: s("hsqe.certificate.warningsure"),
                        positiveText: s("hsqe.certificate.sure"),
                        negativeText: s("hsqe.certificate.candle"),
                        draggable: !0,
                        loading: i.value,
                        onPositiveClick: async ()=>{
                            i.value = !0, await $(m()) && (i.value = !1), c.success(s(a ? "hsqe.certificate.editsuccess" : "hsqe.certificate.addsuccess")), i.value = !1, f("success"), l();
                        },
                        onNegativeClick: ()=>{}
                    }));
                } else c.error(s("hsqe.certificate.Verificationfailed")), n(!1);
            }
            return L(()=>{}), v({
                openModal: w,
                closeModal: l,
                setFieldsValue: d,
                setProps: P,
                getData: k
            }), (t, a)=>(O(), A(o(R), {
                    onRegister: o(S),
                    ref: "modalRef",
                    onOnOk: V
                }, {
                    default: z(()=>[
                            D("div", null, [
                                G(o(_), {
                                    onRegister: o(x)
                                }, null, 8, [
                                    "onRegister"
                                ])
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]));
        }
    });
});
export { oe as _, __tla };
