@shwxdyjs/element-plus-common-components
Version:
基于element-plus的Ht-public公共组件
1,512 lines (1,511 loc) • 114 kB
JavaScript
import './style.css';
import ot, { ElMessage as _e } from "element-plus";
import { ElTag as Ne, ElNotification as te, ElOption as fe, ElSelect as me, ElInput as G, ElFormItem as de, ElForm as ue, ElButton as H, ElDialog as he, ElLoadingDirective as ge, ElMessageBox as ve, ElMessage as Me, ElTableColumn as Fe, ElIcon as qe, ElDropdownItem as Ae, ElDropdownMenu as Be, ElDropdown as ye, ElEmpty as at, ElTable as je, ElConfigProvider as nt, ElPagination as Pe, ElRadio as st, ElRow as it, ElDatePicker as rt, ElTree as dt, ElTabPane as ut, ElTabs as ct, ElUpload as pt, ElCascader as ft } from "element-plus/es";
import { defineComponent as W, reactive as Q, toRefs as J, openBlock as d, createBlock as g, withCtx as i, createTextVNode as T, toDisplayString as I, toRaw as le, mergeProps as U, renderSlot as R, createVNode as C, withDirectives as be, createCommentVNode as _, createElementBlock as E, Fragment as z, renderList as N, resolveDynamicComponent as K, onMounted as X, nextTick as He, resolveComponent as q, createElementVNode as O, withModifiers as Se, createSlots as we, normalizeStyle as Oe, normalizeProps as mt, inject as ht, computed as We, watch as Ee, normalizeClass as gt } from "vue";
import { Search as Ve, ArrowDown as Qe, User as yt } from "@element-plus/icons-vue";
import { get as Je, cloneDeep as ce } from "lodash-es";
import bt from "axios";
import St from "qs";
import wt from "js-cookie";
import { defineStore as Ke, createPinia as Ct } from "pinia";
import { Splitpanes as kt, Pane as _t } from "splitpanes";
import Dt from "pinia-plugin-persistedstate";
const A = (e, o) => {
const t = e.__vccOpts || e;
for (const [c, a] of o)
t[c] = a;
return t;
}, vt = W({
name: "TableColTag",
components: {},
props: {
modelValue: {
type: [String, Number],
default: ""
},
mapper: {
// 形式如: {STATECODE1:{text:'状态1',type:'success'}}
type: Object,
require: !0,
default: () => ({})
}
},
emits: [""],
setup() {
const e = Q({});
return {
...J(e)
};
}
});
function Vt(e, o, t, c, a, s) {
const l = Ne;
return d(), g(l, {
type: e.mapper[e.modelValue].type
}, {
default: i(() => [
T(I(e.mapper[e.modelValue].text), 1)
]),
_: 1
}, 8, ["type"]);
}
const Te = /* @__PURE__ */ A(vt, [["render", Vt]]);
const Et = W({
name: "TableEdit",
props: {
labelWidth: {
type: String,
default: "120px"
},
/*
form-meta 为CRUD弹窗表单元数据信息
{
label: '表单标签',
field: '字段键值',
component: '组件类型,可不填,默认 el-input'
rule: [] // 字段校验
attr: {
// 其他属性
}
},
*/
formMeta: {
type: Array,
default: () => []
},
// 弹出对话框的class
dlgClass: {
type: String,
default: "crud-dlg"
}
},
emits: ["editCommit"],
// emits: ['fetch-data'],
setup(e, { emit: o, attrs: t }) {
console.log("TableEdit:", t);
let c = { c: {}, u: {} };
e.formMeta.forEach((r) => {
if (r.rule) {
let m = r.editComponent && r.editComponent.bindfield || r.field;
r.rule instanceof Array ? (c.c[m] = r.rule, c.u[m] = r.rule) : (c.c[m] = r.rule.c, c.u[m] = r.rule.u);
}
}), console.log("hear is the form rules:", c);
const a = Q({
mode: "c",
// 模式 c-新建 u-更新
commitLoading: !1,
formRef: null,
formData: {},
formMetaRuntime: [],
rules: c,
title: "",
dialogFormVisible: !1,
showCustomDlg: !1,
// 用于控制是否显示自定义dlg的开关
dlgWidth: "50vw"
});
Object.keys(a.rules.c).forEach((r) => {
a.rules.c[r].forEach((m) => {
m.refForm = () => a.formData;
});
}), Object.keys(a.rules.u).forEach((r) => {
a.rules.u[r].forEach((m) => {
m.refForm = () => a.formData;
});
});
const s = (r) => {
a.formMetaRuntime = [], r ? (a.title = "编辑", a.mode = "u", e.formMeta.forEach((m) => {
(!m.editExclusive || m.editExclusive.when === "update" || !m.editExclusive.when) && a.formMetaRuntime.push(m);
}), a.formData = JSON.parse(JSON.stringify(r))) : (a.title = "新建", a.mode = "c", a.formData = {}, e.formMeta.forEach((m) => {
(!m.editExclusive || m.editExclusive.when === "create" || !m.editExclusive.when) && a.formMetaRuntime.push(m), m.default !== void 0 && (a.formData[m.editComponent && m.editComponent.bindfield || m.field] = m.default);
}), console.log("初始化后的formdata", a.formData)), a.dialogFormVisible = !0;
}, l = (r, m) => {
m instanceof String ? a.title = m : (a.title = m.title || a.title, a.dlgWidth = m.dlgWidth || a.dlgWidth), r ? (a.showCustomDlg = !1, a.formMetaRuntime = [], a.title = m, a.mode = "m", e.formMeta.forEach((V) => {
(!V.editExclusive || V.editExclusive.when === "custom" || !V.editExclusive.when) && a.formMetaRuntime.push(V);
}), a.formData = JSON.parse(JSON.stringify(r))) : a.showCustomDlg = !0, a.dialogFormVisible = !0;
}, h = () => {
a.showCustomDlg || a.formRef.resetFields(), a.formData = {}, a.dialogFormVisible = !1;
}, n = () => {
a.showCustomDlg ? (a.formData = {}, a.dialogFormVisible = !1) : a.formRef.validate(async (r) => {
r && (a.commitLoading = !0, console.log("原始formdata", a.formData), o(
"editCommit",
le(a.formData),
a.mode === "m" ? null : a.title === "新建"
));
});
}, f = (r) => {
console.log("Edit组件接收到的响应:", r), a.commitLoading = !1, r.result ? h() : te.error("操作数据发生错误:" + r.message);
};
return {
...J(a),
handleCommitCompleted: f,
showEditCustom: l,
showEdit: s,
close: h,
save: n
};
}
});
function Tt(e, o, t, c, a, s) {
const l = fe, h = me, n = G, f = de, r = ue, m = H, V = he, w = ge;
return d(), g(V, U({
modelValue: e.dialogFormVisible,
"onUpdate:modelValue": o[0] || (o[0] = (b) => e.dialogFormVisible = b)
}, e.$attrs, {
class: e.dlgClass,
title: e.title,
width: e.dlgWidth,
onClose: e.close
}), {
footer: i(() => [
R(e.$slots, "dlg-footer", {}, () => [
C(m, { onClick: e.close }, {
default: i(() => [
T("取 消")
]),
_: 1
}, 8, ["onClick"]),
be((d(), g(m, {
type: "primary",
onClick: e.save
}, {
default: i(() => [
T(" 确 定 ")
]),
_: 1
}, 8, ["onClick"])), [
[w, e.commitLoading]
])
])
]),
default: i(() => [
e.showCustomDlg ? R(e.$slots, "dlg-content", { key: 0 }) : _("", !0),
e.showCustomDlg ? _("", !0) : (d(), g(r, {
key: 1,
ref: "formRef",
"label-position": "left",
"label-width": e.labelWidth,
model: e.formData,
rules: e.rules[e.mode]
}, {
default: i(() => [
(d(!0), E(z, null, N(e.formMetaRuntime.filter((b) => !b.columnsExclusive), (b) => (d(), g(f, {
key: b.field,
label: b.label,
prop: b.editComponent && b.editComponent.bindfield || b.field
}, {
default: i(() => [
b.editComponent && b.editComponent.name === "el-select" ? (d(), g(h, U({ key: 0 }, b.editComponent.attr, {
modelValue: e.formData[b.editComponent.bindfield ? b.editComponent.bindfield : b.field],
"onUpdate:modelValue": (D) => e.formData[b.editComponent.bindfield ? b.editComponent.bindfield : b.field] = D,
placeholder: "请选择" + b.label,
"value-key": b.editComponent.valuekey ? b.editComponent.valuekey : "value"
}), {
default: i(() => [
(d(!0), E(z, null, N(b.editComponent.itemSource, (D, S) => (d(), g(l, {
key: S,
label: b.editComponent.labelpath ? D[b.editComponent.labelpath] : D.label,
value: b.editComponent.bindvalue ? b.editComponent.valuepath ? D[b.editComponent.valuepath] : D.value : D
}, null, 8, ["label", "value"]))), 128))
]),
_: 2
}, 1040, ["modelValue", "onUpdate:modelValue", "placeholder", "value-key"])) : _("", !0),
b.editComponent && b.editComponent.name !== "el-select" ? (d(), g(K(b.editComponent.name), U({
key: 1,
modelValue: e.formData[b.field],
"onUpdate:modelValue": (D) => e.formData[b.field] = D,
placeholder: b.placeholder ? b.placeholder : "请填写" + b.label
}, b.editComponent.attr), null, 16, ["modelValue", "onUpdate:modelValue", "placeholder"])) : _("", !0),
b.editComponent ? _("", !0) : (d(), g(n, U({
key: 2,
modelValue: e.formData[b.field],
"onUpdate:modelValue": (D) => e.formData[b.field] = D,
modelModifiers: { trim: !0 },
placeholder: "请填写" + b.label
}, b.editAttr), null, 16, ["modelValue", "onUpdate:modelValue", "placeholder"]))
]),
_: 2
}, 1032, ["label", "prop"]))), 128))
]),
_: 1
}, 8, ["label-width", "model", "rules"]))
]),
_: 3
}, 16, ["modelValue", "class", "title", "width", "onClose"]);
}
const $e = /* @__PURE__ */ A(Et, [["render", Tt]]), $t = W({
name: "TableColTagField",
components: {},
props: {
modelValue: {
type: [String, Number],
default: ""
},
prepend: {
type: String,
default: "移动端"
},
prependReplace: {
type: String,
default: "mobile_"
}
},
emits: [""],
setup() {
const e = Q({});
return {
...J(e)
};
}
});
function Ut(e, o, t, c, a, s) {
const l = Ne;
return d(), E(z, null, [
C(l, null, {
default: i(() => [
T(I(e.prepend), 1)
]),
_: 1
}),
T(" " + I(e.modelValue.replace(e.prependReplace, "")), 1)
], 64);
}
const It = /* @__PURE__ */ A($t, [["render", Ut]]);
const Mt = W({
name: "TableDetail",
props: {
labelWidth: {
type: String,
default: "120px"
},
/*
form-meta 为CRUD弹窗表单元数据信息
{
label: '表单标签',
field: '字段键值',
component: '组件类型,可不填,默认 el-input'
rule: [] // 字段校验
attr: {
// 其他属性
}
},
*/
formMeta: {
type: Array,
default: () => []
},
// 弹出对话框的class
dlgClass: {
type: String,
default: "crud-dlg"
}
},
emits: [],
// emits: ['fetch-data'],
setup(e, { attrs: o }) {
console.log("TableDetail:", o);
const t = Q({
// mode: 'c', // 模式 c-新建 u-更新
// commitLoading: false,
formRef: null,
formData: {},
formMetaRuntime: [],
title: "",
dialogFormVisible: !1,
showCustomDlg: !1,
// 用于控制是否显示自定义dlg的开关
dlgWidth: "50vw"
}), c = (l) => {
t.formMetaRuntime = [], t.title = "详情", e.formMeta.forEach((h) => {
t.formMetaRuntime.push(h);
}), t.formData = JSON.parse(JSON.stringify(l)), t.dialogFormVisible = !0;
}, a = (l, h) => {
h instanceof String ? t.title = h : (t.title = h.title || t.title, t.dlgWidth = h.dlgWidth || t.dlgWidth), l ? (t.showCustomDlg = !1, t.formMetaRuntime = [], t.title = h, e.formMeta.forEach((n) => {
(!n.editExclusive || n.editExclusive.when === "custom" || !n.editExclusive.when) && t.formMetaRuntime.push(n);
}), t.formData = JSON.parse(JSON.stringify(l))) : t.showCustomDlg = !0, t.dialogFormVisible = !0;
}, s = () => {
t.showCustomDlg || t.formRef.resetFields(), t.formData = {}, t.dialogFormVisible = !1;
};
return {
...J(t),
showDetailCustom: a,
showDetail: c,
close: s
};
}
});
function Ot(e, o, t, c, a, s) {
const l = G, h = de, n = ue, f = H, r = he;
return d(), g(r, U({
modelValue: e.dialogFormVisible,
"onUpdate:modelValue": o[0] || (o[0] = (m) => e.dialogFormVisible = m)
}, e.$attrs, {
class: e.dlgClass,
title: e.title,
width: e.dlgWidth,
onClose: e.close
}), {
footer: i(() => [
R(e.$slots, "dlg-footer", {}, () => [
C(f, { onClick: e.close }, {
default: i(() => [
T("关 闭")
]),
_: 1
}, 8, ["onClick"])
])
]),
default: i(() => [
e.showCustomDlg ? R(e.$slots, "dlg-content", { key: 0 }) : _("", !0),
e.showCustomDlg ? _("", !0) : (d(), g(n, {
key: 1,
ref: "formRef",
"label-width": e.labelWidth,
model: e.formData
}, {
default: i(() => [
(d(!0), E(z, null, N(e.formMetaRuntime.filter((m) => !m.columnsExclusive), (m) => (d(), g(h, {
key: m.field,
label: m.label,
prop: m.component && m.component.bindfield || m.field
}, {
default: i(() => [
m.component ? (d(), g(K(m.component.name), U({
key: 0,
modelValue: e.formData[m.field],
"onUpdate:modelValue": (V) => e.formData[m.field] = V,
readonly: ""
}, m.component.attr), null, 16, ["modelValue", "onUpdate:modelValue"])) : _("", !0),
m.component ? _("", !0) : (d(), g(l, U({
key: 1,
modelValue: e.formData[m.field],
"onUpdate:modelValue": (V) => e.formData[m.field] = V,
modelModifiers: { trim: !0 },
readonly: ""
}, m.editAttr), null, 16, ["modelValue", "onUpdate:modelValue"]))
]),
_: 2
}, 1032, ["label", "prop"]))), 128))
]),
_: 1
}, 8, ["label-width", "model"]))
]),
_: 3
}, 16, ["modelValue", "class", "title", "width", "onClose"]);
}
const Ge = /* @__PURE__ */ A(Mt, [["render", Ot]]);
const Rt = W({
name: "CrudTable",
components: {
Edit: $e,
Detail: Ge,
TableColTag: Te,
Search: Ve,
ArrowDown: Qe
},
props: {
/* 查询条件定义
[
{
field: '查询参数字段'
label: '查询字段名称'
component: '组件名'
}
]
*/
rowScpope: {
type: Object,
default: () => null
},
noHeader: {
type: Boolean,
default: !1
},
autoColHeader: {
type: Boolean,
default: !1
},
queryMeta: {
type: Array,
default: () => []
},
/* 表格列属性定义 */
columnsMeta: {
type: Array,
default: () => []
},
detailMeta: {
type: Array,
default: () => []
},
/* 操作列显示的按钮 */
operList: {
type: Array,
default: () => ["edit"]
},
/* 是否显示索引列 */
showIndex: {
type: Boolean,
default: !0
},
/* 是否显示勾选项 */
showSelection: {
type: Boolean,
default: !0
},
pageSize: {
type: Number,
default: 30
},
pageSizeOption: {
type: Array,
default: () => [20, 30, 50, 100]
},
pagingType: {
type: String,
default: "client"
},
/* 基础按钮的显示控制开关 all 所有按钮显示与否 true/false 优先级最高 | query 查询按钮单控 true/false | update 更新按钮单控 true/false | delete 删除按钮单控 true/false*/
operDisplay: {
type: Object,
default: () => ({ all: !0 })
},
// 弹出对话框的class
dlgClass: {
type: String,
default: "crud-dlg"
},
// 自定义弹出显示详情的回调钩子,入参为当前行,返回值为需要用于显示详情的模型
customDetailHook: {
type: Function,
default: () => null
},
// 表单编辑前可以提供一个钩子函数去对row进行自定义包装
editHook: {
type: Function,
default: () => null
},
dlgAutoHeight: {
type: Boolean,
default: !1
},
buttonCollapseLength: {
type: Number,
default: 3
},
// 是否初始化查询
isInitSearch: {
type: Boolean,
default: !1
}
},
emits: ["queryData", "editCommit", "selectionChange", "deleteData", "sortChange"],
setup(e, { emit: o }) {
const t = async (p) => {
l.listLoading = !0;
let u = await e.customDetailHook(p);
u === null && (u = p), u !== !1 && l.detailRef.showDetail(u), l.listLoading = !1;
}, c = async (p) => {
let u = await e.editHook(p);
u === null && (u = p), u !== !1 && l.editRef.showEdit(u);
}, a = (p) => {
ve.confirm("你确定要删除当前项吗", null, async () => {
l.listLoading = !0, o("deleteData", [p]);
});
}, s = (p, u, v) => {
l.editRef.showEditCustom(p, u, v);
}, l = Q({
operMap: {
edit: {
text: "编辑",
func: c
},
detail: {
text: "详情",
func: t
}
},
editRef: null,
detailRef: null,
listLoading: !1,
dataSource: [],
pageSource: [],
queryForm: {},
// 每次点完查询按钮后暂存的查询条件
cachedQueryForm: null,
selectRows: [],
pageInfo: {
pagingType: e.pagingType,
pageNum: 1,
pageSize: e.pageSize,
pageSizes: e.pageSizeOption,
total: 0,
layout: "total, sizes, prev, pager, next, jumper"
}
}), h = () => {
l.cachedQueryForm = JSON.parse(JSON.stringify(l.queryForm)), n();
}, n = () => {
l.listLoading = !0, o("queryData", le(l.cachedQueryForm), l.pageInfo);
}, f = (p, u) => {
u && (l.pageInfo.pagingType = u), r(p), l.listLoading = !1;
}, r = (p) => {
l.pageInfo.pagingType === "client" ? (l.pageSource = D(p, l.pageInfo), l.dataSource = p) : l.pageInfo.pagingType === "server" ? (l.pageSource = p.content, l.pageInfo.total = p.totalElements, console.log("state.pageInfo", l.pageInfo)) : (l.pageSource = p, l.dataSource = p);
}, m = (p) => {
l.selectRows = p, o("selectionChange", le(p));
}, V = ({ column: p, prop: u, order: v }) => {
o("sortChange", { column: p, prop: u, order: v });
}, w = () => {
l.editRef.showEdit();
}, b = (p, u) => {
u && p.data && p.data instanceof Array && pageInfo.pagingType !== "server" ? (p.data.array.forEach((v) => {
let j = l.dataSource.findIndex(
(Z) => Z.id === (v.id || v)
);
j >= 0 && l.dataSource.splice(j, 1);
}), l.pageInfo.pageNum = 1, l.pageSource = D(
l.dataSource,
l.pageInfo
)) : n();
}, D = (p, u) => (u.total = p.length, p.length <= u.pageSize ? p : p.slice(
(u.pageNum - 1) * u.pageSize,
Math.min(p.length, u.pageNum * u.pageSize)
)), S = (p, u) => {
o("editCommit", p, u);
}, L = (p, u) => {
if (l.editRef.handleCommitCompleted(p), u)
if (p.data && p.data.id && pageInfo.pagingType !== "server") {
let v = l.dataSource.findIndex(
(j) => j.id === p.data.id
);
v >= 0 && l.dataSource.splice(v, 1), l.dataSource.push(p.data), l.pageInfo.pageNum = 1, l.pageSource = D(
l.dataSource,
l.pageInfo
);
} else
n();
else
n();
}, M = () => {
ve.confirm(
"你确定要批量删除勾选项吗?",
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}
).then(() => {
l.listLoading = !0, o("deleteData", l.selectRows), Me({
type: "success",
message: "删除成功"
});
}).catch(() => {
Me({
type: "info",
message: "删除取消"
});
});
}, P = () => {
e.queryMeta.forEach((p) => {
p.default && (l.queryForm[p.field] = p.default);
});
};
return X(async () => {
P(), l.cachedQueryForm = JSON.parse(JSON.stringify(l.queryForm)), He(() => {
console.log("props.isInitSearch", e.isInitSearch), e.isInitSearch && h();
});
}), {
Search: Ve,
handleCommit: S,
handleAdd: w,
handleDetail: t,
handleEdit: c,
handleDelete: a,
handleDeleteDataCompleted: b,
handleQuery: h,
fetchData: n,
handleQueryDataCompleted: f,
handleCommitCompleted: L,
setSelectRows: m,
tableSortChange: V,
handleDeleteBatch: M,
handleCurrentChange: (p) => {
l.pageInfo.pageNum = p, l.pageInfo.pagingType === "client" ? l.pageSource = D(l.dataSource, l.pageInfo) : l.pageInfo.pagingType === "server" ? n() : l.pageSource = data;
},
clientPagiNation: D,
handleSizeChange: (p) => {
l.pageInfo.pageSize = p, l.pageInfo.pageNum = 1, l.pageInfo.pagingType === "client" ? l.pageSource = D(l.dataSource, l.pageInfo) : l.pageInfo.pagingType === "server" && l.cachedQueryForm !== null && n();
},
handleEmit: (p, u) => {
console.log(u, e.operList), o(u, p);
},
handleCustomEdit: s,
resetData: () => {
l.pageInfo.pageNum = 1, l.pageInfo.total = 0, l.pageSource = [], l.dataSource = [];
},
closeDialog: () => {
l.editRef.close();
},
scopeMethods: (p, u) => Je(p, u),
...J(l)
};
}
}), zt = { class: "sys-system-container macross-container" }, Lt = {
key: 0,
class: "macross-container-header"
}, Nt = { class: "macross-container-header-filter" }, Ft = { class: "macross-container-body" }, qt = ["title"], At = { class: "el-dropdown-link" }, Bt = { class: "macross-container-foot" };
function jt(e, o, t, c, a, s) {
const l = fe, h = me, n = G, f = de, r = ue, m = H, V = Fe, w = q("arrow-down"), b = qe, D = Ae, S = Be, L = ye, M = at, P = je, B = nt, x = Pe, ee = q("edit"), k = q("detail"), $ = ge;
return d(), E("div", zt, [
e.noHeader ? _("", !0) : (d(), E("div", Lt, [
O("div", Nt, [
C(r, {
ref: "qf",
inline: !0,
onSubmit: o[0] || (o[0] = Se(() => {
}, ["prevent"]))
}, {
default: i(() => [
R(e.$slots, "prepend-query-form", {}, void 0, !0),
(d(!0), E(z, null, N(e.queryMeta, (y) => (d(), g(f, {
key: y.field,
label: y.label,
prop: y.field
}, {
default: i(() => [
y.component === "el-select" ? (d(), g(h, U({
key: 0,
modelValue: e.queryForm[y.field],
"onUpdate:modelValue": (p) => e.queryForm[y.field] = p,
"value-key": y.value
}, y.attr), {
default: i(() => [
(d(!0), E(z, null, N(y.itemSource, (p, u) => (d(), g(l, {
key: u,
label: p.label,
value: p
}, null, 8, ["label", "value"]))), 128))
]),
_: 2
}, 1040, ["modelValue", "onUpdate:modelValue", "value-key"])) : _("", !0),
y.component && y.component !== "el-select" ? (d(), g(K(y.component), U({
key: 1,
modelValue: e.queryForm[y.field],
"onUpdate:modelValue": (p) => e.queryForm[y.field] = p,
placeholder: "请填写" + y.label
}, y.attr), null, 16, ["modelValue", "onUpdate:modelValue", "placeholder"])) : _("", !0),
y.component ? _("", !0) : (d(), g(n, {
key: 2,
modelValue: e.queryForm[y.field],
"onUpdate:modelValue": (p) => e.queryForm[y.field] = p,
autosize: "",
placeholder: "请填写" + y.label,
style: { width: "120px" }
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"]))
]),
_: 2
}, 1032, ["label", "prop"]))), 128)),
R(e.$slots, "append-query-form", {}, void 0, !0)
]),
_: 3
}, 512)
]),
C(r, {
ref: "queryFormButton",
inline: !0
}, {
default: i(() => [
R(e.$slots, "prepend-query-button", {}, void 0, !0),
!e.operDisplay || e.operDisplay.all || e.operDisplay.query ? (d(), g(f, {
key: 0,
label: ""
}, {
default: i(() => [
C(m, {
icon: e.Search,
type: "primary",
onClick: e.handleQuery
}, {
default: i(() => [
T(I(e.operDisplay && e.operDisplay.query && e.operDisplay.query.text || "查询"), 1)
]),
_: 1
}, 8, ["icon", "onClick"])
]),
_: 1
})) : _("", !0),
!e.operDisplay || e.operDisplay.all || e.operDisplay.create ? (d(), g(f, { key: 1 }, {
default: i(() => [
C(m, {
type: "success",
onClick: e.handleAdd
}, {
default: i(() => [
T(I(e.operDisplay && e.operDisplay.create && e.operDisplay.create.text || "新增"), 1)
]),
_: 1
}, 8, ["onClick"])
]),
_: 1
})) : _("", !0),
(!e.operDisplay || e.operDisplay.all || e.operDisplay.delete) && e.selectRows.length > 0 ? (d(), g(f, { key: 2 }, {
default: i(() => [
C(m, {
type: "danger",
onClick: e.handleDeleteBatch
}, {
default: i(() => [
T(I(e.operDisplay && e.operDisplay.delete && e.operDisplay.delete.text || "删除"), 1)
]),
_: 1
}, 8, ["onClick"])
]),
_: 1
})) : _("", !0),
R(e.$slots, "append-query-button", {}, void 0, !0)
]),
_: 3
}, 512)
])),
O("div", Ft, [
C(B, null, {
default: i(() => [
be((d(), g(P, {
ref: "tableCrud",
border: "",
data: e.pageSource,
height: "100%",
onSelectionChange: e.setSelectRows,
onSortChange: e.tableSortChange
}, {
empty: i(() => [
R(e.$slots, "empty", {}, () => [
C(M, {
description: "暂无数据",
"image-size": 100
})
], !0)
]),
default: i(() => [
e.showSelection ? (d(), g(V, {
key: 0,
align: "center",
fixed: "left",
"show-overflow-tooltip": "",
type: "selection",
width: "55"
})) : _("", !0),
e.showIndex ? (d(), g(V, {
key: 1,
align: "center",
label: "序号",
"show-overflow-tooltip": "",
width: "55"
}, {
default: i(({ $index: y }) => [
T(I(y + 1 + (e.pageInfo.pageNum - 1) * e.pageInfo.pageSize), 1)
]),
_: 1
})) : _("", !0),
(d(!0), E(z, null, N(e.columnsMeta.filter(
(y) => !y.editExclusive && !y.detailExclusive
), (y, p) => (d(), g(V, U({
key: p,
align: y.align ? y.align : "left"
}, y.attr, {
label: y.label,
"min-width": y.minWidth,
prop: y.field,
"show-overflow-tooltip": y.showOverflowTooltip,
width: y.width
}), we({ _: 2 }, [
y.colComponent ? {
name: "default",
fn: i((u) => [
y.colComponent.slot ? _("", !0) : (d(), g(K(y.colComponent.name), U({
key: 0,
modelValue: u.row[y.field],
"onUpdate:modelValue": (v) => u.row[y.field] = v
}, y.colComponent.attr), null, 16, ["modelValue", "onUpdate:modelValue"])),
y.colComponent.slot ? R(e.$slots, y.colComponent.slot, {
key: 1,
row: u.row
}, void 0, !0) : _("", !0)
]),
key: "0"
} : {
name: "default",
fn: i((u) => [
T(I(e.scopeMethods(u.row, y.field)), 1)
]),
key: "1"
},
e.autoColHeader ? {
name: "header",
fn: i(({ column: u }) => [
O("div", {
class: "custom-th",
title: u.label
}, I(u.label), 9, qt)
]),
key: "2"
} : void 0
]), 1040, ["align", "label", "min-width", "prop", "show-overflow-tooltip", "width"]))), 128)),
e.operList.length > 0 ? (d(), g(V, {
key: 2,
align: "center",
fixed: "right",
label: "操作",
"show-overflow-tooltip": "",
width: e.operList.length < e.buttonCollapseLength ? e.operList.length * 50 + 30 : 80
}, {
default: i(({ row: y }) => [
e.operList.length < e.buttonCollapseLength ? (d(!0), E(z, { key: 0 }, N(e.operList, (p, u) => (d(), g(m, {
key: u,
link: "",
style: Oe(`display:${p.show ? p.show(y) ? "" : "none" : ""}`),
type: "primary",
onClick: (v) => typeof p == "string" ? e.operMap[p].func(y) : e.handleEmit(y, p.emit)
}, {
default: i(() => [
T(I(typeof p == "string" ? e.operMap[p].text : p.text), 1)
]),
_: 2
}, 1032, ["style", "onClick"]))), 128)) : _("", !0),
e.operList.length >= e.buttonCollapseLength ? (d(), g(L, { key: 1 }, {
dropdown: i(() => [
C(S, null, {
default: i(() => [
(d(!0), E(z, null, N(e.operList, (p, u) => (d(), g(D, {
key: u,
style: Oe(`display:${p.show ? p.show(y) ? "" : "none" : ""}`),
onClick: (v) => typeof p == "string" ? e.operMap[p].func(y) : e.handleEmit(y, p.emit)
}, {
default: i(() => [
T(I(typeof p == "string" ? e.operMap[p].text : p.text), 1)
]),
_: 2
}, 1032, ["style", "onClick"]))), 128))
]),
_: 2
}, 1024)
]),
default: i(() => [
O("span", At, [
T(" 更多 "),
C(b, { class: "el-icon--right" }, {
default: i(() => [
C(w)
]),
_: 1
})
])
]),
_: 2
}, 1024)) : _("", !0)
]),
_: 1
}, 8, ["width"])) : _("", !0)
]),
_: 3
}, 8, ["data", "onSelectionChange", "onSortChange"])), [
[$, e.listLoading]
])
]),
_: 3
})
]),
O("div", Bt, [
C(B, null, {
default: i(() => [
e.pagingType !== "none" ? (d(), g(x, {
key: 0,
"current-page": e.pageInfo.pageNum,
layout: e.pageInfo.layout,
"page-size": e.pageInfo.pageSize,
"page-sizes": e.pageInfo.pageSizes,
total: e.pageInfo.total,
onCurrentChange: e.handleCurrentChange,
onSizeChange: e.handleSizeChange
}, null, 8, ["current-page", "layout", "page-size", "page-sizes", "total", "onCurrentChange", "onSizeChange"])) : _("", !0)
]),
_: 1
})
]),
O("div", null, [
C(ee, {
ref: "editRef",
"close-on-click-modal": !1,
"dlg-class": e.dlgClass + (e.dlgAutoHeight ? " auto-height" : ""),
"form-meta": e.columnsMeta,
onEditCommit: e.handleCommit
}, {
"dlg-content": i(() => [
R(e.$slots, "dlg-custom", {}, void 0, !0)
]),
"dlg-footer": i(() => [
R(e.$slots, "dlg-custom-footer", {}, void 0, !0)
]),
_: 3
}, 8, ["dlg-class", "form-meta", "onEditCommit"])
]),
O("div", null, [
C(k, {
ref: "detailRef",
"close-on-click-modal": !1,
"dlg-class": e.dlgClass + (e.dlgAutoHeight ? " auto-height" : ""),
"form-meta": e.detailMeta
}, null, 8, ["dlg-class", "form-meta"])
])
]);
}
const Pt = /* @__PURE__ */ A(Rt, [["render", jt], ["__scopeId", "data-v-f983add6"]]);
function Ue(e, o) {
return e ? e === "localStorage" ? localStorage.getItem(o) : e === "sessionStorage" ? sessionStorage.getItem(o) : e === "cookie" ? wt.get(o) : localStorage.getItem(o) : localStorage.getItem(o);
}
let Ce = "localStorage", ke = "token";
const Ql = (e = "localStorage", o = "token") => {
Ce = e, ke = o;
};
let oe = "/api", ae = "application/json;charset=UTF-8", ne = "msg", se = 3e4, Y = "code", pe = [200, 0, "200", "0"], ie = Ue(Ce, ke);
const Jl = (e) => {
oe = e.baseURL || oe, ae = e.contentType || ae, ne = e.messageName || ne, se = e.requestTimeout || se, Y = e.statusName || Y, pe = e.codeVerificationArray || pe, ie = e.token || Ue(Ce, ke);
}, Kl = (e) => {
ie = e || Ue(Ce, ke);
}, De = () => ({
baseURL: oe,
contentType: ae,
messageName: ne,
requestTimeout: se,
statusName: Y,
codeVerificationArray: pe,
token: ie
}), Re = {
200: "服务器成功返回请求数据",
201: "新建或修改数据成功",
202: "一个请求已经进入后台排队(异步任务)",
204: "删除数据成功",
400: "发出信息有误",
401: "用户没有权限(令牌失效、用户名、密码错误、登录过期)",
402: "令牌过期",
403: "用户得到授权,但是访问是被禁止的",
404: "访问资源不存在",
406: "请求格式不可得",
410: "请求资源被永久删除,且不会被看到",
500: "服务器发生错误",
502: "网关错误",
503: "服务不可用,服务器暂时过载或维护",
504: "网关超时"
}, ze = async (e) => {
const { data: o, status: t, statusText: c } = e;
let a = o && o[Y] ? o[Y] : t;
switch (pe.indexOf(o[Y]) + 1 && (a = 200), a) {
case 200:
return o;
case 500:
if (e.config.headers && e.config.headers.isResponseReturn)
return o;
o.result !== void 0 && o.result === !1 && te({
title: "请求出错",
type: "danger",
message: "请求出错:" + o.message
});
break;
default:
o.result !== void 0 && o.result === !1 && te({
title: "请求出错",
type: "danger",
message: "请求出错:" + o.message
});
}
const s = `${o && o[ne] ? o[ne] : Re[a] ? Re[a] : c}`;
return console.error(s, "error"), Promise.reject(o);
}, Ie = bt.create({
baseURL: oe,
timeout: se,
headers: {
"Content-Type": ae
}
});
Ie.interceptors.request.use(
(e) => (e.baseURL = oe, e.timeout = se, e.headers["Content-Type"] = ae, ie && (e.headers.Authorization = `Bearer ${ie}`), e.data && e.headers["Content-Type"] === "application/x-www-form-urlencoded;charset=UTF-8" && (e.data = St.stringify(e.data)), e),
(e) => Promise.reject(e)
);
Ie.interceptors.response.use(
(e) => ze(e),
(e) => {
const { response: o } = e;
return o === void 0 ? (e.message.includes("timeout") ? te({
title: "请求出错",
type: "danger",
message: "请求超时!"
}) : te({
title: "请求出错",
type: "danger",
message: "请求失败"
}), Promise.reject(e)) : ze(o);
}
);
function F(e) {
return e.method && typeof e.url ? Ie(e) : new Promise((o) => {
o(null);
});
}
const re = (e, o, t, c) => {
e.forEach((a, s) => {
a.value = a[o], a.label = a[t], a.children && a.children.length === 0 ? a.children = null : c && c === "admin" ? re(a.children, "rolename", t, c) : re(a.children, o, t, c);
});
}, Ht = (e, o, t, c) => (o.forEach((a) => {
(a === "SBYBEJFL" && e[a] || a === "CPLB" && e[a]) && re(e[a].children, t, "dicname"), c[a] = e[a] && e[a].children.map((s) => (s.value = s[t], s.label = s.dicname, s.disabled = !1, s));
}), c), Wt = (e, o, t, c) => (o.forEach((a) => {
(a === "ZCLB" || a === "CPLB" || a === "WZK") && e[a] && re(e[a].children, t, "configname"), c[a] = e[a] && e[a].children.map((s) => (s.value = s[t], s.label = s.configname, s.disabled = !1, s));
}), c), Qt = Ke("account", {
state: () => ({
empSource: null,
// 人员信息
deptSource: null,
// 部门信息
locationSource: { model: null },
// 存放区域信息
assetcodeSource: null,
// 资产分类代码信息
sysDicsData: {},
// 字典表字段集合
customSysDicsData: {},
// 租户自定义字典表字段集合
roleSource: {},
// 租户角色信息
bizMemo: {},
// 人员部门供应商缓存的数据
currentSystem: {}
}),
getters: {
getDeptSource: (e) => e.deptSource,
getEmpSource: (e) => e.empSource,
getBizMemo: async (e) => (console.log("state", e), Object.keys(e.bizMemo).length || await e.setBizMemo(), e.bizMemo),
getCurrentsystem: async (e) => (console.log("currentSystem", e.currentSystem), Object.keys(e.currentSystem).length || await e.setCurrentsystem(), e.currentSystem)
},
actions: {
// 退出的时候调用清空cache
set(e) {
this.empSource = null, this.deptSource = null, this.assetcodeSource = null, this.sysDicsData = {}, this.customSysDicsData = {};
},
/**
* @description 设置人员数据
* @param {Object} context
* @param {String} size 尺寸
*/
setEmpSource(e = {
url: "/base-upms/api/user/all/tssn",
method: "get"
}, o = {
url: "/casc-palms-std-main/api/orgmgr",
method: "get"
}) {
return new Promise(async (t, c) => {
const a = this.currentSystem.shortname;
e.params = {
tssn: "casc-palms-std"
};
let s = await F(e), l = [a];
s.data.length && (l = s.data.map((h) => h.orgcode), l.unshift(a)), e.params = { tssn: l.join() }, F(e).then(async (h) => {
const n = h.data;
if (n) {
let f = [];
Object.keys(n).map((r) => {
f = f.concat(n[r]);
}), this.empSource = f;
}
t();
}).catch((h) => {
console.log("err: ", h), c(h);
});
});
},
/**
* @description 设置部门数据
* @param {Object} context
* @param {String} size 尺寸
*/
setDeptSource(e = void 0, o = {
url: "/base-upms/api/dept/all/hiberarchy",
method: "get"
}) {
if (e && e.length > 1) {
const t = Promise.all(
e.map((c, a) => new Promise(function(s, l) {
a === 0 && (c = void 0), o.params = { schema: c }, F(o).then(async (h) => {
s(h.data);
}).catch((h) => {
console.log("err: ", h), l(h);
});
}))
);
return new Promise((c, a) => {
t.then(async (s) => {
let l = [];
s.map((h) => {
l = l.concat(h);
}), this.deptSource = l, c();
}).catch((s) => {
console.log("err: ", s), a(s);
});
});
} else
return new Promise((t, c) => {
F(o).then(async (a) => {
this.deptSource = a.data, t();
}).catch((a) => {
console.log("err: ", a), c(a);
});
});
},
/**
* @description 设置存放区域信息
* @param {Object} context
* @param {String} size
*/
setLocationSource(e) {
return new Promise(async (o, t) => {
this.locationSource = e, o();
});
},
/**
* @description 设置资产编码信息
* @param {Object} context
* @param {String} size
*/
setAssetcodeSource(e = {
url: "/casc-palmp-main/api/catalog/parentid",
method: "get"
}) {
return new Promise((o, t) => {
F(e).then(async (c) => {
this.assetcodeSource = c.data, o();
}).catch((c) => {
console.log("err: ", c), t(c);
});
});
},
/**
* @description 设置字典表字段集合
* @param {Object} context
* @param {String} size
*/
setSysDicsData({ dicSn: e = [], key: o = "id" }, t = {
url: "/casc-palms-std-main/api/sysdic/dics",
method: "get"
}) {
return new Promise((c, a) => {
t.params = {
codes: e.join()
}, F(t).then(async (s) => {
const l = ce(this.sysDicsData), h = Ht(s.data, e, o, l) || null;
this.sysDicsData = h, c();
}).catch((s) => {
console.log("err: ", s), a(s);
});
});
},
/**
* @description 设置租户自定义字典字段集合
* @param {Object} context
* @param {String} size
*/
setCustomSysDicsData({ dicSn: e = [], key: o = "id" }, t = {
url: "/casc-palms-std-main/api/tenantconfig/configcodes",
method: "get"
}) {
return new Promise((c, a) => {
t.params = {
configcodes: e.join()
}, F(t).then(async (s) => {
const l = ce(this.customSysDicsData), h = Wt(s.data, e, o, l) || null;
this.customSysDicsData = h, c();
}).catch((s) => {
console.log("err: ", s), a(s);
});
});
},
/**
* @description 设置租户角色
* @param {Object} context
* @param {String} size
*/
setRoleSource(e, o = {
url: "/base-upms/api/role/all",
method: "get"
}) {
return new Promise((t, c) => {
const a = rootGetters["d2admin/account/getCurrentSystem"];
o.params = {
isadminrole: e,
schema: a.usibn + "#" + a.shortname
}, F(o).then(async (s) => {
const l = s.data;
re(l.reverse(), "rolecode", "rolename", "admin"), this.roleSource = {
general: e ? this.roleSource.general : l,
admin: e ? l : this.roleSource.admin
}, t();
}).catch((s) => {
console.log("err: ", s), c(s);
});
});
},
/**
* @description 人员部门供应商选择器缓存
* @param {Object} context
* @param {String} size
*/
setBizMemo(e = {
url: "/base-upms/api/bizmemo/data",
method: "get"
}) {
return new Promise((o, t) => {
e.params = {
event: "人员部门供应商选择器"
}, F(e).then(async (c) => {
this.bizMemo = c.data || {}, o();
}).catch((c) => {
console.log("err: ", c), t(c);
});
});
},
/**
* @description 登录获取currentSystem
* @param {Object} context
* @param {String} size
*/
setCurrentsystem(e = {
url: "/base-upms/asp-auth/casccalogin",
method: "post"
}) {
return new Promise((o, t) => {
F(e).then(async (c) => {
this.currentsystem = data.currentsystem, o();
}).catch((c) => {
console.log("err: ", c), t(c);
});
});
}
}
});
const Jt = {
name: "HtTableCell",
inject: ["formOptions"],
components: {},
props: {
rowHandle: {
type: Object,
default: null
},
columns: {
type: Array,
default: () => []
},
tableData: {
type: Array,
default: () => []
},
// 设置表格行的class
rowStyleFunc: {
type: Function
},
disabled: {
type: Boolean,
default: !1
}
},
data() {
return {
isLoading: !1,
actionOptions: {},
actionCustom: {},
cacheStore: Qt()
};
},
computed: {
sysDicsData() {
return this.cacheStore.sysDicsData;
},
disabledVisible() {
return this.disabled ? !0 : !!(this.formOptions && this.formOptions.disabled);
}
},
watch: {},
mounted() {
console.log(1222, this.cacheStore);
},
async created() {
if (this.rowHandle) {
const { custom: o, options: t } = this.rowHandle;
this.actionOptions = t, this.actionCustom = o;
}
const e = [];
this.columns.forEach((o) => {
const t = o.component;
t && t.sysdic && e.push(t.sysdic);
}), e.length > 0 && (await this.assetsMethos(e), this.columns.forEach((o) => {
const t = o.component;
t && t.sysdic && this.$set(t, "options", this.sysDicsData[t.sysdic] || []);
}));
},
methods: {
getData() {
return this.tableData;
},
async assetsMethos(e) {
const o = [];
e.forEach((t) => {
this.sysDicsData[t] === void 0 && o.push(!0);
}), o.includes(!0) && await this.cacheStore.setSysDicsData({ dicSn: e, key: "dicname" });
},
// 操作按钮
showFunc(e, o, t) {
return e ? e({ index: o, row: t }) : !0;
}
}
}, Kt = { class: "table-cell-content" }, Gt = { key: 1 };
function Zt(e, o, t, c, a, s) {
const l = st, h = q("vxe-radio-group"), n = q("vxe-option"), f = q("vxe-select"), r = q("vxe-column"), m = H, V = q("vxe-table");
return d(), E("div", Kt, [
C(V, U({
ref: "table",
data: t.tableData,
border: "",
"column-config": { resizable: !0 }
}, a.actionOptions), {
default: i(() => [
(d(!0), E(z, null, N(t.columns, (w, b) => (d(), g(r, U({
key: b,
label: w.title || "",
prop: w.key
}, w), {
default: i((D) => [
w.component && w.component.name ? (d(), E(z, { key: 0 }, [
w.component.name === "el-radio" ? (d(), g(h, U({
key: 0,
modelValue: D.row[w.key],
"onUpdate:modelValue": (S) => D.row[w.key] = S
}, w.component.props, {
disabled: s.disabledVisible,
onChange: () => {
e.$emit("app-change-form", { key: w.key, value: D.row[w.key] });
}
}), {
default: i(() => [
(d(!0), E(z, null, N(w.component.options, (S, L) => (d(), g(l, {
value: S.value,
label: S.value,
key: L
}, {
default: i(() => [
T(I(S.label), 1)
]),
_: 2
}, 1032, ["value", "label"]))), 128))
]),
_: 2
}, 1040, ["modelValue", "onUpdate:modelValue", "disabled", "onChange"])) : w.component.name === "el-select" ? (d(), g(f, U({
key: 1,
modelValue: D.row[w.key],
"onUpdate:modelValue": (S) => D.row[w.key] = S
}, w.component.props, {
disabled: s.disabledVisible,
onChange: () => {
e.$emit("app-change-form", { key: w.key, value: D.row[w.key] });
}
}), {
default: i(() => [
(d(!0), E(z, null, N(w.component.options, (S, L) => (d(), g(n, {
key: L,
label: S.label,
value: w.component.valueKey && w.component.valueKey !== "" ? S : S.value,
disabled: S.disabled
}, null, 8, ["label", "value", "disabled"]))), 128))
]),
_: 2
}, 1040, ["modelValue", "onUpdate:modelValue", "disabled", "onChange"])) : (d(), g(K(w.component.name), U({
key: 2,
disabled: s.disabledVisible,
modelValue: D.row[w.key],
"onUpdate:modelValue": (S) => D.row[w.key] = S,
scope: D.row
}, w.component.props, {
onAppChangeForm: () => {
e.$emit("app-change-form", { key: w.key, value: D.row[w.key], index: D.rowIndex });
},
onChange: () => {
e.$emit("app-change-form", { key: w.key, value: D.row[w.key], index: D.rowIndex });
}
}), null, 16, ["disabled", "modelValue", "onUpdate:modelValue", "scope", "onAppChangeForm", "onChange"]))
], 64)) : (d(), E("span", Gt, I(D.row[w.key]), 1))
]),
_: 2
}, 1040, ["label", "prop"]))), 128)),
t.rowHandle && !s.disabledVisible ? (d(), g(r, mt(U({ key: 0 }, a.actionOptions)), we({
default: i((w) => [
(d(!0), E(z, null, N(a.actionCustom, (b, D) => (d(), E(z, { key: D }, [
s.showFunc(b.show, w.rowIndex, w.row) ? (d(), E(z, { key: 0 }, [
b.text ? (d(), g(m, U({
key: 0,
size: "mini"
}, b, {
onClick: (S) => e.$emit(b.emit, { index: w.rowIndex, row: w.row })
}), {
default: i(() => [
T(I(b.text), 1)
]),
_: 2
}, 1040, ["onClick"])) : (d(), g(m, U({
key: 1,
size: "mini"
}, b, {
onClick: (S) => e.$emit(b.emit, { index: w.rowIndex, row: w.row })
}), null, 16, ["onClick"]))
], 64)) : _("", !0)
], 64))), 128))
]),
_: 2
}, [
a.actionOptions && a.actionOptions.component ? {
name: "header",
fn: i(() => [
(d(), g(K(a.actionOptions.component.name), U({ disabled: s.disabledVisible }, a.actionOptions.component.props, {
onClick: o[0] || (o[0] = (w) => e.$emit(a.actionOptions.component.emit))
}), null, 16, ["disabled"]))
]),
key: "0"
} : void 0
]), 1040)) : _("", !0)
]),
_: 1
}, 16, ["data"])
]);
}
const Ze = /* @__PURE__ */ A(Jt, [["render", Zt]]), Yt = {
name: "HtDialog",
inheritAttrs: !1,
props: {
// 对外暴露visible属性,用于显示隐藏弹框
visible: {
type: Boolean,
default: !1
},
appendToBody: {
type: Boolean,
default: !1
},
loading: {
type: Boolean,
default: !1
},
cancelshow: {
type: Boolean,
default: !0
},
confirmshow: {
type: Boolean,
default: !0
},
typeName: {