@form-create/iview 2.5.36 → 2.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -29
- package/dist/form-create.esm.js +4216 -0
- package/dist/form-create.js +6 -6330
- package/dist/form-create.min.js +7 -3
- package/package.json +28 -21
- package/dist/form-create.min.js.map +0 -1
|
@@ -0,0 +1,4216 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* FormCreate 低代码表单渲染器
|
|
3
|
+
* @form-create/iview v2.6.0
|
|
4
|
+
* (c) 2018-2024 xaboy
|
|
5
|
+
* Github https://github.com/xaboy/form-create
|
|
6
|
+
* Site https://form-create.com/
|
|
7
|
+
* Released under the MIT License.
|
|
8
|
+
*/
|
|
9
|
+
(function(){"use strict";try{if(typeof document!="undefined"){var o=document.createElement("style");o.appendChild(document.createTextNode('._fc-frame .fc-upload-btn{border:1px dashed #c0ccda;cursor:pointer}._fc-frame .fc-upload-cover{opacity:0;position:absolute;inset:0;background:#0009;transition:opacity .3s}._fc-frame .fc-upload-cover i{color:#fff;font-size:20px;cursor:pointer;margin:0 2px}._fc-frame .fc-files:hover .fc-upload-cover{opacity:1}._fc-frame .ivu-upload-list{margin-top:0}._fc-frame .fc-files img{width:100%;height:100%;display:inline-block;vertical-align:top}._fc-frame .fc-upload-btn,._fc-frame .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 #0000001a;margin-right:4px;box-sizing:border-box}._fc-upload .fc-upload-btn{border:1px dashed #c0ccda;cursor:pointer}._fc-upload .fc-upload-cover{opacity:0;position:absolute;inset:0;background:#0009;transition:opacity .3s}._fc-upload .fc-upload-cover i{color:#fff;font-size:20px;cursor:pointer;margin:0 2px}._fc-upload .fc-files:hover .fc-upload-cover{opacity:1}._fc-upload .ivu-upload-list{margin-top:0}._fc-upload .fc-files img{width:100%;height:100%;display:inline-block;vertical-align:top}._fc-upload .fc-upload-btn,._fc-upload .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 #0000001a;margin-right:4px;box-sizing:border-box}._fc-group{display:flex;min-height:42px;justify-content:center;flex-direction:column}._fc-group-disabled ._fc-group-btn,._fc-group-disabled ._fc-group-add{cursor:not-allowed}._fc-group-handle{display:flex;flex-direction:row;position:absolute;bottom:-15px;right:30px;border-radius:15px;border:1px dashed #d9d9d9;padding:3px 8px;background-color:#fff}._fc-group-btn{cursor:pointer}._fc-group-idx{position:absolute;bottom:-15px;left:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:#eee;border-radius:15px;font-weight:700}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{position:relative;display:flex;flex-direction:column;border:1px dashed #d9d9d9;padding:20px 20px 25px;margin:5px 5px 25px;border-radius:5px}._fc-group-arrow{position:relative;width:20px;height:20px}._fc-group-arrow:before{content:"";position:absolute;top:8px;left:5px;width:9px;height:9px;border-left:2px solid #999;border-top:2px solid #999}._fc-group-arrow:before{transform:rotate(45deg)}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{width:20px;height:20px;position:relative;cursor:pointer}._fc-group-plus-minus:before,._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:60%;height:2px;background-color:#409eff;transform:translate(-50%,-50%)}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{cursor:pointer;width:25px;height:25px;border:1px solid rgb(64 158 255 / 50%);border-radius:15px}._fc-group-add._fc-group-plus-minus:before,._fc-group-add._fc-group-plus-minus:after{width:50%}.form-create .form-create .ivu-form-item{margin-bottom:24px}.form-create .form-create .ivu-form-item .ivu-form-item{margin-bottom:0}')),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
10
|
+
var vt = Object.defineProperty, bt = Object.defineProperties;
|
|
11
|
+
var Ct = Object.getOwnPropertyDescriptors;
|
|
12
|
+
var Fe = Object.getOwnPropertySymbols;
|
|
13
|
+
var _t = Object.prototype.hasOwnProperty, kt = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var Se = (t, e, r) => e in t ? vt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, y = (t, e) => {
|
|
15
|
+
for (var r in e || (e = {}))
|
|
16
|
+
_t.call(e, r) && Se(t, r, e[r]);
|
|
17
|
+
if (Fe)
|
|
18
|
+
for (var r of Fe(e))
|
|
19
|
+
kt.call(e, r) && Se(t, r, e[r]);
|
|
20
|
+
return t;
|
|
21
|
+
}, H = (t, e) => bt(t, Ct(e));
|
|
22
|
+
import Y, { h as p } from "vue";
|
|
23
|
+
function Ot(t) {
|
|
24
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
25
|
+
}
|
|
26
|
+
function le() {
|
|
27
|
+
return le = Object.assign ? Object.assign.bind() : function(t) {
|
|
28
|
+
for (var e, r = 1; r < arguments.length; r++) for (var i in e = arguments[r], e) Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
|
|
29
|
+
return t;
|
|
30
|
+
}, le.apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
var wt = ["attrs", "props", "domProps"], Ft = ["class", "style", "directives"], St = ["on", "nativeOn"], Rt = function(t) {
|
|
33
|
+
return t.reduce(function(e, r) {
|
|
34
|
+
for (var i in r) if (!e[i]) e[i] = r[i];
|
|
35
|
+
else if (wt.indexOf(i) !== -1) e[i] = le({}, e[i], r[i]);
|
|
36
|
+
else if (Ft.indexOf(i) !== -1) {
|
|
37
|
+
var s = e[i] instanceof Array ? e[i] : [e[i]], n = r[i] instanceof Array ? r[i] : [r[i]];
|
|
38
|
+
e[i] = [].concat(s, n);
|
|
39
|
+
} else if (St.indexOf(i) !== -1)
|
|
40
|
+
for (var o in r[i]) if (e[i][o]) {
|
|
41
|
+
var a = e[i][o] instanceof Array ? e[i][o] : [e[i][o]], u = r[i][o] instanceof Array ? r[i][o] : [r[i][o]];
|
|
42
|
+
e[i][o] = [].concat(a, u);
|
|
43
|
+
} else e[i][o] = r[i][o];
|
|
44
|
+
else if (i === "hook") for (var l in r[i]) e[i][l] = e[i][l] ? Et(e[i][l], r[i][l]) : r[i][l];
|
|
45
|
+
else e[i] = r[i];
|
|
46
|
+
return e;
|
|
47
|
+
}, {});
|
|
48
|
+
}, Et = function(t, e) {
|
|
49
|
+
return function() {
|
|
50
|
+
t && t.apply(this, arguments), e && e.apply(this, arguments);
|
|
51
|
+
};
|
|
52
|
+
}, It = Rt;
|
|
53
|
+
const _ = /* @__PURE__ */ Ot(It);
|
|
54
|
+
function ee(t, e) {
|
|
55
|
+
return Object.keys(t).reduce((r, i) => ((!e || e.indexOf(i) === -1) && r.push(t[i]), r), []);
|
|
56
|
+
}
|
|
57
|
+
const jt = "fcCheckbox", At = {
|
|
58
|
+
name: jt,
|
|
59
|
+
props: {
|
|
60
|
+
formCreateInject: {
|
|
61
|
+
type: Object,
|
|
62
|
+
required: !0
|
|
63
|
+
},
|
|
64
|
+
value: {
|
|
65
|
+
type: Array,
|
|
66
|
+
default: () => []
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
watch: {
|
|
70
|
+
"formCreateInject.options": {
|
|
71
|
+
handler() {
|
|
72
|
+
this.update();
|
|
73
|
+
},
|
|
74
|
+
deep: !0
|
|
75
|
+
},
|
|
76
|
+
value() {
|
|
77
|
+
this.update();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
data() {
|
|
81
|
+
return {
|
|
82
|
+
trueValue: []
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
methods: {
|
|
86
|
+
options() {
|
|
87
|
+
const t = this.formCreateInject.options;
|
|
88
|
+
return Array.isArray(t) ? t : [];
|
|
89
|
+
},
|
|
90
|
+
onInput(t) {
|
|
91
|
+
this.$emit("input", this.options().filter((e) => t.indexOf(e.label) !== -1).map((e) => e.value).filter((e) => e !== void 0));
|
|
92
|
+
},
|
|
93
|
+
update() {
|
|
94
|
+
const t = Array.isArray(this.value) ? this.value : [this.value];
|
|
95
|
+
this.trueValue = this.options().filter((e) => t.indexOf(e.value) !== -1).map((e) => e.label);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
created() {
|
|
99
|
+
this.update();
|
|
100
|
+
},
|
|
101
|
+
render() {
|
|
102
|
+
return p("CheckboxGroup", _([{}, this.formCreateInject.prop, {
|
|
103
|
+
ref: "el"
|
|
104
|
+
}, {
|
|
105
|
+
props: {
|
|
106
|
+
value: this.trueValue
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
on: {
|
|
110
|
+
input: this.onInput
|
|
111
|
+
}
|
|
112
|
+
}]), [this.options().map((t, e) => {
|
|
113
|
+
const r = y({}, t);
|
|
114
|
+
return delete r.value, p("Checkbox", _([{}, {
|
|
115
|
+
props: r
|
|
116
|
+
}, {
|
|
117
|
+
key: "" + e + "-" + t.value
|
|
118
|
+
}]));
|
|
119
|
+
}), ee(this.$slots)]);
|
|
120
|
+
},
|
|
121
|
+
mounted() {
|
|
122
|
+
this.$emit("fc.el", this.$refs.el);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
function j(t) {
|
|
126
|
+
return Array.isArray(t) ? t : [null, void 0, ""].indexOf(t) > -1 ? [] : [t];
|
|
127
|
+
}
|
|
128
|
+
const Vt = "fcFrame";
|
|
129
|
+
function xe(t) {
|
|
130
|
+
return {
|
|
131
|
+
name: Vt,
|
|
132
|
+
props: {
|
|
133
|
+
formCreateInject: {
|
|
134
|
+
type: Object,
|
|
135
|
+
required: !0
|
|
136
|
+
},
|
|
137
|
+
type: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: "input"
|
|
140
|
+
},
|
|
141
|
+
field: String,
|
|
142
|
+
helper: {
|
|
143
|
+
type: Boolean,
|
|
144
|
+
default: !0
|
|
145
|
+
},
|
|
146
|
+
disabled: {
|
|
147
|
+
type: Boolean,
|
|
148
|
+
default: !1
|
|
149
|
+
},
|
|
150
|
+
src: {
|
|
151
|
+
type: String,
|
|
152
|
+
required: !0
|
|
153
|
+
},
|
|
154
|
+
icon: {
|
|
155
|
+
type: String,
|
|
156
|
+
default: t.fileUpIcon
|
|
157
|
+
},
|
|
158
|
+
width: {
|
|
159
|
+
type: [Number, String],
|
|
160
|
+
default: 500
|
|
161
|
+
},
|
|
162
|
+
height: {
|
|
163
|
+
type: String,
|
|
164
|
+
default: "370px"
|
|
165
|
+
},
|
|
166
|
+
maxLength: {
|
|
167
|
+
type: Number,
|
|
168
|
+
default: 0
|
|
169
|
+
},
|
|
170
|
+
okBtnText: {
|
|
171
|
+
type: String,
|
|
172
|
+
default: "确定"
|
|
173
|
+
},
|
|
174
|
+
closeBtnText: {
|
|
175
|
+
type: String,
|
|
176
|
+
default: "关闭"
|
|
177
|
+
},
|
|
178
|
+
modalTitle: String,
|
|
179
|
+
handleIcon: {
|
|
180
|
+
type: [String, Boolean],
|
|
181
|
+
default: void 0
|
|
182
|
+
},
|
|
183
|
+
title: String,
|
|
184
|
+
allowRemove: {
|
|
185
|
+
type: Boolean,
|
|
186
|
+
default: !0
|
|
187
|
+
},
|
|
188
|
+
onOpen: {
|
|
189
|
+
type: Function,
|
|
190
|
+
default: () => {
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
onOk: {
|
|
194
|
+
type: Function,
|
|
195
|
+
default: () => {
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
onCancel: {
|
|
199
|
+
type: Function,
|
|
200
|
+
default: () => {
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
onLoad: {
|
|
204
|
+
type: Function,
|
|
205
|
+
default: () => {
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
onBeforeRemove: {
|
|
209
|
+
type: Function,
|
|
210
|
+
default: () => {
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
onRemove: {
|
|
214
|
+
type: Function,
|
|
215
|
+
default: () => {
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
onHandle: {
|
|
219
|
+
type: Function,
|
|
220
|
+
default(e) {
|
|
221
|
+
this.previewImage = this.getSrc(e), this.previewVisible = !0;
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
modal: {
|
|
225
|
+
type: Object,
|
|
226
|
+
default: () => ({})
|
|
227
|
+
},
|
|
228
|
+
srcKey: {
|
|
229
|
+
type: [String, Number]
|
|
230
|
+
},
|
|
231
|
+
value: [Array, String, Number, Object],
|
|
232
|
+
previewMask: void 0,
|
|
233
|
+
footer: {
|
|
234
|
+
type: Boolean,
|
|
235
|
+
default: !0
|
|
236
|
+
},
|
|
237
|
+
reload: {
|
|
238
|
+
type: Boolean,
|
|
239
|
+
default: !0
|
|
240
|
+
},
|
|
241
|
+
closeBtn: {
|
|
242
|
+
type: Boolean,
|
|
243
|
+
default: !0
|
|
244
|
+
},
|
|
245
|
+
okBtn: {
|
|
246
|
+
type: Boolean,
|
|
247
|
+
default: !0
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
data() {
|
|
251
|
+
return {
|
|
252
|
+
fileList: j(this.value),
|
|
253
|
+
previewVisible: !1,
|
|
254
|
+
frameVisible: !1,
|
|
255
|
+
previewImage: ""
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
watch: {
|
|
259
|
+
value(e) {
|
|
260
|
+
this.fileList = j(e);
|
|
261
|
+
},
|
|
262
|
+
fileList(e) {
|
|
263
|
+
const r = this.maxLength === 1 ? e[0] || "" : e;
|
|
264
|
+
this.$emit("input", r), this.$emit("change", r);
|
|
265
|
+
},
|
|
266
|
+
src(e) {
|
|
267
|
+
this.modalVm && (this.modalVm.src = e);
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
methods: {
|
|
271
|
+
key(e) {
|
|
272
|
+
return e;
|
|
273
|
+
},
|
|
274
|
+
closeModel(e) {
|
|
275
|
+
this.$emit(e ? "$close" : "$ok"), this.reload && (this.$off("$ok"), this.$off("$close")), this.frameVisible = !1;
|
|
276
|
+
},
|
|
277
|
+
showModel() {
|
|
278
|
+
this.disabled || this.onOpen() === !1 || (this.frameVisible = !0);
|
|
279
|
+
},
|
|
280
|
+
makeInput() {
|
|
281
|
+
const e = {
|
|
282
|
+
type: "text",
|
|
283
|
+
value: this.fileList.map((r) => this.getSrc(r)).toString(),
|
|
284
|
+
icon: this.icon,
|
|
285
|
+
readonly: !0,
|
|
286
|
+
clearable: !1
|
|
287
|
+
};
|
|
288
|
+
return p("Input", _([{}, {
|
|
289
|
+
props: e
|
|
290
|
+
}, {}, {
|
|
291
|
+
on: {
|
|
292
|
+
"on-click": () => this.showModel()
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
key: this.key("input")
|
|
296
|
+
}]));
|
|
297
|
+
},
|
|
298
|
+
makeGroup(e) {
|
|
299
|
+
return (!this.maxLength || this.fileList.length < this.maxLength) && e.push(this.makeBtn()), p("div", {
|
|
300
|
+
key: this.key("group")
|
|
301
|
+
}, [...e]);
|
|
302
|
+
},
|
|
303
|
+
makeItem(e, r) {
|
|
304
|
+
return p("div", {
|
|
305
|
+
class: "fc-files",
|
|
306
|
+
key: this.key("file" + e)
|
|
307
|
+
}, [...r]);
|
|
308
|
+
},
|
|
309
|
+
valid(e) {
|
|
310
|
+
const r = this.formCreateInject.field || this.field;
|
|
311
|
+
if (r && e !== r) throw new Error("[frame]无效的字段值");
|
|
312
|
+
},
|
|
313
|
+
makeIcons(e, r) {
|
|
314
|
+
if (this.handleIcon !== !1 || this.allowRemove === !0) {
|
|
315
|
+
const i = [];
|
|
316
|
+
return (this.type !== "file" && this.handleIcon !== !1 || this.type === "file" && this.handleIcon) && i.push(this.makeHandleIcon(e, r)), this.allowRemove && i.push(this.makeRemoveIcon(e, r)), p("div", {
|
|
317
|
+
class: "fc-upload-cover",
|
|
318
|
+
key: this.key("uc")
|
|
319
|
+
}, [i]);
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
makeHandleIcon(e, r) {
|
|
323
|
+
return p("icon", _([{}, {
|
|
324
|
+
props: {
|
|
325
|
+
type: this.handleIcon === !0 || this.handleIcon === void 0 ? "ios-eye-outline" : this.handleIcon
|
|
326
|
+
}
|
|
327
|
+
}, {
|
|
328
|
+
on: {
|
|
329
|
+
click: () => this.handleClick(e)
|
|
330
|
+
},
|
|
331
|
+
key: this.key("hi" + r)
|
|
332
|
+
}]));
|
|
333
|
+
},
|
|
334
|
+
makeRemoveIcon(e, r) {
|
|
335
|
+
return p("icon", _([{}, {
|
|
336
|
+
props: {
|
|
337
|
+
type: "ios-trash-outline"
|
|
338
|
+
}
|
|
339
|
+
}, {
|
|
340
|
+
on: {
|
|
341
|
+
click: () => this.handleRemove(e)
|
|
342
|
+
},
|
|
343
|
+
key: this.key("ri" + r)
|
|
344
|
+
}]));
|
|
345
|
+
},
|
|
346
|
+
makeFiles() {
|
|
347
|
+
return this.makeGroup(this.fileList.map((e, r) => this.makeItem(r, [p("icon", _([{}, {
|
|
348
|
+
props: {
|
|
349
|
+
type: t.fileIcon,
|
|
350
|
+
size: 40
|
|
351
|
+
}
|
|
352
|
+
}, {
|
|
353
|
+
on: {
|
|
354
|
+
click: () => this.handleClick(e)
|
|
355
|
+
}
|
|
356
|
+
}])), this.makeIcons(e, r)])));
|
|
357
|
+
},
|
|
358
|
+
makeImages() {
|
|
359
|
+
return this.makeGroup(this.fileList.map((e, r) => this.makeItem(r, [p("img", {
|
|
360
|
+
attrs: {
|
|
361
|
+
src: this.getSrc(e)
|
|
362
|
+
}
|
|
363
|
+
}), this.makeIcons(e, r)])));
|
|
364
|
+
},
|
|
365
|
+
makeBtn() {
|
|
366
|
+
return p("div", {
|
|
367
|
+
class: "fc-upload-btn",
|
|
368
|
+
on: {
|
|
369
|
+
click: () => this.showModel()
|
|
370
|
+
},
|
|
371
|
+
key: this.key("btn")
|
|
372
|
+
}, [p("icon", _([{}, {
|
|
373
|
+
props: {
|
|
374
|
+
type: this.icon,
|
|
375
|
+
size: 20
|
|
376
|
+
}
|
|
377
|
+
}]))]);
|
|
378
|
+
},
|
|
379
|
+
handleClick(e) {
|
|
380
|
+
return this.onHandle(e);
|
|
381
|
+
},
|
|
382
|
+
handleRemove(e) {
|
|
383
|
+
this.disabled || this.onBeforeRemove(e) !== !1 && (this.fileList.splice(this.fileList.indexOf(e), 1), this.onRemove(e));
|
|
384
|
+
},
|
|
385
|
+
getSrc(e) {
|
|
386
|
+
return this.srcKey ? e[this.srcKey] : e;
|
|
387
|
+
},
|
|
388
|
+
frameLoad(e) {
|
|
389
|
+
this.onLoad(e);
|
|
390
|
+
try {
|
|
391
|
+
this.helper === !0 && (e.form_create_helper = {
|
|
392
|
+
api: this.formCreateInject.api,
|
|
393
|
+
close: (r) => {
|
|
394
|
+
this.valid(r), this.closeModel();
|
|
395
|
+
},
|
|
396
|
+
set: (r, i) => {
|
|
397
|
+
this.valid(r), this.disabled || this.$emit("input", i);
|
|
398
|
+
},
|
|
399
|
+
get: (r) => (this.valid(r), this.value),
|
|
400
|
+
onOk: (r) => this.$on("$ok", r),
|
|
401
|
+
onClose: (r) => this.$on("$close", r)
|
|
402
|
+
});
|
|
403
|
+
} catch (r) {
|
|
404
|
+
console.log(r);
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
makeFooter() {
|
|
408
|
+
const {
|
|
409
|
+
okBtnText: e,
|
|
410
|
+
closeBtnText: r,
|
|
411
|
+
closeBtn: i,
|
|
412
|
+
okBtn: s,
|
|
413
|
+
footer: n
|
|
414
|
+
} = this.$props, o = [];
|
|
415
|
+
return n && (i && o.push(p("Button", {
|
|
416
|
+
on: {
|
|
417
|
+
click: () => this.onCancel() !== !1 && this.closeModel(!0)
|
|
418
|
+
}
|
|
419
|
+
}, [r])), s && o.push(p("Button", {
|
|
420
|
+
attrs: {
|
|
421
|
+
type: "primary"
|
|
422
|
+
},
|
|
423
|
+
on: {
|
|
424
|
+
click: () => this.onOk() !== !1 && this.closeModel()
|
|
425
|
+
}
|
|
426
|
+
}, [e]))), o;
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
render() {
|
|
430
|
+
const e = this.type;
|
|
431
|
+
let r;
|
|
432
|
+
e === "input" ? r = this.makeInput() : e === "image" ? r = this.makeImages() : r = this.makeFiles();
|
|
433
|
+
const {
|
|
434
|
+
width: i,
|
|
435
|
+
height: s,
|
|
436
|
+
src: n,
|
|
437
|
+
title: o,
|
|
438
|
+
modalTitle: a
|
|
439
|
+
} = this.$props;
|
|
440
|
+
return this.$nextTick(() => {
|
|
441
|
+
this.$refs.frame && this.frameLoad(this.$refs.frame.contentWindow || {});
|
|
442
|
+
}), p("div", {
|
|
443
|
+
class: "_fc-frame"
|
|
444
|
+
}, [r, p("Modal", _([{}, {
|
|
445
|
+
props: {
|
|
446
|
+
mask: this.previewMask,
|
|
447
|
+
title: a,
|
|
448
|
+
footerHide: !0
|
|
449
|
+
}
|
|
450
|
+
}, {
|
|
451
|
+
model: {
|
|
452
|
+
value: this.previewVisible,
|
|
453
|
+
callback: (u) => {
|
|
454
|
+
this.previewVisible = u;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}]), [p("img", {
|
|
458
|
+
style: "width: 100%",
|
|
459
|
+
attrs: {
|
|
460
|
+
src: this.previewImage
|
|
461
|
+
}
|
|
462
|
+
})]), p("Modal", _([{}, {
|
|
463
|
+
props: y({
|
|
464
|
+
width: i,
|
|
465
|
+
title: o
|
|
466
|
+
}, this.modal)
|
|
467
|
+
}, {
|
|
468
|
+
on: {
|
|
469
|
+
"on-cancel": () => this.closeModel(!0)
|
|
470
|
+
},
|
|
471
|
+
model: {
|
|
472
|
+
value: this.frameVisible,
|
|
473
|
+
callback: (u) => {
|
|
474
|
+
this.frameVisible = u;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}]), [this.frameVisible || !this.reload ? p("iframe", {
|
|
478
|
+
ref: "frame",
|
|
479
|
+
attrs: {
|
|
480
|
+
src: n,
|
|
481
|
+
frameBorder: "0"
|
|
482
|
+
},
|
|
483
|
+
style: {
|
|
484
|
+
height: s,
|
|
485
|
+
border: "0 none",
|
|
486
|
+
width: "100%"
|
|
487
|
+
}
|
|
488
|
+
}) : null, p("div", {
|
|
489
|
+
slot: "footer"
|
|
490
|
+
}, [this.makeFooter()])])]);
|
|
491
|
+
},
|
|
492
|
+
mounted() {
|
|
493
|
+
this.$on("fc.closeModal", this.closeModal);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
const Ge = xe({
|
|
498
|
+
fileIcon: "md-document",
|
|
499
|
+
fileUpIcon: "ios-folder-open"
|
|
500
|
+
});
|
|
501
|
+
Ge.v2 = xe({
|
|
502
|
+
fileIcon: "document-text",
|
|
503
|
+
fileUpIcon: "folder"
|
|
504
|
+
});
|
|
505
|
+
const Pt = "fcRadio", Dt = {
|
|
506
|
+
name: Pt,
|
|
507
|
+
props: {
|
|
508
|
+
formCreateInject: {
|
|
509
|
+
type: Object,
|
|
510
|
+
required: !0
|
|
511
|
+
},
|
|
512
|
+
value: {}
|
|
513
|
+
},
|
|
514
|
+
watch: {
|
|
515
|
+
"formCreateInject.options": {
|
|
516
|
+
handler() {
|
|
517
|
+
this.update();
|
|
518
|
+
},
|
|
519
|
+
deep: !0
|
|
520
|
+
},
|
|
521
|
+
value() {
|
|
522
|
+
this.update();
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
data() {
|
|
526
|
+
return {
|
|
527
|
+
trueValue: []
|
|
528
|
+
};
|
|
529
|
+
},
|
|
530
|
+
methods: {
|
|
531
|
+
options() {
|
|
532
|
+
const t = this.formCreateInject.options;
|
|
533
|
+
return Array.isArray(t) ? t : [];
|
|
534
|
+
},
|
|
535
|
+
onInput(t) {
|
|
536
|
+
this.$emit("input", this.options().filter((e) => e.label === t).reduce((e, r) => r.value, ""));
|
|
537
|
+
},
|
|
538
|
+
update() {
|
|
539
|
+
this.trueValue = this.options().filter((t) => t.value === this.value).reduce((t, e) => e.label, "");
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
created() {
|
|
543
|
+
this.update();
|
|
544
|
+
},
|
|
545
|
+
render() {
|
|
546
|
+
return p("RadioGroup", _([{}, this.formCreateInject.prop, {}, {
|
|
547
|
+
props: {
|
|
548
|
+
value: this.trueValue
|
|
549
|
+
}
|
|
550
|
+
}, {
|
|
551
|
+
ref: "el",
|
|
552
|
+
on: {
|
|
553
|
+
input: this.onInput
|
|
554
|
+
}
|
|
555
|
+
}]), [this.options().map((t, e) => {
|
|
556
|
+
const r = y({}, t);
|
|
557
|
+
return delete r.value, p("Radio", _([{}, {
|
|
558
|
+
props: r
|
|
559
|
+
}, {
|
|
560
|
+
key: "" + e + "-" + t.value
|
|
561
|
+
}]));
|
|
562
|
+
}), ee(this.$slots)]);
|
|
563
|
+
},
|
|
564
|
+
mounted() {
|
|
565
|
+
this.$emit("fc.el", this.$refs.el);
|
|
566
|
+
}
|
|
567
|
+
}, c = {
|
|
568
|
+
type(t, e) {
|
|
569
|
+
return Object.prototype.toString.call(t) === "[object " + e + "]";
|
|
570
|
+
},
|
|
571
|
+
Undef(t) {
|
|
572
|
+
return t == null;
|
|
573
|
+
},
|
|
574
|
+
Element(t) {
|
|
575
|
+
return typeof t == "object" && t !== null && t.nodeType === 1 && !c.Object(t);
|
|
576
|
+
},
|
|
577
|
+
trueArray(t) {
|
|
578
|
+
return Array.isArray(t) && t.length > 0;
|
|
579
|
+
},
|
|
580
|
+
Function(t) {
|
|
581
|
+
const e = this.getType(t);
|
|
582
|
+
return e === "Function" || e === "AsyncFunction";
|
|
583
|
+
},
|
|
584
|
+
getType(t) {
|
|
585
|
+
const e = Object.prototype.toString.call(t);
|
|
586
|
+
return /^\[object (.*)\]$/.exec(e)[1];
|
|
587
|
+
},
|
|
588
|
+
empty(t) {
|
|
589
|
+
return t == null || Array.isArray(t) && Array.isArray(t) && !t.length ? !0 : typeof t == "string" && !t;
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
["Date", "Object", "String", "Boolean", "Array", "Number"].forEach((t) => {
|
|
593
|
+
c[t] = function(e) {
|
|
594
|
+
return c.type(e, t);
|
|
595
|
+
};
|
|
596
|
+
});
|
|
597
|
+
function w(t, e) {
|
|
598
|
+
return {}.hasOwnProperty.call(t, e);
|
|
599
|
+
}
|
|
600
|
+
const Tt = "fcSelect", Bt = {
|
|
601
|
+
name: Tt,
|
|
602
|
+
functional: !0,
|
|
603
|
+
props: {
|
|
604
|
+
formCreateInject: {
|
|
605
|
+
type: Object,
|
|
606
|
+
required: !0
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
render(t, e) {
|
|
610
|
+
const r = (n, o) => {
|
|
611
|
+
const a = n.slot;
|
|
612
|
+
return t("Option", _([{}, {
|
|
613
|
+
props: n
|
|
614
|
+
}, {
|
|
615
|
+
key: "" + o + "-" + n.value
|
|
616
|
+
}]), [a ? t("template", {
|
|
617
|
+
slot: n.slotName || "default"
|
|
618
|
+
}, [c.Function(a) ? n.slot(t) : a]) : null]);
|
|
619
|
+
}, i = (n, o) => t("OptionGroup", {
|
|
620
|
+
attrs: {
|
|
621
|
+
label: n.label
|
|
622
|
+
},
|
|
623
|
+
key: "" + o + "-" + n.label
|
|
624
|
+
}, [c.trueArray(n.options) && n.options.map((a, u) => r(a, u))]), s = e.props.formCreateInject.options;
|
|
625
|
+
return t("Select", _([{}, e.data, {
|
|
626
|
+
ref: "el"
|
|
627
|
+
}]), [(Array.isArray(s) ? s : []).map((n, o) => w(n || "", "options") ? i(n, o) : r(n, o)), e.children]);
|
|
628
|
+
},
|
|
629
|
+
mounted() {
|
|
630
|
+
this.$emit("fc.el", this.$refs.el);
|
|
631
|
+
}
|
|
632
|
+
}, Lt = "fcTree", Nt = {
|
|
633
|
+
name: Lt,
|
|
634
|
+
props: {
|
|
635
|
+
formCreateInject: {
|
|
636
|
+
type: Object,
|
|
637
|
+
required: !0
|
|
638
|
+
},
|
|
639
|
+
type: {
|
|
640
|
+
type: String,
|
|
641
|
+
default: "checked"
|
|
642
|
+
},
|
|
643
|
+
value: {
|
|
644
|
+
type: [Array, String, Number],
|
|
645
|
+
default: () => []
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
data() {
|
|
649
|
+
return {
|
|
650
|
+
treeData: []
|
|
651
|
+
};
|
|
652
|
+
},
|
|
653
|
+
watch: {
|
|
654
|
+
value(t) {
|
|
655
|
+
this.setStatus(t);
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
created() {
|
|
659
|
+
this.setStatus(this.value);
|
|
660
|
+
},
|
|
661
|
+
methods: {
|
|
662
|
+
setStatus(t) {
|
|
663
|
+
const e = j(t), r = this.formCreateInject.prop.props.data;
|
|
664
|
+
this.type === "selected" ? this.checked(r, e, "selected") : this.checked(r, e, "checked"), this.$forceUpdate();
|
|
665
|
+
},
|
|
666
|
+
checked(t, e, r) {
|
|
667
|
+
t.forEach((i) => {
|
|
668
|
+
this.$set(i, r, e.indexOf(i.id) !== -1), i.children !== void 0 && Array.isArray(i.children) && this.checked(i.children, e, r);
|
|
669
|
+
});
|
|
670
|
+
},
|
|
671
|
+
onInput(t) {
|
|
672
|
+
this.$emit("input", t.map((e) => e.id));
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
render() {
|
|
676
|
+
const t = {};
|
|
677
|
+
return this.type === "selected" ? t["on-select-change"] = this.onInput : t["on-check-change"] = this.onInput, p("Tree", _([{}, this.formCreateInject.prop, {
|
|
678
|
+
ref: "tree"
|
|
679
|
+
}, {
|
|
680
|
+
on: t
|
|
681
|
+
}]), [ee(this.$slots)]);
|
|
682
|
+
},
|
|
683
|
+
mounted() {
|
|
684
|
+
this.$emit("fc.el", this.$refs.tree);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
function Re(t) {
|
|
688
|
+
return {
|
|
689
|
+
url: t,
|
|
690
|
+
name: Mt(t)
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
function Mt(t) {
|
|
694
|
+
return ("" + t).split("/").pop();
|
|
695
|
+
}
|
|
696
|
+
const Ut = "fcUpload";
|
|
697
|
+
function Ke(t) {
|
|
698
|
+
return {
|
|
699
|
+
name: Ut,
|
|
700
|
+
props: {
|
|
701
|
+
formCreateInject: {
|
|
702
|
+
type: Object,
|
|
703
|
+
required: !0
|
|
704
|
+
},
|
|
705
|
+
onHandle: {
|
|
706
|
+
type: Function,
|
|
707
|
+
default(e) {
|
|
708
|
+
this.previewImage = e.url, this.previewVisible = !0;
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
uploadType: {
|
|
712
|
+
type: String,
|
|
713
|
+
default: "file"
|
|
714
|
+
},
|
|
715
|
+
maxLength: {
|
|
716
|
+
type: Number,
|
|
717
|
+
default: 0
|
|
718
|
+
},
|
|
719
|
+
allowRemove: {
|
|
720
|
+
type: Boolean,
|
|
721
|
+
default: !0
|
|
722
|
+
},
|
|
723
|
+
modalTitle: String,
|
|
724
|
+
handleIcon: {
|
|
725
|
+
type: [String, Boolean],
|
|
726
|
+
default: () => {
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
value: [Array, String]
|
|
730
|
+
},
|
|
731
|
+
data() {
|
|
732
|
+
return {
|
|
733
|
+
uploadList: [],
|
|
734
|
+
previewVisible: !1,
|
|
735
|
+
previewImage: "",
|
|
736
|
+
cacheFiles: []
|
|
737
|
+
};
|
|
738
|
+
},
|
|
739
|
+
created() {
|
|
740
|
+
this.formCreateInject.prop.props.showUploadList === void 0 && (this.formCreateInject.prop.props.showUploadList = !1), this.formCreateInject.prop.props.defaultFileList = j(this.value).map(Re);
|
|
741
|
+
},
|
|
742
|
+
watch: {
|
|
743
|
+
value(e) {
|
|
744
|
+
this.$refs.upload.fileList.every((r) => !r.status || r.status === "finished") && (this.$refs.upload.fileList = j(e).map(Re), this.uploadList = this.$refs.upload.fileList);
|
|
745
|
+
},
|
|
746
|
+
maxLength(e, r) {
|
|
747
|
+
(r === 1 || e === 1) && this.update();
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
methods: {
|
|
751
|
+
key(e) {
|
|
752
|
+
return e;
|
|
753
|
+
},
|
|
754
|
+
isDisabled() {
|
|
755
|
+
return this.formCreateInject.prop.props.disabled === !0;
|
|
756
|
+
},
|
|
757
|
+
onRemove(e) {
|
|
758
|
+
this.isDisabled() || this.$refs.upload.handleRemove(e);
|
|
759
|
+
},
|
|
760
|
+
handleClick(e) {
|
|
761
|
+
this.onHandle(e);
|
|
762
|
+
},
|
|
763
|
+
makeItem(e, r) {
|
|
764
|
+
return this.uploadType === "image" ? p("img", {
|
|
765
|
+
attrs: {
|
|
766
|
+
src: e.url
|
|
767
|
+
},
|
|
768
|
+
key: this.key("img" + r)
|
|
769
|
+
}) : p("icon", _([{}, {
|
|
770
|
+
props: {
|
|
771
|
+
type: t.fileIcon,
|
|
772
|
+
size: 40
|
|
773
|
+
}
|
|
774
|
+
}, {
|
|
775
|
+
key: this.key("i" + r)
|
|
776
|
+
}]));
|
|
777
|
+
},
|
|
778
|
+
makeRemoveIcon(e, r) {
|
|
779
|
+
return p("icon", {
|
|
780
|
+
attrs: {
|
|
781
|
+
type: "ios-trash-outline"
|
|
782
|
+
},
|
|
783
|
+
on: {
|
|
784
|
+
click: () => this.onRemove(e)
|
|
785
|
+
},
|
|
786
|
+
key: this.key("ri" + r)
|
|
787
|
+
});
|
|
788
|
+
},
|
|
789
|
+
makeHandleIcon(e, r) {
|
|
790
|
+
return p("icon", {
|
|
791
|
+
attrs: {
|
|
792
|
+
type: this.handleIcon === !0 || this.handleIcon === void 0 ? "ios-eye-outline" : this.handleIcon
|
|
793
|
+
},
|
|
794
|
+
on: {
|
|
795
|
+
click: () => this.handleClick(e)
|
|
796
|
+
},
|
|
797
|
+
key: this.key("hi" + r)
|
|
798
|
+
});
|
|
799
|
+
},
|
|
800
|
+
makeProgress(e, r) {
|
|
801
|
+
return p("Progress", _([{}, {
|
|
802
|
+
props: {
|
|
803
|
+
percent: e.percentage,
|
|
804
|
+
hideInfo: !0
|
|
805
|
+
}
|
|
806
|
+
}, {
|
|
807
|
+
style: "width:90%",
|
|
808
|
+
key: this.key("pg" + r)
|
|
809
|
+
}]));
|
|
810
|
+
},
|
|
811
|
+
makeIcons(e, r) {
|
|
812
|
+
const i = [];
|
|
813
|
+
if (this.allowRemove || this.handleIcon !== !1)
|
|
814
|
+
return (this.uploadType !== "file" && this.handleIcon !== !1 || this.uploadType === "file" && this.handleIcon) && i.push(this.makeHandleIcon(e, r)), this.allowRemove && i.push(this.makeRemoveIcon(e, r)), p("div", {
|
|
815
|
+
class: "fc-upload-cover"
|
|
816
|
+
}, [i]);
|
|
817
|
+
},
|
|
818
|
+
makeFiles() {
|
|
819
|
+
return this.uploadList.map((e, r) => this.$scopedSlots.fileList ? this.$scopedSlots.fileList({
|
|
820
|
+
file: e,
|
|
821
|
+
index: r,
|
|
822
|
+
vm: this
|
|
823
|
+
}) : p("div", {
|
|
824
|
+
key: this.key(r),
|
|
825
|
+
class: "fc-files"
|
|
826
|
+
}, [e.showProgress ? this.makeProgress(e, r) : [this.makeItem(e, r), this.makeIcons(e, r)]]));
|
|
827
|
+
},
|
|
828
|
+
makeUpload() {
|
|
829
|
+
const e = !this.maxLength || this.maxLength > this.uploadList.length;
|
|
830
|
+
return p("Upload", _([{}, this.formCreateInject.prop, {}, {
|
|
831
|
+
style: {
|
|
832
|
+
display: "inline-block"
|
|
833
|
+
},
|
|
834
|
+
key: this.key("upload"),
|
|
835
|
+
ref: "upload"
|
|
836
|
+
}]), [e ? p("template", {
|
|
837
|
+
slot: "default"
|
|
838
|
+
}, [this.$slots.default || p("div", {
|
|
839
|
+
class: "fc-upload-btn"
|
|
840
|
+
}, [p("icon", _([{}, {
|
|
841
|
+
props: {
|
|
842
|
+
type: this.uploadType === "file" ? "ios-cloud-upload-outline" : t.imgUpIcon,
|
|
843
|
+
size: 20
|
|
844
|
+
}
|
|
845
|
+
}]))])]) : null, ee(this.$slots, ["default"])]);
|
|
846
|
+
},
|
|
847
|
+
update() {
|
|
848
|
+
let e = this.$refs.upload.fileList.map((r) => r.url).filter((r) => r !== void 0);
|
|
849
|
+
(this.cacheFiles.length !== e.length || !e.length) && (this.cacheFiles = [...e], this.$emit("input", this.maxLength === 1 ? e[0] || "" : e));
|
|
850
|
+
},
|
|
851
|
+
handleCancel() {
|
|
852
|
+
this.previewVisible = !1;
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
render() {
|
|
856
|
+
return this.$refs.upload && (this.formCreateInject.prop.props.showUploadList === void 0 && (this.formCreateInject.prop.props.showUploadList = this.$refs.upload.showUploadList), this.formCreateInject.prop.props.defaultFileList = this.$refs.upload.defaultFileList), p("div", {
|
|
857
|
+
class: "_fc-upload"
|
|
858
|
+
}, [[this.formCreateInject.prop.props.showUploadList ? [] : this.makeFiles(), this.makeUpload()], p("Modal", _([{}, {
|
|
859
|
+
props: {
|
|
860
|
+
title: this.modalTitle,
|
|
861
|
+
footerHide: !0
|
|
862
|
+
}
|
|
863
|
+
}, {
|
|
864
|
+
model: {
|
|
865
|
+
value: this.previewVisible,
|
|
866
|
+
callback: (e) => {
|
|
867
|
+
this.previewVisible = e;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}]), [p("img", {
|
|
871
|
+
attrs: {
|
|
872
|
+
alt: "example",
|
|
873
|
+
src: this.previewImage
|
|
874
|
+
},
|
|
875
|
+
style: "width: 100%"
|
|
876
|
+
})])]);
|
|
877
|
+
},
|
|
878
|
+
mounted() {
|
|
879
|
+
this.uploadList = this.$refs.upload.fileList, this.$watch(() => this.$refs.upload.fileList, () => {
|
|
880
|
+
this.update();
|
|
881
|
+
}, {
|
|
882
|
+
deep: !0
|
|
883
|
+
}), this.$emit("fc.el", this.$refs.upload);
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
const Xe = Ke({
|
|
888
|
+
fileIcon: "md-document",
|
|
889
|
+
imgUpIcon: "md-images"
|
|
890
|
+
});
|
|
891
|
+
Xe.v2 = Ke({
|
|
892
|
+
fileIcon: "document-text",
|
|
893
|
+
imgUpIcon: "image"
|
|
894
|
+
});
|
|
895
|
+
function F(t, e, r) {
|
|
896
|
+
Y.set(t, e, r);
|
|
897
|
+
}
|
|
898
|
+
function L(t, e) {
|
|
899
|
+
Y.delete(t, e);
|
|
900
|
+
}
|
|
901
|
+
function x(t, e = {}, r) {
|
|
902
|
+
let i = !1;
|
|
903
|
+
for (let s in e)
|
|
904
|
+
if (Object.prototype.hasOwnProperty.call(e, s)) {
|
|
905
|
+
let n = e[s];
|
|
906
|
+
if ((i = Array.isArray(n)) || c.Object(n)) {
|
|
907
|
+
let o = t[s] === void 0;
|
|
908
|
+
if (i)
|
|
909
|
+
i = !1, o && F(t, s, []);
|
|
910
|
+
else if (n._clone && r !== void 0)
|
|
911
|
+
if (r)
|
|
912
|
+
n = n.getRule(), o && F(t, s, {});
|
|
913
|
+
else {
|
|
914
|
+
F(t, s, n._clone());
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
else
|
|
918
|
+
o && F(t, s, {});
|
|
919
|
+
t[s] = x(t[s], n, r);
|
|
920
|
+
} else
|
|
921
|
+
F(t, s, n), c.Undef(n) || (c.Undef(n.__json) || (t[s].__json = n.__json), c.Undef(n.__origin) || (t[s].__origin = n.__origin));
|
|
922
|
+
}
|
|
923
|
+
return r !== void 0 && Array.isArray(t) ? t.filter((s) => !s || !s.__ctrl) : t;
|
|
924
|
+
}
|
|
925
|
+
function N(t) {
|
|
926
|
+
return x({}, { value: t }).value;
|
|
927
|
+
}
|
|
928
|
+
const qt = Object.assign || function(t) {
|
|
929
|
+
for (let e, r = 1; r < arguments.length; r++)
|
|
930
|
+
for (let i in e = arguments[r], e)
|
|
931
|
+
Object.prototype.hasOwnProperty.call(e, i) && F(t, i, e[i]);
|
|
932
|
+
return t;
|
|
933
|
+
};
|
|
934
|
+
function m() {
|
|
935
|
+
return qt.apply(this, arguments);
|
|
936
|
+
}
|
|
937
|
+
const Ht = "fcGroup", Jt = {
|
|
938
|
+
name: Ht,
|
|
939
|
+
props: {
|
|
940
|
+
field: String,
|
|
941
|
+
rule: [Array, Object],
|
|
942
|
+
rules: Array,
|
|
943
|
+
expand: Number,
|
|
944
|
+
options: Object,
|
|
945
|
+
formCreateInject: {
|
|
946
|
+
type: Object,
|
|
947
|
+
required: !0
|
|
948
|
+
},
|
|
949
|
+
button: {
|
|
950
|
+
type: Boolean,
|
|
951
|
+
default: !0
|
|
952
|
+
},
|
|
953
|
+
max: {
|
|
954
|
+
type: Number,
|
|
955
|
+
default: 0
|
|
956
|
+
},
|
|
957
|
+
min: {
|
|
958
|
+
type: Number,
|
|
959
|
+
default: 0
|
|
960
|
+
},
|
|
961
|
+
value: {
|
|
962
|
+
type: Array,
|
|
963
|
+
default: () => []
|
|
964
|
+
},
|
|
965
|
+
sortBtn: {
|
|
966
|
+
type: Boolean,
|
|
967
|
+
default: !0
|
|
968
|
+
},
|
|
969
|
+
defaultValue: Object,
|
|
970
|
+
disabled: {
|
|
971
|
+
type: Boolean,
|
|
972
|
+
default: !1
|
|
973
|
+
},
|
|
974
|
+
syncDisabled: {
|
|
975
|
+
type: Boolean,
|
|
976
|
+
default: !0
|
|
977
|
+
},
|
|
978
|
+
onBeforeRemove: {
|
|
979
|
+
type: Function,
|
|
980
|
+
default: () => {
|
|
981
|
+
}
|
|
982
|
+
},
|
|
983
|
+
onBeforeAdd: {
|
|
984
|
+
type: Function,
|
|
985
|
+
default: () => {
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
parse: Function
|
|
989
|
+
},
|
|
990
|
+
data() {
|
|
991
|
+
return {
|
|
992
|
+
len: 0,
|
|
993
|
+
cacheRule: {},
|
|
994
|
+
cacheValue: {},
|
|
995
|
+
sort: [],
|
|
996
|
+
type: void 0
|
|
997
|
+
};
|
|
998
|
+
},
|
|
999
|
+
computed: {
|
|
1000
|
+
formRule() {
|
|
1001
|
+
return this.rules ? this.rules : this.rule ? Array.isArray(this.rule) ? this.rule : [this.rule] : [];
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
watch: {
|
|
1005
|
+
cacheRule: {
|
|
1006
|
+
handler(t) {
|
|
1007
|
+
this.sort = Object.keys(t);
|
|
1008
|
+
},
|
|
1009
|
+
immediate: !0
|
|
1010
|
+
},
|
|
1011
|
+
formRule: {
|
|
1012
|
+
handler(t, e) {
|
|
1013
|
+
Object.keys(this.cacheRule).forEach((r) => {
|
|
1014
|
+
const i = this.cacheRule[r];
|
|
1015
|
+
if (i.$f) {
|
|
1016
|
+
const s = i.$f.formData();
|
|
1017
|
+
if (t === e)
|
|
1018
|
+
i.$f.deferSyncValue(() => {
|
|
1019
|
+
x(i.rule, t), i.$f.setValue(s);
|
|
1020
|
+
}, !0);
|
|
1021
|
+
else {
|
|
1022
|
+
const n = i.$f.formData();
|
|
1023
|
+
i.$f.once("reloading", () => {
|
|
1024
|
+
i.$f.setValue(n);
|
|
1025
|
+
}), i.rule = N(t);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
},
|
|
1030
|
+
deep: !0
|
|
1031
|
+
},
|
|
1032
|
+
expand(t) {
|
|
1033
|
+
let e = t - this.value.length;
|
|
1034
|
+
e > 0 && this.expandRule(e);
|
|
1035
|
+
},
|
|
1036
|
+
value(t, e) {
|
|
1037
|
+
t = t || [];
|
|
1038
|
+
let r = this.sort, i = r.length, s = i - t.length;
|
|
1039
|
+
if (s < 0) {
|
|
1040
|
+
for (let n = s; n < 0; n++)
|
|
1041
|
+
this.addRule(t.length + n);
|
|
1042
|
+
this.sort = Object.keys(this.cacheRule);
|
|
1043
|
+
for (let n = 0; n < i; n++)
|
|
1044
|
+
this.setValue(r[n], t[n]);
|
|
1045
|
+
} else {
|
|
1046
|
+
if (s > 0)
|
|
1047
|
+
for (let n = 0; n < s; n++)
|
|
1048
|
+
this.removeRule(r[i - n - 1]);
|
|
1049
|
+
this.sort = Object.keys(this.cacheRule), t.forEach((n, o) => {
|
|
1050
|
+
this.setValue(r[o], t[o]);
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
},
|
|
1055
|
+
methods: {
|
|
1056
|
+
_value(t) {
|
|
1057
|
+
return t && w(t, this.field) ? t[this.field] : t;
|
|
1058
|
+
},
|
|
1059
|
+
cache(t, e) {
|
|
1060
|
+
this.cacheValue[t] = JSON.stringify(e);
|
|
1061
|
+
},
|
|
1062
|
+
input(t) {
|
|
1063
|
+
this.$emit("input", t), this.$emit("change", t);
|
|
1064
|
+
},
|
|
1065
|
+
formData(t, e) {
|
|
1066
|
+
const r = this.cacheRule, i = this.sort;
|
|
1067
|
+
if (i.filter((n) => r[n].$f).length !== i.length)
|
|
1068
|
+
return;
|
|
1069
|
+
const s = i.map((n) => {
|
|
1070
|
+
const o = t === n ? e : y({}, this.cacheRule[n].$f.form), a = this.field ? o[this.field] || null : o;
|
|
1071
|
+
return this.cache(n, a), a;
|
|
1072
|
+
});
|
|
1073
|
+
this.input(s);
|
|
1074
|
+
},
|
|
1075
|
+
setValue(t, e) {
|
|
1076
|
+
const r = this.field, i = this.cacheRule[t].$f;
|
|
1077
|
+
r && (e = {
|
|
1078
|
+
[r]: this._value(e)
|
|
1079
|
+
}), this.cacheValue[t] !== JSON.stringify(r ? e[r] : e) && (this.cache(t, e), i && i.coverValue(e || {}));
|
|
1080
|
+
},
|
|
1081
|
+
addRule(t, e) {
|
|
1082
|
+
const r = this.formCreateInject.form.copyRules(this.formRule), i = this.options ? y({}, this.options) : {
|
|
1083
|
+
submitBtn: !1,
|
|
1084
|
+
resetBtn: !1
|
|
1085
|
+
};
|
|
1086
|
+
if (this.defaultValue) {
|
|
1087
|
+
i.formData || (i.formData = {});
|
|
1088
|
+
const s = N(this.defaultValue);
|
|
1089
|
+
m(i.formData, this.field ? {
|
|
1090
|
+
[this.field]: s
|
|
1091
|
+
} : s);
|
|
1092
|
+
}
|
|
1093
|
+
this.parse && this.parse({
|
|
1094
|
+
rule: r,
|
|
1095
|
+
options: i,
|
|
1096
|
+
index: this.sort.length
|
|
1097
|
+
}), this.$set(this.cacheRule, ++this.len, {
|
|
1098
|
+
rule: r,
|
|
1099
|
+
options: i
|
|
1100
|
+
}), e && this.$nextTick(() => this.$emit("add", r, Object.keys(this.cacheRule).length - 1));
|
|
1101
|
+
},
|
|
1102
|
+
add$f(t, e, r) {
|
|
1103
|
+
this.cacheRule[e].$f = r, this.$nextTick(() => {
|
|
1104
|
+
this.$emit("itemMounted", r, Object.keys(this.cacheRule).indexOf(e));
|
|
1105
|
+
});
|
|
1106
|
+
},
|
|
1107
|
+
removeRule(t, e) {
|
|
1108
|
+
const r = Object.keys(this.cacheRule).indexOf(t);
|
|
1109
|
+
this.$delete(this.cacheRule, t), this.$delete(this.cacheValue, t), e && this.$nextTick(() => this.$emit("remove", r));
|
|
1110
|
+
},
|
|
1111
|
+
add(t) {
|
|
1112
|
+
this.disabled || this.onBeforeAdd(this.value) === !1 || this.addRule(t, !0);
|
|
1113
|
+
},
|
|
1114
|
+
del(t, e) {
|
|
1115
|
+
if (this.disabled || this.onBeforeRemove(this.value, t) === !1)
|
|
1116
|
+
return;
|
|
1117
|
+
this.removeRule(e, !0);
|
|
1118
|
+
const r = [...this.value];
|
|
1119
|
+
r.splice(t, 1), this.input(r);
|
|
1120
|
+
},
|
|
1121
|
+
addIcon(t) {
|
|
1122
|
+
return p("div", {
|
|
1123
|
+
class: "_fc-group-btn _fc-group-plus-minus",
|
|
1124
|
+
on: {
|
|
1125
|
+
click: this.add
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
},
|
|
1129
|
+
delIcon(t, e) {
|
|
1130
|
+
return p("div", {
|
|
1131
|
+
class: "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
|
|
1132
|
+
on: {
|
|
1133
|
+
click: () => this.del(t, e)
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
},
|
|
1137
|
+
sortUpIcon(t) {
|
|
1138
|
+
return p("div", {
|
|
1139
|
+
class: "_fc-group-btn _fc-group-arrow _fc-group-up",
|
|
1140
|
+
on: {
|
|
1141
|
+
click: () => this.changeSort(t, -1)
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
},
|
|
1145
|
+
sortDownIcon(t) {
|
|
1146
|
+
return p("div", {
|
|
1147
|
+
class: "_fc-group-btn _fc-group-arrow _fc-group-down",
|
|
1148
|
+
on: {
|
|
1149
|
+
click: () => this.changeSort(t, 1)
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
},
|
|
1153
|
+
changeSort(t, e) {
|
|
1154
|
+
const r = this.sort[t];
|
|
1155
|
+
this.$set(this.sort, t, this.sort[t + e]), this.sort[t + e] = r, this.formData(0);
|
|
1156
|
+
},
|
|
1157
|
+
makeIcon(t, e, r) {
|
|
1158
|
+
if (this.$scopedSlots.button)
|
|
1159
|
+
return this.$scopedSlots.button({
|
|
1160
|
+
total: t,
|
|
1161
|
+
index: e,
|
|
1162
|
+
vm: this,
|
|
1163
|
+
key: r,
|
|
1164
|
+
del: () => this.del(e, r),
|
|
1165
|
+
add: this.add
|
|
1166
|
+
});
|
|
1167
|
+
const i = [];
|
|
1168
|
+
return (!this.max || t < this.max) && t === e + 1 && i.push(this.addIcon(r)), t > this.min && i.push(this.delIcon(e, r)), this.sortBtn && e && i.push(this.sortUpIcon(e)), this.sortBtn && e !== t - 1 && i.push(this.sortDownIcon(e)), i;
|
|
1169
|
+
},
|
|
1170
|
+
emitEvent(t, e, r, i) {
|
|
1171
|
+
this.$emit(t, ...e, this.cacheRule[i].$f, r);
|
|
1172
|
+
},
|
|
1173
|
+
expandRule(t) {
|
|
1174
|
+
for (let e = 0; e < t; e++)
|
|
1175
|
+
this.value.push(this.field ? null : {});
|
|
1176
|
+
}
|
|
1177
|
+
},
|
|
1178
|
+
created() {
|
|
1179
|
+
this.type = this.formCreateInject.form.$form();
|
|
1180
|
+
const t = (this.expand || 0) - this.value.length;
|
|
1181
|
+
t > 0 && this.expandRule(t);
|
|
1182
|
+
for (let e = 0; e < this.value.length; e++)
|
|
1183
|
+
this.addRule(e);
|
|
1184
|
+
},
|
|
1185
|
+
render() {
|
|
1186
|
+
const t = this.sort, e = this.button, r = this.type, i = this.disabled, s = t.length === 0 ? this.$scopedSlots.default ? this.$scopedSlots.default({
|
|
1187
|
+
vm: this,
|
|
1188
|
+
add: this.add
|
|
1189
|
+
}) : p("div", {
|
|
1190
|
+
key: "a_def",
|
|
1191
|
+
class: "_fc-group-plus-minus _fc-group-add",
|
|
1192
|
+
on: {
|
|
1193
|
+
click: this.add
|
|
1194
|
+
}
|
|
1195
|
+
}) : t.map((n, o) => {
|
|
1196
|
+
const {
|
|
1197
|
+
rule: a,
|
|
1198
|
+
options: u
|
|
1199
|
+
} = this.cacheRule[n], l = e && !i ? this.makeIcon(t.length, o, n) : [];
|
|
1200
|
+
return p("div", {
|
|
1201
|
+
class: "_fc-group-container",
|
|
1202
|
+
key: n
|
|
1203
|
+
}, [p(r, _([{
|
|
1204
|
+
key: n
|
|
1205
|
+
}, {
|
|
1206
|
+
on: {
|
|
1207
|
+
"update:value": (h) => this.formData(n, h),
|
|
1208
|
+
"emit-event": (h, ...g) => this.emitEvent(h, g, o, n),
|
|
1209
|
+
input: (h) => this.add$f(o, n, h)
|
|
1210
|
+
}
|
|
1211
|
+
}, {}, {
|
|
1212
|
+
props: {
|
|
1213
|
+
disabled: i,
|
|
1214
|
+
inFor: !0,
|
|
1215
|
+
value: this.field ? {
|
|
1216
|
+
[this.field]: this._value(this.value[o])
|
|
1217
|
+
} : this.value[o],
|
|
1218
|
+
rule: a,
|
|
1219
|
+
option: u,
|
|
1220
|
+
extendOption: !0
|
|
1221
|
+
}
|
|
1222
|
+
}])), p("div", {
|
|
1223
|
+
class: "_fc-group-idx"
|
|
1224
|
+
}, [o + 1]), l.length ? p("div", {
|
|
1225
|
+
class: "_fc-group-handle"
|
|
1226
|
+
}, [l]) : null]);
|
|
1227
|
+
});
|
|
1228
|
+
return p("div", {
|
|
1229
|
+
key: "con",
|
|
1230
|
+
class: "_fc-group " + (i ? "_fc-group-disabled" : "")
|
|
1231
|
+
}, [s]);
|
|
1232
|
+
}
|
|
1233
|
+
}, zt = "fcSubForm", Wt = {
|
|
1234
|
+
name: zt,
|
|
1235
|
+
props: {
|
|
1236
|
+
rule: Array,
|
|
1237
|
+
options: Object,
|
|
1238
|
+
formCreateInject: {
|
|
1239
|
+
type: Object,
|
|
1240
|
+
required: !0
|
|
1241
|
+
},
|
|
1242
|
+
value: {
|
|
1243
|
+
type: Object,
|
|
1244
|
+
default: () => ({})
|
|
1245
|
+
},
|
|
1246
|
+
disabled: {
|
|
1247
|
+
type: Boolean,
|
|
1248
|
+
default: !1
|
|
1249
|
+
},
|
|
1250
|
+
syncDisabled: {
|
|
1251
|
+
type: Boolean,
|
|
1252
|
+
default: !0
|
|
1253
|
+
}
|
|
1254
|
+
},
|
|
1255
|
+
data() {
|
|
1256
|
+
return {
|
|
1257
|
+
cacheRule: {},
|
|
1258
|
+
cacheValue: {},
|
|
1259
|
+
type: void 0
|
|
1260
|
+
};
|
|
1261
|
+
},
|
|
1262
|
+
watch: {
|
|
1263
|
+
value(t) {
|
|
1264
|
+
this.setValue(t);
|
|
1265
|
+
}
|
|
1266
|
+
},
|
|
1267
|
+
methods: {
|
|
1268
|
+
formData(t) {
|
|
1269
|
+
this.cacheValue = JSON.stringify(t), this.$emit("input", t), this.$emit("change", t);
|
|
1270
|
+
},
|
|
1271
|
+
setValue(t) {
|
|
1272
|
+
const e = JSON.stringify(t);
|
|
1273
|
+
this.cacheValue !== e && (this.cacheValue = e, this.cacheRule.$f.coverValue(t || {}));
|
|
1274
|
+
},
|
|
1275
|
+
addRule() {
|
|
1276
|
+
const t = this.options ? this.options : {
|
|
1277
|
+
submitBtn: !1,
|
|
1278
|
+
resetBtn: !1
|
|
1279
|
+
};
|
|
1280
|
+
t.formData = y({}, this.value || {}), this.cacheRule = {
|
|
1281
|
+
rule: this.rule,
|
|
1282
|
+
options: t
|
|
1283
|
+
};
|
|
1284
|
+
},
|
|
1285
|
+
add$f(t) {
|
|
1286
|
+
this.cacheRule.$f = t, this.$nextTick(() => {
|
|
1287
|
+
this.$emit("itemMounted", t);
|
|
1288
|
+
});
|
|
1289
|
+
},
|
|
1290
|
+
emitEvent(t, ...e) {
|
|
1291
|
+
this.$emit(t, ...e);
|
|
1292
|
+
}
|
|
1293
|
+
},
|
|
1294
|
+
created() {
|
|
1295
|
+
this.addRule(), this.type = this.formCreateInject.form.$form();
|
|
1296
|
+
},
|
|
1297
|
+
render() {
|
|
1298
|
+
const {
|
|
1299
|
+
rule: t,
|
|
1300
|
+
options: e
|
|
1301
|
+
} = this.cacheRule, r = this.type;
|
|
1302
|
+
return p(r, _([{}, {
|
|
1303
|
+
on: {
|
|
1304
|
+
"update:value": this.formData,
|
|
1305
|
+
"emit-event": this.emitEvent,
|
|
1306
|
+
input: this.add$f
|
|
1307
|
+
}
|
|
1308
|
+
}, {}, {
|
|
1309
|
+
props: {
|
|
1310
|
+
rule: t,
|
|
1311
|
+
option: e,
|
|
1312
|
+
disabled: this.disabled,
|
|
1313
|
+
extendOption: !0
|
|
1314
|
+
}
|
|
1315
|
+
}]));
|
|
1316
|
+
}
|
|
1317
|
+
}, xt = [
|
|
1318
|
+
At,
|
|
1319
|
+
Dt,
|
|
1320
|
+
Bt,
|
|
1321
|
+
Nt,
|
|
1322
|
+
Wt,
|
|
1323
|
+
Ge,
|
|
1324
|
+
Xe,
|
|
1325
|
+
Jt
|
|
1326
|
+
], Ee = "FormCreate", ue = (t, e) => {
|
|
1327
|
+
if (!(!t || t === e)) {
|
|
1328
|
+
if (t.formCreateInject)
|
|
1329
|
+
return t.formCreateInject;
|
|
1330
|
+
if (t.$parent)
|
|
1331
|
+
return ue(t.$parent, e);
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
function Gt(t) {
|
|
1335
|
+
return {
|
|
1336
|
+
name: Ee,
|
|
1337
|
+
componentName: Ee,
|
|
1338
|
+
model: {
|
|
1339
|
+
prop: "api"
|
|
1340
|
+
},
|
|
1341
|
+
provide() {
|
|
1342
|
+
return {
|
|
1343
|
+
$pfc: this
|
|
1344
|
+
};
|
|
1345
|
+
},
|
|
1346
|
+
inject: { $pfc: { default: null } },
|
|
1347
|
+
props: {
|
|
1348
|
+
rule: {
|
|
1349
|
+
type: Array,
|
|
1350
|
+
required: !0
|
|
1351
|
+
},
|
|
1352
|
+
option: {
|
|
1353
|
+
type: Object,
|
|
1354
|
+
default: () => ({})
|
|
1355
|
+
},
|
|
1356
|
+
extendOption: Boolean,
|
|
1357
|
+
disabled: {
|
|
1358
|
+
type: Boolean,
|
|
1359
|
+
default: void 0
|
|
1360
|
+
},
|
|
1361
|
+
value: Object,
|
|
1362
|
+
api: Object,
|
|
1363
|
+
name: String,
|
|
1364
|
+
subForm: {
|
|
1365
|
+
type: Boolean,
|
|
1366
|
+
default: !0
|
|
1367
|
+
},
|
|
1368
|
+
inFor: Boolean
|
|
1369
|
+
},
|
|
1370
|
+
data() {
|
|
1371
|
+
return {
|
|
1372
|
+
formData: void 0,
|
|
1373
|
+
destroyed: !1,
|
|
1374
|
+
validate: {},
|
|
1375
|
+
$f: void 0,
|
|
1376
|
+
isShow: !0,
|
|
1377
|
+
unique: 1,
|
|
1378
|
+
renderRule: [...this.rule || []],
|
|
1379
|
+
ctxInject: {},
|
|
1380
|
+
updateValue: JSON.stringify(this.value || {}),
|
|
1381
|
+
isMore: !!this.inFor
|
|
1382
|
+
};
|
|
1383
|
+
},
|
|
1384
|
+
render() {
|
|
1385
|
+
return this.formCreate.render();
|
|
1386
|
+
},
|
|
1387
|
+
methods: {
|
|
1388
|
+
_refresh() {
|
|
1389
|
+
++this.unique;
|
|
1390
|
+
},
|
|
1391
|
+
_renderRule() {
|
|
1392
|
+
this.renderRule = [...this.rule || []];
|
|
1393
|
+
},
|
|
1394
|
+
_updateValue(e) {
|
|
1395
|
+
this.destroyed || (this.updateValue = JSON.stringify(e), this.$emit("update:value", e));
|
|
1396
|
+
}
|
|
1397
|
+
},
|
|
1398
|
+
watch: {
|
|
1399
|
+
value: {
|
|
1400
|
+
handler(e) {
|
|
1401
|
+
JSON.stringify(e || {}) !== this.updateValue && (this.$f.config.forceCoverValue ? this.$f.coverValue(e || {}) : this.$f.setValue(e || {}));
|
|
1402
|
+
},
|
|
1403
|
+
deep: !0
|
|
1404
|
+
},
|
|
1405
|
+
option: {
|
|
1406
|
+
handler() {
|
|
1407
|
+
this.formCreate.initOptions(), this.$f.refresh();
|
|
1408
|
+
},
|
|
1409
|
+
deep: !0
|
|
1410
|
+
},
|
|
1411
|
+
rule(e) {
|
|
1412
|
+
e.length === this.renderRule.length && e.every((r) => this.renderRule.indexOf(r) > -1) || (this.formCreate.$handle.reloadRule(e), this._renderRule());
|
|
1413
|
+
},
|
|
1414
|
+
disabled() {
|
|
1415
|
+
this.$f.refresh();
|
|
1416
|
+
}
|
|
1417
|
+
},
|
|
1418
|
+
beforeCreate() {
|
|
1419
|
+
this.formCreate = new t(this), Object.keys(this.formCreate.prop).forEach((e) => {
|
|
1420
|
+
m(this.$options[e], this.formCreate.prop[e]);
|
|
1421
|
+
}), this.$emit("beforeCreate", this.formCreate.api());
|
|
1422
|
+
},
|
|
1423
|
+
created() {
|
|
1424
|
+
const e = this, r = this.formCreate.api(), i = () => {
|
|
1425
|
+
if (e.$pfc) {
|
|
1426
|
+
const n = ue(e, e.$pfc);
|
|
1427
|
+
if (n) {
|
|
1428
|
+
let o;
|
|
1429
|
+
e.isMore ? (o = j(n.getSubForm()), o.push(r)) : o = r, n.subForm(o);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}, s = () => {
|
|
1433
|
+
const n = ue(e, e.$pfc);
|
|
1434
|
+
if (n)
|
|
1435
|
+
if (e.isMore) {
|
|
1436
|
+
const o = j(n.getSubForm()), a = o.indexOf(r);
|
|
1437
|
+
a > -1 && o.splice(a, 1);
|
|
1438
|
+
} else
|
|
1439
|
+
n.subForm();
|
|
1440
|
+
};
|
|
1441
|
+
e.$on("hook:beforeDestroy", () => {
|
|
1442
|
+
s();
|
|
1443
|
+
}), this.$watch(() => this.subForm, (n) => {
|
|
1444
|
+
n ? i() : s();
|
|
1445
|
+
}, { immediate: !0 });
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
const Qe = ["attrs", "props", "domProps", "scopedSlots"], Ze = ["class", "style", "directives"], Ye = ["on", "nativeOn"], T = (t, e = {}, r = {}) => {
|
|
1450
|
+
const i = [...Qe, ...r.normal || []], s = [...Ze, ...r.array || []], n = [...Ye, ...r.functional || []], o = r.props || [];
|
|
1451
|
+
return t.reduce((a, u) => {
|
|
1452
|
+
for (const l in u)
|
|
1453
|
+
if (a[l])
|
|
1454
|
+
if (o.indexOf(l) > -1)
|
|
1455
|
+
a[l] = T([u[l]], a[l]);
|
|
1456
|
+
else if (i.indexOf(l) > -1)
|
|
1457
|
+
a[l] = y(y({}, a[l]), u[l]);
|
|
1458
|
+
else if (s.indexOf(l) > -1) {
|
|
1459
|
+
const h = a[l] instanceof Array ? a[l] : [a[l]], g = u[l] instanceof Array ? u[l] : [u[l]];
|
|
1460
|
+
a[l] = [...h, ...g];
|
|
1461
|
+
} else if (n.indexOf(l) > -1)
|
|
1462
|
+
for (const h in u[l])
|
|
1463
|
+
if (a[l][h]) {
|
|
1464
|
+
const g = a[l][h] instanceof Array ? a[l][h] : [a[l][h]], b = u[l][h] instanceof Array ? u[l][h] : [u[l][h]];
|
|
1465
|
+
a[l][h] = [...g, ...b];
|
|
1466
|
+
} else
|
|
1467
|
+
a[l][h] = u[l][h];
|
|
1468
|
+
else if (l === "hook")
|
|
1469
|
+
for (let h in u[l])
|
|
1470
|
+
a[l][h] ? a[l][h] = Kt(a[l][h], u[l][h]) : a[l][h] = u[l][h];
|
|
1471
|
+
else
|
|
1472
|
+
a[l] = u[l];
|
|
1473
|
+
else
|
|
1474
|
+
i.indexOf(l) > -1 || n.indexOf(l) > -1 || o.indexOf(l) > -1 ? a[l] = y({}, u[l]) : s.indexOf(l) > -1 ? a[l] = u[l] instanceof Array ? [...u[l]] : typeof u[l] == "object" ? y({}, u[l]) : u[l] : a[l] = u[l];
|
|
1475
|
+
return a;
|
|
1476
|
+
}, e);
|
|
1477
|
+
}, Kt = (t, e) => function() {
|
|
1478
|
+
t && t.apply(this, arguments), e && e.apply(this, arguments);
|
|
1479
|
+
}, et = ["type", "slot", "emitPrefix", "value", "name", "native", "hidden", "display", "inject", "options", "emit", "nativeEmit", "link", "prefix", "suffix", "update", "sync", "optionsTo", "key", "preview", "component", "cache"], pe = ["validate", "children", "control"], me = ["effect", "deep"];
|
|
1480
|
+
function Xt() {
|
|
1481
|
+
return [...et, ...Qe, ...Ze, ...Ye, ...pe, ...me];
|
|
1482
|
+
}
|
|
1483
|
+
function ye(t, e, r) {
|
|
1484
|
+
return `[form-create ${t}]: ${e}`;
|
|
1485
|
+
}
|
|
1486
|
+
function Qt(t, e) {
|
|
1487
|
+
console.warn(ye("tip", t));
|
|
1488
|
+
}
|
|
1489
|
+
function ge(t, e) {
|
|
1490
|
+
console.error(ye("err", t));
|
|
1491
|
+
}
|
|
1492
|
+
function Zt(t) {
|
|
1493
|
+
ge(t.toString()), console.error(t);
|
|
1494
|
+
}
|
|
1495
|
+
const fe = "[[FORM-CREATE-PREFIX-", he = "-FORM-CREATE-SUFFIX]]", Ie = "$FN:", je = "$FNX:", z = "function";
|
|
1496
|
+
function tt(t, e) {
|
|
1497
|
+
return JSON.stringify(x(Array.isArray(t) ? [] : {}, t, !0), function(r, i) {
|
|
1498
|
+
if (!(i && i._isVue === !0)) {
|
|
1499
|
+
if (typeof i !== z)
|
|
1500
|
+
return i;
|
|
1501
|
+
if (i.__json)
|
|
1502
|
+
return i.__json;
|
|
1503
|
+
if (i.__origin && (i = i.__origin), !i.__emit)
|
|
1504
|
+
return fe + i + he;
|
|
1505
|
+
}
|
|
1506
|
+
}, e);
|
|
1507
|
+
}
|
|
1508
|
+
function Ae(t) {
|
|
1509
|
+
return new Function("return " + t)();
|
|
1510
|
+
}
|
|
1511
|
+
function U(t, e) {
|
|
1512
|
+
if (t && c.String(t) && t.length > 4) {
|
|
1513
|
+
let r = t.trim(), i = !1;
|
|
1514
|
+
try {
|
|
1515
|
+
if (r.indexOf(he) > 0 && r.indexOf(fe) === 0)
|
|
1516
|
+
r = r.replace(he, "").replace(fe, ""), i = !0;
|
|
1517
|
+
else if (r.indexOf(Ie) === 0)
|
|
1518
|
+
r = r.replace(Ie, ""), i = !0;
|
|
1519
|
+
else {
|
|
1520
|
+
if (r.indexOf(je) === 0)
|
|
1521
|
+
return r = Ae("function($inject){" + r.replace(je, "") + "}"), r.__json = t, r.__inject = !0, r;
|
|
1522
|
+
!e && r.indexOf(z) === 0 && r !== z && (i = !0);
|
|
1523
|
+
}
|
|
1524
|
+
if (!i) return t;
|
|
1525
|
+
const s = Ae(r.indexOf(z) === -1 && r.indexOf("(") !== 0 ? z + " " + r : r);
|
|
1526
|
+
return s.__json = t, s;
|
|
1527
|
+
} catch (s) {
|
|
1528
|
+
ge(`解析失败:${r}
|
|
1529
|
+
|
|
1530
|
+
err: ${s}`);
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
return t;
|
|
1535
|
+
}
|
|
1536
|
+
function Yt(t, e) {
|
|
1537
|
+
return JSON.parse(t, function(r, i) {
|
|
1538
|
+
return c.Undef(i) || !i.indexOf ? i : U(i, e);
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
function rt(t, e) {
|
|
1542
|
+
return {
|
|
1543
|
+
value: t,
|
|
1544
|
+
enumerable: !1,
|
|
1545
|
+
configurable: !1,
|
|
1546
|
+
writable: !!e
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
function $e(t) {
|
|
1550
|
+
return it([t])[0];
|
|
1551
|
+
}
|
|
1552
|
+
function it(t, e) {
|
|
1553
|
+
return x([], [...t], e || !1);
|
|
1554
|
+
}
|
|
1555
|
+
function q(t, e) {
|
|
1556
|
+
return T(Array.isArray(e) ? e : [e], t, { array: pe, normal: me }), t;
|
|
1557
|
+
}
|
|
1558
|
+
function Ve(t) {
|
|
1559
|
+
const e = c.Function(t.getRule) ? t.getRule() : t;
|
|
1560
|
+
return e.type || (e.type = "input"), e;
|
|
1561
|
+
}
|
|
1562
|
+
function er(t, e) {
|
|
1563
|
+
return t ? (Object.keys(e || {}).forEach((r) => {
|
|
1564
|
+
e[r] && (t[r] = q(t[r] || {}, e[r]));
|
|
1565
|
+
}), t) : e;
|
|
1566
|
+
}
|
|
1567
|
+
function nt(t, e) {
|
|
1568
|
+
Object.defineProperties(t, Object.keys(e).reduce((r, i) => (r[i] = {
|
|
1569
|
+
get() {
|
|
1570
|
+
return e[i]();
|
|
1571
|
+
}
|
|
1572
|
+
}, r), {}));
|
|
1573
|
+
}
|
|
1574
|
+
function K(t) {
|
|
1575
|
+
return t.__fc__ || (t.__origin__ ? t.__origin__.__fc__ : null);
|
|
1576
|
+
}
|
|
1577
|
+
function E(t, e) {
|
|
1578
|
+
try {
|
|
1579
|
+
e = t();
|
|
1580
|
+
} catch (r) {
|
|
1581
|
+
Zt(r);
|
|
1582
|
+
}
|
|
1583
|
+
return e;
|
|
1584
|
+
}
|
|
1585
|
+
const Pe = (t, e) => typeof t == "string" ? String(e) : typeof t == "number" ? Number(e) : e, W = {
|
|
1586
|
+
"==": (t, e) => JSON.stringify(t) === JSON.stringify(Pe(t, e)),
|
|
1587
|
+
"!=": (t, e) => !W["=="](t, e),
|
|
1588
|
+
">": (t, e) => t > e,
|
|
1589
|
+
">=": (t, e) => t >= e,
|
|
1590
|
+
"<": (t, e) => t < e,
|
|
1591
|
+
"<=": (t, e) => t <= e,
|
|
1592
|
+
on(t, e) {
|
|
1593
|
+
return t && t.indexOf && t.indexOf(Pe(t[0], e)) > -1;
|
|
1594
|
+
},
|
|
1595
|
+
notOn(t, e) {
|
|
1596
|
+
return !W.on(t, e);
|
|
1597
|
+
},
|
|
1598
|
+
in(t, e) {
|
|
1599
|
+
return e && e.indexOf && e.indexOf(t) > -1;
|
|
1600
|
+
},
|
|
1601
|
+
notIn(t, e) {
|
|
1602
|
+
return !W.in(t, e);
|
|
1603
|
+
},
|
|
1604
|
+
between(t, e) {
|
|
1605
|
+
return t > e[0] && t < e[1];
|
|
1606
|
+
},
|
|
1607
|
+
notBetween(t, e) {
|
|
1608
|
+
return t < e[0] || t > e[1];
|
|
1609
|
+
},
|
|
1610
|
+
empty(t) {
|
|
1611
|
+
return c.empty(t);
|
|
1612
|
+
},
|
|
1613
|
+
notEmpty(t) {
|
|
1614
|
+
return !c.empty(t);
|
|
1615
|
+
},
|
|
1616
|
+
pattern(t, e) {
|
|
1617
|
+
return new RegExp(e, "g").test(t);
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
function st() {
|
|
1621
|
+
return {
|
|
1622
|
+
props: {},
|
|
1623
|
+
on: {},
|
|
1624
|
+
options: [],
|
|
1625
|
+
children: [],
|
|
1626
|
+
effect: {},
|
|
1627
|
+
hidden: !1,
|
|
1628
|
+
display: !0,
|
|
1629
|
+
value: void 0
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
function S(t, e) {
|
|
1633
|
+
return (r, i, s, n = {}) => {
|
|
1634
|
+
const o = new ve(t, r, i, s, n);
|
|
1635
|
+
return e && (c.Function(e) ? e(o) : o.props(e)), o;
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
function ve(t, e, r, i, s) {
|
|
1639
|
+
this._data = m(st(), { type: t, title: e, field: r, value: i, props: s || {} }), this.event = this.on;
|
|
1640
|
+
}
|
|
1641
|
+
m(ve.prototype, {
|
|
1642
|
+
getRule() {
|
|
1643
|
+
return this._data;
|
|
1644
|
+
},
|
|
1645
|
+
setProp(t, e) {
|
|
1646
|
+
return F(this._data, t, e), this;
|
|
1647
|
+
},
|
|
1648
|
+
_clone() {
|
|
1649
|
+
const t = new this.constructor();
|
|
1650
|
+
return t._data = $e(this._data), t;
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
function ot(t) {
|
|
1654
|
+
t.forEach((e) => {
|
|
1655
|
+
ve.prototype[e] = function(r) {
|
|
1656
|
+
return q(this._data, { [e]: arguments.length < 2 ? r : { [r]: arguments[1] } }), this;
|
|
1657
|
+
};
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
ot(Xt());
|
|
1661
|
+
const at = S("");
|
|
1662
|
+
function tr(t, e, r) {
|
|
1663
|
+
let i = at("", e);
|
|
1664
|
+
return i._data.type = t, i._data.title = r, i;
|
|
1665
|
+
}
|
|
1666
|
+
function De(t, e, r, i) {
|
|
1667
|
+
let s = at("", r);
|
|
1668
|
+
return s._data.type = "template", s._data.template = t, s._data.title = i, s._data.vm = e, s;
|
|
1669
|
+
}
|
|
1670
|
+
function rr() {
|
|
1671
|
+
return {
|
|
1672
|
+
create: tr,
|
|
1673
|
+
createTmp: De,
|
|
1674
|
+
template: De,
|
|
1675
|
+
factory: S
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
function ir(t, e, r) {
|
|
1679
|
+
const i = `fail to ${t} ${r.status}'`, s = new Error(i);
|
|
1680
|
+
return s.status = r.status, s.url = t, s;
|
|
1681
|
+
}
|
|
1682
|
+
function Te(t) {
|
|
1683
|
+
const e = t.responseText || t.response;
|
|
1684
|
+
if (!e)
|
|
1685
|
+
return e;
|
|
1686
|
+
try {
|
|
1687
|
+
return JSON.parse(e);
|
|
1688
|
+
} catch (r) {
|
|
1689
|
+
return e;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
function lt(t) {
|
|
1693
|
+
if (typeof XMLHttpRequest == "undefined")
|
|
1694
|
+
return;
|
|
1695
|
+
const e = new XMLHttpRequest(), r = t.action;
|
|
1696
|
+
e.onerror = function(o) {
|
|
1697
|
+
t.onError(o);
|
|
1698
|
+
}, e.onload = function() {
|
|
1699
|
+
if (e.status < 200 || e.status >= 300)
|
|
1700
|
+
return t.onError(ir(r, t, e), Te(e));
|
|
1701
|
+
t.onSuccess(Te(e));
|
|
1702
|
+
}, e.open(t.method || "get", r, !0);
|
|
1703
|
+
let i;
|
|
1704
|
+
t.data && ((t.dataType || "").toLowerCase() !== "json" ? (i = new FormData(), Object.keys(t.data).map((n) => {
|
|
1705
|
+
i.append(n, t.data[n]);
|
|
1706
|
+
})) : (i = JSON.stringify(t.data), e.setRequestHeader("content-type", "application/json"))), t.withCredentials && "withCredentials" in e && (e.withCredentials = !0);
|
|
1707
|
+
const s = t.headers || {};
|
|
1708
|
+
Object.keys(s).forEach((n) => {
|
|
1709
|
+
s[n] !== null && e.setRequestHeader(n, s[n]);
|
|
1710
|
+
}), e.send(i);
|
|
1711
|
+
}
|
|
1712
|
+
function nr(t) {
|
|
1713
|
+
return new Promise((e, r) => {
|
|
1714
|
+
lt(H(y({}, t), {
|
|
1715
|
+
onSuccess(i) {
|
|
1716
|
+
let s = (o) => o;
|
|
1717
|
+
const n = U(t.parse);
|
|
1718
|
+
c.Function(n) ? s = n : n && c.String(n) && (s = (o) => (n.split(".").forEach((a) => {
|
|
1719
|
+
o && (o = o[a]);
|
|
1720
|
+
}), o)), e(s(i));
|
|
1721
|
+
},
|
|
1722
|
+
onError(i) {
|
|
1723
|
+
r(i);
|
|
1724
|
+
}
|
|
1725
|
+
}));
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
function G(t) {
|
|
1729
|
+
return N(t);
|
|
1730
|
+
}
|
|
1731
|
+
function sr(t) {
|
|
1732
|
+
function e(n) {
|
|
1733
|
+
return c.Undef(n) ? n = t.fields() : Array.isArray(n) || (n = [n]), n;
|
|
1734
|
+
}
|
|
1735
|
+
function r(n, o, a) {
|
|
1736
|
+
e(n).forEach((u) => {
|
|
1737
|
+
t.getCtxs(u).forEach((l) => {
|
|
1738
|
+
F(l.rule, o, a), t.$render.clearCache(l);
|
|
1739
|
+
});
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
function i() {
|
|
1743
|
+
const n = t.subForm;
|
|
1744
|
+
return Object.keys(n).reduce((o, a) => {
|
|
1745
|
+
const u = n[a];
|
|
1746
|
+
return u && (Array.isArray(u) ? o.push(...u) : o.push(u)), o;
|
|
1747
|
+
}, []);
|
|
1748
|
+
}
|
|
1749
|
+
const s = {
|
|
1750
|
+
get config() {
|
|
1751
|
+
return t.options;
|
|
1752
|
+
},
|
|
1753
|
+
get options() {
|
|
1754
|
+
return t.options;
|
|
1755
|
+
},
|
|
1756
|
+
get form() {
|
|
1757
|
+
return t.form;
|
|
1758
|
+
},
|
|
1759
|
+
get rule() {
|
|
1760
|
+
return t.rules;
|
|
1761
|
+
},
|
|
1762
|
+
get parent() {
|
|
1763
|
+
return t.vm.$pfc && t.vm.$pfc.$f;
|
|
1764
|
+
},
|
|
1765
|
+
get top() {
|
|
1766
|
+
return s.parent ? s.parent.top : s;
|
|
1767
|
+
},
|
|
1768
|
+
get children() {
|
|
1769
|
+
return i();
|
|
1770
|
+
},
|
|
1771
|
+
formData(n) {
|
|
1772
|
+
return e(n).reduce((o, a) => {
|
|
1773
|
+
const u = t.getFieldCtx(a);
|
|
1774
|
+
return u && (o[u.field] = G(u.rule.value)), o;
|
|
1775
|
+
}, t.options.appendValue !== !1 ? G(t.appendData) : {});
|
|
1776
|
+
},
|
|
1777
|
+
getValue(n) {
|
|
1778
|
+
const o = t.getFieldCtx(n);
|
|
1779
|
+
if (o)
|
|
1780
|
+
return G(o.rule.value);
|
|
1781
|
+
},
|
|
1782
|
+
coverValue(n) {
|
|
1783
|
+
const o = y({}, n || {});
|
|
1784
|
+
t.deferSyncValue(() => {
|
|
1785
|
+
s.fields().forEach((a) => {
|
|
1786
|
+
const u = t.fieldCtx[a];
|
|
1787
|
+
if (u) {
|
|
1788
|
+
const l = w(o, a);
|
|
1789
|
+
u.forEach((h) => {
|
|
1790
|
+
h.rule.value = l ? o[a] : void 0;
|
|
1791
|
+
}), delete o[a];
|
|
1792
|
+
}
|
|
1793
|
+
}), m(t.appendData, o);
|
|
1794
|
+
});
|
|
1795
|
+
},
|
|
1796
|
+
setValue(n) {
|
|
1797
|
+
let o = n;
|
|
1798
|
+
arguments.length >= 2 && (o = { [n]: arguments[1] }), t.deferSyncValue(() => {
|
|
1799
|
+
Object.keys(o).forEach((a) => {
|
|
1800
|
+
const u = t.fieldCtx[a];
|
|
1801
|
+
if (!u) return t.appendData[a] = o[a];
|
|
1802
|
+
u.forEach((l) => {
|
|
1803
|
+
l.rule.value = o[a];
|
|
1804
|
+
});
|
|
1805
|
+
});
|
|
1806
|
+
});
|
|
1807
|
+
},
|
|
1808
|
+
removeField(n) {
|
|
1809
|
+
const o = t.getCtx(n);
|
|
1810
|
+
return t.deferSyncValue(() => {
|
|
1811
|
+
t.getCtxs(n).forEach((a) => {
|
|
1812
|
+
a.rm();
|
|
1813
|
+
});
|
|
1814
|
+
}, !0), o ? o.origin : void 0;
|
|
1815
|
+
},
|
|
1816
|
+
removeRule(n) {
|
|
1817
|
+
const o = n && K(n);
|
|
1818
|
+
if (o)
|
|
1819
|
+
return o.rm(), o.origin;
|
|
1820
|
+
},
|
|
1821
|
+
destroy: () => {
|
|
1822
|
+
t.vm.$el.parentNode && t.vm.$el.parentNode.removeChild(t.vm.$el), t.vm.$destroy();
|
|
1823
|
+
},
|
|
1824
|
+
fields: () => t.fields(),
|
|
1825
|
+
append: (n, o, a) => {
|
|
1826
|
+
let u = t.sort.length - 1, l;
|
|
1827
|
+
const h = t.getCtx(o);
|
|
1828
|
+
h ? a ? (l = h.rule.children, u = h.rule.children.length - 1) : (u = h.root.indexOf(h.origin), l = h.root) : l = t.rules, l.splice(u + 1, 0, n);
|
|
1829
|
+
},
|
|
1830
|
+
prepend: (n, o, a) => {
|
|
1831
|
+
let u = 0, l;
|
|
1832
|
+
const h = t.getCtx(o);
|
|
1833
|
+
h ? a ? l = h.rule.children : (u = h.root.indexOf(h.origin), l = h.root) : l = t.rules, l.splice(u, 0, n);
|
|
1834
|
+
},
|
|
1835
|
+
hidden(n, o) {
|
|
1836
|
+
r(o, "hidden", !!n), t.refresh();
|
|
1837
|
+
},
|
|
1838
|
+
hiddenStatus(n) {
|
|
1839
|
+
const o = t.getCtx(n);
|
|
1840
|
+
if (o)
|
|
1841
|
+
return !!o.rule.hidden;
|
|
1842
|
+
},
|
|
1843
|
+
display(n, o) {
|
|
1844
|
+
r(o, "display", !!n), t.refresh();
|
|
1845
|
+
},
|
|
1846
|
+
displayStatus(n) {
|
|
1847
|
+
const o = t.getCtx(n);
|
|
1848
|
+
if (o)
|
|
1849
|
+
return !!o.rule.display;
|
|
1850
|
+
},
|
|
1851
|
+
disabled(n, o) {
|
|
1852
|
+
e(o).forEach((a) => {
|
|
1853
|
+
t.getCtxs(a).forEach((u) => {
|
|
1854
|
+
u.rule.props && F(u.rule.props, "disabled", !!n);
|
|
1855
|
+
});
|
|
1856
|
+
}), t.refresh();
|
|
1857
|
+
},
|
|
1858
|
+
all(n) {
|
|
1859
|
+
return Object.keys(t.ctxs).map((o) => {
|
|
1860
|
+
const a = t.ctxs[o];
|
|
1861
|
+
return n ? a.origin : a.rule;
|
|
1862
|
+
});
|
|
1863
|
+
},
|
|
1864
|
+
model(n) {
|
|
1865
|
+
return t.fields().reduce((o, a) => {
|
|
1866
|
+
const u = t.fieldCtx[a][0];
|
|
1867
|
+
return o[a] = n ? u.origin : u.rule, o;
|
|
1868
|
+
}, {});
|
|
1869
|
+
},
|
|
1870
|
+
component(n) {
|
|
1871
|
+
return Object.keys(t.nameCtx).reduce((o, a) => {
|
|
1872
|
+
const u = t.nameCtx[a].map((l) => n ? l.origin : l.rule);
|
|
1873
|
+
return o[a] = u.length === 1 ? u[0] : u, o;
|
|
1874
|
+
}, {});
|
|
1875
|
+
},
|
|
1876
|
+
bind() {
|
|
1877
|
+
return s.form;
|
|
1878
|
+
},
|
|
1879
|
+
reload: (n) => {
|
|
1880
|
+
t.reloadRule(n);
|
|
1881
|
+
},
|
|
1882
|
+
updateOptions(n) {
|
|
1883
|
+
t.fc.updateOptions(n), s.refresh();
|
|
1884
|
+
},
|
|
1885
|
+
onSubmit(n) {
|
|
1886
|
+
s.updateOptions({ onSubmit: n });
|
|
1887
|
+
},
|
|
1888
|
+
sync: (n) => {
|
|
1889
|
+
if (Array.isArray(n)) {
|
|
1890
|
+
n.forEach((a) => s.sync(a));
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1893
|
+
let o = c.Object(n) ? K(n) : t.getCtxs(n);
|
|
1894
|
+
o && (o = Array.isArray(o) ? o : [o], o.forEach((a) => {
|
|
1895
|
+
if (!a.deleted) {
|
|
1896
|
+
const u = t.subForm[a.id];
|
|
1897
|
+
u && (Array.isArray(u) ? u.forEach((l) => {
|
|
1898
|
+
l.refresh();
|
|
1899
|
+
}) : u && u.refresh()), t.$render.clearCache(a);
|
|
1900
|
+
}
|
|
1901
|
+
}), t.refresh());
|
|
1902
|
+
},
|
|
1903
|
+
refresh: () => {
|
|
1904
|
+
i().forEach((n) => {
|
|
1905
|
+
n.refresh();
|
|
1906
|
+
}), t.$render.clearCacheAll(), t.refresh();
|
|
1907
|
+
},
|
|
1908
|
+
refreshOptions() {
|
|
1909
|
+
t.$manager.updateOptions(t.options), s.refresh();
|
|
1910
|
+
},
|
|
1911
|
+
hideForm: (n) => {
|
|
1912
|
+
F(t.vm, "isShow", !n);
|
|
1913
|
+
},
|
|
1914
|
+
changeStatus: () => t.changeStatus,
|
|
1915
|
+
clearChangeStatus: () => {
|
|
1916
|
+
t.changeStatus = !1;
|
|
1917
|
+
},
|
|
1918
|
+
updateRule(n, o) {
|
|
1919
|
+
t.getCtxs(n).forEach((a) => {
|
|
1920
|
+
m(a.rule, o);
|
|
1921
|
+
});
|
|
1922
|
+
},
|
|
1923
|
+
updateRules(n) {
|
|
1924
|
+
Object.keys(n).forEach((o) => {
|
|
1925
|
+
s.updateRule(o, n[o]);
|
|
1926
|
+
});
|
|
1927
|
+
},
|
|
1928
|
+
mergeRule: (n, o) => {
|
|
1929
|
+
t.getCtxs(n).forEach((a) => {
|
|
1930
|
+
q(a.rule, o);
|
|
1931
|
+
});
|
|
1932
|
+
},
|
|
1933
|
+
mergeRules(n) {
|
|
1934
|
+
Object.keys(n).forEach((o) => {
|
|
1935
|
+
s.mergeRule(o, n[o]);
|
|
1936
|
+
});
|
|
1937
|
+
},
|
|
1938
|
+
getRule: (n, o) => {
|
|
1939
|
+
const a = t.getCtx(n);
|
|
1940
|
+
if (a)
|
|
1941
|
+
return o ? a.origin : a.rule;
|
|
1942
|
+
},
|
|
1943
|
+
getRenderRule: (n) => {
|
|
1944
|
+
const o = t.getCtx(n);
|
|
1945
|
+
if (o)
|
|
1946
|
+
return o.prop;
|
|
1947
|
+
},
|
|
1948
|
+
getRefRule: (n) => {
|
|
1949
|
+
const o = t.getCtxs(n);
|
|
1950
|
+
if (o && o.length) {
|
|
1951
|
+
const a = o.map((u) => u.rule);
|
|
1952
|
+
return a.length === 1 ? a[0] : a;
|
|
1953
|
+
}
|
|
1954
|
+
},
|
|
1955
|
+
setEffect(n, o, a) {
|
|
1956
|
+
const u = t.getCtx(n);
|
|
1957
|
+
u && o && (o[0] === "$" && (o = o.substr(1)), w(u.rule, "$" + o) && F(u.rule, "$" + o, a), w(u.rule, "effect") || F(u.rule, "effect", {}), F(u.rule.effect, o, a));
|
|
1958
|
+
},
|
|
1959
|
+
clearEffectData(n, o) {
|
|
1960
|
+
const a = t.getCtx(n);
|
|
1961
|
+
a && (o && o[0] === "$" && (o = o.substr(1)), a.clearEffectData(o), s.sync(n));
|
|
1962
|
+
},
|
|
1963
|
+
updateValidate(n, o, a) {
|
|
1964
|
+
a ? s.mergeRule(n, { validate: o }) : r(n, "validate", o);
|
|
1965
|
+
},
|
|
1966
|
+
updateValidates(n, o) {
|
|
1967
|
+
Object.keys(n).forEach((a) => {
|
|
1968
|
+
s.updateValidate(a, n[a], o);
|
|
1969
|
+
});
|
|
1970
|
+
},
|
|
1971
|
+
refreshValidate() {
|
|
1972
|
+
t.vm.validate = {}, s.refresh();
|
|
1973
|
+
},
|
|
1974
|
+
resetFields(n) {
|
|
1975
|
+
e(n).forEach((o) => {
|
|
1976
|
+
t.getCtxs(o).forEach((a) => {
|
|
1977
|
+
t.$render.clearCache(a), a.rule.value = G(a.defaultValue);
|
|
1978
|
+
});
|
|
1979
|
+
});
|
|
1980
|
+
},
|
|
1981
|
+
method(n, o) {
|
|
1982
|
+
const a = s.el(n);
|
|
1983
|
+
if (!a || !a[o])
|
|
1984
|
+
throw new Error(ye("err", `${o}方法不存在`));
|
|
1985
|
+
return (...u) => a[o](...u);
|
|
1986
|
+
},
|
|
1987
|
+
exec(n, o, ...a) {
|
|
1988
|
+
return E(() => s.method(n, o)(...a));
|
|
1989
|
+
},
|
|
1990
|
+
toJson(n) {
|
|
1991
|
+
return tt(s.rule, n);
|
|
1992
|
+
},
|
|
1993
|
+
trigger(n, o, ...a) {
|
|
1994
|
+
const u = s.el(n);
|
|
1995
|
+
u && u.$emit(o, ...a);
|
|
1996
|
+
},
|
|
1997
|
+
el(n) {
|
|
1998
|
+
const o = t.getCtx(n);
|
|
1999
|
+
if (o) return o.exportEl || o.el || t.vm.$refs[o.ref];
|
|
2000
|
+
},
|
|
2001
|
+
closeModal: (n) => {
|
|
2002
|
+
const o = s.el(n);
|
|
2003
|
+
o && o.$emit && o.$emit("close-modal");
|
|
2004
|
+
},
|
|
2005
|
+
getSubForm(n) {
|
|
2006
|
+
const o = t.getCtx(n);
|
|
2007
|
+
return o ? t.subForm[o.id] : void 0;
|
|
2008
|
+
},
|
|
2009
|
+
nextTick(n) {
|
|
2010
|
+
t.bus.$once("next-tick", n), t.refresh();
|
|
2011
|
+
},
|
|
2012
|
+
nextRefresh(n) {
|
|
2013
|
+
t.nextRefresh(), n && E(n);
|
|
2014
|
+
},
|
|
2015
|
+
emit(n, ...o) {
|
|
2016
|
+
t.vm.$emit(n, ...o);
|
|
2017
|
+
},
|
|
2018
|
+
deferSyncValue(n, o) {
|
|
2019
|
+
t.deferSyncValue(n, o);
|
|
2020
|
+
},
|
|
2021
|
+
fetch(n) {
|
|
2022
|
+
return new Promise((o, a) => {
|
|
2023
|
+
t.beforeFetch(n).then(() => nr(n).then(o).catch(a));
|
|
2024
|
+
});
|
|
2025
|
+
},
|
|
2026
|
+
getData(n, o) {
|
|
2027
|
+
return t.fc.getData(n, o);
|
|
2028
|
+
},
|
|
2029
|
+
setData(n, o) {
|
|
2030
|
+
return t.fc.setData(n, o);
|
|
2031
|
+
},
|
|
2032
|
+
helper: {
|
|
2033
|
+
tidyFields: e,
|
|
2034
|
+
props: r
|
|
2035
|
+
}
|
|
2036
|
+
};
|
|
2037
|
+
return ["on", "once", "off", "set", "emit"].forEach((n) => {
|
|
2038
|
+
s[n] = function(...o) {
|
|
2039
|
+
t.vm[`$${n}`](...o);
|
|
2040
|
+
};
|
|
2041
|
+
}), s.changeValue = s.changeField = s.setValue, s;
|
|
2042
|
+
}
|
|
2043
|
+
function or(t) {
|
|
2044
|
+
m(t.prototype, {
|
|
2045
|
+
initCache() {
|
|
2046
|
+
this.clearCacheAll();
|
|
2047
|
+
},
|
|
2048
|
+
clearCache(e) {
|
|
2049
|
+
if (e.rule.cache)
|
|
2050
|
+
return;
|
|
2051
|
+
if (!this.cache[e.id]) {
|
|
2052
|
+
e.parent && this.clearCache(e.parent);
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
(this.cache[e.id].use === !0 || this.cache[e.id].parent) && this.$handle.refresh();
|
|
2056
|
+
const r = this.cache[e.id].parent;
|
|
2057
|
+
this.cache[e.id] = null, r && this.clearCache(r);
|
|
2058
|
+
},
|
|
2059
|
+
clearCacheAll() {
|
|
2060
|
+
this.cache = {};
|
|
2061
|
+
},
|
|
2062
|
+
setCache(e, r, i) {
|
|
2063
|
+
this.cache[e.id] = {
|
|
2064
|
+
vnode: r,
|
|
2065
|
+
use: !1,
|
|
2066
|
+
parent: i,
|
|
2067
|
+
slot: e.rule.slot
|
|
2068
|
+
};
|
|
2069
|
+
},
|
|
2070
|
+
getCache(e) {
|
|
2071
|
+
const r = this.cache[e.id];
|
|
2072
|
+
if (r)
|
|
2073
|
+
return r.use = !0, r.vnode;
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
function I(t) {
|
|
2078
|
+
const e = t.replace(/(-[a-z])/g, function(r) {
|
|
2079
|
+
return r.replace("-", "").toLocaleUpperCase();
|
|
2080
|
+
});
|
|
2081
|
+
return ut(e);
|
|
2082
|
+
}
|
|
2083
|
+
function ut(t) {
|
|
2084
|
+
return t.replace(t[0], t[0].toLowerCase());
|
|
2085
|
+
}
|
|
2086
|
+
function ar(t) {
|
|
2087
|
+
return t == null ? "" : typeof t == "object" ? JSON.stringify(t, null, 2) : String(t);
|
|
2088
|
+
}
|
|
2089
|
+
function X(t) {
|
|
2090
|
+
let e = t.replace(/([A-Z])/g, "-$1").toLocaleLowerCase();
|
|
2091
|
+
return e.indexOf("-") === 0 && (e = e.substr(1)), e;
|
|
2092
|
+
}
|
|
2093
|
+
let lr = 0;
|
|
2094
|
+
function te() {
|
|
2095
|
+
const t = 370 + ++lr;
|
|
2096
|
+
return "F" + Math.random().toString(36).substr(3, 3) + (+`${Date.now()}`).toString(36) + t.toString(36) + "c";
|
|
2097
|
+
}
|
|
2098
|
+
function Q(t, e, r) {
|
|
2099
|
+
let i = t, s;
|
|
2100
|
+
return (e || "").split(".").forEach((n) => {
|
|
2101
|
+
s && ((!i[s] || typeof i[s] != "object") && (i[s] = {}), i = i[s]), s = n;
|
|
2102
|
+
}), i[s] = r, i;
|
|
2103
|
+
}
|
|
2104
|
+
function ur(t) {
|
|
2105
|
+
m(t.prototype, {
|
|
2106
|
+
initRender() {
|
|
2107
|
+
this.tempList = {}, this.clearOrgChildren();
|
|
2108
|
+
},
|
|
2109
|
+
initOrgChildren() {
|
|
2110
|
+
const e = this.$handle.ctxs;
|
|
2111
|
+
this.orgChildren = Object.keys(e).reduce((r, i) => {
|
|
2112
|
+
if (e[i].parser.loadChildren !== !1) {
|
|
2113
|
+
const s = e[i].rule.children;
|
|
2114
|
+
r[i] = c.trueArray(s) ? [...s] : [];
|
|
2115
|
+
}
|
|
2116
|
+
return r;
|
|
2117
|
+
}, {});
|
|
2118
|
+
},
|
|
2119
|
+
clearOrgChildren() {
|
|
2120
|
+
this.orgChildren = {};
|
|
2121
|
+
},
|
|
2122
|
+
getTypeSlot(e) {
|
|
2123
|
+
const r = (i) => {
|
|
2124
|
+
if (i) {
|
|
2125
|
+
let s;
|
|
2126
|
+
return e.rule.field && (s = i.$scopedSlots["field-" + X(e.rule.field)] || i.$scopedSlots["field-" + e.rule.field]), s || (s = i.$scopedSlots["type-" + X(e.type)] || i.$scopedSlots["type-" + e.type]), s || r(i.$pfc);
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
return r(this.vm);
|
|
2130
|
+
},
|
|
2131
|
+
render() {
|
|
2132
|
+
if (!this.vm.isShow)
|
|
2133
|
+
return;
|
|
2134
|
+
this.$h = this.vm.$createElement, this.$manager.beforeRender();
|
|
2135
|
+
let e;
|
|
2136
|
+
const r = () => this.renderList();
|
|
2137
|
+
return r.renderSlot = (i) => this.renderList(i), r.renderName = (i) => this.renderId(i), r.renderField = (i) => this.renderId(i, "field"), this.vm.$scopedSlots.container ? e = [this.vm.$scopedSlots.container(r)] : e = r(), this.$manager.render(e);
|
|
2138
|
+
},
|
|
2139
|
+
renderList(e) {
|
|
2140
|
+
return this.sort.map((r) => e ? this.renderSlot(this.$handle.ctxs[r], e) : this.renderCtx(this.$handle.ctxs[r])).filter((r) => r !== void 0);
|
|
2141
|
+
},
|
|
2142
|
+
makeVm(e) {
|
|
2143
|
+
const r = e.vm;
|
|
2144
|
+
if (r) {
|
|
2145
|
+
if (c.Function(r))
|
|
2146
|
+
return E(() => e.vm(this.$handle.getInjectData(e)));
|
|
2147
|
+
if (!r._isVue)
|
|
2148
|
+
return new B(r);
|
|
2149
|
+
} else return new B();
|
|
2150
|
+
return r;
|
|
2151
|
+
},
|
|
2152
|
+
mergeGlobal(e) {
|
|
2153
|
+
const r = this.$handle.options.global;
|
|
2154
|
+
r && (e.cacheConfig || (e.cacheConfig = r[e.originType] || r[e.type] || r[e.trueType] || {}), e.prop = q({}, [r["*"], e.cacheConfig, e.prop]));
|
|
2155
|
+
},
|
|
2156
|
+
setOptions(e) {
|
|
2157
|
+
e.prop.optionsTo && e.prop.options && Q(e.prop, e.prop.optionsTo, e.prop.options);
|
|
2158
|
+
},
|
|
2159
|
+
deepSet(e) {
|
|
2160
|
+
const r = e.rule.deep;
|
|
2161
|
+
r && Object.keys(r).sort((i, s) => i.length < s.length ? -1 : 1).forEach((i) => {
|
|
2162
|
+
Q(e.prop, i, r[i]);
|
|
2163
|
+
});
|
|
2164
|
+
},
|
|
2165
|
+
setTempProps(e, r) {
|
|
2166
|
+
if (!e.$props) return;
|
|
2167
|
+
const { prop: i } = r, s = Object.keys(e.$props), n = this.injectProp(r), o = Object.keys(n);
|
|
2168
|
+
s.forEach((u) => {
|
|
2169
|
+
w(i.props, u) ? e.$props[u] = i.props[u] : o.indexOf(u) > -1 && (e.$props[u] = n[u]);
|
|
2170
|
+
});
|
|
2171
|
+
const a = e.$options.model && e.$options.model.prop || "value";
|
|
2172
|
+
s.indexOf(a) > -1 && (e.$props[a] = i.value);
|
|
2173
|
+
},
|
|
2174
|
+
renderTemp(e) {
|
|
2175
|
+
if (!B.compile)
|
|
2176
|
+
return Qt("当前使用的Vue构建版本不支持compile,无法使用template功能"), [];
|
|
2177
|
+
const r = e.prop, { id: i, key: s } = e;
|
|
2178
|
+
if (!this.tempList[i]) {
|
|
2179
|
+
e.el || (e.el = this.makeVm(r), this.vm.$nextTick(() => e.parser.mounted(e)));
|
|
2180
|
+
let u = e.el;
|
|
2181
|
+
e.input && u.$on(u.$options.model && u.$options.model.event || "input", (l) => {
|
|
2182
|
+
this.onInput(e, l);
|
|
2183
|
+
}), this.tempList[i] = {
|
|
2184
|
+
vm: u,
|
|
2185
|
+
template: B.compile(r.template)
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
const { vm: n, template: o } = this.tempList[i];
|
|
2189
|
+
this.setTempProps(n, e);
|
|
2190
|
+
const a = o.render.call(n);
|
|
2191
|
+
return c.Undef(a.data) && (a.data = {}), a.key = s, a.data.ref = e.ref, a.data.key = s, a;
|
|
2192
|
+
},
|
|
2193
|
+
parseSide(e, r) {
|
|
2194
|
+
return c.Object(e) ? q({ props: { formCreateInject: r.prop.props.formCreateInject } }, e) : e;
|
|
2195
|
+
},
|
|
2196
|
+
renderSides(e, r, i) {
|
|
2197
|
+
const s = r[i ? "rule" : "prop"];
|
|
2198
|
+
return [this.renderRule(this.parseSide(s.prefix, r)), e, this.renderRule(this.parseSide(s.suffix, r))];
|
|
2199
|
+
},
|
|
2200
|
+
renderSlot(e, r) {
|
|
2201
|
+
return e.rule.slot === r ? this.renderCtx(e) : void 0;
|
|
2202
|
+
},
|
|
2203
|
+
renderId(e, r) {
|
|
2204
|
+
const i = this.$handle[r === "field" ? "fieldCtx" : "nameCtx"][e];
|
|
2205
|
+
return i ? i.map((s) => this.renderCtx(s, s.parent)) : void 0;
|
|
2206
|
+
},
|
|
2207
|
+
renderCtx(e, r) {
|
|
2208
|
+
if (e.type === "hidden") return;
|
|
2209
|
+
const i = e.rule;
|
|
2210
|
+
if (!this.cache[e.id] || this.cache[e.id].slot !== i.slot) {
|
|
2211
|
+
let s, n = i.cache !== !1;
|
|
2212
|
+
const o = e.trueType, a = !(c.Undef(i.display) || i.display);
|
|
2213
|
+
if (o === "template" && !i.template)
|
|
2214
|
+
s = this.renderSides(this.renderChildren(e), e, !0), a && this.display(s), s = this.item(e, s);
|
|
2215
|
+
else if (o === "fcFragment")
|
|
2216
|
+
s = this.renderChildren(e);
|
|
2217
|
+
else {
|
|
2218
|
+
e.initProp(), this.mergeGlobal(e), this.$manager.tidyRule(e), this.deepSet(e), this.setOptions(e), this.ctxProp(e);
|
|
2219
|
+
let u = e.prop;
|
|
2220
|
+
u.preview = !!(w(u, "preview") ? u.preview : this.options.preview), u.props.formCreateInject = this.injectProp(e);
|
|
2221
|
+
const l = u.preview;
|
|
2222
|
+
if (u.hidden) {
|
|
2223
|
+
this.setCache(e, void 0, r);
|
|
2224
|
+
return;
|
|
2225
|
+
}
|
|
2226
|
+
if (o === "template" && u.template)
|
|
2227
|
+
s = this.renderTemp(e), n = !1;
|
|
2228
|
+
else {
|
|
2229
|
+
let h = [];
|
|
2230
|
+
e.parser.renderChildren ? h = e.parser.renderChildren(e) : e.parser.loadChildren !== !1 && (h = this.renderChildren(e));
|
|
2231
|
+
const g = this.getTypeSlot(e);
|
|
2232
|
+
g ? s = g({
|
|
2233
|
+
rule: i,
|
|
2234
|
+
prop: u,
|
|
2235
|
+
preview: l,
|
|
2236
|
+
children: h,
|
|
2237
|
+
api: this.$handle.api,
|
|
2238
|
+
model: u.model || {}
|
|
2239
|
+
}) : s = l ? e.parser.preview(h, e) : e.parser.render(h, e);
|
|
2240
|
+
}
|
|
2241
|
+
s = this.renderSides(s, e), !(!e.input && c.Undef(u.native)) && u.native !== !0 && (s = this.$manager.makeWrap(e, s)), a && (s = this.display(s)), s = this.item(e, s);
|
|
2242
|
+
}
|
|
2243
|
+
return n && this.setCache(e, s, r), s;
|
|
2244
|
+
}
|
|
2245
|
+
return this.getCache(e);
|
|
2246
|
+
},
|
|
2247
|
+
display(e) {
|
|
2248
|
+
if (Array.isArray(e)) {
|
|
2249
|
+
const r = [];
|
|
2250
|
+
return e.forEach((i) => {
|
|
2251
|
+
if (Array.isArray(i)) return this.display(i);
|
|
2252
|
+
this.none(i) && r.push(i);
|
|
2253
|
+
}), r;
|
|
2254
|
+
} else
|
|
2255
|
+
return this.none(e);
|
|
2256
|
+
},
|
|
2257
|
+
none(e) {
|
|
2258
|
+
if (e && e.data)
|
|
2259
|
+
return Array.isArray(e.data.style) ? e.data.style.push({ display: "none" }) : c.String(e.data.style) ? e.data.style += ";display:none;" : e.data.style = [e.data.style, { display: "none" }], e;
|
|
2260
|
+
},
|
|
2261
|
+
item(e, r) {
|
|
2262
|
+
return this.$h("fcFragment", {
|
|
2263
|
+
slot: e.rule.slot,
|
|
2264
|
+
key: e.key
|
|
2265
|
+
}, [r]);
|
|
2266
|
+
},
|
|
2267
|
+
injectProp(e) {
|
|
2268
|
+
this.vm.ctxInject[e.id] || F(this.vm.ctxInject, e.id, {
|
|
2269
|
+
api: this.$handle.api,
|
|
2270
|
+
form: this.fc.create,
|
|
2271
|
+
subForm: (i) => {
|
|
2272
|
+
this.$handle.addSubForm(e, i);
|
|
2273
|
+
},
|
|
2274
|
+
getSubForm: () => this.$handle.subForm[e.id],
|
|
2275
|
+
options: [],
|
|
2276
|
+
children: [],
|
|
2277
|
+
prop: {},
|
|
2278
|
+
preview: !1,
|
|
2279
|
+
id: e.id,
|
|
2280
|
+
field: e.field,
|
|
2281
|
+
rule: e.rule,
|
|
2282
|
+
input: e.input
|
|
2283
|
+
});
|
|
2284
|
+
const r = this.vm.ctxInject[e.id];
|
|
2285
|
+
return m(r, {
|
|
2286
|
+
preview: e.prop.preview,
|
|
2287
|
+
options: e.prop.options,
|
|
2288
|
+
children: e.rule.children,
|
|
2289
|
+
prop: function() {
|
|
2290
|
+
const i = y({}, e.prop);
|
|
2291
|
+
return i.on = i.on ? y({}, i.on) : {}, delete i.model, i;
|
|
2292
|
+
}()
|
|
2293
|
+
}), r;
|
|
2294
|
+
},
|
|
2295
|
+
ctxProp(e) {
|
|
2296
|
+
const { ref: r, key: i, rule: s } = e;
|
|
2297
|
+
this.$manager.mergeProp(e), e.parser.mergeProp(e);
|
|
2298
|
+
const n = [
|
|
2299
|
+
{
|
|
2300
|
+
ref: r,
|
|
2301
|
+
key: s.key || `${i}fc`,
|
|
2302
|
+
slot: void 0,
|
|
2303
|
+
on: {
|
|
2304
|
+
"hook:mounted": () => {
|
|
2305
|
+
this.onMounted(e);
|
|
2306
|
+
},
|
|
2307
|
+
"fc.sub-form": (o) => {
|
|
2308
|
+
this.$handle.addSubForm(e, o);
|
|
2309
|
+
},
|
|
2310
|
+
"fc.el": (o) => {
|
|
2311
|
+
e.exportEl = o, o && ((o.$el || o).__rule__ = e.rule);
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
];
|
|
2316
|
+
return e.input && (this.vm.$props.disabled === !0 && (e.prop.props.disabled = !0), e.prop.model = {
|
|
2317
|
+
value: this.$handle.getFormData(e),
|
|
2318
|
+
callback: (o) => {
|
|
2319
|
+
this.onInput(e, o);
|
|
2320
|
+
},
|
|
2321
|
+
expression: `formData.${e.id}`
|
|
2322
|
+
}), T(n, e.prop), e.prop;
|
|
2323
|
+
},
|
|
2324
|
+
onMounted(e) {
|
|
2325
|
+
e.el = this.vm.$refs[e.ref], e.el && ((e.el.$el || e.el).__rule__ = e.rule), e.parser.mounted(e), this.$handle.effect(e, "mounted");
|
|
2326
|
+
},
|
|
2327
|
+
onInput(e, r) {
|
|
2328
|
+
this.$handle.onInput(e, r);
|
|
2329
|
+
},
|
|
2330
|
+
renderChildren(e) {
|
|
2331
|
+
const { children: r } = e.rule, i = this.orgChildren[e.id], s = (n) => !c.String(n) && n.__fc__ && !this.$handle.ctxs[n.__fc__.id];
|
|
2332
|
+
return !c.trueArray(r) && i ? (this.$handle.deferSyncValue(() => {
|
|
2333
|
+
i.forEach((n) => {
|
|
2334
|
+
n && s(n) && this.$handle.rmCtx(n.__fc__);
|
|
2335
|
+
});
|
|
2336
|
+
}), this.orgChildren[e.id] = [], []) : (i && this.$handle.deferSyncValue(() => {
|
|
2337
|
+
i.forEach((n) => {
|
|
2338
|
+
n && r.indexOf(n) === -1 && s(n) && this.$handle.rmCtx(n.__fc__);
|
|
2339
|
+
});
|
|
2340
|
+
}), r.map((n) => {
|
|
2341
|
+
if (n) {
|
|
2342
|
+
if (c.String(n)) return n;
|
|
2343
|
+
if (n.__fc__)
|
|
2344
|
+
return this.renderCtx(n.__fc__, e);
|
|
2345
|
+
n.type && this.vm.$nextTick(() => {
|
|
2346
|
+
this.$handle.loadChildren(r, e), this.$handle.refresh();
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
}));
|
|
2350
|
+
},
|
|
2351
|
+
defaultRender(e, r) {
|
|
2352
|
+
const i = e.prop;
|
|
2353
|
+
return i.component ? this.vNode.makeComponent(i.component, i, r) : this.vNode[e.type] ? this.vNode[e.type](i, r) : this.vNode[e.originType] ? this.vNode[e.originType](i, r) : this.vNode.make(ut(e.originType), i, r);
|
|
2354
|
+
},
|
|
2355
|
+
renderRule(e, r, i) {
|
|
2356
|
+
if (!e) return;
|
|
2357
|
+
if (c.String(e)) return e;
|
|
2358
|
+
let s;
|
|
2359
|
+
if (i)
|
|
2360
|
+
s = e.type;
|
|
2361
|
+
else if (s = e.is, e.type) {
|
|
2362
|
+
s = I(e.type);
|
|
2363
|
+
const o = this.vNode.aliasMap[s];
|
|
2364
|
+
o && (s = I(o));
|
|
2365
|
+
}
|
|
2366
|
+
if (!s) return;
|
|
2367
|
+
let n = [[r]];
|
|
2368
|
+
return c.trueArray(e.children) && n.push(e.children.map((o) => this.renderRule(o))), this.$h(s, y({}, e), n);
|
|
2369
|
+
}
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
function be(t) {
|
|
2373
|
+
m(this, {
|
|
2374
|
+
$handle: t,
|
|
2375
|
+
fc: t.fc,
|
|
2376
|
+
vm: t.vm,
|
|
2377
|
+
$manager: t.$manager,
|
|
2378
|
+
vNode: new t.fc.CreateNode(t.vm)
|
|
2379
|
+
}), nt(this, {
|
|
2380
|
+
options() {
|
|
2381
|
+
return t.options;
|
|
2382
|
+
},
|
|
2383
|
+
sort() {
|
|
2384
|
+
return t.sort;
|
|
2385
|
+
}
|
|
2386
|
+
}), this.initCache(), this.initRender();
|
|
2387
|
+
}
|
|
2388
|
+
or(be);
|
|
2389
|
+
ur(be);
|
|
2390
|
+
function fr(t) {
|
|
2391
|
+
m(t.prototype, {
|
|
2392
|
+
parseInjectEvent(e, r) {
|
|
2393
|
+
const i = e.inject || this.options.injectEvent;
|
|
2394
|
+
return this.parseEventLst(e, r, i);
|
|
2395
|
+
},
|
|
2396
|
+
parseEventLst(e, r, i, s) {
|
|
2397
|
+
return Object.keys(r).forEach((n) => {
|
|
2398
|
+
const o = this.parseEvent(e, r[n], i, s);
|
|
2399
|
+
o && (r[n] = o);
|
|
2400
|
+
}), r;
|
|
2401
|
+
},
|
|
2402
|
+
parseEvent(e, r, i, s) {
|
|
2403
|
+
if (c.Function(r) && (i !== !1 && !c.Undef(i) || r.__inject))
|
|
2404
|
+
return this.inject(e, r, i);
|
|
2405
|
+
if (!s && Array.isArray(r) && r[0] && (c.String(r[0]) || c.Function(r[0])))
|
|
2406
|
+
return this.parseEventLst(e, r, i, !0);
|
|
2407
|
+
if (c.String(r)) {
|
|
2408
|
+
const n = U(r);
|
|
2409
|
+
if (n && r !== n)
|
|
2410
|
+
return n.__inject ? this.parseEvent(e, n, i, !0) : n;
|
|
2411
|
+
}
|
|
2412
|
+
},
|
|
2413
|
+
parseEmit(e, r) {
|
|
2414
|
+
let i = {}, s = e.rule, { emitPrefix: n, field: o, name: a, inject: u } = s, l = s[r ? "emit" : "nativeEmit"] || [];
|
|
2415
|
+
return c.trueArray(l) && l.forEach((h) => {
|
|
2416
|
+
if (!h) return;
|
|
2417
|
+
let g, b = n || o || a;
|
|
2418
|
+
if (c.Object(h) && (g = h.inject, h = h.name, b = h.prefix || b), b) {
|
|
2419
|
+
r || (b = `native-${b}`);
|
|
2420
|
+
const k = X(`${b}-${h}`), v = (...O) => {
|
|
2421
|
+
this.vm.$emit(k, ...O), this.vm.$emit("emit-event", k, ...O);
|
|
2422
|
+
};
|
|
2423
|
+
if (v.__emit = !0, !g && u === !1)
|
|
2424
|
+
i[h] = v;
|
|
2425
|
+
else {
|
|
2426
|
+
let O = g || u || this.options.injectEvent;
|
|
2427
|
+
i[h] = c.Undef(O) ? v : this.inject(s, v, O);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
}), e.computed[r ? "on" : "nativeOn"] = i, i;
|
|
2431
|
+
},
|
|
2432
|
+
getInjectData(e, r) {
|
|
2433
|
+
const { option: i, rule: s } = this.vm.$options.propsData;
|
|
2434
|
+
return {
|
|
2435
|
+
api: this.api,
|
|
2436
|
+
$f: this.api,
|
|
2437
|
+
rule: s,
|
|
2438
|
+
self: e.__origin__,
|
|
2439
|
+
option: i,
|
|
2440
|
+
inject: r
|
|
2441
|
+
};
|
|
2442
|
+
},
|
|
2443
|
+
inject(e, r, i) {
|
|
2444
|
+
if (r.__origin) {
|
|
2445
|
+
if (this.watching && !this.loading)
|
|
2446
|
+
return r;
|
|
2447
|
+
r = r.__origin;
|
|
2448
|
+
}
|
|
2449
|
+
const s = this, n = function(...o) {
|
|
2450
|
+
const a = s.getInjectData(e, i);
|
|
2451
|
+
return a.args = [...o], o.unshift(a), r.apply(this, o);
|
|
2452
|
+
};
|
|
2453
|
+
return n.__origin = r, n.__json = r.__json, n;
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
const Be = ["hook:updated", "hook:mounted"];
|
|
2458
|
+
function hr(t) {
|
|
2459
|
+
m(t.prototype, {
|
|
2460
|
+
usePage() {
|
|
2461
|
+
const e = this.options.page;
|
|
2462
|
+
if (!e) return;
|
|
2463
|
+
let r = 25, i = cr(this.rules);
|
|
2464
|
+
c.Object(e) && (e.first && (r = parseInt(e.first, 10) || r), e.limit && (i = parseInt(e.limit, 10) || i)), m(this, {
|
|
2465
|
+
first: r,
|
|
2466
|
+
limit: i,
|
|
2467
|
+
pageEnd: this.rules.length <= r
|
|
2468
|
+
}), this.bus.$on("page-end", () => this.vm.$emit("page-end", this.api)), this.pageLoad();
|
|
2469
|
+
},
|
|
2470
|
+
pageLoad() {
|
|
2471
|
+
const e = () => {
|
|
2472
|
+
this.pageEnd ? (this.vm.$off(Be, e), this.bus.$emit("page-end")) : (this.first += this.limit, this.pageEnd = this.rules.length <= this.first, this.loadRule(), this.refresh());
|
|
2473
|
+
};
|
|
2474
|
+
this.vm.$on(Be, e);
|
|
2475
|
+
}
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
function cr(t) {
|
|
2479
|
+
return t.length < 31 ? 31 : Math.ceil(t.length / 3);
|
|
2480
|
+
}
|
|
2481
|
+
function dr(t) {
|
|
2482
|
+
m(t.prototype, {
|
|
2483
|
+
clearNextTick() {
|
|
2484
|
+
this.nextTick && clearTimeout(this.nextTick), this.nextTick = null;
|
|
2485
|
+
},
|
|
2486
|
+
bindNextTick(e) {
|
|
2487
|
+
this.clearNextTick(), this.nextTick = setTimeout(() => {
|
|
2488
|
+
e(), this.nextTick = null;
|
|
2489
|
+
}, 10);
|
|
2490
|
+
},
|
|
2491
|
+
render() {
|
|
2492
|
+
return ++this.loadedId, this.vm.unique > 0 ? this.$render.render() : (this.vm.unique = 1, []);
|
|
2493
|
+
}
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
function pr(t) {
|
|
2497
|
+
Object.defineProperties(t.origin, {
|
|
2498
|
+
__fc__: rt(t, !0)
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
function ft(t, e, r) {
|
|
2502
|
+
const i = te();
|
|
2503
|
+
m(this, {
|
|
2504
|
+
id: i,
|
|
2505
|
+
ref: i,
|
|
2506
|
+
wrapRef: i + "fi",
|
|
2507
|
+
rule: e,
|
|
2508
|
+
origin: e.__origin__ || e,
|
|
2509
|
+
name: e.name,
|
|
2510
|
+
watch: [],
|
|
2511
|
+
linkOn: [],
|
|
2512
|
+
root: [],
|
|
2513
|
+
ctrlRule: [],
|
|
2514
|
+
parent: null,
|
|
2515
|
+
cacheConfig: null,
|
|
2516
|
+
prop: y({}, e),
|
|
2517
|
+
computed: {},
|
|
2518
|
+
payload: {},
|
|
2519
|
+
input: !!e.field,
|
|
2520
|
+
el: void 0,
|
|
2521
|
+
exportEl: void 0,
|
|
2522
|
+
defaultValue: e.field ? N(r) : void 0,
|
|
2523
|
+
field: e.field || void 0
|
|
2524
|
+
}), this.updateType(), this.updateKey(), pr(this), this.update(t, !0);
|
|
2525
|
+
}
|
|
2526
|
+
m(ft.prototype, {
|
|
2527
|
+
effectData(t) {
|
|
2528
|
+
return this.payload[t] || (this.payload[t] = {}), this.payload[t];
|
|
2529
|
+
},
|
|
2530
|
+
clearEffectData(t) {
|
|
2531
|
+
t === void 0 ? this.payload = {} : delete this.payload[t];
|
|
2532
|
+
},
|
|
2533
|
+
updateKey(t) {
|
|
2534
|
+
this.key = te(), t && this.parent && this.parent.updateKey(t);
|
|
2535
|
+
},
|
|
2536
|
+
updateType() {
|
|
2537
|
+
this.originType = this.rule.type, this.type = I(this.rule.type);
|
|
2538
|
+
},
|
|
2539
|
+
setParser(t) {
|
|
2540
|
+
this.parser = t, t.init(this);
|
|
2541
|
+
},
|
|
2542
|
+
initProp() {
|
|
2543
|
+
const t = y({}, this.rule);
|
|
2544
|
+
delete t.children, this.prop = q({}, [t, ...Object.keys(this.payload).map((e) => this.payload[e]), this.computed]);
|
|
2545
|
+
},
|
|
2546
|
+
injectValidate() {
|
|
2547
|
+
return j(this.prop.validate).map((t) => {
|
|
2548
|
+
if (c.Function(t.validator)) {
|
|
2549
|
+
const e = y({}, t), r = this;
|
|
2550
|
+
return e.validator = function(...i) {
|
|
2551
|
+
return t.validator.call({
|
|
2552
|
+
that: this,
|
|
2553
|
+
id: r.id,
|
|
2554
|
+
field: r.field,
|
|
2555
|
+
rule: r.rule,
|
|
2556
|
+
api: r.$handle.api
|
|
2557
|
+
}, ...i);
|
|
2558
|
+
}, e;
|
|
2559
|
+
}
|
|
2560
|
+
return t;
|
|
2561
|
+
});
|
|
2562
|
+
},
|
|
2563
|
+
check(t) {
|
|
2564
|
+
return this.vm === t.vm;
|
|
2565
|
+
},
|
|
2566
|
+
unwatch() {
|
|
2567
|
+
this.watch.forEach((t) => t()), this.watch = [];
|
|
2568
|
+
},
|
|
2569
|
+
unlink() {
|
|
2570
|
+
this.linkOn.forEach((t) => t()), this.linkOn = [];
|
|
2571
|
+
},
|
|
2572
|
+
link() {
|
|
2573
|
+
this.unlink(), this.$handle.appendLink(this);
|
|
2574
|
+
},
|
|
2575
|
+
watchTo() {
|
|
2576
|
+
this.$handle.watchCtx(this);
|
|
2577
|
+
},
|
|
2578
|
+
delete() {
|
|
2579
|
+
this.unwatch(), this.unlink(), this.rmCtrl(), m(this, {
|
|
2580
|
+
deleted: !0,
|
|
2581
|
+
prop: y({}, this.rule),
|
|
2582
|
+
computed: {},
|
|
2583
|
+
el: void 0,
|
|
2584
|
+
$handle: void 0,
|
|
2585
|
+
$render: void 0,
|
|
2586
|
+
$api: void 0,
|
|
2587
|
+
vm: void 0,
|
|
2588
|
+
vNode: void 0,
|
|
2589
|
+
parent: null,
|
|
2590
|
+
cacheConfig: null
|
|
2591
|
+
});
|
|
2592
|
+
},
|
|
2593
|
+
rmCtrl() {
|
|
2594
|
+
this.ctrlRule.forEach((t) => t.__fc__ && t.__fc__.rm()), this.ctrlRule = [];
|
|
2595
|
+
},
|
|
2596
|
+
rm() {
|
|
2597
|
+
const t = () => {
|
|
2598
|
+
let e = this.root.indexOf(this.origin);
|
|
2599
|
+
e > -1 && (this.root.splice(e, 1), this.$handle && this.$handle.refresh());
|
|
2600
|
+
};
|
|
2601
|
+
if (this.deleted) {
|
|
2602
|
+
t();
|
|
2603
|
+
return;
|
|
2604
|
+
}
|
|
2605
|
+
this.$handle.noWatch(() => {
|
|
2606
|
+
this.$handle.deferSyncValue(() => {
|
|
2607
|
+
this.rmCtrl(), t(), this.$handle.rmCtx(this), m(this, {
|
|
2608
|
+
root: []
|
|
2609
|
+
});
|
|
2610
|
+
}, this.input);
|
|
2611
|
+
});
|
|
2612
|
+
},
|
|
2613
|
+
update(t, e) {
|
|
2614
|
+
m(this, {
|
|
2615
|
+
deleted: !1,
|
|
2616
|
+
$handle: t,
|
|
2617
|
+
$render: t.$render,
|
|
2618
|
+
$api: t.api,
|
|
2619
|
+
vm: t.vm,
|
|
2620
|
+
trueType: t.getType(this.originType),
|
|
2621
|
+
vNode: t.$render.vNode,
|
|
2622
|
+
updated: !1,
|
|
2623
|
+
cacheValue: this.rule.value
|
|
2624
|
+
}), !e && this.unwatch(), this.watchTo(), this.link();
|
|
2625
|
+
}
|
|
2626
|
+
});
|
|
2627
|
+
function mr(t) {
|
|
2628
|
+
m(t.prototype, {
|
|
2629
|
+
nextRefresh(e) {
|
|
2630
|
+
const r = this.loadedId;
|
|
2631
|
+
this.vm.$nextTick(() => {
|
|
2632
|
+
r === this.loadedId && (e ? e() : this.refresh());
|
|
2633
|
+
});
|
|
2634
|
+
},
|
|
2635
|
+
parseRule(e) {
|
|
2636
|
+
const r = Ve(e);
|
|
2637
|
+
return Object.defineProperties(r, {
|
|
2638
|
+
__origin__: rt(e, !0)
|
|
2639
|
+
}), yr(r), this.appendValue(r), r.options = Array.isArray(r.options) ? r.options : [], [r, r.prefix, r.suffix].forEach((i) => {
|
|
2640
|
+
i && this.loadFn(i, r);
|
|
2641
|
+
}), this.loadCtrl(r), r.update && (r.update = U(r.update)), r;
|
|
2642
|
+
},
|
|
2643
|
+
loadFn(e, r) {
|
|
2644
|
+
["on", "props", "nativeOn", "deep"].forEach((i) => {
|
|
2645
|
+
e[i] && this.parseInjectEvent(r, e[i]);
|
|
2646
|
+
});
|
|
2647
|
+
},
|
|
2648
|
+
loadCtrl(e) {
|
|
2649
|
+
e.control && e.control.forEach((r) => {
|
|
2650
|
+
r.handle && (r.handle = U(r.handle));
|
|
2651
|
+
});
|
|
2652
|
+
},
|
|
2653
|
+
syncProp(e) {
|
|
2654
|
+
const r = e.rule;
|
|
2655
|
+
c.trueArray(r.sync) && T([{
|
|
2656
|
+
on: r.sync.reduce((i, s) => (i[`update:${s}`] = (n) => {
|
|
2657
|
+
r.props[s] = n, this.vm.$emit("sync", s, n, r, this.fapi);
|
|
2658
|
+
}, i), {})
|
|
2659
|
+
}], e.computed);
|
|
2660
|
+
},
|
|
2661
|
+
loadRule() {
|
|
2662
|
+
this.cycleLoad = !1, this.loading = !0, this.pageEnd && this.bus.$emit("load-start"), this.deferSyncValue(() => {
|
|
2663
|
+
if (this._loadRule(this.rules), this.loading = !1, this.cycleLoad && this.pageEnd)
|
|
2664
|
+
return this.loadRule();
|
|
2665
|
+
this.pageEnd && this.bus.$emit("load-end"), this.vm._renderRule(), this.$render.initOrgChildren(), this.syncForm();
|
|
2666
|
+
});
|
|
2667
|
+
},
|
|
2668
|
+
loadChildren(e, r) {
|
|
2669
|
+
if (this.cycleLoad = !1, this.loading = !0, this.bus.$emit("load-start"), this._loadRule(e, r), this.loading = !1, this.cycleLoad)
|
|
2670
|
+
return this.loadRule();
|
|
2671
|
+
this.bus.$emit("load-end"), this.syncForm(), this.$render.clearCache(r);
|
|
2672
|
+
},
|
|
2673
|
+
_loadRule(e, r) {
|
|
2674
|
+
const i = (n) => {
|
|
2675
|
+
let o = e[n - 1];
|
|
2676
|
+
if (!o || !o.__fc__)
|
|
2677
|
+
return n > 0 ? i(n - 1) : -1;
|
|
2678
|
+
let a = this.sort.indexOf(o.__fc__.id);
|
|
2679
|
+
return a > -1 ? a : i(n - 1);
|
|
2680
|
+
}, s = (n, o) => {
|
|
2681
|
+
c.trueArray(n) && this._loadRule(n, o);
|
|
2682
|
+
};
|
|
2683
|
+
e.map((n, o) => {
|
|
2684
|
+
if (r && !c.Object(n) || !this.pageEnd && !r && o >= this.first) return;
|
|
2685
|
+
if (n.__fc__ && n.__fc__.root === e && this.ctxs[n.__fc__.id])
|
|
2686
|
+
return s(n.__fc__.rule.children, n.__fc__), n.__fc__;
|
|
2687
|
+
let a = Ve(n);
|
|
2688
|
+
const u = () => !!(a.field && this.fieldCtx[a.field] && this.fieldCtx[a.field][0] !== n.__fc__);
|
|
2689
|
+
this.ruleEffect(a, "init", { repeat: u() }), u() && this.vm.$emit("repeat-field", n, this.api);
|
|
2690
|
+
let l, h = !1, g = !!n.__fc__, b = a.value;
|
|
2691
|
+
if (g) {
|
|
2692
|
+
l = n.__fc__, b = l.defaultValue;
|
|
2693
|
+
const v = !l.check(this);
|
|
2694
|
+
if (l.deleted) {
|
|
2695
|
+
if (v) {
|
|
2696
|
+
if (Le(l))
|
|
2697
|
+
return;
|
|
2698
|
+
l.update(this);
|
|
2699
|
+
}
|
|
2700
|
+
} else if (v) {
|
|
2701
|
+
if (Le(l))
|
|
2702
|
+
return;
|
|
2703
|
+
e[o] = n = n._clone ? n._clone() : $e(n), l = null, h = !0;
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
if (l)
|
|
2707
|
+
l.originType !== l.rule.type && (l.updateType(), this.bindParser(l)), this.appendValue(l.rule);
|
|
2708
|
+
else {
|
|
2709
|
+
const v = this.parseRule(n);
|
|
2710
|
+
l = new ft(this, v, b), this.bindParser(l);
|
|
2711
|
+
}
|
|
2712
|
+
if ([!1, !0].forEach((v) => this.parseEmit(l, v)), this.syncProp(l), l.parent = r || null, l.root = e, this.setCtx(l), !h && !g && this.effect(l, "load"), this.effect(l, "created"), l.parser.loadChildren === !1 || s(l.rule.children, l), !r) {
|
|
2713
|
+
const v = i(o);
|
|
2714
|
+
v > -1 || !o ? this.sort.splice(v + 1, 0, l.id) : this.sort.push(l.id);
|
|
2715
|
+
}
|
|
2716
|
+
const k = l.rule;
|
|
2717
|
+
return l.updated || (l.updated = !0, c.Function(k.update) && this.bus.$once("load-end", () => {
|
|
2718
|
+
this.refreshUpdate(l, k.value, "init");
|
|
2719
|
+
}), this.effect(l, "loaded")), l.input && Object.defineProperty(k, "value", this.valueHandle(l)), this.refreshControl(l) && (this.cycleLoad = !0), l;
|
|
2720
|
+
});
|
|
2721
|
+
},
|
|
2722
|
+
refreshControl(e) {
|
|
2723
|
+
return e.input && e.rule.control && this.useCtrl(e);
|
|
2724
|
+
},
|
|
2725
|
+
useCtrl(e) {
|
|
2726
|
+
const r = gr(e), i = [], s = this.api;
|
|
2727
|
+
if (!r.length) return !1;
|
|
2728
|
+
for (let a = 0; a < r.length; a++) {
|
|
2729
|
+
const u = r[a], l = u.handle || function(g) {
|
|
2730
|
+
return (W[u.condition || "=="] || W["=="])(g, u.value);
|
|
2731
|
+
};
|
|
2732
|
+
if (!c.trueArray(u.rule)) continue;
|
|
2733
|
+
const h = H(y({}, u), {
|
|
2734
|
+
valid: E(() => l(e.rule.value, s)),
|
|
2735
|
+
ctrl: $r(e, u.rule),
|
|
2736
|
+
isHidden: c.String(u.rule[0])
|
|
2737
|
+
});
|
|
2738
|
+
h.valid && h.ctrl || !h.valid && !h.ctrl && !h.isHidden || i.push(h);
|
|
2739
|
+
}
|
|
2740
|
+
if (!i.length) return !1;
|
|
2741
|
+
const n = [];
|
|
2742
|
+
let o = !1;
|
|
2743
|
+
return this.deferSyncValue(() => {
|
|
2744
|
+
i.reverse().forEach(({ isHidden: a, valid: u, rule: l, prepend: h, append: g, child: b, ctrl: k, method: v }) => {
|
|
2745
|
+
if (a) {
|
|
2746
|
+
u ? e.ctrlRule.push({
|
|
2747
|
+
__ctrl: !0,
|
|
2748
|
+
children: l,
|
|
2749
|
+
valid: u
|
|
2750
|
+
}) : e.ctrlRule.splice(e.ctrlRule.indexOf(k), 1), n[u ? "push" : "unshift"](() => {
|
|
2751
|
+
v === "disabled" ? this.api.disabled(!u, l) : v === "display" ? this.api.display(u, l) : v === "required" ? (l.forEach((O) => {
|
|
2752
|
+
this.api.setEffect(O, "required", u);
|
|
2753
|
+
}), u || this.api.clearValidateState(l)) : this.api.hidden(!u, l);
|
|
2754
|
+
});
|
|
2755
|
+
return;
|
|
2756
|
+
}
|
|
2757
|
+
if (u) {
|
|
2758
|
+
o = !0;
|
|
2759
|
+
const O = {
|
|
2760
|
+
type: "fcFragment",
|
|
2761
|
+
native: !0,
|
|
2762
|
+
__ctrl: !0,
|
|
2763
|
+
children: l
|
|
2764
|
+
};
|
|
2765
|
+
e.ctrlRule.push(O), this.bus.$once("load-start", () => {
|
|
2766
|
+
h ? s.prepend(O, h, b) : g || b ? s.append(O, g || e.id, b) : e.root.splice(e.root.indexOf(e.origin) + 1, 0, O);
|
|
2767
|
+
});
|
|
2768
|
+
} else {
|
|
2769
|
+
e.ctrlRule.splice(e.ctrlRule.indexOf(k), 1);
|
|
2770
|
+
const O = K(k);
|
|
2771
|
+
O && O.rm();
|
|
2772
|
+
}
|
|
2773
|
+
});
|
|
2774
|
+
}), n.length && this.vm.$nextTick(() => {
|
|
2775
|
+
n.forEach((a) => a());
|
|
2776
|
+
}), this.vm.$emit("control", e.origin, this.api), this.effect(e, "control"), o;
|
|
2777
|
+
},
|
|
2778
|
+
reloadRule(e) {
|
|
2779
|
+
return this._reloadRule(e);
|
|
2780
|
+
},
|
|
2781
|
+
_reloadRule(e) {
|
|
2782
|
+
e || (e = this.rules);
|
|
2783
|
+
const r = y({}, this.ctxs);
|
|
2784
|
+
this.clearNextTick(), this.$render.clearOrgChildren(), this.initData(e), this.fc.rules = e, this.deferSyncValue(() => {
|
|
2785
|
+
this.bus.$once("load-end", () => {
|
|
2786
|
+
Object.keys(r).filter((i) => this.ctxs[i] === void 0).forEach((i) => this.rmCtx(r[i])), this.$render.clearCacheAll();
|
|
2787
|
+
}), this.reloading = !0, this.loadRule(), this.reloading = !1, this.refresh(), this.vm.$emit("reloading", this.api);
|
|
2788
|
+
}), this.bus.$off("next-tick", this.nextReload), this.bus.$once("next-tick", this.nextReload), this.vm.$emit("update", this.api);
|
|
2789
|
+
},
|
|
2790
|
+
//todo 组件生成全部通过 alias
|
|
2791
|
+
refresh() {
|
|
2792
|
+
this.vm._refresh();
|
|
2793
|
+
}
|
|
2794
|
+
});
|
|
2795
|
+
}
|
|
2796
|
+
function yr(t) {
|
|
2797
|
+
const e = st();
|
|
2798
|
+
return Object.keys(e).forEach((r) => {
|
|
2799
|
+
w(t, r) || F(t, r, e[r]);
|
|
2800
|
+
}), t;
|
|
2801
|
+
}
|
|
2802
|
+
function gr(t) {
|
|
2803
|
+
const e = t.rule.control || [];
|
|
2804
|
+
return c.Object(e) ? [e] : e;
|
|
2805
|
+
}
|
|
2806
|
+
function $r(t, e) {
|
|
2807
|
+
for (let r = 0; r < t.ctrlRule.length; r++) {
|
|
2808
|
+
const i = t.ctrlRule[r];
|
|
2809
|
+
if (i.children === e)
|
|
2810
|
+
return i;
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
function Le(t) {
|
|
2814
|
+
return !!t.rule.__ctrl;
|
|
2815
|
+
}
|
|
2816
|
+
function vr(t) {
|
|
2817
|
+
m(t.prototype, {
|
|
2818
|
+
getValue(e) {
|
|
2819
|
+
return c.Undef(e.cacheValue) && (e.cacheValue = e.parser.toValue(this.getFormData(e), e)), e.cacheValue;
|
|
2820
|
+
},
|
|
2821
|
+
setValue(e, r, i, s) {
|
|
2822
|
+
e.deleted || (e.cacheValue = r, this.changeStatus = !0, this.nextRefresh(), this.$render.clearCache(e), this.setFormData(e, i), this.syncValue(), this.valueChange(e, r), this.vm.$emit("change", e.field, r, e.origin, this.api, s || !1), this.effect(e, "value"), this.emitEvent("change", e.field, r, {
|
|
2823
|
+
rule: e.origin,
|
|
2824
|
+
api: this.api,
|
|
2825
|
+
setFlag: s || !1
|
|
2826
|
+
}));
|
|
2827
|
+
},
|
|
2828
|
+
onInput(e, r) {
|
|
2829
|
+
let i;
|
|
2830
|
+
e.input && (this.isQuote(e, i = e.parser.toValue(r, e)) || this.isChange(e, i)) && this.setValue(e, i, r);
|
|
2831
|
+
},
|
|
2832
|
+
setFormData(e, r) {
|
|
2833
|
+
F(this.formData, e.id, r === null ? void 0 : r);
|
|
2834
|
+
},
|
|
2835
|
+
getFormData(e) {
|
|
2836
|
+
return this.formData[e.id];
|
|
2837
|
+
},
|
|
2838
|
+
validate() {
|
|
2839
|
+
return Me(this.vm.validate), this.fields().forEach((e) => {
|
|
2840
|
+
this.fieldCtx[e].forEach((r) => {
|
|
2841
|
+
this.vm.validate[r.id] = j(r.rule.validate);
|
|
2842
|
+
});
|
|
2843
|
+
}), this.vm.validate;
|
|
2844
|
+
},
|
|
2845
|
+
syncForm() {
|
|
2846
|
+
Me(this.form), Object.defineProperties(this.form, this.fields().reduce((e, r) => {
|
|
2847
|
+
const i = this.getFieldCtx(r), s = this.valueHandle(i);
|
|
2848
|
+
return s.configurable = !0, e[r] = s, e;
|
|
2849
|
+
}, this.options.appendValue !== !1 ? Object.keys(this.appendData).reduce((e, r) => (e[r] = {
|
|
2850
|
+
enumerable: !0,
|
|
2851
|
+
configurable: !0,
|
|
2852
|
+
get: () => this.appendData[r],
|
|
2853
|
+
set: (i) => {
|
|
2854
|
+
this.appendData[r] = i;
|
|
2855
|
+
}
|
|
2856
|
+
}, e), {}) : {})), this.syncValue();
|
|
2857
|
+
},
|
|
2858
|
+
valueHandle(e) {
|
|
2859
|
+
return {
|
|
2860
|
+
enumerable: !0,
|
|
2861
|
+
get: () => this.getValue(e),
|
|
2862
|
+
set: (r) => {
|
|
2863
|
+
this.isChange(e, r) && this.setValue(e, r, e.parser.toFormValue(r, e), !0);
|
|
2864
|
+
}
|
|
2865
|
+
};
|
|
2866
|
+
},
|
|
2867
|
+
appendValue(e) {
|
|
2868
|
+
!e.field || !w(this.appendData, e.field) || (e.value = this.appendData[e.field], delete this.appendData[e.field]);
|
|
2869
|
+
},
|
|
2870
|
+
addSubForm(e, r) {
|
|
2871
|
+
this.subForm[e.id] = r;
|
|
2872
|
+
},
|
|
2873
|
+
deferSyncValue(e, r) {
|
|
2874
|
+
this.deferSyncFn || (this.deferSyncFn = e), this.deferSyncFn.sync || (this.deferSyncFn.sync = r), E(e), this.deferSyncFn === e && (this.deferSyncFn = null, e.sync && this.syncValue());
|
|
2875
|
+
},
|
|
2876
|
+
syncValue() {
|
|
2877
|
+
if (this.deferSyncFn)
|
|
2878
|
+
return this.deferSyncFn.sync = !0;
|
|
2879
|
+
this.vm._updateValue(y(y({}, this.options.appendValue !== !1 ? this.appendData : {}), this.form));
|
|
2880
|
+
},
|
|
2881
|
+
isChange(e, r) {
|
|
2882
|
+
return JSON.stringify(e.rule.value, Ne) !== JSON.stringify(r === null ? void 0 : r, Ne);
|
|
2883
|
+
},
|
|
2884
|
+
isQuote(e, r) {
|
|
2885
|
+
return (c.Object(r) || Array.isArray(r)) && r === e.rule.value;
|
|
2886
|
+
},
|
|
2887
|
+
refreshUpdate(e, r, i, s) {
|
|
2888
|
+
if (c.Function(e.rule.update)) {
|
|
2889
|
+
const n = E(() => e.rule.update(r, e.origin, this.api, {
|
|
2890
|
+
origin: i || "change",
|
|
2891
|
+
linkField: s
|
|
2892
|
+
}));
|
|
2893
|
+
if (n === void 0) return;
|
|
2894
|
+
e.rule.hidden = n === !0;
|
|
2895
|
+
}
|
|
2896
|
+
},
|
|
2897
|
+
valueChange(e, r) {
|
|
2898
|
+
this.refreshRule(e, r), this.bus.$emit("change-" + e.field, r);
|
|
2899
|
+
},
|
|
2900
|
+
refreshRule(e, r, i, s) {
|
|
2901
|
+
this.refreshControl(e) && (this.$render.clearCacheAll(), this.loadRule(), this.vm.$emit("update", this.api), this.refresh()), this.refreshUpdate(e, r, i, s);
|
|
2902
|
+
},
|
|
2903
|
+
appendLink(e) {
|
|
2904
|
+
const r = e.rule.link;
|
|
2905
|
+
c.trueArray(r) && r.forEach((i) => {
|
|
2906
|
+
const s = () => this.refreshRule(e, e.rule.value, "link", i);
|
|
2907
|
+
this.bus.$on("change-" + i, s), e.linkOn.push(() => this.bus.$off("change-" + i, s));
|
|
2908
|
+
});
|
|
2909
|
+
},
|
|
2910
|
+
fields() {
|
|
2911
|
+
return Object.keys(this.fieldCtx);
|
|
2912
|
+
}
|
|
2913
|
+
});
|
|
2914
|
+
}
|
|
2915
|
+
function Ne(t, e) {
|
|
2916
|
+
return typeof e == "function" ? "" + e : e;
|
|
2917
|
+
}
|
|
2918
|
+
function Me(t) {
|
|
2919
|
+
Object.keys(t).forEach((e) => delete t[e]);
|
|
2920
|
+
}
|
|
2921
|
+
const ce = {
|
|
2922
|
+
init(t) {
|
|
2923
|
+
},
|
|
2924
|
+
toFormValue(t, e) {
|
|
2925
|
+
return t;
|
|
2926
|
+
},
|
|
2927
|
+
toValue(t, e) {
|
|
2928
|
+
return t;
|
|
2929
|
+
},
|
|
2930
|
+
mounted(t) {
|
|
2931
|
+
},
|
|
2932
|
+
render(t, e) {
|
|
2933
|
+
return e.$render.defaultRender(e, t);
|
|
2934
|
+
},
|
|
2935
|
+
preview(t, e) {
|
|
2936
|
+
return this.render(t, e);
|
|
2937
|
+
},
|
|
2938
|
+
mergeProp(t) {
|
|
2939
|
+
}
|
|
2940
|
+
}, br = ["field", "value", "vm", "template", "name", "config", "control", "inject", "sync", "payload", "optionsTo", "update", "component", "cache"];
|
|
2941
|
+
function Cr(t) {
|
|
2942
|
+
m(t.prototype, {
|
|
2943
|
+
getCtx(e) {
|
|
2944
|
+
return this.getFieldCtx(e) || this.getNameCtx(e)[0] || this.ctxs[e];
|
|
2945
|
+
},
|
|
2946
|
+
getCtxs(e) {
|
|
2947
|
+
return this.fieldCtx[e] || this.nameCtx[e] || (this.ctxs[e] ? [this.ctxs[e]] : []);
|
|
2948
|
+
},
|
|
2949
|
+
setIdCtx(e, r, i) {
|
|
2950
|
+
const s = `${i}Ctx`;
|
|
2951
|
+
this[s][r] ? this[s][r].push(e) : this[s][r] = [e];
|
|
2952
|
+
},
|
|
2953
|
+
rmIdCtx(e, r, i) {
|
|
2954
|
+
const s = `${i}Ctx`, n = this[s][r];
|
|
2955
|
+
if (!n) return !1;
|
|
2956
|
+
const o = n.splice(n.indexOf(e) >>> 0, 1).length > 0;
|
|
2957
|
+
return n.length || delete this[s][r], o;
|
|
2958
|
+
},
|
|
2959
|
+
getFieldCtx(e) {
|
|
2960
|
+
return (this.fieldCtx[e] || [])[0];
|
|
2961
|
+
},
|
|
2962
|
+
getNameCtx(e) {
|
|
2963
|
+
return this.nameCtx[e] || [];
|
|
2964
|
+
},
|
|
2965
|
+
setCtx(e) {
|
|
2966
|
+
let { id: r, field: i, name: s, rule: n } = e;
|
|
2967
|
+
this.ctxs[r] = e, s && this.setIdCtx(e, s, "name"), e.input && (this.setIdCtx(e, i, "field"), this.setFormData(e, e.parser.toFormValue(n.value, e)), this.isMounted && !this.reloading && this.vm.$emit("change", e.field, n.value, e.origin, this.api));
|
|
2968
|
+
},
|
|
2969
|
+
getParser(e) {
|
|
2970
|
+
const r = this.fc.parsers;
|
|
2971
|
+
return r[e.originType] || r[I(e.type)] || r[e.trueType] || ce;
|
|
2972
|
+
},
|
|
2973
|
+
bindParser(e) {
|
|
2974
|
+
e.setParser(this.getParser(e));
|
|
2975
|
+
},
|
|
2976
|
+
getType(e) {
|
|
2977
|
+
const r = this.fc.CreateNode.aliasMap, i = r[e] || r[I(e)] || e;
|
|
2978
|
+
return I(i);
|
|
2979
|
+
},
|
|
2980
|
+
noWatch(e) {
|
|
2981
|
+
this.noWatchFn || (this.noWatchFn = e), E(e), this.noWatchFn === e && (this.noWatchFn = null);
|
|
2982
|
+
},
|
|
2983
|
+
watchCtx(e) {
|
|
2984
|
+
const r = this.vm;
|
|
2985
|
+
Object.keys(e.rule).filter((i) => i[0] !== "_" && i[0] !== "$" && br.indexOf(i) === -1).forEach((i) => {
|
|
2986
|
+
const s = i === "children";
|
|
2987
|
+
e.watch.push(r.$watch(() => e.rule[i], (n, o) => {
|
|
2988
|
+
if (!(this.loading || this.noWatchFn || this.reloading)) {
|
|
2989
|
+
if (s && e.parser.loadChildren === !1) {
|
|
2990
|
+
this.$render.clearCache(e), this.nextRefresh();
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2993
|
+
if (this.watching = !0, i === "link") {
|
|
2994
|
+
e.link();
|
|
2995
|
+
return;
|
|
2996
|
+
} else if (["props", "on", "nativeOn", "deep"].indexOf(i) > -1)
|
|
2997
|
+
this.parseInjectEvent(e.rule, n || {}), i === "props" && e.input && this.setFormData(e, e.parser.toFormValue(e.rule.value, e));
|
|
2998
|
+
else if (["emit", "nativeEmit"].indexOf(i) > -1)
|
|
2999
|
+
this.parseEmit(e, i === "emit");
|
|
3000
|
+
else if (["prefix", "suffix"].indexOf(i) > -1)
|
|
3001
|
+
n && this.loadFn(n, e.rule);
|
|
3002
|
+
else if (i === "type")
|
|
3003
|
+
e.updateType(), this.bindParser(e);
|
|
3004
|
+
else if (i === "children") {
|
|
3005
|
+
const a = c.trueArray(n);
|
|
3006
|
+
this.deferSyncValue(() => {
|
|
3007
|
+
n !== o && (this.rmSub(o, e), this.$render.initOrgChildren()), a && this.loadChildren(n, e), this.vm.$emit("update", this.api);
|
|
3008
|
+
});
|
|
3009
|
+
}
|
|
3010
|
+
this.$render.clearCache(e), this.refresh(), this.watching = !1;
|
|
3011
|
+
}
|
|
3012
|
+
}, { deep: !s, sync: s }));
|
|
3013
|
+
}), this.watchEffect(e);
|
|
3014
|
+
},
|
|
3015
|
+
rmSub(e, r) {
|
|
3016
|
+
c.trueArray(e) && e.forEach((i) => {
|
|
3017
|
+
i && i.__fc__ && i.__fc__.parent === r && this.rmCtx(i.__fc__);
|
|
3018
|
+
});
|
|
3019
|
+
},
|
|
3020
|
+
rmCtx(e) {
|
|
3021
|
+
if (e.deleted) return;
|
|
3022
|
+
const { id: r, field: i, input: s, name: n } = e;
|
|
3023
|
+
e.input && Object.defineProperty(e.rule, "value", {
|
|
3024
|
+
value: e.rule.value,
|
|
3025
|
+
writable: !0
|
|
3026
|
+
}), L(this.ctxs, r), L(this.$render.tempList, r), L(this.$render.orgChildren, r), L(this.vm.ctxInject, r), L(this.formData, r), L(this.subForm, r), L(e, "cacheValue"), s && this.rmIdCtx(e, i, "field"), n && this.rmIdCtx(e, n, "name"), s && !w(this.fieldCtx, i) && L(this.form, i), this.deferSyncValue(() => {
|
|
3027
|
+
this.reloading || (e.parser.loadChildren !== !1 && c.trueArray(e.rule.children) && e.rule.children.forEach((a) => a.__fc__ && this.rmCtx(a.__fc__)), e.root === this.rules && this.vm._renderRule());
|
|
3028
|
+
}, s);
|
|
3029
|
+
const o = this.sort.indexOf(r);
|
|
3030
|
+
return o > -1 && this.sort.splice(o, 1), this.$render.clearCache(e), e.delete(), this.effect(e, "deleted"), s && !this.fieldCtx[i] && this.vm.$emit("removeField", i, e.rule, this.api), e.rule.__ctrl || this.vm.$emit("removeRule", e.rule, this.api), e;
|
|
3031
|
+
}
|
|
3032
|
+
});
|
|
3033
|
+
}
|
|
3034
|
+
function _r(t) {
|
|
3035
|
+
m(t.prototype, {
|
|
3036
|
+
mounted() {
|
|
3037
|
+
const e = () => {
|
|
3038
|
+
this.isMounted = !0, this.lifecycle("mounted");
|
|
3039
|
+
};
|
|
3040
|
+
this.pageEnd ? e() : this.bus.$once("page-end", e);
|
|
3041
|
+
},
|
|
3042
|
+
lifecycle(e) {
|
|
3043
|
+
this.vm.$emit(e, this.api), this.emitEvent(e, this.api);
|
|
3044
|
+
},
|
|
3045
|
+
emitEvent(e, ...r) {
|
|
3046
|
+
const i = this.options[e] || this.options[I("on-" + e)];
|
|
3047
|
+
if (i) {
|
|
3048
|
+
const s = U(i);
|
|
3049
|
+
c.Function(s) && E(() => s(...r));
|
|
3050
|
+
}
|
|
3051
|
+
this.bus.$emit(e, ...r);
|
|
3052
|
+
}
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
function kr(t) {
|
|
3056
|
+
m(t.prototype, {
|
|
3057
|
+
useProvider() {
|
|
3058
|
+
const e = this.fc.providers;
|
|
3059
|
+
Object.keys(e).forEach((r) => {
|
|
3060
|
+
let i = e[r];
|
|
3061
|
+
c.Function(i) && (i = i(this.fc)), i._c = wr(i), this.onEffect(i), this.providers[r] = i;
|
|
3062
|
+
});
|
|
3063
|
+
},
|
|
3064
|
+
onEffect(e) {
|
|
3065
|
+
const r = [];
|
|
3066
|
+
(e._c || ["*"]).forEach((i) => {
|
|
3067
|
+
const s = i === "*" ? "*" : this.getType(i);
|
|
3068
|
+
r.indexOf(s) > -1 || (r.push(s), this.bus.$on(`p:${e.name}:${s}:${e.input ? 1 : 0}`, (n, o) => {
|
|
3069
|
+
e[n] && e[n](...o);
|
|
3070
|
+
}));
|
|
3071
|
+
}), e._used = r;
|
|
3072
|
+
},
|
|
3073
|
+
watchEffect(e) {
|
|
3074
|
+
const r = this.vm;
|
|
3075
|
+
let i = {
|
|
3076
|
+
required: () => {
|
|
3077
|
+
var s, n;
|
|
3078
|
+
return (w(e.rule, "$required") ? e.rule.$required : (n = (s = e.rule) == null ? void 0 : s.effect) == null ? void 0 : n.required) || !1;
|
|
3079
|
+
}
|
|
3080
|
+
};
|
|
3081
|
+
Object.keys(e.rule.effect || {}).forEach((s) => {
|
|
3082
|
+
i[s] = () => e.rule.effect[s];
|
|
3083
|
+
}), Object.keys(e.rule).forEach((s) => {
|
|
3084
|
+
s[0] === "$" && (i[s.substr(1)] = () => e.rule[s]);
|
|
3085
|
+
}), Object.keys(i || {}).forEach((s) => {
|
|
3086
|
+
e.watch.push(r.$watch(i[s], (n) => {
|
|
3087
|
+
this.effect(e, "watch", { [s]: n });
|
|
3088
|
+
}, { deep: !0 }));
|
|
3089
|
+
});
|
|
3090
|
+
},
|
|
3091
|
+
ruleEffect(e, r, i) {
|
|
3092
|
+
this.emitEffect({
|
|
3093
|
+
rule: e,
|
|
3094
|
+
input: !!e.field,
|
|
3095
|
+
type: this.getType(e.type)
|
|
3096
|
+
}, r, i);
|
|
3097
|
+
},
|
|
3098
|
+
effect(e, r, i) {
|
|
3099
|
+
this.emitEffect({
|
|
3100
|
+
rule: e.rule,
|
|
3101
|
+
input: e.input,
|
|
3102
|
+
type: e.trueType,
|
|
3103
|
+
ctx: e,
|
|
3104
|
+
custom: i
|
|
3105
|
+
}, r);
|
|
3106
|
+
},
|
|
3107
|
+
getEffect(e, r) {
|
|
3108
|
+
if (w(e, "$" + r))
|
|
3109
|
+
return e["$" + r];
|
|
3110
|
+
if (w(e, "effect") && w(e.effect, r))
|
|
3111
|
+
return e.effect[r];
|
|
3112
|
+
},
|
|
3113
|
+
emitEffect({ ctx: e, rule: r, input: i, type: s, custom: n }, o, a) {
|
|
3114
|
+
if (!s || s === "fcFragment") return;
|
|
3115
|
+
const u = n || Object.keys(r).reduce((l, h) => (h[0] === "$" && (l[h.substr(1)] = r[h]), l), y({}, r.effect || {}));
|
|
3116
|
+
Object.keys(u).forEach((l) => {
|
|
3117
|
+
const h = this.providers[l];
|
|
3118
|
+
if (!h || h.input && !i) return;
|
|
3119
|
+
let g;
|
|
3120
|
+
if (!h._c)
|
|
3121
|
+
g = "*";
|
|
3122
|
+
else if (h._used.indexOf(s) > -1)
|
|
3123
|
+
g = s;
|
|
3124
|
+
else
|
|
3125
|
+
return;
|
|
3126
|
+
const b = y({ value: u[l], getValue: () => this.getEffect(r, l) }, a || {});
|
|
3127
|
+
e && (b.getProp = () => e.effectData(l), b.clearProp = () => e.clearEffectData(l), b.mergeProp = (k) => q(b.getProp(), [k]), b.id = e.id), this.bus.$emit(`p:${l}:${g}:${h.input ? 1 : 0}`, o, [b, r, this.api]);
|
|
3128
|
+
});
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
3131
|
+
}
|
|
3132
|
+
function Or(t) {
|
|
3133
|
+
return t.filter(function(e, r, i) {
|
|
3134
|
+
return i.indexOf(e, 0) === r;
|
|
3135
|
+
});
|
|
3136
|
+
}
|
|
3137
|
+
function wr(t) {
|
|
3138
|
+
const e = t.components;
|
|
3139
|
+
if (Array.isArray(e)) {
|
|
3140
|
+
const r = Or(e.filter((i) => i !== "*"));
|
|
3141
|
+
return r.length ? r : !1;
|
|
3142
|
+
} else return c.String(e) ? [e] : !1;
|
|
3143
|
+
}
|
|
3144
|
+
function V(t) {
|
|
3145
|
+
m(this, {
|
|
3146
|
+
fc: t,
|
|
3147
|
+
vm: t.vm,
|
|
3148
|
+
watching: !1,
|
|
3149
|
+
loading: !1,
|
|
3150
|
+
reloading: !1,
|
|
3151
|
+
noWatchFn: null,
|
|
3152
|
+
deferSyncFn: null,
|
|
3153
|
+
isMounted: !1,
|
|
3154
|
+
formData: {},
|
|
3155
|
+
subForm: {},
|
|
3156
|
+
form: {},
|
|
3157
|
+
appendData: {},
|
|
3158
|
+
providers: {},
|
|
3159
|
+
cycleLoad: null,
|
|
3160
|
+
loadedId: 1,
|
|
3161
|
+
nextTick: null,
|
|
3162
|
+
changeStatus: !1,
|
|
3163
|
+
pageEnd: !0,
|
|
3164
|
+
nextReload: () => {
|
|
3165
|
+
this.lifecycle("reload");
|
|
3166
|
+
}
|
|
3167
|
+
}), nt(this, {
|
|
3168
|
+
options() {
|
|
3169
|
+
return t.options;
|
|
3170
|
+
},
|
|
3171
|
+
bus() {
|
|
3172
|
+
return t.bus;
|
|
3173
|
+
}
|
|
3174
|
+
}), this.initData(t.rules), this.$manager = new t.manager(this), this.$render = new be(this), this.api = t.extendApi(sr(this), this);
|
|
3175
|
+
}
|
|
3176
|
+
m(V.prototype, {
|
|
3177
|
+
initData(t) {
|
|
3178
|
+
m(this, {
|
|
3179
|
+
ctxs: {},
|
|
3180
|
+
fieldCtx: {},
|
|
3181
|
+
nameCtx: {},
|
|
3182
|
+
sort: [],
|
|
3183
|
+
rules: t
|
|
3184
|
+
});
|
|
3185
|
+
},
|
|
3186
|
+
init() {
|
|
3187
|
+
this.appendData = y(y(y({}, this.fc.options.formData || {}), this.vm.value || {}), this.appendData), this.useProvider(), this.usePage(), this.loadRule(), this.$manager.__init(), this.lifecycle("created"), this.vm.$set(this.vm, "formData", this.formData);
|
|
3188
|
+
},
|
|
3189
|
+
beforeFetch(t) {
|
|
3190
|
+
return new Promise((e) => {
|
|
3191
|
+
const r = this.options.beforeFetch && E(() => this.options.beforeFetch(t, { api: this.api }));
|
|
3192
|
+
r && c.Function(r.then) ? r.then(e) : e();
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
});
|
|
3196
|
+
fr(V);
|
|
3197
|
+
hr(V);
|
|
3198
|
+
dr(V);
|
|
3199
|
+
mr(V);
|
|
3200
|
+
vr(V);
|
|
3201
|
+
Cr(V);
|
|
3202
|
+
_r(V);
|
|
3203
|
+
kr(V);
|
|
3204
|
+
const Fr = "fcFragment", ie = {
|
|
3205
|
+
name: Fr,
|
|
3206
|
+
functional: !0,
|
|
3207
|
+
props: ["vnode"],
|
|
3208
|
+
render(t, e) {
|
|
3209
|
+
return e.props.vnode ? e.props.vnode : e.children;
|
|
3210
|
+
}
|
|
3211
|
+
};
|
|
3212
|
+
function Sr(t) {
|
|
3213
|
+
return c.String(t) ? { domProps: { innerHTML: t } } : t;
|
|
3214
|
+
}
|
|
3215
|
+
function Rr() {
|
|
3216
|
+
const t = {};
|
|
3217
|
+
function e(r) {
|
|
3218
|
+
r && this.setVm(r);
|
|
3219
|
+
}
|
|
3220
|
+
return m(e.prototype, {
|
|
3221
|
+
setVm(r) {
|
|
3222
|
+
this.vm = r, this.$h = r.$createElement;
|
|
3223
|
+
},
|
|
3224
|
+
make(r, i, s) {
|
|
3225
|
+
return Y.config.isReservedTag(r) && i.nativeOn && delete i.nativeOn, this.makeComponent(r, i, s);
|
|
3226
|
+
},
|
|
3227
|
+
makeComponent(r, i, s) {
|
|
3228
|
+
let n = this.$h(r, Sr(i), s || []);
|
|
3229
|
+
return n.context = this.vm, n;
|
|
3230
|
+
},
|
|
3231
|
+
aliasMap: t
|
|
3232
|
+
}), m(e, {
|
|
3233
|
+
aliasMap: t,
|
|
3234
|
+
alias(r, i) {
|
|
3235
|
+
t[r] = i;
|
|
3236
|
+
},
|
|
3237
|
+
use(r) {
|
|
3238
|
+
Object.keys(r).forEach((i) => {
|
|
3239
|
+
const s = X(i), n = ar(i).toLocaleLowerCase(), o = r[i];
|
|
3240
|
+
[i, s, n].forEach((a) => {
|
|
3241
|
+
e.alias(i, o), e.prototype[a] = function(u, l) {
|
|
3242
|
+
return this.make(o, u, l);
|
|
3243
|
+
};
|
|
3244
|
+
});
|
|
3245
|
+
});
|
|
3246
|
+
}
|
|
3247
|
+
}), e;
|
|
3248
|
+
}
|
|
3249
|
+
function Er(t) {
|
|
3250
|
+
class e extends ht {
|
|
3251
|
+
}
|
|
3252
|
+
return Object.assign(e.prototype, t), e;
|
|
3253
|
+
}
|
|
3254
|
+
function ht(t) {
|
|
3255
|
+
m(this, {
|
|
3256
|
+
$handle: t,
|
|
3257
|
+
vm: t.vm,
|
|
3258
|
+
options: {},
|
|
3259
|
+
ref: "fcForm",
|
|
3260
|
+
mergeOptionsRule: {
|
|
3261
|
+
normal: ["form", "row", "info", "submitBtn", "resetBtn"]
|
|
3262
|
+
}
|
|
3263
|
+
}), this.updateKey(), this.init();
|
|
3264
|
+
}
|
|
3265
|
+
m(ht.prototype, {
|
|
3266
|
+
__init() {
|
|
3267
|
+
this.$render = this.$handle.$render, this.$r = (...t) => this.$render.renderRule(...t);
|
|
3268
|
+
},
|
|
3269
|
+
updateKey() {
|
|
3270
|
+
this.key = te();
|
|
3271
|
+
},
|
|
3272
|
+
//TODO interface
|
|
3273
|
+
init() {
|
|
3274
|
+
},
|
|
3275
|
+
update() {
|
|
3276
|
+
},
|
|
3277
|
+
beforeRender() {
|
|
3278
|
+
},
|
|
3279
|
+
form() {
|
|
3280
|
+
return this.vm.$refs[this.ref];
|
|
3281
|
+
},
|
|
3282
|
+
getSlot(t) {
|
|
3283
|
+
const e = (r) => {
|
|
3284
|
+
if (r) {
|
|
3285
|
+
let i = r.$scopedSlots[t];
|
|
3286
|
+
return i || e(r.$pfc);
|
|
3287
|
+
}
|
|
3288
|
+
};
|
|
3289
|
+
return e(this.vm);
|
|
3290
|
+
},
|
|
3291
|
+
mergeOptions(t, e) {
|
|
3292
|
+
return T(t.map((r) => this.tidyOptions(r)), e, this.mergeOptionsRule);
|
|
3293
|
+
},
|
|
3294
|
+
updateOptions(t) {
|
|
3295
|
+
this.options = this.mergeOptions([t], this.getDefaultOptions()), this.update();
|
|
3296
|
+
},
|
|
3297
|
+
tidyOptions(t) {
|
|
3298
|
+
return t;
|
|
3299
|
+
},
|
|
3300
|
+
tidyRule(t) {
|
|
3301
|
+
},
|
|
3302
|
+
mergeProp(t) {
|
|
3303
|
+
},
|
|
3304
|
+
getDefaultOptions() {
|
|
3305
|
+
return {};
|
|
3306
|
+
},
|
|
3307
|
+
render(t) {
|
|
3308
|
+
}
|
|
3309
|
+
});
|
|
3310
|
+
const Ir = function(t) {
|
|
3311
|
+
const e = {
|
|
3312
|
+
name: "loadData",
|
|
3313
|
+
_fn: [],
|
|
3314
|
+
created(r, i, s) {
|
|
3315
|
+
this.deleted(r);
|
|
3316
|
+
let n = j(r.getValue());
|
|
3317
|
+
const o = [];
|
|
3318
|
+
n.forEach((a) => {
|
|
3319
|
+
if (a) {
|
|
3320
|
+
const u = () => {
|
|
3321
|
+
a.watch !== !1 && (t.bus.$off("p.loadData." + a.attr, u), t.bus.$once("p.loadData." + a.attr, u));
|
|
3322
|
+
let l;
|
|
3323
|
+
a.attr && (l = t.loadData[a.attr] || a.default, a.copy !== !1 && (l = N(l))), Q(r.getProp(), a.to || "options", l), s.sync(i);
|
|
3324
|
+
};
|
|
3325
|
+
o.push(() => t.bus.$off("p.loadData." + a.attr, u)), u();
|
|
3326
|
+
}
|
|
3327
|
+
}), this._fn[r.id] = o;
|
|
3328
|
+
},
|
|
3329
|
+
deleted(r) {
|
|
3330
|
+
this._fn[r.id] && (this._fn[r.id].forEach((i) => {
|
|
3331
|
+
i();
|
|
3332
|
+
}), delete this._fn[r.id]), r.clearProp();
|
|
3333
|
+
}
|
|
3334
|
+
};
|
|
3335
|
+
return e.watch = e.created, e;
|
|
3336
|
+
}, ct = {
|
|
3337
|
+
name: "componentValidate",
|
|
3338
|
+
load(t, e, r) {
|
|
3339
|
+
const i = t.getValue();
|
|
3340
|
+
i ? t.getProp().validate = [{
|
|
3341
|
+
validator(...s) {
|
|
3342
|
+
const n = K(e);
|
|
3343
|
+
if (n)
|
|
3344
|
+
return r.exec(n.id, i === !0 ? "formCreateValidate" : i, ...s, {
|
|
3345
|
+
attr: t,
|
|
3346
|
+
rule: e,
|
|
3347
|
+
api: r
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
}] : (t.clearProp(), r.clearValidateState([e.field]));
|
|
3351
|
+
},
|
|
3352
|
+
watch(...t) {
|
|
3353
|
+
ct.load(...t);
|
|
3354
|
+
}
|
|
3355
|
+
}, jr = function(t) {
|
|
3356
|
+
function e(i) {
|
|
3357
|
+
return c.String(i) && (i = {
|
|
3358
|
+
action: i,
|
|
3359
|
+
to: "options"
|
|
3360
|
+
}), i;
|
|
3361
|
+
}
|
|
3362
|
+
function r(i, s, n) {
|
|
3363
|
+
let o = i.value;
|
|
3364
|
+
const a = (g) => {
|
|
3365
|
+
g === void 0 ? (i.clearProp(), n.sync(s)) : Q(i.getProp(), o.to || "options", g);
|
|
3366
|
+
};
|
|
3367
|
+
if (c.Function(o) && (o = o(s, n)), o = e(o), !o || !o.action) {
|
|
3368
|
+
a(void 0);
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3371
|
+
o = N(o), o.to || (o.to = "options");
|
|
3372
|
+
const u = o.onError, l = () => {
|
|
3373
|
+
if (!i.getValue())
|
|
3374
|
+
return i.clearProp(), n.sync(s), !0;
|
|
3375
|
+
}, h = H(y({
|
|
3376
|
+
headers: {}
|
|
3377
|
+
}, o), {
|
|
3378
|
+
onSuccess(g, b) {
|
|
3379
|
+
if (l()) return;
|
|
3380
|
+
let k = (v) => b ? v : w(v, "data") ? v.data : v;
|
|
3381
|
+
c.Function(o.parse) ? k = o.parse : o.parse && c.String(o.parse) && (k = (v) => (o.parse.split(".").forEach((O) => {
|
|
3382
|
+
v && (v = v[O]);
|
|
3383
|
+
}), v)), a(k(g, s, n)), n.sync(s);
|
|
3384
|
+
},
|
|
3385
|
+
onError(g) {
|
|
3386
|
+
a(void 0), !l() && (u || ((b) => ge(b.message || "fetch fail " + o.action)))(g, s, n);
|
|
3387
|
+
}
|
|
3388
|
+
});
|
|
3389
|
+
t.$handle.beforeFetch(h, { rule: s, api: n }).then(() => {
|
|
3390
|
+
if (c.Function(o.action)) {
|
|
3391
|
+
o.action(s, n).then((g) => {
|
|
3392
|
+
h.onSuccess(g, !0);
|
|
3393
|
+
}).catch((g) => {
|
|
3394
|
+
h.onError(g);
|
|
3395
|
+
});
|
|
3396
|
+
return;
|
|
3397
|
+
}
|
|
3398
|
+
E(() => t.create.fetch(h, { inject: i, rule: s, api: n }));
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
return {
|
|
3402
|
+
name: "fetch",
|
|
3403
|
+
loaded(...i) {
|
|
3404
|
+
r(...i);
|
|
3405
|
+
},
|
|
3406
|
+
watch(...i) {
|
|
3407
|
+
r(...i);
|
|
3408
|
+
}
|
|
3409
|
+
};
|
|
3410
|
+
}, dt = {
|
|
3411
|
+
name: "required",
|
|
3412
|
+
load(t, e, r) {
|
|
3413
|
+
const i = Ar(t.getValue());
|
|
3414
|
+
if (i.required === !1)
|
|
3415
|
+
t.clearProp(), r.clearValidateState([e.field]);
|
|
3416
|
+
else {
|
|
3417
|
+
const s = y({
|
|
3418
|
+
required: !0,
|
|
3419
|
+
validator(n, o, a) {
|
|
3420
|
+
c.empty(o) ? a(s.message) : a();
|
|
3421
|
+
}
|
|
3422
|
+
}, i);
|
|
3423
|
+
if (!s.message) {
|
|
3424
|
+
let n = e.title || "";
|
|
3425
|
+
s.message = ((typeof n == "object" ? n.title : n) || "") + "不能为空";
|
|
3426
|
+
}
|
|
3427
|
+
t.getProp().validate = [s];
|
|
3428
|
+
}
|
|
3429
|
+
r.sync(e);
|
|
3430
|
+
},
|
|
3431
|
+
watch(...t) {
|
|
3432
|
+
dt.load(...t);
|
|
3433
|
+
}
|
|
3434
|
+
};
|
|
3435
|
+
function Ar(t) {
|
|
3436
|
+
return c.Boolean(t) ? { required: t } : c.String(t) ? { message: t } : c.Undef(t) ? { required: !1 } : c.Function(t) ? { validator: t } : c.Object(t) ? t : {};
|
|
3437
|
+
}
|
|
3438
|
+
const Vr = {
|
|
3439
|
+
fetch: jr,
|
|
3440
|
+
loadData: Ir,
|
|
3441
|
+
required: dt,
|
|
3442
|
+
componentValidate: ct
|
|
3443
|
+
}, Pr = "html", Dr = {
|
|
3444
|
+
name: Pr,
|
|
3445
|
+
loadChildren: !1,
|
|
3446
|
+
render(t, e) {
|
|
3447
|
+
return e.prop.domProps || (e.prop.domProps = {}), e.prop.domProps.innerHTML = t, e.vNode.make(e.prop.props.tag || "div", e.prop);
|
|
3448
|
+
},
|
|
3449
|
+
renderChildren(t) {
|
|
3450
|
+
return Array.isArray(t.rule.children) ? t.rule.children.filter((e) => c.String(e)).join("") : "";
|
|
3451
|
+
}
|
|
3452
|
+
};
|
|
3453
|
+
let B = typeof window != "undefined" && window.Vue ? window.Vue : Y;
|
|
3454
|
+
function Tr(t, e) {
|
|
3455
|
+
let r;
|
|
3456
|
+
return arguments.length === 2 ? (r = arguments[1], e = r[t]) : r = arguments[2], { id: e, prop: r };
|
|
3457
|
+
}
|
|
3458
|
+
function ne() {
|
|
3459
|
+
return Tr("name", ...arguments);
|
|
3460
|
+
}
|
|
3461
|
+
function Ue(t) {
|
|
3462
|
+
return !t || !t.el ? window.document.body : c.Element(t.el) ? t.el : document.querySelector(t.el);
|
|
3463
|
+
}
|
|
3464
|
+
function qe(t, e) {
|
|
3465
|
+
const r = new B({
|
|
3466
|
+
data() {
|
|
3467
|
+
return { rule: t, option: e || {} };
|
|
3468
|
+
},
|
|
3469
|
+
render(i) {
|
|
3470
|
+
return i("FormCreate", { ref: "fc", props: this.$data });
|
|
3471
|
+
}
|
|
3472
|
+
});
|
|
3473
|
+
return r.$mount(), r;
|
|
3474
|
+
}
|
|
3475
|
+
function Br(t) {
|
|
3476
|
+
const e = t.key || [], r = t.array || [], i = t.normal || [];
|
|
3477
|
+
et.push(...e), pe.push(...r), me.push(...i), ot([...e, ...r, ...i]);
|
|
3478
|
+
}
|
|
3479
|
+
let Lr = 1;
|
|
3480
|
+
const R = {};
|
|
3481
|
+
function pt(t) {
|
|
3482
|
+
const e = {
|
|
3483
|
+
[ie.name]: ie
|
|
3484
|
+
}, r = {}, i = {}, s = y({}, Vr), n = rr();
|
|
3485
|
+
let o = { global: {} };
|
|
3486
|
+
const a = {}, u = Rr();
|
|
3487
|
+
Br(t.attrs || {});
|
|
3488
|
+
function l(f) {
|
|
3489
|
+
const d = R[f];
|
|
3490
|
+
if (Array.isArray(d))
|
|
3491
|
+
return d.map(($) => $.api());
|
|
3492
|
+
if (d)
|
|
3493
|
+
return d.api();
|
|
3494
|
+
}
|
|
3495
|
+
function h() {
|
|
3496
|
+
const f = ne(...arguments);
|
|
3497
|
+
f.id && f.prop && (i[f.id] = f.prop);
|
|
3498
|
+
}
|
|
3499
|
+
function g() {
|
|
3500
|
+
const f = ne(...arguments);
|
|
3501
|
+
f.id && f.prop && (s[f.id] = H(y({}, f.prop), { name: f.id }));
|
|
3502
|
+
}
|
|
3503
|
+
function b(f) {
|
|
3504
|
+
u.use(f);
|
|
3505
|
+
}
|
|
3506
|
+
function k() {
|
|
3507
|
+
const f = ne(...arguments);
|
|
3508
|
+
if (!f.id || !f.prop) return ce;
|
|
3509
|
+
const d = I(f.id), $ = f.prop, C = $.merge === !0 ? r[d] : void 0;
|
|
3510
|
+
r[d] = $, Object.setPrototypeOf($, C || ce), n[d] = S(d), $.maker && m(n, $.maker);
|
|
3511
|
+
}
|
|
3512
|
+
function v(f, d) {
|
|
3513
|
+
let $;
|
|
3514
|
+
if (c.String(f)) {
|
|
3515
|
+
if ($ = I(f), ["form-create", "formcreate"].indexOf($) > -1)
|
|
3516
|
+
return re();
|
|
3517
|
+
if (d === void 0)
|
|
3518
|
+
return e[$];
|
|
3519
|
+
} else
|
|
3520
|
+
$ = I(f.name), d = f;
|
|
3521
|
+
if (!$ || !d) return;
|
|
3522
|
+
const C = I($);
|
|
3523
|
+
e[$] = d, e[C] = d, delete u.aliasMap[$], delete u.aliasMap[C], delete r[$], delete r[C], d.formCreateParser && k($, d.formCreateParser);
|
|
3524
|
+
}
|
|
3525
|
+
function O(f) {
|
|
3526
|
+
Object.keys(R).forEach((d) => {
|
|
3527
|
+
(Array.isArray(R[d]) ? R[d] : [R[d]]).forEach((C) => {
|
|
3528
|
+
C.bus.$emit("p.loadData." + f);
|
|
3529
|
+
});
|
|
3530
|
+
});
|
|
3531
|
+
}
|
|
3532
|
+
function Ce(f, d) {
|
|
3533
|
+
a[f] = d, O(f);
|
|
3534
|
+
}
|
|
3535
|
+
function _e(f, d) {
|
|
3536
|
+
return w(a, f) ? a[f] : d;
|
|
3537
|
+
}
|
|
3538
|
+
function mt(f) {
|
|
3539
|
+
delete a[f], O(f);
|
|
3540
|
+
}
|
|
3541
|
+
function re() {
|
|
3542
|
+
return B.extend(Gt(Oe));
|
|
3543
|
+
}
|
|
3544
|
+
function ke() {
|
|
3545
|
+
return B.extend(ie);
|
|
3546
|
+
}
|
|
3547
|
+
function yt(f, d) {
|
|
3548
|
+
return c.Function(f.install) ? f.install(P, d) : c.Function(f) && f(P, d), this;
|
|
3549
|
+
}
|
|
3550
|
+
function P(f, d, $) {
|
|
3551
|
+
let C = qe(f, d || {});
|
|
3552
|
+
const A = C.$refs.fc.formCreate;
|
|
3553
|
+
return A.$parent = $, Ue(A.options).appendChild(C.$el), A.api();
|
|
3554
|
+
}
|
|
3555
|
+
function gt(f) {
|
|
3556
|
+
let d = y({}, t);
|
|
3557
|
+
return f ? d.inherit = {
|
|
3558
|
+
components: e,
|
|
3559
|
+
parsers: r,
|
|
3560
|
+
directives: i,
|
|
3561
|
+
providers: s,
|
|
3562
|
+
maker: n,
|
|
3563
|
+
loadData: a
|
|
3564
|
+
} : delete d.inherit, pt(d);
|
|
3565
|
+
}
|
|
3566
|
+
function Oe(f) {
|
|
3567
|
+
const d = f.$options.propsData.rule;
|
|
3568
|
+
m(this, {
|
|
3569
|
+
id: Lr++,
|
|
3570
|
+
vm: f,
|
|
3571
|
+
create: P,
|
|
3572
|
+
manager: Er(t.manager),
|
|
3573
|
+
parsers: r,
|
|
3574
|
+
providers: s,
|
|
3575
|
+
rules: Array.isArray(d) ? d : [],
|
|
3576
|
+
name: f.$options.propsData.name || te(),
|
|
3577
|
+
inFor: f.$options.propsData.inFor,
|
|
3578
|
+
prop: {
|
|
3579
|
+
components: e,
|
|
3580
|
+
directives: i
|
|
3581
|
+
},
|
|
3582
|
+
setData: Ce,
|
|
3583
|
+
getData: _e,
|
|
3584
|
+
loadData: a,
|
|
3585
|
+
CreateNode: u,
|
|
3586
|
+
bus: new B(),
|
|
3587
|
+
unwatch: null,
|
|
3588
|
+
options: {},
|
|
3589
|
+
extendApi: t.extendApi || (($) => $)
|
|
3590
|
+
}), this.init(), this.initOptions(), this.name && (this.inFor ? (R[this.name] || (R[this.name] = []), R[this.name].push(this)) : R[this.name] = this);
|
|
3591
|
+
}
|
|
3592
|
+
m(Oe.prototype, {
|
|
3593
|
+
init() {
|
|
3594
|
+
const f = this.vm, d = new V(this);
|
|
3595
|
+
this.$handle = d, f.$f = d.api, f.$emit("input", d.api), f.$on("hook:created", () => {
|
|
3596
|
+
this.isSub() && (this.unwatch = f.$watch(() => f.$pfc.option, () => {
|
|
3597
|
+
this.initOptions(), f.$f.refresh();
|
|
3598
|
+
}, { deep: !0 }), this.initOptions()), this.created();
|
|
3599
|
+
}), f.$on("hook:mounted", () => {
|
|
3600
|
+
this.mounted();
|
|
3601
|
+
}), f.$on("hook:beforeDestroy", () => {
|
|
3602
|
+
if (f.destroyed = !0, this.unwatch && this.unwatch(), d.reloadRule([]), this.name)
|
|
3603
|
+
if (this.inFor) {
|
|
3604
|
+
const $ = R[this.name].indexOf(this);
|
|
3605
|
+
R[this.name].splice($, 1), R[this.name].length || delete R[this.name];
|
|
3606
|
+
} else
|
|
3607
|
+
delete R[this.name];
|
|
3608
|
+
}), f.$on("hook:updated", () => {
|
|
3609
|
+
d.bindNextTick(() => this.bus.$emit("next-tick", d.api));
|
|
3610
|
+
});
|
|
3611
|
+
},
|
|
3612
|
+
isSub() {
|
|
3613
|
+
return this.vm.$pfc && this.vm.extendOption;
|
|
3614
|
+
},
|
|
3615
|
+
initOptions() {
|
|
3616
|
+
this.options = {};
|
|
3617
|
+
let f = y({ formData: {}, submitBtn: {}, resetBtn: {} }, N(o));
|
|
3618
|
+
this.isSub() && this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, !0), f = this.mergeOptions(f, this.vm.$options.propsData.option), this.updateOptions(f);
|
|
3619
|
+
},
|
|
3620
|
+
mergeOptions(f, d, $) {
|
|
3621
|
+
return d = N(d), $ && ["page", "onSubmit", "mounted", "reload", "formData", "el"].forEach((C) => {
|
|
3622
|
+
delete d[C];
|
|
3623
|
+
}), d.global && (f.global = er(f.global, d.global), delete d.global), this.$handle.$manager.mergeOptions([d], f), f;
|
|
3624
|
+
},
|
|
3625
|
+
updateOptions(f) {
|
|
3626
|
+
this.mergeOptions(this.options, f), this.$handle.$manager.updateOptions(this.options);
|
|
3627
|
+
},
|
|
3628
|
+
created() {
|
|
3629
|
+
this.$handle.init(), this.vm.$emit("created", this.api());
|
|
3630
|
+
},
|
|
3631
|
+
api() {
|
|
3632
|
+
return this.$handle.api;
|
|
3633
|
+
},
|
|
3634
|
+
render() {
|
|
3635
|
+
return this.$handle.render();
|
|
3636
|
+
},
|
|
3637
|
+
mounted() {
|
|
3638
|
+
this.$handle.mounted();
|
|
3639
|
+
}
|
|
3640
|
+
});
|
|
3641
|
+
function we(f) {
|
|
3642
|
+
m(f, {
|
|
3643
|
+
version: t.version,
|
|
3644
|
+
ui: t.ui,
|
|
3645
|
+
setData: Ce,
|
|
3646
|
+
getData: _e,
|
|
3647
|
+
removeData: mt,
|
|
3648
|
+
maker: n,
|
|
3649
|
+
component: v,
|
|
3650
|
+
directive: h,
|
|
3651
|
+
register: g,
|
|
3652
|
+
$vnode: ke,
|
|
3653
|
+
parser: k,
|
|
3654
|
+
use: yt,
|
|
3655
|
+
factory: gt,
|
|
3656
|
+
componentAlias: b,
|
|
3657
|
+
copyRule: $e,
|
|
3658
|
+
copyRules: it,
|
|
3659
|
+
fetch: lt,
|
|
3660
|
+
$form: re,
|
|
3661
|
+
parseFn: U,
|
|
3662
|
+
parseJson: Yt,
|
|
3663
|
+
toJson: tt,
|
|
3664
|
+
getApi: l,
|
|
3665
|
+
init(d, $ = {}) {
|
|
3666
|
+
let C = qe(d, $), A = C.$refs.fc.formCreate;
|
|
3667
|
+
return {
|
|
3668
|
+
mount(J) {
|
|
3669
|
+
return J && c.Element(J) && (A.options.el = J), Ue(A.options).appendChild(C.$el), A.api();
|
|
3670
|
+
},
|
|
3671
|
+
remove() {
|
|
3672
|
+
C.$el.parentNode && C.$el.parentNode.removeChild(C.$el);
|
|
3673
|
+
},
|
|
3674
|
+
destroy() {
|
|
3675
|
+
this.remove(), C.$destroy();
|
|
3676
|
+
},
|
|
3677
|
+
$f: A.api()
|
|
3678
|
+
};
|
|
3679
|
+
}
|
|
3680
|
+
});
|
|
3681
|
+
}
|
|
3682
|
+
function $t(f) {
|
|
3683
|
+
m(f, {
|
|
3684
|
+
create: P,
|
|
3685
|
+
install(d, $) {
|
|
3686
|
+
if (o = y(y({}, o), $ || {}), d._installedFormCreate === !0) return;
|
|
3687
|
+
d._installedFormCreate = !0, B = d;
|
|
3688
|
+
const C = function(A, J = {}) {
|
|
3689
|
+
return P(A, J, this);
|
|
3690
|
+
};
|
|
3691
|
+
we(C), d.prototype.$formCreate = C, d.component("FormCreate", re()), d.component("FcFragment", ke());
|
|
3692
|
+
}
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3695
|
+
if (we(P), $t(P), u.use({ fragment: "fcFragment" }), k(Dr), t.install && P.use(t), t.inherit) {
|
|
3696
|
+
const f = t.inherit;
|
|
3697
|
+
f.components && m(e, f.components), f.parsers && m(r, f.parsers), f.directives && m(i, f.directives), f.providers && m(s, f.providers), f.maker && m(n, f.maker), f.loadData && m(a, f.loadData);
|
|
3698
|
+
}
|
|
3699
|
+
return P;
|
|
3700
|
+
}
|
|
3701
|
+
function se(t) {
|
|
3702
|
+
if (c.Date(t))
|
|
3703
|
+
return t;
|
|
3704
|
+
{
|
|
3705
|
+
let e = new Date(t);
|
|
3706
|
+
return e.toString() === "Invalid Date" ? t : e;
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
const He = "datePicker", Nr = {
|
|
3710
|
+
name: He,
|
|
3711
|
+
maker: function() {
|
|
3712
|
+
return ["date", "dateRange", "datetime", "datetimeRange", "year", "month"].reduce((t, e) => (t[e] = S(He, { type: e.toLowerCase() }), t), {});
|
|
3713
|
+
}(),
|
|
3714
|
+
mergeProp(t) {
|
|
3715
|
+
let e = t.prop.props;
|
|
3716
|
+
e.startDate && (e.startDate = e.startDate && se(e.startDate));
|
|
3717
|
+
},
|
|
3718
|
+
isRange(t) {
|
|
3719
|
+
return t.type.includes("range") || t.multiple;
|
|
3720
|
+
},
|
|
3721
|
+
_toValue(t, e) {
|
|
3722
|
+
const r = e.el.formatDate(t || ""), { separator: i } = e.el, s = this.isRange(e.el);
|
|
3723
|
+
return r ? s ? r.split(i) : r : s ? e.el.multiple ? [] : ["", ""] : r;
|
|
3724
|
+
},
|
|
3725
|
+
toValue(t, e) {
|
|
3726
|
+
const r = e.el;
|
|
3727
|
+
return r ? (this.el = r, this._toValue(t, e)) : t;
|
|
3728
|
+
},
|
|
3729
|
+
toFormValue(t, e) {
|
|
3730
|
+
if (e.el) {
|
|
3731
|
+
const r = e.el.parseDate(t);
|
|
3732
|
+
return this.isRange(e.el) ? r : r[0];
|
|
3733
|
+
} else {
|
|
3734
|
+
let r = Array.isArray(t), i = e.prop.props, s, n = i.type || "date";
|
|
3735
|
+
return ["daterange", "datetimerange"].indexOf(n) !== -1 ? r ? s = t.map((o) => o ? se(o) : "") : s = ["", ""] : n === "date" && i.multiple === !0 ? s = toString(t) : (s = r ? t[0] || "" : t, s = s ? se(s) : ""), s;
|
|
3736
|
+
}
|
|
3737
|
+
},
|
|
3738
|
+
mounted(t) {
|
|
3739
|
+
t.rule.value = this.toValue(t.$handle.getFormData(t), t);
|
|
3740
|
+
}
|
|
3741
|
+
}, oe = "hidden", Mr = {
|
|
3742
|
+
name: oe,
|
|
3743
|
+
maker: {
|
|
3744
|
+
[oe]: (t, e) => S(oe)("", t, e)
|
|
3745
|
+
},
|
|
3746
|
+
render() {
|
|
3747
|
+
return [];
|
|
3748
|
+
}
|
|
3749
|
+
}, ae = "input", Ur = {
|
|
3750
|
+
name: ae,
|
|
3751
|
+
maker: function() {
|
|
3752
|
+
const t = ["password", "url", "email", "text", "textarea"].reduce((e, r) => (e[r] = S(ae, { type: r }), e), {});
|
|
3753
|
+
return t.idate = S(ae, { type: "date" }), t;
|
|
3754
|
+
}(),
|
|
3755
|
+
mergeProp(t) {
|
|
3756
|
+
let { props: e } = t.prop;
|
|
3757
|
+
e.autosize && e.autosize.minRows && (e.rows = e.autosize.minRows || 2);
|
|
3758
|
+
}
|
|
3759
|
+
}, Je = "slider", qr = {
|
|
3760
|
+
name: Je,
|
|
3761
|
+
maker: {
|
|
3762
|
+
sliderRange: S(Je, { range: !0 })
|
|
3763
|
+
},
|
|
3764
|
+
toFormValue(t, e) {
|
|
3765
|
+
let r = Array.isArray(t), i = e.prop.props, s = i.min || 0, n;
|
|
3766
|
+
return i.range === !0 ? n = r ? t : [s, parseFloat(t) || s] : n = r ? parseFloat(t[0]) || s : parseFloat(t), n;
|
|
3767
|
+
}
|
|
3768
|
+
}, Hr = {
|
|
3769
|
+
name: "switch",
|
|
3770
|
+
mergeProp(t) {
|
|
3771
|
+
const e = t.prop.props.slot || {}, r = t.prop.scopedSlots || {};
|
|
3772
|
+
e.open && (r.open = () => e.open), e.close && (r.close = () => e.close), t.prop.scopedSlots = r;
|
|
3773
|
+
}
|
|
3774
|
+
}, Jr = {
|
|
3775
|
+
name: "FcRow",
|
|
3776
|
+
render(t, e) {
|
|
3777
|
+
return e.vNode.col({ props: { span: 24 } }, [
|
|
3778
|
+
e.vNode.row(e.prop, t)
|
|
3779
|
+
]);
|
|
3780
|
+
}
|
|
3781
|
+
}, zr = [
|
|
3782
|
+
Nr,
|
|
3783
|
+
Mr,
|
|
3784
|
+
Ur,
|
|
3785
|
+
qr,
|
|
3786
|
+
Hr,
|
|
3787
|
+
Jr
|
|
3788
|
+
], Wr = {
|
|
3789
|
+
button: "iButton",
|
|
3790
|
+
icon: "Icon",
|
|
3791
|
+
slider: "Slider",
|
|
3792
|
+
rate: "Rate",
|
|
3793
|
+
upload: "fcUpload",
|
|
3794
|
+
cascader: "Cascader",
|
|
3795
|
+
colorPicker: "ColorPicker",
|
|
3796
|
+
timePicker: "TimePicker",
|
|
3797
|
+
datePicker: "DatePicker",
|
|
3798
|
+
switch: "iSwitch",
|
|
3799
|
+
select: "fcSelect",
|
|
3800
|
+
checkbox: "fcCheckbox",
|
|
3801
|
+
radio: "fcRadio",
|
|
3802
|
+
inputNumber: "InputNumber",
|
|
3803
|
+
input: "iInput",
|
|
3804
|
+
formItem: "FormItem",
|
|
3805
|
+
form: "iForm",
|
|
3806
|
+
frame: "fcFrame",
|
|
3807
|
+
col: "iCol",
|
|
3808
|
+
row: "row",
|
|
3809
|
+
tree: "fcTree",
|
|
3810
|
+
autoComplete: "AutoComplete",
|
|
3811
|
+
group: "fcGroup",
|
|
3812
|
+
subForm: "fcSubForm",
|
|
3813
|
+
object: "fcSubForm"
|
|
3814
|
+
}, Z = {
|
|
3815
|
+
resetBtnType: "default",
|
|
3816
|
+
resetBtnIcon: "md-refresh",
|
|
3817
|
+
infoIcon: "ios-information-circle-outline"
|
|
3818
|
+
};
|
|
3819
|
+
function xr() {
|
|
3820
|
+
return {
|
|
3821
|
+
type: "poptip",
|
|
3822
|
+
trigger: "hover",
|
|
3823
|
+
placement: "top-start",
|
|
3824
|
+
wordWrap: !0,
|
|
3825
|
+
icon: Z.infoIcon
|
|
3826
|
+
};
|
|
3827
|
+
}
|
|
3828
|
+
function Gr() {
|
|
3829
|
+
return {
|
|
3830
|
+
form: {
|
|
3831
|
+
inline: !1,
|
|
3832
|
+
labelPosition: "right",
|
|
3833
|
+
labelWidth: 125,
|
|
3834
|
+
showMessage: !0,
|
|
3835
|
+
autocomplete: "off",
|
|
3836
|
+
size: void 0
|
|
3837
|
+
},
|
|
3838
|
+
row: {
|
|
3839
|
+
gutter: 0
|
|
3840
|
+
},
|
|
3841
|
+
submitBtn: {
|
|
3842
|
+
type: "primary",
|
|
3843
|
+
disabled: !1,
|
|
3844
|
+
innerText: "提交",
|
|
3845
|
+
loading: !1,
|
|
3846
|
+
show: !0,
|
|
3847
|
+
click: void 0
|
|
3848
|
+
},
|
|
3849
|
+
resetBtn: {
|
|
3850
|
+
type: Z.resetBtnType,
|
|
3851
|
+
disabled: !1,
|
|
3852
|
+
icon: Z.resetBtnIcon,
|
|
3853
|
+
innerText: "重置",
|
|
3854
|
+
loading: !1,
|
|
3855
|
+
show: !1,
|
|
3856
|
+
click: void 0
|
|
3857
|
+
}
|
|
3858
|
+
};
|
|
3859
|
+
}
|
|
3860
|
+
function ze(t, e) {
|
|
3861
|
+
w(t, e) && c.String(t[e]) && (t[e] = { [e]: t[e], show: !0 });
|
|
3862
|
+
}
|
|
3863
|
+
function D(t) {
|
|
3864
|
+
return t === !1;
|
|
3865
|
+
}
|
|
3866
|
+
function Kr(t, e) {
|
|
3867
|
+
w(t, e) && !c.Object(t[e]) && (t[e] = { show: !!t[e] });
|
|
3868
|
+
}
|
|
3869
|
+
const Xr = {
|
|
3870
|
+
validate() {
|
|
3871
|
+
const t = this.form();
|
|
3872
|
+
return t ? new Promise((e, r) => {
|
|
3873
|
+
t.validate().then((i) => {
|
|
3874
|
+
i ? e(!0) : r(!1);
|
|
3875
|
+
});
|
|
3876
|
+
}) : new Promise((e) => e());
|
|
3877
|
+
},
|
|
3878
|
+
validateField(t) {
|
|
3879
|
+
const e = this.form();
|
|
3880
|
+
return e ? new Promise((r, i) => {
|
|
3881
|
+
e.validateField(t, (s) => {
|
|
3882
|
+
s ? i(s) : r(null);
|
|
3883
|
+
});
|
|
3884
|
+
}) : new Promise((r) => r());
|
|
3885
|
+
},
|
|
3886
|
+
clearValidateState(t) {
|
|
3887
|
+
const e = this.vm.$refs[t.wrapRef];
|
|
3888
|
+
e && (e.validateMessage = "", e.validateState = "");
|
|
3889
|
+
},
|
|
3890
|
+
tidyOptions(t) {
|
|
3891
|
+
return ["submitBtn", "resetBtn", "row", "info", "wrap", "col", "title"].forEach((e) => {
|
|
3892
|
+
Kr(t, e);
|
|
3893
|
+
}), t;
|
|
3894
|
+
},
|
|
3895
|
+
tidyRule({ prop: t }) {
|
|
3896
|
+
return ze(t, "title"), ze(t, "info"), t;
|
|
3897
|
+
},
|
|
3898
|
+
mergeProp(t) {
|
|
3899
|
+
t.prop = T([{
|
|
3900
|
+
info: this.options.info || {},
|
|
3901
|
+
wrap: this.options.wrap || {},
|
|
3902
|
+
col: this.options.col || {},
|
|
3903
|
+
title: this.options.title || {}
|
|
3904
|
+
}, t.prop], {
|
|
3905
|
+
info: xr(),
|
|
3906
|
+
title: {},
|
|
3907
|
+
col: { span: 24 },
|
|
3908
|
+
wrap: {}
|
|
3909
|
+
}, { normal: ["title", "info", "col", "wrap"] }), this.setSize(t.prop.props);
|
|
3910
|
+
},
|
|
3911
|
+
setSize(t) {
|
|
3912
|
+
!t.size && this.options.form.size && (t.size = this.options.form.size);
|
|
3913
|
+
},
|
|
3914
|
+
getDefaultOptions() {
|
|
3915
|
+
return Gr();
|
|
3916
|
+
},
|
|
3917
|
+
update() {
|
|
3918
|
+
const t = this.options.form;
|
|
3919
|
+
this.rule = {
|
|
3920
|
+
props: y({}, t),
|
|
3921
|
+
nativeOn: {
|
|
3922
|
+
submit: (e) => {
|
|
3923
|
+
e.preventDefault();
|
|
3924
|
+
}
|
|
3925
|
+
},
|
|
3926
|
+
class: [t.className, t.class, "form-create"],
|
|
3927
|
+
style: t.style,
|
|
3928
|
+
type: "form"
|
|
3929
|
+
};
|
|
3930
|
+
},
|
|
3931
|
+
beforeRender() {
|
|
3932
|
+
const { key: t, ref: e, $handle: r } = this;
|
|
3933
|
+
m(this.rule, { key: t, ref: e }), m(this.rule.props, {
|
|
3934
|
+
model: r.formData
|
|
3935
|
+
// rules: $handle.validate(),
|
|
3936
|
+
});
|
|
3937
|
+
},
|
|
3938
|
+
render(t) {
|
|
3939
|
+
return t.length && t.push(this.makeFormBtn()), this.$r(this.rule, D(this.options.row.show) ? t : [this.makeRow(t)]);
|
|
3940
|
+
},
|
|
3941
|
+
makeWrap(t, e) {
|
|
3942
|
+
const r = t.prop, i = `${this.key}${t.key}`, s = r.col, n = this.isTitle(r), o = !s.labelWidth && !n ? 0 : s.labelWidth, { inline: a, col: u } = this.rule.props, l = D(r.wrap.show) ? e : this.$r(T([r.wrap, {
|
|
3943
|
+
props: H(y({
|
|
3944
|
+
labelWidth: o
|
|
3945
|
+
}, r.wrap || {}), {
|
|
3946
|
+
prop: t.id,
|
|
3947
|
+
rules: t.injectValidate()
|
|
3948
|
+
}),
|
|
3949
|
+
class: r.className,
|
|
3950
|
+
key: `${i}fi`,
|
|
3951
|
+
ref: t.wrapRef,
|
|
3952
|
+
type: "formItem"
|
|
3953
|
+
}]), [e, n ? this.makeInfo(r, i, t) : null]);
|
|
3954
|
+
return a === !0 || D(u) || D(s.show) ? l : this.makeCol(r, i, [l]);
|
|
3955
|
+
},
|
|
3956
|
+
isTitle(t) {
|
|
3957
|
+
if (this.options.form.title === !1) return !1;
|
|
3958
|
+
const e = t.title;
|
|
3959
|
+
return !(!e.title && !e.native || D(e.show));
|
|
3960
|
+
},
|
|
3961
|
+
makeInfo(t, e, r) {
|
|
3962
|
+
const i = t.title, s = t.info, n = this.getSlot("title"), o = [n ? n({ title: i.title || "", rule: r.rule, options: this.options }) : i.title];
|
|
3963
|
+
if (!D(s.show) && (s.info || s.native) && !D(s.icon)) {
|
|
3964
|
+
const a = {
|
|
3965
|
+
type: s.type || "poptip",
|
|
3966
|
+
props: y({}, s),
|
|
3967
|
+
key: `${e}pop`,
|
|
3968
|
+
slot: "label"
|
|
3969
|
+
}, u = "content";
|
|
3970
|
+
s.info && !w(a.props, u) && (a.props[u] = s.info), o[s.align !== "left" ? "unshift" : "push"](this.$r(T([s, a]), [
|
|
3971
|
+
this.$r({
|
|
3972
|
+
type: "icon",
|
|
3973
|
+
props: { type: s.icon === !0 ? Z.infoIcon : s.icon, size: 16 },
|
|
3974
|
+
style: "margin-top: -1px",
|
|
3975
|
+
key: `${e}i`
|
|
3976
|
+
})
|
|
3977
|
+
]));
|
|
3978
|
+
}
|
|
3979
|
+
return this.$r(T([i, {
|
|
3980
|
+
props: i,
|
|
3981
|
+
slot: i.slot || "label",
|
|
3982
|
+
key: `${e}tit`,
|
|
3983
|
+
type: i.type || "span"
|
|
3984
|
+
}]), o);
|
|
3985
|
+
},
|
|
3986
|
+
makeCol(t, e, r) {
|
|
3987
|
+
const i = t.col;
|
|
3988
|
+
return this.$r({
|
|
3989
|
+
class: i.class,
|
|
3990
|
+
type: "col",
|
|
3991
|
+
props: i || { span: 24 },
|
|
3992
|
+
key: `${e}col`
|
|
3993
|
+
}, r);
|
|
3994
|
+
},
|
|
3995
|
+
makeRow(t) {
|
|
3996
|
+
const e = this.options.row || {};
|
|
3997
|
+
return this.$r({
|
|
3998
|
+
type: "row",
|
|
3999
|
+
props: e,
|
|
4000
|
+
class: e.class,
|
|
4001
|
+
key: `${this.key}row`
|
|
4002
|
+
}, t);
|
|
4003
|
+
},
|
|
4004
|
+
makeFormBtn() {
|
|
4005
|
+
let t = [];
|
|
4006
|
+
if (D(this.options.submitBtn.show) || t.push(this.makeSubmitBtn()), D(this.options.resetBtn.show) || t.push(this.makeResetBtn()), !t.length)
|
|
4007
|
+
return;
|
|
4008
|
+
const e = this.$r({
|
|
4009
|
+
type: "formItem",
|
|
4010
|
+
key: `${this.key}fb`
|
|
4011
|
+
}, t);
|
|
4012
|
+
return this.rule.props.inline === !0 ? e : this.$r({
|
|
4013
|
+
type: "col",
|
|
4014
|
+
props: { span: 24 },
|
|
4015
|
+
key: `${this.key}fc`
|
|
4016
|
+
}, [e]);
|
|
4017
|
+
},
|
|
4018
|
+
makeResetBtn() {
|
|
4019
|
+
const t = this.options.resetBtn;
|
|
4020
|
+
return this.setSize(t), this.$r({
|
|
4021
|
+
type: "button",
|
|
4022
|
+
props: t,
|
|
4023
|
+
style: { width: t.width, marginLeft: "15px" },
|
|
4024
|
+
on: {
|
|
4025
|
+
click: () => {
|
|
4026
|
+
const e = this.$handle.api;
|
|
4027
|
+
t.click ? t.click(e) : e.resetFields();
|
|
4028
|
+
}
|
|
4029
|
+
},
|
|
4030
|
+
key: `${this.key}b2`
|
|
4031
|
+
}, [t.innerText]);
|
|
4032
|
+
},
|
|
4033
|
+
makeSubmitBtn() {
|
|
4034
|
+
const t = this.options.submitBtn;
|
|
4035
|
+
return this.setSize(t), this.$r({
|
|
4036
|
+
type: "button",
|
|
4037
|
+
props: t,
|
|
4038
|
+
style: { width: t.width },
|
|
4039
|
+
on: {
|
|
4040
|
+
click: () => {
|
|
4041
|
+
const e = this.$handle.api;
|
|
4042
|
+
t.click ? t.click(e) : e.submit();
|
|
4043
|
+
}
|
|
4044
|
+
},
|
|
4045
|
+
key: `${this.key}b1`
|
|
4046
|
+
}, [t.innerText]);
|
|
4047
|
+
}
|
|
4048
|
+
}, M = {}, Qr = ["upload", "select", "tree", "checkbox", "autoComplete", "cascader", "colorPicker", "frame", "inputNumber", "radio", "rate", "timePicker", "group"];
|
|
4049
|
+
function Zr(t) {
|
|
4050
|
+
Qr.forEach((e) => {
|
|
4051
|
+
t[e] = S(e);
|
|
4052
|
+
}), t.auto = t.autoComplete, t.number = t.inputNumber, t.color = t.colorPicker;
|
|
4053
|
+
}
|
|
4054
|
+
function Yr(t) {
|
|
4055
|
+
const e = "upload", r = {
|
|
4056
|
+
image: ["image", 0],
|
|
4057
|
+
file: ["file", 0],
|
|
4058
|
+
uploadFileOne: ["file", 1],
|
|
4059
|
+
uploadImageOne: ["image", 1]
|
|
4060
|
+
};
|
|
4061
|
+
Object.keys(r).reduce((i, s) => (i[s] = S(e, (n) => n.props({ uploadType: r[s][0], maxLength: r[s][1] })), i), t), t.uploadImage = t.image, t.uploadFile = t.file;
|
|
4062
|
+
}
|
|
4063
|
+
function ei(t) {
|
|
4064
|
+
const e = "tree", r = { treeSelected: "selected", treeChecked: "checked" };
|
|
4065
|
+
Object.keys(r).reduce((i, s) => (i[s] = S(e, { type: r[s] }), i), t);
|
|
4066
|
+
}
|
|
4067
|
+
function ti(t) {
|
|
4068
|
+
const e = "timePicker";
|
|
4069
|
+
t.time = S(e, { type: "time" }), t.timeRange = S(e, { type: "timerange" });
|
|
4070
|
+
}
|
|
4071
|
+
function ri(t) {
|
|
4072
|
+
const e = "select";
|
|
4073
|
+
t.selectMultiple = S(e, { multiple: !0 }), t.selectOne = S(e, { multiple: !1 });
|
|
4074
|
+
}
|
|
4075
|
+
function ii(t) {
|
|
4076
|
+
const e = "frame", r = {
|
|
4077
|
+
frameInputs: ["input", 0],
|
|
4078
|
+
frameFiles: ["file", 0],
|
|
4079
|
+
frameImages: ["image", 0],
|
|
4080
|
+
frameInputOne: ["input", 1],
|
|
4081
|
+
frameFileOne: ["file", 1],
|
|
4082
|
+
frameImageOne: ["image", 1]
|
|
4083
|
+
};
|
|
4084
|
+
Object.keys(r).reduce((i, s) => (i[s] = S(e, (n) => n.props({ type: r[s][0], maxLength: r[s][1] })), i), t), t.frameInput = t.frameInputs, t.frameFile = t.frameFiles, t.frameImage = t.frameImages;
|
|
4085
|
+
}
|
|
4086
|
+
Zr(M);
|
|
4087
|
+
Yr(M);
|
|
4088
|
+
ei(M);
|
|
4089
|
+
ri(M);
|
|
4090
|
+
ii(M);
|
|
4091
|
+
ti(M);
|
|
4092
|
+
function We(t, e) {
|
|
4093
|
+
return c.Boolean(t) ? t = { show: t } : !c.Undef(t) && !c.Object(t) && (t = { show: e }), t;
|
|
4094
|
+
}
|
|
4095
|
+
function ni(t, e) {
|
|
4096
|
+
return m(t, {
|
|
4097
|
+
formEl() {
|
|
4098
|
+
return e.$manager.form();
|
|
4099
|
+
},
|
|
4100
|
+
wrapEl(r) {
|
|
4101
|
+
const i = e.getFieldCtx(r);
|
|
4102
|
+
if (i)
|
|
4103
|
+
return e.vm.$refs[i.wrapRef];
|
|
4104
|
+
},
|
|
4105
|
+
validate(r) {
|
|
4106
|
+
return new Promise((i, s) => {
|
|
4107
|
+
const n = t.children, o = [e.$manager.validate()];
|
|
4108
|
+
n.forEach((a) => {
|
|
4109
|
+
o.push(a.validate());
|
|
4110
|
+
}), Promise.all(o).then(() => {
|
|
4111
|
+
i(!0), r && r(!0);
|
|
4112
|
+
}).catch((a) => {
|
|
4113
|
+
s(a), r && r(a), e.vm.$emit("validate-fail", a, { api: t });
|
|
4114
|
+
});
|
|
4115
|
+
});
|
|
4116
|
+
},
|
|
4117
|
+
validateField: (r, i) => new Promise((s, n) => {
|
|
4118
|
+
const o = e.getFieldCtx(r);
|
|
4119
|
+
if (!o) return;
|
|
4120
|
+
const a = e.subForm[o.id], u = [e.$manager.validateField(o.id)];
|
|
4121
|
+
j(a).forEach((l) => {
|
|
4122
|
+
u.push(l.validate().catch(() => Promise.reject("子表单验证未通过")));
|
|
4123
|
+
}), Promise.all(u).then(() => {
|
|
4124
|
+
s(null), i && i(null);
|
|
4125
|
+
}).catch((l) => {
|
|
4126
|
+
n(l), i && i(l), e.vm.$emit("validate-field-fail", l, { field: r, api: t });
|
|
4127
|
+
});
|
|
4128
|
+
}),
|
|
4129
|
+
clearValidateState(r, i = !0) {
|
|
4130
|
+
t.helper.tidyFields(r).forEach((s) => {
|
|
4131
|
+
i && this.clearSubValidateState(s), e.getCtxs(s).forEach((n) => {
|
|
4132
|
+
e.$manager.clearValidateState(n);
|
|
4133
|
+
});
|
|
4134
|
+
});
|
|
4135
|
+
},
|
|
4136
|
+
clearSubValidateState(r) {
|
|
4137
|
+
t.helper.tidyFields(r).forEach((i) => {
|
|
4138
|
+
e.getCtxs(i).forEach((s) => {
|
|
4139
|
+
const n = e.subForm[s.id];
|
|
4140
|
+
n && (Array.isArray(n) ? n.forEach((o) => {
|
|
4141
|
+
o.clearValidateState();
|
|
4142
|
+
}) : n && n.clearValidateState());
|
|
4143
|
+
});
|
|
4144
|
+
});
|
|
4145
|
+
},
|
|
4146
|
+
btn: {
|
|
4147
|
+
loading: (r = !0) => {
|
|
4148
|
+
t.submitBtnProps({ loading: !!r });
|
|
4149
|
+
},
|
|
4150
|
+
disabled: (r = !0) => {
|
|
4151
|
+
t.submitBtnProps({ disabled: !!r });
|
|
4152
|
+
},
|
|
4153
|
+
show: (r = !0) => {
|
|
4154
|
+
t.submitBtnProps({ show: !!r });
|
|
4155
|
+
}
|
|
4156
|
+
},
|
|
4157
|
+
resetBtn: {
|
|
4158
|
+
loading: (r = !0) => {
|
|
4159
|
+
t.resetBtnProps({ loading: !!r });
|
|
4160
|
+
},
|
|
4161
|
+
disabled: (r = !0) => {
|
|
4162
|
+
t.resetBtnProps({ disabled: !!r });
|
|
4163
|
+
},
|
|
4164
|
+
show: (r = !0) => {
|
|
4165
|
+
t.resetBtnProps({ show: !!r });
|
|
4166
|
+
}
|
|
4167
|
+
},
|
|
4168
|
+
submitBtnProps: (r = {}) => {
|
|
4169
|
+
let i = We(e.options.submitBtn, !0);
|
|
4170
|
+
m(i, r), e.options.submitBtn = i, t.refreshOptions();
|
|
4171
|
+
},
|
|
4172
|
+
resetBtnProps: (r = {}) => {
|
|
4173
|
+
let i = We(e.options.resetBtn, !1);
|
|
4174
|
+
m(i, r), e.options.resetBtn = i, t.refreshOptions();
|
|
4175
|
+
},
|
|
4176
|
+
submit(r, i) {
|
|
4177
|
+
t.validate((s) => {
|
|
4178
|
+
if (s) {
|
|
4179
|
+
let n = t.formData();
|
|
4180
|
+
c.Function(r) ? E(() => r(n, this)) : (c.Function(e.options.onSubmit) && E(() => e.options.onSubmit(n, this)), e.vm.$emit("submit", n, this));
|
|
4181
|
+
} else
|
|
4182
|
+
c.Function(i) && E(() => i(this, ...arguments));
|
|
4183
|
+
});
|
|
4184
|
+
}
|
|
4185
|
+
}), t;
|
|
4186
|
+
}
|
|
4187
|
+
function si(t) {
|
|
4188
|
+
t.componentAlias(Wr), xt.forEach((e) => {
|
|
4189
|
+
t.component(e.name, e);
|
|
4190
|
+
}), zr.forEach((e) => {
|
|
4191
|
+
t.parser(e);
|
|
4192
|
+
}), Object.keys(M).forEach((e) => {
|
|
4193
|
+
t.maker[e] = M[e];
|
|
4194
|
+
});
|
|
4195
|
+
}
|
|
4196
|
+
function oi() {
|
|
4197
|
+
return pt({
|
|
4198
|
+
ui: "iview",
|
|
4199
|
+
version: "2.6.0",
|
|
4200
|
+
manager: Xr,
|
|
4201
|
+
install: si,
|
|
4202
|
+
extendApi: ni,
|
|
4203
|
+
attrs: {
|
|
4204
|
+
normal: ["col", "wrap"],
|
|
4205
|
+
array: ["className"],
|
|
4206
|
+
key: ["title", "info"]
|
|
4207
|
+
}
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
const de = oi();
|
|
4211
|
+
typeof window != "undefined" && (window.formCreate = de, window.Vue && de.install(window.Vue));
|
|
4212
|
+
const ui = de.maker;
|
|
4213
|
+
export {
|
|
4214
|
+
de as default,
|
|
4215
|
+
ui as maker
|
|
4216
|
+
};
|