import { V as F, bk as mt, d as ft, f as gt, a4 as vt, r as h, a as R, Z as $, cZ as _t, gI as j, aw as yt, c as I, o as f, w as e, j as s, D as k, i as m, A as c, l as t, aI as ht, p as _, B as wt, h as z, F as L, a9 as q, W as Dt, hQ as xt, hR as It, df as kt, ae as Ct, H as bt, ef as St, X as Pt, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as At } from "./Table-0PViRYCf.js";
import { _ as zt } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { B as Bt } from "./BasicForm-dL_oCSPM.js";
import { u as Et } from "./useForm-CKmgcynv.js";
import { t as Mt, u as Nt, v as Tt, w as Rt, x as $t } from "./victualingDetail-CLhgLkA4.js";
import { I as C, __tla as __tla_1 } from "./helper-DMSByp-X.js";
import { _ as Lt, __tla as __tla_2 } from "./index.vue_vue_type_script_setup_true_lang-BuFQGrzT.js";
import { _ as Ft, __tla as __tla_3 } from "./index.vue_vue_type_script_setup_true_lang-DtpxaH0W.js";
import { f as b } from "./find-D_h_aJYR.js";
import { i as Q } from "./includes-DdMWPj0t.js";
import { _ as Vt, a as Ot } from "./CollapseItem-DQYTgHby.js";
import { _ as Ut } from "./Flex-CTSf12gq.js";
import "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./Render.vue_vue_type_script_lang-DKUYY0Zw.js";
import "./componentMap-CElCaWis.js";
import "./propTypes-CebMRUpe.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 "./componentSetting-DVhNDBTO.js";
import "./useTimeout-BxFilWvD.js";
import "./usePageCache-DluHn7Yy.js";
import "./tabsView-BXskTdVh.js";
import "./SingleImageUpload-CNx4b9eC.js";
import "./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";
import "./ImageUpload-DUsnro3W.js";
import "./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";
import "./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.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 "./requisitionOrder-D0IG9N7e.js";
import "./TableSelect.vue_vue_type_script_setup_true_lang-BAU5mgvB.js";
import "./props-CLtNejQT.js";
import "./goodsReceiptNoteDetail-DWFnSNrx.js";
import "./equipmentMainLibrary-bJTzj5mC.js";
import "./subtract-Dj32RAiL.js";
import "./_createMathOperation-C_MUc_Og.js";
import "./findIndex-BgUIH3i1.js";
import "./toInteger-DQeH-nF-.js";
let Je;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_2;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_3;
        } catch  {}
    })()
]).then(async ()=>{
    const jt = mt(), { t: u } = F(), qt = ()=>[
            {
                title: u("common.management.Num"),
                key: "num",
                width: 60,
                render: (w, i)=>i + 1
            },
            {
                title: u("victualingDetail.provisionInventory.productNameAndSpecification"),
                key: "productName",
                width: 140
            },
            {
                title: u("victualingDetail.provisionInventory.productNameAndSpecificationCn"),
                key: "productNameCn",
                width: 140
            },
            {
                title: u("victualingDetail.provisionInventory.currency"),
                key: "currency",
                width: 100,
                render: (w)=>jt.getLocale === "en" ? w.currencyNameEn : w.currencyName
            },
            {
                title: u("victualingDetail.provisionInventory.price"),
                key: "price",
                width: 100
            },
            {
                title: u("victualingDetail.provisionInventory.unit"),
                key: "unit",
                width: 80
            },
            {
                title: u("victualingDetail.provisionInventory.qtyAtMonthStart"),
                key: "beginQuantity",
                width: 150
            },
            {
                title: u("victualingDetail.provisionInventory.subtotal"),
                key: "beginTotalAmount",
                width: 100
            },
            {
                title: u("victualingDetail.provisionInventory.qtyAtMonthEnd"),
                key: "endQuantity",
                width: 160
            },
            {
                title: u("victualingDetail.provisionInventory.subtotalAtMonthEnd"),
                key: "endTotalAmount",
                width: 180
            },
            {
                title: u("victualingDetail.provisionInventory.consumption"),
                key: "consumedQuantity",
                width: 140
            },
            {
                title: u("victualingDetail.provisionInventory.subtotalConsumption"),
                key: "consumedTotalAmount",
                width: 200
            },
            {
                title: u("victualingDetail.provisionInventory.updateBy"),
                key: "updateBy",
                width: 120
            },
            {
                title: u("victualingDetail.provisionInventory.updateDate"),
                key: "updateTime",
                width: 120
            }
        ], { t: W } = F();
    function Qt({ id: w, rate: i }) {
        return [
            {
                field: "id",
                defaultValue: w,
                hidden: !0
            },
            {
                field: "rate",
                component: "NInputNumber",
                label: W("victualingDetail.provisionInventory.rate"),
                defaultValue: i,
                componentProps: {
                    min: .01,
                    step: 1,
                    precision: 2,
                    size: "small",
                    class: "w-[130px]",
                    showButton: !1,
                    placeholder: W("victualingDetail.provisionInventory.rate")
                }
            }
        ];
    }
    let Wt, Xt, Zt, Gt, Ht, Jt, Kt, Yt;
    Wt = {
        class: "text-[16px] text-gray-600"
    };
    Xt = {
        class: "text-[16px] font-medium text-[#0EC06A]"
    };
    Zt = {
        class: "text-[16px] text-gray-600"
    };
    Gt = {
        class: "text-[16px] font-medium text-[#0EC06A]"
    };
    Ht = {
        class: "text-[16px] text-gray-600"
    };
    Jt = {
        class: "text-[16px] font-medium text-[#0EC06A]"
    };
    Kt = {
        class: "text-[16px] text-gray-600"
    };
    Yt = {
        class: "text-[16px] font-medium text-[#0EC06A]"
    };
    Je = ft({
        __name: "index",
        setup (w) {
            const { t: i } = F(), V = gt(), B = _t(), y = vt(()=>V.query?.type !== "edit"), E = h(null), M = h(null), O = h(0), d = R({
                page: 1,
                pageSize: 10,
                itemCount: 0
            }), N = h(!1), S = h([]), X = R({
                totalPrice: {
                    title: i("victualingDetail.summary.totalPrice"),
                    field: "beginTotalAmount"
                },
                totalPriceUSD: {
                    title: i("victualingDetail.summary.totalPriceUSD"),
                    field: "beginTotalAmountUSD"
                },
                totalPriceAtMonthEnd: {
                    title: i("victualingDetail.summary.totalPriceAtMonthEnd"),
                    field: "endTotalAmount"
                },
                totalPriceAtMonthEndUSD: {
                    title: i("victualingDetail.summary.totalPriceAtMonthEndUSD"),
                    field: "endTotalAmountUSD"
                }
            }), P = h({}), A = h({}), Z = R({
                width: 140,
                title: i("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (n) {
                    const { isLastMonthBalance: o } = b(S.value, (a)=>b(a.detailList, (r)=>r.id === n.id));
                    return $(zt, {
                        style: "text",
                        actions: [
                            {
                                label: i("common.optionsEditText"),
                                labelShow: !1,
                                ifShow: !y.value && !0,
                                icon: $("i", {
                                    class: "iconfont icon-a-Frame28"
                                }),
                                onClick: Y.bind(null, n)
                            },
                            {
                                label: i("common.delText"),
                                labelShow: !1,
                                ifShow: !y.value && !0 && o !== 1,
                                icon: $("i", {
                                    class: "iconfont icon-Delete red"
                                }),
                                onPositiveClick: tt.bind(null, n),
                                isConfirm: !0,
                                confirmContent: i("common.delPop.contRole")
                            }
                        ]
                    });
                }
            });
            function G() {
                E.value?.handleOpenModal();
            }
            function H(n) {
                E.value?.handleOpenModal({
                    type: "edit",
                    record: n
                });
            }
            function J({ id: n }) {
                Nt(n).then(()=>{
                    B.success(i("common.optionsDelSuccessText")), g(!1);
                });
            }
            function K(n) {
                M.value?.handleOpenModal({
                    type: "add",
                    record: n
                });
            }
            function Y(n) {
                const o = b(S.value, (a)=>b(a.detailList, (r)=>r.id === n.id));
                M.value?.handleOpenModal({
                    type: "edit",
                    record: o,
                    item: n
                });
            }
            function tt({ id: n }) {
                Mt(n).then(()=>{
                    B.success(i("common.optionsDelSuccessText")), g(!1);
                });
            }
            async function et(n) {
                const [o, { submit: a, setFieldsValue: r }] = b(P.value, (D, x)=>x === n + ""), p = await a();
                p && Tt({
                    ...p
                }).then(()=>{
                    B.success(i("common.optionsEditSuccessText")), r({
                        rate: p.rate
                    }), g(!1);
                });
            }
            function U() {
                const { shipId: n, year: o, month: a, startDate: r, endDate: p } = V.query;
                return {
                    shipId: n,
                    year: o,
                    month: a,
                    startDate: r,
                    endDate: p
                };
            }
            async function nt(n) {
                await Rt(n).then((o)=>{
                    O.value = o.endTotalAmount ?? 0;
                });
            }
            async function ot({ page: n, pageSize: o }, a) {
                try {
                    return await $t({
                        pageNum: n,
                        pageSize: o,
                        ...a
                    });
                } catch  {
                    return {
                        total: 0,
                        list: []
                    };
                }
            }
            function it(n) {
                d.page = n, g(!1);
            }
            function at(n) {
                d.pageSize = n, g(!1);
            }
            async function g(n = !0) {
                n && (d.page = 1, d.pageSize = 10);
                const { page: o, pageSize: a } = d;
                try {
                    N.value = !0, await nt(U());
                    const { list: r, total: p } = await ot({
                        page: o,
                        pageSize: a
                    }, U());
                    S.value = r ?? [], d.itemCount = p ?? 0, j(r, ({ id: D, rate: x })=>{
                        const T = j(P.value, "id");
                        Q(T, D) || (P.value[D] = Et({
                            gridProps: {
                                cols: 1
                            },
                            labelPlacement: "left",
                            labelWidth: "60",
                            schemas: Qt({
                                id: D,
                                rate: x ? +x : null
                            }),
                            showAdvancedButton: !1
                        }));
                    });
                } catch (r) {
                    console.error(r);
                } finally{
                    N.value = !1;
                }
            }
            function st(n) {
                const { id: o, rate: a } = n;
                if (Q([
                    "[object Undefined]",
                    "[object Null]"
                ], Object.prototype.toString.call(a)) || a === "") {
                    A.value[o] = !0;
                    return;
                }
                if (isNaN(a) || +a <= 0) {
                    A.value[o] = !0;
                    return;
                }
                A.value[o] = !1;
            }
            return yt(()=>{
                g();
            }), (n, o)=>{
                const a = Ut, r = wt, p = ht, D = Ct, x = kt, T = Dt, rt = Ot, lt = Vt, ct = St, ut = bt, pt = Pt;
                return f(), I(pt, {
                    loading: t(N)
                }, {
                    default: e(()=>[
                            s(a, {
                                align: "center",
                                justify: "space-between",
                                class: "mb-4"
                            }, {
                                default: e(()=>[
                                        s(a, {
                                            align: "center"
                                        }, {
                                            default: e(()=>[
                                                    m("span", Wt, c(t(i)("victualingDetail.provisionInventory.totalPriceAtMonthEnd")) + ": ", 1),
                                                    m("span", Xt, c(t(O)), 1)
                                                ]),
                                            _: 1
                                        }),
                                        !t(y) && !t(C) ? (f(), I(p, {
                                            key: 0,
                                            trigger: "hover"
                                        }, {
                                            trigger: e(()=>[
                                                    s(r, {
                                                        type: "primary",
                                                        strong: "",
                                                        bordered: "",
                                                        secondary: "",
                                                        class: "size-7",
                                                        onClick: G
                                                    }, {
                                                        icon: e(()=>o[2] || (o[2] = [
                                                                m("i", {
                                                                    class: "iconfont icon-ADD"
                                                                }, null, -1)
                                                            ])),
                                                        _: 1
                                                    })
                                                ]),
                                            default: e(()=>[
                                                    _(" " + c(t(i)("victualingDetail.provisionInventory.addBtn")), 1)
                                                ]),
                                            _: 1
                                        })) : k("", !0)
                                    ]),
                                _: 1
                            }),
                            s(lt, {
                                "trigger-areas": [
                                    "arrow"
                                ]
                            }, {
                                default: e(()=>[
                                        (f(!0), z(L, null, q(t(S), (l)=>(f(), I(rt, {
                                                name: l,
                                                key: l.id
                                            }, {
                                                header: e(()=>[
                                                        s(a, {
                                                            class: "w-[60%] pl-8 select-none",
                                                            align: "center"
                                                        }, {
                                                            default: e(()=>[
                                                                    s(a, {
                                                                        class: "w-[40%]"
                                                                    }, {
                                                                        default: e(()=>[
                                                                                m("span", Zt, c(t(i)("victualingDetail.provisionInventory.purchasePort")), 1),
                                                                                m("span", Gt, c(l.portName), 1)
                                                                            ]),
                                                                        _: 2
                                                                    }, 1024),
                                                                    s(a, {
                                                                        class: "w-[36%]"
                                                                    }, {
                                                                        default: e(()=>[
                                                                                m("span", Ht, c(t(i)("victualingDetail.provisionInventory.purchaseDate")), 1),
                                                                                m("span", Jt, c(l.purchaseDate), 1)
                                                                            ]),
                                                                        _: 2
                                                                    }, 1024),
                                                                    s(a, {
                                                                        class: "w-[14%]"
                                                                    }, {
                                                                        default: e(()=>[
                                                                                l.isLastMonthBalance === 0 ? (f(), I(D, {
                                                                                    key: 0,
                                                                                    type: "warning",
                                                                                    size: "small",
                                                                                    class: "text-[14px]"
                                                                                }, {
                                                                                    default: e(()=>[
                                                                                            _(c(t(i)("victualingDetail.provisionInventory.newProvision")), 1)
                                                                                        ]),
                                                                                    _: 1
                                                                                })) : k("", !0)
                                                                            ]),
                                                                        _: 2
                                                                    }, 1024)
                                                                ]),
                                                            _: 2
                                                        }, 1024)
                                                    ]),
                                                "header-extra": e(()=>[
                                                        t(y) ? k("", !0) : (f(), I(a, {
                                                            key: 0,
                                                            class: "w-[110px]"
                                                        }, {
                                                            default: e(()=>[
                                                                    !t(C) && l.isLastMonthBalance === 0 ? (f(), z(L, {
                                                                        key: 0
                                                                    }, [
                                                                        s(p, {
                                                                            trigger: "hover"
                                                                        }, {
                                                                            trigger: e(()=>[
                                                                                    s(r, {
                                                                                        type: "primary",
                                                                                        strong: "",
                                                                                        bordered: "",
                                                                                        secondary: "",
                                                                                        circle: "",
                                                                                        class: "size-7",
                                                                                        onClick: (v)=>K(l)
                                                                                    }, {
                                                                                        icon: e(()=>[
                                                                                                s(t(It))
                                                                                            ]),
                                                                                        _: 2
                                                                                    }, 1032, [
                                                                                        "onClick"
                                                                                    ])
                                                                                ]),
                                                                            default: e(()=>[
                                                                                    _(" " + c(t(i)("victualingDetail.provisionInventory.addItem")), 1)
                                                                                ]),
                                                                            _: 2
                                                                        }, 1024),
                                                                        s(p, {
                                                                            trigger: "hover"
                                                                        }, {
                                                                            trigger: e(()=>[
                                                                                    s(r, {
                                                                                        type: "info",
                                                                                        strong: "",
                                                                                        bordered: "",
                                                                                        secondary: "",
                                                                                        circle: "",
                                                                                        class: "size-7",
                                                                                        onClick: (v)=>H(l)
                                                                                    }, {
                                                                                        icon: e(()=>o[3] || (o[3] = [
                                                                                                m("i", {
                                                                                                    class: "iconfont icon-a-Frame28"
                                                                                                }, null, -1)
                                                                                            ])),
                                                                                        _: 2
                                                                                    }, 1032, [
                                                                                        "onClick"
                                                                                    ])
                                                                                ]),
                                                                            default: e(()=>[
                                                                                    _(" " + c(t(i)("victualingDetail.provisionInventory.editInventory")), 1)
                                                                                ]),
                                                                            _: 2
                                                                        }, 1024),
                                                                        s(x, {
                                                                            onPositiveClick: (v)=>J(l)
                                                                        }, {
                                                                            trigger: e(()=>[
                                                                                    s(p, {
                                                                                        trigger: "hover"
                                                                                    }, {
                                                                                        trigger: e(()=>[
                                                                                                s(r, {
                                                                                                    type: "error",
                                                                                                    strong: "",
                                                                                                    bordered: "",
                                                                                                    secondary: "",
                                                                                                    circle: "",
                                                                                                    class: "size-7"
                                                                                                }, {
                                                                                                    icon: e(()=>o[4] || (o[4] = [
                                                                                                            m("i", {
                                                                                                                class: "iconfont icon-Delete"
                                                                                                            }, null, -1)
                                                                                                        ])),
                                                                                                    _: 1
                                                                                                })
                                                                                            ]),
                                                                                        default: e(()=>[
                                                                                                _(" " + c(t(i)("victualingDetail.provisionInventory.deleteInventory")), 1)
                                                                                            ]),
                                                                                        _: 1
                                                                                    })
                                                                                ]),
                                                                            default: e(()=>[
                                                                                    _(" " + c(t(i)("victualingDetail.provisionInventory.deleteInventoryPopConfirm")), 1)
                                                                                ]),
                                                                            _: 2
                                                                        }, 1032, [
                                                                            "onPositiveClick"
                                                                        ])
                                                                    ], 64)) : k("", !0)
                                                                ]),
                                                            _: 2
                                                        }, 1024))
                                                    ]),
                                                default: e(()=>[
                                                        s(T, {
                                                            bordered: !0,
                                                            class: "proCard",
                                                            "content-class": "p-0"
                                                        }, {
                                                            default: e(()=>[
                                                                    s(t(At), {
                                                                        columns: t(qt)(),
                                                                        "row-key": (v)=>v.id,
                                                                        dataSource: l.detailList,
                                                                        actionColumn: t(y) || t(C) ? void 0 : t(Z),
                                                                        showTableSetting: !1,
                                                                        pagination: !1,
                                                                        autoScrollX: !0,
                                                                        canResize: !1,
                                                                        "virtual-scroll": ""
                                                                    }, null, 8, [
                                                                        "columns",
                                                                        "row-key",
                                                                        "dataSource",
                                                                        "actionColumn"
                                                                    ]),
                                                                    s(a, {
                                                                        align: "flex-end",
                                                                        class: "mt-2 p-4"
                                                                    }, {
                                                                        default: e(()=>[
                                                                                s(t(Bt), {
                                                                                    onRegister: t(P)[l.id][0],
                                                                                    showActionButtonGroup: !1,
                                                                                    "show-feedback": !1,
                                                                                    onChange: st,
                                                                                    disabled: t(y) || t(C)
                                                                                }, null, 8, [
                                                                                    "onRegister",
                                                                                    "disabled"
                                                                                ]),
                                                                                !t(y) && !t(C) ? (f(), I(r, {
                                                                                    key: 0,
                                                                                    strong: "",
                                                                                    bordered: "",
                                                                                    secondary: "",
                                                                                    type: "primary",
                                                                                    class: "size-7 mb-1",
                                                                                    onClick: (v)=>et(l.id),
                                                                                    disabled: t(A)[l.id] === !0
                                                                                }, {
                                                                                    icon: e(()=>[
                                                                                            s(t(xt))
                                                                                        ]),
                                                                                    _: 2
                                                                                }, 1032, [
                                                                                    "onClick",
                                                                                    "disabled"
                                                                                ])) : k("", !0),
                                                                                (f(!0), z(L, null, q(t(X), (v, dt)=>(f(), z("div", {
                                                                                        key: dt,
                                                                                        class: "h-[32px] text-[16px] flex-1 ml-8"
                                                                                    }, [
                                                                                        m("span", Kt, c(v.title) + ": ", 1),
                                                                                        m("span", Yt, c(l[v.field]), 1)
                                                                                    ]))), 128))
                                                                            ]),
                                                                        _: 2
                                                                    }, 1024)
                                                                ]),
                                                            _: 2
                                                        }, 1024)
                                                    ]),
                                                _: 2
                                            }, 1032, [
                                                "name"
                                            ]))), 128))
                                    ]),
                                _: 1
                            }),
                            s(ut, {
                                justify: "end",
                                class: "mt-3"
                            }, {
                                default: e(()=>[
                                        s(ct, {
                                            page: t(d).page,
                                            "onUpdate:page": [
                                                o[0] || (o[0] = (l)=>t(d).page = l),
                                                it
                                            ],
                                            "page-size": t(d).pageSize,
                                            "onUpdate:pageSize": [
                                                o[1] || (o[1] = (l)=>t(d).pageSize = l),
                                                at
                                            ],
                                            "show-size-picker": "",
                                            "page-sizes": [
                                                10,
                                                20,
                                                30,
                                                40,
                                                50,
                                                60,
                                                70,
                                                80
                                            ],
                                            "item-count": t(d).itemCount,
                                            "show-quick-jumper": ""
                                        }, {
                                            prefix: e(({ itemCount: l })=>[
                                                    _(c(`${t(i)("common.total")} ${l} `), 1)
                                                ]),
                                            goto: e(()=>[
                                                    _(c(`${t(i)("common.goto")}`), 1)
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "page",
                                            "page-size",
                                            "item-count"
                                        ])
                                    ]),
                                _: 1
                            }),
                            s(Lt, {
                                ref_key: "newProvisionInventoryRef",
                                ref: E,
                                onRefresh: g
                            }, null, 512),
                            s(Ft, {
                                ref_key: "newProvisionItemRef",
                                ref: M,
                                onRefresh: g
                            }, null, 512)
                        ]),
                    _: 1
                }, 8, [
                    "loading"
                ]);
            };
        }
    });
});
export { Je as default, __tla };
