apply-clients 3.3.40 → 3.3.44

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,381 +1,377 @@
1
- <template>
2
- <div>
3
- <data-grid :model="onetomany" class="list_area table_sy">
4
- <template partial='head'>
5
- <tr>
6
- <th style="white-space: nowrap;">序号</th>
7
- <th v-for="field in $parent.$parent.onetomany.fields" v-if="!field.displayPosition || field.displayPosition === 'list'">
8
- <nobr>{{field.label}}</nobr>
9
- </th>
10
- <th v-if="!$parent.$parent.onetomany.hiddenOperate">
11
- <button :style="$parent.$parent.onetomany.add.style"
12
- :class="$parent.$parent.onetomany.add.class ? $parent.$parent.onetomany.add.class + ' button_spacing' : 'button_new button_spacing'"
13
- v-if="!$parent.$parent.onetomany.add.hidden"
14
- @click.prevent="$parent.$parent.openAdd()" >
15
- {{ $parent.$parent.onetomany.add.text || '添加' }}
16
- </button>
17
- <button :style="$parent.$parent.onetomany.import.style"
18
- :class="$parent.$parent.onetomany.import.class ? $parent.$parent.onetomany.import.class + ' button_spacing' : 'button_export button_spacing'"
19
- v-if="!$parent.$parent.onetomany.import.hidden"
20
- @click.prevent="$parent.$parent.showFile = !$parent.$parent.showFile" >
21
- {{ $parent.$parent.onetomany.import.text || '导入' }}
22
- </button>
23
- <a type="button" style="text-decoration: none"
24
- class="button_export button_spacing"
25
- v-if="$parent.$parent.onetomany.import.templateUrl"
26
- :href="$parent.$parent.onetomany.import.templateUrl" download>模板下载</a>
27
- <export-excel
28
- v-if="!$parent.$parent.onetomany.export.hidden"
29
- :data="$parent.$parent.getCondition"
30
- :field="$parent.$parent.getField"
31
- sqlurl="rs/logic/applyExportfile"
32
- :sql-name="$parent.$parent.onetomany.export.sqlName || 'singleTable'"
33
- :template-name="$parent.$parent.onetomany.export.templateName || '导出明细'"
34
- :btn-name="$parent.$parent.onetomany.export.butName || '导出'"
35
- :choose-col="true"></export-excel>
36
- </th>
37
- </tr>
38
- </template>
39
- <template partial='body'>
40
- <tr>
41
- <td style="text-align: center">
42
- <nobr><font>{{$index+1}}</font></nobr>
43
- </td>
44
- <td class="text-center" style="text-align: center" v-for="key in $parent.$parent.onetomany.fields" v-if="!key.displayPosition || key.displayPosition === 'list'">
45
- {{row[key.field]}}
46
- </td>
47
- <td style="text-align: center" v-if="!$parent.$parent.onetomany.hiddenOperate">
48
- <button :style="$parent.$parent.onetomany.update.style"
49
- :class="$parent.$parent.onetomany.update.class ? $parent.$parent.onetomany.update.class + ' button_spacing' : 'button_search button_spacing'"
50
- v-if="!$parent.$parent.onetomany.update.hidden"
51
- @click.prevent="$parent.$parent.openUpdate($index)" >
52
- {{ $parent.$parent.onetomany.update.text || '修改' }}
53
- </button>
54
- <button :style="$parent.$parent.onetomany.delete.style"
55
- :class="$parent.$parent.onetomany.delete.class ? $parent.$parent.onetomany.delete.class + ' button_spacing' : 'button_delete button_spacing'"
56
- v-if="!$parent.$parent.onetomany.delete.hidden"
57
- @click.prevent="$parent.$parent.openDelete($index)" >
58
- {{ $parent.$parent.onetomany.delete.text || '删除' }}
59
- </button>
60
- </td>
61
- </tr>
62
- </template>
63
- </data-grid>
64
-
65
- <!-- onetomany模态框 -->
66
- <modal v-if="showModal" :show.sync="showModal" backdrop="false" large>
67
- <header slot="modal-header" class="modal-header">
68
- <button type="button" class="close" @click="closeModal()"><span>&times;</span></button>
69
- <span class="modal-title"><font
70
- size="3">{{modelTitle}}</font></span>
71
- </header>
72
- <article slot="modal-body" class="modal-body clearfix">
73
- <div class="form-group" style="padding: 0 150px">
74
- <div v-for="(index,item) in onetomany.fields">
75
- <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group' : 'form-group']"
76
- v-if="(item.type==='input' || item.type==='number'||item.type === 'tel'||item.type === 'email') && !item.hidden && (item.device === 'pc' || !item.device)">
77
- <label :style="item.label_style ? item.label_style : ''"
78
- :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label col-sm-6'">{{item.label}}</label>
79
- <div :style="item.value_style ? item.value_style : ''"
80
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-sm-9'">
81
- <input class="form-control input_view"
82
- :placeholder="item.placeholder"
83
- :type="item.type"
84
- v-model="item.value"
85
- :value="item.value"
86
- :readonly="item.readonly"
87
- :disabled="item.disabled"
88
- @change="onchange(index)"
89
- @blur="onblur(index)"
90
- @input="oninput(index)"
91
- />
92
- </div>
93
- </div>
94
-
95
- <!--时间datepicker-->
96
- <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
97
- v-if="item.type==='datepicker' && !item.hidden && (item.device === 'pc' || !item.device)">
98
- <label :style="item.label_style ? item.label_style : ''"
99
- :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label col-sm-6'">{{item.label}}</label>
100
- <div :style="item.value_style ? item.value_style : ''"
101
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-sm-9'">
102
- <datepicker
103
- :placeholder="item.placeholder"
104
- :value.sync="item.value"
105
- v-model="item.value"
106
- :readonly="item.readonly"
107
- :disabled="item.disabled"
108
- :format="item.format ? item.format : 'yyyy-MM-dd'"
109
- :show-reset-button="true"
110
- @change="onchange(index)"
111
- @blur="onblur(index)"
112
- ></datepicker>
113
- </div>
114
- </div>
115
-
116
- <!--select-->
117
- <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
118
- v-if="item.type==='select' && !item.hidden && (item.device === 'pc' || !item.device)">
119
- <label :style="item.label_style ? item.label_style : ''"
120
- :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label col-sm-6'">{{item.label}}</label>
121
- <div :style="item.value_style ? item.value_style : ''"
122
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-sm-9'">
123
- <input-select
124
- class="select select_list"
125
- :value.sync="item.value"
126
- v-model="item.value"
127
- :options='item.options'
128
- :readonly="item.readonly"
129
- :disable="item.disabled"
130
- :valueSingle="true"
131
- @blur="onblur(index)"
132
- @change="onchange(index)"
133
- ></input-select>
134
- </div>
135
- </div>
136
-
137
- <!--textarea-->
138
- <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
139
- v-if="item.type==='textarea' && !item.hidden && (item.device === 'pc' || !item.device)">
140
- <label :style="item.label_style ? item.label_style : ''"
141
- :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label col-sm-6'">{{item.label}}</label>
142
- <div :style="item.value_style ? item.value_style : ''"
143
- :class="item.value_bootstraped ? item.value_bootstraped : 'col-sm-9'">
144
- <textarea
145
- class="form-control input_view"
146
- style="width: 100%;height: 100%"
147
- v-model="item.value"
148
- :value="item.value"
149
- :rows="item.rows"
150
- :readonly="item.readonly"
151
- :disabled="item.disabled"
152
- @change="onchange(index)"
153
- @blur="onblur(index)"
154
- @input="oninput(index)"
155
- ></textarea>
156
- </div>
157
- </div>
158
- </div>
159
- </div>
160
- </article>
161
- <footer slot="modal-footer" class="modal-footer">
162
- <button :class="disableButton ? 'btn btn-default':'btn btn-primary'"
163
- :disabled="disableButton" type="button" @click="confirmModal()">
164
- 确认
165
- </button>
166
- </footer>
167
- </modal>
168
-
169
- <modal v-if="showFile" :show.sync="showFile" v-ref:modal :backdrop="false" title="选择文件">
170
- <header slot="modal-header" class="modal-header">
171
- <button type="button" class="close" @click="closeFile()"><span>&times;</span></button>
172
- <h4 class="modal-title">选择文件</h4>
173
- </header>
174
- <article slot="modal-body" class="modal-body">
175
- <div class="form-group">
176
- <file-upload class="my-file-uploader" action="rs/file/uploadFile" tagname="确定" v-ref:file></file-upload>
177
- </div>
178
- </article>
179
- <footer slot="modal-footer" class="modal-footer"></footer>
180
- </modal>
181
- </div>
182
- </template>
183
-
184
- <script>
185
- import {HttpResetClass} from 'vue-client'
186
- import Vue from 'vue'
187
- export default {
188
- title: 'onetomany',
189
- props: {
190
- selectdata: {
191
- type: Object
192
- },
193
- onetomany: {
194
- type: Object
195
- },
196
- index: {
197
- type: Number
198
- }
199
- },
200
- data () {
201
- return {
202
- disableButton: false,
203
- showModal: false,
204
- modelTitle: null,
205
- rowIndex: null,
206
- showFile: false
207
- }
208
- },
209
- ready () {
210
- },
211
- methods: {
212
- confirmModal () {
213
- if (this.modelTitle === '新增') {
214
- if (this.onetomany.add.event) {
215
- this.$dispatch(this.onetomany.add.event, this.index)
216
- } else {
217
- this.$dispatch('onetomanyadd', this.index)
218
- }
219
- }
220
- if (this.modelTitle === '修改') {
221
- if (this.onetomany.update.event) {
222
- this.$dispatch(this.onetomany.update.event, this.index, this.rowIndex)
223
- } else {
224
- this.$dispatch('onetomanyupdate', this.index, this.rowIndex)
225
- }
226
- }
227
-
228
- this.closeModal()
229
- },
230
- onchange (fieldIndex) {
231
- this.disableModalButton()
232
- if (this.onetomany.fields[fieldIndex].onchange) {
233
- this.$dispatch(this.onetomany.fields[fieldIndex].onchange, this.index, fieldIndex)
234
- } else {
235
- this.$dispatch('onchangeModal', this.index, fieldIndex)
236
- }
237
- },
238
- onblur (fieldIndex) {
239
- this.disableModalButton()
240
- if (this.onetomany.fields[fieldIndex].onblur) {
241
- this.$dispatch(this.onetomany.fields[fieldIndex].onblur, this.index, fieldIndex)
242
- } else {
243
- this.$dispatch('onblurModal', this.index, fieldIndex)
244
- }
245
- },
246
- oninput (fieldIndex) {
247
- this.disableModalButton()
248
- if (this.onetomany.fields[fieldIndex].oninput) {
249
- this.$dispatch(this.onetomany.fields[fieldIndex].oninput, this.index, fieldIndex)
250
- } else {
251
- this.$dispatch('oninputModal', this.index, fieldIndex)
252
- }
253
- },
254
- openDelete (rowIndex) {
255
- this.$showMessage(this.onetomany.delete.message ? this.onetomany.delete.message : '您确定要删除这条记录吗?', ['confirm']).then((res) => {
256
- if (res === 'confirm') {
257
- if (this.onetomany.delete.event) {
258
- this.$dispatch(this.onetomany.delete.event, this.index, rowIndex)
259
- } else {
260
- this.$dispatch('onetomanydelete', this.index, rowIndex)
261
- }
262
- }
263
- })
264
- },
265
- // 修改
266
- openUpdate (rowIndex) {
267
- let row = this.onetomany.rows[rowIndex]
268
- for (const item of this.onetomany.fields) {
269
- item.value = row[item.field]
270
- }
271
-
272
- this.disableModalButton()
273
-
274
- this.modelTitle = '修改'
275
- this.rowIndex = rowIndex
276
-
277
- if (this.onetomany.update.openEvent) {
278
- this.$dispatch(this.onetomany.update.openEvent, this.index, this.rowIndex)
279
- }
280
- this.$dispatch('openUpdateModel', this.index, this.rowIndex)
281
-
282
- this.showModal = true
283
- },
284
- // 添加
285
- openAdd () {
286
- this.disableModalButton()
287
- this.modelTitle = '新增'
288
-
289
- if (this.onetomany.add.openEvent) {
290
- this.$dispatch(this.onetomany.add.openEvent, this.index)
291
- }
292
- this.$dispatch('openAddModel', this.index)
293
-
294
- this.showModal = true
295
- },
296
- closeModal () {
297
- this.showModal = false
298
- this.disableButton = false
299
- this.modelTitle = null
300
- this.rowIndex = null
301
-
302
- for (const item of this.onetomany.fields) {
303
- item.value = null
304
- }
305
- },
306
- // 是否禁用按钮
307
- disableModalButton () {
308
- let flag = false
309
-
310
- for (const field of this.onetomany.fields) {
311
- if (field.required && !field.value) {
312
- if (field.value === 0) {
313
- flag = false
314
- } else {
315
- flag = true
316
- }
317
- }
318
- }
319
-
320
- this.disableButton = flag
321
- },
322
- // 关闭文件上传对话框
323
- closeFile () {
324
- this.showFile = false
325
- // 将选的文件清空
326
- this.$refs.file.$el.querySelector('input').value = ''
327
- }
328
- },
329
- computed: {
330
- getField () {
331
- if (this.onetomany.export.fields) {
332
- return this.onetomany.export.fields
333
- }
334
- let field = {}
335
- for (const item of this.onetomany.fields) {
336
- if (item.displayPosition === 'form' || !item.displayPosition) {
337
- field[item.field] = item.label
338
- }
339
- }
340
- return field
341
- },
342
- getCondition () {
343
- if (this.onetomany.export.condition) {
344
- return this.onetomany.export.condition
345
- }
346
- return {
347
- tablename: this.onetomany.tables[0],
348
- condition: `f_process_id='${this.selectdata.f_process_id}'`
349
- }
350
- }
351
- },
352
- events: {
353
- async 'onFileUpload'(file, result) {
354
- if (this.onetomany.import.event) {
355
- this.$dispatch(this.onetomany.import.event, this.index, this.onetomany.tables[0], this.onetomany.import.configName, result.f_downloadpath)
356
- } else {
357
- this.$dispatch('importEvent', this.index, this.onetomany.tables[0], this.onetomany.import.configName, result.f_downloadpath)
358
- }
359
- }
360
- }
361
- }
362
- </script>
363
-
364
- <style scoped>
365
- .control-label-justify {
366
- display: inline-block;
367
- vertical-align: top;
368
- width: 110px;
369
- text-align: justify;
370
- font-family: PingFang-SC-Bold;
371
- }
372
-
373
- .control-label-justify::after {
374
- content: "";
375
- display: inline-block;
376
- width: 100%;
377
- overflow: hidden;
378
- height: 0;
379
- }
380
-
381
- </style>
1
+ <template>
2
+ <div>
3
+ <data-grid :model="onetomany" class="list_area table_sy">
4
+ <template partial='head'>
5
+ <tr>
6
+ <th style="white-space: nowrap;">序号</th>
7
+ <th v-for="field in $parent.$parent.onetomany.fields" v-if="!field.displayPosition || field.displayPosition === 'list'">
8
+ <nobr>{{field.label}}</nobr>
9
+ </th>
10
+ <th v-if="!$parent.$parent.onetomany.hiddenOperate">
11
+ <button :style="$parent.$parent.onetomany.add.style"
12
+ :class="$parent.$parent.onetomany.add.class ? $parent.$parent.onetomany.add.class + ' button_spacing' : 'button_new button_spacing'"
13
+ v-if="!$parent.$parent.onetomany.add.hidden"
14
+ @click.prevent="$parent.$parent.openAdd()" >
15
+ {{ $parent.$parent.onetomany.add.text || '添加' }}
16
+ </button>
17
+ <button :style="$parent.$parent.onetomany.import.style"
18
+ :class="$parent.$parent.onetomany.import.class ? $parent.$parent.onetomany.import.class + ' button_spacing' : 'button_export button_spacing'"
19
+ v-if="!$parent.$parent.onetomany.import.hidden"
20
+ @click.prevent="$parent.$parent.showFile = !$parent.$parent.showFile" >
21
+ {{ $parent.$parent.onetomany.import.text || '导入' }}
22
+ </button>
23
+ <a type="button" style="text-decoration: none"
24
+ class="button_export button_spacing"
25
+ v-if="$parent.$parent.onetomany.import.templateUrl"
26
+ :href="$parent.$parent.onetomany.import.templateUrl" download>模板下载</a>
27
+ <export-excel
28
+ v-if="!$parent.$parent.onetomany.export.hidden"
29
+ :data="$parent.$parent.getCondition"
30
+ :field="$parent.$parent.getField"
31
+ sqlurl="rs/logic/applyExportfile"
32
+ :sql-name="$parent.$parent.onetomany.export.sqlName || 'singleTable'"
33
+ :template-name="$parent.$parent.onetomany.export.templateName || '导出明细'"
34
+ :btn-name="$parent.$parent.onetomany.export.butName || '导出'"
35
+ :choose-col="true"></export-excel>
36
+ </th>
37
+ </tr>
38
+ </template>
39
+ <template partial='body'>
40
+ <tr>
41
+ <td style="text-align: center">
42
+ <nobr><font>{{$index+1}}</font></nobr>
43
+ </td>
44
+ <td class="text-center" style="text-align: center" v-for="key in $parent.$parent.onetomany.fields" v-if="!key.displayPosition || key.displayPosition === 'list'">
45
+ {{row[key.field]}}
46
+ </td>
47
+ <td style="text-align: center" v-if="!$parent.$parent.onetomany.hiddenOperate">
48
+ <button :style="$parent.$parent.onetomany.update.style"
49
+ :class="$parent.$parent.onetomany.update.class ? $parent.$parent.onetomany.update.class + ' button_spacing' : 'button_search button_spacing'"
50
+ v-if="!$parent.$parent.onetomany.update.hidden"
51
+ @click.prevent="$parent.$parent.openUpdate($index)" >
52
+ {{ $parent.$parent.onetomany.update.text || '修改' }}
53
+ </button>
54
+ <button :style="$parent.$parent.onetomany.delete.style"
55
+ :class="$parent.$parent.onetomany.delete.class ? $parent.$parent.onetomany.delete.class + ' button_spacing' : 'button_delete button_spacing'"
56
+ v-if="!$parent.$parent.onetomany.delete.hidden"
57
+ @click.prevent="$parent.$parent.openDelete($index)" >
58
+ {{ $parent.$parent.onetomany.delete.text || '删除' }}
59
+ </button>
60
+ </td>
61
+ </tr>
62
+ </template>
63
+ </data-grid>
64
+
65
+ <!-- onetomany模态框 -->
66
+ <modal v-if="showModal" :show.sync="showModal" backdrop="false" large>
67
+ <header slot="modal-header" class="modal-header">
68
+ <button type="button" class="close" @click="closeModal()"><span>&times;</span></button>
69
+ <span class="modal-title"><font
70
+ size="3">{{modelTitle}}</font></span>
71
+ </header>
72
+ <article slot="modal-body" class="modal-body clearfix">
73
+ <div class="form-group" style="padding: 0 150px">
74
+ <div v-for="(index,item) in onetomany.fields">
75
+ <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group' : 'form-group']"
76
+ v-if="(item.type==='input' || item.type==='number'||item.type === 'tel'||item.type === 'email') && !item.hidden && (item.device === 'pc' || !item.device)">
77
+ <label :style="item.label_style ? item.label_style : ''"
78
+ :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label col-sm-6'">{{item.label}}</label>
79
+ <div :style="item.value_style ? item.value_style : ''"
80
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-sm-9'">
81
+ <input class="form-control input_view"
82
+ :placeholder="item.placeholder"
83
+ :type="item.type"
84
+ v-model="item.value"
85
+ :value="item.value"
86
+ :readonly="item.readonly"
87
+ :disabled="item.disabled"
88
+ @change="onchange(index)"
89
+ @blur="onblur(index)"
90
+ @input="oninput(index)"
91
+ />
92
+ </div>
93
+ </div>
94
+
95
+ <!--时间datepicker-->
96
+ <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
97
+ v-if="item.type==='datepicker' && !item.hidden && (item.device === 'pc' || !item.device)">
98
+ <label :style="item.label_style ? item.label_style : ''"
99
+ :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label col-sm-6'">{{item.label}}</label>
100
+ <div :style="item.value_style ? item.value_style : ''"
101
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-sm-9'">
102
+ <datepicker
103
+ :placeholder="item.placeholder"
104
+ :value.sync="item.value"
105
+ v-model="item.value"
106
+ :readonly="item.readonly"
107
+ :disabled="item.disabled"
108
+ :format="item.format ? item.format : 'yyyy-MM-dd'"
109
+ :show-reset-button="true"
110
+ @change="onchange(index)"
111
+ @blur="onblur(index)"
112
+ ></datepicker>
113
+ </div>
114
+ </div>
115
+
116
+ <!--select-->
117
+ <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
118
+ v-if="item.type==='select' && !item.hidden && (item.device === 'pc' || !item.device)">
119
+ <label :style="item.label_style ? item.label_style : ''"
120
+ :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label col-sm-6'">{{item.label}}</label>
121
+ <div :style="item.value_style ? item.value_style : ''"
122
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-sm-9'">
123
+ <input-select
124
+ class="select select_list"
125
+ :value.sync="item.value"
126
+ v-model="item.value"
127
+ :options='item.options'
128
+ :readonly="item.readonly"
129
+ :disable="item.disabled"
130
+ :valueSingle="true"
131
+ @blur="onblur(index)"
132
+ @change="onchange(index)"
133
+ ></input-select>
134
+ </div>
135
+ </div>
136
+
137
+ <!--textarea-->
138
+ <div :style="item.style ? item.style : ''" :class="[item.required && !(item.value) ? 'has-error' : '', item.bootstraped ? item.bootstraped + ' form-group':'form-group']"
139
+ v-if="item.type==='textarea' && !item.hidden && (item.device === 'pc' || !item.device)">
140
+ <label :style="item.label_style ? item.label_style : ''"
141
+ :class="item.label_bootstraped ? item.label_bootstraped + ' control-label-justify control-label' : 'control-label-justify control-label col-sm-6'">{{item.label}}</label>
142
+ <div :style="item.value_style ? item.value_style : ''"
143
+ :class="item.value_bootstraped ? item.value_bootstraped : 'col-sm-9'">
144
+ <textarea
145
+ class="form-control input_view"
146
+ style="width: 100%;height: 100%"
147
+ v-model="item.value"
148
+ :value="item.value"
149
+ :rows="item.rows"
150
+ :readonly="item.readonly"
151
+ :disabled="item.disabled"
152
+ @change="onchange(index)"
153
+ @blur="onblur(index)"
154
+ @input="oninput(index)"
155
+ ></textarea>
156
+ </div>
157
+ </div>
158
+ </div>
159
+ </div>
160
+ </article>
161
+ <footer slot="modal-footer" class="modal-footer">
162
+ <button :class="disableButton ? 'btn btn-default':'btn btn-primary'"
163
+ :disabled="disableButton" type="button" @click="confirmModal()">
164
+ 确认
165
+ </button>
166
+ </footer>
167
+ </modal>
168
+
169
+ <modal v-if="showFile" :show.sync="showFile" v-ref:modal :backdrop="false" title="选择文件">
170
+ <header slot="modal-header" class="modal-header">
171
+ <button type="button" class="close" @click="closeFile()"><span>&times;</span></button>
172
+ <h4 class="modal-title">选择文件</h4>
173
+ </header>
174
+ <article slot="modal-body" class="modal-body">
175
+ <div class="form-group">
176
+ <file-upload class="my-file-uploader" action="rs/file/uploadFile" tagname="确定" v-ref:file></file-upload>
177
+ </div>
178
+ </article>
179
+ <footer slot="modal-footer" class="modal-footer"></footer>
180
+ </modal>
181
+ </div>
182
+ </template>
183
+
184
+ <script>
185
+ import {HttpResetClass} from 'vue-client'
186
+ import Vue from 'vue'
187
+ export default {
188
+ title: 'onetomany',
189
+ props: {
190
+ selectdata: {
191
+ type: Object
192
+ },
193
+ onetomany: {
194
+ type: Object
195
+ },
196
+ index: {
197
+ type: Number
198
+ }
199
+ },
200
+ data () {
201
+ return {
202
+ disableButton: false,
203
+ showModal: false,
204
+ modelTitle: null,
205
+ rowIndex: null,
206
+ showFile: false
207
+ }
208
+ },
209
+ ready () {
210
+ },
211
+ methods: {
212
+ confirmModal () {
213
+ if (this.modelTitle === '新增') {
214
+ if (this.onetomany.add.event) {
215
+ this.$dispatch(this.onetomany.add.event, this.index)
216
+ } else {
217
+ this.$dispatch('onetomanyadd', this.index)
218
+ }
219
+ }
220
+ if (this.modelTitle === '修改') {
221
+ if (this.onetomany.update.event) {
222
+ this.$dispatch(this.onetomany.update.event, this.index, this.rowIndex)
223
+ } else {
224
+ this.$dispatch('onetomanyupdate', this.index, this.rowIndex)
225
+ }
226
+ }
227
+
228
+ this.closeModal()
229
+ },
230
+ onchange (fieldIndex) {
231
+ this.disableModalButton()
232
+ if (this.onetomany.fields[fieldIndex].onchange) {
233
+ this.$dispatch(this.onetomany.fields[fieldIndex].onchange, this.index, fieldIndex)
234
+ } else {
235
+ this.$dispatch('onchangeModal', this.index, fieldIndex)
236
+ }
237
+ },
238
+ onblur (fieldIndex) {
239
+ this.disableModalButton()
240
+ if (this.onetomany.fields[fieldIndex].onblur) {
241
+ this.$dispatch(this.onetomany.fields[fieldIndex].onblur, this.index, fieldIndex)
242
+ } else {
243
+ this.$dispatch('onblurModal', this.index, fieldIndex)
244
+ }
245
+ },
246
+ oninput (fieldIndex) {
247
+ this.disableModalButton()
248
+ if (this.onetomany.fields[fieldIndex].oninput) {
249
+ this.$dispatch(this.onetomany.fields[fieldIndex].oninput, this.index, fieldIndex)
250
+ } else {
251
+ this.$dispatch('oninputModal', this.index, fieldIndex)
252
+ }
253
+ },
254
+ openDelete (rowIndex) {
255
+ this.$showMessage(this.onetomany.delete.message ? this.onetomany.delete.message : '您确定要删除这条记录吗?', ['confirm']).then((res) => {
256
+ if (res === 'confirm') {
257
+ if (this.onetomany.delete.event) {
258
+ this.$dispatch(this.onetomany.delete.event, this.index, rowIndex)
259
+ } else {
260
+ this.$dispatch('onetomanydelete', this.index, rowIndex)
261
+ }
262
+ }
263
+ })
264
+ },
265
+ // 修改
266
+ openUpdate (rowIndex) {
267
+ let row = this.onetomany.rows[rowIndex]
268
+ for (const item of this.onetomany.fields) {
269
+ item.value = row[item.field]
270
+ }
271
+
272
+ this.disableModalButton()
273
+
274
+ this.modelTitle = '修改'
275
+ this.rowIndex = rowIndex
276
+
277
+ if (this.onetomany.update.openEvent) {
278
+ this.$dispatch(this.onetomany.update.openEvent, this.index, this.rowIndex)
279
+ }
280
+ this.$dispatch('openUpdateModel', this.index, this.rowIndex)
281
+
282
+ this.showModal = true
283
+ },
284
+ // 添加
285
+ openAdd () {
286
+ this.disableModalButton()
287
+ this.modelTitle = '新增'
288
+
289
+ if (this.onetomany.add.openEvent) {
290
+ this.$dispatch(this.onetomany.add.openEvent, this.index)
291
+ }
292
+ this.$dispatch('openAddModel', this.index)
293
+
294
+ this.showModal = true
295
+ },
296
+ closeModal () {
297
+ this.showModal = false
298
+ this.disableButton = false
299
+ this.modelTitle = null
300
+ this.rowIndex = null
301
+
302
+ for (const item of this.onetomany.fields) {
303
+ item.value = null
304
+ }
305
+ },
306
+ // 是否禁用按钮
307
+ disableModalButton () {
308
+ let flag = false
309
+
310
+ for (const field of this.onetomany.fields) {
311
+ if (field.required && !field.value && !field.hidden && field.value !== 0) {
312
+ flag = true
313
+ }
314
+ }
315
+
316
+ this.disableButton = flag
317
+ },
318
+ // 关闭文件上传对话框
319
+ closeFile () {
320
+ this.showFile = false
321
+ // 将选的文件清空
322
+ this.$refs.file.$el.querySelector('input').value = ''
323
+ }
324
+ },
325
+ computed: {
326
+ getField () {
327
+ if (this.onetomany.export.fields) {
328
+ return this.onetomany.export.fields
329
+ }
330
+ let field = {}
331
+ for (const item of this.onetomany.fields) {
332
+ if (item.displayPosition === 'form' || !item.displayPosition) {
333
+ field[item.field] = item.label
334
+ }
335
+ }
336
+ return field
337
+ },
338
+ getCondition () {
339
+ if (this.onetomany.export.condition) {
340
+ return this.onetomany.export.condition
341
+ }
342
+ return {
343
+ tablename: this.onetomany.tables[0],
344
+ condition: `f_process_id='${this.selectdata.f_process_id}'`
345
+ }
346
+ }
347
+ },
348
+ events: {
349
+ async 'onFileUpload'(file, result) {
350
+ if (this.onetomany.import.event) {
351
+ this.$dispatch(this.onetomany.import.event, this.index, this.onetomany.tables[0], this.onetomany.import.configName, result.f_downloadpath)
352
+ } else {
353
+ this.$dispatch('importEvent', this.index, this.onetomany.tables[0], this.onetomany.import.configName, result.f_downloadpath)
354
+ }
355
+ }
356
+ }
357
+ }
358
+ </script>
359
+
360
+ <style scoped>
361
+ .control-label-justify {
362
+ display: inline-block;
363
+ vertical-align: top;
364
+ width: 110px;
365
+ text-align: justify;
366
+ font-family: PingFang-SC-Bold;
367
+ }
368
+
369
+ .control-label-justify::after {
370
+ content: "";
371
+ display: inline-block;
372
+ width: 100%;
373
+ overflow: hidden;
374
+ height: 0;
375
+ }
376
+
377
+ </style>