import { _ as I } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { B as V } from "./BasicForm-dL_oCSPM.js";
import { V as k, hc as L, bk as R, r as h, gL as E, a4 as p, d8 as m, Z as l, ae as O, d as C, c as W, o as Z, l as g, w as j, j as z, ac as G, cZ as H, __tla as __tla_0 } from "./index-9PRMimni.js";
import { i as f } from "./isEmpty-BUg1OsQj.js";
import { s as J } from "./crewDailyTask-CA-vJisZ.js";
import { u as K } from "./useModal-CO65vga3.js";
import { u as Q } from "./useForm-CKmgcynv.js";
let de, ce;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    let e, w, U, n, b, X, Y;
    ({ t: e } = k());
    w = R();
    U = await E("schedule_task_type");
    n = await L();
    b = n && n.length > 0 ? n[0].id : 0;
    X = (a)=>{
        const r = h(a.isAdd);
        return {
            schemas: [
                {
                    field: "id",
                    hidden: !0
                },
                {
                    field: "vesselId",
                    hidden: !0
                },
                {
                    field: "type",
                    component: "NSelect",
                    componentProps: {
                        disabled: p(()=>!r.value),
                        options: U,
                        "label-field": w.getLocale === "en" ? "labelEn" : "label"
                    },
                    label: e("operation.crewDailyTask.type"),
                    rules: [
                        {
                            required: !0,
                            message: `${e("operation.crewDailyTask.type")} ${e("common.required")}`,
                            trigger: "blur"
                        }
                    ],
                    giProps: {
                        span: 2
                    }
                },
                {
                    field: "code",
                    component: "NInput",
                    label: e("operation.crewDailyTask.code"),
                    componentProps: {
                        disabled: p(()=>!r.value)
                    },
                    rules: [
                        {
                            required: !0,
                            message: `${e("operation.crewDailyTask.code")} ${e("common.required")}`,
                            trigger: "blur"
                        }
                    ],
                    giProps: {
                        span: 2
                    }
                },
                {
                    field: "colour",
                    component: "NSelect",
                    componentProps: {
                        options: [
                            {
                                label: "green",
                                value: "#18A058"
                            },
                            {
                                label: "blue",
                                value: "#2080F0"
                            },
                            {
                                label: "yellow",
                                value: "#F0A020"
                            }
                        ],
                        renderLabel: Y
                    },
                    label: e("operation.crewDailyTask.color"),
                    giProps: {
                        span: 2
                    }
                },
                {
                    field: "active",
                    component: "NSwitch",
                    componentProps: {
                        checkedValue: 1,
                        uncheckedValue: 2
                    },
                    label: e("operation.crewDailyTask.active"),
                    rules: [
                        {
                            required: !0,
                            validator: (i, s)=>f(s) && !m(s) ? new Error(`${e("operation.crewDailyTask.active")} ${e("common.required")}`) : !0,
                            trigger: "blur"
                        }
                    ],
                    giProps: {
                        span: 1
                    }
                },
                {
                    field: "specialTask",
                    component: "NSwitch",
                    componentProps: {
                        checkedValue: 1,
                        uncheckedValue: 0
                    },
                    label: e("operation.crewDailyTask.specialTask"),
                    rules: [
                        {
                            required: !0,
                            validator: (i, s)=>f(s) && !m(s) ? new Error(`${e("operation.crewDailyTask.specialTask")} ${e("common.required")}`) : !0,
                            trigger: "blur"
                        }
                    ],
                    giProps: {
                        span: 1
                    }
                },
                {
                    field: "subtask",
                    component: "NInput",
                    componentProps: {
                        type: "textarea"
                    },
                    label: e("operation.crewDailyTask.subtask"),
                    rules: [
                        {
                            required: !0,
                            message: `${e("operation.crewDailyTask.subtask")} ${e("common.required")}`,
                            trigger: "blur"
                        }
                    ],
                    giProps: {
                        span: 4
                    }
                }
            ],
            updateIsAdd: (i)=>{
                r.value = i;
            }
        };
    };
    ce = ()=>({
            infoSchemas: [
                {
                    field: "vesselId",
                    component: "NSelect",
                    componentProps: {
                        options: n,
                        value: b,
                        "label-field": w.getLocale === "en" ? "shipNameEn" : "shipName",
                        "value-field": "id",
                        disabled: !0
                    },
                    label: e("operation.crewDailyTask.vessel"),
                    giProps: {
                        span: 3
                    }
                }
            ],
            initShipValue: b
        });
    Y = (a)=>(console.log(a), l("div", {
            style: {
                display: "flex",
                alignItems: "center"
            }
        }, [
            l(O, {
                color: {
                    color: a.value
                },
                size: "large"
            }),
            l("div", {
                style: {
                    marginLeft: "12px",
                    padding: "4px 0"
                }
            }, [
                l("div", null, [
                    a.label
                ])
            ])
        ]));
    de = C({
        __name: "Modal",
        emits: [
            "success"
        ],
        setup (a, { expose: r, emit: d }) {
            const i = H(), s = d, { t: o } = k(), c = h(!0), { schemas: y, updateIsAdd: T } = X({
                isAdd: !0
            }), [v, { openModal: _, closeModal: D, setSubLoading: u, setProps: P }] = K({
                title: o("operation.crewDailyTask.addTask"),
                subBtuText: o("common.saveText"),
                cancelText: o("common.cancelText"),
                displayDirective: "if",
                width: 650
            }), [S, { getFieldsValue: x, resetFields: N, setFieldsValue: $, validate: q }] = Q({
                gridProps: {
                    cols: "4"
                },
                labelWidth: 80,
                schemas: y,
                showAdvancedButton: !1
            });
            async function A(t) {
                _(), c.value = !t.id, P({
                    title: c.value ? o("operation.crewDailyTask.addTask") : o("operation.crewDailyTask.editTask")
                }), G(()=>{
                    T(c.value), N(), $(t);
                });
            }
            async function B() {
                try {
                    await q();
                    const t = x();
                    await J(t), u(!1), i.success(o("common.saveSuccessText")), s("success"), D();
                } catch  {
                    u(!1);
                }
            }
            return r({
                showModal: A
            }), (t, ee)=>{
                const M = V, F = I;
                return Z(), W(F, {
                    ref: "modalRef",
                    onRegister: g(v),
                    class: "basicModal basicFormModal",
                    onOnOk: B
                }, {
                    default: j(()=>[
                            z(M, {
                                onRegister: g(S),
                                showActionButtonGroup: !1,
                                showSubmitButton: !1,
                                showResetButton: !1
                            }, null, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]);
            };
        }
    });
});
export { de as _, ce as c, __tla };
