UNPKG

arco-crud-plus

Version:

基于arco-design-vue的配置化表格表单组件

147 lines (146 loc) 4.78 kB
import { defineComponent as A, useSlots as N, computed as S, resolveComponent as b, openBlock as a, createElementBlock as s, createVNode as k, createSlots as L, withCtx as r, unref as i, renderSlot as m, createCommentVNode as y, createBlock as h, createTextVNode as P, renderList as T, toDisplayString as E, resolveDynamicComponent as R, mergeProps as U } from "vue"; import q from "../table/main.vue.js"; import { validataNull as _, deepCopy as D } from "../utils/validate.js"; import { getComponentBindProps as F } from "../utils/form.js"; const G = { class: "table-edit" }, H = { key: 1 }, J = { key: 0 }, K = { key: 2 }, M = { key: 1 }, Q = { key: 0 }, W = { key: 0, class: "table-edit-slot" }, I = /* @__PURE__ */ A({ name: "aTableEdit", __name: "main", props: { option: { type: Object, default: () => ({}) }, data: { type: Array, default: () => [] }, default: { type: Object }, isDisabled: { type: Object, default: () => () => !1 }, isDelBtn: { type: Object, default: () => () => !0 } }, emits: ["onAdd", "onDel"], setup(u, { expose: C, emit: g }) { const p = N(), v = g, n = u, d = S({ get() { return n.option.search = !1, n.option.page = !1, n.option.tool = !1, n.option; }, set(t) { return !0; } }); function V(t, f) { n.data.splice(f, 1), v("onDel", { record: t, index: f }); } function $() { n.data.push(_(n.default) ? {} : D(n.default)), v("onAdd"); } function B(t) { n.data.splice(t, 1); } function O(t) { n.data.push(D(t)); } return C({ add: O, del: B }), (t, f) => { const j = b("a-button"), z = b("a-popconfirm"); return a(), s("div", G, [ k(q, { option: d.value, data: u.data }, L({ menu: r(({ column: e, record: o, rowIndex: l, size: c }) => [ i(p).menu ? m(t.$slots, "menu", { key: 0, record: o, rowIndex: l, size: c }, void 0, !0) : (a(), s("div", H, [ i(p).menuLeft ? (a(), s("span", J, [ m(t.$slots, "menuLeft", { record: o, rowIndex: l, size: c }, void 0, !0) ])) : y("", !0), u.isDelBtn(o, l) ? (a(), h(z, { key: 1, content: d.value.delConfirm || "确认删除?", type: "error", onOk: (X) => V(o, l) }, { default: r(() => [ k(j, { type: "text", size: "mini", status: "danger" }, { default: r(() => f[0] || (f[0] = [ P("删除") ])), _: 1 }) ]), _: 2 }, 1032, ["content", "onOk"])) : y("", !0), i(p).menuRight ? (a(), s("span", K, [ m(t.$slots, "menuRight", { record: o, rowIndex: l, size: c }, void 0, !0) ])) : y("", !0) ])) ]), _: 2 }, [ T(d.value.columns, (e) => ({ name: e.field, fn: r(({ record: o, rowIndex: l }) => [ i(p)[e.field] ? m(t.$slots, e.field, { key: 0, item: e, column: e, record: o, disabled: d.value.detail ?? e.disabled ?? u.isDisabled(o, l) ?? !1, rowIndex: l, size: d.value.size ?? "small" }, void 0, !0) : (a(), s("span", M, [ i(_)(e.type) ? (a(), s("span", Q, E(o[e.field]), 1)) : (a(), h(R(e.component ? e.component : `a-${e.type || "input"}`), U({ key: 1, style: { width: e.type === "switch" ? "" : "100%" }, size: d.value.size ?? "medium", disabled: d.value.detail ?? e.disabled ?? u.isDisabled(o, l) ?? !1, modelValue: o[e.field], "onUpdate:modelValue": (c) => o[e.field] = c }, i(F)([], e)), null, 16, ["style", "size", "disabled", "modelValue", "onUpdate:modelValue"])) ])) ]) })) ]), 1032, ["option", "data"]), i(p).add ? (a(), s("div", W, [ m(t.$slots, "add", {}, void 0, !0) ])) : (a(), s("div", { key: 1, class: "table-edit-add", onClick: $ }, "+增加")) ]); }; } }); export { I as default };