vue2-components-plus 1.0.3 → 1.0.6

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,2895 @@
1
+ import Vue, { getCurrentInstance, nextTick } from "vue";
2
+ const main = "";
3
+ function parseBindingValue(binding) {
4
+ const defaultConfig = { maxLength: 50, pattern: null, min: null, max: null, int: false };
5
+ const value = binding.value;
6
+ if (typeof value === "number") {
7
+ return { ...defaultConfig, maxLength: value };
8
+ }
9
+ if (value && typeof value === "object") {
10
+ return {
11
+ maxLength: value.maxLength || defaultConfig.maxLength,
12
+ pattern: value.pattern || null,
13
+ min: typeof value.min === "number" ? value.min : null,
14
+ max: typeof value.max === "number" ? value.max : null,
15
+ int: !!value.int
16
+ };
17
+ }
18
+ return defaultConfig;
19
+ }
20
+ function formatNumberInput(value, maxLength, allowNegative = true) {
21
+ let result = "";
22
+ let hasMinus = false;
23
+ let hasDot = false;
24
+ String(value || "").split("").forEach((char, index2) => {
25
+ if (char === "-") {
26
+ if (allowNegative && index2 === 0 && !hasMinus) {
27
+ result += char;
28
+ hasMinus = true;
29
+ }
30
+ return;
31
+ }
32
+ if (char === ".") {
33
+ if (index2 !== 0 && !hasDot && result[result.length - 1] !== "-") {
34
+ result += char;
35
+ hasDot = true;
36
+ }
37
+ return;
38
+ }
39
+ if (/^\d$/.test(char)) {
40
+ const current = hasMinus ? result.slice(1) : result;
41
+ if (current === "0" && char !== "0" && !hasDot) {
42
+ result = hasMinus ? "-" : "";
43
+ }
44
+ result += char;
45
+ }
46
+ });
47
+ return result.slice(0, maxLength);
48
+ }
49
+ function formatIntegerInput(value, maxLength, config) {
50
+ let result = "";
51
+ let hasMinus = false;
52
+ const allowNegative = config.min !== null && config.min < 0;
53
+ String(value || "").split("").forEach((char, index2) => {
54
+ if (char === "-") {
55
+ if (allowNegative && index2 === 0 && !hasMinus) {
56
+ result += char;
57
+ hasMinus = true;
58
+ }
59
+ return;
60
+ }
61
+ if (/^\d$/.test(char)) {
62
+ const current = hasMinus ? result.slice(1) : result;
63
+ if (current === "0" && char !== "0") {
64
+ result = hasMinus ? "-" : "";
65
+ }
66
+ result += char;
67
+ }
68
+ });
69
+ return result.slice(0, maxLength);
70
+ }
71
+ function formatRangeInput(value, config) {
72
+ if (config.int) {
73
+ const result2 = formatIntegerInput(value, config.maxLength || 50, config);
74
+ if (result2 === "" || result2 === "-")
75
+ return result2;
76
+ const numberValue2 = parseInt(result2, 10);
77
+ if (Number.isNaN(numberValue2))
78
+ return "";
79
+ if (config.min !== null && numberValue2 < config.min)
80
+ return String(Math.ceil(config.min));
81
+ if (config.max !== null && numberValue2 > config.max)
82
+ return String(Math.floor(config.max));
83
+ return result2;
84
+ }
85
+ const allowNegative = config.min !== null && config.min < 0;
86
+ const result = formatNumberInput(value, config.maxLength || 50, allowNegative);
87
+ if (result === "" || result === "-" || result === ".")
88
+ return result;
89
+ const numberValue = parseFloat(result);
90
+ if (Number.isNaN(numberValue))
91
+ return "";
92
+ if (config.min !== null && numberValue < config.min)
93
+ return String(config.min);
94
+ if (config.max !== null && numberValue > config.max)
95
+ return String(config.max);
96
+ return result;
97
+ }
98
+ function formatRegexInput(value, maxLength, pattern) {
99
+ let result = "";
100
+ String(value || "").split("").forEach((char) => {
101
+ if (result.length >= maxLength)
102
+ return;
103
+ const nextValue = result + char;
104
+ if (pattern.test(nextValue)) {
105
+ result = nextValue;
106
+ }
107
+ });
108
+ return result;
109
+ }
110
+ function getInputElement(el) {
111
+ if (!el)
112
+ return null;
113
+ if (el.tagName === "INPUT" || el.tagName === "TEXTAREA") {
114
+ return el;
115
+ }
116
+ return el.querySelector("input, textarea");
117
+ }
118
+ function updateInputValue(inputEl, binding) {
119
+ if (!inputEl)
120
+ return;
121
+ const config = parseBindingValue(binding);
122
+ let nextValue = inputEl.value || "";
123
+ if (binding.modifiers.range) {
124
+ nextValue = formatRangeInput(nextValue, config);
125
+ } else if (binding.modifiers.number) {
126
+ nextValue = formatNumberInput(nextValue, config.maxLength);
127
+ } else if (binding.modifiers.regex && config.pattern) {
128
+ nextValue = formatRegexInput(nextValue, config.maxLength, config.pattern);
129
+ } else {
130
+ nextValue = String(nextValue).slice(0, config.maxLength);
131
+ }
132
+ if (nextValue !== inputEl.value) {
133
+ inputEl.value = nextValue;
134
+ inputEl.dispatchEvent(new Event("input", { bubbles: true }));
135
+ }
136
+ }
137
+ function bindLengthDirective(el, binding) {
138
+ const inputEl = getInputElement(el);
139
+ if (!inputEl)
140
+ return;
141
+ let composing = false;
142
+ const handleCompositionStart = () => {
143
+ composing = true;
144
+ };
145
+ const handleCompositionEnd = () => {
146
+ composing = false;
147
+ updateInputValue(inputEl, binding);
148
+ };
149
+ const handleInput = () => {
150
+ if (!composing) {
151
+ updateInputValue(inputEl, binding);
152
+ }
153
+ };
154
+ inputEl.addEventListener("compositionstart", handleCompositionStart);
155
+ inputEl.addEventListener("compositionend", handleCompositionEnd);
156
+ inputEl.addEventListener("input", handleInput);
157
+ updateInputValue(inputEl, binding);
158
+ el.__nsLengthHandlers = {
159
+ inputEl,
160
+ handleCompositionStart,
161
+ handleCompositionEnd,
162
+ handleInput
163
+ };
164
+ }
165
+ function unbindLengthDirective(el) {
166
+ const handlers = el.__nsLengthHandlers;
167
+ if (!handlers)
168
+ return;
169
+ handlers.inputEl.removeEventListener("compositionstart", handlers.handleCompositionStart);
170
+ handlers.inputEl.removeEventListener("compositionend", handlers.handleCompositionEnd);
171
+ handlers.inputEl.removeEventListener("input", handlers.handleInput);
172
+ delete el.__nsLengthHandlers;
173
+ }
174
+ function registerDirective(Vue2) {
175
+ Vue2.directive("sline", {
176
+ inserted(el) {
177
+ el.style.whiteSpace = "nowrap";
178
+ el.style.overflow = "hidden";
179
+ el.style.textOverflow = "ellipsis";
180
+ el.style.display = "inline-block";
181
+ el.style.maxWidth = "100%";
182
+ }
183
+ });
184
+ Vue2.directive("permission", {
185
+ inserted(el, binding) {
186
+ let permissionList = [];
187
+ try {
188
+ permissionList = JSON.parse(sessionStorage.getItem("btnsPermission") || localStorage.getItem("btnsPermission") || "[]");
189
+ } catch (error) {
190
+ permissionList = [];
191
+ }
192
+ if (!Array.isArray(permissionList)) {
193
+ permissionList = [];
194
+ }
195
+ const selector = binding.modifiers.class ? "class" : "id";
196
+ const isDisplayNone = !!binding.modifiers.display;
197
+ const matched = selector === "class" ? permissionList.some((item) => el.classList.contains(item)) : permissionList.includes(el.getAttribute("id"));
198
+ if (!matched) {
199
+ if (isDisplayNone) {
200
+ el.style.display = "none";
201
+ } else {
202
+ el.style.visibility = "hidden";
203
+ el.style.pointerEvents = "none";
204
+ }
205
+ }
206
+ }
207
+ });
208
+ Vue2.directive("length", {
209
+ inserted(el, binding) {
210
+ bindLengthDirective(el, binding);
211
+ },
212
+ componentUpdated(el, binding) {
213
+ const inputEl = getInputElement(el);
214
+ updateInputValue(inputEl, binding);
215
+ },
216
+ unbind(el) {
217
+ unbindLengthDirective(el);
218
+ }
219
+ });
220
+ Vue2.directive("event-unuse", {
221
+ inserted(el) {
222
+ el.style.pointerEvents = "none";
223
+ }
224
+ });
225
+ Vue2.directive("event-use", {
226
+ inserted(el) {
227
+ el.style.pointerEvents = "auto";
228
+ }
229
+ });
230
+ }
231
+ let ThemeVar$1 = class ThemeVar {
232
+ };
233
+ ThemeVar$1.VARS = {};
234
+ function loadCssVars$1() {
235
+ if (typeof document === "undefined") {
236
+ return ThemeVar$1.VARS;
237
+ }
238
+ if (Object.keys(ThemeVar$1.VARS).length > 0) {
239
+ return ThemeVar$1.VARS;
240
+ }
241
+ const variables = {};
242
+ Array.from(document.styleSheets || []).forEach((sheet) => {
243
+ let cssRules = [];
244
+ try {
245
+ cssRules = Array.from(sheet.cssRules || []);
246
+ } catch (error) {
247
+ cssRules = [];
248
+ }
249
+ cssRules.forEach((rule) => {
250
+ if (rule.selectorText !== ":root") {
251
+ return;
252
+ }
253
+ Array.from(rule.style || []).filter((name) => name.indexOf("--matrix-") === 0).forEach((name) => {
254
+ variables[name] = rule.style.getPropertyValue(name).trim();
255
+ });
256
+ });
257
+ });
258
+ ThemeVar$1.VARS = variables;
259
+ return variables;
260
+ }
261
+ function toKebabCase$1(value) {
262
+ if (typeof value !== "string")
263
+ return value;
264
+ if (value.indexOf("-") > -1)
265
+ return value.toLowerCase();
266
+ return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
267
+ }
268
+ function normalizeComponent$1(component) {
269
+ if (!component)
270
+ return "span";
271
+ if (typeof component === "string") {
272
+ return toKebabCase$1(component);
273
+ }
274
+ return component;
275
+ }
276
+ function cloneVNodeWithSlot(vnode, slotName) {
277
+ if (!vnode || slotName === "default") {
278
+ return vnode;
279
+ }
280
+ const data = vnode.data || (vnode.data = {});
281
+ data.slot = slotName;
282
+ return vnode;
283
+ }
284
+ function normalizeChildren(result, slotName) {
285
+ if (!result)
286
+ return [];
287
+ const list = Array.isArray(result) ? result : [result];
288
+ return list.map((item) => cloneVNodeWithSlot(item, slotName)).filter(Boolean);
289
+ }
290
+ function isComponentName(component, names) {
291
+ const name = String(typeof component === "string" ? component : component && component.name ? component.name : "").replace(/-/g, "").toLowerCase();
292
+ return names.some((item) => name === item.toLowerCase());
293
+ }
294
+ const FormFieldRenderer = {
295
+ name: "NsFormFieldRenderer",
296
+ inheritAttrs: false,
297
+ props: {
298
+ field: {
299
+ type: Object,
300
+ required: true
301
+ },
302
+ value: {
303
+ default: void 0
304
+ }
305
+ },
306
+ mounted() {
307
+ this.emitRef();
308
+ },
309
+ updated() {
310
+ this.emitRef();
311
+ },
312
+ methods: {
313
+ emitRef() {
314
+ this.$emit("ref", this.$refs.control || null);
315
+ },
316
+ getComponent() {
317
+ return normalizeComponent$1(this.field.component);
318
+ },
319
+ isUpload() {
320
+ return isComponentName(this.field.component, ["elupload"]);
321
+ },
322
+ rendersOptionsByChildren() {
323
+ return isComponentName(this.field.component, ["elselect", "elradiogroup", "elcheckboxgroup"]);
324
+ },
325
+ isFullWidthComponent() {
326
+ return isComponentName(this.field.component, [
327
+ "elinput",
328
+ "elselect",
329
+ "elcascader",
330
+ "eldatepicker",
331
+ "eltimepicker",
332
+ "elinputnumber",
333
+ "elautocomplete"
334
+ ]);
335
+ },
336
+ buildProps() {
337
+ const params = this.field.params || {};
338
+ const result = {};
339
+ Object.keys(params).forEach((key) => {
340
+ if (key.indexOf("v-") === 0)
341
+ return;
342
+ if (key === "rules" || key === "style")
343
+ return;
344
+ if (key === "options" && this.rendersOptionsByChildren())
345
+ return;
346
+ result[key] = params[key];
347
+ });
348
+ if (!this.isUpload()) {
349
+ result.value = this.value;
350
+ }
351
+ return result;
352
+ },
353
+ buildStyle() {
354
+ const params = this.field.params || {};
355
+ const style = {
356
+ ...this.field.style || {},
357
+ ...params.style || {}
358
+ };
359
+ if (this.isFullWidthComponent() && style.width === void 0) {
360
+ style.width = "100%";
361
+ }
362
+ return style;
363
+ },
364
+ buildDirectives() {
365
+ const params = this.field.params || {};
366
+ return Object.keys(params).filter((key) => key.indexOf("v-") === 0).map((key) => {
367
+ const [, definition] = key.split("v-");
368
+ const [name, ...modifiers] = definition.split(".");
369
+ const modifierObject = {};
370
+ modifiers.forEach((item) => {
371
+ modifierObject[item] = true;
372
+ });
373
+ return {
374
+ name,
375
+ value: params[key],
376
+ modifiers: modifierObject
377
+ };
378
+ });
379
+ },
380
+ buildEvents() {
381
+ const userEvents = this.field.events || {};
382
+ const listeners = {};
383
+ Object.keys(userEvents).forEach((name) => {
384
+ listeners[name] = (...args) => {
385
+ userEvents[name](...args);
386
+ };
387
+ });
388
+ if (!this.isUpload()) {
389
+ const originalInput = listeners.input;
390
+ listeners.input = (val, ...args) => {
391
+ this.$emit("input", val);
392
+ if (originalInput) {
393
+ originalInput(val, ...args);
394
+ }
395
+ };
396
+ }
397
+ return listeners;
398
+ },
399
+ buildScopedSlots() {
400
+ const slots = this.field.slots || {};
401
+ const scopedSlots = {};
402
+ Object.keys(slots).forEach((name) => {
403
+ if (typeof slots[name] === "function") {
404
+ scopedSlots[name] = (scope) => slots[name](scope);
405
+ }
406
+ });
407
+ return scopedSlots;
408
+ },
409
+ renderOptionNodes(h) {
410
+ const params = this.field.params || {};
411
+ const options = params.options || [];
412
+ const component = this.getComponent();
413
+ if (!Array.isArray(options) || options.length === 0) {
414
+ return [];
415
+ }
416
+ if (isComponentName(component, ["elselect"])) {
417
+ return options.map(
418
+ (option, index2) => h("el-option", {
419
+ key: option.value !== void 0 ? option.value : index2,
420
+ props: {
421
+ label: option.label,
422
+ value: option.value,
423
+ disabled: option.disabled
424
+ }
425
+ })
426
+ );
427
+ }
428
+ if (isComponentName(component, ["elradiogroup"])) {
429
+ return options.map(
430
+ (option, index2) => h(
431
+ "el-radio",
432
+ {
433
+ key: option.value !== void 0 ? option.value : index2,
434
+ props: {
435
+ label: option.value,
436
+ disabled: option.disabled
437
+ }
438
+ },
439
+ [option.label]
440
+ )
441
+ );
442
+ }
443
+ if (isComponentName(component, ["elcheckboxgroup"])) {
444
+ return options.map(
445
+ (option, index2) => h(
446
+ "el-checkbox",
447
+ {
448
+ key: option.value !== void 0 ? option.value : index2,
449
+ props: {
450
+ label: option.value,
451
+ disabled: option.disabled
452
+ }
453
+ },
454
+ [option.label]
455
+ )
456
+ );
457
+ }
458
+ return [];
459
+ }
460
+ },
461
+ render(h) {
462
+ const component = this.getComponent();
463
+ const slotNodes = [];
464
+ const slots = this.field.slots || {};
465
+ Object.keys(slots).forEach((name) => {
466
+ if (typeof slots[name] === "function") {
467
+ slotNodes.push(...normalizeChildren(slots[name]({ field: this.field, value: this.value }), name));
468
+ }
469
+ });
470
+ return h(
471
+ component,
472
+ {
473
+ ref: "control",
474
+ props: this.buildProps(),
475
+ style: this.buildStyle(),
476
+ on: this.buildEvents(),
477
+ directives: this.buildDirectives(),
478
+ scopedSlots: this.buildScopedSlots()
479
+ },
480
+ [...this.renderOptionNodes(h), ...slotNodes]
481
+ );
482
+ }
483
+ };
484
+ function isNotNull(value) {
485
+ if (Array.isArray(value)) {
486
+ return true;
487
+ }
488
+ if (value === 0 || value === "0") {
489
+ return true;
490
+ }
491
+ return !(value === "" || value === null || typeof value === "undefined" || value === "null" || value === "undefined" || String(value).trim() === "" || String(value).trim() === "undefined");
492
+ }
493
+ const DynamicForm_vue_vue_type_style_index_0_scoped_4efb4504_lang = "";
494
+ function normalizeComponent(scriptExports, render7, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
495
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
496
+ if (render7) {
497
+ options.render = render7;
498
+ options.staticRenderFns = staticRenderFns;
499
+ options._compiled = true;
500
+ }
501
+ if (functionalTemplate) {
502
+ options.functional = true;
503
+ }
504
+ if (scopeId) {
505
+ options._scopeId = "data-v-" + scopeId;
506
+ }
507
+ var hook;
508
+ if (moduleIdentifier) {
509
+ hook = function(context) {
510
+ context = context || // cached call
511
+ this.$vnode && this.$vnode.ssrContext || // stateful
512
+ this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
513
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
514
+ context = __VUE_SSR_CONTEXT__;
515
+ }
516
+ if (injectStyles) {
517
+ injectStyles.call(this, context);
518
+ }
519
+ if (context && context._registeredComponents) {
520
+ context._registeredComponents.add(moduleIdentifier);
521
+ }
522
+ };
523
+ options._ssrRegister = hook;
524
+ } else if (injectStyles) {
525
+ hook = shadowMode ? function() {
526
+ injectStyles.call(
527
+ this,
528
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
529
+ );
530
+ } : injectStyles;
531
+ }
532
+ if (hook) {
533
+ if (options.functional) {
534
+ options._injectStyles = hook;
535
+ var originalRender = options.render;
536
+ options.render = function renderWithStyleInjection(h, context) {
537
+ hook.call(context);
538
+ return originalRender(h, context);
539
+ };
540
+ } else {
541
+ var existing = options.beforeCreate;
542
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
543
+ }
544
+ }
545
+ return {
546
+ exports: scriptExports,
547
+ options
548
+ };
549
+ }
550
+ function deepClone(value) {
551
+ if (value === null || typeof value !== "object") {
552
+ return value;
553
+ }
554
+ if (Array.isArray(value)) {
555
+ return value.map((item) => deepClone(item));
556
+ }
557
+ const result = {};
558
+ Object.keys(value).forEach((key) => {
559
+ result[key] = deepClone(value[key]);
560
+ });
561
+ return result;
562
+ }
563
+ function normalizeComponentName(component) {
564
+ const name = String(typeof component === "string" ? component : component && component.name ? component.name : "");
565
+ return name.replace(/-/g, "").toLowerCase();
566
+ }
567
+ const _sfc_main$5 = {
568
+ name: "NsForm",
569
+ components: {
570
+ FormFieldRenderer
571
+ },
572
+ props: {
573
+ model: {
574
+ type: String,
575
+ default: ""
576
+ },
577
+ readOnly: {
578
+ type: Boolean,
579
+ default: false
580
+ },
581
+ labelWidth: {
582
+ type: String,
583
+ default: "80px"
584
+ },
585
+ superLabelWidth: {
586
+ type: String,
587
+ default: "30px"
588
+ },
589
+ labelColor: {
590
+ type: String,
591
+ default: "#0A7BFF"
592
+ },
593
+ gapH: {
594
+ type: String,
595
+ default: "10px"
596
+ },
597
+ gapV: {
598
+ type: String,
599
+ default: "10px"
600
+ },
601
+ height: {
602
+ type: String,
603
+ default: "32px"
604
+ },
605
+ rows: {
606
+ type: Array,
607
+ default: () => []
608
+ },
609
+ backgroundColor: {
610
+ type: String,
611
+ default: ""
612
+ },
613
+ valueEmptyTag: {
614
+ type: String,
615
+ default: "--"
616
+ },
617
+ formPropKey: {
618
+ type: String,
619
+ default: "rows"
620
+ },
621
+ hasPoint: {
622
+ type: Boolean,
623
+ default: false
624
+ }
625
+ },
626
+ data() {
627
+ return {
628
+ componentRefs: {}
629
+ };
630
+ },
631
+ computed: {
632
+ formClassList() {
633
+ return {
634
+ "is-vertical": this.model.indexOf("vertical") > -1,
635
+ "is-table": this.model.indexOf("table") > -1,
636
+ "is-readonly": this.readOnly
637
+ };
638
+ },
639
+ wrapperStyle() {
640
+ return {
641
+ "--ns-form-label-width": this.normalizeSize(this.labelWidth),
642
+ "--ns-form-super-label-width": this.normalizeSize(this.superLabelWidth),
643
+ "--ns-form-label-color": this.labelColor,
644
+ "--ns-form-row-gap": this.gapV,
645
+ "--ns-form-col-gap": this.gapH,
646
+ "--ns-form-item-height": this.normalizeSize(this.height),
647
+ "--ns-form-background-color": this.backgroundColor || "#ffffff"
648
+ };
649
+ },
650
+ rowStyle() {
651
+ return {
652
+ marginBottom: this.model.indexOf("table") > -1 ? "0" : this.gapV
653
+ };
654
+ },
655
+ labelStyle() {
656
+ return {
657
+ width: this.normalizeSize(this.labelWidth),
658
+ color: this.labelColor
659
+ };
660
+ },
661
+ groupLabelStyle() {
662
+ return {
663
+ width: this.normalizeSize(this.superLabelWidth),
664
+ color: this.labelColor
665
+ };
666
+ },
667
+ valueStyle() {
668
+ return {
669
+ minHeight: this.normalizeSize(this.height)
670
+ };
671
+ }
672
+ },
673
+ watch: {
674
+ rows: {
675
+ handler(newRows) {
676
+ this.initializeDefaultValues(newRows);
677
+ },
678
+ deep: true,
679
+ immediate: true
680
+ }
681
+ },
682
+ methods: {
683
+ walkFields(callback) {
684
+ (this.rows || []).forEach((row, rowIndex) => {
685
+ (row || []).forEach((item, itemIndex) => {
686
+ callback(item, rowIndex, itemIndex, null, null);
687
+ (item.children || []).forEach((child, childIndex) => {
688
+ callback(child, rowIndex, itemIndex, childIndex, item);
689
+ });
690
+ });
691
+ });
692
+ },
693
+ initializeDefaultValues(rows) {
694
+ (rows || []).forEach((row) => {
695
+ (row || []).forEach((item) => {
696
+ if (item && item.key && item.defaultValue === void 0) {
697
+ this.$set(item, "defaultValue", deepClone(item.value));
698
+ }
699
+ (item.children || []).forEach((child) => {
700
+ if (child && child.key && child.defaultValue === void 0) {
701
+ this.$set(child, "defaultValue", deepClone(child.value));
702
+ }
703
+ });
704
+ });
705
+ });
706
+ },
707
+ normalizeSize(value) {
708
+ if (value === null || value === void 0 || value === "")
709
+ return "";
710
+ return /^\d+$/.test(String(value)) ? `${value}px` : String(value);
711
+ },
712
+ hasChildren(item) {
713
+ return Array.isArray(item.children) && item.children.length > 0;
714
+ },
715
+ getItemStyle(item, row) {
716
+ if (item.span === 0) {
717
+ return { display: "none" };
718
+ }
719
+ if (typeof item.span === "string" && item.span.indexOf("%") > -1) {
720
+ return {
721
+ flex: `0 0 ${item.span}`,
722
+ maxWidth: item.span
723
+ };
724
+ }
725
+ if (item.span !== void 0 && item.span !== null && item.span !== "") {
726
+ const span = Number(item.span);
727
+ if (!Number.isNaN(span)) {
728
+ const width2 = span > 24 ? `${span}px` : `${span / 24 * 100}%`;
729
+ return {
730
+ flex: `0 0 ${width2}`,
731
+ maxWidth: width2
732
+ };
733
+ }
734
+ }
735
+ const columns = (row || []).filter((field) => field && field.span !== 0).length || 1;
736
+ const width = `calc(${100 / columns}% - ${this.gapH})`;
737
+ return {
738
+ flex: `0 0 ${width}`,
739
+ maxWidth: width
740
+ };
741
+ },
742
+ getFieldRules(field) {
743
+ if (this.readOnly)
744
+ return [];
745
+ return field.params && field.params.rules || [];
746
+ },
747
+ isRequiredField(field) {
748
+ if (!field || this.readOnly)
749
+ return false;
750
+ if (typeof field.required === "boolean") {
751
+ return field.required;
752
+ }
753
+ return this.getFieldRules(field).some((rule) => rule && rule.required);
754
+ },
755
+ getFieldRequired(field) {
756
+ if (!field || this.readOnly)
757
+ return false;
758
+ return field && typeof field.required === "boolean" ? field.required : void 0;
759
+ },
760
+ updateFieldValue(field, value) {
761
+ this.$set(field, "value", value);
762
+ },
763
+ setComponentRef(field, ref) {
764
+ if (!field || !field.key)
765
+ return;
766
+ this.$set(field, "ref", ref);
767
+ this.$set(this.componentRefs, field.key, ref);
768
+ },
769
+ showReadOnlyText(field) {
770
+ return this.readOnly && !(field && field.readOnlyUseComponent);
771
+ },
772
+ normalizeDisplayValue(value, field) {
773
+ if (isNotNull(value)) {
774
+ if (Array.isArray(value)) {
775
+ return value.join(",");
776
+ }
777
+ return value;
778
+ }
779
+ return field && field.valueEmptyTag || this.valueEmptyTag;
780
+ },
781
+ getReadOnlyDisplayValue(field) {
782
+ var _a, _b, _c;
783
+ if (!field) {
784
+ return this.valueEmptyTag;
785
+ }
786
+ if (typeof ((_a = field.params) == null ? void 0 : _a.formatter) === "function") {
787
+ return field.params.formatter(field.value, field) || this.valueEmptyTag;
788
+ }
789
+ if (!isNotNull(field.value)) {
790
+ return field.valueEmptyTag || this.valueEmptyTag;
791
+ }
792
+ if (this.isUploadComponent(field)) {
793
+ return (field.value || []).map((item) => item.fileName || item.name || item.filePath).filter(Boolean).join(",") || (field.valueEmptyTag || this.valueEmptyTag);
794
+ }
795
+ if (this.isSwitchComponent(field)) {
796
+ return field.value ? ((_b = field.params) == null ? void 0 : _b.activeText) || "是" : ((_c = field.params) == null ? void 0 : _c.inactiveText) || "否";
797
+ }
798
+ if (this.isSelectLikeComponent(field)) {
799
+ return this.getOptionDisplayText(field);
800
+ }
801
+ if (this.isCascaderComponent(field)) {
802
+ return this.getCascaderDisplayValue(field);
803
+ }
804
+ if (Array.isArray(field.value)) {
805
+ return field.value.join(",");
806
+ }
807
+ return field.value;
808
+ },
809
+ getOptionDisplayText(field) {
810
+ var _a;
811
+ const options = ((_a = field.params) == null ? void 0 : _a.options) || [];
812
+ const rawValue = field.value;
813
+ const valueList = Array.isArray(rawValue) ? rawValue : typeof rawValue === "string" && rawValue.indexOf(",") > -1 ? rawValue.split(",").filter(Boolean) : [rawValue];
814
+ const labels = valueList.map((value) => {
815
+ const option = options.find((item) => item.value === value);
816
+ return option ? option.label : value;
817
+ }).filter((item) => item !== void 0 && item !== null && item !== "");
818
+ return labels.join(",") || field.valueEmptyTag || this.valueEmptyTag;
819
+ },
820
+ getCascaderDisplayValue(field) {
821
+ var _a, _b, _c, _d;
822
+ const params = field.params || {};
823
+ const options = params.options || [];
824
+ const propConfig = {
825
+ value: ((_a = params.props) == null ? void 0 : _a.value) || "value",
826
+ label: ((_b = params.props) == null ? void 0 : _b.label) || "label",
827
+ children: ((_c = params.props) == null ? void 0 : _c.children) || "children",
828
+ multiple: !!((_d = params.props) == null ? void 0 : _d.multiple),
829
+ separator: params.separator || " / "
830
+ };
831
+ const normalizePath = (pathValue) => {
832
+ if (Array.isArray(pathValue))
833
+ return pathValue;
834
+ if (typeof pathValue === "string" && pathValue.indexOf(",") > -1) {
835
+ return pathValue.split(",").filter(Boolean);
836
+ }
837
+ return [pathValue];
838
+ };
839
+ const getPathLabels = (pathValue) => {
840
+ const labels = [];
841
+ let currentOptions = options;
842
+ normalizePath(pathValue).forEach((value) => {
843
+ const current = (currentOptions || []).find((item) => item[propConfig.value] === value);
844
+ if (current) {
845
+ labels.push(current[propConfig.label]);
846
+ currentOptions = current[propConfig.children];
847
+ }
848
+ });
849
+ return labels.join(propConfig.separator);
850
+ };
851
+ if (propConfig.multiple && Array.isArray(field.value) && Array.isArray(field.value[0])) {
852
+ return field.value.map((item) => getPathLabels(item)).join(",");
853
+ }
854
+ return getPathLabels(field.value);
855
+ },
856
+ isSelectLikeComponent(field) {
857
+ return ["elselect", "elradiogroup", "elcheckboxgroup"].includes(normalizeComponentName(field.component));
858
+ },
859
+ isSwitchComponent(field) {
860
+ return normalizeComponentName(field.component) === "elswitch";
861
+ },
862
+ isCascaderComponent(field) {
863
+ return normalizeComponentName(field.component) === "elcascader";
864
+ },
865
+ isUploadComponent(field) {
866
+ return normalizeComponentName(field.component) === "elupload";
867
+ },
868
+ getFormNodeByKey(key) {
869
+ for (let rowIndex = 0; rowIndex < this.rows.length; rowIndex += 1) {
870
+ const row = this.rows[rowIndex];
871
+ for (let colIndex = 0; colIndex < row.length; colIndex += 1) {
872
+ const item = row[colIndex];
873
+ if (item.key === key)
874
+ return item;
875
+ for (let childIndex = 0; childIndex < (item.children || []).length; childIndex += 1) {
876
+ const child = item.children[childIndex];
877
+ if (child.key === key)
878
+ return child;
879
+ }
880
+ }
881
+ }
882
+ return null;
883
+ },
884
+ getFormNodeRefByKey(key) {
885
+ return this.componentRefs[key] || null;
886
+ },
887
+ getFormKvData() {
888
+ const result = {};
889
+ this.walkFields((field) => {
890
+ if (!field || !field.key)
891
+ return;
892
+ result[field.key] = Array.isArray(field.value) && Array.isArray(field.delValue) ? field.value.concat(field.delValue) : field.value;
893
+ });
894
+ return result;
895
+ },
896
+ resetForm(triggerEvents = false) {
897
+ this.walkFields((field) => {
898
+ var _a, _b;
899
+ if (!field || !field.key)
900
+ return;
901
+ const oldValue = deepClone(field.value);
902
+ const nextValue = field.defaultValue !== void 0 ? deepClone(field.defaultValue) : Array.isArray(field.value) ? [] : typeof field.value === "boolean" ? false : typeof field.value === "number" ? 0 : "";
903
+ this.$set(field, "value", nextValue);
904
+ if (field.delValue !== void 0) {
905
+ this.$set(field, "delValue", []);
906
+ }
907
+ if (field.params && Array.isArray(field.params.fileList)) {
908
+ field.params.fileList.splice(0, field.params.fileList.length);
909
+ }
910
+ if (triggerEvents && JSON.stringify(oldValue) !== JSON.stringify(nextValue)) {
911
+ if (typeof ((_a = field.events) == null ? void 0 : _a.change) === "function") {
912
+ this.$nextTick(() => field.events.change(nextValue));
913
+ }
914
+ if (typeof ((_b = field.events) == null ? void 0 : _b.input) === "function") {
915
+ this.$nextTick(() => field.events.input(nextValue));
916
+ }
917
+ }
918
+ });
919
+ },
920
+ setFormData(data) {
921
+ if (!data || typeof data !== "object") {
922
+ return;
923
+ }
924
+ this.walkFields((field) => {
925
+ if (!field || !field.key || !Object.prototype.hasOwnProperty.call(data, field.key))
926
+ return;
927
+ let nextValue = deepClone(data[field.key]);
928
+ if (this.isCascaderComponent(field) && typeof nextValue === "string" && nextValue.indexOf(",") > -1) {
929
+ nextValue = nextValue.split(",").filter(Boolean);
930
+ }
931
+ this.$set(field, "value", nextValue);
932
+ if (this.isUploadComponent(field)) {
933
+ const fileList = Array.isArray(nextValue) ? deepClone(nextValue) : [];
934
+ if (field.params) {
935
+ this.$set(field.params, "fileList", fileList);
936
+ }
937
+ }
938
+ });
939
+ },
940
+ initDefaultValues() {
941
+ this.initializeDefaultValues(this.rows);
942
+ }
943
+ }
944
+ };
945
+ var _sfc_render$5 = function render() {
946
+ var _vm = this, _c = _vm._self._c;
947
+ return _vm.rows && _vm.rows.length ? _c("div", { staticClass: "ns-dynamic-form", class: _vm.formClassList, style: _vm.wrapperStyle }, _vm._l(_vm.rows, function(row, rowIndex) {
948
+ return _c("div", { key: `row-${rowIndex}`, staticClass: "ns-dynamic-form__row", style: _vm.rowStyle }, _vm._l(row, function(item, itemIndex) {
949
+ return _c("div", { key: item.key || `${rowIndex}-${itemIndex}`, staticClass: "ns-dynamic-form__item", class: { "has-children": _vm.hasChildren(item) }, style: _vm.getItemStyle(item, row) }, [_vm.hasChildren(item) ? [!item.hideLabel && item.label ? _c("div", { staticClass: "ns-dynamic-form__group-label", style: _vm.groupLabelStyle }, [_vm._v(" " + _vm._s(item.label) + " ")]) : _vm._e(), _c("div", { staticClass: "ns-dynamic-form__children" }, _vm._l(item.children, function(child, childIndex) {
950
+ return _c("div", { key: child.key || `${rowIndex}-${itemIndex}-${childIndex}`, staticClass: "ns-dynamic-form__child" }, [!child.hideLabel && child.label ? _c("div", { staticClass: "ns-dynamic-form__label", class: { "has-point": _vm.hasPoint || _vm.isRequiredField(child) }, style: _vm.labelStyle }, [_vm._v(" " + _vm._s(child.label) + " ")]) : _vm._e(), _c("div", { staticClass: "ns-dynamic-form__value", style: _vm.valueStyle }, [_vm.showReadOnlyText(child) ? [_c("span", { directives: [{ name: "sline", rawName: "v-sline" }] }, [_vm._v(_vm._s(_vm.getReadOnlyDisplayValue(child)))])] : child.component ? [_c("el-form-item", { staticClass: "ns-dynamic-form__form-item", attrs: { "label-width": "0px", "prop": `${_vm.formPropKey}.${rowIndex}.${itemIndex}.children.${childIndex}.value`, "rules": _vm.getFieldRules(child), "required": _vm.getFieldRequired(child) } }, [_c("form-field-renderer", { attrs: { "field": child, "value": child.value }, on: { "input": function($event) {
951
+ return _vm.updateFieldValue(child, $event);
952
+ }, "ref": function($event) {
953
+ return _vm.setComponentRef(child, $event);
954
+ } } })], 1)] : [_c("span", { directives: [{ name: "sline", rawName: "v-sline" }] }, [_vm._v(_vm._s(_vm.normalizeDisplayValue(child.value, child)))])]], 2)]);
955
+ }), 0)] : [!item.hideLabel && item.label ? _c("div", { staticClass: "ns-dynamic-form__label", class: { "has-point": _vm.hasPoint || _vm.isRequiredField(item) }, style: _vm.labelStyle }, [_vm._v(" " + _vm._s(item.label) + " ")]) : _vm._e(), _c("div", { staticClass: "ns-dynamic-form__value", style: _vm.valueStyle }, [_vm.showReadOnlyText(item) ? [_c("span", { directives: [{ name: "sline", rawName: "v-sline" }] }, [_vm._v(_vm._s(_vm.getReadOnlyDisplayValue(item)))])] : item.component ? [_c("el-form-item", { staticClass: "ns-dynamic-form__form-item", attrs: { "label-width": "0px", "prop": `${_vm.formPropKey}.${rowIndex}.${itemIndex}.value`, "rules": _vm.getFieldRules(item), "required": _vm.getFieldRequired(item) } }, [_c("form-field-renderer", { attrs: { "field": item, "value": item.value }, on: { "input": function($event) {
956
+ return _vm.updateFieldValue(item, $event);
957
+ }, "ref": function($event) {
958
+ return _vm.setComponentRef(item, $event);
959
+ } } })], 1)] : [_c("span", { directives: [{ name: "sline", rawName: "v-sline" }] }, [_vm._v(_vm._s(_vm.normalizeDisplayValue(item.value, item)))])]], 2)]], 2);
960
+ }), 0);
961
+ }), 0) : _vm._e();
962
+ };
963
+ var _sfc_staticRenderFns$5 = [];
964
+ var __component__$5 = /* @__PURE__ */ normalizeComponent(
965
+ _sfc_main$5,
966
+ _sfc_render$5,
967
+ _sfc_staticRenderFns$5,
968
+ false,
969
+ null,
970
+ "4efb4504",
971
+ null,
972
+ null
973
+ );
974
+ const NsForm = __component__$5.exports;
975
+ class ThemeVar2 {
976
+ }
977
+ ThemeVar2.VARS = {};
978
+ function loadCssVars() {
979
+ if (typeof document === "undefined") {
980
+ return ThemeVar2.VARS;
981
+ }
982
+ if (Object.keys(ThemeVar2.VARS).length > 0) {
983
+ return ThemeVar2.VARS;
984
+ }
985
+ const variables = {};
986
+ Array.from(document.styleSheets || []).forEach((sheet) => {
987
+ let cssRules = [];
988
+ try {
989
+ cssRules = Array.from(sheet.cssRules || []);
990
+ } catch (error) {
991
+ cssRules = [];
992
+ }
993
+ cssRules.forEach((rule) => {
994
+ if (rule.selectorText !== ":root") {
995
+ return;
996
+ }
997
+ Array.from(rule.style || []).filter((name) => name.indexOf("--matrix-") === 0).forEach((name) => {
998
+ variables[name] = rule.style.getPropertyValue(name).trim();
999
+ });
1000
+ });
1001
+ });
1002
+ ThemeVar2.VARS = variables;
1003
+ return variables;
1004
+ }
1005
+ const DynamicFormTitle_vue_vue_type_style_index_0_scoped_4e159c2c_lang = "";
1006
+ const _sfc_main$4 = {
1007
+ name: "NsFormTitle",
1008
+ props: {
1009
+ title: {
1010
+ type: String,
1011
+ default: ""
1012
+ }
1013
+ },
1014
+ mounted() {
1015
+ loadCssVars();
1016
+ }
1017
+ };
1018
+ var _sfc_render$4 = function render2() {
1019
+ var _vm = this, _c = _vm._self._c;
1020
+ return _c("div", { staticClass: "ns-form-title" }, [_c("div", { staticClass: "ns-form-title__header" }, [_vm._t("title", function() {
1021
+ return [_c("span", { staticClass: "ns-form-title__icon" }), _c("span", { staticClass: "ns-form-title__text" }, [_vm._v(_vm._s(_vm.title))])];
1022
+ })], 2), _c("div", { staticClass: "ns-form-title__content" }, [_vm._t("default")], 2)]);
1023
+ };
1024
+ var _sfc_staticRenderFns$4 = [];
1025
+ var __component__$4 = /* @__PURE__ */ normalizeComponent(
1026
+ _sfc_main$4,
1027
+ _sfc_render$4,
1028
+ _sfc_staticRenderFns$4,
1029
+ false,
1030
+ null,
1031
+ "4e159c2c",
1032
+ null,
1033
+ null
1034
+ );
1035
+ const NsFormTitle = __component__$4.exports;
1036
+ function getImageBaseUrl(instance) {
1037
+ var _a;
1038
+ return ((_a = instance == null ? void 0 : instance.proxy) == null ? void 0 : _a.$ImageBaseUrl) || "";
1039
+ }
1040
+ function getFieldPathByKey(rows, key, formPropKey = "rows") {
1041
+ for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
1042
+ const row = rows[rowIndex];
1043
+ for (let colIndex = 0; colIndex < row.length; colIndex += 1) {
1044
+ const item = row[colIndex];
1045
+ if (item.key === key) {
1046
+ return `${formPropKey}.${rowIndex}.${colIndex}.value`;
1047
+ }
1048
+ if (Array.isArray(item.children)) {
1049
+ for (let childIndex = 0; childIndex < item.children.length; childIndex += 1) {
1050
+ const child = item.children[childIndex];
1051
+ if (child.key === key) {
1052
+ return `${formPropKey}.${rowIndex}.${colIndex}.children.${childIndex}.value`;
1053
+ }
1054
+ }
1055
+ }
1056
+ }
1057
+ }
1058
+ return null;
1059
+ }
1060
+ function useFileUpload(state) {
1061
+ const instance = getCurrentInstance();
1062
+ function handleFormatFileList(field, fileList) {
1063
+ const baseUrl = getImageBaseUrl(instance);
1064
+ const nextList = Array.isArray(fileList) ? fileList : [];
1065
+ nextList.forEach((item) => {
1066
+ if (item.filePath && !item.url) {
1067
+ item.url = `${baseUrl}${item.filePath}`;
1068
+ }
1069
+ if (!item.name) {
1070
+ item.name = item.fileName || item.name || item.filePath || "未命名文件";
1071
+ }
1072
+ });
1073
+ if (field && field.params) {
1074
+ field.params.fileList = nextList;
1075
+ }
1076
+ if (field) {
1077
+ field.value = nextList.slice();
1078
+ }
1079
+ return nextList;
1080
+ }
1081
+ function handleRemoveFile(file, fileList, fieldKey, rows = state.rows) {
1082
+ const field = getAllFormNodeByKey(rows, fieldKey);
1083
+ if (!field) {
1084
+ return fileList;
1085
+ }
1086
+ const nextValue = (fileList || []).map((item) => ({
1087
+ ...item,
1088
+ fileName: item.response ? item.response.data.fileName : item.fileName,
1089
+ filePath: item.response ? item.response.data.filePath : item.filePath,
1090
+ fileSize: item.response ? item.response.data.fileSize : item.fileSize
1091
+ }));
1092
+ if (!Array.isArray(field.delValue)) {
1093
+ field.delValue = [];
1094
+ }
1095
+ if (!file.response && file.status === "success") {
1096
+ field.delValue.push({ ...file, isDelete: 1 });
1097
+ }
1098
+ field.value = nextValue;
1099
+ if (field.params) {
1100
+ field.params.fileList = fileList || [];
1101
+ }
1102
+ return fileList;
1103
+ }
1104
+ function handleFileSuccessFile(response, file, fileList, fieldKey, rows = state.rows) {
1105
+ const field = getAllFormNodeByKey(rows, fieldKey);
1106
+ if (!field) {
1107
+ return fileList;
1108
+ }
1109
+ if (!Array.isArray(field.value)) {
1110
+ field.value = [];
1111
+ }
1112
+ if (file && file.status === "success" && response && response.data) {
1113
+ field.value.push({ ...response.data });
1114
+ }
1115
+ if (field.params) {
1116
+ field.params.fileList = fileList || [];
1117
+ }
1118
+ return fileList;
1119
+ }
1120
+ function handleCheckFileRequire(rows, key, formRef, formPropKey = "rows") {
1121
+ const field = getAllFormNodeByKey(rows, key);
1122
+ if (field && !Array.isArray(field.value)) {
1123
+ field.value = [];
1124
+ }
1125
+ const fieldPath = getFieldPathByKey(rows, key, formPropKey);
1126
+ nextTick(() => {
1127
+ const formInstance = formRef && (formRef.value || formRef);
1128
+ if (fieldPath && formInstance && typeof formInstance.validateField === "function") {
1129
+ formInstance.validateField(fieldPath);
1130
+ }
1131
+ });
1132
+ }
1133
+ return {
1134
+ handleFormatFileList,
1135
+ handleRemoveFile,
1136
+ handleFileSuccessFile,
1137
+ handleCheckFileRequire
1138
+ };
1139
+ }
1140
+ function installComponent(component) {
1141
+ component.install = function install3(Vue2) {
1142
+ Vue2.component(component.name, component);
1143
+ };
1144
+ }
1145
+ installComponent(NsForm);
1146
+ installComponent(NsFormTitle);
1147
+ const originalNsFormInstall = NsForm.install;
1148
+ NsForm.install = function install(Vue2) {
1149
+ registerDirective(Vue2);
1150
+ originalNsFormInstall(Vue2);
1151
+ };
1152
+ function getAllFormKvData(rows) {
1153
+ const result = {};
1154
+ (rows || []).forEach((row) => {
1155
+ (row || []).forEach((item) => {
1156
+ if (item && item.key) {
1157
+ result[item.key] = Array.isArray(item.value) && Array.isArray(item.delValue) ? item.value.concat(item.delValue) : item.value;
1158
+ }
1159
+ (item.children || []).forEach((child) => {
1160
+ if (child && child.key) {
1161
+ result[child.key] = Array.isArray(child.value) && Array.isArray(child.delValue) ? child.value.concat(child.delValue) : child.value;
1162
+ }
1163
+ });
1164
+ });
1165
+ });
1166
+ return result;
1167
+ }
1168
+ function getAllFormNodeByKey(rows, key) {
1169
+ for (let rowIndex = 0; rowIndex < (rows || []).length; rowIndex += 1) {
1170
+ const row = rows[rowIndex] || [];
1171
+ for (let colIndex = 0; colIndex < row.length; colIndex += 1) {
1172
+ const item = row[colIndex];
1173
+ if (item && item.key === key) {
1174
+ return item;
1175
+ }
1176
+ const children = item && item.children || [];
1177
+ for (let childIndex = 0; childIndex < children.length; childIndex += 1) {
1178
+ if (children[childIndex] && children[childIndex].key === key) {
1179
+ return children[childIndex];
1180
+ }
1181
+ }
1182
+ }
1183
+ }
1184
+ return null;
1185
+ }
1186
+ function getAllFormNodeRefByKey(rows, key) {
1187
+ const node = getAllFormNodeByKey(rows, key);
1188
+ return node ? node.ref || null : null;
1189
+ }
1190
+ if (typeof globalThis !== "undefined") {
1191
+ globalThis.getAllFormKvData = getAllFormKvData;
1192
+ globalThis.getAllFormNodeByKey = getAllFormNodeByKey;
1193
+ globalThis.getAllFormNodeRefByKey = getAllFormNodeRefByKey;
1194
+ }
1195
+ const SlotRenderer = {
1196
+ name: "NsSlotRenderer",
1197
+ functional: true,
1198
+ props: {
1199
+ renderer: {
1200
+ type: Function,
1201
+ default: null
1202
+ },
1203
+ scope: {
1204
+ type: Object,
1205
+ default: () => ({})
1206
+ }
1207
+ },
1208
+ render(h, ctx) {
1209
+ const renderer = ctx.props.renderer;
1210
+ return renderer ? renderer(ctx.props.scope || {}) : null;
1211
+ }
1212
+ };
1213
+ const PageSearch_vue_vue_type_style_index_0_scoped_9eea70d9_lang = "";
1214
+ function toKebabCase(value) {
1215
+ if (typeof value !== "string")
1216
+ return value;
1217
+ if (value.indexOf("-") > -1)
1218
+ return value.toLowerCase();
1219
+ return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1220
+ }
1221
+ const _sfc_main$3 = {
1222
+ name: "NsSearch",
1223
+ components: {
1224
+ SlotRenderer
1225
+ },
1226
+ inheritAttrs: false,
1227
+ props: {
1228
+ items: {
1229
+ type: Array,
1230
+ default: () => []
1231
+ },
1232
+ externalParams: {
1233
+ type: Object,
1234
+ default: () => ({})
1235
+ },
1236
+ defaultSpan: {
1237
+ type: Number,
1238
+ default: 6
1239
+ },
1240
+ showCollapse: {
1241
+ type: Boolean,
1242
+ default: true
1243
+ },
1244
+ collapseLimit: {
1245
+ type: Number,
1246
+ default: 3
1247
+ },
1248
+ slotRenderers: {
1249
+ type: Object,
1250
+ default: () => ({})
1251
+ }
1252
+ },
1253
+ data() {
1254
+ return {
1255
+ formData: {},
1256
+ isCollapsed: true
1257
+ };
1258
+ },
1259
+ computed: {
1260
+ visibleItems() {
1261
+ if (!this.showCollapse || !this.isCollapsed) {
1262
+ return this.items;
1263
+ }
1264
+ return this.items.slice(0, this.collapseLimit);
1265
+ }
1266
+ },
1267
+ watch: {
1268
+ items: {
1269
+ handler() {
1270
+ this.initFormData();
1271
+ },
1272
+ deep: true,
1273
+ immediate: true
1274
+ },
1275
+ externalParams: {
1276
+ handler() {
1277
+ this.formData = {
1278
+ ...this.formData,
1279
+ ...this.externalParams
1280
+ };
1281
+ },
1282
+ deep: true,
1283
+ immediate: true
1284
+ }
1285
+ },
1286
+ methods: {
1287
+ normalizeComponent(component) {
1288
+ return typeof component === "string" ? toKebabCase(component) : component;
1289
+ },
1290
+ initFormData() {
1291
+ const nextData = {};
1292
+ (this.items || []).forEach((item) => {
1293
+ nextData[item.prop] = item.defaultValue !== void 0 ? item.defaultValue : void 0;
1294
+ });
1295
+ this.formData = {
1296
+ ...nextData,
1297
+ ...this.externalParams
1298
+ };
1299
+ },
1300
+ isSlotItem(item) {
1301
+ return item && (item.type === "slot" || item.slot === true || typeof item.slot === "string");
1302
+ },
1303
+ getSlotRenderer(item) {
1304
+ const name = typeof item.slot === "string" ? item.slot : item.slotName || item.prop;
1305
+ return this.slotRenderers[name] || null;
1306
+ },
1307
+ isSelectComponent(item) {
1308
+ const name = String(this.normalizeComponent(item.component || "") || "");
1309
+ return name === "el-select";
1310
+ },
1311
+ handleSearch() {
1312
+ this.$emit("search", { ...this.formData, _resetPage: true });
1313
+ },
1314
+ handleReset() {
1315
+ const nextData = {};
1316
+ (this.items || []).forEach((item) => {
1317
+ nextData[item.prop] = item.defaultValue !== void 0 ? item.defaultValue : void 0;
1318
+ });
1319
+ this.formData = {
1320
+ ...nextData,
1321
+ ...this.externalParams
1322
+ };
1323
+ this.$emit("search", { ...this.formData, _resetPage: true });
1324
+ this.$emit("reset");
1325
+ },
1326
+ toggleCollapse() {
1327
+ this.isCollapsed = !this.isCollapsed;
1328
+ },
1329
+ getFormData() {
1330
+ return { ...this.formData };
1331
+ },
1332
+ setFormData(data) {
1333
+ this.formData = {
1334
+ ...this.formData,
1335
+ ...data || {}
1336
+ };
1337
+ },
1338
+ resetForm() {
1339
+ this.handleReset();
1340
+ },
1341
+ validate() {
1342
+ return this.$refs.formRef && this.$refs.formRef.validate ? this.$refs.formRef.validate() : Promise.resolve(true);
1343
+ },
1344
+ clearValidate(props) {
1345
+ if (this.$refs.formRef && this.$refs.formRef.clearValidate) {
1346
+ this.$refs.formRef.clearValidate(props);
1347
+ }
1348
+ }
1349
+ }
1350
+ };
1351
+ var _sfc_render$3 = function render3() {
1352
+ var _vm = this, _c = _vm._self._c;
1353
+ return _c("div", { staticClass: "page-search" }, [_c("el-form", _vm._b({ ref: "formRef", staticClass: "page-search__form", attrs: { "inline": true, "model": _vm.formData } }, "el-form", _vm.$attrs, false), [_c("el-row", { attrs: { "gutter": 16 } }, [_vm._l(_vm.visibleItems, function(item, index2) {
1354
+ return _c("el-col", { key: item.prop || index2, attrs: { "span": item.span || _vm.defaultSpan } }, [_c("el-form-item", _vm._b({ attrs: { "label": item.label, "prop": item.prop } }, "el-form-item", item.formItemAttrs || {}, false), [_vm.isSlotItem(item) ? _c("slot-renderer", { attrs: { "renderer": _vm.getSlotRenderer(item), "scope": { formData: _vm.formData, item } } }) : _c(_vm.normalizeComponent(item.component || "el-input"), _vm._g(_vm._b({ tag: "component", model: { value: _vm.formData[item.prop], callback: function($$v) {
1355
+ _vm.$set(_vm.formData, item.prop, $$v);
1356
+ }, expression: "formData[item.prop]" } }, "component", item.attrs || {}, false), item.events || {}), [_vm.isSelectComponent(item) ? _vm._l(item.children || [], function(option, optionIndex) {
1357
+ return _c("el-option", { key: option.value !== void 0 ? option.value : optionIndex, attrs: { "label": option.label, "value": option.value, "disabled": option.disabled } });
1358
+ }) : _vm._e()], 2)], 1)], 1);
1359
+ }), _c("el-col", { staticClass: "page-search__actions", attrs: { "span": _vm.defaultSpan } }, [_c("el-form-item", { attrs: { "label-width": "0" } }, [_c("el-button", { attrs: { "type": "primary" }, on: { "click": _vm.handleSearch } }, [_vm._v("查询")]), _c("el-button", { on: { "click": _vm.handleReset } }, [_vm._v("重置")]), _vm.showCollapse && _vm.items.length > _vm.collapseLimit ? _c("el-button", { attrs: { "type": "text" }, on: { "click": _vm.toggleCollapse } }, [_vm._v(" " + _vm._s(_vm.isCollapsed ? "展开" : "收起") + " ")]) : _vm._e()], 1)], 1)], 2)], 1)], 1);
1360
+ };
1361
+ var _sfc_staticRenderFns$3 = [];
1362
+ var __component__$3 = /* @__PURE__ */ normalizeComponent(
1363
+ _sfc_main$3,
1364
+ _sfc_render$3,
1365
+ _sfc_staticRenderFns$3,
1366
+ false,
1367
+ null,
1368
+ "9eea70d9",
1369
+ null,
1370
+ null
1371
+ );
1372
+ const NsSearch = __component__$3.exports;
1373
+ const RESERVED_KEYS = [
1374
+ "children",
1375
+ "slot",
1376
+ "headerSlot",
1377
+ "buttons",
1378
+ "enum",
1379
+ "type",
1380
+ "imageWidth",
1381
+ "imageHeight",
1382
+ "linkText"
1383
+ ];
1384
+ const TableColumn = {
1385
+ name: "NsTableColumn",
1386
+ props: {
1387
+ column: {
1388
+ type: Object,
1389
+ required: true
1390
+ },
1391
+ slotRenderers: {
1392
+ type: Object,
1393
+ default: () => ({})
1394
+ }
1395
+ },
1396
+ methods: {
1397
+ getColumnProps(column) {
1398
+ const props = { ...column };
1399
+ RESERVED_KEYS.forEach((key) => delete props[key]);
1400
+ return props;
1401
+ },
1402
+ getRenderer(name) {
1403
+ return name ? this.slotRenderers[name] : null;
1404
+ },
1405
+ getCellValue(row, column) {
1406
+ return column.prop ? row[column.prop] : void 0;
1407
+ },
1408
+ isVisible(config, row) {
1409
+ if (typeof config.show === "function") {
1410
+ return config.show(row) !== false;
1411
+ }
1412
+ if (config.show === void 0) {
1413
+ return true;
1414
+ }
1415
+ return !!config.show;
1416
+ },
1417
+ isDisabled(config, row) {
1418
+ return typeof config.disabled === "function" ? !!config.disabled(row) : !!config.disabled;
1419
+ },
1420
+ renderActionButtons(h, scope, column) {
1421
+ const buttons = Array.isArray(column.buttons) ? column.buttons : [];
1422
+ return buttons.filter((button) => this.isVisible(button, scope.row)).map((button, index2) => {
1423
+ const slotRenderer = this.getRenderer(button.slot);
1424
+ if (slotRenderer) {
1425
+ return slotRenderer({ ...scope, row: scope.row, column, button });
1426
+ }
1427
+ return h(
1428
+ "el-button",
1429
+ {
1430
+ key: button.label || index2,
1431
+ props: {
1432
+ size: button.size || "mini",
1433
+ type: button.link ? "text" : button.type || "text",
1434
+ icon: typeof button.icon === "string" ? button.icon : void 0,
1435
+ disabled: this.isDisabled(button, scope.row)
1436
+ },
1437
+ on: {
1438
+ click: () => {
1439
+ if (typeof button.handler === "function") {
1440
+ button.handler(scope.row, scope.$index);
1441
+ }
1442
+ this.$emit("button-click", scope.row, column, button);
1443
+ }
1444
+ }
1445
+ },
1446
+ [button.label]
1447
+ );
1448
+ });
1449
+ },
1450
+ renderTag(h, scope, column) {
1451
+ const cellValue = this.getCellValue(scope.row, column);
1452
+ const tagType = typeof column.tagType === "function" ? column.tagType(scope.row, cellValue) : column.tagType;
1453
+ const text = typeof column.formatter === "function" ? column.formatter(scope.row, column, cellValue) : this.resolveEnumText(column, cellValue);
1454
+ return h("el-tag", { props: { type: tagType || "info", size: column.tagSize || "small" } }, [text]);
1455
+ },
1456
+ renderImage(h, scope, column) {
1457
+ const src = this.getCellValue(scope.row, column);
1458
+ if (!src) {
1459
+ return "-";
1460
+ }
1461
+ return h("img", {
1462
+ style: {
1463
+ width: column.imageWidth || "40px",
1464
+ height: column.imageHeight || "40px",
1465
+ objectFit: "cover",
1466
+ borderRadius: "4px"
1467
+ },
1468
+ attrs: {
1469
+ src,
1470
+ alt: column.label || "image"
1471
+ }
1472
+ });
1473
+ },
1474
+ renderLink(h, scope, column) {
1475
+ const renderer = this.getRenderer(column.slot);
1476
+ if (renderer) {
1477
+ return renderer(scope);
1478
+ }
1479
+ const cellValue = this.getCellValue(scope.row, column);
1480
+ return h(
1481
+ "el-button",
1482
+ {
1483
+ props: {
1484
+ type: "text"
1485
+ },
1486
+ on: {
1487
+ click: () => this.$emit("link-click", scope.row, column)
1488
+ }
1489
+ },
1490
+ [column.linkText || cellValue || "-"]
1491
+ );
1492
+ },
1493
+ resolveEnumText(column, value) {
1494
+ const enumList = column.enum || column.options || [];
1495
+ if (!Array.isArray(enumList)) {
1496
+ return value;
1497
+ }
1498
+ const matched = enumList.find((item) => item.value === value);
1499
+ return matched ? matched.label : value;
1500
+ },
1501
+ renderDefaultCell(h, scope, column) {
1502
+ const renderer = this.getRenderer(column.slot);
1503
+ if (renderer) {
1504
+ return renderer(scope);
1505
+ }
1506
+ if (column.type === "action") {
1507
+ return h("div", { class: "ns-table-column__actions" }, this.renderActionButtons(h, scope, column));
1508
+ }
1509
+ if (column.type === "tag") {
1510
+ return this.renderTag(h, scope, column);
1511
+ }
1512
+ if (column.type === "image") {
1513
+ return this.renderImage(h, scope, column);
1514
+ }
1515
+ if (column.type === "link") {
1516
+ return this.renderLink(h, scope, column);
1517
+ }
1518
+ const cellValue = this.getCellValue(scope.row, column);
1519
+ if (typeof column.formatter === "function") {
1520
+ return column.formatter(scope.row, column, cellValue);
1521
+ }
1522
+ if (column.enum) {
1523
+ return this.resolveEnumText(column, cellValue);
1524
+ }
1525
+ return cellValue === void 0 || cellValue === null || cellValue === "" ? "-" : cellValue;
1526
+ },
1527
+ renderColumn(h, column) {
1528
+ const children = Array.isArray(column.children) ? column.children.map(
1529
+ (child, index2) => h(TableColumn, {
1530
+ key: child.prop || child.label || index2,
1531
+ props: {
1532
+ column: child,
1533
+ slotRenderers: this.slotRenderers
1534
+ },
1535
+ on: {
1536
+ "link-click": (...args) => this.$emit("link-click", ...args),
1537
+ "button-click": (...args) => this.$emit("button-click", ...args)
1538
+ }
1539
+ })
1540
+ ) : [];
1541
+ const headerRenderer = this.getRenderer(column.headerSlot);
1542
+ return h(
1543
+ "el-table-column",
1544
+ {
1545
+ props: this.getColumnProps(column),
1546
+ scopedSlots: children.length ? headerRenderer ? { header: headerRenderer } : void 0 : {
1547
+ default: (scope) => this.renderDefaultCell(h, scope, column),
1548
+ ...headerRenderer ? { header: headerRenderer } : {}
1549
+ }
1550
+ },
1551
+ children
1552
+ );
1553
+ }
1554
+ },
1555
+ render(h) {
1556
+ return this.renderColumn(h, this.column);
1557
+ }
1558
+ };
1559
+ const TableColumn$1 = TableColumn;
1560
+ const DEFAULT_PAGINATION = {
1561
+ total: 0,
1562
+ currentPage: 1,
1563
+ pageSize: 10
1564
+ };
1565
+ const DEFAULT_KEY_CONFIG = {
1566
+ totalKey: "total",
1567
+ currentPageKey: "currentPage",
1568
+ pageSizeKey: "pageSize"
1569
+ };
1570
+ function createPagination(customParams = {}) {
1571
+ return {
1572
+ ...DEFAULT_PAGINATION,
1573
+ ...customParams
1574
+ };
1575
+ }
1576
+ function createPaginationWithCustomKeys(pagination, keyConfig = {}) {
1577
+ const config = {
1578
+ ...DEFAULT_KEY_CONFIG,
1579
+ ...keyConfig
1580
+ };
1581
+ return {
1582
+ [config.totalKey]: pagination.total,
1583
+ [config.currentPageKey]: pagination.currentPage,
1584
+ [config.pageSizeKey]: pagination.pageSize
1585
+ };
1586
+ }
1587
+ function resetPagination(pagination) {
1588
+ pagination.total = 0;
1589
+ pagination.currentPage = 1;
1590
+ pagination.pageSize = 10;
1591
+ return pagination;
1592
+ }
1593
+ const PageTable_vue_vue_type_style_index_0_scoped_e9b089a2_lang = "";
1594
+ const RESERVED_LISTENERS = ["add", "selection-change", "sort-change", "row-click", "size-change", "current-change", "link-click"];
1595
+ const _sfc_main$2 = {
1596
+ name: "NsTable",
1597
+ components: {
1598
+ SlotRenderer,
1599
+ TableColumn: TableColumn$1
1600
+ },
1601
+ inheritAttrs: false,
1602
+ props: {
1603
+ tableData: {
1604
+ type: Array,
1605
+ default: () => []
1606
+ },
1607
+ columns: {
1608
+ type: Array,
1609
+ default: () => []
1610
+ },
1611
+ actionButtons: {
1612
+ type: Array,
1613
+ default: () => []
1614
+ },
1615
+ showAddButton: {
1616
+ type: Boolean,
1617
+ default: true
1618
+ },
1619
+ addButtonText: {
1620
+ type: String,
1621
+ default: "新增"
1622
+ },
1623
+ showHeaderToolbar: {
1624
+ type: Boolean,
1625
+ default: true
1626
+ },
1627
+ showSelection: {
1628
+ type: Boolean,
1629
+ default: false
1630
+ },
1631
+ showIndex: {
1632
+ type: Boolean,
1633
+ default: false
1634
+ },
1635
+ border: {
1636
+ type: Boolean,
1637
+ default: true
1638
+ },
1639
+ stripe: {
1640
+ type: Boolean,
1641
+ default: false
1642
+ },
1643
+ height: {
1644
+ type: [String, Number],
1645
+ default: void 0
1646
+ },
1647
+ maxHeight: {
1648
+ type: [String, Number],
1649
+ default: void 0
1650
+ },
1651
+ rowKey: {
1652
+ type: [String, Function],
1653
+ default: void 0
1654
+ },
1655
+ defaultExpandAll: {
1656
+ type: Boolean,
1657
+ default: false
1658
+ },
1659
+ highlightCurrentRow: {
1660
+ type: Boolean,
1661
+ default: false
1662
+ },
1663
+ loading: {
1664
+ type: Boolean,
1665
+ default: false
1666
+ },
1667
+ showPagination: {
1668
+ type: Boolean,
1669
+ default: true
1670
+ },
1671
+ total: {
1672
+ type: Number,
1673
+ default: 0
1674
+ },
1675
+ currentPage: {
1676
+ type: Number,
1677
+ default: null
1678
+ },
1679
+ pageSize: {
1680
+ type: Number,
1681
+ default: null
1682
+ },
1683
+ pageSizes: {
1684
+ type: Array,
1685
+ default: () => [10, 20, 50, 100]
1686
+ },
1687
+ paginationLayout: {
1688
+ type: String,
1689
+ default: "total, sizes, prev, pager, next, jumper"
1690
+ },
1691
+ pageNumberKey: {
1692
+ type: String,
1693
+ default: "currentPage"
1694
+ },
1695
+ pageSizeKey: {
1696
+ type: String,
1697
+ default: "pageSize"
1698
+ },
1699
+ pageTotalKey: {
1700
+ type: String,
1701
+ default: "total"
1702
+ },
1703
+ slotRenderers: {
1704
+ type: Object,
1705
+ default: () => ({})
1706
+ }
1707
+ },
1708
+ data() {
1709
+ return {
1710
+ internalPagination: createPagination()
1711
+ };
1712
+ },
1713
+ computed: {
1714
+ currentPageModel() {
1715
+ return this.currentPage === null ? this.internalPagination.currentPage : this.currentPage;
1716
+ },
1717
+ pageSizeModel() {
1718
+ return this.pageSize === null ? this.internalPagination.pageSize : this.pageSize;
1719
+ },
1720
+ mergedAttrs() {
1721
+ return this.$attrs || {};
1722
+ },
1723
+ mergedListeners() {
1724
+ const listeners = { ...this.$listeners || {} };
1725
+ RESERVED_LISTENERS.forEach((name) => delete listeners[name]);
1726
+ return listeners;
1727
+ }
1728
+ },
1729
+ watch: {
1730
+ currentPage: {
1731
+ handler(value) {
1732
+ if (value !== null) {
1733
+ this.internalPagination.currentPage = value;
1734
+ }
1735
+ },
1736
+ immediate: true
1737
+ },
1738
+ pageSize: {
1739
+ handler(value) {
1740
+ if (value !== null) {
1741
+ this.internalPagination.pageSize = value;
1742
+ }
1743
+ },
1744
+ immediate: true
1745
+ }
1746
+ },
1747
+ methods: {
1748
+ handleAdd() {
1749
+ this.$emit("add");
1750
+ },
1751
+ handleSelectionChange(selection) {
1752
+ this.$emit("selection-change", selection);
1753
+ },
1754
+ handleSortChange(sort) {
1755
+ this.$emit("sort-change", sort);
1756
+ },
1757
+ handleRowClick(row, column, event) {
1758
+ this.$emit("row-click", row, column, event);
1759
+ },
1760
+ handleSizeChange(size) {
1761
+ this.internalPagination.pageSize = size;
1762
+ this.$emit("update:pageSize", size);
1763
+ this.$emit("size-change", size);
1764
+ },
1765
+ handleCurrentChange(page) {
1766
+ this.internalPagination.currentPage = page;
1767
+ this.$emit("update:currentPage", page);
1768
+ this.$emit("current-change", page);
1769
+ },
1770
+ handleLinkClick(row, column) {
1771
+ this.$emit("link-click", row, column);
1772
+ },
1773
+ getIndex(index2) {
1774
+ if (!this.showPagination) {
1775
+ return index2 + 1;
1776
+ }
1777
+ const currentPage = Number(this.currentPageModel || 1);
1778
+ const pageSize = Number(this.pageSizeModel || 10);
1779
+ return (currentPage - 1) * pageSize + index2 + 1;
1780
+ },
1781
+ getSelectionRows() {
1782
+ return this.$refs.tableRef && this.$refs.tableRef.selection ? this.$refs.tableRef.selection : [];
1783
+ },
1784
+ getSelectionKeys() {
1785
+ const rows = this.getSelectionRows();
1786
+ if (!this.rowKey) {
1787
+ return rows;
1788
+ }
1789
+ return rows.map((row) => typeof this.rowKey === "function" ? this.rowKey(row) : row[this.rowKey]);
1790
+ },
1791
+ setSelectionRows(rows) {
1792
+ if (!this.$refs.tableRef)
1793
+ return;
1794
+ this.$refs.tableRef.clearSelection();
1795
+ (rows || []).forEach((row) => {
1796
+ this.$refs.tableRef.toggleRowSelection(row, true);
1797
+ });
1798
+ },
1799
+ setSelectionKeys(keys) {
1800
+ if (!this.$refs.tableRef || !this.rowKey)
1801
+ return;
1802
+ this.$refs.tableRef.clearSelection();
1803
+ (keys || []).forEach((key) => {
1804
+ const row = (this.tableData || []).find((item) => (typeof this.rowKey === "function" ? this.rowKey(item) : item[this.rowKey]) === key);
1805
+ if (row) {
1806
+ this.$refs.tableRef.toggleRowSelection(row, true);
1807
+ }
1808
+ });
1809
+ },
1810
+ isRowSelected(row) {
1811
+ return this.getSelectionRows().includes(row);
1812
+ },
1813
+ isKeySelected(key) {
1814
+ return this.getSelectionKeys().includes(key);
1815
+ },
1816
+ clearSelection() {
1817
+ if (this.$refs.tableRef) {
1818
+ this.$refs.tableRef.clearSelection();
1819
+ }
1820
+ },
1821
+ toggleRowSelection(row, selected) {
1822
+ if (this.$refs.tableRef) {
1823
+ this.$refs.tableRef.toggleRowSelection(row, selected);
1824
+ }
1825
+ },
1826
+ toggleAllSelection() {
1827
+ if (this.$refs.tableRef) {
1828
+ this.$refs.tableRef.toggleAllSelection();
1829
+ }
1830
+ },
1831
+ selectAll() {
1832
+ this.toggleAllSelection();
1833
+ },
1834
+ clearAllSelection() {
1835
+ this.clearSelection();
1836
+ },
1837
+ clearSort() {
1838
+ this.$refs.tableRef && this.$refs.tableRef.clearSort && this.$refs.tableRef.clearSort();
1839
+ },
1840
+ clearFilter(columnKey) {
1841
+ this.$refs.tableRef && this.$refs.tableRef.clearFilter && this.$refs.tableRef.clearFilter(columnKey);
1842
+ },
1843
+ doLayout() {
1844
+ this.$refs.tableRef && this.$refs.tableRef.doLayout && this.$refs.tableRef.doLayout();
1845
+ },
1846
+ sort(prop, order) {
1847
+ this.$refs.tableRef && this.$refs.tableRef.sort && this.$refs.tableRef.sort(prop, order);
1848
+ },
1849
+ resetPage() {
1850
+ this.internalPagination.currentPage = 1;
1851
+ this.$emit("update:currentPage", 1);
1852
+ },
1853
+ setPage(page) {
1854
+ this.internalPagination.currentPage = page;
1855
+ this.$emit("update:currentPage", page);
1856
+ },
1857
+ setPageSize(size) {
1858
+ this.internalPagination.pageSize = size;
1859
+ this.$emit("update:pageSize", size);
1860
+ },
1861
+ getPagination() {
1862
+ return {
1863
+ [this.pageTotalKey]: this.total,
1864
+ [this.pageNumberKey]: this.currentPageModel,
1865
+ [this.pageSizeKey]: this.pageSizeModel
1866
+ };
1867
+ },
1868
+ setPagination(pagination) {
1869
+ if (pagination.currentPage !== void 0) {
1870
+ this.setPage(pagination.currentPage);
1871
+ }
1872
+ if (pagination.pageSize !== void 0) {
1873
+ this.setPageSize(pagination.pageSize);
1874
+ }
1875
+ }
1876
+ }
1877
+ };
1878
+ var _sfc_render$2 = function render4() {
1879
+ var _vm = this, _c = _vm._self._c;
1880
+ return _c("div", { staticClass: "page-table" }, [_vm.showHeaderToolbar ? _c("div", { staticClass: "page-table__header" }, [_c("slot-renderer", { attrs: { "renderer": _vm.slotRenderers["header-left"], "scope": { tableData: _vm.tableData } } }), _c("div", { staticClass: "page-table__actions" }, [_c("slot-renderer", { attrs: { "renderer": _vm.slotRenderers["header-actions"], "scope": { tableData: _vm.tableData } } }), _vm.showAddButton && !_vm.slotRenderers["header-actions"] ? _c("el-button", { attrs: { "type": "primary", "size": "small" }, on: { "click": _vm.handleAdd } }, [_vm._v(" " + _vm._s(_vm.addButtonText) + " ")]) : _vm._e()], 1)], 1) : _vm._e(), _c("el-table", _vm._g(_vm._b({ directives: [{ name: "loading", rawName: "v-loading", value: _vm.loading, expression: "loading" }], ref: "tableRef", attrs: { "data": _vm.tableData, "border": _vm.border, "stripe": _vm.stripe, "height": _vm.height, "max-height": _vm.maxHeight, "row-key": _vm.rowKey, "default-expand-all": _vm.defaultExpandAll, "highlight-current-row": _vm.highlightCurrentRow }, on: { "selection-change": _vm.handleSelectionChange, "sort-change": _vm.handleSortChange, "row-click": _vm.handleRowClick } }, "el-table", _vm.mergedAttrs, false), _vm.mergedListeners), [_vm.showSelection ? _c("el-table-column", { attrs: { "type": "selection", "width": "55", "reserve-selection": !!_vm.rowKey } }) : _vm._e(), _vm.showIndex ? _c("el-table-column", { attrs: { "type": "index", "label": "序号", "width": "60", "index": _vm.getIndex } }) : _vm._e(), _vm._l(_vm.columns, function(column, index2) {
1881
+ return _c("table-column", { key: column.prop || column.label || index2, attrs: { "column": column, "slot-renderers": _vm.slotRenderers }, on: { "link-click": _vm.handleLinkClick } });
1882
+ }), _c("template", { slot: "empty" }, [_vm.slotRenderers.empty ? _c("slot-renderer", { attrs: { "renderer": _vm.slotRenderers.empty, "scope": { tableData: _vm.tableData } } }) : _c("div", { staticClass: "page-table__empty" }, [_vm._v("暂无数据")])], 1)], 2), _vm.showPagination ? _c("div", { staticClass: "page-table__pagination" }, [_c("el-pagination", { attrs: { "background": "", "current-page": _vm.currentPageModel, "page-size": _vm.pageSizeModel, "page-sizes": _vm.pageSizes, "total": _vm.total, "layout": _vm.paginationLayout }, on: { "size-change": _vm.handleSizeChange, "current-change": _vm.handleCurrentChange } })], 1) : _vm._e()], 1);
1883
+ };
1884
+ var _sfc_staticRenderFns$2 = [];
1885
+ var __component__$2 = /* @__PURE__ */ normalizeComponent(
1886
+ _sfc_main$2,
1887
+ _sfc_render$2,
1888
+ _sfc_staticRenderFns$2,
1889
+ false,
1890
+ null,
1891
+ "e9b089a2",
1892
+ null,
1893
+ null
1894
+ );
1895
+ const NsTable = __component__$2.exports;
1896
+ const PageContainer_vue_vue_type_style_index_0_scoped_400797f6_lang = "";
1897
+ const _sfc_main$1 = {
1898
+ name: "NsTableContainer",
1899
+ components: {
1900
+ PageSearch: NsSearch,
1901
+ PageTable: NsTable
1902
+ },
1903
+ props: {
1904
+ showSearch: {
1905
+ type: Boolean,
1906
+ default: true
1907
+ },
1908
+ externalSearchParams: {
1909
+ type: Object,
1910
+ default: () => ({})
1911
+ },
1912
+ searchItems: {
1913
+ type: Array,
1914
+ default: () => []
1915
+ },
1916
+ tableData: {
1917
+ type: Array,
1918
+ default: () => []
1919
+ },
1920
+ columns: {
1921
+ type: Array,
1922
+ default: () => []
1923
+ },
1924
+ actionButtons: {
1925
+ type: Array,
1926
+ default: () => []
1927
+ },
1928
+ total: {
1929
+ type: Number,
1930
+ default: 0
1931
+ },
1932
+ currentPage: {
1933
+ type: Number,
1934
+ default: null
1935
+ },
1936
+ pageSize: {
1937
+ type: Number,
1938
+ default: null
1939
+ },
1940
+ pageNumberKey: {
1941
+ type: String,
1942
+ default: "currentPage"
1943
+ },
1944
+ pageSizeKey: {
1945
+ type: String,
1946
+ default: "pageSize"
1947
+ },
1948
+ pageTotalKey: {
1949
+ type: String,
1950
+ default: "total"
1951
+ },
1952
+ searchProps: {
1953
+ type: Object,
1954
+ default: () => ({})
1955
+ },
1956
+ tableProps: {
1957
+ type: Object,
1958
+ default: () => ({})
1959
+ },
1960
+ loadData: {
1961
+ type: Function,
1962
+ default: null
1963
+ }
1964
+ },
1965
+ data() {
1966
+ return {
1967
+ internalPagination: createPagination(),
1968
+ pendingSelectionKeys: /* @__PURE__ */ new Set(),
1969
+ selectionRowMap: {},
1970
+ isSyncingSelection: false
1971
+ };
1972
+ },
1973
+ computed: {
1974
+ currentPageModel() {
1975
+ return this.currentPage === null ? this.internalPagination.currentPage : this.currentPage;
1976
+ },
1977
+ pageSizeModel() {
1978
+ return this.pageSize === null ? this.internalPagination.pageSize : this.pageSize;
1979
+ },
1980
+ currentRowKey() {
1981
+ return this.tableProps && this.tableProps.rowKey;
1982
+ }
1983
+ },
1984
+ watch: {
1985
+ currentPage: {
1986
+ handler(value) {
1987
+ if (value !== null) {
1988
+ this.internalPagination.currentPage = value;
1989
+ }
1990
+ },
1991
+ immediate: true
1992
+ },
1993
+ pageSize: {
1994
+ handler(value) {
1995
+ if (value !== null) {
1996
+ this.internalPagination.pageSize = value;
1997
+ }
1998
+ },
1999
+ immediate: true
2000
+ },
2001
+ tableData: {
2002
+ handler() {
2003
+ this.$nextTick(() => {
2004
+ this.syncSelectionToCurrentPage();
2005
+ });
2006
+ },
2007
+ deep: true,
2008
+ immediate: true
2009
+ }
2010
+ },
2011
+ methods: {
2012
+ getRowKey(row) {
2013
+ if (!this.currentRowKey)
2014
+ return row;
2015
+ return typeof this.currentRowKey === "function" ? this.currentRowKey(row) : row[this.currentRowKey];
2016
+ },
2017
+ resetSelectionState() {
2018
+ this.pendingSelectionKeys = /* @__PURE__ */ new Set();
2019
+ this.selectionRowMap = {};
2020
+ this.$refs.tableRef && this.$refs.tableRef.clearSelection && this.$refs.tableRef.clearSelection();
2021
+ },
2022
+ syncSelectionToCurrentPage() {
2023
+ if (!this.currentRowKey || !this.$refs.tableRef) {
2024
+ return;
2025
+ }
2026
+ this.isSyncingSelection = true;
2027
+ this.$refs.tableRef.clearSelection();
2028
+ (this.tableData || []).forEach((row) => {
2029
+ const key = this.getRowKey(row);
2030
+ if (this.pendingSelectionKeys.has(key)) {
2031
+ this.$set(this.selectionRowMap, key, row);
2032
+ this.$refs.tableRef.toggleRowSelection(row, true);
2033
+ }
2034
+ });
2035
+ this.$nextTick(() => {
2036
+ this.isSyncingSelection = false;
2037
+ });
2038
+ },
2039
+ handleSearch(params) {
2040
+ this.resetSelectionState();
2041
+ if (params && params._resetPage) {
2042
+ const { _resetPage, ...searchParams } = params;
2043
+ this.internalPagination.currentPage = 1;
2044
+ this.$emit("update:currentPage", 1);
2045
+ this.$emit("search", searchParams);
2046
+ return;
2047
+ }
2048
+ this.$emit("search", params);
2049
+ },
2050
+ handleReset() {
2051
+ this.resetSelectionState();
2052
+ this.$emit("reset");
2053
+ },
2054
+ handleAdd() {
2055
+ this.$emit("add");
2056
+ },
2057
+ handleSizeChange(size) {
2058
+ this.internalPagination.pageSize = size;
2059
+ this.$emit("update:pageSize", size);
2060
+ this.$emit("size-change", size);
2061
+ this.$emit("page-change", {
2062
+ currentPage: this.currentPageModel,
2063
+ pageSize: size
2064
+ });
2065
+ if (this.loadData) {
2066
+ this.loadData();
2067
+ }
2068
+ },
2069
+ handleCurrentChange(page) {
2070
+ this.internalPagination.currentPage = page;
2071
+ this.$emit("update:currentPage", page);
2072
+ this.$emit("current-change", page);
2073
+ this.$emit("page-change", {
2074
+ currentPage: page,
2075
+ pageSize: this.pageSizeModel
2076
+ });
2077
+ if (this.loadData) {
2078
+ this.loadData();
2079
+ }
2080
+ },
2081
+ handleSelectionChange(selection) {
2082
+ if (this.isSyncingSelection) {
2083
+ return;
2084
+ }
2085
+ if (!this.currentRowKey) {
2086
+ this.$emit("selection-change", selection);
2087
+ return;
2088
+ }
2089
+ const currentPageKeys = (this.tableData || []).map((row) => this.getRowKey(row));
2090
+ currentPageKeys.forEach((key) => {
2091
+ this.pendingSelectionKeys.delete(key);
2092
+ this.$delete(this.selectionRowMap, key);
2093
+ });
2094
+ (selection || []).forEach((row) => {
2095
+ const key = this.getRowKey(row);
2096
+ this.pendingSelectionKeys.add(key);
2097
+ this.$set(this.selectionRowMap, key, row);
2098
+ });
2099
+ this.$emit("selection-change", Object.values(this.selectionRowMap));
2100
+ },
2101
+ handleSortChange(sort) {
2102
+ this.$emit("sort-change", sort);
2103
+ },
2104
+ handleRowClick(row, column, event) {
2105
+ this.$emit("row-click", row, column, event);
2106
+ },
2107
+ handleLinkClick(row, column) {
2108
+ this.$emit("link-click", row, column);
2109
+ },
2110
+ initSearchAndLoad() {
2111
+ this.$nextTick(() => {
2112
+ if (this.showSearch && this.$refs.searchRef) {
2113
+ this.$emit("search", this.$refs.searchRef.getFormData());
2114
+ return;
2115
+ }
2116
+ if (this.loadData) {
2117
+ this.loadData();
2118
+ }
2119
+ });
2120
+ },
2121
+ getSearchFormData() {
2122
+ return this.$refs.searchRef ? this.$refs.searchRef.getFormData() : {};
2123
+ },
2124
+ setSearchFormData(data) {
2125
+ this.$refs.searchRef && this.$refs.searchRef.setFormData(data);
2126
+ },
2127
+ resetSearchForm() {
2128
+ this.$refs.searchRef && this.$refs.searchRef.resetForm();
2129
+ },
2130
+ validateSearchForm() {
2131
+ return this.$refs.searchRef ? this.$refs.searchRef.validate() : Promise.resolve(true);
2132
+ },
2133
+ getPagination() {
2134
+ return {
2135
+ [this.pageTotalKey]: this.total,
2136
+ [this.pageNumberKey]: this.currentPageModel,
2137
+ [this.pageSizeKey]: this.pageSizeModel
2138
+ };
2139
+ },
2140
+ getSelectionRows() {
2141
+ var _a, _b;
2142
+ return this.currentRowKey ? Object.values(this.selectionRowMap) : ((_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.getSelectionRows) == null ? void 0 : _b.call(_a)) || [];
2143
+ },
2144
+ getSelectionKeys() {
2145
+ var _a, _b;
2146
+ return this.currentRowKey ? Array.from(this.pendingSelectionKeys) : ((_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.getSelectionKeys) == null ? void 0 : _b.call(_a)) || [];
2147
+ },
2148
+ setSelectionRows(rows) {
2149
+ if (!this.currentRowKey) {
2150
+ this.$refs.tableRef && this.$refs.tableRef.setSelectionRows(rows);
2151
+ return;
2152
+ }
2153
+ this.pendingSelectionKeys = /* @__PURE__ */ new Set();
2154
+ this.selectionRowMap = {};
2155
+ (rows || []).forEach((row) => {
2156
+ const key = this.getRowKey(row);
2157
+ this.pendingSelectionKeys.add(key);
2158
+ this.$set(this.selectionRowMap, key, row);
2159
+ });
2160
+ this.syncSelectionToCurrentPage();
2161
+ },
2162
+ setSelectionKeys(keys) {
2163
+ if (!this.currentRowKey) {
2164
+ this.$refs.tableRef && this.$refs.tableRef.setSelectionKeys(keys);
2165
+ return;
2166
+ }
2167
+ this.pendingSelectionKeys = new Set(keys || []);
2168
+ (this.tableData || []).forEach((row) => {
2169
+ const key = this.getRowKey(row);
2170
+ if (this.pendingSelectionKeys.has(key)) {
2171
+ this.$set(this.selectionRowMap, key, row);
2172
+ }
2173
+ });
2174
+ this.syncSelectionToCurrentPage();
2175
+ },
2176
+ clearAllSelection() {
2177
+ this.resetSelectionState();
2178
+ },
2179
+ selectAll() {
2180
+ if (!this.$refs.tableRef)
2181
+ return;
2182
+ if (!this.currentRowKey) {
2183
+ this.$refs.tableRef.selectAll();
2184
+ return;
2185
+ }
2186
+ (this.tableData || []).forEach((row) => {
2187
+ const key = this.getRowKey(row);
2188
+ this.pendingSelectionKeys.add(key);
2189
+ this.$set(this.selectionRowMap, key, row);
2190
+ });
2191
+ this.$refs.tableRef.setSelectionRows(this.tableData);
2192
+ },
2193
+ isRowSelected(row) {
2194
+ var _a, _b;
2195
+ 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);
2196
+ },
2197
+ isKeySelected(key) {
2198
+ var _a, _b;
2199
+ return this.currentRowKey ? this.pendingSelectionKeys.has(key) : (_b = (_a = this.$refs.tableRef) == null ? void 0 : _a.isKeySelected) == null ? void 0 : _b.call(_a, key);
2200
+ }
2201
+ }
2202
+ };
2203
+ var _sfc_render$1 = function render5() {
2204
+ var _vm = this, _c = _vm._self._c;
2205
+ return _c("div", { staticClass: "page-container" }, [_vm.showSearch ? _c("page-search", _vm._b({ ref: "searchRef", attrs: { "items": _vm.searchItems, "external-params": _vm.externalSearchParams, "slot-renderers": _vm.$scopedSlots }, on: { "search": _vm.handleSearch, "reset": _vm.handleReset } }, "page-search", _vm.searchProps, false)) : _vm._e(), _c("page-table", _vm._b({ ref: "tableRef", attrs: { "table-data": _vm.tableData, "columns": _vm.columns, "action-buttons": _vm.actionButtons, "total": _vm.total, "current-page": _vm.currentPageModel, "page-size": _vm.pageSizeModel, "page-number-key": _vm.pageNumberKey, "page-size-key": _vm.pageSizeKey, "page-total-key": _vm.pageTotalKey, "slot-renderers": _vm.$scopedSlots }, on: { "add": _vm.handleAdd, "selection-change": _vm.handleSelectionChange, "sort-change": _vm.handleSortChange, "row-click": _vm.handleRowClick, "size-change": _vm.handleSizeChange, "current-change": _vm.handleCurrentChange, "link-click": _vm.handleLinkClick } }, "page-table", _vm.tableProps, false))], 1);
2206
+ };
2207
+ var _sfc_staticRenderFns$1 = [];
2208
+ var __component__$1 = /* @__PURE__ */ normalizeComponent(
2209
+ _sfc_main$1,
2210
+ _sfc_render$1,
2211
+ _sfc_staticRenderFns$1,
2212
+ false,
2213
+ null,
2214
+ "400797f6",
2215
+ null,
2216
+ null
2217
+ );
2218
+ const NsTableContainer = __component__$1.exports;
2219
+ [NsTableContainer, NsSearch, NsTable].forEach((component) => {
2220
+ component.install = function install3(Vue2) {
2221
+ Vue2.component(component.name, component);
2222
+ };
2223
+ });
2224
+ const NsDialog_vue_vue_type_style_index_0_scoped_4f4f8603_lang = "";
2225
+ const _sfc_main = {
2226
+ name: "NsDialogComponent",
2227
+ props: {
2228
+ className: {
2229
+ type: String,
2230
+ default: ""
2231
+ },
2232
+ title: {
2233
+ type: String,
2234
+ default: ""
2235
+ },
2236
+ width: {
2237
+ type: [Number, String],
2238
+ default: 500
2239
+ },
2240
+ height: {
2241
+ type: [Number, String],
2242
+ default: ""
2243
+ },
2244
+ modal: {
2245
+ type: Boolean,
2246
+ default: true
2247
+ },
2248
+ dialogPadding: {
2249
+ type: [Number, String, Array],
2250
+ default: -1
2251
+ },
2252
+ modalColor: {
2253
+ type: String,
2254
+ default: "rgba(0, 0, 0, 0.45)"
2255
+ },
2256
+ closeOnClickModal: {
2257
+ type: Boolean,
2258
+ default: true
2259
+ },
2260
+ dom: {
2261
+ type: [Object, Function],
2262
+ default: null
2263
+ },
2264
+ option: {
2265
+ type: Object,
2266
+ default: () => ({})
2267
+ },
2268
+ events: {
2269
+ type: Object,
2270
+ default: () => ({})
2271
+ },
2272
+ domCompleted: {
2273
+ type: Function,
2274
+ default: null
2275
+ },
2276
+ headerDom: {
2277
+ type: [Object, Function],
2278
+ default: null
2279
+ },
2280
+ headerOption: {
2281
+ type: Object,
2282
+ default: () => ({})
2283
+ },
2284
+ headerEvents: {
2285
+ type: Object,
2286
+ default: () => ({})
2287
+ },
2288
+ showFooter: {
2289
+ type: Boolean,
2290
+ default: true
2291
+ },
2292
+ footerDom: {
2293
+ type: [Object, Function],
2294
+ default: null
2295
+ },
2296
+ footerOption: {
2297
+ type: Object,
2298
+ default: () => ({})
2299
+ },
2300
+ footerTitle: {
2301
+ type: Object,
2302
+ default: () => ({
2303
+ close: "取消",
2304
+ confirm: "确定"
2305
+ })
2306
+ },
2307
+ footerEvents: {
2308
+ type: Object,
2309
+ default: () => ({})
2310
+ },
2311
+ immediately: {
2312
+ type: Boolean,
2313
+ default: false
2314
+ },
2315
+ close: {
2316
+ type: Function,
2317
+ default: null
2318
+ },
2319
+ closed: {
2320
+ type: Function,
2321
+ default: null
2322
+ },
2323
+ draggable: {
2324
+ type: Boolean,
2325
+ default: false
2326
+ },
2327
+ confirm: {
2328
+ type: Function,
2329
+ default: null
2330
+ },
2331
+ x: {
2332
+ type: [Number, String],
2333
+ default: null
2334
+ },
2335
+ y: {
2336
+ type: [Number, String],
2337
+ default: null
2338
+ },
2339
+ maxSize: {
2340
+ type: Function,
2341
+ default: null
2342
+ },
2343
+ dialogInstance: {
2344
+ type: Object,
2345
+ default: null
2346
+ },
2347
+ containerId: {
2348
+ type: String,
2349
+ default: ""
2350
+ }
2351
+ },
2352
+ data() {
2353
+ return {
2354
+ visible: false,
2355
+ currentTitle: this.title,
2356
+ currentOption: { ...this.option },
2357
+ currentWidth: this.width,
2358
+ currentHeight: this.height,
2359
+ currentX: this.x,
2360
+ currentY: this.y,
2361
+ footerLoading: false,
2362
+ isMaximized: false,
2363
+ originalSize: {
2364
+ width: this.width,
2365
+ height: this.height,
2366
+ x: this.x,
2367
+ y: this.y
2368
+ },
2369
+ dragContext: null,
2370
+ domCompletedCalled: false
2371
+ };
2372
+ },
2373
+ computed: {
2374
+ normalizedWidth() {
2375
+ return this.normalizeSize(this.currentWidth || this.width || 500);
2376
+ },
2377
+ bodyStyle() {
2378
+ const padding = this.resolvePadding();
2379
+ return {
2380
+ padding,
2381
+ minHeight: this.currentHeight ? this.normalizeSize(this.currentHeight) : "auto",
2382
+ maxHeight: this.currentHeight ? this.normalizeSize(this.currentHeight) : "none",
2383
+ overflow: "auto"
2384
+ };
2385
+ },
2386
+ dialogCustomClass() {
2387
+ return ["ns-dialog-plus", this.className, this.hasAbsolutePosition ? "ns-dialog-plus--absolute" : ""].filter(Boolean).join(" ");
2388
+ },
2389
+ modalClassName() {
2390
+ return `ns-dialog-plus-modal ns-dialog-plus-modal--${this.containerId}`;
2391
+ },
2392
+ resolvedDom() {
2393
+ return this.resolveComponent(this.dom);
2394
+ },
2395
+ resolvedHeaderDom() {
2396
+ return this.resolveComponent(this.headerDom);
2397
+ },
2398
+ resolvedFooterDom() {
2399
+ return this.resolveComponent(this.footerDom);
2400
+ },
2401
+ footerButtonText() {
2402
+ var _a, _b;
2403
+ return {
2404
+ close: ((_a = this.footerTitle) == null ? void 0 : _a.close) || "取消",
2405
+ confirm: ((_b = this.footerTitle) == null ? void 0 : _b.confirm) || "确定"
2406
+ };
2407
+ },
2408
+ showMaximizeButton() {
2409
+ return typeof this.maxSize === "function";
2410
+ },
2411
+ hasAbsolutePosition() {
2412
+ return this.currentX !== null || this.currentY !== null;
2413
+ }
2414
+ },
2415
+ watch: {
2416
+ option: {
2417
+ handler(value) {
2418
+ this.currentOption = { ...value };
2419
+ },
2420
+ deep: true
2421
+ },
2422
+ title(value) {
2423
+ this.currentTitle = value;
2424
+ },
2425
+ width(value) {
2426
+ if (!this.isMaximized)
2427
+ this.currentWidth = value;
2428
+ },
2429
+ height(value) {
2430
+ if (!this.isMaximized)
2431
+ this.currentHeight = value;
2432
+ },
2433
+ x(value) {
2434
+ if (!this.isMaximized)
2435
+ this.currentX = value;
2436
+ },
2437
+ y(value) {
2438
+ if (!this.isMaximized)
2439
+ this.currentY = value;
2440
+ },
2441
+ visible() {
2442
+ this.$nextTick(() => {
2443
+ this.applyDialogLayout();
2444
+ this.syncDialogInstance();
2445
+ this.triggerDomCompleted();
2446
+ });
2447
+ }
2448
+ },
2449
+ mounted() {
2450
+ loadCssVars$1();
2451
+ this.visible = true;
2452
+ this.updateModalStyle();
2453
+ this.syncDialogInstance();
2454
+ this.$nextTick(() => {
2455
+ this.applyDialogLayout();
2456
+ this.triggerDomCompleted();
2457
+ });
2458
+ document.addEventListener("keydown", this.handleKeydown);
2459
+ },
2460
+ updated() {
2461
+ this.syncDialogInstance();
2462
+ this.triggerDomCompleted();
2463
+ this.$nextTick(() => {
2464
+ this.applyDialogLayout();
2465
+ });
2466
+ },
2467
+ beforeDestroy() {
2468
+ document.removeEventListener("keydown", this.handleKeydown);
2469
+ this.removeDragListeners();
2470
+ this.removeModalStyle();
2471
+ },
2472
+ methods: {
2473
+ normalizeSize(value) {
2474
+ if (value === null || value === void 0 || value === "")
2475
+ return "";
2476
+ return /^\d+$/.test(String(value)) ? `${value}px` : String(value);
2477
+ },
2478
+ resolvePadding() {
2479
+ if (Array.isArray(this.dialogPadding)) {
2480
+ return this.dialogPadding.map((item) => this.normalizeSize(item)).join(" ");
2481
+ }
2482
+ if (this.dialogPadding === -1 || this.dialogPadding === "-1") {
2483
+ return "16px 20px";
2484
+ }
2485
+ return this.normalizeSize(this.dialogPadding);
2486
+ },
2487
+ resolveComponent(source) {
2488
+ if (!source)
2489
+ return null;
2490
+ if (source.default) {
2491
+ return source.default;
2492
+ }
2493
+ if (typeof source.then === "function") {
2494
+ return () => source;
2495
+ }
2496
+ return source;
2497
+ },
2498
+ mergeEvents(listeners = {}) {
2499
+ return {
2500
+ ...listeners,
2501
+ close: () => this.closeDialog()
2502
+ };
2503
+ },
2504
+ resolveDialogElement() {
2505
+ return this.$el && this.$el.querySelector ? this.$el.querySelector(".el-dialog") : null;
2506
+ },
2507
+ resolveWrapperElement() {
2508
+ return this.$el && this.$el.querySelector ? this.$el.querySelector(".el-dialog__wrapper") : null;
2509
+ },
2510
+ applyDialogLayout() {
2511
+ const dialog = this.resolveDialogElement();
2512
+ if (!dialog)
2513
+ return;
2514
+ if (this.currentHeight) {
2515
+ dialog.style.height = this.normalizeSize(this.currentHeight);
2516
+ dialog.style.display = "flex";
2517
+ dialog.style.flexDirection = "column";
2518
+ } else {
2519
+ dialog.style.height = "";
2520
+ }
2521
+ if (this.hasAbsolutePosition) {
2522
+ dialog.style.position = "fixed";
2523
+ dialog.style.margin = "0";
2524
+ if (this.currentX !== null) {
2525
+ dialog.style.left = this.normalizeSize(this.currentX);
2526
+ }
2527
+ if (this.currentY !== null) {
2528
+ dialog.style.top = this.normalizeSize(this.currentY);
2529
+ }
2530
+ } else {
2531
+ dialog.style.position = "";
2532
+ dialog.style.left = "";
2533
+ dialog.style.top = "";
2534
+ }
2535
+ },
2536
+ updateModalStyle() {
2537
+ if (!this.containerId)
2538
+ return;
2539
+ let styleEl = document.getElementById(`style-${this.containerId}`);
2540
+ if (!styleEl) {
2541
+ styleEl = document.createElement("style");
2542
+ styleEl.id = `style-${this.containerId}`;
2543
+ document.head.appendChild(styleEl);
2544
+ }
2545
+ styleEl.textContent = `.${this.modalClassName.replace(/ /g, ".")} { background-color: ${this.modalColor} !important; }`;
2546
+ },
2547
+ removeModalStyle() {
2548
+ if (!this.containerId)
2549
+ return;
2550
+ const styleEl = document.getElementById(`style-${this.containerId}`);
2551
+ if (styleEl && styleEl.parentNode) {
2552
+ styleEl.parentNode.removeChild(styleEl);
2553
+ }
2554
+ },
2555
+ syncDialogInstance() {
2556
+ if (!this.dialogInstance)
2557
+ return;
2558
+ this.dialogInstance.domRef = this.$refs.contentRef || null;
2559
+ this.dialogInstance.updateOption = (newOption = {}) => {
2560
+ if (Object.prototype.hasOwnProperty.call(newOption, "title")) {
2561
+ this.currentTitle = newOption.title;
2562
+ }
2563
+ if (Object.prototype.hasOwnProperty.call(newOption, "width")) {
2564
+ this.currentWidth = newOption.width;
2565
+ }
2566
+ if (Object.prototype.hasOwnProperty.call(newOption, "height")) {
2567
+ this.currentHeight = newOption.height;
2568
+ }
2569
+ if (Object.prototype.hasOwnProperty.call(newOption, "x")) {
2570
+ this.currentX = newOption.x;
2571
+ }
2572
+ if (Object.prototype.hasOwnProperty.call(newOption, "y")) {
2573
+ this.currentY = newOption.y;
2574
+ }
2575
+ const mergedOption = { ...newOption };
2576
+ delete mergedOption.title;
2577
+ delete mergedOption.width;
2578
+ delete mergedOption.height;
2579
+ delete mergedOption.x;
2580
+ delete mergedOption.y;
2581
+ this.currentOption = {
2582
+ ...this.currentOption,
2583
+ ...mergedOption
2584
+ };
2585
+ };
2586
+ this.dialogInstance.callMethod = (methodName, ...args) => {
2587
+ const target = this.$refs.contentRef;
2588
+ if (target && typeof target[methodName] === "function") {
2589
+ return target[methodName](...args);
2590
+ }
2591
+ return void 0;
2592
+ };
2593
+ this.dialogInstance.close = () => this.closeDialog();
2594
+ },
2595
+ triggerDomCompleted() {
2596
+ if (this.domCompletedCalled)
2597
+ return;
2598
+ if (this.$refs.contentRef) {
2599
+ this.domCompletedCalled = true;
2600
+ if (typeof this.domCompleted === "function") {
2601
+ this.domCompleted(this.$refs.contentRef);
2602
+ }
2603
+ }
2604
+ },
2605
+ toggleMaximize() {
2606
+ if (!this.showMaximizeButton)
2607
+ return;
2608
+ if (!this.isMaximized) {
2609
+ this.originalSize = {
2610
+ width: this.currentWidth,
2611
+ height: this.currentHeight,
2612
+ x: this.currentX,
2613
+ y: this.currentY
2614
+ };
2615
+ const maxConfig = this.maxSize ? this.maxSize() || {} : {};
2616
+ this.currentWidth = maxConfig.width || "100vw";
2617
+ this.currentHeight = maxConfig.height || "100vh";
2618
+ this.currentX = maxConfig.x !== void 0 ? maxConfig.x : 0;
2619
+ this.currentY = maxConfig.y !== void 0 ? maxConfig.y : 0;
2620
+ this.isMaximized = true;
2621
+ } else {
2622
+ this.currentWidth = this.originalSize.width;
2623
+ this.currentHeight = this.originalSize.height;
2624
+ this.currentX = this.originalSize.x;
2625
+ this.currentY = this.originalSize.y;
2626
+ this.isMaximized = false;
2627
+ }
2628
+ this.$nextTick(() => this.applyDialogLayout());
2629
+ },
2630
+ closeDialog() {
2631
+ this.visible = false;
2632
+ },
2633
+ dealClose() {
2634
+ if (typeof this.close === "function") {
2635
+ this.close();
2636
+ }
2637
+ },
2638
+ dealClosed() {
2639
+ if (typeof this.closed === "function") {
2640
+ this.closed();
2641
+ }
2642
+ },
2643
+ dealConfirm() {
2644
+ this.footerLoading = true;
2645
+ if (!this.confirm) {
2646
+ this.footerLoading = false;
2647
+ return;
2648
+ }
2649
+ if (this.immediately) {
2650
+ this.footerLoading = false;
2651
+ this.visible = false;
2652
+ this.confirm(null, this.$refs.contentRef);
2653
+ return;
2654
+ }
2655
+ this.confirm(
2656
+ () => {
2657
+ this.footerLoading = false;
2658
+ this.visible = false;
2659
+ this.$message && this.$message.success && this.$message.success("操作成功");
2660
+ },
2661
+ this.$refs.contentRef,
2662
+ {
2663
+ value: this.footerLoading,
2664
+ set value(nextValue) {
2665
+ this.footerLoading = nextValue;
2666
+ }
2667
+ }
2668
+ );
2669
+ },
2670
+ handleKeydown(event) {
2671
+ if (!this.visible || !this.showFooter)
2672
+ return;
2673
+ if (event.key === "Enter" && !this.footerDom) {
2674
+ event.preventDefault();
2675
+ this.dealConfirm();
2676
+ }
2677
+ },
2678
+ handleDragStart(event) {
2679
+ if (!this.draggable || this.showMaximizeButton || event.button !== 0) {
2680
+ return;
2681
+ }
2682
+ const dialog = this.resolveDialogElement();
2683
+ if (!dialog)
2684
+ return;
2685
+ const rect = dialog.getBoundingClientRect();
2686
+ this.currentX = rect.left;
2687
+ this.currentY = rect.top;
2688
+ this.dragContext = {
2689
+ startX: event.clientX,
2690
+ startY: event.clientY,
2691
+ originX: rect.left,
2692
+ originY: rect.top
2693
+ };
2694
+ document.addEventListener("mousemove", this.handleDragMove);
2695
+ document.addEventListener("mouseup", this.handleDragEnd);
2696
+ },
2697
+ handleDragMove(event) {
2698
+ if (!this.dragContext)
2699
+ return;
2700
+ const deltaX = event.clientX - this.dragContext.startX;
2701
+ const deltaY = event.clientY - this.dragContext.startY;
2702
+ this.currentX = this.dragContext.originX + deltaX;
2703
+ this.currentY = this.dragContext.originY + deltaY;
2704
+ this.applyDialogLayout();
2705
+ },
2706
+ handleDragEnd() {
2707
+ this.removeDragListeners();
2708
+ },
2709
+ removeDragListeners() {
2710
+ document.removeEventListener("mousemove", this.handleDragMove);
2711
+ document.removeEventListener("mouseup", this.handleDragEnd);
2712
+ this.dragContext = null;
2713
+ }
2714
+ }
2715
+ };
2716
+ var _sfc_render = function render6() {
2717
+ var _vm = this, _c = _vm._self._c;
2718
+ return _c("el-dialog", { attrs: { "visible": _vm.visible, "width": _vm.normalizedWidth, "modal": _vm.modal, "modal-class": _vm.modalClassName, "show-close": false, "append-to-body": false, "close-on-click-modal": _vm.closeOnClickModal, "custom-class": _vm.dialogCustomClass }, on: { "update:visible": function($event) {
2719
+ _vm.visible = $event;
2720
+ }, "close": _vm.dealClose, "closed": _vm.dealClosed } }, [_c("div", { staticClass: "ns-dialog-plus__header", attrs: { "slot": "title" }, on: { "mousedown": _vm.handleDragStart }, slot: "title" }, [_c("div", { staticClass: "ns-dialog-plus__title" }, [_vm.resolvedHeaderDom ? _c(_vm.resolvedHeaderDom, _vm._g(_vm._b({ tag: "component" }, "component", _vm.headerOption, false), _vm.mergeEvents(_vm.headerEvents))) : [_vm._v(_vm._s(_vm.currentTitle))]], 2), _c("div", { staticClass: "ns-dialog-plus__actions" }, [_vm.showMaximizeButton ? _c("el-button", { staticClass: "ns-dialog-plus__action-btn", attrs: { "type": "text" }, on: { "click": function($event) {
2721
+ $event.stopPropagation();
2722
+ return _vm.toggleMaximize.apply(null, arguments);
2723
+ } } }, [_vm._v(" " + _vm._s(_vm.isMaximized ? "还原" : "最大化") + " ")]) : _vm._e(), _c("el-button", { staticClass: "ns-dialog-plus__action-btn", attrs: { "type": "text" }, on: { "click": function($event) {
2724
+ $event.stopPropagation();
2725
+ return _vm.closeDialog.apply(null, arguments);
2726
+ } } }, [_vm._v("关闭")])], 1)]), _c("div", { staticClass: "ns-dialog-plus__body", style: _vm.bodyStyle }, [_c(_vm.resolvedDom, _vm._g(_vm._b({ ref: "contentRef", tag: "component" }, "component", _vm.currentOption, false), _vm.mergeEvents(_vm.events)))], 1), _vm.showFooter ? _c("div", { staticClass: "ns-dialog-plus__footer", attrs: { "slot": "footer" }, slot: "footer" }, [_vm.resolvedFooterDom ? _c(_vm.resolvedFooterDom, _vm._g(_vm._b({ tag: "component" }, "component", _vm.footerOption, false), _vm.mergeEvents(_vm.footerEvents))) : [_c("el-button", { on: { "click": _vm.closeDialog } }, [_vm._v(_vm._s(_vm.footerButtonText.close))]), _c("el-button", { attrs: { "type": "primary", "loading": _vm.footerLoading }, on: { "click": _vm.dealConfirm } }, [_vm._v(_vm._s(_vm.footerButtonText.confirm))])]], 2) : _vm._e()]);
2727
+ };
2728
+ var _sfc_staticRenderFns = [];
2729
+ var __component__ = /* @__PURE__ */ normalizeComponent(
2730
+ _sfc_main,
2731
+ _sfc_render,
2732
+ _sfc_staticRenderFns,
2733
+ false,
2734
+ null,
2735
+ "4f4f8603",
2736
+ null,
2737
+ null
2738
+ );
2739
+ const NsDialogComponent = __component__.exports;
2740
+ const dialogInstances = typeof window !== "undefined" ? window.__dialogInstances = window.__dialogInstances || [] : [];
2741
+ let externalVue = Vue;
2742
+ let dialogSeed = 0;
2743
+ function setExternalApp(app) {
2744
+ if (!app)
2745
+ return;
2746
+ if (app.extend) {
2747
+ externalVue = app;
2748
+ return;
2749
+ }
2750
+ if (app.constructor && app.constructor.extend) {
2751
+ externalVue = app.constructor;
2752
+ }
2753
+ }
2754
+ function resolveMountTarget(selector) {
2755
+ if (typeof document === "undefined") {
2756
+ return null;
2757
+ }
2758
+ return document.querySelector(selector) || document.body;
2759
+ }
2760
+ function removeDialogInstance(instance) {
2761
+ const index2 = dialogInstances.findIndex((item) => item.id === instance.id);
2762
+ if (index2 > -1) {
2763
+ dialogInstances.splice(index2, 1);
2764
+ }
2765
+ }
2766
+ function closeAllNsDialog() {
2767
+ dialogInstances.slice().forEach((instance) => {
2768
+ if (instance && typeof instance.close === "function") {
2769
+ instance.close();
2770
+ }
2771
+ });
2772
+ }
2773
+ function NsDialog(data, modal = true, appendTo = "#app") {
2774
+ if (!data || !data.dom) {
2775
+ return false;
2776
+ }
2777
+ const mountTarget = resolveMountTarget(appendTo);
2778
+ if (!mountTarget) {
2779
+ return false;
2780
+ }
2781
+ const id = data.id || `ns-dialog-${Date.now()}-${dialogSeed++}`;
2782
+ const container = document.createElement("div");
2783
+ container.id = id;
2784
+ mountTarget.appendChild(container);
2785
+ const instance = {
2786
+ id,
2787
+ class: data.class || "",
2788
+ element: container,
2789
+ vm: null,
2790
+ domRef: null,
2791
+ updateOption: () => {
2792
+ },
2793
+ callMethod: () => {
2794
+ },
2795
+ close: () => {
2796
+ }
2797
+ };
2798
+ const DialogConstructor = (externalVue || Vue).extend(NsDialogComponent);
2799
+ const propsData = {
2800
+ ...data,
2801
+ className: data.class || "",
2802
+ modal,
2803
+ containerId: id,
2804
+ dialogInstance: instance,
2805
+ close: () => {
2806
+ if (typeof data.close === "function") {
2807
+ data.close();
2808
+ }
2809
+ },
2810
+ closed: () => {
2811
+ try {
2812
+ if (typeof data.closed === "function") {
2813
+ data.closed();
2814
+ }
2815
+ } finally {
2816
+ if (instance.vm) {
2817
+ instance.vm.$destroy();
2818
+ }
2819
+ if (container.parentNode) {
2820
+ container.parentNode.removeChild(container);
2821
+ }
2822
+ removeDialogInstance(instance);
2823
+ }
2824
+ }
2825
+ };
2826
+ const vm = new DialogConstructor({ propsData });
2827
+ instance.vm = vm;
2828
+ instance.close = () => {
2829
+ if (vm && typeof vm.closeDialog === "function") {
2830
+ vm.closeDialog();
2831
+ }
2832
+ };
2833
+ dialogInstances.push(instance);
2834
+ vm.$mount(container);
2835
+ return instance;
2836
+ }
2837
+ const components = [NsForm, NsFormTitle, NsTableContainer, NsSearch, NsTable];
2838
+ function install2(Vue2) {
2839
+ if (install2.installed)
2840
+ return;
2841
+ install2.installed = true;
2842
+ registerDirective(Vue2);
2843
+ components.forEach((component) => {
2844
+ if (component && component.name) {
2845
+ Vue2.component(component.name, component);
2846
+ }
2847
+ });
2848
+ setExternalApp(Vue2);
2849
+ loadCssVars$1();
2850
+ if (Vue2 && Vue2.prototype) {
2851
+ Vue2.prototype.$NsDialog = NsDialog;
2852
+ Vue2.prototype.$closeAllNsDialog = closeAllNsDialog;
2853
+ }
2854
+ if (typeof window !== "undefined") {
2855
+ window.NsDialog = NsDialog;
2856
+ window.closeAllNsDialog = closeAllNsDialog;
2857
+ }
2858
+ }
2859
+ const index = {
2860
+ install: install2,
2861
+ NsForm,
2862
+ NsFormTitle,
2863
+ NsTableContainer,
2864
+ NsSearch,
2865
+ NsTable,
2866
+ NsDialog,
2867
+ closeAllNsDialog,
2868
+ setExternalApp,
2869
+ useFileUpload,
2870
+ getAllFormNodeByKey,
2871
+ getAllFormKvData,
2872
+ getAllFormNodeRefByKey,
2873
+ createPagination,
2874
+ createPaginationWithCustomKeys,
2875
+ resetPagination
2876
+ };
2877
+ export {
2878
+ NsDialog,
2879
+ NsForm,
2880
+ NsFormTitle,
2881
+ NsSearch,
2882
+ NsTable,
2883
+ NsTableContainer,
2884
+ closeAllNsDialog,
2885
+ createPagination,
2886
+ createPaginationWithCustomKeys,
2887
+ index as default,
2888
+ getAllFormKvData,
2889
+ getAllFormNodeByKey,
2890
+ getAllFormNodeRefByKey,
2891
+ install2 as install,
2892
+ resetPagination,
2893
+ setExternalApp,
2894
+ useFileUpload
2895
+ };