apply-clients 3.3.65 → 3.3.69

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