vue2-components-plus 1.0.69 → 1.0.70

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.
@@ -0,0 +1,3742 @@
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 = /*#__PURE__*/_createClass(function ThemeVar() {
335
+ _classCallCheck(this, ThemeVar);
336
+ });
337
+ ThemeVar.VARS = {};
338
+ function loadCssVars() {
339
+ if (typeof document === "undefined") {
340
+ return ThemeVar.VARS;
341
+ }
342
+ if (Object.keys(ThemeVar.VARS).length > 0) {
343
+ return ThemeVar.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.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 DynamicFormTitle_vue_vue_type_style_index_0_scoped_5d766a25_lang = "";
1205
+ var _sfc_main$4 = {
1206
+ name: "NsFormTitle",
1207
+ props: {
1208
+ title: {
1209
+ type: String,
1210
+ default: ""
1211
+ }
1212
+ },
1213
+ mounted: function mounted() {
1214
+ loadCssVars();
1215
+ }
1216
+ };
1217
+ var _sfc_render$4 = function render2() {
1218
+ var _vm = this,
1219
+ _c = _vm._self._c;
1220
+ return _c("div", {
1221
+ staticClass: "ns-form-title"
1222
+ }, [_c("div", {
1223
+ staticClass: "ns-form-title__header"
1224
+ }, [_vm._t("title", function () {
1225
+ return [_c("span", {
1226
+ staticClass: "ns-form-title__icon"
1227
+ }), _c("span", {
1228
+ staticClass: "ns-form-title__text"
1229
+ }, [_vm._v(_vm._s(_vm.title))])];
1230
+ })], 2), _c("div", {
1231
+ staticClass: "ns-form-title__content"
1232
+ }, [_vm._t("default")], 2)]);
1233
+ };
1234
+ var _sfc_staticRenderFns$4 = [];
1235
+ var __component__$4 = /* @__PURE__ */normalizeComponent(_sfc_main$4, _sfc_render$4, _sfc_staticRenderFns$4, false, null, "5d766a25", null, null);
1236
+ var NsFormTitle = __component__$4.exports;
1237
+ function getImageBaseUrl(instance) {
1238
+ var _a;
1239
+ return ((_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$ImageBaseUrl) || "";
1240
+ }
1241
+ function getFieldPathByKey(rows, key) {
1242
+ var formPropKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "rows";
1243
+ for (var rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
1244
+ var row = rows[rowIndex];
1245
+ for (var colIndex = 0; colIndex < row.length; colIndex += 1) {
1246
+ var item = row[colIndex];
1247
+ if (item.key === key) {
1248
+ return "".concat(formPropKey, ".").concat(rowIndex, ".").concat(colIndex, ".value");
1249
+ }
1250
+ if (Array.isArray(item.children)) {
1251
+ for (var childIndex = 0; childIndex < item.children.length; childIndex += 1) {
1252
+ var child = item.children[childIndex];
1253
+ if (child.key === key) {
1254
+ return "".concat(formPropKey, ".").concat(rowIndex, ".").concat(colIndex, ".children.").concat(childIndex, ".value");
1255
+ }
1256
+ }
1257
+ }
1258
+ }
1259
+ }
1260
+ return null;
1261
+ }
1262
+ function useFileUpload(state) {
1263
+ var instance = getCurrentInstance();
1264
+ function handleFormatFileList(field, fileList) {
1265
+ var baseUrl = getImageBaseUrl(instance);
1266
+ var nextList = Array.isArray(fileList) ? fileList : [];
1267
+ nextList.forEach(function (item) {
1268
+ if (item.filePath && !item.url) {
1269
+ item.url = "".concat(baseUrl).concat(item.filePath);
1270
+ }
1271
+ if (!item.name) {
1272
+ item.name = item.fileName || item.name || item.filePath || "未命名文件";
1273
+ }
1274
+ });
1275
+ if (field && field.params) {
1276
+ field.params.fileList = nextList;
1277
+ }
1278
+ if (field) {
1279
+ field.value = nextList.slice();
1280
+ }
1281
+ return nextList;
1282
+ }
1283
+ function handleRemoveFile(file, fileList, fieldKey) {
1284
+ var rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : state.rows;
1285
+ var field = getAllFormNodeByKey(rows, fieldKey);
1286
+ if (!field) {
1287
+ return fileList;
1288
+ }
1289
+ var nextValue = (fileList || []).map(function (item) {
1290
+ return __spreadProps(__spreadValues({}, item), {
1291
+ fileName: item.response ? item.response.data.fileName : item.fileName,
1292
+ filePath: item.response ? item.response.data.filePath : item.filePath,
1293
+ fileSize: item.response ? item.response.data.fileSize : item.fileSize
1294
+ });
1295
+ });
1296
+ if (!Array.isArray(field.delValue)) {
1297
+ field.delValue = [];
1298
+ }
1299
+ if (!file.response && file.status === "success") {
1300
+ field.delValue.push(__spreadProps(__spreadValues({}, file), {
1301
+ isDelete: 1
1302
+ }));
1303
+ }
1304
+ field.value = nextValue;
1305
+ if (field.params) {
1306
+ field.params.fileList = fileList || [];
1307
+ }
1308
+ return fileList;
1309
+ }
1310
+ function handleFileSuccessFile(response, file, fileList, fieldKey) {
1311
+ var rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : state.rows;
1312
+ var field = getAllFormNodeByKey(rows, fieldKey);
1313
+ if (!field) {
1314
+ return fileList;
1315
+ }
1316
+ if (!Array.isArray(field.value)) {
1317
+ field.value = [];
1318
+ }
1319
+ if (file && file.status === "success" && response && response.data) {
1320
+ field.value.push(__spreadValues({}, response.data));
1321
+ }
1322
+ if (field.params) {
1323
+ field.params.fileList = fileList || [];
1324
+ }
1325
+ return fileList;
1326
+ }
1327
+ function handleCheckFileRequire(rows, key, formRef) {
1328
+ var formPropKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "rows";
1329
+ var field = getAllFormNodeByKey(rows, key);
1330
+ if (field && !Array.isArray(field.value)) {
1331
+ field.value = [];
1332
+ }
1333
+ var fieldPath = getFieldPathByKey(rows, key, formPropKey);
1334
+ nextTick(function () {
1335
+ var formInstance = formRef && (formRef.value || formRef);
1336
+ if (fieldPath && formInstance && typeof formInstance.validateField === "function") {
1337
+ formInstance.validateField(fieldPath);
1338
+ }
1339
+ });
1340
+ }
1341
+ return {
1342
+ handleFormatFileList: handleFormatFileList,
1343
+ handleRemoveFile: handleRemoveFile,
1344
+ handleFileSuccessFile: handleFileSuccessFile,
1345
+ handleCheckFileRequire: handleCheckFileRequire
1346
+ };
1347
+ }
1348
+ function installComponent(component) {
1349
+ component.install = function install3(Vue2) {
1350
+ Vue2.component(component.name, component);
1351
+ };
1352
+ }
1353
+ installComponent(NsForm);
1354
+ installComponent(NsFormTitle);
1355
+ var originalNsFormInstall = NsForm.install;
1356
+ NsForm.install = function install(Vue2) {
1357
+ registerDirective(Vue2);
1358
+ originalNsFormInstall(Vue2);
1359
+ };
1360
+ function getAllFormKvData(rows) {
1361
+ var result = {};
1362
+ (rows || []).forEach(function (row) {
1363
+ (row || []).forEach(function (item) {
1364
+ if (item && item.key) {
1365
+ result[item.key] = Array.isArray(item.value) && Array.isArray(item.delValue) ? item.value.concat(item.delValue) : item.value;
1366
+ }
1367
+ (item.children || []).forEach(function (child) {
1368
+ if (child && child.key) {
1369
+ result[child.key] = Array.isArray(child.value) && Array.isArray(child.delValue) ? child.value.concat(child.delValue) : child.value;
1370
+ }
1371
+ });
1372
+ });
1373
+ });
1374
+ return result;
1375
+ }
1376
+ function getAllFormNodeByKey(rows, key) {
1377
+ for (var rowIndex = 0; rowIndex < (rows || []).length; rowIndex += 1) {
1378
+ var row = rows[rowIndex] || [];
1379
+ for (var colIndex = 0; colIndex < row.length; colIndex += 1) {
1380
+ var item = row[colIndex];
1381
+ if (item && item.key === key) {
1382
+ return item;
1383
+ }
1384
+ var children = item && item.children || [];
1385
+ for (var childIndex = 0; childIndex < children.length; childIndex += 1) {
1386
+ if (children[childIndex] && children[childIndex].key === key) {
1387
+ return children[childIndex];
1388
+ }
1389
+ }
1390
+ }
1391
+ }
1392
+ return null;
1393
+ }
1394
+ function getAllFormNodeRefByKey(rows, key) {
1395
+ var node = getAllFormNodeByKey(rows, key);
1396
+ return node ? node.ref || null : null;
1397
+ }
1398
+ if (typeof globalThis !== "undefined") {
1399
+ globalThis.getAllFormKvData = getAllFormKvData;
1400
+ globalThis.getAllFormNodeByKey = getAllFormNodeByKey;
1401
+ globalThis.getAllFormNodeRefByKey = getAllFormNodeRefByKey;
1402
+ }
1403
+ var SlotRenderer = {
1404
+ name: "NsSlotRenderer",
1405
+ functional: true,
1406
+ props: {
1407
+ renderer: {
1408
+ type: Function,
1409
+ default: null
1410
+ },
1411
+ scope: {
1412
+ type: Object,
1413
+ default: function _default() {
1414
+ return {};
1415
+ }
1416
+ }
1417
+ },
1418
+ render: function render(h, ctx) {
1419
+ var renderer = ctx.props.renderer;
1420
+ return renderer ? renderer(ctx.props.scope || {}) : null;
1421
+ }
1422
+ };
1423
+ var PageSearch_vue_vue_type_style_index_0_scoped_90982d04_lang = "";
1424
+ function toKebabCase(value) {
1425
+ if (typeof value !== "string") return value;
1426
+ if (value.indexOf("-") > -1) return value.toLowerCase();
1427
+ return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1428
+ }
1429
+ var _sfc_main$3 = {
1430
+ name: "NsSearch",
1431
+ components: {
1432
+ SlotRenderer: SlotRenderer
1433
+ },
1434
+ inheritAttrs: false,
1435
+ props: {
1436
+ items: {
1437
+ type: Array,
1438
+ default: function _default() {
1439
+ return [];
1440
+ }
1441
+ },
1442
+ externalParams: {
1443
+ type: Object,
1444
+ default: function _default() {
1445
+ return {};
1446
+ }
1447
+ },
1448
+ defaultSpan: {
1449
+ type: Number,
1450
+ default: 6
1451
+ },
1452
+ showCollapse: {
1453
+ type: Boolean,
1454
+ default: true
1455
+ },
1456
+ collapseLimit: {
1457
+ type: Number,
1458
+ default: 3
1459
+ },
1460
+ slotRenderers: {
1461
+ type: Object,
1462
+ default: function _default() {
1463
+ return {};
1464
+ }
1465
+ },
1466
+ actionsAlign: {
1467
+ type: String,
1468
+ default: "left"
1469
+ },
1470
+ actionsSpan: {
1471
+ type: Number,
1472
+ default: null
1473
+ },
1474
+ actionsWidth: {
1475
+ type: [String, Number],
1476
+ default: ""
1477
+ },
1478
+ collapseToggleText: {
1479
+ type: [Array, String],
1480
+ default: function _default() {
1481
+ return ["展开", "收起"];
1482
+ }
1483
+ },
1484
+ enterTrigger: {
1485
+ type: Boolean,
1486
+ default: true
1487
+ }
1488
+ },
1489
+ data: function data() {
1490
+ return {
1491
+ formData: {},
1492
+ isCollapsed: true
1493
+ };
1494
+ },
1495
+ computed: {
1496
+ itemsPerRow: function itemsPerRow() {
1497
+ var span = Number(this.defaultSpan || 6);
1498
+ var normalizedSpan = Number.isFinite(span) && span > 0 ? span : 6;
1499
+ return Math.max(1, Math.floor(24 / normalizedSpan));
1500
+ },
1501
+ visibleItems: function visibleItems() {
1502
+ if (!this.showCollapse || !this.isCollapsed) {
1503
+ return this.items;
1504
+ }
1505
+ var sourceItems = this.items || [];
1506
+ var limit = Math.min(Number(this.collapseLimit || 0), sourceItems.length);
1507
+ if (limit > 0 && limit % this.itemsPerRow === 0 && sourceItems.length > limit) {
1508
+ limit = limit - 1;
1509
+ }
1510
+ return sourceItems.slice(0, Math.max(limit, 1));
1511
+ },
1512
+ normalizedActionsAlign: function normalizedActionsAlign() {
1513
+ var value = String(this.actionsAlign || "").toLowerCase();
1514
+ return ["left", "center", "right"].includes(value) ? value : "left";
1515
+ },
1516
+ actionAlignClass: function actionAlignClass() {
1517
+ return "page-search__actions--".concat(this.normalizedActionsAlign);
1518
+ },
1519
+ resolvedActionsSpan: function resolvedActionsSpan() {
1520
+ var span = Number(this.actionsSpan);
1521
+ if (Number.isFinite(span) && span > 0) {
1522
+ return Math.min(Math.floor(span), 24);
1523
+ }
1524
+ return Number(this.defaultSpan || 6);
1525
+ },
1526
+ actionsColStyle: function actionsColStyle() {
1527
+ var width = this.toCssSize(this.actionsWidth);
1528
+ if (!width) return void 0;
1529
+ return {
1530
+ flex: "0 0 ".concat(width),
1531
+ maxWidth: width
1532
+ };
1533
+ },
1534
+ collapseToggleLabels: function collapseToggleLabels() {
1535
+ if (Array.isArray(this.collapseToggleText)) {
1536
+ var expandLabel2 = String(this.collapseToggleText[0] || "").trim();
1537
+ var collapseLabel2 = String(this.collapseToggleText[1] || "").trim();
1538
+ return [expandLabel2 || "展开", collapseLabel2 || "收起"];
1539
+ }
1540
+ var text = String(this.collapseToggleText || "").trim();
1541
+ if (!text) return ["展开", "收起"];
1542
+ var parts = text.split("/");
1543
+ var expandLabel = String(parts[0] || "").trim();
1544
+ var collapseLabel = String(parts[1] || "").trim();
1545
+ return [expandLabel || "展开", collapseLabel || "收起"];
1546
+ }
1547
+ },
1548
+ watch: {
1549
+ items: {
1550
+ handler: function handler() {
1551
+ this.initFormData();
1552
+ },
1553
+ deep: true,
1554
+ immediate: true
1555
+ },
1556
+ externalParams: {
1557
+ handler: function handler() {
1558
+ this.formData = __spreadValues(__spreadValues({}, this.formData), this.externalParams);
1559
+ },
1560
+ deep: true,
1561
+ immediate: true
1562
+ }
1563
+ },
1564
+ methods: {
1565
+ normalizeComponent: function normalizeComponent(component) {
1566
+ return typeof component === "string" ? toKebabCase(component) : component;
1567
+ },
1568
+ initFormData: function initFormData() {
1569
+ var nextData = {};
1570
+ (this.items || []).forEach(function (item) {
1571
+ nextData[item.prop] = item.defaultValue !== void 0 ? item.defaultValue : void 0;
1572
+ });
1573
+ this.formData = __spreadValues(__spreadValues({}, nextData), this.externalParams);
1574
+ },
1575
+ isSlotItem: function isSlotItem(item) {
1576
+ return item && (item.type === "slot" || item.slot === true || typeof item.slot === "string");
1577
+ },
1578
+ getSlotRenderer: function getSlotRenderer(item) {
1579
+ var name = typeof item.slot === "string" ? item.slot : item.slotName || item.prop;
1580
+ return this.slotRenderers[name] || null;
1581
+ },
1582
+ isSelectComponent: function isSelectComponent(item) {
1583
+ var name = String(this.normalizeComponent(item.component || "") || "");
1584
+ return name === "el-select";
1585
+ },
1586
+ toCssSize: function toCssSize(value) {
1587
+ if (value === "" || value === null || value === void 0) return "";
1588
+ if (typeof value === "number") return "".concat(value, "px");
1589
+ return String(value);
1590
+ },
1591
+ handleSearch: function handleSearch() {
1592
+ this.$emit("search", __spreadProps(__spreadValues({}, this.formData), {
1593
+ _resetPage: true
1594
+ }));
1595
+ },
1596
+ handleReset: function handleReset() {
1597
+ var nextData = {};
1598
+ (this.items || []).forEach(function (item) {
1599
+ nextData[item.prop] = item.defaultValue !== void 0 ? item.defaultValue : void 0;
1600
+ });
1601
+ this.formData = __spreadValues(__spreadValues({}, nextData), this.externalParams);
1602
+ this.$emit("search", __spreadProps(__spreadValues({}, this.formData), {
1603
+ _resetPage: true
1604
+ }));
1605
+ this.$emit("reset");
1606
+ },
1607
+ toggleCollapse: function toggleCollapse() {
1608
+ this.isCollapsed = !this.isCollapsed;
1609
+ },
1610
+ getFormData: function getFormData() {
1611
+ return __spreadValues({}, this.formData);
1612
+ },
1613
+ setFormData: function setFormData(data) {
1614
+ this.formData = __spreadValues(__spreadValues({}, this.formData), data || {});
1615
+ },
1616
+ resetForm: function resetForm() {
1617
+ this.handleReset();
1618
+ },
1619
+ validate: function validate() {
1620
+ return this.$refs.formRef && this.$refs.formRef.validate ? this.$refs.formRef.validate() : Promise.resolve(true);
1621
+ },
1622
+ clearValidate: function clearValidate(props) {
1623
+ if (this.$refs.formRef && this.$refs.formRef.clearValidate) {
1624
+ this.$refs.formRef.clearValidate(props);
1625
+ }
1626
+ }
1627
+ }
1628
+ };
1629
+ var _sfc_render$3 = function render3() {
1630
+ var _vm = this,
1631
+ _c = _vm._self._c;
1632
+ return _c("div", {
1633
+ staticClass: "page-search"
1634
+ }, [_c("el-form", _vm._b({
1635
+ ref: "formRef",
1636
+ staticClass: "page-search__form",
1637
+ attrs: {
1638
+ "inline": true,
1639
+ "model": _vm.formData
1640
+ }
1641
+ }, "el-form", _vm.$attrs, false), [_c("el-row", {
1642
+ staticClass: "page-search__row",
1643
+ attrs: {
1644
+ "gutter": 16,
1645
+ "type": "flex"
1646
+ }
1647
+ }, [_vm._l(_vm.visibleItems, function (item, index2) {
1648
+ return _c("el-col", {
1649
+ key: item.prop || index2,
1650
+ attrs: {
1651
+ "span": item.span || _vm.defaultSpan
1652
+ }
1653
+ }, [_c("el-form-item", _vm._b({
1654
+ attrs: {
1655
+ "label": item.label,
1656
+ "prop": item.prop
1657
+ }
1658
+ }, "el-form-item", item.formItemAttrs || {}, false), [_vm.isSlotItem(item) ? _c("slot-renderer", {
1659
+ attrs: {
1660
+ "renderer": _vm.getSlotRenderer(item),
1661
+ "scope": {
1662
+ formData: _vm.formData,
1663
+ item: item
1664
+ }
1665
+ }
1666
+ }) : _c(_vm.normalizeComponent(item.component || "el-input"), _vm._g(_vm._b({
1667
+ tag: "component",
1668
+ model: {
1669
+ value: _vm.formData[item.prop],
1670
+ callback: function callback($$v) {
1671
+ _vm.$set(_vm.formData, item.prop, $$v);
1672
+ },
1673
+ expression: "formData[item.prop]"
1674
+ }
1675
+ }, "component", item.attrs || {}, false), item.events || {}), [_vm.isSelectComponent(item) ? _vm._l(item.children || [], function (option, optionIndex) {
1676
+ return _c("el-option", {
1677
+ key: option.value !== void 0 ? option.value : optionIndex,
1678
+ attrs: {
1679
+ "label": option.label,
1680
+ "value": option.value,
1681
+ "disabled": option.disabled
1682
+ }
1683
+ });
1684
+ }) : _vm._e()], 2)], 1)], 1);
1685
+ }), _c("el-col", {
1686
+ staticClass: "page-search__actions",
1687
+ class: _vm.actionAlignClass,
1688
+ style: _vm.actionsColStyle,
1689
+ attrs: {
1690
+ "span": _vm.resolvedActionsSpan
1691
+ }
1692
+ }, [_c("el-form-item", {
1693
+ attrs: {
1694
+ "label-width": "0"
1695
+ }
1696
+ }, [_vm.enterTrigger ? _c("el-button", {
1697
+ directives: [{
1698
+ name: "enterClick",
1699
+ rawName: "v-enterClick"
1700
+ }],
1701
+ attrs: {
1702
+ "type": "primary"
1703
+ },
1704
+ on: {
1705
+ "click": _vm.handleSearch
1706
+ }
1707
+ }, [_vm._v("查询")]) : _c("el-button", {
1708
+ attrs: {
1709
+ "type": "primary"
1710
+ },
1711
+ on: {
1712
+ "click": _vm.handleSearch
1713
+ }
1714
+ }, [_vm._v("查询")]), _c("el-button", {
1715
+ on: {
1716
+ "click": _vm.handleReset
1717
+ }
1718
+ }, [_vm._v("重置")]), _vm.slotRenderers["actions-after-reset"] ? _c("slot-renderer", {
1719
+ attrs: {
1720
+ "renderer": _vm.slotRenderers["actions-after-reset"],
1721
+ "scope": {
1722
+ formData: _vm.formData,
1723
+ handleSearch: _vm.handleSearch,
1724
+ handleReset: _vm.handleReset,
1725
+ isCollapsed: _vm.isCollapsed
1726
+ }
1727
+ }
1728
+ }) : _vm._e(), _vm.showCollapse && _vm.items.length > _vm.collapseLimit ? _c("el-button", {
1729
+ attrs: {
1730
+ "type": "text"
1731
+ },
1732
+ on: {
1733
+ "click": _vm.toggleCollapse
1734
+ }
1735
+ }, [_c("span", [_vm._v(_vm._s(_vm.isCollapsed ? _vm.collapseToggleLabels[0] : _vm.collapseToggleLabels[1]))]), _c("i", {
1736
+ class: _vm.isCollapsed ? "el-icon-arrow-down" : "el-icon-arrow-up"
1737
+ })]) : _vm._e()], 1)], 1)], 2)], 1)], 1);
1738
+ };
1739
+ var _sfc_staticRenderFns$3 = [];
1740
+ var __component__$3 = /* @__PURE__ */normalizeComponent(_sfc_main$3, _sfc_render$3, _sfc_staticRenderFns$3, false, null, "90982d04", null, null);
1741
+ var NsSearch = __component__$3.exports;
1742
+ var RESERVED_KEYS = ["children", "slot", "headerSlot", "buttons", "enum", "type", "imageWidth", "imageHeight", "linkText"];
1743
+ function getColumnProps(column) {
1744
+ var props = __spreadValues({}, column);
1745
+ RESERVED_KEYS.forEach(function (key) {
1746
+ return delete props[key];
1747
+ });
1748
+ return props;
1749
+ }
1750
+ function getRenderer(slotRenderers, name) {
1751
+ return name ? slotRenderers[name] : null;
1752
+ }
1753
+ function getCellValue(row, column) {
1754
+ return column.prop ? row[column.prop] : void 0;
1755
+ }
1756
+ function isVisible(config, row) {
1757
+ if (typeof config.show === "function") {
1758
+ return config.show(row) !== false;
1759
+ }
1760
+ if (config.show === void 0) {
1761
+ return true;
1762
+ }
1763
+ return !!config.show;
1764
+ }
1765
+ function isDisabled(config, row) {
1766
+ return typeof config.disabled === "function" ? !!config.disabled(row) : !!config.disabled;
1767
+ }
1768
+ function emit(listeners, name) {
1769
+ for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
1770
+ args[_key2 - 2] = arguments[_key2];
1771
+ }
1772
+ var handler = listeners && listeners[name];
1773
+ if (!handler) {
1774
+ return;
1775
+ }
1776
+ if (Array.isArray(handler)) {
1777
+ handler.forEach(function (fn) {
1778
+ return typeof fn === "function" && fn.apply(void 0, args);
1779
+ });
1780
+ return;
1781
+ }
1782
+ if (typeof handler === "function") {
1783
+ handler.apply(void 0, args);
1784
+ }
1785
+ }
1786
+ function resolveEnumText(column, value) {
1787
+ var enumList = column.enum || column.options || [];
1788
+ if (!Array.isArray(enumList)) {
1789
+ return value;
1790
+ }
1791
+ var matched = enumList.find(function (item) {
1792
+ return item.value === value;
1793
+ });
1794
+ return matched ? matched.label : value;
1795
+ }
1796
+ function renderActionButtons(h, scope, column, slotRenderers, listeners) {
1797
+ var buttons = Array.isArray(column.buttons) ? column.buttons : [];
1798
+ return buttons.filter(function (button) {
1799
+ return isVisible(button, scope.row);
1800
+ }).map(function (button, index2) {
1801
+ var slotRenderer = getRenderer(slotRenderers, button.slot);
1802
+ if (slotRenderer) {
1803
+ return slotRenderer(__spreadProps(__spreadValues({}, scope), {
1804
+ row: scope.row,
1805
+ column: column,
1806
+ button: button
1807
+ }));
1808
+ }
1809
+ return h("el-button", {
1810
+ key: button.label || index2,
1811
+ props: {
1812
+ size: button.size || "mini",
1813
+ type: button.link ? "text" : button.type || "text",
1814
+ icon: typeof button.icon === "string" ? button.icon : void 0,
1815
+ disabled: isDisabled(button, scope.row)
1816
+ },
1817
+ on: {
1818
+ click: function click() {
1819
+ if (typeof button.handler === "function") {
1820
+ button.handler(scope.row, scope.$index);
1821
+ }
1822
+ emit(listeners, "button-click", scope.row, column, button);
1823
+ }
1824
+ }
1825
+ }, [button.label]);
1826
+ });
1827
+ }
1828
+ function renderTag(h, scope, column) {
1829
+ var cellValue = getCellValue(scope.row, column);
1830
+ var tagType = typeof column.tagType === "function" ? column.tagType(scope.row, cellValue) : column.tagType;
1831
+ var text = typeof column.formatter === "function" ? column.formatter(scope.row, column, cellValue) : resolveEnumText(column, cellValue);
1832
+ return h("el-tag", {
1833
+ props: {
1834
+ type: tagType || "info",
1835
+ size: column.tagSize || "small"
1836
+ }
1837
+ }, [text]);
1838
+ }
1839
+ function renderImage(h, scope, column) {
1840
+ var src = getCellValue(scope.row, column);
1841
+ if (!src) {
1842
+ return "-";
1843
+ }
1844
+ return h("img", {
1845
+ style: {
1846
+ width: column.imageWidth || "40px",
1847
+ height: column.imageHeight || "40px",
1848
+ objectFit: "cover",
1849
+ borderRadius: "4px"
1850
+ },
1851
+ attrs: {
1852
+ src: src,
1853
+ alt: column.label || "image"
1854
+ }
1855
+ });
1856
+ }
1857
+ function renderLink(h, scope, column, slotRenderers, listeners) {
1858
+ var renderer = getRenderer(slotRenderers, column.slot);
1859
+ if (renderer) {
1860
+ return renderer(scope);
1861
+ }
1862
+ var cellValue = getCellValue(scope.row, column);
1863
+ return h("el-button", {
1864
+ props: {
1865
+ type: "text"
1866
+ },
1867
+ on: {
1868
+ click: function click() {
1869
+ return emit(listeners, "link-click", scope.row, column);
1870
+ }
1871
+ }
1872
+ }, [column.linkText || cellValue || "-"]);
1873
+ }
1874
+ function renderDefaultCell(h, scope, column, slotRenderers, listeners) {
1875
+ var renderer = getRenderer(slotRenderers, column.slot);
1876
+ if (renderer) {
1877
+ return renderer(scope);
1878
+ }
1879
+ if (column.type === "action") {
1880
+ return h("div", {
1881
+ class: "ns-table-column__actions"
1882
+ }, renderActionButtons(h, scope, column, slotRenderers, listeners));
1883
+ }
1884
+ if (column.type === "tag") {
1885
+ return renderTag(h, scope, column);
1886
+ }
1887
+ if (column.type === "image") {
1888
+ return renderImage(h, scope, column);
1889
+ }
1890
+ if (column.type === "link") {
1891
+ return renderLink(h, scope, column, slotRenderers, listeners);
1892
+ }
1893
+ var cellValue = getCellValue(scope.row, column);
1894
+ if (typeof column.formatter === "function") {
1895
+ return column.formatter(scope.row, column, cellValue);
1896
+ }
1897
+ if (column.enum) {
1898
+ return resolveEnumText(column, cellValue);
1899
+ }
1900
+ return cellValue === void 0 || cellValue === null || cellValue === "" ? "-" : cellValue;
1901
+ }
1902
+ function renderColumn(h, column, slotRenderers, listeners) {
1903
+ var children = Array.isArray(column.children) ? column.children.map(function (child, index2) {
1904
+ return h(TableColumn, {
1905
+ key: child.prop || child.label || index2,
1906
+ props: {
1907
+ column: child,
1908
+ slotRenderers: slotRenderers
1909
+ },
1910
+ on: listeners
1911
+ });
1912
+ }) : [];
1913
+ var headerRenderer = getRenderer(slotRenderers, column.headerSlot);
1914
+ return h("el-table-column", {
1915
+ props: getColumnProps(column),
1916
+ scopedSlots: children.length ? headerRenderer ? {
1917
+ header: headerRenderer
1918
+ } : void 0 : __spreadValues({
1919
+ default: function _default(scope) {
1920
+ return renderDefaultCell(h, scope, column, slotRenderers, listeners);
1921
+ }
1922
+ }, headerRenderer ? {
1923
+ header: headerRenderer
1924
+ } : {})
1925
+ }, children);
1926
+ }
1927
+ var TableColumn = {
1928
+ name: "NsTableColumn",
1929
+ functional: true,
1930
+ props: {
1931
+ column: {
1932
+ type: Object,
1933
+ required: true
1934
+ },
1935
+ slotRenderers: {
1936
+ type: Object,
1937
+ default: function _default() {
1938
+ return {};
1939
+ }
1940
+ }
1941
+ },
1942
+ render: function render(h, ctx) {
1943
+ return renderColumn(h, ctx.props.column, ctx.props.slotRenderers || {}, ctx.listeners || {});
1944
+ }
1945
+ };
1946
+ var TableColumn$1 = TableColumn;
1947
+ var DEFAULT_PAGINATION = {
1948
+ total: 0,
1949
+ currentPage: 1,
1950
+ pageSize: 10
1951
+ };
1952
+ var DEFAULT_KEY_CONFIG = {
1953
+ totalKey: "total",
1954
+ currentPageKey: "currentPage",
1955
+ pageSizeKey: "pageSize"
1956
+ };
1957
+ function createPagination() {
1958
+ var customParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1959
+ return __spreadValues(__spreadValues({}, DEFAULT_PAGINATION), customParams);
1960
+ }
1961
+ function createPaginationWithCustomKeys(pagination) {
1962
+ var keyConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1963
+ var config = __spreadValues(__spreadValues({}, DEFAULT_KEY_CONFIG), keyConfig);
1964
+ return _defineProperty(_defineProperty(_defineProperty({}, config.totalKey, pagination.total), config.currentPageKey, pagination.currentPage), config.pageSizeKey, pagination.pageSize);
1965
+ }
1966
+ function resetPagination(pagination) {
1967
+ pagination.total = 0;
1968
+ pagination.currentPage = 1;
1969
+ pagination.pageSize = 10;
1970
+ return pagination;
1971
+ }
1972
+ var PageTable_vue_vue_type_style_index_0_scoped_31eeea22_lang = "";
1973
+ var RESERVED_LISTENERS = ["add", "selection-change", "sort-change", "row-click", "size-change", "current-change", "link-click"];
1974
+ var _sfc_main$2 = {
1975
+ name: "NsTable",
1976
+ components: {
1977
+ SlotRenderer: SlotRenderer,
1978
+ TableColumn: TableColumn$1
1979
+ },
1980
+ inheritAttrs: false,
1981
+ props: {
1982
+ tableData: {
1983
+ type: Array,
1984
+ default: function _default() {
1985
+ return [];
1986
+ }
1987
+ },
1988
+ columns: {
1989
+ type: Array,
1990
+ default: function _default() {
1991
+ return [];
1992
+ }
1993
+ },
1994
+ actionButtons: {
1995
+ type: Array,
1996
+ default: function _default() {
1997
+ return [];
1998
+ }
1999
+ },
2000
+ showAddButton: {
2001
+ type: Boolean,
2002
+ default: true
2003
+ },
2004
+ addButtonText: {
2005
+ type: String,
2006
+ default: "新增"
2007
+ },
2008
+ showHeaderToolbar: {
2009
+ type: Boolean,
2010
+ default: true
2011
+ },
2012
+ showSelection: {
2013
+ type: Boolean,
2014
+ default: false
2015
+ },
2016
+ showIndex: {
2017
+ type: Boolean,
2018
+ default: false
2019
+ },
2020
+ indexWidth: {
2021
+ type: [String, Number],
2022
+ default: 60
2023
+ },
2024
+ indexAlign: {
2025
+ type: String,
2026
+ default: ""
2027
+ },
2028
+ indexHeaderAlign: {
2029
+ type: String,
2030
+ default: ""
2031
+ },
2032
+ border: {
2033
+ type: Boolean,
2034
+ default: true
2035
+ },
2036
+ stripe: {
2037
+ type: Boolean,
2038
+ default: false
2039
+ },
2040
+ height: {
2041
+ type: [String, Number],
2042
+ default: void 0
2043
+ },
2044
+ maxHeight: {
2045
+ type: [String, Number],
2046
+ default: void 0
2047
+ },
2048
+ autoHeight: {
2049
+ type: Boolean,
2050
+ default: true
2051
+ },
2052
+ rowKey: {
2053
+ type: [String, Function],
2054
+ default: void 0
2055
+ },
2056
+ defaultExpandAll: {
2057
+ type: Boolean,
2058
+ default: false
2059
+ },
2060
+ highlightCurrentRow: {
2061
+ type: Boolean,
2062
+ default: false
2063
+ },
2064
+ loading: {
2065
+ type: Boolean,
2066
+ default: false
2067
+ },
2068
+ showPagination: {
2069
+ type: Boolean,
2070
+ default: true
2071
+ },
2072
+ total: {
2073
+ type: Number,
2074
+ default: 0
2075
+ },
2076
+ currentPage: {
2077
+ type: Number,
2078
+ default: null
2079
+ },
2080
+ pageSize: {
2081
+ type: Number,
2082
+ default: null
2083
+ },
2084
+ pageSizes: {
2085
+ type: Array,
2086
+ default: function _default() {
2087
+ return [10, 20, 50, 100];
2088
+ }
2089
+ },
2090
+ paginationLayout: {
2091
+ type: String,
2092
+ default: "total, sizes, prev, pager, next, jumper"
2093
+ },
2094
+ pageNumberKey: {
2095
+ type: String,
2096
+ default: "currentPage"
2097
+ },
2098
+ pageSizeKey: {
2099
+ type: String,
2100
+ default: "pageSize"
2101
+ },
2102
+ pageTotalKey: {
2103
+ type: String,
2104
+ default: "total"
2105
+ },
2106
+ slotRenderers: {
2107
+ type: Object,
2108
+ default: function _default() {
2109
+ return {};
2110
+ }
2111
+ }
2112
+ },
2113
+ data: function data() {
2114
+ return {
2115
+ internalPagination: createPagination(),
2116
+ resizeObserver: null,
2117
+ layoutTimer: null
2118
+ };
2119
+ },
2120
+ computed: {
2121
+ currentPageModel: function currentPageModel() {
2122
+ return this.currentPage === null ? this.internalPagination.currentPage : this.currentPage;
2123
+ },
2124
+ pageSizeModel: function pageSizeModel() {
2125
+ return this.pageSize === null ? this.internalPagination.pageSize : this.pageSize;
2126
+ },
2127
+ mergedAttrs: function mergedAttrs() {
2128
+ return this.$attrs || {};
2129
+ },
2130
+ mergedListeners: function mergedListeners() {
2131
+ var listeners = __spreadValues({}, this.$listeners || {});
2132
+ RESERVED_LISTENERS.forEach(function (name) {
2133
+ return delete listeners[name];
2134
+ });
2135
+ return listeners;
2136
+ },
2137
+ resolvedHeight: function resolvedHeight() {
2138
+ if (this.height !== void 0 && this.height !== null && this.height !== "") {
2139
+ return this.height;
2140
+ }
2141
+ return void 0;
2142
+ },
2143
+ resolvedMaxHeight: function resolvedMaxHeight() {
2144
+ if (this.maxHeight !== void 0) {
2145
+ return this.maxHeight;
2146
+ }
2147
+ return void 0;
2148
+ }
2149
+ },
2150
+ watch: {
2151
+ currentPage: {
2152
+ handler: function handler(value) {
2153
+ if (value !== null) {
2154
+ this.internalPagination.currentPage = value;
2155
+ }
2156
+ },
2157
+ immediate: true
2158
+ },
2159
+ pageSize: {
2160
+ handler: function handler(value) {
2161
+ if (value !== null) {
2162
+ this.internalPagination.pageSize = value;
2163
+ }
2164
+ },
2165
+ immediate: true
2166
+ },
2167
+ tableData: {
2168
+ handler: function handler() {
2169
+ this.scheduleLayout();
2170
+ },
2171
+ deep: true,
2172
+ immediate: true
2173
+ },
2174
+ columns: {
2175
+ handler: function handler() {
2176
+ this.scheduleLayout();
2177
+ },
2178
+ deep: true,
2179
+ immediate: true
2180
+ }
2181
+ },
2182
+ mounted: function mounted() {
2183
+ this.scheduleLayout();
2184
+ this.initResizeObserver();
2185
+ },
2186
+ beforeDestroy: function beforeDestroy() {
2187
+ if (this.resizeObserver) {
2188
+ this.resizeObserver.disconnect();
2189
+ this.resizeObserver = null;
2190
+ }
2191
+ if (this.layoutTimer) {
2192
+ clearTimeout(this.layoutTimer);
2193
+ this.layoutTimer = null;
2194
+ }
2195
+ },
2196
+ methods: {
2197
+ scheduleLayout: function scheduleLayout() {
2198
+ var _this7 = this;
2199
+ this.$nextTick(function () {
2200
+ _this7.doLayout();
2201
+ if (_this7.layoutTimer) {
2202
+ clearTimeout(_this7.layoutTimer);
2203
+ }
2204
+ _this7.layoutTimer = setTimeout(function () {
2205
+ _this7.doLayout();
2206
+ _this7.layoutTimer = null;
2207
+ }, 50);
2208
+ });
2209
+ },
2210
+ initResizeObserver: function initResizeObserver() {
2211
+ var _this8 = this;
2212
+ if (typeof ResizeObserver === "undefined") {
2213
+ return;
2214
+ }
2215
+ this.resizeObserver = new ResizeObserver(function () {
2216
+ _this8.scheduleLayout();
2217
+ });
2218
+ if (this.$el) {
2219
+ this.resizeObserver.observe(this.$el);
2220
+ }
2221
+ if (this.$el && this.$el.parentElement) {
2222
+ this.resizeObserver.observe(this.$el.parentElement);
2223
+ }
2224
+ },
2225
+ handleAdd: function handleAdd() {
2226
+ this.$emit("add");
2227
+ },
2228
+ handleSelectionChange: function handleSelectionChange(selection) {
2229
+ this.$emit("selection-change", selection);
2230
+ },
2231
+ handleSortChange: function handleSortChange(sort) {
2232
+ this.$emit("sort-change", sort);
2233
+ },
2234
+ handleRowClick: function handleRowClick(row, column, event) {
2235
+ this.$emit("row-click", row, column, event);
2236
+ },
2237
+ handleSizeChange: function handleSizeChange(size) {
2238
+ this.internalPagination.pageSize = size;
2239
+ this.$emit("update:pageSize", size);
2240
+ this.$emit("size-change", size);
2241
+ },
2242
+ handleCurrentChange: function handleCurrentChange(page) {
2243
+ this.internalPagination.currentPage = page;
2244
+ this.$emit("update:currentPage", page);
2245
+ this.$emit("current-change", page);
2246
+ },
2247
+ handleLinkClick: function handleLinkClick(row, column) {
2248
+ this.$emit("link-click", row, column);
2249
+ },
2250
+ getIndex: function getIndex(index2) {
2251
+ if (!this.showPagination) {
2252
+ return index2 + 1;
2253
+ }
2254
+ var currentPage = Number(this.currentPageModel || 1);
2255
+ var pageSize = Number(this.pageSizeModel || 10);
2256
+ return (currentPage - 1) * pageSize + index2 + 1;
2257
+ },
2258
+ getSelectionRows: function getSelectionRows() {
2259
+ return this.$refs.tableRef && this.$refs.tableRef.selection ? this.$refs.tableRef.selection : [];
2260
+ },
2261
+ getSelectionKeys: function getSelectionKeys() {
2262
+ var _this9 = this;
2263
+ var rows = this.getSelectionRows();
2264
+ if (!this.rowKey) {
2265
+ return rows;
2266
+ }
2267
+ return rows.map(function (row) {
2268
+ return typeof _this9.rowKey === "function" ? _this9.rowKey(row) : row[_this9.rowKey];
2269
+ });
2270
+ },
2271
+ setSelectionRows: function setSelectionRows(rows) {
2272
+ var _this0 = this;
2273
+ if (!this.$refs.tableRef) return;
2274
+ this.$refs.tableRef.clearSelection();
2275
+ (rows || []).forEach(function (row) {
2276
+ _this0.$refs.tableRef.toggleRowSelection(row, true);
2277
+ });
2278
+ },
2279
+ setSelectionKeys: function setSelectionKeys(keys) {
2280
+ var _this1 = this;
2281
+ if (!this.$refs.tableRef || !this.rowKey) return;
2282
+ this.$refs.tableRef.clearSelection();
2283
+ (keys || []).forEach(function (key) {
2284
+ var row = (_this1.tableData || []).find(function (item) {
2285
+ return (typeof _this1.rowKey === "function" ? _this1.rowKey(item) : item[_this1.rowKey]) === key;
2286
+ });
2287
+ if (row) {
2288
+ _this1.$refs.tableRef.toggleRowSelection(row, true);
2289
+ }
2290
+ });
2291
+ },
2292
+ isRowSelected: function isRowSelected(row) {
2293
+ return this.getSelectionRows().includes(row);
2294
+ },
2295
+ isKeySelected: function isKeySelected(key) {
2296
+ return this.getSelectionKeys().includes(key);
2297
+ },
2298
+ clearSelection: function clearSelection() {
2299
+ if (this.$refs.tableRef) {
2300
+ this.$refs.tableRef.clearSelection();
2301
+ }
2302
+ },
2303
+ toggleRowSelection: function toggleRowSelection(row, selected) {
2304
+ if (this.$refs.tableRef) {
2305
+ this.$refs.tableRef.toggleRowSelection(row, selected);
2306
+ }
2307
+ },
2308
+ toggleAllSelection: function toggleAllSelection() {
2309
+ if (this.$refs.tableRef) {
2310
+ this.$refs.tableRef.toggleAllSelection();
2311
+ }
2312
+ },
2313
+ selectAll: function selectAll() {
2314
+ this.toggleAllSelection();
2315
+ },
2316
+ clearAllSelection: function clearAllSelection() {
2317
+ this.clearSelection();
2318
+ },
2319
+ clearSort: function clearSort() {
2320
+ this.$refs.tableRef && this.$refs.tableRef.clearSort && this.$refs.tableRef.clearSort();
2321
+ },
2322
+ clearFilter: function clearFilter(columnKey) {
2323
+ this.$refs.tableRef && this.$refs.tableRef.clearFilter && this.$refs.tableRef.clearFilter(columnKey);
2324
+ },
2325
+ doLayout: function doLayout() {
2326
+ this.$refs.tableRef && this.$refs.tableRef.doLayout && this.$refs.tableRef.doLayout();
2327
+ },
2328
+ sort: function sort(prop, order) {
2329
+ this.$refs.tableRef && this.$refs.tableRef.sort && this.$refs.tableRef.sort(prop, order);
2330
+ },
2331
+ resetPage: function resetPage() {
2332
+ this.internalPagination.currentPage = 1;
2333
+ this.$emit("update:currentPage", 1);
2334
+ },
2335
+ setPage: function setPage(page) {
2336
+ this.internalPagination.currentPage = page;
2337
+ this.$emit("update:currentPage", page);
2338
+ },
2339
+ setPageSize: function setPageSize(size) {
2340
+ this.internalPagination.pageSize = size;
2341
+ this.$emit("update:pageSize", size);
2342
+ },
2343
+ getPagination: function getPagination() {
2344
+ return _defineProperty(_defineProperty(_defineProperty({}, this.pageTotalKey, this.total), this.pageNumberKey, this.currentPageModel), this.pageSizeKey, this.pageSizeModel);
2345
+ },
2346
+ setPagination: function setPagination(pagination) {
2347
+ if (pagination.currentPage !== void 0) {
2348
+ this.setPage(pagination.currentPage);
2349
+ }
2350
+ if (pagination.pageSize !== void 0) {
2351
+ this.setPageSize(pagination.pageSize);
2352
+ }
2353
+ }
2354
+ }
2355
+ };
2356
+ var _sfc_render$2 = function render4() {
2357
+ var _vm = this,
2358
+ _c = _vm._self._c;
2359
+ return _c("div", {
2360
+ staticClass: "page-table"
2361
+ }, [_vm.showHeaderToolbar ? _c("div", {
2362
+ staticClass: "page-table__header"
2363
+ }, [_c("slot-renderer", {
2364
+ attrs: {
2365
+ "renderer": _vm.slotRenderers["header-left"],
2366
+ "scope": {
2367
+ tableData: _vm.tableData
2368
+ }
2369
+ }
2370
+ }), _c("div", {
2371
+ staticClass: "page-table__actions"
2372
+ }, [_c("slot-renderer", {
2373
+ attrs: {
2374
+ "renderer": _vm.slotRenderers["header-actions"],
2375
+ "scope": {
2376
+ tableData: _vm.tableData
2377
+ }
2378
+ }
2379
+ }), _vm.showAddButton && !_vm.slotRenderers["header-actions"] ? _c("el-button", {
2380
+ attrs: {
2381
+ "type": "primary",
2382
+ "size": "small"
2383
+ },
2384
+ on: {
2385
+ "click": _vm.handleAdd
2386
+ }
2387
+ }, [_vm._v(" " + _vm._s(_vm.addButtonText) + " ")]) : _vm._e()], 1)], 1) : _vm._e(), _c("div", {
2388
+ staticClass: "page-table__main"
2389
+ }, [_c("el-table", _vm._g(_vm._b({
2390
+ directives: [{
2391
+ name: "loading",
2392
+ rawName: "v-loading",
2393
+ value: _vm.loading,
2394
+ expression: "loading"
2395
+ }],
2396
+ ref: "tableRef",
2397
+ class: ["page-table__table", {
2398
+ "page-table__table--no-border": !_vm.border
2399
+ }],
2400
+ attrs: {
2401
+ "data": _vm.tableData,
2402
+ "border": _vm.border,
2403
+ "stripe": _vm.stripe,
2404
+ "height": _vm.resolvedHeight,
2405
+ "max-height": _vm.resolvedMaxHeight,
2406
+ "row-key": _vm.rowKey,
2407
+ "default-expand-all": _vm.defaultExpandAll,
2408
+ "highlight-current-row": _vm.highlightCurrentRow
2409
+ },
2410
+ on: {
2411
+ "selection-change": _vm.handleSelectionChange,
2412
+ "sort-change": _vm.handleSortChange,
2413
+ "row-click": _vm.handleRowClick
2414
+ }
2415
+ }, "el-table", _vm.mergedAttrs, false), _vm.mergedListeners), [_vm.showSelection ? _c("el-table-column", {
2416
+ attrs: {
2417
+ "type": "selection",
2418
+ "width": "55",
2419
+ "reserve-selection": !!_vm.rowKey
2420
+ }
2421
+ }) : _vm._e(), _vm.showIndex ? _c("el-table-column", {
2422
+ attrs: {
2423
+ "type": "index",
2424
+ "label": "序号",
2425
+ "width": _vm.indexWidth,
2426
+ "index": _vm.getIndex,
2427
+ "align": _vm.indexAlign,
2428
+ "header-align": _vm.indexHeaderAlign || _vm.indexAlign
2429
+ }
2430
+ }) : _vm._e(), _vm._l(_vm.columns, function (column, index2) {
2431
+ return _c("table-column", {
2432
+ key: column.prop || column.label || index2,
2433
+ attrs: {
2434
+ "column": column,
2435
+ "slot-renderers": _vm.slotRenderers
2436
+ },
2437
+ on: {
2438
+ "link-click": _vm.handleLinkClick
2439
+ }
2440
+ });
2441
+ }), _c("template", {
2442
+ slot: "empty"
2443
+ }, [_vm.slotRenderers.empty ? _c("slot-renderer", {
2444
+ attrs: {
2445
+ "renderer": _vm.slotRenderers.empty,
2446
+ "scope": {
2447
+ tableData: _vm.tableData
2448
+ }
2449
+ }
2450
+ }) : _c("div", {
2451
+ staticClass: "page-table__empty"
2452
+ }, [_vm._v("暂无数据")])], 1)], 2)], 1), _vm.showPagination ? _c("div", {
2453
+ staticClass: "page-table__pagination"
2454
+ }, [_c("el-pagination", {
2455
+ attrs: {
2456
+ "background": "",
2457
+ "current-page": _vm.currentPageModel,
2458
+ "page-size": _vm.pageSizeModel,
2459
+ "page-sizes": _vm.pageSizes,
2460
+ "total": _vm.total,
2461
+ "layout": _vm.paginationLayout
2462
+ },
2463
+ on: {
2464
+ "size-change": _vm.handleSizeChange,
2465
+ "current-change": _vm.handleCurrentChange
2466
+ }
2467
+ })], 1) : _vm._e()]);
2468
+ };
2469
+ var _sfc_staticRenderFns$2 = [];
2470
+ var __component__$2 = /* @__PURE__ */normalizeComponent(_sfc_main$2, _sfc_render$2, _sfc_staticRenderFns$2, false, null, "31eeea22", null, null);
2471
+ var NsTable = __component__$2.exports;
2472
+ var PageContainer_vue_vue_type_style_index_0_scoped_1c664e81_lang = "";
2473
+ var _sfc_main$1 = {
2474
+ name: "NsTableContainer",
2475
+ components: {
2476
+ PageSearch: NsSearch,
2477
+ PageTable: NsTable
2478
+ },
2479
+ props: {
2480
+ showSearch: {
2481
+ type: Boolean,
2482
+ default: true
2483
+ },
2484
+ externalSearchParams: {
2485
+ type: Object,
2486
+ default: function _default() {
2487
+ return {};
2488
+ }
2489
+ },
2490
+ searchItems: {
2491
+ type: Array,
2492
+ default: function _default() {
2493
+ return [];
2494
+ }
2495
+ },
2496
+ tableData: {
2497
+ type: Array,
2498
+ default: function _default() {
2499
+ return [];
2500
+ }
2501
+ },
2502
+ columns: {
2503
+ type: Array,
2504
+ default: function _default() {
2505
+ return [];
2506
+ }
2507
+ },
2508
+ actionButtons: {
2509
+ type: Array,
2510
+ default: function _default() {
2511
+ return [];
2512
+ }
2513
+ },
2514
+ total: {
2515
+ type: Number,
2516
+ default: 0
2517
+ },
2518
+ currentPage: {
2519
+ type: Number,
2520
+ default: null
2521
+ },
2522
+ pageSize: {
2523
+ type: Number,
2524
+ default: null
2525
+ },
2526
+ pageNumberKey: {
2527
+ type: String,
2528
+ default: "currentPage"
2529
+ },
2530
+ pageSizeKey: {
2531
+ type: String,
2532
+ default: "pageSize"
2533
+ },
2534
+ pageTotalKey: {
2535
+ type: String,
2536
+ default: "total"
2537
+ },
2538
+ searchProps: {
2539
+ type: Object,
2540
+ default: function _default() {
2541
+ return {};
2542
+ }
2543
+ },
2544
+ enterTrigger: {
2545
+ type: Boolean,
2546
+ default: true
2547
+ },
2548
+ tableProps: {
2549
+ type: Object,
2550
+ default: function _default() {
2551
+ return {};
2552
+ }
2553
+ },
2554
+ loadData: {
2555
+ type: Function,
2556
+ default: null
2557
+ }
2558
+ },
2559
+ data: function data() {
2560
+ return {
2561
+ internalPagination: createPagination(),
2562
+ pendingSelectionKeys: /* @__PURE__ */new Set(),
2563
+ selectionRowMap: {},
2564
+ isSyncingSelection: false
2565
+ };
2566
+ },
2567
+ computed: {
2568
+ currentPageModel: function currentPageModel() {
2569
+ return this.currentPage === null ? this.internalPagination.currentPage : this.currentPage;
2570
+ },
2571
+ pageSizeModel: function pageSizeModel() {
2572
+ return this.pageSize === null ? this.internalPagination.pageSize : this.pageSize;
2573
+ },
2574
+ currentRowKey: function currentRowKey() {
2575
+ return this.tableProps && this.tableProps.rowKey;
2576
+ }
2577
+ },
2578
+ watch: {
2579
+ currentPage: {
2580
+ handler: function handler(value) {
2581
+ if (value !== null) {
2582
+ this.internalPagination.currentPage = value;
2583
+ }
2584
+ },
2585
+ immediate: true
2586
+ },
2587
+ pageSize: {
2588
+ handler: function handler(value) {
2589
+ if (value !== null) {
2590
+ this.internalPagination.pageSize = value;
2591
+ }
2592
+ },
2593
+ immediate: true
2594
+ },
2595
+ tableData: {
2596
+ handler: function handler() {
2597
+ var _this10 = this;
2598
+ this.$nextTick(function () {
2599
+ _this10.syncSelectionToCurrentPage();
2600
+ });
2601
+ },
2602
+ deep: true,
2603
+ immediate: true
2604
+ }
2605
+ },
2606
+ methods: {
2607
+ getRowKey: function getRowKey(row) {
2608
+ if (!this.currentRowKey) return row;
2609
+ return typeof this.currentRowKey === "function" ? this.currentRowKey(row) : row[this.currentRowKey];
2610
+ },
2611
+ resetSelectionState: function resetSelectionState() {
2612
+ this.pendingSelectionKeys = /* @__PURE__ */new Set();
2613
+ this.selectionRowMap = {};
2614
+ this.$refs.tableRef && this.$refs.tableRef.clearSelection && this.$refs.tableRef.clearSelection();
2615
+ },
2616
+ syncSelectionToCurrentPage: function syncSelectionToCurrentPage() {
2617
+ var _this11 = this;
2618
+ if (!this.currentRowKey || !this.$refs.tableRef) {
2619
+ return;
2620
+ }
2621
+ this.isSyncingSelection = true;
2622
+ this.$refs.tableRef.clearSelection();
2623
+ (this.tableData || []).forEach(function (row) {
2624
+ var key = _this11.getRowKey(row);
2625
+ if (_this11.pendingSelectionKeys.has(key)) {
2626
+ _this11.$set(_this11.selectionRowMap, key, row);
2627
+ _this11.$refs.tableRef.toggleRowSelection(row, true);
2628
+ }
2629
+ });
2630
+ this.$nextTick(function () {
2631
+ _this11.isSyncingSelection = false;
2632
+ });
2633
+ },
2634
+ handleSearch: function handleSearch(params) {
2635
+ this.resetSelectionState();
2636
+ if (params && params._resetPage) {
2637
+ var _a = params,
2638
+ _resetPage = _a._resetPage,
2639
+ searchParams = __objRest(_a, ["_resetPage"]);
2640
+ this.internalPagination.currentPage = 1;
2641
+ this.$emit("update:currentPage", 1);
2642
+ this.$emit("search", searchParams);
2643
+ return;
2644
+ }
2645
+ this.$emit("search", params);
2646
+ },
2647
+ handleReset: function handleReset() {
2648
+ this.resetSelectionState();
2649
+ this.$emit("reset");
2650
+ },
2651
+ handleAdd: function handleAdd() {
2652
+ this.$emit("add");
2653
+ },
2654
+ handleSizeChange: function handleSizeChange(size) {
2655
+ this.internalPagination.pageSize = size;
2656
+ this.$emit("update:pageSize", size);
2657
+ this.$emit("size-change", size);
2658
+ this.$emit("page-change", {
2659
+ currentPage: this.currentPageModel,
2660
+ pageSize: size
2661
+ });
2662
+ if (this.loadData) {
2663
+ this.loadData();
2664
+ }
2665
+ },
2666
+ handleCurrentChange: function handleCurrentChange(page) {
2667
+ this.internalPagination.currentPage = page;
2668
+ this.$emit("update:currentPage", page);
2669
+ this.$emit("current-change", page);
2670
+ this.$emit("page-change", {
2671
+ currentPage: page,
2672
+ pageSize: this.pageSizeModel
2673
+ });
2674
+ if (this.loadData) {
2675
+ this.loadData();
2676
+ }
2677
+ },
2678
+ handleSelectionChange: function handleSelectionChange(selection) {
2679
+ var _this12 = this;
2680
+ if (this.isSyncingSelection) {
2681
+ return;
2682
+ }
2683
+ if (!this.currentRowKey) {
2684
+ this.$emit("selection-change", selection);
2685
+ return;
2686
+ }
2687
+ var currentPageKeys = (this.tableData || []).map(function (row) {
2688
+ return _this12.getRowKey(row);
2689
+ });
2690
+ currentPageKeys.forEach(function (key) {
2691
+ _this12.pendingSelectionKeys.delete(key);
2692
+ _this12.$delete(_this12.selectionRowMap, key);
2693
+ });
2694
+ (selection || []).forEach(function (row) {
2695
+ var key = _this12.getRowKey(row);
2696
+ _this12.pendingSelectionKeys.add(key);
2697
+ _this12.$set(_this12.selectionRowMap, key, row);
2698
+ });
2699
+ this.$emit("selection-change", Object.values(this.selectionRowMap));
2700
+ },
2701
+ handleSortChange: function handleSortChange(sort) {
2702
+ this.$emit("sort-change", sort);
2703
+ },
2704
+ handleRowClick: function handleRowClick(row, column, event) {
2705
+ this.$emit("row-click", row, column, event);
2706
+ },
2707
+ handleLinkClick: function handleLinkClick(row, column) {
2708
+ this.$emit("link-click", row, column);
2709
+ },
2710
+ initSearchAndLoad: function initSearchAndLoad() {
2711
+ var _this13 = this;
2712
+ this.$nextTick(function () {
2713
+ if (_this13.showSearch && _this13.$refs.searchRef) {
2714
+ _this13.$emit("search", _this13.$refs.searchRef.getFormData());
2715
+ return;
2716
+ }
2717
+ if (_this13.loadData) {
2718
+ _this13.loadData();
2719
+ }
2720
+ });
2721
+ },
2722
+ getSearchFormData: function getSearchFormData() {
2723
+ return this.$refs.searchRef ? this.$refs.searchRef.getFormData() : {};
2724
+ },
2725
+ setSearchFormData: function setSearchFormData(data) {
2726
+ this.$refs.searchRef && this.$refs.searchRef.setFormData(data);
2727
+ },
2728
+ resetSearchForm: function resetSearchForm() {
2729
+ this.$refs.searchRef && this.$refs.searchRef.resetForm();
2730
+ },
2731
+ validateSearchForm: function validateSearchForm() {
2732
+ return this.$refs.searchRef ? this.$refs.searchRef.validate() : Promise.resolve(true);
2733
+ },
2734
+ getPagination: function getPagination() {
2735
+ return _defineProperty(_defineProperty(_defineProperty({}, this.pageTotalKey, this.total), this.pageNumberKey, this.currentPageModel), this.pageSizeKey, this.pageSizeModel);
2736
+ },
2737
+ getSelectionRows: function getSelectionRows() {
2738
+ var _a, _b;
2739
+ return this.currentRowKey ? Object.values(this.selectionRowMap) : ((_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.getSelectionRows) == null ? void 0 : _b.call(_a)) || [];
2740
+ },
2741
+ getSelectionKeys: function getSelectionKeys() {
2742
+ var _a, _b;
2743
+ return this.currentRowKey ? Array.from(this.pendingSelectionKeys) : ((_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.getSelectionKeys) == null ? void 0 : _b.call(_a)) || [];
2744
+ },
2745
+ setSelectionRows: function setSelectionRows(rows) {
2746
+ var _this14 = this;
2747
+ if (!this.currentRowKey) {
2748
+ this.$refs.tableRef && this.$refs.tableRef.setSelectionRows(rows);
2749
+ return;
2750
+ }
2751
+ this.pendingSelectionKeys = /* @__PURE__ */new Set();
2752
+ this.selectionRowMap = {};
2753
+ (rows || []).forEach(function (row) {
2754
+ var key = _this14.getRowKey(row);
2755
+ _this14.pendingSelectionKeys.add(key);
2756
+ _this14.$set(_this14.selectionRowMap, key, row);
2757
+ });
2758
+ this.syncSelectionToCurrentPage();
2759
+ },
2760
+ setSelectionKeys: function setSelectionKeys(keys) {
2761
+ var _this15 = this;
2762
+ if (!this.currentRowKey) {
2763
+ this.$refs.tableRef && this.$refs.tableRef.setSelectionKeys(keys);
2764
+ return;
2765
+ }
2766
+ this.pendingSelectionKeys = new Set(keys || []);
2767
+ (this.tableData || []).forEach(function (row) {
2768
+ var key = _this15.getRowKey(row);
2769
+ if (_this15.pendingSelectionKeys.has(key)) {
2770
+ _this15.$set(_this15.selectionRowMap, key, row);
2771
+ }
2772
+ });
2773
+ this.syncSelectionToCurrentPage();
2774
+ },
2775
+ clearAllSelection: function clearAllSelection() {
2776
+ this.resetSelectionState();
2777
+ },
2778
+ selectAll: function selectAll() {
2779
+ var _this16 = this;
2780
+ if (!this.$refs.tableRef) return;
2781
+ if (!this.currentRowKey) {
2782
+ this.$refs.tableRef.selectAll();
2783
+ return;
2784
+ }
2785
+ (this.tableData || []).forEach(function (row) {
2786
+ var key = _this16.getRowKey(row);
2787
+ _this16.pendingSelectionKeys.add(key);
2788
+ _this16.$set(_this16.selectionRowMap, key, row);
2789
+ });
2790
+ this.$refs.tableRef.setSelectionRows(this.tableData);
2791
+ },
2792
+ isRowSelected: function isRowSelected(row) {
2793
+ var _a, _b;
2794
+ 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);
2795
+ },
2796
+ isKeySelected: function isKeySelected(key) {
2797
+ var _a, _b;
2798
+ return this.currentRowKey ? this.pendingSelectionKeys.has(key) : (_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.isKeySelected) == null ? void 0 : _b.call(_a, key);
2799
+ }
2800
+ }
2801
+ };
2802
+ var _sfc_render$1 = function render5() {
2803
+ var _vm = this,
2804
+ _c = _vm._self._c;
2805
+ return _c("div", {
2806
+ staticClass: "page-container"
2807
+ }, [_vm.showSearch ? _c("page-search", _vm._b({
2808
+ ref: "searchRef",
2809
+ attrs: {
2810
+ "items": _vm.searchItems,
2811
+ "external-params": _vm.externalSearchParams,
2812
+ "enter-trigger": _vm.enterTrigger,
2813
+ "slot-renderers": _vm.$scopedSlots
2814
+ },
2815
+ on: {
2816
+ "search": _vm.handleSearch,
2817
+ "reset": _vm.handleReset
2818
+ }
2819
+ }, "page-search", _vm.searchProps, false)) : _vm._e(), _vm._t("extend"), _c("page-table", _vm._b({
2820
+ ref: "tableRef",
2821
+ attrs: {
2822
+ "table-data": _vm.tableData,
2823
+ "columns": _vm.columns,
2824
+ "action-buttons": _vm.actionButtons,
2825
+ "total": _vm.total,
2826
+ "current-page": _vm.currentPageModel,
2827
+ "page-size": _vm.pageSizeModel,
2828
+ "page-number-key": _vm.pageNumberKey,
2829
+ "page-size-key": _vm.pageSizeKey,
2830
+ "page-total-key": _vm.pageTotalKey,
2831
+ "slot-renderers": _vm.$scopedSlots
2832
+ },
2833
+ on: {
2834
+ "add": _vm.handleAdd,
2835
+ "selection-change": _vm.handleSelectionChange,
2836
+ "sort-change": _vm.handleSortChange,
2837
+ "row-click": _vm.handleRowClick,
2838
+ "size-change": _vm.handleSizeChange,
2839
+ "current-change": _vm.handleCurrentChange,
2840
+ "link-click": _vm.handleLinkClick
2841
+ }
2842
+ }, "page-table", _vm.tableProps, false))], 2);
2843
+ };
2844
+ var _sfc_staticRenderFns$1 = [];
2845
+ var __component__$1 = /* @__PURE__ */normalizeComponent(_sfc_main$1, _sfc_render$1, _sfc_staticRenderFns$1, false, null, "1c664e81", null, null);
2846
+ var NsTableContainer = __component__$1.exports;
2847
+ [NsTableContainer, NsSearch, NsTable].forEach(function (component) {
2848
+ component.install = function install3(Vue2) {
2849
+ Vue2.component(component.name, component);
2850
+ };
2851
+ });
2852
+ var NsDialog_vue_vue_type_style_index_0_scoped_19b1fbf8_lang = "";
2853
+ var _sfc_main = {
2854
+ name: "NsDialogComponent",
2855
+ props: {
2856
+ className: {
2857
+ type: String,
2858
+ default: ""
2859
+ },
2860
+ title: {
2861
+ type: String,
2862
+ default: ""
2863
+ },
2864
+ width: {
2865
+ type: [Number, String],
2866
+ default: 500
2867
+ },
2868
+ height: {
2869
+ type: [Number, String],
2870
+ default: ""
2871
+ },
2872
+ modal: {
2873
+ type: Boolean,
2874
+ default: true
2875
+ },
2876
+ dialogPadding: {
2877
+ type: [Number, String, Array],
2878
+ default: -1
2879
+ },
2880
+ modalColor: {
2881
+ type: String,
2882
+ default: "rgba(0, 0, 0, 0.45)"
2883
+ },
2884
+ closeOnClickModal: {
2885
+ type: Boolean,
2886
+ default: true
2887
+ },
2888
+ dom: {
2889
+ type: [Object, Function],
2890
+ default: null
2891
+ },
2892
+ option: {
2893
+ type: Object,
2894
+ default: function _default() {
2895
+ return {};
2896
+ }
2897
+ },
2898
+ events: {
2899
+ type: Object,
2900
+ default: function _default() {
2901
+ return {};
2902
+ }
2903
+ },
2904
+ domCompleted: {
2905
+ type: Function,
2906
+ default: null
2907
+ },
2908
+ headerDom: {
2909
+ type: [Object, Function],
2910
+ default: null
2911
+ },
2912
+ headerOption: {
2913
+ type: Object,
2914
+ default: function _default() {
2915
+ return {};
2916
+ }
2917
+ },
2918
+ headerEvents: {
2919
+ type: Object,
2920
+ default: function _default() {
2921
+ return {};
2922
+ }
2923
+ },
2924
+ showFooter: {
2925
+ type: Boolean,
2926
+ default: true
2927
+ },
2928
+ footerDom: {
2929
+ type: [Object, Function],
2930
+ default: null
2931
+ },
2932
+ footerOption: {
2933
+ type: Object,
2934
+ default: function _default() {
2935
+ return {};
2936
+ }
2937
+ },
2938
+ footerTitle: {
2939
+ type: Object,
2940
+ default: function _default() {
2941
+ return {
2942
+ close: "取消",
2943
+ confirm: "确定"
2944
+ };
2945
+ }
2946
+ },
2947
+ footerEvents: {
2948
+ type: Object,
2949
+ default: function _default() {
2950
+ return {};
2951
+ }
2952
+ },
2953
+ footerButtonReverse: {
2954
+ type: Boolean,
2955
+ default: false
2956
+ },
2957
+ footerCloseOnly: {
2958
+ type: Boolean,
2959
+ default: false
2960
+ },
2961
+ enterTrigger: {
2962
+ type: Boolean,
2963
+ default: false
2964
+ },
2965
+ immediately: {
2966
+ type: Boolean,
2967
+ default: false
2968
+ },
2969
+ close: {
2970
+ type: Function,
2971
+ default: null
2972
+ },
2973
+ closed: {
2974
+ type: Function,
2975
+ default: null
2976
+ },
2977
+ sizeChange: {
2978
+ type: Function,
2979
+ default: null
2980
+ },
2981
+ draggable: {
2982
+ type: Boolean,
2983
+ default: false
2984
+ },
2985
+ confirm: {
2986
+ type: Function,
2987
+ default: null
2988
+ },
2989
+ x: {
2990
+ type: [Number, String],
2991
+ default: null
2992
+ },
2993
+ y: {
2994
+ type: [Number, String],
2995
+ default: null
2996
+ },
2997
+ maxSize: {
2998
+ type: Function,
2999
+ default: null
3000
+ },
3001
+ dialogInstance: {
3002
+ type: Object,
3003
+ default: null
3004
+ },
3005
+ containerId: {
3006
+ type: String,
3007
+ default: ""
3008
+ }
3009
+ },
3010
+ data: function data() {
3011
+ return {
3012
+ visible: false,
3013
+ currentTitle: this.title,
3014
+ currentOption: __spreadValues({}, this.option),
3015
+ currentWidth: this.width,
3016
+ currentHeight: this.height,
3017
+ currentX: this.x,
3018
+ currentY: this.y,
3019
+ footerLoading: false,
3020
+ isMaximized: false,
3021
+ originalSize: {
3022
+ width: this.width,
3023
+ height: this.height,
3024
+ x: this.x,
3025
+ y: this.y
3026
+ },
3027
+ dragContext: null,
3028
+ domCompletedCalled: false
3029
+ };
3030
+ },
3031
+ computed: {
3032
+ normalizedWidth: function normalizedWidth() {
3033
+ return this.normalizeSize(this.currentWidth || this.width || 500);
3034
+ },
3035
+ bodyStyle: function bodyStyle() {
3036
+ var padding = this.resolvePadding();
3037
+ if (!this.currentHeight) {
3038
+ return {
3039
+ padding: padding,
3040
+ minHeight: "auto",
3041
+ maxHeight: "none",
3042
+ overflow: "auto"
3043
+ };
3044
+ }
3045
+ return {
3046
+ padding: padding,
3047
+ height: "100%",
3048
+ minHeight: 0,
3049
+ overflow: "auto",
3050
+ flex: "1 1 auto"
3051
+ };
3052
+ },
3053
+ dialogCustomClass: function dialogCustomClass() {
3054
+ return ["ns-dialog-plus", this.className, this.hasAbsolutePosition ? "ns-dialog-plus--absolute" : ""].filter(Boolean).join(" ");
3055
+ },
3056
+ modalClassName: function modalClassName() {
3057
+ return "ns-dialog-plus-modal ns-dialog-plus-modal--".concat(this.containerId);
3058
+ },
3059
+ resolvedDom: function resolvedDom() {
3060
+ return this.resolveComponent(this.dom);
3061
+ },
3062
+ resolvedHeaderDom: function resolvedHeaderDom() {
3063
+ return this.resolveComponent(this.headerDom);
3064
+ },
3065
+ resolvedFooterDom: function resolvedFooterDom() {
3066
+ return this.resolveComponent(this.footerDom);
3067
+ },
3068
+ footerButtonText: function footerButtonText() {
3069
+ var _a, _b;
3070
+ return {
3071
+ close: ((_a = this.footerTitle) == null ? void 0 : _a.close) || "取消",
3072
+ confirm: ((_b = this.footerTitle) == null ? void 0 : _b.confirm) || "确定"
3073
+ };
3074
+ },
3075
+ showMaximizeButton: function showMaximizeButton() {
3076
+ return typeof this.maxSize === "function";
3077
+ },
3078
+ hasAbsolutePosition: function hasAbsolutePosition() {
3079
+ return this.currentX !== null || this.currentY !== null;
3080
+ }
3081
+ },
3082
+ watch: {
3083
+ option: {
3084
+ handler: function handler(value) {
3085
+ this.currentOption = __spreadValues({}, value);
3086
+ },
3087
+ deep: true
3088
+ },
3089
+ title: function title(value) {
3090
+ this.currentTitle = value;
3091
+ },
3092
+ width: function width(value) {
3093
+ if (!this.isMaximized) this.currentWidth = value;
3094
+ },
3095
+ height: function height(value) {
3096
+ if (!this.isMaximized) this.currentHeight = value;
3097
+ },
3098
+ x: function x(value) {
3099
+ if (!this.isMaximized) this.currentX = value;
3100
+ },
3101
+ y: function y(value) {
3102
+ if (!this.isMaximized) this.currentY = value;
3103
+ },
3104
+ visible: function visible() {
3105
+ var _this17 = this;
3106
+ this.$nextTick(function () {
3107
+ _this17.applyDialogLayout();
3108
+ _this17.syncDialogInstance();
3109
+ _this17.triggerDomCompleted();
3110
+ });
3111
+ }
3112
+ },
3113
+ mounted: function mounted() {
3114
+ var _this18 = this;
3115
+ loadCssVars();
3116
+ this.visible = true;
3117
+ this.updateModalStyle();
3118
+ this.syncDialogInstance();
3119
+ this.$nextTick(function () {
3120
+ _this18.applyDialogLayout();
3121
+ _this18.triggerDomCompleted();
3122
+ });
3123
+ document.addEventListener("keydown", this.handleKeydown);
3124
+ window.addEventListener("resize", this.applyDialogLayout);
3125
+ },
3126
+ updated: function updated() {
3127
+ var _this19 = this;
3128
+ this.syncDialogInstance();
3129
+ this.triggerDomCompleted();
3130
+ this.$nextTick(function () {
3131
+ _this19.applyDialogLayout();
3132
+ });
3133
+ },
3134
+ beforeDestroy: function beforeDestroy() {
3135
+ document.removeEventListener("keydown", this.handleKeydown);
3136
+ window.removeEventListener("resize", this.applyDialogLayout);
3137
+ this.removeDragListeners();
3138
+ this.removeModalStyle();
3139
+ },
3140
+ methods: {
3141
+ notifySizeChange: function notifySizeChange() {
3142
+ var payload = {
3143
+ width: this.currentWidth,
3144
+ height: this.currentHeight,
3145
+ x: this.currentX,
3146
+ y: this.currentY,
3147
+ isMaximized: this.isMaximized
3148
+ };
3149
+ if (typeof this.sizeChange === "function") {
3150
+ this.sizeChange(payload);
3151
+ }
3152
+ this.$emit("sizeChange", payload);
3153
+ var content = this.$refs.contentRef;
3154
+ if (content && typeof content.doLayout === "function") {
3155
+ this.$nextTick(function () {
3156
+ return content.doLayout();
3157
+ });
3158
+ }
3159
+ },
3160
+ normalizeSize: function normalizeSize(value) {
3161
+ if (value === null || value === void 0 || value === "") return "";
3162
+ if (typeof value === "number" && isFinite(value)) return "".concat(value, "px");
3163
+ var str = String(value).trim();
3164
+ if (str === "") return "";
3165
+ return Number.isNaN(Number(str)) ? str : "".concat(Number(str), "px");
3166
+ },
3167
+ resolvePadding: function resolvePadding() {
3168
+ var _this20 = this;
3169
+ if (Array.isArray(this.dialogPadding)) {
3170
+ return this.dialogPadding.map(function (item) {
3171
+ return _this20.normalizeSize(item);
3172
+ }).join(" ");
3173
+ }
3174
+ if (this.dialogPadding === -1 || this.dialogPadding === "-1") {
3175
+ return "16px 20px";
3176
+ }
3177
+ return this.normalizeSize(this.dialogPadding);
3178
+ },
3179
+ resolveComponent: function resolveComponent(source) {
3180
+ if (!source) return null;
3181
+ if (source.default) {
3182
+ return source.default;
3183
+ }
3184
+ if (typeof source.then === "function") {
3185
+ return function () {
3186
+ return source;
3187
+ };
3188
+ }
3189
+ return source;
3190
+ },
3191
+ mergeEvents: function mergeEvents() {
3192
+ var _this21 = this;
3193
+ var listeners = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3194
+ return __spreadProps(__spreadValues({}, listeners), {
3195
+ close: function close() {
3196
+ return _this21.closeDialog();
3197
+ }
3198
+ });
3199
+ },
3200
+ resolveDialogElement: function resolveDialogElement() {
3201
+ return this.$el && this.$el.querySelector ? this.$el.querySelector(".el-dialog") : null;
3202
+ },
3203
+ resolveWrapperElement: function resolveWrapperElement() {
3204
+ return this.$el && this.$el.querySelector ? this.$el.querySelector(".el-dialog__wrapper") : null;
3205
+ },
3206
+ applyDialogLayout: function applyDialogLayout() {
3207
+ var emitSizeChange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
3208
+ var dialog = this.resolveDialogElement();
3209
+ if (!dialog) return;
3210
+ var wrapper = this.resolveWrapperElement();
3211
+ if (wrapper) {
3212
+ wrapper.style.display = "";
3213
+ wrapper.style.alignItems = "";
3214
+ wrapper.style.justifyContent = "";
3215
+ }
3216
+ if (this.currentHeight) {
3217
+ dialog.style.height = this.normalizeSize(this.currentHeight);
3218
+ dialog.style.display = "flex";
3219
+ dialog.style.flexDirection = "column";
3220
+ } else {
3221
+ dialog.style.height = "";
3222
+ }
3223
+ var dialogHeight = dialog.getBoundingClientRect().height;
3224
+ var centeredTop = dialogHeight >= window.innerHeight ? 20 : Math.max((window.innerHeight - dialogHeight) / 2, 0);
3225
+ if (this.hasAbsolutePosition) {
3226
+ dialog.style.position = "fixed";
3227
+ dialog.style.margin = "0";
3228
+ if (this.currentX !== null) {
3229
+ dialog.style.left = this.normalizeSize(this.currentX);
3230
+ } else {
3231
+ dialog.style.left = "";
3232
+ }
3233
+ if (this.currentY !== null) {
3234
+ dialog.style.top = this.normalizeSize(this.currentY);
3235
+ } else {
3236
+ dialog.style.top = "".concat(centeredTop, "px");
3237
+ }
3238
+ } else {
3239
+ dialog.style.position = "relative";
3240
+ dialog.style.left = "";
3241
+ dialog.style.top = "".concat(centeredTop, "px");
3242
+ dialog.style.margin = "0 auto";
3243
+ }
3244
+ if (emitSizeChange) {
3245
+ this.notifySizeChange();
3246
+ }
3247
+ },
3248
+ updateModalStyle: function updateModalStyle() {
3249
+ if (!this.containerId) return;
3250
+ var styleEl = document.getElementById("style-".concat(this.containerId));
3251
+ if (!styleEl) {
3252
+ styleEl = document.createElement("style");
3253
+ styleEl.id = "style-".concat(this.containerId);
3254
+ document.head.appendChild(styleEl);
3255
+ }
3256
+ styleEl.textContent = ".".concat(this.modalClassName.replace(/ /g, "."), " { background-color: ").concat(this.modalColor, " !important; }");
3257
+ },
3258
+ removeModalStyle: function removeModalStyle() {
3259
+ if (!this.containerId) return;
3260
+ var styleEl = document.getElementById("style-".concat(this.containerId));
3261
+ if (styleEl && styleEl.parentNode) {
3262
+ styleEl.parentNode.removeChild(styleEl);
3263
+ }
3264
+ },
3265
+ syncDialogInstance: function syncDialogInstance() {
3266
+ var _this22 = this;
3267
+ if (!this.dialogInstance) return;
3268
+ this.dialogInstance.domRef = this.$refs.contentRef || null;
3269
+ this.dialogInstance.updateOption = function () {
3270
+ var newOption = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3271
+ if (Object.prototype.hasOwnProperty.call(newOption, "title")) {
3272
+ _this22.currentTitle = newOption.title;
3273
+ }
3274
+ if (Object.prototype.hasOwnProperty.call(newOption, "width")) {
3275
+ _this22.currentWidth = newOption.width;
3276
+ }
3277
+ if (Object.prototype.hasOwnProperty.call(newOption, "height")) {
3278
+ _this22.currentHeight = newOption.height;
3279
+ }
3280
+ if (Object.prototype.hasOwnProperty.call(newOption, "x")) {
3281
+ _this22.currentX = newOption.x;
3282
+ }
3283
+ if (Object.prototype.hasOwnProperty.call(newOption, "y")) {
3284
+ _this22.currentY = newOption.y;
3285
+ }
3286
+ var mergedOption = __spreadValues({}, newOption);
3287
+ delete mergedOption.title;
3288
+ delete mergedOption.width;
3289
+ delete mergedOption.height;
3290
+ delete mergedOption.x;
3291
+ delete mergedOption.y;
3292
+ _this22.currentOption = __spreadValues(__spreadValues({}, _this22.currentOption), mergedOption);
3293
+ };
3294
+ this.dialogInstance.callMethod = function (methodName) {
3295
+ var target = _this22.$refs.contentRef;
3296
+ if (target && typeof target[methodName] === "function") {
3297
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
3298
+ args[_key3 - 1] = arguments[_key3];
3299
+ }
3300
+ return target[methodName].apply(target, args);
3301
+ }
3302
+ return void 0;
3303
+ };
3304
+ this.dialogInstance.close = function () {
3305
+ return _this22.closeDialog();
3306
+ };
3307
+ },
3308
+ triggerDomCompleted: function triggerDomCompleted() {
3309
+ if (this.domCompletedCalled) return;
3310
+ if (this.$refs.contentRef) {
3311
+ this.domCompletedCalled = true;
3312
+ if (typeof this.domCompleted === "function") {
3313
+ this.domCompleted(this.$refs.contentRef);
3314
+ }
3315
+ }
3316
+ },
3317
+ toggleMaximize: function toggleMaximize() {
3318
+ var _this23 = this;
3319
+ if (!this.showMaximizeButton) return;
3320
+ if (!this.isMaximized) {
3321
+ this.originalSize = {
3322
+ width: this.currentWidth,
3323
+ height: this.currentHeight,
3324
+ x: this.currentX,
3325
+ y: this.currentY
3326
+ };
3327
+ var maxConfig = this.maxSize ? this.maxSize() || {} : {};
3328
+ this.currentWidth = maxConfig.width || "100vw";
3329
+ this.currentHeight = maxConfig.height || "100vh";
3330
+ this.currentX = maxConfig.x !== void 0 ? maxConfig.x : 0;
3331
+ this.currentY = maxConfig.y !== void 0 ? maxConfig.y : 0;
3332
+ this.isMaximized = true;
3333
+ } else {
3334
+ this.currentWidth = this.originalSize.width;
3335
+ this.currentHeight = this.originalSize.height;
3336
+ this.currentX = this.originalSize.x;
3337
+ this.currentY = this.originalSize.y;
3338
+ this.isMaximized = false;
3339
+ }
3340
+ this.notifySizeChange();
3341
+ this.$nextTick(function () {
3342
+ return _this23.applyDialogLayout(false);
3343
+ });
3344
+ },
3345
+ closeDialog: function closeDialog() {
3346
+ this.visible = false;
3347
+ },
3348
+ dealClose: function dealClose() {
3349
+ if (typeof this.close === "function") {
3350
+ this.close();
3351
+ }
3352
+ },
3353
+ dealClosed: function dealClosed() {
3354
+ if (typeof this.closed === "function") {
3355
+ this.closed();
3356
+ }
3357
+ },
3358
+ dealConfirm: function dealConfirm() {
3359
+ var _this24 = this;
3360
+ var vm = this;
3361
+ var loadingController = {
3362
+ get value() {
3363
+ return vm.footerLoading;
3364
+ },
3365
+ set value(nextValue) {
3366
+ vm.footerLoading = !!nextValue;
3367
+ }
3368
+ };
3369
+ this.footerLoading = true;
3370
+ if (!this.confirm) {
3371
+ this.footerLoading = false;
3372
+ return;
3373
+ }
3374
+ if (this.immediately) {
3375
+ this.footerLoading = false;
3376
+ this.visible = false;
3377
+ this.confirm(null, this.$refs.contentRef);
3378
+ return;
3379
+ }
3380
+ this.confirm(function () {
3381
+ _this24.footerLoading = false;
3382
+ _this24.visible = false;
3383
+ }, this.$refs.contentRef, loadingController);
3384
+ },
3385
+ handleKeydown: function handleKeydown(event) {
3386
+ if (!this.visible || !this.showFooter || !this.enterTrigger) return;
3387
+ if (event.key === "Enter" && !this.footerDom && !this.footerCloseOnly) {
3388
+ event.preventDefault();
3389
+ this.dealConfirm();
3390
+ }
3391
+ },
3392
+ handleDragStart: function handleDragStart(event) {
3393
+ if (!this.draggable || event.button !== 0) {
3394
+ return;
3395
+ }
3396
+ var dialog = this.resolveDialogElement();
3397
+ if (!dialog) return;
3398
+ var rect = dialog.getBoundingClientRect();
3399
+ this.currentX = rect.left;
3400
+ this.currentY = rect.top;
3401
+ this.dragContext = {
3402
+ startX: event.clientX,
3403
+ startY: event.clientY,
3404
+ originX: rect.left,
3405
+ originY: rect.top
3406
+ };
3407
+ document.addEventListener("mousemove", this.handleDragMove);
3408
+ document.addEventListener("mouseup", this.handleDragEnd);
3409
+ },
3410
+ handleDragMove: function handleDragMove(event) {
3411
+ if (!this.dragContext) return;
3412
+ var deltaX = event.clientX - this.dragContext.startX;
3413
+ var deltaY = event.clientY - this.dragContext.startY;
3414
+ this.currentX = this.dragContext.originX + deltaX;
3415
+ this.currentY = this.dragContext.originY + deltaY;
3416
+ this.applyDialogLayout();
3417
+ },
3418
+ handleDragEnd: function handleDragEnd() {
3419
+ this.removeDragListeners();
3420
+ },
3421
+ removeDragListeners: function removeDragListeners() {
3422
+ document.removeEventListener("mousemove", this.handleDragMove);
3423
+ document.removeEventListener("mouseup", this.handleDragEnd);
3424
+ this.dragContext = null;
3425
+ }
3426
+ }
3427
+ };
3428
+ var _sfc_render = function render6() {
3429
+ var _vm = this,
3430
+ _c = _vm._self._c;
3431
+ return _c("el-dialog", {
3432
+ attrs: {
3433
+ "visible": _vm.visible,
3434
+ "width": _vm.normalizedWidth,
3435
+ "modal": _vm.modal,
3436
+ "modal-class": _vm.modalClassName,
3437
+ "show-close": false,
3438
+ "append-to-body": false,
3439
+ "close-on-click-modal": _vm.closeOnClickModal,
3440
+ "custom-class": _vm.dialogCustomClass
3441
+ },
3442
+ on: {
3443
+ "update:visible": function updateVisible($event) {
3444
+ _vm.visible = $event;
3445
+ },
3446
+ "close": _vm.dealClose,
3447
+ "closed": _vm.dealClosed
3448
+ }
3449
+ }, [_c("div", {
3450
+ staticClass: "ns-dialog-plus__header",
3451
+ attrs: {
3452
+ "slot": "title"
3453
+ },
3454
+ on: {
3455
+ "mousedown": _vm.handleDragStart
3456
+ },
3457
+ slot: "title"
3458
+ }, [_c("div", {
3459
+ staticClass: "ns-dialog-plus__title"
3460
+ }, [_vm.resolvedHeaderDom ? _c(_vm.resolvedHeaderDom, _vm._g(_vm._b({
3461
+ tag: "component"
3462
+ }, "component", _vm.headerOption, false), _vm.mergeEvents(_vm.headerEvents))) : [_vm._v(_vm._s(_vm.currentTitle))]], 2), _c("div", {
3463
+ staticClass: "dialog-controls"
3464
+ }, [_vm.showMaximizeButton ? _c("span", {
3465
+ staticClass: "dialog-icon dialog-maximize",
3466
+ attrs: {
3467
+ "title": "最大化/还原"
3468
+ },
3469
+ on: {
3470
+ "click": function click($event) {
3471
+ $event.stopPropagation();
3472
+ return _vm.toggleMaximize.apply(null, arguments);
3473
+ }
3474
+ }
3475
+ }, [!_vm.isMaximized ? _c("i", {
3476
+ staticClass: "el-icon-full-screen"
3477
+ }) : _c("i", {
3478
+ staticClass: "el-icon-zoom-out"
3479
+ })]) : _vm._e(), _c("span", {
3480
+ staticClass: "dialog-icon dialog-close",
3481
+ attrs: {
3482
+ "title": "关闭"
3483
+ },
3484
+ on: {
3485
+ "click": function click($event) {
3486
+ $event.stopPropagation();
3487
+ return _vm.closeDialog.apply(null, arguments);
3488
+ }
3489
+ }
3490
+ }, [_c("i", {
3491
+ staticClass: "el-icon-close"
3492
+ })])])]), _c("div", {
3493
+ staticClass: "ns-dialog-plus__body",
3494
+ style: _vm.bodyStyle
3495
+ }, [_c(_vm.resolvedDom, _vm._g(_vm._b({
3496
+ ref: "contentRef",
3497
+ tag: "component"
3498
+ }, "component", _vm.currentOption, false), _vm.mergeEvents(_vm.events)))], 1), _vm.showFooter ? _c("div", {
3499
+ staticClass: "ns-dialog-plus__footer",
3500
+ attrs: {
3501
+ "slot": "footer"
3502
+ },
3503
+ slot: "footer"
3504
+ }, [_vm.resolvedFooterDom ? _c(_vm.resolvedFooterDom, _vm._g(_vm._b({
3505
+ tag: "component"
3506
+ }, "component", _vm.footerOption, false), _vm.mergeEvents(_vm.footerEvents))) : [_vm.footerButtonReverse && !_vm.footerCloseOnly ? _c("el-button", {
3507
+ attrs: {
3508
+ "type": "primary",
3509
+ "loading": _vm.footerLoading
3510
+ },
3511
+ on: {
3512
+ "click": _vm.dealConfirm
3513
+ }
3514
+ }, [_vm._v(_vm._s(_vm.footerButtonText.confirm))]) : _vm._e(), _c("el-button", {
3515
+ on: {
3516
+ "click": _vm.closeDialog
3517
+ }
3518
+ }, [_vm._v(_vm._s(_vm.footerButtonText.close))]), !_vm.footerButtonReverse && !_vm.footerCloseOnly ? _c("el-button", {
3519
+ attrs: {
3520
+ "type": "primary",
3521
+ "loading": _vm.footerLoading
3522
+ },
3523
+ on: {
3524
+ "click": _vm.dealConfirm
3525
+ }
3526
+ }, [_vm._v(_vm._s(_vm.footerButtonText.confirm))]) : _vm._e()]], 2) : _vm._e()]);
3527
+ };
3528
+ var _sfc_staticRenderFns = [];
3529
+ var __component__ = /* @__PURE__ */normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "19b1fbf8", null, null);
3530
+ var NsDialogComponent = __component__.exports;
3531
+ var dialogInstances = typeof window !== "undefined" ? window.__dialogInstances = window.__dialogInstances || [] : [];
3532
+ var externalVue = Vue;
3533
+ var externalStore = null;
3534
+ var externalPinia = null;
3535
+ var dialogSeed = 0;
3536
+ function resolveContextValue(primaryValue) {
3537
+ var fallbackValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
3538
+ if (primaryValue) {
3539
+ return primaryValue;
3540
+ }
3541
+ return fallbackValues.find(Boolean) || null;
3542
+ }
3543
+ function resolveVueConstructor(app) {
3544
+ if (!app) return null;
3545
+ if (app.extend) {
3546
+ return app;
3547
+ }
3548
+ if (app.constructor && app.constructor.extend) {
3549
+ return app.constructor;
3550
+ }
3551
+ return null;
3552
+ }
3553
+ function resolveStore(app) {
3554
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3555
+ return resolveContextValue(options.store, [app && app.$store, app && app.$options && app.$options.store, app && app.store, externalStore]);
3556
+ }
3557
+ function resolvePinia(app) {
3558
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3559
+ return resolveContextValue(options.pinia, [app && app.$pinia, app && app.$options && app.$options.pinia, app && app.pinia, externalPinia]);
3560
+ }
3561
+ function setExternalApp(app) {
3562
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3563
+ if (!app) return;
3564
+ var resolvedVue = resolveVueConstructor(app);
3565
+ if (resolvedVue) {
3566
+ externalVue = resolvedVue;
3567
+ }
3568
+ externalStore = resolveStore(app, options);
3569
+ externalPinia = resolvePinia(app, options);
3570
+ }
3571
+ function resolveMountTarget(selector) {
3572
+ if (typeof document === "undefined") {
3573
+ return null;
3574
+ }
3575
+ return document.querySelector(selector) || document.body;
3576
+ }
3577
+ function removeDialogInstance(instance) {
3578
+ var index2 = dialogInstances.findIndex(function (item) {
3579
+ return item.id === instance.id;
3580
+ });
3581
+ if (index2 > -1) {
3582
+ dialogInstances.splice(index2, 1);
3583
+ }
3584
+ }
3585
+ function destroyDialog(instance) {
3586
+ if (!instance || instance.destroyed) {
3587
+ return;
3588
+ }
3589
+ instance.destroyed = true;
3590
+ var vm = instance.vm;
3591
+ if (vm && !vm._isDestroyed) {
3592
+ vm.$destroy();
3593
+ }
3594
+ var rootEl = instance.rootEl || vm && vm.$el;
3595
+ if (rootEl && instance.element && rootEl.parentNode === instance.element) {
3596
+ instance.element.removeChild(rootEl);
3597
+ }
3598
+ if (instance.element && instance.element.parentNode) {
3599
+ instance.element.parentNode.removeChild(instance.element);
3600
+ }
3601
+ instance.vm = null;
3602
+ instance.domRef = null;
3603
+ instance.rootEl = null;
3604
+ instance.updateOption = function () {};
3605
+ instance.callMethod = function () {};
3606
+ instance.close = function () {};
3607
+ removeDialogInstance(instance);
3608
+ }
3609
+ function closeAllNsDialog() {
3610
+ dialogInstances.slice().forEach(function (instance) {
3611
+ if (instance && typeof instance.close === "function") {
3612
+ instance.close();
3613
+ }
3614
+ });
3615
+ }
3616
+ function NsDialog(data) {
3617
+ var modal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3618
+ var appendTo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "#app";
3619
+ if (!data || !data.dom) {
3620
+ return false;
3621
+ }
3622
+ var mountTarget = resolveMountTarget(appendTo);
3623
+ if (!mountTarget) {
3624
+ return false;
3625
+ }
3626
+ var callerVm = this && this._isVue ? this : null;
3627
+ var _a = data,
3628
+ dataStore = _a.store,
3629
+ dataPinia = _a.pinia,
3630
+ dialogData = __objRest(_a, ["store", "pinia"]);
3631
+ var store = resolveStore(callerVm, {
3632
+ store: dataStore
3633
+ });
3634
+ var pinia = resolvePinia(callerVm, {
3635
+ pinia: dataPinia
3636
+ });
3637
+ var id = dialogData.id || "ns-dialog-".concat(Date.now(), "-").concat(dialogSeed++);
3638
+ var container = document.createElement("div");
3639
+ container.id = id;
3640
+ mountTarget.appendChild(container);
3641
+ var instance = {
3642
+ id: id,
3643
+ class: dialogData.class || "",
3644
+ element: container,
3645
+ vm: null,
3646
+ rootEl: null,
3647
+ destroyed: false,
3648
+ domRef: null,
3649
+ updateOption: function updateOption() {},
3650
+ callMethod: function callMethod() {},
3651
+ close: function close() {}
3652
+ };
3653
+ var DialogConstructor = (externalVue || Vue).extend(NsDialogComponent);
3654
+ var propsData = __spreadProps(__spreadValues({}, dialogData), {
3655
+ className: dialogData.class || "",
3656
+ modal: modal,
3657
+ footerButtonReverse: true,
3658
+ containerId: id,
3659
+ dialogInstance: instance,
3660
+ close: function close() {
3661
+ if (typeof dialogData.close === "function") {
3662
+ dialogData.close();
3663
+ }
3664
+ },
3665
+ closed: function closed() {
3666
+ try {
3667
+ if (typeof dialogData.closed === "function") {
3668
+ dialogData.closed();
3669
+ }
3670
+ } finally {
3671
+ destroyDialog(instance);
3672
+ }
3673
+ }
3674
+ });
3675
+ var vmOptions = {
3676
+ propsData: propsData
3677
+ };
3678
+ if (store) {
3679
+ vmOptions.store = store;
3680
+ }
3681
+ if (pinia) {
3682
+ vmOptions.pinia = pinia;
3683
+ }
3684
+ var vm = new DialogConstructor(vmOptions);
3685
+ instance.vm = vm;
3686
+ instance.close = function () {
3687
+ if (instance.destroyed) {
3688
+ return;
3689
+ }
3690
+ if (vm && typeof vm.closeDialog === "function") {
3691
+ vm.closeDialog();
3692
+ }
3693
+ };
3694
+ dialogInstances.push(instance);
3695
+ vm.$mount();
3696
+ if (vm.$el) {
3697
+ instance.rootEl = vm.$el;
3698
+ container.appendChild(vm.$el);
3699
+ }
3700
+ return instance;
3701
+ }
3702
+ var components = [NsForm, NsFormTitle, NsTableContainer, NsSearch, NsTable];
3703
+ function install2(Vue2) {
3704
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3705
+ if (install2.installed) return;
3706
+ install2.installed = true;
3707
+ registerDirective(Vue2);
3708
+ components.forEach(function (component) {
3709
+ if (component && component.name) {
3710
+ Vue2.component(component.name, component);
3711
+ }
3712
+ });
3713
+ setExternalApp(Vue2, options);
3714
+ loadCssVars();
3715
+ if (Vue2 && Vue2.prototype) {
3716
+ Vue2.prototype.$NsDialog = NsDialog;
3717
+ Vue2.prototype.$closeAllNsDialog = closeAllNsDialog;
3718
+ }
3719
+ if (typeof window !== "undefined") {
3720
+ window.NsDialog = NsDialog;
3721
+ window.closeAllNsDialog = closeAllNsDialog;
3722
+ }
3723
+ }
3724
+ var index = {
3725
+ install: install2,
3726
+ NsForm: NsForm,
3727
+ NsFormTitle: NsFormTitle,
3728
+ NsTableContainer: NsTableContainer,
3729
+ NsSearch: NsSearch,
3730
+ NsTable: NsTable,
3731
+ NsDialog: NsDialog,
3732
+ closeAllNsDialog: closeAllNsDialog,
3733
+ setExternalApp: setExternalApp,
3734
+ useFileUpload: useFileUpload,
3735
+ getAllFormNodeByKey: getAllFormNodeByKey,
3736
+ getAllFormKvData: getAllFormKvData,
3737
+ getAllFormNodeRefByKey: getAllFormNodeRefByKey,
3738
+ createPagination: createPagination,
3739
+ createPaginationWithCustomKeys: createPaginationWithCustomKeys,
3740
+ resetPagination: resetPagination
3741
+ };
3742
+ export { NsDialog, NsForm, NsFormTitle, NsSearch, NsTable, NsTableContainer, closeAllNsDialog, createPagination, createPaginationWithCustomKeys, index as default, getAllFormKvData, getAllFormNodeByKey, getAllFormNodeRefByKey, install2 as install, resetPagination, setExternalApp, useFileUpload };