import { V as S, bk as q, r as f, a4 as W, Z as d, cf as fe, hc as ge, ad as w, d as ve, f as he, a as N, ay as we, cZ as _e, ac as ye, aw as be, d9 as Re, c as k, o as V, w as l, j as u, D as Me, W as ke, l as a, i as F, H as Ve, aI as Se, p as $, A, aE as Te, B as Ce, aF as De, db as Pe, ik as Be, X as xe, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as I } from "./Table-0PViRYCf.js";
import { _ as Ne } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { B as O } from "./BasicForm-dL_oCSPM.js";
import { u as E } from "./useForm-CKmgcynv.js";
import { g as Fe } from "./vesselRuleMappingSetting-D4CBkDWj.js";
import { i as $e } from "./isEmpty-BUg1OsQj.js";
import { o as Ae } from "./omit-B2_8Y6O_.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 "./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 "./Flex-CTSf12gq.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 "./_flatRest-DBrd2CHT.js";
import "./flatten-DeoUZLdb.js";
let xt;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const Ie = q(), { t: g } = S(), Oe = ()=>({
            columns: [
                {
                    title: g("common.messagedefine.Num"),
                    key: "num",
                    width: 60,
                    render: (t, n)=>n + 1
                },
                {
                    title: g("operation.vesselRuleMapping.rules"),
                    key: Ie.getLocale === "en" ? "ruleNameEn" : "ruleName",
                    width: 120
                },
                {
                    title: g("operation.vesselRuleMapping.from"),
                    key: "dateFrom",
                    width: 120
                },
                {
                    title: g("operation.vesselRuleMapping.to"),
                    key: "dateTo",
                    width: 120
                }
            ]
        }), Ee = (s)=>{
        const t = f(s.type), n = (o)=>{
            t.value = o;
        };
        return {
            rulesColumns: W(()=>[
                    {
                        title: g("common.messagedefine.Num"),
                        key: "num",
                        width: 60,
                        render: (o, i)=>i + 1
                    },
                    {
                        title: g("operation.vesselRuleMapping.description"),
                        key: "description",
                        width: 200,
                        align: "left"
                    },
                    {
                        title: g("operation.vesselRuleMapping.value"),
                        key: "ruleHours",
                        width: 120
                    },
                    {
                        title: g("vesselRuleMapping.detailTable.applicable"),
                        width: 120,
                        render (o) {
                            return t.value === "view" ? +o.isApplicable == 1 ? "已启用" : "已禁用" : d(fe, {
                                value: o.isApplicable,
                                checkedValue: 1,
                                uncheckedValue: 0,
                                checked: ()=>d("span", [
                                        "启用"
                                    ]),
                                unchecked: ()=>d("span", [
                                        "禁用"
                                    ]),
                                onUpdateValue (i) {
                                    o.isApplicable = i;
                                }
                            });
                        }
                    }
                ]),
            updateType: n
        };
    }, Le = q(), { t: p } = S(), b = await ge(), L = b && b.length > 0 ? b[0].id : 0, qe = ()=>({
            schemas: [
                {
                    field: "shipId",
                    component: "NSelect",
                    componentProps: {
                        disabled: !0,
                        options: b,
                        value: L,
                        "label-field": Le.getLocale === "en" ? "shipNameEn" : "shipName",
                        "value-field": "id"
                    },
                    label: p("operation.vesselRuleMapping.vessel"),
                    giProps: {
                        span: 3
                    }
                }
            ],
            initShipValue: L
        }), We = (s)=>{
        const { updateDetails: t } = s, n = f(s.type), v = (c)=>{
            n.value = c;
        }, o = f(s.rulesOptsList);
        return {
            rulesSchemas: W(()=>[
                    {
                        field: "rule",
                        component: "BasicSelect",
                        componentProps: {
                            class: "w-full",
                            options: o.value,
                            disabled: [
                                "edit",
                                "view"
                            ].includes(n.value),
                            onUpdateValue (c, y) {
                                t(y.raw?.details);
                            }
                        },
                        label: p("operation.vesselRuleMapping.rules"),
                        rules: [
                            {
                                required: !0,
                                message: `${p("operation.vesselRuleMapping.rules")} ${p("common.required")}`,
                                trigger: [
                                    "submit"
                                ],
                                type: "number"
                            }
                        ],
                        giProps: {
                            span: 3
                        }
                    },
                    {
                        field: "dateFrom",
                        component: "NDatePicker",
                        componentProps: {
                            type: "date",
                            valueFormat: "yyyy-MM-dd",
                            disabled: n.value === "view"
                        },
                        label: p("operation.vesselRuleMapping.from"),
                        rules: [
                            {
                                required: !0,
                                message: `${p("operation.vesselRuleMapping.from")} ${p("common.required")}`,
                                trigger: [
                                    "submit"
                                ]
                            }
                        ],
                        giProps: {
                            span: 3
                        }
                    },
                    {
                        field: "dateTo",
                        component: "NDatePicker",
                        componentProps: {
                            type: "date",
                            valueFormat: "yyyy-MM-dd",
                            disabled: n.value === "view"
                        },
                        label: p("operation.vesselRuleMapping.to"),
                        giProps: {
                            span: 3
                        }
                    },
                    {
                        field: "isMain",
                        component: "NSwitch",
                        componentProps: {
                            checkedValue: 1,
                            uncheckedValue: 0,
                            checked: ()=>d("span", [
                                    "是"
                                ]),
                            unchecked: ()=>d("span", [
                                    "否"
                                ]),
                            disabled: n.value === "view"
                        },
                        label: p("vesselRuleMapping.isMain"),
                        giProps: {
                            span: 3
                        }
                    }
                ]),
            updateType: v,
            updateRulesOpts: (c)=>{
                o.value = c;
            }
        };
    }, _ = "";
    function Ge(s) {
        return w.Get(`${_}/scheduleVesselRuleMapping/getPageList`, {
            params: s
        });
    }
    function Xe(s) {
        return w.Get(`${_}/scheduleVesselRuleMapping/getDataById`, {
            params: {
                id: s
            }
        });
    }
    function je(s) {
        return w.Delete(`${_}//scheduleVesselRuleMapping/delete?id=${s}`);
    }
    function ze(s) {
        return w.Post(`${_}/scheduleVesselRuleMapping/save`, s);
    }
    function He(s) {
        return w.Put(`${_}/scheduleVesselRuleMapping/update`, s);
    }
    let Ue;
    Ue = {
        class: "w-full flex items-center justify-between"
    };
    xt = ve({
        __name: "index",
        setup (s) {
            const { t } = S(), n = he(), v = _e(), o = f(), i = f(), r = f(""), c = f(), y = f(), G = N({
                add: t("vesselRuleMapping.addRules"),
                edit: t("vesselRuleMapping.editRules"),
                view: t("vesselRuleMapping.viewRules")
            }), { schemas: X, initShipValue: j } = qe(), { rulesSchemas: z, updateType: H, updateRulesOpts: U } = We({
                type: "view",
                rulesOptsList: [],
                updateDetails: oe
            }), { columns: Z } = Oe(), { rulesColumns: J, updateType: K } = Ee({
                type: "view"
            });
            we(r, (e)=>{
                H(e), K(e);
            });
            const [Q, { setFieldsValue: Y, getFieldsValue: ee }] = E({
                gridProps: {
                    cols: 5
                },
                schemas: X,
                labelPlacement: "left",
                labelWidth: 80,
                showAdvancedButton: !1
            }), [te, { resetFields: R, submit: se, setFieldsValue: T, getFieldsValue: C }] = E({
                gridProps: {
                    cols: 12
                },
                schemas: z,
                labelWidth: 80,
                showAdvancedButton: !1
            }), ae = N({
                width: 100,
                title: t("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (e) {
                    return d(Ne, {
                        style: "text",
                        actions: [
                            {
                                label: t("common.optionsViewText"),
                                labelShow: !1,
                                icon: d("i", {
                                    class: "iconfont icon-View blue"
                                }),
                                onClick: ()=>{
                                    ne(e);
                                }
                            },
                            {
                                label: t("common.optionsEditText"),
                                labelShow: !1,
                                icon: d("i", {
                                    class: "iconfont icon-a-Frame28"
                                }),
                                onClick: ()=>{
                                    ie(e);
                                }
                            },
                            {
                                label: t("common.optionsDelText"),
                                labelShow: !1,
                                icon: d("i", {
                                    class: "iconfont icon-Delete red"
                                }),
                                onPositiveClick: async ()=>{
                                    await je(e.id), v.success(t("common.optionsDelSuccessText")), D();
                                },
                                onNegativeClick: ()=>{},
                                isConfirm: !0,
                                confirmContent: t("common.delPop.contRole")
                            }
                        ]
                    });
                }
            });
            function oe(e) {
                i.value = e;
            }
            function D() {
                r.value = "", y.value.restReload();
            }
            async function le(e) {
                return await Ge({
                    ...e,
                    ...ee()
                });
            }
            function ne(e) {
                r.value = "view", P(e.id);
            }
            function ie(e) {
                r.value = "edit", P(e.id);
            }
            async function P(e) {
                e && (o.value = await Xe(e), ye(()=>{
                    R && R(), i.value = o.value.details, T(o.value);
                }));
            }
            function ue() {
                r.value = "add", R(), i.value = [], T({
                    isMain: 0
                });
            }
            async function re() {
                await se(), $e(o.value) ? await ze({
                    ...C(),
                    vesselId: c.value,
                    details: i.value.map((e)=>Ae(e, "id"))
                }) : await He({
                    ...o.value,
                    ...C(),
                    details: i.value
                }), v.success(t("common.saveSuccessText")), D();
            }
            async function ce() {
                c.value = n.query?.vesselId || j;
                const e = await Fe(c.value);
                U(e.map((m)=>({
                        label: m.ruleName,
                        labelEn: m.ruleNameEn,
                        value: m.id,
                        raw: m
                    }))), Y({
                    shipId: c.value
                });
            }
            return be(()=>{
                ce();
            }), (e, m)=>{
                const B = Ce, x = Se, pe = Ve, M = ke, de = xe, me = Re("debounce");
                return V(), k(de, null, {
                    default: l(()=>[
                            u(M, {
                                class: "proCard"
                            }, {
                                header: l(()=>[
                                        F("div", Ue, [
                                            u(a(O), {
                                                class: "w-[40%]",
                                                onRegister: a(Q),
                                                showActionButtonGroup: !1,
                                                showSubmitButton: !1,
                                                showResetButton: !1
                                            }, null, 8, [
                                                "onRegister"
                                            ]),
                                            u(pe, null, {
                                                default: l(()=>[
                                                        u(x, {
                                                            trigger: "hover"
                                                        }, {
                                                            trigger: l(()=>[
                                                                    Te((V(), k(B, {
                                                                        strong: "",
                                                                        secondary: "",
                                                                        type: "primary",
                                                                        class: "size-9"
                                                                    }, {
                                                                        icon: l(()=>m[0] || (m[0] = [
                                                                                F("i", {
                                                                                    class: "iconfont icon-Save"
                                                                                }, null, -1)
                                                                            ])),
                                                                        _: 1
                                                                    })), [
                                                                        [
                                                                            me,
                                                                            re,
                                                                            "1000"
                                                                        ],
                                                                        [
                                                                            De,
                                                                            [
                                                                                "edit",
                                                                                "add"
                                                                            ].includes(a(r))
                                                                        ]
                                                                    ])
                                                                ]),
                                                            default: l(()=>[
                                                                    $(A(a(t)("common.saveText")), 1)
                                                                ]),
                                                            _: 1
                                                        }),
                                                        u(x, {
                                                            trigger: "hover"
                                                        }, {
                                                            trigger: l(()=>[
                                                                    u(B, {
                                                                        strong: "",
                                                                        secondary: "",
                                                                        type: "primary",
                                                                        onClick: Pe(ue, [
                                                                            "stop"
                                                                        ]),
                                                                        class: "size-9"
                                                                    }, {
                                                                        icon: l(()=>[
                                                                                u(a(Be))
                                                                            ]),
                                                                        _: 1
                                                                    })
                                                                ]),
                                                            default: l(()=>[
                                                                    $(A(a(t)("common.addText")), 1)
                                                                ]),
                                                            _: 1
                                                        })
                                                    ]),
                                                _: 1
                                            })
                                        ])
                                    ]),
                                default: l(()=>[
                                        u(a(I), {
                                            columns: a(Z),
                                            showTableSetting: !1,
                                            actionColumn: a(ae),
                                            "row-key": (h)=>h.id,
                                            ref_key: "basicTableRef",
                                            ref: y,
                                            autoScrollX: !0,
                                            request: (h)=>le(h)
                                        }, null, 8, [
                                            "columns",
                                            "actionColumn",
                                            "row-key",
                                            "request"
                                        ])
                                    ]),
                                _: 1
                            }),
                            a(r) ? (V(), k(M, {
                                key: 0,
                                class: "proCard mt-2",
                                title: a(G)[a(r)]
                            }, {
                                default: l(()=>[
                                        u(a(O), {
                                            class: "w-[100%]",
                                            onRegister: a(te),
                                            showActionButtonGroup: !1,
                                            showSubmitButton: !1,
                                            showResetButton: !1
                                        }, null, 8, [
                                            "onRegister"
                                        ]),
                                        u(M, {
                                            bordered: !1,
                                            class: "proCard",
                                            title: a(t)("operation.vesselRuleMapping.rulesDescription")
                                        }, {
                                            default: l(()=>[
                                                    u(a(I), {
                                                        columns: a(J),
                                                        showTableSetting: !1,
                                                        pagination: !1,
                                                        actionColumn: !1,
                                                        "row-key": (h)=>h.id,
                                                        autoScrollX: !0,
                                                        dataSource: a(i)
                                                    }, null, 8, [
                                                        "columns",
                                                        "row-key",
                                                        "dataSource"
                                                    ])
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "title"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "title"
                            ])) : Me("", !0)
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { xt as default, __tla };
