yxuse 3.0.91 → 3.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api.cjs.js +1 -1
- package/lib/api.es.js +2 -2
- package/lib/components.cjs.js +1 -1
- package/lib/components.es.js +11 -9
- package/lib/hooks.cjs.js +1 -1
- package/lib/hooks.es.js +6 -6
- package/lib/index.cjs.js +1 -1
- package/lib/index.cjs11.js +1 -1
- package/lib/index.cjs12.js +1 -1
- package/lib/index.cjs13.js +1 -1
- package/lib/index.cjs14.js +1 -1
- package/lib/index.cjs2.js +1 -1
- package/lib/index.cjs3.js +1 -1
- package/lib/index.cjs4.js +1 -1
- package/lib/index.cjs5.js +1 -1
- package/lib/index.cjs5.js.gz +0 -0
- package/lib/index.cjs6.js +1 -1
- package/lib/index.cjs7.js +1 -1
- package/lib/index.cjs8.js +1 -1
- package/lib/index.cjs9.js +1 -1
- package/lib/index.es.js +8 -9
- package/lib/index.es11.js +454 -15
- package/lib/index.es12.js +226 -423
- package/lib/index.es13.js +29 -202
- package/lib/index.es14.js +19 -34
- package/lib/index.es2.js +4 -3
- package/lib/index.es3.js +2 -2
- package/lib/index.es4.js +3 -3
- package/lib/index.es5.js +1751 -34
- package/lib/index.es5.js.gz +0 -0
- package/lib/index.es6.js +35 -841
- package/lib/index.es6.js.gz +0 -0
- package/lib/index.es7.js +1 -1
- package/lib/index.es8.js +1 -1
- package/lib/index.es9.js +4 -125
- package/lib/theme.cjs.js +1 -1
- package/lib/theme.es.js +12 -13
- package/lib/translate.cjs.js +1 -1
- package/lib/translate.es.js +9 -10
- package/lib/utils.cjs.js +1 -1
- package/lib/utils.es.js +5 -4
- package/lib/yxIcon.cjs.js +1 -1
- package/lib/yxIcon.es.js +2 -2
- package/lib/yxi18n.cjs.js +1 -1
- package/lib/yxi18n.es.js +1 -1
- package/lib/yxuse.css +1 -1
- package/lib/yxuse.css.gz +0 -0
- package/package.json +1 -1
- package/types/components/CommonPage/pagination.d.ts +2 -2
- package/types/components/CommonPage/props.d.ts +2 -2
- package/types/components/YxForm/index.vue.d.ts +1 -1
- package/types/components/YxForm/type.d.ts +14 -1
- package/types/components/YxNormalPage/config.d.ts +12 -0
- package/types/components/YxNormalPage/form.d.ts +7 -0
- package/types/components/YxNormalPage/index.d.ts +3 -0
- package/types/components/YxNormalPage/page.d.ts +83 -0
- package/types/components/YxNormalPage/pagination.d.ts +9 -0
- package/types/components/YxNormalPage/props.d.ts +40 -0
- package/types/components/YxNormalPage/search.d.ts +9 -0
- package/types/components/YxNormalPage/table.d.ts +5 -0
- package/types/components/YxNormalPage/type.d.ts +69 -0
- package/types/components/YxTable/index.vue.d.ts +4 -4
- package/types/components/YxTableBar/bar.d.ts +47 -0
- package/types/components/YxTableBar/config.d.ts +18 -0
- package/types/components/YxTableBar/index.d.ts +11 -0
- package/types/components/YxTableBar/props.d.ts +23 -0
- package/types/components/YxTableBar/type.d.ts +11 -0
- package/types/components/YxTablePro/index.d.ts +14 -14
- package/types/components/YxUpload/index.vue.d.ts +3 -3
- package/types/components/Yxbutton/index.vue.d.ts +6 -6
- package/types/components/index.d.ts +2 -0
- package/types/hooks/useConfirm/index.d.ts +1 -1
- package/types/hooks/useDialog/type.d.ts +1 -1
- package/types/theme/config.d.ts +1 -1
- package/types/theme/index.d.ts +1 -1
- package/types/utils/common/index.d.ts +7 -1
- package/types/utils/common/util.d.ts +1 -1
- package/types/utils/excel/index.d.ts +8 -8
- package/types/utils/subscribe/index.d.ts +1 -1
- package/lib/index.cjs15.js +0 -1
- package/lib/index.cjs6.js.gz +0 -0
- package/lib/index.es15.js +0 -22
- /package/lib/{index.es12.js.gz → index.es11.js.gz} +0 -0
package/lib/index.es5.js
CHANGED
|
@@ -9,28 +9,37 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
9
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
10
|
var _elId;
|
|
11
11
|
import { b as getCommentUntreatedCount, c as getUserThemeList } from "./index.es4.js";
|
|
12
|
-
import {
|
|
13
|
-
import "xlsx";
|
|
12
|
+
import { defineComponent, useSlots, useAttrs, ref, onMounted, nextTick, watch, onBeforeMount, createBlock, openBlock, resolveDynamicComponent, createVNode, Fragment, resolveComponent, mergeProps, withDirectives, withModifiers, isVNode, h, createApp, reactive, createElementBlock, createElementVNode, createTextVNode, unref, getCurrentInstance, onUnmounted, createStaticVNode, toDisplayString, vShow, Transition, withCtx, normalizeClass, createCommentVNode, normalizeStyle, renderList, useCssVars, version, onActivated, onDeactivated, renderSlot } from "vue";
|
|
13
|
+
import * as XLSX from "xlsx";
|
|
14
14
|
import "./vendor-file-saver.es.js";
|
|
15
15
|
import "xlsx-js-style";
|
|
16
16
|
import { S as Sortable } from "./vendor-sortablejs.es.js";
|
|
17
|
-
import "element-plus";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
17
|
+
import ElementPlus, { ElMessageBox, ElDialog, ElButton, ElMessage, ElIcon, ElDropdown, ElDropdownMenu, ElDropdownItem, ElPopover, ElCheckbox, ElScrollbar, ElCheckboxGroup, ElTooltip, ElDivider } from "element-plus";
|
|
18
|
+
import "element-plus/es/components/divider/style/index";
|
|
19
|
+
import "element-plus/es/components/tooltip/style/index";
|
|
20
|
+
import "element-plus/es/components/dropdown/style/index";
|
|
21
|
+
import "element-plus/es/components/dropdown-menu/style/index";
|
|
22
|
+
import "element-plus/es/components/dropdown-item/style/index";
|
|
23
|
+
import "element-plus/es/components/icon/style/index";
|
|
24
|
+
import "element-plus/es/components/popover/style/index";
|
|
25
|
+
import "element-plus/es/components/scrollbar/style/index";
|
|
26
|
+
import "element-plus/es/components/checkbox-group/style/index";
|
|
27
|
+
import "element-plus/es/components/checkbox/style/index";
|
|
28
|
+
import "element-plus/es/components/button/style/index";
|
|
29
|
+
import { e as changeSystemConfig, f as getSystemConfig, a as http, B as BC_LANG_NAME, i as BC_THEME_NAME, k as setSystemConfig } from "./index.es11.js";
|
|
30
|
+
import { d as deepClone, i as isColorEqual } from "./index.es12.js";
|
|
21
31
|
import "element-plus/es/components/message/style/index";
|
|
22
32
|
import "element-plus/es/components/loading/style/index";
|
|
23
33
|
import "element-plus/es/components/message/style/css";
|
|
24
34
|
import "element-plus/es/components/loading/style/css";
|
|
25
35
|
import "./vendor-mqtt.es.js";
|
|
36
|
+
import { y as yxSubscribe } from "./index.es13.js";
|
|
26
37
|
import { l as localforage } from "./vendor-localforage.es.js";
|
|
27
38
|
import "element-plus/es/components/message-box/style/index";
|
|
28
|
-
import "./vendor-dayjs.es.js";
|
|
39
|
+
import { d as dayjs } from "./vendor-dayjs.es.js";
|
|
29
40
|
import { _ } from "./vendor-lodash.es.js";
|
|
30
41
|
import "./index.es7.js";
|
|
31
|
-
import "./index.es11.js";
|
|
32
42
|
import "element-plus/es/components/dialog/style/index";
|
|
33
|
-
import "element-plus/es/components/button/style/index";
|
|
34
43
|
import "element-plus/es/components/drawer/style/index";
|
|
35
44
|
const YX_TITLE = "@font-face {font-family: 'YX-TITLE';font-size: 16px; src: url('https://yx-picture.obs.cn-north-4.myhuaweicloud.com/ttc/bucket/1699612675710_ALIBABAPUHUITI-2-105-HEAVY.TTF') format('woff'), url('https://yx-picture.obs.cn-north-4.myhuaweicloud.com/ttc/bucket/1699612675710_ALIBABAPUHUITI-2-105-HEAVY.TTF') format('woff2'); font-style: normal;font-display: swap;}";
|
|
36
45
|
const YX_SP_TITLE = "@font-face { font-family: 'YX-SP-TITLE'; font-size: 16px; src: url('https://yx-picture.obs.cn-north-4.myhuaweicloud.com/ttc/bucket/1699844184489_bt.ttf') format('woff'),url('https://yx-picture.obs.cn-north-4.myhuaweicloud.com/ttc/bucket/1699844184489_bt.ttf') format('woff2');font-style: normal; font-display: swap}";
|
|
@@ -54,6 +63,1648 @@ const defaultConfig = {
|
|
|
54
63
|
isTranslateApi: false,
|
|
55
64
|
whitelistTranslateApi: []
|
|
56
65
|
};
|
|
66
|
+
const exportToExcel = ({ header, tableData, fileName }) => {
|
|
67
|
+
const tHeader = header.map((col) => col.label);
|
|
68
|
+
const data = tableData.map((row) => {
|
|
69
|
+
return header.map((col) => row[col.prop]);
|
|
70
|
+
});
|
|
71
|
+
const finalData = [tHeader, ...data];
|
|
72
|
+
const ws = XLSX.utils.aoa_to_sheet(finalData);
|
|
73
|
+
const wb = XLSX.utils.book_new();
|
|
74
|
+
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
|
|
75
|
+
XLSX.writeFile(wb, `${fileName}.xlsx`);
|
|
76
|
+
};
|
|
77
|
+
function _isSlot$2(s) {
|
|
78
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
79
|
+
}
|
|
80
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
81
|
+
...{
|
|
82
|
+
name: "YxTable",
|
|
83
|
+
inheritAttrs: false
|
|
84
|
+
},
|
|
85
|
+
__name: "index",
|
|
86
|
+
props: {
|
|
87
|
+
tableData: {},
|
|
88
|
+
rowKey: {
|
|
89
|
+
default: "id"
|
|
90
|
+
},
|
|
91
|
+
columns: {},
|
|
92
|
+
pageInfo: {},
|
|
93
|
+
sort: {
|
|
94
|
+
type: Boolean
|
|
95
|
+
},
|
|
96
|
+
config: {
|
|
97
|
+
default: () => ({
|
|
98
|
+
headerOverflowHide: true
|
|
99
|
+
})
|
|
100
|
+
},
|
|
101
|
+
sortHandle: {}
|
|
102
|
+
},
|
|
103
|
+
emits: ["operate-handle", "sort-end", "update-page"],
|
|
104
|
+
setup(__props, {
|
|
105
|
+
expose: __expose,
|
|
106
|
+
emit: __emit
|
|
107
|
+
}) {
|
|
108
|
+
const props = __props;
|
|
109
|
+
const slots = useSlots();
|
|
110
|
+
const attrs = useAttrs();
|
|
111
|
+
const tableRef = ref();
|
|
112
|
+
const tableFormRef = ref();
|
|
113
|
+
const columns = ref([]);
|
|
114
|
+
const isFormTable = ref(false);
|
|
115
|
+
const formTableRules = ref({});
|
|
116
|
+
const emit = __emit;
|
|
117
|
+
onMounted(() => {
|
|
118
|
+
nextTick(() => {
|
|
119
|
+
startSort();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
watch(() => props.columns, () => {
|
|
123
|
+
initTable();
|
|
124
|
+
});
|
|
125
|
+
onBeforeMount(async () => {
|
|
126
|
+
await initTable();
|
|
127
|
+
});
|
|
128
|
+
const initTable = async () => {
|
|
129
|
+
columns.value = typeof props.columns === "function" ? await props.columns() : props.columns;
|
|
130
|
+
columns.value.forEach((col) => {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
if (col.required || ((_a = col.rules) == null ? void 0 : _a.length)) {
|
|
133
|
+
isFormTable.value = true;
|
|
134
|
+
}
|
|
135
|
+
if ((col == null ? void 0 : col.renderType) && ["select", "cascader"].includes(col == null ? void 0 : col.renderType) && ((_b = col == null ? void 0 : col.config) == null ? void 0 : _b.loadOptions)) {
|
|
136
|
+
loadOptions2(col.config);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
if (isFormTable.value) {
|
|
140
|
+
getRules();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const loadOptions2 = async (config2) => {
|
|
144
|
+
if ((config2 == null ? void 0 : config2.options) && (config2 == null ? void 0 : config2.options.length) === 0 && (config2 == null ? void 0 : config2.loadOptions) && typeof (config2 == null ? void 0 : config2.loadOptions) === "function") {
|
|
145
|
+
config2.options = await (config2 == null ? void 0 : config2.loadOptions());
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const startSort = () => {
|
|
149
|
+
var _a, _b;
|
|
150
|
+
if (!props.sort) return;
|
|
151
|
+
const sortDom = (_b = (_a = tableRef.value) == null ? void 0 : _a.$el) == null ? void 0 : _b.querySelector(".el-table__body tbody");
|
|
152
|
+
Sortable.create(sortDom, {
|
|
153
|
+
animation: 200,
|
|
154
|
+
// group: "el-table__row table-row",
|
|
155
|
+
sort: true,
|
|
156
|
+
handle: props.sortHandle ? `.${props.sortHandle}` : null,
|
|
157
|
+
onEnd: ({
|
|
158
|
+
oldIndex,
|
|
159
|
+
newIndex
|
|
160
|
+
}) => {
|
|
161
|
+
emit("sort-end", oldIndex, newIndex);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
const dynamicComponent2 = (column, {
|
|
166
|
+
$index,
|
|
167
|
+
row
|
|
168
|
+
}) => {
|
|
169
|
+
let _slot;
|
|
170
|
+
const {
|
|
171
|
+
renderType,
|
|
172
|
+
event = {},
|
|
173
|
+
prop,
|
|
174
|
+
label,
|
|
175
|
+
config: config2 = {},
|
|
176
|
+
required,
|
|
177
|
+
rules
|
|
178
|
+
} = column;
|
|
179
|
+
if (!prop || !renderType) return null;
|
|
180
|
+
const Component = resolveComponent("el-" + renderType);
|
|
181
|
+
const {
|
|
182
|
+
options = [],
|
|
183
|
+
...restConfig
|
|
184
|
+
} = config2;
|
|
185
|
+
const renderChildComponent = () => {
|
|
186
|
+
if (!options || options.length === 0) return null;
|
|
187
|
+
if (renderType === "select") {
|
|
188
|
+
return options.map((item) => createVNode(resolveComponent("el-option"), {
|
|
189
|
+
"label": item.label,
|
|
190
|
+
"value": item.value,
|
|
191
|
+
"key": item.value
|
|
192
|
+
}, null));
|
|
193
|
+
}
|
|
194
|
+
if (renderType === "radio-group") {
|
|
195
|
+
return options.map((item) => createVNode(resolveComponent("el-radio"), {
|
|
196
|
+
"label": item.value,
|
|
197
|
+
"key": item.value
|
|
198
|
+
}, {
|
|
199
|
+
default: () => [item.label]
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
};
|
|
204
|
+
if (renderType === "cascader") {
|
|
205
|
+
return createVNode(resolveComponent("el-cascader"), mergeProps({
|
|
206
|
+
"modelValue": row[prop],
|
|
207
|
+
"onUpdate:modelValue": ($event) => row[prop] = $event,
|
|
208
|
+
"placeholder": `请选择${label}`,
|
|
209
|
+
"options": options
|
|
210
|
+
}, event, restConfig), null);
|
|
211
|
+
}
|
|
212
|
+
const isSelect = ["select", "cascader"].includes(renderType);
|
|
213
|
+
const isFormCell = required || (rules == null ? void 0 : rules.length);
|
|
214
|
+
const modelValue = row[prop];
|
|
215
|
+
const updateModelValue = (val) => {
|
|
216
|
+
row[prop] = (config2 == null ? void 0 : config2.type) === "number" ? Number(val) : val;
|
|
217
|
+
};
|
|
218
|
+
const component = createVNode(Component, mergeProps({
|
|
219
|
+
"modelValue": modelValue,
|
|
220
|
+
"onUpdate:modelValue": updateModelValue,
|
|
221
|
+
"placeholder": `请${isSelect ? "选择" : "输入"}${label}`
|
|
222
|
+
}, event, restConfig), _isSlot$2(_slot = renderChildComponent()) ? _slot : {
|
|
223
|
+
default: () => [_slot]
|
|
224
|
+
});
|
|
225
|
+
if (!isFormCell) return component;
|
|
226
|
+
return renderForm(prop, $index, component);
|
|
227
|
+
};
|
|
228
|
+
const renderForm = (prop, index, component) => {
|
|
229
|
+
return createVNode(resolveComponent("el-form-item"), {
|
|
230
|
+
"prop": "tableData." + index + "." + prop,
|
|
231
|
+
"rules": formTableRules.value[prop]
|
|
232
|
+
}, _isSlot$2(component) ? component : {
|
|
233
|
+
default: () => [component]
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
const getRules = () => {
|
|
237
|
+
const rules = {};
|
|
238
|
+
if (!isFormTable.value) return;
|
|
239
|
+
const handleRule = (item) => {
|
|
240
|
+
if (!item.prop) return;
|
|
241
|
+
const isSelect = (item == null ? void 0 : item.renderType) && ["select", "cascader"].includes(item == null ? void 0 : item.renderType);
|
|
242
|
+
const defaultRule = {
|
|
243
|
+
required: true,
|
|
244
|
+
message: `${item.label ?? "该字段"}不能为空`,
|
|
245
|
+
trigger: isSelect ? "change" : "blur"
|
|
246
|
+
};
|
|
247
|
+
if (item.required) {
|
|
248
|
+
rules[item.prop] = [defaultRule];
|
|
249
|
+
}
|
|
250
|
+
if (item.rules && item.rules.length > 0) {
|
|
251
|
+
rules[item.prop] = [...rules[item == null ? void 0 : item.prop] || [], ...item.rules];
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
columns.value.filter((cell) => ((cell == null ? void 0 : cell.renderType) || (cell == null ? void 0 : cell.render)) && ((cell == null ? void 0 : cell.required) || (cell == null ? void 0 : cell.rules))).forEach((form) => {
|
|
255
|
+
var _a;
|
|
256
|
+
(_a = form.children) == null ? void 0 : _a.forEach(handleRule);
|
|
257
|
+
handleRule(form);
|
|
258
|
+
});
|
|
259
|
+
formTableRules.value = rules;
|
|
260
|
+
};
|
|
261
|
+
const tableFormValidate = async () => {
|
|
262
|
+
if (!isFormTable.value) return Promise.resolve(true);
|
|
263
|
+
if (!tableFormRef.value) return Promise.resolve(false);
|
|
264
|
+
return await tableFormRef.value.validate(() => Promise.resolve());
|
|
265
|
+
};
|
|
266
|
+
const observeWeakMap = /* @__PURE__ */ new WeakMap();
|
|
267
|
+
const vAutoTooltip = {
|
|
268
|
+
mounted(el, binding) {
|
|
269
|
+
const observer2 = new IntersectionObserver((entries) => {
|
|
270
|
+
entries.forEach((entry) => {
|
|
271
|
+
if (entry.isIntersecting) {
|
|
272
|
+
requestAnimationFrame(() => {
|
|
273
|
+
const styles = getComputedStyle(entry.target);
|
|
274
|
+
const height = parseFloat(styles.height);
|
|
275
|
+
const lineHeight = parseFloat(styles.lineHeight);
|
|
276
|
+
const isOverflow = Number(height) > Number(lineHeight);
|
|
277
|
+
if (isOverflow) {
|
|
278
|
+
const item = columns.value.find((item2) => item2.prop === binding.value);
|
|
279
|
+
if (item) {
|
|
280
|
+
item.headerTooltip = isOverflow;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
observer2.observe(el);
|
|
288
|
+
observeWeakMap.set(el, observer2);
|
|
289
|
+
},
|
|
290
|
+
unmounted(el) {
|
|
291
|
+
const observer2 = observeWeakMap.get(el);
|
|
292
|
+
if (observer2) {
|
|
293
|
+
observer2.disconnect();
|
|
294
|
+
observeWeakMap.delete(el);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const render2 = (props2) => {
|
|
299
|
+
let _slot2;
|
|
300
|
+
const {
|
|
301
|
+
rowKey,
|
|
302
|
+
tableData,
|
|
303
|
+
pageInfo
|
|
304
|
+
} = props2;
|
|
305
|
+
const columnSlots = (cell, scope) => {
|
|
306
|
+
var _a;
|
|
307
|
+
return cell.slotName && ((_a = slots[cell.slotName]) == null ? void 0 : _a.call(slots, scope));
|
|
308
|
+
};
|
|
309
|
+
const renderColumn = (columns2) => {
|
|
310
|
+
return columns2.filter((cell) => !cell.show || cell.show(cell)).map((cell, index) => {
|
|
311
|
+
const {
|
|
312
|
+
children,
|
|
313
|
+
...cellConf
|
|
314
|
+
} = cell;
|
|
315
|
+
return createVNode(resolveComponent("el-table-column"), cellConf, {
|
|
316
|
+
default: (scope) => {
|
|
317
|
+
if ((cell == null ? void 0 : cell.renderType) === "operate") return renderOperate(cell, scope);
|
|
318
|
+
if ((cell == null ? void 0 : cell.renderType) && (cell == null ? void 0 : cell.renderType) !== "operate") {
|
|
319
|
+
return dynamicComponent2(cell, scope);
|
|
320
|
+
}
|
|
321
|
+
if (cell == null ? void 0 : cell.render) {
|
|
322
|
+
const renderResult = cell.render(scope.row, scope.$index, cell);
|
|
323
|
+
const needsValidation = cell.required || cell.rules;
|
|
324
|
+
const isFragment = ["symbol", "object"].includes(typeof (renderResult == null ? void 0 : renderResult.type));
|
|
325
|
+
if (needsValidation && isFragment) {
|
|
326
|
+
return renderForm(cell.prop, scope.$index, renderResult);
|
|
327
|
+
}
|
|
328
|
+
return renderResult;
|
|
329
|
+
}
|
|
330
|
+
if (children && (children == null ? void 0 : children.length) > 0) return renderColumn(children);
|
|
331
|
+
if (cell == null ? void 0 : cell.tooltip) {
|
|
332
|
+
return createVNode(resolveComponent("el-tooltip"), {
|
|
333
|
+
"content": scope.row[scope.column.property]
|
|
334
|
+
}, {
|
|
335
|
+
default: () => [createVNode("span", {
|
|
336
|
+
"class": "truncate"
|
|
337
|
+
}, [scope.row[scope.column.property]])]
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
return (cell == null ? void 0 : cell.slotName) && columnSlots(cell, scope);
|
|
341
|
+
},
|
|
342
|
+
header: (scope) => {
|
|
343
|
+
var _a, _b;
|
|
344
|
+
if (cell == null ? void 0 : cell.headerRender) return cell == null ? void 0 : cell.headerRender(scope.row);
|
|
345
|
+
if (cell == null ? void 0 : cell.headerSlotName) return (_a = slots[cell == null ? void 0 : cell.headerSlotName]) == null ? void 0 : _a.call(slots, scope);
|
|
346
|
+
if (attrs.border) {
|
|
347
|
+
return createVNode("span", null, [scope == null ? void 0 : scope.column.label]);
|
|
348
|
+
}
|
|
349
|
+
if (cell.headerTooltip) {
|
|
350
|
+
return createVNode(resolveComponent("el-tooltip"), {
|
|
351
|
+
"content": (_b = scope == null ? void 0 : scope.column) == null ? void 0 : _b.label,
|
|
352
|
+
"placement": "top"
|
|
353
|
+
}, {
|
|
354
|
+
default: () => {
|
|
355
|
+
var _a2;
|
|
356
|
+
return [createVNode("span", {
|
|
357
|
+
"class": `${cell.required ? "required" : ""} truncate`
|
|
358
|
+
}, [(_a2 = scope == null ? void 0 : scope.column) == null ? void 0 : _a2.label])];
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
return withDirectives(createVNode("div", {
|
|
363
|
+
"class": cell.required ? "required" : ""
|
|
364
|
+
}, [scope == null ? void 0 : scope.column.label]), [[vAutoTooltip, cell.prop]]);
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
const renderOperate = (cell, scope) => {
|
|
370
|
+
var _a, _b;
|
|
371
|
+
return createVNode("div", {
|
|
372
|
+
"class": `flex justify-center items-center cursor-pointer gap-10 ${((_a = cell.config) == null ? void 0 : _a.className) ?? ""}`
|
|
373
|
+
}, [(_b = cell.operate) == null ? void 0 : _b.filter((op) => !op.show || op.show(scope.row)).map((op) => {
|
|
374
|
+
if (op == null ? void 0 : op.render) return op.render(scope.row, scope.$index);
|
|
375
|
+
const disabled = typeof (op == null ? void 0 : op.disabled) === "function" ? op.disabled(scope.row, scope.$index) : (op == null ? void 0 : op.disabled) ?? false;
|
|
376
|
+
return createVNode("span", {
|
|
377
|
+
"onClick": withModifiers(() => {
|
|
378
|
+
if (!disabled) {
|
|
379
|
+
(op == null ? void 0 : op.onClick) && (op == null ? void 0 : op.onClick(scope.row));
|
|
380
|
+
emit("operate-handle", op.key, scope.row, scope.$index);
|
|
381
|
+
}
|
|
382
|
+
}, ["stop"]),
|
|
383
|
+
"class": `table-handle whitespace-nowrap ${(op == null ? void 0 : op.className) ?? ""} ${disabled ? "table-handle-disabled" : ""}`
|
|
384
|
+
}, [op.label]);
|
|
385
|
+
})]);
|
|
386
|
+
};
|
|
387
|
+
const pagination = () => {
|
|
388
|
+
if (!pageInfo) return null;
|
|
389
|
+
const handleSizeChange = (e) => {
|
|
390
|
+
emit("update-page", "pageSize", e);
|
|
391
|
+
};
|
|
392
|
+
const handleCurrentChange = (e) => {
|
|
393
|
+
emit("update-page", "pageIndex", e);
|
|
394
|
+
};
|
|
395
|
+
return createVNode("div", {
|
|
396
|
+
"class": "pagination-wrap"
|
|
397
|
+
}, [createVNode(resolveComponent("el-pagination"), {
|
|
398
|
+
"currentPage": pageInfo.pageIndex,
|
|
399
|
+
"onUpdate:currentPage": ($event) => pageInfo.pageIndex = $event,
|
|
400
|
+
"pageSize": pageInfo.pageSize,
|
|
401
|
+
"onUpdate:pageSize": ($event) => pageInfo.pageSize = $event,
|
|
402
|
+
"disabled": false,
|
|
403
|
+
"page-sizes": pageInfo.sizes ?? [10, 20, 50, 100],
|
|
404
|
+
"layout": (pageInfo == null ? void 0 : pageInfo.layout) ? pageInfo == null ? void 0 : pageInfo.layout : "total,sizes,prev, pager, next",
|
|
405
|
+
"background": false,
|
|
406
|
+
"total": pageInfo.total,
|
|
407
|
+
"onSizeChange": handleSizeChange,
|
|
408
|
+
"onCurrentChange": handleCurrentChange
|
|
409
|
+
}, null)]);
|
|
410
|
+
};
|
|
411
|
+
if (!columns.value) return;
|
|
412
|
+
return createVNode(Fragment, null, [isFormTable.value ? createVNode(resolveComponent("el-form"), {
|
|
413
|
+
"model": props2,
|
|
414
|
+
"ref": tableFormRef
|
|
415
|
+
}, _isSlot$2(_slot2 = renderTable()) ? _slot2 : {
|
|
416
|
+
default: () => [_slot2]
|
|
417
|
+
}) : renderTable(), pagination()]);
|
|
418
|
+
function renderTable() {
|
|
419
|
+
let _slot3;
|
|
420
|
+
return createVNode(resolveComponent("el-table"), mergeProps({
|
|
421
|
+
"ref": tableRef
|
|
422
|
+
}, attrs, {
|
|
423
|
+
"row-key": rowKey,
|
|
424
|
+
"data": tableData
|
|
425
|
+
}), _isSlot$2(_slot3 = renderColumn(columns.value)) ? _slot3 : {
|
|
426
|
+
default: () => [_slot3]
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
const exportDataToExcel = (fileName) => {
|
|
431
|
+
const header = columns.value.filter((cell) => cell.prop);
|
|
432
|
+
const tableData = props.tableData;
|
|
433
|
+
exportToExcel({
|
|
434
|
+
header,
|
|
435
|
+
tableData,
|
|
436
|
+
fileName: fileName || Date.now()
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
const updateColumns = async (newColumns) => {
|
|
440
|
+
if (!columns.value) return;
|
|
441
|
+
columns.value = typeof newColumns === "function" ? await newColumns() : newColumns;
|
|
442
|
+
};
|
|
443
|
+
__expose({
|
|
444
|
+
tableRef,
|
|
445
|
+
exportDataToExcel,
|
|
446
|
+
updateColumns,
|
|
447
|
+
tableFormValidate
|
|
448
|
+
});
|
|
449
|
+
return (_ctx, _cache) => {
|
|
450
|
+
return openBlock(), createBlock(resolveDynamicComponent(render2(props)));
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
const defaultPageConfig = {
|
|
455
|
+
isPage: true,
|
|
456
|
+
gap: 10,
|
|
457
|
+
reset: true,
|
|
458
|
+
create: true,
|
|
459
|
+
pageSize: 10,
|
|
460
|
+
pageIndex: 1,
|
|
461
|
+
sizes: [10, 20, 50, 100],
|
|
462
|
+
layout: "total,sizes,prev, pager, next",
|
|
463
|
+
tableBar: true
|
|
464
|
+
};
|
|
465
|
+
const defaultSearchFormConfig = {
|
|
466
|
+
gap: "10px",
|
|
467
|
+
labelWidth: "fit-content"
|
|
468
|
+
};
|
|
469
|
+
const defaultFormConfig = {
|
|
470
|
+
gap: "10px",
|
|
471
|
+
row: 2,
|
|
472
|
+
labelWidth: "fit-content"
|
|
473
|
+
};
|
|
474
|
+
const searchFormRef = ref();
|
|
475
|
+
function createButton(props, text) {
|
|
476
|
+
if (!props.show) return;
|
|
477
|
+
return h(_sfc_main, props, {
|
|
478
|
+
default: () => text
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
const searchRender = (searchProps, {
|
|
482
|
+
search,
|
|
483
|
+
create,
|
|
484
|
+
name,
|
|
485
|
+
reset,
|
|
486
|
+
createHandle
|
|
487
|
+
}) => {
|
|
488
|
+
const { btnSlots } = searchProps;
|
|
489
|
+
return h(
|
|
490
|
+
"div",
|
|
491
|
+
{
|
|
492
|
+
class: "flex items-center gap-10"
|
|
493
|
+
},
|
|
494
|
+
[
|
|
495
|
+
h(YxForm, {
|
|
496
|
+
...searchProps,
|
|
497
|
+
formStyle: {
|
|
498
|
+
...defaultSearchFormConfig,
|
|
499
|
+
row: searchProps.formList.length,
|
|
500
|
+
...searchProps.formStyle
|
|
501
|
+
},
|
|
502
|
+
ref: searchFormRef
|
|
503
|
+
}),
|
|
504
|
+
h(
|
|
505
|
+
"div",
|
|
506
|
+
{
|
|
507
|
+
class: "flex items-center gap-10 flex-1"
|
|
508
|
+
},
|
|
509
|
+
[
|
|
510
|
+
h("div", { class: "flex items-center gap-10" }, [
|
|
511
|
+
createButton(
|
|
512
|
+
{
|
|
513
|
+
onClick: search,
|
|
514
|
+
show: true,
|
|
515
|
+
enter: true
|
|
516
|
+
},
|
|
517
|
+
"搜索"
|
|
518
|
+
),
|
|
519
|
+
createButton(
|
|
520
|
+
{
|
|
521
|
+
plain: true,
|
|
522
|
+
show: reset,
|
|
523
|
+
onClick: async () => {
|
|
524
|
+
searchFormRef.value.formRef.resetFields();
|
|
525
|
+
await search();
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
"重置"
|
|
529
|
+
)
|
|
530
|
+
]),
|
|
531
|
+
h("div", { class: "flex items-center justify-end gap-10 flex-1" }, [
|
|
532
|
+
createButton(
|
|
533
|
+
{
|
|
534
|
+
onClick: createHandle,
|
|
535
|
+
show: create
|
|
536
|
+
},
|
|
537
|
+
`新增${name ?? ""}`
|
|
538
|
+
),
|
|
539
|
+
btnSlots && h(btnSlots)
|
|
540
|
+
])
|
|
541
|
+
]
|
|
542
|
+
)
|
|
543
|
+
]
|
|
544
|
+
);
|
|
545
|
+
};
|
|
546
|
+
const getSearchFormData = () => {
|
|
547
|
+
return searchFormRef.value.formData;
|
|
548
|
+
};
|
|
549
|
+
const tableRender = (tableProps, slots) => {
|
|
550
|
+
return h(
|
|
551
|
+
_sfc_main$4,
|
|
552
|
+
{
|
|
553
|
+
...tableProps
|
|
554
|
+
},
|
|
555
|
+
slots
|
|
556
|
+
);
|
|
557
|
+
};
|
|
558
|
+
const pageProps = {
|
|
559
|
+
searchProps: {
|
|
560
|
+
required: false,
|
|
561
|
+
type: Object,
|
|
562
|
+
default: () => ({})
|
|
563
|
+
},
|
|
564
|
+
tableProps: {
|
|
565
|
+
required: true,
|
|
566
|
+
type: Object,
|
|
567
|
+
default: () => ({})
|
|
568
|
+
},
|
|
569
|
+
formProps: {
|
|
570
|
+
required: false,
|
|
571
|
+
type: Object,
|
|
572
|
+
default: () => ({})
|
|
573
|
+
},
|
|
574
|
+
tableBarProps: {
|
|
575
|
+
required: false,
|
|
576
|
+
type: Object,
|
|
577
|
+
default: () => ({})
|
|
578
|
+
},
|
|
579
|
+
pageConfig: {
|
|
580
|
+
required: false,
|
|
581
|
+
type: Object,
|
|
582
|
+
default: () => ({
|
|
583
|
+
isPage: true,
|
|
584
|
+
gap: 10,
|
|
585
|
+
pageSize: 10,
|
|
586
|
+
pageIndex: 1
|
|
587
|
+
})
|
|
588
|
+
},
|
|
589
|
+
requestConfig: {
|
|
590
|
+
required: true,
|
|
591
|
+
type: Object,
|
|
592
|
+
default: () => ({})
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
const paginationRender = (pageInfo, updatePage) => {
|
|
596
|
+
if (!pageInfo) return null;
|
|
597
|
+
const handleSizeChange = (e) => {
|
|
598
|
+
updatePage("pageSize", e);
|
|
599
|
+
};
|
|
600
|
+
const handleCurrentChange = (e) => {
|
|
601
|
+
updatePage("pageIndex", e);
|
|
602
|
+
};
|
|
603
|
+
return createVNode("div", {
|
|
604
|
+
"class": "flex items-center justify-end"
|
|
605
|
+
}, [createVNode(resolveComponent("el-pagination"), {
|
|
606
|
+
"currentPage": pageInfo.pageIndex,
|
|
607
|
+
"onUpdate:currentPage": ($event) => pageInfo.pageIndex = $event,
|
|
608
|
+
"pageSize": pageInfo.pageSize,
|
|
609
|
+
"onUpdate:pageSize": ($event) => pageInfo.pageSize = $event,
|
|
610
|
+
"disabled": false,
|
|
611
|
+
"page-sizes": pageInfo.sizes ?? [10, 20, 50, 100],
|
|
612
|
+
"layout": (pageInfo == null ? void 0 : pageInfo.layout) ? pageInfo == null ? void 0 : pageInfo.layout : "total,sizes,prev, pager, next",
|
|
613
|
+
"background": false,
|
|
614
|
+
"total": pageInfo.total,
|
|
615
|
+
"onSizeChange": handleSizeChange,
|
|
616
|
+
"onCurrentChange": handleCurrentChange
|
|
617
|
+
}, null)]);
|
|
618
|
+
};
|
|
619
|
+
const time = ref("");
|
|
620
|
+
let _timer;
|
|
621
|
+
const useTime = () => {
|
|
622
|
+
const timedExecution = () => {
|
|
623
|
+
_timer = setTimeout(() => {
|
|
624
|
+
time.value = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
|
625
|
+
_timer && clearTimeout(_timer);
|
|
626
|
+
timedExecution();
|
|
627
|
+
}, 1e3);
|
|
628
|
+
};
|
|
629
|
+
timedExecution();
|
|
630
|
+
return { time };
|
|
631
|
+
};
|
|
632
|
+
const useConfirm = (content, confirmCallback, options = {}) => {
|
|
633
|
+
ElMessageBox.confirm(content, (options == null ? void 0 : options.title) || "提示", {
|
|
634
|
+
confirmButtonText: "确定",
|
|
635
|
+
cancelButtonText: "取消",
|
|
636
|
+
type: "warning",
|
|
637
|
+
...options
|
|
638
|
+
}).then(() => {
|
|
639
|
+
confirmCallback();
|
|
640
|
+
}).catch(() => {
|
|
641
|
+
});
|
|
642
|
+
};
|
|
643
|
+
const diaConfig = {
|
|
644
|
+
width: "30%",
|
|
645
|
+
showFooter: true,
|
|
646
|
+
autoClose: true,
|
|
647
|
+
confirmText: "确认",
|
|
648
|
+
cancelText: "取消",
|
|
649
|
+
draggable: true,
|
|
650
|
+
closeOnClickModal: false,
|
|
651
|
+
destroyOnClose: true
|
|
652
|
+
};
|
|
653
|
+
const useDialog = async (options) => {
|
|
654
|
+
let app;
|
|
655
|
+
const visible = ref(true);
|
|
656
|
+
const loading = ref(false);
|
|
657
|
+
const mergeOptions = { ...diaConfig, ...options };
|
|
658
|
+
const { showFooter, autoClose, submit, cancel, beforeOpen, beforeSubmit, confirmText, cancelText, content } = mergeOptions;
|
|
659
|
+
if (beforeOpen) {
|
|
660
|
+
await beforeOpen();
|
|
661
|
+
}
|
|
662
|
+
const dialogWrapper = defineComponent({
|
|
663
|
+
setup() {
|
|
664
|
+
const close = () => {
|
|
665
|
+
visible.value = false;
|
|
666
|
+
};
|
|
667
|
+
const selfSubmit = async () => {
|
|
668
|
+
try {
|
|
669
|
+
const shouldProceed = beforeSubmit ? await beforeSubmit() : true;
|
|
670
|
+
if (shouldProceed) {
|
|
671
|
+
loading.value = true;
|
|
672
|
+
const isSuccess = await (submit == null ? void 0 : submit());
|
|
673
|
+
if (isSuccess && autoClose) {
|
|
674
|
+
visible.value = false;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
} finally {
|
|
678
|
+
loading.value = false;
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
return {
|
|
682
|
+
open,
|
|
683
|
+
close,
|
|
684
|
+
selfSubmit
|
|
685
|
+
};
|
|
686
|
+
},
|
|
687
|
+
render() {
|
|
688
|
+
const footer = () => {
|
|
689
|
+
return h("div", { class: "flex justify-end gap-10" }, [
|
|
690
|
+
h(ElButton, { onClick: this.close, plain: true }, { default: () => cancelText }),
|
|
691
|
+
h(
|
|
692
|
+
_sfc_main,
|
|
693
|
+
{
|
|
694
|
+
onClick: this.selfSubmit
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
default: () => confirmText
|
|
698
|
+
}
|
|
699
|
+
)
|
|
700
|
+
]);
|
|
701
|
+
};
|
|
702
|
+
return h(
|
|
703
|
+
ElDialog,
|
|
704
|
+
{
|
|
705
|
+
modelValue: visible.value,
|
|
706
|
+
...mergeOptions,
|
|
707
|
+
beforeClose: () => {
|
|
708
|
+
this.close();
|
|
709
|
+
cancel && cancel();
|
|
710
|
+
},
|
|
711
|
+
onClosed: () => {
|
|
712
|
+
app.unmount();
|
|
713
|
+
document.body.removeChild(container);
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
default: () => content && content instanceof Function ? content() : content,
|
|
718
|
+
footer: () => showFooter ? footer() : null
|
|
719
|
+
}
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
const container = document.createElement("div");
|
|
724
|
+
document.body.appendChild(container);
|
|
725
|
+
app = createApp(dialogWrapper);
|
|
726
|
+
app.use(ElementPlus).mount(container);
|
|
727
|
+
return () => {
|
|
728
|
+
visible.value = false;
|
|
729
|
+
};
|
|
730
|
+
};
|
|
731
|
+
const useMessage = (arg) => {
|
|
732
|
+
if (arg) {
|
|
733
|
+
const { data, callback, isShowError = false } = arg;
|
|
734
|
+
try {
|
|
735
|
+
if (data == null ? void 0 : data.isSuccess) {
|
|
736
|
+
ElMessage.success((data == null ? void 0 : data.resultMsg) || "操作成功");
|
|
737
|
+
callback && callback();
|
|
738
|
+
} else {
|
|
739
|
+
if (isShowError) {
|
|
740
|
+
ElMessage.error((data == null ? void 0 : data.resultMsg) || "操作失败");
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
} catch (error) {
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
return {
|
|
747
|
+
success: (msg) => ElMessage.success(msg),
|
|
748
|
+
error: (msg) => ElMessage.error(msg),
|
|
749
|
+
warning: (msg) => ElMessage.warning(msg)
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
const formRef = ref();
|
|
753
|
+
const formRender = (formProps) => {
|
|
754
|
+
return h(YxForm, {
|
|
755
|
+
formLayout: "vertical",
|
|
756
|
+
...formProps,
|
|
757
|
+
formStyle: {
|
|
758
|
+
...defaultFormConfig,
|
|
759
|
+
...formProps.formStyle
|
|
760
|
+
},
|
|
761
|
+
ref: formRef
|
|
762
|
+
});
|
|
763
|
+
};
|
|
764
|
+
const formValidate = async () => {
|
|
765
|
+
return await formRef.value.formValidate();
|
|
766
|
+
};
|
|
767
|
+
const getFormData = () => {
|
|
768
|
+
return formRef.value.formData;
|
|
769
|
+
};
|
|
770
|
+
const page = defineComponent({
|
|
771
|
+
props: pageProps,
|
|
772
|
+
setup(props, { expose, slots }) {
|
|
773
|
+
const { tableBarProps: tableBarProps2, searchProps, formProps, tableProps, pageConfig, requestConfig } = props;
|
|
774
|
+
const { searchCallback, createCallback, updateCallback, deleteCallback, getDetailCallback } = requestConfig;
|
|
775
|
+
const newConfig = Object.assign({}, defaultPageConfig, pageConfig);
|
|
776
|
+
const { tableBar, sizes, layout, pageIndex, pageSize, isPage, gap, create, reset, name, searchFormToBarTitle } = newConfig;
|
|
777
|
+
onMounted(async () => {
|
|
778
|
+
await search();
|
|
779
|
+
});
|
|
780
|
+
const pageData = reactive({
|
|
781
|
+
pageIndex,
|
|
782
|
+
pageSize,
|
|
783
|
+
total: 0,
|
|
784
|
+
sizes,
|
|
785
|
+
layout
|
|
786
|
+
});
|
|
787
|
+
const search = async () => {
|
|
788
|
+
if (!searchCallback) return;
|
|
789
|
+
const searchData = await getSearchFormData();
|
|
790
|
+
const data = await searchCallback({
|
|
791
|
+
...searchData,
|
|
792
|
+
pageIndex: isPage ? pageData.pageIndex : void 0,
|
|
793
|
+
pageSize: isPage ? pageData.pageSize : void 0
|
|
794
|
+
});
|
|
795
|
+
if (isPage) {
|
|
796
|
+
const { records, total } = data;
|
|
797
|
+
pageData.total = total;
|
|
798
|
+
tableProps.tableData = records;
|
|
799
|
+
} else {
|
|
800
|
+
tableProps.tableData = data;
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
const initPageInfo = () => {
|
|
804
|
+
pageData.pageIndex = pageIndex;
|
|
805
|
+
pageData.pageSize = pageSize;
|
|
806
|
+
pageData.total = 0;
|
|
807
|
+
};
|
|
808
|
+
const updatePage = async (type, e) => {
|
|
809
|
+
pageData[type] = e;
|
|
810
|
+
await search();
|
|
811
|
+
};
|
|
812
|
+
let closeDialog;
|
|
813
|
+
const createHandle = () => {
|
|
814
|
+
formProps.formParams = {};
|
|
815
|
+
if (!createCallback) return;
|
|
816
|
+
showDialog(`新增${name ?? ""}`, createCallback);
|
|
817
|
+
};
|
|
818
|
+
const updateHandle = async (data) => {
|
|
819
|
+
if (!updateCallback) return;
|
|
820
|
+
await asyncFormData(data);
|
|
821
|
+
showDialog(`编辑${name ?? ""}`, updateCallback);
|
|
822
|
+
};
|
|
823
|
+
const asyncFormData = async (data) => {
|
|
824
|
+
let params = getDetailCallback ? await getDetailCallback() : data;
|
|
825
|
+
if (typeof formProps.formList === "object") {
|
|
826
|
+
formProps.formList.forEach((item) => {
|
|
827
|
+
formProps.formParams && (formProps.formParams[item.prop] = params[item.prop]);
|
|
828
|
+
});
|
|
829
|
+
} else {
|
|
830
|
+
formProps.formParams = params;
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
const showDialog = async (title, callback) => {
|
|
834
|
+
closeDialog = await useDialog({
|
|
835
|
+
title,
|
|
836
|
+
content: () => formRender(formProps),
|
|
837
|
+
confirmText: "确定",
|
|
838
|
+
cancelText: "取消",
|
|
839
|
+
beforeSubmit: async () => await formValidate(),
|
|
840
|
+
submit: async () => {
|
|
841
|
+
const isSuccess = await callback(getFormData());
|
|
842
|
+
if (isSuccess) {
|
|
843
|
+
useMessage().success("操作成功");
|
|
844
|
+
closeDialog && closeDialog();
|
|
845
|
+
initPageInfo();
|
|
846
|
+
await search();
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
};
|
|
851
|
+
let operateHandle;
|
|
852
|
+
if (tableProps.onOperateHandle) {
|
|
853
|
+
operateHandle = tableProps.onOperateHandle;
|
|
854
|
+
tableProps.onOperateHandle = (type, data, index) => {
|
|
855
|
+
if (type === "del") {
|
|
856
|
+
useConfirm(`是否确认删除此${name ?? ""}?`, async () => {
|
|
857
|
+
if (!deleteCallback) return;
|
|
858
|
+
const isSuccess = await deleteCallback(data, index);
|
|
859
|
+
if (isSuccess) {
|
|
860
|
+
useMessage().success("删除成功");
|
|
861
|
+
initPageInfo();
|
|
862
|
+
search();
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
} else if (type === "edit") {
|
|
866
|
+
updateHandle(data);
|
|
867
|
+
} else {
|
|
868
|
+
operateHandle(type, data, index);
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
expose({
|
|
873
|
+
search,
|
|
874
|
+
closeDialog,
|
|
875
|
+
getFormData,
|
|
876
|
+
createHandle,
|
|
877
|
+
getSearchFormData
|
|
878
|
+
});
|
|
879
|
+
return () => {
|
|
880
|
+
var _a, _b;
|
|
881
|
+
return h(
|
|
882
|
+
"div",
|
|
883
|
+
{
|
|
884
|
+
class: `flex flex-col w-full h-full gap-${gap}`
|
|
885
|
+
},
|
|
886
|
+
[
|
|
887
|
+
!searchFormToBarTitle && searchRender(searchProps, {
|
|
888
|
+
search,
|
|
889
|
+
create,
|
|
890
|
+
name,
|
|
891
|
+
reset,
|
|
892
|
+
createHandle
|
|
893
|
+
}),
|
|
894
|
+
tableBar ? h(
|
|
895
|
+
YxTableBar,
|
|
896
|
+
{
|
|
897
|
+
class: "flex-1 min-h-0",
|
|
898
|
+
columns: tableProps.columns,
|
|
899
|
+
onRefresh: search
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
default: ({ dynamicColumns, tableStyle, border }) => h(
|
|
903
|
+
_sfc_main$4,
|
|
904
|
+
{
|
|
905
|
+
...tableProps,
|
|
906
|
+
columns: dynamicColumns,
|
|
907
|
+
style: tableStyle,
|
|
908
|
+
border
|
|
909
|
+
},
|
|
910
|
+
slots
|
|
911
|
+
),
|
|
912
|
+
barTitle: searchFormToBarTitle ? searchRender(searchProps, {
|
|
913
|
+
search,
|
|
914
|
+
create,
|
|
915
|
+
name,
|
|
916
|
+
reset,
|
|
917
|
+
createHandle
|
|
918
|
+
}) : ((_a = slots == null ? void 0 : slots.barTitle) == null ? void 0 : _a.call(slots)) || ((_b = tableBarProps2 == null ? void 0 : tableBarProps2.barTitle) == null ? void 0 : _b.call(tableBarProps2))
|
|
919
|
+
}
|
|
920
|
+
) : tableRender(tableProps, slots),
|
|
921
|
+
// tableRender(tableProps, slots),
|
|
922
|
+
paginationRender(pageData, updatePage)
|
|
923
|
+
]
|
|
924
|
+
);
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
const _hoisted_1$f = { viewBox: "0 0 24 24" };
|
|
929
|
+
function render$c(_ctx, _cache) {
|
|
930
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$f, _cache[0] || (_cache[0] = [
|
|
931
|
+
createElementVNode("path", {
|
|
932
|
+
fill: "none",
|
|
933
|
+
stroke: "currentColor",
|
|
934
|
+
"stroke-linecap": "round",
|
|
935
|
+
"stroke-linejoin": "round",
|
|
936
|
+
"stroke-width": "2",
|
|
937
|
+
d: "M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"
|
|
938
|
+
}, null, -1)
|
|
939
|
+
]));
|
|
940
|
+
}
|
|
941
|
+
const Refresh = { render: render$c };
|
|
942
|
+
const _hoisted_1$e = {
|
|
943
|
+
width: "32",
|
|
944
|
+
height: "32",
|
|
945
|
+
viewBox: "0 0 24 24"
|
|
946
|
+
};
|
|
947
|
+
function render$b(_ctx, _cache) {
|
|
948
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$e, _cache[0] || (_cache[0] = [
|
|
949
|
+
createElementVNode("path", {
|
|
950
|
+
fill: "currentColor",
|
|
951
|
+
d: "M13.79 10.21a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42l-2.5-2.5a1 1 0 0 0-.33-.21 1 1 0 0 0-.76 0 1 1 0 0 0-.33.21l-2.5 2.5a1 1 0 0 0 1.42 1.42l.79-.8v5.18l-.79-.8a1 1 0 0 0-1.42 1.42l2.5 2.5a1 1 0 0 0 .33.21.94.94 0 0 0 .76 0 1 1 0 0 0 .33-.21l2.5-2.5a1 1 0 0 0-1.42-1.42l-.79.8V9.41ZM7 4h10a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2m10 16H7a1 1 0 0 0 0 2h10a1 1 0 0 0 0-2"
|
|
952
|
+
}, null, -1)
|
|
953
|
+
]));
|
|
954
|
+
}
|
|
955
|
+
const Collapse = { render: render$b };
|
|
956
|
+
const _hoisted_1$d = { viewBox: "0 0 24 24" };
|
|
957
|
+
function render$a(_ctx, _cache) {
|
|
958
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$d, _cache[0] || (_cache[0] = [
|
|
959
|
+
createElementVNode("path", {
|
|
960
|
+
fill: "currentColor",
|
|
961
|
+
d: "M3.34 17a10 10 0 0 1-.978-2.326 3 3 0 0 0 .002-5.347A10 10 0 0 1 4.865 4.99a3 3 0 0 0 4.631-2.674 10 10 0 0 1 5.007.002 3 3 0 0 0 4.632 2.672A10 10 0 0 1 20.66 7c.433.749.757 1.53.978 2.326a3 3 0 0 0-.002 5.347 10 10 0 0 1-2.501 4.337 3 3 0 0 0-4.631 2.674 10 10 0 0 1-5.007-.002 3 3 0 0 0-4.632-2.672A10 10 0 0 1 3.34 17m5.66.196a5 5 0 0 1 2.25 2.77q.75.071 1.499.001A5 5 0 0 1 15 17.197a5 5 0 0 1 3.525-.565q.435-.614.748-1.298A5 5 0 0 1 18 12c0-1.26.47-2.437 1.273-3.334a8 8 0 0 0-.75-1.298A5 5 0 0 1 15 6.804a5 5 0 0 1-2.25-2.77q-.75-.071-1.499-.001A5 5 0 0 1 9 6.803a5 5 0 0 1-3.525.565 8 8 0 0 0-.748 1.298A5 5 0 0 1 6 12a5 5 0 0 1-1.273 3.334 8 8 0 0 0 .75 1.298A5 5 0 0 1 9 17.196M12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2"
|
|
962
|
+
}, null, -1)
|
|
963
|
+
]));
|
|
964
|
+
}
|
|
965
|
+
const Settings = { render: render$a };
|
|
966
|
+
const _hoisted_1$c = {
|
|
967
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
968
|
+
viewBox: "0 0 1024 1024"
|
|
969
|
+
};
|
|
970
|
+
function render$9(_ctx, _cache) {
|
|
971
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$c, _cache[0] || (_cache[0] = [
|
|
972
|
+
createElementVNode("path", {
|
|
973
|
+
fill: "currentColor",
|
|
974
|
+
d: "m160 96.064 192 .192a32 32 0 0 1 0 64l-192-.192V352a32 32 0 0 1-64 0V96h64zm0 831.872V928H96V672a32 32 0 1 1 64 0v191.936l192-.192a32 32 0 1 1 0 64zM864 96.064V96h64v256a32 32 0 1 1-64 0V160.064l-192 .192a32 32 0 1 1 0-64zm0 831.872-192-.192a32 32 0 0 1 0-64l192 .192V672a32 32 0 1 1 64 0v256h-64z"
|
|
975
|
+
}, null, -1)
|
|
976
|
+
]));
|
|
977
|
+
}
|
|
978
|
+
const FullScreen = { render: render$9 };
|
|
979
|
+
const _hoisted_1$b = {
|
|
980
|
+
"aria-hidden": "false",
|
|
981
|
+
viewBox: "0 0 24 24"
|
|
982
|
+
};
|
|
983
|
+
function render$8(_ctx, _cache) {
|
|
984
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$b, _cache[0] || (_cache[0] = [
|
|
985
|
+
createElementVNode("path", {
|
|
986
|
+
fill: "currentColor",
|
|
987
|
+
d: "M18 7h4v2h-6V3h2zM8 9H2V7h4V3h2zm10 8v4h-2v-6h6v2zM8 15v6H6v-4H2"
|
|
988
|
+
}, null, -1)
|
|
989
|
+
]));
|
|
990
|
+
}
|
|
991
|
+
const ExitScreen = { render: render$8 };
|
|
992
|
+
const _hoisted_1$a = {
|
|
993
|
+
width: "32",
|
|
994
|
+
height: "32",
|
|
995
|
+
fill: "currentColor",
|
|
996
|
+
"data-icon": "holder",
|
|
997
|
+
viewBox: "64 64 896 896"
|
|
998
|
+
};
|
|
999
|
+
function render$7(_ctx, _cache) {
|
|
1000
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$a, _cache[0] || (_cache[0] = [
|
|
1001
|
+
createElementVNode("path", { d: "M300 276.5a56 56 0 1 0 56-97 56 56 0 0 0-56 97m0 284a56 56 0 1 0 56-97 56 56 0 0 0-56 97M640 228a56 56 0 1 0 112 0 56 56 0 0 0-112 0m0 284a56 56 0 1 0 112 0 56 56 0 0 0-112 0M300 844.5a56 56 0 1 0 56-97 56 56 0 0 0-56 97M640 796a56 56 0 1 0 112 0 56 56 0 0 0-112 0" }, null, -1)
|
|
1002
|
+
]));
|
|
1003
|
+
}
|
|
1004
|
+
const DragIcon = { render: render$7 };
|
|
1005
|
+
const _hoisted_1$9 = {
|
|
1006
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1007
|
+
viewBox: "0 0 24 24"
|
|
1008
|
+
};
|
|
1009
|
+
function render$6(_ctx, _cache) {
|
|
1010
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$9, _cache[0] || (_cache[0] = [
|
|
1011
|
+
createElementVNode("path", {
|
|
1012
|
+
fill: "currentColor",
|
|
1013
|
+
d: "M3 19V5q0-.825.588-1.412T5 3h14q.825 0 1.413.588T21 5v14q0 .825-.587 1.413T19 21H5q-.825 0-1.412-.587T3 19m10-6v6h6v-6zm0-2h6V5h-6zm-2 0V5H5v6zm0 2H5v6h6z"
|
|
1014
|
+
}, null, -1)
|
|
1015
|
+
]));
|
|
1016
|
+
}
|
|
1017
|
+
const Border = { render: render$6 };
|
|
1018
|
+
const _hoisted_1$8 = {
|
|
1019
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1020
|
+
viewBox: "0 0 24 24"
|
|
1021
|
+
};
|
|
1022
|
+
function render$5(_ctx, _cache) {
|
|
1023
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$8, _cache[0] || (_cache[0] = [
|
|
1024
|
+
createElementVNode("path", {
|
|
1025
|
+
fill: "currentColor",
|
|
1026
|
+
d: "M12 9q-.425 0-.712-.288T11 8t.288-.712T12 7t.713.288T13 8t-.288.713T12 9m-4 4q-.425 0-.712-.288T7 12t.288-.712T8 11t.713.288T9 12t-.288.713T8 13m4 0q-.425 0-.712-.288T11 12t.288-.712T12 11t.713.288T13 12t-.288.713T12 13m4 0q-.425 0-.712-.288T15 12t.288-.712T16 11t.713.288T17 12t-.288.713T16 13m-4 4q-.425 0-.712-.288T11 16t.288-.712T12 15t.713.288T13 16t-.288.713T12 17M4 5q-.425 0-.712-.288T3 4t.288-.712T4 3t.713.288T5 4t-.288.713T4 5m4 0q-.425 0-.712-.288T7 4t.288-.712T8 3t.713.288T9 4t-.288.713T8 5m4 0q-.425 0-.712-.288T11 4t.288-.712T12 3t.713.288T13 4t-.288.713T12 5m4 0q-.425 0-.712-.288T15 4t.288-.712T16 3t.713.288T17 4t-.288.713T16 5m4 0q-.425 0-.712-.288T19 4t.288-.712T20 3t.713.288T21 4t-.288.713T20 5M4 9q-.425 0-.712-.288T3 8t.288-.712T4 7t.713.288T5 8t-.288.713T4 9m16 0q-.425 0-.712-.288T19 8t.288-.712T20 7t.713.288T21 8t-.288.713T20 9M4 13q-.425 0-.712-.288T3 12t.288-.712T4 11t.713.288T5 12t-.288.713T4 13m16 0q-.425 0-.712-.288T19 12t.288-.712T20 11t.713.288T21 12t-.288.713T20 13M4 17q-.425 0-.712-.288T3 16t.288-.712T4 15t.713.288T5 16t-.288.713T4 17m16 0q-.425 0-.712-.288T19 16t.288-.712T20 15t.713.288T21 16t-.288.713T20 17M4 21q-.425 0-.712-.288T3 20t.288-.712T4 19t.713.288T5 20t-.288.713T4 21m4 0q-.425 0-.712-.288T7 20t.288-.712T8 19t.713.288T9 20t-.288.713T8 21m4 0q-.425 0-.712-.288T11 20t.288-.712T12 19t.713.288T13 20t-.288.713T12 21m4 0q-.425 0-.712-.288T15 20t.288-.712T16 19t.713.288T17 20t-.288.713T16 21m4 0q-.425 0-.712-.288T19 20t.288-.712T20 19t.713.288T21 20t-.288.713T20 21"
|
|
1027
|
+
}, null, -1)
|
|
1028
|
+
]));
|
|
1029
|
+
}
|
|
1030
|
+
const NoBorder = { render: render$5 };
|
|
1031
|
+
const renderIcon = (name, callback) => {
|
|
1032
|
+
return h(ElIcon, {
|
|
1033
|
+
size: 16,
|
|
1034
|
+
class: "cursor-pointer",
|
|
1035
|
+
onClick: () => {
|
|
1036
|
+
callback && callback();
|
|
1037
|
+
}
|
|
1038
|
+
}, {
|
|
1039
|
+
default: () => h(name)
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
1042
|
+
const tableBarConfig = [{
|
|
1043
|
+
icon: Refresh,
|
|
1044
|
+
label: "刷新",
|
|
1045
|
+
key: "refresh",
|
|
1046
|
+
render: (item, options) => renderIcon(item.icon, options.refresh)
|
|
1047
|
+
}, {
|
|
1048
|
+
icon: Collapse,
|
|
1049
|
+
label: "字体",
|
|
1050
|
+
key: "font",
|
|
1051
|
+
render: (item, options) => renderDropdown(item, options)
|
|
1052
|
+
}, {
|
|
1053
|
+
icon: Settings,
|
|
1054
|
+
label: "列设置",
|
|
1055
|
+
key: "column",
|
|
1056
|
+
render: (item, options) => setColumn(item, options)
|
|
1057
|
+
// render: (item, props: YxTableBarProps) => renderIcon(item.icon)
|
|
1058
|
+
}, {
|
|
1059
|
+
icon: NoBorder,
|
|
1060
|
+
iconActive: Border,
|
|
1061
|
+
label: "边框",
|
|
1062
|
+
key: "border",
|
|
1063
|
+
render: (item, options) => renderIcon((options == null ? void 0 : options.isBorder.value) ? item.iconActive : item.icon, options.setBorder)
|
|
1064
|
+
}, {
|
|
1065
|
+
icon: FullScreen,
|
|
1066
|
+
iconActive: ExitScreen,
|
|
1067
|
+
label: "全屏",
|
|
1068
|
+
key: "fullscreen",
|
|
1069
|
+
render: (item, options) => renderIcon((options == null ? void 0 : options.isFullscreen.value) ? item.iconActive : item.icon, options.fullScreen)
|
|
1070
|
+
}];
|
|
1071
|
+
const checkAll = ref(true);
|
|
1072
|
+
const checkedColumns = ref([]);
|
|
1073
|
+
const checkColumnList = ref([]);
|
|
1074
|
+
const setColumn = (item, {
|
|
1075
|
+
props,
|
|
1076
|
+
updateColumns,
|
|
1077
|
+
reset,
|
|
1078
|
+
sortColumns,
|
|
1079
|
+
dynamicColumns
|
|
1080
|
+
}) => {
|
|
1081
|
+
checkColumnList.value = dynamicColumns.value.map((item2) => item2.label);
|
|
1082
|
+
checkedColumns.value = checkColumnList.value;
|
|
1083
|
+
const isFixedColumn = (label) => {
|
|
1084
|
+
return dynamicColumns.value.find((item2) => item2.label === label).fixed ? true : false;
|
|
1085
|
+
};
|
|
1086
|
+
const rowDrop = (event) => {
|
|
1087
|
+
event.preventDefault();
|
|
1088
|
+
nextTick(() => {
|
|
1089
|
+
sortColumns();
|
|
1090
|
+
});
|
|
1091
|
+
};
|
|
1092
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
1093
|
+
"class": "flex items-center justify-center cursor-pointer"
|
|
1094
|
+
}, [createVNode(ElPopover, {
|
|
1095
|
+
"placement": "bottom",
|
|
1096
|
+
"trigger": "click",
|
|
1097
|
+
"width": 200,
|
|
1098
|
+
"popper-style": {
|
|
1099
|
+
padding: "5px 10px"
|
|
1100
|
+
}
|
|
1101
|
+
}, {
|
|
1102
|
+
default: () => [createVNode("div", {
|
|
1103
|
+
"class": "w-full flex flex-col gap-5"
|
|
1104
|
+
}, [createVNode("div", {
|
|
1105
|
+
"class": "flex items-center justify-between"
|
|
1106
|
+
}, [createVNode(ElCheckbox, {
|
|
1107
|
+
"modelValue": checkAll.value,
|
|
1108
|
+
"onUpdate:modelValue": ($event) => checkAll.value = $event,
|
|
1109
|
+
"label": "列展示"
|
|
1110
|
+
}, null), createVNode(ElButton, {
|
|
1111
|
+
"link": true,
|
|
1112
|
+
"size": "small",
|
|
1113
|
+
"onClick": reset
|
|
1114
|
+
}, {
|
|
1115
|
+
default: () => [createTextVNode("重置")]
|
|
1116
|
+
})]), createVNode("div", {
|
|
1117
|
+
"class": "h-1 w-full bg-[var(--border-deep-color)]"
|
|
1118
|
+
}, null), createVNode(ElScrollbar, {
|
|
1119
|
+
"maxHeight": "36vh"
|
|
1120
|
+
}, {
|
|
1121
|
+
default: () => [createVNode(ElCheckboxGroup, {
|
|
1122
|
+
"ref": `GroupRef${unref(props.tableKey)}`,
|
|
1123
|
+
"modelValue": checkedColumns.value,
|
|
1124
|
+
"onUpdate:modelValue": ($event) => checkedColumns.value = $event,
|
|
1125
|
+
"onChange": (value) => updateColumns(value)
|
|
1126
|
+
}, {
|
|
1127
|
+
default: () => [createVNode("div", {
|
|
1128
|
+
"class": "flex flex-col"
|
|
1129
|
+
}, [checkColumnList.value.map((item2) => {
|
|
1130
|
+
return createVNode("div", {
|
|
1131
|
+
"class": "flex items-center gap-10",
|
|
1132
|
+
"key": item2
|
|
1133
|
+
}, [createVNode(ElIcon, {
|
|
1134
|
+
"size": 16,
|
|
1135
|
+
"class": ["drag-btn", isFixedColumn(item2) ? "cursor-no-drop" : "cursor-move"],
|
|
1136
|
+
"onMouseenter": (event) => rowDrop(event)
|
|
1137
|
+
}, {
|
|
1138
|
+
default: () => [createVNode(DragIcon, null, null)]
|
|
1139
|
+
}), createVNode(ElCheckbox, {
|
|
1140
|
+
"onChange": (value) => updateColumns(value, item2),
|
|
1141
|
+
"label": item2
|
|
1142
|
+
}, {
|
|
1143
|
+
default: () => [createVNode("span", null, [item2])]
|
|
1144
|
+
})]);
|
|
1145
|
+
})])]
|
|
1146
|
+
})]
|
|
1147
|
+
})])],
|
|
1148
|
+
reference: () => renderIcon(item.icon)
|
|
1149
|
+
})])]);
|
|
1150
|
+
};
|
|
1151
|
+
const renderDropdown = (item, {
|
|
1152
|
+
setCollapse
|
|
1153
|
+
}) => {
|
|
1154
|
+
const list = [{
|
|
1155
|
+
label: "大号",
|
|
1156
|
+
value: 1.5
|
|
1157
|
+
}, {
|
|
1158
|
+
label: "默认",
|
|
1159
|
+
value: 1
|
|
1160
|
+
}, {
|
|
1161
|
+
label: "小号",
|
|
1162
|
+
value: 0.8
|
|
1163
|
+
}];
|
|
1164
|
+
return h(ElDropdown, {
|
|
1165
|
+
placement: "bottom",
|
|
1166
|
+
trigger: "click"
|
|
1167
|
+
}, {
|
|
1168
|
+
default: () => renderIcon(item.icon),
|
|
1169
|
+
dropdown: () => h(ElDropdownMenu, {}, {
|
|
1170
|
+
default: () => list.map((item2) => {
|
|
1171
|
+
return h(ElDropdownItem, {
|
|
1172
|
+
onClick: () => setCollapse(item2.value)
|
|
1173
|
+
}, {
|
|
1174
|
+
default: () => item2.label
|
|
1175
|
+
});
|
|
1176
|
+
})
|
|
1177
|
+
})
|
|
1178
|
+
});
|
|
1179
|
+
};
|
|
1180
|
+
const tableBarProps = {
|
|
1181
|
+
columns: {
|
|
1182
|
+
type: Object,
|
|
1183
|
+
default: () => []
|
|
1184
|
+
},
|
|
1185
|
+
barLayout: {
|
|
1186
|
+
type: String,
|
|
1187
|
+
default: () => "refresh,font,column,border,fullscreen"
|
|
1188
|
+
},
|
|
1189
|
+
barStyle: {
|
|
1190
|
+
type: Object,
|
|
1191
|
+
default: {
|
|
1192
|
+
padding: "10px"
|
|
1193
|
+
}
|
|
1194
|
+
},
|
|
1195
|
+
tableKey: {
|
|
1196
|
+
type: [String, Number],
|
|
1197
|
+
default: "0"
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
const renderTableBar = (options) => {
|
|
1201
|
+
var _a;
|
|
1202
|
+
const layout = (_a = options == null ? void 0 : options.props) == null ? void 0 : _a.barLayout;
|
|
1203
|
+
const showLayout = layout ? layout.split(",") : [];
|
|
1204
|
+
const renderTableBar2 = tableBarConfig.filter((item) => showLayout.includes(item.key));
|
|
1205
|
+
return renderTableBar2.map((item, index) => {
|
|
1206
|
+
return [
|
|
1207
|
+
h(
|
|
1208
|
+
"div",
|
|
1209
|
+
{
|
|
1210
|
+
class: "flex items-center justify-center cursor-pointer"
|
|
1211
|
+
},
|
|
1212
|
+
[
|
|
1213
|
+
h(
|
|
1214
|
+
ElTooltip,
|
|
1215
|
+
{
|
|
1216
|
+
placement: "top",
|
|
1217
|
+
content: item.label
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
default: () => item == null ? void 0 : item.render(item, options)
|
|
1221
|
+
}
|
|
1222
|
+
)
|
|
1223
|
+
]
|
|
1224
|
+
),
|
|
1225
|
+
index !== renderTableBar2.length - 1 && h(ElDivider, {
|
|
1226
|
+
direction: "vertical"
|
|
1227
|
+
})
|
|
1228
|
+
];
|
|
1229
|
+
});
|
|
1230
|
+
};
|
|
1231
|
+
const YxTableBar = defineComponent({
|
|
1232
|
+
name: "YxTableBar",
|
|
1233
|
+
props: tableBarProps,
|
|
1234
|
+
emit: ["refresh"],
|
|
1235
|
+
setup(props, { slots, emit }) {
|
|
1236
|
+
const dynamicColumns = ref(deepClone(props == null ? void 0 : props.columns));
|
|
1237
|
+
const instance = getCurrentInstance();
|
|
1238
|
+
const tableCss = getGroupColor("table");
|
|
1239
|
+
const defaultTableCss = {
|
|
1240
|
+
"--table-body-font-size": parseInt(tableCss["body-font-size"]),
|
|
1241
|
+
"--table-header-font-size": parseInt(tableCss["header-font-size"]),
|
|
1242
|
+
"--table-header-height": parseInt(tableCss["header-height"]),
|
|
1243
|
+
"--table-header-border-radius": parseInt(tableCss["header-border-radius"]),
|
|
1244
|
+
"--table-row-height": parseInt(tableCss["row-height"])
|
|
1245
|
+
};
|
|
1246
|
+
const tableStyle = reactive({});
|
|
1247
|
+
const updateColumns = (value, label) => {
|
|
1248
|
+
if (label) {
|
|
1249
|
+
const columns = dynamicColumns.value.find((item) => item.label === label);
|
|
1250
|
+
if (!columns) return;
|
|
1251
|
+
columns.show = () => value;
|
|
1252
|
+
} else {
|
|
1253
|
+
dynamicColumns.value.forEach((item) => item.show = () => value);
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
const reset = () => {
|
|
1257
|
+
dynamicColumns.value = deepClone(props == null ? void 0 : props.columns);
|
|
1258
|
+
};
|
|
1259
|
+
const sortColumns = () => {
|
|
1260
|
+
var _a;
|
|
1261
|
+
const wrapper = ((_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$refs[`GroupRef${unref(props == null ? void 0 : props.tableKey)}`]).$el.firstElementChild;
|
|
1262
|
+
Sortable.create(wrapper, {
|
|
1263
|
+
animation: 300,
|
|
1264
|
+
handle: ".drag-btn",
|
|
1265
|
+
onEnd: ({ newIndex, oldIndex, item }) => {
|
|
1266
|
+
const targetThElem = item;
|
|
1267
|
+
const wrapperElem = targetThElem.parentNode;
|
|
1268
|
+
const oldColumn = dynamicColumns.value[oldIndex];
|
|
1269
|
+
const newColumn = dynamicColumns.value[newIndex];
|
|
1270
|
+
if ((oldColumn == null ? void 0 : oldColumn.fixed) || (newColumn == null ? void 0 : newColumn.fixed)) {
|
|
1271
|
+
const oldThElem = wrapperElem.children[oldIndex];
|
|
1272
|
+
if (newIndex > oldIndex) {
|
|
1273
|
+
wrapperElem.insertBefore(targetThElem, oldThElem);
|
|
1274
|
+
} else {
|
|
1275
|
+
wrapperElem.insertBefore(targetThElem, oldThElem ? oldThElem.nextElementSibling : oldThElem);
|
|
1276
|
+
}
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
const currentRow = dynamicColumns.value.splice(oldIndex, 1)[0];
|
|
1280
|
+
dynamicColumns.value.splice(newIndex, 0, currentRow);
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
};
|
|
1284
|
+
const setCollapse = (value) => {
|
|
1285
|
+
const newTableCss = {};
|
|
1286
|
+
Object.keys(defaultTableCss).forEach((key) => {
|
|
1287
|
+
newTableCss[key] = (defaultTableCss[key] * value).toFixed(0) + "px";
|
|
1288
|
+
});
|
|
1289
|
+
Object.assign(tableStyle, newTableCss);
|
|
1290
|
+
};
|
|
1291
|
+
const refresh = () => {
|
|
1292
|
+
emit("refresh");
|
|
1293
|
+
};
|
|
1294
|
+
const isFullscreen = ref(false);
|
|
1295
|
+
const fullScreen = () => {
|
|
1296
|
+
isFullscreen.value = !isFullscreen.value;
|
|
1297
|
+
};
|
|
1298
|
+
const isBorder = ref(false);
|
|
1299
|
+
const setBorder = () => {
|
|
1300
|
+
isBorder.value = !isBorder.value;
|
|
1301
|
+
};
|
|
1302
|
+
return () => {
|
|
1303
|
+
var _a, _b;
|
|
1304
|
+
return h(
|
|
1305
|
+
"div",
|
|
1306
|
+
{
|
|
1307
|
+
class: `h-full flex flex-col ${isFullscreen.value ? "h-full z-2002 fixed inset-0 p-10 box-border" : ""}`
|
|
1308
|
+
},
|
|
1309
|
+
[
|
|
1310
|
+
h(
|
|
1311
|
+
"div",
|
|
1312
|
+
{
|
|
1313
|
+
class: "flex items-center justify-between",
|
|
1314
|
+
style: props == null ? void 0 : props.barStyle
|
|
1315
|
+
},
|
|
1316
|
+
[
|
|
1317
|
+
((_a = slots == null ? void 0 : slots.barTitle) == null ? void 0 : _a.call(slots)) ?? h("div"),
|
|
1318
|
+
h(
|
|
1319
|
+
"div",
|
|
1320
|
+
{
|
|
1321
|
+
class: "flex items-center"
|
|
1322
|
+
},
|
|
1323
|
+
renderTableBar({
|
|
1324
|
+
updateColumns,
|
|
1325
|
+
reset,
|
|
1326
|
+
props,
|
|
1327
|
+
sortColumns,
|
|
1328
|
+
setCollapse,
|
|
1329
|
+
refresh,
|
|
1330
|
+
fullScreen,
|
|
1331
|
+
isFullscreen,
|
|
1332
|
+
setBorder,
|
|
1333
|
+
isBorder,
|
|
1334
|
+
dynamicColumns
|
|
1335
|
+
})
|
|
1336
|
+
)
|
|
1337
|
+
]
|
|
1338
|
+
),
|
|
1339
|
+
(_b = slots.default) == null ? void 0 : _b.call(slots, { dynamicColumns: dynamicColumns.value, tableStyle, border: isBorder.value })
|
|
1340
|
+
]
|
|
1341
|
+
);
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
const _hoisted_1$7 = {
|
|
1346
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1347
|
+
viewBox: "0 0 1024 1024"
|
|
1348
|
+
};
|
|
1349
|
+
function render$4(_ctx, _cache) {
|
|
1350
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$7, _cache[0] || (_cache[0] = [
|
|
1351
|
+
createElementVNode("path", {
|
|
1352
|
+
fill: "currentColor",
|
|
1353
|
+
d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m23.744 191.488c-52.096 0-92.928 14.784-123.2 44.352-30.976 29.568-45.76 70.4-45.76 122.496h80.256c0-29.568 5.632-52.8 17.6-68.992 13.376-19.712 35.2-28.864 66.176-28.864 23.936 0 42.944 6.336 56.32 19.712 12.672 13.376 19.712 31.68 19.712 54.912 0 17.6-6.336 34.496-19.008 49.984l-8.448 9.856c-45.76 40.832-73.216 70.4-82.368 89.408-9.856 19.008-14.08 42.24-14.08 68.992v9.856h80.96v-9.856c0-16.896 3.52-31.68 10.56-45.76 6.336-12.672 15.488-24.64 28.16-35.2 33.792-29.568 54.208-48.576 60.544-55.616 16.896-22.528 26.048-51.392 26.048-86.592q0-64.416-42.24-101.376c-28.16-25.344-65.472-37.312-111.232-37.312m-12.672 406.208a54.27 54.27 0 0 0-38.72 14.784 49.4 49.4 0 0 0-15.488 38.016c0 15.488 4.928 28.16 15.488 38.016A54.85 54.85 0 0 0 523.072 768c15.488 0 28.16-4.928 38.72-14.784a51.52 51.52 0 0 0 16.192-38.72 51.97 51.97 0 0 0-15.488-38.016 55.94 55.94 0 0 0-39.424-14.784"
|
|
1354
|
+
}, null, -1)
|
|
1355
|
+
]));
|
|
1356
|
+
}
|
|
1357
|
+
const Question = { render: render$4 };
|
|
1358
|
+
function _isSlot$1(s) {
|
|
1359
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
1360
|
+
}
|
|
1361
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
1362
|
+
...{
|
|
1363
|
+
name: "YxForm"
|
|
1364
|
+
},
|
|
1365
|
+
__name: "index",
|
|
1366
|
+
props: {
|
|
1367
|
+
formParams: {},
|
|
1368
|
+
formList: {},
|
|
1369
|
+
formLayout: {
|
|
1370
|
+
default: "horizontal"
|
|
1371
|
+
},
|
|
1372
|
+
formStyle: {
|
|
1373
|
+
default: () => ({
|
|
1374
|
+
row: 3,
|
|
1375
|
+
gap: "15px",
|
|
1376
|
+
labelWidth: "100px",
|
|
1377
|
+
alignItems: "start"
|
|
1378
|
+
})
|
|
1379
|
+
},
|
|
1380
|
+
rules: {}
|
|
1381
|
+
},
|
|
1382
|
+
setup(__props, {
|
|
1383
|
+
expose: __expose
|
|
1384
|
+
}) {
|
|
1385
|
+
const formData = ref({});
|
|
1386
|
+
const formRules = ref({});
|
|
1387
|
+
const formColumn = ref([]);
|
|
1388
|
+
const attrs = useAttrs();
|
|
1389
|
+
const props = __props;
|
|
1390
|
+
const isOptionsComponent = (type) => type && ["select", "cascader"].includes(type);
|
|
1391
|
+
const initForm = async () => {
|
|
1392
|
+
var _a;
|
|
1393
|
+
const {
|
|
1394
|
+
formList,
|
|
1395
|
+
formParams
|
|
1396
|
+
} = props;
|
|
1397
|
+
formColumn.value = typeof formList === "function" ? await formList() : formList;
|
|
1398
|
+
if (!Array.isArray(formColumn.value) || formColumn.value.length === 0) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
const initialData = {};
|
|
1402
|
+
const fillFormData = (item) => {
|
|
1403
|
+
if (item.prop && !(item.prop in initialData)) {
|
|
1404
|
+
initialData[item.prop] = void 0;
|
|
1405
|
+
}
|
|
1406
|
+
if (isOptionsComponent(item == null ? void 0 : item.renderType)) {
|
|
1407
|
+
loadOptions2(item);
|
|
1408
|
+
}
|
|
1409
|
+
if (Array.isArray(item.children)) {
|
|
1410
|
+
item.children.forEach(fillFormData);
|
|
1411
|
+
}
|
|
1412
|
+
handleLinkOptions(item);
|
|
1413
|
+
};
|
|
1414
|
+
formColumn.value.forEach((item) => fillFormData(item));
|
|
1415
|
+
if (formParams && Object.keys(formParams).length > 0) {
|
|
1416
|
+
if (hasLoadOptions()) {
|
|
1417
|
+
for (const item of formColumn.value) {
|
|
1418
|
+
if (!item.prop) continue;
|
|
1419
|
+
const isAsyncOption = ((_a = item.config) == null ? void 0 : _a.loadOptions) && typeof item.config.loadOptions === "function";
|
|
1420
|
+
if (!(isAsyncOption && formParams[item.prop] !== void 0)) {
|
|
1421
|
+
formData.value[item.prop] = formParams[item.prop];
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
} else {
|
|
1425
|
+
formData.value = formParams;
|
|
1426
|
+
}
|
|
1427
|
+
} else {
|
|
1428
|
+
formData.value = initialData;
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
const handleLinkOptions = (item) => {
|
|
1432
|
+
var _a, _b;
|
|
1433
|
+
if (!((_a = item.config) == null ? void 0 : _a.linkOptions) || (item == null ? void 0 : item._linkedHandled)) return;
|
|
1434
|
+
const linkOptions = item.config.linkOptions;
|
|
1435
|
+
const originOnChange = (_b = item.event) == null ? void 0 : _b.onChange;
|
|
1436
|
+
const newOnChange = async (e) => {
|
|
1437
|
+
var _a2;
|
|
1438
|
+
const updateForm = formColumn.value.find((form) => (form == null ? void 0 : form.prop) === linkOptions);
|
|
1439
|
+
if (!updateForm || !((_a2 = updateForm == null ? void 0 : updateForm.config) == null ? void 0 : _a2.loadOptions)) return;
|
|
1440
|
+
const options = await updateForm.config.loadOptions(e);
|
|
1441
|
+
updateForm.config.options = options;
|
|
1442
|
+
if (typeof originOnChange === "function") {
|
|
1443
|
+
originOnChange(e);
|
|
1444
|
+
}
|
|
1445
|
+
};
|
|
1446
|
+
item.event = {
|
|
1447
|
+
...item.event,
|
|
1448
|
+
onChange: newOnChange
|
|
1449
|
+
};
|
|
1450
|
+
item._linkedHandled = true;
|
|
1451
|
+
};
|
|
1452
|
+
const hasLoadOptions = () => {
|
|
1453
|
+
return formColumn.value.some((item) => {
|
|
1454
|
+
var _a;
|
|
1455
|
+
return ((_a = item.config) == null ? void 0 : _a.loadOptions) && typeof item.config.loadOptions === "function";
|
|
1456
|
+
});
|
|
1457
|
+
};
|
|
1458
|
+
const loadOptions2 = async ({
|
|
1459
|
+
config: config2,
|
|
1460
|
+
prop
|
|
1461
|
+
}) => {
|
|
1462
|
+
var _a;
|
|
1463
|
+
if (!config2 || config2.notAutoLoadOptions) return;
|
|
1464
|
+
const {
|
|
1465
|
+
loadOptions: loadOptions3,
|
|
1466
|
+
options
|
|
1467
|
+
} = config2;
|
|
1468
|
+
if (!options || typeof loadOptions3 !== "function") return;
|
|
1469
|
+
const {
|
|
1470
|
+
formParams
|
|
1471
|
+
} = props;
|
|
1472
|
+
const parentProp = (_a = formColumn.value.find((item) => {
|
|
1473
|
+
var _a2;
|
|
1474
|
+
return ((_a2 = item == null ? void 0 : item.config) == null ? void 0 : _a2.linkOptions) === prop;
|
|
1475
|
+
})) == null ? void 0 : _a.prop;
|
|
1476
|
+
const parentValue = parentProp ? formParams == null ? void 0 : formParams[parentProp] : void 0;
|
|
1477
|
+
try {
|
|
1478
|
+
config2.options = await loadOptions3(parentValue);
|
|
1479
|
+
if (prop && (formParams == null ? void 0 : formParams[prop])) {
|
|
1480
|
+
formData.value[prop] = formParams[prop];
|
|
1481
|
+
}
|
|
1482
|
+
} catch (err) {
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
watch(() => props.formList, (formList) => {
|
|
1486
|
+
if (formList.length > 0) {
|
|
1487
|
+
initForm();
|
|
1488
|
+
getRules();
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1491
|
+
watch(() => props.formParams, (formParams) => {
|
|
1492
|
+
if (formParams) {
|
|
1493
|
+
initForm();
|
|
1494
|
+
}
|
|
1495
|
+
});
|
|
1496
|
+
const getRules = () => {
|
|
1497
|
+
var _a;
|
|
1498
|
+
const rules = {};
|
|
1499
|
+
if (!((_a = formColumn.value) == null ? void 0 : _a.length)) return;
|
|
1500
|
+
const handleRule = (item) => {
|
|
1501
|
+
if (!item.prop) return;
|
|
1502
|
+
const isSelect = (item == null ? void 0 : item.renderType) && ["select", "cascader"].includes(item == null ? void 0 : item.renderType);
|
|
1503
|
+
const defaultRule = {
|
|
1504
|
+
required: true,
|
|
1505
|
+
message: `${item.label ?? "该字段"}不能为空`,
|
|
1506
|
+
trigger: isSelect ? "change" : "blur"
|
|
1507
|
+
};
|
|
1508
|
+
if (item.required) {
|
|
1509
|
+
rules[item.prop] = [defaultRule];
|
|
1510
|
+
}
|
|
1511
|
+
if (item.rules && item.rules.length > 0) {
|
|
1512
|
+
rules[item.prop] = [...rules[item == null ? void 0 : item.prop] || [], ...item.rules];
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
formColumn.value.forEach((form) => {
|
|
1516
|
+
var _a2;
|
|
1517
|
+
(_a2 = form.children) == null ? void 0 : _a2.forEach(handleRule);
|
|
1518
|
+
handleRule(form);
|
|
1519
|
+
});
|
|
1520
|
+
formRules.value = rules;
|
|
1521
|
+
};
|
|
1522
|
+
onBeforeMount(async () => {
|
|
1523
|
+
if (props.formList) {
|
|
1524
|
+
await initForm();
|
|
1525
|
+
getRules();
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
onUnmounted(() => {
|
|
1529
|
+
});
|
|
1530
|
+
const formRef2 = ref();
|
|
1531
|
+
const getFormStyle = () => {
|
|
1532
|
+
const {
|
|
1533
|
+
formStyle
|
|
1534
|
+
} = props;
|
|
1535
|
+
const {
|
|
1536
|
+
row,
|
|
1537
|
+
gap,
|
|
1538
|
+
...style
|
|
1539
|
+
} = formStyle;
|
|
1540
|
+
return {
|
|
1541
|
+
"grid-template-columns": `repeat(${row}, 1fr)`,
|
|
1542
|
+
"grid-gap": gap,
|
|
1543
|
+
...style
|
|
1544
|
+
};
|
|
1545
|
+
};
|
|
1546
|
+
const getGroupStyle = (groupStyle) => {
|
|
1547
|
+
if (!groupStyle) return {};
|
|
1548
|
+
const {
|
|
1549
|
+
row,
|
|
1550
|
+
gap,
|
|
1551
|
+
...style
|
|
1552
|
+
} = groupStyle;
|
|
1553
|
+
return {
|
|
1554
|
+
"grid-template-columns": `repeat(${row}, 1fr)`,
|
|
1555
|
+
"grid-gap": gap,
|
|
1556
|
+
...style
|
|
1557
|
+
};
|
|
1558
|
+
};
|
|
1559
|
+
const dynamicComponent2 = ({
|
|
1560
|
+
renderType,
|
|
1561
|
+
event,
|
|
1562
|
+
prop,
|
|
1563
|
+
label,
|
|
1564
|
+
config: config2
|
|
1565
|
+
}) => {
|
|
1566
|
+
let _slot;
|
|
1567
|
+
if (!prop) return;
|
|
1568
|
+
const {
|
|
1569
|
+
options,
|
|
1570
|
+
...conf
|
|
1571
|
+
} = config2 || {};
|
|
1572
|
+
if (renderType === "cascader") return createVNode(resolveComponent("el-cascader"), mergeProps(event, conf, {
|
|
1573
|
+
"options": options,
|
|
1574
|
+
"modelValue": formData.value[prop],
|
|
1575
|
+
"onUpdate:modelValue": ($event) => formData.value[prop] = $event,
|
|
1576
|
+
"placeholder": `请选择${label}`
|
|
1577
|
+
}), null);
|
|
1578
|
+
const Component = resolveComponent("el-" + renderType);
|
|
1579
|
+
const renderChildComponent = () => {
|
|
1580
|
+
if (renderType === "select" && (config2 == null ? void 0 : config2.options)) {
|
|
1581
|
+
return config2 == null ? void 0 : config2.options.map((item) => createVNode(resolveComponent("el-option"), {
|
|
1582
|
+
"label": item.label,
|
|
1583
|
+
"value": item.value
|
|
1584
|
+
}, null));
|
|
1585
|
+
} else if (renderType === "radio-group" && (config2 == null ? void 0 : config2.options)) {
|
|
1586
|
+
return config2 == null ? void 0 : config2.options.map((item) => createVNode(resolveComponent("el-radio"), {
|
|
1587
|
+
"label": item.label,
|
|
1588
|
+
"value": item.value
|
|
1589
|
+
}, null));
|
|
1590
|
+
} else {
|
|
1591
|
+
return null;
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
const isSelect = renderType && ["select", "cascader"].includes(renderType);
|
|
1595
|
+
return createVNode(Component, mergeProps(event, {
|
|
1596
|
+
"placeholder": `请${isSelect ? "选择" : "输入"}${label}`
|
|
1597
|
+
}, conf, {
|
|
1598
|
+
"modelValue": formData.value[prop],
|
|
1599
|
+
"onUpdate:modelValue": ($event) => formData.value[prop] = $event
|
|
1600
|
+
}), _isSlot$1(_slot = renderChildComponent()) ? _slot : {
|
|
1601
|
+
default: () => [_slot]
|
|
1602
|
+
});
|
|
1603
|
+
};
|
|
1604
|
+
const render2 = (props2) => {
|
|
1605
|
+
var _a;
|
|
1606
|
+
let _slot2;
|
|
1607
|
+
const {
|
|
1608
|
+
formStyle,
|
|
1609
|
+
formLayout
|
|
1610
|
+
} = props2;
|
|
1611
|
+
if (!((_a = formColumn.value) == null ? void 0 : _a.length)) return;
|
|
1612
|
+
const slots = useSlots();
|
|
1613
|
+
const formItemSlots = (form) => {
|
|
1614
|
+
var _a2;
|
|
1615
|
+
return form.slotName && ((_a2 = slots[form.slotName]) == null ? void 0 : _a2.call(slots, formData.value));
|
|
1616
|
+
};
|
|
1617
|
+
const renderFormItem = (formList) => {
|
|
1618
|
+
const renderForm = (form) => {
|
|
1619
|
+
const {
|
|
1620
|
+
className,
|
|
1621
|
+
prop,
|
|
1622
|
+
config: config2,
|
|
1623
|
+
renderType,
|
|
1624
|
+
...formProps
|
|
1625
|
+
} = form;
|
|
1626
|
+
return createVNode(resolveComponent("el-form-item"), mergeProps({
|
|
1627
|
+
"class": `${formLayout === "vertical" ? "flex flex-col " : ""} ${(formStyle == null ? void 0 : formStyle.formItemClassName) ?? ""} ${className ?? ""} ${!form.label ? "no-label-item" : ""}`,
|
|
1628
|
+
"prop": form.prop,
|
|
1629
|
+
"labelWidth": formStyle == null ? void 0 : formStyle.labelWidth,
|
|
1630
|
+
"labelPosition": formStyle == null ? void 0 : formStyle.labelPosition,
|
|
1631
|
+
"key": form.prop
|
|
1632
|
+
}, formProps), {
|
|
1633
|
+
default: () => {
|
|
1634
|
+
if (form == null ? void 0 : form.render) return form == null ? void 0 : form.render(formData.value);
|
|
1635
|
+
if (form.renderType) return dynamicComponent2(form);
|
|
1636
|
+
return (form == null ? void 0 : form.slotName) && formItemSlots(form);
|
|
1637
|
+
},
|
|
1638
|
+
label: () => {
|
|
1639
|
+
var _a2;
|
|
1640
|
+
return form.label ? createVNode("div", {
|
|
1641
|
+
"class": `flex items-center gap-5 ${form.labelClassName ?? ""}`
|
|
1642
|
+
}, [form.label, form.promptConf ? createVNode(resolveComponent("el-tooltip"), (_a2 = form.promptConf) == null ? void 0 : _a2.tooltipConf, {
|
|
1643
|
+
default: () => {
|
|
1644
|
+
var _a3, _b;
|
|
1645
|
+
return [createVNode(resolveComponent("el-icon"), {
|
|
1646
|
+
"size": ((_a3 = form.promptConf) == null ? void 0 : _a3.size) ?? 15,
|
|
1647
|
+
"color": (_b = form.promptConf) == null ? void 0 : _b.color
|
|
1648
|
+
}, {
|
|
1649
|
+
default: () => [createVNode(Question, null, null)]
|
|
1650
|
+
})];
|
|
1651
|
+
}
|
|
1652
|
+
}) : ""]) : null;
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
};
|
|
1656
|
+
return formList.filter((form) => !form.show || form.show(formData.value)).map((form) => {
|
|
1657
|
+
if (form.children && form.children.length > 0) {
|
|
1658
|
+
return createVNode("div", {
|
|
1659
|
+
"class": `flex flex-col ${form.groupWrapClassName ?? ""}`,
|
|
1660
|
+
"style": {
|
|
1661
|
+
...form == null ? void 0 : form.groupWrapStyle
|
|
1662
|
+
}
|
|
1663
|
+
}, [createVNode("div", {
|
|
1664
|
+
"class": form.groupTitleClassName ?? "",
|
|
1665
|
+
"style": {
|
|
1666
|
+
...form == null ? void 0 : form.groupTitleStyle
|
|
1667
|
+
}
|
|
1668
|
+
}, [form.groupName]), createVNode("div", {
|
|
1669
|
+
"class": `grid ${form.groupClassName ?? ""}`,
|
|
1670
|
+
"style": {
|
|
1671
|
+
...getGroupStyle((form == null ? void 0 : form.groupStyle) ?? {})
|
|
1672
|
+
}
|
|
1673
|
+
}, [form.children.filter((form2) => !form2.show || form2.show(formData.value)).map((form2) => renderForm(form2))])]);
|
|
1674
|
+
} else {
|
|
1675
|
+
return renderForm(form);
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
};
|
|
1679
|
+
return createVNode(Fragment, null, [createVNode(resolveComponent("el-form"), mergeProps({
|
|
1680
|
+
"scroll-to-error": true,
|
|
1681
|
+
"model": formData.value,
|
|
1682
|
+
"rules": formRules.value,
|
|
1683
|
+
"class": "grid",
|
|
1684
|
+
"ref": formRef2,
|
|
1685
|
+
"validate-on-rule-change": false
|
|
1686
|
+
}, attrs, {
|
|
1687
|
+
"style": {
|
|
1688
|
+
...getFormStyle()
|
|
1689
|
+
}
|
|
1690
|
+
}), _isSlot$1(_slot2 = renderFormItem(formColumn.value)) ? _slot2 : {
|
|
1691
|
+
default: () => [_slot2]
|
|
1692
|
+
})]);
|
|
1693
|
+
};
|
|
1694
|
+
const formValidate2 = async () => {
|
|
1695
|
+
if (!formRef2.value) return Promise.resolve(false);
|
|
1696
|
+
return await formRef2.value.validate(() => Promise.resolve());
|
|
1697
|
+
};
|
|
1698
|
+
__expose({
|
|
1699
|
+
formData,
|
|
1700
|
+
formValidate: formValidate2,
|
|
1701
|
+
formRef: formRef2
|
|
1702
|
+
});
|
|
1703
|
+
return (_ctx, _cache) => {
|
|
1704
|
+
return openBlock(), createBlock(resolveDynamicComponent(render2(props)));
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
57
1708
|
const _export_sfc = (sfc, props) => {
|
|
58
1709
|
const target = sfc.__vccOpts || sfc;
|
|
59
1710
|
for (const [key, val] of props) {
|
|
@@ -61,6 +1712,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
61
1712
|
}
|
|
62
1713
|
return target;
|
|
63
1714
|
};
|
|
1715
|
+
const YxForm = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-4548eea9"]]);
|
|
64
1716
|
function _isSlot(s) {
|
|
65
1717
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
66
1718
|
}
|
|
@@ -904,7 +2556,7 @@ const translate2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
904
2556
|
loadCustomThesaurus,
|
|
905
2557
|
whitelistApi
|
|
906
2558
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
907
|
-
const _sfc_main$
|
|
2559
|
+
const _sfc_main$2 = {
|
|
908
2560
|
props: {
|
|
909
2561
|
value: {
|
|
910
2562
|
typeof: Number
|
|
@@ -919,8 +2571,8 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
919
2571
|
[vShow, $props.value > 0]
|
|
920
2572
|
]);
|
|
921
2573
|
}
|
|
922
|
-
const Badge = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
923
|
-
const _sfc_main = {
|
|
2574
|
+
const Badge = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-588a1297"]]);
|
|
2575
|
+
const _sfc_main$1 = {
|
|
924
2576
|
components: { theme, issue, Badge, lang },
|
|
925
2577
|
props: {
|
|
926
2578
|
showTool: {
|
|
@@ -1148,7 +2800,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1148
2800
|
_: 1
|
|
1149
2801
|
});
|
|
1150
2802
|
}
|
|
1151
|
-
const ToolbarContainer = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render$1], ["__scopeId", "data-v-adceffc6"]]);
|
|
2803
|
+
const ToolbarContainer = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-adceffc6"]]);
|
|
1152
2804
|
const _hoisted_1$1 = {
|
|
1153
2805
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1154
2806
|
width: "50",
|
|
@@ -1335,13 +2987,69 @@ const _Toolbar = class _Toolbar {
|
|
|
1335
2987
|
return createApp(ToolbarApp).mount(`#${__privateGet(this, _elId)}`);
|
|
1336
2988
|
} else {
|
|
1337
2989
|
const Vue = require("vue");
|
|
1338
|
-
return new Vue({ render: (
|
|
2990
|
+
return new Vue({ render: (h2) => h2(ToolbarApp) }).$mount(`#${__privateGet(this, _elId)}`);
|
|
1339
2991
|
}
|
|
1340
2992
|
}
|
|
1341
2993
|
};
|
|
1342
2994
|
_elId = new WeakMap();
|
|
1343
2995
|
_Toolbar.instance = null;
|
|
1344
2996
|
let Toolbar = _Toolbar;
|
|
2997
|
+
function useEnterKey(callback) {
|
|
2998
|
+
const handleKeyUp = (event) => {
|
|
2999
|
+
if (event.key === "Enter") {
|
|
3000
|
+
callback();
|
|
3001
|
+
}
|
|
3002
|
+
};
|
|
3003
|
+
onMounted(() => {
|
|
3004
|
+
window.addEventListener("keyup", handleKeyUp);
|
|
3005
|
+
});
|
|
3006
|
+
onUnmounted(() => {
|
|
3007
|
+
window.removeEventListener("keyup", handleKeyUp);
|
|
3008
|
+
});
|
|
3009
|
+
onActivated(() => {
|
|
3010
|
+
window.addEventListener("keyup", handleKeyUp);
|
|
3011
|
+
});
|
|
3012
|
+
onDeactivated(() => {
|
|
3013
|
+
window.removeEventListener("keyup", handleKeyUp);
|
|
3014
|
+
});
|
|
3015
|
+
}
|
|
3016
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3017
|
+
__name: "index",
|
|
3018
|
+
props: {
|
|
3019
|
+
onClick: {},
|
|
3020
|
+
noLoading: { type: Boolean, default: false },
|
|
3021
|
+
enter: { type: Boolean, default: false }
|
|
3022
|
+
},
|
|
3023
|
+
setup(__props) {
|
|
3024
|
+
const props = __props;
|
|
3025
|
+
const loading = ref(false);
|
|
3026
|
+
const handleClick = async () => {
|
|
3027
|
+
if (props.onClick) {
|
|
3028
|
+
const result = props.onClick();
|
|
3029
|
+
if (result instanceof Promise && !props.noLoading) {
|
|
3030
|
+
try {
|
|
3031
|
+
loading.value = true;
|
|
3032
|
+
await result;
|
|
3033
|
+
} finally {
|
|
3034
|
+
loading.value = false;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
};
|
|
3039
|
+
if (props.enter) {
|
|
3040
|
+
useEnterKey(handleClick);
|
|
3041
|
+
}
|
|
3042
|
+
return (_ctx, _cache) => {
|
|
3043
|
+
const _component_el_button = resolveComponent("el-button");
|
|
3044
|
+
return openBlock(), createBlock(_component_el_button, mergeProps({ loading: loading.value }, _ctx.$attrs, { onClick: handleClick }), {
|
|
3045
|
+
default: withCtx(() => [
|
|
3046
|
+
renderSlot(_ctx.$slots, "default")
|
|
3047
|
+
]),
|
|
3048
|
+
_: 3
|
|
3049
|
+
}, 16, ["loading"]);
|
|
3050
|
+
};
|
|
3051
|
+
}
|
|
3052
|
+
});
|
|
1345
3053
|
const TTC_THTEME_KEY = "ttcGlobalState";
|
|
1346
3054
|
const install = async (config2) => {
|
|
1347
3055
|
var _a;
|
|
@@ -1569,30 +3277,39 @@ const BC$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty
|
|
|
1569
3277
|
BC
|
|
1570
3278
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1571
3279
|
export {
|
|
3280
|
+
getCurTheme as A,
|
|
1572
3281
|
BC$1 as B,
|
|
3282
|
+
getCurThemeCssVar as C,
|
|
3283
|
+
getGroupColor as D,
|
|
3284
|
+
findColorByTheme as E,
|
|
3285
|
+
installCssVarInSystemTheme as F,
|
|
1573
3286
|
Toolbar as T,
|
|
1574
|
-
|
|
3287
|
+
YxForm as Y,
|
|
1575
3288
|
_export_sfc as _,
|
|
1576
3289
|
theme2 as a,
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
3290
|
+
useConfirm as b,
|
|
3291
|
+
useDialog as c,
|
|
3292
|
+
useMessage as d,
|
|
3293
|
+
BC as e,
|
|
3294
|
+
_sfc_main as f,
|
|
3295
|
+
_sfc_main$4 as g,
|
|
3296
|
+
YxTableBar as h,
|
|
3297
|
+
YxTablePro as i,
|
|
3298
|
+
initTranslate as j,
|
|
3299
|
+
changeLang as k,
|
|
3300
|
+
getLang as l,
|
|
3301
|
+
getWordByYxI18nThesaurus as m,
|
|
3302
|
+
getZhWordByYxI18nThesaurus as n,
|
|
3303
|
+
loadCustomThesaurus as o,
|
|
3304
|
+
page as p,
|
|
3305
|
+
handleTranslation as q,
|
|
3306
|
+
install as r,
|
|
1594
3307
|
saveCssVar as s,
|
|
1595
3308
|
translate2 as t,
|
|
1596
|
-
|
|
1597
|
-
|
|
3309
|
+
useTime as u,
|
|
3310
|
+
changeTheme as v,
|
|
3311
|
+
whitelistApi as w,
|
|
3312
|
+
updateTheme as x,
|
|
3313
|
+
setCssVar as y,
|
|
3314
|
+
getDefaultThemeUrl as z
|
|
1598
3315
|
};
|