import { V as N, c_ as E, d as M, bk as $, r as j, a4 as D, ay as L, ac as W, c as U, o as Y, w as R, j as S, l as x, W as z, X as G, aj as w, cZ as X, v as Z, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as H } from "./BasicForm-dL_oCSPM.js";
import { f as k } from "./unPlannedJob-BvCurP2n.js";
import { i as m } from "./isEmpty-BUg1OsQj.js";
import { _ as K, __tla as __tla_1 } from "./index.vue_vue_type_script_setup_true_lang-DgBCbd0g.js";
import { _ as Q, __tla as __tla_2 } from "./index.vue_vue_type_script_setup_true_lang-HM65iKHJ.js";
import { u as ee } from "./useForm-CKmgcynv.js";
import "./Render.vue_vue_type_script_lang-DKUYY0Zw.js";
import "./SingleImageUpload-CNx4b9eC.js";
import "./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";
import "./componentSetting-DVhNDBTO.js";
import "./ImageUpload-DUsnro3W.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";
import "./tabsView-BXskTdVh.js";
import "./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.js";
import "./propTypes-CebMRUpe.js";
import "./BasicSelect-C_uwzMkE.js";
import "./BasicSelect.vue_vue_type_style_index_0_scoped_772d51cc_lang-Brp6PjEU.js";
import "./dictionary-BRse4lkf.js";
import "./index-DkvzUEqh.js";
import "./index-kKnqLkWM.js";
import "./AutoComplete-Dv1Bqed4.js";
import "./TreeSelect-BZh2DeCh.js";
import "./Table-0PViRYCf.js";
import "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./componentMap-CElCaWis.js";
import "./format-DgF6KtHk.js";
import "./omit-B2_8Y6O_.js";
import "./_flatRest-DBrd2CHT.js";
import "./flatten-DeoUZLdb.js";
import "./print-CT_2hrjP.js";
import "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import "./useModal-CO65vga3.js";
import "./useTimeout-BxFilWvD.js";
import "./usePageCache-DluHn7Yy.js";
import "./Flex-CTSf12gq.js";
import "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { __tla as __tla_3 } from "./index.vue_vue_type_style_index_0_scoped_b974e5ec_lang-_0QwzFKM.js";
import "./jobOrder-CGbsc7bp.js";
import "./has-CjqcrIOV.js";
import { __tla as __tla_4 } from "./index.vue_vue_type_script_setup_true_lang-BaiGZfx5.js";
import "./schemas-BmKi-UM9.js";
import "./props-CLtNejQT.js";
import "./sparePartsStock-8NzBm-vI.js";
import { __tla as __tla_5 } from "./index.vue_vue_type_script_setup_true_lang-CiThekrH.js";
import "./materialsStock-DZo3mecL.js";
let He;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_3;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_4;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_5;
        } catch  {}
    })()
]).then(async ()=>{
    let f, v, te, F, ae;
    ({ t: f } = N());
    v = E();
    te = (c)=>{
        const { isView: A, formRef: g } = c, P = [
            {
                field: "sparePartsRequired",
                component: "NSwitch",
                label: f("unPlannedJob.unPlannedJobComp.sparePartsRequired"),
                giProps: {
                    span: 24
                },
                hidden: !0,
                componentProps: ({ formAction: p })=>{
                    const { setFieldsValue: r, getFieldsValue: u, updateSchema: n } = p, C = F(P, "spareActualConsumption");
                    return {
                        onUpdateValue: (h)=>{
                            if (!h) return v.warning({
                                title: f("common.dialogTitleWarning"),
                                content: f("unPlannedJob.compSwitchMessage"),
                                positiveText: "YES",
                                negativeText: "NO",
                                closable: !1,
                                maskClosable: !1,
                                onPositiveClick: async ()=>{
                                    const a = u();
                                    if (r({
                                        ...a,
                                        sparePartsRequired: !1,
                                        spareActualConsumption: []
                                    }), n({
                                        ...C,
                                        hidden: !0
                                    }), !m(a?.spareActualConsumption)) {
                                        const l = a?.spareActualConsumption.filter((b)=>b.id).map((b)=>b.id);
                                        m(l) || await k(l);
                                    }
                                },
                                onNegativeClick: ()=>{
                                    const a = u();
                                    r({
                                        ...a,
                                        sparePartsRequired: !0
                                    });
                                }
                            }), !1;
                            n({
                                ...C,
                                hidden: !h
                            });
                        },
                        disabled: A
                    };
                }
            },
            {
                field: "spareActualConsumption",
                giProps: {
                    span: 24
                },
                label: "",
                showLabel: !1,
                slot: "spareActualConsumptionSlot",
                hidden: !1,
                rules: [
                    {
                        required: !0,
                        validator (p, r) {
                            const { getFieldsValue: u } = g.value, { sparePartsRequired: n } = u();
                            return n && m(r) ? Promise.reject(f("common.RequireTips")) : Promise.resolve(!0);
                        }
                    }
                ]
            },
            {
                field: "materialsRequired",
                component: "NSwitch",
                giProps: {
                    span: 24
                },
                label: f("unPlannedJob.unPlannedJobComp.materialsRequired"),
                hidden: !0,
                componentProps: ({ formAction: p })=>{
                    const r = F(P, "materialsActualConsumption"), { setFieldsValue: u, getFieldsValue: n, updateSchema: C } = p;
                    return {
                        disabled: A,
                        placeholder: f("unPlannedJob.unPlannedJobComp.materialsRequired"),
                        onUpdateValue: (h)=>{
                            if (!h) return v.warning({
                                title: f("common.dialogTitleWarning"),
                                content: f("unPlannedJob.compSwitchMessage"),
                                positiveText: "YES",
                                negativeText: "NO",
                                closable: !1,
                                maskClosable: !1,
                                onPositiveClick: async ()=>{
                                    const a = n();
                                    if (u({
                                        ...a,
                                        materialsRequired: !1,
                                        materialsActualConsumption: []
                                    }), C({
                                        ...r,
                                        hidden: !0
                                    }), !m(a?.materialsActualConsumption)) {
                                        const l = a?.materialsActualConsumption.filter((b)=>b.id).map((b)=>b.id);
                                        m(l) || await k(l);
                                    }
                                },
                                onNegativeClick: ()=>{
                                    const a = n();
                                    u({
                                        ...a,
                                        materialsRequired: !0
                                    });
                                }
                            }), !1;
                            C({
                                ...r,
                                hidden: !h
                            });
                        }
                    };
                }
            },
            {
                field: "materialsActualConsumption",
                giProps: {
                    span: 24
                },
                label: "",
                showLabel: !1,
                slot: "materialsActualConsumptionSlot",
                rules: [
                    {
                        required: !0,
                        validator (p, r) {
                            const { getFieldsValue: u } = g.value, { materialsRequired: n } = u();
                            return n && m(r) ? Promise.reject(f("common.RequireTips")) : Promise.resolve(!0);
                        }
                    }
                ]
            }
        ];
        return {
            formSchemas: P
        };
    };
    F = (c, A)=>c.find((g)=>g.field === A);
    ae = M({
        __name: "index",
        props: {
            sourceData: {
                type: Object,
                default: null
            },
            isView: {
                default: !1,
                type: Boolean
            },
            tabContext: {
                default: !1,
                type: null
            }
        },
        setup (c, { expose: A }) {
            const g = $(), P = X(), p = c, r = j(), { t: u } = N(), n = D(()=>{
                const { formSchemas: o } = te({
                    isView: p.isView,
                    formRef: r
                });
                return o;
            }), C = D(()=>p.tabContext[0]), [h, { setFieldsValue: a, getFieldsValue: l, updateSchema: b, validate: T }] = ee({
                gridProps: {
                    cols: 24
                },
                schemas: n,
                layout: "horizontal",
                showActionButtonGroup: !1
            });
            function y(o) {
                const e = l();
                let t = w(e.spareActualConsumption || []);
                t.splice(o, 1), a({
                    ...e,
                    spareActualConsumption: t,
                    sparePartsRequired: !m(t)
                });
            }
            function J(o) {
                const e = l();
                let t = w(e.materialsActualConsumption || []);
                t.splice(o, 1), a({
                    ...e,
                    materialsActualConsumption: t,
                    materialsRequired: !m(t)
                });
            }
            function O(o) {
                const { mainData: e, tableData: t, isEdit: I, close: _ } = o;
                console.log("物料添加信息：mainData----------------------------------------->", e);
                const d = l();
                let i = w(d.materialsActualConsumption || []).map((s)=>({
                        ...s,
                        materialItemId: s.materialId || s.materialItemId
                    }));
                if (I && e?.materialItemId) i.forEach((s)=>{
                    s.materialItemId === e.materialItemId && (s.quantity = e.quantity, s.tableData = t, s.remarks = e.remarks);
                });
                else {
                    if (i.some((V)=>{
                        if (V.materialItemId === e.materialItemId) {
                            const q = g.getLocale === "en" ? `code: [${e.code || e.itemCode}] be in existence` : `物料编码：【${e.code || e.itemCode}】在列表中已存在`;
                            return P.warning(q), !0;
                        } else return !1;
                    })) return;
                    i.push({
                        ...e,
                        tableData: t
                    });
                }
                a({
                    ...d,
                    materialsActualConsumption: i,
                    materialsRequired: !0
                }), _();
            }
            function B(o) {
                const { mainData: e, tableData: t, isEdit: I, close: _ } = o;
                console.log("备件添加信息：mainData----------------------------------------->", e);
                const d = l();
                let i = w(d.spareActualConsumption || []);
                if (I && e?.itemId) i.forEach((s)=>{
                    s.itemId === e.itemId && (s.tableData = t, s.quantity = e.quantity, s.remarks = e.remarks);
                });
                else {
                    if (i.some((V)=>{
                        if (V.itemId === e.itemId) {
                            const q = g.getLocale === "en" ? `[${e.productName}]  be in existence` : `【${e.productName}】在列表中已存在`;
                            return P.warning(q), !0;
                        } else return !1;
                    })) return;
                    i.push({
                        ...e,
                        partNumber: e.sparePartNumber,
                        units: e.raw.uomName,
                        specification: e.raw.itemSpecification,
                        drawingNumber: e.raw.plateDrawingNumber,
                        tableData: t
                    });
                }
                a({
                    ...d,
                    spareActualConsumption: i,
                    sparePartsRequired: !0
                }), _();
            }
            return L(()=>p.sourceData?.consumption, (o)=>{
                W(()=>{
                    if (!m(o)) {
                        const e = o.partsInfo, t = o.materialInfo;
                        a({
                            sparePartsRequired: !m(e),
                            materialsRequired: !m(t),
                            spareActualConsumption: e,
                            materialsActualConsumption: t
                        });
                    }
                });
            }, {
                immediate: !0
            }), A({
                validate () {
                    return new Promise((o, e)=>{
                        T().then(()=>{
                            o(!0);
                        }).catch(()=>{
                            e("3");
                        });
                    });
                },
                getFieldsValue: l
            }), (o, e)=>{
                const t = z, I = H, _ = G;
                return Y(), U(_, null, {
                    default: R(()=>[
                            S(I, {
                                ref_key: "basicFormRef",
                                ref: r,
                                onRegister: x(h)
                            }, {
                                spareActualConsumptionSlot: R(({ model: d, field: i })=>[
                                        S(t, {
                                            bordered: !1
                                        }, {
                                            default: R(()=>[
                                                    S(K, {
                                                        disabled: c.isView,
                                                        dataSource: d[i],
                                                        onRemove: y,
                                                        onAddOk: B,
                                                        mainData: c.sourceData,
                                                        basicTabContext: x(C)
                                                    }, null, 8, [
                                                        "disabled",
                                                        "dataSource",
                                                        "mainData",
                                                        "basicTabContext"
                                                    ])
                                                ]),
                                            _: 2
                                        }, 1024)
                                    ]),
                                materialsActualConsumptionSlot: R(({ model: d, field: i })=>[
                                        S(t, {
                                            bordered: !1
                                        }, {
                                            default: R(()=>[
                                                    S(Q, {
                                                        disabled: c.isView,
                                                        dataSource: d[i],
                                                        onRemove: J,
                                                        onAddOk: O,
                                                        mainData: c.sourceData,
                                                        basicTabContext: x(C)
                                                    }, null, 8, [
                                                        "disabled",
                                                        "dataSource",
                                                        "mainData",
                                                        "basicTabContext"
                                                    ])
                                                ]),
                                            _: 2
                                        }, 1024)
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
    He = Z(ae, [
        [
            "__scopeId",
            "data-v-1e7c4a00"
        ]
    ]);
});
export { He as default, __tla };
