import { _ as P } 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 V } from "./BasicForm-dL_oCSPM.js";
import { aV as B } from "./template-rpthWlT9.js";
import { ad as n, r as c, V as F, d as L, c as q, o as G, l as h, w as z, j as E, ac as $, __tla as __tla_0 } from "./index-9PRMimni.js";
import { u as j } from "./useModal-CO65vga3.js";
import { u as D } from "./useForm-CKmgcynv.js";
let ie, ne, se;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    se = function(e) {
        return n.Get("/audit-category/list", e);
    };
    function _() {
        return n.Get("/audit-type/options");
    }
    function U() {
        return n.Get("/dict-data/shipCategory/options");
    }
    function W(e) {
        return n.Post("/audit-category", e);
    }
    function H(e) {
        return n.Put("/audit-category", e);
    }
    ne = function(e) {
        return n.Delete(`/audit-category/${e}`);
    };
    const { t: o } = F(), J = await _(), K = await U();
    await B(0);
    function Q() {
        const e = c(!1);
        return {
            modalSchemas: [
                {
                    field: "auditTypeNameEn",
                    component: "NSelect",
                    label: o("mdm.inspection.smsInsCategory"),
                    componentProps: {
                        options: J,
                        "label-field": "content",
                        "value-field": "content"
                    },
                    rules: [
                        {
                            required: !0,
                            message: o("common.chooseText") + " " + o("mdm.inspection.smsInsCategory"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "shipCategoryId",
                    component: "NSelect",
                    label: o("mdm.inspection.smsManCategory"),
                    componentProps: {
                        options: K,
                        "label-field": "label",
                        "value-field": "value",
                        onUpdateValue: (a)=>{
                            console.log(a);
                        }
                    },
                    rules: [
                        {
                            required: !0,
                            message: o("common.chooseText") + " " + o("mdm.inspection.smsManCategory"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "intervalTime",
                    component: "NInput",
                    label: o("mdm.inspection.smsInterval"),
                    componentProps: {}
                }
            ],
            methods: {
                updataReadOnly: (a)=>{
                    e.value = a;
                }
            }
        };
    }
    ie = L({
        __name: "Modal",
        emits: [
            "success"
        ],
        setup (e, { expose: d, emit: m }) {
            const a = m, [C, { openModal: b, closeModal: p, setSubLoading: u, setProps: R }] = j({
                title: "",
                width: 600
            }), { modalSchemas: v, methods: I } = Q(), { updataReadOnly: T } = I, [A, { submit: w, setFieldsValue: S, getFieldsValue: M }] = D({
                gridProps: {
                    cols: 1
                },
                layout: "horizontal",
                labelWidth: "auto",
                schemas: v,
                showActionButtonGroup: !1
            }), f = c(), k = c(), r = c(null);
            function x(l, s, t) {
                R({
                    title: l
                }), b(), f.value.setSubLoading(!1), s ? (r.value = s.id, $(()=>{
                    const i = s;
                    i.shipCategoryId = s.shipCategoryId + "", S(i);
                }), t && T(t)) : r.value = null;
            }
            async function N() {
                const l = await _();
                if (!await w()) return u(!1);
                let t = M(), g = l.filter((O)=>O.content.includes(t.auditTypeNameEn)), y = {
                    intervalTime: Number(t.intervalTime),
                    auditTypeId: g.length > 0 ? g[0].id : null,
                    shipCategoryId: t.shipCategoryId
                };
                r.value ? (await H({
                    id: r.value,
                    ...y
                }), u(!1), p(), a("success")) : (await W(y), u(!1), p(), a("success"));
            }
            return d({
                showModal: x
            }), (l, s)=>{
                const t = V, i = P;
                return G(), q(i, {
                    ref_key: "modalRef",
                    ref: f,
                    onRegister: h(C),
                    onOnOk: N
                }, {
                    default: z(()=>[
                            E(t, {
                                ref_key: "formRef",
                                ref: k,
                                onRegister: h(A)
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { ie as _, ne as d, se as g, __tla };
