askbot-dragon 0.6.17 → 0.6.21

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.
Files changed (45) hide show
  1. package/README.md +27 -27
  2. package/babel.config.js +5 -5
  3. package/dragon.iml +7 -7
  4. package/package.json +54 -52
  5. package/public/index.html +27 -26
  6. package/src/App.vue +31 -31
  7. package/src/api/index.js +1 -1
  8. package/src/api/mock.http +2 -2
  9. package/src/api/requestUrl.js +185 -185
  10. package/src/assets/less/common.css +6760 -6760
  11. package/src/assets/less/converSationContainer/common.less +4751 -4751
  12. package/src/assets/less/converSationContainer/converSatonContainer.less +492 -492
  13. package/src/assets/less/ticketMessage.less +319 -319
  14. package/src/components/ActionAlertIframe.vue +117 -117
  15. package/src/components/AskIFrame.vue +15 -15
  16. package/src/components/ConversationContainer.vue +1388 -1388
  17. package/src/components/FileType.vue +88 -88
  18. package/src/components/Message.vue +27 -27
  19. package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
  20. package/src/components/ask-components/Msgloading.vue +37 -37
  21. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  22. package/src/components/chatContent.vue +512 -512
  23. package/src/components/feedBack.vue +133 -133
  24. package/src/components/file/AliyunOssComponents.vue +109 -109
  25. package/src/components/formTemplate.vue +1898 -2039
  26. package/src/components/message/ActionAlertIframe.vue +116 -116
  27. package/src/components/message/ShopMessage.vue +168 -168
  28. package/src/components/message/TextMessage.vue +895 -895
  29. package/src/components/message/TicketMessage.vue +173 -173
  30. package/src/components/message/swiper/index.js +4 -4
  31. package/src/components/message/swiper/ticketSwiper.vue +530 -530
  32. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  33. package/src/components/selector/hOption.vue +20 -20
  34. package/src/components/selector/hSelector.vue +199 -199
  35. package/src/components/selector/hWrapper.vue +216 -216
  36. package/src/components/source/BotMessage.vue +24 -24
  37. package/src/components/source/CustomMessage.vue +24 -24
  38. package/src/components/test.vue +260 -260
  39. package/src/components/utils/AliyunIssUtil.js +72 -72
  40. package/src/components/utils/ckeditor.js +124 -0
  41. package/src/components/utils/format_date.js +18 -18
  42. package/src/components/utils/index.js +6 -6
  43. package/src/components/utils/math_utils.js +15 -15
  44. package/src/main.js +44 -43
  45. package/vue.config.js +34 -28
@@ -1,2040 +1,1899 @@
1
- <template>
2
- <div class="media-body">
3
- <div class="formClass" :class="{remPhoneClassForm:isPhone,remCompanyClassForm:isCompany}" v-if="formShow.form">
4
- <div class="titleName" >
5
- {{formShow.form.name}}
6
- </div>
7
- <div class="pcFormClass" v-if="isCompany===true" style="width: 300px;margin: 0 auto;">
8
- <div v-for="(item) in formShow.form.formFieldRelation"
9
- :key="item.formField.id"
10
- :class="{notClick:disableds === true}"
11
- >
12
- <div v-if="item.formField.type!=='CHAT_RECORD'&&item.formField.type!=='CHANNEL'&&item.display&&item.fieldId!=='workorder_name'" class="field-item">
13
- <div v-if="item.display&&item.fieldId!=='workorder_name'&&item.formField.type!=='EXPLANATION'&&item.formField.type!=='EXPLAIN'" class="field-item-name">
14
- <span style="color: red" v-if="item.required===true">*</span>
15
- <span v-if="item.fieldId!=='workorder_description'&&item.fieldId!=='workorder_clientId'">{{item.formField.name}}</span>
16
- <span v-if="item.fieldId==='workorder_description'">问题描述</span>
17
- <span v-if="item.fieldId==='workorder_clientId'">报单人</span>
18
- </div>
19
- <el-input v-model=item.value
20
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
21
- :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
22
- v-if="item.formField.type==='INPUT'&&item.fieldId!=='workorder_name'"
23
- ></el-input>
24
- <div v-if="item.formField.type==='EXPLANATION'">
25
- <div style="display: flex;padding: 4px 0">
26
- <p style="color: #4C61E1;font-size: 14px;margin: 10px 4px">
27
- <span class="el-icon-info"></span>
28
- {{item.formField.extInfo.descriptionText}}
29
- </p>
30
- </div>
31
- </div>
32
- <div v-if="item.formField.type==='EXPLAIN'">
33
- <div style="display: flex;padding: 4px 0">
34
- <p style="color: #4C61E1;font-size: 14px;margin: 10px 4px">
35
- <span class="el-icon-info"></span>
36
- <span v-if="item.formField.extInfo.url" class="explain-url"><a :href="item.formField.extInfo.url" target="_blank">{{item.value}}</a></span>
37
- <span v-else>{{item.value}}</span>
38
- </p>
39
- </div>
40
- </div>
41
- <el-input type="textarea" :rows="2" v-model=item.value
42
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
43
- :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
44
- v-if="item.formField.type==='TEXTAREA'&& item.display"
45
- ></el-input>
46
- <el-date-picker
47
- v-model=item.value
48
- type="date"
49
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
50
- style="width: 100%"
51
- v-if="item.formField.type==='DATE_PICKER'"
52
- >
53
- </el-date-picker>
54
- <el-time-picker
55
- v-model=item.value
56
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
57
- style="width: 100%"
58
- v-if="item.formField.type==='TIME_PICKER' && !item.formField.extInfo.mold"
59
- >
60
- </el-time-picker>
61
- <el-date-picker
62
- v-model=item.value
63
- type="date"
64
- style="width: 100%"
65
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
66
- v-if="item.formField.type==='TIME_PICKER' &&item.formField.extInfo.mold==='DATA'"
67
- >
68
- </el-date-picker>
69
- <el-date-picker
70
- v-model=item.value
71
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期时间'"
72
- clearable
73
- style="width: 100%"
74
- type="datetime"
75
- v-if="item.formField.type==='TIME_PICKER' &&item.formField.extInfo.mold==='DATA_TIME'"
76
- >
77
- </el-date-picker>
78
- <div v-if="item.formField.type==='RADIO' &&item.formField.extInfo.options">
79
- <el-radio-group v-model=item.value style="text-align:left">
80
- <el-radio v-for="(items,index) in item.formField.extInfo.options" :label=items.value :key="index">{{items.label}}</el-radio>
81
- </el-radio-group>
82
- </div>
83
- <div v-if="item.formField.type==='RADIO' &&item.formField.extInfo.option">
84
- <el-radio-group v-model=item.value style="text-align:left">
85
- <el-radio v-for="(items,index) in item.formField.extInfo.option" :label=items.value :key="index">{{items.label}}</el-radio>
86
- </el-radio-group>
87
- </div>
88
- <div v-if="item.formField.type==='CHECKBOX' && item.formField.extInfo.option">
89
- <el-checkbox-group v-model=item.value style="text-align:left">
90
- <el-checkbox
91
- v-for="(items,index) in item.formField.extInfo.option"
92
- :label=items.value
93
- :key="index"
94
- >{{items.label}}</el-checkbox>
95
- </el-checkbox-group>
96
- </div>
97
- <div v-if="item.formField.type==='CHECKBOX' && item.formField.extInfo.options">
98
- <el-checkbox-group v-model=item.value style="text-align:left">
99
- <el-checkbox
100
- v-for="(items,index) in item.formField.extInfo.options"
101
- :label=items.value
102
- :key="index"
103
- >{{items.label}}</el-checkbox>
104
- </el-checkbox-group>
105
- </div>
106
- <div v-if="item.formField.type==='SELECT'">
107
- <el-select
108
- v-model=item.value
109
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
110
- style="width: 100%"
111
- filterable
112
- v-if="item.formField.extInfo.option"
113
- >
114
- <el-option
115
- v-for="(items,index) in item.formField.extInfo.option"
116
- :key="index"
117
- :label="items.label"
118
- :value="items.value">
119
- </el-option>
120
- </el-select>
121
- <el-select
122
- v-model=item.value
123
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
124
- style="width: 100%"
125
- filterable
126
- v-else-if="item.formField.extInfo.options"
127
- >
128
- <el-option
129
- v-for="(items,index) in item.formField.extInfo.options"
130
- :key="index"
131
- :label="items.label"
132
- :value="items.value">
133
- </el-option>
134
- </el-select>
135
- </div>
136
- <div v-if="item.formField.type==='CASCADER'">
137
- <el-cascader
138
- v-model=item.value
139
- :options=item.formField.extInfo.cascade
140
- style="width: 100%;"
141
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
142
- v-if="item.formField.extInfo.cascade"
143
- ></el-cascader>
144
- <el-cascader
145
- v-model=item.value
146
- :options=item.formField.extInfo.cascadeDown[0].options
147
- style="width: 100%;"
148
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
149
- v-else-if="item.formField.extInfo.cascadeDown"
150
- ></el-cascader>
151
- </div>
152
- <div v-if="item.formField.type==='FILE'">
153
- <div @click="checkUpload(item.fieldId,item.formField.extInfo.limitNum)" @mouseover="checkUpload(item.fieldId,item.formField.extInfo.limitNum)" style="flex: 0.75;display:flex;align-items: center;">
154
- <el-upload
155
- class="upload-demo"
156
- ref="upload"
157
- list-type="picture-card"
158
- accept="image/*"
159
- name="file"
160
- action="/open/media/file/upload"
161
- :multiple="false"
162
- :file-list="fileListList[item.fieldId]"
163
- :limit=item.formField.extInfo.limitNum?Number(item.formField.extInfo.limitNum):1
164
- :before-upload="beforeAvatarUpload"
165
- :on-exceed="exceedUpload"
166
- :on-remove="handleRemove"
167
- :http-request="aliyunOssRequest"
168
- :on-change="handleEditChange"
169
- :on-success="successUpload"
170
- >
171
- <i class="el-icon-plus"></i>
172
- </el-upload>
173
- </div>
174
- </div>
175
- </div>
176
-
177
- <!-- <div v-if="item.formField.type==='DATE_PICKER'&& item.display===true" style="border-bottom: 1px solid #ebebeb">
178
-
179
- <div style="display: flex;padding: 4px 0">
180
- <div style="flex: 0.25;display:flex;align-items: center;height: 40px;text-align: left"><span style="color: red" v-if="item.required===true">*</span>{{item.formField.name}}</div>
181
- <div style="flex: 0.75;display:flex;align-items: center;">
182
- <el-date-picker
183
- v-model=item.value
184
- type="date"
185
- :placeholder="item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
186
- style="width: 100%"
187
- >
188
- </el-date-picker>
189
- </div>
190
- </div>
191
-
192
- </div>
193
- <div v-if="item.formField.type==='TIME_PICKER' && item.display===true" style="border-bottom: 1px solid #ebebeb">
194
- <div style="display: flex;padding: 4px 0">
195
- <div style="flex: 0.25;display:flex;align-items: center;height: 40px;text-align: left"><span style="color: red;" v-if="item.required===true">*</span>{{item.formField.name}}</div>
196
- <div style="flex: 0.75;display:flex;align-items: center;" v-if="!item.formField.extInfo.mold">
197
- <el-time-picker
198
- v-model=item.value
199
- :placeholder="item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
200
- style="width: 100%"
201
- >
202
- </el-time-picker>
203
- </div>
204
- <div style="flex: 0.75;display:flex;align-items: center;" v-if="item.formField.extInfo.mold==='DATA'">
205
- <el-date-picker
206
- v-model=item.value
207
- type="date"
208
- :placeholder="item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
209
- >
210
- </el-date-picker>
211
- </div>
212
- <div style="flex: 0.75;display:flex;align-items: center;" v-if="item.formField.extInfo.mold==='DATA_TIME'">
213
- <el-date-picker
214
- v-model=item.value
215
- :placeholder="item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期时间'"
216
- clearable
217
- type="datetime"
218
- >
219
- </el-date-picker>
220
- </div>
221
- </div>
222
- </div>
223
- <div v-if="item.formField.type==='RADIO' && item.display===true" style="border-bottom: 1px solid #ebebeb">
224
- <div style="display: flex;padding: 4px 0">
225
- <div style="flex: 0.25 ;display:flex;align-items: center;height: 40px;text-align: left"><span style="color: red" v-if="item.required===true">*</span>{{item.formField.name}}</div>
226
- <div style="flex: 0.75;display:flex;align-items: center" v-if="item.formField.extInfo.option">
227
- <el-radio-group v-model=item.value style="text-align:left">
228
- <el-radio v-for="(items,index) in item.formField.extInfo.option" :label=items.value :key="index">{{items.label}}</el-radio>
229
- </el-radio-group>
230
- </div>
231
- <div style="flex: 0.75;display:flex;align-items: center" v-if="item.formField.extInfo.options">
232
- <el-radio-group v-model=item.value style="text-align:left">
233
- <el-radio v-for="(items,index) in item.formField.extInfo.options" :label=items.value :key="index">{{items.label}}</el-radio>
234
- </el-radio-group>
235
- </div>
236
- </div>
237
-
238
-
239
- </div>
240
- <div v-if="item.formField.type==='CHECKBOX' && item.display===true" style="border-bottom: 1px solid #ebebeb">
241
- <div style="display: flex;padding: 4px 0">
242
- <div style="flex: 0.25 ;display:flex;align-items: center;height: 40px;text-align: left"><span style="color: red" v-if="item.required===true">*</span>{{item.formField.name}}</div>
243
- <div style="flex: 0.75;display:flex;align-items: center" v-if="item.formField.extInfo.option">
244
- <el-checkbox-group v-model=item.value style="text-align:left">
245
- <el-checkbox
246
- v-for="(items,index) in item.formField.extInfo.option"
247
- :label=items.value
248
- :key="index"
249
- >{{items.label}}</el-checkbox>
250
- </el-checkbox-group>
251
- </div>
252
- <div style="flex: 0.75;display:flex;align-items: center" v-if="item.formField.extInfo.options">
253
- <el-checkbox-group v-model=item.value style="text-align:left">
254
- <el-checkbox
255
- v-for="(items,index) in item.formField.extInfo.options"
256
- :label=items.value
257
- :key="index"
258
- >{{items.label}}</el-checkbox>
259
- </el-checkbox-group>
260
- </div>
261
- </div>
262
-
263
- </div>
264
- <div v-if="item.formField.type==='SELECT' && item.display===true" style="border-bottom: 1px solid #ebebeb">
265
- <div style="display: flex;padding:4px 0">
266
- <div style="flex: 0.25 ;display:flex;align-items: center;height: 40px;text-align: left"><span style="color: red" v-if="item.required===true">*</span>{{item.formField.name}}</div>
267
- <div style="flex: 0.75;display:flex;align-items: center;" v-if="item.formField.extInfo.option">
268
- <el-select
269
- v-model=item.value
270
- :placeholder="item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
271
- style="width: 100%"
272
- filterable
273
- >
274
- <el-option
275
- v-for="(items,index) in item.formField.extInfo.option"
276
- :key="index"
277
- :label="items.label"
278
- :value="items.value">
279
- </el-option>
280
- </el-select>
281
- </div>
282
- <div style="flex: 0.75;display:flex;align-items: center;" v-if="item.formField.extInfo.options">
283
- <el-select
284
- v-model=item.value
285
- :placeholder="item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
286
- style="width: 100%"
287
- filterable
288
- >
289
- <el-option
290
- v-for="(items,index) in item.formField.extInfo.options"
291
- :key="index"
292
- :label="items.label"
293
- :value="items.value">
294
- </el-option>
295
- </el-select>
296
- </div>
297
- </div>
298
-
299
- </div>
300
- <div v-if="item.formField.type==='CASCADER' && item.display===true" style="border-bottom: 1px solid #ebebeb">
301
- <div style="display: flex;padding: 4px 0">
302
- <div style="flex: 0.25 ;display:flex;align-items: center;height: 40px;text-align: left"><span style="color: red" v-if="item.required===true">*</span>{{item.formField.name}}</div>
303
- <div style="flex: 0.75;display:flex;align-items: center;" v-if="item.formField.extInfo.cascade">
304
- <el-cascader
305
- v-model=item.value
306
- :options=item.formField.extInfo.cascade
307
- style="width: 100%;"
308
- :placeholder="item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
309
- ></el-cascader>
310
- </div>
311
- <div style="flex: 0.75;display:flex;align-items: center;" v-if="item.formField.extInfo.cascadeDown">
312
- <el-cascader
313
- v-model=item.value
314
- :options=item.formField.extInfo.cascadeDown[0].options
315
- style="width: 100%;"
316
- :placeholder="item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
317
- ></el-cascader>
318
- </div>
319
- </div>
320
- </div>
321
- <div v-if="item.formField.type==='FILE' && item.display===true" style="border-bottom: 1px solid #ebebeb">
322
- <div style="display: flex;padding: 4px 0">
323
- <div style="flex: 0.25 ;display:flex;align-items: center;height: 40px;text-align: left"><span style="color: red" v-if="item.required===true">*</span>{{item.formField.name}}</div>
324
- <div @click="checkUpload(item.fieldId,item.formField.extInfo.limitNum)" @mouseover="checkUpload(item.fieldId,item.formField.extInfo.limitNum)" style="flex: 0.75;display:flex;align-items: center;">
325
- <el-upload
326
- class="upload-demo"
327
- ref="upload"
328
- list-type="picture-card"
329
- accept="image/*"
330
- name="file"
331
- action="/open/media/file/upload"
332
- :multiple="false"
333
- :file-list="fileListList[item.fieldId]"
334
- :limit=item.formField.extInfo.limitNum?Number(item.formField.extInfo.limitNum):1
335
- :before-upload="beforeAvatarUpload"
336
- :on-exceed="exceedUpload"
337
- :on-remove="handleRemove"
338
- :http-request="aliyunOssRequest"
339
- :on-change="handleEditChange"
340
- :on-success="successUpload"
341
- >
342
- <i class="el-icon-plus"></i>
343
- </el-upload>
344
- </div>
345
-
346
- </div>
347
- </div>-->
348
- </div>
349
- <div style="padding: 10px 0;text-align: center">
350
- <el-button style="border-color: #4C61E1;color: white;background-color: #4C61E1" round class="submitClass" size="small" @click="submitClick" :disabled="disableds">{{submitValue}}</el-button>
351
- </div>
352
-
353
- </div>
354
- <div class="mobileFormClass" v-if="isPhone===true" style="padding: 10px 0;" :class="{notClick:disableds === true}">
355
- <div v-for="(item,index) in formShow.form.formFieldRelation" :key="item.formField.id" >
356
- <div v-if="item.formField.type==='INPUT'&&item.display === true&&item.fieldId!=='workorder_name'" style="border-bottom: 1px solid #ebebeb">
357
- <van-field v-model=item.value
358
- :label=item.formField.name
359
- :required="item.required===true"
360
- :disabled="disableds"
361
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
362
- :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
363
- />
364
- </div>
365
- <div v-if="item.formField.type==='EXPLANATION'" style="border-bottom: 1px solid #ebebeb">
366
- <div style="display: flex;padding: 4px 0">
367
- <p style="color: #4C61E1;font-size: 14px;margin: 16px 4px">
368
- <span class="el-icon-info"></span>
369
- {{item.formField.extInfo.descriptionText}}
370
- </p>
371
- </div>
372
- </div>
373
- <div v-if="item.formField.type==='EXPLAIN'" style="border-bottom: 1px solid #ebebeb">
374
- <div style="display: flex;padding: 4px 0">
375
- <p style="color: #4C61E1;font-size: 14px;margin: 16px 4px">
376
- <span class="el-icon-info"></span>
377
- <span v-if="item.formField.extInfo.url" class="explain-url"><a :href="item.formField.extInfo.url" target="_blank">{{item.value}}</a></span>
378
- <span v-else>{{item.value}}</span>
379
- </p>
380
- </div>
381
- </div>
382
- <div v-if="item.formField.type==='TEXTAREA'&&item.display === true" style="border-bottom: 1px solid #ebebeb">
383
- <van-field v-model=item.value
384
- :label=item.formField.name
385
- :required="item.required===true"
386
- type="textarea"
387
- :disabled="disableds"
388
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
389
- :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
390
- v-if="item.fieldId!=='workorder_description'"
391
- />
392
- <van-field v-model=item.value
393
- label='问题描述'
394
- :required="item.required===true"
395
- type="textarea"
396
- :disabled="disableds"
397
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
398
- :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
399
- v-if="item.fieldId==='workorder_description'"
400
- />
401
- </div>
402
- <div v-if="item.formField.type==='DATE_PICKER'&&item.display === true" style="display: flex;border-bottom: 1px solid #ebebeb">
403
-
404
- <van-field
405
- readonly
406
- clickable
407
- name="calendar"
408
- :value=dateValue[item.fieldId]
409
- :label=item.formField.name
410
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
411
- :required="item.required===true"
412
- @click="dateClick(item.fieldId)"
413
- :disabled="disableds"
414
- />
415
-
416
- <van-calendar
417
- v-model="showCalendar"
418
- @confirm="onConfirmCalendar($event,dateId)"
419
- />
420
- <!-- <div style="display: flex;justify-content: space-between">-->
421
-
422
- <!-- <van-cell :title=item.name :value=item.value @click="dateClick(item.id)"/>-->
423
- <!-- <van-calendar v-model="showCalendar" @confirm="onConfirmCalendar($event,dateId)" />-->
424
- <!-- <i class="van-icon van-icon-arrow van-cell__right-icon" style="line-height: 44px"></i>-->
425
- <!-- </div>-->
426
-
427
- </div>
428
- <div v-if="item.formField.type==='TIME_PICKER'&&item.display === true&&(!item.formField.extInfo.mold||item.formField.extInfo.mold==='DATA_TIME')" style="display: flex;border-bottom: 1px solid #ebebeb">
429
- <van-field
430
- readonly
431
- clickable
432
- name="datetimePicker"
433
- :required="item.required===true"
434
- :value=timeValue[item.fieldId]
435
- :label=item.formField.name
436
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
437
- @click="timeClick(item.fieldId,item)"
438
- :disabled="disableds"
439
-
440
- />
441
- <van-popup v-model="showTimePicker" position="bottom">
442
- <van-datetime-picker
443
- v-model="currentDate"
444
- type="datetime"
445
- @confirm="onConfirm($event,timeId,item)"
446
- @cancel="showTimePicker = false"
447
- :min-date="minDate"
448
- :formatter="formatter"
449
- :max-date="maxDate"
450
- />
451
- </van-popup>
452
- </div>
453
- <div v-if="item.formField.type==='TIME_PICKER'&&item.display === true&&item.formField.extInfo.mold==='DATA'" style="display: flex;border-bottom: 1px solid #ebebeb">
454
- <van-field
455
- readonly
456
- clickable
457
- name="datetimePicker"
458
- :required="item.required===true"
459
- :value=timeValue[item.fieldId]
460
- :label=item.formField.name
461
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
462
- @click="timeClick(item.fieldId,item)"
463
- :disabled="disableds"
464
-
465
- />
466
- <van-calendar v-model="showTimePickerd" :show-confirm="false" @confirm="onConfirm($event,timeId,item)" @cancel="showTimePickerd = false"/>
467
- </div>
468
- <!-- <div v-if="item.formField.type==='DATETIME_RANGE'">
469
- <van-field
470
- readonly
471
- clickable
472
- name="datetimePicker"
473
- :value=dateTimeValue[item.formField.id]
474
- :label=item.formField.name
475
- placeholder="点击选择开始日期时间"
476
- @click="dateTimeClick(item.formField.id)"
477
- />
478
- <van-popup v-model="showDateTimePicker" position="bottom">
479
- <van-datetime-picker
480
- v-model="currentDate"
481
- type="datetime"
482
- title="选择开始日期时间"
483
- @confirm="onConfirmDateTime($event,dateTimeId)"
484
- @cancel="showDateTimePicker = false"
485
- :min-date="minDate"
486
- :formatter="formatter"
487
- />
488
- </van-popup>
489
- <van-field
490
- readonly
491
- clickable
492
- name="datetimePicker"
493
- :value=dateTimeValue1[item.formField.id]
494
- label=" "
495
- placeholder="点击选择结束日期时间"
496
- @click="dateTimeClick1(item.formField.id)"
497
- />
498
- <van-popup v-model="showDateTimePicker1" position="bottom">
499
- <van-datetime-picker
500
- v-model="currentDate"
501
- type="datetime"
502
- title="选择结束日期时间"
503
- @confirm="onConfirmDateTime1($event,dateTimeId)"
504
- @cancel="showDateTimePicker1 = false"
505
- :min-date="minDate"
506
- :formatter="formatter"
507
- />
508
- </van-popup>
509
-
510
- &lt;!&ndash; <van-calendar
511
- v-model="showDateTimePicker"
512
- type="range"
513
- @confirm="onConfirmDateTime($event,dateTimeId)"
514
-
515
- />&ndash;&gt;
516
-
517
-
518
- &lt;!&ndash; <van-datetime-picker
519
- v-model="showDateTimePicker"
520
- type="datetime"
521
- @confirm="onConfirmDateTime($event,dateTimeId)"
522
- :formatter="formatter"
523
- />&ndash;&gt;
524
- </div>-->
525
- <div v-if="item.formField.type==='RADIO'&&item.display === true" style="display: flex;border-bottom: 1px solid #ebebeb">
526
- <van-field name="radio" :label="item.formField.name" :required="item.required===true" :disabled="disableds" v-if="item.formField.extInfo.option">
527
- <template #input style="display: flex;align-items: center">
528
- <van-radio-group v-model=item.value direction="horizontal" :disabled="disableds">
529
- <van-radio v-for="(items,index) in item.formField.extInfo.option" :name=items.value :key="index">{{items.label}}</van-radio>
530
- </van-radio-group>
531
- </template>
532
- </van-field>
533
- <van-field name="radio" :label="item.formField.name" :required="item.required===true" :disabled="disableds" v-if="item.formField.extInfo.options">
534
- <template #input style="display: flex;align-items: center" >
535
- <van-radio-group v-model=item.value direction="horizontal" :disabled="disableds">
536
- <van-radio v-for="(items,index) in item.formField.extInfo.options" :name=items.value :key="index">{{items.label}}</van-radio>
537
- </van-radio-group>
538
- </template>
539
- </van-field>
540
- </div>
541
- <div v-if="item.formField.type==='CHECKBOX'&&item.display === true" style="display: flex;border-bottom: 1px solid #ebebeb" >
542
- <van-field name="checkbox" :label=item.formField.name :required="item.required===true" :disabled="disableds" v-if="item.formField.extInfo.option">
543
- <template #input style="display: flex;align-items: center" >
544
- <van-checkbox-group v-model=item.value ref="checkboxGroup" direction="horizontal" :disabled="disableds">
545
- <van-checkbox
546
- v-for="(items,index) in item.formField.extInfo.option"
547
- shape="square"
548
- :key="index"
549
- :name=items.value>
550
- {{items.label}}
551
- </van-checkbox>
552
- </van-checkbox-group>
553
- </template>
554
- </van-field>
555
- <van-field name="checkbox" :label=item.formField.name :required="item.required===true" :disabled="disableds" v-if="item.formField.extInfo.options">
556
- <template #input style="display: flex;align-items: center" >
557
- <van-checkbox-group v-model=item.value ref="checkboxGroup" direction="horizontal" :disabled="disableds">
558
- <van-checkbox
559
- v-for="(items,index) in item.formField.extInfo.options"
560
- shape="square"
561
- :key="index"
562
- :name=items.value>
563
- {{items.label}}
564
- </van-checkbox>
565
- </van-checkbox-group>
566
- </template>
567
- </van-field>
568
- </div>
569
- <div v-if="item.formField.type==='SELECT'&&item.display === true" style="display: flex;border-bottom: 1px solid #ebebeb">
570
- <van-field
571
- readonly
572
- clickable
573
- name="picker"
574
- :value=selectValues[item.fieldId]
575
- :label=item.formField.name
576
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
577
- @click="selectClick(item.fieldId)"
578
- :required="item.required===true"
579
- :disabled="disableds"
580
- v-if="item.fieldId!=='workorder_clientId'"
581
- />
582
- <van-field
583
- readonly
584
- clickable
585
- name="picker"
586
- :value=selectValues[item.fieldId]
587
- label='报单人'
588
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
589
- @click="selectClick(item.fieldId)"
590
- :required="item.required===true"
591
- :disabled="disableds"
592
- v-if="item.fieldId==='workorder_clientId'"
593
- />
594
- <van-popup v-model="showPicker" position="bottom">
595
- <van-picker
596
- show-toolbar
597
- :columns=selectValue
598
- @confirm="onConfirmSelect($event,selectId)"
599
- @cancel="showPicker = false"
600
- :key="selectKey"
601
-
602
- />
603
- <!-- <van-action-sheet
604
- v-model="showPicker"
605
- :actions="item.formField.extInfo.option"
606
- cancel-text="取消"
607
- @select="onConfirmSelect($event,item.fieldId)"
608
- duration="0.5"
609
- />-->
610
- </van-popup>
611
- <span style="padding: 0 8px 0 0;display: flex;align-items: center"> <i class="van-icon van-icon-arrow van-cell__right-icon"></i></span>
612
-
613
- </div>
614
- <div v-if="item.formField.type==='CASCADER'&&item.display === true" style="display: flex;border-bottom: 1px solid #ebebeb">
615
- <van-field
616
- readonly
617
- clickable
618
- name="area"
619
- :value=cascadeValue[item.fieldId]
620
- :label=item.formField.name
621
- :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
622
- @click="pickerClick(item.fieldId)"
623
- :required="item.required===true"
624
- :disabled="disableds"
625
- />
626
-
627
- <van-popup v-model="showArea" position="bottom">
628
- <van-picker v-if="pageShow"
629
- show-toolbar
630
- :columns="column"
631
- @cancel="onCancel"
632
- @confirm="onConfirms($event,pickerId,index)"
633
- @change="onChange"
634
- :item-height="45"
635
- :key="keyValue"
636
- />
637
- </van-popup>
638
- <span style="padding: 0 8px 0 0;display: flex;align-items: center"> <i class="van-icon van-icon-arrow van-cell__right-icon"></i></span>
639
-
640
- </div>
641
- <div v-if="item.formField.type === 'FILE'&&item.display === true" style="display: flex;border-bottom: 1px solid #ebebeb;padding: 10px 8px">
642
- <div @click="checkUpload(item.fieldId,item.formField.extInfo.limitNum)">
643
- <div class="fileName"><span style="color: red" v-if="item.required===true">*</span>{{item.formField.name}}</div>
644
- <van-uploader
645
- v-model="fileListList[item.fieldId]"
646
- :before-read="beforeRead"
647
- :max-count='item.formField.extInfo.limitNum!==undefined?item.formField.extInfo.limitNum:1'
648
- :after-read="afterRead"
649
- accept="image/*"
650
- :multiple=false
651
- >
652
- <div class="vant-upload--picture-card">
653
- <i class="el-icon-plus"></i>
654
- </div>
655
-
656
- </van-uploader>
657
- </div>
658
- </div>
659
- </div>
660
- <div style="padding: 14px 16px 0 16px;text-align: center">
661
- <van-button round type="info" class="submitClass" @click="submitClick" :disabled="disableds">{{submitValue}}</van-button>
662
- </div>
663
- <van-popup v-model="fileUpload" :close-on-click-overlay="false">
664
- <div style="background-color: black;height: 100px;width: 100px;display: flex;justify-content: center;align-items: center" >
665
- <van-loading type="spinner"/>
666
- </div>
667
- </van-popup>
668
- </div>
669
- </div>
670
- <el-dialog :visible.sync="dialogVisible">
671
- <img width="100%" :src="dialogImageUrl" alt="">
672
- </el-dialog>
673
-
674
- </div>
675
- </template>
676
-
677
- <script>
678
- let that
679
- import {multipartUpload,ossFileUrl} from "./utils/AliyunIssUtil";
680
- export default {
681
- name: "formTemplate",
682
- data() {
683
- return {
684
- isPhone: false,
685
- isCompany: false,
686
- checkboxGroup: [],
687
- currentDate: new Date(),
688
- timeValue: [],
689
- dateValue: [],
690
- showPicker: false,
691
- showTimePicker: false,
692
- showTimePickerd:false,
693
- showCalendar: false,
694
- radio: [],
695
- selectValue: [],
696
- pickerValue: [],
697
- showArea: false,
698
- dateTimeValue: [],
699
- dateTimeValue1: [],
700
- showDateTimePicker: false,
701
- showDateTimePicker1: false,
702
- pickerId: 0,
703
- dateId: 0,
704
- timeId: 0,
705
- selectId: 0,
706
- dateTimeId: 0,
707
- column: [
708
- {
709
- values: '', // 设置的页面初始值
710
- className: "column1"
711
- },
712
- {
713
- values: '',
714
- className: "column2",
715
- },
716
- {
717
- values: '',
718
- className: "column3",
719
- }
720
- ],
721
- pageShow: false, //省市区三级联动是否显示(因为是接口返回的数据,等三级数据渲染完毕之后,在显示三级联动)
722
- cityDates: '', //安联当前选中市的所有区所有数据
723
- data: [],//接口返回所有级联数据
724
- dateTimeRange: '',
725
- selectValues: [],
726
- cascadeValue: [],
727
- minDate: new Date(2020, 0, 1),
728
- maxDate: new Date(2025, 11, 31),
729
- disableds: false,
730
- submitValue: '提交',
731
- clickPicker: '',
732
- columns: [],
733
- copyForm: [],
734
- cascaderId:0,
735
- formShow:[],
736
-
737
- uploadAvatarParams: {
738
- token: "8c98087dfd2d48f856d8c95c09115def",
739
- },
740
- fileListList:[],
741
- keyValue:'',
742
- selectKey:'shuijiao',
743
- filedId:'',
744
- disabled:false,
745
- dialogVisible:false,
746
- dialogImageUrl:'',
747
- fileUpload:false,
748
- videoFlag:false,
749
- videoUploadPercent:false,
750
- fileType:['PICTURE','VIDEO','AUDIO'],
751
- loading:'',
752
- ossConfig: {
753
- region: "oss-cn-zhangjiakou",
754
- //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
755
- accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
756
- accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
757
- // stsToken: '<Your securityToken(STS)>',
758
- bucket: "guoranopen-zjk",
759
- },
760
- hideUploadEdit:false,
761
- limitNum:1
762
-
763
- }
764
- },
765
- props: {
766
- formList: {
767
- type: Object,
768
- default() {
769
- return {}
770
- }
771
- },
772
- type:String,
773
- disable:Boolean,
774
- submit:Boolean,
775
- usePropStyleType:{
776
- type:Boolean,
777
- default() {
778
- return false;
779
- }
780
- },
781
- propIsPhone: {
782
- type:Boolean,
783
- default() {
784
- return false;
785
- }
786
- },
787
- propIsCompany: {
788
- type:Boolean,
789
- default() {
790
- return false;
791
- }
792
- },
793
- uploadUrl: {
794
- type:String,
795
- default(){
796
- return '/open/media/file/upload'
797
- }
798
- }
799
- },
800
- computed:{
801
- acceptType:function () {
802
- return '.jpg,.jpeg,.png,.gif,.JPG,.JPEG,.PBG,.GIF'
803
- }
804
- },
805
- mounted() {
806
- console.log(this.formList)
807
- console.log(this.disable)
808
- this.isMobile()
809
- },
810
- beforeCreate() {
811
- // 等待dom渲染完毕之后,再去显示 三级联动。
812
- that=this
813
- this.$nextTick(function () {
814
- this.pageShow = true;
815
- })
816
- },
817
- created() {
818
-
819
- if(this.disable===true)
820
- {
821
- this.disableds=true
822
- }
823
- else
824
- {
825
- this.disableds=false
826
- }
827
- if(this.submit===true)
828
- {
829
- this.submitValue='已提交'
830
- }
831
- else
832
- {
833
- this.submitValue='提交'
834
- }
835
- },
836
- beforeMount() {
837
- that.defaultClick()
838
- },
839
- methods: {
840
- beforeRead(file){
841
- console.log('file',file)
842
- console.log('fileType',!Array.isArray(file))
843
- if (!Array.isArray(file)){
844
- const isLte2M = file.size / 1024 / 1024 <= 8;
845
- console.log(file.type.indexOf('image')!==-1)
846
- const isSupportedFormat =file.type.indexOf('image')!==-1
847
- if (!isSupportedFormat){
848
- this.$message.error("只能上传图片格式");
849
- return false
850
- }
851
- if (!isLte2M&&isSupportedFormat) {
852
- this.$message.error("上传图片大小不能超过 8MB!");
853
- return false
854
- }
855
- return true
856
- }
857
- else{
858
- let length = 0
859
- if (this.fileListList[this.filedId]){
860
- length = this.fileListList[this.filedId].length
861
- }
862
- if (file.length<=this.limitNum-length){
863
- for (let i=0;i<file.length;i++){
864
- const isLte2M = file[i].size / 1024 / 1024 <= 8;
865
- console.log(file[i].type.indexOf('image')!==-1)
866
- const isSupportedFormat =file[i].type.indexOf('image')!==-1
867
- if (!isSupportedFormat){
868
- this.$message.error("只能上传图片格式");
869
- return false
870
- }
871
- if (!isLte2M&&isSupportedFormat) {
872
- this.$message.error("上传图片大小不能超过 8MB!");
873
- return false
874
- }
875
- return true
876
- }
877
- }
878
- else {
879
- let num = 1
880
- if (this.limitNum){
881
- num = this.limitNum
882
- }
883
- let messageText = '仅支持上传'+num+'张图片'
884
- this.$message.error(messageText);
885
- return false
886
- }
887
-
888
- }
889
-
890
- },
891
- //文件上传至服务器
892
- afterRead(file){
893
- this.fileUpload=true
894
- console.log(file)
895
- console.log(!Array.isArray(file))
896
- if (!Array.isArray(file)){
897
- this.uploadImgFun(file.content,file.file.name,file,file.file);
898
- }
899
- else {
900
- console.log(file.length)
901
- let num = 1
902
- if (this.limitNum){
903
- num = this.limitNum
904
- }
905
- if (file.length >num){
906
- this.$message.warning('仅支持上传'+num+'张图片')
907
- return false
908
- }
909
- else {
910
- for (let i = 0; i < file.length; i++){
911
- this.uploadImgFun(file[i].content,file[i].file.name,file[i],file[i].file);
912
- }
913
- }
914
- }
915
-
916
- console.log(file)
917
- console.log(this.fileListList[this.filedId])
918
- },
919
- uploadImgFun(content,name,fileCon,file){
920
- console.log(fileCon)
921
- let imageData = {
922
- urls:[]
923
- }
924
- let imageInfo = {
925
- name:"",
926
- status:'',
927
- url:''
928
- }
929
- let res = multipartUpload(
930
- this.ossConfig,
931
- file,
932
- null,
933
- imageInfo
934
- );
935
- res.then((res) => {
936
- console.log("upload result:", res);
937
- // let filePath = res.name;
938
- imageData.urls.push({
939
- name:res.name,
940
- url:ossFileUrl(this.ossConfig, res.name),
941
- status:'success'
942
- })
943
- imageInfo.url = ossFileUrl(this.ossConfig, res.name)
944
- imageInfo.status='success'
945
- imageInfo.name=res.name
946
- console.log(this.fileListList[this.filedId])
947
- console.log(imageData)
948
- for (let j=0;j<this.fileListList[this.filedId].length;j++){
949
- if (this.fileListList[this.filedId][j].content&&this.fileListList[this.filedId][j].content===content){
950
- this.fileListList[this.filedId][j].name=res.name
951
- this.fileListList[this.filedId][j].status='success'
952
- this.fileListList[this.filedId][j].url=imageInfo.url
953
- delete this.fileListList[this.filedId][j].content
954
- }
955
- }
956
- this.fileUpload=false
957
- }).catch((err) => {
958
- console.log("upload err", err);
959
- });
960
-
961
- },
962
- dataURLtoFileFun (dataurl, filename) {
963
- // 将base64转换为文件,dataurl为base64字符串,filename为文件名(必须带后缀名,如.jpg,.png)
964
- let arr = dataurl.split(",");
965
- let mime = arr[0].match(/:(.*?);/)[1];
966
- let bstr = atob(arr[1]);
967
- let n = bstr.length;
968
- let u8arr = new Uint8Array(n);
969
- while (n--) {
970
- u8arr[n] = bstr.charCodeAt(n);
971
- }
972
- return new File([u8arr], filename, { type: mime });
973
- },
974
- //初始化默认值
975
- defaultClick() {
976
- for (let i = 0; i < this.formList.form.formFieldRelation.length; i++)
977
- {
978
- if(this.formList.form.formFieldRelation[i].formField.type ==='SELECT'||this.formList.form.formFieldRelation[i].formField.type ==='CHECKBOX' ||this.formList.form.formFieldRelation[i].formField.type==='RADIO')
979
- {
980
- if(!this.formList.form.formFieldRelation[i].formField.extInfo.option)
981
- {
982
- if(this.formList.form.formFieldRelation[i].formField.extInfo.exinfo)
983
- {
984
- for (let j=0;j<this.formList.form.formFieldRelation[i].formField.extInfo.exinfo.length;j++)
985
- {
986
- this.$set(this.formList.form.formFieldRelation[i].formField.extInfo.exinfo[j],'label',this.formList.form.formFieldRelation[i].formField.extInfo.exinfo[j].value)
987
- }
988
- this.$set(this.formList.form.formFieldRelation[i].formField.extInfo,'option',this.formList.form.formFieldRelation[i].formField.extInfo.exinfo)
989
- }
990
- if (this.formList.form.formFieldRelation[i].formField.extInfo.option){
991
- if (this.formList.form.formFieldRelation[i].formField.type === 'RADIO') {
992
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
993
- if(!this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value)
994
- {
995
- this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value=this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
996
- }
997
- }
998
- if(!this.formList.form.formFieldRelation[i].value)
999
- {
1000
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
1001
- if (this.formList.form.formFieldRelation[i].formField.extInfo.option[j]._default === 'true') {
1002
- this.formList.form.formFieldRelation[i].value = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value
1003
- }
1004
- }
1005
- }
1006
- }
1007
- if (this.formList.form.formFieldRelation[i].formField.type === 'CHECKBOX') {
1008
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
1009
- if (!this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value) {
1010
- this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
1011
- }
1012
- }
1013
-
1014
- if (!this.formList.form.formFieldRelation[i].value||this.formList.form.formFieldRelation[i].value.length === 0)
1015
- {
1016
- this.formList.form.formFieldRelation[i].value=[]
1017
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
1018
- if (this.formList.form.formFieldRelation[i].formField.extInfo.option[j]._default === 'true') {
1019
- this.formList.form.formFieldRelation[i].value[0] = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value
1020
- }
1021
- }
1022
- }
1023
- }
1024
- }
1025
-
1026
- }
1027
- else {
1028
- if (this.formList.form.formFieldRelation[i].formField.extInfo.options){
1029
- if (this.formList.form.formFieldRelation[i].formField.type === 'RADIO') {
1030
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
1031
- if(!this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value)
1032
- {
1033
- this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value=this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
1034
- }
1035
- }
1036
- if(!this.formList.form.formFieldRelation[i].value)
1037
- {
1038
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
1039
- if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j]._default === 'true') {
1040
- this.formList.form.formFieldRelation[i].value = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value
1041
- }
1042
- }
1043
- }
1044
- }
1045
- if (this.formList.form.formFieldRelation[i].formField.type === 'CHECKBOX') {
1046
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
1047
- if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value === '') {
1048
- this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
1049
- }
1050
- }
1051
-
1052
- if (this.formList.form.formFieldRelation[i].value === null||this.formList.form.formFieldRelation[i].value.length === 0)
1053
- {
1054
- this.formList.form.formFieldRelation[i].value=[]
1055
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
1056
- if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j]._default === 'true') {
1057
- this.formList.form.formFieldRelation[i].value[0] = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value
1058
- }
1059
- }
1060
- }
1061
- }
1062
- }
1063
- }
1064
-
1065
- }
1066
- if (this.formList.form.formFieldRelation[i].formField.type ==='FILE'){
1067
- if (this.formList.form.formFieldRelation[i].value!==undefined){
1068
- if (this.formList.form.formFieldRelation[i].value===null||this.formList.form.formFieldRelation[i].value===''){
1069
- this.formList.form.formFieldRelation[i].value=[]
1070
- }
1071
- else {
1072
- let valueList=[]
1073
- let bool=false
1074
- if(this.formList.form.formFieldRelation[i].value.length > 0) {
1075
- for (let file=0;file<this.formList.form.formFieldRelation[i].value.length;file++) {
1076
- let type = typeof (this.formList.form.formFieldRelation[i].value[file])
1077
- if (type === "string") {
1078
- bool = true
1079
- valueList[file] = {}
1080
- valueList[file].url = this.formList.form.formFieldRelation[i].value[file]
1081
- }
1082
- if (type === 'object'&&JSON.stringify(this.formList.form.formFieldRelation[i].value[file])!=='{}') {
1083
- this.fileListList[this.formList.form.formFieldRelation[i].fieldId]=this.formList.form.formFieldRelation[i].value
1084
- }
1085
- else {
1086
- this.fileListList[this.formList.form.formFieldRelation[i].fieldId]=[]
1087
- }
1088
- }
1089
- if (bool){
1090
- this.fileListList[this.formList.form.formFieldRelation[i].fieldId]=valueList
1091
- }
1092
-
1093
- console.log(bool)
1094
- console.log(this.fileListList[this.formList.form.formFieldRelation[i].fieldId])
1095
- }
1096
- }
1097
- }
1098
-
1099
-
1100
-
1101
- }
1102
-
1103
- }
1104
- console.log(this.formList)
1105
- let test = []
1106
- for (let i = 0; i < this.formList.form.formFieldRelation.length; i++) {
1107
- if (this.formList.form.formFieldRelation[i].formField.type === 'CASCADER') {
1108
- test.push(this.formList.form.formFieldRelation[i])
1109
- let cascader=''
1110
- console.log(this.formList.form.formFieldRelation[i])
1111
- if(this.formList.form.formFieldRelation[i].value)
1112
- {
1113
- if(this.formList.form.formFieldRelation[i].value.length > 0)
1114
- {
1115
- for (let j = 0; j < this.formList.form.formFieldRelation[i].value.length; j++) {
1116
- if (this.formList.form.formFieldRelation[i].value[j]) {
1117
- cascader += this.formList.form.formFieldRelation[i].value[j] + '/'
1118
- }
1119
- }
1120
- cascader = cascader.substr(0, cascader.length - 1)
1121
-
1122
- }
1123
- this.cascadeValue[this.formList.form.formFieldRelation[i].fieldId]=cascader
1124
- }
1125
- else
1126
- {
1127
- this.formList.form.formFieldRelation[i].value=[]
1128
- }
1129
- }
1130
- if (this.formList.form.formFieldRelation[i].formField.type === 'DATE_PICKER')
1131
- {
1132
- if(this.formList.form.formFieldRelation[i].value!==null && this.formList.form.formFieldRelation[i].value!=='' )
1133
- {
1134
-
1135
- this.dateValue[this.formList.form.formFieldRelation[i].fieldId]=this.formatDate(this.formList.form.formFieldRelation[i].value)
1136
- }
1137
- }
1138
- if (this.formList.form.formFieldRelation[i].formField.type === 'TIME_PICKER')
1139
- {
1140
- if(this.formList.form.formFieldRelation[i].value!==''&& this.formList.form.formFieldRelation[i].value!==null)
1141
- {
1142
- const dateTime = new Date(this.formList.form.formFieldRelation[i].value)
1143
- this.timeValue[this.formList.form.formFieldRelation[i].fieldId]=this.addZero(dateTime.getHours()) + ':' + this.addZero(dateTime.getMinutes())
1144
-
1145
- }
1146
- }
1147
- if (this.formList.form.formFieldRelation[i].formField.type === 'SELECT') {
1148
- if ( this.formList.form.formFieldRelation[i].formField.extInfo.option){
1149
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
1150
- if (this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value === '') {
1151
- this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
1152
- }
1153
- }
1154
- if(this.formList.form.formFieldRelation[i].value)
1155
- {
1156
- console.log(this.formList.form.formFieldRelation[i].formField.extInfo.option)
1157
- for (let j=0;j<this.formList.form.formFieldRelation[i].formField.extInfo.option.length;j++)
1158
- {
1159
- if (this.formList.form.formFieldRelation[i].value === this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value)
1160
- {
1161
- this.selectValues[this.formList.form.formFieldRelation[i].fieldId] =this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
1162
- }
1163
- }
1164
- /*this.selectValues[this.formList.form.formFieldRelation[i].fieldId] = this.formList.form.formFieldRelation[i].value*/
1165
-
1166
- }
1167
- else
1168
- {
1169
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
1170
- if (this.formList.form.formFieldRelation[i].formField.extInfo.option[j]._default === 'true') {
1171
- this.selectValues[this.formList.form.formFieldRelation[i].fieldId] = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
1172
- this.formList.form.formFieldRelation[i].value=this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value
1173
- }
1174
- }
1175
- }
1176
- }
1177
- else {
1178
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
1179
- if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value === '') {
1180
- this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
1181
- }
1182
- }
1183
- if(this.formList.form.formFieldRelation[i].value)
1184
- {
1185
- for (let j=0;j<this.formList.form.formFieldRelation[i].formField.extInfo.options.length;j++)
1186
- {
1187
- if (this.formList.form.formFieldRelation[i].value === this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value)
1188
- {
1189
- this.selectValues[this.formList.form.formFieldRelation[i].fieldId] =this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
1190
- }
1191
- }
1192
- /*this.selectValues[this.formList.form.formFieldRelation[i].fieldId] = this.formList.form.formFieldRelation[i].value*/
1193
-
1194
- }
1195
- else
1196
- {
1197
- for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
1198
- if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j]._default === 'true') {
1199
- this.selectValues[this.formList.form.formFieldRelation[i].fieldId] = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
1200
- this.formList.form.formFieldRelation[i].value=this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value
1201
- }
1202
- }
1203
- }
1204
- }
1205
-
1206
- }
1207
- }
1208
- this.formShow=this.formList
1209
- console.log(this.formList.form.formFieldRelation)
1210
- },
1211
- addZero(i) {
1212
- if (i < 10) {
1213
- i = "0" + i;
1214
- }
1215
- return i;
1216
- },
1217
- formatter(type, value) {
1218
- // 格式化选择器日期
1219
- if (type === "year") {
1220
- return `${value}年`;
1221
- } else if (type === "month") {
1222
- return `${value}月`;
1223
- } else if (type === "day") {
1224
- return `${value}日`;
1225
- } else if (type === "hour") {
1226
- return `${value}时`;
1227
- } else if (type === "minute") {
1228
- return `${value}分`;
1229
- }
1230
- return value;
1231
- },
1232
-
1233
- isMobile() {
1234
- if (this.usePropStyleType === false){
1235
- let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
1236
- if (flag) {
1237
- this.isPhone=true
1238
- }
1239
- else {
1240
- this.isCompany=true
1241
- }
1242
- }else {
1243
- this.isPhone=this.propIsPhone;
1244
- this.isCompany=this.propIsCompany;
1245
- }
1246
- },
1247
- //时间的选择器
1248
- onConfirm(value, id,item) {
1249
- for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1250
- if (this.formShow.form.formFieldRelation[i].fieldId=== id) {
1251
- this.formShow.form.formFieldRelation[i].value = value
1252
- if (!item.formField.extInfo.mold||item.formField.extInfo.mold==='DATA_TIME'){
1253
- this.timeValue[id] =this.formatDate(value) +" "+ this.addZero(value.getHours()) + ':' + this.addZero(value.getMinutes())
1254
- this.showTimePicker = false;
1255
- }
1256
- else {
1257
- this.timeValue[id] =this.formatDate(value)
1258
- this.showTimePickerd = false;
1259
- }
1260
- break
1261
- }
1262
- }
1263
- },
1264
- //转换日期的函数
1265
- formatDate(date) {
1266
- const dateTime = new Date(date)
1267
- return `${dateTime.getFullYear()}-${dateTime.getMonth() + 1}-${dateTime.getDate()}`;
1268
- },
1269
- //日期的选择器
1270
- onConfirmCalendar(date, id) {
1271
- for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1272
- if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1273
- this.dateValue[id] = this.formatDate(date)
1274
- this.formShow.form.formFieldRelation[i].value = date
1275
- this.showCalendar = false;
1276
- break
1277
- }
1278
- }
1279
- },
1280
- //下拉的选择器
1281
- onConfirmSelect(value, id) {
1282
- console.log(value)
1283
- for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1284
- if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1285
- this.selectValues[this.formShow.form.formFieldRelation[i].fieldId] = value
1286
- if (this.formShow.form.formFieldRelation[i].formField.extInfo.option){
1287
- for (let j = 0; j < this.formShow.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
1288
- if(value ===this.formShow.form.formFieldRelation[i].formField.extInfo.option[j].label)
1289
- {
1290
- this.formShow.form.formFieldRelation[i].value = this.formShow.form.formFieldRelation[i].formField.extInfo.option[j].value
1291
- }
1292
- }
1293
- }
1294
- else {
1295
- for (let j = 0; j < this.formShow.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
1296
- if(value ===this.formShow.form.formFieldRelation[i].formField.extInfo.options[j].label)
1297
- {
1298
- this.formShow.form.formFieldRelation[i].value = this.formShow.form.formFieldRelation[i].formField.extInfo.options[j].value
1299
- }
1300
- }
1301
- }
1302
-
1303
- this.showPicker = false;
1304
- break
1305
- }
1306
- }
1307
- },
1308
- //时间日期的选择器
1309
- /* onConfirmDateTime(date,id){
1310
- for (let i=0;i<this.formList.form.formFieldRelation.length;i++)
1311
- {
1312
-
1313
- if(this.formList.form.formFieldRelation[i].formField.id===id)
1314
- {
1315
- this.dateTimeValue[id]=this.addZero(date.getFullYear())+'-'+this.addZero(date.getMonth())+'-'+this.addZero(date.getDate())+' '+this.addZero(date.getHours())+':'+this.addZero(date.getMinutes())
1316
- this.formList.form.formFieldRelation[i].value[0]=date
1317
- this.showDateTimePicker = false;
1318
- break
1319
- }
1320
- }
1321
-
1322
- },
1323
- onConfirmDateTime1(date,id){
1324
- for (let i=0;i<this.formList.form.formFieldRelation.length;i++)
1325
- {
1326
- if(this.formList.form.formFieldRelation[i].formField.id===id)
1327
- {
1328
-
1329
- this.dateTimeValue1[id]=this.addZero(date.getFullYear())+'-'+this.addZero(date.getMonth())+'-'+this.addZero(date.getDate())+' '+this.addZero(date.getHours())+':'+this.addZero(date.getMinutes())
1330
- this.formList.form.formFieldRelation[i].value[1]=date
1331
- this.showDateTimePicker1 = false;
1332
- break
1333
- }
1334
- }
1335
- },*/
1336
- //提交按钮事件
1337
- submitClick() {
1338
-
1339
- for (let i=0;i<this.formShow.form.formFieldRelation.length;i++)
1340
- {
1341
- if(this.formShow.form.formFieldRelation[i].formField.type==='CASCADER')
1342
- {
1343
- let cascader = this.formShow.form.formFieldRelation[i].formField.extInfo.cascade?this.formShow.form.formFieldRelation[i].formField.extInfo.cascade:this.formShow.form.formFieldRelation[i].formField.extInfo.cascadeDown[0].options?this.formShow.form.formFieldRelation[i].formField.extInfo.cascadeDown[0].options:[]
1344
- cascader.forEach(item=>{
1345
- if(item.children!==undefined)
1346
- {
1347
- if(item.children.length===0)
1348
- delete item.children
1349
- else {
1350
- item.children.forEach(items=>{
1351
- if(items.children)
1352
- {
1353
- if(items.children.length===0)
1354
- delete items.children
1355
- }
1356
- })
1357
- }
1358
- }
1359
- })
1360
-
1361
- let test=[]
1362
- console.log(typeof test)
1363
- }
1364
- if (this.fileListList[this.formShow.form.formFieldRelation[i].fieldId]!==undefined){
1365
- let value=[]
1366
-
1367
- this.fileListList[this.formShow.form.formFieldRelation[i].fieldId].forEach(item=>{
1368
- let file={}
1369
- file.name=item.name
1370
- file.url=item.url
1371
- value.push(file)
1372
- })
1373
- console.log(value)
1374
- this.formShow.form.formFieldRelation[i].value=value
1375
- }
1376
-
1377
- if(this.formShow.form.formFieldRelation[i].display===true && this.formShow.form.formFieldRelation[i].required === true&&this.formShow.form.formFieldRelation[i].fieldId!=='workorder_name')
1378
- {
1379
-
1380
- if(!this.formShow.form.formFieldRelation[i].value || (this.formShow.form.formFieldRelation[i].value&&this.formShow.form.formFieldRelation[i].value.length===0))
1381
- {
1382
- this.$message.error('请完善'+ this.formShow.form.formFieldRelation[i].formField.name)
1383
- return
1384
- }
1385
- }
1386
-
1387
- console.log( this.fileListList)
1388
- }
1389
- console.log(this.formShow)
1390
- this.$emit('submitClick',this.formShow)
1391
- this.disableds = true
1392
- this.submitValue = '已提交'
1393
-
1394
-
1395
- },
1396
- //日期的点击事件
1397
- dateClick(id) {
1398
- if(this.disableds === false)
1399
- {
1400
- for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1401
- if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1402
- this.dateId = id
1403
- this.showCalendar = true
1404
- break
1405
- }
1406
- }
1407
- }
1408
-
1409
- },
1410
- //时间的点击事件
1411
- timeClick(id,item) {
1412
- if(this.disableds === false){
1413
- for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1414
- if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1415
- this.timeId = id
1416
- if (!item.formField.extInfo.mold||item.formField.extInfo.mold==='DATA_TIME'){
1417
- this.showTimePicker = true
1418
- }
1419
- else {
1420
- this.showTimePickerd= true
1421
- }
1422
-
1423
- break
1424
- }
1425
-
1426
- }
1427
- }
1428
-
1429
- },
1430
- //下拉的点击事件
1431
- selectClick(id) {
1432
- console.log(id)
1433
- if(this.disableds === false){
1434
- let selectOption
1435
- this.selectValue=[]
1436
- for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1437
- if(this.formShow.form.formFieldRelation[i].formField.type==='SELECT')
1438
- {
1439
- if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1440
- selectOption = this.formShow.form.formFieldRelation[i].formField.extInfo.option?this.formShow.form.formFieldRelation[i].formField.extInfo.option:this.formShow.form.formFieldRelation[i].formField.extInfo.options?this.formShow.form.formFieldRelation[i].formField.extInfo.options:[]
1441
- for (let j = 0; j < selectOption.length; j++) {
1442
- this.selectValue[j] = selectOption[j].label
1443
- }
1444
-
1445
- }
1446
- }
1447
- }
1448
- console.log(this.selectValue)
1449
- this.selectId = id
1450
- this.showPicker = true
1451
- }
1452
-
1453
- },
1454
- //级联的点击的事件
1455
- pickerClick(id) {
1456
- if(this.disableds === false)
1457
- {
1458
- if(this.pickerId!==id)
1459
- {
1460
- for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1461
- if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1462
- console.log(this.formShow.form.formFieldRelation[i].value)
1463
- this.keyValue=''
1464
- if(this.formShow.form.formFieldRelation[i].value.length!==undefined)
1465
- {
1466
- for (let m=0;m<this.formShow.form.formFieldRelation[i].value.length;m++)
1467
- {
1468
- this.keyValue+=this.formShow.form.formFieldRelation[i].value[m]
1469
- }
1470
- }
1471
-
1472
- this.data = this.formShow.form.formFieldRelation[i].formField.extInfo.cascade?this.formShow.form.formFieldRelation[i].formField.extInfo.cascade:this.formShow.form.formFieldRelation[i].formField.extInfo.cascadeDown?this.formShow.form.formFieldRelation[i].formField.extInfo.cascadeDown[0].options:[]
1473
- this.column[0].values = Object.values(this.data).map(function (e) {
1474
- return {text: e.value, code: e.value}
1475
- })
1476
- if (this.data[0].children !== undefined) {
1477
- this.column[1].values = Object.values(this.data[0].children).map(function (e) {
1478
- return {text: e.value, code: e.value}
1479
- })
1480
- if (this.data[0].children[0].children !== undefined) {
1481
- this.column[2].values = Object.values(this.data[0].children[0].children).map(function (e) {
1482
- return {text: e.value, code: e.value}
1483
- })
1484
- }
1485
- else {
1486
- this.$set(this.data[0].children[0], 'children', [])
1487
- this.column[2].values=Object.values(this.data[0].children[0].children).map(function (res) {
1488
- return {text: res.value, code: res.value};
1489
- })
1490
- }
1491
- }
1492
- }
1493
- }
1494
- }
1495
-
1496
- this.pickerId = id
1497
- this.showArea = true
1498
- }
1499
-
1500
-
1501
- },
1502
-
1503
- onChange(picker, values,index) {
1504
- // 这里我有可能渲染的有问题,导致回调每次都修改了当前列,其他值没有修改,当前列??(当前列什么鬼呀,什么垃圾啊???) 解释一下 ↓↓
1505
- // 因为vant的 van-picker 回调只会返回你修改的那一列,比如现在为 [北京,北京,东城区],你修改了省为[天津市,天津市,和平区],但是vant的change回调会得到[天津市,北京,东城区],后面两个在回调中没有修改,不知道我的渲染方法有问题还是什么问题。
1506
- // 所以我在这里判断change事件触发后,如果你修改了省份的话,回调里面省份会改变,但是市和区还是上一个省份的 市和区,这时我们执行回调修改省,市,区的时候,因为回调只有省改变了,市和区DOM改变了,但是回调里面没改变的问题(不晓得什么问题),这时我们去找省下面的 市,我们取回调的市名称,如果在省下面没有找到这个市,默认展示第一个市,区也默认展示第一个市下面的区,如果遍历市能查到,就去展示对应的市。
1507
- // 回调时修改第2列数据
1508
- console.log(index)
1509
- if (index == 0){
1510
- picker.setColumnValues(2, []); // 防止突然选中第一个,第二个是更新的,但第三个联级不更新,我暂时强制清空
1511
- }
1512
- let ColumnIndexss=picker.getIndexes()
1513
- let getValues=picker.getValues()
1514
- console.log(getValues)
1515
- console.log(ColumnIndexss)
1516
-
1517
- console.log(this.data)
1518
- let testValue=''
1519
- this.$nextTick(()=>{
1520
- if(index == 0)
1521
- {
1522
- if(this.data[ColumnIndexss[0]].children.length > 0)
1523
- {
1524
- if(this.data[ColumnIndexss[0]].children[0]!==undefined)
1525
- {
1526
- testValue=this.data[ColumnIndexss[0]].children[0].value
1527
- picker.setColumnValues(2, this.county(this.data, testValue));
1528
- }
1529
- }
1530
- else
1531
- picker.setColumnValues(2, []);
1532
- }
1533
- if(index == 1)
1534
- {
1535
- if(this.data[ColumnIndexss[0]].children.length > 0)
1536
- {
1537
- if(this.data[ColumnIndexss[0]].children[ColumnIndexss[1]]!==undefined)
1538
- {
1539
- testValue=this.data[ColumnIndexss[0]].children[ColumnIndexss[1]].value
1540
- picker.setColumnValues(2, this.county(this.data, testValue));
1541
- }
1542
- }
1543
- else
1544
- picker.setColumnValues(2, []);
1545
- }
1546
- })
1547
-
1548
- picker.setColumnValues(1, this.cityDate(this.data, values[0].text));
1549
- // 回调时修改第3列数据
1550
-
1551
-
1552
- },
1553
- // 修改级联第二级 这里不再多说什么了根据自己的数据格式来
1554
- cityDate(data, province) {
1555
- var that = this;
1556
- data.forEach(function (res) {
1557
- if (res.value == province) {
1558
- that.cityDates = res;
1559
- }
1560
- });
1561
- console.log(that.cityDates.children)
1562
- if (that.cityDates.children !== undefined&&that.cityDates.children.length > 0) {
1563
- return that.cityDates.children.map(function (res) {
1564
- return {text: res.value, code: res.value};
1565
- })
1566
- } else {
1567
- this.$set(that.cityDates, 'children', [])
1568
- return that.cityDates.children.map(function (res) {
1569
- return {text: res.value, code: res.value};
1570
- })
1571
- }
1572
- // return 返回数据格式,因为我需要省市区code,所以我return的格式是对象,例:[{text:'北京市',code:'1'},{text:'河南省',code:'2'},...],如果你不需要code直接这样就可以 例['北京市','河南省',.....]
1573
- },
1574
- // 修改级联第三级 这里不再多说什么了根据自己的数据格式来
1575
- county(data, county) {
1576
- var that = this;
1577
- var countyDate = '';
1578
- // 因为vant的 van-picker 回调只会返回你修改的那一列,比如现在为 [北京,北京,东城区],你修改了省为[天津市,天津市,和平区],但是vant的change回调会得到[天津市,北京,东城区],后面两个在回调中没有修改,不知道我的渲染方法有问题还是什么问题。
1579
- // 所以我在这里判断change事件触发后,如果你修改了省份的话,回调里面省份会改变,但是市和区还是上一个省份的 市和区,这时我们执行回调修改省,市,区的时候,因为回调只有省改变了,市和区DOM改变了,但是回调里面没改变的问题(不晓得什么问题),这时我们去找省下面的 市,我们取回调的市名称,如果在省下面没有找到这个市,默认展示第一个市,区也默认展示第一个市下面的区,如果遍历市能查到,就去展示对应的市。
1580
- that.cityDates.children.forEach(function (res) {
1581
- if (res.value == county) {
1582
- countyDate = res;
1583
- }
1584
- });
1585
- // 这里如果没有找到对应的县
1586
- if (countyDate == '') {
1587
- console.log(that.cityDates.children.length)
1588
- if(that.cityDates.children.length > 0)
1589
- {
1590
- countyDate = that.cityDates.children[0];
1591
- }
1592
-
1593
- }
1594
- console.log(countyDate.children)
1595
- // return 县
1596
- if (countyDate.children === undefined) {
1597
- this.$set(countyDate, 'children', [])
1598
- return countyDate.children.map(function (res) {
1599
- return {text: res.value, code: res.value};
1600
- })
1601
- } else {
1602
- return countyDate.children.map(function (res) {
1603
- return {text: res.value, code: res.value};
1604
- })
1605
- }
1606
-
1607
- // return 返回数据格式,因为我需要省市区code,所以我return的格式是对象,例:[{text:'北京市',code:'1'},{text:'河南省',code:'2'},...],如果你不需要code直接这样就可以 例['北京市','河南省',.....]
1608
- },
1609
- //点击级联弹出框的确认按钮
1610
- onConfirms(val, id) {
1611
- let test = ''
1612
- for (let i = 0; i < val.length; i++) {
1613
- if (val[i] !== undefined) {
1614
- test += val[i].text + '/'
1615
- }
1616
- }
1617
- test = test.substr(0, test.length - 1)
1618
- for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1619
- if (this.formShow.form.formFieldRelation[i].fieldId=== id) {
1620
- this.cascadeValue[id] = test
1621
- for (let j = 0; j < val.length; j++) {
1622
- if (val[j] !== undefined) {
1623
- this.formShow.form.formFieldRelation[i].value[j] = val[j].text
1624
- }
1625
- }
1626
- break
1627
- }
1628
- }
1629
- this.showArea = false;
1630
- sessionStorage.setItem('cascader',test)
1631
- },
1632
- onCancel() {
1633
- this.showArea = false;
1634
- },
1635
- aliyunOssRequest(data){
1636
- console.log("upload request data", data);
1637
- console.log(this.fileListList)
1638
-
1639
- this.loading = this.$loading({
1640
- lock: true,
1641
- text: 'Loading',
1642
- spinner: 'el-icon-loading',
1643
- background: 'rgba(0, 0, 0, 0.8)'
1644
- });
1645
- let file = data.file;
1646
- console.log("upload file:", file);
1647
- let imgInfo = {
1648
- status:'',
1649
- url:'',
1650
- name:''
1651
- }
1652
- /* let imageData = {
1653
- id:cid,
1654
- cid:cid,
1655
- type: "IMAGE",
1656
- content: {
1657
- urls: [],
1658
- progress: 0,
1659
- },
1660
- };*/
1661
- let res = multipartUpload(
1662
- this.ossConfig,
1663
- file,
1664
- null,
1665
- imgInfo
1666
- );
1667
- res.then((res) => {
1668
- console.log("upload result:", res);
1669
- // let filePath = res.name;
1670
- /* imageData.content.progress = 1;
1671
- imageData.content.urls.push(
1672
- ossFileUrl(this.ossConfig, res.name)
1673
- );
1674
- console.log('imageData',imageData)*/
1675
- imgInfo.url = ossFileUrl(this.ossConfig, res.name)
1676
- imgInfo.status='success'
1677
- if (data.file){
1678
- imgInfo.name = data.file.name
1679
- imgInfo.uid = data.file.uid
1680
- }
1681
- if (!this.fileListList[this.filedId])
1682
- {
1683
- this.fileListList[this.filedId] = []
1684
- }
1685
- this.fileListList[this.filedId].push(imgInfo)
1686
- this.loading.close()
1687
- }).catch((err) => {
1688
- console.log("upload err", err);
1689
- });
1690
- console.log('fileListList',this.fileListList[this.filedId])
1691
- console.log('imgInfo',imgInfo)
1692
- },
1693
- successUpload(response,file,fileList){
1694
- console.log('fileList',fileList)
1695
- if (!this.fileListList[this.filedId]){
1696
- this.fileListList[this.filedId] = []
1697
- }
1698
- for (let i=0;i<fileList.length;i++){
1699
- if (!this.fileListList[this.filedId][i]){
1700
- this.fileListList[this.filedId][i]={}
1701
- }
1702
- this.fileListList[this.filedId][i].url=fileList[i].url
1703
- this.fileListList[this.filedId][i].name=fileList[i].name
1704
- this.fileListList[this.filedId][i].status=fileList[i].status
1705
- }
1706
- console.log('successUpload',this.fileListList)
1707
- },
1708
- uploadProgress(e,res,response){
1709
- console.log(e,res,response)
1710
- this.loading = this.$loading({
1711
- lock: true,
1712
- text: 'Loading',
1713
- spinner: 'el-icon-loading',
1714
- background: 'rgba(0, 0, 0, 0.7)'
1715
- });
1716
- },
1717
- handleRemove(file,fileList) {
1718
- console.log(file);
1719
- console.log(fileList)
1720
- console.log(this.fileListList)
1721
- if (this.fileListList[this.filedId]){
1722
- for (let i=0;i<this.fileListList[this.filedId].length;i++)
1723
- {
1724
- if (this.fileListList[this.filedId][i].uid){
1725
- if (this.fileListList[this.filedId][i].uid===file.uid){
1726
- this.fileListList[this.filedId].splice(i,1)
1727
- return
1728
- }
1729
- }
1730
- else if (this.fileListList[this.filedId][i].url===file.url){
1731
- this.fileListList[this.filedId].splice(i,1)
1732
- return
1733
- }
1734
- }
1735
-
1736
- }
1737
- /*let value=[]
1738
- for (let i=0;i<fileList.length;i++){
1739
- value[i]={}
1740
- value[i].name=fileList[i].name
1741
- if(fileList[i].response){
1742
- value[i].url=fileList[i].response.data
1743
- }
1744
- else {
1745
- value[i].url=fileList[i].url
1746
- }
1747
- }
1748
- for (let i=0;i<this.formShow.form.formFieldRelation.length;i++){
1749
- if (this.formShow.form.formFieldRelation[i].fieldId===this.filedId){
1750
- this.fileListList[this.filedId]=value
1751
- }
1752
- }*/
1753
- /*this.fileListList = [...this.fileListList]*/
1754
- },
1755
- handleEditChange(file,fileList){
1756
- console.log(file)
1757
- this.hideUploadEdit=fileList.length >= this.limitNum
1758
- console.log(this.hideUploadEdit)
1759
- console.log(fileList)
1760
- },
1761
-
1762
- onUploadProgress: function (progress, point, file, videoData) {
1763
- console.debug("upload video progress", progress, point);
1764
- if (progress === 1) {
1765
- // this.loadingIns.close();
1766
- videoData.content.url = ossFileUrl(this.ossConfig, point.name);
1767
- // this.chooseVideo({data:url},file);
1768
-
1769
- } else {
1770
- videoData.content.progress = progress;
1771
-
1772
- }
1773
- console.log('1234',videoData)
1774
- },
1775
- checkUpload(id,limitNum){
1776
- this.filedId=id
1777
- console.log(this.filedId)
1778
- console.log(limitNum)
1779
- this.limitNum = limitNum
1780
-
1781
- },
1782
- beforeAvatarUpload(file){
1783
- const isLte2M = file.size / 1024 / 1024 <= 8;
1784
- const isSupportedFormat =file.type.indexOf('image')!==-1
1785
- if (!isSupportedFormat){
1786
- this.$message.error("只能上传图片格式");
1787
- return false
1788
- }
1789
- if (!isLte2M) {
1790
- this.$message.error("上传图片大小不能超过 8MB!");
1791
- return false
1792
- }
1793
- return true
1794
- },
1795
- exceedUpload(){
1796
- this.$message.warning('上传文件数量达到上限')
1797
- },
1798
-
1799
- handlePictureCardPreview(file) {
1800
- console.log(file)
1801
- this.videoFlag = true;
1802
- this.videoUploadPercent = file.percentage.toFixed(0);
1803
- },
1804
- },
1805
- //时间日期范围的点击事件
1806
- /* dateTimeClick(id){
1807
- for (let i=0;i<this.formList.form.formFieldRelation.length;i++)
1808
- {
1809
- if(this.formList.form.formFieldRelation[i].formField.id===id)
1810
- {
1811
- this.dateTimeId=id
1812
- this.showDateTimePicker = true
1813
- break
1814
- }
1815
- }
1816
- },
1817
- dateTimeClick1(id){
1818
- if(this.dateTimeValue.length === 0)
1819
- {
1820
- this.$message.error('请先选择开始日期时间')
1821
- }
1822
- else
1823
- {
1824
- for (let i=0;i<this.formList.form.formFieldRelation.length;i++)
1825
- {
1826
- if(this.formList.form.formFieldRelation[i].formField.id===id)
1827
- {
1828
- this.dateTimeId=id
1829
- this.showDateTimePicker1 = true
1830
- break
1831
- }
1832
- }
1833
- }
1834
-
1835
- },*/
1836
-
1837
-
1838
-
1839
- }
1840
- </script>
1841
-
1842
- <style lang="less" scoped>
1843
- .notClick {
1844
- pointer-events: none;
1845
- }
1846
- .formClass{
1847
- .explain-url{
1848
- a{
1849
- color:#4C61E1 ;
1850
- }
1851
- }
1852
- }
1853
- .mobileFormClass,.pcFormClass{
1854
- /* border: 1px solid #ebebeb;*/
1855
- font-family: "Avenir", Helvetica, Arial, sans-serif;
1856
- border-radius: 15px;
1857
- }
1858
- .pcFormClass{
1859
- .field-item{
1860
- padding: 8px 0;
1861
- .field-item-name{
1862
- padding-bottom: 4px;
1863
- }
1864
- }
1865
- /deep/.el-upload--picture-card{
1866
- background-color: #fbfdff;
1867
- border: 1px dashed #c0ccda;
1868
- border-radius: 6px;
1869
- width: 74px;
1870
- height: 74px;
1871
- vertical-align: top;
1872
- cursor: pointer;
1873
- text-align: center;
1874
- font-size:28px;
1875
- color:#8c939d;
1876
- display: flex;
1877
- align-items: center;
1878
- justify-content: center;
1879
- }
1880
-
1881
- /deep/.el-upload-list--picture-card{
1882
- .el-upload-list__item{
1883
- width: 74px;
1884
- height: 74px;
1885
- }
1886
- }
1887
- /deep/.el-upload-list__item-name{
1888
- max-width: 180px;
1889
- }
1890
- .hide .el-upload--picture-card {
1891
- display: none!important;
1892
- }
1893
- }
1894
- /deep/.van-radio__icon--checked .van-icon{
1895
- background-color: #4C61E1!important;
1896
- border-color: #4C61E1!important;
1897
- }
1898
- /deep/.van-checkbox__icon--checked .van-icon{
1899
- background-color: #4C61E1!important;
1900
- border-color: #4C61E1!important;
1901
- }
1902
- /deep/.vant-upload--picture-card{
1903
- background-color: #fbfdff;
1904
- border: 1px dashed #c0ccda;
1905
- border-radius: 6px;
1906
- width: 74px;
1907
- height: 74px;
1908
- vertical-align: top;
1909
- cursor: pointer;
1910
- text-align: center;
1911
- font-size:28px;
1912
- color:#8c939d;
1913
- display: flex;
1914
- align-items: center;
1915
- justify-content: center;
1916
- }
1917
- /deep/.van-popup{
1918
- border-radius: 5px;
1919
- }
1920
- .remPhoneClassForm{
1921
- .titleName{
1922
- text-align: center;
1923
- padding-bottom: 4px;
1924
- }
1925
- .mobileFormClass{
1926
- width: 80vw;
1927
- .fileName{
1928
- padding-bottom: 6px;
1929
- }
1930
- }
1931
- .mobileFormClass{
1932
- .upload-phone-demo{
1933
- /deep/.el-upload--picture-card{
1934
- background-color: #fbfdff;
1935
- border: 1px dashed #c0ccda;
1936
- border-radius: 6px;
1937
- width: 74px;
1938
- height: 74px;
1939
- vertical-align: top;
1940
- cursor: pointer;
1941
- text-align: center;
1942
- font-size:28px;
1943
- color:#8c939d;
1944
- display: flex;
1945
- align-items: center;
1946
- justify-content: center;
1947
- }
1948
- /deep/.el-upload-list--picture-card .el-upload-list__item{
1949
- height: 76px;
1950
- width: 76px;
1951
- }
1952
- }
1953
-
1954
-
1955
- }
1956
- .submitClass{
1957
- width: 120px;
1958
- background-color: #4C61E1;
1959
- color: white!important;
1960
- height: 36px;
1961
- }
1962
- /deep/.van-button--info{
1963
- border:1px solid #4C61E1;
1964
- }
1965
- /deep/.van-field__label{
1966
- width: 5em!important;
1967
- text-align: left;
1968
- color: #000000!important;
1969
- display: flex;
1970
- align-items: center;
1971
- line-height: 2;
1972
- }
1973
-
1974
- /deep/.van-field__control{
1975
- min-height: 36px;
1976
- border-radius: 5px;
1977
- }
1978
- /deep/.van-checkbox--horizontal{
1979
- padding: 0.2rem 0;
1980
- }
1981
- /deep/.van-radio--horizontal{
1982
- padding: 0.2rem 0;
1983
- }
1984
- /deep/.van-dropdown-menu__bar{
1985
- box-shadow: none!important;
1986
- }
1987
-
1988
- /deep/.van-overlay{
1989
- background-color: rgba(0,0,0,.5);
1990
- }
1991
-
1992
-
1993
- /deep/.el-input__inner{
1994
- background-color: transparent!important;
1995
- }
1996
-
1997
-
1998
- }
1999
-
2000
- .remCompanyClassForm{
2001
- width: 100%;
2002
- font-size: 1em;
2003
- .pcFormClass{
2004
- width: 100%;
2005
- }
2006
- .submitClass{
2007
- width: 120px;
2008
- color: white!important;
2009
- background-color:#4C61E1;
2010
- border-color: #4C61E1;
2011
- }
2012
- .el-checkbox{
2013
- line-height: 2;
2014
- }
2015
- .el-radio{
2016
- padding: 4px 0;
2017
- }
2018
- .titleName{
2019
- font-size: 1em;
2020
- text-align: center;
2021
- padding: 8px 0;
2022
- }
2023
- /deep/.el-radio__input.is-checked+.el-radio__label{
2024
- color: #4C61E1!important;
2025
- }
2026
- /deep/.el-radio__input.is-checked .el-radio__inner{
2027
- color: #4C61E1!important;
2028
- border-color: #4C61E1!important;
2029
- background: #4C61E1!important;
2030
- }
2031
- /deep/.el-checkbox__input.is-checked+.el-checkbox__label{
2032
- color: #4C61E1!important;
2033
- }
2034
- /deep/.el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner{
2035
- background-color: #4C61E1!important;
2036
- border-color: #4C61E1!important;
2037
- }
2038
- }
2039
-
1
+ <template>
2
+ <div class="media-body">
3
+ <div class="formClass" :class="isPhone?'remPhoneClassForm':'remCompanyClassForm'" v-if="formShow.form">
4
+ <div class="titleName" >
5
+ {{formShow.form.name}}
6
+ </div>
7
+ <div class="pcFormClass" v-if="isCompany===true">
8
+ <div v-for="(item) in formShow.form.formFieldRelation"
9
+ :key="item.formField.id"
10
+ :class="{notClick:disableds === true}"
11
+ >
12
+ <div v-if="item.formField.type!=='CHAT_RECORD'&&item.formField.type!=='CHANNEL'&&item.display&&item.fieldId!=='workorder_name'" class="field-item">
13
+ <div v-if="item.display&&item.fieldId!=='workorder_name'&&item.formField.type!=='EXPLANATION'&&item.formField.type!=='EXPLAIN'" class="field-item-name">
14
+ <span style="color: red" v-if="item.required===true">*</span>
15
+ <span v-if="item.fieldId!=='workorder_description'&&item.fieldId!=='workorder_clientId'">{{item.formField.name}}</span>
16
+ <span v-if="item.fieldId==='workorder_description'">问题描述</span>
17
+ <span v-if="item.fieldId==='workorder_clientId'">报单人</span>
18
+ </div>
19
+ <el-input v-model=item.value
20
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
21
+ :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
22
+ v-if="item.formField.type==='INPUT'&&item.fieldId!=='workorder_name'"
23
+ ></el-input>
24
+ <div v-if="item.formField.type==='EXPLANATION'">
25
+ <div style="display: flex;padding: 4px 0">
26
+ <p style="color: #4C61E1;font-size: 14px;margin: 10px 4px">
27
+ <span class="el-icon-info"></span>
28
+ {{item.formField.extInfo.descriptionText}}
29
+ </p>
30
+ </div>
31
+ </div>
32
+ <div v-if="item.formField.type==='EXPLAIN'">
33
+ <div style="display: flex;padding: 4px 0">
34
+ <p style="color: #4C61E1;font-size: 14px;margin: 10px 4px">
35
+ <span class="el-icon-info"></span>
36
+ <span v-if="item.formField.extInfo.url" class="explain-url"><a :href="item.formField.extInfo.url" target="_blank">{{item.value}}</a></span>
37
+ <span v-else>{{item.value}}</span>
38
+ </p>
39
+ </div>
40
+ </div>
41
+ <el-input type="textarea" :rows="2" v-model=item.value
42
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
43
+ :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
44
+ v-if="item.formField.type==='TEXTAREA'&& item.display&&item.fieldId!=='workorder_description'"
45
+ ></el-input>
46
+ <ckeditor
47
+ :editor="ckeditor.editor"
48
+ v-model="item.value"
49
+ :config="ckeditor.editorConfig"
50
+ v-else-if="item.display&&item.fieldId==='workorder_description'"
51
+ ></ckeditor>
52
+ <el-date-picker
53
+ v-model=item.value
54
+ type="date"
55
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
56
+ style="width: 100%"
57
+ v-if="item.formField.type==='DATE_PICKER'"
58
+ >
59
+ </el-date-picker>
60
+ <el-time-picker
61
+ v-model=item.value
62
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
63
+ style="width: 100%"
64
+ v-if="item.formField.type==='TIME_PICKER' && !item.formField.extInfo.mold"
65
+ >
66
+ </el-time-picker>
67
+ <el-date-picker
68
+ v-model=item.value
69
+ type="date"
70
+ style="width: 100%"
71
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
72
+ v-if="item.formField.type==='TIME_PICKER' &&item.formField.extInfo.mold==='DATA'"
73
+ >
74
+ </el-date-picker>
75
+ <el-date-picker
76
+ v-model=item.value
77
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期时间'"
78
+ clearable
79
+ style="width: 100%"
80
+ type="datetime"
81
+ v-if="item.formField.type==='TIME_PICKER' &&item.formField.extInfo.mold==='DATA_TIME'"
82
+ >
83
+ </el-date-picker>
84
+ <div v-if="item.formField.type==='RADIO' &&item.formField.extInfo.options">
85
+ <el-radio-group v-model=item.value style="text-align:left">
86
+ <el-radio v-for="(items,index) in item.formField.extInfo.options" :label=items.value :key="index">{{items.label}}</el-radio>
87
+ </el-radio-group>
88
+ </div>
89
+ <div v-if="item.formField.type==='RADIO' &&item.formField.extInfo.option">
90
+ <el-radio-group v-model=item.value style="text-align:left">
91
+ <el-radio v-for="(items,index) in item.formField.extInfo.option" :label=items.value :key="index">{{items.label}}</el-radio>
92
+ </el-radio-group>
93
+ </div>
94
+ <div v-if="item.formField.type==='CHECKBOX' && item.formField.extInfo.option">
95
+ <el-checkbox-group v-model=item.value style="text-align:left">
96
+ <el-checkbox
97
+ v-for="(items,index) in item.formField.extInfo.option"
98
+ :label=items.value
99
+ :key="index"
100
+ >{{items.label}}</el-checkbox>
101
+ </el-checkbox-group>
102
+ </div>
103
+ <div v-if="item.formField.type==='CHECKBOX' && item.formField.extInfo.options">
104
+ <el-checkbox-group v-model=item.value style="text-align:left">
105
+ <el-checkbox
106
+ v-for="(items,index) in item.formField.extInfo.options"
107
+ :label=items.value
108
+ :key="index"
109
+ >{{items.label}}</el-checkbox>
110
+ </el-checkbox-group>
111
+ </div>
112
+ <div v-if="item.formField.type==='SELECT'">
113
+ <el-select
114
+ v-model=item.value
115
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
116
+ style="width: 100%"
117
+ filterable
118
+ v-if="item.formField.extInfo.option"
119
+ >
120
+ <el-option
121
+ v-for="(items,index) in item.formField.extInfo.option"
122
+ :key="index"
123
+ :label="items.label"
124
+ :value="items.value">
125
+ </el-option>
126
+ </el-select>
127
+ <el-select
128
+ v-model=item.value
129
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
130
+ style="width: 100%"
131
+ filterable
132
+ v-else-if="item.formField.extInfo.options"
133
+ >
134
+ <el-option
135
+ v-for="(items,index) in item.formField.extInfo.options"
136
+ :key="index"
137
+ :label="items.label"
138
+ :value="items.value">
139
+ </el-option>
140
+ </el-select>
141
+ </div>
142
+ <div v-if="item.formField.type==='CASCADER'">
143
+ <el-cascader
144
+ v-model=item.value
145
+ :options=item.formField.extInfo.cascade
146
+ style="width: 100%;"
147
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
148
+ v-if="item.formField.extInfo.cascade"
149
+ ></el-cascader>
150
+ <el-cascader
151
+ v-model=item.value
152
+ :options=item.formField.extInfo.cascadeDown[0].options
153
+ style="width: 100%;"
154
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
155
+ v-else-if="item.formField.extInfo.cascadeDown"
156
+ ></el-cascader>
157
+ </div>
158
+ <div v-if="item.formField.type==='FILE'">
159
+ <div @click="checkUpload(item.fieldId,item.formField.extInfo.limitNum)" @mouseover="checkUpload(item.fieldId,item.formField.extInfo.limitNum)" style="flex: 0.75;display:flex;align-items: center;">
160
+ <el-upload
161
+ class="upload-demo"
162
+ ref="upload"
163
+ list-type="picture-card"
164
+ accept="image/*"
165
+ name="file"
166
+ action="/open/media/file/upload"
167
+ :multiple="false"
168
+ :file-list="fileListList[item.fieldId]"
169
+ :limit=item.formField.extInfo.limitNum?Number(item.formField.extInfo.limitNum):1
170
+ :before-upload="beforeAvatarUpload"
171
+ :on-exceed="exceedUpload"
172
+ :on-remove="handleRemove"
173
+ :http-request="aliyunOssRequest"
174
+ :on-change="handleEditChange"
175
+ :on-success="successUpload"
176
+ >
177
+ <i class="el-icon-plus"></i>
178
+ </el-upload>
179
+ </div>
180
+ </div>
181
+ </div>
182
+ </div>
183
+ <div style="padding: 10px 0;text-align: center">
184
+ <el-button style="border-color: #4C61E1;color: white;background-color: #4C61E1" round class="submitClass" size="small" @click="submitClick" :disabled="disableds">{{submitValue}}</el-button>
185
+ </div>
186
+ </div>
187
+ <div class="mobileFormClass" v-else style="padding: 10px 0;" :class="{notClick:disableds === true}">
188
+ <div v-for="(item,index) in formFieldRelation"
189
+ :key="item.formField.id"
190
+ class="form-field-item"
191
+ >
192
+ <div v-if="item.formField.type==='INPUT'" class="form-field-item-value">
193
+ <van-field v-model=item.value
194
+ :label=item.formField.name
195
+ :required="item.required===true"
196
+ :disabled="disableds"
197
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
198
+ :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
199
+ />
200
+ </div>
201
+ <div v-else-if="item.formField.type==='EXPLANATION'||item.formField.type==='EXPLAIN'" class="explan-ation">
202
+ <div class="explan-ation-div">
203
+ <p class="explan-ation-p" v-if="item.formField.type==='EXPLANATION'">
204
+ <span class="el-icon-info"></span>
205
+ {{item.formField.extInfo.descriptionText}}
206
+ </p>
207
+ <p v-else class="explan-ation-p">
208
+ <span class="el-icon-info"></span>
209
+ <span v-if="item.formField.extInfo.url" class="explain-url"><a :href="item.formField.extInfo.url" target="_blank">{{item.value}}</a></span>
210
+ <span v-else>{{item.value}}</span>
211
+ </p>
212
+ </div>
213
+ </div>
214
+ <div v-else-if="item.formField.type==='TEXTAREA'" class="form-field-item-value">
215
+ <van-field v-model=item.value
216
+ :label=item.formField.name
217
+ :required="item.required===true"
218
+ type="textarea"
219
+ :disabled="disableds"
220
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'"
221
+ :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
222
+ v-if="item.fieldId!=='workorder_description'"
223
+ />
224
+ <div v-if="item.fieldId==='workorder_description'" class="workorder_description">
225
+ <div class="field-name" :class="item.required?'required-name':''">
226
+ <span v-if="item.required" style="color: red">*</span>
227
+ {{item.formField.name}}
228
+ </div>
229
+ <ckeditor
230
+ :editor="ckeditor.editor"
231
+ v-model="item.value"
232
+ :config="ckeditor.editorConfig"
233
+ ></ckeditor>
234
+ </div>
235
+ </div>
236
+ <div v-else-if="item.formField.type==='DATE_PICKER'" class="form-field-item-value">
237
+ <van-field
238
+ readonly
239
+ clickable
240
+ name="calendar"
241
+ :value=dateValue[item.fieldId]
242
+ :label=item.formField.name
243
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
244
+ :required="item.required===true"
245
+ @click="dateClick(item.fieldId)"
246
+ :disabled="disableds"
247
+ />
248
+ <van-calendar
249
+ v-model="showCalendar"
250
+ @confirm="onConfirmCalendar($event,dateId)"
251
+ />
252
+ </div>
253
+ <div v-else-if="item.formField.type==='TIME_PICKER'&&(!item.formField.extInfo.mold||item.formField.extInfo.mold==='DATA_TIME')" class="form-field-item-value">
254
+ <van-field
255
+ readonly
256
+ clickable
257
+ name="datetimePicker"
258
+ :required="item.required===true"
259
+ :value=timeValue[item.fieldId]
260
+ :label=item.formField.name
261
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择时间'"
262
+ @click="timeClick(item.fieldId,item)"
263
+ :disabled="disableds"
264
+
265
+ />
266
+ <van-popup v-model="showTimePicker" position="bottom">
267
+ <van-datetime-picker
268
+ v-model="currentDate"
269
+ type="datetime"
270
+ @confirm="onConfirm($event,timeId,item)"
271
+ @cancel="showTimePicker = false"
272
+ :min-date="minDate"
273
+ :formatter="formatter"
274
+ :max-date="maxDate"
275
+ />
276
+ </van-popup>
277
+ </div>
278
+ <div v-else-if="item.formField.type==='TIME_PICKER'&&item.formField.extInfo.mold==='DATA'" class="form-field-item-value">
279
+ <van-field
280
+ readonly
281
+ clickable
282
+ name="datetimePicker"
283
+ :required="item.required===true"
284
+ :value=timeValue[item.fieldId]
285
+ :label=item.formField.name
286
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择日期'"
287
+ @click="timeClick(item.fieldId,item)"
288
+ :disabled="disableds"
289
+
290
+ />
291
+ <van-calendar v-model="showTimePickerd" :show-confirm="false" @confirm="onConfirm($event,timeId,item)" @cancel="showTimePickerd = false"/>
292
+ </div>
293
+ <div v-else-if="item.formField.type==='RADIO'" class="form-field-item-other">
294
+ <van-field name="radio" :label="item.formField.name" :required="item.required===true" :disabled="disableds" v-if="item.formField.extInfo.option">
295
+ <template #input style="display: flex;align-items: center">
296
+ <van-radio-group v-model=item.value direction="horizontal" :disabled="disableds">
297
+ <van-radio v-for="(items,index) in item.formField.extInfo.option" :name=items.value :key="index">{{items.label}}</van-radio>
298
+ </van-radio-group>
299
+ </template>
300
+ </van-field>
301
+ <van-field name="radio" :label="item.formField.name" :required="item.required===true" :disabled="disableds" v-if="item.formField.extInfo.options">
302
+ <template #input style="display: flex;align-items: center" >
303
+ <van-radio-group v-model=item.value direction="horizontal" :disabled="disableds">
304
+ <van-radio v-for="(items,index) in item.formField.extInfo.options" :name=items.value :key="index">{{items.label}}</van-radio>
305
+ </van-radio-group>
306
+ </template>
307
+ </van-field>
308
+ </div>
309
+ <div v-else-if="item.formField.type==='CHECKBOX'" class="form-field-item-other">
310
+ <van-field name="checkbox" :label=item.formField.name :required="item.required===true" :disabled="disableds" v-if="item.formField.extInfo.option">
311
+ <template #input style="display: flex;align-items: center" >
312
+ <van-checkbox-group v-model=item.value ref="checkboxGroup" direction="horizontal" :disabled="disableds">
313
+ <van-checkbox
314
+ v-for="(items,index) in item.formField.extInfo.option"
315
+ shape="square"
316
+ :key="index"
317
+ :name=items.value>
318
+ {{items.label}}
319
+ </van-checkbox>
320
+ </van-checkbox-group>
321
+ </template>
322
+ </van-field>
323
+ <van-field name="checkbox" :label=item.formField.name :required="item.required===true" :disabled="disableds" v-if="item.formField.extInfo.options">
324
+ <template #input style="display: flex;align-items: center" >
325
+ <van-checkbox-group v-model=item.value ref="checkboxGroup" direction="horizontal" :disabled="disableds">
326
+ <van-checkbox
327
+ v-for="(items,index) in item.formField.extInfo.options"
328
+ shape="square"
329
+ :key="index"
330
+ :name=items.value>
331
+ {{items.label}}
332
+ </van-checkbox>
333
+ </van-checkbox-group>
334
+ </template>
335
+ </van-field>
336
+ </div>
337
+ <div v-else-if="item.formField.type==='SELECT'" class="form-field-item-value">
338
+ <van-field
339
+ readonly
340
+ clickable
341
+ name="picker"
342
+ :value=selectValues[item.fieldId]
343
+ :label=item.formField.name
344
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
345
+ @click="selectClick(item.fieldId)"
346
+ :required="item.required===true"
347
+ :disabled="disableds"
348
+ v-if="item.fieldId!=='workorder_clientId'"
349
+ right-icon="van-icon van-icon-arrow van-cell__right-icon"
350
+ />
351
+ <van-field
352
+ readonly
353
+ clickable
354
+ name="picker"
355
+ :value=selectValues[item.fieldId]
356
+ label='报单人'
357
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
358
+ @click="selectClick(item.fieldId)"
359
+ :required="item.required===true"
360
+ :disabled="disableds"
361
+ v-if="item.fieldId==='workorder_clientId'"
362
+ right-icon="van-icon van-icon-arrow van-cell__right-icon"
363
+ />
364
+ <van-popup v-model="showPicker" position="bottom">
365
+ <van-picker
366
+ show-toolbar
367
+ :columns=selectValue
368
+ @confirm="onConfirmSelect($event,selectId)"
369
+ @cancel="showPicker = false"
370
+ :key="selectKey"
371
+
372
+ />
373
+ </van-popup>
374
+ </div>
375
+ <div v-else-if="item.formField.type==='CASCADER'" class="form-field-item-value">
376
+ <van-field
377
+ readonly
378
+ clickable
379
+ name="area"
380
+ :value=cascadeValue[item.fieldId]
381
+ :label=item.formField.name
382
+ :placeholder="item.formField.extInfo&&item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请选择'"
383
+ @click="pickerClick(item.fieldId)"
384
+ :required="item.required===true"
385
+ :disabled="disableds"
386
+ right-icon="van-icon van-icon-arrow van-cell__right-icon"
387
+ />
388
+
389
+ <van-popup v-model="showArea" position="bottom">
390
+ <van-picker v-if="pageShow"
391
+ show-toolbar
392
+ :columns="column"
393
+ @cancel="onCancel"
394
+ @confirm="onConfirms($event,pickerId,index)"
395
+ @change="onChange"
396
+ :item-height="45"
397
+ :key="keyValue"
398
+ />
399
+ </van-popup>
400
+ </div>
401
+ <div v-else-if="item.formField.type === 'FILE'" class="form-field-item-value">
402
+ <div @click="checkUpload(item.fieldId,item.formField.extInfo.limitNum)" class="form-field-item-file">
403
+ <div class="fileName"><span style="color: red" v-if="item.required">*</span>{{item.formField.name}}</div>
404
+ <van-uploader
405
+ v-model="fileListList[item.fieldId]"
406
+ :before-read="beforeRead"
407
+ :max-count='item.formField.extInfo.limitNum!==undefined?item.formField.extInfo.limitNum:1'
408
+ :after-read="afterRead"
409
+ accept="image/*"
410
+ :multiple=false
411
+ >
412
+ <div class="vant-upload--picture-card">
413
+ <i class="el-icon-plus"></i>
414
+ </div>
415
+
416
+ </van-uploader>
417
+ </div>
418
+ </div>
419
+ </div>
420
+ <div class="form-submit-btn">
421
+ <van-button round type="info" class="submitClass" @click="submitClick" :disabled="disableds">{{submitValue}}</van-button>
422
+ </div>
423
+ <van-popup v-model="fileUpload" :close-on-click-overlay="false">
424
+ <div style="background-color: black;height: 100px;width: 100px;display: flex;justify-content: center;align-items: center" >
425
+ <van-loading type="spinner"/>
426
+ </div>
427
+ </van-popup>
428
+ </div>
429
+ </div>
430
+ <el-dialog :visible.sync="dialogVisible">
431
+ <img width="100%" :src="dialogImageUrl" alt="">
432
+ </el-dialog>
433
+
434
+ </div>
435
+ </template>
436
+
437
+ <script>
438
+ let that
439
+ import {multipartUpload,ossFileUrl} from "./utils/AliyunIssUtil";
440
+ import {MyCustomUploadAdapterPlugin} from "./utils/ckeditor";
441
+ import CKEDITOR from 'ckeditor'
442
+ export default {
443
+ name: "formTemplate",
444
+ data() {
445
+ return {
446
+ isPhone: false,
447
+ isCompany: false,
448
+ checkboxGroup: [],
449
+ currentDate: new Date(),
450
+ timeValue: [],
451
+ dateValue: [],
452
+ showPicker: false,
453
+ showTimePicker: false,
454
+ showTimePickerd:false,
455
+ showCalendar: false,
456
+ radio: [],
457
+ selectValue: [],
458
+ pickerValue: [],
459
+ showArea: false,
460
+ dateTimeValue: [],
461
+ dateTimeValue1: [],
462
+ showDateTimePicker: false,
463
+ showDateTimePicker1: false,
464
+ pickerId: 0,
465
+ dateId: 0,
466
+ timeId: 0,
467
+ selectId: 0,
468
+ dateTimeId: 0,
469
+ column: [
470
+ {
471
+ values: '', // 设置的页面初始值
472
+ className: "column1"
473
+ },
474
+ {
475
+ values: '',
476
+ className: "column2",
477
+ },
478
+ {
479
+ values: '',
480
+ className: "column3",
481
+ }
482
+ ],
483
+ pageShow: false, //省市区三级联动是否显示(因为是接口返回的数据,等三级数据渲染完毕之后,在显示三级联动)
484
+ cityDates: '', //安联当前选中市的所有区所有数据
485
+ data: [],//接口返回所有级联数据
486
+ dateTimeRange: '',
487
+ selectValues: [],
488
+ cascadeValue: [],
489
+ minDate: new Date(2020, 0, 1),
490
+ maxDate: new Date(2025, 11, 31),
491
+ disableds: false,
492
+ submitValue: '提交',
493
+ clickPicker: '',
494
+ columns: [],
495
+ copyForm: [],
496
+ cascaderId:0,
497
+ formShow:[],
498
+
499
+ uploadAvatarParams: {
500
+ token: "8c98087dfd2d48f856d8c95c09115def",
501
+ },
502
+ fileListList:[],
503
+ keyValue:'',
504
+ selectKey:'shuijiao',
505
+ filedId:'',
506
+ disabled:false,
507
+ dialogVisible:false,
508
+ dialogImageUrl:'',
509
+ fileUpload:false,
510
+ videoFlag:false,
511
+ videoUploadPercent:false,
512
+ fileType:['PICTURE','VIDEO','AUDIO'],
513
+ loading:'',
514
+ ossConfig: {
515
+ region: "oss-cn-zhangjiakou",
516
+ //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
517
+ accessKeyId: "LTAI4G3QtdEdwkEbihBngAsK",
518
+ accessKeySecret: "OwgdVfc5PeCkIgqIdug660xmiSPchn",
519
+ // stsToken: '<Your securityToken(STS)>',
520
+ bucket: "guoranopen-zjk",
521
+ },
522
+ hideUploadEdit:false,
523
+ limitNum:1,
524
+ ckeditor: {
525
+ editor: CKEDITOR.ClassicEditor,
526
+ editorConfig: {
527
+ extraPlugins: [MyCustomUploadAdapterPlugin],
528
+ toolbar: [
529
+ 'imageUpload'
530
+ ]
531
+ },
532
+ },
533
+
534
+ }
535
+ },
536
+ props: {
537
+ formList: {
538
+ type: Object,
539
+ default() {
540
+ return {}
541
+ }
542
+ },
543
+ type:String,
544
+ disable:Boolean,
545
+ submit:Boolean,
546
+ usePropStyleType:{
547
+ type:Boolean,
548
+ default() {
549
+ return false;
550
+ }
551
+ },
552
+ propIsPhone: {
553
+ type:Boolean,
554
+ default() {
555
+ return false;
556
+ }
557
+ },
558
+ propIsCompany: {
559
+ type:Boolean,
560
+ default() {
561
+ return false;
562
+ }
563
+ },
564
+ uploadUrl: {
565
+ type:String,
566
+ default(){
567
+ return '/open/media/file/upload'
568
+ }
569
+ }
570
+ },
571
+ computed:{
572
+ acceptType:function () {
573
+ return '.jpg,.jpeg,.png,.gif,.JPG,.JPEG,.PBG,.GIF'
574
+ },
575
+ formFieldRelation:function (){
576
+ console.log('this.formShow.form.formFieldRelation',this.formShow.form.formFieldRelation)
577
+ let arr = [];
578
+ this.formShow.form.formFieldRelation.forEach(item=> {
579
+ if (item.fieldId!=='workorder_name'&&item.display) {
580
+ arr.push(item);
581
+ }
582
+ })
583
+ return arr;
584
+ }
585
+
586
+ },
587
+ mounted() {
588
+ console.log(this.formList)
589
+ console.log(this.disable)
590
+ this.isMobile()
591
+ },
592
+ beforeCreate() {
593
+ // 等待dom渲染完毕之后,再去显示 三级联动。
594
+ that=this
595
+ this.$nextTick(function () {
596
+ this.pageShow = true;
597
+ })
598
+ },
599
+ created() {
600
+
601
+ if(this.disable===true)
602
+ {
603
+ this.disableds=true
604
+ }
605
+ else
606
+ {
607
+ this.disableds=false
608
+ }
609
+ if(this.submit===true)
610
+ {
611
+ this.submitValue='已提交'
612
+ }
613
+ else
614
+ {
615
+ this.submitValue='提交'
616
+ }
617
+ },
618
+ beforeMount() {
619
+ that.defaultClick()
620
+ },
621
+ methods: {
622
+ beforeRead(file){
623
+ console.log('file',file)
624
+ console.log('fileType',!Array.isArray(file))
625
+ if (!Array.isArray(file)){
626
+ const isLte2M = file.size / 1024 / 1024 <= 8;
627
+ console.log(file.type.indexOf('image')!==-1)
628
+ const isSupportedFormat =file.type.indexOf('image')!==-1
629
+ if (!isSupportedFormat){
630
+ this.$message.error("只能上传图片格式");
631
+ return false
632
+ }
633
+ if (!isLte2M&&isSupportedFormat) {
634
+ this.$message.error("上传图片大小不能超过 8MB!");
635
+ return false
636
+ }
637
+ return true
638
+ }
639
+ else{
640
+ let length = 0
641
+ if (this.fileListList[this.filedId]){
642
+ length = this.fileListList[this.filedId].length
643
+ }
644
+ if (file.length<=this.limitNum-length){
645
+ for (let i=0;i<file.length;i++){
646
+ const isLte2M = file[i].size / 1024 / 1024 <= 8;
647
+ console.log(file[i].type.indexOf('image')!==-1)
648
+ const isSupportedFormat =file[i].type.indexOf('image')!==-1
649
+ if (!isSupportedFormat){
650
+ this.$message.error("只能上传图片格式");
651
+ return false
652
+ }
653
+ if (!isLte2M&&isSupportedFormat) {
654
+ this.$message.error("上传图片大小不能超过 8MB!");
655
+ return false
656
+ }
657
+ return true
658
+ }
659
+ }
660
+ else {
661
+ let num = 1
662
+ if (this.limitNum){
663
+ num = this.limitNum
664
+ }
665
+ let messageText = '仅支持上传'+num+'张图片'
666
+ this.$message.error(messageText);
667
+ return false
668
+ }
669
+
670
+ }
671
+
672
+ },
673
+ //文件上传至服务器
674
+ afterRead(file){
675
+ this.fileUpload=true
676
+ console.log(file)
677
+ console.log(!Array.isArray(file))
678
+ if (!Array.isArray(file)){
679
+ this.uploadImgFun(file.content,file.file.name,file,file.file);
680
+ }
681
+ else {
682
+ console.log(file.length)
683
+ let num = 1
684
+ if (this.limitNum){
685
+ num = this.limitNum
686
+ }
687
+ if (file.length >num){
688
+ this.$message.warning('仅支持上传'+num+'张图片')
689
+ return false
690
+ }
691
+ else {
692
+ for (let i = 0; i < file.length; i++){
693
+ this.uploadImgFun(file[i].content,file[i].file.name,file[i],file[i].file);
694
+ }
695
+ }
696
+ }
697
+
698
+ console.log(file)
699
+ console.log(this.fileListList[this.filedId])
700
+ },
701
+ uploadImgFun(content,name,fileCon,file){
702
+ console.log(fileCon)
703
+ let imageData = {
704
+ urls:[]
705
+ }
706
+ let imageInfo = {
707
+ name:"",
708
+ status:'',
709
+ url:''
710
+ }
711
+ let res = multipartUpload(
712
+ this.ossConfig,
713
+ file,
714
+ null,
715
+ imageInfo
716
+ );
717
+ res.then((res) => {
718
+ console.log("upload result:", res);
719
+ // let filePath = res.name;
720
+ imageData.urls.push({
721
+ name:res.name,
722
+ url:ossFileUrl(this.ossConfig, res.name),
723
+ status:'success'
724
+ })
725
+ imageInfo.url = ossFileUrl(this.ossConfig, res.name)
726
+ imageInfo.status='success'
727
+ imageInfo.name=res.name
728
+ console.log(this.fileListList[this.filedId])
729
+ console.log(imageData)
730
+ for (let j=0;j<this.fileListList[this.filedId].length;j++){
731
+ if (this.fileListList[this.filedId][j].content&&this.fileListList[this.filedId][j].content===content){
732
+ this.fileListList[this.filedId][j].name=res.name
733
+ this.fileListList[this.filedId][j].status='success'
734
+ this.fileListList[this.filedId][j].url=imageInfo.url
735
+ delete this.fileListList[this.filedId][j].content
736
+ }
737
+ }
738
+ this.fileUpload=false
739
+ }).catch((err) => {
740
+ console.log("upload err", err);
741
+ });
742
+
743
+ },
744
+ dataURLtoFileFun (dataurl, filename) {
745
+ // 将base64转换为文件,dataurl为base64字符串,filename为文件名(必须带后缀名,如.jpg,.png)
746
+ let arr = dataurl.split(",");
747
+ let mime = arr[0].match(/:(.*?);/)[1];
748
+ let bstr = atob(arr[1]);
749
+ let n = bstr.length;
750
+ let u8arr = new Uint8Array(n);
751
+ while (n--) {
752
+ u8arr[n] = bstr.charCodeAt(n);
753
+ }
754
+ return new File([u8arr], filename, { type: mime });
755
+ },
756
+ //初始化默认值
757
+ defaultClick() {
758
+ for (let i = 0; i < this.formList.form.formFieldRelation.length; i++)
759
+ {
760
+ if(this.formList.form.formFieldRelation[i].formField.type ==='SELECT'||this.formList.form.formFieldRelation[i].formField.type ==='CHECKBOX' ||this.formList.form.formFieldRelation[i].formField.type==='RADIO')
761
+ {
762
+ if(!this.formList.form.formFieldRelation[i].formField.extInfo.option)
763
+ {
764
+ if(this.formList.form.formFieldRelation[i].formField.extInfo.exinfo)
765
+ {
766
+ for (let j=0;j<this.formList.form.formFieldRelation[i].formField.extInfo.exinfo.length;j++)
767
+ {
768
+ this.$set(this.formList.form.formFieldRelation[i].formField.extInfo.exinfo[j],'label',this.formList.form.formFieldRelation[i].formField.extInfo.exinfo[j].value)
769
+ }
770
+ this.$set(this.formList.form.formFieldRelation[i].formField.extInfo,'option',this.formList.form.formFieldRelation[i].formField.extInfo.exinfo)
771
+ }
772
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.option){
773
+ if (this.formList.form.formFieldRelation[i].formField.type === 'RADIO') {
774
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
775
+ if(!this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value)
776
+ {
777
+ this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value=this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
778
+ }
779
+ }
780
+ if(!this.formList.form.formFieldRelation[i].value)
781
+ {
782
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
783
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.option[j]._default === 'true') {
784
+ this.formList.form.formFieldRelation[i].value = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value
785
+ }
786
+ }
787
+ }
788
+ }
789
+ if (this.formList.form.formFieldRelation[i].formField.type === 'CHECKBOX') {
790
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
791
+ if (!this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value) {
792
+ this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
793
+ }
794
+ }
795
+
796
+ if (!this.formList.form.formFieldRelation[i].value||this.formList.form.formFieldRelation[i].value.length === 0)
797
+ {
798
+ this.formList.form.formFieldRelation[i].value=[]
799
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
800
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.option[j]._default === 'true') {
801
+ this.formList.form.formFieldRelation[i].value[0] = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value
802
+ }
803
+ }
804
+ }
805
+ }
806
+ }
807
+
808
+ }
809
+ else {
810
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.options){
811
+ if (this.formList.form.formFieldRelation[i].formField.type === 'RADIO') {
812
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
813
+ if(!this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value)
814
+ {
815
+ this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value=this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
816
+ }
817
+ }
818
+ if(!this.formList.form.formFieldRelation[i].value)
819
+ {
820
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
821
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j]._default === 'true') {
822
+ this.formList.form.formFieldRelation[i].value = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value
823
+ }
824
+ }
825
+ }
826
+ }
827
+ if (this.formList.form.formFieldRelation[i].formField.type === 'CHECKBOX') {
828
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
829
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value === '') {
830
+ this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
831
+ }
832
+ }
833
+
834
+ if (this.formList.form.formFieldRelation[i].value === null||this.formList.form.formFieldRelation[i].value.length === 0)
835
+ {
836
+ this.formList.form.formFieldRelation[i].value=[]
837
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
838
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j]._default === 'true') {
839
+ this.formList.form.formFieldRelation[i].value[0] = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value
840
+ }
841
+ }
842
+ }
843
+ }
844
+ }
845
+ }
846
+
847
+ }
848
+ if (this.formList.form.formFieldRelation[i].formField.type ==='FILE'){
849
+ if (this.formList.form.formFieldRelation[i].value!==undefined){
850
+ if (this.formList.form.formFieldRelation[i].value===null||this.formList.form.formFieldRelation[i].value===''){
851
+ this.formList.form.formFieldRelation[i].value=[]
852
+ }
853
+ else {
854
+ let valueList=[]
855
+ let bool=false
856
+ if(this.formList.form.formFieldRelation[i].value.length > 0) {
857
+ for (let file=0;file<this.formList.form.formFieldRelation[i].value.length;file++) {
858
+ let type = typeof (this.formList.form.formFieldRelation[i].value[file])
859
+ if (type === "string") {
860
+ bool = true
861
+ valueList[file] = {}
862
+ valueList[file].url = this.formList.form.formFieldRelation[i].value[file]
863
+ }
864
+ if (type === 'object'&&JSON.stringify(this.formList.form.formFieldRelation[i].value[file])!=='{}') {
865
+ this.fileListList[this.formList.form.formFieldRelation[i].fieldId]=this.formList.form.formFieldRelation[i].value
866
+ }
867
+ else {
868
+ this.fileListList[this.formList.form.formFieldRelation[i].fieldId]=[]
869
+ }
870
+ }
871
+ if (bool){
872
+ this.fileListList[this.formList.form.formFieldRelation[i].fieldId]=valueList
873
+ }
874
+
875
+ console.log(bool)
876
+ console.log(this.fileListList[this.formList.form.formFieldRelation[i].fieldId])
877
+ }
878
+ }
879
+ }
880
+
881
+
882
+
883
+ }
884
+
885
+ }
886
+ console.log(this.formList)
887
+ let test = []
888
+ for (let i = 0; i < this.formList.form.formFieldRelation.length; i++) {
889
+ if (this.formList.form.formFieldRelation[i].formField.type === 'CASCADER') {
890
+ test.push(this.formList.form.formFieldRelation[i])
891
+ let cascader=''
892
+ console.log(this.formList.form.formFieldRelation[i])
893
+ if(this.formList.form.formFieldRelation[i].value)
894
+ {
895
+ if(this.formList.form.formFieldRelation[i].value.length > 0)
896
+ {
897
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].value.length; j++) {
898
+ if (this.formList.form.formFieldRelation[i].value[j]) {
899
+ cascader += this.formList.form.formFieldRelation[i].value[j] + '/'
900
+ }
901
+ }
902
+ cascader = cascader.substr(0, cascader.length - 1)
903
+
904
+ }
905
+ this.cascadeValue[this.formList.form.formFieldRelation[i].fieldId]=cascader
906
+ }
907
+ else
908
+ {
909
+ this.formList.form.formFieldRelation[i].value=[]
910
+ }
911
+ }
912
+ if (this.formList.form.formFieldRelation[i].formField.type === 'DATE_PICKER')
913
+ {
914
+ if(this.formList.form.formFieldRelation[i].value!==null && this.formList.form.formFieldRelation[i].value!=='' )
915
+ {
916
+
917
+ this.dateValue[this.formList.form.formFieldRelation[i].fieldId]=this.formatDate(this.formList.form.formFieldRelation[i].value)
918
+ }
919
+ }
920
+ if (this.formList.form.formFieldRelation[i].formField.type === 'TIME_PICKER')
921
+ {
922
+ if(this.formList.form.formFieldRelation[i].value!==''&& this.formList.form.formFieldRelation[i].value!==null)
923
+ {
924
+ const dateTime = new Date(this.formList.form.formFieldRelation[i].value)
925
+ this.timeValue[this.formList.form.formFieldRelation[i].fieldId]=this.addZero(dateTime.getHours()) + ':' + this.addZero(dateTime.getMinutes())
926
+
927
+ }
928
+ }
929
+ if (this.formList.form.formFieldRelation[i].formField.type === 'SELECT') {
930
+ if ( this.formList.form.formFieldRelation[i].formField.extInfo.option){
931
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
932
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value === '') {
933
+ this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
934
+ }
935
+ }
936
+ if(this.formList.form.formFieldRelation[i].value)
937
+ {
938
+ console.log(this.formList.form.formFieldRelation[i].formField.extInfo.option)
939
+ for (let j=0;j<this.formList.form.formFieldRelation[i].formField.extInfo.option.length;j++)
940
+ {
941
+ if (this.formList.form.formFieldRelation[i].value === this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value)
942
+ {
943
+ this.selectValues[this.formList.form.formFieldRelation[i].fieldId] =this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
944
+ }
945
+ }
946
+ /*this.selectValues[this.formList.form.formFieldRelation[i].fieldId] = this.formList.form.formFieldRelation[i].value*/
947
+
948
+ }
949
+ else
950
+ {
951
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
952
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.option[j]._default === 'true') {
953
+ this.selectValues[this.formList.form.formFieldRelation[i].fieldId] = this.formList.form.formFieldRelation[i].formField.extInfo.option[j].label
954
+ this.formList.form.formFieldRelation[i].value=this.formList.form.formFieldRelation[i].formField.extInfo.option[j].value
955
+ }
956
+ }
957
+ }
958
+ }
959
+ else {
960
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
961
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value === '') {
962
+ this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
963
+ }
964
+ }
965
+ if(this.formList.form.formFieldRelation[i].value)
966
+ {
967
+ for (let j=0;j<this.formList.form.formFieldRelation[i].formField.extInfo.options.length;j++)
968
+ {
969
+ if (this.formList.form.formFieldRelation[i].value === this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value)
970
+ {
971
+ this.selectValues[this.formList.form.formFieldRelation[i].fieldId] =this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
972
+ }
973
+ }
974
+ /*this.selectValues[this.formList.form.formFieldRelation[i].fieldId] = this.formList.form.formFieldRelation[i].value*/
975
+
976
+ }
977
+ else
978
+ {
979
+ for (let j = 0; j < this.formList.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
980
+ if (this.formList.form.formFieldRelation[i].formField.extInfo.options[j]._default === 'true') {
981
+ this.selectValues[this.formList.form.formFieldRelation[i].fieldId] = this.formList.form.formFieldRelation[i].formField.extInfo.options[j].label
982
+ this.formList.form.formFieldRelation[i].value=this.formList.form.formFieldRelation[i].formField.extInfo.options[j].value
983
+ }
984
+ }
985
+ }
986
+ }
987
+
988
+ }
989
+ }
990
+ this.formShow=this.formList
991
+ console.log(this.formList.form.formFieldRelation)
992
+ },
993
+ addZero(i) {
994
+ if (i < 10) {
995
+ i = "0" + i;
996
+ }
997
+ return i;
998
+ },
999
+ formatter(type, value) {
1000
+ // 格式化选择器日期
1001
+ if (type === "year") {
1002
+ return `${value}年`;
1003
+ } else if (type === "month") {
1004
+ return `${value}月`;
1005
+ } else if (type === "day") {
1006
+ return `${value}日`;
1007
+ } else if (type === "hour") {
1008
+ return `${value}时`;
1009
+ } else if (type === "minute") {
1010
+ return `${value}分`;
1011
+ }
1012
+ return value;
1013
+ },
1014
+
1015
+ isMobile() {
1016
+ if (this.usePropStyleType === false){
1017
+ let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
1018
+ if (flag) {
1019
+ this.isPhone=true
1020
+ }
1021
+ else {
1022
+ this.isCompany=true
1023
+ }
1024
+ }else {
1025
+ this.isPhone=this.propIsPhone;
1026
+ this.isCompany=this.propIsCompany;
1027
+ }
1028
+ },
1029
+ //时间的选择器
1030
+ onConfirm(value, id,item) {
1031
+ for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1032
+ if (this.formShow.form.formFieldRelation[i].fieldId=== id) {
1033
+ this.formShow.form.formFieldRelation[i].value = value
1034
+ if (!item.formField.extInfo.mold||item.formField.extInfo.mold==='DATA_TIME'){
1035
+ this.timeValue[id] =this.formatDate(value) +" "+ this.addZero(value.getHours()) + ':' + this.addZero(value.getMinutes())
1036
+ this.showTimePicker = false;
1037
+ }
1038
+ else {
1039
+ this.timeValue[id] =this.formatDate(value)
1040
+ this.showTimePickerd = false;
1041
+ }
1042
+ break
1043
+ }
1044
+ }
1045
+ },
1046
+ //转换日期的函数
1047
+ formatDate(date) {
1048
+ const dateTime = new Date(date)
1049
+ return `${dateTime.getFullYear()}-${dateTime.getMonth() + 1}-${dateTime.getDate()}`;
1050
+ },
1051
+ //日期的选择器
1052
+ onConfirmCalendar(date, id) {
1053
+ for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1054
+ if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1055
+ this.dateValue[id] = this.formatDate(date)
1056
+ this.formShow.form.formFieldRelation[i].value = date
1057
+ this.showCalendar = false;
1058
+ break
1059
+ }
1060
+ }
1061
+ },
1062
+ //下拉的选择器
1063
+ onConfirmSelect(value, id) {
1064
+ console.log(value)
1065
+ for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1066
+ if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1067
+ this.selectValues[this.formShow.form.formFieldRelation[i].fieldId] = value
1068
+ if (this.formShow.form.formFieldRelation[i].formField.extInfo.option){
1069
+ for (let j = 0; j < this.formShow.form.formFieldRelation[i].formField.extInfo.option.length; j++) {
1070
+ if(value ===this.formShow.form.formFieldRelation[i].formField.extInfo.option[j].label)
1071
+ {
1072
+ this.formShow.form.formFieldRelation[i].value = this.formShow.form.formFieldRelation[i].formField.extInfo.option[j].value
1073
+ }
1074
+ }
1075
+ }
1076
+ else {
1077
+ for (let j = 0; j < this.formShow.form.formFieldRelation[i].formField.extInfo.options.length; j++) {
1078
+ if(value ===this.formShow.form.formFieldRelation[i].formField.extInfo.options[j].label)
1079
+ {
1080
+ this.formShow.form.formFieldRelation[i].value = this.formShow.form.formFieldRelation[i].formField.extInfo.options[j].value
1081
+ }
1082
+ }
1083
+ }
1084
+
1085
+ this.showPicker = false;
1086
+ break
1087
+ }
1088
+ }
1089
+ },
1090
+ //时间日期的选择器
1091
+ /* onConfirmDateTime(date,id){
1092
+ for (let i=0;i<this.formList.form.formFieldRelation.length;i++)
1093
+ {
1094
+
1095
+ if(this.formList.form.formFieldRelation[i].formField.id===id)
1096
+ {
1097
+ this.dateTimeValue[id]=this.addZero(date.getFullYear())+'-'+this.addZero(date.getMonth())+'-'+this.addZero(date.getDate())+' '+this.addZero(date.getHours())+':'+this.addZero(date.getMinutes())
1098
+ this.formList.form.formFieldRelation[i].value[0]=date
1099
+ this.showDateTimePicker = false;
1100
+ break
1101
+ }
1102
+ }
1103
+
1104
+ },
1105
+ onConfirmDateTime1(date,id){
1106
+ for (let i=0;i<this.formList.form.formFieldRelation.length;i++)
1107
+ {
1108
+ if(this.formList.form.formFieldRelation[i].formField.id===id)
1109
+ {
1110
+
1111
+ this.dateTimeValue1[id]=this.addZero(date.getFullYear())+'-'+this.addZero(date.getMonth())+'-'+this.addZero(date.getDate())+' '+this.addZero(date.getHours())+':'+this.addZero(date.getMinutes())
1112
+ this.formList.form.formFieldRelation[i].value[1]=date
1113
+ this.showDateTimePicker1 = false;
1114
+ break
1115
+ }
1116
+ }
1117
+ },*/
1118
+ //提交按钮事件
1119
+ submitClick() {
1120
+
1121
+ for (let i=0;i<this.formShow.form.formFieldRelation.length;i++)
1122
+ {
1123
+ if(this.formShow.form.formFieldRelation[i].formField.type==='CASCADER')
1124
+ {
1125
+ let cascader = this.formShow.form.formFieldRelation[i].formField.extInfo.cascade?this.formShow.form.formFieldRelation[i].formField.extInfo.cascade:this.formShow.form.formFieldRelation[i].formField.extInfo.cascadeDown[0].options?this.formShow.form.formFieldRelation[i].formField.extInfo.cascadeDown[0].options:[]
1126
+ cascader.forEach(item=>{
1127
+ if(item.children!==undefined)
1128
+ {
1129
+ if(item.children.length===0)
1130
+ delete item.children
1131
+ else {
1132
+ item.children.forEach(items=>{
1133
+ if(items.children)
1134
+ {
1135
+ if(items.children.length===0)
1136
+ delete items.children
1137
+ }
1138
+ })
1139
+ }
1140
+ }
1141
+ })
1142
+
1143
+ let test=[]
1144
+ console.log(typeof test)
1145
+ }
1146
+ if (this.fileListList[this.formShow.form.formFieldRelation[i].fieldId]!==undefined){
1147
+ let value=[]
1148
+
1149
+ this.fileListList[this.formShow.form.formFieldRelation[i].fieldId].forEach(item=>{
1150
+ let file={}
1151
+ file.name=item.name
1152
+ file.url=item.url
1153
+ value.push(file)
1154
+ })
1155
+ console.log(value)
1156
+ this.formShow.form.formFieldRelation[i].value=value
1157
+ }
1158
+
1159
+ if(this.formShow.form.formFieldRelation[i].display===true && this.formShow.form.formFieldRelation[i].required === true&&this.formShow.form.formFieldRelation[i].fieldId!=='workorder_name')
1160
+ {
1161
+
1162
+ if(!this.formShow.form.formFieldRelation[i].value || (this.formShow.form.formFieldRelation[i].value&&this.formShow.form.formFieldRelation[i].value.length===0))
1163
+ {
1164
+ this.$message.error('请完善'+ this.formShow.form.formFieldRelation[i].formField.name)
1165
+ return
1166
+ }
1167
+ }
1168
+
1169
+ console.log( this.fileListList)
1170
+ }
1171
+ console.log(this.formShow)
1172
+ this.$emit('submitClick',this.formShow)
1173
+ this.disableds = true
1174
+ this.submitValue = '已提交'
1175
+
1176
+
1177
+ },
1178
+ //日期的点击事件
1179
+ dateClick(id) {
1180
+ if(this.disableds === false)
1181
+ {
1182
+ for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1183
+ if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1184
+ this.dateId = id
1185
+ this.showCalendar = true
1186
+ break
1187
+ }
1188
+ }
1189
+ }
1190
+
1191
+ },
1192
+ //时间的点击事件
1193
+ timeClick(id,item) {
1194
+ if(this.disableds === false){
1195
+ for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1196
+ if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1197
+ this.timeId = id
1198
+ if (!item.formField.extInfo.mold||item.formField.extInfo.mold==='DATA_TIME'){
1199
+ this.showTimePicker = true
1200
+ }
1201
+ else {
1202
+ this.showTimePickerd= true
1203
+ }
1204
+
1205
+ break
1206
+ }
1207
+
1208
+ }
1209
+ }
1210
+
1211
+ },
1212
+ //下拉的点击事件
1213
+ selectClick(id) {
1214
+ console.log(id)
1215
+ if(this.disableds === false){
1216
+ let selectOption
1217
+ this.selectValue=[]
1218
+ for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1219
+ if(this.formShow.form.formFieldRelation[i].formField.type==='SELECT')
1220
+ {
1221
+ if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1222
+ selectOption = this.formShow.form.formFieldRelation[i].formField.extInfo.option?this.formShow.form.formFieldRelation[i].formField.extInfo.option:this.formShow.form.formFieldRelation[i].formField.extInfo.options?this.formShow.form.formFieldRelation[i].formField.extInfo.options:[]
1223
+ for (let j = 0; j < selectOption.length; j++) {
1224
+ this.selectValue[j] = selectOption[j].label
1225
+ }
1226
+
1227
+ }
1228
+ }
1229
+ }
1230
+ console.log(this.selectValue)
1231
+ this.selectId = id
1232
+ this.showPicker = true
1233
+ }
1234
+
1235
+ },
1236
+ //级联的点击的事件
1237
+ pickerClick(id) {
1238
+ if(this.disableds === false)
1239
+ {
1240
+ if(this.pickerId!==id)
1241
+ {
1242
+ for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1243
+ if (this.formShow.form.formFieldRelation[i].fieldId === id) {
1244
+ console.log(this.formShow.form.formFieldRelation[i].value)
1245
+ this.keyValue=''
1246
+ if(this.formShow.form.formFieldRelation[i].value.length!==undefined)
1247
+ {
1248
+ for (let m=0;m<this.formShow.form.formFieldRelation[i].value.length;m++)
1249
+ {
1250
+ this.keyValue+=this.formShow.form.formFieldRelation[i].value[m]
1251
+ }
1252
+ }
1253
+
1254
+ this.data = this.formShow.form.formFieldRelation[i].formField.extInfo.cascade?this.formShow.form.formFieldRelation[i].formField.extInfo.cascade:this.formShow.form.formFieldRelation[i].formField.extInfo.cascadeDown?this.formShow.form.formFieldRelation[i].formField.extInfo.cascadeDown[0].options:[]
1255
+ this.column[0].values = Object.values(this.data).map(function (e) {
1256
+ return {text: e.value, code: e.value}
1257
+ })
1258
+ if (this.data[0].children !== undefined) {
1259
+ this.column[1].values = Object.values(this.data[0].children).map(function (e) {
1260
+ return {text: e.value, code: e.value}
1261
+ })
1262
+ if (this.data[0].children[0].children !== undefined) {
1263
+ this.column[2].values = Object.values(this.data[0].children[0].children).map(function (e) {
1264
+ return {text: e.value, code: e.value}
1265
+ })
1266
+ }
1267
+ else {
1268
+ this.$set(this.data[0].children[0], 'children', [])
1269
+ this.column[2].values=Object.values(this.data[0].children[0].children).map(function (res) {
1270
+ return {text: res.value, code: res.value};
1271
+ })
1272
+ }
1273
+ }
1274
+ }
1275
+ }
1276
+ }
1277
+
1278
+ this.pickerId = id
1279
+ this.showArea = true
1280
+ }
1281
+
1282
+
1283
+ },
1284
+
1285
+ onChange(picker, values,index) {
1286
+ // 这里我有可能渲染的有问题,导致回调每次都修改了当前列,其他值没有修改,当前列??(当前列什么鬼呀,什么垃圾啊???) 解释一下 ↓↓
1287
+ // 因为vant的 van-picker 回调只会返回你修改的那一列,比如现在为 [北京,北京,东城区],你修改了省为[天津市,天津市,和平区],但是vant的change回调会得到[天津市,北京,东城区],后面两个在回调中没有修改,不知道我的渲染方法有问题还是什么问题。
1288
+ // 所以我在这里判断change事件触发后,如果你修改了省份的话,回调里面省份会改变,但是市和区还是上一个省份的 市和区,这时我们执行回调修改省,市,区的时候,因为回调只有省改变了,市和区DOM改变了,但是回调里面没改变的问题(不晓得什么问题),这时我们去找省下面的 市,我们取回调的市名称,如果在省下面没有找到这个市,默认展示第一个市,区也默认展示第一个市下面的区,如果遍历市能查到,就去展示对应的市。
1289
+ // 回调时修改第2列数据
1290
+ console.log(index)
1291
+ if (index == 0){
1292
+ picker.setColumnValues(2, []); // 防止突然选中第一个,第二个是更新的,但第三个联级不更新,我暂时强制清空
1293
+ }
1294
+ let ColumnIndexss=picker.getIndexes()
1295
+ let getValues=picker.getValues()
1296
+ console.log(getValues)
1297
+ console.log(ColumnIndexss)
1298
+
1299
+ console.log(this.data)
1300
+ let testValue=''
1301
+ this.$nextTick(()=>{
1302
+ if(index == 0)
1303
+ {
1304
+ if(this.data[ColumnIndexss[0]].children.length > 0)
1305
+ {
1306
+ if(this.data[ColumnIndexss[0]].children[0]!==undefined)
1307
+ {
1308
+ testValue=this.data[ColumnIndexss[0]].children[0].value
1309
+ picker.setColumnValues(2, this.county(this.data, testValue));
1310
+ }
1311
+ }
1312
+ else
1313
+ picker.setColumnValues(2, []);
1314
+ }
1315
+ if(index == 1)
1316
+ {
1317
+ if(this.data[ColumnIndexss[0]].children.length > 0)
1318
+ {
1319
+ if(this.data[ColumnIndexss[0]].children[ColumnIndexss[1]]!==undefined)
1320
+ {
1321
+ testValue=this.data[ColumnIndexss[0]].children[ColumnIndexss[1]].value
1322
+ picker.setColumnValues(2, this.county(this.data, testValue));
1323
+ }
1324
+ }
1325
+ else
1326
+ picker.setColumnValues(2, []);
1327
+ }
1328
+ })
1329
+
1330
+ picker.setColumnValues(1, this.cityDate(this.data, values[0].text));
1331
+ // 回调时修改第3列数据
1332
+
1333
+
1334
+ },
1335
+ // 修改级联第二级 这里不再多说什么了根据自己的数据格式来
1336
+ cityDate(data, province) {
1337
+ var that = this;
1338
+ data.forEach(function (res) {
1339
+ if (res.value == province) {
1340
+ that.cityDates = res;
1341
+ }
1342
+ });
1343
+ console.log(that.cityDates.children)
1344
+ if (that.cityDates.children !== undefined&&that.cityDates.children.length > 0) {
1345
+ return that.cityDates.children.map(function (res) {
1346
+ return {text: res.value, code: res.value};
1347
+ })
1348
+ } else {
1349
+ this.$set(that.cityDates, 'children', [])
1350
+ return that.cityDates.children.map(function (res) {
1351
+ return {text: res.value, code: res.value};
1352
+ })
1353
+ }
1354
+ // return 返回数据格式,因为我需要省市区code,所以我return的格式是对象,例:[{text:'北京市',code:'1'},{text:'河南省',code:'2'},...],如果你不需要code直接这样就可以 例['北京市','河南省',.....]
1355
+ },
1356
+ // 修改级联第三级 这里不再多说什么了根据自己的数据格式来
1357
+ county(data, county) {
1358
+ var that = this;
1359
+ var countyDate = '';
1360
+ // 因为vant的 van-picker 回调只会返回你修改的那一列,比如现在为 [北京,北京,东城区],你修改了省为[天津市,天津市,和平区],但是vant的change回调会得到[天津市,北京,东城区],后面两个在回调中没有修改,不知道我的渲染方法有问题还是什么问题。
1361
+ // 所以我在这里判断change事件触发后,如果你修改了省份的话,回调里面省份会改变,但是市和区还是上一个省份的 市和区,这时我们执行回调修改省,市,区的时候,因为回调只有省改变了,市和区DOM改变了,但是回调里面没改变的问题(不晓得什么问题),这时我们去找省下面的 市,我们取回调的市名称,如果在省下面没有找到这个市,默认展示第一个市,区也默认展示第一个市下面的区,如果遍历市能查到,就去展示对应的市。
1362
+ that.cityDates.children.forEach(function (res) {
1363
+ if (res.value == county) {
1364
+ countyDate = res;
1365
+ }
1366
+ });
1367
+ // 这里如果没有找到对应的县
1368
+ if (countyDate == '') {
1369
+ console.log(that.cityDates.children.length)
1370
+ if(that.cityDates.children.length > 0)
1371
+ {
1372
+ countyDate = that.cityDates.children[0];
1373
+ }
1374
+
1375
+ }
1376
+ console.log(countyDate.children)
1377
+ // return
1378
+ if (countyDate.children === undefined) {
1379
+ this.$set(countyDate, 'children', [])
1380
+ return countyDate.children.map(function (res) {
1381
+ return {text: res.value, code: res.value};
1382
+ })
1383
+ } else {
1384
+ return countyDate.children.map(function (res) {
1385
+ return {text: res.value, code: res.value};
1386
+ })
1387
+ }
1388
+
1389
+ // return 返回数据格式,因为我需要省市区code,所以我return的格式是对象,例:[{text:'北京市',code:'1'},{text:'河南省',code:'2'},...],如果你不需要code直接这样就可以 例['北京市','河南省',.....]
1390
+ },
1391
+ //点击级联弹出框的确认按钮
1392
+ onConfirms(val, id) {
1393
+ let test = ''
1394
+ for (let i = 0; i < val.length; i++) {
1395
+ if (val[i] !== undefined) {
1396
+ test += val[i].text + '/'
1397
+ }
1398
+ }
1399
+ test = test.substr(0, test.length - 1)
1400
+ for (let i = 0; i < this.formShow.form.formFieldRelation.length; i++) {
1401
+ if (this.formShow.form.formFieldRelation[i].fieldId=== id) {
1402
+ this.cascadeValue[id] = test
1403
+ for (let j = 0; j < val.length; j++) {
1404
+ if (val[j] !== undefined) {
1405
+ this.formShow.form.formFieldRelation[i].value[j] = val[j].text
1406
+ }
1407
+ }
1408
+ break
1409
+ }
1410
+ }
1411
+ this.showArea = false;
1412
+ sessionStorage.setItem('cascader',test)
1413
+ },
1414
+ onCancel() {
1415
+ this.showArea = false;
1416
+ },
1417
+ aliyunOssRequest(data){
1418
+ console.log("upload request data", data);
1419
+ console.log(this.fileListList)
1420
+
1421
+ this.loading = this.$loading({
1422
+ lock: true,
1423
+ text: 'Loading',
1424
+ spinner: 'el-icon-loading',
1425
+ background: 'rgba(0, 0, 0, 0.8)'
1426
+ });
1427
+ let file = data.file;
1428
+ console.log("upload file:", file);
1429
+ let imgInfo = {
1430
+ status:'',
1431
+ url:'',
1432
+ name:''
1433
+ }
1434
+ /* let imageData = {
1435
+ id:cid,
1436
+ cid:cid,
1437
+ type: "IMAGE",
1438
+ content: {
1439
+ urls: [],
1440
+ progress: 0,
1441
+ },
1442
+ };*/
1443
+ let res = multipartUpload(
1444
+ this.ossConfig,
1445
+ file,
1446
+ null,
1447
+ imgInfo
1448
+ );
1449
+ res.then((res) => {
1450
+ console.log("upload result:", res);
1451
+ // let filePath = res.name;
1452
+ /* imageData.content.progress = 1;
1453
+ imageData.content.urls.push(
1454
+ ossFileUrl(this.ossConfig, res.name)
1455
+ );
1456
+ console.log('imageData',imageData)*/
1457
+ imgInfo.url = ossFileUrl(this.ossConfig, res.name)
1458
+ imgInfo.status='success'
1459
+ if (data.file){
1460
+ imgInfo.name = data.file.name
1461
+ imgInfo.uid = data.file.uid
1462
+ }
1463
+ if (!this.fileListList[this.filedId])
1464
+ {
1465
+ this.fileListList[this.filedId] = []
1466
+ }
1467
+ this.fileListList[this.filedId].push(imgInfo)
1468
+ this.loading.close()
1469
+ }).catch((err) => {
1470
+ console.log("upload err", err);
1471
+ });
1472
+ console.log('fileListList',this.fileListList[this.filedId])
1473
+ console.log('imgInfo',imgInfo)
1474
+ },
1475
+ successUpload(response,file,fileList){
1476
+ console.log('fileList',fileList)
1477
+ if (!this.fileListList[this.filedId]){
1478
+ this.fileListList[this.filedId] = []
1479
+ }
1480
+ for (let i=0;i<fileList.length;i++){
1481
+ if (!this.fileListList[this.filedId][i]){
1482
+ this.fileListList[this.filedId][i]={}
1483
+ }
1484
+ this.fileListList[this.filedId][i].url=fileList[i].url
1485
+ this.fileListList[this.filedId][i].name=fileList[i].name
1486
+ this.fileListList[this.filedId][i].status=fileList[i].status
1487
+ }
1488
+ console.log('successUpload',this.fileListList)
1489
+ },
1490
+ uploadProgress(e,res,response){
1491
+ console.log(e,res,response)
1492
+ this.loading = this.$loading({
1493
+ lock: true,
1494
+ text: 'Loading',
1495
+ spinner: 'el-icon-loading',
1496
+ background: 'rgba(0, 0, 0, 0.7)'
1497
+ });
1498
+ },
1499
+ handleRemove(file,fileList) {
1500
+ console.log(file);
1501
+ console.log(fileList)
1502
+ console.log(this.fileListList)
1503
+ if (this.fileListList[this.filedId]){
1504
+ for (let i=0;i<this.fileListList[this.filedId].length;i++)
1505
+ {
1506
+ if (this.fileListList[this.filedId][i].uid){
1507
+ if (this.fileListList[this.filedId][i].uid===file.uid){
1508
+ this.fileListList[this.filedId].splice(i,1)
1509
+ return
1510
+ }
1511
+ }
1512
+ else if (this.fileListList[this.filedId][i].url===file.url){
1513
+ this.fileListList[this.filedId].splice(i,1)
1514
+ return
1515
+ }
1516
+ }
1517
+
1518
+ }
1519
+ /*let value=[]
1520
+ for (let i=0;i<fileList.length;i++){
1521
+ value[i]={}
1522
+ value[i].name=fileList[i].name
1523
+ if(fileList[i].response){
1524
+ value[i].url=fileList[i].response.data
1525
+ }
1526
+ else {
1527
+ value[i].url=fileList[i].url
1528
+ }
1529
+ }
1530
+ for (let i=0;i<this.formShow.form.formFieldRelation.length;i++){
1531
+ if (this.formShow.form.formFieldRelation[i].fieldId===this.filedId){
1532
+ this.fileListList[this.filedId]=value
1533
+ }
1534
+ }*/
1535
+ /*this.fileListList = [...this.fileListList]*/
1536
+ },
1537
+ handleEditChange(file,fileList){
1538
+ console.log(file)
1539
+ this.hideUploadEdit=fileList.length >= this.limitNum
1540
+ console.log(this.hideUploadEdit)
1541
+ console.log(fileList)
1542
+ },
1543
+
1544
+ onUploadProgress: function (progress, point, file, videoData) {
1545
+ console.debug("upload video progress", progress, point);
1546
+ if (progress === 1) {
1547
+ // this.loadingIns.close();
1548
+ videoData.content.url = ossFileUrl(this.ossConfig, point.name);
1549
+ // this.chooseVideo({data:url},file);
1550
+
1551
+ } else {
1552
+ videoData.content.progress = progress;
1553
+
1554
+ }
1555
+ console.log('1234',videoData)
1556
+ },
1557
+ checkUpload(id,limitNum){
1558
+ this.filedId=id
1559
+ console.log(this.filedId)
1560
+ console.log(limitNum)
1561
+ this.limitNum = limitNum
1562
+
1563
+ },
1564
+ beforeAvatarUpload(file){
1565
+ const isLte2M = file.size / 1024 / 1024 <= 8;
1566
+ const isSupportedFormat =file.type.indexOf('image')!==-1
1567
+ if (!isSupportedFormat){
1568
+ this.$message.error("只能上传图片格式");
1569
+ return false
1570
+ }
1571
+ if (!isLte2M) {
1572
+ this.$message.error("上传图片大小不能超过 8MB!");
1573
+ return false
1574
+ }
1575
+ return true
1576
+ },
1577
+ exceedUpload(){
1578
+ this.$message.warning('上传文件数量达到上限')
1579
+ },
1580
+
1581
+ handlePictureCardPreview(file) {
1582
+ console.log(file)
1583
+ this.videoFlag = true;
1584
+ this.videoUploadPercent = file.percentage.toFixed(0);
1585
+ },
1586
+ },
1587
+ //时间日期范围的点击事件
1588
+ /* dateTimeClick(id){
1589
+ for (let i=0;i<this.formList.form.formFieldRelation.length;i++)
1590
+ {
1591
+ if(this.formList.form.formFieldRelation[i].formField.id===id)
1592
+ {
1593
+ this.dateTimeId=id
1594
+ this.showDateTimePicker = true
1595
+ break
1596
+ }
1597
+ }
1598
+ },
1599
+ dateTimeClick1(id){
1600
+ if(this.dateTimeValue.length === 0)
1601
+ {
1602
+ this.$message.error('请先选择开始日期时间')
1603
+ }
1604
+ else
1605
+ {
1606
+ for (let i=0;i<this.formList.form.formFieldRelation.length;i++)
1607
+ {
1608
+ if(this.formList.form.formFieldRelation[i].formField.id===id)
1609
+ {
1610
+ this.dateTimeId=id
1611
+ this.showDateTimePicker1 = true
1612
+ break
1613
+ }
1614
+ }
1615
+ }
1616
+
1617
+ },*/
1618
+
1619
+
1620
+
1621
+ }
1622
+ </script>
1623
+
1624
+ <style lang="less" scoped>
1625
+ .notClick {
1626
+ pointer-events: none;
1627
+ }
1628
+ .formClass{
1629
+ /* border: 1px solid #ebebeb;*/
1630
+ font-family: "Avenir", Helvetica, Arial, sans-serif;
1631
+ border-radius: 15px;
1632
+ .explain-url{
1633
+ a{
1634
+ color:#4C61E1 ;
1635
+ }
1636
+ }
1637
+ .titleName{
1638
+ font-size: 1em;
1639
+ text-align: center;
1640
+ padding: 10px 0;
1641
+ display: flex;
1642
+ align-items: center;
1643
+ justify-content: center;
1644
+ border-bottom: 1px solid #EEEEEE;
1645
+ }
1646
+ .form-submit-btn{
1647
+ padding: 14px 16px 0 16px;
1648
+ text-align: center;
1649
+ border-top: 1px solid #EEEEEE;
1650
+ }
1651
+ /deep/.ck.ck-toolbar{
1652
+ border-color:#E0E6F7;
1653
+ border-top-left-radius: 5px!important;
1654
+ border-top-right-radius: 5px!important;
1655
+ }
1656
+ /deep/.ck.ck-editor__editable_inline{
1657
+ border-color:#E0E6F7;
1658
+ min-height: 130px!important;
1659
+ border-bottom-left-radius: 5px!important;
1660
+ border-bottom-right-radius: 5px!important;
1661
+ }
1662
+ }
1663
+ .pcFormClass{
1664
+ width: 300px;
1665
+ margin: 0 auto;
1666
+ .field-item{
1667
+ padding: 8px 0;
1668
+ .field-item-name{
1669
+ padding-bottom: 8px;
1670
+ /*color: #A9B3C6;*/
1671
+ color: #000000;
1672
+ }
1673
+ }
1674
+ /deep/.el-upload--picture-card{
1675
+ background-color: #fbfdff;
1676
+ border: 1px dashed #c0ccda;
1677
+ border-radius: 6px;
1678
+ width: 74px;
1679
+ height: 74px;
1680
+ vertical-align: top;
1681
+ cursor: pointer;
1682
+ text-align: center;
1683
+ font-size:28px;
1684
+ color:#8c939d;
1685
+ display: flex;
1686
+ align-items: center;
1687
+ justify-content: center;
1688
+ }
1689
+
1690
+ /deep/.el-upload-list--picture-card{
1691
+ .el-upload-list__item{
1692
+ width: 74px;
1693
+ height: 74px;
1694
+ }
1695
+ }
1696
+ /deep/.el-upload-list__item-name{
1697
+ max-width: 180px;
1698
+ }
1699
+ .hide .el-upload--picture-card {
1700
+ display: none!important;
1701
+ }
1702
+ }
1703
+ /deep/.van-radio__icon--checked .van-icon{
1704
+ background-color: #4C61E1!important;
1705
+ border-color: #4C61E1!important;
1706
+ }
1707
+ /deep/.van-checkbox__icon--checked .van-icon{
1708
+ background-color: #4C61E1!important;
1709
+ border-color: #4C61E1!important;
1710
+ }
1711
+ /deep/.vant-upload--picture-card{
1712
+ background-color: #fbfdff;
1713
+ border: 1px dashed #c0ccda;
1714
+ border-radius: 10px;
1715
+ width: 74px;
1716
+ height: 74px;
1717
+ vertical-align: top;
1718
+ cursor: pointer;
1719
+ text-align: center;
1720
+ font-size:28px;
1721
+ color:#8c939d;
1722
+ display: flex;
1723
+ align-items: center;
1724
+ justify-content: center;
1725
+ }
1726
+ /deep/.van-popup{
1727
+ border-radius: 5px;
1728
+ }
1729
+ .remPhoneClassForm{
1730
+ .mobileFormClass{
1731
+ width: 80vw;
1732
+ .form-field-item{
1733
+ /* border-bottom: 1px solid #ebebeb;*/
1734
+ .form-field-item-value{
1735
+ /deep/.van-cell{
1736
+ flex-direction: column;
1737
+ padding: 8px 16px;
1738
+ }
1739
+ /deep/.van-cell__value{
1740
+ border: 1px solid #E0E6F7;
1741
+ border-radius: 9px;
1742
+ min-height: 40px;
1743
+ padding: 0 10px;
1744
+ }
1745
+ /deep/.van-cell__right-icon{
1746
+ color: #999999!important;
1747
+ }
1748
+ .form-field-item-file{
1749
+ padding: 8px 16px;
1750
+ .fileName{
1751
+ padding-bottom: 8px;
1752
+ /* color: #A9B3C6;*/
1753
+ color: #000000;
1754
+ }
1755
+ }
1756
+ .workorder_description{
1757
+ /* padding: 8px 16px;*/
1758
+ padding: 8px 0;
1759
+ /*font-size: 14px;*/
1760
+ .field-name{
1761
+ width: 100%;
1762
+ text-align: left;
1763
+ /* color: #A9B3C6;*/
1764
+ color: #000000;
1765
+ line-height: 1;
1766
+ padding-bottom: 8px;
1767
+ }
1768
+ /*.required-name{
1769
+ margin-left: -6px;
1770
+ }*/
1771
+
1772
+ /* /deep/.ck-content .image img{
1773
+ max-width: 200px!important;
1774
+ }*/
1775
+ }
1776
+ }
1777
+ .form-field-item-other{
1778
+ /deep/.van-cell{
1779
+ flex-direction: column;
1780
+ }
1781
+ /deep/.van-cell__value{
1782
+ min-height: 40px;
1783
+ }
1784
+ }
1785
+ .explan-ation{
1786
+ .explan-ation-div{
1787
+ display: flex;
1788
+ /* padding: 4px 16px;*/
1789
+ padding: 4px 0;
1790
+ }
1791
+ .explan-ation-p{
1792
+ color: #4C61E1;font-size: 14px;margin: 16px 4px;
1793
+ }
1794
+ }
1795
+ }
1796
+ .upload-phone-demo{
1797
+ /deep/.el-upload--picture-card{
1798
+ background-color: #fbfdff;
1799
+ border: 1px dashed #c0ccda;
1800
+ border-radius: 6px;
1801
+ width: 74px;
1802
+ height: 74px;
1803
+ vertical-align: top;
1804
+ cursor: pointer;
1805
+ text-align: center;
1806
+ font-size:28px;
1807
+ color:#8c939d;
1808
+ display: flex;
1809
+ align-items: center;
1810
+ justify-content: center;
1811
+ }
1812
+ /deep/.el-upload-list--picture-card .el-upload-list__item{
1813
+ height: 76px;
1814
+ width: 76px;
1815
+ }
1816
+ }
1817
+ /deep/.van-image__img{
1818
+ border-radius: 10px;
1819
+ }
1820
+ }
1821
+ .submitClass{
1822
+ width: 120px;
1823
+ background-color: #4C61E1;
1824
+ color: white!important;
1825
+ height: 36px;
1826
+ }
1827
+ /deep/.van-button--info{
1828
+ border:1px solid #4C61E1;
1829
+ }
1830
+ /deep/.van-field__label{
1831
+ width: 100%;
1832
+ text-align: left;
1833
+ /*color: #A9B3C6!important;*/
1834
+ color: #000000!important;
1835
+ display: flex;
1836
+ align-items: center;
1837
+ line-height: 1;
1838
+ padding-bottom: 8px;
1839
+ font-size: 1em;
1840
+ }
1841
+
1842
+ /deep/.van-field__control{
1843
+ min-height: 40px;
1844
+ }
1845
+ /deep/.van-checkbox--horizontal{
1846
+ padding: 0.2rem 0;
1847
+ }
1848
+ /deep/.van-radio--horizontal{
1849
+ padding: 0.2rem 0;
1850
+ }
1851
+ /deep/.van-dropdown-menu__bar{
1852
+ box-shadow: none!important;
1853
+ }
1854
+
1855
+ /deep/.van-overlay{
1856
+ background-color: rgba(0,0,0,.4);
1857
+ }
1858
+
1859
+
1860
+ /deep/.el-input__inner{
1861
+ background-color: transparent!important;
1862
+ }
1863
+
1864
+
1865
+ }
1866
+
1867
+ .remCompanyClassForm{
1868
+ width: 100%;
1869
+ font-size: 1em;
1870
+ .submitClass{
1871
+ width: 120px;
1872
+ color: white!important;
1873
+ background-color:#4C61E1;
1874
+ border-color: #4C61E1;
1875
+ }
1876
+ .el-checkbox{
1877
+ line-height: 2;
1878
+ }
1879
+ .el-radio{
1880
+ padding: 4px 0;
1881
+ }
1882
+ /deep/.el-radio__input.is-checked+.el-radio__label{
1883
+ color: #4C61E1!important;
1884
+ }
1885
+ /deep/.el-radio__input.is-checked .el-radio__inner{
1886
+ color: #4C61E1!important;
1887
+ border-color: #4C61E1!important;
1888
+ background: #4C61E1!important;
1889
+ }
1890
+ /deep/.el-checkbox__input.is-checked+.el-checkbox__label{
1891
+ color: #4C61E1!important;
1892
+ }
1893
+ /deep/.el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner{
1894
+ background-color: #4C61E1!important;
1895
+ border-color: #4C61E1!important;
1896
+ }
1897
+ }
1898
+
2040
1899
  </style>