vue2-client 1.8.218 → 1.8.219

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.8.218",
3
+ "version": "1.8.219",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -23,6 +23,7 @@
23
23
  :layout="layout"
24
24
  :get-data-params="getDataParams"
25
25
  :env="env"
26
+ @x-form-item-emit-func="emitFunc"
26
27
  />
27
28
  </a-row>
28
29
  <a-row :gutter="16" v-for="(groupItem, groupIndex) in groupJsonData" :key="groupIndex">
@@ -409,105 +410,139 @@ export default {
409
410
  return value.addOrEdit === 'readonly'
410
411
  },
411
412
  async onSubmit () {
412
- this.$refs.selectForm.validate(async valid => {
413
- // 验证未通过直接返回
414
- if (!valid) {
415
- return false
416
- }
417
- this.loading = true
418
- for (const key of Object.keys(this.form)) {
419
- const value = this.form[key]
420
- if (value === null || value === '' || (typeof value === 'object' && Object.keys(value).length === 0)) {
421
- this.form[key] = undefined
422
- }
423
- }
424
- const requestForm = Object.assign({}, this.form)
425
- // 追加静默新增字段
426
- if (this.businessType === '新增') {
427
- for (const item of this.silenceAddJsonData) {
428
- switch (item.silencePurpose) {
429
- case 'createTime':
430
- requestForm[item.model] = formatDate('now')
431
- break
432
- case 'operator':
433
- requestForm[item.model] = this.currUser.name
434
- break
435
- case 'operatorId':
436
- requestForm[item.model] = this.currUser.id
437
- break
438
- case 'orgId':
439
- requestForm[item.model] = this.currUser.orgid
440
- break
441
- case 'orgName':
442
- requestForm[item.model] = this.currUser.orgs
443
- break
444
- case 'depId':
445
- requestForm[item.model] = this.currUser.depids
446
- break
447
- case 'depName':
448
- requestForm[item.model] = this.currUser.deps
449
- break
450
- }
451
- }
452
- // 通过请求追加静默新增:自定义字段
453
- for (const item of this.silenceAddJsonData.filter((item) => item.silencePurpose === 'customize')) {
454
- // 获取通过logic静默新增的字段
455
- requestForm[item.model] = await runLogic(item.silenceSource, requestForm, this.serviceName)
456
- }
457
- }
458
- // 如果是临时表
459
- if (this.isTableTemp) {
460
- this.$emit('tempTableModify', {
461
- valid: valid,
462
- form: requestForm,
463
- businessType: this.businessType
464
- })
465
- return
466
- }
467
- // 处理表单键问题
468
- const realForm = {}
469
- for (const key of Object.keys(requestForm)) {
470
- const value = requestForm[key]
471
- const extraFormKeyTagIndex = key.indexOf('@')
472
- // 如果含有动态简易表单项,则将该项的值放入具体的动态表单配置字段中
473
- if (extraFormKeyTagIndex !== -1) {
474
- const extraFormKey = key.substring(0, extraFormKeyTagIndex)
475
- const realKey = key.substring(extraFormKeyTagIndex + 1)
476
- if (!realForm[extraFormKey]) {
477
- realForm[extraFormKey] = {}
478
- }
479
- realForm[extraFormKey][realKey] = value
480
- } else {
481
- const realKey = this.isKeyHandle ? this.getRealKey(key) : key
482
- realForm[realKey] = value
413
+ const valid = await this.validateForm()
414
+ if (!valid) return false
415
+ this.loading = true
416
+ const requestForm = this.prepareForm()
417
+ await this.appendSilenceAddFields(requestForm)
418
+
419
+ if (this.isTableTemp) {
420
+ this.$emit('tempTableModify', {
421
+ valid: valid,
422
+ form: requestForm,
423
+ businessType: this.businessType
424
+ })
425
+ return
426
+ }
427
+
428
+ const realForm = this.handleFormKeys(requestForm)
429
+ if (this.viewMode) {
430
+ this.$message.info('预览模式禁止新增和修改')
431
+ return false
432
+ }
433
+
434
+ if (this.$listeners.onSubmit || this.$listeners.componentDidMounted) {
435
+ this.$lowCodeEmit('onSubmit', {
436
+ businessType: this.businessType,
437
+ serviceName: this.serviceName,
438
+ realForm: realForm,
439
+ currUserName: this.currUser.name,
440
+ currUserId: this.currUser.id,
441
+ orgId: this.currUser.orgid
442
+ })
443
+ this.$emit('onSubmit', {
444
+ businessType: this.businessType,
445
+ serviceName: this.serviceName,
446
+ realForm: realForm,
447
+ currUserName: this.currUser.name,
448
+ currUserId: this.currUser.id,
449
+ orgId: this.currUser.orgid
450
+ })
451
+ } else {
452
+ this.defaultSubmit(realForm)
453
+ }
454
+ },
455
+
456
+ async asyncSubmit () {
457
+ return new Promise((resolve, reject) => {
458
+ this.$refs.selectForm.validate(async valid => {
459
+ if (!valid) {
460
+ reject(new Error('Form validation failed'))
461
+ return
483
462
  }
484
- }
485
- if (this.viewMode) {
486
- this.$message.info('预览模式禁止新增和修改')
487
- return false
488
- }
489
- if (this.$listeners.onSubmit || this.$listeners.componentDidMounted) {
490
- this.$lowCodeEmit('onSubmit', {
463
+ this.loading = true
464
+ const requestForm = this.prepareForm()
465
+ await this.appendSilenceAddFields(requestForm)
466
+ resolve({
491
467
  businessType: this.businessType,
492
468
  serviceName: this.serviceName,
493
- realForm: realForm,
494
- currUserName: this.currUser.name,
495
- currUserId: this.currUser.id,
496
- orgId: this.currUser.orgid
497
- })
498
- // 交由父级处理
499
- this.$emit('onSubmit', {
500
- businessType: this.businessType,
501
- serviceName: this.serviceName,
502
- realForm: realForm,
469
+ realForm: this.handleFormKeys(requestForm),
503
470
  currUserName: this.currUser.name,
504
471
  currUserId: this.currUser.id,
505
472
  orgId: this.currUser.orgid
506
473
  })
474
+ })
475
+ })
476
+ },
477
+
478
+ validateForm () {
479
+ return new Promise((resolve) => {
480
+ this.$refs.selectForm.validate(valid => resolve(valid))
481
+ })
482
+ },
483
+
484
+ prepareForm () {
485
+ const form = { ...this.form }
486
+ for (const key of Object.keys(form)) {
487
+ const value = form[key]
488
+ if (value === null || value === '' || (typeof value === 'object' && Object.keys(value).length === 0)) {
489
+ form[key] = undefined
490
+ }
491
+ }
492
+ return form
493
+ },
494
+
495
+ async appendSilenceAddFields (form) {
496
+ if (this.businessType === '新增') {
497
+ for (const item of this.silenceAddJsonData) {
498
+ switch (item.silencePurpose) {
499
+ case 'createTime':
500
+ form[item.model] = formatDate('now')
501
+ break
502
+ case 'operator':
503
+ form[item.model] = this.currUser.name
504
+ break
505
+ case 'operatorId':
506
+ form[item.model] = this.currUser.id
507
+ break
508
+ case 'orgId':
509
+ form[item.model] = this.currUser.orgid
510
+ break
511
+ case 'orgName':
512
+ form[item.model] = this.currUser.orgs
513
+ break
514
+ case 'depId':
515
+ form[item.model] = this.currUser.depids
516
+ break
517
+ case 'depName':
518
+ form[item.model] = this.currUser.deps
519
+ break
520
+ }
521
+ }
522
+ for (const item of this.silenceAddJsonData.filter((item) => item.silencePurpose === 'customize')) {
523
+ form[item.model] = await runLogic(item.silenceSource, form, this.serviceName)
524
+ }
525
+ }
526
+ },
527
+
528
+ handleFormKeys (form) {
529
+ const realForm = {}
530
+ for (const key of Object.keys(form)) {
531
+ const value = form[key]
532
+ const extraFormKeyTagIndex = key.indexOf('@')
533
+ if (extraFormKeyTagIndex !== -1) {
534
+ const extraFormKey = key.substring(0, extraFormKeyTagIndex)
535
+ const realKey = key.substring(extraFormKeyTagIndex + 1)
536
+ if (!realForm[extraFormKey]) {
537
+ realForm[extraFormKey] = {}
538
+ }
539
+ realForm[extraFormKey][realKey] = value
507
540
  } else {
508
- this.defaultSubmit(realForm)
541
+ const realKey = this.isKeyHandle ? this.getRealKey(key) : key
542
+ realForm[realKey] = value
509
543
  }
510
- })
544
+ }
545
+ return realForm
511
546
  },
512
547
  // 默认提交事件
513
548
  defaultSubmit (realForm, callback) {
@@ -595,6 +630,9 @@ export default {
595
630
  this.form[item.model] = modifyModelData.data[item.model] + ''
596
631
  }
597
632
  }
633
+ },
634
+ emitFunc (func, data) {
635
+ this.$emit('x-form-item-emit-func', func, data)
598
636
  }
599
637
  },
600
638
  watch: {
@@ -6,8 +6,26 @@
6
6
  <a-form-model-item
7
7
  :ref="attr.model"
8
8
  :label="attr.name"
9
+ :labelCol="layout === 'inline' && attr.occupyCol?labelAndWrapperCol[attr.occupyCol].labelCol:undefined"
10
+ :wrapperCol="layout === 'inline'&& attr.occupyCol? labelAndWrapperCol[attr.occupyCol].wrapperCol:undefined"
9
11
  :prop="attr.prop ? attr.prop : attr.model">
10
- <a-input v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
12
+ <a-input-group v-if="attr.inputOnAfterName && attr.inputOnAfterFunc" compact>
13
+ <a-input
14
+ v-model="form[attr.model]"
15
+ :disabled="disabled"
16
+ style="width:90%"
17
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
18
+ <a-button style="width:10%" type="primary" @click="emitFunc(attr.inputOnAfterFunc,form[attr.model])">
19
+ {{ attr.inputOnAfterName }}
20
+ </a-button>
21
+ </a-input-group>
22
+ <a-input
23
+ v-else
24
+ v-model="form[attr.model]"
25
+ :disabled="disabled"
26
+ style="width:100%"
27
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
28
+
11
29
  </a-form-model-item>
12
30
  </x-form-col>
13
31
  <!-- 下拉框 -->
@@ -90,7 +108,7 @@
90
108
  show-search
91
109
  @search="fetchFunction"
92
110
  >
93
- <a-spin v-if="searching" slot="notFoundContent" size="small" />
111
+ <a-spin v-if="searching" slot="notFoundContent" size="small"/>
94
112
  <a-select-option
95
113
  v-if="mode === '查询'"
96
114
  key="999999"
@@ -162,7 +180,7 @@
162
180
  allowClear
163
181
  @search="fetchFunction"
164
182
  >
165
- <a-spin v-if="searching" slot="notFoundContent" size="small" />
183
+ <a-spin v-if="searching" slot="notFoundContent" size="small"/>
166
184
  <a-select-option
167
185
  v-for="(item,index) in option"
168
186
  :key="index"
@@ -212,8 +230,16 @@
212
230
  v-model="form[attr.model]"
213
231
  :disabled="disabled"
214
232
  :show-time="true"
233
+ style="width: 100%;"
215
234
  valueFormat="YYYY-MM-DD HH:mm:ss"/>
216
- <a-range-picker v-else v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM-DD HH:mm:ss"/>
235
+ <a-range-picker
236
+ v-else
237
+ v-model="form[attr.model]"
238
+ :disabled="disabled"
239
+ :show-time="true"
240
+ valueFormat="YYYY-MM-DD HH:mm:ss"
241
+ style="width: 100%;"
242
+ />
217
243
  </a-form-model-item>
218
244
  </x-form-col>
219
245
  <!-- 月份选择器 -->
@@ -221,7 +247,13 @@
221
247
  v-else-if="attr.type === 'monthPicker'"
222
248
  :flex="attr.flex">
223
249
  <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
224
- <a-month-picker v-model="form[attr.model]" :disabled="disabled" :show-time="true" valueFormat="YYYY-MM"/>
250
+ <a-month-picker
251
+ v-model="form[attr.model]"
252
+ :disabled="disabled"
253
+ :show-time="true"
254
+ valueFormat="YYYY-MM"
255
+ style="width: 100%;"
256
+ />
225
257
  </a-form-model-item>
226
258
  </x-form-col>
227
259
  <!-- 年份选择器 -->
@@ -237,6 +269,7 @@
237
269
  v-decorator="['year']"
238
270
  placeholder="请选择年份"
239
271
  :open="yearShowOne"
272
+ style="width: 100%;"
240
273
  @openChange="openChangeOne"
241
274
  @panelChange="panelChangeOne"/>
242
275
  </a-form-model-item>
@@ -251,15 +284,21 @@
251
284
  v-model="form[attr.model]"
252
285
  :disabled="disabled"
253
286
  :show-time="true"
287
+ style="width: 100%;"
254
288
  format="YYYY-MM-DD"
255
- valueFormat="YYYY-MM-DD HH:mm:ss" />
256
- <a-date-picker v-else v-model="form[attr.model]" :disabled="disabled" :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }" valueFormat="YYYY-MM-DD HH:mm:ss"/>
289
+ valueFormat="YYYY-MM-DD HH:mm:ss"/>
290
+ <a-date-picker
291
+ v-else
292
+ v-model="form[attr.model]"
293
+ :disabled="disabled"
294
+ style="width: 100%;"
295
+ :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
296
+ valueFormat="YYYY-MM-DD HH:mm:ss"/>
257
297
  </a-form-model-item>
258
298
  </x-form-col>
259
299
  <!-- 文本域 -->
260
300
  <a-col
261
301
  v-else-if="attr.type === 'textarea'"
262
- :style="layout === 'inline'?{width:'calc(100% - 60px)'}:{}"
263
302
  :xs="24"
264
303
  :sm="24"
265
304
  :md="24"
@@ -268,10 +307,16 @@
268
307
  :xxl="24">
269
308
  <a-form-model-item
270
309
  :labelCol="layout === 'inline'?{span:2}:undefined"
310
+ :wrapperCol="layout === 'inline'?{span:22}:undefined"
271
311
  :ref="attr.model"
272
312
  :label="attr.name"
273
313
  :prop="attr.prop ? attr.prop : attr.model">
274
- <a-textarea v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')" :rows="4"/>
314
+ <a-textarea
315
+ v-model="form[attr.model]"
316
+ style="width: 100%;"
317
+ :disabled="disabled"
318
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
319
+ :rows="4"/>
275
320
  </a-form-model-item>
276
321
  </a-col>
277
322
  <!-- 文件上传 -->
@@ -286,6 +331,7 @@
286
331
  :xxl="24">
287
332
  <a-form-model-item
288
333
  :labelCol="layout === 'inline'?{span:2}:undefined"
334
+ :wrapperCol="layout === 'inline'?{span:22}:undefined"
289
335
  :ref="attr.model"
290
336
  :label="attr.name"
291
337
  :prop="attr.prop ? attr.prop : attr.model">
@@ -303,7 +349,12 @@
303
349
  v-else-if="attr.type === 'citySelect'"
304
350
  :flex="attr.flex">
305
351
  <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
306
- <citySelect ref="citySelect" v-model="form[attr.model]" :contexts="attr.contexts" :value-type="attr.valueType" :default-value="form[attr.model]"></citySelect>
352
+ <citySelect
353
+ ref="citySelect"
354
+ v-model="form[attr.model]"
355
+ :contexts="attr.contexts"
356
+ :value-type="attr.valueType"
357
+ :default-value="form[attr.model]"></citySelect>
307
358
  </a-form-model-item>
308
359
  </x-form-col>
309
360
  <!-- 地点搜索框 -->
@@ -324,7 +375,7 @@
324
375
  v-else-if="attr.type === 'personSetting'"
325
376
  :flex="attr.flex">
326
377
  <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
327
- <PersonSetting v-model="form[attr.model]" ></PersonSetting>
378
+ <PersonSetting v-model="form[attr.model]"></PersonSetting>
328
379
  </a-form-model-item>
329
380
  </x-form-col>
330
381
  <!-- 树形选择框 -->
@@ -345,7 +396,7 @@
345
396
  :ref="attr.model"
346
397
  :label="attr.name"
347
398
  :prop="attr.prop ? attr.prop : attr.model">
348
- <a-rate v-model="form[attr.model]" />
399
+ <a-rate v-model="form[attr.model]"/>
349
400
  </a-form-model-item>
350
401
  </x-form-col>
351
402
  </template>
@@ -388,6 +439,22 @@ export default {
388
439
  searchResult: '',
389
440
  yearShowOne: false,
390
441
  optionForFunc: [],
442
+ labelAndWrapperCol: [{
443
+ labelCol: undefined,
444
+ wrapperCol: undefined
445
+ },
446
+ {
447
+ labelCol: undefined,
448
+ wrapperCol: undefined
449
+ },
450
+ {
451
+ labelCol: { span: 3 },
452
+ wrapperCol: { span: 21 }
453
+ },
454
+ {
455
+ labelCol: { span: 2 },
456
+ wrapperCol: { span: 22 }
457
+ }],
391
458
  // moment
392
459
  moment
393
460
  }
@@ -395,59 +462,70 @@ export default {
395
462
  props: {
396
463
  attr: {
397
464
  type: Object,
398
- default: () => {
399
- return {}
400
- }
465
+ default:
466
+ () => {
467
+ return {}
468
+ }
401
469
  },
402
470
  form: {
403
471
  type: Object,
404
- required: true
472
+ required:
473
+ true
405
474
  },
406
475
  disabled: {
407
476
  type: Boolean,
408
- default: () => {
409
- return false
410
- }
477
+ default:
478
+ () => {
479
+ return false
480
+ }
411
481
  },
412
482
  mode: {
413
483
  type: String,
414
- default: () => {
415
- return '查询'
416
- }
484
+ default:
485
+ () => {
486
+ return '查询'
487
+ }
417
488
  },
418
489
  files: {
419
490
  type: Array,
420
- default: () => {
421
- return []
422
- }
491
+ default:
492
+ () => {
493
+ return []
494
+ }
423
495
  },
424
496
  images: {
425
497
  type: Array,
426
- default: () => {
427
- return []
428
- }
498
+ default:
499
+ () => {
500
+ return []
501
+ }
429
502
  },
430
503
  serviceName: {
431
504
  type: String,
432
- default: undefined
505
+ default:
506
+ undefined
433
507
  },
434
508
  // 调用logic获取数据源的追加参数
435
509
  getDataParams: {
436
510
  type: Object,
437
- default: undefined
511
+ default:
512
+ undefined
438
513
  },
439
514
  // 布局
440
515
  layout: {
441
516
  type: String,
442
- default: 'horizontal'
517
+ default:
518
+ 'horizontal'
443
519
  },
444
520
  // 环境
445
521
  env: {
446
522
  type: String,
447
- default: () => {
448
- return 'prod'
449
- }
450
- },
523
+ default:
524
+ () => {
525
+ return 'prod'
526
+ }
527
+ }
528
+ ,
451
529
  },
452
530
  created () {
453
531
  this.init()
@@ -491,14 +569,26 @@ export default {
491
569
  xxl: 24
492
570
  }
493
571
  } else {
494
- // 新增修改表单 vertical 模式下默认为1列
495
- this.attr.flex = {
496
- xs: 24,
497
- sm: 24,
498
- md: 24,
499
- lg: 12,
500
- xl: 8,
501
- xxl: 8
572
+ if (this.attr.type === 'input' && this.attr.occupyCol) {
573
+ // 如果是 input 看是否配置了 占用列配置
574
+ this.attr.flex = {
575
+ xs: 8 * this.attr.occupyCol,
576
+ sm: 8 * this.attr.occupyCol,
577
+ md: 8 * this.attr.occupyCol,
578
+ lg: 8 * this.attr.occupyCol,
579
+ xl: 8 * this.attr.occupyCol,
580
+ xxl: 8 * this.attr.occupyCol
581
+ }
582
+ } else {
583
+ // 新增修改表单 vertical 模式下默认为1列
584
+ this.attr.flex = {
585
+ xs: 24,
586
+ sm: 24,
587
+ md: 24,
588
+ lg: 12,
589
+ xl: 8,
590
+ xxl: 8
591
+ }
502
592
  }
503
593
  }
504
594
  }
@@ -610,6 +700,9 @@ export default {
610
700
  } else {
611
701
  return child.child.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
612
702
  }
703
+ },
704
+ emitFunc (func, data) {
705
+ this.$emit('x-form-item-emit-func', func, data)
613
706
  }
614
707
  }
615
708
  }