import { _ as D } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { d as E, V as P, r as c, a4 as g, c as f, o as _, w as p, i as s, D as C, j as h, eB as V, l as e, p as v, A as l, gR as z, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as H } from "./Table-0PViRYCf.js";
import { c as X, __tla as __tla_1 } from "./columns-tUQK1rQL.js";
import { u as $ } from "./useModal-CO65vga3.js";
import { h as b } from "./has-CjqcrIOV.js";
import { _ as q, a as G } from "./CollapseItem-DQYTgHby.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 "./componentSetting-DVhNDBTO.js";
import "./useTimeout-BxFilWvD.js";
import "./usePageCache-DluHn7Yy.js";
import "./tabsView-BXskTdVh.js";
import "./Flex-CTSf12gq.js";
import "./dictUtils-D8jA3mBt.js";
let xe;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    let J, K, Q, U;
    J = {
        class: "flex flex-row align-center"
    };
    K = {
        class: "text-green-500 text-[16px]"
    };
    Q = {
        class: "text-red-500 text-[16px]"
    };
    U = {
        class: "text-[16px]"
    };
    xe = E({
        __name: "Modal",
        emits: [
            "reloadTable"
        ],
        setup (W, { expose: w, emit: x }) {
            const y = x, { t: n } = P(), { columns: I } = X(), [M, { openModal: R, setProps: j }] = $({
                title: n("jobOrderList.batchApprove"),
                preset: "dialog",
                displayDirective: "if",
                closeOnEsc: !1,
                width: 650
            }), i = c(), d = c(!1), u = c(1), m = c(10), o = c({
                successCount: 0,
                failCount: 0,
                failedItems: [],
                totalCount: 0,
                currentCount: 0
            }), B = g(()=>{
                const t = (u.value - 1) * m.value, a = t + m.value;
                return o.value.failedItems.slice(t, a);
            }), O = g(()=>o.value.currentCount / o.value.totalCount * 100);
            function S(t) {
                console.log(t), u.value = t;
            }
            function T(t) {
                m.value = t, u.value = 1, console.log(t);
            }
            async function F(t) {
                if (console.log(t), !!t) {
                    L(), i.value = t, R();
                    try {
                        if (i.value && i.value.length === 0) return;
                        o.value.totalCount = i.value.length;
                        for (const a of i.value)try {
                            if (!b(a, "id")) throw new Error(n("common.missingFields") + "id");
                            if (!b(a, "moduleCode")) throw new Error(n("common.missingFields") + "moduleCode");
                            const r = {
                                busId: a.busId,
                                moduleCode: a.moduleCode,
                                shipId: a.shipId,
                                subModuleCode: a.subModuleCode,
                                comment: "pass"
                            };
                            await z(r), o.value.successCount++;
                        } catch (r) {
                            console.log("审批失败", r), o.value.failCount++, o.value.failedItems.push({
                                ...a,
                                errorMessage: r || n("jobOrderList.unknownError")
                            });
                        } finally{
                            o.value.currentCount++;
                        }
                    } finally{
                        console.log(o.value), d.value = !0, y("reloadTable");
                    }
                }
            }
            function L() {
                u.value = 1, m.value = 10, o.value = {
                    successCount: 0,
                    failCount: 0,
                    failedItems: [],
                    totalCount: 0,
                    currentCount: 0
                };
            }
            return w({
                showModal: F,
                setProps: j
            }), (t, a)=>{
                const r = V, N = G, k = q, A = D;
                return _(), f(A, {
                    ref: "modalRef",
                    onRegister: e(M),
                    class: "basicModal basicFormModal",
                    showAction: !1,
                    closable: e(d)
                }, {
                    default: p(()=>[
                            s("div", null, [
                                s("div", J, [
                                    h(r, {
                                        type: "line",
                                        percentage: e(O)
                                    }, {
                                        default: p(()=>[
                                                v(l(e(o).currentCount) + "/" + l(e(o).totalCount), 1)
                                            ]),
                                        _: 1
                                    }, 8, [
                                        "percentage"
                                    ])
                                ]),
                                s("div", null, [
                                    s("div", null, [
                                        v(l(e(n)("jobOrderList.approval")) + ": ", 1),
                                        s("span", K, l(e(o).successCount), 1)
                                    ]),
                                    s("div", null, [
                                        v(l(e(n)("jobOrderList.approvalFail")) + ": ", 1),
                                        s("span", Q, l(e(o).failCount), 1)
                                    ])
                                ]),
                                e(o).failCount && e(o).failCount > 0 ? (_(), f(k, {
                                    key: 0,
                                    "arrow-placement": "right"
                                }, {
                                    default: p(()=>[
                                            h(N, {
                                                name: "1"
                                            }, {
                                                header: p(()=>[
                                                        s("div", U, l(e(n)("jobOrderList.errorDetails")), 1)
                                                    ]),
                                                default: p(()=>[
                                                        e(d) ? (_(), f(e(H), {
                                                            key: 0,
                                                            columns: e(I),
                                                            showTableSetting: !1,
                                                            dataSource: e(B),
                                                            pagination: {
                                                                page: e(u),
                                                                itemCount: e(o).totalCount
                                                            },
                                                            "on-update:page": S,
                                                            "on-update:page-size": T,
                                                            ref: "basicTableRef",
                                                            autoScrollX: !0,
                                                            "virtual-scroll": ""
                                                        }, null, 8, [
                                                            "columns",
                                                            "dataSource",
                                                            "pagination"
                                                        ])) : C("", !0)
                                                    ]),
                                                _: 1
                                            })
                                        ]),
                                    _: 1
                                })) : C("", !0)
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister",
                    "closable"
                ]);
            };
        }
    });
});
export { xe as default, __tla };
