tianheng-ui 0.1.46 → 0.1.47

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