tianheng-ui 0.1.40 → 0.1.41

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.
@@ -12,7 +12,7 @@
12
12
  <template v-for="item in getList">
13
13
  <el-table-column
14
14
  v-if="item.type"
15
- :key="item.prop"
15
+ :key="item.type"
16
16
  :type="item.type"
17
17
  :label="item.label"
18
18
  :width="item.width || 50"
@@ -20,10 +20,10 @@
20
20
  </el-table-column>
21
21
  <el-table-column
22
22
  v-else
23
- :key="item.prop"
24
- :prop="item.prop"
23
+ :key="item.pProp"
24
+ :prop="item.pProp"
25
25
  :label="item.label"
26
- :width="item.width || 180"
26
+ :width="item.width"
27
27
  >
28
28
  <template slot-scope="scope">
29
29
  <slot
@@ -32,7 +32,7 @@
32
32
  :scope="scope"
33
33
  :option="item"
34
34
  />
35
- <span v-else>{{ scope.row[item.prop] }}</span>
35
+ <span v-else>{{ getValue(scope.row, item.pProp) }}</span>
36
36
  </template>
37
37
  </el-table-column>
38
38
  </template>
@@ -68,7 +68,11 @@ export default {
68
68
  },
69
69
  created() {},
70
70
  mounted() {},
71
- methods: {}
71
+ methods: {
72
+ getValue(item, key) {
73
+ return eval(`item.${key}`);
74
+ }
75
+ }
72
76
  };
73
77
  </script>
74
78
 
@@ -400,7 +400,7 @@ export default {
400
400
  let params = {};
401
401
  switch (actionType) {
402
402
  case "list":
403
- for (let key of Object.keys(config.params)) {
403
+ for (let key of Object.keys(config.interfaceParameterInputList)) {
404
404
  params[key] = paramsData[key] || this.query[key];
405
405
  }
406
406
  if (this.tableConfig.pageInfo.show) {
@@ -411,7 +411,7 @@ export default {
411
411
  case "add":
412
412
  case "edit":
413
413
  case "delete":
414
- for (let key of Object.keys(config.params)) {
414
+ for (let key of Object.keys(config.interfaceParameterInputList)) {
415
415
  params[key] = paramsData[key];
416
416
  }
417
417
  break;
@@ -3,48 +3,41 @@
3
3
  <div class="tabs ">
4
4
  <div
5
5
  v-for="(item, index) in tabsMenus"
6
- :key="index"
7
6
  class="tabs-item"
8
7
  :class="{ 'tabs-item__active': activeTab.value === item.value }"
8
+ :key="index"
9
9
  @click="activeTab = item"
10
10
  >
11
11
  {{ item.title }}
12
12
  </div>
13
13
  </div>
14
14
  <div v-if="activeTab.value === 'field'" class="configItem fieldsView">
15
- <template v-if="fields.length">
15
+ <template v-if="fieldsTree.search.length || fieldsTree.table.length">
16
16
  <el-collapse v-model="collapseValue">
17
17
  <el-collapse-item title="查询字段" name="group-fields_search">
18
- <el-checkbox
19
- v-model="searchField.isCheckAll"
20
- :indeterminate="searchField.isIndeterminate"
21
- @change="val => handleCheckAllChange(val, 'searchField')"
22
- >全选</el-checkbox
23
- >
24
- <el-checkbox
25
- v-for="item in fields"
26
- :label="item.prop"
27
- :key="`searchField-${item.prop}-${item.isSearch}`"
28
- :checked="item.isSearch"
29
- @change="val => handleCheckboxChange(val, 'searchField', item)"
30
- >{{ item.label }}</el-checkbox
18
+ <el-tree
19
+ :data="fieldsTree.search"
20
+ :default-checked-keys="searchActiveFields"
21
+ show-checkbox
22
+ node-key="key"
23
+ :props="{ label: 'label', value: 'prop' }"
24
+ ref="fieldsTreeRef"
25
+ @check-change="handleTreeCheckChange('search')"
31
26
  >
27
+ </el-tree>
32
28
  </el-collapse-item>
33
29
  <el-collapse-item title="列表字段" name="group-fields_table">
34
- <el-checkbox
35
- v-model="tableField.isCheckAll"
36
- :indeterminate="tableField.isIndeterminate"
37
- @change="val => handleCheckAllChange(val, 'tableField')"
38
- >全选</el-checkbox
39
- >
40
- <el-checkbox
41
- v-for="item in fields"
42
- :label="item.prop"
43
- :key="`tableField-${item.prop}-${item.isTable}`"
44
- :checked="item.isTable"
45
- @change="val => handleCheckboxChange(val, 'tableField', item)"
46
- >{{ item.label }}</el-checkbox
30
+ <el-tree
31
+ :data="fieldsTree.table"
32
+ :default-checked-keys="tableActiveFields"
33
+ show-checkbox
34
+ node-key="key"
35
+ :check-strictly="true"
36
+ :props="{ label: 'label', value: 'prop' }"
37
+ ref="fieldsTreeRef"
38
+ @check-change="handleTreeCheckChange('table')"
47
39
  >
40
+ </el-tree>
48
41
  </el-collapse-item>
49
42
  </el-collapse>
50
43
  </template>
@@ -129,7 +122,7 @@
129
122
  clearable
130
123
  >
131
124
  <el-option
132
- v-for="item in fields"
125
+ v-for="item in config.table.options"
133
126
  :key="item.prop"
134
127
  :label="item.label"
135
128
  :value="item.alias"
@@ -641,7 +634,6 @@ export default {
641
634
  { title: "样式设置", value: "css" }
642
635
  ],
643
636
  activeTab: { title: "列表属性", value: "table" },
644
- fields: [],
645
637
  searchField: {
646
638
  isCheckAll: false,
647
639
  isIndeterminate: false
@@ -687,16 +679,16 @@ export default {
687
679
  { required: true, message: "请选择列表接口", trigger: "change" }
688
680
  ]
689
681
  },
682
+ fieldsTree: {
683
+ search: [],
684
+ table: []
685
+ },
690
686
  dialog: { show: false, data: null }
691
687
  };
692
688
  },
693
689
  watch: {
694
690
  config(val) {
695
691
  this.handleFieldsApiChange(val.table.mounted.api);
696
- this.handleFields();
697
- },
698
- fields(val) {
699
- this.handleFields();
700
692
  },
701
693
  apiOptions() {
702
694
  this.handleFieldsApiChange(this.config.table.mounted.api);
@@ -705,113 +697,76 @@ export default {
705
697
  computed: {
706
698
  searchActiveFields() {
707
699
  const data = this.config.search.options.map(item => {
708
- return item.prop;
700
+ return item.key;
709
701
  });
710
702
  return data;
711
703
  },
712
704
  tableActiveFields() {
713
705
  const data = this.config.table.options.map(item => {
714
- return item.prop;
706
+ return item.key;
715
707
  });
716
708
  return data;
717
709
  }
718
710
  },
719
711
  mounted() {},
720
712
  methods: {
721
- handleFields() {
722
- this.fields.forEach(item => {
723
- item.isSearch = this.searchActiveFields.includes(item.prop);
724
- item.isTable = this.tableActiveFields.includes(item.prop);
725
- });
726
- this.searchField = {
727
- isCheckAll: this.searchActiveFields.length === this.fields.length,
728
- isIndeterminate:
729
- this.searchActiveFields.length !== 0 &&
730
- this.searchActiveFields.length !== this.fields.length
731
- };
732
- this.tableField = {
733
- isCheckAll: this.tableActiveFields.length === this.fields.length,
734
- isIndeterminate:
735
- this.tableActiveFields.length !== 0 &&
736
- this.tableActiveFields.length !== this.fields.length
737
- };
738
- },
739
- handleCheckAllChange(bool, action) {
740
- if (action === "searchField") {
741
- this.fields.forEach(item => {
742
- item.isSearch = bool;
743
- });
744
- const data = deepClone(this.fields);
745
- this.config.search.options = bool ? data : [];
746
- this.searchField = { isCheckAll: bool, isIndeterminate: false };
747
- return;
748
- }
749
- if (action === "tableField") {
750
- this.fields.forEach(item => {
751
- item.isTable = bool;
752
- });
753
- const data = deepClone(this.fields);
754
- this.config.table.options = bool ? data : [];
755
- this.tableField = { isCheckAll: bool, isIndeterminate: false };
756
- return;
757
- }
758
- },
759
- handleCheckboxChange(bool, action, data) {
760
- if (action === "searchField") {
761
- data.isSearch = bool;
762
- bool
763
- ? this.config.search.options.push(deepClone(data))
764
- : (this.config.search.options = this.config.search.options.filter(
765
- item => {
766
- return item.prop !== data.prop;
767
- }
768
- ));
769
- this.searchField = {
770
- isCheckAll: this.config.search.options.length === this.fields.length,
771
- isIndeterminate:
772
- this.config.search.options.length !== 0 &&
773
- this.config.search.options.length !== this.fields.length
774
- };
775
- return;
776
- }
777
- if (action === "tableField") {
778
- data.isTable = bool;
779
- bool
780
- ? this.config.table.options.push(deepClone(data))
781
- : (this.config.table.options = this.config.table.options.filter(
782
- item => {
783
- return item.prop !== data.prop;
784
- }
785
- ));
786
- this.tableField = {
787
- isCheckAll: this.config.table.options.length === this.fields.length,
788
- isIndeterminate:
789
- this.config.table.options.length !== 0 &&
790
- this.config.table.options.length !== this.fields.length
791
- };
792
- return;
793
- }
794
- },
795
713
  handleActionConfig(data) {
796
714
  this.dialog = { show: true, data };
797
715
  },
798
716
  handleFieldsApiChange(val) {
799
- const dataArr = this.apiOptions.filter(item => {
717
+ const api = this.apiOptions.filter(item => {
800
718
  return item.id === val;
801
- });
802
- if (dataArr.length && dataArr[0].paramsOut) {
803
- const fields = dataArr[0].paramsOut.map(item => {
804
- return {
805
- label: item.note || item.name,
806
- alias: item.name,
807
- prop: item.name,
808
- elType: "input",
809
- align: "left"
810
- };
719
+ })[0];
720
+ if (!api) return (this.fieldsTree = { search: [], table: [] });
721
+
722
+ const initParams = (paramsList, pProp) => {
723
+ paramsList.forEach(item => {
724
+ item.elType = "input";
725
+ item.align = "left";
726
+ item.pProp = pProp ? `${pProp}.${item.prop}` : item.prop;
727
+ if (item.children && item.children.length) {
728
+ initParams(item.children, item.pProp);
729
+ }
730
+ });
731
+ };
732
+ this.fieldsTree.search = deepClone(api.interfaceParameterInputList) || [];
733
+ initParams(this.fieldsTree.search);
734
+ this.fieldsTree.table = deepClone(api.interfaceParameterOutPutList) || [];
735
+ initParams(this.fieldsTree.table);
736
+ },
737
+ handleTreeCheckChange(action) {
738
+ let nodes = deepClone(this.$refs.fieldsTreeRef.getCheckedNodes());
739
+ if (action === "search") {
740
+ const keys = this.config.search.options.map(item => {
741
+ return item.key;
742
+ });
743
+ nodes.map(item => {
744
+ const index = keys.indexOf(item.key);
745
+ if (index > -1) {
746
+ return this.config.search.options[index];
747
+ } else {
748
+ return item;
749
+ }
750
+ });
751
+ this.config.search.options = nodes;
752
+ } else {
753
+ const keys = this.config.table.options.map(item => {
754
+ return item.key;
811
755
  });
812
- this.fields = fields;
813
- } else this.fields = [];
756
+
757
+ nodes = nodes.map(item => {
758
+ const index = keys.indexOf(item.key);
759
+ if (index > -1) {
760
+ return this.config.table.options[index];
761
+ } else {
762
+ return item;
763
+ }
764
+ });
765
+ this.config.table.options = nodes;
766
+ }
767
+ console.log("handleTreeCheckChange =>", nodes);
814
768
  },
769
+ // 对外暴露表单校验
815
770
  formValidate() {
816
771
  return new Promise((resolve, reject) => {
817
772
  if (this.$refs.formRef) {
@@ -11,7 +11,13 @@
11
11
  <div class="table-item table-header">
12
12
  <div class="table-item-custom">拖动</div>
13
13
  <div>列名</div>
14
- <!-- <div>字段</div> -->
14
+ <el-tooltip
15
+ content="对应列内容的字段名,支持eval函数,非必要不修改!"
16
+ placement="top-start"
17
+ effect="light"
18
+ >
19
+ <div><el-button type="text">字段</el-button></div>
20
+ </el-tooltip>
15
21
  <div>类型</div>
16
22
  <div>默认值</div>
17
23
  <!-- <div>数据来源</div> -->
@@ -38,6 +44,7 @@
38
44
  <i class="iconfont icon-drag drag-widget"></i>
39
45
  </div>
40
46
  <el-input v-model="item.label" size="mini"></el-input>
47
+ <el-input v-model="item.pProp" size="mini"></el-input>
41
48
  <div>
42
49
  <el-select
43
50
  v-model="item.elType"
@@ -83,7 +90,13 @@
83
90
  <div class="table-item table-header">
84
91
  <div class="table-item-custom">拖动</div>
85
92
  <div>列名</div>
86
- <!-- <div>字段</div> -->
93
+ <el-tooltip
94
+ content="对应列内容的字段名,支持eval函数,非必要不修改!"
95
+ placement="top-start"
96
+ effect="light"
97
+ >
98
+ <div><el-button type="text">字段</el-button></div>
99
+ </el-tooltip>
87
100
  <div>对齐</div>
88
101
  <div>宽度</div>
89
102
  <div class="table-item-custom">排序</div>
@@ -109,6 +122,7 @@
109
122
  <i class="iconfont icon-drag drag-widget"></i>
110
123
  </div>
111
124
  <el-input v-model="item.label" size="mini"></el-input>
125
+ <el-input v-model="item.pProp" size="mini"></el-input>
112
126
  <div>
113
127
  <el-select v-model="item.align" placeholder="请选择" size="mini">
114
128
  <el-option