import { _ as C } 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 M } from "./BasicForm-dL_oCSPM.js";
import { s as O, __tla as __tla_0 } from "./schemas-BqGurRC_.js";
import { d as T, V as D, r, c as I, o as V, w as i, j as c, l as a, aH as q, ds as z, cO as A, fm as G, cq as $, aI as P, p as j, A as H, B as K, i as W, bR as Z, R as J, cZ as Q, ac as X, __tla as __tla_1 } from "./index-9PRMimni.js";
import { c as Y } from "./componentSetting-DVhNDBTO.js";
import { u as ee } from "./useForm-CKmgcynv.js";
import { u as se } from "./useModal-CO65vga3.js";
let me;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    let te;
    te = {
        name: "UploadFile"
    };
    me = T({
        ...te,
        emits: [
            "success"
        ],
        setup (oe, { expose: x, emit: b }) {
            const { t: _ } = D(), v = Q(), n = r([]), g = r(0), u = r(!1), { schemasUpload: U } = O(), [R] = ee({
                schemas: U,
                labelWidth: "auto",
                layout: "horizontal",
                collapsed: !0,
                gridProps: {
                    cols: 1,
                    xGap: 15
                },
                showActionButtonGroup: !1
            }), S = b, B = r(), [N, { openModal: y, closeModal: h, setSubLoading: f }] = se({
                title: _("hsqe.rs.uploadText"),
                width: 500
            });
            function F({ file: s, event: e }) {
                try {
                    const t = Z("(" + e.target.response + ")"), { infoField: l } = Y.upload.apiSetting, { code: o } = t, m = t.msg || t.message || "上传失败", p = t[l];
                    o === J.SUCCESS ? s.thumbnailUrl = p.name : v.error(m);
                } catch  {}
            }
            function w(s, e, t) {
                y(), g.value = e;
                const l = [];
                s && s.length > 0 ? (s.forEach((o)=>{
                    l.push({
                        id: o.fileName || "",
                        url: o.fileUrl || "",
                        name: o.fileName?.split("/").pop() || "",
                        thumbnailUrl: o.fileName || "",
                        fileName: o.thumbnailUrl || o.fileName || "",
                        status: t ? "finished" : "uploading"
                    });
                }), n.value = l) : n.value = [], X(()=>{
                    u.value = t;
                });
            }
            async function E() {
                try {
                    h(), f(!1), S("success", {
                        fileList: L(),
                        currentIndex: g.value
                    });
                } catch  {
                    f(!1);
                }
                f(!0), h();
            }
            function L() {
                const s = [];
                return n.value && n.value.length > 0 && n.value.forEach((e)=>{
                    s.push({
                        thumbnailUrl: e.thumbnailUrl || "",
                        fileUrl: e.url || "",
                        fileName: e.thumbnailUrl || e.name || "",
                        name: e.thumbnailUrl || e.name || "",
                        status: "finished"
                    });
                }), s;
            }
            return x({
                handleOpenModal: w
            }), (s, e)=>{
                const t = K, l = P, o = q, m = M, p = C;
                return V(), I(p, {
                    ref_key: "modalRef",
                    ref: B,
                    "show-action": a(u),
                    onOnOk: E,
                    onRegister: a(N)
                }, {
                    default: i(()=>[
                            c(m, {
                                onRegister: a(R)
                            }, {
                                attachment: i(({})=>[
                                        c(o, {
                                            action: `${a($)().urlPrefix}/files`,
                                            accept: ".doc,.docx,.pdf,.xls,.xlsx",
                                            headers: {
                                                timestamp: new Date().getTime(),
                                                authorization: `${a(A).get(a(G))}`
                                            },
                                            max: 15,
                                            "file-list": a(n),
                                            "onUpdate:fileList": e[0] || (e[0] = (d)=>z(n) ? n.value = d : null),
                                            onFinish: e[1] || (e[1] = ({ file: d, event: k })=>F({
                                                    file: d,
                                                    event: k
                                                })),
                                            class: "uploadStyle",
                                            "file-list-style": {
                                                margin: 0,
                                                flex: 1
                                            },
                                            disabled: !a(u)
                                        }, {
                                            default: i(()=>[
                                                    c(l, {
                                                        trigger: "hover"
                                                    }, {
                                                        trigger: i(()=>[
                                                                c(t, {
                                                                    strong: "",
                                                                    secondary: "",
                                                                    class: "size-7"
                                                                }, {
                                                                    icon: i(()=>e[2] || (e[2] = [
                                                                            W("i", {
                                                                                class: "iconfont icon-upload1"
                                                                            }, null, -1)
                                                                        ])),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        default: i(()=>[
                                                                j(" " + H(a(_)("hsqe.rs.uploadText")), 1)
                                                            ]),
                                                        _: 1
                                                    })
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "action",
                                            "headers",
                                            "file-list",
                                            "disabled"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                }, 8, [
                    "show-action",
                    "onRegister"
                ]);
            };
        }
    });
});
export { me as _, __tla };
