apply-clients 3.3.77 → 3.3.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,662 +1,683 @@
1
- <template>
2
- <div class="form-horizontal select-overspread">
3
- <validator name='v' @valid="$emit('valid')" @invalid="$emit('invalid')">
4
- <form>
5
- <div v-for="(index,item) in data.fields">
6
- <!--input-->
7
- <div :style="item.style ? item.style : ''"
8
- v-if="(item.type==='input' || item.type==='number'||item.type === 'tel'||item.type === 'email') && !item.hidden && (item.device === 'app' || !item.device)&& (item.label !== '证件号码')&&(item.label !== '身份证') && (item.label !== '用户电话')"
9
- :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
10
- <label class="control-label-justify">{{item.label}}</label>
11
- <div :style="item.value_style ? item.value_style:''"
12
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
13
- <input class="" style="width: 100%"
14
- :type="item.type"
15
- v-model="data.fields[index].value"
16
- :placeholder="item.placeholder"
17
- :value="data.fields[index].value"
18
- :readonly="item.readonly"
19
- :disabled="item.disabled"
20
- @change="onchange(index)"
21
- @blur="onblur(index)"
22
- @input="oninput(index)"
23
- />
24
- </div>
25
- </div>
26
-
27
- <!--input身份证验证-->
28
- <div :style="item.style ? item.style : ''"
29
- v-if="(item.label==='身份证') || (data.f_credentials === '身份证' && item.label === '证件号码')"
30
- :class="[$v.f_idnumber2.identityCardValid ? 'apply-has-error' : '',item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
31
- <label class="control-label-justify">{{item.label}}</label>
32
- <div :style="item.value_style ? item.value_style:''"
33
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
34
- <input class="" style="width: 100%"
35
- :type="item.type"
36
- maxlength="18"
37
- v-model="data.fields[index].value"
38
- :placeholder="item.placeholder"
39
- :value="data.fields[index].value"
40
- onKeypress="return(/[\d\.]/.test(String.fromCharCode(event.keyCode)))"
41
- :readonly="item.readonly"
42
- v-validate:f_idnumber2='{identityCardValid: true}'
43
- @change="onchange(index)"
44
- @blur="onblur(index)"
45
- @input="oninput(index)"
46
- />
47
- </div>
48
- </div>
49
-
50
-
51
- <!--input手机号验证-->
52
- <div :style="item.style ? item.style : ''"
53
- v-if="item.label === '用户电话'"
54
- :class="[$v.f_user_phone.minlength || $v.f_user_phone.maxlength ? 'apply-has-error' : '',item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
55
- <label class="control-label-justify">{{item.label}}</label>
56
- <div :style="item.value_style ? item.value_style:''"
57
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
58
- <input class="" style="width: 100%"
59
- maxlength="18"
60
- type="number"
61
- onKeypress="return(/[\d\.]/.test(String.fromCharCode(event.keyCode)))"
62
- oninput="if(value.length > 11) value=value.slice(0,11)"
63
- v-validate:f_user_phone="{minlength: 11, maxlength: 11 }"
64
- v-model="data.fields[index].value"
65
- :placeholder="item.placeholder"
66
- :value="data.fields[index].value"
67
- :readonly="item.readonly"
68
- @change="onchange(index)"
69
- @blur="onblur(index)"
70
- @input="oninput(index)"
71
- />
72
- </div>
73
- </div>
74
-
75
- <!--select-->
76
- <div :style="item.style ? item.style : ''"
77
- v-if="item.type==='select' && !item.hidden && (item.device === 'app' || !item.device)"
78
- :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
79
- <label class="control-label-justify">{{item.label}}</label>
80
- <div :style="item.value_style ? item.value_style:''"
81
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
82
- <v-select
83
- class="select" width="100%" align="right"
84
- :placeholder="item.placeholder"
85
- :search="item.search"
86
- close-on-select value-single
87
- @select-search="selectSearch($arguments,index)"
88
- :options="data.fields[index].options"
89
- v-model="data.fields[index].value"
90
- :value.sync="data.fields[index].value"
91
- @blur="onblur(index)"
92
- @change="onchange(index)"
93
- :readonly="item.readonly"
94
- :disabled="item.disabled"
95
- ></v-select>
96
- </div>
97
- </div>
98
-
99
- <!--时间datepicker-->
100
- <div :style="item.style ? item.style : ''"
101
- v-if="item.type==='datepicker' && !item.hidden && (item.device === 'app' || !item.device)"
102
- :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped ? item.bootstraped+' form-group app-input':'col-xs-12 form-group app-input']">
103
- <label class="control-label-justify">{{item.label}}</label>
104
- <div class="form-group" :style="item.value_style ? item.value_style:''"
105
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
106
- <datepicker
107
- @change="onchange(index)"
108
- @blur="onblur(index)"
109
- :placeholder="item.placeholder"
110
- :value.sync="data.fields[index].value"
111
- :format="item.format ? item.format : 'yyyy-MM-dd'"
112
- v-model="data.fields[index].value"
113
- :readonly="item.readonly"
114
- :disabled="item.disabled"
115
- :show-reset-button="true">
116
- </datepicker>
117
- </div>
118
- </div>
119
-
120
- <!--textarea-->
121
- <div :style="item.style ? item.style : ''"
122
- v-if="item.type==='textarea' && !item.hidden && (item.device === 'app' || !item.device)"
123
- :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped?item.bootstraped+' form-group app-input':'col-xs-12 form-group app-input']">
124
- <label class="control-label-justify">{{item.label}}</label>
125
- <div :style="item.value_style ? item.value_style:''"
126
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
127
- <textarea
128
- :readonly="item.readonly"
129
- :disabled="item.disabled"
130
- class="" rows="1"
131
- style="width: 100%;height: 100%"
132
- v-model="data.fields[index].value"
133
- :value="data.fields[index].value"
134
- @change="onchange(index)"
135
- @blur="onblur(index)"
136
- @input="oninput(index)"
137
- ></textarea>
138
- </div>
139
- </div>
140
-
141
- <!--checkbox-->
142
- <div :style="item.style ? item.style : ''"
143
- v-if="item.type==='checkbox' && !item.hidden && (item.device === 'app' || !item.device)"
144
- :class="[item.required && item.value.length === 0 ? 'apply-has-error' : '',item.bootstraped?item.bootstraped+' form-group app-input':'col-xs-12 form-group app-input']">
145
- <label class="control-label-justify">{{item.label}}</label>
146
- <div :style="item.value_style ? item.value_style:''"
147
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
148
- <label class="" v-for="(index2,row) in item.options">
149
- <input type="checkbox" class=""
150
- :readonly="data.fields[index].readonly"
151
- :disabled="data.fields[index].disabled"
152
- v-model="data.fields[index].value"
153
- :value="data.fields[index].options[index2].value"
154
- @change="onchange(index)"
155
- @blur="onblur(index)">
156
- {{row.label}}
157
- </label>
158
- </div>
159
- </div>
160
- </div>
161
-
162
- <div class="col-sm-12 col-xs-12" id="test11">
163
- <accordion one-at-a-time="true">
164
- <panel v-for="(i,item) in data.onetomany" :header="item.title" :is-open="false" type="primary">
165
- <app-onetomany :onetomany="item" :index="i"></app-onetomany>
166
- </panel>
167
- <panel v-for="(i,item) in data.components" :header="item.title" :is-open="false" type="primary" v-if="item.device === 'app' || !item.device">
168
- <component :is="item.name" :selectdata="data" :mark="item.mark"></component>
169
- </panel>
170
- </accordion>
171
- </div>
172
-
173
- <!--自定义组件-->
174
- <slot></slot>
175
-
176
- <!-- 按钮组 -->
177
- <div class="text-center">
178
- <button v-for="(index,button) in data.buttons"
179
- :disabled="button.disabled && disable_button"
180
- style="min-width:100px"
181
- :class="button.disabled && disable_button ? 'btn btn-default button_spacing' : 'btn btn-primary button_spacing'"
182
- v-if="!button.hidden && button.button_name !=='提交'&& button.button_name !=='确认'"
183
- @click.prevent="click_but(button)"
184
- >
185
- {{button.button_name}}
186
- </button>
187
- <button v-for="(index,button) in data.buttons"
188
- :disabled="(button.disabled && disable_button) || (!$v.valid)"
189
- style="min-width:100px"
190
- :class="button.disabled && disable_button || (!$v.valid) ? 'btn btn-default button_spacing' : 'btn btn-primary button_spacing'"
191
- v-if="!button.hidden && (button.button_name ==='提交'||button.button_name ==='确认')"
192
- @click.prevent="click_but(button)"
193
- >
194
- {{button.button_name}}
195
- </button>
196
- </div>
197
-
198
- <!-- 按钮模态框 -->
199
- <modal v-if="showButModal" :show.sync="showButModal" backdrop="false" large>
200
- <header slot="modal-header" class="modal-header">
201
- <button type="button" class="close" @click="closeModal()"><span>&times;</span></button>
202
- <span class="modal-title"><font
203
- size="3">{{data.button.button_name}}</font></span>
204
- </header>
205
- <article slot="modal-body" class="modal-body clearfix">
206
- <div class="form-group" >
207
- <div v-for="(index,item) in data.button.button_fields">
208
- <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group' : 'form-group']"
209
- v-if="(item.type==='input' || item.type==='number'||item.type === 'tel'||item.type === 'email') && !item.hidden && (item.device === 'pc' || !item.device)">
210
- <label :style="item.label_style ? item.label_style : ''"
211
- :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label'">{{item.label}}</label>
212
- <div :style="item.value_style ? item.value_style : ''"
213
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
214
- <input class="form-control input_view"
215
- :placeholder="item.placeholder"
216
- :type="item.type"
217
- v-model="item.value"
218
- :value="item.value"
219
- :readonly="item.readonly"
220
- :disabled="item.disabled"
221
- @change="onbutchange(index)"
222
- @blur="onbutblur(index)"
223
- @input="onbutinput(index)"
224
- />
225
- </div>
226
- </div>
227
-
228
- <!--时间datepicker-->
229
- <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
230
- v-if="item.type==='datepicker' && !item.hidden && (item.device === 'pc' || !item.device)">
231
- <label :style="item.label_style ? item.label_style : ''"
232
- :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label'">{{item.label}}</label>
233
- <div :style="item.value_style ? item.value_style : ''"
234
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
235
- <datepicker
236
- :placeholder="item.placeholder"
237
- :value.sync="item.value"
238
- v-model="item.value"
239
- :readonly="item.readonly"
240
- :disabled="item.disabled"
241
- :format="item.format ? item.format : 'yyyy-MM-dd'"
242
- :show-reset-button="true"
243
- @change="onbutchange(index)"
244
- @blur="onbutblur(index)"
245
- ></datepicker>
246
- </div>
247
- </div>
248
-
249
- <!--select-->
250
- <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
251
- v-if="item.type==='select' && !item.hidden && (item.device === 'pc' || !item.device)">
252
- <label :style="item.label_style ? item.label_style : ''"
253
- :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label'">{{item.label}}</label>
254
- <div :style="item.value_style ? item.value_style : ''"
255
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
256
- <input-select
257
- class="select select_list"
258
- :value.sync="item.value"
259
- v-model="item.value"
260
- :options='item.options'
261
- :readonly="item.readonly"
262
- :disable="item.disabled"
263
- :valueSingle="true"
264
- @blur="onbutblur(index)"
265
- @change="onbutchange(index)"
266
- ></input-select>
267
- </div>
268
- </div>
269
-
270
- <!--textarea-->
271
- <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
272
- v-if="item.type==='textarea' && !item.hidden && (item.device === 'pc' || !item.device)">
273
- <label :style="item.label_style ? item.label_style : ''"
274
- :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label'">{{item.label}}</label>
275
- <div :style="item.value_style ? item.value_style : ''"
276
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
277
- <textarea
278
- class="form-control input_view"
279
- style="width: 100%;height: 100%"
280
- v-model="item.value"
281
- :value="item.value"
282
- :rows="item.rows"
283
- :readonly="item.readonly"
284
- :disabled="item.disabled"
285
- @change="onbutchange(index)"
286
- @blur="onbutblur(index)"
287
- @input="onbutinput(index)"
288
- ></textarea>
289
- </div>
290
- </div>
291
- </div>
292
- </div>
293
- </article>
294
- <footer slot="modal-footer" class="modal-footer">
295
- <button :class="disable_modal_button ? 'btn btn-default':'btn btn-primary'"
296
- :disabled="disable_modal_button" type="button" @click="confirmModal()">
297
- 确认
298
- </button>
299
- </footer>
300
- </modal>
301
- </form>>
302
- </div>
303
- </template>
304
- <script>
305
- import Vue from 'vue'
306
- import {isEmpty} from "../Util";
307
- // Date格式化
308
- Date.prototype.Format = function (fmt) {
309
- var o = {
310
- 'M+': this.getMonth() + 1, // 月份
311
- 'd+': this.getDate(), // 日
312
- 'H+': this.getHours(), // 小时
313
- 'm+': this.getMinutes(), // 分
314
- 's+': this.getSeconds(), // 秒
315
- 'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
316
- 'S': this.getMilliseconds() // 毫秒
317
- }
318
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
319
- for (var k in o) {
320
- if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
321
- }
322
- return fmt
323
- }
324
-
325
- export default {
326
- title: '报建业务通用组件',
327
- props: {
328
- data: {
329
- type: Object
330
- },
331
- showprint: {
332
- type: Boolean,
333
- default: true
334
- }
335
- },
336
- data () {
337
- return {
338
- model: {}, // 公司等属性
339
- disable_button: true, // 控制按钮禁用
340
- disable_modal_button: true, // 控制按钮禁用
341
- showButModal: false
342
- }
343
- },
344
- watch: {
345
- deep: true
346
- },
347
- computed: {
348
-
349
- },
350
- created () {
351
- // 初始化数据
352
- this.initializtion()
353
- if (this.data.readyEvent) {
354
- this.$dispatch(this.data.readyEvent)
355
- }
356
- this.$dispatch('initializtionView')
357
- },
358
- methods: {
359
- // 初始化数据
360
- initializtion () {
361
- for (const item of this.data.fields) {
362
- this.data[item.field] = item.value
363
- }
364
- // 是否禁用按钮
365
- this.disableButton()
366
- },
367
- // 是否禁用按钮
368
- disableButton () {
369
- let flag = false
370
-
371
- for (const field of this.data.fields) {
372
- if (field.required && !field.value && !field.hidden && field.value !== 0) {
373
- flag = true
374
- }
375
-
376
- // 任何选择框只要是否都不能提交
377
- if (field.type === 'select' && field.value === '否' && field.value_no_disable) {
378
- flag = true
379
- }
380
-
381
- if (field.type === 'checkbox' && field.required && field.value.length === 0) {
382
- flag = true
383
- }
384
- }
385
-
386
- this.disable_button = flag
387
- },
388
- // 失去焦点且值最终发生变化触发
389
- async onchange (index) {
390
- // 是否禁用按钮
391
- this.disableButton()
392
-
393
- if (!isEmpty(this.data.fields[index].value)) {
394
- // 前缀、后缀
395
- if (this.data.fields[index].prefix) {
396
- this.data.fields[index].value = this.data.fields[index].prefix + this.data.fields[index].value
397
- }
398
- if (this.data.fields[index].suffix) {
399
- this.data.fields[index].value = this.data.fields[index].value + this.data.fields[index].suffix
400
- }
401
- }
402
-
403
- // data赋值
404
- this.data[this.data.fields[index].field] = this.data.fields[index].value
405
-
406
- if (this.data.fields[index].type === 'datepicker') {
407
- this.check_datepicker(index)
408
- }
409
-
410
- if (this.data.fields[index].onchange) {
411
- this.$dispatch(this.data.fields[index].onchange, index)
412
- }
413
- this.$dispatch('onchange', index)
414
-
415
-
416
- },
417
- // 失去焦点触发,无论值是否发生变化
418
- onblur (index) {
419
- this.disableButton()
420
-
421
- if (this.data.fields[index].onblur) {
422
- this.$dispatch(this.data.fields[index].onblur, index)
423
- }
424
-
425
- this.$dispatch('onblur', index)
426
- },
427
- oninput (index) {
428
- // 是否禁用按钮
429
- this.disableButton()
430
-
431
- if (this.data.fields[index].oninput) {
432
- this.$dispatch(this.data.fields[index].oninput, index)
433
- }
434
- this.$dispatch('oninput', index)
435
- },
436
- // 点击按钮组按钮
437
- async click_but (button) {
438
- if (this.data.defname === '通气点火') {
439
-
440
- this.$showMessage(`请确认表号是否正确`).then((res) => {
441
-
442
-
443
- this.disable_button = true
444
-
445
- this.data.fields.forEach(item => {
446
- this.data[item.field] = item.value
447
- })
448
-
449
- this.data.button = button
450
-
451
- if (button.button_fields && button.button_fields.length > 0) {
452
- this.showButModal = true
453
- return
454
- }
455
-
456
- if (this.data.button.event) {
457
- this.$dispatch(this.data.button.event)
458
- } else {
459
- this.$dispatch('button')
460
- }
461
-
462
- })
463
-
464
- }
465
- else{
466
- this.disable_button = true
467
-
468
- this.data.fields.forEach(item => {
469
- this.data[item.field] = item.value
470
- })
471
-
472
- this.data.button = button
473
-
474
- if (button.button_fields && button.button_fields.length > 0) {
475
- this.showButModal = true
476
- return
477
- }
478
-
479
- if (this.data.button.event) {
480
- this.$dispatch(this.data.button.event)
481
- } else {
482
- this.$dispatch('button')
483
- }
484
- }
485
- },
486
- confirmModal () {
487
- this.closeModal()
488
-
489
- this.data.button.button_fields.forEach(item => {
490
- this.data.button[item.field] = item.value
491
- })
492
-
493
- if (this.data.button.event) {
494
- this.$dispatch(this.data.button.event)
495
- } else {
496
- this.$dispatch('button')
497
- }
498
- },
499
- // 关闭模态框
500
- closeModal () {
501
- this.showButModal = false
502
- this.disable_modal_button = true
503
- },
504
- onbutchange (index) {
505
- // 是否禁用按钮
506
- this.disableModalButton()
507
-
508
- if (this.data.button.button_fields[index].onchange) {
509
- this.$dispatch(this.data.button.button_fields[index].onchange, index)
510
- } else {
511
- this.$dispatch('onbutchange', index)
512
- }
513
-
514
- },
515
- onbutblur (index) {
516
- this.disableModalButton()
517
-
518
- if (this.data.button.button_fields[index].onblur) {
519
- this.$dispatch(this.data.button.button_fields[index].onblur, index)
520
- } else {
521
- this.$dispatch('onbutblur', index)
522
- }
523
- },
524
- onbutinput (index) {
525
- // 是否禁用按钮
526
- this.disableModalButton()
527
-
528
- if (this.data.button.button_fields[index].oninput) {
529
- this.$dispatch(this.data.button.button_fields[index].oninput, index)
530
- } else {
531
- this.$dispatch('onbutinput', index)
532
- }
533
- },
534
- disableModalButton () {
535
- let flag = false
536
-
537
-
538
- for (const item of this.data.button.button_fields) {
539
- if (item.required && !item.value) {
540
- if (item.value === 0) {
541
- flag = false
542
- } else {
543
- flag = true
544
- }
545
- }
546
- }
547
-
548
- this.disable_modal_button = flag
549
- },
550
- check_datepicker (index) {
551
- // 时间格式检测
552
- if (!isEmpty(this.data.fields[index].value)) {
553
-
554
- let dateReg = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/
555
- let timeReg = /^(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/
556
- let datetimeReg = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/
557
- if (this.data.fields[index].format) {
558
- if (this.data.fields[index].format === 'yyyy-MM-dd') {
559
- if (!dateReg.test(this.data.fields[index].value)) {
560
- this.data.fields[index].value = ''
561
- this.$showAlert(this.data.fields[index].label + '格式错误如:2021-01-01', 'warning', 2000)
562
- }
563
- }
564
- if (this.data.fields[index].format === 'HH:mm:ss') {
565
- if (!timeReg.test(this.data.fields[index].value)) {
566
- this.data.fields[index].value = ''
567
- this.$showAlert(this.data.fields[index].label + '格式错误如:00:00:00', 'warning', 2000)
568
- }
569
- }
570
- if (this.data.fields[index].format === 'yyyy-MM-dd HH:mm:ss') {
571
- if (!datetimeReg.test(this.data.fields[index].value)) {
572
- this.data.fields[index].value = ''
573
- this.$showAlert(this.data.fields[index].label + '格式错误如:2021-01-01 00:00:00', 'warning', 2000)
574
- }
575
- }
576
- } else {
577
- if (!dateReg.test(this.data.fields[index].value)) {
578
- this.data.fields[index].value = ''
579
- this.$showAlert(this.data.fields[index].label + '格式错误如:2021-01-01', 'warning', 2000)
580
- }
581
- }
582
- }
583
- },
584
- selectSearch(event, index) {
585
- if (this.data.fields[index].selectSearch) {
586
- this.$dispatch(this.data.fields[index].selectSearch, event[0], index)
587
- }
588
- this.$dispatch('selectSearch', event[0], index)
589
- }
590
- },
591
- events: {
592
- }
593
- }
594
- </script>
595
- <style scoped>
596
- .control-label-justify {
597
- width: 30%;
598
- text-align: justify;
599
- text-align-last: justify;
600
- font-family: PingFang-SC-Bold;
601
- float: left;
602
- }
603
- .button_spacing{margin: 0px 0px 0px 10px;}
604
- </style>
605
- <style lang="less">
606
- .apply-has-error {
607
- border-bottom: 1px solid #a94442;
608
- }
609
- .app-input {
610
- label {
611
- float: left;
612
- }
613
- .select {
614
- button {
615
- border: none;
616
- outline: none;
617
- text-align: left;
618
- .btn-placeholder {
619
- color: #ACA899
620
- }
621
- }
622
- }
623
- .datepicker {
624
- .form-control:focus {
625
- border: none!important;
626
- outline: none!important;
627
- -webkit-box-shadow: none;
628
- box-shadow: none;
629
- }
630
- }
631
- textarea {
632
- padding: 8px 10px;
633
- border: none;
634
- outline: none;
635
- margin: 0px;
636
- }
637
- input[readonly]{
638
- color: #ACA899!important;
639
- background: #FFFFFF;
640
- border: none;
641
- outline: none;
642
- }
643
- input:disabled{
644
- color: #ACA899!important;
645
- background: #FFFFFF;
646
- border: none;
647
- outline: none;
648
- }
649
- textarea[readonly]{
650
- color: #ACA899!important;
651
- background: #FFFFFF;
652
- border: none;
653
- outline: none;
654
- }
655
- textarea:disabled{
656
- color: #ACA899!important;
657
- background: #FFFFFF;
658
- border: none;
659
- outline: none;
660
- }
661
- }
662
- </style>
1
+ <template>
2
+ <div class="form-horizontal select-overspread">
3
+ <validator name='v' @valid="$emit('valid')" @invalid="$emit('invalid')">
4
+ <form>
5
+ <div v-for="(index,item) in data.fields">
6
+ <!--input-->
7
+ <div :style="item.style ? item.style : ''"
8
+ v-if="(item.type==='input' || item.type==='number'||item.type === 'tel'||item.type === 'email') && !item.hidden && (item.device === 'app' || !item.device) && (item.label != '证件号码')&&(item.label != '身份证') && (item.label != '用户电话')"
9
+ :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
10
+ <label class="control-label-justify">{{item.label}}</label>
11
+ <div :style="item.value_style ? item.value_style:''"
12
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
13
+ <input class="" style="width: 100%"
14
+ :type="item.type"
15
+ v-model="data.fields[index].value"
16
+ :placeholder="item.placeholder"
17
+ :value="data.fields[index].value"
18
+ :readonly="item.readonly"
19
+ :disabled="item.disabled"
20
+ @change="onchange(index)"
21
+ @blur="onblur(index)"
22
+ @input="oninput(index)"
23
+ />
24
+ </div>
25
+ </div>
26
+
27
+ <div :style="item.style ? item.style : ''"
28
+ v-if="(data.fields[index-1].value ==='营业执照'||data.fields[index-1].value ==='军官证')&& (item.label === '证件号码')"
29
+ :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
30
+ <label class="control-label-justify">{{item.label}}</label>
31
+ <div :style="item.value_style ? item.value_style:''"
32
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
33
+ <input class="" style="width: 100%"
34
+ :type="item.type"
35
+ v-model="data.fields[index].value"
36
+ :placeholder="item.placeholder"
37
+ :value="data.fields[index].value"
38
+ :readonly="item.readonly"
39
+ :disabled="item.disabled"
40
+ @change="onchange(index)"
41
+ @blur="onblur(index)"
42
+ @input="oninput(index)"
43
+ />
44
+ </div>
45
+ </div>
46
+
47
+
48
+ <!--input身份证验证-->
49
+ <div :style="item.style ? item.style : ''"
50
+ v-if="(item.label==='身份证') || (item.label === '证件号码' && data.fields[index-1].value ==='身份证')"
51
+ :class="[$v.f_idnumber2.identityCardValid ? 'apply-has-error' : '',item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
52
+ <label class="control-label-justify">{{item.label}}</label>
53
+ <div :style="item.value_style ? item.value_style:''"
54
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
55
+ <input class="" style="width: 100%"
56
+ :type="item.type"
57
+ maxlength="18"
58
+ v-model="data.fields[index].value"
59
+ :placeholder="item.placeholder"
60
+ :value="data.fields[index].value"
61
+ onKeypress="return(/[\d\.]/.test(String.fromCharCode(event.keyCode)))"
62
+ :readonly="item.readonly"
63
+ v-validate:f_idnumber2='{identityCardValid: true}'
64
+ @change="onchange(index)"
65
+ @blur="onblur(index)"
66
+ @input="oninput(index)"
67
+ />
68
+ </div>
69
+ </div>
70
+
71
+
72
+ <!--input手机号验证-->
73
+ <div :style="item.style ? item.style : ''"
74
+ v-if="item.label === '用户电话'"
75
+ :class="[$v.f_user_phone.minlength || $v.f_user_phone.maxlength ? 'apply-has-error' : '',item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
76
+ <label class="control-label-justify">{{item.label}}</label>
77
+ <div :style="item.value_style ? item.value_style:''"
78
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
79
+ <input class="" style="width: 100%"
80
+ maxlength="18"
81
+ type="number"
82
+ onKeypress="return(/[\d\.]/.test(String.fromCharCode(event.keyCode)))"
83
+ oninput="if(value.length > 11) value=value.slice(0,11)"
84
+ v-validate:f_user_phone="{minlength: 7, maxlength: 11 }"
85
+ v-model="data.fields[index].value"
86
+ :placeholder="item.placeholder"
87
+ :value="data.fields[index].value"
88
+ :readonly="item.readonly"
89
+ @change="onchange(index)"
90
+ @blur="onblur(index)"
91
+ @input="oninput(index)"
92
+ />
93
+ </div>
94
+ </div>
95
+
96
+ <!--select-->
97
+ <div :style="item.style ? item.style : ''"
98
+ v-if="item.type==='select' && !item.hidden && (item.device === 'app' || !item.device)"
99
+ :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped ? item.bootstraped + ' form-group app-input':'col-xs-12 form-group app-input']">
100
+ <label class="control-label-justify">{{item.label}}</label>
101
+ <div :style="item.value_style ? item.value_style:''"
102
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
103
+ <v-select
104
+ class="select" width="100%" align="right"
105
+ :placeholder="item.placeholder"
106
+ :search="item.search"
107
+ close-on-select value-single
108
+ @select-search="selectSearch($arguments,index)"
109
+ :options="data.fields[index].options"
110
+ v-model="data.fields[index].value"
111
+ :value.sync="data.fields[index].value"
112
+ @blur="onblur(index)"
113
+ @change="onchange(index)"
114
+ :readonly="item.readonly"
115
+ :disabled="item.disabled"
116
+ ></v-select>
117
+ </div>
118
+ </div>
119
+
120
+ <!--时间datepicker-->
121
+ <div :style="item.style ? item.style : ''"
122
+ v-if="item.type==='datepicker' && !item.hidden && (item.device === 'app' || !item.device)"
123
+ :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped ? item.bootstraped+' form-group app-input':'col-xs-12 form-group app-input']">
124
+ <label class="control-label-justify">{{item.label}}</label>
125
+ <div class="form-group" :style="item.value_style ? item.value_style:''"
126
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
127
+ <datepicker
128
+ @change="onchange(index)"
129
+ @blur="onblur(index)"
130
+ :placeholder="item.placeholder"
131
+ :value.sync="data.fields[index].value"
132
+ :format="item.format ? item.format : 'yyyy-MM-dd'"
133
+ v-model="data.fields[index].value"
134
+ :readonly="item.readonly"
135
+ :disabled="item.disabled"
136
+ :show-reset-button="true">
137
+ </datepicker>
138
+ </div>
139
+ </div>
140
+
141
+ <!--textarea-->
142
+ <div :style="item.style ? item.style : ''"
143
+ v-if="item.type==='textarea' && !item.hidden && (item.device === 'app' || !item.device)"
144
+ :class="[item.required && !(item.value) ? 'apply-has-error' : '', item.bootstraped?item.bootstraped+' form-group app-input':'col-xs-12 form-group app-input']">
145
+ <label class="control-label-justify">{{item.label}}</label>
146
+ <div :style="item.value_style ? item.value_style:''"
147
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
148
+ <textarea
149
+ :readonly="item.readonly"
150
+ :disabled="item.disabled"
151
+ class="" rows="1"
152
+ style="width: 100%;height: 100%"
153
+ v-model="data.fields[index].value"
154
+ :value="data.fields[index].value"
155
+ @change="onchange(index)"
156
+ @blur="onblur(index)"
157
+ @input="oninput(index)"
158
+ ></textarea>
159
+ </div>
160
+ </div>
161
+
162
+ <!--checkbox-->
163
+ <div :style="item.style ? item.style : ''"
164
+ v-if="item.type==='checkbox' && !item.hidden && (item.device === 'app' || !item.device)"
165
+ :class="[item.required && item.value.length === 0 ? 'apply-has-error' : '',item.bootstraped?item.bootstraped+' form-group app-input':'col-xs-12 form-group app-input']">
166
+ <label class="control-label-justify">{{item.label}}</label>
167
+ <div :style="item.value_style ? item.value_style:''"
168
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
169
+ <label class="" v-for="(index2,row) in item.options">
170
+ <input type="checkbox" class=""
171
+ :readonly="data.fields[index].readonly"
172
+ :disabled="data.fields[index].disabled"
173
+ v-model="data.fields[index].value"
174
+ :value="data.fields[index].options[index2].value"
175
+ @change="onchange(index)"
176
+ @blur="onblur(index)">
177
+ {{row.label}}
178
+ </label>
179
+ </div>
180
+ </div>
181
+ </div>
182
+
183
+ <div class="col-sm-12 col-xs-12" id="test11">
184
+ <accordion one-at-a-time="true">
185
+ <panel v-for="(i,item) in data.onetomany" :header="item.title" :is-open="false" type="primary">
186
+ <app-onetomany :onetomany="item" :index="i"></app-onetomany>
187
+ </panel>
188
+ <panel v-for="(i,item) in data.components" :header="item.title" :is-open="false" type="primary" v-if="item.device === 'app' || !item.device">
189
+ <component :is="item.name" :selectdata="data" :mark="item.mark"></component>
190
+ </panel>
191
+ </accordion>
192
+ </div>
193
+
194
+ <!--自定义组件-->
195
+ <slot></slot>
196
+
197
+ <!-- 按钮组 -->
198
+ <div class="text-center">
199
+ <button v-for="(index,button) in data.buttons"
200
+ :disabled="button.disabled && disable_button"
201
+ style="min-width:100px"
202
+ :class="button.disabled && disable_button ? 'btn btn-default button_spacing' : 'btn btn-primary button_spacing'"
203
+ v-if="!button.hidden && button.button_name !=='提交'&& button.button_name !=='确认'"
204
+ @click.prevent="click_but(button)"
205
+ >
206
+ {{button.button_name}}
207
+ </button>
208
+ <button v-for="(index,button) in data.buttons"
209
+ :disabled="(button.disabled && disable_button) || (!$v.valid)"
210
+ style="min-width:100px"
211
+ :class="button.disabled && disable_button || (!$v.valid) ? 'btn btn-default button_spacing' : 'btn btn-primary button_spacing'"
212
+ v-if="!button.hidden && (button.button_name ==='提交'||button.button_name ==='确认')"
213
+ @click.prevent="click_but(button)"
214
+ >
215
+ {{button.button_name}}
216
+ </button>
217
+ </div>
218
+
219
+ <!-- 按钮模态框 -->
220
+ <modal v-if="showButModal" :show.sync="showButModal" backdrop="false" large>
221
+ <header slot="modal-header" class="modal-header">
222
+ <button type="button" class="close" @click="closeModal()"><span>&times;</span></button>
223
+ <span class="modal-title"><font
224
+ size="3">{{data.button.button_name}}</font></span>
225
+ </header>
226
+ <article slot="modal-body" class="modal-body clearfix">
227
+ <div class="form-group" >
228
+ <div v-for="(index,item) in data.button.button_fields">
229
+ <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group' : 'form-group']"
230
+ v-if="(item.type==='input' || item.type==='number'||item.type === 'tel'||item.type === 'email') && !item.hidden && (item.device === 'pc' || !item.device)">
231
+ <label :style="item.label_style ? item.label_style : ''"
232
+ :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label'">{{item.label}}</label>
233
+ <div :style="item.value_style ? item.value_style : ''"
234
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
235
+ <input class="form-control input_view"
236
+ :placeholder="item.placeholder"
237
+ :type="item.type"
238
+ v-model="item.value"
239
+ :value="item.value"
240
+ :readonly="item.readonly"
241
+ :disabled="item.disabled"
242
+ @change="onbutchange(index)"
243
+ @blur="onbutblur(index)"
244
+ @input="onbutinput(index)"
245
+ />
246
+ </div>
247
+ </div>
248
+
249
+ <!--时间datepicker-->
250
+ <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
251
+ v-if="item.type==='datepicker' && !item.hidden && (item.device === 'pc' || !item.device)">
252
+ <label :style="item.label_style ? item.label_style : ''"
253
+ :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label'">{{item.label}}</label>
254
+ <div :style="item.value_style ? item.value_style : ''"
255
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
256
+ <datepicker
257
+ :placeholder="item.placeholder"
258
+ :value.sync="item.value"
259
+ v-model="item.value"
260
+ :readonly="item.readonly"
261
+ :disabled="item.disabled"
262
+ :format="item.format ? item.format : 'yyyy-MM-dd'"
263
+ :show-reset-button="true"
264
+ @change="onbutchange(index)"
265
+ @blur="onbutblur(index)"
266
+ ></datepicker>
267
+ </div>
268
+ </div>
269
+
270
+ <!--select-->
271
+ <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
272
+ v-if="item.type==='select' && !item.hidden && (item.device === 'pc' || !item.device)">
273
+ <label :style="item.label_style ? item.label_style : ''"
274
+ :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label'">{{item.label}}</label>
275
+ <div :style="item.value_style ? item.value_style : ''"
276
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
277
+ <input-select
278
+ class="select select_list"
279
+ :value.sync="item.value"
280
+ v-model="item.value"
281
+ :options='item.options'
282
+ :readonly="item.readonly"
283
+ :disable="item.disabled"
284
+ :valueSingle="true"
285
+ @blur="onbutblur(index)"
286
+ @change="onbutchange(index)"
287
+ ></input-select>
288
+ </div>
289
+ </div>
290
+
291
+ <!--textarea-->
292
+ <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
293
+ v-if="item.type==='textarea' && !item.hidden && (item.device === 'pc' || !item.device)">
294
+ <label :style="item.label_style ? item.label_style : ''"
295
+ :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label'">{{item.label}}</label>
296
+ <div :style="item.value_style ? item.value_style : ''"
297
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-xs-8'">
298
+ <textarea
299
+ class="form-control input_view"
300
+ style="width: 100%;height: 100%"
301
+ v-model="item.value"
302
+ :value="item.value"
303
+ :rows="item.rows"
304
+ :readonly="item.readonly"
305
+ :disabled="item.disabled"
306
+ @change="onbutchange(index)"
307
+ @blur="onbutblur(index)"
308
+ @input="onbutinput(index)"
309
+ ></textarea>
310
+ </div>
311
+ </div>
312
+ </div>
313
+ </div>
314
+ </article>
315
+ <footer slot="modal-footer" class="modal-footer">
316
+ <button :class="disable_modal_button ? 'btn btn-default':'btn btn-primary'"
317
+ :disabled="disable_modal_button" type="button" @click="confirmModal()">
318
+ 确认
319
+ </button>
320
+ </footer>
321
+ </modal>
322
+ </form>
323
+ </div>
324
+ </template>
325
+ <script>
326
+ import Vue from 'vue'
327
+ import {isEmpty} from "../Util";
328
+ // Date格式化
329
+ Date.prototype.Format = function (fmt) {
330
+ var o = {
331
+ 'M+': this.getMonth() + 1, // 月份
332
+ 'd+': this.getDate(), // 日
333
+ 'H+': this.getHours(), // 小时
334
+ 'm+': this.getMinutes(), // 分
335
+ 's+': this.getSeconds(), // 秒
336
+ 'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
337
+ 'S': this.getMilliseconds() // 毫秒
338
+ }
339
+ if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
340
+ for (var k in o) {
341
+ if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
342
+ }
343
+ return fmt
344
+ }
345
+
346
+ export default {
347
+ title: '报建业务通用组件',
348
+ props: {
349
+ data: {
350
+ type: Object
351
+ },
352
+ showprint: {
353
+ type: Boolean,
354
+ default: true
355
+ }
356
+ },
357
+ data () {
358
+ return {
359
+ model: {}, // 公司等属性
360
+ disable_button: true, // 控制按钮禁用
361
+ disable_modal_button: true, // 控制按钮禁用
362
+ showButModal: false
363
+ }
364
+ },
365
+ watch: {
366
+ deep: true
367
+ },
368
+ computed: {
369
+
370
+ },
371
+ created () {
372
+ // 初始化数据
373
+ this.initializtion()
374
+ if (this.data.readyEvent) {
375
+ this.$dispatch(this.data.readyEvent)
376
+ }
377
+ this.$dispatch('initializtionView')
378
+ },
379
+ methods: {
380
+ // 初始化数据
381
+ initializtion () {
382
+ for (const item of this.data.fields) {
383
+ this.data[item.field] = item.value
384
+ }
385
+ // 是否禁用按钮
386
+ this.disableButton()
387
+ },
388
+ // 是否禁用按钮
389
+ disableButton () {
390
+ let flag = false
391
+
392
+ for (const field of this.data.fields) {
393
+ if (field.required && !field.value && !field.hidden && field.value !== 0) {
394
+ flag = true
395
+ }
396
+
397
+ // 任何选择框只要是否都不能提交
398
+ if (field.type === 'select' && field.value === '否' && field.value_no_disable) {
399
+ flag = true
400
+ }
401
+
402
+ if (field.type === 'checkbox' && field.required && field.value.length === 0) {
403
+ flag = true
404
+ }
405
+ }
406
+
407
+ this.disable_button = flag
408
+ },
409
+ // 失去焦点且值最终发生变化触发
410
+ async onchange (index) {
411
+ // 是否禁用按钮
412
+ this.disableButton()
413
+
414
+ if (!isEmpty(this.data.fields[index].value)) {
415
+ // 前缀、后缀
416
+ if (this.data.fields[index].prefix) {
417
+ this.data.fields[index].value = this.data.fields[index].prefix + this.data.fields[index].value
418
+ }
419
+ if (this.data.fields[index].suffix) {
420
+ this.data.fields[index].value = this.data.fields[index].value + this.data.fields[index].suffix
421
+ }
422
+ }
423
+
424
+ // data赋值
425
+ this.data[this.data.fields[index].field] = this.data.fields[index].value
426
+
427
+ if (this.data.fields[index].type === 'datepicker') {
428
+ this.check_datepicker(index)
429
+ }
430
+
431
+ if (this.data.fields[index].onchange) {
432
+ this.$dispatch(this.data.fields[index].onchange, index)
433
+ }
434
+ this.$dispatch('onchange', index)
435
+
436
+
437
+ },
438
+ // 失去焦点触发,无论值是否发生变化
439
+ onblur (index) {
440
+ this.disableButton()
441
+
442
+ if (this.data.fields[index].onblur) {
443
+ this.$dispatch(this.data.fields[index].onblur, index)
444
+ }
445
+
446
+ this.$dispatch('onblur', index)
447
+ },
448
+ oninput (index) {
449
+ // 是否禁用按钮
450
+ this.disableButton()
451
+
452
+ if (this.data.fields[index].oninput) {
453
+ this.$dispatch(this.data.fields[index].oninput, index)
454
+ }
455
+ this.$dispatch('oninput', index)
456
+ },
457
+ // 点击按钮组按钮
458
+ async click_but (button) {
459
+ if (this.data.defname === '通气点火') {
460
+
461
+ this.$showMessage(`请确认表号是否正确`).then((res) => {
462
+
463
+
464
+ this.disable_button = true
465
+
466
+ this.data.fields.forEach(item => {
467
+ this.data[item.field] = item.value
468
+ })
469
+
470
+ this.data.button = button
471
+
472
+ if (button.button_fields && button.button_fields.length > 0) {
473
+ this.showButModal = true
474
+ return
475
+ }
476
+
477
+ if (this.data.button.event) {
478
+ this.$dispatch(this.data.button.event)
479
+ } else {
480
+ this.$dispatch('button')
481
+ }
482
+
483
+ })
484
+
485
+ }
486
+ else{
487
+ this.disable_button = true
488
+
489
+ this.data.fields.forEach(item => {
490
+ this.data[item.field] = item.value
491
+ })
492
+
493
+ this.data.button = button
494
+
495
+ if (button.button_fields && button.button_fields.length > 0) {
496
+ this.showButModal = true
497
+ return
498
+ }
499
+
500
+ if (this.data.button.event) {
501
+ this.$dispatch(this.data.button.event)
502
+ } else {
503
+ this.$dispatch('button')
504
+ }
505
+ }
506
+ },
507
+ confirmModal () {
508
+ this.closeModal()
509
+
510
+ this.data.button.button_fields.forEach(item => {
511
+ this.data.button[item.field] = item.value
512
+ })
513
+
514
+ if (this.data.button.event) {
515
+ this.$dispatch(this.data.button.event)
516
+ } else {
517
+ this.$dispatch('button')
518
+ }
519
+ },
520
+ // 关闭模态框
521
+ closeModal () {
522
+ this.showButModal = false
523
+ this.disable_modal_button = true
524
+ },
525
+ onbutchange (index) {
526
+ // 是否禁用按钮
527
+ this.disableModalButton()
528
+
529
+ if (this.data.button.button_fields[index].onchange) {
530
+ this.$dispatch(this.data.button.button_fields[index].onchange, index)
531
+ } else {
532
+ this.$dispatch('onbutchange', index)
533
+ }
534
+
535
+ },
536
+ onbutblur (index) {
537
+ this.disableModalButton()
538
+
539
+ if (this.data.button.button_fields[index].onblur) {
540
+ this.$dispatch(this.data.button.button_fields[index].onblur, index)
541
+ } else {
542
+ this.$dispatch('onbutblur', index)
543
+ }
544
+ },
545
+ onbutinput (index) {
546
+ // 是否禁用按钮
547
+ this.disableModalButton()
548
+
549
+ if (this.data.button.button_fields[index].oninput) {
550
+ this.$dispatch(this.data.button.button_fields[index].oninput, index)
551
+ } else {
552
+ this.$dispatch('onbutinput', index)
553
+ }
554
+ },
555
+ disableModalButton () {
556
+ let flag = false
557
+
558
+
559
+ for (const item of this.data.button.button_fields) {
560
+ if (item.required && !item.value) {
561
+ if (item.value === 0) {
562
+ flag = false
563
+ } else {
564
+ flag = true
565
+ }
566
+ }
567
+ }
568
+
569
+ this.disable_modal_button = flag
570
+ },
571
+ check_datepicker (index) {
572
+ // 时间格式检测
573
+ if (!isEmpty(this.data.fields[index].value)) {
574
+
575
+ let dateReg = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/
576
+ let timeReg = /^(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/
577
+ let datetimeReg = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/
578
+ if (this.data.fields[index].format) {
579
+ if (this.data.fields[index].format === 'yyyy-MM-dd') {
580
+ if (!dateReg.test(this.data.fields[index].value)) {
581
+ this.data.fields[index].value = ''
582
+ this.$showAlert(this.data.fields[index].label + '格式错误如:2021-01-01', 'warning', 2000)
583
+ }
584
+ }
585
+ if (this.data.fields[index].format === 'HH:mm:ss') {
586
+ if (!timeReg.test(this.data.fields[index].value)) {
587
+ this.data.fields[index].value = ''
588
+ this.$showAlert(this.data.fields[index].label + '格式错误如:00:00:00', 'warning', 2000)
589
+ }
590
+ }
591
+ if (this.data.fields[index].format === 'yyyy-MM-dd HH:mm:ss') {
592
+ if (!datetimeReg.test(this.data.fields[index].value)) {
593
+ this.data.fields[index].value = ''
594
+ this.$showAlert(this.data.fields[index].label + '格式错误如:2021-01-01 00:00:00', 'warning', 2000)
595
+ }
596
+ }
597
+ } else {
598
+ if (!dateReg.test(this.data.fields[index].value)) {
599
+ this.data.fields[index].value = ''
600
+ this.$showAlert(this.data.fields[index].label + '格式错误如:2021-01-01', 'warning', 2000)
601
+ }
602
+ }
603
+ }
604
+ },
605
+ selectSearch(event, index) {
606
+ if (this.data.fields[index].selectSearch) {
607
+ this.$dispatch(this.data.fields[index].selectSearch, event[0], index)
608
+ }
609
+ this.$dispatch('selectSearch', event[0], index)
610
+ }
611
+ },
612
+ events: {
613
+ }
614
+ }
615
+ </script>
616
+ <style scoped>
617
+ .control-label-justify {
618
+ width: 30%;
619
+ text-align: justify;
620
+ text-align-last: justify;
621
+ font-family: PingFang-SC-Bold;
622
+ float: left;
623
+ }
624
+ .button_spacing{margin: 0px 0px 0px 10px;}
625
+ </style>
626
+ <style lang="less">
627
+ .apply-has-error {
628
+ border-bottom: 1px solid #a94442;
629
+ }
630
+ .app-input {
631
+ label {
632
+ float: left;
633
+ }
634
+ .select {
635
+ button {
636
+ border: none;
637
+ outline: none;
638
+ text-align: left;
639
+ .btn-placeholder {
640
+ color: #ACA899
641
+ }
642
+ }
643
+ }
644
+ .datepicker {
645
+ .form-control:focus {
646
+ border: none!important;
647
+ outline: none!important;
648
+ -webkit-box-shadow: none;
649
+ box-shadow: none;
650
+ }
651
+ }
652
+ textarea {
653
+ padding: 8px 10px;
654
+ border: none;
655
+ outline: none;
656
+ margin: 0px;
657
+ }
658
+ input[readonly]{
659
+ color: #ACA899!important;
660
+ background: #FFFFFF;
661
+ border: none;
662
+ outline: none;
663
+ }
664
+ input:disabled{
665
+ color: #ACA899!important;
666
+ background: #FFFFFF;
667
+ border: none;
668
+ outline: none;
669
+ }
670
+ textarea[readonly]{
671
+ color: #ACA899!important;
672
+ background: #FFFFFF;
673
+ border: none;
674
+ outline: none;
675
+ }
676
+ textarea:disabled{
677
+ color: #ACA899!important;
678
+ background: #FFFFFF;
679
+ border: none;
680
+ outline: none;
681
+ }
682
+ }
683
+ </style>