import { r as n, V as _, hc as M, bk as B, d as L, c$ as O, aw as A, ay as N, c as V, o as z, w as F, j as y, l as s, aA as U, aD as W, X as $, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as G } from "./BasicForm-dL_oCSPM.js";
import { a as H } from "./vesselEquipmentDetails-CJeqdW1Z.js";
import { u as j } from "./useForm-CKmgcynv.js";
let ae;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const K = await M(), Q = B(), { t: e } = _();
    function X() {
        const o = n(!1);
        return {
            formSchemas: [
                {
                    field: "shipId",
                    component: "NSelect",
                    label: e("defectFormPage.basicDetailTab.vesselName"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        options: K,
                        disabled: o,
                        filterable: !0,
                        clearable: !1,
                        "label-field": Q.getLocale === "en" ? "shipNameEn" : "shipName",
                        "value-field": "id"
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (i, a)=>a != null,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "sectionName",
                    component: "BasicSelect",
                    label: e("defectFormPage.basicDetailTab.sectionName"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        disabled: o,
                        cacheKey: "vessel_department",
                        optionType: "number",
                        block: !0
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (i, a)=>a != null,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "level",
                    component: "BasicSelect",
                    label: e("defectFormPage.basicDetailTab.defectPriority"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        block: !0,
                        disabled: o,
                        options: [
                            {
                                value: 1,
                                label: "紧急",
                                labelEn: "Urgent"
                            },
                            {
                                value: 2,
                                label: "警告",
                                labelEn: "Warning"
                            },
                            {
                                value: 3,
                                label: "正常",
                                labelEn: "Normal"
                            }
                        ]
                    },
                    rules: [
                        {
                            required: !0,
                            validator: (i, a)=>a != null,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "issueDate",
                    component: "NDatePicker",
                    label: e("defectFormPage.basicDetailTab.defectIssued"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        placeholder: e("defectFormPage.basicDetailTab.defectIssued"),
                        valueFormat: "yyyy-MM-dd",
                        disabled: o
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "category",
                    component: "BasicSelect",
                    label: e("defectFormPage.basicDetailTab.department"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        block: !0,
                        placeholder: e("defectFormPage.basicDetailTab.department"),
                        disabled: o,
                        options: [
                            {
                                value: 1,
                                label: "船身",
                                labelEn: "HULL"
                            },
                            {
                                value: 2,
                                label: "机器",
                                labelEn: "MACHINERY"
                            },
                            {
                                value: 3,
                                label: "电的",
                                labelEn: "ELECTRIC"
                            },
                            {
                                value: 4,
                                label: "航行",
                                labelEn: "NAVIGATION"
                            }
                        ]
                    }
                },
                {
                    field: "equipmentCode",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.equipmentCode"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        placeholder: e("common.chooseText"),
                        disabled: !0
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "equipmentName",
                    label: e("defectFormPage.basicDetailTab.equipmentName"),
                    giProps: {
                        span: 1
                    },
                    slot: "equipmentCodeSlotName",
                    componentProps: {
                        placeholder: e("common.chooseText"),
                        disabled: o
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "equipmentMaker",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.maker"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        placeholder: e("defectFormPage.basicDetailTab.maker"),
                        disabled: !0
                    }
                },
                {
                    field: "equipmentModel",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.modelType"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        placeholder: e("defectFormPage.basicDetailTab.modelType"),
                        disabled: !0
                    }
                },
                {
                    field: "equipmentSerial",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.serialNo"),
                    giProps: {
                        span: 1
                    },
                    componentProps: {
                        placeholder: e("defectFormPage.basicDetailTab.serialNo"),
                        disabled: !0
                    }
                },
                {
                    field: "title",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.defectReportTitle"),
                    giProps: {
                        span: 3
                    },
                    componentProps: {
                        placeholder: e("defectFormPage.basicDetailTab.defectReportTitle"),
                        type: "textarea",
                        disabled: o,
                        maxlength: 1e3
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "description",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.defectDescription"),
                    giProps: {
                        span: 5
                    },
                    componentProps: {
                        type: "textarea",
                        disabled: o,
                        maxlength: 1e3
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "consequence",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.possibleConsequences"),
                    giProps: {
                        span: 5
                    },
                    componentProps: {
                        type: "textarea",
                        disabled: o,
                        maxlength: 1e3
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "rootCause",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.rootCause"),
                    giProps: {
                        span: 5
                    },
                    componentProps: {
                        disabled: o,
                        maxlength: 1e3
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                },
                {
                    field: "correctAction",
                    component: "NInput",
                    label: e("defectFormPage.basicDetailTab.correctiveActionsCarriedOut"),
                    giProps: {
                        span: 5
                    },
                    componentProps: {
                        type: "textarea",
                        disabled: o,
                        maxlength: 1e3
                    },
                    rules: [
                        {
                            required: !0,
                            message: e("common.RequireTips"),
                            trigger: [
                                "blur",
                                "change"
                            ]
                        }
                    ]
                }
            ],
            methods: {
                updataReadOnly: (i)=>{
                    o.value = i;
                }
            }
        };
    }
    ae = L({
        __name: "index",
        props: {
            defectDetail: {},
            type: {}
        },
        emits: [
            "updateDefectDetail"
        ],
        setup (o, { expose: P, emit: q }) {
            const i = q, a = o, { t: R } = _(), { formSchemas: S, methods: I } = X(), { updataReadOnly: p } = I, D = n(), x = O(), c = n(), d = n(!1), u = n(!1), [C, { submit: k, setFieldsValue: b }] = j({
                gridProps: {
                    cols: 5
                },
                layout: "horizontal",
                schemas: S,
                showActionButtonGroup: !1
            });
            A(()=>{
                if (a.defectDetail) {
                    const l = a.defectDetail.model && a.defectDetail.model.includes("default") ? void 0 : a.defectDetail.model, t = a.defectDetail.serialNumber && a.defectDetail.serialNumber.includes("default") ? void 0 : a.defectDetail.serialNumber, r = {
                        ...a.defectDetail,
                        equipmentModel: l,
                        equipmentSerial: t
                    };
                    b(r);
                }
                a.type === "view" ? p(!0) : p(!1);
            }), N(()=>a.defectDetail, (l)=>{
                l && b(l);
            }, {
                immediate: !0
            }), N(()=>a.type, (l)=>{
                p(l === "view");
            }, {
                immediate: !0
            });
            const g = W(async (l)=>{
                if (!l) {
                    c.value = [], u.value = !1;
                    return;
                }
                d.value = !0, u.value = !0;
                try {
                    const t = await H({
                        shipId: x.shipList[0]?.id,
                        productName: l
                    });
                    c.value = t.map((r)=>({
                            ...r,
                            key: r.productCode + (r.model || "") + (r.serialNumber || "")
                        })), d.value = !1;
                } catch  {
                    c.value = [], d.value = !1;
                }
            }, 800);
            function w(l, t) {
                console.log(l, t);
                const r = t.model && t.model.includes("default") ? void 0 : t.model, f = t.serialNumber && t.serialNumber.includes("default") ? void 0 : t.serialNumber, m = {
                    equipmentName: t.productName,
                    equipmentCode: t.productCode,
                    equipmentMaker: t.maker,
                    equipmentModel: r,
                    equipmentSerial: f
                };
                b(m), u.value = !1, i("updateDefectDetail", m);
            }
            async function E() {
                return await k(), D.value?.getFieldsValue();
            }
            return P({
                getFormData: E
            }), (l, t)=>{
                const r = U, f = G, m = $;
                return z(), V(m, null, {
                    default: F(()=>[
                            y(f, {
                                ref_key: "formRef",
                                ref: D,
                                onRegister: s(C)
                            }, {
                                equipmentCodeSlotName: F(({ model: T, field: v })=>[
                                        y(r, {
                                            value: T[v],
                                            "onUpdate:value": [
                                                (h)=>T[v] = h,
                                                w
                                            ],
                                            filterable: "",
                                            options: s(c),
                                            disabled: a.type === "view",
                                            loading: s(d),
                                            placeholder: s(R)("equipmentLibrary.equipmentMainLibrary.treeSearchPlaceholder"),
                                            labelField: "productName",
                                            valueField: "key",
                                            clearable: "",
                                            remote: "",
                                            show: s(u),
                                            onBlur: t[0] || (t[0] = (h)=>s(g)("")),
                                            onClear: t[1] || (t[1] = (h)=>s(g)("")),
                                            onSearch: s(g),
                                            class: "mb-[5px]"
                                        }, null, 8, [
                                            "value",
                                            "onUpdate:value",
                                            "options",
                                            "disabled",
                                            "loading",
                                            "placeholder",
                                            "show",
                                            "onSearch"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { ae as _, __tla };
