vue2-components-plus 1.0.68 → 1.0.69

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.
@@ -1,3719 +0,0 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
5
- function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
6
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
7
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
11
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
12
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
13
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
17
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
18
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
19
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
20
- var __defProp = Object.defineProperty;
21
- var __defProps = Object.defineProperties;
22
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
23
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
24
- var __hasOwnProp = Object.prototype.hasOwnProperty;
25
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
26
- var __defNormalProp = function __defNormalProp(obj, key, value) {
27
- return key in obj ? __defProp(obj, key, {
28
- enumerable: true,
29
- configurable: true,
30
- writable: true,
31
- value: value
32
- }) : obj[key] = value;
33
- };
34
- var __spreadValues = function __spreadValues(a, b) {
35
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
36
- if (__getOwnPropSymbols) {
37
- var _iterator = _createForOfIteratorHelper(__getOwnPropSymbols(b)),
38
- _step;
39
- try {
40
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
41
- var prop = _step.value;
42
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
43
- }
44
- } catch (err) {
45
- _iterator.e(err);
46
- } finally {
47
- _iterator.f();
48
- }
49
- }
50
- return a;
51
- };
52
- var __spreadProps = function __spreadProps(a, b) {
53
- return __defProps(a, __getOwnPropDescs(b));
54
- };
55
- var __objRest = function __objRest(source, exclude) {
56
- var target = {};
57
- for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
58
- if (source != null && __getOwnPropSymbols) {
59
- var _iterator2 = _createForOfIteratorHelper(__getOwnPropSymbols(source)),
60
- _step2;
61
- try {
62
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
63
- var prop = _step2.value;
64
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
65
- }
66
- } catch (err) {
67
- _iterator2.e(err);
68
- } finally {
69
- _iterator2.f();
70
- }
71
- }
72
- return target;
73
- };
74
- import Vue, { getCurrentInstance, nextTick } from "vue";
75
- var main = "";
76
- function parseBindingValue(binding) {
77
- var defaultConfig = {
78
- maxLength: 50,
79
- pattern: null,
80
- min: null,
81
- max: null,
82
- int: false
83
- };
84
- var value = binding.value;
85
- if (typeof value === "number") {
86
- return __spreadProps(__spreadValues({}, defaultConfig), {
87
- maxLength: value
88
- });
89
- }
90
- if (value && _typeof(value) === "object") {
91
- return {
92
- maxLength: value.maxLength || defaultConfig.maxLength,
93
- pattern: value.pattern || null,
94
- min: typeof value.min === "number" ? value.min : null,
95
- max: typeof value.max === "number" ? value.max : null,
96
- int: !!value.int
97
- };
98
- }
99
- return defaultConfig;
100
- }
101
- function formatNumberInput(value, maxLength) {
102
- var allowNegative = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
103
- var result = "";
104
- var hasMinus = false;
105
- var hasDot = false;
106
- String(value || "").split("").forEach(function (char, index2) {
107
- if (char === "-") {
108
- if (allowNegative && index2 === 0 && !hasMinus) {
109
- result += char;
110
- hasMinus = true;
111
- }
112
- return;
113
- }
114
- if (char === ".") {
115
- if (index2 !== 0 && !hasDot && result[result.length - 1] !== "-") {
116
- result += char;
117
- hasDot = true;
118
- }
119
- return;
120
- }
121
- if (/^\d$/.test(char)) {
122
- var current = hasMinus ? result.slice(1) : result;
123
- if (current === "0" && char !== "0" && !hasDot) {
124
- result = hasMinus ? "-" : "";
125
- }
126
- result += char;
127
- }
128
- });
129
- return result.slice(0, maxLength);
130
- }
131
- function formatIntegerInput(value, maxLength, config) {
132
- var result = "";
133
- var hasMinus = false;
134
- var allowNegative = config.min !== null && config.min < 0;
135
- String(value || "").split("").forEach(function (char, index2) {
136
- if (char === "-") {
137
- if (allowNegative && index2 === 0 && !hasMinus) {
138
- result += char;
139
- hasMinus = true;
140
- }
141
- return;
142
- }
143
- if (/^\d$/.test(char)) {
144
- var current = hasMinus ? result.slice(1) : result;
145
- if (current === "0" && char !== "0") {
146
- result = hasMinus ? "-" : "";
147
- }
148
- result += char;
149
- }
150
- });
151
- return result.slice(0, maxLength);
152
- }
153
- function formatRangeInput(value, config) {
154
- if (config.int) {
155
- var result2 = formatIntegerInput(value, config.maxLength || 50, config);
156
- if (result2 === "" || result2 === "-") return result2;
157
- var numberValue2 = parseInt(result2, 10);
158
- if (Number.isNaN(numberValue2)) return "";
159
- if (config.min !== null && numberValue2 < config.min) return String(Math.ceil(config.min));
160
- if (config.max !== null && numberValue2 > config.max) return String(Math.floor(config.max));
161
- return result2;
162
- }
163
- var allowNegative = config.min !== null && config.min < 0;
164
- var result = formatNumberInput(value, config.maxLength || 50, allowNegative);
165
- if (result === "" || result === "-" || result === ".") return result;
166
- var numberValue = parseFloat(result);
167
- if (Number.isNaN(numberValue)) return "";
168
- if (config.min !== null && numberValue < config.min) return String(config.min);
169
- if (config.max !== null && numberValue > config.max) return String(config.max);
170
- return result;
171
- }
172
- function formatRegexInput(value, maxLength, pattern) {
173
- var result = "";
174
- String(value || "").split("").forEach(function (char) {
175
- if (result.length >= maxLength) return;
176
- var nextValue = result + char;
177
- if (pattern.test(nextValue)) {
178
- result = nextValue;
179
- }
180
- });
181
- return result;
182
- }
183
- function getInputElement(el) {
184
- if (!el) return null;
185
- if (el.tagName === "INPUT" || el.tagName === "TEXTAREA") {
186
- return el;
187
- }
188
- return el.querySelector("input, textarea");
189
- }
190
- function updateInputValue(inputEl, binding) {
191
- if (!inputEl) return;
192
- var config = parseBindingValue(binding);
193
- var nextValue = inputEl.value || "";
194
- if (binding.modifiers.range) {
195
- nextValue = formatRangeInput(nextValue, config);
196
- } else if (binding.modifiers.number) {
197
- nextValue = formatNumberInput(nextValue, config.maxLength);
198
- } else if (binding.modifiers.regex && config.pattern) {
199
- nextValue = formatRegexInput(nextValue, config.maxLength, config.pattern);
200
- } else {
201
- nextValue = String(nextValue).slice(0, config.maxLength);
202
- }
203
- if (nextValue !== inputEl.value) {
204
- inputEl.value = nextValue;
205
- inputEl.dispatchEvent(new Event("input", {
206
- bubbles: true
207
- }));
208
- }
209
- }
210
- function bindLengthDirective(el, binding) {
211
- var inputEl = getInputElement(el);
212
- if (!inputEl) return;
213
- var composing = false;
214
- var handleCompositionStart = function handleCompositionStart() {
215
- composing = true;
216
- };
217
- var handleCompositionEnd = function handleCompositionEnd() {
218
- composing = false;
219
- updateInputValue(inputEl, binding);
220
- };
221
- var handleInput = function handleInput() {
222
- if (!composing) {
223
- updateInputValue(inputEl, binding);
224
- }
225
- };
226
- inputEl.addEventListener("compositionstart", handleCompositionStart);
227
- inputEl.addEventListener("compositionend", handleCompositionEnd);
228
- inputEl.addEventListener("input", handleInput);
229
- updateInputValue(inputEl, binding);
230
- el.__nsLengthHandlers = {
231
- inputEl: inputEl,
232
- handleCompositionStart: handleCompositionStart,
233
- handleCompositionEnd: handleCompositionEnd,
234
- handleInput: handleInput
235
- };
236
- }
237
- function unbindLengthDirective(el) {
238
- var handlers = el.__nsLengthHandlers;
239
- if (!handlers) return;
240
- handlers.inputEl.removeEventListener("compositionstart", handlers.handleCompositionStart);
241
- handlers.inputEl.removeEventListener("compositionend", handlers.handleCompositionEnd);
242
- handlers.inputEl.removeEventListener("input", handlers.handleInput);
243
- delete el.__nsLengthHandlers;
244
- }
245
- var enterClickDirective = {
246
- inserted: function inserted(el) {
247
- var handler = function handler(event) {
248
- if (event.key !== "Enter") return;
249
- var activeEl = document.activeElement;
250
- var isSelectTrigger = activeEl && activeEl.tagName === "INPUT" && activeEl.closest(".el-select");
251
- if (isSelectTrigger) {
252
- var isDropdownOpen = activeEl.getAttribute("aria-expanded") === "true";
253
- if (isDropdownOpen) {
254
- return;
255
- }
256
- }
257
- el.click();
258
- if (isSelectTrigger) {
259
- event.preventDefault();
260
- event.stopPropagation();
261
- }
262
- };
263
- el.__nsEnterClickHandler = handler;
264
- document.addEventListener("keydown", handler, true);
265
- },
266
- unbind: function unbind(el) {
267
- if (el.__nsEnterClickHandler) {
268
- document.removeEventListener("keydown", el.__nsEnterClickHandler, true);
269
- delete el.__nsEnterClickHandler;
270
- }
271
- }
272
- };
273
- function registerDirective(Vue2) {
274
- Vue2.directive("sline", {
275
- inserted: function inserted(el) {
276
- el.style.whiteSpace = "nowrap";
277
- el.style.overflow = "hidden";
278
- el.style.textOverflow = "ellipsis";
279
- el.style.display = "inline-block";
280
- el.style.maxWidth = "100%";
281
- }
282
- });
283
- Vue2.directive("permission", {
284
- inserted: function inserted(el, binding) {
285
- var permissionList = [];
286
- try {
287
- permissionList = JSON.parse(sessionStorage.getItem("btnsPermission") || localStorage.getItem("btnsPermission") || "[]");
288
- } catch (error) {
289
- permissionList = [];
290
- }
291
- if (!Array.isArray(permissionList)) {
292
- permissionList = [];
293
- }
294
- var selector = binding.modifiers.class ? "class" : "id";
295
- var isDisplayNone = !!binding.modifiers.display;
296
- var matched = selector === "class" ? permissionList.some(function (item) {
297
- return el.classList.contains(item);
298
- }) : permissionList.includes(el.getAttribute("id"));
299
- if (!matched) {
300
- if (isDisplayNone) {
301
- el.style.display = "none";
302
- } else {
303
- el.style.visibility = "hidden";
304
- el.style.pointerEvents = "none";
305
- }
306
- }
307
- }
308
- });
309
- Vue2.directive("length", {
310
- inserted: function inserted(el, binding) {
311
- bindLengthDirective(el, binding);
312
- },
313
- componentUpdated: function componentUpdated(el, binding) {
314
- var inputEl = getInputElement(el);
315
- updateInputValue(inputEl, binding);
316
- },
317
- unbind: function unbind(el) {
318
- unbindLengthDirective(el);
319
- }
320
- });
321
- Vue2.directive("event-unuse", {
322
- inserted: function inserted(el) {
323
- el.style.pointerEvents = "none";
324
- }
325
- });
326
- Vue2.directive("event-use", {
327
- inserted: function inserted(el) {
328
- el.style.pointerEvents = "auto";
329
- }
330
- });
331
- Vue2.directive("enterClick", enterClickDirective);
332
- Vue2.directive("enter-click", enterClickDirective);
333
- }
334
- var ThemeVar$1 = /*#__PURE__*/_createClass(function ThemeVar() {
335
- _classCallCheck(this, ThemeVar);
336
- });
337
- ThemeVar$1.VARS = {};
338
- function loadCssVars$1() {
339
- if (typeof document === "undefined") {
340
- return ThemeVar$1.VARS;
341
- }
342
- if (Object.keys(ThemeVar$1.VARS).length > 0) {
343
- return ThemeVar$1.VARS;
344
- }
345
- var variables = {};
346
- Array.from(document.styleSheets || []).forEach(function (sheet) {
347
- var cssRules = [];
348
- try {
349
- cssRules = Array.from(sheet.cssRules || []);
350
- } catch (error) {
351
- cssRules = [];
352
- }
353
- cssRules.forEach(function (rule) {
354
- if (rule.selectorText !== ":root") {
355
- return;
356
- }
357
- Array.from(rule.style || []).filter(function (name) {
358
- return name.indexOf("--matrix-") === 0;
359
- }).forEach(function (name) {
360
- variables[name] = rule.style.getPropertyValue(name).trim();
361
- });
362
- });
363
- });
364
- ThemeVar$1.VARS = variables;
365
- return variables;
366
- }
367
- function toKebabCase$1(value) {
368
- if (typeof value !== "string") return value;
369
- if (value.indexOf("-") > -1) return value.toLowerCase();
370
- return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
371
- }
372
- function normalizeComponent$1(component) {
373
- if (!component) return "span";
374
- if (typeof component === "string") {
375
- return toKebabCase$1(component);
376
- }
377
- return component;
378
- }
379
- function getFieldBindings(field) {
380
- if (!field || _typeof(field) !== "object") return {};
381
- return __spreadValues(__spreadValues(__spreadValues({}, field.attrs || {}), field.props || {}), field.params || {});
382
- }
383
- function cloneVNodeWithSlot(vnode, slotName) {
384
- if (!vnode || slotName === "default") {
385
- return vnode;
386
- }
387
- var data = vnode.data || (vnode.data = {});
388
- data.slot = slotName;
389
- return vnode;
390
- }
391
- function normalizeChildren(result, slotName) {
392
- if (!result) return [];
393
- var list = Array.isArray(result) ? result : [result];
394
- return list.map(function (item) {
395
- return cloneVNodeWithSlot(item, slotName);
396
- }).filter(Boolean);
397
- }
398
- function isComponentName(component, names) {
399
- var name = String(typeof component === "string" ? component : component && component.name ? component.name : "").replace(/-/g, "").toLowerCase();
400
- return names.some(function (item) {
401
- return name === item.toLowerCase();
402
- });
403
- }
404
- var FormFieldRenderer = {
405
- name: "NsFormFieldRenderer",
406
- inheritAttrs: false,
407
- props: {
408
- field: {
409
- type: Object,
410
- required: true
411
- },
412
- value: {
413
- default: void 0
414
- }
415
- },
416
- mounted: function mounted() {
417
- this.emitRef();
418
- },
419
- updated: function updated() {
420
- this.emitRef();
421
- },
422
- methods: {
423
- emitRef: function emitRef() {
424
- this.$emit("ref", this.$refs.control || null);
425
- },
426
- getComponent: function getComponent() {
427
- return normalizeComponent$1(this.field.component);
428
- },
429
- isUpload: function isUpload() {
430
- return isComponentName(this.field.component, ["elupload"]);
431
- },
432
- rendersOptionsByChildren: function rendersOptionsByChildren() {
433
- return isComponentName(this.field.component, ["elselect", "elradiogroup", "elcheckboxgroup"]);
434
- },
435
- isFullWidthComponent: function isFullWidthComponent() {
436
- return isComponentName(this.field.component, ["elinput", "elselect", "elcascader", "eldatepicker", "eltimepicker", "elinputnumber", "elautocomplete"]);
437
- },
438
- getBindings: function getBindings() {
439
- return getFieldBindings(this.field);
440
- },
441
- getRenderableBindings: function getRenderableBindings() {
442
- var _this = this;
443
- var bindings = this.getBindings();
444
- var result = {};
445
- Object.keys(bindings).forEach(function (key) {
446
- if (key.indexOf("v-") === 0) return;
447
- if (key === "rules" || key === "style") return;
448
- if (key === "options" && _this.rendersOptionsByChildren()) return;
449
- result[key] = bindings[key];
450
- });
451
- return result;
452
- },
453
- buildProps: function buildProps() {
454
- var result = this.getRenderableBindings();
455
- if (!this.isUpload()) {
456
- result.value = this.value;
457
- }
458
- return result;
459
- },
460
- buildAttrs: function buildAttrs() {
461
- return this.getRenderableBindings();
462
- },
463
- buildStyle: function buildStyle() {
464
- var bindings = this.getBindings();
465
- var style = __spreadValues(__spreadValues({}, this.field.style || {}), bindings.style || {});
466
- if (this.isFullWidthComponent() && style.width === void 0) {
467
- style.width = "100%";
468
- }
469
- return style;
470
- },
471
- buildDirectives: function buildDirectives() {
472
- var bindings = this.getBindings();
473
- return Object.keys(bindings).filter(function (key) {
474
- return key.indexOf("v-") === 0;
475
- }).map(function (key) {
476
- var _key$split = key.split("v-"),
477
- _key$split2 = _slicedToArray(_key$split, 2),
478
- definition = _key$split2[1];
479
- var _definition$split = definition.split("."),
480
- _definition$split2 = _toArray(_definition$split),
481
- name = _definition$split2[0],
482
- modifiers = _arrayLikeToArray(_definition$split2).slice(1);
483
- var modifierObject = {};
484
- modifiers.forEach(function (item) {
485
- modifierObject[item] = true;
486
- });
487
- return {
488
- name: name,
489
- value: bindings[key],
490
- modifiers: modifierObject
491
- };
492
- });
493
- },
494
- buildEvents: function buildEvents() {
495
- var _this2 = this;
496
- var userEvents = this.field.events || {};
497
- var listeners = {};
498
- Object.keys(userEvents).forEach(function (name) {
499
- listeners[name] = function () {
500
- userEvents[name].apply(userEvents, arguments);
501
- };
502
- });
503
- if (!this.isUpload()) {
504
- var originalInput = listeners.input;
505
- listeners.input = function (val) {
506
- _this2.$emit("input", val);
507
- if (originalInput) {
508
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
509
- args[_key - 1] = arguments[_key];
510
- }
511
- originalInput.apply(void 0, [val].concat(args));
512
- }
513
- };
514
- }
515
- return listeners;
516
- },
517
- buildScopedSlots: function buildScopedSlots() {
518
- var slots = this.field.slots || {};
519
- var scopedSlots = {};
520
- Object.keys(slots).forEach(function (name) {
521
- if (typeof slots[name] === "function") {
522
- scopedSlots[name] = function (scope) {
523
- return slots[name](scope);
524
- };
525
- }
526
- });
527
- return scopedSlots;
528
- },
529
- renderOptionNodes: function renderOptionNodes(h) {
530
- var bindings = this.getBindings();
531
- var options = bindings.options || [];
532
- var component = this.getComponent();
533
- if (!Array.isArray(options) || options.length === 0) {
534
- return [];
535
- }
536
- if (isComponentName(component, ["elselect"])) {
537
- return options.map(function (option, index2) {
538
- return h("el-option", {
539
- key: option.value !== void 0 ? option.value : index2,
540
- props: {
541
- label: option.label,
542
- value: option.value,
543
- disabled: option.disabled
544
- }
545
- });
546
- });
547
- }
548
- if (isComponentName(component, ["elradiogroup"])) {
549
- return options.map(function (option, index2) {
550
- return h("el-radio", {
551
- key: option.value !== void 0 ? option.value : index2,
552
- props: {
553
- label: option.value,
554
- disabled: option.disabled
555
- }
556
- }, [option.label]);
557
- });
558
- }
559
- if (isComponentName(component, ["elcheckboxgroup"])) {
560
- return options.map(function (option, index2) {
561
- return h("el-checkbox", {
562
- key: option.value !== void 0 ? option.value : index2,
563
- props: {
564
- label: option.value,
565
- disabled: option.disabled
566
- }
567
- }, [option.label]);
568
- });
569
- }
570
- return [];
571
- }
572
- },
573
- render: function render(h) {
574
- var _this3 = this;
575
- var component = this.getComponent();
576
- var slotNodes = [];
577
- var slots = this.field.slots || {};
578
- Object.keys(slots).forEach(function (name) {
579
- if (typeof slots[name] === "function") {
580
- slotNodes.push.apply(slotNodes, _toConsumableArray(normalizeChildren(slots[name]({
581
- field: _this3.field,
582
- value: _this3.value
583
- }), name)));
584
- }
585
- });
586
- return h(component, {
587
- ref: "control",
588
- props: this.buildProps(),
589
- attrs: this.buildAttrs(),
590
- style: this.buildStyle(),
591
- on: this.buildEvents(),
592
- directives: this.buildDirectives(),
593
- scopedSlots: this.buildScopedSlots()
594
- }, [].concat(_toConsumableArray(this.renderOptionNodes(h)), slotNodes));
595
- }
596
- };
597
- function isNotNull(value) {
598
- if (Array.isArray(value)) {
599
- return true;
600
- }
601
- if (value === 0 || value === "0") {
602
- return true;
603
- }
604
- return !(value === "" || value === null || typeof value === "undefined" || value === "null" || value === "undefined" || String(value).trim() === "" || String(value).trim() === "undefined");
605
- }
606
- var DynamicForm_vue_vue_type_style_index_0_scoped_a83d5d48_lang = "";
607
- function normalizeComponent(scriptExports, render7, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
608
- var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
609
- if (render7) {
610
- options.render = render7;
611
- options.staticRenderFns = staticRenderFns;
612
- options._compiled = true;
613
- }
614
- if (functionalTemplate) {
615
- options.functional = true;
616
- }
617
- if (scopeId) {
618
- options._scopeId = "data-v-" + scopeId;
619
- }
620
- var hook;
621
- if (moduleIdentifier) {
622
- hook = function hook(context) {
623
- context = context ||
624
- // cached call
625
- this.$vnode && this.$vnode.ssrContext ||
626
- // stateful
627
- this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
628
- if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
629
- context = __VUE_SSR_CONTEXT__;
630
- }
631
- if (injectStyles) {
632
- injectStyles.call(this, context);
633
- }
634
- if (context && context._registeredComponents) {
635
- context._registeredComponents.add(moduleIdentifier);
636
- }
637
- };
638
- options._ssrRegister = hook;
639
- } else if (injectStyles) {
640
- hook = shadowMode ? function () {
641
- injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
642
- } : injectStyles;
643
- }
644
- if (hook) {
645
- if (options.functional) {
646
- options._injectStyles = hook;
647
- var originalRender = options.render;
648
- options.render = function renderWithStyleInjection(h, context) {
649
- hook.call(context);
650
- return originalRender(h, context);
651
- };
652
- } else {
653
- var existing = options.beforeCreate;
654
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
655
- }
656
- }
657
- return {
658
- exports: scriptExports,
659
- options: options
660
- };
661
- }
662
- function deepClone(value) {
663
- if (value === null || _typeof(value) !== "object") {
664
- return value;
665
- }
666
- if (Array.isArray(value)) {
667
- return value.map(function (item) {
668
- return deepClone(item);
669
- });
670
- }
671
- var result = {};
672
- Object.keys(value).forEach(function (key) {
673
- result[key] = deepClone(value[key]);
674
- });
675
- return result;
676
- }
677
- function normalizeComponentName(component) {
678
- var name = String(typeof component === "string" ? component : component && component.name ? component.name : "");
679
- return name.replace(/-/g, "").toLowerCase();
680
- }
681
- var _sfc_main$5 = {
682
- name: "NsForm",
683
- components: {
684
- FormFieldRenderer: FormFieldRenderer
685
- },
686
- props: {
687
- model: {
688
- type: String,
689
- default: ""
690
- },
691
- readOnly: {
692
- type: Boolean,
693
- default: false
694
- },
695
- labelWidth: {
696
- type: String,
697
- default: "80px"
698
- },
699
- superLabelWidth: {
700
- type: String,
701
- default: "30px"
702
- },
703
- labelColor: {
704
- type: String,
705
- default: "#0A7BFF"
706
- },
707
- gapH: {
708
- type: String,
709
- default: "10px"
710
- },
711
- gapV: {
712
- type: String,
713
- default: "10px"
714
- },
715
- height: {
716
- type: String,
717
- default: "32px"
718
- },
719
- rows: {
720
- type: Array,
721
- default: function _default() {
722
- return [];
723
- }
724
- },
725
- backgroundColor: {
726
- type: String,
727
- default: ""
728
- },
729
- valueEmptyTag: {
730
- type: String,
731
- default: "--"
732
- },
733
- formPropKey: {
734
- type: String,
735
- default: "rows"
736
- },
737
- hasPoint: {
738
- type: Boolean,
739
- default: false
740
- },
741
- labelPosition: {
742
- type: String,
743
- default: "left"
744
- }
745
- },
746
- data: function data() {
747
- return {
748
- componentRefs: {}
749
- };
750
- },
751
- computed: {
752
- formClassList: function formClassList() {
753
- var labelPosition = this.normalizedLabelPosition;
754
- return {
755
- "is-vertical": this.model.indexOf("vertical") > -1,
756
- "is-table": this.model.indexOf("table") > -1,
757
- "is-readonly": this.readOnly,
758
- "is-label-left": labelPosition === "left",
759
- "is-label-right": labelPosition === "right",
760
- "is-label-top": labelPosition === "top"
761
- };
762
- },
763
- normalizedLabelPosition: function normalizedLabelPosition() {
764
- return ["left", "right", "top"].includes(this.labelPosition) ? this.labelPosition : "left";
765
- },
766
- wrapperStyle: function wrapperStyle() {
767
- return {
768
- "--ns-form-label-width": this.normalizeSize(this.labelWidth),
769
- "--ns-form-super-label-width": this.normalizeSize(this.superLabelWidth),
770
- "--ns-form-label-color": this.labelColor,
771
- "--ns-form-row-gap": this.normalizeSize(this.gapV),
772
- "--ns-form-col-gap": this.normalizeSize(this.gapH),
773
- "--ns-form-item-height": this.normalizeSize(this.height),
774
- "--ns-form-background-color": this.backgroundColor || "#ffffff"
775
- };
776
- },
777
- rowStyle: function rowStyle() {
778
- return {
779
- marginBottom: this.model.indexOf("table") > -1 ? "0" : this.normalizeSize(this.gapV)
780
- };
781
- },
782
- labelStyle: function labelStyle() {
783
- return {
784
- width: this.normalizeSize(this.labelWidth),
785
- color: this.labelColor,
786
- textAlign: this.normalizedLabelPosition === "right" ? "right" : "left"
787
- };
788
- },
789
- groupLabelStyle: function groupLabelStyle() {
790
- return {
791
- width: this.normalizeSize(this.superLabelWidth),
792
- color: this.labelColor,
793
- textAlign: this.normalizedLabelPosition === "right" ? "right" : "left"
794
- };
795
- },
796
- valueStyle: function valueStyle() {
797
- return {
798
- minHeight: this.normalizeSize(this.height)
799
- };
800
- }
801
- },
802
- watch: {
803
- rows: {
804
- handler: function handler(newRows) {
805
- this.initializeDefaultValues(newRows);
806
- },
807
- deep: true,
808
- immediate: true
809
- }
810
- },
811
- methods: {
812
- walkFields: function walkFields(callback) {
813
- (this.rows || []).forEach(function (row, rowIndex) {
814
- (row || []).forEach(function (item, itemIndex) {
815
- callback(item, rowIndex, itemIndex, null, null);
816
- (item.children || []).forEach(function (child, childIndex) {
817
- callback(child, rowIndex, itemIndex, childIndex, item);
818
- });
819
- });
820
- });
821
- },
822
- initializeDefaultValues: function initializeDefaultValues(rows) {
823
- var _this4 = this;
824
- (rows || []).forEach(function (row) {
825
- (row || []).forEach(function (item) {
826
- if (item && item.key && item.defaultValue === void 0) {
827
- _this4.$set(item, "defaultValue", deepClone(item.value));
828
- }
829
- (item.children || []).forEach(function (child) {
830
- if (child && child.key && child.defaultValue === void 0) {
831
- _this4.$set(child, "defaultValue", deepClone(child.value));
832
- }
833
- });
834
- });
835
- });
836
- },
837
- normalizeSize: function normalizeSize(value) {
838
- if (value === null || value === void 0 || value === "") return "";
839
- return /^\d+$/.test(String(value)) ? "".concat(value, "px") : String(value);
840
- },
841
- hasChildren: function hasChildren(item) {
842
- return Array.isArray(item.children) && item.children.length > 0;
843
- },
844
- getItemStyle: function getItemStyle(item, row) {
845
- if (item.span === 0) {
846
- return {
847
- display: "none"
848
- };
849
- }
850
- if (typeof item.span === "string" && item.span.indexOf("%") > -1) {
851
- return {
852
- flex: "0 0 ".concat(item.span),
853
- maxWidth: item.span
854
- };
855
- }
856
- if (item.span !== void 0 && item.span !== null && item.span !== "") {
857
- var span = Number(item.span);
858
- if (!Number.isNaN(span)) {
859
- var width2 = span > 24 ? "".concat(span, "px") : "".concat(span / 24 * 100, "%");
860
- return {
861
- flex: "0 0 ".concat(width2),
862
- maxWidth: width2
863
- };
864
- }
865
- }
866
- var columns = (row || []).filter(function (field) {
867
- return field && field.span !== 0;
868
- }).length || 1;
869
- var width = "calc((100% - ".concat(columns - 1, " * var(--ns-form-col-gap)) / ").concat(columns, ")");
870
- return {
871
- flex: "0 0 ".concat(width),
872
- maxWidth: width
873
- };
874
- },
875
- getFieldRules: function getFieldRules(field) {
876
- if (this.readOnly) return [];
877
- return field.params && field.params.rules || [];
878
- },
879
- isRequiredField: function isRequiredField(field) {
880
- if (!field || this.readOnly) return false;
881
- if (typeof field.required === "boolean") {
882
- return field.required;
883
- }
884
- return this.getFieldRules(field).some(function (rule) {
885
- return rule && rule.required;
886
- });
887
- },
888
- getFieldRequired: function getFieldRequired(field) {
889
- if (!field || this.readOnly) return false;
890
- return field && typeof field.required === "boolean" ? field.required : void 0;
891
- },
892
- updateFieldValue: function updateFieldValue(field, value) {
893
- this.$set(field, "value", value);
894
- },
895
- setComponentRef: function setComponentRef(field, ref) {
896
- if (!field || !field.key) return;
897
- this.$set(field, "ref", ref);
898
- this.$set(this.componentRefs, field.key, ref);
899
- },
900
- showReadOnlyText: function showReadOnlyText(field) {
901
- return this.readOnly && !(field && field.readOnlyUseComponent);
902
- },
903
- normalizeDisplayValue: function normalizeDisplayValue(value, field) {
904
- if (isNotNull(value)) {
905
- if (Array.isArray(value)) {
906
- return value.join(",");
907
- }
908
- return value;
909
- }
910
- return field && field.valueEmptyTag || this.valueEmptyTag;
911
- },
912
- getReadOnlyDisplayValue: function getReadOnlyDisplayValue(field) {
913
- var _a, _b, _c;
914
- if (!field) {
915
- return this.valueEmptyTag;
916
- }
917
- if (typeof ((_a = field.params) == null ? void 0 : _a.formatter) === "function") {
918
- return field.params.formatter(field.value, field) || this.valueEmptyTag;
919
- }
920
- if (!isNotNull(field.value)) {
921
- return field.valueEmptyTag || this.valueEmptyTag;
922
- }
923
- if (this.isUploadComponent(field)) {
924
- return (field.value || []).map(function (item) {
925
- return item.fileName || item.name || item.filePath;
926
- }).filter(Boolean).join(",") || field.valueEmptyTag || this.valueEmptyTag;
927
- }
928
- if (this.isSwitchComponent(field)) {
929
- return field.value ? ((_b = field.params) == null ? void 0 : _b.activeText) || "是" : ((_c = field.params) == null ? void 0 : _c.inactiveText) || "否";
930
- }
931
- if (this.isSelectLikeComponent(field)) {
932
- return this.getOptionDisplayText(field);
933
- }
934
- if (this.isCascaderComponent(field)) {
935
- return this.getCascaderDisplayValue(field);
936
- }
937
- if (Array.isArray(field.value)) {
938
- return field.value.join(",");
939
- }
940
- return field.value;
941
- },
942
- getOptionDisplayText: function getOptionDisplayText(field) {
943
- var _a;
944
- var options = ((_a = field.params) == null ? void 0 : _a.options) || [];
945
- var rawValue = field.value;
946
- var valueList = Array.isArray(rawValue) ? rawValue : typeof rawValue === "string" && rawValue.indexOf(",") > -1 ? rawValue.split(",").filter(Boolean) : [rawValue];
947
- var labels = valueList.map(function (value) {
948
- var option = options.find(function (item) {
949
- return item.value === value;
950
- });
951
- return option ? option.label : value;
952
- }).filter(function (item) {
953
- return item !== void 0 && item !== null && item !== "";
954
- });
955
- return labels.join(",") || field.valueEmptyTag || this.valueEmptyTag;
956
- },
957
- getCascaderDisplayValue: function getCascaderDisplayValue(field) {
958
- var _a, _b, _c, _d;
959
- var params = field.params || {};
960
- var options = params.options || [];
961
- var propConfig = {
962
- value: ((_a = params.props) == null ? void 0 : _a.value) || "value",
963
- label: ((_b = params.props) == null ? void 0 : _b.label) || "label",
964
- children: ((_c = params.props) == null ? void 0 : _c.children) || "children",
965
- multiple: !!((_d = params.props) == null ? void 0 : _d.multiple),
966
- separator: params.separator || " / "
967
- };
968
- var normalizePath = function normalizePath(pathValue) {
969
- if (Array.isArray(pathValue)) return pathValue;
970
- if (typeof pathValue === "string" && pathValue.indexOf(",") > -1) {
971
- return pathValue.split(",").filter(Boolean);
972
- }
973
- return [pathValue];
974
- };
975
- var getPathLabels = function getPathLabels(pathValue) {
976
- var labels = [];
977
- var currentOptions = options;
978
- normalizePath(pathValue).forEach(function (value) {
979
- var current = (currentOptions || []).find(function (item) {
980
- return item[propConfig.value] === value;
981
- });
982
- if (current) {
983
- labels.push(current[propConfig.label]);
984
- currentOptions = current[propConfig.children];
985
- }
986
- });
987
- return labels.join(propConfig.separator);
988
- };
989
- if (propConfig.multiple && Array.isArray(field.value) && Array.isArray(field.value[0])) {
990
- return field.value.map(function (item) {
991
- return getPathLabels(item);
992
- }).join(",");
993
- }
994
- return getPathLabels(field.value);
995
- },
996
- isSelectLikeComponent: function isSelectLikeComponent(field) {
997
- return ["elselect", "elradiogroup", "elcheckboxgroup"].includes(normalizeComponentName(field.component));
998
- },
999
- isSwitchComponent: function isSwitchComponent(field) {
1000
- return normalizeComponentName(field.component) === "elswitch";
1001
- },
1002
- isCascaderComponent: function isCascaderComponent(field) {
1003
- return normalizeComponentName(field.component) === "elcascader";
1004
- },
1005
- isUploadComponent: function isUploadComponent(field) {
1006
- return normalizeComponentName(field.component) === "elupload";
1007
- },
1008
- getFormNodeByKey: function getFormNodeByKey(key) {
1009
- for (var rowIndex = 0; rowIndex < this.rows.length; rowIndex += 1) {
1010
- var row = this.rows[rowIndex];
1011
- for (var colIndex = 0; colIndex < row.length; colIndex += 1) {
1012
- var item = row[colIndex];
1013
- if (item.key === key) return item;
1014
- for (var childIndex = 0; childIndex < (item.children || []).length; childIndex += 1) {
1015
- var child = item.children[childIndex];
1016
- if (child.key === key) return child;
1017
- }
1018
- }
1019
- }
1020
- return null;
1021
- },
1022
- getFormNodeRefByKey: function getFormNodeRefByKey(key) {
1023
- return this.componentRefs[key] || null;
1024
- },
1025
- getFormKvData: function getFormKvData() {
1026
- var result = {};
1027
- this.walkFields(function (field) {
1028
- if (!field || !field.key) return;
1029
- result[field.key] = Array.isArray(field.value) && Array.isArray(field.delValue) ? field.value.concat(field.delValue) : field.value;
1030
- });
1031
- return result;
1032
- },
1033
- resetForm: function resetForm() {
1034
- var _this5 = this;
1035
- var triggerEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1036
- this.walkFields(function (field) {
1037
- var _a, _b;
1038
- if (!field || !field.key) return;
1039
- var oldValue = deepClone(field.value);
1040
- var nextValue = field.defaultValue !== void 0 ? deepClone(field.defaultValue) : Array.isArray(field.value) ? [] : typeof field.value === "boolean" ? false : typeof field.value === "number" ? 0 : "";
1041
- _this5.$set(field, "value", nextValue);
1042
- if (field.delValue !== void 0) {
1043
- _this5.$set(field, "delValue", []);
1044
- }
1045
- if (field.params && Array.isArray(field.params.fileList)) {
1046
- field.params.fileList.splice(0, field.params.fileList.length);
1047
- }
1048
- if (triggerEvents && JSON.stringify(oldValue) !== JSON.stringify(nextValue)) {
1049
- if (typeof ((_a = field.events) == null ? void 0 : _a.change) === "function") {
1050
- _this5.$nextTick(function () {
1051
- return field.events.change(nextValue);
1052
- });
1053
- }
1054
- if (typeof ((_b = field.events) == null ? void 0 : _b.input) === "function") {
1055
- _this5.$nextTick(function () {
1056
- return field.events.input(nextValue);
1057
- });
1058
- }
1059
- }
1060
- });
1061
- },
1062
- setFormData: function setFormData(data) {
1063
- var _this6 = this;
1064
- if (!data || _typeof(data) !== "object") {
1065
- return;
1066
- }
1067
- this.walkFields(function (field) {
1068
- if (!field || !field.key || !Object.prototype.hasOwnProperty.call(data, field.key)) return;
1069
- var nextValue = deepClone(data[field.key]);
1070
- if (_this6.isCascaderComponent(field) && typeof nextValue === "string" && nextValue.indexOf(",") > -1) {
1071
- nextValue = nextValue.split(",").filter(Boolean);
1072
- }
1073
- _this6.$set(field, "value", nextValue);
1074
- if (_this6.isUploadComponent(field)) {
1075
- var fileList = Array.isArray(nextValue) ? deepClone(nextValue) : [];
1076
- if (field.params) {
1077
- _this6.$set(field.params, "fileList", fileList);
1078
- }
1079
- }
1080
- });
1081
- },
1082
- initDefaultValues: function initDefaultValues() {
1083
- this.initializeDefaultValues(this.rows);
1084
- }
1085
- }
1086
- };
1087
- var _sfc_render$5 = function render() {
1088
- var _vm = this,
1089
- _c = _vm._self._c;
1090
- return _vm.rows && _vm.rows.length ? _c("div", {
1091
- staticClass: "ns-dynamic-form",
1092
- class: _vm.formClassList,
1093
- style: _vm.wrapperStyle
1094
- }, _vm._l(_vm.rows, function (row, rowIndex) {
1095
- return _c("div", {
1096
- key: "row-".concat(rowIndex),
1097
- staticClass: "ns-dynamic-form__row",
1098
- style: _vm.rowStyle
1099
- }, _vm._l(row, function (item, itemIndex) {
1100
- return _c("div", {
1101
- key: item.key || "".concat(rowIndex, "-").concat(itemIndex),
1102
- staticClass: "ns-dynamic-form__item",
1103
- class: {
1104
- "has-children": _vm.hasChildren(item)
1105
- },
1106
- style: _vm.getItemStyle(item, row)
1107
- }, [_vm.hasChildren(item) ? [!item.hideLabel && item.label ? _c("div", {
1108
- staticClass: "ns-dynamic-form__group-label",
1109
- style: _vm.groupLabelStyle
1110
- }, [_vm._v(" " + _vm._s(item.label) + " ")]) : _vm._e(), _c("div", {
1111
- staticClass: "ns-dynamic-form__children"
1112
- }, _vm._l(item.children, function (child, childIndex) {
1113
- return _c("div", {
1114
- key: child.key || "".concat(rowIndex, "-").concat(itemIndex, "-").concat(childIndex),
1115
- staticClass: "ns-dynamic-form__child"
1116
- }, [!child.hideLabel && child.label ? _c("div", {
1117
- staticClass: "ns-dynamic-form__label",
1118
- class: {
1119
- "has-point": _vm.hasPoint || _vm.isRequiredField(child)
1120
- },
1121
- style: _vm.labelStyle
1122
- }, [_vm._v(" " + _vm._s(child.label) + " ")]) : _vm._e(), _c("div", {
1123
- staticClass: "ns-dynamic-form__value",
1124
- style: _vm.valueStyle
1125
- }, [_vm.showReadOnlyText(child) ? [_c("span", {
1126
- directives: [{
1127
- name: "sline",
1128
- rawName: "v-sline"
1129
- }]
1130
- }, [_vm._v(_vm._s(_vm.getReadOnlyDisplayValue(child)))])] : child.component ? [_c("el-form-item", {
1131
- staticClass: "ns-dynamic-form__form-item",
1132
- attrs: {
1133
- "label-width": "0px",
1134
- "prop": "".concat(_vm.formPropKey, ".").concat(rowIndex, ".").concat(itemIndex, ".children.").concat(childIndex, ".value"),
1135
- "rules": _vm.getFieldRules(child),
1136
- "required": _vm.getFieldRequired(child)
1137
- }
1138
- }, [_c("form-field-renderer", {
1139
- attrs: {
1140
- "field": child,
1141
- "value": child.value
1142
- },
1143
- on: {
1144
- "input": function input($event) {
1145
- return _vm.updateFieldValue(child, $event);
1146
- },
1147
- "ref": function ref($event) {
1148
- return _vm.setComponentRef(child, $event);
1149
- }
1150
- }
1151
- })], 1)] : [_c("span", {
1152
- directives: [{
1153
- name: "sline",
1154
- rawName: "v-sline"
1155
- }]
1156
- }, [_vm._v(_vm._s(_vm.normalizeDisplayValue(child.value, child)))])]], 2)]);
1157
- }), 0)] : [!item.hideLabel && item.label ? _c("div", {
1158
- staticClass: "ns-dynamic-form__label",
1159
- class: {
1160
- "has-point": _vm.hasPoint || _vm.isRequiredField(item)
1161
- },
1162
- style: _vm.labelStyle
1163
- }, [_vm._v(" " + _vm._s(item.label) + " ")]) : _vm._e(), _c("div", {
1164
- staticClass: "ns-dynamic-form__value",
1165
- style: _vm.valueStyle
1166
- }, [_vm.showReadOnlyText(item) ? [_c("span", {
1167
- directives: [{
1168
- name: "sline",
1169
- rawName: "v-sline"
1170
- }]
1171
- }, [_vm._v(_vm._s(_vm.getReadOnlyDisplayValue(item)))])] : item.component ? [_c("el-form-item", {
1172
- staticClass: "ns-dynamic-form__form-item",
1173
- attrs: {
1174
- "label-width": "0px",
1175
- "prop": "".concat(_vm.formPropKey, ".").concat(rowIndex, ".").concat(itemIndex, ".value"),
1176
- "rules": _vm.getFieldRules(item),
1177
- "required": _vm.getFieldRequired(item)
1178
- }
1179
- }, [_c("form-field-renderer", {
1180
- attrs: {
1181
- "field": item,
1182
- "value": item.value
1183
- },
1184
- on: {
1185
- "input": function input($event) {
1186
- return _vm.updateFieldValue(item, $event);
1187
- },
1188
- "ref": function ref($event) {
1189
- return _vm.setComponentRef(item, $event);
1190
- }
1191
- }
1192
- })], 1)] : [_c("span", {
1193
- directives: [{
1194
- name: "sline",
1195
- rawName: "v-sline"
1196
- }]
1197
- }, [_vm._v(_vm._s(_vm.normalizeDisplayValue(item.value, item)))])]], 2)]], 2);
1198
- }), 0);
1199
- }), 0) : _vm._e();
1200
- };
1201
- var _sfc_staticRenderFns$5 = [];
1202
- var __component__$5 = /* @__PURE__ */normalizeComponent(_sfc_main$5, _sfc_render$5, _sfc_staticRenderFns$5, false, null, "a83d5d48", null, null);
1203
- var NsForm = __component__$5.exports;
1204
- var ThemeVar2 = /*#__PURE__*/_createClass(function ThemeVar2() {
1205
- _classCallCheck(this, ThemeVar2);
1206
- });
1207
- ThemeVar2.VARS = {};
1208
- function loadCssVars() {
1209
- if (typeof document === "undefined") {
1210
- return ThemeVar2.VARS;
1211
- }
1212
- if (Object.keys(ThemeVar2.VARS).length > 0) {
1213
- return ThemeVar2.VARS;
1214
- }
1215
- var variables = {};
1216
- Array.from(document.styleSheets || []).forEach(function (sheet) {
1217
- var cssRules = [];
1218
- try {
1219
- cssRules = Array.from(sheet.cssRules || []);
1220
- } catch (error) {
1221
- cssRules = [];
1222
- }
1223
- cssRules.forEach(function (rule) {
1224
- if (rule.selectorText !== ":root") {
1225
- return;
1226
- }
1227
- Array.from(rule.style || []).filter(function (name) {
1228
- return name.indexOf("--matrix-") === 0;
1229
- }).forEach(function (name) {
1230
- variables[name] = rule.style.getPropertyValue(name).trim();
1231
- });
1232
- });
1233
- });
1234
- ThemeVar2.VARS = variables;
1235
- return variables;
1236
- }
1237
- var DynamicFormTitle_vue_vue_type_style_index_0_scoped_29c80ec1_lang = "";
1238
- var _sfc_main$4 = {
1239
- name: "NsFormTitle",
1240
- props: {
1241
- title: {
1242
- type: String,
1243
- default: ""
1244
- }
1245
- },
1246
- mounted: function mounted() {
1247
- loadCssVars();
1248
- }
1249
- };
1250
- var _sfc_render$4 = function render2() {
1251
- var _vm = this,
1252
- _c = _vm._self._c;
1253
- return _c("div", {
1254
- staticClass: "ns-form-title"
1255
- }, [_c("div", {
1256
- staticClass: "ns-form-title__header"
1257
- }, [_vm._t("title", function () {
1258
- return [_c("span", {
1259
- staticClass: "ns-form-title__icon"
1260
- }), _c("span", {
1261
- staticClass: "ns-form-title__text"
1262
- }, [_vm._v(_vm._s(_vm.title))])];
1263
- })], 2), _c("div", {
1264
- staticClass: "ns-form-title__content"
1265
- }, [_vm._t("default")], 2)]);
1266
- };
1267
- var _sfc_staticRenderFns$4 = [];
1268
- var __component__$4 = /* @__PURE__ */normalizeComponent(_sfc_main$4, _sfc_render$4, _sfc_staticRenderFns$4, false, null, "29c80ec1", null, null);
1269
- var NsFormTitle = __component__$4.exports;
1270
- function getImageBaseUrl(instance) {
1271
- var _a;
1272
- return ((_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$ImageBaseUrl) || "";
1273
- }
1274
- function getFieldPathByKey(rows, key) {
1275
- var formPropKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "rows";
1276
- for (var rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
1277
- var row = rows[rowIndex];
1278
- for (var colIndex = 0; colIndex < row.length; colIndex += 1) {
1279
- var item = row[colIndex];
1280
- if (item.key === key) {
1281
- return "".concat(formPropKey, ".").concat(rowIndex, ".").concat(colIndex, ".value");
1282
- }
1283
- if (Array.isArray(item.children)) {
1284
- for (var childIndex = 0; childIndex < item.children.length; childIndex += 1) {
1285
- var child = item.children[childIndex];
1286
- if (child.key === key) {
1287
- return "".concat(formPropKey, ".").concat(rowIndex, ".").concat(colIndex, ".children.").concat(childIndex, ".value");
1288
- }
1289
- }
1290
- }
1291
- }
1292
- }
1293
- return null;
1294
- }
1295
- function useFileUpload(state) {
1296
- var instance = getCurrentInstance();
1297
- function handleFormatFileList(field, fileList) {
1298
- var baseUrl = getImageBaseUrl(instance);
1299
- var nextList = Array.isArray(fileList) ? fileList : [];
1300
- nextList.forEach(function (item) {
1301
- if (item.filePath && !item.url) {
1302
- item.url = "".concat(baseUrl).concat(item.filePath);
1303
- }
1304
- if (!item.name) {
1305
- item.name = item.fileName || item.name || item.filePath || "未命名文件";
1306
- }
1307
- });
1308
- if (field && field.params) {
1309
- field.params.fileList = nextList;
1310
- }
1311
- if (field) {
1312
- field.value = nextList.slice();
1313
- }
1314
- return nextList;
1315
- }
1316
- function handleRemoveFile(file, fileList, fieldKey) {
1317
- var rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : state.rows;
1318
- var field = getAllFormNodeByKey(rows, fieldKey);
1319
- if (!field) {
1320
- return fileList;
1321
- }
1322
- var nextValue = (fileList || []).map(function (item) {
1323
- return __spreadProps(__spreadValues({}, item), {
1324
- fileName: item.response ? item.response.data.fileName : item.fileName,
1325
- filePath: item.response ? item.response.data.filePath : item.filePath,
1326
- fileSize: item.response ? item.response.data.fileSize : item.fileSize
1327
- });
1328
- });
1329
- if (!Array.isArray(field.delValue)) {
1330
- field.delValue = [];
1331
- }
1332
- if (!file.response && file.status === "success") {
1333
- field.delValue.push(__spreadProps(__spreadValues({}, file), {
1334
- isDelete: 1
1335
- }));
1336
- }
1337
- field.value = nextValue;
1338
- if (field.params) {
1339
- field.params.fileList = fileList || [];
1340
- }
1341
- return fileList;
1342
- }
1343
- function handleFileSuccessFile(response, file, fileList, fieldKey) {
1344
- var rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : state.rows;
1345
- var field = getAllFormNodeByKey(rows, fieldKey);
1346
- if (!field) {
1347
- return fileList;
1348
- }
1349
- if (!Array.isArray(field.value)) {
1350
- field.value = [];
1351
- }
1352
- if (file && file.status === "success" && response && response.data) {
1353
- field.value.push(__spreadValues({}, response.data));
1354
- }
1355
- if (field.params) {
1356
- field.params.fileList = fileList || [];
1357
- }
1358
- return fileList;
1359
- }
1360
- function handleCheckFileRequire(rows, key, formRef) {
1361
- var formPropKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "rows";
1362
- var field = getAllFormNodeByKey(rows, key);
1363
- if (field && !Array.isArray(field.value)) {
1364
- field.value = [];
1365
- }
1366
- var fieldPath = getFieldPathByKey(rows, key, formPropKey);
1367
- nextTick(function () {
1368
- var formInstance = formRef && (formRef.value || formRef);
1369
- if (fieldPath && formInstance && typeof formInstance.validateField === "function") {
1370
- formInstance.validateField(fieldPath);
1371
- }
1372
- });
1373
- }
1374
- return {
1375
- handleFormatFileList: handleFormatFileList,
1376
- handleRemoveFile: handleRemoveFile,
1377
- handleFileSuccessFile: handleFileSuccessFile,
1378
- handleCheckFileRequire: handleCheckFileRequire
1379
- };
1380
- }
1381
- function installComponent(component) {
1382
- component.install = function install3(Vue2) {
1383
- Vue2.component(component.name, component);
1384
- };
1385
- }
1386
- installComponent(NsForm);
1387
- installComponent(NsFormTitle);
1388
- var originalNsFormInstall = NsForm.install;
1389
- NsForm.install = function install(Vue2) {
1390
- registerDirective(Vue2);
1391
- originalNsFormInstall(Vue2);
1392
- };
1393
- function getAllFormKvData(rows) {
1394
- var result = {};
1395
- (rows || []).forEach(function (row) {
1396
- (row || []).forEach(function (item) {
1397
- if (item && item.key) {
1398
- result[item.key] = Array.isArray(item.value) && Array.isArray(item.delValue) ? item.value.concat(item.delValue) : item.value;
1399
- }
1400
- (item.children || []).forEach(function (child) {
1401
- if (child && child.key) {
1402
- result[child.key] = Array.isArray(child.value) && Array.isArray(child.delValue) ? child.value.concat(child.delValue) : child.value;
1403
- }
1404
- });
1405
- });
1406
- });
1407
- return result;
1408
- }
1409
- function getAllFormNodeByKey(rows, key) {
1410
- for (var rowIndex = 0; rowIndex < (rows || []).length; rowIndex += 1) {
1411
- var row = rows[rowIndex] || [];
1412
- for (var colIndex = 0; colIndex < row.length; colIndex += 1) {
1413
- var item = row[colIndex];
1414
- if (item && item.key === key) {
1415
- return item;
1416
- }
1417
- var children = item && item.children || [];
1418
- for (var childIndex = 0; childIndex < children.length; childIndex += 1) {
1419
- if (children[childIndex] && children[childIndex].key === key) {
1420
- return children[childIndex];
1421
- }
1422
- }
1423
- }
1424
- }
1425
- return null;
1426
- }
1427
- function getAllFormNodeRefByKey(rows, key) {
1428
- var node = getAllFormNodeByKey(rows, key);
1429
- return node ? node.ref || null : null;
1430
- }
1431
- if (typeof globalThis !== "undefined") {
1432
- globalThis.getAllFormKvData = getAllFormKvData;
1433
- globalThis.getAllFormNodeByKey = getAllFormNodeByKey;
1434
- globalThis.getAllFormNodeRefByKey = getAllFormNodeRefByKey;
1435
- }
1436
- var SlotRenderer = {
1437
- name: "NsSlotRenderer",
1438
- functional: true,
1439
- props: {
1440
- renderer: {
1441
- type: Function,
1442
- default: null
1443
- },
1444
- scope: {
1445
- type: Object,
1446
- default: function _default() {
1447
- return {};
1448
- }
1449
- }
1450
- },
1451
- render: function render(h, ctx) {
1452
- var renderer = ctx.props.renderer;
1453
- return renderer ? renderer(ctx.props.scope || {}) : null;
1454
- }
1455
- };
1456
- var PageSearch_vue_vue_type_style_index_0_scoped_90982d04_lang = "";
1457
- function toKebabCase(value) {
1458
- if (typeof value !== "string") return value;
1459
- if (value.indexOf("-") > -1) return value.toLowerCase();
1460
- return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1461
- }
1462
- var _sfc_main$3 = {
1463
- name: "NsSearch",
1464
- components: {
1465
- SlotRenderer: SlotRenderer
1466
- },
1467
- inheritAttrs: false,
1468
- props: {
1469
- items: {
1470
- type: Array,
1471
- default: function _default() {
1472
- return [];
1473
- }
1474
- },
1475
- externalParams: {
1476
- type: Object,
1477
- default: function _default() {
1478
- return {};
1479
- }
1480
- },
1481
- defaultSpan: {
1482
- type: Number,
1483
- default: 6
1484
- },
1485
- showCollapse: {
1486
- type: Boolean,
1487
- default: true
1488
- },
1489
- collapseLimit: {
1490
- type: Number,
1491
- default: 3
1492
- },
1493
- slotRenderers: {
1494
- type: Object,
1495
- default: function _default() {
1496
- return {};
1497
- }
1498
- },
1499
- actionsAlign: {
1500
- type: String,
1501
- default: "left"
1502
- },
1503
- actionsSpan: {
1504
- type: Number,
1505
- default: null
1506
- },
1507
- actionsWidth: {
1508
- type: [String, Number],
1509
- default: ""
1510
- },
1511
- collapseToggleText: {
1512
- type: [Array, String],
1513
- default: function _default() {
1514
- return ["展开", "收起"];
1515
- }
1516
- },
1517
- enterTrigger: {
1518
- type: Boolean,
1519
- default: true
1520
- }
1521
- },
1522
- data: function data() {
1523
- return {
1524
- formData: {},
1525
- isCollapsed: true
1526
- };
1527
- },
1528
- computed: {
1529
- itemsPerRow: function itemsPerRow() {
1530
- var span = Number(this.defaultSpan || 6);
1531
- var normalizedSpan = Number.isFinite(span) && span > 0 ? span : 6;
1532
- return Math.max(1, Math.floor(24 / normalizedSpan));
1533
- },
1534
- visibleItems: function visibleItems() {
1535
- if (!this.showCollapse || !this.isCollapsed) {
1536
- return this.items;
1537
- }
1538
- var sourceItems = this.items || [];
1539
- var limit = Math.min(Number(this.collapseLimit || 0), sourceItems.length);
1540
- if (limit > 0 && limit % this.itemsPerRow === 0 && sourceItems.length > limit) {
1541
- limit = limit - 1;
1542
- }
1543
- return sourceItems.slice(0, Math.max(limit, 1));
1544
- },
1545
- normalizedActionsAlign: function normalizedActionsAlign() {
1546
- var value = String(this.actionsAlign || "").toLowerCase();
1547
- return ["left", "center", "right"].includes(value) ? value : "left";
1548
- },
1549
- actionAlignClass: function actionAlignClass() {
1550
- return "page-search__actions--".concat(this.normalizedActionsAlign);
1551
- },
1552
- resolvedActionsSpan: function resolvedActionsSpan() {
1553
- var span = Number(this.actionsSpan);
1554
- if (Number.isFinite(span) && span > 0) {
1555
- return Math.min(Math.floor(span), 24);
1556
- }
1557
- return Number(this.defaultSpan || 6);
1558
- },
1559
- actionsColStyle: function actionsColStyle() {
1560
- var width = this.toCssSize(this.actionsWidth);
1561
- if (!width) return void 0;
1562
- return {
1563
- flex: "0 0 ".concat(width),
1564
- maxWidth: width
1565
- };
1566
- },
1567
- collapseToggleLabels: function collapseToggleLabels() {
1568
- if (Array.isArray(this.collapseToggleText)) {
1569
- var expandLabel2 = String(this.collapseToggleText[0] || "").trim();
1570
- var collapseLabel2 = String(this.collapseToggleText[1] || "").trim();
1571
- return [expandLabel2 || "展开", collapseLabel2 || "收起"];
1572
- }
1573
- var text = String(this.collapseToggleText || "").trim();
1574
- if (!text) return ["展开", "收起"];
1575
- var parts = text.split("/");
1576
- var expandLabel = String(parts[0] || "").trim();
1577
- var collapseLabel = String(parts[1] || "").trim();
1578
- return [expandLabel || "展开", collapseLabel || "收起"];
1579
- }
1580
- },
1581
- watch: {
1582
- items: {
1583
- handler: function handler() {
1584
- this.initFormData();
1585
- },
1586
- deep: true,
1587
- immediate: true
1588
- },
1589
- externalParams: {
1590
- handler: function handler() {
1591
- this.formData = __spreadValues(__spreadValues({}, this.formData), this.externalParams);
1592
- },
1593
- deep: true,
1594
- immediate: true
1595
- }
1596
- },
1597
- methods: {
1598
- normalizeComponent: function normalizeComponent(component) {
1599
- return typeof component === "string" ? toKebabCase(component) : component;
1600
- },
1601
- initFormData: function initFormData() {
1602
- var nextData = {};
1603
- (this.items || []).forEach(function (item) {
1604
- nextData[item.prop] = item.defaultValue !== void 0 ? item.defaultValue : void 0;
1605
- });
1606
- this.formData = __spreadValues(__spreadValues({}, nextData), this.externalParams);
1607
- },
1608
- isSlotItem: function isSlotItem(item) {
1609
- return item && (item.type === "slot" || item.slot === true || typeof item.slot === "string");
1610
- },
1611
- getSlotRenderer: function getSlotRenderer(item) {
1612
- var name = typeof item.slot === "string" ? item.slot : item.slotName || item.prop;
1613
- return this.slotRenderers[name] || null;
1614
- },
1615
- isSelectComponent: function isSelectComponent(item) {
1616
- var name = String(this.normalizeComponent(item.component || "") || "");
1617
- return name === "el-select";
1618
- },
1619
- toCssSize: function toCssSize(value) {
1620
- if (value === "" || value === null || value === void 0) return "";
1621
- if (typeof value === "number") return "".concat(value, "px");
1622
- return String(value);
1623
- },
1624
- handleSearch: function handleSearch() {
1625
- this.$emit("search", __spreadProps(__spreadValues({}, this.formData), {
1626
- _resetPage: true
1627
- }));
1628
- },
1629
- handleReset: function handleReset() {
1630
- var nextData = {};
1631
- (this.items || []).forEach(function (item) {
1632
- nextData[item.prop] = item.defaultValue !== void 0 ? item.defaultValue : void 0;
1633
- });
1634
- this.formData = __spreadValues(__spreadValues({}, nextData), this.externalParams);
1635
- this.$emit("search", __spreadProps(__spreadValues({}, this.formData), {
1636
- _resetPage: true
1637
- }));
1638
- this.$emit("reset");
1639
- },
1640
- toggleCollapse: function toggleCollapse() {
1641
- this.isCollapsed = !this.isCollapsed;
1642
- },
1643
- getFormData: function getFormData() {
1644
- return __spreadValues({}, this.formData);
1645
- },
1646
- setFormData: function setFormData(data) {
1647
- this.formData = __spreadValues(__spreadValues({}, this.formData), data || {});
1648
- },
1649
- resetForm: function resetForm() {
1650
- this.handleReset();
1651
- },
1652
- validate: function validate() {
1653
- return this.$refs.formRef && this.$refs.formRef.validate ? this.$refs.formRef.validate() : Promise.resolve(true);
1654
- },
1655
- clearValidate: function clearValidate(props) {
1656
- if (this.$refs.formRef && this.$refs.formRef.clearValidate) {
1657
- this.$refs.formRef.clearValidate(props);
1658
- }
1659
- }
1660
- }
1661
- };
1662
- var _sfc_render$3 = function render3() {
1663
- var _vm = this,
1664
- _c = _vm._self._c;
1665
- return _c("div", {
1666
- staticClass: "page-search"
1667
- }, [_c("el-form", _vm._b({
1668
- ref: "formRef",
1669
- staticClass: "page-search__form",
1670
- attrs: {
1671
- "inline": true,
1672
- "model": _vm.formData
1673
- }
1674
- }, "el-form", _vm.$attrs, false), [_c("el-row", {
1675
- staticClass: "page-search__row",
1676
- attrs: {
1677
- "gutter": 16,
1678
- "type": "flex"
1679
- }
1680
- }, [_vm._l(_vm.visibleItems, function (item, index2) {
1681
- return _c("el-col", {
1682
- key: item.prop || index2,
1683
- attrs: {
1684
- "span": item.span || _vm.defaultSpan
1685
- }
1686
- }, [_c("el-form-item", _vm._b({
1687
- attrs: {
1688
- "label": item.label,
1689
- "prop": item.prop
1690
- }
1691
- }, "el-form-item", item.formItemAttrs || {}, false), [_vm.isSlotItem(item) ? _c("slot-renderer", {
1692
- attrs: {
1693
- "renderer": _vm.getSlotRenderer(item),
1694
- "scope": {
1695
- formData: _vm.formData,
1696
- item: item
1697
- }
1698
- }
1699
- }) : _c(_vm.normalizeComponent(item.component || "el-input"), _vm._g(_vm._b({
1700
- tag: "component",
1701
- model: {
1702
- value: _vm.formData[item.prop],
1703
- callback: function callback($$v) {
1704
- _vm.$set(_vm.formData, item.prop, $$v);
1705
- },
1706
- expression: "formData[item.prop]"
1707
- }
1708
- }, "component", item.attrs || {}, false), item.events || {}), [_vm.isSelectComponent(item) ? _vm._l(item.children || [], function (option, optionIndex) {
1709
- return _c("el-option", {
1710
- key: option.value !== void 0 ? option.value : optionIndex,
1711
- attrs: {
1712
- "label": option.label,
1713
- "value": option.value,
1714
- "disabled": option.disabled
1715
- }
1716
- });
1717
- }) : _vm._e()], 2)], 1)], 1);
1718
- }), _c("el-col", {
1719
- staticClass: "page-search__actions",
1720
- class: _vm.actionAlignClass,
1721
- style: _vm.actionsColStyle,
1722
- attrs: {
1723
- "span": _vm.resolvedActionsSpan
1724
- }
1725
- }, [_c("el-form-item", {
1726
- attrs: {
1727
- "label-width": "0"
1728
- }
1729
- }, [_vm.enterTrigger ? _c("el-button", {
1730
- directives: [{
1731
- name: "enterClick",
1732
- rawName: "v-enterClick"
1733
- }],
1734
- attrs: {
1735
- "type": "primary"
1736
- },
1737
- on: {
1738
- "click": _vm.handleSearch
1739
- }
1740
- }, [_vm._v("查询")]) : _c("el-button", {
1741
- attrs: {
1742
- "type": "primary"
1743
- },
1744
- on: {
1745
- "click": _vm.handleSearch
1746
- }
1747
- }, [_vm._v("查询")]), _c("el-button", {
1748
- on: {
1749
- "click": _vm.handleReset
1750
- }
1751
- }, [_vm._v("重置")]), _vm.slotRenderers["actions-after-reset"] ? _c("slot-renderer", {
1752
- attrs: {
1753
- "renderer": _vm.slotRenderers["actions-after-reset"],
1754
- "scope": {
1755
- formData: _vm.formData,
1756
- handleSearch: _vm.handleSearch,
1757
- handleReset: _vm.handleReset,
1758
- isCollapsed: _vm.isCollapsed
1759
- }
1760
- }
1761
- }) : _vm._e(), _vm.showCollapse && _vm.items.length > _vm.collapseLimit ? _c("el-button", {
1762
- attrs: {
1763
- "type": "text"
1764
- },
1765
- on: {
1766
- "click": _vm.toggleCollapse
1767
- }
1768
- }, [_c("span", [_vm._v(_vm._s(_vm.isCollapsed ? _vm.collapseToggleLabels[0] : _vm.collapseToggleLabels[1]))]), _c("i", {
1769
- class: _vm.isCollapsed ? "el-icon-arrow-down" : "el-icon-arrow-up"
1770
- })]) : _vm._e()], 1)], 1)], 2)], 1)], 1);
1771
- };
1772
- var _sfc_staticRenderFns$3 = [];
1773
- var __component__$3 = /* @__PURE__ */normalizeComponent(_sfc_main$3, _sfc_render$3, _sfc_staticRenderFns$3, false, null, "90982d04", null, null);
1774
- var NsSearch = __component__$3.exports;
1775
- var RESERVED_KEYS = ["children", "slot", "headerSlot", "buttons", "enum", "type", "imageWidth", "imageHeight", "linkText"];
1776
- var TableColumn = {
1777
- name: "NsTableColumn",
1778
- props: {
1779
- column: {
1780
- type: Object,
1781
- required: true
1782
- },
1783
- slotRenderers: {
1784
- type: Object,
1785
- default: function _default() {
1786
- return {};
1787
- }
1788
- }
1789
- },
1790
- methods: {
1791
- getColumnProps: function getColumnProps(column) {
1792
- var props = __spreadValues({}, column);
1793
- RESERVED_KEYS.forEach(function (key) {
1794
- return delete props[key];
1795
- });
1796
- return props;
1797
- },
1798
- getRenderer: function getRenderer(name) {
1799
- return name ? this.slotRenderers[name] : null;
1800
- },
1801
- getCellValue: function getCellValue(row, column) {
1802
- return column.prop ? row[column.prop] : void 0;
1803
- },
1804
- isVisible: function isVisible(config, row) {
1805
- if (typeof config.show === "function") {
1806
- return config.show(row) !== false;
1807
- }
1808
- if (config.show === void 0) {
1809
- return true;
1810
- }
1811
- return !!config.show;
1812
- },
1813
- isDisabled: function isDisabled(config, row) {
1814
- return typeof config.disabled === "function" ? !!config.disabled(row) : !!config.disabled;
1815
- },
1816
- renderActionButtons: function renderActionButtons(h, scope, column) {
1817
- var _this7 = this;
1818
- var buttons = Array.isArray(column.buttons) ? column.buttons : [];
1819
- return buttons.filter(function (button) {
1820
- return _this7.isVisible(button, scope.row);
1821
- }).map(function (button, index2) {
1822
- var slotRenderer = _this7.getRenderer(button.slot);
1823
- if (slotRenderer) {
1824
- return slotRenderer(__spreadProps(__spreadValues({}, scope), {
1825
- row: scope.row,
1826
- column: column,
1827
- button: button
1828
- }));
1829
- }
1830
- return h("el-button", {
1831
- key: button.label || index2,
1832
- props: {
1833
- size: button.size || "mini",
1834
- type: button.link ? "text" : button.type || "text",
1835
- icon: typeof button.icon === "string" ? button.icon : void 0,
1836
- disabled: _this7.isDisabled(button, scope.row)
1837
- },
1838
- on: {
1839
- click: function click() {
1840
- if (typeof button.handler === "function") {
1841
- button.handler(scope.row, scope.$index);
1842
- }
1843
- _this7.$emit("button-click", scope.row, column, button);
1844
- }
1845
- }
1846
- }, [button.label]);
1847
- });
1848
- },
1849
- renderTag: function renderTag(h, scope, column) {
1850
- var cellValue = this.getCellValue(scope.row, column);
1851
- var tagType = typeof column.tagType === "function" ? column.tagType(scope.row, cellValue) : column.tagType;
1852
- var text = typeof column.formatter === "function" ? column.formatter(scope.row, column, cellValue) : this.resolveEnumText(column, cellValue);
1853
- return h("el-tag", {
1854
- props: {
1855
- type: tagType || "info",
1856
- size: column.tagSize || "small"
1857
- }
1858
- }, [text]);
1859
- },
1860
- renderImage: function renderImage(h, scope, column) {
1861
- var src = this.getCellValue(scope.row, column);
1862
- if (!src) {
1863
- return "-";
1864
- }
1865
- return h("img", {
1866
- style: {
1867
- width: column.imageWidth || "40px",
1868
- height: column.imageHeight || "40px",
1869
- objectFit: "cover",
1870
- borderRadius: "4px"
1871
- },
1872
- attrs: {
1873
- src: src,
1874
- alt: column.label || "image"
1875
- }
1876
- });
1877
- },
1878
- renderLink: function renderLink(h, scope, column) {
1879
- var _this8 = this;
1880
- var renderer = this.getRenderer(column.slot);
1881
- if (renderer) {
1882
- return renderer(scope);
1883
- }
1884
- var cellValue = this.getCellValue(scope.row, column);
1885
- return h("el-button", {
1886
- props: {
1887
- type: "text"
1888
- },
1889
- on: {
1890
- click: function click() {
1891
- return _this8.$emit("link-click", scope.row, column);
1892
- }
1893
- }
1894
- }, [column.linkText || cellValue || "-"]);
1895
- },
1896
- resolveEnumText: function resolveEnumText(column, value) {
1897
- var enumList = column.enum || column.options || [];
1898
- if (!Array.isArray(enumList)) {
1899
- return value;
1900
- }
1901
- var matched = enumList.find(function (item) {
1902
- return item.value === value;
1903
- });
1904
- return matched ? matched.label : value;
1905
- },
1906
- renderDefaultCell: function renderDefaultCell(h, scope, column) {
1907
- var renderer = this.getRenderer(column.slot);
1908
- if (renderer) {
1909
- return renderer(scope);
1910
- }
1911
- if (column.type === "action") {
1912
- return h("div", {
1913
- class: "ns-table-column__actions"
1914
- }, this.renderActionButtons(h, scope, column));
1915
- }
1916
- if (column.type === "tag") {
1917
- return this.renderTag(h, scope, column);
1918
- }
1919
- if (column.type === "image") {
1920
- return this.renderImage(h, scope, column);
1921
- }
1922
- if (column.type === "link") {
1923
- return this.renderLink(h, scope, column);
1924
- }
1925
- var cellValue = this.getCellValue(scope.row, column);
1926
- if (typeof column.formatter === "function") {
1927
- return column.formatter(scope.row, column, cellValue);
1928
- }
1929
- if (column.enum) {
1930
- return this.resolveEnumText(column, cellValue);
1931
- }
1932
- return cellValue === void 0 || cellValue === null || cellValue === "" ? "-" : cellValue;
1933
- },
1934
- renderColumn: function renderColumn(h, column) {
1935
- var _this9 = this;
1936
- var children = Array.isArray(column.children) ? column.children.map(function (child, index2) {
1937
- return h(TableColumn, {
1938
- key: child.prop || child.label || index2,
1939
- props: {
1940
- column: child,
1941
- slotRenderers: _this9.slotRenderers
1942
- },
1943
- on: {
1944
- "link-click": function linkClick() {
1945
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1946
- args[_key2] = arguments[_key2];
1947
- }
1948
- return _this9.$emit.apply(_this9, ["link-click"].concat(args));
1949
- },
1950
- "button-click": function buttonClick() {
1951
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1952
- args[_key3] = arguments[_key3];
1953
- }
1954
- return _this9.$emit.apply(_this9, ["button-click"].concat(args));
1955
- }
1956
- }
1957
- });
1958
- }) : [];
1959
- var headerRenderer = this.getRenderer(column.headerSlot);
1960
- return h("el-table-column", {
1961
- props: this.getColumnProps(column),
1962
- scopedSlots: children.length ? headerRenderer ? {
1963
- header: headerRenderer
1964
- } : void 0 : __spreadValues({
1965
- default: function _default(scope) {
1966
- return _this9.renderDefaultCell(h, scope, column);
1967
- }
1968
- }, headerRenderer ? {
1969
- header: headerRenderer
1970
- } : {})
1971
- }, children);
1972
- }
1973
- },
1974
- render: function render(h) {
1975
- return this.renderColumn(h, this.column);
1976
- }
1977
- };
1978
- var TableColumn$1 = TableColumn;
1979
- var DEFAULT_PAGINATION = {
1980
- total: 0,
1981
- currentPage: 1,
1982
- pageSize: 10
1983
- };
1984
- var DEFAULT_KEY_CONFIG = {
1985
- totalKey: "total",
1986
- currentPageKey: "currentPage",
1987
- pageSizeKey: "pageSize"
1988
- };
1989
- function createPagination() {
1990
- var customParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1991
- return __spreadValues(__spreadValues({}, DEFAULT_PAGINATION), customParams);
1992
- }
1993
- function createPaginationWithCustomKeys(pagination) {
1994
- var keyConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1995
- var config = __spreadValues(__spreadValues({}, DEFAULT_KEY_CONFIG), keyConfig);
1996
- return _defineProperty(_defineProperty(_defineProperty({}, config.totalKey, pagination.total), config.currentPageKey, pagination.currentPage), config.pageSizeKey, pagination.pageSize);
1997
- }
1998
- function resetPagination(pagination) {
1999
- pagination.total = 0;
2000
- pagination.currentPage = 1;
2001
- pagination.pageSize = 10;
2002
- return pagination;
2003
- }
2004
- var PageTable_vue_vue_type_style_index_0_scoped_9ad56349_lang = "";
2005
- var RESERVED_LISTENERS = ["add", "selection-change", "sort-change", "row-click", "size-change", "current-change", "link-click"];
2006
- var _sfc_main$2 = {
2007
- name: "NsTable",
2008
- components: {
2009
- SlotRenderer: SlotRenderer,
2010
- TableColumn: TableColumn$1
2011
- },
2012
- inheritAttrs: false,
2013
- props: {
2014
- tableData: {
2015
- type: Array,
2016
- default: function _default() {
2017
- return [];
2018
- }
2019
- },
2020
- columns: {
2021
- type: Array,
2022
- default: function _default() {
2023
- return [];
2024
- }
2025
- },
2026
- actionButtons: {
2027
- type: Array,
2028
- default: function _default() {
2029
- return [];
2030
- }
2031
- },
2032
- showAddButton: {
2033
- type: Boolean,
2034
- default: true
2035
- },
2036
- addButtonText: {
2037
- type: String,
2038
- default: "新增"
2039
- },
2040
- showHeaderToolbar: {
2041
- type: Boolean,
2042
- default: true
2043
- },
2044
- showSelection: {
2045
- type: Boolean,
2046
- default: false
2047
- },
2048
- showIndex: {
2049
- type: Boolean,
2050
- default: false
2051
- },
2052
- indexWidth: {
2053
- type: [String, Number],
2054
- default: 60
2055
- },
2056
- indexAlign: {
2057
- type: String,
2058
- default: ""
2059
- },
2060
- indexHeaderAlign: {
2061
- type: String,
2062
- default: ""
2063
- },
2064
- border: {
2065
- type: Boolean,
2066
- default: true
2067
- },
2068
- stripe: {
2069
- type: Boolean,
2070
- default: false
2071
- },
2072
- height: {
2073
- type: [String, Number],
2074
- default: void 0
2075
- },
2076
- maxHeight: {
2077
- type: [String, Number],
2078
- default: void 0
2079
- },
2080
- autoHeight: {
2081
- type: Boolean,
2082
- default: true
2083
- },
2084
- rowKey: {
2085
- type: [String, Function],
2086
- default: void 0
2087
- },
2088
- defaultExpandAll: {
2089
- type: Boolean,
2090
- default: false
2091
- },
2092
- highlightCurrentRow: {
2093
- type: Boolean,
2094
- default: false
2095
- },
2096
- loading: {
2097
- type: Boolean,
2098
- default: false
2099
- },
2100
- showPagination: {
2101
- type: Boolean,
2102
- default: true
2103
- },
2104
- total: {
2105
- type: Number,
2106
- default: 0
2107
- },
2108
- currentPage: {
2109
- type: Number,
2110
- default: null
2111
- },
2112
- pageSize: {
2113
- type: Number,
2114
- default: null
2115
- },
2116
- pageSizes: {
2117
- type: Array,
2118
- default: function _default() {
2119
- return [10, 20, 50, 100];
2120
- }
2121
- },
2122
- paginationLayout: {
2123
- type: String,
2124
- default: "total, sizes, prev, pager, next, jumper"
2125
- },
2126
- pageNumberKey: {
2127
- type: String,
2128
- default: "currentPage"
2129
- },
2130
- pageSizeKey: {
2131
- type: String,
2132
- default: "pageSize"
2133
- },
2134
- pageTotalKey: {
2135
- type: String,
2136
- default: "total"
2137
- },
2138
- slotRenderers: {
2139
- type: Object,
2140
- default: function _default() {
2141
- return {};
2142
- }
2143
- }
2144
- },
2145
- data: function data() {
2146
- return {
2147
- internalPagination: createPagination()
2148
- };
2149
- },
2150
- computed: {
2151
- currentPageModel: function currentPageModel() {
2152
- return this.currentPage === null ? this.internalPagination.currentPage : this.currentPage;
2153
- },
2154
- pageSizeModel: function pageSizeModel() {
2155
- return this.pageSize === null ? this.internalPagination.pageSize : this.pageSize;
2156
- },
2157
- mergedAttrs: function mergedAttrs() {
2158
- return this.$attrs || {};
2159
- },
2160
- mergedListeners: function mergedListeners() {
2161
- var listeners = __spreadValues({}, this.$listeners || {});
2162
- RESERVED_LISTENERS.forEach(function (name) {
2163
- return delete listeners[name];
2164
- });
2165
- return listeners;
2166
- },
2167
- resolvedHeight: function resolvedHeight() {
2168
- if (this.height !== void 0) {
2169
- return this.height;
2170
- }
2171
- if (this.autoHeight && this.maxHeight === void 0) {
2172
- return "100%";
2173
- }
2174
- return void 0;
2175
- },
2176
- resolvedMaxHeight: function resolvedMaxHeight() {
2177
- if (this.maxHeight !== void 0) {
2178
- return this.maxHeight;
2179
- }
2180
- return void 0;
2181
- }
2182
- },
2183
- watch: {
2184
- currentPage: {
2185
- handler: function handler(value) {
2186
- if (value !== null) {
2187
- this.internalPagination.currentPage = value;
2188
- }
2189
- },
2190
- immediate: true
2191
- },
2192
- pageSize: {
2193
- handler: function handler(value) {
2194
- if (value !== null) {
2195
- this.internalPagination.pageSize = value;
2196
- }
2197
- },
2198
- immediate: true
2199
- }
2200
- },
2201
- methods: {
2202
- handleAdd: function handleAdd() {
2203
- this.$emit("add");
2204
- },
2205
- handleSelectionChange: function handleSelectionChange(selection) {
2206
- this.$emit("selection-change", selection);
2207
- },
2208
- handleSortChange: function handleSortChange(sort) {
2209
- this.$emit("sort-change", sort);
2210
- },
2211
- handleRowClick: function handleRowClick(row, column, event) {
2212
- this.$emit("row-click", row, column, event);
2213
- },
2214
- handleSizeChange: function handleSizeChange(size) {
2215
- this.internalPagination.pageSize = size;
2216
- this.$emit("update:pageSize", size);
2217
- this.$emit("size-change", size);
2218
- },
2219
- handleCurrentChange: function handleCurrentChange(page) {
2220
- this.internalPagination.currentPage = page;
2221
- this.$emit("update:currentPage", page);
2222
- this.$emit("current-change", page);
2223
- },
2224
- handleLinkClick: function handleLinkClick(row, column) {
2225
- this.$emit("link-click", row, column);
2226
- },
2227
- getIndex: function getIndex(index2) {
2228
- if (!this.showPagination) {
2229
- return index2 + 1;
2230
- }
2231
- var currentPage = Number(this.currentPageModel || 1);
2232
- var pageSize = Number(this.pageSizeModel || 10);
2233
- return (currentPage - 1) * pageSize + index2 + 1;
2234
- },
2235
- getSelectionRows: function getSelectionRows() {
2236
- return this.$refs.tableRef && this.$refs.tableRef.selection ? this.$refs.tableRef.selection : [];
2237
- },
2238
- getSelectionKeys: function getSelectionKeys() {
2239
- var _this0 = this;
2240
- var rows = this.getSelectionRows();
2241
- if (!this.rowKey) {
2242
- return rows;
2243
- }
2244
- return rows.map(function (row) {
2245
- return typeof _this0.rowKey === "function" ? _this0.rowKey(row) : row[_this0.rowKey];
2246
- });
2247
- },
2248
- setSelectionRows: function setSelectionRows(rows) {
2249
- var _this1 = this;
2250
- if (!this.$refs.tableRef) return;
2251
- this.$refs.tableRef.clearSelection();
2252
- (rows || []).forEach(function (row) {
2253
- _this1.$refs.tableRef.toggleRowSelection(row, true);
2254
- });
2255
- },
2256
- setSelectionKeys: function setSelectionKeys(keys) {
2257
- var _this10 = this;
2258
- if (!this.$refs.tableRef || !this.rowKey) return;
2259
- this.$refs.tableRef.clearSelection();
2260
- (keys || []).forEach(function (key) {
2261
- var row = (_this10.tableData || []).find(function (item) {
2262
- return (typeof _this10.rowKey === "function" ? _this10.rowKey(item) : item[_this10.rowKey]) === key;
2263
- });
2264
- if (row) {
2265
- _this10.$refs.tableRef.toggleRowSelection(row, true);
2266
- }
2267
- });
2268
- },
2269
- isRowSelected: function isRowSelected(row) {
2270
- return this.getSelectionRows().includes(row);
2271
- },
2272
- isKeySelected: function isKeySelected(key) {
2273
- return this.getSelectionKeys().includes(key);
2274
- },
2275
- clearSelection: function clearSelection() {
2276
- if (this.$refs.tableRef) {
2277
- this.$refs.tableRef.clearSelection();
2278
- }
2279
- },
2280
- toggleRowSelection: function toggleRowSelection(row, selected) {
2281
- if (this.$refs.tableRef) {
2282
- this.$refs.tableRef.toggleRowSelection(row, selected);
2283
- }
2284
- },
2285
- toggleAllSelection: function toggleAllSelection() {
2286
- if (this.$refs.tableRef) {
2287
- this.$refs.tableRef.toggleAllSelection();
2288
- }
2289
- },
2290
- selectAll: function selectAll() {
2291
- this.toggleAllSelection();
2292
- },
2293
- clearAllSelection: function clearAllSelection() {
2294
- this.clearSelection();
2295
- },
2296
- clearSort: function clearSort() {
2297
- this.$refs.tableRef && this.$refs.tableRef.clearSort && this.$refs.tableRef.clearSort();
2298
- },
2299
- clearFilter: function clearFilter(columnKey) {
2300
- this.$refs.tableRef && this.$refs.tableRef.clearFilter && this.$refs.tableRef.clearFilter(columnKey);
2301
- },
2302
- doLayout: function doLayout() {
2303
- this.$refs.tableRef && this.$refs.tableRef.doLayout && this.$refs.tableRef.doLayout();
2304
- },
2305
- sort: function sort(prop, order) {
2306
- this.$refs.tableRef && this.$refs.tableRef.sort && this.$refs.tableRef.sort(prop, order);
2307
- },
2308
- resetPage: function resetPage() {
2309
- this.internalPagination.currentPage = 1;
2310
- this.$emit("update:currentPage", 1);
2311
- },
2312
- setPage: function setPage(page) {
2313
- this.internalPagination.currentPage = page;
2314
- this.$emit("update:currentPage", page);
2315
- },
2316
- setPageSize: function setPageSize(size) {
2317
- this.internalPagination.pageSize = size;
2318
- this.$emit("update:pageSize", size);
2319
- },
2320
- getPagination: function getPagination() {
2321
- return _defineProperty(_defineProperty(_defineProperty({}, this.pageTotalKey, this.total), this.pageNumberKey, this.currentPageModel), this.pageSizeKey, this.pageSizeModel);
2322
- },
2323
- setPagination: function setPagination(pagination) {
2324
- if (pagination.currentPage !== void 0) {
2325
- this.setPage(pagination.currentPage);
2326
- }
2327
- if (pagination.pageSize !== void 0) {
2328
- this.setPageSize(pagination.pageSize);
2329
- }
2330
- }
2331
- }
2332
- };
2333
- var _sfc_render$2 = function render4() {
2334
- var _vm = this,
2335
- _c = _vm._self._c;
2336
- return _c("div", {
2337
- staticClass: "page-table"
2338
- }, [_vm.showHeaderToolbar ? _c("div", {
2339
- staticClass: "page-table__header"
2340
- }, [_c("slot-renderer", {
2341
- attrs: {
2342
- "renderer": _vm.slotRenderers["header-left"],
2343
- "scope": {
2344
- tableData: _vm.tableData
2345
- }
2346
- }
2347
- }), _c("div", {
2348
- staticClass: "page-table__actions"
2349
- }, [_c("slot-renderer", {
2350
- attrs: {
2351
- "renderer": _vm.slotRenderers["header-actions"],
2352
- "scope": {
2353
- tableData: _vm.tableData
2354
- }
2355
- }
2356
- }), _vm.showAddButton && !_vm.slotRenderers["header-actions"] ? _c("el-button", {
2357
- attrs: {
2358
- "type": "primary",
2359
- "size": "small"
2360
- },
2361
- on: {
2362
- "click": _vm.handleAdd
2363
- }
2364
- }, [_vm._v(" " + _vm._s(_vm.addButtonText) + " ")]) : _vm._e()], 1)], 1) : _vm._e(), _c("div", {
2365
- staticClass: "page-table__main"
2366
- }, [_c("el-table", _vm._g(_vm._b({
2367
- directives: [{
2368
- name: "loading",
2369
- rawName: "v-loading",
2370
- value: _vm.loading,
2371
- expression: "loading"
2372
- }],
2373
- ref: "tableRef",
2374
- class: ["page-table__table", {
2375
- "page-table__table--no-border": !_vm.border
2376
- }],
2377
- attrs: {
2378
- "data": _vm.tableData,
2379
- "border": _vm.border,
2380
- "stripe": _vm.stripe,
2381
- "height": _vm.resolvedHeight,
2382
- "max-height": _vm.resolvedMaxHeight,
2383
- "row-key": _vm.rowKey,
2384
- "default-expand-all": _vm.defaultExpandAll,
2385
- "highlight-current-row": _vm.highlightCurrentRow
2386
- },
2387
- on: {
2388
- "selection-change": _vm.handleSelectionChange,
2389
- "sort-change": _vm.handleSortChange,
2390
- "row-click": _vm.handleRowClick
2391
- }
2392
- }, "el-table", _vm.mergedAttrs, false), _vm.mergedListeners), [_vm.showSelection ? _c("el-table-column", {
2393
- attrs: {
2394
- "type": "selection",
2395
- "width": "55",
2396
- "reserve-selection": !!_vm.rowKey
2397
- }
2398
- }) : _vm._e(), _vm.showIndex ? _c("el-table-column", {
2399
- attrs: {
2400
- "type": "index",
2401
- "label": "序号",
2402
- "width": _vm.indexWidth,
2403
- "index": _vm.getIndex,
2404
- "align": _vm.indexAlign,
2405
- "header-align": _vm.indexHeaderAlign || _vm.indexAlign
2406
- }
2407
- }) : _vm._e(), _vm._l(_vm.columns, function (column, index2) {
2408
- return _c("table-column", {
2409
- key: column.prop || column.label || index2,
2410
- attrs: {
2411
- "column": column,
2412
- "slot-renderers": _vm.slotRenderers
2413
- },
2414
- on: {
2415
- "link-click": _vm.handleLinkClick
2416
- }
2417
- });
2418
- }), _c("template", {
2419
- slot: "empty"
2420
- }, [_vm.slotRenderers.empty ? _c("slot-renderer", {
2421
- attrs: {
2422
- "renderer": _vm.slotRenderers.empty,
2423
- "scope": {
2424
- tableData: _vm.tableData
2425
- }
2426
- }
2427
- }) : _c("div", {
2428
- staticClass: "page-table__empty"
2429
- }, [_vm._v("暂无数据")])], 1)], 2)], 1), _vm.showPagination ? _c("div", {
2430
- staticClass: "page-table__pagination"
2431
- }, [_c("el-pagination", {
2432
- attrs: {
2433
- "background": "",
2434
- "current-page": _vm.currentPageModel,
2435
- "page-size": _vm.pageSizeModel,
2436
- "page-sizes": _vm.pageSizes,
2437
- "total": _vm.total,
2438
- "layout": _vm.paginationLayout
2439
- },
2440
- on: {
2441
- "size-change": _vm.handleSizeChange,
2442
- "current-change": _vm.handleCurrentChange
2443
- }
2444
- })], 1) : _vm._e()]);
2445
- };
2446
- var _sfc_staticRenderFns$2 = [];
2447
- var __component__$2 = /* @__PURE__ */normalizeComponent(_sfc_main$2, _sfc_render$2, _sfc_staticRenderFns$2, false, null, "9ad56349", null, null);
2448
- var NsTable = __component__$2.exports;
2449
- var PageContainer_vue_vue_type_style_index_0_scoped_1c664e81_lang = "";
2450
- var _sfc_main$1 = {
2451
- name: "NsTableContainer",
2452
- components: {
2453
- PageSearch: NsSearch,
2454
- PageTable: NsTable
2455
- },
2456
- props: {
2457
- showSearch: {
2458
- type: Boolean,
2459
- default: true
2460
- },
2461
- externalSearchParams: {
2462
- type: Object,
2463
- default: function _default() {
2464
- return {};
2465
- }
2466
- },
2467
- searchItems: {
2468
- type: Array,
2469
- default: function _default() {
2470
- return [];
2471
- }
2472
- },
2473
- tableData: {
2474
- type: Array,
2475
- default: function _default() {
2476
- return [];
2477
- }
2478
- },
2479
- columns: {
2480
- type: Array,
2481
- default: function _default() {
2482
- return [];
2483
- }
2484
- },
2485
- actionButtons: {
2486
- type: Array,
2487
- default: function _default() {
2488
- return [];
2489
- }
2490
- },
2491
- total: {
2492
- type: Number,
2493
- default: 0
2494
- },
2495
- currentPage: {
2496
- type: Number,
2497
- default: null
2498
- },
2499
- pageSize: {
2500
- type: Number,
2501
- default: null
2502
- },
2503
- pageNumberKey: {
2504
- type: String,
2505
- default: "currentPage"
2506
- },
2507
- pageSizeKey: {
2508
- type: String,
2509
- default: "pageSize"
2510
- },
2511
- pageTotalKey: {
2512
- type: String,
2513
- default: "total"
2514
- },
2515
- searchProps: {
2516
- type: Object,
2517
- default: function _default() {
2518
- return {};
2519
- }
2520
- },
2521
- enterTrigger: {
2522
- type: Boolean,
2523
- default: true
2524
- },
2525
- tableProps: {
2526
- type: Object,
2527
- default: function _default() {
2528
- return {};
2529
- }
2530
- },
2531
- loadData: {
2532
- type: Function,
2533
- default: null
2534
- }
2535
- },
2536
- data: function data() {
2537
- return {
2538
- internalPagination: createPagination(),
2539
- pendingSelectionKeys: /* @__PURE__ */new Set(),
2540
- selectionRowMap: {},
2541
- isSyncingSelection: false
2542
- };
2543
- },
2544
- computed: {
2545
- currentPageModel: function currentPageModel() {
2546
- return this.currentPage === null ? this.internalPagination.currentPage : this.currentPage;
2547
- },
2548
- pageSizeModel: function pageSizeModel() {
2549
- return this.pageSize === null ? this.internalPagination.pageSize : this.pageSize;
2550
- },
2551
- currentRowKey: function currentRowKey() {
2552
- return this.tableProps && this.tableProps.rowKey;
2553
- }
2554
- },
2555
- watch: {
2556
- currentPage: {
2557
- handler: function handler(value) {
2558
- if (value !== null) {
2559
- this.internalPagination.currentPage = value;
2560
- }
2561
- },
2562
- immediate: true
2563
- },
2564
- pageSize: {
2565
- handler: function handler(value) {
2566
- if (value !== null) {
2567
- this.internalPagination.pageSize = value;
2568
- }
2569
- },
2570
- immediate: true
2571
- },
2572
- tableData: {
2573
- handler: function handler() {
2574
- var _this11 = this;
2575
- this.$nextTick(function () {
2576
- _this11.syncSelectionToCurrentPage();
2577
- });
2578
- },
2579
- deep: true,
2580
- immediate: true
2581
- }
2582
- },
2583
- methods: {
2584
- getRowKey: function getRowKey(row) {
2585
- if (!this.currentRowKey) return row;
2586
- return typeof this.currentRowKey === "function" ? this.currentRowKey(row) : row[this.currentRowKey];
2587
- },
2588
- resetSelectionState: function resetSelectionState() {
2589
- this.pendingSelectionKeys = /* @__PURE__ */new Set();
2590
- this.selectionRowMap = {};
2591
- this.$refs.tableRef && this.$refs.tableRef.clearSelection && this.$refs.tableRef.clearSelection();
2592
- },
2593
- syncSelectionToCurrentPage: function syncSelectionToCurrentPage() {
2594
- var _this12 = this;
2595
- if (!this.currentRowKey || !this.$refs.tableRef) {
2596
- return;
2597
- }
2598
- this.isSyncingSelection = true;
2599
- this.$refs.tableRef.clearSelection();
2600
- (this.tableData || []).forEach(function (row) {
2601
- var key = _this12.getRowKey(row);
2602
- if (_this12.pendingSelectionKeys.has(key)) {
2603
- _this12.$set(_this12.selectionRowMap, key, row);
2604
- _this12.$refs.tableRef.toggleRowSelection(row, true);
2605
- }
2606
- });
2607
- this.$nextTick(function () {
2608
- _this12.isSyncingSelection = false;
2609
- });
2610
- },
2611
- handleSearch: function handleSearch(params) {
2612
- this.resetSelectionState();
2613
- if (params && params._resetPage) {
2614
- var _a = params,
2615
- _resetPage = _a._resetPage,
2616
- searchParams = __objRest(_a, ["_resetPage"]);
2617
- this.internalPagination.currentPage = 1;
2618
- this.$emit("update:currentPage", 1);
2619
- this.$emit("search", searchParams);
2620
- return;
2621
- }
2622
- this.$emit("search", params);
2623
- },
2624
- handleReset: function handleReset() {
2625
- this.resetSelectionState();
2626
- this.$emit("reset");
2627
- },
2628
- handleAdd: function handleAdd() {
2629
- this.$emit("add");
2630
- },
2631
- handleSizeChange: function handleSizeChange(size) {
2632
- this.internalPagination.pageSize = size;
2633
- this.$emit("update:pageSize", size);
2634
- this.$emit("size-change", size);
2635
- this.$emit("page-change", {
2636
- currentPage: this.currentPageModel,
2637
- pageSize: size
2638
- });
2639
- if (this.loadData) {
2640
- this.loadData();
2641
- }
2642
- },
2643
- handleCurrentChange: function handleCurrentChange(page) {
2644
- this.internalPagination.currentPage = page;
2645
- this.$emit("update:currentPage", page);
2646
- this.$emit("current-change", page);
2647
- this.$emit("page-change", {
2648
- currentPage: page,
2649
- pageSize: this.pageSizeModel
2650
- });
2651
- if (this.loadData) {
2652
- this.loadData();
2653
- }
2654
- },
2655
- handleSelectionChange: function handleSelectionChange(selection) {
2656
- var _this13 = this;
2657
- if (this.isSyncingSelection) {
2658
- return;
2659
- }
2660
- if (!this.currentRowKey) {
2661
- this.$emit("selection-change", selection);
2662
- return;
2663
- }
2664
- var currentPageKeys = (this.tableData || []).map(function (row) {
2665
- return _this13.getRowKey(row);
2666
- });
2667
- currentPageKeys.forEach(function (key) {
2668
- _this13.pendingSelectionKeys.delete(key);
2669
- _this13.$delete(_this13.selectionRowMap, key);
2670
- });
2671
- (selection || []).forEach(function (row) {
2672
- var key = _this13.getRowKey(row);
2673
- _this13.pendingSelectionKeys.add(key);
2674
- _this13.$set(_this13.selectionRowMap, key, row);
2675
- });
2676
- this.$emit("selection-change", Object.values(this.selectionRowMap));
2677
- },
2678
- handleSortChange: function handleSortChange(sort) {
2679
- this.$emit("sort-change", sort);
2680
- },
2681
- handleRowClick: function handleRowClick(row, column, event) {
2682
- this.$emit("row-click", row, column, event);
2683
- },
2684
- handleLinkClick: function handleLinkClick(row, column) {
2685
- this.$emit("link-click", row, column);
2686
- },
2687
- initSearchAndLoad: function initSearchAndLoad() {
2688
- var _this14 = this;
2689
- this.$nextTick(function () {
2690
- if (_this14.showSearch && _this14.$refs.searchRef) {
2691
- _this14.$emit("search", _this14.$refs.searchRef.getFormData());
2692
- return;
2693
- }
2694
- if (_this14.loadData) {
2695
- _this14.loadData();
2696
- }
2697
- });
2698
- },
2699
- getSearchFormData: function getSearchFormData() {
2700
- return this.$refs.searchRef ? this.$refs.searchRef.getFormData() : {};
2701
- },
2702
- setSearchFormData: function setSearchFormData(data) {
2703
- this.$refs.searchRef && this.$refs.searchRef.setFormData(data);
2704
- },
2705
- resetSearchForm: function resetSearchForm() {
2706
- this.$refs.searchRef && this.$refs.searchRef.resetForm();
2707
- },
2708
- validateSearchForm: function validateSearchForm() {
2709
- return this.$refs.searchRef ? this.$refs.searchRef.validate() : Promise.resolve(true);
2710
- },
2711
- getPagination: function getPagination() {
2712
- return _defineProperty(_defineProperty(_defineProperty({}, this.pageTotalKey, this.total), this.pageNumberKey, this.currentPageModel), this.pageSizeKey, this.pageSizeModel);
2713
- },
2714
- getSelectionRows: function getSelectionRows() {
2715
- var _a, _b;
2716
- return this.currentRowKey ? Object.values(this.selectionRowMap) : ((_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.getSelectionRows) == null ? void 0 : _b.call(_a)) || [];
2717
- },
2718
- getSelectionKeys: function getSelectionKeys() {
2719
- var _a, _b;
2720
- return this.currentRowKey ? Array.from(this.pendingSelectionKeys) : ((_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.getSelectionKeys) == null ? void 0 : _b.call(_a)) || [];
2721
- },
2722
- setSelectionRows: function setSelectionRows(rows) {
2723
- var _this15 = this;
2724
- if (!this.currentRowKey) {
2725
- this.$refs.tableRef && this.$refs.tableRef.setSelectionRows(rows);
2726
- return;
2727
- }
2728
- this.pendingSelectionKeys = /* @__PURE__ */new Set();
2729
- this.selectionRowMap = {};
2730
- (rows || []).forEach(function (row) {
2731
- var key = _this15.getRowKey(row);
2732
- _this15.pendingSelectionKeys.add(key);
2733
- _this15.$set(_this15.selectionRowMap, key, row);
2734
- });
2735
- this.syncSelectionToCurrentPage();
2736
- },
2737
- setSelectionKeys: function setSelectionKeys(keys) {
2738
- var _this16 = this;
2739
- if (!this.currentRowKey) {
2740
- this.$refs.tableRef && this.$refs.tableRef.setSelectionKeys(keys);
2741
- return;
2742
- }
2743
- this.pendingSelectionKeys = new Set(keys || []);
2744
- (this.tableData || []).forEach(function (row) {
2745
- var key = _this16.getRowKey(row);
2746
- if (_this16.pendingSelectionKeys.has(key)) {
2747
- _this16.$set(_this16.selectionRowMap, key, row);
2748
- }
2749
- });
2750
- this.syncSelectionToCurrentPage();
2751
- },
2752
- clearAllSelection: function clearAllSelection() {
2753
- this.resetSelectionState();
2754
- },
2755
- selectAll: function selectAll() {
2756
- var _this17 = this;
2757
- if (!this.$refs.tableRef) return;
2758
- if (!this.currentRowKey) {
2759
- this.$refs.tableRef.selectAll();
2760
- return;
2761
- }
2762
- (this.tableData || []).forEach(function (row) {
2763
- var key = _this17.getRowKey(row);
2764
- _this17.pendingSelectionKeys.add(key);
2765
- _this17.$set(_this17.selectionRowMap, key, row);
2766
- });
2767
- this.$refs.tableRef.setSelectionRows(this.tableData);
2768
- },
2769
- isRowSelected: function isRowSelected(row) {
2770
- var _a, _b;
2771
- return this.currentRowKey ? this.pendingSelectionKeys.has(this.getRowKey(row)) : (_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.isRowSelected) == null ? void 0 : _b.call(_a, row);
2772
- },
2773
- isKeySelected: function isKeySelected(key) {
2774
- var _a, _b;
2775
- return this.currentRowKey ? this.pendingSelectionKeys.has(key) : (_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.isKeySelected) == null ? void 0 : _b.call(_a, key);
2776
- }
2777
- }
2778
- };
2779
- var _sfc_render$1 = function render5() {
2780
- var _vm = this,
2781
- _c = _vm._self._c;
2782
- return _c("div", {
2783
- staticClass: "page-container"
2784
- }, [_vm.showSearch ? _c("page-search", _vm._b({
2785
- ref: "searchRef",
2786
- attrs: {
2787
- "items": _vm.searchItems,
2788
- "external-params": _vm.externalSearchParams,
2789
- "enter-trigger": _vm.enterTrigger,
2790
- "slot-renderers": _vm.$scopedSlots
2791
- },
2792
- on: {
2793
- "search": _vm.handleSearch,
2794
- "reset": _vm.handleReset
2795
- }
2796
- }, "page-search", _vm.searchProps, false)) : _vm._e(), _vm._t("extend"), _c("page-table", _vm._b({
2797
- ref: "tableRef",
2798
- attrs: {
2799
- "table-data": _vm.tableData,
2800
- "columns": _vm.columns,
2801
- "action-buttons": _vm.actionButtons,
2802
- "total": _vm.total,
2803
- "current-page": _vm.currentPageModel,
2804
- "page-size": _vm.pageSizeModel,
2805
- "page-number-key": _vm.pageNumberKey,
2806
- "page-size-key": _vm.pageSizeKey,
2807
- "page-total-key": _vm.pageTotalKey,
2808
- "slot-renderers": _vm.$scopedSlots
2809
- },
2810
- on: {
2811
- "add": _vm.handleAdd,
2812
- "selection-change": _vm.handleSelectionChange,
2813
- "sort-change": _vm.handleSortChange,
2814
- "row-click": _vm.handleRowClick,
2815
- "size-change": _vm.handleSizeChange,
2816
- "current-change": _vm.handleCurrentChange,
2817
- "link-click": _vm.handleLinkClick
2818
- }
2819
- }, "page-table", _vm.tableProps, false))], 2);
2820
- };
2821
- var _sfc_staticRenderFns$1 = [];
2822
- var __component__$1 = /* @__PURE__ */normalizeComponent(_sfc_main$1, _sfc_render$1, _sfc_staticRenderFns$1, false, null, "1c664e81", null, null);
2823
- var NsTableContainer = __component__$1.exports;
2824
- [NsTableContainer, NsSearch, NsTable].forEach(function (component) {
2825
- component.install = function install3(Vue2) {
2826
- Vue2.component(component.name, component);
2827
- };
2828
- });
2829
- var NsDialog_vue_vue_type_style_index_0_scoped_19b1fbf8_lang = "";
2830
- var _sfc_main = {
2831
- name: "NsDialogComponent",
2832
- props: {
2833
- className: {
2834
- type: String,
2835
- default: ""
2836
- },
2837
- title: {
2838
- type: String,
2839
- default: ""
2840
- },
2841
- width: {
2842
- type: [Number, String],
2843
- default: 500
2844
- },
2845
- height: {
2846
- type: [Number, String],
2847
- default: ""
2848
- },
2849
- modal: {
2850
- type: Boolean,
2851
- default: true
2852
- },
2853
- dialogPadding: {
2854
- type: [Number, String, Array],
2855
- default: -1
2856
- },
2857
- modalColor: {
2858
- type: String,
2859
- default: "rgba(0, 0, 0, 0.45)"
2860
- },
2861
- closeOnClickModal: {
2862
- type: Boolean,
2863
- default: true
2864
- },
2865
- dom: {
2866
- type: [Object, Function],
2867
- default: null
2868
- },
2869
- option: {
2870
- type: Object,
2871
- default: function _default() {
2872
- return {};
2873
- }
2874
- },
2875
- events: {
2876
- type: Object,
2877
- default: function _default() {
2878
- return {};
2879
- }
2880
- },
2881
- domCompleted: {
2882
- type: Function,
2883
- default: null
2884
- },
2885
- headerDom: {
2886
- type: [Object, Function],
2887
- default: null
2888
- },
2889
- headerOption: {
2890
- type: Object,
2891
- default: function _default() {
2892
- return {};
2893
- }
2894
- },
2895
- headerEvents: {
2896
- type: Object,
2897
- default: function _default() {
2898
- return {};
2899
- }
2900
- },
2901
- showFooter: {
2902
- type: Boolean,
2903
- default: true
2904
- },
2905
- footerDom: {
2906
- type: [Object, Function],
2907
- default: null
2908
- },
2909
- footerOption: {
2910
- type: Object,
2911
- default: function _default() {
2912
- return {};
2913
- }
2914
- },
2915
- footerTitle: {
2916
- type: Object,
2917
- default: function _default() {
2918
- return {
2919
- close: "取消",
2920
- confirm: "确定"
2921
- };
2922
- }
2923
- },
2924
- footerEvents: {
2925
- type: Object,
2926
- default: function _default() {
2927
- return {};
2928
- }
2929
- },
2930
- footerButtonReverse: {
2931
- type: Boolean,
2932
- default: false
2933
- },
2934
- footerCloseOnly: {
2935
- type: Boolean,
2936
- default: false
2937
- },
2938
- enterTrigger: {
2939
- type: Boolean,
2940
- default: false
2941
- },
2942
- immediately: {
2943
- type: Boolean,
2944
- default: false
2945
- },
2946
- close: {
2947
- type: Function,
2948
- default: null
2949
- },
2950
- closed: {
2951
- type: Function,
2952
- default: null
2953
- },
2954
- sizeChange: {
2955
- type: Function,
2956
- default: null
2957
- },
2958
- draggable: {
2959
- type: Boolean,
2960
- default: false
2961
- },
2962
- confirm: {
2963
- type: Function,
2964
- default: null
2965
- },
2966
- x: {
2967
- type: [Number, String],
2968
- default: null
2969
- },
2970
- y: {
2971
- type: [Number, String],
2972
- default: null
2973
- },
2974
- maxSize: {
2975
- type: Function,
2976
- default: null
2977
- },
2978
- dialogInstance: {
2979
- type: Object,
2980
- default: null
2981
- },
2982
- containerId: {
2983
- type: String,
2984
- default: ""
2985
- }
2986
- },
2987
- data: function data() {
2988
- return {
2989
- visible: false,
2990
- currentTitle: this.title,
2991
- currentOption: __spreadValues({}, this.option),
2992
- currentWidth: this.width,
2993
- currentHeight: this.height,
2994
- currentX: this.x,
2995
- currentY: this.y,
2996
- footerLoading: false,
2997
- isMaximized: false,
2998
- originalSize: {
2999
- width: this.width,
3000
- height: this.height,
3001
- x: this.x,
3002
- y: this.y
3003
- },
3004
- dragContext: null,
3005
- domCompletedCalled: false
3006
- };
3007
- },
3008
- computed: {
3009
- normalizedWidth: function normalizedWidth() {
3010
- return this.normalizeSize(this.currentWidth || this.width || 500);
3011
- },
3012
- bodyStyle: function bodyStyle() {
3013
- var padding = this.resolvePadding();
3014
- if (!this.currentHeight) {
3015
- return {
3016
- padding: padding,
3017
- minHeight: "auto",
3018
- maxHeight: "none",
3019
- overflow: "auto"
3020
- };
3021
- }
3022
- return {
3023
- padding: padding,
3024
- height: "100%",
3025
- minHeight: 0,
3026
- overflow: "auto",
3027
- flex: "1 1 auto"
3028
- };
3029
- },
3030
- dialogCustomClass: function dialogCustomClass() {
3031
- return ["ns-dialog-plus", this.className, this.hasAbsolutePosition ? "ns-dialog-plus--absolute" : ""].filter(Boolean).join(" ");
3032
- },
3033
- modalClassName: function modalClassName() {
3034
- return "ns-dialog-plus-modal ns-dialog-plus-modal--".concat(this.containerId);
3035
- },
3036
- resolvedDom: function resolvedDom() {
3037
- return this.resolveComponent(this.dom);
3038
- },
3039
- resolvedHeaderDom: function resolvedHeaderDom() {
3040
- return this.resolveComponent(this.headerDom);
3041
- },
3042
- resolvedFooterDom: function resolvedFooterDom() {
3043
- return this.resolveComponent(this.footerDom);
3044
- },
3045
- footerButtonText: function footerButtonText() {
3046
- var _a, _b;
3047
- return {
3048
- close: ((_a = this.footerTitle) == null ? void 0 : _a.close) || "取消",
3049
- confirm: ((_b = this.footerTitle) == null ? void 0 : _b.confirm) || "确定"
3050
- };
3051
- },
3052
- showMaximizeButton: function showMaximizeButton() {
3053
- return typeof this.maxSize === "function";
3054
- },
3055
- hasAbsolutePosition: function hasAbsolutePosition() {
3056
- return this.currentX !== null || this.currentY !== null;
3057
- }
3058
- },
3059
- watch: {
3060
- option: {
3061
- handler: function handler(value) {
3062
- this.currentOption = __spreadValues({}, value);
3063
- },
3064
- deep: true
3065
- },
3066
- title: function title(value) {
3067
- this.currentTitle = value;
3068
- },
3069
- width: function width(value) {
3070
- if (!this.isMaximized) this.currentWidth = value;
3071
- },
3072
- height: function height(value) {
3073
- if (!this.isMaximized) this.currentHeight = value;
3074
- },
3075
- x: function x(value) {
3076
- if (!this.isMaximized) this.currentX = value;
3077
- },
3078
- y: function y(value) {
3079
- if (!this.isMaximized) this.currentY = value;
3080
- },
3081
- visible: function visible() {
3082
- var _this18 = this;
3083
- this.$nextTick(function () {
3084
- _this18.applyDialogLayout();
3085
- _this18.syncDialogInstance();
3086
- _this18.triggerDomCompleted();
3087
- });
3088
- }
3089
- },
3090
- mounted: function mounted() {
3091
- var _this19 = this;
3092
- loadCssVars$1();
3093
- this.visible = true;
3094
- this.updateModalStyle();
3095
- this.syncDialogInstance();
3096
- this.$nextTick(function () {
3097
- _this19.applyDialogLayout();
3098
- _this19.triggerDomCompleted();
3099
- });
3100
- document.addEventListener("keydown", this.handleKeydown);
3101
- window.addEventListener("resize", this.applyDialogLayout);
3102
- },
3103
- updated: function updated() {
3104
- var _this20 = this;
3105
- this.syncDialogInstance();
3106
- this.triggerDomCompleted();
3107
- this.$nextTick(function () {
3108
- _this20.applyDialogLayout();
3109
- });
3110
- },
3111
- beforeDestroy: function beforeDestroy() {
3112
- document.removeEventListener("keydown", this.handleKeydown);
3113
- window.removeEventListener("resize", this.applyDialogLayout);
3114
- this.removeDragListeners();
3115
- this.removeModalStyle();
3116
- },
3117
- methods: {
3118
- notifySizeChange: function notifySizeChange() {
3119
- var payload = {
3120
- width: this.currentWidth,
3121
- height: this.currentHeight,
3122
- x: this.currentX,
3123
- y: this.currentY,
3124
- isMaximized: this.isMaximized
3125
- };
3126
- if (typeof this.sizeChange === "function") {
3127
- this.sizeChange(payload);
3128
- }
3129
- this.$emit("sizeChange", payload);
3130
- var content = this.$refs.contentRef;
3131
- if (content && typeof content.doLayout === "function") {
3132
- this.$nextTick(function () {
3133
- return content.doLayout();
3134
- });
3135
- }
3136
- },
3137
- normalizeSize: function normalizeSize(value) {
3138
- if (value === null || value === void 0 || value === "") return "";
3139
- if (typeof value === "number" && isFinite(value)) return "".concat(value, "px");
3140
- var str = String(value).trim();
3141
- if (str === "") return "";
3142
- return Number.isNaN(Number(str)) ? str : "".concat(Number(str), "px");
3143
- },
3144
- resolvePadding: function resolvePadding() {
3145
- var _this21 = this;
3146
- if (Array.isArray(this.dialogPadding)) {
3147
- return this.dialogPadding.map(function (item) {
3148
- return _this21.normalizeSize(item);
3149
- }).join(" ");
3150
- }
3151
- if (this.dialogPadding === -1 || this.dialogPadding === "-1") {
3152
- return "16px 20px";
3153
- }
3154
- return this.normalizeSize(this.dialogPadding);
3155
- },
3156
- resolveComponent: function resolveComponent(source) {
3157
- if (!source) return null;
3158
- if (source.default) {
3159
- return source.default;
3160
- }
3161
- if (typeof source.then === "function") {
3162
- return function () {
3163
- return source;
3164
- };
3165
- }
3166
- return source;
3167
- },
3168
- mergeEvents: function mergeEvents() {
3169
- var _this22 = this;
3170
- var listeners = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3171
- return __spreadProps(__spreadValues({}, listeners), {
3172
- close: function close() {
3173
- return _this22.closeDialog();
3174
- }
3175
- });
3176
- },
3177
- resolveDialogElement: function resolveDialogElement() {
3178
- return this.$el && this.$el.querySelector ? this.$el.querySelector(".el-dialog") : null;
3179
- },
3180
- resolveWrapperElement: function resolveWrapperElement() {
3181
- return this.$el && this.$el.querySelector ? this.$el.querySelector(".el-dialog__wrapper") : null;
3182
- },
3183
- applyDialogLayout: function applyDialogLayout() {
3184
- var emitSizeChange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
3185
- var dialog = this.resolveDialogElement();
3186
- if (!dialog) return;
3187
- var wrapper = this.resolveWrapperElement();
3188
- if (wrapper) {
3189
- wrapper.style.display = "";
3190
- wrapper.style.alignItems = "";
3191
- wrapper.style.justifyContent = "";
3192
- }
3193
- if (this.currentHeight) {
3194
- dialog.style.height = this.normalizeSize(this.currentHeight);
3195
- dialog.style.display = "flex";
3196
- dialog.style.flexDirection = "column";
3197
- } else {
3198
- dialog.style.height = "";
3199
- }
3200
- var dialogHeight = dialog.getBoundingClientRect().height;
3201
- var centeredTop = dialogHeight >= window.innerHeight ? 20 : Math.max((window.innerHeight - dialogHeight) / 2, 0);
3202
- if (this.hasAbsolutePosition) {
3203
- dialog.style.position = "fixed";
3204
- dialog.style.margin = "0";
3205
- if (this.currentX !== null) {
3206
- dialog.style.left = this.normalizeSize(this.currentX);
3207
- } else {
3208
- dialog.style.left = "";
3209
- }
3210
- if (this.currentY !== null) {
3211
- dialog.style.top = this.normalizeSize(this.currentY);
3212
- } else {
3213
- dialog.style.top = "".concat(centeredTop, "px");
3214
- }
3215
- } else {
3216
- dialog.style.position = "relative";
3217
- dialog.style.left = "";
3218
- dialog.style.top = "".concat(centeredTop, "px");
3219
- dialog.style.margin = "0 auto";
3220
- }
3221
- if (emitSizeChange) {
3222
- this.notifySizeChange();
3223
- }
3224
- },
3225
- updateModalStyle: function updateModalStyle() {
3226
- if (!this.containerId) return;
3227
- var styleEl = document.getElementById("style-".concat(this.containerId));
3228
- if (!styleEl) {
3229
- styleEl = document.createElement("style");
3230
- styleEl.id = "style-".concat(this.containerId);
3231
- document.head.appendChild(styleEl);
3232
- }
3233
- styleEl.textContent = ".".concat(this.modalClassName.replace(/ /g, "."), " { background-color: ").concat(this.modalColor, " !important; }");
3234
- },
3235
- removeModalStyle: function removeModalStyle() {
3236
- if (!this.containerId) return;
3237
- var styleEl = document.getElementById("style-".concat(this.containerId));
3238
- if (styleEl && styleEl.parentNode) {
3239
- styleEl.parentNode.removeChild(styleEl);
3240
- }
3241
- },
3242
- syncDialogInstance: function syncDialogInstance() {
3243
- var _this23 = this;
3244
- if (!this.dialogInstance) return;
3245
- this.dialogInstance.domRef = this.$refs.contentRef || null;
3246
- this.dialogInstance.updateOption = function () {
3247
- var newOption = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3248
- if (Object.prototype.hasOwnProperty.call(newOption, "title")) {
3249
- _this23.currentTitle = newOption.title;
3250
- }
3251
- if (Object.prototype.hasOwnProperty.call(newOption, "width")) {
3252
- _this23.currentWidth = newOption.width;
3253
- }
3254
- if (Object.prototype.hasOwnProperty.call(newOption, "height")) {
3255
- _this23.currentHeight = newOption.height;
3256
- }
3257
- if (Object.prototype.hasOwnProperty.call(newOption, "x")) {
3258
- _this23.currentX = newOption.x;
3259
- }
3260
- if (Object.prototype.hasOwnProperty.call(newOption, "y")) {
3261
- _this23.currentY = newOption.y;
3262
- }
3263
- var mergedOption = __spreadValues({}, newOption);
3264
- delete mergedOption.title;
3265
- delete mergedOption.width;
3266
- delete mergedOption.height;
3267
- delete mergedOption.x;
3268
- delete mergedOption.y;
3269
- _this23.currentOption = __spreadValues(__spreadValues({}, _this23.currentOption), mergedOption);
3270
- };
3271
- this.dialogInstance.callMethod = function (methodName) {
3272
- var target = _this23.$refs.contentRef;
3273
- if (target && typeof target[methodName] === "function") {
3274
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
3275
- args[_key4 - 1] = arguments[_key4];
3276
- }
3277
- return target[methodName].apply(target, args);
3278
- }
3279
- return void 0;
3280
- };
3281
- this.dialogInstance.close = function () {
3282
- return _this23.closeDialog();
3283
- };
3284
- },
3285
- triggerDomCompleted: function triggerDomCompleted() {
3286
- if (this.domCompletedCalled) return;
3287
- if (this.$refs.contentRef) {
3288
- this.domCompletedCalled = true;
3289
- if (typeof this.domCompleted === "function") {
3290
- this.domCompleted(this.$refs.contentRef);
3291
- }
3292
- }
3293
- },
3294
- toggleMaximize: function toggleMaximize() {
3295
- var _this24 = this;
3296
- if (!this.showMaximizeButton) return;
3297
- if (!this.isMaximized) {
3298
- this.originalSize = {
3299
- width: this.currentWidth,
3300
- height: this.currentHeight,
3301
- x: this.currentX,
3302
- y: this.currentY
3303
- };
3304
- var maxConfig = this.maxSize ? this.maxSize() || {} : {};
3305
- this.currentWidth = maxConfig.width || "100vw";
3306
- this.currentHeight = maxConfig.height || "100vh";
3307
- this.currentX = maxConfig.x !== void 0 ? maxConfig.x : 0;
3308
- this.currentY = maxConfig.y !== void 0 ? maxConfig.y : 0;
3309
- this.isMaximized = true;
3310
- } else {
3311
- this.currentWidth = this.originalSize.width;
3312
- this.currentHeight = this.originalSize.height;
3313
- this.currentX = this.originalSize.x;
3314
- this.currentY = this.originalSize.y;
3315
- this.isMaximized = false;
3316
- }
3317
- this.notifySizeChange();
3318
- this.$nextTick(function () {
3319
- return _this24.applyDialogLayout(false);
3320
- });
3321
- },
3322
- closeDialog: function closeDialog() {
3323
- this.visible = false;
3324
- },
3325
- dealClose: function dealClose() {
3326
- if (typeof this.close === "function") {
3327
- this.close();
3328
- }
3329
- },
3330
- dealClosed: function dealClosed() {
3331
- if (typeof this.closed === "function") {
3332
- this.closed();
3333
- }
3334
- },
3335
- dealConfirm: function dealConfirm() {
3336
- var _this25 = this;
3337
- var vm = this;
3338
- var loadingController = {
3339
- get value() {
3340
- return vm.footerLoading;
3341
- },
3342
- set value(nextValue) {
3343
- vm.footerLoading = !!nextValue;
3344
- }
3345
- };
3346
- this.footerLoading = true;
3347
- if (!this.confirm) {
3348
- this.footerLoading = false;
3349
- return;
3350
- }
3351
- if (this.immediately) {
3352
- this.footerLoading = false;
3353
- this.visible = false;
3354
- this.confirm(null, this.$refs.contentRef);
3355
- return;
3356
- }
3357
- this.confirm(function () {
3358
- _this25.footerLoading = false;
3359
- _this25.visible = false;
3360
- }, this.$refs.contentRef, loadingController);
3361
- },
3362
- handleKeydown: function handleKeydown(event) {
3363
- if (!this.visible || !this.showFooter || !this.enterTrigger) return;
3364
- if (event.key === "Enter" && !this.footerDom && !this.footerCloseOnly) {
3365
- event.preventDefault();
3366
- this.dealConfirm();
3367
- }
3368
- },
3369
- handleDragStart: function handleDragStart(event) {
3370
- if (!this.draggable || event.button !== 0) {
3371
- return;
3372
- }
3373
- var dialog = this.resolveDialogElement();
3374
- if (!dialog) return;
3375
- var rect = dialog.getBoundingClientRect();
3376
- this.currentX = rect.left;
3377
- this.currentY = rect.top;
3378
- this.dragContext = {
3379
- startX: event.clientX,
3380
- startY: event.clientY,
3381
- originX: rect.left,
3382
- originY: rect.top
3383
- };
3384
- document.addEventListener("mousemove", this.handleDragMove);
3385
- document.addEventListener("mouseup", this.handleDragEnd);
3386
- },
3387
- handleDragMove: function handleDragMove(event) {
3388
- if (!this.dragContext) return;
3389
- var deltaX = event.clientX - this.dragContext.startX;
3390
- var deltaY = event.clientY - this.dragContext.startY;
3391
- this.currentX = this.dragContext.originX + deltaX;
3392
- this.currentY = this.dragContext.originY + deltaY;
3393
- this.applyDialogLayout();
3394
- },
3395
- handleDragEnd: function handleDragEnd() {
3396
- this.removeDragListeners();
3397
- },
3398
- removeDragListeners: function removeDragListeners() {
3399
- document.removeEventListener("mousemove", this.handleDragMove);
3400
- document.removeEventListener("mouseup", this.handleDragEnd);
3401
- this.dragContext = null;
3402
- }
3403
- }
3404
- };
3405
- var _sfc_render = function render6() {
3406
- var _vm = this,
3407
- _c = _vm._self._c;
3408
- return _c("el-dialog", {
3409
- attrs: {
3410
- "visible": _vm.visible,
3411
- "width": _vm.normalizedWidth,
3412
- "modal": _vm.modal,
3413
- "modal-class": _vm.modalClassName,
3414
- "show-close": false,
3415
- "append-to-body": false,
3416
- "close-on-click-modal": _vm.closeOnClickModal,
3417
- "custom-class": _vm.dialogCustomClass
3418
- },
3419
- on: {
3420
- "update:visible": function updateVisible($event) {
3421
- _vm.visible = $event;
3422
- },
3423
- "close": _vm.dealClose,
3424
- "closed": _vm.dealClosed
3425
- }
3426
- }, [_c("div", {
3427
- staticClass: "ns-dialog-plus__header",
3428
- attrs: {
3429
- "slot": "title"
3430
- },
3431
- on: {
3432
- "mousedown": _vm.handleDragStart
3433
- },
3434
- slot: "title"
3435
- }, [_c("div", {
3436
- staticClass: "ns-dialog-plus__title"
3437
- }, [_vm.resolvedHeaderDom ? _c(_vm.resolvedHeaderDom, _vm._g(_vm._b({
3438
- tag: "component"
3439
- }, "component", _vm.headerOption, false), _vm.mergeEvents(_vm.headerEvents))) : [_vm._v(_vm._s(_vm.currentTitle))]], 2), _c("div", {
3440
- staticClass: "dialog-controls"
3441
- }, [_vm.showMaximizeButton ? _c("span", {
3442
- staticClass: "dialog-icon dialog-maximize",
3443
- attrs: {
3444
- "title": "最大化/还原"
3445
- },
3446
- on: {
3447
- "click": function click($event) {
3448
- $event.stopPropagation();
3449
- return _vm.toggleMaximize.apply(null, arguments);
3450
- }
3451
- }
3452
- }, [!_vm.isMaximized ? _c("i", {
3453
- staticClass: "el-icon-full-screen"
3454
- }) : _c("i", {
3455
- staticClass: "el-icon-zoom-out"
3456
- })]) : _vm._e(), _c("span", {
3457
- staticClass: "dialog-icon dialog-close",
3458
- attrs: {
3459
- "title": "关闭"
3460
- },
3461
- on: {
3462
- "click": function click($event) {
3463
- $event.stopPropagation();
3464
- return _vm.closeDialog.apply(null, arguments);
3465
- }
3466
- }
3467
- }, [_c("i", {
3468
- staticClass: "el-icon-close"
3469
- })])])]), _c("div", {
3470
- staticClass: "ns-dialog-plus__body",
3471
- style: _vm.bodyStyle
3472
- }, [_c(_vm.resolvedDom, _vm._g(_vm._b({
3473
- ref: "contentRef",
3474
- tag: "component"
3475
- }, "component", _vm.currentOption, false), _vm.mergeEvents(_vm.events)))], 1), _vm.showFooter ? _c("div", {
3476
- staticClass: "ns-dialog-plus__footer",
3477
- attrs: {
3478
- "slot": "footer"
3479
- },
3480
- slot: "footer"
3481
- }, [_vm.resolvedFooterDom ? _c(_vm.resolvedFooterDom, _vm._g(_vm._b({
3482
- tag: "component"
3483
- }, "component", _vm.footerOption, false), _vm.mergeEvents(_vm.footerEvents))) : [_vm.footerButtonReverse && !_vm.footerCloseOnly ? _c("el-button", {
3484
- attrs: {
3485
- "type": "primary",
3486
- "loading": _vm.footerLoading
3487
- },
3488
- on: {
3489
- "click": _vm.dealConfirm
3490
- }
3491
- }, [_vm._v(_vm._s(_vm.footerButtonText.confirm))]) : _vm._e(), _c("el-button", {
3492
- on: {
3493
- "click": _vm.closeDialog
3494
- }
3495
- }, [_vm._v(_vm._s(_vm.footerButtonText.close))]), !_vm.footerButtonReverse && !_vm.footerCloseOnly ? _c("el-button", {
3496
- attrs: {
3497
- "type": "primary",
3498
- "loading": _vm.footerLoading
3499
- },
3500
- on: {
3501
- "click": _vm.dealConfirm
3502
- }
3503
- }, [_vm._v(_vm._s(_vm.footerButtonText.confirm))]) : _vm._e()]], 2) : _vm._e()]);
3504
- };
3505
- var _sfc_staticRenderFns = [];
3506
- var __component__ = /* @__PURE__ */normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "19b1fbf8", null, null);
3507
- var NsDialogComponent = __component__.exports;
3508
- var dialogInstances = typeof window !== "undefined" ? window.__dialogInstances = window.__dialogInstances || [] : [];
3509
- var externalVue = Vue;
3510
- var externalStore = null;
3511
- var externalPinia = null;
3512
- var dialogSeed = 0;
3513
- function resolveContextValue(primaryValue) {
3514
- var fallbackValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
3515
- if (primaryValue) {
3516
- return primaryValue;
3517
- }
3518
- return fallbackValues.find(Boolean) || null;
3519
- }
3520
- function resolveVueConstructor(app) {
3521
- if (!app) return null;
3522
- if (app.extend) {
3523
- return app;
3524
- }
3525
- if (app.constructor && app.constructor.extend) {
3526
- return app.constructor;
3527
- }
3528
- return null;
3529
- }
3530
- function resolveStore(app) {
3531
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3532
- return resolveContextValue(options.store, [app && app.$store, app && app.$options && app.$options.store, app && app.store, externalStore]);
3533
- }
3534
- function resolvePinia(app) {
3535
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3536
- return resolveContextValue(options.pinia, [app && app.$pinia, app && app.$options && app.$options.pinia, app && app.pinia, externalPinia]);
3537
- }
3538
- function setExternalApp(app) {
3539
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3540
- if (!app) return;
3541
- var resolvedVue = resolveVueConstructor(app);
3542
- if (resolvedVue) {
3543
- externalVue = resolvedVue;
3544
- }
3545
- externalStore = resolveStore(app, options);
3546
- externalPinia = resolvePinia(app, options);
3547
- }
3548
- function resolveMountTarget(selector) {
3549
- if (typeof document === "undefined") {
3550
- return null;
3551
- }
3552
- return document.querySelector(selector) || document.body;
3553
- }
3554
- function removeDialogInstance(instance) {
3555
- var index2 = dialogInstances.findIndex(function (item) {
3556
- return item.id === instance.id;
3557
- });
3558
- if (index2 > -1) {
3559
- dialogInstances.splice(index2, 1);
3560
- }
3561
- }
3562
- function destroyDialog(instance) {
3563
- if (!instance || instance.destroyed) {
3564
- return;
3565
- }
3566
- instance.destroyed = true;
3567
- var vm = instance.vm;
3568
- if (vm && !vm._isDestroyed) {
3569
- vm.$destroy();
3570
- }
3571
- var rootEl = instance.rootEl || vm && vm.$el;
3572
- if (rootEl && instance.element && rootEl.parentNode === instance.element) {
3573
- instance.element.removeChild(rootEl);
3574
- }
3575
- if (instance.element && instance.element.parentNode) {
3576
- instance.element.parentNode.removeChild(instance.element);
3577
- }
3578
- instance.vm = null;
3579
- instance.domRef = null;
3580
- instance.rootEl = null;
3581
- instance.updateOption = function () {};
3582
- instance.callMethod = function () {};
3583
- instance.close = function () {};
3584
- removeDialogInstance(instance);
3585
- }
3586
- function closeAllNsDialog() {
3587
- dialogInstances.slice().forEach(function (instance) {
3588
- if (instance && typeof instance.close === "function") {
3589
- instance.close();
3590
- }
3591
- });
3592
- }
3593
- function NsDialog(data) {
3594
- var modal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3595
- var appendTo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "#app";
3596
- if (!data || !data.dom) {
3597
- return false;
3598
- }
3599
- var mountTarget = resolveMountTarget(appendTo);
3600
- if (!mountTarget) {
3601
- return false;
3602
- }
3603
- var callerVm = this && this._isVue ? this : null;
3604
- var _a = data,
3605
- dataStore = _a.store,
3606
- dataPinia = _a.pinia,
3607
- dialogData = __objRest(_a, ["store", "pinia"]);
3608
- var store = resolveStore(callerVm, {
3609
- store: dataStore
3610
- });
3611
- var pinia = resolvePinia(callerVm, {
3612
- pinia: dataPinia
3613
- });
3614
- var id = dialogData.id || "ns-dialog-".concat(Date.now(), "-").concat(dialogSeed++);
3615
- var container = document.createElement("div");
3616
- container.id = id;
3617
- mountTarget.appendChild(container);
3618
- var instance = {
3619
- id: id,
3620
- class: dialogData.class || "",
3621
- element: container,
3622
- vm: null,
3623
- rootEl: null,
3624
- destroyed: false,
3625
- domRef: null,
3626
- updateOption: function updateOption() {},
3627
- callMethod: function callMethod() {},
3628
- close: function close() {}
3629
- };
3630
- var DialogConstructor = (externalVue || Vue).extend(NsDialogComponent);
3631
- var propsData = __spreadProps(__spreadValues({}, dialogData), {
3632
- className: dialogData.class || "",
3633
- modal: modal,
3634
- footerButtonReverse: true,
3635
- containerId: id,
3636
- dialogInstance: instance,
3637
- close: function close() {
3638
- if (typeof dialogData.close === "function") {
3639
- dialogData.close();
3640
- }
3641
- },
3642
- closed: function closed() {
3643
- try {
3644
- if (typeof dialogData.closed === "function") {
3645
- dialogData.closed();
3646
- }
3647
- } finally {
3648
- destroyDialog(instance);
3649
- }
3650
- }
3651
- });
3652
- var vmOptions = {
3653
- propsData: propsData
3654
- };
3655
- if (store) {
3656
- vmOptions.store = store;
3657
- }
3658
- if (pinia) {
3659
- vmOptions.pinia = pinia;
3660
- }
3661
- var vm = new DialogConstructor(vmOptions);
3662
- instance.vm = vm;
3663
- instance.close = function () {
3664
- if (instance.destroyed) {
3665
- return;
3666
- }
3667
- if (vm && typeof vm.closeDialog === "function") {
3668
- vm.closeDialog();
3669
- }
3670
- };
3671
- dialogInstances.push(instance);
3672
- vm.$mount();
3673
- if (vm.$el) {
3674
- instance.rootEl = vm.$el;
3675
- container.appendChild(vm.$el);
3676
- }
3677
- return instance;
3678
- }
3679
- var components = [NsForm, NsFormTitle, NsTableContainer, NsSearch, NsTable];
3680
- function install2(Vue2) {
3681
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3682
- if (install2.installed) return;
3683
- install2.installed = true;
3684
- registerDirective(Vue2);
3685
- components.forEach(function (component) {
3686
- if (component && component.name) {
3687
- Vue2.component(component.name, component);
3688
- }
3689
- });
3690
- setExternalApp(Vue2, options);
3691
- loadCssVars$1();
3692
- if (Vue2 && Vue2.prototype) {
3693
- Vue2.prototype.$NsDialog = NsDialog;
3694
- Vue2.prototype.$closeAllNsDialog = closeAllNsDialog;
3695
- }
3696
- if (typeof window !== "undefined") {
3697
- window.NsDialog = NsDialog;
3698
- window.closeAllNsDialog = closeAllNsDialog;
3699
- }
3700
- }
3701
- var index = {
3702
- install: install2,
3703
- NsForm: NsForm,
3704
- NsFormTitle: NsFormTitle,
3705
- NsTableContainer: NsTableContainer,
3706
- NsSearch: NsSearch,
3707
- NsTable: NsTable,
3708
- NsDialog: NsDialog,
3709
- closeAllNsDialog: closeAllNsDialog,
3710
- setExternalApp: setExternalApp,
3711
- useFileUpload: useFileUpload,
3712
- getAllFormNodeByKey: getAllFormNodeByKey,
3713
- getAllFormKvData: getAllFormKvData,
3714
- getAllFormNodeRefByKey: getAllFormNodeRefByKey,
3715
- createPagination: createPagination,
3716
- createPaginationWithCustomKeys: createPaginationWithCustomKeys,
3717
- resetPagination: resetPagination
3718
- };
3719
- export { NsDialog, NsForm, NsFormTitle, NsSearch, NsTable, NsTableContainer, closeAllNsDialog, createPagination, createPaginationWithCustomKeys, index as default, getAllFormKvData, getAllFormNodeByKey, getAllFormNodeRefByKey, install2 as install, resetPagination, setExternalApp, useFileUpload };