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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-trees-ui",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "publicPath": "/ui",
5
5
  "author": "hotent",
6
6
  "private": false,
@@ -139,6 +139,7 @@
139
139
  class="org-table"
140
140
  size="medium"
141
141
  style="width: 100%"
142
+ :height="tableHeight"
142
143
  @row-click="orgRowClick"
143
144
  @selection-change="orgTableSelection"
144
145
  @select="onTableSelect"
@@ -323,9 +324,15 @@
323
324
  sunIndex: Number,
324
325
  subPath: String,
325
326
  currentSubData: Array,
327
+ isReadOnly: {
328
+ type: Boolean,
329
+ default: false,
330
+ },
331
+ dialogConfig: Object,
326
332
  },
327
333
  data() {
328
334
  return {
335
+ tableHeight: 350,
329
336
  isEditInputShow: false,
330
337
  customValue: '',
331
338
  defualtTooltipplacement: 'bottom',
@@ -396,6 +403,19 @@
396
403
  }
397
404
  return []
398
405
  },
406
+ jumpParamKey() {
407
+ return this.dialogConfig && this.dialogConfig.jumpParamKey
408
+ ? this.dialogConfig.jumpParamKey
409
+ : ''
410
+ },
411
+ // 是否保存成跳转url参数
412
+ isHaveJumpUrl() {
413
+ return (
414
+ this.dialogConfig &&
415
+ ((this.isMobile && this.dialogConfig.mobileUrl) ||
416
+ (!this.isMobile && this.dialogConfig.pcUrl))
417
+ )
418
+ },
399
419
  },
400
420
  watch: {
401
421
  dialogData: {
@@ -416,154 +436,170 @@
416
436
  })
417
437
  }
418
438
  }
439
+ this.initTableHeight()
419
440
  },
420
441
  immediate: true,
421
442
  deep: true,
422
443
  },
423
444
  },
424
445
  mounted() {
425
- if (this.value) {
426
- this.showDialog(true)
427
- }
446
+ this.$root.$on('resize', () => {
447
+ this.initTableHeight()
448
+ })
449
+ this.$nextTick(() => {
450
+ if (this.value && !this.isReadOnly) {
451
+ this.showDialog(true)
452
+ }
453
+ })
428
454
  },
429
455
  methods: {
430
456
  showDialog(isMounted = false) {
431
- const this_ = this
432
457
  this.fixedParams = {}
458
+ // 如果已存在配置信息就不去请求配置信息 直接初始化数据
459
+ if (this.dialogConfig) {
460
+ this.initDialog(this.dialogConfig, isMounted)
461
+ return
462
+ }
433
463
  var alias = this.custdialog.custDialog.alias
434
464
  this.$requestConfig
435
465
  .getCustomDialogByAlias(alias)
436
466
  .then((customDialog) => {
437
- if (!customDialog || !customDialog.alias) {
438
- this.$message.error('对话框别名【' + alias + '】不存在!')
439
- return
440
- }
441
- if (customDialog.style == 1) {
442
- var displaylist = JSON.parse(customDialog.displayfield)
443
- this_.nodeKey = displaylist.id
444
- }
445
- if (customDialog.needPage && customDialog.requestType === 'POST') {
446
- let obj = {}
447
- this.getLastKeyByPath(obj, customDialog.pageKey, 1)
448
- this.getLastKeyByPath(obj, customDialog.pageSizeKey, 10)
449
- this.getLastKeyByPath(obj, customDialog.totalKey, true)
450
- const exp = utils.parseExp(customDialog.dataParam, obj, true)
451
- if (exp) {
452
- const params = JSON.parse(exp)
453
- if (params.pageBean) {
454
- this.pagination = {
455
- ...params.pageBean,
456
- }
457
- }
467
+ this.initDialog(customDialog, isMounted)
468
+ })
469
+ },
470
+ initDialog(customDialog, isMounted) {
471
+ let alias = this.custdialog.custDialog.alias
472
+ const this_ = this
473
+ if (!customDialog || !customDialog.alias) {
474
+ this.$message.error('对话框别名【' + alias + '】不存在!')
475
+ return
476
+ }
477
+ if (customDialog.style == 1) {
478
+ var displaylist = JSON.parse(customDialog.displayfield)
479
+ this_.nodeKey = displaylist.id
480
+ }
481
+ if (customDialog.needPage && customDialog.requestType === 'POST') {
482
+ let obj = {}
483
+ this.getLastKeyByPath(obj, customDialog.pageKey, 1)
484
+ this.getLastKeyByPath(obj, customDialog.pageSizeKey, 10)
485
+ this.getLastKeyByPath(obj, customDialog.totalKey, true)
486
+ const exp = utils.parseExp(customDialog.dataParam, obj, true)
487
+ if (exp) {
488
+ const params = JSON.parse(exp)
489
+ if (params.pageBean) {
490
+ this.pagination = {
491
+ ...params.pageBean,
458
492
  }
459
493
  }
460
- //对话框按表单字段查询(参数传入的)
461
- let bindList = this_.custdialog.custDialog.conditions
462
- this_.param = [] //绑定的表单字段
463
- if (bindList.length > 0) {
464
- bindList.forEach((ele) => {
465
- //绑定表单字段
466
- if (
467
- ele.bind &&
468
- (ele.defaultType == '3' ||
469
- ele.bind.startsWith('data.searchForm'))
470
- ) {
471
- let obj = {}
472
- obj.field = ele.field
473
- obj.bind = ele.bind
474
- obj.bindType = ele.bindType
475
- this_.param.push(obj)
476
- }
477
- //取值对象为脚本时获取value
478
- if (ele.bindType === 3) {
479
- this_.$requestConfig.executeScript(ele.bind).then((res) => {
480
- this_.executeScriptResult = res && res.value
481
- })
482
- }
483
- })
494
+ }
495
+ }
496
+ //对话框按表单字段查询(参数传入的)
497
+ let bindList = this_.custdialog.custDialog.conditions
498
+ this_.param = [] //绑定的表单字段
499
+ if (bindList.length > 0) {
500
+ bindList.forEach((ele) => {
501
+ //绑定表单字段
502
+ if (
503
+ ele.bind &&
504
+ (ele.defaultType == '3' || ele.bind.startsWith('data.searchForm'))
505
+ ) {
506
+ let obj = {}
507
+ obj.field = ele.field
508
+ obj.bind = ele.bind
509
+ obj.bindType = ele.bindType
510
+ this_.param.push(obj)
484
511
  }
485
- //判断对话框查询是否有条件
486
- let userInputList = JSON.parse(customDialog.conditionfield)
487
- this_.quickSearch = '' //填写提示 placeholder
488
- this_.conditionBind = []
489
- let queryParams = []
490
- let placeholders = []
491
- if (userInputList.length > 0) {
492
- userInputList.forEach((ele) => {
493
- var obj = {}
494
- //条件查询参数(用户输入的) 文本框输入 defaultType 1 用户输入 2固定值 3参数传入 5脚本
495
- if (ele.defaultType == '1') {
496
- obj[ele.field] = ''
497
- queryParams.push(obj)
498
- // queryParams[ele.field] = "";
499
- this_.conditionBind.push(ele)
500
- placeholders.push('请输入' + ele.comment)
501
- }
502
- if (ele.defaultType == '2' && ele.defaultValue) {
503
- this_.fixedParams[ele.field] = ele.defaultValue
504
- }
512
+ //取值对象为脚本时获取value
513
+ if (ele.bindType === 3) {
514
+ this_.$requestConfig.executeScript(ele.bind).then((res) => {
515
+ this_.executeScriptResult = res && res.value
505
516
  })
506
- this.$set(this, 'queryParams', queryParams)
507
- this.$set(this, 'placeholders', placeholders)
508
517
  }
509
- //判断是否显示条件查询输入框
510
- if (this_.quickSearch != '') {
511
- this_.querysShow = true
512
- } else {
513
- this_.querysShow = true
518
+ })
519
+ }
520
+ //判断对话框查询是否有条件
521
+ let userInputList = JSON.parse(customDialog.conditionfield)
522
+ this_.quickSearch = '' //填写提示 placeholder
523
+ this_.conditionBind = []
524
+ let queryParams = []
525
+ let placeholders = []
526
+ if (userInputList.length > 0) {
527
+ userInputList.forEach((ele) => {
528
+ var obj = {}
529
+ //条件查询参数(用户输入的) 文本框输入 defaultType 1 用户输入 2固定值 3参数传入 5脚本
530
+ if (ele.defaultType == '1') {
531
+ obj[ele.field] = ''
532
+ queryParams.push(obj)
533
+ // queryParams[ele.field] = "";
534
+ this_.conditionBind.push(ele)
535
+ placeholders.push('请输入' + ele.comment)
514
536
  }
515
- this_.quickSearch = '请输入' + this.quickSearch + '查询'
516
- this_.style = 'height:' + customDialog.height + 'px'
517
- if (window.screen.height && window.screen.height <= 900) {
518
- this.style = 'height:440px'
537
+ if (ele.defaultType == '2' && ele.defaultValue) {
538
+ this_.fixedParams[ele.field] = ele.defaultValue
519
539
  }
520
- if (customDialog.style == 0 || customDialog.style == 2) {
521
- //列表
522
- setTimeout(() => {
523
- this_.customDialogShow(
524
- {
525
- alias: alias,
526
- customDialog: customDialog,
527
- },
528
- isMounted
529
- )
530
- }, 100)
531
- } else if (customDialog.style == 1) {
532
- //树形
533
- this_.pageParam = { alias: alias, customDialog: customDialog }
534
- this_.customDialog = customDialog
535
- let param = {}
536
- this_.conditionfieldTree = []
537
- //判断是否存在条件
538
- if (customDialog.conditionfield) {
539
- this_.conditionfieldTree = JSON.parse(
540
- customDialog.conditionfield
541
- )
542
- if (this_.conditionfieldTree.length > 0) {
543
- for (
544
- let i = this_.conditionfieldTree.length - 1;
545
- i >= 0;
546
- i--
547
- ) {
548
- //判断条件字段是否是动态传入(defaultType:4:动态传入,2:固定值
549
- if (this_.conditionfieldTree[i].defaultType == '4') {
550
- param[this_.conditionfieldTree[i].field] =
551
- this_.conditionfieldTree[i].comment
552
- }
553
- }
554
- }
555
- }
556
- //有动态传入的字段
557
- if (!isMounted) {
558
- if (JSON.stringify(param) != '{}') {
559
- this_.dialogVisible = true
560
- } else {
561
- //无动态传入的字段
562
- this_.customDialogTreeShow(this_.pageParam)
540
+ })
541
+ this.$set(this, 'queryParams', queryParams)
542
+ this.$set(this, 'placeholders', placeholders)
543
+ }
544
+ //判断是否显示条件查询输入框
545
+ if (this_.quickSearch != '') {
546
+ this_.querysShow = true
547
+ } else {
548
+ this_.querysShow = true
549
+ }
550
+ this_.quickSearch = '请输入' + this.quickSearch + '查询'
551
+ this_.style = 'height:' + customDialog.height + 'px'
552
+ if (window.screen.height && window.screen.height <= 900) {
553
+ this.style = 'height:440px'
554
+ }
555
+ if (customDialog.style == 0 || customDialog.style == 2) {
556
+ //列表
557
+ setTimeout(() => {
558
+ this_.customDialogShow(
559
+ {
560
+ alias: alias,
561
+ customDialog: customDialog,
562
+ },
563
+ isMounted
564
+ )
565
+ }, 100)
566
+ } else if (customDialog.style == 1) {
567
+ //树形
568
+ this_.pageParam = { alias: alias, customDialog: customDialog }
569
+ this_.customDialog = customDialog
570
+ let param = {}
571
+ this_.conditionfieldTree = []
572
+ //判断是否存在条件
573
+ if (customDialog.conditionfield) {
574
+ this_.conditionfieldTree = JSON.parse(customDialog.conditionfield)
575
+ if (this_.conditionfieldTree.length > 0) {
576
+ for (let i = this_.conditionfieldTree.length - 1; i >= 0; i--) {
577
+ //判断条件字段是否是动态传入(defaultType:4:动态传入,2:固定值
578
+ if (this_.conditionfieldTree[i].defaultType == '4') {
579
+ param[this_.conditionfieldTree[i].field] =
580
+ this_.conditionfieldTree[i].comment
563
581
  }
564
582
  }
565
583
  }
566
- })
584
+ }
585
+ //有动态传入的字段
586
+ if (!isMounted) {
587
+ if (JSON.stringify(param) != '{}') {
588
+ this_.dialogVisible = true
589
+ } else {
590
+ //无动态传入的字段
591
+ this_.customDialogTreeShow(this_.pageParam)
592
+ }
593
+ }
594
+ }
595
+ },
596
+ initTableHeight() {
597
+ this.$nextTick(() => {
598
+ let mainEl = document.getElementsByClassName('custom-dialog_main')
599
+ if (mainEl && mainEl.length) {
600
+ this.tableHeight = mainEl[0].clientHeight - 40
601
+ }
602
+ })
567
603
  },
568
604
  treeClick(data) {
569
605
  // 单选
@@ -702,13 +738,22 @@
702
738
  }
703
739
  // 添加用户id 岗位id 组织id
704
740
  try {
705
- if (this.$requestConfig.getUserId()) {
741
+ if (
742
+ this.$requestConfig.getUserId &&
743
+ this.$requestConfig.getUserId()
744
+ ) {
706
745
  ctx.userId = this.$requestConfig.getUserId()
707
746
  }
708
- if (this.$requestConfig.getOrgId()) {
747
+ if (
748
+ this.$requestConfig.getOrgId &&
749
+ this.$requestConfig.getOrgId()
750
+ ) {
709
751
  ctx.orgId = this.$requestConfig.getOrgId()
710
752
  }
711
- if (this.$requestConfig.getPostId()) {
753
+ if (
754
+ this.$requestConfig.getPostId &&
755
+ this.$requestConfig.getPostId()
756
+ ) {
712
757
  ctx.postId = this.$requestConfig.getPostId()
713
758
  }
714
759
  } catch (e) {
@@ -781,6 +826,7 @@
781
826
  if (this.customDialog.selectNum === 1) {
782
827
  nodes = this.propsData[0]
783
828
  var temp = ''
829
+ debugger
784
830
  for (var j = 0; j < comment.length; j++) {
785
831
  temp += '"' + comment[j] + '":"' + nodes[field[j]] + '",'
786
832
  }
@@ -803,10 +849,21 @@
803
849
  }
804
850
  const pInst = utils.getOnlineFormInstance(this)
805
851
  this.selectOrgs = this.convertComment2Field(str, field)
806
- this.custdialog.custDialog.mappingConf.forEach((con) => {
852
+ this.custdialog.custDialog.mappingConf.forEach((con, index) => {
807
853
  var val = ''
808
854
  str.forEach((item) => {
809
- val += item[con.from] + ','
855
+ // 此处添加url跳转参数保存逻辑
856
+ if (
857
+ this.jumpParamKey &&
858
+ this.isHaveJumpUrl &&
859
+ this.modelName == 'data.' + con['target'][0]
860
+ ) {
861
+ val += `${item[con.from]}¯${this.jumpParamKey}:${
862
+ this.selectOrgs[index][this.jumpParamKey]
863
+ },`
864
+ } else {
865
+ val += item[con.from] + ','
866
+ }
810
867
  })
811
868
  if (this.modelName == 'data.' + con['target'][0]) {
812
869
  utils.setValueByPath(
@@ -969,13 +1026,22 @@
969
1026
  queryParamMap.total = pageBean.pageBean.total
970
1027
  // 添加用户id 岗位id 组织id
971
1028
  try {
972
- if (this.$requestConfig.getUserId()) {
1029
+ if (
1030
+ this.$requestConfig.getUserId &&
1031
+ this.$requestConfig.getUserId()
1032
+ ) {
973
1033
  ctx.userId = this.$requestConfig.getUserId()
974
1034
  }
975
- if (this.$requestConfig.getOrgId()) {
1035
+ if (
1036
+ this.$requestConfig.getOrgId &&
1037
+ this.$requestConfig.getOrgId()
1038
+ ) {
976
1039
  ctx.orgId = this.$requestConfig.getOrgId()
977
1040
  }
978
- if (this.$requestConfig.getPostId()) {
1041
+ if (
1042
+ this.$requestConfig.getPostId &&
1043
+ this.$requestConfig.getPostId()
1044
+ ) {
979
1045
  ctx.postId = this.$requestConfig.getPostId()
980
1046
  }
981
1047
  } catch (e) {
@@ -1000,7 +1066,7 @@
1000
1066
  value: queryParamMap[bindKey] || ctx[bindKey] || '',
1001
1067
  }
1002
1068
  })
1003
- param.querys = queryList
1069
+ param.querys = queryList || []
1004
1070
  if (this.customDialog.needPage) {
1005
1071
  param.pageBean = obj
1006
1072
  } else {
@@ -1296,6 +1362,8 @@
1296
1362
  },
1297
1363
  // 同步选择结果
1298
1364
  syncInputValue() {
1365
+ // 对话框跳转url需要两个参数 1当前控件绑定的对象参数modelName 2对话框配置中配置的key名称
1366
+ // 同步值时,如果有绑定url跳转参数,值格式为 名称¯跳转key:跳转value
1299
1367
  let thisIndex = null //当前数据所在下标
1300
1368
  let parentIndex = null //父节点所在下标
1301
1369
  if (this.$parent.$el) {
@@ -1388,8 +1456,19 @@
1388
1456
  var val = ''
1389
1457
  var from = con.from.toLowerCase()
1390
1458
  str.forEach((item) => {
1459
+ // 如果有绑定url跳转参数 需获取跳转参数的key
1391
1460
  if (item) {
1392
- val += decodeURIComponent(item[from]) + ','
1461
+ if (
1462
+ this.jumpParamKey &&
1463
+ this.isHaveJumpUrl &&
1464
+ this.modelName == 'data.' + con['target'][0]
1465
+ ) {
1466
+ val += `${decodeURIComponent(item[from])}¯${
1467
+ this.jumpParamKey
1468
+ }:${item[this.jumpParamKey]},`
1469
+ } else {
1470
+ val += decodeURIComponent(item[from]) + ','
1471
+ }
1393
1472
  }
1394
1473
  })
1395
1474
  if (this.modelName == 'data.' + con['target'][0]) {