three-trees-ui 1.0.99 → 1.1.1

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,9 +1,9 @@
1
1
  <template>
2
- <div name="online-form" :class="{ 'is-mobile-online-form': isMobile }">
2
+ <div name="online-form">
3
3
  <el-skeleton v-if="loadStatus == 0" :rows="6" animated />
4
4
  <component
5
- :is="currentComponent"
6
5
  v-else-if="loadStatus > 0"
6
+ v-bind:is="currentComponent"
7
7
  :name="formName"
8
8
  :data="data"
9
9
  :permission="permission"
@@ -31,15 +31,12 @@
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'
37
34
 
38
35
  import Vue from 'vue'
39
36
  export default {
40
37
  name: 'HtOnlineForm',
41
38
  componentName: 'HtOnlineForm',
42
- mixins: [regionValidator, emitter, mobileMode],
39
+ mixins: [regionValidator, emitter],
43
40
  props: {
44
41
  html: String,
45
42
  data: Object,
@@ -82,9 +79,6 @@
82
79
  type: Boolean,
83
80
  default: false,
84
81
  },
85
- formExpand: {
86
- type: String,
87
- },
88
82
  },
89
83
  data() {
90
84
  return {
@@ -134,16 +128,10 @@
134
128
  } else {
135
129
  // 执行校验逻辑
136
130
  this.validateRegion(`[name='${this.formName}']`).then(
137
- async (errorItems) => {
131
+ (errorItems) => {
138
132
  if (errorItems.length > 0) {
139
133
  reject(errorItems)
140
134
  } else {
141
- // 如果有子表,需要检验子表必填
142
- let result = await this.validateTable()
143
- if (result === false) {
144
- reject(8)
145
- return
146
- }
147
135
  this.broadcast('HtGlobalValidate', 'global-validate')
148
136
  }
149
137
  }
@@ -151,93 +139,6 @@
151
139
  }
152
140
  })
153
141
  },
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
- },
241
142
  init() {
242
143
  this.currentComponent = 'runtimeTemplate_' + this.scopeName
243
144
  this.loadStatus = 1
@@ -281,11 +182,6 @@
281
182
  default: false,
282
183
  },
283
184
  },
284
- data() {
285
- return {
286
- subDivCollapse: [],
287
- }
288
- },
289
185
  template: this.html,
290
186
  })
291
187
  },
@@ -293,29 +189,6 @@
293
189
  }
294
190
  </script>
295
191
  <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
- }
319
192
  .transition {
320
193
  outline: 1px dotted #85a5ff;
321
194
  outline-width: 2px;
@@ -435,7 +308,7 @@
435
308
  width: 100%;
436
309
  }
437
310
  .el-input {
438
- width: 100%;
311
+ width: 100% !important;
439
312
  }
440
313
  .amap-page-container {
441
314
  .amap-toolbar,
@@ -568,7 +441,6 @@
568
441
  }
569
442
 
570
443
  .el-icon-copy-document,
571
- .el-icon-edit,
572
444
  .el-icon-delete {
573
445
  display: inline-block;
574
446
  border: 1px solid #409eff;
@@ -577,9 +449,6 @@
577
449
  color: #409eff;
578
450
  background: #fff;
579
451
  }
580
- .el-button + .el-button {
581
- margin-left: 4px;
582
- }
583
452
  }
584
453
 
585
454
  .el-icon-arrow-right:before {
@@ -653,7 +522,6 @@
653
522
  }
654
523
 
655
524
  .el-icon-copy-document,
656
- .el-icon-edit,
657
525
  .el-icon-delete {
658
526
  display: inline-block;
659
527
  border: 1px solid #409eff;
@@ -687,24 +555,6 @@
687
555
  }
688
556
  }
689
557
  }
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
- }
708
558
  }
709
559
 
710
560
  ::v-deep .el-table__header {
@@ -16,23 +16,35 @@
16
16
  @click="showDialog"
17
17
  >
18
18
  <div
19
- v-if="inputWriteable"
20
- class="el-input el-input--suffix"
21
- :class="{ 'custom-selector-mobile': isMobile }"
19
+ ref="tagSpans"
20
+ style="width: calc(100% - 25px);"
21
+ :class="{
22
+ 'el-select__tags_readonly': !inputWriteable,
23
+ 'el-select__tags': inputWriteable,
24
+ }"
22
25
  >
23
- <div v-if="isMobile" class="custom-selector-mobile-box">
24
- <div
26
+ <span class="tag-wrap">
27
+ <span
25
28
  v-for="(item, index) in selectors"
26
29
  :key="index"
27
- class="common-selector-tag"
30
+ class="el-tag el-tag--info el-tag--small"
31
+ @click.stop
28
32
  >
29
- <span>{{ item.name }}</span>
30
- <i class="el-icon-error" @click.stop="handleRemove(item)"></i>
31
- </div>
32
- </div>
33
+ <span class="el-select__tags-text">
34
+ {{ showPath ? item.pathName : item.name }}
35
+ </span>
36
+ <i
37
+ v-if="inputWriteable"
38
+ class="el-tag__close el-icon-close"
39
+ @click="handleRemove(item)"
40
+ ></i>
41
+ </span>
42
+ </span>
43
+ </div>
44
+ <div v-if="inputWriteable" class="el-input el-input--suffix">
33
45
  <input
34
46
  ref="inputEl"
35
- v-model="calcInputValue"
47
+ v-model="value"
36
48
  v-validate="inputValidate"
37
49
  type="text"
38
50
  readonly="readonly"
@@ -40,6 +52,10 @@
40
52
  autocomplete="off"
41
53
  class="el-input__inner"
42
54
  :placeholder="placeholder"
55
+ :style="{
56
+ height: inputSuffixHeight + 'px',
57
+ lineHeight: inputSuffixHeight + 'px',
58
+ }"
43
59
  />
44
60
  <span class="el-input__suffix">
45
61
  <span class="el-input__suffix-inner">
@@ -48,56 +64,51 @@
48
64
  </span>
49
65
  </span>
50
66
  </div>
51
- <div v-else class="el-select__tags_readonly">
52
- <span>{{ calcInputValue }}</span>
53
- </div>
54
67
  </div>
55
68
  <ht-field-tail :field-name="inputName" :input-value="value" />
56
- <template v-if="isDialogShow">
57
- <org-selector-dialog
58
- v-if="!isMobile"
59
- ref="orgSelectorDialog"
60
- v-model="selectors"
61
- :title="title"
62
- :append-to-body="appendToBody"
63
- :data="data"
64
- :pagination="pagination"
65
- :select-label="selectLabel"
66
- :quick-search-props="quickSearchProps"
67
- :single="single"
68
- :search-placeholder="searchPlaceholder"
69
- :primary-field="primaryField"
70
- :mode="mode"
71
- @filter-type-change="(type) => $emit('filter-type-change', type)"
72
- @search="(word) => $emit('search', word)"
73
- @reset="() => $emit('reset')"
74
- @row-click="(row) => $emit('row-click', row)"
75
- @select-data="(data) => $emit('select-data', data)"
76
- @page-change="(page) => $emit('page-change', page)"
77
- @size-change="(size) => $emit('size-change', size)"
78
- @contact-group-change="(group) => $emit('contact-group-change', group)"
79
- @load-org="(org) => $emit('load-org', org)"
80
- @load-policy-org="(policy) => $emit('load-policy-org', policy)"
81
- />
82
- <org-selector-mobile-dialog
83
- v-else
84
- ref="orgSelectorMobileDialog"
85
- v-model="selectors"
86
- :title="title"
87
- :append-to-body="appendToBody"
88
- :data="data"
89
- :pagination="pagination"
90
- :select-label="selectLabel"
91
- :single="single"
92
- :search-placeholder="searchPlaceholder"
93
- :primary-field="primaryField"
94
- @search="(word) => $emit('search', word)"
95
- @reset="() => $emit('reset')"
96
- @row-click="(row) => $emit('row-click', row)"
97
- @select-data="(data) => $emit('select-data', data)"
98
- @page-change="(page) => $emit('page-change', page)"
99
- />
100
- </template>
69
+ <org-selector-dialog
70
+ v-if="!isMobile"
71
+ ref="orgSelectorDialog"
72
+ v-model="selectors"
73
+ :title="title"
74
+ :append-to-body="appendToBody"
75
+ :data="data"
76
+ :pagination="pagination"
77
+ :select-label="selectLabel"
78
+ :quick-search-props="quickSearchProps"
79
+ :single="single"
80
+ :search-placeholder="searchPlaceholder"
81
+ :primary-field="primaryField"
82
+ :mode="mode"
83
+ @filter-type-change="(type) => $emit('filter-type-change', type)"
84
+ @search="(word) => $emit('search', word)"
85
+ @reset="() => $emit('reset')"
86
+ @row-click="(row) => $emit('row-click', row)"
87
+ @select-data="(data) => $emit('select-data', data)"
88
+ @page-change="(page) => $emit('page-change', page)"
89
+ @size-change="(size) => $emit('size-change', size)"
90
+ @contact-group-change="(group) => $emit('contact-group-change', group)"
91
+ @load-org="(org) => $emit('load-org', org)"
92
+ @load-policy-org="(policy) => $emit('load-policy-org', policy)"
93
+ />
94
+ <org-selector-mobile-dialog
95
+ v-else
96
+ ref="orgSelectorMobileDialog"
97
+ v-model="selectors"
98
+ :title="title"
99
+ :append-to-body="appendToBody"
100
+ :data="data"
101
+ :pagination="pagination"
102
+ :select-label="selectLabel"
103
+ :single="single"
104
+ :search-placeholder="searchPlaceholder"
105
+ :primary-field="primaryField"
106
+ @search="(word) => $emit('search', word)"
107
+ @reset="() => $emit('reset')"
108
+ @row-click="(row) => $emit('row-click', row)"
109
+ @select-data="(data) => $emit('select-data', data)"
110
+ @page-change="(page) => $emit('page-change', page)"
111
+ />
101
112
  </div>
102
113
  </template>
103
114
  <script>
@@ -175,23 +186,11 @@
175
186
  },
176
187
  data() {
177
188
  return {
178
- isDialogShow: false,
179
189
  inputSuffixHeight: 30,
180
190
  selectors: [],
181
191
  }
182
192
  },
183
193
  computed: {
184
- calcInputValue: function() {
185
- let name = ''
186
- if (this.selectors) {
187
- name = this.selectors
188
- .map((k) => {
189
- return this.showPath ? k.pathName : k.name
190
- })
191
- .join(',')
192
- }
193
- return name
194
- },
195
194
  primaryField: function() {
196
195
  return this.config && this.config.hasOwnProperty('id')
197
196
  ? 'id'
@@ -263,8 +262,14 @@
263
262
  // 通过valueChange事件发布值变更消息
264
263
  this.$emit('valueChange', ary.join(','), newVal)
265
264
  setTimeout(() => {
265
+ if (newVal.length > 0) {
266
+ this.calacInputSuffixHeight()
267
+ } else {
268
+ this.inputSuffixHeight = 30
269
+ }
266
270
  if (this.$refs.inputEl) {
267
- this.$validator.validate(this.inputName)
271
+ this.$refs.inputEl.focus()
272
+ this.$refs.inputEl.blur()
268
273
  }
269
274
  }, 10)
270
275
  },
@@ -345,14 +350,10 @@
345
350
  this.selectors = tmpAry
346
351
  }
347
352
  },
348
- async showDialog() {
353
+ showDialog() {
349
354
  if (!this.inputWriteable) {
350
355
  return
351
356
  }
352
- if (this.isDialogShow === false) {
353
- this.isDialogShow = true
354
- await this.$nextTick()
355
- }
356
357
  if (this.isMobile) {
357
358
  this.$refs.orgSelectorMobileDialog.showDialog()
358
359
  } else {
@@ -368,12 +369,12 @@
368
369
  },
369
370
  // 更新当前输入框的高度来适配已选数据的高度
370
371
  calacInputSuffixHeight() {
371
- // if (!this.$refs.tagSpans) return
372
- // if (this.$refs.tagSpans.offsetHeight) {
373
- // this.inputSuffixHeight = this.$refs.tagSpans.offsetHeight + 5
374
- // } else {
375
- // this.inputSuffixHeight = 30
376
- // }
372
+ if (!this.$refs.tagSpans) return
373
+ if (this.$refs.tagSpans.offsetHeight) {
374
+ this.inputSuffixHeight = this.$refs.tagSpans.offsetHeight + 5
375
+ } else {
376
+ this.inputSuffixHeight = 30
377
+ }
377
378
  },
378
379
  },
379
380
  }
@@ -390,10 +391,7 @@
390
391
  position: relative;
391
392
  top: 50%;
392
393
  }
393
- .el-input__inner {
394
- height: 32px;
395
- line-height: 32px;
396
- }
394
+
397
395
  .el-input__inner[aria-invalid='true'] {
398
396
  border-color: #f56c6c;
399
397
  }