import { V as E, Z as g, d as ee, u as te, f as oe, a4 as ne, ay as ae, r as C, a as re, ac as ie, aw as se, c as F, o as A, w as a, D as le, j as r, l as e, aI as ce, p as q, A as v, B as me, hK as ue, aH as pe, cO as de, fm as fe, cq as he, ds as _e, hr as ge, i as be, N as Te, i6 as ye, S as xe, ak as Se, X as ke, bR as Ce, R as qe, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as ve } from "./BasicForm-dL_oCSPM.js";
import { c as Ee } from "./componentSetting-DVhNDBTO.js";
import { i as Re, j as Oe, k as we } from "./requisitionOrder-D0IG9N7e.js";
import { _ as Fe } 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 Ae } from "./useModal-CO65vga3.js";
import { B as Ne } from "./Table-0PViRYCf.js";
import { _ as Ie } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { P as m, e as Be, C as Pe, __tla as __tla_1 } from "./helper-CNwA55dE.js";
import { u as De } from "./useForm-CKmgcynv.js";
import { i as N } from "./includes-DdMWPj0t.js";
import "./Render.vue_vue_type_script_lang-DKUYY0Zw.js";
import "./SingleImageUpload-CNx4b9eC.js";
import "./ImageUpload.vue_vue_type_style_index_0_scoped_cb086928_lang-D-28kXvw.js";
import "./ImageUpload-DUsnro3W.js";
import "./vuedraggable.umd-Co2xEC3p.js";
import "./BasicUpload.vue_vue_type_style_index_0_scoped_a4d0e930_lang-DxRbtP01.js";
import "./tabsView-BXskTdVh.js";
import "./BasicForm.vue_vue_type_style_index_0_scoped_b9e995ec_lang-CEvcLwxD.js";
import "./propTypes-CebMRUpe.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 "./Table.vue_vue_type_style_index_0_scoped_7b9e6ece_lang-BoW2DV_e.js";
import "./componentMap-CElCaWis.js";
import "./format-DgF6KtHk.js";
import "./omit-B2_8Y6O_.js";
import "./_flatRest-DBrd2CHT.js";
import "./flatten-DeoUZLdb.js";
import "./print-CT_2hrjP.js";
import "./useTimeout-BxFilWvD.js";
import "./usePageCache-DluHn7Yy.js";
import "./Flex-CTSf12gq.js";
import "./equipmentMainLibrary-bJTzj5mC.js";
import "./useRole-C-Zpngq4.js";
import "./toInteger-DQeH-nF-.js";
let Ot;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })(),
    (()=>{
        try {
            return __tla_1;
        } catch  {}
    })()
]).then(async ()=>{
    const { t: u } = E();
    function Le(l) {
        return [
            {
                field: "file",
                label: u("requisitionOrder.attachmentsTab.file"),
                slot: "fileSlot",
                rules: [
                    {
                        key: "file",
                        required: !0,
                        message: u("requisitionOrder.attachmentsTab.filePlaceholder"),
                        trigger: [
                            "change",
                            "blur"
                        ],
                        type: "object"
                    }
                ]
            },
            {
                field: "remark",
                component: "NInput",
                label: u("requisitionOrder.attachmentsTab.remark"),
                componentProps: {
                    placeholder: u("requisitionOrder.attachmentsTab.remark"),
                    type: "textarea",
                    showCount: !0,
                    maxlength: 1e3,
                    autosize: {
                        minRows: 3,
                        maxRows: 3
                    }
                },
                rules: [
                    {
                        required: !0,
                        message: u("requisitionOrder.attachmentsTab.remarkRequired"),
                        trigger: [
                            "blur"
                        ]
                    }
                ]
            }
        ];
    }
    let I, Ve, $e;
    ({ t: I } = E());
    Ve = [
        {
            title: I("requisitionOrder.attachmentsTab.fileName"),
            key: "attachName",
            width: 200,
            render: (l)=>g("a", {
                    href: l.attachUrl,
                    target: "_blank",
                    rel: "noopener noreferrer",
                    class: "text-blue-500 underline cursor-pointer"
                }, l.attachName)
        },
        {
            title: I("requisitionOrder.attachmentsTab.remark"),
            key: "description",
            width: 480
        }
    ];
    $e = {
        style: {
            "margin-bottom": "12px"
        }
    };
    Ot = ee({
        __name: "index",
        props: {
            procurementCategory: {},
            reqFormOtherInfo: {}
        },
        setup (l) {
            const { t: o } = E(), c = te(), b = l, B = oe(), R = ne(()=>B.query.type ?? m.CREATE);
            ae(()=>b.procurementCategory, ()=>{
                p();
            });
            const s = C([]), O = C([]);
            async function p() {
                const t = await Re(b.reqFormOtherInfo.id);
                O.value = t.attachList;
            }
            const P = re({
                width: 120,
                title: o("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (t) {
                    return g(Ie, {
                        style: "text",
                        actions: [
                            {
                                label: o("common.optionsEditText"),
                                labelShow: !1,
                                disabled: !1,
                                icon: g("i", {
                                    class: "iconfont icon-a-Frame28"
                                }),
                                onClick: w.bind(null, t)
                            },
                            {
                                label: o("common.delText"),
                                labelShow: !1,
                                disabled: !1,
                                icon: g("i", {
                                    class: "iconfont icon-Delete red"
                                }),
                                onPositiveClick: H.bind(null, t.id),
                                isConfirm: !0,
                                confirmContent: o("common.delPop.contRole")
                            }
                        ]
                    });
                }
            }), [D, { openModal: L, closeModal: V, setSubLoading: $ }] = Ae({
                width: 600,
                title: o("requisitionOrder.attachmentsTab.uploadAttachment")
            }), [U, { submit: Ue, setFieldsValue: z, getFieldsValue: M, validate: j }] = De({
                schemas: Le(),
                labelWidth: "auto",
                layout: "horizontal",
                gridProps: {
                    cols: 1,
                    xGap: 15
                },
                showActionButtonGroup: !1
            });
            async function G() {
                j().then(()=>{
                    const { file: t, remark: n } = M();
                    we({
                        ...d.value ? {
                            id: d.value
                        } : {
                            reqId: b.reqFormOtherInfo.id
                        },
                        attachName: t.name,
                        attachPath: t.path,
                        description: n
                    }).then((f)=>{
                        c.success(d.value ? o("common.replaceSuccessText") : o("common.uploadSuccessText")), p(), V();
                    });
                }).finally(()=>{
                    $(!1);
                });
            }
            function K({ file: t, event: n }, f, T) {
                try {
                    const i = Ce("(" + n.target.response + ")"), { infoField: y } = Ee.upload.apiSetting, { code: x } = i, S = i.msg || i.message || o("common.uploadFailText"), h = i[y];
                    x === qe.SUCCESS ? f[T] = {
                        name: t.name,
                        path: h.name,
                        url: h.url,
                        status: "finished"
                    } : c.error(S);
                } catch (i) {
                    console.error(i);
                }
            }
            function W(t) {
                s.value = [];
            }
            function X(t) {
                console.warn("File upload error:", t), c.error(o("common.uploadFailText"));
            }
            const d = C(null);
            function w(t) {
                d.value = t?.id || null, s.value = [], L(), ie(()=>{
                    t && (z({
                        file: {
                            name: t.attachName,
                            url: t.attachUrl,
                            status: "finished"
                        },
                        remark: t.description || ""
                    }), s.value = [
                        {
                            name: t.attachName,
                            url: t.attachUrl,
                            status: "finished"
                        }
                    ]);
                });
            }
            function H(t) {
                Oe(t).then(()=>{
                    c.success(o("common.delPop.success")), p();
                }).catch((n)=>{
                    console.error("Delete attachment failed:", n), c.error(o("common.error.error"));
                });
            }
            return se(()=>{
                p();
            }), (t, n)=>{
                const f = me, T = ce, i = Te, y = xe, x = Se, S = ge, h = pe, Z = ve, J = ke;
                return A(), F(J, null, {
                    default: a(()=>[
                            e(N)([
                                e(m).CREATE,
                                e(m).EDIT
                            ], e(R)) ? (A(), F(T, {
                                key: 0,
                                trigger: "hover"
                            }, {
                                trigger: a(()=>[
                                        r(f, {
                                            type: "primary",
                                            onClick: n[0] || (n[0] = (_)=>w())
                                        }, {
                                            icon: a(()=>[
                                                    r(e(ue))
                                                ]),
                                            _: 1
                                        })
                                    ]),
                                default: a(()=>[
                                        q(" " + v(e(o)("requisitionOrder.attachmentsTab.uploadAttachment")), 1)
                                    ]),
                                _: 1
                            })) : le("", !0),
                            r(e(Ne), {
                                class: "w-[800px]",
                                columns: e(Ve),
                                dataSource: e(O),
                                "row-key": (_)=>_.attachPath,
                                pagination: !1,
                                ref: "itemDetailsTableRef",
                                actionColumn: e(N)([
                                    e(m).CREATE,
                                    e(m).EDIT
                                ], e(R)) ? e(P) : void 0,
                                autoScrollX: !0,
                                "virtual-scroll": "",
                                showTableSetting: !1
                            }, null, 8, [
                                "columns",
                                "dataSource",
                                "row-key",
                                "actionColumn"
                            ]),
                            r(e(Fe), {
                                onRegister: e(D),
                                onOnOk: G
                            }, {
                                default: a(()=>[
                                        r(Z, {
                                            onRegister: e(U)
                                        }, {
                                            fileSlot: a(({ model: _, field: Q })=>[
                                                    r(h, {
                                                        "directory-dnd": "",
                                                        "file-list": e(s),
                                                        "onUpdate:fileList": n[1] || (n[1] = (k)=>_e(s) ? s.value = k : null),
                                                        accept: ".pdf,.jpg,.png",
                                                        action: `${e(he)().urlPrefix}${e(Be) === e(Pe).OFFICE ? "/system" : ""}/files`,
                                                        headers: {
                                                            timestamp: new Date().getTime(),
                                                            authorization: `${e(de).get(e(fe))}`
                                                        },
                                                        max: 1,
                                                        onRemove: W,
                                                        onError: X,
                                                        onFinish: ({ file: k, event: Y })=>K({
                                                                file: k,
                                                                event: Y
                                                            }, _, Q)
                                                    }, {
                                                        default: a(()=>[
                                                                r(S, null, {
                                                                    default: a(()=>[
                                                                            be("div", $e, [
                                                                                r(i, {
                                                                                    size: "48",
                                                                                    depth: 3,
                                                                                    component: e(ye)
                                                                                }, null, 8, [
                                                                                    "component"
                                                                                ])
                                                                            ]),
                                                                            r(y, {
                                                                                style: {
                                                                                    "font-size": "16px"
                                                                                }
                                                                            }, {
                                                                                default: a(()=>[
                                                                                        q(v(e(o)("requisitionOrder.attachmentsTab.uploadBtn")), 1)
                                                                                    ]),
                                                                                _: 1
                                                                            }),
                                                                            r(x, {
                                                                                depth: "3",
                                                                                style: {
                                                                                    margin: "8px 0 0 0"
                                                                                }
                                                                            }, {
                                                                                default: a(()=>[
                                                                                        q(v(e(o)("requisitionOrder.attachmentsTab.uploadTips")), 1)
                                                                                    ]),
                                                                                _: 1
                                                                            })
                                                                        ]),
                                                                    _: 1
                                                                })
                                                            ]),
                                                        _: 2
                                                    }, 1032, [
                                                        "file-list",
                                                        "action",
                                                        "headers",
                                                        "onFinish"
                                                    ])
                                                ]),
                                            _: 1
                                        }, 8, [
                                            "onRegister"
                                        ])
                                    ]),
                                _: 1
                            }, 8, [
                                "onRegister"
                            ])
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { Ot as default, __tla };
