tianheng-ui 0.0.43 → 0.0.46

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