import { d as x, r as _, aw as R, ay as l, c, o as m, w as p, j as k, l as d, i as E, X as V, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as b } from "./BasicForm-dL_oCSPM.js";
import { c as A, __tla as __tla_1 } from "./NewSparePartsModal.vue_vue_type_script_setup_true_lang-B9o2yLPr.js";
import { _ as G, __tla as __tla_2 } from "./SparePartsRequiredController.vue_vue_type_script_setup_true_lang-DDxJK7Vg.js";
import N from "./AttachmentController-1vuzH_dH.js";
import { u as j } from "./useForm-CKmgcynv.js";
let $;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })()
]).then(async ()=>{
    $ = x({
        __name: "index",
        props: {
            defectDetail: {},
            sparePartsList: {},
            id: {},
            type: {},
            canEdit: {}
        },
        emits: [
            "getSparePartsList"
        ],
        setup (h, { expose: g, emit: y }) {
            const P = y, s = _(), { formSchemas: v, getSchema: L, methods: S } = A(), { updataReadOnly: o } = S, e = h, [w, { setFieldsValue: r, submit: q }] = j({
                gridProps: {
                    cols: 24,
                    yGap: 20
                },
                schemas: v,
                layout: "horizontal",
                showActionButtonGroup: !1
            }), i = _(e.sparePartsList || []);
            function C(t) {
                i.value = t, P("getSparePartsList");
            }
            R(()=>{
                e.defectDetail && r(e.defectDetail), e.type === "view" ? o(!0) : o(!1);
            }), l(()=>e.defectDetail, (t)=>{
                t && r(t);
            }, {
                immediate: !0
            }), l(()=>e.sparePartsList, (t)=>{
                i.value = t || [];
            }, {
                immediate: !0
            }), l(()=>e.type, (t)=>{
                o(t === "view");
            }, {
                immediate: !0
            });
            const u = function(t, f) {
                r({
                    [t.field]: f
                });
            };
            async function D() {
                return await s.value?.validate(), s.value?.getFieldsValue();
            }
            return g({
                getFormData: D
            }), (t, f)=>{
                const B = b, F = V;
                return m(), c(F, null, {
                    default: p(()=>[
                            k(B, {
                                ref_key: "formRef",
                                ref: s,
                                onRegister: d(w),
                                class: "mb-[8px]"
                            }, {
                                sparePartsRequiredSlot: p((a)=>[
                                        E("div", null, [
                                            (m(), c(G, {
                                                key: a.field,
                                                defectDetail: e.defectDetail,
                                                options: d(L)(a.field)?.componentProps?.options,
                                                value: a.value,
                                                sparePartsList: d(i),
                                                onChange: (n)=>u(a, n),
                                                "onUpdate:sparePartsList": C,
                                                id: e.id,
                                                canEdit: e.canEdit,
                                                type: e.type
                                            }, null, 8, [
                                                "defectDetail",
                                                "options",
                                                "value",
                                                "sparePartsList",
                                                "onChange",
                                                "id",
                                                "canEdit",
                                                "type"
                                            ]))
                                        ])
                                    ]),
                                attachmentsSlot: p((a)=>[
                                        (m(), c(N, {
                                            key: a.field,
                                            value: a.value,
                                            onChange: (n)=>u(a, n)
                                        }, null, 8, [
                                            "value",
                                            "onChange"
                                        ]))
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { $ as _, __tla };
