import { B as V } from "./BasicForm-dL_oCSPM.js";
import { u as $ } from "./useForm-CKmgcynv.js";
import { _ as z } from "./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";
import "./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";
import { u as G } from "./useModal-CO65vga3.js";
import { P as R } from "./Password-BeBc6acq.js";
import { g as U } from "./dept-C5ivQanA.js";
import { V as _, r as h, cO as N, cq as I, fm as k, d as A, u as j, c as K, o as W, l as m, w as p, i as H, j as d, ac as J, fn as Q, fo as X, fp as Y, __tla as __tla_0 } from "./index-9PRMimni.js";
import { e as Z, f as ee } from "./template-rpthWlT9.js";
import { c as oe } from "./company-PiwOjwod.js";
let ge;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: e } = _(), re = await oe(), C = h([]);
    C.value = await U({});
    let le, f, ne, g;
    le = await ee();
    f = await Z({});
    ne = [
        {
            value: "1",
            label: e("common.userController.typeShore")
        },
        {
            value: "2",
            label: e("common.userController.typeShip")
        }
    ];
    g = [
        {
            field: "username",
            component: "NInput",
            label: e("common.userController.username"),
            componentProps: {
                placeholder: e("common.userController.placeholderUsername")
            },
            rules: [
                {
                    required: !0,
                    message: e("common.userController.placeholderUsername"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        },
        {
            field: "nickname",
            component: "NInput",
            label: e("common.userController.nickname"),
            componentProps: {
                placeholder: e("common.userController.nickname")
            },
            rules: [
                {
                    required: !0,
                    message: e("common.userController.nickname"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        },
        {
            field: "phone",
            component: "NInputNumber",
            label: e("common.userController.phone"),
            componentProps: {
                placeholder: e("common.userController.placeholderPhone"),
                showButton: !1
            },
            rules: [
                {
                    required: !0,
                    type: "number",
                    message: e("common.userController.placeholderPhone"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        },
        {
            field: "email",
            component: "NInput",
            label: e("common.userController.email"),
            componentProps: {
                placeholder: e("common.userController.placeholderEmail"),
                showButton: !1
            },
            rules: [
                {
                    required: !0,
                    type: "email",
                    message: e("common.userController.placeholderEmail"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        },
        {
            field: "gender",
            component: "NSelect",
            label: e("common.userController.gender"),
            componentProps: {
                placeholder: e("common.userController.placeholderGender"),
                options: [
                    {
                        label: e("common.userController.men"),
                        value: 1
                    },
                    {
                        label: e("common.userController.women"),
                        value: 2
                    }
                ]
            },
            rules: [
                {
                    required: !0,
                    type: "number",
                    message: e("common.userController.placeholderGender"),
                    trigger: [
                        "change"
                    ]
                }
            ]
        },
        {
            field: "status",
            component: "NSelect",
            label: e("common.userController.status"),
            componentProps: {
                placeholder: e("common.userController.placeholderStatus"),
                options: [
                    {
                        label: e("common.userController.normal"),
                        value: 1
                    },
                    {
                        label: e("common.userController.disable"),
                        value: 0
                    }
                ]
            },
            rules: [
                {
                    required: !0,
                    type: "number",
                    message: e("common.userController.placeholderStatus"),
                    trigger: [
                        "change"
                    ]
                }
            ]
        },
        {
            field: "userType",
            component: "NSelect",
            label: e("common.userController.userType"),
            componentProps: {
                placeholder: e("common.userController.userType"),
                options: ne
            },
            rules: [
                {
                    required: !0,
                    message: e("common.userController.userType"),
                    trigger: [
                        "change"
                    ]
                }
            ]
        },
        {
            field: "companyId",
            component: "NTreeSelect",
            label: e("common.userController.managementCompany"),
            componentProps: ({ model: o })=>({
                    placeholder: e("common.userController.managementCompany"),
                    options: re,
                    keyField: "value",
                    "onUpdate:value": async (l)=>{
                        o.deptId = null, C.value = await U({
                            companyId: l
                        });
                    }
                }),
            rules: [
                {
                    required: !0,
                    type: "number",
                    message: e("common.userController.managementCompany"),
                    trigger: [
                        "change"
                    ]
                }
            ],
            hidden: ({ model: o, field: l })=>{
                const r = +o.userType != 1;
                return r && (o[l] = void 0), r;
            }
        },
        {
            field: "roleIds",
            component: "NSelect",
            label: e("common.userController.managementCompanyRole"),
            componentProps: {
                placeholder: e("common.userController.managementCompanyRole"),
                options: (f || []).filter((o)=>+o.roleType == 3),
                multiple: !0,
                valueField: "id",
                labelField: "name"
            },
            rules: [
                {
                    required: !0,
                    type: "array",
                    message: e("common.userController.managementCompanyRole"),
                    trigger: [
                        "change"
                    ]
                }
            ],
            hidden: ({ model: o, field: l })=>{
                const r = +o.userType != 1;
                return r && (o[l] = void 0), r;
            }
        },
        {
            field: "deptId",
            component: "NTreeSelect",
            label: e("common.userController.dept"),
            componentProps: {
                placeholder: e("common.userController.placeholderDept"),
                options: C,
                "key-field": "value"
            },
            hidden: ({ model: o, field: l })=>{
                const r = +o.userType != 1;
                return r && (o[l] = void 0), r;
            }
        },
        {
            field: "docId",
            component: "NSelect",
            label: e("common.userController.doc"),
            componentProps: {
                placeholder: e("common.userController.doc"),
                options: le,
                "value-field": "id",
                "label-field": "companyNameCn"
            },
            hidden: ({ model: o, field: l })=>{
                const r = +o.userType != 1;
                return r && (o[l] = void 0), r;
            }
        },
        {
            field: "docRoleIds",
            component: "NSelect",
            label: e("common.userController.docRole"),
            componentProps: {
                placeholder: e("common.userController.docRole"),
                options: (f || []).filter((o)=>+o.roleType == 4),
                multiple: !0,
                valueField: "id",
                labelField: "name"
            },
            hidden: ({ model: o, field: l })=>{
                const r = +o.userType != 1;
                return r && (o[l] = void 0), r;
            }
        },
        {
            field: "shipRoleIds",
            component: "NSelect",
            label: e("common.userController.vesselRole"),
            componentProps: {
                placeholder: e("common.userController.vesselRole"),
                options: (f || []).filter((o)=>+o.roleType == 2),
                multiple: !0,
                valueField: "id",
                labelField: "name"
            },
            hidden: ({ model: o, field: l })=>{
                const r = +o.userType == 1;
                return r && (o[l] = void 0), r;
            }
        },
        {
            field: "password",
            label: e("common.userController.password"),
            slot: "passwordSlot",
            showFeedback: !1,
            rules: [
                {
                    required: !0,
                    message: e("common.userController.placeholderPassword"),
                    trigger: [
                        "blur"
                    ]
                }
            ]
        },
        {
            field: "signUrl",
            label: e("common.userController.sign"),
            component: "SingleImageUpload",
            componentProps: (o)=>({
                    action: `${I().urlPrefix}/files`,
                    headers: {
                        timestamp: new Date().getTime(),
                        authorization: `${N.get(k)}`
                    },
                    onUploadChange: (l)=>{
                        console.log("file", l);
                    }
                })
        },
        {
            field: "avatar",
            label: e("common.userController.avatar"),
            component: "SingleImageUpload",
            componentProps: (o)=>({
                    action: `${I().urlPrefix}/files`,
                    headers: {
                        timestamp: new Date().getTime(),
                        authorization: `${N.get(k)}`
                    },
                    onUploadChange: ()=>{}
                })
        }
    ];
    ge = A({
        __name: "CreateModal",
        props: {
            title: {
                type: String,
                default: ""
            },
            isEdit: {
                type: Boolean,
                default: !1
            }
        },
        emits: [
            "success"
        ],
        setup (o, { expose: l, emit: r }) {
            const { t: b } = _(), y = j(), v = o, q = r, c = h(null), F = h(v.title), [x, { submit: B, setFieldsValue: w, getFieldsValue: u, setSchema: P }] = $({
                gridProps: {
                    cols: 2
                },
                collapsed: !1,
                collapsedRows: 12,
                labelWidth: 80,
                layout: "horizontal",
                submitButtonText: "确定",
                showActionButtonGroup: !1,
                schemas: g
            }), [L, { openModal: D, closeModal: S, setSubLoading: T, setProps: E }] = G({
                title: F,
                subBtuText: b("common.okText"),
                cancelText: b("common.cancelText"),
                width: 650
            });
            async function M(a) {
                if (console.log("id", a), c.value = a, await J(), a) {
                    const s = await Q(a);
                    s.phone && (s.phone = Number(s.phone)), w({
                        ...s
                    });
                    const n = g.map((t)=>(t.field === "username" && (t.componentProps = {
                            disabled: !0
                        }), t.field === "password" && (t.hidden = !0), t));
                    P(n);
                } else {
                    const s = g.map((n)=>(n.field === "username" && (n.componentProps = {
                            disabled: !1
                        }), n.field === "password" && (n.hidden = !0), n));
                    P(s);
                }
            }
            async function O() {
                if (await B()) {
                    const { isEdit: s } = v;
                    console.log("表单值：", u()), c.value == null ? await X(u()) : await Y(c.value, u()), y.success(s ? "修改成功" : "添加成功"), q("success"), T(!1), S();
                } else y.error("验证失败，请填写完整信息"), T(!1);
            }
            return l({
                openModal: D,
                closeModal: S,
                setFieldsValue: w,
                setProps: E,
                getData: M
            }), (a, s)=>(W(), K(m(z), {
                    onRegister: m(L),
                    ref: "modalRef",
                    onOnOk: O
                }, {
                    default: p(()=>[
                            H("div", null, [
                                d(m(V), {
                                    onRegister: m(x)
                                }, {
                                    passwordSlot: p(({ model: n, field: t })=>[
                                            d(m(R), {
                                                ref: "passwordRef",
                                                value: n[t],
                                                "onUpdate:value": (i)=>n[t] = i,
                                                required: !0,
                                                block: ""
                                            }, null, 8, [
                                                "value",
                                                "onUpdate:value"
                                            ])
                                        ]),
                                    rePasswordSlot: p(({ model: n, field: t })=>[
                                            d(m(R), {
                                                ref: "passwordRef",
                                                value: n[t],
                                                "onUpdate:value": (i)=>n[t] = i,
                                                required: !1,
                                                block: ""
                                            }, null, 8, [
                                                "value",
                                                "onUpdate:value"
                                            ])
                                        ]),
                                    _: 1
                                }, 8, [
                                    "onRegister"
                                ])
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "onRegister"
                ]));
        }
    });
});
export { ge as _, __tla };
