three-trees-ui 1.0.0 → 1.0.2

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,6 +278,7 @@
278
278
  sunIndex: Number,
279
279
  subPath: String,
280
280
  currentSubData: Array,
281
+ dialogConfig: Object,
281
282
  },
282
283
  data() {
283
284
  return {
@@ -349,6 +350,19 @@
349
350
  this.selectIds.length > 0 ? `(${this.selectIds.length})` : ''
350
351
  return `${this.$t('ht.common.confirm')}${selectedText}`
351
352
  },
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
+ },
352
366
  },
353
367
  methods: {
354
368
  searchInputChange() {
@@ -396,122 +410,124 @@
396
410
  this.search(true)
397
411
  },
398
412
  showDialog() {
399
- const this_ = this
400
413
  this.fixedParams = {}
414
+ // 如果已存在配置信息就不去请求配置信息 直接初始化数据
415
+ if (this.dialogConfig) {
416
+ this.initDialog(this.dialogConfig)
417
+ return
418
+ }
401
419
  var alias = this.custdialog.custDialog.alias
402
420
  this.$requestConfig
403
421
  .getCustomDialogByAlias(alias)
404
422
  .then((customDialog) => {
405
- if (!customDialog || !customDialog.alias) {
406
- this.$message.error('对话框别名【' + alias + '】不存在!')
407
- return
408
- }
409
- if (customDialog.style == 1) {
410
- var displaylist = JSON.parse(customDialog.displayfield)
411
- this_.nodeKey = displaylist.id
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
+ }
412
449
  }
413
- if (customDialog.needPage && customDialog.requestType === 'POST') {
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
+ ) {
414
462
  let 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
- }
463
+ obj.field = ele.field
464
+ obj.bind = ele.bind
465
+ obj.bindType = ele.bindType
466
+ this_.param.push(obj)
427
467
  }
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
- })
468
+ // bindType 1 表单字段 2固定 3脚本
469
+ if (ele.defaultType == '3' && ele.bindType === 2) {
470
+ this_.fixedParams[ele.field] = ele.bind || ''
450
471
  }
472
+ })
473
+ }
451
474
 
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)
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)
474
490
  }
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
- }
491
+ if (ele.defaultType == '2' && ele.defaultValue) {
492
+ this_.fixedParams[ele.field] = ele.defaultValue
493
+ }
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
+ //判断条件字段是否是动态传入(defaultType4:动态传入,2:固定值
516
+ if (this_.conditionfieldTree[i].defaultType == '4') {
517
+ param[this_.conditionfieldTree[i].field] =
518
+ this_.conditionfieldTree[i].comment
504
519
  }
505
520
  }
506
- //有动态传入的字段
507
- if (JSON.stringify(param) != '{}') {
508
- this_.dialogVisible = true
509
- } else {
510
- //无动态传入的字段
511
- this_.customDialogTreeShow(this_.pageParam)
512
- }
513
521
  }
514
- })
522
+ }
523
+ //有动态传入的字段
524
+ if (JSON.stringify(param) != '{}') {
525
+ this_.dialogVisible = true
526
+ } else {
527
+ //无动态传入的字段
528
+ this_.customDialogTreeShow(this_.pageParam)
529
+ }
530
+ }
515
531
  },
516
532
  treeClick(data) {
517
533
  // 单选
@@ -648,13 +664,22 @@
648
664
  }
649
665
  // 添加用户id 岗位id 组织id
650
666
  try {
651
- if (this.$requestConfig.getUserId()) {
667
+ if (
668
+ this.$requestConfig.getUserId &&
669
+ this.$requestConfig.getUserId()
670
+ ) {
652
671
  ctx.userId = this.$requestConfig.getUserId()
653
672
  }
654
- if (this.$requestConfig.getOrgId()) {
673
+ if (
674
+ this.$requestConfig.getOrgId &&
675
+ this.$requestConfig.getOrgId()
676
+ ) {
655
677
  ctx.orgId = this.$requestConfig.getOrgId()
656
678
  }
657
- if (this.$requestConfig.getPostId()) {
679
+ if (
680
+ this.$requestConfig.getPostId &&
681
+ this.$requestConfig.getPostId()
682
+ ) {
658
683
  ctx.postId = this.$requestConfig.getPostId()
659
684
  }
660
685
  } catch (e) {
@@ -751,8 +776,19 @@
751
776
  this.selectOrgs = this.convertComment2Field(str, field)
752
777
  this.custdialog.custDialog.mappingConf.forEach((con) => {
753
778
  var val = ''
754
- str.forEach((item) => {
755
- val += item[con.from] + ','
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
+ }
756
792
  })
757
793
  if (this.modelName == 'data.' + con['target'][0]) {
758
794
  utils.setValueByPath(
@@ -912,13 +948,22 @@
912
948
  ctx.total = pageBean.pageBean.total
913
949
  // 添加用户id 岗位id 组织id
914
950
  try {
915
- if (this.$requestConfig.getUserId()) {
951
+ if (
952
+ this.$requestConfig.getUserId &&
953
+ this.$requestConfig.getUserId()
954
+ ) {
916
955
  ctx.userId = this.$requestConfig.getUserId()
917
956
  }
918
- if (this.$requestConfig.getOrgId()) {
957
+ if (
958
+ this.$requestConfig.getOrgId &&
959
+ this.$requestConfig.getOrgId()
960
+ ) {
919
961
  ctx.orgId = this.$requestConfig.getOrgId()
920
962
  }
921
- if (this.$requestConfig.getPostId()) {
963
+ if (
964
+ this.$requestConfig.getPostId &&
965
+ this.$requestConfig.getPostId()
966
+ ) {
922
967
  ctx.postId = this.$requestConfig.getPostId()
923
968
  }
924
969
  } catch (e) {
@@ -1211,7 +1256,17 @@
1211
1256
  var from = con.from.toLowerCase()
1212
1257
  str.forEach((item) => {
1213
1258
  if (item) {
1214
- val += decodeURIComponent(item[from]) + ','
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
+ }
1215
1270
  }
1216
1271
  })
1217
1272
  if (this.modelName == 'data.' + con['target'][0]) {
@@ -22,9 +22,14 @@
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="showEditInput"
25
+ @click.stop="jumpUrl(item)"
26
26
  >
27
- <span class="el-select__tags-text">{{ item.value }}</span>
27
+ <span
28
+ class="el-select__tags-text"
29
+ :class="{ 'src-color': isSrcColor }"
30
+ >
31
+ {{ item.value }}
32
+ </span>
28
33
  <i
29
34
  class="el-tag__close el-icon-close"
30
35
  @click.stop="removeSelectOrg(index)"
@@ -94,9 +99,11 @@
94
99
  :key="item.value"
95
100
  class="el-tag el-tag--info el-tag--small"
96
101
  style="margin-right: 8px"
97
- @click.stop
102
+ @click.stop="jumpUrl(item)"
98
103
  >
99
- <span class="el-select__tags-text">{{ item.value }}</span>
104
+ <span class="el-select__tags-text" :class="{ 'src-color': isSrcColor }">
105
+ {{ item.value }}
106
+ </span>
100
107
  </span>
101
108
  </span>
102
109
  <custom-mobile-dialog
@@ -108,6 +115,7 @@
108
115
  :sun-index="sunIndex"
109
116
  :sub-path="subPath"
110
117
  :current-sub-data="currentSubData"
118
+ :dialog-config="dialogConfig"
111
119
  @calacInputSuffixHeight="calacInputSuffixHeight"
112
120
  @updateInput="updateInput"
113
121
  ></custom-mobile-dialog>
@@ -121,6 +129,8 @@
121
129
  :sun-index="sunIndex"
122
130
  :sub-path="subPath"
123
131
  :current-sub-data="currentSubData"
132
+ :is-read-only="!inputWriteable"
133
+ :dialog-config="dialogConfig"
124
134
  @calacInputSuffixHeight="calacInputSuffixHeight"
125
135
  @updateInput="updateInput"
126
136
  ></custom-dialog>
@@ -161,6 +171,7 @@
161
171
  },
162
172
  data() {
163
173
  return {
174
+ dialogConfig: null, // 对话框配置信息
164
175
  isEditInputShow: false,
165
176
  customValue: '',
166
177
  defualtTooltipplacement: 'bottom',
@@ -200,7 +211,19 @@
200
211
  }
201
212
  let result = []
202
213
  nameAry.forEach((m) => {
203
- let n = { value: 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
227
  result.push(n)
205
228
  })
206
229
  return result
@@ -209,6 +232,18 @@
209
232
  isAllowCustom() {
210
233
  return this.custdialog && this.custdialog.allowInput
211
234
  },
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()
212
247
  },
213
248
  mounted() {
214
249
  const { subScopeEl } = utils.getSubScopeElAndIndex(this.$el)
@@ -233,6 +268,72 @@
233
268
  this.calacInputSuffixWidth()
234
269
  },
235
270
  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
+ },
236
337
  editInputBlur() {
237
338
  this.$emit('input', this.customValue)
238
339
  this.isEditInputShow = false
@@ -482,4 +583,8 @@
482
583
  display: block;
483
584
  margin: 8px 0;
484
585
  }
586
+ .src-color {
587
+ cursor: pointer;
588
+ color: #409eff;
589
+ }
485
590
  </style>