three-trees-ui 1.0.2 → 1.0.4

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.
@@ -278,7 +278,6 @@
278
278
  sunIndex: Number,
279
279
  subPath: String,
280
280
  currentSubData: Array,
281
- dialogConfig: Object,
282
281
  },
283
282
  data() {
284
283
  return {
@@ -350,19 +349,6 @@
350
349
  this.selectIds.length > 0 ? `(${this.selectIds.length})` : ''
351
350
  return `${this.$t('ht.common.confirm')}${selectedText}`
352
351
  },
353
- jumpParamKey() {
354
- return this.dialogConfig && this.dialogConfig.jumpParamKey
355
- ? this.dialogConfig.jumpParamKey
356
- : ''
357
- },
358
- // 是否保存成跳转url参数
359
- isHaveJumpUrl() {
360
- return (
361
- this.dialogConfig &&
362
- ((this.isMobile && this.dialogConfig.mobileUrl) ||
363
- (!this.isMobile && this.dialogConfig.pcUrl))
364
- )
365
- },
366
352
  },
367
353
  methods: {
368
354
  searchInputChange() {
@@ -410,124 +396,122 @@
410
396
  this.search(true)
411
397
  },
412
398
  showDialog() {
399
+ const this_ = this
413
400
  this.fixedParams = {}
414
- // 如果已存在配置信息就不去请求配置信息 直接初始化数据
415
- if (this.dialogConfig) {
416
- this.initDialog(this.dialogConfig)
417
- return
418
- }
419
401
  var alias = this.custdialog.custDialog.alias
420
402
  this.$requestConfig
421
403
  .getCustomDialogByAlias(alias)
422
404
  .then((customDialog) => {
423
- this.initDialog(customDialog)
424
- })
425
- },
426
- initDialog(customDialog) {
427
- let alias = this.custdialog.custDialog.alias
428
- const this_ = this
429
- if (!customDialog || !customDialog.alias) {
430
- this.$message.error('对话框别名【' + alias + '】不存在!')
431
- return
432
- }
433
- if (customDialog.style == 1) {
434
- var displaylist = JSON.parse(customDialog.displayfield)
435
- this_.nodeKey = displaylist.id
436
- }
437
- if (customDialog.needPage && customDialog.requestType === 'POST') {
438
- let obj = {}
439
- this.getLastKeyByPath(obj, customDialog.pageKey, 1)
440
- this.getLastKeyByPath(obj, customDialog.pageSizeKey, 10)
441
- this.getLastKeyByPath(obj, customDialog.totalKey, true)
442
- const exp = utils.parseExp(customDialog.dataParam, obj, true)
443
- if (exp) {
444
- const params = JSON.parse(exp)
445
- if (params.pageBean) {
446
- this.pagination = {
447
- ...params.pageBean,
448
- }
405
+ if (!customDialog || !customDialog.alias) {
406
+ this.$message.error('对话框别名【' + alias + '】不存在!')
407
+ return
449
408
  }
450
- }
451
- }
452
- //对话框按表单字段查询(参数传入的)
453
- let bindList = this_.custdialog.custDialog.conditions
454
- this_.param = [] //绑定的表单字段
455
- if (bindList.length > 0) {
456
- bindList.forEach((ele) => {
457
- //绑定表单字段
458
- if (
459
- ele.bind &&
460
- (ele.defaultType == '3' || ele.bind.startsWith('data.searchForm'))
461
- ) {
409
+ if (customDialog.style == 1) {
410
+ var displaylist = JSON.parse(customDialog.displayfield)
411
+ this_.nodeKey = displaylist.id
412
+ }
413
+ if (customDialog.needPage && customDialog.requestType === 'POST') {
462
414
  let obj = {}
463
- obj.field = ele.field
464
- obj.bind = ele.bind
465
- obj.bindType = ele.bindType
466
- this_.param.push(obj)
415
+ this.getLastKeyByPath(obj, customDialog.pageKey, 1)
416
+ this.getLastKeyByPath(obj, customDialog.pageSizeKey, 10)
417
+ this.getLastKeyByPath(obj, customDialog.totalKey, true)
418
+ const exp = utils.parseExp(customDialog.dataParam, obj, true)
419
+ if (exp) {
420
+ const params = JSON.parse(exp)
421
+ if (params.pageBean) {
422
+ this.pagination = {
423
+ ...params.pageBean,
424
+ }
425
+ }
426
+ }
467
427
  }
468
- // bindType 1 表单字段 2固定 3脚本
469
- if (ele.defaultType == '3' && ele.bindType === 2) {
470
- this_.fixedParams[ele.field] = ele.bind || ''
428
+ //对话框按表单字段查询(参数传入的)
429
+ let bindList = this_.custdialog.custDialog.conditions
430
+ this_.param = [] //绑定的表单字段
431
+ if (bindList.length > 0) {
432
+ bindList.forEach((ele) => {
433
+ //绑定表单字段
434
+ if (
435
+ ele.bind &&
436
+ (ele.defaultType == '3' ||
437
+ ele.bind.startsWith('data.searchForm'))
438
+ ) {
439
+ let obj = {}
440
+ obj.field = ele.field
441
+ obj.bind = ele.bind
442
+ obj.bindType = ele.bindType
443
+ this_.param.push(obj)
444
+ }
445
+ // bindType 1 表单字段 2固定 3脚本
446
+ if (ele.defaultType == '3' && ele.bindType === 2) {
447
+ this_.fixedParams[ele.field] = ele.bind || ''
448
+ }
449
+ })
471
450
  }
472
- })
473
- }
474
451
 
475
- //判断对话框查询是否有条件
476
- let userInputList = JSON.parse(customDialog.conditionfield)
477
- this_.conditionBind = []
478
- let queryParams = []
479
- let placeholders = []
480
- if (userInputList.length > 0) {
481
- userInputList.forEach((ele) => {
482
- var obj = {}
483
- //条件查询参数(用户输入的) 文本框输入 defaultType 1 用户输入 2固定值 3参数传入 5脚本
484
- if (ele.defaultType == '1') {
485
- obj[ele.field] = ''
486
- queryParams.push(obj)
487
- // queryParams[ele.field] = "";
488
- this_.conditionBind.push(ele)
489
- placeholders.push('请输入' + ele.comment)
490
- }
491
- if (ele.defaultType == '2' && ele.defaultValue) {
492
- this_.fixedParams[ele.field] = ele.defaultValue
452
+ //判断对话框查询是否有条件
453
+ let userInputList = JSON.parse(customDialog.conditionfield)
454
+ this_.conditionBind = []
455
+ let queryParams = []
456
+ let placeholders = []
457
+ if (userInputList.length > 0) {
458
+ userInputList.forEach((ele) => {
459
+ var obj = {}
460
+ //条件查询参数(用户输入的) 文本框输入 defaultType 1 用户输入 2固定值 3参数传入 5脚本
461
+ if (ele.defaultType == '1') {
462
+ obj[ele.field] = ''
463
+ queryParams.push(obj)
464
+ // queryParams[ele.field] = "";
465
+ this_.conditionBind.push(ele)
466
+ placeholders.push('请输入' + ele.comment)
467
+ }
468
+ if (ele.defaultType == '2' && ele.defaultValue) {
469
+ this_.fixedParams[ele.field] = ele.defaultValue
470
+ }
471
+ })
472
+ this.$set(this, 'queryParams', queryParams)
473
+ this.$set(this, 'placeholders', placeholders)
493
474
  }
494
- })
495
- this.$set(this, 'queryParams', queryParams)
496
- this.$set(this, 'placeholders', placeholders)
497
- }
498
- if (customDialog.style == 0 || customDialog.style == 2) {
499
- //列表
500
- this_.customDialogShow({
501
- alias: alias,
502
- customDialog: customDialog,
503
- })
504
- } else if (customDialog.style == 1) {
505
- //树形
506
- this_.pageParam = { alias: alias, customDialog: customDialog }
507
- this_.customDialog = customDialog
508
- let param = {}
509
- this_.conditionfieldTree = []
510
- //判断是否存在条件
511
- if (customDialog.conditionfield) {
512
- this_.conditionfieldTree = JSON.parse(customDialog.conditionfield)
513
- if (this_.conditionfieldTree.length > 0) {
514
- for (let i = this_.conditionfieldTree.length - 1; i >= 0; i--) {
515
- //判断条件字段是否是动态传入(defaultType:4:动态传入,2:固定值 )
516
- if (this_.conditionfieldTree[i].defaultType == '4') {
517
- param[this_.conditionfieldTree[i].field] =
518
- this_.conditionfieldTree[i].comment
475
+ if (customDialog.style == 0 || customDialog.style == 2) {
476
+ //列表
477
+ this_.customDialogShow({
478
+ alias: alias,
479
+ customDialog: customDialog,
480
+ })
481
+ } else if (customDialog.style == 1) {
482
+ //树形
483
+ this_.pageParam = { alias: alias, customDialog: customDialog }
484
+ this_.customDialog = customDialog
485
+ let param = {}
486
+ this_.conditionfieldTree = []
487
+ //判断是否存在条件
488
+ if (customDialog.conditionfield) {
489
+ this_.conditionfieldTree = JSON.parse(
490
+ customDialog.conditionfield
491
+ )
492
+ if (this_.conditionfieldTree.length > 0) {
493
+ for (
494
+ let i = this_.conditionfieldTree.length - 1;
495
+ i >= 0;
496
+ i--
497
+ ) {
498
+ //判断条件字段是否是动态传入(defaultType:4:动态传入,2:固定值
499
+ if (this_.conditionfieldTree[i].defaultType == '4') {
500
+ param[this_.conditionfieldTree[i].field] =
501
+ this_.conditionfieldTree[i].comment
502
+ }
503
+ }
519
504
  }
520
505
  }
506
+ //有动态传入的字段
507
+ if (JSON.stringify(param) != '{}') {
508
+ this_.dialogVisible = true
509
+ } else {
510
+ //无动态传入的字段
511
+ this_.customDialogTreeShow(this_.pageParam)
512
+ }
521
513
  }
522
- }
523
- //有动态传入的字段
524
- if (JSON.stringify(param) != '{}') {
525
- this_.dialogVisible = true
526
- } else {
527
- //无动态传入的字段
528
- this_.customDialogTreeShow(this_.pageParam)
529
- }
530
- }
514
+ })
531
515
  },
532
516
  treeClick(data) {
533
517
  // 单选
@@ -664,22 +648,13 @@
664
648
  }
665
649
  // 添加用户id 岗位id 组织id
666
650
  try {
667
- if (
668
- this.$requestConfig.getUserId &&
669
- this.$requestConfig.getUserId()
670
- ) {
651
+ if (this.$requestConfig.getUserId()) {
671
652
  ctx.userId = this.$requestConfig.getUserId()
672
653
  }
673
- if (
674
- this.$requestConfig.getOrgId &&
675
- this.$requestConfig.getOrgId()
676
- ) {
654
+ if (this.$requestConfig.getOrgId()) {
677
655
  ctx.orgId = this.$requestConfig.getOrgId()
678
656
  }
679
- if (
680
- this.$requestConfig.getPostId &&
681
- this.$requestConfig.getPostId()
682
- ) {
657
+ if (this.$requestConfig.getPostId()) {
683
658
  ctx.postId = this.$requestConfig.getPostId()
684
659
  }
685
660
  } catch (e) {
@@ -776,19 +751,8 @@
776
751
  this.selectOrgs = this.convertComment2Field(str, field)
777
752
  this.custdialog.custDialog.mappingConf.forEach((con) => {
778
753
  var val = ''
779
- str.forEach((item, index) => {
780
- // 此处添加url跳转参数保存逻辑
781
- if (
782
- this.jumpParamKey &&
783
- this.isHaveJumpUrl &&
784
- this.modelName == 'data.' + con['target'][0]
785
- ) {
786
- val += `${item[con.from]}¯${this.jumpParamKey}:${
787
- this.selectOrgs[index][this.jumpParamKey]
788
- },`
789
- } else {
790
- val += item[con.from] + ','
791
- }
754
+ str.forEach((item) => {
755
+ val += item[con.from] + ','
792
756
  })
793
757
  if (this.modelName == 'data.' + con['target'][0]) {
794
758
  utils.setValueByPath(
@@ -948,22 +912,13 @@
948
912
  ctx.total = pageBean.pageBean.total
949
913
  // 添加用户id 岗位id 组织id
950
914
  try {
951
- if (
952
- this.$requestConfig.getUserId &&
953
- this.$requestConfig.getUserId()
954
- ) {
915
+ if (this.$requestConfig.getUserId()) {
955
916
  ctx.userId = this.$requestConfig.getUserId()
956
917
  }
957
- if (
958
- this.$requestConfig.getOrgId &&
959
- this.$requestConfig.getOrgId()
960
- ) {
918
+ if (this.$requestConfig.getOrgId()) {
961
919
  ctx.orgId = this.$requestConfig.getOrgId()
962
920
  }
963
- if (
964
- this.$requestConfig.getPostId &&
965
- this.$requestConfig.getPostId()
966
- ) {
921
+ if (this.$requestConfig.getPostId()) {
967
922
  ctx.postId = this.$requestConfig.getPostId()
968
923
  }
969
924
  } catch (e) {
@@ -1256,17 +1211,7 @@
1256
1211
  var from = con.from.toLowerCase()
1257
1212
  str.forEach((item) => {
1258
1213
  if (item) {
1259
- if (
1260
- this.jumpParamKey &&
1261
- this.isHaveJumpUrl &&
1262
- this.modelName == 'data.' + con['target'][0]
1263
- ) {
1264
- val += `${decodeURIComponent(item[from])}¯${
1265
- this.jumpParamKey
1266
- }:${item[this.jumpParamKey]},`
1267
- } else {
1268
- val += decodeURIComponent(item[from]) + ','
1269
- }
1214
+ val += decodeURIComponent(item[from]) + ','
1270
1215
  }
1271
1216
  })
1272
1217
  if (this.modelName == 'data.' + con['target'][0]) {
@@ -22,14 +22,9 @@
22
22
  v-for="(item, index) in inputVal"
23
23
  :key="item.value"
24
24
  class="el-tag el-tag--info el-tag--small"
25
- @click.stop="jumpUrl(item)"
25
+ @click="showEditInput"
26
26
  >
27
- <span
28
- class="el-select__tags-text"
29
- :class="{ 'src-color': isSrcColor }"
30
- >
31
- {{ item.value }}
32
- </span>
27
+ <span class="el-select__tags-text">{{ item.value }}</span>
33
28
  <i
34
29
  class="el-tag__close el-icon-close"
35
30
  @click.stop="removeSelectOrg(index)"
@@ -99,11 +94,9 @@
99
94
  :key="item.value"
100
95
  class="el-tag el-tag--info el-tag--small"
101
96
  style="margin-right: 8px"
102
- @click.stop="jumpUrl(item)"
97
+ @click.stop
103
98
  >
104
- <span class="el-select__tags-text" :class="{ 'src-color': isSrcColor }">
105
- {{ item.value }}
106
- </span>
99
+ <span class="el-select__tags-text">{{ item.value }}</span>
107
100
  </span>
108
101
  </span>
109
102
  <custom-mobile-dialog
@@ -115,7 +108,6 @@
115
108
  :sun-index="sunIndex"
116
109
  :sub-path="subPath"
117
110
  :current-sub-data="currentSubData"
118
- :dialog-config="dialogConfig"
119
111
  @calacInputSuffixHeight="calacInputSuffixHeight"
120
112
  @updateInput="updateInput"
121
113
  ></custom-mobile-dialog>
@@ -130,7 +122,6 @@
130
122
  :sub-path="subPath"
131
123
  :current-sub-data="currentSubData"
132
124
  :is-read-only="!inputWriteable"
133
- :dialog-config="dialogConfig"
134
125
  @calacInputSuffixHeight="calacInputSuffixHeight"
135
126
  @updateInput="updateInput"
136
127
  ></custom-dialog>
@@ -171,7 +162,6 @@
171
162
  },
172
163
  data() {
173
164
  return {
174
- dialogConfig: null, // 对话框配置信息
175
165
  isEditInputShow: false,
176
166
  customValue: '',
177
167
  defualtTooltipplacement: 'bottom',
@@ -211,19 +201,7 @@
211
201
  }
212
202
  let result = []
213
203
  nameAry.forEach((m) => {
214
- // 带url跳转参数的 使用上横杆区分参数 值格式为 名称¯跳转key:跳转value
215
- let n = {}
216
- if (m.includes('¯') && m.split('¯')[1]) {
217
- n.value = m.split('¯')[0]
218
- let jumpParamStr = m.split('¯')[1]
219
- if (jumpParamStr) {
220
- let jumpParam = jumpParamStr.split(':')
221
- n.jumpParamKey = jumpParam[0]
222
- n.jumpParamValue = jumpParam[1]
223
- }
224
- } else {
225
- n = { value: m }
226
- }
204
+ let n = { value: m }
227
205
  result.push(n)
228
206
  })
229
207
  return result
@@ -232,18 +210,6 @@
232
210
  isAllowCustom() {
233
211
  return this.custdialog && this.custdialog.allowInput
234
212
  },
235
- // 是否展示可跳转颜色
236
- isSrcColor() {
237
- return (
238
- this.dialogConfig &&
239
- ((this.isMobile && this.dialogConfig.mobileUrl) ||
240
- (!this.isMobile && this.dialogConfig.pcUrl))
241
- )
242
- },
243
- },
244
- created() {
245
- // 获取对话框配置,看是否有配置url跳转
246
- this.getDialogConfig()
247
213
  },
248
214
  mounted() {
249
215
  const { subScopeEl } = utils.getSubScopeElAndIndex(this.$el)
@@ -268,72 +234,6 @@
268
234
  this.calacInputSuffixWidth()
269
235
  },
270
236
  methods: {
271
- // 跳转url页面
272
- jumpUrl(item) {
273
- if (!this.dialogConfig || !this.dialogConfig.pcUrl) {
274
- return
275
- }
276
- let url = this.isMobile
277
- ? this.dialogConfig.mobileUrl
278
- : this.dialogConfig.pcUrl
279
- // 获取通用token 和 url翻译
280
- Promise.all([
281
- this.$requestConfig.getThreeTreeToken(),
282
- this.transformUrl(url),
283
- ]).then((res) => {
284
- if (res[0] && res[0].code == 200) {
285
- let token = res[0].value
286
- let endUrl = res[1]
287
- // 拼接参数 token和参数
288
- if (endUrl.indexOf('?') == -1) {
289
- endUrl += `?bnsToken=${token}&${item.jumpParamKey}=${item.jumpParamValue}`
290
- } else {
291
- endUrl += `&bnsToken=${token}&${item.jumpParamKey}=${item.jumpParamValue}`
292
- }
293
- window.open(endUrl)
294
- } else {
295
- this.$message.info(res.message || '获取token失败!')
296
- }
297
- })
298
- },
299
- // 替换url中域名通配符 需要发送接口
300
- transformUrl(url) {
301
- return new Promise((resolve) => {
302
- var reg = /(\$\{(\w+)\})/
303
- var match = reg.exec(url)
304
- if (match) {
305
- let alias = match[2]
306
- if (alias) {
307
- this.$requestConfig.getHostByAlias(alias).then((res) => {
308
- if (res && res.value && res.value.rootAddress) {
309
- resolve(url.replace(match[1], res.value.rootAddress))
310
- } else {
311
- resolve(url)
312
- }
313
- })
314
- } else {
315
- resolve(url)
316
- }
317
- } else {
318
- resolve(url)
319
- }
320
- })
321
- },
322
- // 获取对话框配置
323
- getDialogConfig() {
324
- if (
325
- this.custdialog &&
326
- this.custdialog.custDialog &&
327
- this.custdialog.custDialog.alias
328
- )
329
- this.$requestConfig
330
- .getCustomDialogByAlias(this.custdialog.custDialog.alias)
331
- .then((response) => {
332
- if (response) {
333
- this.dialogConfig = response
334
- }
335
- })
336
- },
337
237
  editInputBlur() {
338
238
  this.$emit('input', this.customValue)
339
239
  this.isEditInputShow = false
@@ -583,8 +483,4 @@
583
483
  display: block;
584
484
  margin: 8px 0;
585
485
  }
586
- .src-color {
587
- cursor: pointer;
588
- color: #409eff;
589
- }
590
486
  </style>