import { d as y, V as P, r as _, c as F, o as B, X as N, w as h, j as g, l as b, ds as x, c$ as R, a4 as D, aw as C, ay as L, ac as T, aa as k, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as I } from "./BasicForm-dL_oCSPM.js";
import { a as q, __tla as __tla_1 } from "./schemas-C5Mwn7qw.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { u as O } from "./useForm-CKmgcynv.js";
import { __tla as __tla_2 } from "./index.vue_vue_type_style_index_0_scoped_b974e5ec_lang-_0QwzFKM.js";
import "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./print-CT_2hrjP.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./schemas-BmKi-UM9.js";
import { e as j } from "./template-rpthWlT9.js";
import { _ as U } from "./TableSelect.vue_vue_type_script_setup_true_lang-BAU5mgvB.js";
import { g as W } from "./unPlannedJob-BvCurP2n.js";
let te;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })()
]).then(async ()=>{
    let A;
    A = y({
        __name: "index",
        props: {
            value: {
                required: !0,
                default: void 0,
                type: String
            },
            disabled: {
                default: !1,
                type: Boolean
            },
            labelField: {
                default: "defectNo",
                type: String
            },
            valueField: {
                default: "defectNo",
                type: String
            },
            multiple: {
                default: !1,
                type: Boolean
            }
        },
        emits: [
            "update:value",
            "change"
        ],
        setup (o, { emit: m }) {
            const { t } = P(), s = _(), r = o, l = m, d = {
                gridProps: {
                    cols: "2"
                },
                labelWidth: 80,
                submitButtonText: t("common.searchText"),
                showAdvancedButton: !1,
                schemas: [
                    {
                        field: "equipmentName",
                        component: "NInput",
                        label: t("pms.defectList.equipmentName")
                    },
                    {
                        field: "title",
                        component: "NInput",
                        label: t("pms.defectList.defectTitle"),
                        componentProps: {}
                    }
                ]
            }, n = [
                {
                    title: t("common.messagedefine.Num"),
                    key: "num",
                    width: 60,
                    render: (e, a)=>a + 1
                },
                {
                    title: t("pms.defectList.defectNo"),
                    key: "defectNo",
                    width: 140
                },
                {
                    title: t("pms.defectList.defectTitle"),
                    key: "title",
                    width: 140
                },
                {
                    title: t("pms.defectList.equipmentName"),
                    key: "equipmentName",
                    width: 140
                }
            ];
            async function u(e) {
                try {
                    return await W({
                        ...e,
                        ...s.value
                    });
                } catch  {
                    return {
                        list: [],
                        total: 0
                    };
                }
            }
            function v(e) {
                l("update:value", e ? e[r.labelField] : ""), l("change", e);
            }
            function p() {
                l("update:value", ""), l("change", "");
            }
            return (e, a)=>{
                const c = U, f = N;
                return B(), F(f, null, {
                    default: h(()=>[
                            g(c, {
                                labelField: o.labelField,
                                valueField: o.valueField,
                                value: o.value,
                                multiple: o.multiple,
                                disabled: o.disabled,
                                formProps: d,
                                formValues: b(s),
                                "onUpdate:formValues": a[0] || (a[0] = (i)=>x(s) ? s.value = i : null),
                                onChange: v,
                                tableProps: {
                                    rowKey: (i)=>i.id,
                                    request: u,
                                    columns: n,
                                    pagination: {
                                        simple: !0
                                    }
                                },
                                class: "w-full",
                                onClear: p
                            }, null, 8, [
                                "labelField",
                                "valueField",
                                "value",
                                "multiple",
                                "disabled",
                                "formValues",
                                "tableProps"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
    te = y({
        __name: "index",
        props: {
            sourceData: {
                default: null,
                type: Object
            },
            isView: {
                default: !1,
                type: Boolean
            },
            isDefect: {
                default: !1,
                type: Boolean
            }
        },
        setup (o, { expose: m }) {
            const t = o, s = R(), r = _(), l = D(()=>{
                const { formSchemas: e } = q({
                    isView: t.isView,
                    isDefect: t.isDefect,
                    jobReportedByOptions: r
                });
                return e;
            }), [d, n] = O({
                gridProps: {
                    cols: 5
                },
                layout: "horizontal",
                schemas: l,
                showActionButtonGroup: !1,
                validateOnMount: !1
            }), { setFieldsValue: u, setSchema: v } = n;
            function p() {}
            return m({
                validate () {
                    return new Promise((e, a)=>{
                        n.validate().then(()=>{
                            e(!0);
                        }).catch(()=>{
                            a("1");
                        });
                    });
                },
                getFieldsValue: n.getFieldsValue,
                setFieldsValue: u
            }), C(async ()=>{
                if (r.value = await j({
                    roleType: 2
                }), !t.isView) {
                    const e = new Date().toISOString().slice(0, 10), a = r.value.filter((c)=>c.code === s.getRoles[0])[0];
                    n.setFieldsValue({
                        jobReportedDate: e,
                        jobReportedBy: a.id
                    });
                }
            }), L(()=>t.sourceData, (e)=>{
                T(()=>{
                    u({
                        shipId: e?.shipId || s.shipList[0]?.id,
                        ...e?.basic
                    });
                });
            }, {
                immediate: !0
            }), (e, a)=>{
                const c = I, f = N;
                return B(), F(f, null, {
                    default: h(()=>[
                            g(c, {
                                ref: "formRef",
                                onRegister: b(d),
                                onChange: p
                            }, {
                                incidentNumberSlotName: h(({ model: i, field: w, schema: S })=>[
                                        g(b(A), k({
                                            value: i[w],
                                            "onUpdate:value": (V)=>i[w] = V
                                        }, S.componentProps), null, 16, [
                                            "value",
                                            "onUpdate:value"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { te as _, __tla };
