tianheng-ui 0.1.40 → 0.1.42

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,44 @@
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
+ ref="fieldsSearchTreeRef"
20
+ :data="fieldsTree.search"
21
+ :default-checked-keys="searchActiveFields"
22
+ show-checkbox
23
+ node-key="key"
24
+ :default-expand-all="true"
25
+ :check-strictly="true"
26
+ :props="{ label: 'label', value: 'prop' }"
27
+ @check-change="handleTreeCheckChange('search')"
31
28
  >
29
+ </el-tree>
32
30
  </el-collapse-item>
33
31
  <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
32
+ <el-tree
33
+ ref="fieldsTableTreeRef"
34
+ :data="fieldsTree.table"
35
+ :default-checked-keys="tableActiveFields"
36
+ show-checkbox
37
+ node-key="key"
38
+ :default-expand-all="true"
39
+ :check-strictly="true"
40
+ :props="{ label: 'label', value: 'prop' }"
41
+ @check-change="handleTreeCheckChange('table')"
47
42
  >
43
+ </el-tree>
48
44
  </el-collapse-item>
49
45
  </el-collapse>
50
46
  </template>
@@ -129,7 +125,7 @@
129
125
  clearable
130
126
  >
131
127
  <el-option
132
- v-for="item in fields"
128
+ v-for="item in config.table.options"
133
129
  :key="item.prop"
134
130
  :label="item.label"
135
131
  :value="item.alias"
@@ -641,7 +637,6 @@ export default {
641
637
  { title: "样式设置", value: "css" }
642
638
  ],
643
639
  activeTab: { title: "列表属性", value: "table" },
644
- fields: [],
645
640
  searchField: {
646
641
  isCheckAll: false,
647
642
  isIndeterminate: false
@@ -687,16 +682,16 @@ export default {
687
682
  { required: true, message: "请选择列表接口", trigger: "change" }
688
683
  ]
689
684
  },
685
+ fieldsTree: {
686
+ search: [],
687
+ table: []
688
+ },
690
689
  dialog: { show: false, data: null }
691
690
  };
692
691
  },
693
692
  watch: {
694
693
  config(val) {
695
694
  this.handleFieldsApiChange(val.table.mounted.api);
696
- this.handleFields();
697
- },
698
- fields(val) {
699
- this.handleFields();
700
695
  },
701
696
  apiOptions() {
702
697
  this.handleFieldsApiChange(this.config.table.mounted.api);
@@ -705,113 +700,77 @@ export default {
705
700
  computed: {
706
701
  searchActiveFields() {
707
702
  const data = this.config.search.options.map(item => {
708
- return item.prop;
703
+ return item.key;
709
704
  });
710
705
  return data;
711
706
  },
712
707
  tableActiveFields() {
713
708
  const data = this.config.table.options.map(item => {
714
- return item.prop;
709
+ return item.key;
715
710
  });
716
711
  return data;
717
712
  }
718
713
  },
719
714
  mounted() {},
720
715
  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
716
  handleActionConfig(data) {
796
717
  this.dialog = { show: true, data };
797
718
  },
798
719
  handleFieldsApiChange(val) {
799
- const dataArr = this.apiOptions.filter(item => {
720
+ const api = this.apiOptions.filter(item => {
800
721
  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
- };
722
+ })[0];
723
+ if (!api) return (this.fieldsTree = { search: [], table: [] });
724
+
725
+ const initParams = (paramsList, pProp) => {
726
+ paramsList.forEach(item => {
727
+ item.elType = "input";
728
+ item.align = "left";
729
+ item.pProp = pProp ? `${pProp}.${item.prop}` : item.prop;
730
+ if (item.children && item.children.length) {
731
+ initParams(item.children, item.pProp);
732
+ }
733
+ });
734
+ };
735
+ this.fieldsTree.search = deepClone(api.interfaceParameterInputList) || [];
736
+ initParams(this.fieldsTree.search);
737
+ this.fieldsTree.table = deepClone(api.interfaceParameterOutPutList) || [];
738
+ initParams(this.fieldsTree.table);
739
+ },
740
+ handleTreeCheckChange(action) {
741
+ if (action === "search") {
742
+ const keys = this.config.search.options.map(item => {
743
+ return item.key;
744
+ });
745
+ let nodes = deepClone(this.$refs.fieldsSearchTreeRef.getCheckedNodes());
746
+ nodes.map(item => {
747
+ const index = keys.indexOf(item.key);
748
+ if (index > -1) {
749
+ return this.config.search.options[index];
750
+ } else {
751
+ return item;
752
+ }
753
+ });
754
+ this.config.search.options = nodes;
755
+ } else {
756
+ const keys = this.config.table.options.map(item => {
757
+ return item.key;
811
758
  });
812
- this.fields = fields;
813
- } else this.fields = [];
759
+
760
+ let nodes = deepClone(this.$refs.fieldsTableTreeRef.getCheckedNodes());
761
+ nodes = nodes.map(item => {
762
+ const index = keys.indexOf(item.key);
763
+ if (index > -1) {
764
+ return this.config.table.options[index];
765
+ } else {
766
+ return item;
767
+ }
768
+ });
769
+ this.config.table.options = nodes;
770
+ }
771
+ console.log("handleTreeCheckChange =>", nodes);
814
772
  },
773
+ // 对外暴露表单校验
815
774
  formValidate() {
816
775
  return new Promise((resolve, reject) => {
817
776
  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="对应列内容的字段名,非必要不修改!"
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="对应列内容的字段名,非必要不修改!"
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