tianheng-ui 0.1.46 → 0.1.48

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,15 +12,17 @@
12
12
  </div>
13
13
  </div>
14
14
  <div v-if="activeTab.value === 'field'" class="configItem fieldsView">
15
- <template v-if="fieldsTree.search.length || fieldsTree.table.length">
15
+ <template
16
+ v-if="fieldsData.inParams.length || fieldsData.outParams.length"
17
+ >
16
18
  <el-collapse v-model="collapseValue">
17
19
  <el-collapse-item title="查询字段" name="group-fields_search">
18
20
  <el-tree
19
21
  ref="fieldsSearchTreeRef"
20
- :data="fieldsTree.search"
22
+ :data="fieldsData.inParams"
21
23
  :default-checked-keys="searchActiveFields"
22
24
  show-checkbox
23
- node-key="key"
25
+ node-key="id"
24
26
  :default-expand-all="true"
25
27
  :check-strictly="true"
26
28
  :props="{ label: 'label', value: 'alias' }"
@@ -31,10 +33,10 @@
31
33
  <el-collapse-item title="列表字段" name="group-fields_table">
32
34
  <el-tree
33
35
  ref="fieldsTableTreeRef"
34
- :data="fieldsTree.table"
36
+ :data="fieldsData.outParams"
35
37
  :default-checked-keys="tableActiveFields"
36
38
  show-checkbox
37
- node-key="key"
39
+ node-key="id"
38
40
  :default-expand-all="true"
39
41
  :check-strictly="true"
40
42
  :props="{ label: 'label', value: 'alias' }"
@@ -100,7 +102,7 @@
100
102
  placeholder="请选择"
101
103
  no-data-text="暂无接口,请前往【接口模块】创建"
102
104
  filterable
103
- @change="handleFieldsApiChange"
105
+ @change="handleResetTableFields"
104
106
  >
105
107
  <el-option
106
108
  v-for="item in apiOptions"
@@ -248,8 +250,8 @@
248
250
  </div>
249
251
  </template>
250
252
  <div
251
- v-for="(item, index) in Object.values(config.tools)"
252
- :key="index"
253
+ v-for="item in Object.values(config.tools)"
254
+ :key="item.type"
253
255
  class="tools-item"
254
256
  >
255
257
  <el-checkbox v-model="item.show">{{ item.name }}</el-checkbox>
@@ -511,12 +513,12 @@
511
513
  > -->
512
514
  </div>
513
515
  <div
514
- v-for="(item, index) in Object.values(config.tools || [])"
516
+ v-for="item in Object.values(config.tools || [])"
515
517
  class="list-item th-is_hover"
516
518
  :class="{
517
519
  'th-is_active': dialog.data && dialog.data.name === item.name
518
520
  }"
519
- :key="item.key"
521
+ :key="item.type"
520
522
  @click="dialog.data = item"
521
523
  >
522
524
  <div class="list-item-value">{{ item.name }}</div>
@@ -707,10 +709,7 @@ export default {
707
709
  { required: true, message: "请选择列表名称", trigger: "change" }
708
710
  ]
709
711
  },
710
- fieldsTree: {
711
- search: [],
712
- table: []
713
- },
712
+ fieldsData: { inParams: [], outParams: [] },
714
713
  dialog: { show: false, data: null },
715
714
  cssDemo: `
716
715
  {<br>
@@ -722,43 +721,86 @@ export default {
722
721
  };
723
722
  },
724
723
  watch: {
725
- config(val) {
726
- this.handleInitFields(val.table.mounted.api);
724
+ "config.table.mounted.api"(val) {
725
+ this.handleFieldsApiChange(val, true);
726
+ },
727
+ "config.tools.add.show"(bool) {
728
+ if (bool) this.handleFieldsApiChange(this.config.tools.add.api);
729
+ },
730
+ "config.tools.edit.show"(bool) {
731
+ if (bool) this.handleFieldsApiChange(this.config.tools.edit.api);
732
+ },
733
+ "config.tools.look.show"(bool) {
734
+ if (bool) this.handleFieldsApiChange(this.config.tools.look.api);
735
+ },
736
+ "config.tools.delete.show"(bool) {
737
+ if (bool) this.handleFieldsApiChange(this.config.tools.delete.api);
738
+ },
739
+ "config.tools.batchDelete.show"(bool) {
740
+ if (bool) this.handleFieldsApiChange(this.config.tools.batchDelete.api);
741
+ },
742
+ "config.tools.export.show"(bool) {
743
+ if (bool) this.handleFieldsApiChange(this.config.tools.export.api);
744
+ },
745
+ "config.tools.import.show"(bool) {
746
+ if (bool) this.handleFieldsApiChange(this.config.tools.import.api);
747
+ },
748
+ "config.tools.add.api"(val) {
749
+ if (this.config.tools.add.show) this.handleFieldsApiChange(val);
750
+ },
751
+ "config.tools.edit.api"(val) {
752
+ if (this.config.tools.edit.show) this.handleFieldsApiChange(val);
753
+ },
754
+ "config.tools.look.api"(val) {
755
+ if (this.config.tools.look.show) this.handleFieldsApiChange(val);
756
+ },
757
+ "config.tools.delete.api"(val) {
758
+ if (this.config.tools.delete.show) this.handleFieldsApiChange(val);
759
+ },
760
+ "config.tools.batchDelete.api"(val) {
761
+ if (this.config.tools.batchDelete.show) this.handleFieldsApiChange(val);
727
762
  },
728
- apiOptions() {
729
- this.handleInitFields(this.config.table.mounted.api);
763
+ "config.tools.export.api"(val) {
764
+ if (this.config.tools.export.show) this.handleFieldsApiChange(val);
765
+ },
766
+ "config.tools.import.api"(val) {
767
+ if (this.config.tools.import.show) this.handleFieldsApiChange(val);
730
768
  }
731
769
  },
732
770
  computed: {
733
771
  searchActiveFields() {
734
772
  const data = this.config.search.options.map(item => {
735
- return item.key;
773
+ return item.id;
736
774
  });
737
775
  return data;
738
776
  },
739
777
  tableActiveFields() {
740
778
  const data = this.config.table.options.map(item => {
741
- return item.key;
779
+ return item.id;
742
780
  });
743
781
  return data;
744
782
  }
745
783
  },
746
784
  mounted() {},
747
785
  methods: {
748
- handleActionConfig(data) {
749
- this.dialog = { show: true, data };
750
- },
751
- handleFieldsApiChange(val) {
752
- this.fieldsTree = { search: [], table: [] };
786
+ handleResetTableFields() {
753
787
  this.config.search.options = [];
754
788
  this.config.table.options = [];
755
- this.handleInitFields(val);
756
789
  },
757
- handleInitFields(apiId) {
790
+ handleActionConfig(data) {
791
+ this.dialog = { show: true, data };
792
+ },
793
+ handleFieldsApiChange(apiId, isFields) {
794
+ if (isFields) this.fieldsData = { inParams: [], outParams: [] };
795
+ if (!this.apiOptions.length || !apiId) return;
796
+
758
797
  const api = this.apiOptions.filter(item => {
759
798
  return item.id === apiId;
760
799
  })[0];
761
- if (!api) return;
800
+ if (!api) {
801
+ this.$message.warning("未知的接口,请检查配置信息");
802
+ return;
803
+ }
762
804
 
763
805
  const initParams = (paramsList, pAlias) => {
764
806
  paramsList.forEach(item => {
@@ -770,31 +812,38 @@ export default {
770
812
  }
771
813
  });
772
814
  };
815
+
773
816
  if (this.config.table.fields.remote) {
774
817
  const callback = res => {
775
818
  api.inParams = res.inParams;
776
819
  api.outParams = res.outParams;
777
- this.fieldsTree.search = deepClone(res.inParams) || [];
778
- initParams(this.fieldsTree.search);
779
- this.fieldsTree.table = deepClone(res.outParams) || [];
780
- initParams(this.fieldsTree.table);
820
+ if (isFields) {
821
+ this.fieldsData.inParams = deepClone(res.inParams || []);
822
+ initParams(this.fieldsData.inParams);
823
+ this.fieldsData.outParams = deepClone(res.outParams || []);
824
+ initParams(this.fieldsData.outParams);
825
+ }
781
826
  };
782
827
  this.$emit("remote-params", apiId, callback);
783
- } else {
784
- this.fieldsTree.search = deepClone(api.inParams) || [];
785
- initParams(this.fieldsTree.search);
786
- this.fieldsTree.table = deepClone(api.outParams) || [];
787
- initParams(this.fieldsTree.table);
828
+ return;
829
+ }
830
+
831
+ if (isFields) {
832
+ this.fieldsData.inParams = deepClone(api.inParams || []);
833
+ initParams(this.fieldsData.inParams);
834
+ this.fieldsData.outParams = deepClone(api.outParams || []);
835
+ initParams(this.fieldsData.outParams);
836
+ return;
788
837
  }
789
838
  },
790
839
  handleTreeCheckChange(action) {
791
840
  if (action === "search") {
792
841
  const keys = this.config.search.options.map(item => {
793
- return item.key;
842
+ return item.id;
794
843
  });
795
844
  let nodes = deepClone(this.$refs.fieldsSearchTreeRef.getCheckedNodes());
796
845
  nodes.map(item => {
797
- const index = keys.indexOf(item.key);
846
+ const index = keys.indexOf(item.id);
798
847
  if (index > -1) {
799
848
  return this.config.search.options[index];
800
849
  } else {
@@ -804,12 +853,12 @@ export default {
804
853
  this.config.search.options = nodes;
805
854
  } else {
806
855
  const keys = this.config.table.options.map(item => {
807
- return item.key;
856
+ return item.id;
808
857
  });
809
858
 
810
859
  let nodes = deepClone(this.$refs.fieldsTableTreeRef.getCheckedNodes());
811
860
  nodes = nodes.map(item => {
812
- const index = keys.indexOf(item.key);
861
+ const index = keys.indexOf(item.id);
813
862
  if (index > -1) {
814
863
  return this.config.table.options[index];
815
864
  } else {
@@ -47,7 +47,7 @@
47
47
  >
48
48
  <div
49
49
  v-for="item in config.search.options"
50
- :key="item.pAlias"
50
+ :key="item.id"
51
51
  class="table-item"
52
52
  >
53
53
  <div class="table-item-custom drag">
@@ -135,7 +135,7 @@
135
135
  >
136
136
  <div
137
137
  v-for="item in config.table.options"
138
- :key="item.pAlias"
138
+ :key="item.id"
139
139
  class="table-item"
140
140
  >
141
141
  <div class="table-item-custom drag">