tianheng-ui 0.0.44 → 0.0.45

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.
@@ -1,266 +1,516 @@
1
- <template>
2
- <el-form-item :label="widget.name" :prop="widget.model">
3
- <template v-if="widget.type == 'input'" >
4
- <el-input
5
- v-if="widget.options.dataType == 'number' || widget.options.dataType == 'integer' || widget.options.dataType == 'float'"
6
- type="number"
7
- v-model.number="dataModel"
8
- :placeholder="widget.options.placeholder"
9
- :style="{width: widget.options.width}"
10
- :disabled="widget.options.disabled"
11
- ></el-input>
12
- <el-input
13
- v-else
14
- type="text"
15
- v-model="dataModel"
16
- :disabled="widget.options.disabled"
17
- :placeholder="widget.options.placeholder"
18
- :style="{width: widget.options.width}"
19
- :maxlength="widget.options.maxlength"
20
- :show-word-limit="widget.options.showWordLimit"
21
- ></el-input>
22
- </template>
23
-
24
- <template v-if="widget.type == 'textarea'">
25
- <el-input type="textarea" :rows="5"
26
- v-model="dataModel"
27
- :disabled="widget.options.disabled"
28
- :placeholder="widget.options.placeholder"
29
- :style="{width: widget.options.width}"
30
- :maxlength="widget.options.maxlength"
31
- :show-word-limit="widget.options.showWordLimit"
32
- ></el-input>
33
- </template>
34
-
35
- <template v-if="widget.type == 'number'">
36
- <el-input-number
37
- v-model="dataModel"
38
- :style="{width: widget.options.width}"
39
- :step="widget.options.step"
40
- controls-position="right"
41
- :disabled="widget.options.disabled"
42
- :min="widget.options.min"
43
- :max="widget.options.max"
44
- ></el-input-number>
45
- </template>
46
-
47
- <template v-if="widget.type == 'radio'">
48
- <el-radio-group v-model="dataModel"
49
- :style="{width: widget.options.width}"
50
- :disabled="widget.options.disabled"
51
- >
52
- <el-radio
53
- :style="{display: widget.options.inline ? 'inline-block' : 'block'}"
54
- :label="item.value" v-for="(item, index) in (widget.options.remote ? widget.options.remoteOptions : widget.options.options)" :key="index"
55
- >
56
- <template v-if="widget.options.remote">{{item.label}}</template>
57
- <template v-else>{{widget.options.showLabel ? item.label : item.value}}</template>
58
- </el-radio>
59
- </el-radio-group>
60
- </template>
61
-
62
- <template v-if="widget.type == 'checkbox'">
63
- <el-checkbox-group v-model="dataModel"
64
- :style="{width: widget.options.width}"
65
- :disabled="widget.options.disabled"
66
- >
67
- <el-checkbox
68
-
69
- :style="{display: widget.options.inline ? 'inline-block' : 'block'}"
70
- :label="item.value" v-for="(item, index) in (widget.options.remote ? widget.options.remoteOptions : widget.options.options)" :key="index"
71
- >
72
- <template v-if="widget.options.remote">{{item.label}}</template>
73
- <template v-else>{{widget.options.showLabel ? item.label : item.value}}</template>
74
- </el-checkbox>
75
- </el-checkbox-group>
76
- </template>
77
-
78
- <template v-if="widget.type == 'time'">
79
- <el-time-picker
80
- v-model="dataModel"
81
- :is-range="widget.options.isRange"
82
- :placeholder="widget.options.placeholder"
83
- :start-placeholder="widget.options.startPlaceholder"
84
- :end-placeholder="widget.options.endPlaceholder"
85
- :readonly="widget.options.readonly"
86
- :disabled="widget.options.disabled"
87
- :editable="widget.options.editable"
88
- :clearable="widget.options.clearable"
89
- :arrowControl="widget.options.arrowControl"
90
- :value-format="widget.options.format"
91
- :style="{width: widget.options.width}"
92
- >
93
- </el-time-picker>
94
- </template>
95
-
96
- <template v-if="widget.type=='date'">
97
- <el-date-picker
98
- v-model="dataModel"
99
- :type="widget.options.type"
100
- :placeholder="widget.options.placeholder"
101
- :start-placeholder="widget.options.startPlaceholder"
102
- :end-placeholder="widget.options.endPlaceholder"
103
- :readonly="widget.options.readonly"
104
- :disabled="widget.options.disabled"
105
- :editable="widget.options.editable"
106
- :clearable="widget.options.clearable"
107
- :value-format="widget.options.timestamp ? 'timestamp' : widget.options.format"
108
- :format="widget.options.format"
109
- :style="{width: widget.options.width}"
110
- >
111
- </el-date-picker>
112
- </template>
113
-
114
- <template v-if="widget.type =='rate'">
115
- <el-rate v-model="dataModel"
116
- :max="widget.options.max"
117
- :disabled="widget.options.disabled"
118
- :allow-half="widget.options.allowHalf"
119
- ></el-rate>
120
- </template>
121
-
122
- <template v-if="widget.type == 'color'">
123
- <el-color-picker
124
- v-model="dataModel"
125
- :disabled="widget.options.disabled"
126
- :show-alpha="widget.options.showAlpha"
127
- ></el-color-picker>
128
- </template>
129
-
130
- <template v-if="widget.type == 'select'">
131
- <el-select
132
- v-model="dataModel"
133
- :disabled="widget.options.disabled"
134
- :multiple="widget.options.multiple"
135
- :clearable="widget.options.clearable"
136
- :placeholder="widget.options.placeholder"
137
- :style="{width: widget.options.width}"
138
- :filterable="widget.options.filterable"
139
- >
140
- <el-option v-for="item in (widget.options.remote ? widget.options.remoteOptions : widget.options.options)" :key="item.value" :value="item.value" :label="widget.options.showLabel || widget.options.remote?item.label:item.value"></el-option>
141
- </el-select>
142
- </template>
143
-
144
- <template v-if="widget.type=='switch'">
145
- <el-switch
146
- v-model="dataModel"
147
- :disabled="widget.options.disabled"
148
- >
149
- </el-switch>
150
- </template>
151
-
152
- <template v-if="widget.type=='slider'">
153
- <el-slider
154
- v-model="dataModel"
155
- :min="widget.options.min"
156
- :max="widget.options.max"
157
- :disabled="widget.options.disabled"
158
- :step="widget.options.step"
159
- :show-input="widget.options.showInput"
160
- :range="widget.options.range"
161
- :style="{width: widget.options.width}"
162
- ></el-slider>
163
- </template>
164
-
165
- <template v-if="widget.type=='imgupload'">
166
- <fm-upload
167
- v-model="dataModel"
168
- :disabled="widget.options.disabled"
169
- :style="{'width': widget.options.width}"
170
- :width="widget.options.size.width"
171
- :height="widget.options.size.height"
172
- :token="widget.options.token"
173
- :domain="widget.options.domain"
174
- :multiple="widget.options.multiple"
175
- :length="widget.options.length"
176
- :is-qiniu="widget.options.isQiniu"
177
- :is-delete="widget.options.isDelete"
178
- :min="widget.options.min"
179
- :is-edit="widget.options.isEdit"
180
- :action="widget.options.action"
181
- >
182
- </fm-upload>
183
- </template>
184
-
185
- <template v-if="widget.type == 'editor'">
186
- <vue-editor
187
- v-model="dataModel"
188
- :style="{width: widget.options.width}"
189
- >
190
- </vue-editor>
191
- </template>
192
-
193
- <template v-if="widget.type == 'cascader'">
194
- <el-cascader
195
- v-model="dataModel"
196
- :disabled="widget.options.disabled"
197
- :clearable="widget.options.clearable"
198
- :placeholder="widget.options.placeholder"
199
- :style="{width: widget.options.width}"
200
- :options="widget.options.remoteOptions"
201
- >
202
-
203
- </el-cascader>
204
- </template>
205
-
206
- <template v-if="widget.type == 'text'">
207
- <span>{{dataModel}}</span>
208
- </template>
209
- </el-form-item>
210
- </template>
211
-
212
- <script>
213
- import FmUpload from './Upload'
214
-
215
- export default {
216
- props: ['widget', 'models', 'rules', 'remote'],
217
- components: {
218
- FmUpload
219
- },
220
- data () {
221
- return {
222
- dataModel: this.models[this.widget.model]
223
- }
224
- },
225
- created () {
226
- if (this.widget.options.remote && this.remote[this.widget.options.remoteFunc]) {
227
- this.remote[this.widget.options.remoteFunc]((data) => {
228
- this.widget.options.remoteOptions = data.map(item => {
229
- return {
230
- value: item[this.widget.options.props.value],
231
- label: item[this.widget.options.props.label],
232
- children: item[this.widget.options.props.children]
233
- }
234
- })
235
- })
236
- }
237
-
238
- if (this.widget.type === 'imgupload' && this.widget.options.isQiniu) {
239
- this.remote[this.widget.options.tokenFunc]((data) => {
240
- this.widget.options.token = data
241
- })
242
- }
243
- },
244
- methods: {
245
- },
246
- watch: {
247
- dataModel: {
248
- deep: true,
249
- handler (val) {
250
- this.models[this.widget.model] = val
251
- this.$emit('update:models', {
252
- ...this.models,
253
- [this.widget.model]: val
254
- })
255
- this.$emit('input-change', val, this.widget.model)
256
- }
257
- },
258
- models: {
259
- deep: true,
260
- handler (val) {
261
- this.dataModel = val[this.widget.model]
262
- }
263
- }
264
- }
265
- }
266
- </script>
1
+ <template>
2
+ <el-form-item :label="widget.name" :prop="widget.model">
3
+ <template v-if="widget.type == 'input'">
4
+ <el-input
5
+ v-if="
6
+ widget.options.dataType == 'number' ||
7
+ widget.options.dataType == 'integer' ||
8
+ widget.options.dataType == 'float'
9
+ "
10
+ type="number"
11
+ v-model.number="dataModel"
12
+ :placeholder="widget.options.placeholder"
13
+ :style="{ width: widget.options.width }"
14
+ :disabled="widget.options.disabled"
15
+ :readonly="widget.options.readonly"
16
+ :clearable="widget.options.clearable"
17
+ :maxlength="widget.options.maxlength"
18
+ :show-word-limit="widget.options.showWordLimit"
19
+ :show-password="widget.options.showPassword"
20
+ >
21
+ </el-input>
22
+ <el-input
23
+ v-else
24
+ type="text"
25
+ v-model="dataModel"
26
+ :placeholder="widget.options.placeholder"
27
+ :style="{ width: widget.options.width }"
28
+ :disabled="widget.options.disabled"
29
+ :readonly="widget.options.readonly"
30
+ :clearable="widget.options.clearable"
31
+ :maxlength="widget.options.maxlength"
32
+ :show-word-limit="widget.options.showWordLimit"
33
+ :show-password="widget.options.showPassword"
34
+ :suffix-icon="widget.options.suffixIcon"
35
+ :prefix-icon="widget.options.prefixIcon"
36
+ >
37
+ <template v-if="widget.options.prepend" slot="prepend">{{
38
+ widget.options.prepend
39
+ }}</template>
40
+ <template v-if="widget.options.append" slot="append">{{
41
+ widget.options.append
42
+ }}</template>
43
+ </el-input>
44
+ </template>
45
+
46
+ <template v-if="widget.type == 'textarea'">
47
+ <el-input
48
+ type="textarea"
49
+ v-model="dataModel"
50
+ :disabled="widget.options.disabled"
51
+ :placeholder="widget.options.placeholder"
52
+ :style="{ width: widget.options.width }"
53
+ :maxlength="widget.options.maxlength"
54
+ :clearable="widget.options.clearable"
55
+ :show-word-limit="widget.options.showWordLimit"
56
+ :autosize="{
57
+ minRows: widget.options.minRows,
58
+ maxRows: widget.options.maxRows
59
+ }"
60
+ ></el-input>
61
+ </template>
62
+
63
+ <template v-if="widget.type == 'number'">
64
+ <el-input-number
65
+ v-model="dataModel"
66
+ :style="{ width: widget.options.width }"
67
+ :step="widget.options.step"
68
+ :controls-position="widget.options.controlsPosition ? 'right' : ''"
69
+ :disabled="widget.options.disabled"
70
+ :min="widget.options.min"
71
+ :max="widget.options.max"
72
+ :precision="widget.options.precision"
73
+ ></el-input-number>
74
+ </template>
75
+
76
+ <template v-if="widget.type == 'radio'">
77
+ <el-radio-group
78
+ v-model="dataModel"
79
+ :style="{ width: widget.options.width }"
80
+ :disabled="widget.options.disabled"
81
+ >
82
+ <template v-if="widget.options.buttonType">
83
+ <el-radio-button
84
+ :style="{
85
+ display: widget.options.inline ? 'inline-block' : 'block'
86
+ }"
87
+ :label="item.value"
88
+ :border="widget.options.border"
89
+ v-for="(item, index) in widget.options.remote
90
+ ? widget.options.remoteOptions
91
+ : widget.options.options"
92
+ :key="index"
93
+ >
94
+ <template v-if="widget.options.remote">{{ item.label }}</template>
95
+ <template v-else>{{
96
+ widget.options.showLabel ? item.label : item.value
97
+ }}</template>
98
+ </el-radio-button>
99
+ </template>
100
+ <template v-else>
101
+ <el-radio
102
+ :style="{
103
+ display: widget.options.inline ? 'inline-block' : 'block'
104
+ }"
105
+ :label="item.value"
106
+ :border="widget.options.border"
107
+ v-for="(item, index) in widget.options.remote
108
+ ? widget.options.remoteOptions
109
+ : widget.options.options"
110
+ :key="index"
111
+ >
112
+ <template v-if="widget.options.remote">{{ item.label }}</template>
113
+ <template v-else>{{
114
+ widget.options.showLabel ? item.label : item.value
115
+ }}</template>
116
+ </el-radio>
117
+ </template>
118
+ </el-radio-group>
119
+ </template>
120
+
121
+ <template v-if="widget.type == 'checkbox'">
122
+ <el-checkbox-group
123
+ v-model="dataModel"
124
+ :style="{ width: widget.options.width }"
125
+ :disabled="widget.options.disabled"
126
+ :min="widget.options.min"
127
+ :max="widget.options.max"
128
+ >
129
+ <template v-if="widget.options.buttonType">
130
+ <el-checkbox-button
131
+ :style="{
132
+ display: widget.options.inline ? 'inline-block' : 'block'
133
+ }"
134
+ :label="item.value"
135
+ :border="widget.options.border"
136
+ v-for="(item, index) in widget.options.remote
137
+ ? widget.options.remoteOptions
138
+ : widget.options.options"
139
+ :key="index"
140
+ >
141
+ <template v-if="widget.options.remote">{{ item.label }}</template>
142
+ <template v-else>{{
143
+ widget.options.showLabel ? item.label : item.value
144
+ }}</template>
145
+ </el-checkbox-button>
146
+ </template>
147
+ <template v-else>
148
+ <el-checkbox
149
+ :style="{
150
+ display: widget.options.inline ? 'inline-block' : 'block'
151
+ }"
152
+ :label="item.value"
153
+ :border="widget.options.border"
154
+ v-for="(item, index) in widget.options.remote
155
+ ? widget.options.remoteOptions
156
+ : widget.options.options"
157
+ :key="index"
158
+ >
159
+ <template v-if="widget.options.remote">{{ item.label }}</template>
160
+ <template v-else>{{
161
+ widget.options.showLabel ? item.label : item.value
162
+ }}</template>
163
+ </el-checkbox>
164
+ </template>
165
+ </el-checkbox-group>
166
+ </template>
167
+
168
+ <template v-if="widget.type == 'time'">
169
+ <el-time-picker
170
+ v-if="widget.options.timeType"
171
+ v-model="dataModel"
172
+ :is-range="widget.options.isRange"
173
+ :placeholder="widget.options.placeholder"
174
+ :start-placeholder="widget.options.startPlaceholder"
175
+ :end-placeholder="widget.options.endPlaceholder"
176
+ :readonly="widget.options.readonly"
177
+ :disabled="widget.options.disabled"
178
+ :editable="widget.options.editable"
179
+ :clearable="widget.options.clearable"
180
+ :arrowControl="widget.options.arrowControl"
181
+ :value-format="widget.options.format"
182
+ :style="{ width: widget.options.width }"
183
+ >
184
+ </el-time-picker>
185
+ <template v-else>
186
+ <el-time-select
187
+ v-model="dataModel[0]"
188
+ :placeholder="
189
+ widget.options.selectRange
190
+ ? widget.options.startPlaceholder
191
+ : widget.options.placeholder
192
+ "
193
+ :readonly="widget.options.readonly"
194
+ :disabled="widget.options.disabled"
195
+ :editable="widget.options.editable"
196
+ :clearable="widget.options.clearable"
197
+ :arrowControl="widget.options.arrowControl"
198
+ :style="{ width: widget.options.width }"
199
+ :picker-options="widget.options.stretTimePickerOptions"
200
+ @change="e => handleTimePicker(e)"
201
+ >
202
+ </el-time-select>
203
+ <el-time-select
204
+ v-model="dataModel[1]"
205
+ v-if="widget.options.selectRange"
206
+ :placeholder="widget.options.endPlaceholder"
207
+ :readonly="widget.options.readonly"
208
+ :disabled="widget.options.disabled"
209
+ :editable="widget.options.editable"
210
+ :clearable="widget.options.clearable"
211
+ :arrowControl="widget.options.arrowControl"
212
+ :style="{ width: widget.options.width }"
213
+ :picker-options="widget.options.endTimePickerOptions"
214
+ >
215
+ </el-time-select>
216
+ </template>
217
+ </template>
218
+
219
+ <template v-if="widget.type == 'date'">
220
+ <el-date-picker
221
+ v-model="dataModel"
222
+ :type="widget.options.type"
223
+ :is-range="widget.options.isRange"
224
+ :placeholder="widget.options.placeholder"
225
+ :start-placeholder="widget.options.startPlaceholder"
226
+ :end-placeholder="widget.options.endPlaceholder"
227
+ :readonly="widget.options.readonly"
228
+ :disabled="widget.options.disabled"
229
+ :editable="widget.options.editable"
230
+ :clearable="widget.options.clearable"
231
+ :style="{ width: widget.options.width }"
232
+ >
233
+ </el-date-picker>
234
+ </template>
235
+
236
+ <template v-if="widget.type == 'rate'">
237
+ <el-rate
238
+ v-model="dataModel"
239
+ :max="widget.options.max"
240
+ :disabled="widget.options.disabled"
241
+ :allow-half="widget.options.allowHalf"
242
+ :show-text="widget.options.showText"
243
+ :texts="widget.options.auxiliaryValue"
244
+ ></el-rate>
245
+ </template>
246
+
247
+ <template v-if="widget.type == 'color'">
248
+ <el-color-picker
249
+ v-model="dataModel"
250
+ :disabled="widget.options.disabled"
251
+ :show-alpha="widget.options.showAlpha"
252
+ ></el-color-picker>
253
+ </template>
254
+
255
+ <template v-if="widget.type == 'select'">
256
+ <el-select
257
+ v-model="dataModel"
258
+ :disabled="widget.options.disabled"
259
+ :multiple="widget.options.multiple"
260
+ :clearable="widget.options.clearable"
261
+ :placeholder="widget.options.placeholder"
262
+ :collapseTags="widget.options.collapseTags"
263
+ :allowCreate="widget.options.allowCreate"
264
+ :filterable="
265
+ widget.options.allowCreate ? true : widget.options.filterable
266
+ "
267
+ :style="{ width: widget.options.width }"
268
+ >
269
+ <el-option
270
+ v-for="item in widget.options.remote
271
+ ? widget.options.remoteOptions
272
+ : widget.options.options"
273
+ :key="item.value"
274
+ :value="item.value"
275
+ :label="
276
+ widget.options.showLabel || widget.options.remote
277
+ ? item.label
278
+ : item.value
279
+ "
280
+ ></el-option>
281
+ </el-select>
282
+ </template>
283
+
284
+ <template v-if="widget.type == 'switch'">
285
+ <el-switch
286
+ v-model="dataModel"
287
+ :disabled="widget.options.disabled"
288
+ :inactive-text="widget.options.switchInactiveText"
289
+ :active-text="widget.options.switchActiveText"
290
+ :inactive-color="widget.options.switchInactiveColor"
291
+ :active-color="widget.options.switchActiveColor"
292
+ >
293
+ </el-switch>
294
+ </template>
295
+
296
+ <template v-if="widget.type == 'slider'">
297
+ <el-slider
298
+ v-model="dataModel"
299
+ :min="widget.options.min"
300
+ :max="widget.options.max"
301
+ :disabled="widget.options.disabled"
302
+ :step="widget.options.step"
303
+ :show-input="widget.options.showInput"
304
+ :range="widget.options.range"
305
+ :style="{ width: widget.options.width, height: widget.options.height }"
306
+ :show-tooltip="widget.options.showTooltip"
307
+ :format-tooltip="
308
+ val => formatTooltip(val, widget.options.formatTooltip)
309
+ "
310
+ :show-stops="widget.options.showStops"
311
+ :vertical="widget.options.vertical"
312
+ ></el-slider>
313
+ </template>
314
+
315
+ <template v-if="widget.type == 'imgupload'">
316
+ <!-- <fm-upload
317
+ v-model="dataModel"
318
+ :disabled="widget.options.disabled"
319
+ :style="{ width: widget.options.width }"
320
+ :width="widget.options.size.width"
321
+ :height="widget.options.size.height"
322
+ :token="widget.options.token"
323
+ :domain="widget.options.domain"
324
+ :multiple="widget.options.multiple"
325
+ :length="widget.options.length"
326
+ :is-qiniu="widget.options.isQiniu"
327
+ :is-delete="widget.options.isDelete"
328
+ :min="widget.options.min"
329
+ :is-edit="widget.options.isEdit"
330
+ :action="widget.options.action"
331
+ >
332
+ </fm-upload> -->
333
+
334
+ <el-upload
335
+ class="upload-demo"
336
+ :action="widget.options.remoteFunc"
337
+ :on-preview="
338
+ file => handlePictureCardPreview(file, widget.options.listType)
339
+ "
340
+ :on-remove="handleRemove"
341
+ :multiple="widget.options.multiple"
342
+ :limit="widget.options.length"
343
+ :width="widget.options.size.width"
344
+ :height="widget.options.size.height"
345
+ :list-type="widget.options.listType"
346
+ :on-change="handleAvatar"
347
+ :on-error="handleAvatarError"
348
+ :drag="widget.options.drag"
349
+ :disabled="widget.options.disabled"
350
+ :auto-upload="false"
351
+ >
352
+ <el-button
353
+ size="small"
354
+ type="primary"
355
+ :disabled="widget.options.disabled"
356
+ v-if="
357
+ ['default', 'picture'].includes(widget.options.listType) &&
358
+ !widget.options.drag
359
+ "
360
+ >点击上传</el-button
361
+ >
362
+ <i
363
+ slot="default"
364
+ class="el-icon-plus"
365
+ v-if="
366
+ widget.options.listType === 'picture-card' && !widget.options.drag
367
+ "
368
+ ></i>
369
+ <i class="el-icon-upload" v-if="widget.options.drag"></i>
370
+ <div class="el-upload__text" v-if="widget.options.drag">
371
+ 将文件拖到此处,或<em>点击上传</em>
372
+ </div>
373
+ <div
374
+ slot="tip"
375
+ class="el-upload__tip"
376
+ v-html="widget.options.elUploadTip"
377
+ ></div>
378
+ </el-upload>
379
+ </template>
380
+
381
+ <template v-if="widget.type == 'editor'">
382
+ <vue-editor
383
+ v-model="dataModel"
384
+ :style="{ width: widget.options.width }"
385
+ :disabled="widget.options.disabled"
386
+ >
387
+ </vue-editor>
388
+ </template>
389
+
390
+ <template v-if="widget.type == 'cascader'">
391
+ <el-cascader
392
+ v-model="dataModel"
393
+ :disabled="widget.options.disabled"
394
+ :clearable="widget.options.clearable"
395
+ :placeholder="widget.options.placeholder"
396
+ :style="{ width: widget.options.width, height: widget.options.height }"
397
+ :options="widget.options.remoteOptions"
398
+ :props="widget.options.props"
399
+ :show-all-levels="widget.options.showAllLevels ? false : true"
400
+ :collapse-tags="widget.options.collapseTags"
401
+ :filterable="widget.options.filterable"
402
+ >
403
+ <template slot-scope="{ data }">
404
+ <span v-html="widget.options.prepend"></span>
405
+ <span>{{ data.label }}</span>
406
+ <span v-html="widget.options.append"></span>
407
+ </template>
408
+ </el-cascader>
409
+ </template>
410
+
411
+ <template v-if="widget.type == 'text'">
412
+ <span>{{ dataModel }}</span>
413
+ </template>
414
+ <el-dialog :visible.sync="dialogVisible" append-to-body>
415
+ <img width="100%" :src="dialogImageUrl" alt="" />
416
+ </el-dialog>
417
+ </el-form-item>
418
+ </template>
419
+
420
+ <script>
421
+ import FmUpload from "./Upload";
422
+ import { VueEditor } from "vue2-editor";
423
+ export default {
424
+ props: ["widget", "models", "rules", "remote"],
425
+ components: {
426
+ FmUpload,
427
+ VueEditor
428
+ },
429
+ data() {
430
+ return {
431
+ dataModel: this.models[this.widget.model],
432
+ dialogVisible: false,
433
+ dialogImageUrl: ""
434
+ };
435
+ },
436
+ created() {
437
+ if (
438
+ this.widget.options.remote &&
439
+ this.remote[this.widget.options.remoteFunc]
440
+ ) {
441
+ this.remote[this.widget.options.remoteFunc](data => {
442
+ this.widget.options.remoteOptions = data.map(item => {
443
+ return {
444
+ value: item[this.widget.options.props.value],
445
+ label: item[this.widget.options.props.label],
446
+ children: item[this.widget.options.props.children]
447
+ };
448
+ });
449
+ });
450
+ }
451
+
452
+ if (
453
+ this.widget.type === "imgupload" &&
454
+ this.remote[this.widget.options.remoteFunc]
455
+ ) {
456
+ this.remote[this.widget.options.remoteFunc](data => {
457
+ this.widget.options.remoteApi = data;
458
+ });
459
+ }
460
+
461
+ if (this.widget.type === "time" && !this.widget.options.timeType) {
462
+ this.dataModel = [];
463
+ }
464
+ },
465
+ methods: {
466
+ handleTimePicker(vals) {
467
+ this.dataModel = [];
468
+ this.dataModel[0] = vals;
469
+ this.widget.options.endTimePickerOptions.minTime = vals;
470
+ },
471
+ formatTooltip(val, num) {
472
+ return val / num;
473
+ },
474
+ handlePictureCardPreview(file, listType) {
475
+ if (listType === "picture-card") {
476
+ this.dialogImageUrl = file.url;
477
+ this.dialogVisible = true;
478
+ }
479
+ },
480
+ handleRemove(file, fileList) {
481
+ this.dataModel = {
482
+ data: fileList,
483
+ remoteApi: this.widget.options.remoteApi
484
+ };
485
+ },
486
+ handleAvatar(res, file) {
487
+ this.dataModel = {
488
+ data: file,
489
+ remoteApi: this.widget.options.remoteApi
490
+ };
491
+ },
492
+ handleAvatarError() {
493
+ console.log("上传失败!");
494
+ }
495
+ },
496
+ watch: {
497
+ dataModel: {
498
+ deep: true,
499
+ handler(val) {
500
+ this.models[this.widget.model] = val;
501
+ this.$emit("update:models", {
502
+ ...this.models,
503
+ [this.widget.model]: val
504
+ });
505
+ this.$emit("input-change", val, this.widget.model);
506
+ }
507
+ },
508
+ models: {
509
+ deep: true,
510
+ handler(val) {
511
+ this.dataModel = val[this.widget.model];
512
+ }
513
+ }
514
+ }
515
+ };
516
+ </script>