three-trees-ui 1.1.2 → 1.1.3

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.
@@ -16,33 +16,23 @@
16
16
  @click="showDialog"
17
17
  >
18
18
  <div
19
- ref="tagSpans"
20
- style="width: calc(100% - 25px);"
21
- :class="{
22
- 'el-select__tags_readonly': !inputWriteable,
23
- 'el-select__tags': inputWriteable,
24
- }"
19
+ v-if="inputWriteable"
20
+ class="el-input el-input--suffix"
21
+ :class="{ 'custom-selector-mobile': isMobile }"
25
22
  >
26
- <span class="tag-wrap">
27
- <span
23
+ <div v-if="isMobile" class="custom-selector-mobile-box">
24
+ <div
28
25
  v-for="(item, index) in demensions"
29
26
  :key="index"
30
- class="el-tag el-tag--info el-tag--small"
31
- @click.stop
27
+ class="common-selector-tag"
32
28
  >
33
- <span class="el-select__tags-text">{{ item.name }}</span>
34
- <i
35
- v-if="inputWriteable"
36
- class="el-tag__close el-icon-close"
37
- @click="handleRemove(item)"
38
- ></i>
39
- </span>
40
- </span>
41
- </div>
42
- <div v-if="inputWriteable" class="el-input el-input--suffix">
29
+ <span>{{ item.name }}</span>
30
+ <i class="el-icon-error" @click.stop="handleRemove(item)"></i>
31
+ </div>
32
+ </div>
43
33
  <input
44
34
  ref="inputEl"
45
- v-model="value"
35
+ v-model="calcInputValue"
46
36
  v-validate="inputValidate"
47
37
  type="text"
48
38
  readonly="readonly"
@@ -50,10 +40,6 @@
50
40
  autocomplete="off"
51
41
  class="el-input__inner"
52
42
  :placeholder="placeholder"
53
- :style="{
54
- height: inputSuffixHeight + 'px',
55
- lineHeight: inputSuffixHeight + 'px',
56
- }"
57
43
  />
58
44
  <span class="el-input__suffix">
59
45
  <span class="el-input__suffix-inner">
@@ -62,9 +48,13 @@
62
48
  </span>
63
49
  </span>
64
50
  </div>
51
+ <div v-else class="el-select__tags_readonly">
52
+ <span>{{ calcInputValue }}</span>
53
+ </div>
65
54
  </div>
66
55
  <ht-field-tail :field-name="inputName" :input-value="value" />
67
56
  <el-dialog
57
+ v-if="dialogVisible"
68
58
  title="选择维度"
69
59
  :visible.sync="dialogVisible"
70
60
  class="dialog-selector__wrapper"
@@ -216,6 +206,10 @@
216
206
  mode: {
217
207
  type: String,
218
208
  },
209
+ formInputsDisplay: {
210
+ type: String,
211
+ default: 'inline',
212
+ },
219
213
  },
220
214
  data() {
221
215
  return {
@@ -227,6 +221,17 @@
227
221
  }
228
222
  },
229
223
  computed: {
224
+ calcInputValue: function() {
225
+ let name = ''
226
+ if (this.demensions) {
227
+ name = this.demensions
228
+ .map((k) => {
229
+ return k.name
230
+ })
231
+ .join(',')
232
+ }
233
+ return name
234
+ },
230
235
  primaryField: function() {
231
236
  return this.config && this.config.hasOwnProperty('id')
232
237
  ? 'id'
@@ -285,14 +290,8 @@
285
290
  // 通过valueChange事件发布值变更消息
286
291
  this.$emit('valueChange', ary.join(','), newVal)
287
292
  setTimeout(() => {
288
- if (newVal.length > 0) {
289
- this.calacInputSuffixHeight()
290
- } else {
291
- this.inputSuffixHeight = 30
292
- }
293
293
  if (this.$refs.inputEl) {
294
- this.$refs.inputEl.focus()
295
- this.$refs.inputEl.blur()
294
+ this.$validator.validate(this.inputName)
296
295
  }
297
296
  }, 10)
298
297
  },
@@ -371,14 +370,13 @@
371
370
  this.demensions = tmpAry
372
371
  }
373
372
  },
374
- showDialog() {
373
+ async showDialog() {
375
374
  if (!this.inputWriteable) {
376
375
  return
377
376
  }
378
377
  this.dialogVisible = true
379
- setTimeout(() => {
380
- this.$refs.selector.onShow()
381
- })
378
+ await this.$nextTick()
379
+ this.$refs.selector.onShow()
382
380
  },
383
381
  handleClose(done) {
384
382
  this.$refs.selector.onHide()
@@ -401,12 +399,12 @@
401
399
  },
402
400
  // 更新当前输入框的高度来适配已选数据的高度
403
401
  calacInputSuffixHeight() {
404
- if (!this.$refs.tagSpans) return
405
- if (this.$refs.tagSpans.offsetHeight) {
406
- this.inputSuffixHeight = this.$refs.tagSpans.offsetHeight + 5
407
- } else {
408
- this.inputSuffixHeight = 30
409
- }
402
+ // if (!this.$refs.tagSpans) return
403
+ // if (this.$refs.tagSpans.offsetHeight) {
404
+ // this.inputSuffixHeight = this.$refs.tagSpans.offsetHeight + 5
405
+ // } else {
406
+ // this.inputSuffixHeight = 30
407
+ // }
410
408
  },
411
409
  },
412
410
  }
@@ -427,7 +425,10 @@
427
425
  position: relative;
428
426
  top: 50%;
429
427
  }
430
-
428
+ .el-input__inner {
429
+ height: 32px;
430
+ line-height: 32px;
431
+ }
431
432
  .el-input__inner[aria-invalid='true'] {
432
433
  border-color: #f56c6c;
433
434
  }
@@ -16,33 +16,23 @@
16
16
  @click="showDialog"
17
17
  >
18
18
  <div
19
- ref="tagSpans"
20
- style="width: calc(100% - 25px);"
21
- :class="{
22
- 'el-select__tags_readonly': !inputWriteable,
23
- 'el-select__tags': inputWriteable,
24
- }"
19
+ v-if="inputWriteable"
20
+ class="el-input el-input--suffix"
21
+ :class="{ 'custom-selector-mobile': isMobile }"
25
22
  >
26
- <span class="tag-wrap">
27
- <span
23
+ <div v-if="isMobile" class="custom-selector-mobile-box">
24
+ <div
28
25
  v-for="(item, index) in selectors"
29
26
  :key="index"
30
- class="el-tag el-tag--info el-tag--small"
31
- @click.stop
27
+ class="common-selector-tag"
32
28
  >
33
- <span class="el-select__tags-text">{{ item.name }}</span>
34
- <i
35
- v-if="inputWriteable"
36
- class="el-tag__close el-icon-close"
37
- @click="handleRemove(item)"
38
- ></i>
39
- </span>
40
- </span>
41
- </div>
42
- <div v-if="inputWriteable" class="el-input el-input--suffix">
29
+ <span>{{ item.name }}</span>
30
+ <i class="el-icon-error" @click.stop="handleRemove(item)"></i>
31
+ </div>
32
+ </div>
43
33
  <input
44
34
  ref="inputEl"
45
- v-model="value"
35
+ v-model="calcInputValue"
46
36
  v-validate="inputValidate"
47
37
  type="text"
48
38
  readonly="readonly"
@@ -50,10 +40,6 @@
50
40
  autocomplete="off"
51
41
  class="el-input__inner"
52
42
  :placeholder="placeholder"
53
- :style="{
54
- height: inputSuffixHeight + 'px',
55
- lineHeight: inputSuffixHeight + 'px',
56
- }"
57
43
  />
58
44
  <span class="el-input__suffix">
59
45
  <span class="el-input__suffix-inner">
@@ -62,49 +48,54 @@
62
48
  </span>
63
49
  </span>
64
50
  </div>
51
+ <div v-else class="el-select__tags_readonly">
52
+ <span>{{ calcInputValue }}</span>
53
+ </div>
65
54
  </div>
66
55
  <ht-field-tail :field-name="inputName" :input-value="value" />
67
- <job-selector-mobile-dialog
68
- v-if="isMobile"
69
- ref="jobSelectorMobileDialog"
70
- v-model="selectors"
71
- :search-placeholder="searchPlaceholder"
72
- :single="single"
73
- :data="data"
74
- :pagination="pagination"
75
- :select-label="selectLabel"
76
- :quick-search-props="quickSearchProps"
77
- :append-to-body="appendToBody"
78
- :title="title"
79
- :primary-field="primaryField"
80
- @search="(word) => $emit('search', word)"
81
- @reset="() => $emit('reset')"
82
- @row-click="(row) => $emit('row-click', row)"
83
- @select-data="(data) => $emit('select-data', data)"
84
- @page-change="(page) => $emit('page-change', page)"
85
- />
86
- <job-selector-dialog
87
- v-else
88
- ref="jobSelectorDialog"
89
- v-model="selectors"
90
- :search-placeholder="searchPlaceholder"
91
- :single="single"
92
- :data="data"
93
- :table-columns="tableColumns"
94
- :pagination="pagination"
95
- :select-label="selectLabel"
96
- :quick-search-props="quickSearchProps"
97
- :append-to-body="appendToBody"
98
- :title="title"
99
- :primary-field="primaryField"
100
- :mode="mode"
101
- @search="(word) => $emit('search', word)"
102
- @reset="() => $emit('reset')"
103
- @row-click="(row) => $emit('row-click', row)"
104
- @select-data="(data) => $emit('select-data', data)"
105
- @page-change="(page) => $emit('page-change', page)"
106
- @size-change="(size) => $emit('size-change', size)"
107
- />
56
+ <template v-if="isDialogShow">
57
+ <job-selector-mobile-dialog
58
+ v-if="isMobile"
59
+ ref="jobSelectorMobileDialog"
60
+ v-model="selectors"
61
+ :search-placeholder="searchPlaceholder"
62
+ :single="single"
63
+ :data="data"
64
+ :pagination="pagination"
65
+ :select-label="selectLabel"
66
+ :quick-search-props="quickSearchProps"
67
+ :append-to-body="appendToBody"
68
+ :title="title"
69
+ :primary-field="primaryField"
70
+ @search="(word) => $emit('search', word)"
71
+ @reset="() => $emit('reset')"
72
+ @row-click="(row) => $emit('row-click', row)"
73
+ @select-data="(data) => $emit('select-data', data)"
74
+ @page-change="(page) => $emit('page-change', page)"
75
+ />
76
+ <job-selector-dialog
77
+ v-else
78
+ ref="jobSelectorDialog"
79
+ v-model="selectors"
80
+ :search-placeholder="searchPlaceholder"
81
+ :single="single"
82
+ :data="data"
83
+ :table-columns="tableColumns"
84
+ :pagination="pagination"
85
+ :select-label="selectLabel"
86
+ :quick-search-props="quickSearchProps"
87
+ :append-to-body="appendToBody"
88
+ :title="title"
89
+ :primary-field="primaryField"
90
+ :mode="mode"
91
+ @search="(word) => $emit('search', word)"
92
+ @reset="() => $emit('reset')"
93
+ @row-click="(row) => $emit('row-click', row)"
94
+ @select-data="(data) => $emit('select-data', data)"
95
+ @page-change="(page) => $emit('page-change', page)"
96
+ @size-change="(size) => $emit('size-change', size)"
97
+ />
98
+ </template>
108
99
  </div>
109
100
  </template>
110
101
  <script>
@@ -181,11 +172,23 @@
181
172
  },
182
173
  data() {
183
174
  return {
175
+ isDialogShow: false,
184
176
  inputSuffixHeight: 30,
185
177
  selectors: [],
186
178
  }
187
179
  },
188
180
  computed: {
181
+ calcInputValue: function() {
182
+ let name = ''
183
+ if (this.selectors) {
184
+ name = this.selectors
185
+ .map((k) => {
186
+ return k.name
187
+ })
188
+ .join(',')
189
+ }
190
+ return name
191
+ },
189
192
  primaryField: function() {
190
193
  return this.config && this.config.hasOwnProperty('id')
191
194
  ? 'id'
@@ -235,14 +238,8 @@
235
238
  // 通过valueChange事件发布值变更消息
236
239
  this.$emit('valueChange', ary.join(','), newVal)
237
240
  setTimeout(() => {
238
- if (newVal.length > 0) {
239
- this.calacInputSuffixHeight()
240
- } else {
241
- this.inputSuffixHeight = 30
242
- }
243
241
  if (this.$refs.inputEl) {
244
- this.$refs.inputEl.focus()
245
- this.$refs.inputEl.blur()
242
+ this.$validator.validate(this.inputName)
246
243
  }
247
244
  }, 10)
248
245
  },
@@ -296,10 +293,14 @@
296
293
  this.selectors = tmpAry
297
294
  }
298
295
  },
299
- showDialog() {
296
+ async showDialog() {
300
297
  if (!this.inputWriteable) {
301
298
  return
302
299
  }
300
+ if (this.isDialogShow === false) {
301
+ this.isDialogShow = true
302
+ await this.$nextTick()
303
+ }
303
304
  if (this.isMobile) {
304
305
  this.$refs.jobSelectorMobileDialog.showDialog()
305
306
  } else {
@@ -315,12 +316,12 @@
315
316
  },
316
317
  // 更新当前输入框的高度来适配已选数据的高度
317
318
  calacInputSuffixHeight() {
318
- if (!this.$refs.tagSpans) return
319
- if (this.$refs.tagSpans.offsetHeight) {
320
- this.inputSuffixHeight = this.$refs.tagSpans.offsetHeight + 5
321
- } else {
322
- this.inputSuffixHeight = 30
323
- }
319
+ // if (!this.$refs.tagSpans) return
320
+ // if (this.$refs.tagSpans.offsetHeight) {
321
+ // this.inputSuffixHeight = this.$refs.tagSpans.offsetHeight + 5
322
+ // } else {
323
+ // this.inputSuffixHeight = 30
324
+ // }
324
325
  },
325
326
  },
326
327
  }
@@ -335,7 +336,10 @@
335
336
  position: relative;
336
337
  top: 50%;
337
338
  }
338
-
339
+ .el-input__inner {
340
+ height: 32px;
341
+ line-height: 32px;
342
+ }
339
343
  .el-input__inner[aria-invalid='true'] {
340
344
  border-color: #f56c6c;
341
345
  }
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <div name="online-form">
2
+ <div name="online-form" :class="{ 'is-mobile-online-form': isMobile }">
3
3
  <el-skeleton v-if="loadStatus == 0" :rows="6" animated />
4
4
  <component
5
+ :is="currentComponent"
5
6
  v-else-if="loadStatus > 0"
6
- v-bind:is="currentComponent"
7
7
  :name="formName"
8
8
  :data="data"
9
9
  :permission="permission"
@@ -31,12 +31,15 @@
31
31
  import onlineSubtable from '@/mixins/onlineSubtable.js'
32
32
  import regionValidator from '@/mixins/regionValidator.js'
33
33
  import emitter from '@/mixins/emitter.js'
34
+ import mobileMode from '@/mixins/mobileMode.js'
35
+ import { Notification } from 'element-ui'
36
+ import { Notify } from 'vant'
34
37
 
35
38
  import Vue from 'vue'
36
39
  export default {
37
40
  name: 'HtOnlineForm',
38
41
  componentName: 'HtOnlineForm',
39
- mixins: [regionValidator, emitter],
42
+ mixins: [regionValidator, emitter, mobileMode],
40
43
  props: {
41
44
  html: String,
42
45
  data: Object,
@@ -79,6 +82,9 @@
79
82
  type: Boolean,
80
83
  default: false,
81
84
  },
85
+ formExpand: {
86
+ type: String,
87
+ },
82
88
  },
83
89
  data() {
84
90
  return {
@@ -128,10 +134,16 @@
128
134
  } else {
129
135
  // 执行校验逻辑
130
136
  this.validateRegion(`[name='${this.formName}']`).then(
131
- (errorItems) => {
137
+ async (errorItems) => {
132
138
  if (errorItems.length > 0) {
133
139
  reject(errorItems)
134
140
  } else {
141
+ // 如果有子表,需要检验子表必填
142
+ let result = await this.validateTable()
143
+ if (result === false) {
144
+ reject(8)
145
+ return
146
+ }
135
147
  this.broadcast('HtGlobalValidate', 'global-validate')
136
148
  }
137
149
  }
@@ -139,6 +151,93 @@
139
151
  }
140
152
  })
141
153
  },
154
+ // 校验子表必填
155
+ validateTable() {
156
+ return new Promise((resolve) => {
157
+ if (!this.formExpand) {
158
+ resolve(true)
159
+ return
160
+ }
161
+ const expandList = JSON.parse(this.formExpand)
162
+
163
+ if (!expandList.list) {
164
+ resolve(true)
165
+ return
166
+ }
167
+ const subTableList = expandList.list.filter((it) => {
168
+ return (
169
+ (this.isMobile && it.ctrlType == 'subDiv') ||
170
+ (!this.isMobile && it.ctrlType === 'subtable')
171
+ )
172
+ })
173
+ if (!this.isMobile) {
174
+ // pc端找到 分页的子表 校验
175
+ const havePageSub = subTableList.filter((k) => {
176
+ return k.subtablePagination
177
+ })
178
+ if (!havePageSub.length) {
179
+ resolve(true)
180
+ return
181
+ }
182
+ }
183
+ const mainAlias = Object.keys(this.data)[0]
184
+ const mainData = this.data[mainAlias]
185
+ const errorResult = []
186
+
187
+ Object.keys(mainData).forEach((key) => {
188
+ if (key.startsWith('sub_')) {
189
+ const curSubConfig = subTableList.find((sub) => {
190
+ return sub.name == key.replace('sub_', '')
191
+ })
192
+ const subAlias = key.replace('sub_', '')
193
+ const subPermission = this.permission.fields[subAlias]
194
+ mainData[key].forEach((item, index) => {
195
+ Object.keys(item).forEach((subKey) => {
196
+ if (subPermission[subKey] == 'b' && !item[subKey]) {
197
+ const subItem = curSubConfig.list.find((l) => {
198
+ return l.name === subKey
199
+ })
200
+ let haveIndex = errorResult.findIndex((it) => {
201
+ return (
202
+ it.tableName === curSubConfig.desc &&
203
+ it.fieldName === subItem.desc
204
+ )
205
+ })
206
+ if (haveIndex === -1) {
207
+ errorResult.push({
208
+ tableName: curSubConfig.desc,
209
+ index: index + 1,
210
+ fieldName: subItem.desc,
211
+ })
212
+ }
213
+ }
214
+ })
215
+ })
216
+ }
217
+ })
218
+ if (errorResult.length > 0) {
219
+ const messages = errorResult.map((k) => {
220
+ return `${k.tableName},【${k.fieldName}】必填`
221
+ })
222
+ // 判断是移动端还是pc
223
+ if (utils.isMobile()) {
224
+ Notify({
225
+ message: messages.join('\n'),
226
+ background: '#f25130',
227
+ })
228
+ } else {
229
+ Notification.error({
230
+ title: this.$t('ht.common.warmTips'),
231
+ dangerouslyUseHTMLString: true,
232
+ message: messages.join('<br/>'),
233
+ })
234
+ }
235
+ resolve(false)
236
+ } else {
237
+ resolve(true)
238
+ }
239
+ })
240
+ },
142
241
  init() {
143
242
  this.currentComponent = 'runtimeTemplate_' + this.scopeName
144
243
  this.loadStatus = 1
@@ -182,6 +281,11 @@
182
281
  default: false,
183
282
  },
184
283
  },
284
+ data() {
285
+ return {
286
+ subDivCollapse: [],
287
+ }
288
+ },
185
289
  template: this.html,
186
290
  })
187
291
  },
@@ -189,6 +293,29 @@
189
293
  }
190
294
  </script>
191
295
  <style lang="scss">
296
+ .is-mobile-online-form {
297
+ .ht-form-item {
298
+ .el-form-item__label {
299
+ width: 76px !important;
300
+ overflow: hidden;
301
+ text-overflow: ellipsis;
302
+ white-space: nowrap;
303
+ text-align: left;
304
+ > span {
305
+ display: inline-block;
306
+ max-width: 100%;
307
+ font-size: 14px;
308
+ color: #656a72;
309
+ margin-left: 0 !important;
310
+ overflow: hidden;
311
+ text-overflow: ellipsis;
312
+ }
313
+ }
314
+ .el-form-item__content {
315
+ margin-left: 76px !important;
316
+ }
317
+ }
318
+ }
192
319
  .transition {
193
320
  outline: 1px dotted #85a5ff;
194
321
  outline-width: 2px;
@@ -308,7 +435,7 @@
308
435
  width: 100%;
309
436
  }
310
437
  .el-input {
311
- width: 100% !important;
438
+ width: 100%;
312
439
  }
313
440
  .amap-page-container {
314
441
  .amap-toolbar,
@@ -441,6 +568,7 @@
441
568
  }
442
569
 
443
570
  .el-icon-copy-document,
571
+ .el-icon-edit,
444
572
  .el-icon-delete {
445
573
  display: inline-block;
446
574
  border: 1px solid #409eff;
@@ -449,6 +577,9 @@
449
577
  color: #409eff;
450
578
  background: #fff;
451
579
  }
580
+ .el-button + .el-button {
581
+ margin-left: 4px;
582
+ }
452
583
  }
453
584
 
454
585
  .el-icon-arrow-right:before {
@@ -522,6 +653,7 @@
522
653
  }
523
654
 
524
655
  .el-icon-copy-document,
656
+ .el-icon-edit,
525
657
  .el-icon-delete {
526
658
  display: inline-block;
527
659
  border: 1px solid #409eff;
@@ -555,6 +687,24 @@
555
687
  }
556
688
  }
557
689
  }
690
+ .sonDetail_lable_box,
691
+ .sonDetail_lable_value {
692
+ width: calc(100% - 70px);
693
+ .sonDetail_lable_item {
694
+ font-weight: 500;
695
+ }
696
+ > div {
697
+ flex: 1;
698
+ display: -webkit-box;
699
+ -webkit-box-orient: vertical;
700
+ -webkit-line-clamp: 2;
701
+ overflow: hidden;
702
+ text-overflow: ellipsis;
703
+ word-break: break-all;
704
+ line-height: normal;
705
+ text-align: center;
706
+ }
707
+ }
558
708
  }
559
709
 
560
710
  ::v-deep .el-table__header {