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