1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | (function (global, factory) {
|
8 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('iview')) :
|
9 | typeof define === 'function' && define.amd ? define(['exports', 'vue', 'iview'], factory) :
|
10 | (factory((global.formCreate = {}),global.Vue,global.iview));
|
11 | }(this, (function (exports,Vue$1,iview) { 'use strict';
|
12 |
|
13 | Vue$1 = Vue$1 && Vue$1.hasOwnProperty('default') ? Vue$1['default'] : Vue$1;
|
14 | iview = iview && iview.hasOwnProperty('default') ? iview['default'] : iview;
|
15 |
|
16 | var toString = {}.toString;
|
17 |
|
18 | var classofRaw = function (it) {
|
19 | return toString.call(it).slice(8, -1);
|
20 | };
|
21 |
|
22 |
|
23 |
|
24 | var isArray = Array.isArray || function isArray(arg) {
|
25 | return classofRaw(arg) == 'Array';
|
26 | };
|
27 |
|
28 | var isObject = function (it) {
|
29 | return typeof it === 'object' ? it !== null : typeof it === 'function';
|
30 | };
|
31 |
|
32 |
|
33 |
|
34 | var requireObjectCoercible = function (it) {
|
35 | if (it == undefined) throw TypeError("Can't call method on " + it);
|
36 | return it;
|
37 | };
|
38 |
|
39 |
|
40 |
|
41 | var toObject = function (argument) {
|
42 | return Object(requireObjectCoercible(argument));
|
43 | };
|
44 |
|
45 | var ceil = Math.ceil;
|
46 | var floor = Math.floor;
|
47 |
|
48 |
|
49 |
|
50 | var toInteger = function (argument) {
|
51 | return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
|
52 | };
|
53 |
|
54 | var min = Math.min;
|
55 |
|
56 |
|
57 |
|
58 | var toLength = function (argument) {
|
59 | return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0;
|
60 | };
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | var toPrimitive = function (it, S) {
|
67 | if (!isObject(it)) return it;
|
68 | var fn, val;
|
69 | if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
|
70 | if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
|
71 | if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
|
72 | throw TypeError("Can't convert object to primitive value");
|
73 | };
|
74 |
|
75 | var fails = function (exec) {
|
76 | try {
|
77 | return !!exec();
|
78 | } catch (error) {
|
79 | return true;
|
80 | }
|
81 | };
|
82 |
|
83 |
|
84 | var descriptors = !fails(function () {
|
85 | return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
|
86 | });
|
87 |
|
88 |
|
89 | var global$1 = typeof window == 'object' && window && window.Math == Math ? window
|
90 | : typeof self == 'object' && self && self.Math == Math ? self
|
91 |
|
92 | : Function('return this')();
|
93 |
|
94 | var document$1 = global$1.document;
|
95 |
|
96 | var exist = isObject(document$1) && isObject(document$1.createElement);
|
97 |
|
98 | var documentCreateElement = function (it) {
|
99 | return exist ? document$1.createElement(it) : {};
|
100 | };
|
101 |
|
102 |
|
103 | var ie8DomDefine = !descriptors && !fails(function () {
|
104 | return Object.defineProperty(documentCreateElement('div'), 'a', {
|
105 | get: function () { return 7; }
|
106 | }).a != 7;
|
107 | });
|
108 |
|
109 | var anObject = function (it) {
|
110 | if (!isObject(it)) {
|
111 | throw TypeError(String(it) + ' is not an object');
|
112 | } return it;
|
113 | };
|
114 |
|
115 | var nativeDefineProperty = Object.defineProperty;
|
116 |
|
117 | var f = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
|
118 | anObject(O);
|
119 | P = toPrimitive(P, true);
|
120 | anObject(Attributes);
|
121 | if (ie8DomDefine) try {
|
122 | return nativeDefineProperty(O, P, Attributes);
|
123 | } catch (error) { }
|
124 | if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
|
125 | if ('value' in Attributes) O[P] = Attributes.value;
|
126 | return O;
|
127 | };
|
128 |
|
129 | var objectDefineProperty = {
|
130 | f: f
|
131 | };
|
132 |
|
133 | var createPropertyDescriptor = function (bitmap, value) {
|
134 | return {
|
135 | enumerable: !(bitmap & 1),
|
136 | configurable: !(bitmap & 2),
|
137 | writable: !(bitmap & 4),
|
138 | value: value
|
139 | };
|
140 | };
|
141 |
|
142 | var createProperty = function (object, key, value) {
|
143 | var propertyKey = toPrimitive(key);
|
144 | if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
|
145 | else object[propertyKey] = value;
|
146 | };
|
147 |
|
148 | function createCommonjsModule(fn, module) {
|
149 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
150 | }
|
151 |
|
152 | var hide = descriptors ? function (object, key, value) {
|
153 | return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
|
154 | } : function (object, key, value) {
|
155 | object[key] = value;
|
156 | return object;
|
157 | };
|
158 |
|
159 | var setGlobal = function (key, value) {
|
160 | try {
|
161 | hide(global$1, key, value);
|
162 | } catch (error) {
|
163 | global$1[key] = value;
|
164 | } return value;
|
165 | };
|
166 |
|
167 | var isPure = false;
|
168 |
|
169 | var shared = createCommonjsModule(function (module) {
|
170 | var SHARED = '__core-js_shared__';
|
171 | var store = global$1[SHARED] || setGlobal(SHARED, {});
|
172 |
|
173 | (module.exports = function (key, value) {
|
174 | return store[key] || (store[key] = value !== undefined ? value : {});
|
175 | })('versions', []).push({
|
176 | version: '3.0.1',
|
177 | mode: isPure ? 'pure' : 'global',
|
178 | copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
|
179 | });
|
180 | });
|
181 |
|
182 | var id = 0;
|
183 | var postfix = Math.random();
|
184 |
|
185 | var uid = function (key) {
|
186 | return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + postfix).toString(36));
|
187 | };
|
188 |
|
189 |
|
190 | var nativeSymbol = !fails(function () {
|
191 |
|
192 | return !String(Symbol());
|
193 | });
|
194 |
|
195 | var store = shared('wks');
|
196 |
|
197 | var Symbol$1 = global$1.Symbol;
|
198 |
|
199 |
|
200 | var wellKnownSymbol = function (name) {
|
201 | return store[name] || (store[name] = nativeSymbol && Symbol$1[name]
|
202 | || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
|
203 | };
|
204 |
|
205 | var SPECIES = wellKnownSymbol('species');
|
206 |
|
207 |
|
208 |
|
209 | var arraySpeciesCreate = function (originalArray, length) {
|
210 | var C;
|
211 | if (isArray(originalArray)) {
|
212 | C = originalArray.constructor;
|
213 |
|
214 | if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
|
215 | else if (isObject(C)) {
|
216 | C = C[SPECIES];
|
217 | if (C === null) C = undefined;
|
218 | }
|
219 | } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
|
220 | };
|
221 |
|
222 | var SPECIES$1 = wellKnownSymbol('species');
|
223 |
|
224 | var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
|
225 | return !fails(function () {
|
226 | var array = [];
|
227 | var constructor = array.constructor = {};
|
228 | constructor[SPECIES$1] = function () {
|
229 | return { foo: 1 };
|
230 | };
|
231 | return array[METHOD_NAME](Boolean).foo !== 1;
|
232 | });
|
233 | };
|
234 |
|
235 | var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
|
236 | var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
237 |
|
238 |
|
239 | var NASHORN_BUG = nativeGetOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
|
240 |
|
241 | var f$1 = NASHORN_BUG ? function propertyIsEnumerable(V) {
|
242 | var descriptor = nativeGetOwnPropertyDescriptor(this, V);
|
243 | return !!descriptor && descriptor.enumerable;
|
244 | } : nativePropertyIsEnumerable;
|
245 |
|
246 | var objectPropertyIsEnumerable = {
|
247 | f: f$1
|
248 | };
|
249 |
|
250 |
|
251 |
|
252 |
|
253 | var split = ''.split;
|
254 |
|
255 | var indexedObject = fails(function () {
|
256 |
|
257 |
|
258 | return !Object('z').propertyIsEnumerable(0);
|
259 | }) ? function (it) {
|
260 | return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
|
261 | } : Object;
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 | var toIndexedObject = function (it) {
|
268 | return indexedObject(requireObjectCoercible(it));
|
269 | };
|
270 |
|
271 | var hasOwnProperty = {}.hasOwnProperty;
|
272 |
|
273 | var has = function (it, key) {
|
274 | return hasOwnProperty.call(it, key);
|
275 | };
|
276 |
|
277 | var nativeGetOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
|
278 |
|
279 | var f$2 = descriptors ? nativeGetOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
|
280 | O = toIndexedObject(O);
|
281 | P = toPrimitive(P, true);
|
282 | if (ie8DomDefine) try {
|
283 | return nativeGetOwnPropertyDescriptor$1(O, P);
|
284 | } catch (error) { }
|
285 | if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
|
286 | };
|
287 |
|
288 | var objectGetOwnPropertyDescriptor = {
|
289 | f: f$2
|
290 | };
|
291 |
|
292 | var functionToString = shared('native-function-to-string', Function.toString);
|
293 |
|
294 | var WeakMap$1 = global$1.WeakMap;
|
295 |
|
296 | var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(functionToString.call(WeakMap$1));
|
297 |
|
298 | var shared$1 = shared('keys');
|
299 |
|
300 |
|
301 | var sharedKey = function (key) {
|
302 | return shared$1[key] || (shared$1[key] = uid(key));
|
303 | };
|
304 |
|
305 | var hiddenKeys = {};
|
306 |
|
307 | var WeakMap$2 = global$1.WeakMap;
|
308 | var set, get, has$1;
|
309 |
|
310 | var enforce = function (it) {
|
311 | return has$1(it) ? get(it) : set(it, {});
|
312 | };
|
313 |
|
314 | var getterFor = function (TYPE) {
|
315 | return function (it) {
|
316 | var state;
|
317 | if (!isObject(it) || (state = get(it)).type !== TYPE) {
|
318 | throw TypeError('Incompatible receiver, ' + TYPE + ' required');
|
319 | } return state;
|
320 | };
|
321 | };
|
322 |
|
323 | if (nativeWeakMap) {
|
324 | var store$1 = new WeakMap$2();
|
325 | var wmget = store$1.get;
|
326 | var wmhas = store$1.has;
|
327 | var wmset = store$1.set;
|
328 | set = function (it, metadata) {
|
329 | wmset.call(store$1, it, metadata);
|
330 | return metadata;
|
331 | };
|
332 | get = function (it) {
|
333 | return wmget.call(store$1, it) || {};
|
334 | };
|
335 | has$1 = function (it) {
|
336 | return wmhas.call(store$1, it);
|
337 | };
|
338 | } else {
|
339 | var STATE = sharedKey('state');
|
340 | hiddenKeys[STATE] = true;
|
341 | set = function (it, metadata) {
|
342 | hide(it, STATE, metadata);
|
343 | return metadata;
|
344 | };
|
345 | get = function (it) {
|
346 | return has(it, STATE) ? it[STATE] : {};
|
347 | };
|
348 | has$1 = function (it) {
|
349 | return has(it, STATE);
|
350 | };
|
351 | }
|
352 |
|
353 | var internalState = {
|
354 | set: set,
|
355 | get: get,
|
356 | has: has$1,
|
357 | enforce: enforce,
|
358 | getterFor: getterFor
|
359 | };
|
360 |
|
361 | var redefine = createCommonjsModule(function (module) {
|
362 | var getInternalState = internalState.get;
|
363 | var enforceInternalState = internalState.enforce;
|
364 | var TEMPLATE = String(functionToString).split('toString');
|
365 |
|
366 | shared('inspectSource', function (it) {
|
367 | return functionToString.call(it);
|
368 | });
|
369 |
|
370 | (module.exports = function (O, key, value, options) {
|
371 | var unsafe = options ? !!options.unsafe : false;
|
372 | var simple = options ? !!options.enumerable : false;
|
373 | var noTargetGet = options ? !!options.noTargetGet : false;
|
374 | if (typeof value == 'function') {
|
375 | if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
|
376 | enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
|
377 | }
|
378 | if (O === global$1) {
|
379 | if (simple) O[key] = value;
|
380 | else setGlobal(key, value);
|
381 | return;
|
382 | } else if (!unsafe) {
|
383 | delete O[key];
|
384 | } else if (!noTargetGet && O[key]) {
|
385 | simple = true;
|
386 | }
|
387 | if (simple) O[key] = value;
|
388 | else hide(O, key, value);
|
389 |
|
390 | })(Function.prototype, 'toString', function toString() {
|
391 | return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
|
392 | });
|
393 | });
|
394 |
|
395 | var max = Math.max;
|
396 | var min$1 = Math.min;
|
397 |
|
398 |
|
399 |
|
400 |
|
401 | var toAbsoluteIndex = function (index, length) {
|
402 | var integer = toInteger(index);
|
403 | return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
|
404 | };
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 | var arrayIncludes = function (IS_INCLUDES) {
|
412 | return function ($this, el, fromIndex) {
|
413 | var O = toIndexedObject($this);
|
414 | var length = toLength(O.length);
|
415 | var index = toAbsoluteIndex(fromIndex, length);
|
416 | var value;
|
417 |
|
418 |
|
419 | if (IS_INCLUDES && el != el) while (length > index) {
|
420 | value = O[index++];
|
421 |
|
422 | if (value != value) return true;
|
423 |
|
424 | } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
|
425 | if (O[index] === el) return IS_INCLUDES || index || 0;
|
426 | } return !IS_INCLUDES && -1;
|
427 | };
|
428 | };
|
429 |
|
430 | var arrayIndexOf = arrayIncludes(false);
|
431 |
|
432 |
|
433 | var objectKeysInternal = function (object, names) {
|
434 | var O = toIndexedObject(object);
|
435 | var i = 0;
|
436 | var result = [];
|
437 | var key;
|
438 | for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
|
439 |
|
440 | while (names.length > i) if (has(O, key = names[i++])) {
|
441 | ~arrayIndexOf(result, key) || result.push(key);
|
442 | }
|
443 | return result;
|
444 | };
|
445 |
|
446 |
|
447 | var enumBugKeys = [
|
448 | 'constructor',
|
449 | 'hasOwnProperty',
|
450 | 'isPrototypeOf',
|
451 | 'propertyIsEnumerable',
|
452 | 'toLocaleString',
|
453 | 'toString',
|
454 | 'valueOf'
|
455 | ];
|
456 |
|
457 |
|
458 |
|
459 | var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
|
460 |
|
461 | var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
462 | return objectKeysInternal(O, hiddenKeys$1);
|
463 | };
|
464 |
|
465 | var objectGetOwnPropertyNames = {
|
466 | f: f$3
|
467 | };
|
468 |
|
469 | var f$4 = Object.getOwnPropertySymbols;
|
470 |
|
471 | var objectGetOwnPropertySymbols = {
|
472 | f: f$4
|
473 | };
|
474 |
|
475 | var Reflect$1 = global$1.Reflect;
|
476 |
|
477 |
|
478 | var ownKeys = Reflect$1 && Reflect$1.ownKeys || function ownKeys(it) {
|
479 | var keys = objectGetOwnPropertyNames.f(anObject(it));
|
480 | var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
|
481 | return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
|
482 | };
|
483 |
|
484 | var copyConstructorProperties = function (target, source) {
|
485 | var keys = ownKeys(source);
|
486 | var defineProperty = objectDefineProperty.f;
|
487 | var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
|
488 | for (var i = 0; i < keys.length; i++) {
|
489 | var key = keys[i];
|
490 | if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
|
491 | }
|
492 | };
|
493 |
|
494 | var replacement = /#|\.prototype\./;
|
495 |
|
496 | var isForced = function (feature, detection) {
|
497 | var value = data[normalize(feature)];
|
498 | return value == POLYFILL ? true
|
499 | : value == NATIVE ? false
|
500 | : typeof detection == 'function' ? fails(detection)
|
501 | : !!detection;
|
502 | };
|
503 |
|
504 | var normalize = isForced.normalize = function (string) {
|
505 | return String(string).replace(replacement, '.').toLowerCase();
|
506 | };
|
507 |
|
508 | var data = isForced.data = {};
|
509 | var NATIVE = isForced.NATIVE = 'N';
|
510 | var POLYFILL = isForced.POLYFILL = 'P';
|
511 |
|
512 | var isForced_1 = isForced;
|
513 |
|
514 | var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 | |
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 | var _export = function (options, source) {
|
536 | var TARGET = options.target;
|
537 | var GLOBAL = options.global;
|
538 | var STATIC = options.stat;
|
539 | var FORCED, target, key, targetProperty, sourceProperty, descriptor;
|
540 | if (GLOBAL) {
|
541 | target = global$1;
|
542 | } else if (STATIC) {
|
543 | target = global$1[TARGET] || setGlobal(TARGET, {});
|
544 | } else {
|
545 | target = (global$1[TARGET] || {}).prototype;
|
546 | }
|
547 | if (target) for (key in source) {
|
548 | sourceProperty = source[key];
|
549 | if (options.noTargetGet) {
|
550 | descriptor = getOwnPropertyDescriptor(target, key);
|
551 | targetProperty = descriptor && descriptor.value;
|
552 | } else targetProperty = target[key];
|
553 | FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
|
554 |
|
555 | if (!FORCED && targetProperty !== undefined) {
|
556 | if (typeof sourceProperty === typeof targetProperty) continue;
|
557 | copyConstructorProperties(sourceProperty, targetProperty);
|
558 | }
|
559 |
|
560 | if (options.sham || (targetProperty && targetProperty.sham)) {
|
561 | hide(sourceProperty, 'sham', true);
|
562 | }
|
563 |
|
564 | redefine(target, key, sourceProperty, options);
|
565 | }
|
566 | };
|
567 |
|
568 | var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
|
569 | var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
|
570 | var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
|
571 |
|
572 | var IS_CONCAT_SPREADABLE_SUPPORT = !fails(function () {
|
573 | var array = [];
|
574 | array[IS_CONCAT_SPREADABLE] = false;
|
575 | return array.concat()[0] !== array;
|
576 | });
|
577 |
|
578 | var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
|
579 |
|
580 | var isConcatSpreadable = function (O) {
|
581 | if (!isObject(O)) return false;
|
582 | var spreadable = O[IS_CONCAT_SPREADABLE];
|
583 | return spreadable !== undefined ? !!spreadable : isArray(O);
|
584 | };
|
585 |
|
586 | var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
|
587 |
|
588 |
|
589 |
|
590 |
|
591 | _export({ target: 'Array', proto: true, forced: FORCED }, {
|
592 | concat: function concat(arg) {
|
593 | var O = toObject(this);
|
594 | var A = arraySpeciesCreate(O, 0);
|
595 | var n = 0;
|
596 | var i, k, length, len, E;
|
597 | for (i = -1, length = arguments.length; i < length; i++) {
|
598 | E = i === -1 ? O : arguments[i];
|
599 | if (isConcatSpreadable(E)) {
|
600 | len = toLength(E.length);
|
601 | if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
|
602 | for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
|
603 | } else {
|
604 | if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
|
605 | createProperty(A, n++, E);
|
606 | }
|
607 | }
|
608 | A.length = n;
|
609 | return A;
|
610 | }
|
611 | });
|
612 |
|
613 | var aFunction = function (it) {
|
614 | if (typeof it != 'function') {
|
615 | throw TypeError(String(it) + ' is not a function');
|
616 | } return it;
|
617 | };
|
618 |
|
619 |
|
620 | var bindContext = function (fn, that, length) {
|
621 | aFunction(fn);
|
622 | if (that === undefined) return fn;
|
623 | switch (length) {
|
624 | case 0: return function () {
|
625 | return fn.call(that);
|
626 | };
|
627 | case 1: return function (a) {
|
628 | return fn.call(that, a);
|
629 | };
|
630 | case 2: return function (a, b) {
|
631 | return fn.call(that, a, b);
|
632 | };
|
633 | case 3: return function (a, b, c) {
|
634 | return fn.call(that, a, b, c);
|
635 | };
|
636 | }
|
637 | return function (/* ...args */) {
|
638 | return fn.apply(that, arguments);
|
639 | };
|
640 | };
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 | var arrayMethods = function (TYPE, specificCreate) {
|
658 | var IS_MAP = TYPE == 1;
|
659 | var IS_FILTER = TYPE == 2;
|
660 | var IS_SOME = TYPE == 3;
|
661 | var IS_EVERY = TYPE == 4;
|
662 | var IS_FIND_INDEX = TYPE == 6;
|
663 | var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
664 | var create = specificCreate || arraySpeciesCreate;
|
665 | return function ($this, callbackfn, that) {
|
666 | var O = toObject($this);
|
667 | var self = indexedObject(O);
|
668 | var boundFunction = bindContext(callbackfn, that, 3);
|
669 | var length = toLength(self.length);
|
670 | var index = 0;
|
671 | var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
|
672 | var value, result;
|
673 | for (;length > index; index++) if (NO_HOLES || index in self) {
|
674 | value = self[index];
|
675 | result = boundFunction(value, index, O);
|
676 | if (TYPE) {
|
677 | if (IS_MAP) target[index] = result;
|
678 | else if (result) switch (TYPE) {
|
679 | case 3: return true;
|
680 | case 5: return value;
|
681 | case 6: return index;
|
682 | case 2: target.push(value);
|
683 | } else if (IS_EVERY) return false;
|
684 | }
|
685 | }
|
686 | return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
|
687 | };
|
688 | };
|
689 |
|
690 | var internalFilter = arrayMethods(2);
|
691 |
|
692 | var SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('filter');
|
693 |
|
694 |
|
695 |
|
696 |
|
697 | _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$1 }, {
|
698 | filter: function filter(callbackfn /* , thisArg */) {
|
699 | return internalFilter(this, callbackfn, arguments[1]);
|
700 | }
|
701 | });
|
702 |
|
703 | var internalMap = arrayMethods(1);
|
704 |
|
705 | var SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('map');
|
706 |
|
707 |
|
708 |
|
709 |
|
710 | _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$2 }, {
|
711 | map: function map(callbackfn /* , thisArg */) {
|
712 | return internalMap(this, callbackfn, arguments[1]);
|
713 | }
|
714 | });
|
715 |
|
716 | var max$1 = Math.max;
|
717 | var min$2 = Math.min;
|
718 | var MAX_SAFE_INTEGER$1 = 0x1FFFFFFFFFFFFF;
|
719 | var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
|
720 |
|
721 | var SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport('splice');
|
722 |
|
723 |
|
724 |
|
725 |
|
726 | _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$3 }, {
|
727 | splice: function splice(start, deleteCount /* , ...items */) {
|
728 | var O = toObject(this);
|
729 | var len = toLength(O.length);
|
730 | var actualStart = toAbsoluteIndex(start, len);
|
731 | var argumentsLength = arguments.length;
|
732 | var insertCount, actualDeleteCount, A, k, from, to;
|
733 | if (argumentsLength === 0) {
|
734 | insertCount = actualDeleteCount = 0;
|
735 | } else if (argumentsLength === 1) {
|
736 | insertCount = 0;
|
737 | actualDeleteCount = len - actualStart;
|
738 | } else {
|
739 | insertCount = argumentsLength - 2;
|
740 | actualDeleteCount = min$2(max$1(toInteger(deleteCount), 0), len - actualStart);
|
741 | }
|
742 | if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER$1) {
|
743 | throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
|
744 | }
|
745 | A = arraySpeciesCreate(O, actualDeleteCount);
|
746 | for (k = 0; k < actualDeleteCount; k++) {
|
747 | from = actualStart + k;
|
748 | if (from in O) createProperty(A, k, O[from]);
|
749 | }
|
750 | A.length = actualDeleteCount;
|
751 | if (insertCount < actualDeleteCount) {
|
752 | for (k = actualStart; k < len - actualDeleteCount; k++) {
|
753 | from = k + actualDeleteCount;
|
754 | to = k + insertCount;
|
755 | if (from in O) O[to] = O[from];
|
756 | else delete O[to];
|
757 | }
|
758 | for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
|
759 | } else if (insertCount > actualDeleteCount) {
|
760 | for (k = len - actualDeleteCount; k > actualStart; k--) {
|
761 | from = k + actualDeleteCount - 1;
|
762 | to = k + insertCount - 1;
|
763 | if (from in O) O[to] = O[from];
|
764 | else delete O[to];
|
765 | }
|
766 | }
|
767 | for (k = 0; k < insertCount; k++) {
|
768 | O[k + actualStart] = arguments[k + 2];
|
769 | }
|
770 | O.length = len - actualDeleteCount + insertCount;
|
771 | return A;
|
772 | }
|
773 | });
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 | var objectKeys = Object.keys || function keys(O) {
|
780 | return objectKeysInternal(O, enumBugKeys);
|
781 | };
|
782 |
|
783 | var FAILS_ON_PRIMITIVES = fails(function () { objectKeys(1); });
|
784 |
|
785 |
|
786 |
|
787 | _export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
|
788 | keys: function keys(it) {
|
789 | return objectKeys(toObject(it));
|
790 | }
|
791 | });
|
792 |
|
793 |
|
794 |
|
795 | var domIterables = {
|
796 | CSSRuleList: 0,
|
797 | CSSStyleDeclaration: 0,
|
798 | CSSValueList: 0,
|
799 | ClientRectList: 0,
|
800 | DOMRectList: 0,
|
801 | DOMStringList: 0,
|
802 | DOMTokenList: 1,
|
803 | DataTransferItemList: 0,
|
804 | FileList: 0,
|
805 | HTMLAllCollection: 0,
|
806 | HTMLCollection: 0,
|
807 | HTMLFormElement: 0,
|
808 | HTMLSelectElement: 0,
|
809 | MediaList: 0,
|
810 | MimeTypeArray: 0,
|
811 | NamedNodeMap: 0,
|
812 | NodeList: 1,
|
813 | PaintRequestList: 0,
|
814 | Plugin: 0,
|
815 | PluginArray: 0,
|
816 | SVGLengthList: 0,
|
817 | SVGNumberList: 0,
|
818 | SVGPathSegList: 0,
|
819 | SVGPointList: 0,
|
820 | SVGStringList: 0,
|
821 | SVGTransformList: 0,
|
822 | SourceBufferList: 0,
|
823 | StyleSheetList: 0,
|
824 | TextTrackCueList: 0,
|
825 | TextTrackList: 0,
|
826 | TouchList: 0
|
827 | };
|
828 |
|
829 | var sloppyArrayMethod = function (METHOD_NAME, argument) {
|
830 | var method = [][METHOD_NAME];
|
831 | return !method || !fails(function () {
|
832 |
|
833 | method.call(null, argument || function () { throw 1; }, 1);
|
834 | });
|
835 | };
|
836 |
|
837 | var nativeForEach = [].forEach;
|
838 | var internalForEach = arrayMethods(0);
|
839 |
|
840 | var SLOPPY_METHOD = sloppyArrayMethod('forEach');
|
841 |
|
842 |
|
843 |
|
844 | var arrayForEach = SLOPPY_METHOD ? function forEach(callbackfn /* , thisArg */) {
|
845 | return internalForEach(this, callbackfn, arguments[1]);
|
846 | } : nativeForEach;
|
847 |
|
848 | for (var COLLECTION_NAME in domIterables) {
|
849 | var Collection = global$1[COLLECTION_NAME];
|
850 | var CollectionPrototype = Collection && Collection.prototype;
|
851 |
|
852 | if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
|
853 | hide(CollectionPrototype, 'forEach', arrayForEach);
|
854 | } catch (error) {
|
855 | CollectionPrototype.forEach = arrayForEach;
|
856 | }
|
857 | }
|
858 |
|
859 | function _typeof(obj) {
|
860 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
861 | _typeof = function (obj) {
|
862 | return typeof obj;
|
863 | };
|
864 | } else {
|
865 | _typeof = function (obj) {
|
866 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
867 | };
|
868 | }
|
869 |
|
870 | return _typeof(obj);
|
871 | }
|
872 |
|
873 | function _classCallCheck(instance, Constructor) {
|
874 | if (!(instance instanceof Constructor)) {
|
875 | throw new TypeError("Cannot call a class as a function");
|
876 | }
|
877 | }
|
878 |
|
879 | function _defineProperties(target, props) {
|
880 | for (var i = 0; i < props.length; i++) {
|
881 | var descriptor = props[i];
|
882 | descriptor.enumerable = descriptor.enumerable || false;
|
883 | descriptor.configurable = true;
|
884 | if ("value" in descriptor) descriptor.writable = true;
|
885 | Object.defineProperty(target, descriptor.key, descriptor);
|
886 | }
|
887 | }
|
888 |
|
889 | function _createClass(Constructor, protoProps, staticProps) {
|
890 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
891 | if (staticProps) _defineProperties(Constructor, staticProps);
|
892 | return Constructor;
|
893 | }
|
894 |
|
895 | function _defineProperty(obj, key, value) {
|
896 | if (key in obj) {
|
897 | Object.defineProperty(obj, key, {
|
898 | value: value,
|
899 | enumerable: true,
|
900 | configurable: true,
|
901 | writable: true
|
902 | });
|
903 | } else {
|
904 | obj[key] = value;
|
905 | }
|
906 |
|
907 | return obj;
|
908 | }
|
909 |
|
910 | function _objectSpread(target) {
|
911 | for (var i = 1; i < arguments.length; i++) {
|
912 | var source = arguments[i] != null ? arguments[i] : {};
|
913 | var ownKeys = Object.keys(source);
|
914 |
|
915 | if (typeof Object.getOwnPropertySymbols === 'function') {
|
916 | ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
917 | return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
918 | }));
|
919 | }
|
920 |
|
921 | ownKeys.forEach(function (key) {
|
922 | _defineProperty(target, key, source[key]);
|
923 | });
|
924 | }
|
925 |
|
926 | return target;
|
927 | }
|
928 |
|
929 | function _inherits(subClass, superClass) {
|
930 | if (typeof superClass !== "function" && superClass !== null) {
|
931 | throw new TypeError("Super expression must either be null or a function");
|
932 | }
|
933 |
|
934 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
935 | constructor: {
|
936 | value: subClass,
|
937 | writable: true,
|
938 | configurable: true
|
939 | }
|
940 | });
|
941 | if (superClass) _setPrototypeOf(subClass, superClass);
|
942 | }
|
943 |
|
944 | function _getPrototypeOf(o) {
|
945 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
946 | return o.__proto__ || Object.getPrototypeOf(o);
|
947 | };
|
948 | return _getPrototypeOf(o);
|
949 | }
|
950 |
|
951 | function _setPrototypeOf(o, p) {
|
952 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
953 | o.__proto__ = p;
|
954 | return o;
|
955 | };
|
956 |
|
957 | return _setPrototypeOf(o, p);
|
958 | }
|
959 |
|
960 | function _assertThisInitialized(self) {
|
961 | if (self === void 0) {
|
962 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
963 | }
|
964 |
|
965 | return self;
|
966 | }
|
967 |
|
968 | function _possibleConstructorReturn(self, call) {
|
969 | if (call && (typeof call === "object" || typeof call === "function")) {
|
970 | return call;
|
971 | }
|
972 |
|
973 | return _assertThisInitialized(self);
|
974 | }
|
975 |
|
976 | function _superPropBase(object, property) {
|
977 | while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
978 | object = _getPrototypeOf(object);
|
979 | if (object === null) break;
|
980 | }
|
981 |
|
982 | return object;
|
983 | }
|
984 |
|
985 | function _get(target, property, receiver) {
|
986 | if (typeof Reflect !== "undefined" && Reflect.get) {
|
987 | _get = Reflect.get;
|
988 | } else {
|
989 | _get = function _get(target, property, receiver) {
|
990 | var base = _superPropBase(target, property);
|
991 |
|
992 | if (!base) return;
|
993 | var desc = Object.getOwnPropertyDescriptor(base, property);
|
994 |
|
995 | if (desc.get) {
|
996 | return desc.get.call(receiver);
|
997 | }
|
998 |
|
999 | return desc.value;
|
1000 | };
|
1001 | }
|
1002 |
|
1003 | return _get(target, property, receiver || target);
|
1004 | }
|
1005 |
|
1006 | function _toConsumableArray(arr) {
|
1007 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
1008 | }
|
1009 |
|
1010 | function _arrayWithoutHoles(arr) {
|
1011 | if (Array.isArray(arr)) {
|
1012 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
1013 |
|
1014 | return arr2;
|
1015 | }
|
1016 | }
|
1017 |
|
1018 | function _iterableToArray(iter) {
|
1019 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
1020 | }
|
1021 |
|
1022 | function _nonIterableSpread() {
|
1023 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
1024 | }
|
1025 |
|
1026 | var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
1027 |
|
1028 | var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
|
1029 |
|
1030 |
|
1031 | var tryGet = function (it, key) {
|
1032 | try {
|
1033 | return it[key];
|
1034 | } catch (error) { }
|
1035 | };
|
1036 |
|
1037 |
|
1038 | var classof = function (it) {
|
1039 | var O, tag, result;
|
1040 | return it === undefined ? 'Undefined' : it === null ? 'Null'
|
1041 |
|
1042 | : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
|
1043 |
|
1044 | : CORRECT_ARGUMENTS ? classofRaw(O)
|
1045 |
|
1046 | : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
|
1047 | };
|
1048 |
|
1049 | var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
|
1050 | var test = {};
|
1051 |
|
1052 | test[TO_STRING_TAG$1] = 'z';
|
1053 |
|
1054 |
|
1055 |
|
1056 | var objectToString = String(test) !== '[object z]' ? function toString() {
|
1057 | return '[object ' + classof(this) + ']';
|
1058 | } : test.toString;
|
1059 |
|
1060 | var ObjectPrototype = Object.prototype;
|
1061 |
|
1062 |
|
1063 |
|
1064 | if (objectToString !== ObjectPrototype.toString) {
|
1065 | redefine(ObjectPrototype, 'toString', objectToString, { unsafe: true });
|
1066 | }
|
1067 |
|
1068 | var validateSetPrototypeOfArguments = function (O, proto) {
|
1069 | anObject(O);
|
1070 | if (!isObject(proto) && proto !== null) {
|
1071 | throw TypeError("Can't set " + String(proto) + ' as a prototype');
|
1072 | }
|
1073 | };
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 | var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
|
1080 | var correctSetter = false;
|
1081 | var test = {};
|
1082 | var setter;
|
1083 | try {
|
1084 | setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
|
1085 | setter.call(test, []);
|
1086 | correctSetter = test instanceof Array;
|
1087 | } catch (error) { }
|
1088 | return function setPrototypeOf(O, proto) {
|
1089 | validateSetPrototypeOfArguments(O, proto);
|
1090 | if (correctSetter) setter.call(O, proto);
|
1091 | else O.__proto__ = proto;
|
1092 | return O;
|
1093 | };
|
1094 | }() : undefined);
|
1095 |
|
1096 | var inheritIfRequired = function (that, target, C) {
|
1097 | var S = target.constructor;
|
1098 | var P;
|
1099 | if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && objectSetPrototypeOf) {
|
1100 | objectSetPrototypeOf(that, P);
|
1101 | } return that;
|
1102 | };
|
1103 |
|
1104 | var MATCH = wellKnownSymbol('match');
|
1105 |
|
1106 |
|
1107 |
|
1108 | var isRegexp = function (it) {
|
1109 | var isRegExp;
|
1110 | return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
|
1111 | };
|
1112 |
|
1113 |
|
1114 |
|
1115 | var regexpFlags = function () {
|
1116 | var that = anObject(this);
|
1117 | var result = '';
|
1118 | if (that.global) result += 'g';
|
1119 | if (that.ignoreCase) result += 'i';
|
1120 | if (that.multiline) result += 'm';
|
1121 | if (that.unicode) result += 'u';
|
1122 | if (that.sticky) result += 'y';
|
1123 | return result;
|
1124 | };
|
1125 |
|
1126 | var path = global$1;
|
1127 |
|
1128 | var aFunction$1 = function (variable) {
|
1129 | return typeof variable == 'function' ? variable : undefined;
|
1130 | };
|
1131 |
|
1132 | var getBuiltIn = function (namespace, method) {
|
1133 | return arguments.length < 2 ? aFunction$1(path[namespace]) || aFunction$1(global$1[namespace])
|
1134 | : path[namespace] && path[namespace][method] || global$1[namespace] && global$1[namespace][method];
|
1135 | };
|
1136 |
|
1137 | var SPECIES$2 = wellKnownSymbol('species');
|
1138 |
|
1139 | var setSpecies = function (CONSTRUCTOR_NAME) {
|
1140 | var C = getBuiltIn(CONSTRUCTOR_NAME);
|
1141 | var defineProperty = objectDefineProperty.f;
|
1142 | if (descriptors && C && !C[SPECIES$2]) defineProperty(C, SPECIES$2, {
|
1143 | configurable: true,
|
1144 | get: function () { return this; }
|
1145 | });
|
1146 | };
|
1147 |
|
1148 | var MATCH$1 = wellKnownSymbol('match');
|
1149 |
|
1150 |
|
1151 |
|
1152 | var defineProperty = objectDefineProperty.f;
|
1153 | var getOwnPropertyNames = objectGetOwnPropertyNames.f;
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 | var NativeRegExp = global$1.RegExp;
|
1159 | var RegExpPrototype = NativeRegExp.prototype;
|
1160 | var re1 = /a/g;
|
1161 | var re2 = /a/g;
|
1162 |
|
1163 |
|
1164 | var CORRECT_NEW = new NativeRegExp(re1) !== re1;
|
1165 |
|
1166 | var FORCED$1 = isForced_1('RegExp', descriptors && (!CORRECT_NEW || fails(function () {
|
1167 | re2[MATCH$1] = false;
|
1168 |
|
1169 | return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';
|
1170 | })));
|
1171 |
|
1172 |
|
1173 |
|
1174 | if (FORCED$1) {
|
1175 | var RegExpWrapper = function RegExp(pattern, flags) {
|
1176 | var thisIsRegExp = this instanceof RegExpWrapper;
|
1177 | var patternIsRegExp = isRegexp(pattern);
|
1178 | var flagsAreUndefined = flags === undefined;
|
1179 | return !thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined ? pattern
|
1180 | : inheritIfRequired(CORRECT_NEW
|
1181 | ? new NativeRegExp(patternIsRegExp && !flagsAreUndefined ? pattern.source : pattern, flags)
|
1182 | : NativeRegExp((patternIsRegExp = pattern instanceof RegExpWrapper)
|
1183 | ? pattern.source
|
1184 | : pattern, patternIsRegExp && flagsAreUndefined ? regexpFlags.call(pattern) : flags)
|
1185 | , thisIsRegExp ? this : RegExpPrototype, RegExpWrapper);
|
1186 | };
|
1187 | var proxy = function (key) {
|
1188 | key in RegExpWrapper || defineProperty(RegExpWrapper, key, {
|
1189 | configurable: true,
|
1190 | get: function () { return NativeRegExp[key]; },
|
1191 | set: function (it) { NativeRegExp[key] = it; }
|
1192 | });
|
1193 | };
|
1194 | var keys = getOwnPropertyNames(NativeRegExp);
|
1195 | var i = 0;
|
1196 | while (i < keys.length) proxy(keys[i++]);
|
1197 | RegExpPrototype.constructor = RegExpWrapper;
|
1198 | RegExpWrapper.prototype = RegExpPrototype;
|
1199 | redefine(global$1, 'RegExp', RegExpWrapper);
|
1200 | }
|
1201 |
|
1202 |
|
1203 | setSpecies('RegExp');
|
1204 |
|
1205 | var TO_STRING = 'toString';
|
1206 | var nativeToString = /./[TO_STRING];
|
1207 |
|
1208 | var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
|
1209 |
|
1210 | var INCORRECT_NAME = nativeToString.name != TO_STRING;
|
1211 |
|
1212 |
|
1213 |
|
1214 | if (NOT_GENERIC || INCORRECT_NAME) {
|
1215 | redefine(RegExp.prototype, TO_STRING, function toString() {
|
1216 | var R = anObject(this);
|
1217 | return '/'.concat(R.source, '/',
|
1218 | 'flags' in R ? R.flags : !descriptors && R instanceof RegExp ? regexpFlags.call(R) : undefined);
|
1219 | }, { unsafe: true });
|
1220 | }
|
1221 |
|
1222 |
|
1223 |
|
1224 | var stringAt = function (that, pos, CONVERT_TO_STRING) {
|
1225 | var S = String(requireObjectCoercible(that));
|
1226 | var position = toInteger(pos);
|
1227 | var size = S.length;
|
1228 | var first, second;
|
1229 | if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
|
1230 | first = S.charCodeAt(position);
|
1231 | return first < 0xD800 || first > 0xDBFF || position + 1 === size
|
1232 | || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
|
1233 | ? CONVERT_TO_STRING ? S.charAt(position) : first
|
1234 | : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
|
1235 | };
|
1236 |
|
1237 |
|
1238 |
|
1239 | var advanceStringIndex = function (S, index, unicode) {
|
1240 | return index + (unicode ? stringAt(S, index, true).length : 1);
|
1241 | };
|
1242 |
|
1243 | var nativeExec = RegExp.prototype.exec;
|
1244 |
|
1245 |
|
1246 |
|
1247 | var nativeReplace = String.prototype.replace;
|
1248 |
|
1249 | var patchedExec = nativeExec;
|
1250 |
|
1251 | var UPDATES_LAST_INDEX_WRONG = (function () {
|
1252 | var re1 = /a/;
|
1253 | var re2 = /b*/g;
|
1254 | nativeExec.call(re1, 'a');
|
1255 | nativeExec.call(re2, 'a');
|
1256 | return re1.lastIndex !== 0 || re2.lastIndex !== 0;
|
1257 | })();
|
1258 |
|
1259 |
|
1260 | var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
|
1261 |
|
1262 | var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
|
1263 |
|
1264 | if (PATCH) {
|
1265 | patchedExec = function exec(str) {
|
1266 | var re = this;
|
1267 | var lastIndex, reCopy, match, i;
|
1268 |
|
1269 | if (NPCG_INCLUDED) {
|
1270 | reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
|
1271 | }
|
1272 | if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
|
1273 |
|
1274 | match = nativeExec.call(re, str);
|
1275 |
|
1276 | if (UPDATES_LAST_INDEX_WRONG && match) {
|
1277 | re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
|
1278 | }
|
1279 | if (NPCG_INCLUDED && match && match.length > 1) {
|
1280 |
|
1281 |
|
1282 | nativeReplace.call(match[0], reCopy, function () {
|
1283 | for (i = 1; i < arguments.length - 2; i++) {
|
1284 | if (arguments[i] === undefined) match[i] = undefined;
|
1285 | }
|
1286 | });
|
1287 | }
|
1288 |
|
1289 | return match;
|
1290 | };
|
1291 | }
|
1292 |
|
1293 | var regexpExec = patchedExec;
|
1294 |
|
1295 |
|
1296 |
|
1297 | var regexpExecAbstract = function (R, S) {
|
1298 | var exec = R.exec;
|
1299 | if (typeof exec === 'function') {
|
1300 | var result = exec.call(R, S);
|
1301 | if (typeof result !== 'object') {
|
1302 | throw TypeError('RegExp exec method returned something other than an Object or null');
|
1303 | }
|
1304 | return result;
|
1305 | }
|
1306 |
|
1307 | if (classofRaw(R) !== 'RegExp') {
|
1308 | throw TypeError('RegExp#exec called on incompatible receiver');
|
1309 | }
|
1310 |
|
1311 | return regexpExec.call(R, S);
|
1312 | };
|
1313 |
|
1314 | var SPECIES$3 = wellKnownSymbol('species');
|
1315 |
|
1316 | var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
|
1317 |
|
1318 |
|
1319 |
|
1320 | var re = /./;
|
1321 | re.exec = function () {
|
1322 | var result = [];
|
1323 | result.groups = { a: '7' };
|
1324 | return result;
|
1325 | };
|
1326 | return ''.replace(re, '$<a>') !== '7';
|
1327 | });
|
1328 |
|
1329 |
|
1330 |
|
1331 | var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
|
1332 | var re = /(?:)/;
|
1333 | var originalExec = re.exec;
|
1334 | re.exec = function () { return originalExec.apply(this, arguments); };
|
1335 | var result = 'ab'.split(re);
|
1336 | return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
|
1337 | });
|
1338 |
|
1339 | var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
|
1340 | var SYMBOL = wellKnownSymbol(KEY);
|
1341 |
|
1342 | var DELEGATES_TO_SYMBOL = !fails(function () {
|
1343 |
|
1344 | var O = {};
|
1345 | O[SYMBOL] = function () { return 7; };
|
1346 | return ''[KEY](O) != 7;
|
1347 | });
|
1348 |
|
1349 | var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
|
1350 |
|
1351 | var execCalled = false;
|
1352 | var re = /a/;
|
1353 | re.exec = function () { execCalled = true; return null; };
|
1354 |
|
1355 | if (KEY === 'split') {
|
1356 |
|
1357 |
|
1358 | re.constructor = {};
|
1359 | re.constructor[SPECIES$3] = function () { return re; };
|
1360 | }
|
1361 |
|
1362 | re[SYMBOL]('');
|
1363 | return !execCalled;
|
1364 | });
|
1365 |
|
1366 | if (
|
1367 | !DELEGATES_TO_SYMBOL ||
|
1368 | !DELEGATES_TO_EXEC ||
|
1369 | (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
|
1370 | (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
|
1371 | ) {
|
1372 | var nativeRegExpMethod = /./[SYMBOL];
|
1373 | var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
|
1374 | if (regexp.exec === regexpExec) {
|
1375 | if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
|
1376 |
|
1377 |
|
1378 |
|
1379 | return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
|
1380 | }
|
1381 | return { done: true, value: nativeMethod.call(str, regexp, arg2) };
|
1382 | }
|
1383 | return { done: false };
|
1384 | });
|
1385 | var stringMethod = methods[0];
|
1386 | var regexMethod = methods[1];
|
1387 |
|
1388 | redefine(String.prototype, KEY, stringMethod);
|
1389 | redefine(RegExp.prototype, SYMBOL, length == 2
|
1390 |
|
1391 |
|
1392 | ? function (string, arg) { return regexMethod.call(string, this, arg); }
|
1393 |
|
1394 |
|
1395 | : function (string) { return regexMethod.call(string, this); }
|
1396 | );
|
1397 | if (sham) hide(RegExp.prototype[SYMBOL], 'sham', true);
|
1398 | }
|
1399 | };
|
1400 |
|
1401 | var max$2 = Math.max;
|
1402 | var min$3 = Math.min;
|
1403 | var floor$1 = Math.floor;
|
1404 | var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
|
1405 | var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
|
1406 |
|
1407 | var maybeToString = function (it) {
|
1408 | return it === undefined ? it : String(it);
|
1409 | };
|
1410 |
|
1411 |
|
1412 | fixRegexpWellKnownSymbolLogic(
|
1413 | 'replace',
|
1414 | 2,
|
1415 | function (REPLACE, nativeReplace, maybeCallNative) {
|
1416 | return [
|
1417 |
|
1418 |
|
1419 | function replace(searchValue, replaceValue) {
|
1420 | var O = requireObjectCoercible(this);
|
1421 | var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
|
1422 | return replacer !== undefined
|
1423 | ? replacer.call(searchValue, O, replaceValue)
|
1424 | : nativeReplace.call(String(O), searchValue, replaceValue);
|
1425 | },
|
1426 |
|
1427 |
|
1428 | function (regexp, replaceValue) {
|
1429 | var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
|
1430 | if (res.done) return res.value;
|
1431 |
|
1432 | var rx = anObject(regexp);
|
1433 | var S = String(this);
|
1434 |
|
1435 | var functionalReplace = typeof replaceValue === 'function';
|
1436 | if (!functionalReplace) replaceValue = String(replaceValue);
|
1437 |
|
1438 | var global = rx.global;
|
1439 | if (global) {
|
1440 | var fullUnicode = rx.unicode;
|
1441 | rx.lastIndex = 0;
|
1442 | }
|
1443 | var results = [];
|
1444 | while (true) {
|
1445 | var result = regexpExecAbstract(rx, S);
|
1446 | if (result === null) break;
|
1447 |
|
1448 | results.push(result);
|
1449 | if (!global) break;
|
1450 |
|
1451 | var matchStr = String(result[0]);
|
1452 | if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
|
1453 | }
|
1454 |
|
1455 | var accumulatedResult = '';
|
1456 | var nextSourcePosition = 0;
|
1457 | for (var i = 0; i < results.length; i++) {
|
1458 | result = results[i];
|
1459 |
|
1460 | var matched = String(result[0]);
|
1461 | var position = max$2(min$3(toInteger(result.index), S.length), 0);
|
1462 | var captures = [];
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 | for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
|
1469 | var namedCaptures = result.groups;
|
1470 | if (functionalReplace) {
|
1471 | var replacerArgs = [matched].concat(captures, position, S);
|
1472 | if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
|
1473 | var replacement = String(replaceValue.apply(undefined, replacerArgs));
|
1474 | } else {
|
1475 | replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
|
1476 | }
|
1477 | if (position >= nextSourcePosition) {
|
1478 | accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
|
1479 | nextSourcePosition = position + matched.length;
|
1480 | }
|
1481 | }
|
1482 | return accumulatedResult + S.slice(nextSourcePosition);
|
1483 | }
|
1484 | ];
|
1485 |
|
1486 |
|
1487 | function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
|
1488 | var tailPos = position + matched.length;
|
1489 | var m = captures.length;
|
1490 | var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
|
1491 | if (namedCaptures !== undefined) {
|
1492 | namedCaptures = toObject(namedCaptures);
|
1493 | symbols = SUBSTITUTION_SYMBOLS;
|
1494 | }
|
1495 | return nativeReplace.call(replacement, symbols, function (match, ch) {
|
1496 | var capture;
|
1497 | switch (ch.charAt(0)) {
|
1498 | case '$': return '$';
|
1499 | case '&': return matched;
|
1500 | case '`': return str.slice(0, position);
|
1501 | case "'": return str.slice(tailPos);
|
1502 | case '<':
|
1503 | capture = namedCaptures[ch.slice(1, -1)];
|
1504 | break;
|
1505 | default:
|
1506 | var n = +ch;
|
1507 | if (n === 0) return match;
|
1508 | if (n > m) {
|
1509 | var f = floor$1(n / 10);
|
1510 | if (f === 0) return match;
|
1511 | if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
|
1512 | return match;
|
1513 | }
|
1514 | capture = captures[n - 1];
|
1515 | }
|
1516 | return capture === undefined ? '' : capture;
|
1517 | });
|
1518 | }
|
1519 | }
|
1520 | );
|
1521 |
|
1522 | var navigator = global$1.navigator;
|
1523 |
|
1524 | var userAgent = navigator && navigator.userAgent || '';
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 | var slice = [].slice;
|
1530 |
|
1531 | var MSIE = /MSIE .\./.test(userAgent);
|
1532 |
|
1533 | var wrap = function (set) {
|
1534 | return function (fn, time /* , ...args */) {
|
1535 | var boundArgs = arguments.length > 2;
|
1536 | var args = boundArgs ? slice.call(arguments, 2) : false;
|
1537 | return set(boundArgs ? function () {
|
1538 |
|
1539 | (typeof fn == 'function' ? fn : Function(fn)).apply(this, args);
|
1540 | } : fn, time);
|
1541 | };
|
1542 | };
|
1543 |
|
1544 | _export({ global: true, bind: true, forced: MSIE }, {
|
1545 | setTimeout: wrap(global$1.setTimeout),
|
1546 | setInterval: wrap(global$1.setInterval)
|
1547 | });
|
1548 |
|
1549 | function $nt(fn) {
|
1550 | Vue$1.nextTick(fn);
|
1551 | }
|
1552 | function $set(target, field, value) {
|
1553 | Vue$1.set(target, field, value);
|
1554 | }
|
1555 | function $del(target, field) {
|
1556 | Vue$1.delete(target, field);
|
1557 | }
|
1558 | function isValidChildren(children) {
|
1559 | return Array.isArray(children) && children.length > 0;
|
1560 | }
|
1561 | var _toString = Object.prototype.toString;
|
1562 | function isUndef(v) {
|
1563 | return v === undefined || v === null;
|
1564 | }
|
1565 | function toString$1(val) {
|
1566 | return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
|
1567 | }
|
1568 | function extend(to, _from) {
|
1569 | for (var key in _from) {
|
1570 | $set(to, key, _from[key]);
|
1571 | }
|
1572 |
|
1573 | return to;
|
1574 | }
|
1575 | function debounce(fn, wait) {
|
1576 | var timeout = null;
|
1577 | return function () {
|
1578 | for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
|
1579 | arg[_key] = arguments[_key];
|
1580 | }
|
1581 |
|
1582 | if (timeout !== null) clearTimeout(timeout);
|
1583 | timeout = setTimeout(function () {
|
1584 | return fn.apply(void 0, arg);
|
1585 | }, wait);
|
1586 | };
|
1587 | }
|
1588 | function isDate(arg) {
|
1589 | return _toString.call(arg) === '[object Date]';
|
1590 | }
|
1591 | function isPlainObject(arg) {
|
1592 | return _toString.call(arg) === '[object Object]';
|
1593 | }
|
1594 | function isFunction(arg) {
|
1595 | return _toString.call(arg) === '[object Function]';
|
1596 | }
|
1597 | function isString(arg) {
|
1598 | return _toString.call(arg) === '[object String]';
|
1599 | }
|
1600 | function isBool(arg) {
|
1601 | return _toString.call(arg) === '[object Boolean]';
|
1602 | }
|
1603 | function toLine(name) {
|
1604 | var line = name.replace(/([A-Z])/g, '-$1').toLowerCase();
|
1605 | if (line.indexOf('-') === 0) line = line.substr(1);
|
1606 | return line;
|
1607 | }
|
1608 | function isNumeric(n) {
|
1609 | return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
1610 | }
|
1611 | function toArray(a) {
|
1612 | return Array.isArray(a) ? a : [a];
|
1613 | }
|
1614 | function isElement(arg) {
|
1615 | return _typeof(arg) === 'object' && arg !== null && arg.nodeType === 1 && !isPlainObject(arg);
|
1616 | }
|
1617 | function deepExtend(origin) {
|
1618 | var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1619 | var isArr = false;
|
1620 |
|
1621 | for (var key in target) {
|
1622 | if (Object.prototype.hasOwnProperty.call(target, key)) {
|
1623 | var clone = target[key];
|
1624 |
|
1625 | if ((isArr = Array.isArray(clone)) || isPlainObject(clone)) {
|
1626 | var nst = origin[key] === undefined;
|
1627 |
|
1628 | if (isArr) {
|
1629 | isArr = false;
|
1630 | nst && $set(origin, key, []);
|
1631 | } else {
|
1632 | nst && $set(origin, key, {});
|
1633 | }
|
1634 |
|
1635 | deepExtend(origin[key], clone);
|
1636 | } else {
|
1637 | $set(origin, key, clone);
|
1638 | }
|
1639 | }
|
1640 | }
|
1641 |
|
1642 | return origin;
|
1643 | }
|
1644 | var id$2 = 0;
|
1645 | function uniqueId() {
|
1646 | return ++id$2;
|
1647 | }
|
1648 | function toDefSlot(slot, $h, rule) {
|
1649 | return [slot && isFunction(slot) ? slot.call(rule, $h) : slot];
|
1650 | }
|
1651 | function timeStampToDate(timeStamp) {
|
1652 | if (isDate(timeStamp)) return timeStamp;else {
|
1653 | var date = new Date(timeStamp);
|
1654 | return date.toString() === 'Invalid Date' ? timeStamp : date;
|
1655 | }
|
1656 | }
|
1657 | function preventDefault(e) {
|
1658 | e.preventDefault();
|
1659 | }
|
1660 | function dateFormat(fmt) {
|
1661 | var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
|
1662 | var o = {
|
1663 | "M+": date.getMonth() + 1,
|
1664 | "d+": date.getDate(),
|
1665 | "h+": date.getHours(),
|
1666 | "m+": date.getMinutes(),
|
1667 | "s+": date.getSeconds(),
|
1668 | "q+": Math.floor((date.getMonth() + 3) / 3),
|
1669 | "S": date.getMilliseconds()
|
1670 | };
|
1671 | if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
|
1672 |
|
1673 | for (var k in o) {
|
1674 | if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
|
1675 | }
|
1676 |
|
1677 | return fmt;
|
1678 | }
|
1679 | function errMsg() {
|
1680 | return '\n\x67\x69\x74\x68\x75\x62\x3a\x68\x74\x74\x70' + '\x73\x3a\x2f\x2f\x67\x69\x74\x68\x75\x62\x2e\x63\x6f' + '\x6d\x2f\x78\x61\x62\x6f\x79\x2f\x66\x6f\x72\x6d\x2d' + '\x63\x72\x65\x61\x74\x65\n\x64\x6f\x63\x75\x6d\x65' + '\x6e\x74\x3a\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77' + '\x2e\x66\x6f\x72\x6d\x2d\x63\x72\x65\x61\x74\x65\x2e' + '\x63\x6f\x6d';
|
1681 | }
|
1682 |
|
1683 | var baseComponent = {
|
1684 | data: function data() {
|
1685 | return {
|
1686 | rules: {},
|
1687 | components: {},
|
1688 | cptData: {},
|
1689 | buttonProps: {},
|
1690 | resetProps: {},
|
1691 | trueData: {},
|
1692 | jsonData: {},
|
1693 | $f: {},
|
1694 | isShow: true,
|
1695 | unique: 1
|
1696 | };
|
1697 | },
|
1698 | components: components,
|
1699 | methods: {
|
1700 | _formField: function _formField() {
|
1701 | return Object.keys(this.trueData);
|
1702 | },
|
1703 | _changeFormData: function _changeFormData(field, value) {
|
1704 | if (Object.keys(this.cptData).indexOf(field) !== -1) this.$set(this.cptData, field, value);
|
1705 | },
|
1706 | _changeValue: function _changeValue(field, value) {
|
1707 | this.$set(this.trueData[field], 'value', value);
|
1708 | },
|
1709 | _value: function _value(field) {
|
1710 | return this.trueData[field] === undefined ? undefined : this.trueData[field].value;
|
1711 | },
|
1712 | _trueData: function _trueData(field) {
|
1713 | return this.trueData[field];
|
1714 | },
|
1715 | _formData: function _formData(field) {
|
1716 | return this.cptData[field];
|
1717 | },
|
1718 | _removeField: function _removeField(field) {
|
1719 | $del(this.cptData, field);
|
1720 | $del(this.trueData, field);
|
1721 | $del(this.jsonData, field);
|
1722 | if (this.components[field] !== undefined) $del(this.components, field);
|
1723 | },
|
1724 | _buttonProps: function _buttonProps(props) {
|
1725 | this.$set(this, 'buttonProps', deepExtend(this.buttonProps, props));
|
1726 | },
|
1727 | _resetProps: function _resetProps(props) {
|
1728 | this.$set(this, 'resetProps', deepExtend(this.resetProps, props));
|
1729 | },
|
1730 | __init: function __init() {},
|
1731 | _refresh: function _refresh() {
|
1732 | this.unique += 1;
|
1733 | },
|
1734 | _sync: function _sync() {
|
1735 | this.unique += 1;
|
1736 | this._fComponent.fRender.cacheUnique = this.unique;
|
1737 | },
|
1738 | _change: function _change(field, json) {
|
1739 | if (this.jsonData[field] !== json) {
|
1740 | this.jsonData[field] = json;
|
1741 | return true;
|
1742 | }
|
1743 |
|
1744 | return false;
|
1745 | }
|
1746 | },
|
1747 | beforeDestroy: function beforeDestroy() {
|
1748 | this._fComponent.reload([]);
|
1749 | }
|
1750 | };
|
1751 |
|
1752 | var formCreateName = 'FormCreate';
|
1753 |
|
1754 | var $FormCreate = function $FormCreate() {
|
1755 | return {
|
1756 | name: formCreateName,
|
1757 | mixins: [baseComponent],
|
1758 | props: {
|
1759 | rule: {
|
1760 | type: Array,
|
1761 | required: true,
|
1762 | default: function _default() {
|
1763 | return {};
|
1764 | }
|
1765 | },
|
1766 | option: {
|
1767 | type: Object,
|
1768 | default: function _default() {
|
1769 | return {};
|
1770 | },
|
1771 | required: false
|
1772 | },
|
1773 | value: Object
|
1774 | },
|
1775 | render: function render() {
|
1776 | return this._fComponent.render();
|
1777 | },
|
1778 | beforeCreate: function beforeCreate() {
|
1779 | var _this$$options$propsD = this.$options.propsData,
|
1780 | rule = _this$$options$propsD.rule,
|
1781 | option = _this$$options$propsD.option;
|
1782 |
|
1783 | var _fc = new FormCreate(rule, option);
|
1784 |
|
1785 | this._fComponent = _fc;
|
1786 | _fc._type = 'rule';
|
1787 |
|
1788 | _fc.beforeBoot(this);
|
1789 | },
|
1790 | created: function created() {
|
1791 | var _fc = this._fComponent;
|
1792 |
|
1793 | _fc.boot();
|
1794 |
|
1795 | this.$f = _fc.fCreateApi;
|
1796 | this.$emit('input', _fc.fCreateApi);
|
1797 | },
|
1798 | mounted: function mounted() {
|
1799 | var _this = this;
|
1800 |
|
1801 | var _fc = this._fComponent;
|
1802 |
|
1803 | _fc.mounted(this);
|
1804 |
|
1805 | this.$watch('rule', function (n) {
|
1806 | _fc.reload(n);
|
1807 |
|
1808 | _this.$emit('input', _this.$f);
|
1809 | });
|
1810 | this.$watch('option', function (n) {
|
1811 | $nt(function () {
|
1812 | _this._sync();
|
1813 | });
|
1814 | }, {
|
1815 | deep: true
|
1816 | });
|
1817 |
|
1818 | this.__init();
|
1819 |
|
1820 | this.$emit('input', this.$f);
|
1821 | }
|
1822 | };
|
1823 | };
|
1824 |
|
1825 | function coreComponent(fComponent) {
|
1826 | return {
|
1827 | name: "".concat(formCreateName, "Core"),
|
1828 | mixins: [baseComponent],
|
1829 | render: function render() {
|
1830 | return fComponent.render();
|
1831 | },
|
1832 | beforeCreate: function beforeCreate() {
|
1833 | this._fComponent = fComponent;
|
1834 | fComponent._type = 'rules';
|
1835 | fComponent.beforeBoot(this);
|
1836 | },
|
1837 | created: function created() {
|
1838 | fComponent.boot();
|
1839 | this.$f = fComponent.fCreateApi;
|
1840 | },
|
1841 | mounted: function mounted() {
|
1842 | var _this = this;
|
1843 |
|
1844 | fComponent.mounted(this);
|
1845 | this.$watch('rules', function (n) {
|
1846 | _this._fComponent.reload(n);
|
1847 | });
|
1848 | this.$watch('option', function (n) {
|
1849 | $nt(function () {
|
1850 | _this._sync();
|
1851 | });
|
1852 | }, {
|
1853 | deep: true
|
1854 | });
|
1855 |
|
1856 | this.__init();
|
1857 | }
|
1858 | };
|
1859 | }
|
1860 |
|
1861 | var Handler = function () {
|
1862 | function Handler(vm, _rule, Render, options, noValue) {
|
1863 | _classCallCheck(this, Handler);
|
1864 |
|
1865 | var rule = parseRule(_rule, vm, noValue);
|
1866 | this.rule = rule;
|
1867 | this.noValue = noValue;
|
1868 | this.type = toString$1(rule.type).toLowerCase();
|
1869 | this.isDef = true;
|
1870 | this.vm = vm;
|
1871 | this.el = {};
|
1872 | this.watch = [];
|
1873 | this.root = [];
|
1874 | this.orgChildren = [];
|
1875 |
|
1876 | if (!rule.field && noValue) {
|
1877 | this.field = '_def_' + uniqueId();
|
1878 | this.isDef = false;
|
1879 | } else {
|
1880 | this.field = rule.field;
|
1881 | }
|
1882 |
|
1883 | this.init();
|
1884 | var id = uniqueId();
|
1885 | this.id = id;
|
1886 | this.unique = 'fc_' + id;
|
1887 | this.key = 'key_' + id;
|
1888 | this.refName = '__' + this.field + this.id;
|
1889 | if (isUndef(rule.props.elementId)) $set(rule.props, 'elementId', this.unique);
|
1890 | this.refresh();
|
1891 | this.render = new Render(vm, this, options);
|
1892 | }
|
1893 |
|
1894 | _createClass(Handler, [{
|
1895 | key: "refresh",
|
1896 | value: function refresh() {
|
1897 | var rule = this.rule;
|
1898 | this.parseValue = this.toFormValue(rule.value);
|
1899 | this.orgChildren = isValidChildren(rule.children) ? _toConsumableArray(rule.children) : [];
|
1900 | this.deleted = false;
|
1901 | return this;
|
1902 | }
|
1903 | }, {
|
1904 | key: "init",
|
1905 | value: function init() {}
|
1906 | }, {
|
1907 | key: "toFormValue",
|
1908 | value: function toFormValue(value) {
|
1909 | return value;
|
1910 | }
|
1911 | }, {
|
1912 | key: "toValue",
|
1913 | value: function toValue(parseValue) {
|
1914 | return parseValue;
|
1915 | }
|
1916 | }, {
|
1917 | key: "setValue",
|
1918 | value: function setValue(value) {
|
1919 | this.rule.value = value;
|
1920 |
|
1921 | this.vm._changeValue(this.field, value);
|
1922 | }
|
1923 | }, {
|
1924 | key: "getValue",
|
1925 | value: function getValue() {
|
1926 | return this.vm._value(this.field);
|
1927 | }
|
1928 | }, {
|
1929 | key: "watchValue",
|
1930 | value: function watchValue(n) {
|
1931 | $set(this.rule, 'value', n);
|
1932 |
|
1933 | this.vm._changeFormData(this.field, this.toFormValue(n));
|
1934 | }
|
1935 | }, {
|
1936 | key: "watchFormValue",
|
1937 | value: function watchFormValue(n) {}
|
1938 | }, {
|
1939 | key: "reset",
|
1940 | value: function reset() {
|
1941 | this.vm._changeValue(this.field, this.defaultValue);
|
1942 |
|
1943 | this.clearMsg();
|
1944 | }
|
1945 | }, {
|
1946 | key: "clearMsg",
|
1947 | value: function clearMsg() {
|
1948 | var refName = 'fItem' + this.refName,
|
1949 | fItem = this.vm.$refs[refName];
|
1950 |
|
1951 | if (fItem) {
|
1952 | fItem.validateMessage = '';
|
1953 | fItem.validateState = '';
|
1954 | fItem.validateDisabled = true;
|
1955 | }
|
1956 | }
|
1957 | }, {
|
1958 | key: "mounted",
|
1959 | value: function mounted() {
|
1960 | var refName = 'fItem' + this.refName,
|
1961 | vm = this.vm;
|
1962 | this.el = vm.$refs[this.refName] || {};
|
1963 | if (this.defaultValue === undefined) this.defaultValue = this.toValue(vm.$refs[refName] && !isUndef(vm.$refs[refName].initialValue) ? vm.$refs[refName].initialValue : deepExtend({}, {
|
1964 | value: this.rule.value
|
1965 | }).value);
|
1966 | }
|
1967 | }, {
|
1968 | key: "$emit",
|
1969 | value: function $emit(eventName) {
|
1970 | var _this$rule$vm, _this$el;
|
1971 |
|
1972 | eventName = "fc:".concat(eventName);
|
1973 |
|
1974 | for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1975 | params[_key - 1] = arguments[_key];
|
1976 | }
|
1977 |
|
1978 | if (this.type === 'template' && this.rule.template) (_this$rule$vm = this.rule.vm).$emit.apply(_this$rule$vm, [eventName].concat(params));else if (this.noValue === true && this.el.$emit) (_this$el = this.el).$emit.apply(_this$el, [eventName].concat(params));
|
1979 | }
|
1980 | }]);
|
1981 |
|
1982 | return Handler;
|
1983 | }();
|
1984 | function defRule() {
|
1985 | return {
|
1986 | validate: [],
|
1987 | event: {},
|
1988 | col: {},
|
1989 | emit: [],
|
1990 | props: {},
|
1991 | on: {},
|
1992 | options: [],
|
1993 | title: '',
|
1994 | value: '',
|
1995 | field: '',
|
1996 | className: ''
|
1997 | };
|
1998 | }
|
1999 | function parseRule(rule, vm, noVal) {
|
2000 | var def = defRule();
|
2001 | Object.keys(def).forEach(function (k) {
|
2002 | if (isUndef(rule[k])) $set(rule, k, def[k]);
|
2003 | });
|
2004 | var parseRule = {
|
2005 | col: parseCol(rule.col),
|
2006 | props: parseProps(rule.props),
|
2007 | emitEvent: parseEmit(rule.field, rule.emitPrefix, rule.emit, vm),
|
2008 | validate: parseArray(rule.validate),
|
2009 | options: parseArray(rule.options)
|
2010 | };
|
2011 | parseRule.event = extend(parseEvent(rule.event), parseRule.emitEvent);
|
2012 | parseRule.on = parseOn(rule.on, parseRule.emitEvent);
|
2013 | Object.keys(parseRule).forEach(function (k) {
|
2014 | $set(rule, k, parseRule[k]);
|
2015 | });
|
2016 |
|
2017 | if (!rule.field && !noVal) {
|
2018 | console.error('规则的 field 字段不能空' + errMsg());
|
2019 | }
|
2020 |
|
2021 | return rule;
|
2022 | }
|
2023 | function parseOn(on, emitEvent) {
|
2024 | if (Object.keys(emitEvent).length > 0) extend(on, emitEvent);
|
2025 | return on;
|
2026 | }
|
2027 | function parseArray(validate) {
|
2028 | return Array.isArray(validate) ? validate : [];
|
2029 | }
|
2030 | function parseEmit(field, emitPrefix, emit, vm) {
|
2031 | var event = {};
|
2032 | if (!Array.isArray(emit)) return event;
|
2033 | emit.forEach(function (eventName) {
|
2034 | var fieldKey = toLine("".concat(field, "-").concat(eventName)).replace('_', '-');
|
2035 | var emitKey = emitPrefix ? "".concat(emitPrefix, "-").toLowerCase() + toLine(eventName) : emitPrefix;
|
2036 |
|
2037 | event[eventName] = function () {
|
2038 | for (var _len2 = arguments.length, arg = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
2039 | arg[_key2] = arguments[_key2];
|
2040 | }
|
2041 |
|
2042 | vm.$emit.apply(vm, [fieldKey].concat(arg));
|
2043 | if (emitKey && fieldKey !== emitKey) vm.$emit.apply(vm, [emitKey].concat(arg));
|
2044 | };
|
2045 |
|
2046 | event["on-".concat(eventName)] = event[eventName];
|
2047 | });
|
2048 | return event;
|
2049 | }
|
2050 | function parseEvent(event) {
|
2051 | Object.keys(event).forEach(function (eventName) {
|
2052 | var _name = toString$1(eventName).indexOf('on-') === 0 ? eventName : "on-".concat(eventName);
|
2053 |
|
2054 | if (_name !== eventName) {
|
2055 | $set(event, _name, event[eventName]);
|
2056 | }
|
2057 | });
|
2058 | return event;
|
2059 | }
|
2060 | function parseProps(props) {
|
2061 | if (isUndef(props.hidden)) $set(props, 'hidden', false);
|
2062 | if (isUndef(props.visibility)) $set(props, 'visibility', false);
|
2063 | return props;
|
2064 | }
|
2065 | function parseCol(col) {
|
2066 | if (isNumeric(col)) {
|
2067 | return {
|
2068 | span: col
|
2069 | };
|
2070 | } else if (col.span === undefined) $set(col, 'span', 24);
|
2071 |
|
2072 | return col;
|
2073 | }
|
2074 |
|
2075 | function parseVData(data) {
|
2076 | if (isString(data)) data = {
|
2077 | domProps: {
|
2078 | innerHTML: data
|
2079 | }
|
2080 | };else if (data && isFunction(data.get)) data = data.get();
|
2081 | return data;
|
2082 | }
|
2083 | function getVNode(VNode) {
|
2084 | return isFunction(VNode) ? VNode() : VNode || [];
|
2085 | }
|
2086 |
|
2087 | var VNode = function () {
|
2088 | function VNode(vm) {
|
2089 | _classCallCheck(this, VNode);
|
2090 |
|
2091 | this.setVm(vm);
|
2092 | }
|
2093 |
|
2094 | _createClass(VNode, [{
|
2095 | key: "setVm",
|
2096 | value: function setVm(vm) {
|
2097 | this.vm = vm;
|
2098 | this.$h = vm.$createElement;
|
2099 | }
|
2100 | }, {
|
2101 | key: "make",
|
2102 | value: function make(nodeName, data, VNodeFn) {
|
2103 | var Node = this.$h(nodeName, parseVData(data), getVNode(VNodeFn));
|
2104 | Node.context = this.vm;
|
2105 | return Node;
|
2106 | }
|
2107 | }], [{
|
2108 | key: "use",
|
2109 | value: function use(nodes) {
|
2110 | Object.keys(nodes).forEach(function (k) {
|
2111 | VNode.prototype[k] = function (data, VNodeFn) {
|
2112 | return this.make(nodes[k], data, VNodeFn);
|
2113 | };
|
2114 | });
|
2115 | }
|
2116 | }]);
|
2117 |
|
2118 | return VNode;
|
2119 | }();
|
2120 |
|
2121 | function defVData() {
|
2122 | return {
|
2123 | class: {},
|
2124 | style: {},
|
2125 | attrs: {},
|
2126 | props: {},
|
2127 | domProps: {},
|
2128 | on: {},
|
2129 | nativeOn: {},
|
2130 | directives: [],
|
2131 | scopedSlots: {},
|
2132 | slot: undefined,
|
2133 | key: undefined,
|
2134 | ref: undefined
|
2135 | };
|
2136 | }
|
2137 |
|
2138 | var VData = function () {
|
2139 | function VData() {
|
2140 | _classCallCheck(this, VData);
|
2141 |
|
2142 | this.init();
|
2143 | }
|
2144 |
|
2145 | _createClass(VData, [{
|
2146 | key: "class",
|
2147 | value: function _class(classList) {
|
2148 | var _this = this;
|
2149 |
|
2150 | var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
2151 | if (isUndef(classList)) return this;
|
2152 |
|
2153 | if (Array.isArray(classList)) {
|
2154 | classList.forEach(function (cls) {
|
2155 | $set(_this._data.class, toString$1(cls), true);
|
2156 | });
|
2157 | } else if (isPlainObject(classList)) {
|
2158 | $set(this._data, 'class', extend(this._data.class, classList));
|
2159 | } else {
|
2160 | $set(this._data.class, toString$1(classList), status === undefined ? true : status);
|
2161 | }
|
2162 |
|
2163 | return this;
|
2164 | }
|
2165 | }, {
|
2166 | key: "directives",
|
2167 | value: function directives(_directives) {
|
2168 | if (isUndef(_directives)) return this;
|
2169 | $set(this._data, 'directives', this._data.directives.concat(toArray(_directives)));
|
2170 | return this;
|
2171 | }
|
2172 | }, {
|
2173 | key: "init",
|
2174 | value: function init() {
|
2175 | this._data = defVData();
|
2176 | return this;
|
2177 | }
|
2178 | }, {
|
2179 | key: "get",
|
2180 | value: function get() {
|
2181 | this._prev = this._data;
|
2182 | this.init();
|
2183 | return this._prev;
|
2184 | }
|
2185 | }]);
|
2186 |
|
2187 | return VData;
|
2188 | }();
|
2189 | var keyList = ['ref', 'key', 'slot'];
|
2190 | var objList = ['scopedSlots', 'nativeOn', 'on', 'domProps', 'props', 'attrs', 'style'];
|
2191 | keyList.forEach(function (key) {
|
2192 | VData.prototype[key] = function (val) {
|
2193 | $set(this._data, key, val);
|
2194 | return this;
|
2195 | };
|
2196 | });
|
2197 | objList.forEach(function (key) {
|
2198 | VData.prototype[key] = function (obj, val) {
|
2199 | if (isUndef(obj)) return this;
|
2200 |
|
2201 | if (isPlainObject(obj)) {
|
2202 | $set(this._data, key, extend(this._data[key], obj));
|
2203 | } else {
|
2204 | $set(this._data[key], toString$1(obj), val);
|
2205 | }
|
2206 |
|
2207 | return this;
|
2208 | };
|
2209 | });
|
2210 |
|
2211 | var $de = debounce(function (fn) {
|
2212 | return fn();
|
2213 | }, 1);
|
2214 |
|
2215 | var Render = function () {
|
2216 | function Render(vm, handler) {
|
2217 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
2218 |
|
2219 | _classCallCheck(this, Render);
|
2220 |
|
2221 | this.vm = vm;
|
2222 | this.handler = handler;
|
2223 | this.options = options;
|
2224 | this.vNode = new VNode(vm);
|
2225 | this.vData = new VData();
|
2226 | this.cache = null;
|
2227 | this.$tickEvent = [];
|
2228 | this.init();
|
2229 | }
|
2230 |
|
2231 | _createClass(Render, [{
|
2232 | key: "init",
|
2233 | value: function init() {}
|
2234 | }, {
|
2235 | key: "cacheParse",
|
2236 | value: function cacheParse(form, _super) {
|
2237 | var _this$handler = this.handler,
|
2238 | noValue = _this$handler.noValue,
|
2239 | noCache = _this$handler.noCache;
|
2240 | if (!this.cache || noValue === true || noCache === true) this.cache = _super ? Render.prototype.parse.call(this, form) : this.parse(form);
|
2241 |
|
2242 | var eventList = _toConsumableArray(this.$tickEvent);
|
2243 |
|
2244 | this.$tickEvent = [];
|
2245 | if (eventList.length) $nt(function () {
|
2246 | eventList.forEach(function (event) {
|
2247 | return event();
|
2248 | });
|
2249 | });
|
2250 | return this.cache;
|
2251 | }
|
2252 | }, {
|
2253 | key: "sync",
|
2254 | value: function sync(event) {
|
2255 | if (isFunction(event)) this.$tickEvent.push(event);
|
2256 | this.clearCache();
|
2257 |
|
2258 | this.vm._sync();
|
2259 | }
|
2260 | }, {
|
2261 | key: "clearCache",
|
2262 | value: function clearCache() {
|
2263 | this.cache = null;
|
2264 | var children = this.handler.rule.children;
|
2265 | if (isValidChildren(children)) children.forEach(function (child) {
|
2266 | return !isString(child) && child.__handler__.render.clearCache();
|
2267 | });
|
2268 | }
|
2269 | }, {
|
2270 | key: "childrenParse",
|
2271 | value: function childrenParse(form) {
|
2272 | var _this$handler2 = this.handler,
|
2273 | rule = _this$handler2.rule,
|
2274 | orgChildren = _this$handler2.orgChildren,
|
2275 | vm = _this$handler2.vm,
|
2276 | children = rule.children,
|
2277 | vn = [];
|
2278 |
|
2279 | if (isValidChildren(children)) {
|
2280 | orgChildren.forEach(function (_rule) {
|
2281 | if (children.indexOf(_rule) === -1) {
|
2282 | vm._fComponent.removeField(_rule.__field__);
|
2283 | }
|
2284 | });
|
2285 | vn = children.map(function (child) {
|
2286 | if (isString(child)) return [child];
|
2287 |
|
2288 | if (child.__handler__) {
|
2289 | return child.__handler__.render.cacheParse(form, true);
|
2290 | }
|
2291 |
|
2292 | $de(function () {
|
2293 | return vm._fComponent.reload();
|
2294 | });
|
2295 | });
|
2296 | this.handler.orgChildren = _toConsumableArray(children);
|
2297 | } else if (orgChildren.length > 0) {
|
2298 | orgChildren.forEach(function (_rule) {
|
2299 | vm._fComponent.removeField(_rule.__field__);
|
2300 | });
|
2301 | this.handler.orgChildren = [];
|
2302 | }
|
2303 |
|
2304 | return vn;
|
2305 | }
|
2306 | }, {
|
2307 | key: "parse",
|
2308 | value: function parse(form) {
|
2309 | var _this$handler3 = this.handler,
|
2310 | type = _this$handler3.type,
|
2311 | rule = _this$handler3.rule,
|
2312 | refName = _this$handler3.refName,
|
2313 | key = _this$handler3.key,
|
2314 | noValue = _this$handler3.noValue;
|
2315 |
|
2316 | if (type === 'template' && rule.template) {
|
2317 | if (Vue$1.compile === undefined) {
|
2318 | console.error('使用的 Vue 版本不支持 compile' + errMsg());
|
2319 | return [];
|
2320 | }
|
2321 |
|
2322 | if (isUndef(rule.vm)) rule.vm = new Vue$1();
|
2323 | var vn = Vue$1.compile(rule.template, {}).render.call(rule.vm);
|
2324 | if (vn.data === undefined) vn.data = {};
|
2325 | extend(vn.data, rule);
|
2326 | vn.key = key;
|
2327 | return [vn];
|
2328 | } else if (!noValue) {
|
2329 | return form.makeComponent(this.handler.render);
|
2330 | } else {
|
2331 | rule.ref = refName;
|
2332 | if (isUndef(rule.key)) rule.key = 'def' + uniqueId();
|
2333 |
|
2334 | var _vn = this.vNode.make(type, _objectSpread({}, rule), this.childrenParse(form));
|
2335 |
|
2336 | _vn.key = key;
|
2337 | return [_vn];
|
2338 | }
|
2339 | }
|
2340 | }, {
|
2341 | key: "inputProps",
|
2342 | value: function inputProps() {
|
2343 | var _this = this;
|
2344 |
|
2345 | var _this$handler4 = this.handler,
|
2346 | refName = _this$handler4.refName,
|
2347 | key = _this$handler4.key,
|
2348 | field = _this$handler4.field,
|
2349 | rule = _this$handler4.rule;
|
2350 | var props = rule.props,
|
2351 | event = rule.event;
|
2352 | Object.keys(this.vData._data).forEach(function (key) {
|
2353 | if (rule[key] !== undefined) _this.vData[key](rule[key]);
|
2354 | });
|
2355 | var data = this.vData.props({
|
2356 | value: this.vm._formData(field)
|
2357 | }).ref(refName).key(key + 'fc' + field).on(event).on('input', function (value) {
|
2358 | _this.onInput(value);
|
2359 | });
|
2360 | if (isUndef(props.size)) data.props({
|
2361 | size: this.options.form.size
|
2362 | });
|
2363 | return data;
|
2364 | }
|
2365 | }, {
|
2366 | key: "onInput",
|
2367 | value: function onInput(value) {
|
2368 | value = isUndef(value) ? '' : value;
|
2369 | var handler = this.handler,
|
2370 | _this$handler5 = this.handler,
|
2371 | field = _this$handler5.field,
|
2372 | vm = _this$handler5.vm,
|
2373 | trueValue = handler.toValue(value);
|
2374 |
|
2375 | vm._changeFormData(field, value);
|
2376 |
|
2377 | if (!vm._change(field, JSON.stringify(trueValue))) return;
|
2378 | handler.setValue(trueValue);
|
2379 | handler.watchFormValue(value);
|
2380 | }
|
2381 | }]);
|
2382 |
|
2383 | return Render;
|
2384 | }();
|
2385 | function defaultRenderFactory(node) {
|
2386 | var setKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2387 | return function (_Render) {
|
2388 | _inherits(render, _Render);
|
2389 |
|
2390 | function render() {
|
2391 | _classCallCheck(this, render);
|
2392 |
|
2393 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
2394 | }
|
2395 |
|
2396 | _createClass(render, [{
|
2397 | key: "parse",
|
2398 | value: function parse(form) {
|
2399 | var props = this.inputProps();
|
2400 | if (setKey) props.key(this.handler.key);
|
2401 | return [this.vNode[node](props.get(), this.childrenParse(form))];
|
2402 | }
|
2403 | }]);
|
2404 |
|
2405 | return render;
|
2406 | }(Render);
|
2407 | }
|
2408 |
|
2409 | function getBaseConfig() {
|
2410 | return {
|
2411 | mounted: function mounted($f) {},
|
2412 | onReload: function onReload($f) {},
|
2413 | onSubmit: function onSubmit(formData, $f) {},
|
2414 | el: null,
|
2415 | switchMaker: true
|
2416 | };
|
2417 | }
|
2418 |
|
2419 | var version = "1.6.5";
|
2420 | var ui = "iview";
|
2421 | var formCreateStyleElId = 'form-create-style';
|
2422 | var drive = {};
|
2423 | function getRule(rule) {
|
2424 | if (isFunction(rule.getRule)) return rule.getRule();else return rule;
|
2425 | }
|
2426 | function getComponent(vm, rule, createOptions) {
|
2427 | var componentList = drive.componentList,
|
2428 | name = toString$1(rule.type).toLowerCase(),
|
2429 | component = isComponent(name) ? componentList[name] : getUdfComponent();
|
2430 | return new component.handler(vm, rule, component.render, createOptions, component.noValue);
|
2431 | }
|
2432 | function isComponent(type) {
|
2433 | return drive.componentList[type] !== undefined;
|
2434 | }
|
2435 | function getUdfComponent() {
|
2436 | return {
|
2437 | handler: Handler,
|
2438 | render: Render,
|
2439 | noValue: true
|
2440 | };
|
2441 | }
|
2442 | var _vue = typeof window !== 'undefined' && window.Vue ? window.Vue : Vue$1;
|
2443 | function bindHandler(rule, handler) {
|
2444 | Object.defineProperties(rule, {
|
2445 | __field__: {
|
2446 | value: handler.field,
|
2447 | enumerable: false,
|
2448 | configurable: false
|
2449 | },
|
2450 | __handler__: {
|
2451 | value: handler,
|
2452 | enumerable: false,
|
2453 | configurable: false
|
2454 | }
|
2455 | });
|
2456 | }
|
2457 | function initStyle() {
|
2458 | if (document.getElementById(formCreateStyleElId) !== null) return;
|
2459 | var style = document.createElement('style');
|
2460 | style.id = formCreateStyleElId;
|
2461 | style.innerText = drive.style;
|
2462 | document.getElementsByTagName('head')[0].appendChild(style);
|
2463 | }
|
2464 | function margeGlobal(_options) {
|
2465 | if (isBool(_options.sumbitBtn)) $set(_options, 'sumbitBtn', {
|
2466 | show: _options.sumbitBtn
|
2467 | });
|
2468 | if (isBool(_options.resetBtn)) $set(_options, 'resetBtn', {
|
2469 | show: _options.resetBtn
|
2470 | });
|
2471 | var options = deepExtend(extend(drive.getConfig(), getBaseConfig()), _options);
|
2472 | $set(options, 'el', !options.el ? window.document.body : isElement(options.el) ? options.el : document.querySelector(options.el));
|
2473 | return options;
|
2474 | }
|
2475 | function delHandler(handler) {
|
2476 | handler.watch.forEach(function (unWatch) {
|
2477 | return unWatch();
|
2478 | });
|
2479 | handler.watch = [];
|
2480 | handler.deleted = true;
|
2481 | }
|
2482 | var components = {
|
2483 | 'form-create': _vue.extend($FormCreate())
|
2484 | };
|
2485 | function setComponent(id, component) {
|
2486 | if (component) {
|
2487 | return _vue.component(toString$1(id), component);
|
2488 | } else if (id) return components[toString$1(id)];else return _objectSpread({}, components);
|
2489 | }
|
2490 |
|
2491 | var FormCreate = function () {
|
2492 | function FormCreate(rules) {
|
2493 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2494 |
|
2495 | _classCallCheck(this, FormCreate);
|
2496 |
|
2497 | this.fRender = undefined;
|
2498 | this.fCreateApi = undefined;
|
2499 | this.$parent = undefined;
|
2500 | this.id = uniqueId();
|
2501 | this.validate = {};
|
2502 |
|
2503 | this.__init(rules, options);
|
2504 |
|
2505 | initStyle();
|
2506 | this.$tick = debounce(function (fn) {
|
2507 | return fn();
|
2508 | }, 150);
|
2509 | }
|
2510 |
|
2511 | _createClass(FormCreate, [{
|
2512 | key: "__init",
|
2513 | value: function __init(rules, options) {
|
2514 | this.options = margeGlobal(options);
|
2515 | this.rules = Array.isArray(rules) ? rules : [];
|
2516 | this.origin = _toConsumableArray(this.rules);
|
2517 | this.handlers = {};
|
2518 | this.formData = {};
|
2519 | this.trueData = {};
|
2520 | this.components = {};
|
2521 | this.fieldList = [];
|
2522 | this.switchMaker = this.options.switchMaker;
|
2523 | }
|
2524 | }, {
|
2525 | key: "render",
|
2526 | value: function render() {
|
2527 | return this.fRender.render(this.vm);
|
2528 | }
|
2529 | }, {
|
2530 | key: "beforeBoot",
|
2531 | value: function beforeBoot(vm) {
|
2532 | this.vm = vm;
|
2533 | this.createHandler(this.rules);
|
2534 | this.fRender = new drive.formRender(this);
|
2535 | }
|
2536 | }, {
|
2537 | key: "boot",
|
2538 | value: function boot() {
|
2539 | var vm = this.vm;
|
2540 | vm.$set(vm, 'cptData', this.formData);
|
2541 | vm.$set(vm, 'trueData', this.trueData);
|
2542 | vm.$set(vm, 'buttonProps', this.options.submitBtn);
|
2543 | vm.$set(vm, 'resetProps', this.options.resetBtn);
|
2544 | vm.$set(vm, 'rules', this.rules);
|
2545 | vm.$set(vm, 'components', this.components);
|
2546 | if (this.fCreateApi === undefined) this.fCreateApi = drive.getGlobalApi(this);
|
2547 | this.fCreateApi.rule = this.rules;
|
2548 | this.fCreateApi.config = this.options;
|
2549 | }
|
2550 | }, {
|
2551 | key: "setHandler",
|
2552 | value: function setHandler(handler) {
|
2553 | var rule = handler.rule,
|
2554 | field = handler.field,
|
2555 | isDef = handler.isDef;
|
2556 | this.handlers[field] = handler;
|
2557 |
|
2558 | if (handler.noValue === true) {
|
2559 | if (isDef === true) $set(this.components, field, rule);
|
2560 | return;
|
2561 | }
|
2562 |
|
2563 | $set(this.formData, field, handler.parseValue);
|
2564 | $set(this.validate, field, rule.validate);
|
2565 | $set(this.trueData, field, rule);
|
2566 | }
|
2567 | }, {
|
2568 | key: "notField",
|
2569 | value: function notField(field) {
|
2570 | return this.handlers[field] === undefined;
|
2571 | }
|
2572 | }, {
|
2573 | key: "createHandler",
|
2574 | value: function createHandler(rules, child) {
|
2575 | var _this = this;
|
2576 |
|
2577 | rules.map(function (_rule, index) {
|
2578 | if (child && isString(_rule)) return;
|
2579 | if (!_rule.type) return console.error("\u672A\u5B9A\u4E49\u751F\u6210\u89C4\u5219\u7684 type \u5B57\u6BB5" + errMsg());
|
2580 | var rule = getRule(_rule),
|
2581 | handler;
|
2582 |
|
2583 | if (_rule.__handler__) {
|
2584 | handler = _rule.__handler__;
|
2585 | if (handler.vm !== _this.vm && !handler.deleted) return console.error("\u7B2C".concat(index + 1, "\u6761\u89C4\u5219\u6B63\u5728\u5176\u4ED6\u7684 <form-create> \u4E2D\u4F7F\u7528") + errMsg());
|
2586 | handler.vm = _this.vm;
|
2587 | handler.render.vm = _this.vm;
|
2588 | handler.render.vNode.setVm(_this.vm);
|
2589 | handler.refresh();
|
2590 | } else {
|
2591 | handler = getComponent(_this.vm, rule, _this.options);
|
2592 | }
|
2593 |
|
2594 | var children = handler.rule.children;
|
2595 | if (!_this.notField(handler.field)) return console.error("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728") + errMsg());
|
2596 |
|
2597 | if (_this.switchMaker) {
|
2598 | rules[index] = rule;
|
2599 | if (!child) _this.origin[index] = rule;
|
2600 | _rule = rule;
|
2601 | }
|
2602 |
|
2603 | _this.setHandler(handler);
|
2604 |
|
2605 | if (!_rule.__handler__) {
|
2606 | bindHandler(_rule, handler);
|
2607 | }
|
2608 |
|
2609 | if (isValidChildren(children)) _this.createHandler(children, true);
|
2610 | if (!child) _this.fieldList.push(handler.field);
|
2611 | return handler;
|
2612 | }).filter(function (h) {
|
2613 | return h;
|
2614 | }).forEach(function (h) {
|
2615 | h.root = rules;
|
2616 | });
|
2617 | return rules;
|
2618 | }
|
2619 | }, {
|
2620 | key: "create",
|
2621 | value: function create(Vue) {
|
2622 | var $fCreate = Vue.extend(coreComponent(this)),
|
2623 | $vm = new $fCreate().$mount();
|
2624 | this.options.el.appendChild($vm.$el);
|
2625 | return $vm;
|
2626 | }
|
2627 | }, {
|
2628 | key: "mounted",
|
2629 | value: function mounted(vm) {
|
2630 | var _this2 = this;
|
2631 |
|
2632 | var first = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
2633 | this.vm = vm;
|
2634 | var _this$options = this.options,
|
2635 | mounted = _this$options.mounted,
|
2636 | onReload = _this$options.onReload;
|
2637 | Object.keys(this.handlers).forEach(function (field) {
|
2638 | var handler = _this2.handlers[field];
|
2639 | if (handler.watch.length === 0) _this2.addHandlerWatch(handler);
|
2640 | handler.mounted();
|
2641 | });
|
2642 | Object.keys(vm.cptData).forEach(function (field) {
|
2643 | var value = _this2.handlers[field].toValue(vm.cptData[field]);
|
2644 |
|
2645 | vm.jsonData[field] = JSON.stringify(value);
|
2646 |
|
2647 | vm._changeValue(field, value);
|
2648 | });
|
2649 |
|
2650 | if (first) {
|
2651 | mounted && mounted(this.fCreateApi);
|
2652 | this.$emit('mounted', this.fCreateApi);
|
2653 | }
|
2654 |
|
2655 | onReload && onReload(this.fCreateApi);
|
2656 | this.$emit('reload', this.fCreateApi);
|
2657 | }
|
2658 | }, {
|
2659 | key: "$emit",
|
2660 | value: function $emit(eventName) {
|
2661 | for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
2662 | params[_key - 1] = arguments[_key];
|
2663 | }
|
2664 |
|
2665 | if (this.$parent) {
|
2666 | var _this$$parent;
|
2667 |
|
2668 | (_this$$parent = this.$parent).$emit.apply(_this$$parent, ["fc:".concat(eventName)].concat(params));
|
2669 | } else {
|
2670 | var _this$vm;
|
2671 |
|
2672 | (_this$vm = this.vm).$emit.apply(_this$vm, [eventName].concat(params));
|
2673 | }
|
2674 | }
|
2675 | }, {
|
2676 | key: "removeField",
|
2677 | value: function removeField(field) {
|
2678 | if (this.handlers[field] === undefined) return;
|
2679 | var index = this.fieldList.indexOf(field);
|
2680 | delHandler(this.handlers[field]);
|
2681 | $del(this.handlers, field);
|
2682 | $del(this.validate, field);
|
2683 |
|
2684 | if (index !== -1) {
|
2685 | this.fieldList.splice(index, 1);
|
2686 | }
|
2687 |
|
2688 | this.vm._removeField(field);
|
2689 | }
|
2690 | }, {
|
2691 | key: "addHandlerWatch",
|
2692 | value: function addHandlerWatch(handler) {
|
2693 | var _this3 = this;
|
2694 |
|
2695 | if (handler.noValue === true) return;
|
2696 | var field = handler.field,
|
2697 | vm = this.vm;
|
2698 | var unWatch = vm.$watch(function () {
|
2699 | return vm.cptData[field];
|
2700 | }, function (n) {
|
2701 | if (_this3.handlers[field] === undefined) return delHandler(handler);
|
2702 | var trueValue = handler.toValue(n),
|
2703 | json = JSON.stringify(trueValue);
|
2704 |
|
2705 | if (vm._change(field, json)) {
|
2706 | handler.setValue(trueValue);
|
2707 | handler.watchFormValue(n);
|
2708 | }
|
2709 | }, {
|
2710 | deep: true
|
2711 | });
|
2712 | var unWatch2 = vm.$watch(function () {
|
2713 | return vm.trueData[field].value;
|
2714 | }, function (n) {
|
2715 | if (n === undefined) return;
|
2716 | if (_this3.handlers[field] === undefined) return delHandler(handler);
|
2717 | var json = JSON.stringify(n);
|
2718 |
|
2719 | if (vm._change(field, json)) {
|
2720 | handler.watchValue(n);
|
2721 | $nt(function () {
|
2722 | return handler.render.sync();
|
2723 | });
|
2724 | }
|
2725 | }, {
|
2726 | deep: true
|
2727 | });
|
2728 | handler.watch.push(unWatch, unWatch2);
|
2729 |
|
2730 | var bind = function bind() {
|
2731 | if (_this3.handlers[field] === undefined) delHandler(handler);else _this3.$tick(function () {
|
2732 | return handler.render.sync();
|
2733 | });
|
2734 | };
|
2735 |
|
2736 | Object.keys(vm._trueData(field)).forEach(function (key) {
|
2737 | if (key === 'value') return;
|
2738 | handler.watch.push(vm.$watch(function () {
|
2739 | return vm.trueData[field][key];
|
2740 | }, bind, {
|
2741 | deep: true
|
2742 | }));
|
2743 | });
|
2744 | }
|
2745 | }, {
|
2746 | key: "reload",
|
2747 | value: function reload(rules) {
|
2748 | var _this4 = this;
|
2749 |
|
2750 | var vm = this.vm;
|
2751 | if (!rules) return this.reload(this.rules);
|
2752 | if (!this.origin.length) this.fCreateApi.refresh();
|
2753 | this.origin = _toConsumableArray(rules);
|
2754 | Object.keys(this.handlers).forEach(function (field) {
|
2755 | return _this4.removeField(field);
|
2756 | });
|
2757 |
|
2758 | this.__init(rules, this.options);
|
2759 |
|
2760 | this.beforeBoot(vm);
|
2761 | this.boot();
|
2762 |
|
2763 | vm.__init();
|
2764 |
|
2765 | $nt(function () {
|
2766 | _this4.mounted(vm, false);
|
2767 | });
|
2768 | vm.$f = this.fCreateApi;
|
2769 | }
|
2770 | }, {
|
2771 | key: "getFormRef",
|
2772 | value: function getFormRef() {
|
2773 | return this.vm.$refs[this.fRender.refName];
|
2774 | }
|
2775 | }], [{
|
2776 | key: "create",
|
2777 | value: function create(rules) {
|
2778 | var _opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2779 |
|
2780 | var $parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
2781 | var opt = isElement(_opt) ? {
|
2782 | el: _opt
|
2783 | } : _opt;
|
2784 | var fComponent = new FormCreate(rules, opt),
|
2785 | $vm = fComponent.create(_vue);
|
2786 | fComponent.$parent = $parent;
|
2787 | return fComponent.fCreateApi;
|
2788 | }
|
2789 | }, {
|
2790 | key: "install",
|
2791 | value: function install(Vue) {
|
2792 | var $formCreate = function $formCreate(rules) {
|
2793 | var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2794 | return FormCreate.create(rules, opt, this);
|
2795 | };
|
2796 |
|
2797 | $formCreate.maker = FormCreate.maker;
|
2798 | $formCreate.version = version;
|
2799 | $formCreate.ui = ui;
|
2800 | $formCreate.component = setComponent;
|
2801 | Vue.prototype.$formCreate = $formCreate;
|
2802 | Vue.component(formCreateName, Vue.extend($FormCreate()));
|
2803 | _vue = Vue;
|
2804 | }
|
2805 | }, {
|
2806 | key: "init",
|
2807 | value: function init(rules) {
|
2808 | var _opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2809 |
|
2810 | var opt = isElement(_opt) ? {
|
2811 | el: _opt
|
2812 | } : _opt;
|
2813 | var fComponent = new FormCreate(rules, opt);
|
2814 |
|
2815 | var $fCreate = _vue.extend(coreComponent(fComponent));
|
2816 |
|
2817 | var $vm = new $fCreate().$mount();
|
2818 | return {
|
2819 | mount: function mount($el) {
|
2820 | if ($el && isElement($el)) $set(fComponent.options, 'el', $el);
|
2821 | fComponent.options.el.appendChild($vm.$el);
|
2822 | return fComponent.fCreateApi;
|
2823 | },
|
2824 | remove: function remove() {
|
2825 | fComponent.options.el.removeChild($vm.$el);
|
2826 | },
|
2827 | $f: fComponent.fCreateApi
|
2828 | };
|
2829 | }
|
2830 | }]);
|
2831 |
|
2832 | return FormCreate;
|
2833 | }();
|
2834 | FormCreate.version = version;
|
2835 | FormCreate.ui = ui;
|
2836 | FormCreate.component = setComponent;
|
2837 | function setDrive(_drive) {
|
2838 | drive = _drive;
|
2839 |
|
2840 | _drive.install(FormCreate);
|
2841 | }
|
2842 | function install(Vue) {
|
2843 | if (Vue._installedFormCreate === true) return;
|
2844 | Vue._installedFormCreate = true;
|
2845 | Vue.use(FormCreate);
|
2846 | }
|
2847 |
|
2848 | function baseRule() {
|
2849 | return {
|
2850 | event: {},
|
2851 | validate: [],
|
2852 | options: [],
|
2853 | col: {},
|
2854 | children: [],
|
2855 | emit: [],
|
2856 | template: null,
|
2857 | emitPrefix: null
|
2858 | };
|
2859 | }
|
2860 | function creatorFactory(name) {
|
2861 | return function (title, field, value) {
|
2862 | var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
2863 | return new Creator(name, title, field, value, props);
|
2864 | };
|
2865 | }
|
2866 | function creatorTypeFactory(name, type) {
|
2867 | var typeName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'type';
|
2868 | return function (title, field, value) {
|
2869 | var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
2870 | var maker = new Creator(name, title, field, value, props);
|
2871 | if (isFunction(type)) type(maker);else maker.props(typeName, type);
|
2872 | return maker;
|
2873 | };
|
2874 | }
|
2875 |
|
2876 | var Creator = function (_VData) {
|
2877 | _inherits(Creator, _VData);
|
2878 |
|
2879 | function Creator(type, title, field, value) {
|
2880 | var _this;
|
2881 |
|
2882 | var props = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
2883 |
|
2884 | _classCallCheck(this, Creator);
|
2885 |
|
2886 | _this = _possibleConstructorReturn(this, _getPrototypeOf(Creator).call(this));
|
2887 | _this.rule = extend(baseRule(), {
|
2888 | type: type,
|
2889 | title: title,
|
2890 | field: field,
|
2891 | value: value
|
2892 | });
|
2893 |
|
2894 | _this.props({
|
2895 | hidden: false,
|
2896 | visibility: false
|
2897 | });
|
2898 |
|
2899 | if (isPlainObject(props)) _this.props(props);
|
2900 | return _this;
|
2901 | }
|
2902 |
|
2903 | _createClass(Creator, [{
|
2904 | key: "type",
|
2905 | value: function type(_type) {
|
2906 | this.props('type', _type);
|
2907 | return this;
|
2908 | }
|
2909 | }, {
|
2910 | key: "get",
|
2911 | value: function get() {
|
2912 | return this._data;
|
2913 | }
|
2914 | }, {
|
2915 | key: "getRule",
|
2916 | value: function getRule() {
|
2917 | return extend(this.rule, this.get());
|
2918 | }
|
2919 | }, {
|
2920 | key: "setValue",
|
2921 | value: function setValue(value) {
|
2922 | $set(this.rule, 'value', value);
|
2923 | return this;
|
2924 | }
|
2925 | }]);
|
2926 |
|
2927 | return Creator;
|
2928 | }(VData);
|
2929 | var keyAttrs = ['emitPrefix', 'className', 'defaultSlot'];
|
2930 | keyAttrs.forEach(function (attr) {
|
2931 | Creator.prototype[attr] = function (value) {
|
2932 | $set(this.rule, attr, value);
|
2933 | return this;
|
2934 | };
|
2935 | });
|
2936 | var objAttrs = ['event', 'col'];
|
2937 | objAttrs.forEach(function (attr) {
|
2938 | Creator.prototype[attr] = function (opt) {
|
2939 | $set(this.rule, attr, extend(this.rule[attr], opt));
|
2940 | return this;
|
2941 | };
|
2942 | });
|
2943 | var arrAttrs = ['validate', 'options', 'children', 'emit'];
|
2944 | arrAttrs.forEach(function (attr) {
|
2945 | Creator.prototype[attr] = function (opt) {
|
2946 | if (!Array.isArray(opt)) opt = [opt];
|
2947 | $set(this.rule, attr, this.rule[attr].concat(opt));
|
2948 | return this;
|
2949 | };
|
2950 | });
|
2951 |
|
2952 | var name = "hidden";
|
2953 |
|
2954 | var render = function (_Render) {
|
2955 | _inherits(render, _Render);
|
2956 |
|
2957 | function render() {
|
2958 | _classCallCheck(this, render);
|
2959 |
|
2960 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
2961 | }
|
2962 |
|
2963 | _createClass(render, [{
|
2964 | key: "parse",
|
2965 | value: function parse() {
|
2966 | return [];
|
2967 | }
|
2968 | }]);
|
2969 |
|
2970 | return render;
|
2971 | }(Render);
|
2972 |
|
2973 | var maker = _defineProperty({}, name, function (field, value) {
|
2974 | return creatorFactory(name)('', field, value);
|
2975 | });
|
2976 |
|
2977 | var hidden = {
|
2978 | handler: Handler,
|
2979 | render: render,
|
2980 | name: name,
|
2981 | maker: maker
|
2982 | };
|
2983 |
|
2984 | var handler = function (_Handler) {
|
2985 | _inherits(handler, _Handler);
|
2986 |
|
2987 | function handler() {
|
2988 | _classCallCheck(this, handler);
|
2989 |
|
2990 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
2991 | }
|
2992 |
|
2993 | _createClass(handler, [{
|
2994 | key: "init",
|
2995 | value: function init() {
|
2996 | var props = this.rule.props;
|
2997 | if (props.autosize && props.autosize.minRows) $set(props, 'rows', props.autosize.minRows || 2);
|
2998 | }
|
2999 | }, {
|
3000 | key: "toFormValue",
|
3001 | value: function toFormValue(v) {
|
3002 | return toString$1(v);
|
3003 | }
|
3004 | }]);
|
3005 |
|
3006 | return handler;
|
3007 | }(Handler);
|
3008 |
|
3009 | var name$1 = "input";
|
3010 | var maker$1 = ['password', 'url', 'email', 'text', 'textarea'].reduce(function (initial, type) {
|
3011 | initial[type] = creatorTypeFactory(name$1, type);
|
3012 | return initial;
|
3013 | }, {});
|
3014 | maker$1.idate = creatorTypeFactory(name$1, 'date');
|
3015 | var render$1 = defaultRenderFactory(name$1);
|
3016 | var input = {
|
3017 | handler: handler,
|
3018 | render: render$1,
|
3019 | name: name$1,
|
3020 | maker: maker$1
|
3021 | };
|
3022 |
|
3023 | var handler$1 = function (_Handler) {
|
3024 | _inherits(handler, _Handler);
|
3025 |
|
3026 | function handler() {
|
3027 | _classCallCheck(this, handler);
|
3028 |
|
3029 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
3030 | }
|
3031 |
|
3032 | _createClass(handler, [{
|
3033 | key: "toFormValue",
|
3034 | value: function toFormValue(value) {
|
3035 | return this.rule.options.filter(function (opt) {
|
3036 | return opt.value === value;
|
3037 | }).reduce(function (initial, opt) {
|
3038 | return opt.label;
|
3039 | }, '');
|
3040 | }
|
3041 | }, {
|
3042 | key: "toValue",
|
3043 | value: function toValue(parseValue) {
|
3044 | return this.rule.options.filter(function (opt) {
|
3045 | return opt.label === parseValue;
|
3046 | }).reduce(function (initial, opt) {
|
3047 | return opt.value;
|
3048 | }, '');
|
3049 | }
|
3050 | }]);
|
3051 |
|
3052 | return handler;
|
3053 | }(Handler);
|
3054 |
|
3055 | var render$2 = function (_Render) {
|
3056 | _inherits(render, _Render);
|
3057 |
|
3058 | function render() {
|
3059 | _classCallCheck(this, render);
|
3060 |
|
3061 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
3062 | }
|
3063 |
|
3064 | _createClass(render, [{
|
3065 | key: "parse",
|
3066 | value: function parse() {
|
3067 | var _this = this;
|
3068 |
|
3069 | var _this$handler = this.handler,
|
3070 | unique = _this$handler.unique,
|
3071 | options = _this$handler.rule.options;
|
3072 | return [this.vNode.radioGroup(this.inputProps().get(), function () {
|
3073 | return options.map(function (option, index) {
|
3074 | var clone = _objectSpread({}, option);
|
3075 |
|
3076 | delete clone.value;
|
3077 | return _this.vNode.radio({
|
3078 | props: clone,
|
3079 | key: "ropt".concat(index).concat(unique)
|
3080 | });
|
3081 | });
|
3082 | })];
|
3083 | }
|
3084 | }]);
|
3085 |
|
3086 | return render;
|
3087 | }(Render);
|
3088 |
|
3089 | var name$2 = "radio";
|
3090 | var radio = {
|
3091 | handler: handler$1,
|
3092 | render: render$2,
|
3093 | name: name$2
|
3094 | };
|
3095 |
|
3096 | var handler$2 = function (_Handler) {
|
3097 | _inherits(handler, _Handler);
|
3098 |
|
3099 | function handler() {
|
3100 | _classCallCheck(this, handler);
|
3101 |
|
3102 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
3103 | }
|
3104 |
|
3105 | _createClass(handler, [{
|
3106 | key: "init",
|
3107 | value: function init() {
|
3108 | var props = this.rule.props;
|
3109 | if (isUndef(props.disabled)) $set(props, 'disabled', false);
|
3110 | }
|
3111 | }, {
|
3112 | key: "toFormValue",
|
3113 | value: function toFormValue(value) {
|
3114 | if (!value) value = [];else if (!Array.isArray(value)) value = [value];
|
3115 | return this.rule.options.filter(function (opt) {
|
3116 | return value.indexOf(opt.value) !== -1;
|
3117 | }).map(function (option) {
|
3118 | return option.label;
|
3119 | });
|
3120 | }
|
3121 | }, {
|
3122 | key: "toValue",
|
3123 | value: function toValue(parseValue) {
|
3124 | var value = this.rule.options.filter(function (opt) {
|
3125 | return parseValue.indexOf(opt.label) !== -1;
|
3126 | }).map(function (opt) {
|
3127 | return opt.value;
|
3128 | });
|
3129 | if (this.rule.options.length === 1) return value[0] === undefined ? '' : value[0];else return value;
|
3130 | }
|
3131 | }, {
|
3132 | key: "watchFormValue",
|
3133 | value: function watchFormValue(n) {
|
3134 | _get(_getPrototypeOf(handler.prototype), "watchFormValue", this).call(this, n);
|
3135 |
|
3136 | this.render.sync();
|
3137 | }
|
3138 | }]);
|
3139 |
|
3140 | return handler;
|
3141 | }(Handler);
|
3142 |
|
3143 | var render$3 = function (_Render) {
|
3144 | _inherits(render, _Render);
|
3145 |
|
3146 | function render() {
|
3147 | _classCallCheck(this, render);
|
3148 |
|
3149 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
3150 | }
|
3151 |
|
3152 | _createClass(render, [{
|
3153 | key: "parse",
|
3154 | value: function parse() {
|
3155 | var _this = this;
|
3156 |
|
3157 | var _this$handler = this.handler,
|
3158 | unique = _this$handler.unique,
|
3159 | options = _this$handler.rule.options,
|
3160 | key = _this$handler.key;
|
3161 | return [this.vNode.checkboxGroup(this.inputProps().key(key).get(), function () {
|
3162 | return options.map(function (option, index) {
|
3163 | var clone = _objectSpread({}, option);
|
3164 |
|
3165 | delete clone.value;
|
3166 | return _this.vNode.checkbox({
|
3167 | props: clone,
|
3168 | key: "copt".concat(index).concat(unique)
|
3169 | });
|
3170 | });
|
3171 | })];
|
3172 | }
|
3173 | }]);
|
3174 |
|
3175 | return render;
|
3176 | }(Render);
|
3177 |
|
3178 | var name$3 = "checkbox";
|
3179 | var checkbox = {
|
3180 | handler: handler$2,
|
3181 | render: render$3,
|
3182 | name: name$3
|
3183 | };
|
3184 |
|
3185 | var render$4 = function (_Render) {
|
3186 | _inherits(render, _Render);
|
3187 |
|
3188 | function render() {
|
3189 | _classCallCheck(this, render);
|
3190 |
|
3191 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
3192 | }
|
3193 |
|
3194 | _createClass(render, [{
|
3195 | key: "parse",
|
3196 | value: function parse() {
|
3197 | var rule = this.handler.rule,
|
3198 | slot = isUndef(rule.props.slot) ? rule.slot : rule.props.slot;
|
3199 | if (!isPlainObject(slot)) slot = {};
|
3200 | return [this.vNode.switch(this.inputProps().scopedSlots({
|
3201 | open: function open() {
|
3202 | return slot.open;
|
3203 | },
|
3204 | close: function close() {
|
3205 | return slot.close;
|
3206 | }
|
3207 | }).style({
|
3208 | 'margin': '4.5px 0px'
|
3209 | }).get())];
|
3210 | }
|
3211 | }]);
|
3212 |
|
3213 | return render;
|
3214 | }(Render);
|
3215 |
|
3216 | var name$4 = "switch";
|
3217 | var maker$2 = {
|
3218 | sliderRange: creatorTypeFactory(name$4, true, 'range')
|
3219 | };
|
3220 | var iswitch = {
|
3221 | handler: Handler,
|
3222 | render: render$4,
|
3223 | name: name$4,
|
3224 | maker: maker$2
|
3225 | };
|
3226 |
|
3227 | var handler$3 = function (_Handler) {
|
3228 | _inherits(handler, _Handler);
|
3229 |
|
3230 | function handler() {
|
3231 | _classCallCheck(this, handler);
|
3232 |
|
3233 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
3234 | }
|
3235 |
|
3236 | _createClass(handler, [{
|
3237 | key: "toFormValue",
|
3238 | value: function toFormValue(value) {
|
3239 | var isArr = Array.isArray(value);
|
3240 | if (this.rule.props.multiple === true) return isArr === true ? value : [value];else return isArr === true ? value[0] || '' : value;
|
3241 | }
|
3242 | }, {
|
3243 | key: "watchFormValue",
|
3244 | value: function watchFormValue(n) {
|
3245 | _get(_getPrototypeOf(handler.prototype), "watchFormValue", this).call(this, n);
|
3246 |
|
3247 | this.render.sync();
|
3248 | }
|
3249 | }]);
|
3250 |
|
3251 | return handler;
|
3252 | }(Handler);
|
3253 |
|
3254 | var render$5 = function (_Render) {
|
3255 | _inherits(render, _Render);
|
3256 |
|
3257 | function render() {
|
3258 | _classCallCheck(this, render);
|
3259 |
|
3260 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
3261 | }
|
3262 |
|
3263 | _createClass(render, [{
|
3264 | key: "parse",
|
3265 | value: function parse() {
|
3266 | var _this = this;
|
3267 |
|
3268 | var _this$handler = this.handler,
|
3269 | unique = _this$handler.unique,
|
3270 | rule = _this$handler.rule;
|
3271 | return [this.vNode.select(this.inputProps().get(), function () {
|
3272 | return rule.options.map(function (option, index) {
|
3273 | return _this.vNode.option({
|
3274 | props: option,
|
3275 | key: "sopt".concat(index).concat(unique)
|
3276 | }, toDefSlot(option.slot, _this.vm.$createElement, rule));
|
3277 | });
|
3278 | })];
|
3279 | }
|
3280 | }]);
|
3281 |
|
3282 | return render;
|
3283 | }(Render);
|
3284 |
|
3285 | var name$5 = "select";
|
3286 | var maker$3 = {
|
3287 | selectMultiple: creatorTypeFactory(name$5, true, 'multiple'),
|
3288 | selectOne: creatorTypeFactory(name$5, false, 'multiple')
|
3289 | };
|
3290 | var select = {
|
3291 | handler: handler$3,
|
3292 | render: render$5,
|
3293 | name: name$5,
|
3294 | maker: maker$3
|
3295 | };
|
3296 |
|
3297 | var handler$4 = function (_Handler) {
|
3298 | _inherits(handler, _Handler);
|
3299 |
|
3300 | function handler() {
|
3301 | _classCallCheck(this, handler);
|
3302 |
|
3303 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
3304 | }
|
3305 |
|
3306 | _createClass(handler, [{
|
3307 | key: "init",
|
3308 | value: function init() {
|
3309 | var props = this.rule.props;
|
3310 | $set(props, 'type', !props.type ? 'date' : toString$1(props.type).toLowerCase());
|
3311 | if (isUndef(props.startDate)) $set(props, 'startDate', timeStampToDate(props.startDate));
|
3312 | }
|
3313 | }, {
|
3314 | key: "toFormValue",
|
3315 | value: function toFormValue(value) {
|
3316 | var isArr = Array.isArray(value),
|
3317 | props = this.rule.props,
|
3318 | parseValue;
|
3319 |
|
3320 | if (['daterange', 'datetimerange'].indexOf(props.type) !== -1) {
|
3321 | if (isArr) {
|
3322 | parseValue = value.map(function (time) {
|
3323 | return !time ? '' : timeStampToDate(time);
|
3324 | });
|
3325 | } else {
|
3326 | parseValue = ['', ''];
|
3327 | }
|
3328 | } else if ('date' === props.type && props.multiple === true) {
|
3329 | parseValue = toString$1(value);
|
3330 | } else {
|
3331 | parseValue = isArr ? value[0] || '' : value;
|
3332 | parseValue = !parseValue ? '' : timeStampToDate(parseValue);
|
3333 | }
|
3334 |
|
3335 | return parseValue;
|
3336 | }
|
3337 | }, {
|
3338 | key: "toValue",
|
3339 | value: function toValue() {
|
3340 | return this.el.publicStringValue;
|
3341 | }
|
3342 | }, {
|
3343 | key: "mounted",
|
3344 | value: function mounted() {
|
3345 | _get(_getPrototypeOf(handler.prototype), "mounted", this).call(this);
|
3346 |
|
3347 | this.rule.value = this.el.publicStringValue;
|
3348 |
|
3349 | this.vm._changeFormData(this.field, this.toFormValue(this.el.publicStringValue));
|
3350 | }
|
3351 | }]);
|
3352 |
|
3353 | return handler;
|
3354 | }(Handler);
|
3355 |
|
3356 | var name$6 = "datePicker";
|
3357 | var maker$4 = ['date', 'dateRange', 'dateTime', 'dateTimeRange', 'year', 'month'].reduce(function (initial, type) {
|
3358 | initial[type] = creatorTypeFactory(name$6, type.toLowerCase());
|
3359 | return initial;
|
3360 | }, {});
|
3361 | var render$6 = defaultRenderFactory(name$6, true);
|
3362 | var datepicker = {
|
3363 | handler: handler$4,
|
3364 | render: render$6,
|
3365 | name: name$6,
|
3366 | maker: maker$4
|
3367 | };
|
3368 |
|
3369 | function getTime(date) {
|
3370 | return isDate(date) ? dateFormat('hh:mm:ss', date) : date;
|
3371 | }
|
3372 |
|
3373 | var handler$5 = function (_Handler) {
|
3374 | _inherits(handler, _Handler);
|
3375 |
|
3376 | function handler() {
|
3377 | _classCallCheck(this, handler);
|
3378 |
|
3379 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
3380 | }
|
3381 |
|
3382 | _createClass(handler, [{
|
3383 | key: "init",
|
3384 | value: function init() {
|
3385 | var props = this.rule.props;
|
3386 | if (!props.type) $set(props, 'type', 'time');
|
3387 | if (isUndef(props.confirm)) $set(props, 'confirm', true);
|
3388 | }
|
3389 | }, {
|
3390 | key: "toFormValue",
|
3391 | value: function toFormValue(value) {
|
3392 | var parseValue,
|
3393 | isArr = Array.isArray(value);
|
3394 |
|
3395 | if ('timerange' === this.rule.props.type) {
|
3396 | if (isArr) {
|
3397 | parseValue = value.map(function (time) {
|
3398 | return !time ? '' : getTime(timeStampToDate(time));
|
3399 | });
|
3400 | } else {
|
3401 | parseValue = ['', ''];
|
3402 | }
|
3403 | } else {
|
3404 | isArr && (value = value[0]);
|
3405 | parseValue = !value ? '' : getTime(timeStampToDate(value));
|
3406 | }
|
3407 |
|
3408 | return parseValue;
|
3409 | }
|
3410 | }, {
|
3411 | key: "mounted",
|
3412 | value: function mounted() {
|
3413 | _get(_getPrototypeOf(handler.prototype), "mounted", this).call(this);
|
3414 |
|
3415 | this.rule.value = this.el.publicStringValue;
|
3416 |
|
3417 | this.vm._changeFormData(this.field, this.toFormValue(this.el.publicStringValue));
|
3418 | }
|
3419 | }]);
|
3420 |
|
3421 | return handler;
|
3422 | }(Handler);
|
3423 |
|
3424 | var name$7 = "timePicker";
|
3425 | var maker$5 = {
|
3426 | time: creatorTypeFactory(name$7, 'time'),
|
3427 | timeRange: creatorTypeFactory(name$7, 'timerange')
|
3428 | };
|
3429 | var render$7 = defaultRenderFactory(name$7, true);
|
3430 | var timepicker = {
|
3431 | handler: handler$5,
|
3432 | render: render$7,
|
3433 | name: name$7,
|
3434 | maker: maker$5
|
3435 | };
|
3436 |
|
3437 |
|
3438 |
|
3439 | var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
|
3440 |
|
3441 | var whitespace = '[' + whitespaces + ']';
|
3442 | var ltrim = RegExp('^' + whitespace + whitespace + '*');
|
3443 | var rtrim = RegExp(whitespace + whitespace + '*$');
|
3444 |
|
3445 |
|
3446 |
|
3447 |
|
3448 | var stringTrim = function (string, TYPE) {
|
3449 | string = String(requireObjectCoercible(string));
|
3450 | if (TYPE & 1) string = string.replace(ltrim, '');
|
3451 | if (TYPE & 2) string = string.replace(rtrim, '');
|
3452 | return string;
|
3453 | };
|
3454 |
|
3455 | var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
|
3456 | anObject(O);
|
3457 | var keys = objectKeys(Properties);
|
3458 | var length = keys.length;
|
3459 | var i = 0;
|
3460 | var key;
|
3461 | while (length > i) objectDefineProperty.f(O, key = keys[i++], Properties[key]);
|
3462 | return O;
|
3463 | };
|
3464 |
|
3465 | var document$2 = global$1.document;
|
3466 |
|
3467 | var html = document$2 && document$2.documentElement;
|
3468 |
|
3469 |
|
3470 |
|
3471 |
|
3472 |
|
3473 |
|
3474 |
|
3475 | var IE_PROTO = sharedKey('IE_PROTO');
|
3476 | var PROTOTYPE = 'prototype';
|
3477 | var Empty = function () { };
|
3478 |
|
3479 |
|
3480 | var createDict = function () {
|
3481 |
|
3482 | var iframe = documentCreateElement('iframe');
|
3483 | var length = enumBugKeys.length;
|
3484 | var lt = '<';
|
3485 | var script = 'script';
|
3486 | var gt = '>';
|
3487 | var js = 'java' + script + ':';
|
3488 | var iframeDocument;
|
3489 | iframe.style.display = 'none';
|
3490 | html.appendChild(iframe);
|
3491 | iframe.src = String(js);
|
3492 | iframeDocument = iframe.contentWindow.document;
|
3493 | iframeDocument.open();
|
3494 | iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
|
3495 | iframeDocument.close();
|
3496 | createDict = iframeDocument.F;
|
3497 | while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]];
|
3498 | return createDict();
|
3499 | };
|
3500 |
|
3501 | var objectCreate = Object.create || function create(O, Properties) {
|
3502 | var result;
|
3503 | if (O !== null) {
|
3504 | Empty[PROTOTYPE] = anObject(O);
|
3505 | result = new Empty();
|
3506 | Empty[PROTOTYPE] = null;
|
3507 |
|
3508 | result[IE_PROTO] = O;
|
3509 | } else result = createDict();
|
3510 | return Properties === undefined ? result : objectDefineProperties(result, Properties);
|
3511 | };
|
3512 |
|
3513 | hiddenKeys[IE_PROTO] = true;
|
3514 |
|
3515 | var getOwnPropertyNames$1 = objectGetOwnPropertyNames.f;
|
3516 | var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
|
3517 | var defineProperty$1 = objectDefineProperty.f;
|
3518 |
|
3519 | var NUMBER = 'Number';
|
3520 | var NativeNumber = global$1[NUMBER];
|
3521 | var NumberPrototype = NativeNumber.prototype;
|
3522 |
|
3523 |
|
3524 | var BROKEN_CLASSOF = classofRaw(objectCreate(NumberPrototype)) == NUMBER;
|
3525 | var NATIVE_TRIM = 'trim' in String.prototype;
|
3526 |
|
3527 |
|
3528 |
|
3529 | var toNumber = function (argument) {
|
3530 | var it = toPrimitive(argument, false);
|
3531 | var first, third, radix, maxCode, digits, length, i, code;
|
3532 | if (typeof it == 'string' && it.length > 2) {
|
3533 | it = NATIVE_TRIM ? it.trim() : stringTrim(it, 3);
|
3534 | first = it.charCodeAt(0);
|
3535 | if (first === 43 || first === 45) {
|
3536 | third = it.charCodeAt(2);
|
3537 | if (third === 88 || third === 120) return NaN;
|
3538 | } else if (first === 48) {
|
3539 | switch (it.charCodeAt(1)) {
|
3540 | case 66: case 98: radix = 2; maxCode = 49; break;
|
3541 | case 79: case 111: radix = 8; maxCode = 55; break;
|
3542 | default: return +it;
|
3543 | }
|
3544 | digits = it.slice(2);
|
3545 | length = digits.length;
|
3546 | for (i = 0; i < length; i++) {
|
3547 | code = digits.charCodeAt(i);
|
3548 |
|
3549 |
|
3550 | if (code < 48 || code > maxCode) return NaN;
|
3551 | } return parseInt(digits, radix);
|
3552 | }
|
3553 | } return +it;
|
3554 | };
|
3555 |
|
3556 |
|
3557 |
|
3558 | if (isForced_1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
|
3559 | var NumberWrapper = function Number(value) {
|
3560 | var it = arguments.length < 1 ? 0 : value;
|
3561 | var that = this;
|
3562 | return that instanceof NumberWrapper
|
3563 |
|
3564 | && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(that); }) : classofRaw(that) != NUMBER)
|
3565 | ? inheritIfRequired(new NativeNumber(toNumber(it)), that, NumberWrapper) : toNumber(it);
|
3566 | };
|
3567 | for (var keys$1 = descriptors ? getOwnPropertyNames$1(NativeNumber) : (
|
3568 |
|
3569 | 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
|
3570 |
|
3571 | 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
|
3572 | 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
|
3573 | ).split(','), j = 0, key; keys$1.length > j; j++) {
|
3574 | if (has(NativeNumber, key = keys$1[j]) && !has(NumberWrapper, key)) {
|
3575 | defineProperty$1(NumberWrapper, key, getOwnPropertyDescriptor$1(NativeNumber, key));
|
3576 | }
|
3577 | }
|
3578 | NumberWrapper.prototype = NumberPrototype;
|
3579 | NumberPrototype.constructor = NumberWrapper;
|
3580 | redefine(global$1, NUMBER, NumberWrapper);
|
3581 | }
|
3582 |
|
3583 |
|
3584 |
|
3585 | _export({ target: 'Number', stat: true }, {
|
3586 | isNaN: function isNaN(number) {
|
3587 |
|
3588 | return number != number;
|
3589 | }
|
3590 | });
|
3591 |
|
3592 | var handler$6 = function (_Handler) {
|
3593 | _inherits(handler, _Handler);
|
3594 |
|
3595 | function handler() {
|
3596 | _classCallCheck(this, handler);
|
3597 |
|
3598 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
3599 | }
|
3600 |
|
3601 | _createClass(handler, [{
|
3602 | key: "toFormValue",
|
3603 | value: function toFormValue(value) {
|
3604 | var parseValue = parseFloat(value);
|
3605 | if (Number.isNaN(parseValue)) parseValue = 0;
|
3606 | return parseValue;
|
3607 | }
|
3608 | }]);
|
3609 |
|
3610 | return handler;
|
3611 | }(Handler);
|
3612 |
|
3613 | var name$8 = "inputNumber";
|
3614 | var maker$6 = {
|
3615 | number: creatorFactory(name$8)
|
3616 | };
|
3617 | var render$8 = defaultRenderFactory(name$8);
|
3618 | var inputnumber = {
|
3619 | handler: handler$6,
|
3620 | render: render$8,
|
3621 | name: name$8,
|
3622 | maker: maker$6
|
3623 | };
|
3624 |
|
3625 | var handler$7 = function (_Handler) {
|
3626 | _inherits(handler, _Handler);
|
3627 |
|
3628 | function handler() {
|
3629 | _classCallCheck(this, handler);
|
3630 |
|
3631 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
3632 | }
|
3633 |
|
3634 | _createClass(handler, [{
|
3635 | key: "watchFormValue",
|
3636 | value: function watchFormValue(n) {
|
3637 | _get(_getPrototypeOf(handler.prototype), "watchFormValue", this).call(this, n);
|
3638 |
|
3639 | this.render.sync();
|
3640 | }
|
3641 | }]);
|
3642 |
|
3643 | return handler;
|
3644 | }(Handler);
|
3645 |
|
3646 | var name$9 = "colorPicker";
|
3647 | var maker$7 = {
|
3648 | color: creatorFactory(name$9)
|
3649 | };
|
3650 | var render$9 = defaultRenderFactory(name$9, true);
|
3651 | var colorpicker = {
|
3652 | handler: handler$7,
|
3653 | render: render$9,
|
3654 | name: name$9,
|
3655 | maker: maker$7
|
3656 | };
|
3657 |
|
3658 | var SPECIES$4 = wellKnownSymbol('species');
|
3659 |
|
3660 |
|
3661 |
|
3662 | var speciesConstructor = function (O, defaultConstructor) {
|
3663 | var C = anObject(O).constructor;
|
3664 | var S;
|
3665 | return C === undefined || (S = anObject(C)[SPECIES$4]) == undefined ? defaultConstructor : aFunction(S);
|
3666 | };
|
3667 |
|
3668 | var arrayPush = [].push;
|
3669 | var min$4 = Math.min;
|
3670 | var MAX_UINT32 = 0xFFFFFFFF;
|
3671 |
|
3672 |
|
3673 | var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });
|
3674 |
|
3675 |
|
3676 | fixRegexpWellKnownSymbolLogic(
|
3677 | 'split',
|
3678 | 2,
|
3679 | function (SPLIT, nativeSplit, maybeCallNative) {
|
3680 | var internalSplit;
|
3681 | if (
|
3682 | 'abbc'.split(/(b)*/)[1] == 'c' ||
|
3683 | 'test'.split(/(?:)/, -1).length != 4 ||
|
3684 | 'ab'.split(/(?:ab)*/).length != 2 ||
|
3685 | '.'.split(/(.?)(.?)/).length != 4 ||
|
3686 | '.'.split(/()()/).length > 1 ||
|
3687 | ''.split(/.?/).length
|
3688 | ) {
|
3689 |
|
3690 | internalSplit = function (separator, limit) {
|
3691 | var string = String(requireObjectCoercible(this));
|
3692 | var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
|
3693 | if (lim === 0) return [];
|
3694 | if (separator === undefined) return [string];
|
3695 |
|
3696 | if (!isRegexp(separator)) {
|
3697 | return nativeSplit.call(string, separator, lim);
|
3698 | }
|
3699 | var output = [];
|
3700 | var flags = (separator.ignoreCase ? 'i' : '') +
|
3701 | (separator.multiline ? 'm' : '') +
|
3702 | (separator.unicode ? 'u' : '') +
|
3703 | (separator.sticky ? 'y' : '');
|
3704 | var lastLastIndex = 0;
|
3705 |
|
3706 | var separatorCopy = new RegExp(separator.source, flags + 'g');
|
3707 | var match, lastIndex, lastLength;
|
3708 | while (match = regexpExec.call(separatorCopy, string)) {
|
3709 | lastIndex = separatorCopy.lastIndex;
|
3710 | if (lastIndex > lastLastIndex) {
|
3711 | output.push(string.slice(lastLastIndex, match.index));
|
3712 | if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));
|
3713 | lastLength = match[0].length;
|
3714 | lastLastIndex = lastIndex;
|
3715 | if (output.length >= lim) break;
|
3716 | }
|
3717 | if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++;
|
3718 | }
|
3719 | if (lastLastIndex === string.length) {
|
3720 | if (lastLength || !separatorCopy.test('')) output.push('');
|
3721 | } else output.push(string.slice(lastLastIndex));
|
3722 | return output.length > lim ? output.slice(0, lim) : output;
|
3723 | };
|
3724 |
|
3725 | } else if ('0'.split(undefined, 0).length) {
|
3726 | internalSplit = function (separator, limit) {
|
3727 | return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
|
3728 | };
|
3729 | } else internalSplit = nativeSplit;
|
3730 |
|
3731 | return [
|
3732 |
|
3733 |
|
3734 | function split(separator, limit) {
|
3735 | var O = requireObjectCoercible(this);
|
3736 | var splitter = separator == undefined ? undefined : separator[SPLIT];
|
3737 | return splitter !== undefined
|
3738 | ? splitter.call(separator, O, limit)
|
3739 | : internalSplit.call(String(O), separator, limit);
|
3740 | },
|
3741 |
|
3742 |
|
3743 |
|
3744 |
|
3745 |
|
3746 | function (regexp, limit) {
|
3747 | var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
|
3748 | if (res.done) return res.value;
|
3749 |
|
3750 | var rx = anObject(regexp);
|
3751 | var S = String(this);
|
3752 | var C = speciesConstructor(rx, RegExp);
|
3753 |
|
3754 | var unicodeMatching = rx.unicode;
|
3755 | var flags = (rx.ignoreCase ? 'i' : '') +
|
3756 | (rx.multiline ? 'm' : '') +
|
3757 | (rx.unicode ? 'u' : '') +
|
3758 | (SUPPORTS_Y ? 'y' : 'g');
|
3759 |
|
3760 |
|
3761 |
|
3762 | var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
|
3763 | var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
|
3764 | if (lim === 0) return [];
|
3765 | if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : [];
|
3766 | var p = 0;
|
3767 | var q = 0;
|
3768 | var A = [];
|
3769 | while (q < S.length) {
|
3770 | splitter.lastIndex = SUPPORTS_Y ? q : 0;
|
3771 | var z = regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q));
|
3772 | var e;
|
3773 | if (
|
3774 | z === null ||
|
3775 | (e = min$4(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
|
3776 | ) {
|
3777 | q = advanceStringIndex(S, q, unicodeMatching);
|
3778 | } else {
|
3779 | A.push(S.slice(p, q));
|
3780 | if (A.length === lim) return A;
|
3781 | for (var i = 1; i <= z.length - 1; i++) {
|
3782 | A.push(z[i]);
|
3783 | if (A.length === lim) return A;
|
3784 | }
|
3785 | q = p = e;
|
3786 | }
|
3787 | }
|
3788 | A.push(S.slice(p));
|
3789 | return A;
|
3790 | }
|
3791 | ];
|
3792 | },
|
3793 | !SUPPORTS_Y
|
3794 | );
|
3795 |
|
3796 | function getFileName(pic) {
|
3797 | return toString$1(pic).split('/').pop();
|
3798 | }
|
3799 | function parseValue(value) {
|
3800 | return Array.isArray(value) ? value : !value ? [] : [value];
|
3801 | }
|
3802 |
|
3803 | var handler$8 = function (_Handler) {
|
3804 | _inherits(handler, _Handler);
|
3805 |
|
3806 | function handler() {
|
3807 | _classCallCheck(this, handler);
|
3808 |
|
3809 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
3810 | }
|
3811 |
|
3812 | _createClass(handler, [{
|
3813 | key: "init",
|
3814 | value: function init() {
|
3815 | var props = this.rule.props;
|
3816 | $set(props, 'defaultFileList', []);
|
3817 | if (isUndef(props.showUploadList)) $set(props, 'showUploadList', false);
|
3818 | if (isUndef(props.uploadType)) $set(props, 'uploadType', 'file');
|
3819 | if (props.maxLength === undefined) $set(props, 'maxLength', 0);
|
3820 | if (props.action === undefined) $set(props, 'action', '');
|
3821 | if (props.uploadType === 'file' && isUndef(props.handleIcon)) $set(props, 'handleIcon', false);
|
3822 | if (!props.modalTitle) $set(props, 'modalTitle', '预览');
|
3823 | $set(this.rule, 'value', parseValue(this.rule.value));
|
3824 | this.parseValue = [];
|
3825 | }
|
3826 | }, {
|
3827 | key: "toFormValue",
|
3828 | value: function toFormValue(value) {
|
3829 | var _this = this;
|
3830 |
|
3831 | var files = parseValue(value);
|
3832 | this.parseValue.splice(0, this.parseValue.length);
|
3833 | files.forEach(function (file) {
|
3834 | return _this.push(file);
|
3835 | });
|
3836 | $set(this.rule.props, 'defaultFileList', this.parseValue);
|
3837 | return this.parseValue;
|
3838 | }
|
3839 | }, {
|
3840 | key: "mounted",
|
3841 | value: function mounted() {
|
3842 | _get(_getPrototypeOf(handler.prototype), "mounted", this).call(this);
|
3843 |
|
3844 | $set(this.rule.props, 'defaultFileList', this.parseValue);
|
3845 | this.changeParseValue(this.el.fileList || []);
|
3846 | }
|
3847 | }, {
|
3848 | key: "push",
|
3849 | value: function push(file) {
|
3850 | this.parseValue.push({
|
3851 | url: file,
|
3852 | name: getFileName(file)
|
3853 | });
|
3854 | }
|
3855 | }, {
|
3856 | key: "toValue",
|
3857 | value: function toValue(parseValue) {
|
3858 | if (isUndef(parseValue)) return [];
|
3859 | var files = parseValue.map(function (file) {
|
3860 | return file.url;
|
3861 | }).filter(function (file) {
|
3862 | return file !== undefined;
|
3863 | });
|
3864 | return this.rule.props.maxLength === 1 ? files[0] || '' : files;
|
3865 | }
|
3866 | }, {
|
3867 | key: "changeParseValue",
|
3868 | value: function changeParseValue(parseValue) {
|
3869 | this.parseValue = parseValue;
|
3870 |
|
3871 | this.vm._changeFormData(this.field, parseValue);
|
3872 | }
|
3873 | }, {
|
3874 | key: "watchValue",
|
3875 | value: function watchValue(n) {
|
3876 | var b = true;
|
3877 | this.rule.props.defaultFileList.forEach(function (pic) {
|
3878 | b = b && (pic.percentage === undefined || pic.status === 'finished');
|
3879 | });
|
3880 | if (b) _get(_getPrototypeOf(handler.prototype), "watchValue", this).call(this, n);
|
3881 | }
|
3882 | }]);
|
3883 |
|
3884 | return handler;
|
3885 | }(Handler);
|
3886 |
|
3887 | var iview2 = {
|
3888 | _v: 2,
|
3889 | resetBtnType: 'ghost',
|
3890 | resetBtnIcon: 'refresh',
|
3891 | submitBtnIcon: 'ios-upload',
|
3892 | fileIcon: 'document-text',
|
3893 | fileUpIcon: 'folder',
|
3894 | imgUpIcon: 'image'
|
3895 | };
|
3896 | var iview3 = {
|
3897 | _v: 3,
|
3898 | resetBtnType: 'default',
|
3899 | resetBtnIcon: 'md-refresh',
|
3900 | submitBtnIcon: 'ios-share',
|
3901 | fileIcon: 'md-document',
|
3902 | fileUpIcon: 'ios-folder-open',
|
3903 | imgUpIcon: 'md-images'
|
3904 | };
|
3905 | var iviewConfig = function () {
|
3906 | if (typeof iview === 'undefined') return iview2;
|
3907 | return iview.version && iview.version.split('.')[0] == 3 ? iview3 : iview2;
|
3908 | }();
|
3909 | function getConfig() {
|
3910 | return {
|
3911 | form: {
|
3912 | inline: false,
|
3913 | labelPosition: 'right',
|
3914 | labelWidth: 125,
|
3915 | showMessage: true,
|
3916 | autocomplete: 'off',
|
3917 | size: undefined
|
3918 | },
|
3919 | row: {
|
3920 | gutter: 0,
|
3921 | type: undefined,
|
3922 | align: undefined,
|
3923 | justify: undefined,
|
3924 | className: undefined
|
3925 | },
|
3926 | upload: {
|
3927 | beforeUpload: function beforeUpload() {},
|
3928 | onProgress: function onProgress(event, file, fileList) {},
|
3929 | onSuccess: function onSuccess(response, file, fileList) {},
|
3930 | onError: function onError(error, file, fileList) {},
|
3931 | onPreview: function onPreview(file) {},
|
3932 | onRemove: function onRemove(file, fileList) {},
|
3933 | onFormatError: function onFormatError(file, fileList) {},
|
3934 | onExceededSize: function onExceededSize(file, fileList) {},
|
3935 | handleIcon: 'ios-eye-outline',
|
3936 | allowRemove: true
|
3937 | },
|
3938 | submitBtn: {
|
3939 | type: "primary",
|
3940 | size: "large",
|
3941 | shape: undefined,
|
3942 | long: true,
|
3943 | htmlType: "button",
|
3944 | disabled: false,
|
3945 | icon: iviewConfig.submitBtnIcon,
|
3946 | innerText: "提交",
|
3947 | loading: false,
|
3948 | show: true,
|
3949 | col: undefined,
|
3950 | click: undefined
|
3951 | },
|
3952 | resetBtn: {
|
3953 | type: iviewConfig.resetBtnType,
|
3954 | size: "large",
|
3955 | shape: undefined,
|
3956 | long: true,
|
3957 | htmlType: "button",
|
3958 | disabled: false,
|
3959 | icon: iviewConfig.resetBtnIcon,
|
3960 | innerText: "重置",
|
3961 | loading: false,
|
3962 | show: false,
|
3963 | col: undefined,
|
3964 | click: undefined
|
3965 | },
|
3966 | iframeHelper: false
|
3967 | };
|
3968 | }
|
3969 |
|
3970 | var vNode = new VNode({});
|
3971 |
|
3972 | var Modal = function Modal(options, cb) {
|
3973 | return {
|
3974 | name: 'fc-modal',
|
3975 | data: function data() {
|
3976 | return _objectSpread({
|
3977 | value: true
|
3978 | }, options);
|
3979 | },
|
3980 | render: function render() {
|
3981 | vNode.setVm(this);
|
3982 | return vNode.modal({
|
3983 | props: this.$data,
|
3984 | on: {
|
3985 | 'on-visible-change': this.remove
|
3986 | }
|
3987 | }, [cb(vNode, this)]);
|
3988 | },
|
3989 | methods: {
|
3990 | onClose: function onClose() {
|
3991 | this.value = false;
|
3992 | },
|
3993 | remove: function remove() {
|
3994 | this.$el.parentNode.removeChild(this.$el);
|
3995 | }
|
3996 | }
|
3997 | };
|
3998 | };
|
3999 |
|
4000 | function mount(options, content) {
|
4001 | var $modal = _vue.extend(Modal(options, content)),
|
4002 | $vm = new $modal().$mount();
|
4003 |
|
4004 | window.document.body.appendChild($vm.$el);
|
4005 | }
|
4006 | function defaultOnHandle(src, title) {
|
4007 | mount({
|
4008 | title: title,
|
4009 | footerHide: true
|
4010 | }, function (vNode) {
|
4011 | return vNode.make('img', {
|
4012 | style: {
|
4013 | width: '100%'
|
4014 | },
|
4015 | attrs: {
|
4016 | src: src
|
4017 | }
|
4018 | });
|
4019 | });
|
4020 | }
|
4021 |
|
4022 | var render$a = function (_Render) {
|
4023 | _inherits(render, _Render);
|
4024 |
|
4025 | function render() {
|
4026 | _classCallCheck(this, render);
|
4027 |
|
4028 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
4029 | }
|
4030 |
|
4031 | _createClass(render, [{
|
4032 | key: "init",
|
4033 | value: function init() {
|
4034 | var _this = this;
|
4035 |
|
4036 | var handler = this.handler;
|
4037 | this.uploadOptions = extend(_objectSpread({}, this.options.upload), this.handler.rule.props);
|
4038 | this.issetIcon = this.uploadOptions.allowRemove || this.uploadOptions.handleIcon;
|
4039 | this.propsData = this.vData.props(this.uploadOptions).props('onSuccess', function () {
|
4040 | return _this.onSuccess.apply(_this, arguments);
|
4041 | }).props('onRemove', function () {
|
4042 | return _this.onRemove.apply(_this, arguments);
|
4043 | }).props('beforeUpload', function () {
|
4044 | return _this.beforeUpload.apply(_this, arguments);
|
4045 | }).ref(handler.refName).key("fip".concat(handler.unique)).get();
|
4046 | }
|
4047 | }, {
|
4048 | key: "onRemove",
|
4049 | value: function onRemove() {
|
4050 | var _this$uploadOptions;
|
4051 |
|
4052 | this.handler.changeParseValue(this.handler.el.fileList);
|
4053 | this.uploadOptions.onRemove && (_this$uploadOptions = this.uploadOptions).onRemove.apply(_this$uploadOptions, arguments);
|
4054 | this.sync();
|
4055 | }
|
4056 | }, {
|
4057 | key: "beforeUpload",
|
4058 | value: function beforeUpload() {
|
4059 | var _this$uploadOptions2;
|
4060 |
|
4061 | this.handler.changeParseValue(this.handler.el.fileList);
|
4062 | this.uploadOptions.beforeUpload && (_this$uploadOptions2 = this.uploadOptions).beforeUpload.apply(_this$uploadOptions2, arguments);
|
4063 | }
|
4064 | }, {
|
4065 | key: "onSuccess",
|
4066 | value: function onSuccess(response, file, fileList) {
|
4067 | var url = this.uploadOptions.onSuccess.call(null, response, file, fileList);
|
4068 |
|
4069 | if (!isUndef(url)) {
|
4070 | file.url = url;
|
4071 | file.showProgress = false;
|
4072 | } else {
|
4073 | var index = fileList.indexOf(file);
|
4074 | if (index !== -1) fileList.splice(index, 1);
|
4075 | }
|
4076 |
|
4077 | this.handler.changeParseValue(fileList);
|
4078 | }
|
4079 | }, {
|
4080 | key: "onHandle",
|
4081 | value: function onHandle(src) {
|
4082 | var fn = this.uploadOptions.onHandle;
|
4083 | if (fn) return fn(src);else defaultOnHandle(src, this.uploadOptions.modalTitle);
|
4084 | }
|
4085 | }, {
|
4086 | key: "parse",
|
4087 | value: function parse() {
|
4088 | var _this2 = this;
|
4089 |
|
4090 | var _this$handler = this.handler,
|
4091 | unique = _this$handler.unique,
|
4092 | field = _this$handler.field;
|
4093 | this.init();
|
4094 | if (this.uploadOptions.handleIcon === true) this.uploadOptions.handleIcon = 'ios-eye-outline';
|
4095 |
|
4096 | var value = this.vm._formData(field),
|
4097 | render = this.uploadOptions.showUploadList ? [] : _toConsumableArray(value.map(function (file, index) {
|
4098 | if (file.showProgress) {
|
4099 | return _this2.makeProgress(file, "uppg".concat(index).concat(unique));
|
4100 | } else if (file.status === undefined || file.status === 'finished') {
|
4101 | return _this2.makeUploadView(file.url, "upview".concat(index).concat(unique), index);
|
4102 | }
|
4103 | }));
|
4104 |
|
4105 | var isShow = !this.uploadOptions.maxLength || this.uploadOptions.maxLength > value.length;
|
4106 | render.push(this.makeUploadBtn(unique, isShow));
|
4107 | return [this.vNode.make('div', {
|
4108 | key: "div4".concat(unique),
|
4109 | class: {
|
4110 | 'fc-upload': true,
|
4111 | 'fc-hide-btn': !isShow
|
4112 | }
|
4113 | }, render)];
|
4114 | }
|
4115 | }, {
|
4116 | key: "cacheParse",
|
4117 | value: function cacheParse(form) {
|
4118 | this.cache = null;
|
4119 | return _get(_getPrototypeOf(render.prototype), "cacheParse", this).call(this, form);
|
4120 | }
|
4121 | }, {
|
4122 | key: "makeUploadView",
|
4123 | value: function makeUploadView(src, key, index) {
|
4124 | var _this3 = this;
|
4125 |
|
4126 | return this.vNode.make('div', {
|
4127 | key: "div1".concat(key),
|
4128 | class: {
|
4129 | 'fc-files': true
|
4130 | }
|
4131 | }, function () {
|
4132 | var container = [];
|
4133 |
|
4134 | if (_this3.handler.rule.props.uploadType === 'image') {
|
4135 | container.push(_this3.vNode.make('img', {
|
4136 | key: "img".concat(key),
|
4137 | attrs: {
|
4138 | src: src
|
4139 | }
|
4140 | }));
|
4141 | } else {
|
4142 | container.push(_this3.vNode.icon({
|
4143 | key: "file".concat(key),
|
4144 | props: {
|
4145 | type: iviewConfig.fileIcon,
|
4146 | size: 40
|
4147 | }
|
4148 | }));
|
4149 | }
|
4150 |
|
4151 | if (_this3.issetIcon) container.push(_this3.makeIcons(src, key, index));
|
4152 | return container;
|
4153 | });
|
4154 | }
|
4155 | }, {
|
4156 | key: "makeIcons",
|
4157 | value: function makeIcons(src, key, index) {
|
4158 | var _this4 = this;
|
4159 |
|
4160 | return this.vNode.make('div', {
|
4161 | key: "div2".concat(key),
|
4162 | class: {
|
4163 | 'fc-upload-cover': true
|
4164 | }
|
4165 | }, function () {
|
4166 | var icon = [];
|
4167 | if (!!_this4.uploadOptions.handleIcon) icon.push(_this4.makeHandleIcon(src, key, index));
|
4168 | if (_this4.uploadOptions.allowRemove === true) icon.push(_this4.makeRemoveIcon(src, key, index));
|
4169 | return icon;
|
4170 | });
|
4171 | }
|
4172 | }, {
|
4173 | key: "makeProgress",
|
4174 | value: function makeProgress(file, unique) {
|
4175 | return this.vNode.make('div', {
|
4176 | key: "div3".concat(unique),
|
4177 | class: {
|
4178 | 'fc-files': true
|
4179 | }
|
4180 | }, [this.vNode.progress({
|
4181 | key: "upp".concat(unique),
|
4182 | props: {
|
4183 | percent: file.percentage,
|
4184 | hideInfo: true
|
4185 | },
|
4186 | style: {
|
4187 | width: '90%'
|
4188 | }
|
4189 | })]);
|
4190 | }
|
4191 | }, {
|
4192 | key: "makeUploadBtn",
|
4193 | value: function makeUploadBtn(unique, isShow) {
|
4194 | return this.vNode.upload(this.propsData, isShow === true ? [this.vNode.make('div', {
|
4195 | key: "div5".concat(unique),
|
4196 | class: {
|
4197 | 'fc-upload-btn': true
|
4198 | }
|
4199 | }, [this.vNode.icon({
|
4200 | key: "upi".concat(unique),
|
4201 | props: {
|
4202 | type: this.handler.rule.props.uploadType === 'file' ? 'ios-cloud-upload-outline' : iviewConfig.imgUpIcon,
|
4203 | size: 20
|
4204 | }
|
4205 | })])] : []);
|
4206 | }
|
4207 | }, {
|
4208 | key: "makeRemoveIcon",
|
4209 | value: function makeRemoveIcon(src, key, index) {
|
4210 | var _this5 = this;
|
4211 |
|
4212 | return this.vNode.icon({
|
4213 | key: "upri".concat(key).concat(index),
|
4214 | props: {
|
4215 | type: 'ios-trash-outline'
|
4216 | },
|
4217 | nativeOn: {
|
4218 | 'click': function click() {
|
4219 | if (_this5.uploadOptions.disabled === true) return;
|
4220 | var fileList = _this5.handler.el.fileList,
|
4221 | file = fileList[index];
|
4222 | fileList.splice(index, 1);
|
4223 |
|
4224 | _this5.onRemove(file, fileList);
|
4225 | }
|
4226 | }
|
4227 | });
|
4228 | }
|
4229 | }, {
|
4230 | key: "makeHandleIcon",
|
4231 | value: function makeHandleIcon(src, key, index) {
|
4232 | var _this6 = this;
|
4233 |
|
4234 | return this.vNode.icon({
|
4235 | key: "uphi".concat(key).concat(index),
|
4236 | props: {
|
4237 | type: toString$1(this.uploadOptions.handleIcon)
|
4238 | },
|
4239 | nativeOn: {
|
4240 | 'click': function click() {
|
4241 | if (_this6.uploadOptions.disabled === true) return;
|
4242 |
|
4243 | _this6.onHandle(src);
|
4244 | }
|
4245 | }
|
4246 | });
|
4247 | }
|
4248 | }]);
|
4249 |
|
4250 | return render;
|
4251 | }(Render);
|
4252 |
|
4253 | var name$a = "upload";
|
4254 | var types = {
|
4255 | image: ['image', 0],
|
4256 | file: ['file', 0],
|
4257 | uploadFileOne: ['file', 1],
|
4258 | uploadImageOne: ['image', 1]
|
4259 | };
|
4260 | var maker$8 = Object.keys(types).reduce(function (initial, key) {
|
4261 | initial[key] = creatorTypeFactory(name$a, function (m) {
|
4262 | return m.props({
|
4263 | uploadType: types[key][0],
|
4264 | maxLength: types[key][1]
|
4265 | });
|
4266 | });
|
4267 | return initial;
|
4268 | }, {});
|
4269 | maker$8.uploadImage = maker$8.image;
|
4270 | maker$8.uploadFile = maker$8.file;
|
4271 | var upload = {
|
4272 | handler: handler$8,
|
4273 | render: render$a,
|
4274 | name: name$a,
|
4275 | maker: maker$8
|
4276 | };
|
4277 |
|
4278 | var handler$9 = function (_Handler) {
|
4279 | _inherits(handler, _Handler);
|
4280 |
|
4281 | function handler() {
|
4282 | _classCallCheck(this, handler);
|
4283 |
|
4284 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
4285 | }
|
4286 |
|
4287 | _createClass(handler, [{
|
4288 | key: "init",
|
4289 | value: function init() {
|
4290 | var rule = this.rule;
|
4291 | if (!rule.props.data) $set(rule.props, 'data', []);
|
4292 | if (!rule.props.options) $set(rule.props, 'options', []);
|
4293 | if (!Array.isArray(this.rule.value)) $set(rule, 'value', []);
|
4294 | }
|
4295 | }, {
|
4296 | key: "toFormValue",
|
4297 | value: function toFormValue(value) {
|
4298 | return Array.isArray(value) ? value : [];
|
4299 | }
|
4300 | }, {
|
4301 | key: "mounted",
|
4302 | value: function mounted() {
|
4303 | _get(_getPrototypeOf(handler.prototype), "mounted", this).call(this);
|
4304 |
|
4305 | this.vm._changeFormData(this.field, this.toFormValue(this.el.value));
|
4306 | }
|
4307 | }]);
|
4308 |
|
4309 | return handler;
|
4310 | }(Handler);
|
4311 |
|
4312 | var name$b = 'cascader';
|
4313 | var render$b = defaultRenderFactory(name$b);
|
4314 | var cascader = {
|
4315 | handler: handler$9,
|
4316 | render: render$b,
|
4317 | name: name$b
|
4318 | };
|
4319 |
|
4320 | var handler$a = function (_Handler) {
|
4321 | _inherits(handler, _Handler);
|
4322 |
|
4323 | function handler() {
|
4324 | _classCallCheck(this, handler);
|
4325 |
|
4326 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
4327 | }
|
4328 |
|
4329 | _createClass(handler, [{
|
4330 | key: "toFormValue",
|
4331 | value: function toFormValue(value) {
|
4332 | var parseValue = parseFloat(value);
|
4333 | if (Number.isNaN(parseValue)) parseValue = 0;
|
4334 | return parseValue;
|
4335 | }
|
4336 | }]);
|
4337 |
|
4338 | return handler;
|
4339 | }(Handler);
|
4340 |
|
4341 | var name$c = "rate";
|
4342 | var render$c = defaultRenderFactory(name$c);
|
4343 | var rate = {
|
4344 | handler: handler$a,
|
4345 | render: render$c,
|
4346 | name: name$c
|
4347 | };
|
4348 |
|
4349 | var handler$b = function (_Handler) {
|
4350 | _inherits(handler, _Handler);
|
4351 |
|
4352 | function handler() {
|
4353 | _classCallCheck(this, handler);
|
4354 |
|
4355 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
4356 | }
|
4357 |
|
4358 | _createClass(handler, [{
|
4359 | key: "init",
|
4360 | value: function init() {
|
4361 | var rule = this.rule;
|
4362 | $set(rule.props, 'min', rule.props.min === undefined ? 0 : parseFloat(rule.props.min) || 0);
|
4363 | }
|
4364 | }, {
|
4365 | key: "toFormValue",
|
4366 | value: function toFormValue(value) {
|
4367 | var rule = this.rule,
|
4368 | isArr = Array.isArray(value),
|
4369 | props = rule.props,
|
4370 | min = props.min,
|
4371 | parseValue;
|
4372 |
|
4373 | if (props.range === true) {
|
4374 | parseValue = isArr ? value : [min, parseFloat(value) || min];
|
4375 | } else {
|
4376 | parseValue = isArr ? parseFloat(value[0]) || min : parseFloat(value);
|
4377 | }
|
4378 |
|
4379 | return parseValue;
|
4380 | }
|
4381 | }]);
|
4382 |
|
4383 | return handler;
|
4384 | }(Handler);
|
4385 |
|
4386 | var name$d = "slider";
|
4387 | var maker$9 = {
|
4388 | sliderRange: creatorTypeFactory(name$d, true, 'range')
|
4389 | };
|
4390 | var render$d = defaultRenderFactory(name$d);
|
4391 | var slider = {
|
4392 | handler: handler$b,
|
4393 | render: render$d,
|
4394 | name: name$d,
|
4395 | maker: maker$9
|
4396 | };
|
4397 |
|
4398 | function parseRule$1(rule) {
|
4399 | var props = rule.props;
|
4400 | if (!props.type) $set(props, 'type', 'input');
|
4401 | if (!props.icon) $set(props, 'icon', iviewConfig.fileUpIcon);
|
4402 | if (!props.width) $set(props, 'width', '500px');
|
4403 | if (!props.height) $set(props, 'height', '370px');
|
4404 | if (isUndef(props.spin)) $set(props, 'spin', true);
|
4405 | if (!props.title) $set(props, 'title', '请选择' + rule.title);
|
4406 | if (!props.maxLength) $set(props, 'maxLength', 0);
|
4407 | if (!props.okBtnText) $set(props, 'okBtnText', '确定');
|
4408 | if (!props.closeBtnText) $set(props, 'closeBtnText', '关闭');
|
4409 | if (!props.modalTitle) $set(props, 'modalTitle', '预览');
|
4410 | if (!props.loadingText) $set(props, 'loadingText', '加载中...');
|
4411 | var handleIcon = props.handleIcon;
|
4412 | if (props.type === 'file' && props.handleIcon === undefined) handleIcon = false;else handleIcon = props.handleIcon === true || props.handleIcon === undefined ? 'ios-eye-outline' : props.handleIcon;
|
4413 | $set(props, 'handleIcon', handleIcon);
|
4414 | if (props.allowRemove === undefined) $set(props, 'allowRemove', true);
|
4415 | }
|
4416 |
|
4417 | var handler$c = function (_Handler) {
|
4418 | _inherits(handler, _Handler);
|
4419 |
|
4420 | function handler() {
|
4421 | _classCallCheck(this, handler);
|
4422 |
|
4423 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
4424 | }
|
4425 |
|
4426 | _createClass(handler, [{
|
4427 | key: "init",
|
4428 | value: function init() {
|
4429 | parseRule$1(this.rule);
|
4430 | }
|
4431 | }, {
|
4432 | key: "toFormValue",
|
4433 | value: function toFormValue(value) {
|
4434 | var parseValue,
|
4435 | oldValue = value,
|
4436 | isArr = Array.isArray(oldValue);
|
4437 | if (oldValue === '') parseValue = [];else if (!isArr) parseValue = [oldValue];else parseValue = oldValue;
|
4438 | this.parseValue = parseValue;
|
4439 | return parseValue;
|
4440 | }
|
4441 | }, {
|
4442 | key: "toValue",
|
4443 | value: function toValue(parseValue) {
|
4444 | return this.rule.props.maxLength != 1 ? parseValue : parseValue[0] === undefined ? '' : parseValue[0];
|
4445 | }
|
4446 | }, {
|
4447 | key: "watchValue",
|
4448 | value: function watchValue(n) {
|
4449 | _get(_getPrototypeOf(handler.prototype), "watchValue", this).call(this, n);
|
4450 |
|
4451 | this.render.onChange(n);
|
4452 | this.render.sync();
|
4453 | }
|
4454 | }, {
|
4455 | key: "watchFormValue",
|
4456 | value: function watchFormValue(n) {
|
4457 | _get(_getPrototypeOf(handler.prototype), "watchFormValue", this).call(this, n);
|
4458 |
|
4459 | this.parseValue = n;
|
4460 | this.render.sync();
|
4461 | }
|
4462 | }]);
|
4463 |
|
4464 | return handler;
|
4465 | }(Handler);
|
4466 |
|
4467 | var eventList = {
|
4468 | onOpen: 'on-open',
|
4469 | onChange: 'on-change',
|
4470 | onCancel: 'on-cancel',
|
4471 | onOk: 'on-ok'
|
4472 | };
|
4473 |
|
4474 | var render$e = function (_Render) {
|
4475 | _inherits(render, _Render);
|
4476 |
|
4477 | function render() {
|
4478 | _classCallCheck(this, render);
|
4479 |
|
4480 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
4481 | }
|
4482 |
|
4483 | _createClass(render, [{
|
4484 | key: "init",
|
4485 | value: function init() {
|
4486 | this._props = this.handler.rule.props;
|
4487 | this.issetIcon = this._props.handleIcon !== false || this._props.allowRemove === true;
|
4488 | }
|
4489 | }, {
|
4490 | key: "parse",
|
4491 | value: function parse() {
|
4492 | this.init();
|
4493 | var type = this._props.type,
|
4494 | vNode;
|
4495 | if (type === 'image') vNode = this.makeGroup(this.makeImage());else if (type === 'file') vNode = this.makeGroup(this.makeFile());else vNode = this.makeInput();
|
4496 | return vNode;
|
4497 | }
|
4498 | }, {
|
4499 | key: "makeInput",
|
4500 | value: function makeInput(hidden) {
|
4501 | var _this = this;
|
4502 |
|
4503 | var unique = this.handler.unique,
|
4504 | props = this.inputProps().props({
|
4505 | type: "text",
|
4506 | value: this.handler.parseValue.toString(),
|
4507 | icon: this._props.icon,
|
4508 | readonly: true,
|
4509 | clearable: true
|
4510 | }).on('on-click', function () {
|
4511 | _this.showModel();
|
4512 | }).on('input', function () {}).key('ifit' + unique).class('__fc_h', hidden === true).get();
|
4513 | return [this.vNode.input(props)];
|
4514 | }
|
4515 | }, {
|
4516 | key: "makeGroup",
|
4517 | value: function makeGroup(render) {
|
4518 | var unique = this.handler.unique,
|
4519 | field = this.handler.field;
|
4520 | return [this.vNode.make('div', {
|
4521 | key: "ifgp1".concat(unique),
|
4522 | class: {
|
4523 | 'fc-upload fc-frame': true
|
4524 | },
|
4525 | ref: this.handler.refName,
|
4526 | props: {
|
4527 | value: this.vm._formData(field)
|
4528 | }
|
4529 | }, render), this.makeInput(true)];
|
4530 | }
|
4531 | }, {
|
4532 | key: "makeImage",
|
4533 | value: function makeImage() {
|
4534 | var _this2 = this;
|
4535 |
|
4536 | var unique = this.handler.unique;
|
4537 | var vNode = this.handler.parseValue.map(function (src, index) {
|
4538 | return _this2.vNode.make('div', {
|
4539 | key: "ifid1".concat(unique).concat(index),
|
4540 | class: {
|
4541 | 'fc-files': true
|
4542 | }
|
4543 | }, [_this2.vNode.make('img', {
|
4544 | key: "ifim".concat(unique).concat(index),
|
4545 | attrs: {
|
4546 | src: src
|
4547 | }
|
4548 | }), _this2.makeIcons(src, unique, index)]);
|
4549 | });
|
4550 | vNode.push(this.makeBtn());
|
4551 | return vNode;
|
4552 | }
|
4553 | }, {
|
4554 | key: "makeFile",
|
4555 | value: function makeFile() {
|
4556 | var _this3 = this;
|
4557 |
|
4558 | var unique = this.handler.unique;
|
4559 | var vNode = this.handler.parseValue.map(function (src, index) {
|
4560 | return _this3.vNode.make('div', {
|
4561 | key: "iffd2".concat(unique).concat(index),
|
4562 | class: {
|
4563 | 'fc-files': true
|
4564 | }
|
4565 | }, [_this3.vNode.icon({
|
4566 | key: "iff".concat(unique).concat(index),
|
4567 | props: {
|
4568 | type: iviewConfig.fileIcon,
|
4569 | size: 40
|
4570 | }
|
4571 | }), _this3.makeIcons(src, unique, index)]);
|
4572 | });
|
4573 | vNode.push(this.makeBtn());
|
4574 | return vNode;
|
4575 | }
|
4576 | }, {
|
4577 | key: "makeBtn",
|
4578 | value: function makeBtn() {
|
4579 | var _this4 = this;
|
4580 |
|
4581 | var props = this.handler.rule.props;
|
4582 | if (props.maxLength > 0 && this.handler.parseValue.length >= props.maxLength) return;
|
4583 | var unique = this.handler.unique;
|
4584 | return this.vNode.make('div', {
|
4585 | key: "ifbd3".concat(unique),
|
4586 | class: {
|
4587 | 'fc-upload-btn': true
|
4588 | },
|
4589 | on: {
|
4590 | click: function click() {
|
4591 | if (props.disabled === true) return;
|
4592 |
|
4593 | _this4.showModel();
|
4594 | }
|
4595 | }
|
4596 | }, [this.vNode.icon({
|
4597 | key: "ifbi3".concat(unique),
|
4598 | props: {
|
4599 | type: this._props.icon,
|
4600 | size: 20
|
4601 | }
|
4602 | })]);
|
4603 | }
|
4604 | }, {
|
4605 | key: "makeSpin",
|
4606 | value: function makeSpin(vNode) {
|
4607 | if (true !== this._props.spin) return;
|
4608 | var unique = this.handler.unique;
|
4609 | return vNode.make('Spin', {
|
4610 | props: {
|
4611 | fix: true
|
4612 | },
|
4613 | key: 'ifsp' + unique,
|
4614 | ref: 'spin',
|
4615 | class: {
|
4616 | 'fc-spin': true
|
4617 | }
|
4618 | }, [vNode.icon({
|
4619 | props: {
|
4620 | type: 'load-c',
|
4621 | size: 18
|
4622 | },
|
4623 | class: {
|
4624 | 'fc-spin-icon-load': true
|
4625 | },
|
4626 | key: 'ifspi' + unique
|
4627 | }), vNode.make('div', {
|
4628 | domProps: {
|
4629 | innerHTML: toString$1(this._props.loadingText)
|
4630 | },
|
4631 | key: 'ifspd' + unique
|
4632 | })]);
|
4633 | }
|
4634 | }, {
|
4635 | key: "makeIcons",
|
4636 | value: function makeIcons(src, key, index) {
|
4637 | var _this5 = this;
|
4638 |
|
4639 | if (this.issetIcon === true) return this.vNode.make('div', {
|
4640 | key: "ifis".concat(key).concat(index),
|
4641 | class: {
|
4642 | 'fc-upload-cover': true
|
4643 | }
|
4644 | }, function () {
|
4645 | var icon = [];
|
4646 | if (_this5._props.handleIcon !== false) icon.push(_this5.makeHandleIcon(src, key, index));
|
4647 | if (_this5._props.allowRemove === true) icon.push(_this5.makeRemoveIcon(src, key, index));
|
4648 | return icon;
|
4649 | });
|
4650 | }
|
4651 | }, {
|
4652 | key: "makeRemoveIcon",
|
4653 | value: function makeRemoveIcon(src, key, index) {
|
4654 | var _this6 = this;
|
4655 |
|
4656 | return this.vNode.icon({
|
4657 | key: "ifri".concat(key).concat(index),
|
4658 | props: {
|
4659 | type: 'ios-trash-outline'
|
4660 | },
|
4661 | nativeOn: {
|
4662 | 'click': function click() {
|
4663 | if (_this6._props.disabled === true) return;
|
4664 |
|
4665 | if (_this6.onRemove(src) !== false) {
|
4666 | _this6.handler.parseValue.splice(index, 1);
|
4667 |
|
4668 | _this6.sync();
|
4669 | }
|
4670 | }
|
4671 | }
|
4672 | });
|
4673 | }
|
4674 | }, {
|
4675 | key: "makeHandleIcon",
|
4676 | value: function makeHandleIcon(src, key, index) {
|
4677 | var _this7 = this;
|
4678 |
|
4679 | var props = this._props;
|
4680 | return this.vNode.icon({
|
4681 | key: "ifhi".concat(key).concat(index),
|
4682 | props: {
|
4683 | type: toString$1(props.handleIcon)
|
4684 | },
|
4685 | nativeOn: {
|
4686 | 'click': function click() {
|
4687 | if (props.disabled === true) return;
|
4688 |
|
4689 | _this7.onHandle(src);
|
4690 | }
|
4691 | }
|
4692 | });
|
4693 | }
|
4694 | }, {
|
4695 | key: "onRemove",
|
4696 | value: function onRemove(src) {
|
4697 | if (this._props.disabled === true) return;
|
4698 | var fn = this.handler.rule.event['on-remove'];
|
4699 | if (fn) return fn(src, this.handler.getValue());
|
4700 | }
|
4701 | }, {
|
4702 | key: "onHandle",
|
4703 | value: function onHandle(src) {
|
4704 | if (this._props.disabled === true) return;
|
4705 | var fn = this.handler.rule.event['on-handle'];
|
4706 | if (fn) return fn(src);else defaultOnHandle(src, this._props.modalTitle);
|
4707 | }
|
4708 | }, {
|
4709 | key: "valid",
|
4710 | value: function valid(field) {
|
4711 | if (field !== this.handler.field) throw new Error('无效的表单字段' + errMsg());
|
4712 | }
|
4713 | }, {
|
4714 | key: "showModel",
|
4715 | value: function showModel() {
|
4716 | var _this8 = this;
|
4717 |
|
4718 | var isShow = false !== this.onOpen(),
|
4719 | _this$_props = this._props,
|
4720 | width = _this$_props.width,
|
4721 | height = _this$_props.height,
|
4722 | src = _this$_props.src,
|
4723 | title = _this$_props.title,
|
4724 | okBtnText = _this$_props.okBtnText,
|
4725 | closeBtnText = _this$_props.closeBtnText;
|
4726 | if (!isShow) return;
|
4727 | mount({
|
4728 | width: width,
|
4729 | title: title
|
4730 | }, function (vNode, _vm) {
|
4731 | _this8.handler.$modal = _vm;
|
4732 | return [_this8.makeSpin(vNode), vNode.make('iframe', {
|
4733 | attrs: {
|
4734 | src: src
|
4735 | },
|
4736 | style: {
|
4737 | 'height': height,
|
4738 | 'border': "0 none",
|
4739 | 'width': '100%'
|
4740 | },
|
4741 | on: {
|
4742 | 'load': function load(e) {
|
4743 | var spin = _vm.$refs.spin;
|
4744 | if (spin) spin.$el.parentNode.removeChild(spin.$el);
|
4745 |
|
4746 | try {
|
4747 | if (_this8.options.iframeHelper === true) {
|
4748 | var iframe = e.path[0].contentWindow;
|
4749 |
|
4750 | iframe["".concat(_this8.handler.field, "_change")] = function (val) {
|
4751 | _this8.handler.setValue(val);
|
4752 | };
|
4753 |
|
4754 | iframe["form_create_helper"] = {
|
4755 | close: function close(field) {
|
4756 | _this8.valid(field);
|
4757 |
|
4758 | _vm.onClose();
|
4759 | },
|
4760 | set: function set(field, value) {
|
4761 | _this8.valid(field);
|
4762 |
|
4763 | iframe["".concat(field, "_change")](value);
|
4764 | },
|
4765 | get: function get(field) {
|
4766 | _this8.valid(field);
|
4767 |
|
4768 | return _this8.handler.rule.value;
|
4769 | }
|
4770 | };
|
4771 | }
|
4772 | } catch (e) {}
|
4773 | }
|
4774 | }
|
4775 | }), vNode.make('div', {
|
4776 | slot: 'footer'
|
4777 | }, [vNode.button({
|
4778 | on: {
|
4779 | click: function click() {
|
4780 | _vm.onClose();
|
4781 |
|
4782 | _this8.onCancel();
|
4783 | }
|
4784 | }
|
4785 | }, [toString$1(closeBtnText)]), vNode.button({
|
4786 | props: {
|
4787 | type: 'primary'
|
4788 | },
|
4789 | on: {
|
4790 | click: function click() {
|
4791 | _this8.onOk() !== false && _vm.onClose();
|
4792 | }
|
4793 | }
|
4794 | }, [toString$1(okBtnText)])])];
|
4795 | });
|
4796 | }
|
4797 | }]);
|
4798 |
|
4799 | return render;
|
4800 | }(Render);
|
4801 | Object.keys(eventList).forEach(function (k) {
|
4802 | render$e.prototype[k] = function () {
|
4803 | var fn = this.handler.rule.event[eventList[k]];
|
4804 | if (fn) return fn(this.handler.getValue());
|
4805 | };
|
4806 | });
|
4807 |
|
4808 | var name$e = "frame";
|
4809 | var types$1 = {
|
4810 | frameInputs: ['input', 0],
|
4811 | frameFiles: ['file', 0],
|
4812 | frameImages: ['image', 0],
|
4813 | frameInputOne: ['input', 1],
|
4814 | frameFileOne: ['file', 1],
|
4815 | frameImageOne: ['image', 1]
|
4816 | };
|
4817 | var maker$a = Object.keys(types$1).reduce(function (initial, key) {
|
4818 | initial[key] = creatorTypeFactory(name$e, function (m) {
|
4819 | return m.props({
|
4820 | type: types$1[key][0],
|
4821 | maxLength: types$1[key][1]
|
4822 | });
|
4823 | });
|
4824 | return initial;
|
4825 | }, {});
|
4826 | maker$a.frameInput = maker$a.frameInputs;
|
4827 | maker$a.frameFile = maker$a.frameFiles;
|
4828 | maker$a.frameImage = maker$a.frameImages;
|
4829 | var frame = {
|
4830 | handler: handler$c,
|
4831 | render: render$e,
|
4832 | name: name$e,
|
4833 | maker: maker$a
|
4834 | };
|
4835 |
|
4836 | function parseRule$2(rule) {
|
4837 | var props = rule.props;
|
4838 | if (props.data === undefined) $set(props, 'data', []);
|
4839 | if (props.type === undefined) $set(props, 'type', 'checked');
|
4840 | if (props.multiple === undefined) $set(props, 'multiple', false);
|
4841 | return rule;
|
4842 | }
|
4843 | function isMultiple(rule) {
|
4844 | return !rule.props.multiple && rule.props.type === 'selected';
|
4845 | }
|
4846 |
|
4847 | var handler$d = function (_Handler) {
|
4848 | _inherits(handler, _Handler);
|
4849 |
|
4850 | function handler() {
|
4851 | _classCallCheck(this, handler);
|
4852 |
|
4853 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
4854 | }
|
4855 |
|
4856 | _createClass(handler, [{
|
4857 | key: "init",
|
4858 | value: function init() {
|
4859 | parseRule$2(this.rule);
|
4860 | this._data = {};
|
4861 | this.data(this.rule.props.data);
|
4862 | $set(this.rule, 'value', this._parseValue());
|
4863 | }
|
4864 | }, {
|
4865 | key: "_parseValue",
|
4866 | value: function _parseValue() {
|
4867 | var _this = this;
|
4868 |
|
4869 | this.rule.value.forEach(this.rule.props.type === 'selected' ? function (v) {
|
4870 | return _this.selected(v);
|
4871 | } : function (v) {
|
4872 | return _this.checked(v);
|
4873 | });
|
4874 | var value = [],
|
4875 | props = this.rule.props;
|
4876 | props.type === 'selected' ? Object.keys(this._data).forEach(function (key) {
|
4877 | var node = _this._data[key];
|
4878 | if (node.selected === true) value.push(node.id);
|
4879 | }) : Object.keys(this._data).forEach(function (key) {
|
4880 | var node = _this._data[key];
|
4881 | if (node.checked === true) value.push(node.id);
|
4882 | });
|
4883 | return value;
|
4884 | }
|
4885 | }, {
|
4886 | key: "toFormValue",
|
4887 | value: function toFormValue(value) {
|
4888 | value = toArray(value);
|
4889 | this.choose(value);
|
4890 | this.parseValue = value;
|
4891 | return value;
|
4892 | }
|
4893 | }, {
|
4894 | key: "choose",
|
4895 | value: function choose(value) {
|
4896 | var rule = this.rule,
|
4897 | _data = this._data;
|
4898 | rule.props.type === 'selected' ? Object.keys(_data).forEach(function (key) {
|
4899 | $set(_data[key], 'selected', value.indexOf(_data[key].id) !== -1);
|
4900 | }) : Object.keys(_data).forEach(function (key) {
|
4901 | $set(_data[key], 'checked', value.indexOf(_data[key].id) !== -1);
|
4902 | });
|
4903 | }
|
4904 | }, {
|
4905 | key: "checked",
|
4906 | value: function checked(v) {
|
4907 | if (this._data[v] !== undefined) {
|
4908 | $set(this._data[v], 'checked', true);
|
4909 | }
|
4910 | }
|
4911 | }, {
|
4912 | key: "selected",
|
4913 | value: function selected(v) {
|
4914 | if (this._data[v] !== undefined) {
|
4915 | $set(this._data[v], 'selected', true);
|
4916 | }
|
4917 | }
|
4918 | }, {
|
4919 | key: "toValue",
|
4920 | value: function toValue(parseValue) {
|
4921 | var value = parseValue;
|
4922 | return !isMultiple(this.rule) ? value : value[0] || '';
|
4923 | }
|
4924 | }, {
|
4925 | key: "watchFormValue",
|
4926 | value: function watchFormValue(n) {
|
4927 | this.choose(n);
|
4928 | }
|
4929 | }, {
|
4930 | key: "selectedValue",
|
4931 | value: function selectedValue(nodes) {
|
4932 | var value = [];
|
4933 | nodes.forEach(function (node) {
|
4934 | if (node.selected === true) value.push(node.id);
|
4935 | });
|
4936 | return value;
|
4937 | }
|
4938 | }, {
|
4939 | key: "checkedValue",
|
4940 | value: function checkedValue(nodes) {
|
4941 | var value = [];
|
4942 | nodes.forEach(function (node) {
|
4943 | if (node.checked === true) value.push(node.id);
|
4944 | });
|
4945 | return value;
|
4946 | }
|
4947 | }, {
|
4948 | key: "_toValue",
|
4949 | value: function _toValue() {
|
4950 | return this.rule.props.type === 'selected' ? this.selectedValue(this.el.getSelectedNodes()) : this.checkedValue(this.el.getCheckedNodes());
|
4951 | }
|
4952 | }, {
|
4953 | key: "data",
|
4954 | value: function data(_data2) {
|
4955 | var _this2 = this;
|
4956 |
|
4957 | _data2.forEach(function (node) {
|
4958 | _this2._data[node.id] = node;
|
4959 | if (node.children !== undefined && Array.isArray(node.children)) _this2.data(node.children);
|
4960 | });
|
4961 | }
|
4962 | }]);
|
4963 |
|
4964 | return handler;
|
4965 | }(Handler);
|
4966 |
|
4967 | var event = {
|
4968 | s: 'on-select-change',
|
4969 | c: 'on-check-change'
|
4970 | };
|
4971 |
|
4972 | var render$f = function (_Render) {
|
4973 | _inherits(render, _Render);
|
4974 |
|
4975 | function render() {
|
4976 | _classCallCheck(this, render);
|
4977 |
|
4978 | return _possibleConstructorReturn(this, _getPrototypeOf(render).apply(this, arguments));
|
4979 | }
|
4980 |
|
4981 | _createClass(render, [{
|
4982 | key: "parse",
|
4983 | value: function parse() {
|
4984 | var _this = this,
|
4985 | _this$vData$on$on;
|
4986 |
|
4987 | var _this$handler = this.handler,
|
4988 | rule = _this$handler.rule,
|
4989 | refName = _this$handler.refName,
|
4990 | field = _this$handler.field,
|
4991 | unique = _this$handler.unique,
|
4992 | props = this.vData.on(rule.event).on((_this$vData$on$on = {}, _defineProperty(_this$vData$on$on, event.s, function () {
|
4993 | var _rule$event;
|
4994 |
|
4995 | _this.vm._changeFormData(field, _this.handler._toValue());
|
4996 |
|
4997 | rule.event[event.s] && (_rule$event = rule.event)[event.s].apply(_rule$event, arguments);
|
4998 | }), _defineProperty(_this$vData$on$on, event.c, function () {
|
4999 | var _rule$event2;
|
5000 |
|
5001 | _this.vm._changeFormData(field, _this.handler._toValue());
|
5002 |
|
5003 | rule.event[event.c] && (_rule$event2 = rule.event)[event.c].apply(_rule$event2, arguments);
|
5004 | }), _this$vData$on$on)).props(rule.props).ref(refName).key("fip".concat(unique)).get();
|
5005 | var inputProps = this.inputProps().props({
|
5006 | type: "text",
|
5007 | value: '' + this.handler.rule.value,
|
5008 | disable: true,
|
5009 | readonly: true
|
5010 | }).key('fipit' + unique).class('__fc_h').ref("".concat(refName, "it")).on('input', function () {}).get();
|
5011 | return [this.vNode.tree(props), this.vNode.input(inputProps)];
|
5012 | }
|
5013 | }]);
|
5014 |
|
5015 | return render;
|
5016 | }(Render);
|
5017 |
|
5018 | var name$f = "tree";
|
5019 | var types$2 = {
|
5020 | 'treeSelected': 'selected',
|
5021 | 'treeChecked': 'checked'
|
5022 | };
|
5023 | var maker$b = Object.keys(types$2).reduce(function (initial, key) {
|
5024 | initial[key] = creatorTypeFactory(name$f, types$2[key]);
|
5025 | return initial;
|
5026 | }, {});
|
5027 | var tree = {
|
5028 | handler: handler$d,
|
5029 | render: render$f,
|
5030 | name: name$f,
|
5031 | maker: maker$b
|
5032 | };
|
5033 |
|
5034 | var handler$e = function (_Handler) {
|
5035 | _inherits(handler, _Handler);
|
5036 |
|
5037 | function handler() {
|
5038 | _classCallCheck(this, handler);
|
5039 |
|
5040 | return _possibleConstructorReturn(this, _getPrototypeOf(handler).apply(this, arguments));
|
5041 | }
|
5042 |
|
5043 | _createClass(handler, [{
|
5044 | key: "init",
|
5045 | value: function init() {
|
5046 | var rule = this.rule;
|
5047 | if (!Array.isArray(rule.data)) $set(rule, 'data', []);
|
5048 | }
|
5049 | }, {
|
5050 | key: "watchFormValue",
|
5051 | value: function watchFormValue(n) {
|
5052 | _get(_getPrototypeOf(handler.prototype), "watchFormValue", this).call(this, n);
|
5053 |
|
5054 | this.render.sync();
|
5055 | }
|
5056 | }]);
|
5057 |
|
5058 | return handler;
|
5059 | }(Handler);
|
5060 |
|
5061 | var name$g = 'autoComplete';
|
5062 | var maker$c = {
|
5063 | auto: creatorFactory(name$g)
|
5064 | };
|
5065 | var render$g = defaultRenderFactory(name$g, true);
|
5066 | var autocomplete = {
|
5067 | handler: handler$e,
|
5068 | render: render$g,
|
5069 | name: name$g,
|
5070 | maker: maker$c
|
5071 | };
|
5072 |
|
5073 | var Form = function () {
|
5074 | function Form(fComponent) {
|
5075 | _classCallCheck(this, Form);
|
5076 |
|
5077 | var id = fComponent.id,
|
5078 | vm = fComponent.vm,
|
5079 | fieldList = fComponent.fieldList,
|
5080 | handlers = fComponent.handlers;
|
5081 | this.vm = vm;
|
5082 | this.handlers = handlers;
|
5083 | this.renderSort = fieldList;
|
5084 | this._fc = fComponent;
|
5085 | this.vNode = new VNode(vm);
|
5086 | this.vData = new VData();
|
5087 | this.unique = id;
|
5088 | this.refName = "cForm".concat(id);
|
5089 | this.cacheUnique = 0;
|
5090 | }
|
5091 |
|
5092 | _createClass(Form, [{
|
5093 | key: "getRender",
|
5094 | value: function getRender(field) {
|
5095 | return this.handlers[field].render;
|
5096 | }
|
5097 | }, {
|
5098 | key: "render",
|
5099 | value: function render(vm) {
|
5100 | var _this = this;
|
5101 |
|
5102 | if (!vm.isShow) return;
|
5103 | this.vNode.setVm(vm);
|
5104 |
|
5105 | if (this.cacheUnique !== vm.unique) {
|
5106 | this.renderSort.forEach(function (field) {
|
5107 | _this.getRender(field).clearCache();
|
5108 | });
|
5109 | this.cacheUnique = vm.unique;
|
5110 | }
|
5111 |
|
5112 | this.propsData = this.vData.props(this._fc.options.form).props({
|
5113 | model: this._fc.formData,
|
5114 | rules: this._fc.validate,
|
5115 | key: 'form' + this.unique
|
5116 | }).ref(this.refName).nativeOn({
|
5117 | submit: preventDefault
|
5118 | }).class('form-create', true).key(this.unique).get();
|
5119 | var unique = this.unique,
|
5120 | vn = this.renderSort.map(function (field) {
|
5121 | var render = _this.getRender(field);
|
5122 |
|
5123 | if (render.handler.type === 'hidden') return;
|
5124 | return _this.makeComponent(render);
|
5125 | }).filter(function (val) {
|
5126 | return val !== undefined;
|
5127 | });
|
5128 | if (vn.length > 0) vn.push(this.makeFormBtn(unique));
|
5129 | return this.vNode.form(this.propsData, vn.length > 0 ? [this.vNode.row(extend({
|
5130 | props: this._fc.options.row || {}
|
5131 | }, {
|
5132 | key: 'row' + unique
|
5133 | }), vn)] : []);
|
5134 | }
|
5135 | }, {
|
5136 | key: "makeComponent",
|
5137 | value: function makeComponent(render) {
|
5138 | return this.makeFormItem(render.handler, render.cacheParse(this), "fItem".concat(render.handler.key).concat(this.unique));
|
5139 | }
|
5140 | }, {
|
5141 | key: "makeFormItem",
|
5142 | value: function makeFormItem(_ref, VNodeFn, fItemUnique) {
|
5143 | var type = _ref.type,
|
5144 | rule = _ref.rule,
|
5145 | unique = _ref.unique,
|
5146 | field = _ref.field,
|
5147 | refName = _ref.refName;
|
5148 | var labelWidth = !isComponent(type) && !rule.col.labelWidth && !rule.title ? 1 : rule.col.labelWidth,
|
5149 | className = rule.className,
|
5150 | propsData = this.vData.props({
|
5151 | prop: field,
|
5152 | label: rule.title,
|
5153 | labelFor: unique,
|
5154 | rules: rule.validate,
|
5155 | labelWidth: labelWidth,
|
5156 | required: rule.props.required
|
5157 | }).key(fItemUnique).ref('fItem' + refName).class(className).get(),
|
5158 | node = this.vNode.formItem(propsData, VNodeFn);
|
5159 | return this.propsData.props.inline === true ? [node] : this.makeCol(rule, fItemUnique, [node]);
|
5160 | }
|
5161 | }, {
|
5162 | key: "makeCol",
|
5163 | value: function makeCol(rule, fItemUnique, VNodeFn) {
|
5164 | return this.vNode.col({
|
5165 | props: rule.col,
|
5166 | 'class': {
|
5167 | '__fc_h': rule.props.hidden === true,
|
5168 | '__fc_v': rule.props.visibility === true
|
5169 | },
|
5170 | key: "".concat(fItemUnique, "col1")
|
5171 | }, VNodeFn);
|
5172 | }
|
5173 | }, {
|
5174 | key: "makeFormBtn",
|
5175 | value: function makeFormBtn(unique) {
|
5176 | var btn = [],
|
5177 | submitBtnShow = false !== this.vm.buttonProps && false !== this.vm.buttonProps.show,
|
5178 | resetBtnShow = false !== this.vm.resetProps && false !== this.vm.resetProps.show;
|
5179 | if (submitBtnShow) btn.push(this.makeSubmitBtn(unique, resetBtnShow ? 19 : 24));
|
5180 | if (resetBtnShow) btn.push(this.makeResetBtn(unique, 4));
|
5181 | return this.vNode.col({
|
5182 | props: {
|
5183 | span: 24
|
5184 | },
|
5185 | key: "".concat(this.unique, "col2")
|
5186 | }, btn);
|
5187 | }
|
5188 | }, {
|
5189 | key: "makeResetBtn",
|
5190 | value: function makeResetBtn(unique, span) {
|
5191 | var _this2 = this;
|
5192 |
|
5193 | var resetBtn = this._fc.options.resetBtn,
|
5194 | props = isUndef(this._fc.options.resetBtn.col) ? {
|
5195 | span: span,
|
5196 | push: 1
|
5197 | } : resetBtn.col;
|
5198 | return this.vNode.col({
|
5199 | props: props,
|
5200 | key: "".concat(this.unique, "col3")
|
5201 | }, [this.vNode.button({
|
5202 | key: "frsbtn".concat(unique),
|
5203 | props: this.vm.resetProps,
|
5204 | on: {
|
5205 | "click": function click() {
|
5206 | var fApi = _this2._fc.fCreateApi;
|
5207 | isFunction(resetBtn.click) ? resetBtn.click(fApi) : fApi.resetFields();
|
5208 | }
|
5209 | }
|
5210 | }, [this.vm.resetProps.innerText])]);
|
5211 | }
|
5212 | }, {
|
5213 | key: "makeSubmitBtn",
|
5214 | value: function makeSubmitBtn(unique, span) {
|
5215 | var _this3 = this;
|
5216 |
|
5217 | var submitBtn = this._fc.options.submitBtn,
|
5218 | props = isUndef(this._fc.options.submitBtn.col) ? {
|
5219 | span: span
|
5220 | } : submitBtn.col;
|
5221 | return this.vNode.col({
|
5222 | props: props,
|
5223 | key: "".concat(this.unique, "col4")
|
5224 | }, [this.vNode.button({
|
5225 | key: "fbtn".concat(unique),
|
5226 | props: this.vm.buttonProps,
|
5227 | on: {
|
5228 | "click": function click() {
|
5229 | var fApi = _this3._fc.fCreateApi;
|
5230 | isFunction(submitBtn.click) ? submitBtn.click(fApi) : fApi.submit();
|
5231 | }
|
5232 | }
|
5233 | }, [this.vm.buttonProps.innerText])]);
|
5234 | }
|
5235 | }]);
|
5236 |
|
5237 | return Form;
|
5238 | }();
|
5239 |
|
5240 | var defineProperty$2 = objectDefineProperty.f;
|
5241 | var FunctionPrototype = Function.prototype;
|
5242 | var FunctionPrototypeToString = FunctionPrototype.toString;
|
5243 | var nameRE = /^\s*function ([^ (]*)/;
|
5244 | var NAME = 'name';
|
5245 |
|
5246 |
|
5247 |
|
5248 | if (descriptors && !(NAME in FunctionPrototype)) {
|
5249 | defineProperty$2(FunctionPrototype, NAME, {
|
5250 | configurable: true,
|
5251 | get: function () {
|
5252 | try {
|
5253 | return FunctionPrototypeToString.call(this).match(nameRE)[1];
|
5254 | } catch (error) {
|
5255 | return '';
|
5256 | }
|
5257 | }
|
5258 | });
|
5259 | }
|
5260 |
|
5261 | function makerFactory(componentList) {
|
5262 | var _m = {};
|
5263 | Object.keys(componentList).forEach(function (key) {
|
5264 | var component = componentList[key];
|
5265 | var undef = isUndef(component.maker);
|
5266 | if (undef || component.maker[component.name] === undefined) _m[component.name] = creatorFactory(component.name);
|
5267 | if (!undef) extend(_m, component.maker);
|
5268 | });
|
5269 | var commonMaker = creatorFactory('');
|
5270 | extend(_m, {
|
5271 | create: function create(type, field, title) {
|
5272 | var make = commonMaker('', field);
|
5273 | make.rule.type = type;
|
5274 | make.rule.title = title;
|
5275 | return make;
|
5276 | },
|
5277 | createTmp: function createTmp(template, vm, field, title) {
|
5278 | var make = commonMaker('', field);
|
5279 | make.rule.type = 'template';
|
5280 | make.rule.template = template;
|
5281 | make.rule.title = title;
|
5282 | make.rule.vm = vm;
|
5283 | return make;
|
5284 | }
|
5285 | });
|
5286 | _m.template = _m.createTmp;
|
5287 | _m.parse = parse;
|
5288 | return _m;
|
5289 | }
|
5290 |
|
5291 | function parse(rule) {
|
5292 | var toMaker = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
5293 | if (isString(rule)) rule = JSON.parse(rule);
|
5294 | if (rule instanceof Creator) return toMaker ? rule : rule.getRule();
|
5295 |
|
5296 | if (isPlainObject(rule)) {
|
5297 | var maker = ruleToMaker(rule);
|
5298 | return toMaker ? maker : maker.getRule();
|
5299 | } else if (!Array.isArray(rule)) return rule;else {
|
5300 | var rules = rule.map(function (r) {
|
5301 | return parse(r, toMaker);
|
5302 | });
|
5303 | Object.defineProperty(rules, 'find', {
|
5304 | value: findField,
|
5305 | enumerable: false,
|
5306 | configurable: false
|
5307 | });
|
5308 | return rules;
|
5309 | }
|
5310 | }
|
5311 |
|
5312 | function findField(field) {
|
5313 | var children = [];
|
5314 |
|
5315 | for (var i in this) {
|
5316 | var rule = this[i] instanceof Creator ? this[i].rule : this[i];
|
5317 | if (rule.field === field) return this[i];
|
5318 | if (isValidChildren(rule.children)) children = children.concat(rule.children);
|
5319 | }
|
5320 |
|
5321 | if (children.length > 0) return findField.call(children, field);
|
5322 | }
|
5323 |
|
5324 | function ruleToMaker(rule) {
|
5325 | var maker = new Creator();
|
5326 | Object.keys(rule).forEach(function (key) {
|
5327 | if (Object.keys(maker._data).indexOf(key) === -1) {
|
5328 | maker.rule[key] = rule[key];
|
5329 | } else {
|
5330 | maker._data[key] = rule[key];
|
5331 | }
|
5332 | });
|
5333 | return maker;
|
5334 | }
|
5335 |
|
5336 | function getGlobalApi(fComponent) {
|
5337 | var vm = fComponent.vm;
|
5338 |
|
5339 | function tidyFields(fields) {
|
5340 | var all = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
5341 | if (!fields) fields = all ? Object.keys(fComponent.handlers) : vm._formField();else if (!Array.isArray(fields)) fields = [fields];
|
5342 | return fields;
|
5343 | }
|
5344 |
|
5345 | return {
|
5346 | formData: function formData() {
|
5347 | var _this = this;
|
5348 |
|
5349 | var handlers = fComponent.handlers;
|
5350 | return Object.keys(handlers).reduce(function (initial, field) {
|
5351 | var handler = handlers[field];
|
5352 |
|
5353 | if (handler.noValue === true) {
|
5354 | handler.$emit('input', function (val) {
|
5355 | initial[field] = val;
|
5356 | }, _this);
|
5357 | } else {
|
5358 | initial[field] = deepExtend({}, {
|
5359 | value: vm._value(field)
|
5360 | }).value;
|
5361 | }
|
5362 |
|
5363 | return initial;
|
5364 | }, {});
|
5365 | },
|
5366 | getValue: function getValue(field) {
|
5367 | field = toString$1(field);
|
5368 | var handler = fComponent.handlers[field];
|
5369 | if (isUndef(handler)) return;
|
5370 | var val = undefined;
|
5371 | if (handler.noValue === true) handler.$emit('input', function (v) {
|
5372 | val = v;
|
5373 | }, this);else val = deepExtend({}, {
|
5374 | value: vm._value(field)
|
5375 | }).value;
|
5376 | return val;
|
5377 | },
|
5378 | setValue: function setValue(field, value) {
|
5379 | var _this2 = this;
|
5380 |
|
5381 | var formData = field;
|
5382 | if (!isPlainObject(field)) formData = _defineProperty({}, field, value);
|
5383 | Object.keys(formData).forEach(function (key) {
|
5384 | _this2.changeValue(key, formData[key]);
|
5385 | });
|
5386 | },
|
5387 | changeValue: function changeValue(field, value) {
|
5388 | var _this3 = this;
|
5389 |
|
5390 | field = toString$1(field);
|
5391 | var handler = fComponent.handlers[field];
|
5392 | if (handler === undefined) return;
|
5393 | if (isFunction(value)) value(vm._trueData(field), function (changeValue) {
|
5394 | _this3.changeField(field, changeValue);
|
5395 | });else {
|
5396 | if (handler.noValue === true) handler.$emit('set-value', value, this);else handler.setValue(value);
|
5397 | }
|
5398 | },
|
5399 | changeField: function changeField(field, value) {
|
5400 | this.setValue(field, value);
|
5401 | },
|
5402 | removeField: function removeField(field) {
|
5403 | var handler = fComponent.handlers[field];
|
5404 | if (!handler) return;
|
5405 | var fields = handler.root.map(function (rule) {
|
5406 | return rule.__field__;
|
5407 | }),
|
5408 | index = fields.indexOf(toString$1(field));
|
5409 | if (index === -1) return;
|
5410 | handler.root.splice(index, 1);
|
5411 |
|
5412 | vm._refresh();
|
5413 | },
|
5414 | validate: function validate(successFn, errorFn) {
|
5415 | fComponent.getFormRef().validate(function (valid) {
|
5416 | valid === true ? successFn && successFn() : errorFn && errorFn();
|
5417 | });
|
5418 | },
|
5419 | validateField: function validateField(field, callback) {
|
5420 | if (!vm.cptData[field]) return;
|
5421 | fComponent.getFormRef().validateField(field, callback);
|
5422 | },
|
5423 | resetFields: function resetFields(fields) {
|
5424 | var _this4 = this;
|
5425 |
|
5426 | var handlers = fComponent.handlers;
|
5427 | tidyFields(fields, true).forEach(function (field) {
|
5428 | var handler = handlers[field];
|
5429 | if (!handler) return;
|
5430 | if (!handler.noValue) handler.reset();else handler.$emit('reset-field', _this4);
|
5431 | });
|
5432 | this.refresh();
|
5433 | },
|
5434 | destroy: function destroy() {
|
5435 | vm.$el.parentNode.removeChild(vm.$el);
|
5436 | vm.$destroy();
|
5437 | },
|
5438 | fields: function fields() {
|
5439 | return vm._formField();
|
5440 | },
|
5441 | append: function append(rule, after) {
|
5442 | var fields = fComponent.fieldList,
|
5443 | index = fields.indexOf(toString$1(after));
|
5444 | if (rule.field && fields.indexOf(toString$1(rule.field)) !== -1) return console.error("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728") + errMsg());
|
5445 |
|
5446 | if (isUndef(after)) {
|
5447 | index = fields.length;
|
5448 | } else if (index === -1) return;
|
5449 |
|
5450 | fComponent.rules.splice(index + 1, 0, rule);
|
5451 | },
|
5452 | prepend: function prepend(rule, after) {
|
5453 | var fields = fComponent.fieldList,
|
5454 | index = fields.indexOf(toString$1(after));
|
5455 | if (rule.field && fields.indexOf(toString$1(rule.field)) !== -1) return console.error("".concat(rule.field, " \u5B57\u6BB5\u5DF2\u5B58\u5728") + errMsg());
|
5456 |
|
5457 | if (isUndef(after)) {
|
5458 | index = 0;
|
5459 | } else if (index === -1) return;else index--;
|
5460 |
|
5461 | fComponent.rules.splice(index + 1, 0, rule);
|
5462 | },
|
5463 | submit: function submit(successFn, failFn) {
|
5464 | var _this5 = this;
|
5465 |
|
5466 | this.validate(function () {
|
5467 | var formData = _this5.formData();
|
5468 |
|
5469 | if (isFunction(successFn)) successFn(formData, _this5);else fComponent.options.onSubmit && fComponent.options.onSubmit(formData);
|
5470 | }, function () {
|
5471 | return failFn && failFn();
|
5472 | });
|
5473 | },
|
5474 | hidden: function hidden(fields) {
|
5475 | var _hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
5476 |
|
5477 | tidyFields(fields).forEach(function (field) {
|
5478 | var handler = fComponent.handlers[field];
|
5479 | if (!fComponent.handlers[field]) return;
|
5480 | vm.$set(vm._trueData(field).props, 'hidden', !!_hidden);
|
5481 | handler.render.sync();
|
5482 | });
|
5483 | },
|
5484 | visibility: function visibility(fields) {
|
5485 | var _visibility = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
5486 |
|
5487 | tidyFields(fields).forEach(function (field) {
|
5488 | var handler = fComponent.handlers[field];
|
5489 | if (!handler) return;
|
5490 | vm.$set(vm._trueData(field).props, 'visibility', !!_visibility);
|
5491 | handler.render.sync();
|
5492 | });
|
5493 | },
|
5494 | disabled: function disabled(fields) {
|
5495 | var _this6 = this;
|
5496 |
|
5497 | var _disabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
5498 |
|
5499 | _disabled = !!_disabled;
|
5500 | tidyFields(fields, true).forEach(function (field) {
|
5501 | var handler = fComponent.handlers[field];
|
5502 | if (!handler) return;
|
5503 | if (!handler.noValue) vm.$set(vm._trueData(field).props, 'disabled', _disabled);else handler.$emit('disabled', _disabled, _this6);
|
5504 | handler.render.sync();
|
5505 | });
|
5506 | },
|
5507 | clearValidateState: function clearValidateState(fields) {
|
5508 | tidyFields(fields).forEach(function (field) {
|
5509 | var handler = fComponent.handlers[field];
|
5510 | if (!handler) return;
|
5511 | handler.clearMsg();
|
5512 | });
|
5513 | },
|
5514 | model: function model() {
|
5515 | return _objectSpread({}, vm.trueData);
|
5516 | },
|
5517 | component: function component() {
|
5518 | return _objectSpread({}, vm.components);
|
5519 | },
|
5520 | bind: function bind(fields) {
|
5521 | var bind = {},
|
5522 | properties = {};
|
5523 | tidyFields(fields).forEach(function (field) {
|
5524 | var rule = vm._trueData(field);
|
5525 |
|
5526 | if (!rule) return console.error("".concat(field, " \u5B57\u6BB5\u4E0D\u5B58\u5728") + errMsg());
|
5527 | properties[field] = {
|
5528 | get: function get() {
|
5529 | return rule.value;
|
5530 | },
|
5531 | set: function set(value) {
|
5532 | vm.$set(rule, 'value', value);
|
5533 | },
|
5534 | enumerable: true,
|
5535 | configurable: true
|
5536 | };
|
5537 | });
|
5538 | Object.defineProperties(bind, properties);
|
5539 | return bind;
|
5540 | },
|
5541 | submitStatus: function submitStatus() {
|
5542 | var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
5543 |
|
5544 | vm._buttonProps(props);
|
5545 | },
|
5546 | resetStatus: function resetStatus() {
|
5547 | var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
5548 |
|
5549 | vm._resetProps(props);
|
5550 | },
|
5551 | btn: {
|
5552 | loading: function loading() {
|
5553 | var _loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
5554 |
|
5555 | vm._buttonProps({
|
5556 | loading: _loading
|
5557 | });
|
5558 | },
|
5559 | finish: function finish() {
|
5560 | this.loading(false);
|
5561 | },
|
5562 | disabled: function disabled() {
|
5563 | var _disabled2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
5564 |
|
5565 | vm._buttonProps({
|
5566 | disabled: _disabled2
|
5567 | });
|
5568 | },
|
5569 | show: function show() {
|
5570 | var isShow = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
5571 |
|
5572 | vm._buttonProps({
|
5573 | show: isShow
|
5574 | });
|
5575 | }
|
5576 | },
|
5577 | resetBtn: {
|
5578 | loading: function loading() {
|
5579 | var _loading2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
5580 |
|
5581 | vm._resetProps({
|
5582 | loading: _loading2
|
5583 | });
|
5584 | },
|
5585 | finish: function finish() {
|
5586 | this.loading(false);
|
5587 | },
|
5588 | disabled: function disabled() {
|
5589 | var _disabled3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
5590 |
|
5591 | vm._resetProps({
|
5592 | disabled: _disabled3
|
5593 | });
|
5594 | },
|
5595 | show: function show() {
|
5596 | var isShow = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
5597 |
|
5598 | vm._resetProps({
|
5599 | show: isShow
|
5600 | });
|
5601 | }
|
5602 | },
|
5603 | closeModal: function closeModal(field) {
|
5604 | var handler = fComponent.handlers[field];
|
5605 |
|
5606 | if (handler && handler.$modal) {
|
5607 | handler.$modal.onClose();
|
5608 | handler.$modal = null;
|
5609 | }
|
5610 | },
|
5611 | set: function set(node, field, value) {
|
5612 | vm.$set(node, field, value);
|
5613 | },
|
5614 | reload: function reload(rules) {
|
5615 | fComponent.reload(rules);
|
5616 | },
|
5617 | options: function options(_options) {
|
5618 | deepExtend(fComponent.options, _options);
|
5619 |
|
5620 | vm._sync();
|
5621 | },
|
5622 | onSuccess: function onSuccess(fn) {
|
5623 | this.onSubmit(fn);
|
5624 | },
|
5625 | onSubmit: function onSubmit(fn) {
|
5626 | this.options({
|
5627 | onSubmit: fn
|
5628 | });
|
5629 | },
|
5630 | sync: function sync(field, callback) {
|
5631 | if (fComponent.handlers[field]) fComponent.handlers[field].render.sync(callback);
|
5632 | },
|
5633 | refresh: function refresh() {
|
5634 | vm._refresh();
|
5635 | },
|
5636 | show: function show() {
|
5637 | var isShow = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
5638 | vm.isShow = !!isShow;
|
5639 | }
|
5640 | };
|
5641 | }
|
5642 |
|
5643 | var componentList = {
|
5644 | hidden: hidden,
|
5645 | input: input,
|
5646 | radio: radio,
|
5647 | checkbox: checkbox,
|
5648 | switch: iswitch,
|
5649 | select: select,
|
5650 | datepicker: datepicker,
|
5651 | timepicker: timepicker,
|
5652 | inputnumber: inputnumber,
|
5653 | colorpicker: colorpicker,
|
5654 | upload: upload,
|
5655 | cascader: cascader,
|
5656 | rate: rate,
|
5657 | slider: slider,
|
5658 | frame: frame,
|
5659 | tree: tree,
|
5660 | autocomplete: autocomplete
|
5661 | };
|
5662 | var style = '.form-create{padding:25px;} .fc-upload-btn,.fc-files{display: inline-block;width: 58px;height: 58px;text-align: center;line-height: 58px;border: 1px solid #c0ccda;border-radius: 4px;overflow: hidden;background: #fff;position: relative;box-shadow: 2px 2px 5px rgba(0,0,0,.1);margin-right: 4px;box-sizing: border-box;}.__fc_h{display:none;}.__fc_v{visibility:hidden;}' + ' .fc-files>.ivu-icon{vertical-align: middle;}' + '.fc-files img{width:100%;height:100%;display:inline-block;vertical-align: top;}' + '.fc-upload .ivu-upload{display: inline-block;}' + '.fc-upload-btn{border: 1px dashed #c0ccda;cursor: pointer;}' + '.fc-upload-btn>ivu-icon{vertical-align:sub;}' + '.fc-upload .fc-upload-cover{opacity: 0; position: absolute; top: 0; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.6); transition: opacity .3s;}' + '.fc-upload .fc-upload-cover i{ color: #fff; font-size: 20px; cursor: pointer; margin: 0 2px; }' + '.fc-files:hover .fc-upload-cover{opacity: 1; }' + '.fc-hide-btn .ivu-upload .ivu-upload{display:none;}' + '.fc-upload .ivu-upload-list{margin-top: 0;}' + '.fc-spin-icon-load{animation: ani-fc-spin 1s linear infinite;} @-webkit-keyframes ani-fc-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}50%{-webkit-transform:rotate(180deg);transform:rotate(180deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes ani-fc-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}50%{-webkit-transform:rotate(180deg);transform:rotate(180deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}';
|
5663 | var nodes = {
|
5664 | modal: 'Modal',
|
5665 | progress: 'i-progress',
|
5666 | button: 'i-button',
|
5667 | icon: 'Icon',
|
5668 | slider: 'Slider',
|
5669 | rate: 'Rate',
|
5670 | upload: 'Upload',
|
5671 | cascader: 'Cascader',
|
5672 | colorPicker: 'Color-Picker',
|
5673 | timePicker: 'Time-Picker',
|
5674 | datePicker: 'Date-Picker',
|
5675 | 'switch': 'i-switch',
|
5676 | option: 'i-option',
|
5677 | select: 'i-select',
|
5678 | checkbox: 'Checkbox',
|
5679 | checkboxGroup: 'Checkbox-Group',
|
5680 | radio: 'Radio',
|
5681 | radioGroup: 'Radio-Group',
|
5682 | inputNumber: 'Input-Number',
|
5683 | input: 'i-input',
|
5684 | formItem: 'Form-Item',
|
5685 | form: 'i-form',
|
5686 | col: 'i-col',
|
5687 | row: 'row',
|
5688 | tree: 'Tree',
|
5689 | autoComplete: 'AutoComplete'
|
5690 | };
|
5691 | function install$1(FormCreate) {
|
5692 | FormCreate.maker = makerFactory(componentList);
|
5693 | VNode.use(nodes);
|
5694 | }
|
5695 | var drive$1 = {
|
5696 | componentList: componentList,
|
5697 | formRender: Form,
|
5698 | style: style,
|
5699 | getGlobalApi: getGlobalApi,
|
5700 | getConfig: getConfig,
|
5701 | install: install$1
|
5702 | };
|
5703 |
|
5704 | setDrive(drive$1);
|
5705 |
|
5706 | if (typeof window !== 'undefined') {
|
5707 | window.formCreate = FormCreate;
|
5708 |
|
5709 | if (window.Vue) {
|
5710 | install(Vue);
|
5711 | }
|
5712 | }
|
5713 |
|
5714 | var maker$d = FormCreate.maker;
|
5715 |
|
5716 | exports.maker = maker$d;
|
5717 | exports.default = FormCreate;
|
5718 |
|
5719 | Object.defineProperty(exports, '__esModule', { value: true });
|
5720 |
|
5721 | })));
|