import { V, Z as n, bk as N, aA as $, ch as p, d as I, u as O, r as _, a as j, aw as z, ay as F, a4 as L, c as P, o as S, w as i, j as d, W, D as E, l as f, c6 as X, H, aI as Z, p as D, A as x, B as q, i as G, S as K, X as Q, __tla as __tla_0 } from "./index-9PRMimni.js";
import { B as Y } from "./Table-0PViRYCf.js";
import { _ as ee } from "./TableAction.vue_vue_type_script_setup_true_lang-Bj_Y4LtN.js";
import { B as J } from "./BasicSelect-C_uwzMkE.js";
import { e as te } from "./template-rpthWlT9.js";
import { h as ne } from "./unPlannedJob-BvCurP2n.js";
import { i as ae } from "./isEmpty-BUg1OsQj.js";
let fe;
let __tla = Promise.all([
    (()=>{
        try {
            return __tla_0;
        } catch  {}
    })()
]).then(async ()=>{
    let s, se, le, ie, oe;
    ({ t: s } = V());
    se = N();
    le = await te({
        roleType: 2,
        roleCategory: 1
    });
    ie = {
        discipline: s("unPlannedJob.resourcesTable.pic"),
        estimatedTime: s("unPlannedJob.resourcesTable.estimatedTime"),
        timeMeasurement: s("unPlannedJob.resourcesTable.timeMeasurement"),
        actualTimes: s("unPlannedJob.resourcesTable.actualTimes")
    };
    oe = (c)=>{
        const { isView: l } = c;
        return {
            columns: [
                {
                    title: s("unPlannedJob.resourcesTable.no"),
                    key: "num",
                    width: 60,
                    render: (e, t)=>t + 1
                },
                {
                    title: ()=>n("span", {}, [
                            s("unPlannedJob.resourcesTable.pic"),
                            n("span", {
                                style: {
                                    color: "red"
                                }
                            }, [
                                "*"
                            ])
                        ]),
                    key: "discipline",
                    width: 200,
                    titleAlign: "center",
                    align: "left",
                    ellipsis: !1,
                    resizable: !1,
                    render: (e)=>n($, {
                            value: e.discipline,
                            options: le,
                            valueField: "id",
                            labelField: se.getLocale === "en" ? "nameEn" : "name",
                            "onUpdate:value": (t)=>{
                                e.discipline = t;
                            },
                            disabled: l
                        })
                },
                {
                    title: ()=>n("span", {}, [
                            s("unPlannedJob.resourcesTable.estimatedTime"),
                            n("span", {
                                style: {
                                    color: "red"
                                }
                            }, [
                                "*"
                            ])
                        ]),
                    key: "estimatedTime",
                    width: 200,
                    titleAlign: "center",
                    align: "left",
                    render: (e)=>n(p, {
                            value: e.estimatedTime,
                            min: 0,
                            precision: 0,
                            "onUpdate:value": (t)=>{
                                e.estimatedTime = t;
                            },
                            disabled: l
                        })
                },
                {
                    title: ()=>n("span", {}, [
                            s("unPlannedJob.resourcesTable.actualTimes"),
                            n("span", {
                                style: {
                                    color: "red"
                                }
                            }, [
                                "*"
                            ])
                        ]),
                    key: "actualTimes",
                    titleAlign: "center",
                    align: "left",
                    width: 200,
                    render: (e)=>n(p, {
                            min: 0,
                            precision: 0,
                            "onUpdate:value": (t)=>{
                                e.actualTimes = t;
                            },
                            value: e.actualTimes,
                            disabled: l
                        })
                },
                {
                    title: ()=>n("span", {}, [
                            s("unPlannedJob.resourcesTable.timeMeasurement"),
                            n("span", {
                                style: {
                                    color: "red"
                                }
                            }, [
                                "*"
                            ])
                        ]),
                    key: "timeMeasurement",
                    titleAlign: "center",
                    align: "left",
                    width: 200,
                    ellipsis: !1,
                    resizable: !1,
                    render: (e)=>n(J, {
                            style: {
                                width: "100%"
                            },
                            value: e.timeMeasurement,
                            cacheKey: "unplanned_time_unit",
                            "onUpdate:value": (t)=>{
                                e.timeMeasurement = t;
                            },
                            disabled: l
                        })
                },
                {
                    title: s("unPlannedJob.resourcesTable.estimatedCost"),
                    key: "estimatedCost",
                    titleAlign: "center",
                    align: "left",
                    width: 200,
                    render: (e)=>n(p, {
                            min: 0,
                            precision: 2,
                            value: e.estimatedCost,
                            "onUpdate:value": (t)=>{
                                e.estimatedCost = t;
                            },
                            disabled: l
                        })
                },
                {
                    title: s("unPlannedJob.resourcesTable.actualCost"),
                    key: "actualCost",
                    titleAlign: "center",
                    align: "left",
                    width: 200,
                    render: (e)=>n(p, {
                            min: 0,
                            precision: 2,
                            value: e.actualCost,
                            "onUpdate:value": (t)=>{
                                e.actualCost = t;
                            },
                            disabled: l
                        })
                },
                {
                    title: s("unPlannedJob.resourcesTable.currency"),
                    key: "currency",
                    titleAlign: "center",
                    align: "left",
                    width: 200,
                    render: (e)=>n(J, {
                            cacheKey: "currency",
                            value: e.currency,
                            onUpdateValue: (t)=>{
                                e.currency = t;
                            },
                            disabled: l
                        })
                }
            ]
        };
    };
    fe = I({
        __name: "index",
        props: {
            sourceData: {
                type: Object,
                default: null
            },
            isView: {
                default: !1,
                type: Boolean
            }
        },
        setup (c, { expose: l }) {
            const b = c, { t: e } = V(), t = O(), M = _(), r = _([]), T = _(!0), w = _(""), A = j({
                width: 160,
                title: e("common.optionsText"),
                key: "action",
                fixed: "right",
                align: "center",
                render (a, o) {
                    return n(ee, {
                        style: "text",
                        actions: [
                            {
                                label: e("common.optionsDelText"),
                                labelShow: !1,
                                icon: n("i", {
                                    class: "iconfont icon-Delete red"
                                }),
                                onPositiveClick: async ()=>{
                                    a.id ? (await ne([
                                        a.id
                                    ]), C(o), t.success(e("common.optionsDelSuccessText"))) : (C(o), t.success(e("common.optionsDelSuccessText")));
                                },
                                onNegativeClick: ()=>{},
                                isConfirm: !0,
                                confirmContent: e("common.delPop.cont")
                            }
                        ]
                    });
                }
            });
            function C(a) {
                r.value.splice(a, 1);
            }
            function B() {
                const a = [
                    "discipline",
                    "estimatedTime",
                    "actualTimes",
                    "timeMeasurement"
                ];
                return new Promise((o, y)=>{
                    r.value.some((m, g)=>Object.keys(m).some((u)=>{
                            if (a.includes(u) && !m[u]) {
                                T.value = !1;
                                const v = h.value.find((R)=>R.key === u);
                                return w.value = `第${g + 1}行数据【${ie[v?.key]}】必填`, !0;
                            } else return T.value = !0, !1;
                        })) ? y("2") : o(!0);
                });
            }
            function U() {
                const a = {
                    discipline: void 0,
                    estimatedTime: void 0,
                    actualTimes: void 0,
                    timeMeasurement: void 0,
                    estimatedCost: void 0,
                    actualCost: void 0,
                    currency: void 0
                };
                r.value.push(a);
            }
            z(()=>{}), l({
                validate: B,
                formData: r
            }), F(()=>b.sourceData, (a)=>{
                ae(a?.resources) || (r.value = a?.resources);
            }, {
                immediate: !0
            });
            const h = L(()=>{
                const { columns: a } = oe({
                    isView: b.isView
                });
                return a;
            });
            return (a, o)=>{
                const y = Z, k = H, m = K, g = W, u = Q;
                return S(), P(u, null, {
                    default: i(()=>[
                            d(g, {
                                bordered: !1,
                                class: "proCard"
                            }, {
                                default: i(()=>[
                                        d(f(Y), {
                                            columns: f(h),
                                            "row-key": (v)=>v.id,
                                            ref_key: "basicTableRef",
                                            ref: M,
                                            actionColumn: !c.isView && A,
                                            autoScrollX: !0,
                                            dataSource: r.value,
                                            "virtual-scroll": "",
                                            pagination: !1,
                                            showTableSetting: !1
                                        }, X({
                                            _: 2
                                        }, [
                                            c.isView ? void 0 : {
                                                name: "tableTitle",
                                                fn: i(()=>[
                                                        d(k, null, {
                                                            default: i(()=>[
                                                                    d(y, {
                                                                        trigger: "hover"
                                                                    }, {
                                                                        trigger: i(()=>[
                                                                                d(f(q), {
                                                                                    type: "primary",
                                                                                    strong: "",
                                                                                    bordered: "",
                                                                                    secondary: "",
                                                                                    class: "size-7",
                                                                                    onClick: U
                                                                                }, {
                                                                                    icon: i(()=>o[0] || (o[0] = [
                                                                                            G("i", {
                                                                                                class: "iconfont icon-ADD"
                                                                                            }, null, -1)
                                                                                        ])),
                                                                                    _: 1
                                                                                })
                                                                            ]),
                                                                        default: i(()=>[
                                                                                D(" " + x(f(e)("unPlannedJob.add")), 1)
                                                                            ]),
                                                                        _: 1
                                                                    })
                                                                ]),
                                                            _: 1
                                                        })
                                                    ]),
                                                key: "0"
                                            }
                                        ]), 1032, [
                                            "columns",
                                            "row-key",
                                            "actionColumn",
                                            "dataSource"
                                        ]),
                                        T.value ? E("", !0) : (S(), P(m, {
                                            key: 0,
                                            class: "text-red-500"
                                        }, {
                                            default: i(()=>[
                                                    D(x(w.value), 1)
                                                ]),
                                            _: 1
                                        }))
                                    ]),
                                _: 1
                            })
                        ]),
                    _: 1
                });
            };
        }
    });
});
export { fe as _, __tla };
