eoss-ui 0.5.81-beta3 → 0.5.81-beta4

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.
@@ -78,7 +78,7 @@
78
78
  class="es-simplicity-subMenus"
79
79
  direction="ltr"
80
80
  modal-class="es-simplicity-apps-modal"
81
- :size="width"
81
+ :size="width + 'px'"
82
82
  :modal-append-to-body="false"
83
83
  :with-header="false"
84
84
  :visible.sync="showMenu"
@@ -195,7 +195,6 @@
195
195
  v-model="activeName"
196
196
  closable
197
197
  hide-bar
198
- @tab-click="handleTab"
199
198
  @tab-remove="handleRemove"
200
199
  @tab-contextmenu="handleContextmenu"
201
200
  >
@@ -455,7 +454,11 @@ export default {
455
454
  //无界微前端Props属性
456
455
  wjProps: Object,
457
456
  //无界微前端Attrs属性
458
- wjAttrs: Object
457
+ wjAttrs: Object,
458
+ menuWidth: {
459
+ type: Number,
460
+ default: 220
461
+ }
459
462
  },
460
463
  data() {
461
464
  return {
@@ -474,7 +477,7 @@ export default {
474
477
  //展示菜单导航
475
478
  showMenu: false,
476
479
  //展示菜单导航宽度
477
- width: '296px',
480
+ width: this.menuWidth,
478
481
  //人工智能配置
479
482
  aiConfig: null,
480
483
  //公用窗口面板配置
@@ -664,7 +667,6 @@ export default {
664
667
  this.setConfig(results);
665
668
  if (this.remote) {
666
669
  this.getApplications();
667
- this.getMenus();
668
670
  }
669
671
  },
670
672
  /**
@@ -784,6 +786,7 @@ export default {
784
786
  * @date 2024年9月7日
785
787
  **/
786
788
  getApplications() {
789
+ let loading = util.loading('', '加载中...');
787
790
  util
788
791
  .ajax({
789
792
  url: this.appsUrl,
@@ -807,12 +810,15 @@ export default {
807
810
  } else {
808
811
  this.$message.error('未分配应用菜单权限,请联系管理员!');
809
812
  }
813
+ this.getMenus(loading);
810
814
  } else {
815
+ loading.close();
811
816
  let msg = res.msg || '系统错误,请联系管理员!';
812
817
  this.$message.error(msg);
813
818
  }
814
819
  })
815
820
  .catch((err) => {
821
+ loading.close();
816
822
  if (err.message && err.message !== 'canceled') {
817
823
  this.$message.error(err.message);
818
824
  }
@@ -823,20 +829,84 @@ export default {
823
829
  * @author huangbo
824
830
  * @date 2024年9月7日
825
831
  **/
826
- getMenus() {
832
+ getMenus(loading) {
827
833
  util
828
834
  .ajax({ url: this._menuUrl })
829
835
  .then((res) => {
836
+ loading.close();
830
837
  if (res.rCode === 0) {
831
838
  if (res.results && res.results.length) {
832
839
  this.menus = res.results;
833
840
  this.setTips(this.menus);
834
841
  store.set('nav', this.menus);
842
+ console.log(12121);
843
+ if (this.appCode) {
844
+ let app = this.userApps.filter((item) => {
845
+ return item.code === this.appCode;
846
+ })[0];
847
+ if (app) {
848
+ this.active = app.id;
849
+ if (app.url) {
850
+ let obj = this.getMenu(this.menus, app.url);
851
+ if (obj) {
852
+ let tab = this.setIframeType(obj);
853
+ this.tabs = [tab];
854
+ this.activeName = tab.id;
855
+ if (tab.method == 'router') {
856
+ let params = util.getParams({ url: tab.url });
857
+ this.$router.push({
858
+ path: tab.path,
859
+ query: params
860
+ });
861
+ }
862
+ }
863
+ }
864
+ }
865
+ if (this.tabs.length == 0) {
866
+ let subMenus = this.getMenu(
867
+ this.menus,
868
+ this.appCode,
869
+ 'appCode'
870
+ );
871
+ if (subMenus) {
872
+ // this.subMenus = subMenus;
873
+ // this.showMenu = true;
874
+ let obj = this.getFirst(subMenus);
875
+ if (obj) {
876
+ let tab = this.setIframeType(obj);
877
+ this.tabs = [tab];
878
+ this.activeName = tab.id;
879
+ if (tab.method == 'router') {
880
+ let params = util.getParams({ url: tab.url });
881
+ this.$router.push({
882
+ path: tab.path,
883
+ query: params
884
+ });
885
+ }
886
+ }
887
+ } else {
888
+ this.subMenus = null;
889
+ this.showMenu = false;
890
+ }
891
+ }
892
+ // this.width = this.menuWidth;
893
+ // this.$refs.subMenus && this.$refs.subMenus.clearSubmenu();
894
+ }
835
895
  if (this.indexUrl) {
836
896
  let obj = this.getMenu(this.menus, this.indexUrl);
837
897
  if (obj) {
838
- this.tabs = [this.setIframeType(obj)];
839
- this.activeName = obj.id;
898
+ if (!this.appCode) {
899
+ let tab = this.setIframeType(obj);
900
+ this.tabs = [tab];
901
+ this.activeName = tab.id;
902
+ if (tab.method == 'router') {
903
+ let params = util.getParams({ url: tab.url });
904
+ this.$router.push({
905
+ path: tab.path,
906
+ query: params
907
+ });
908
+ }
909
+ }
840
910
  this.homePage = obj;
841
911
  } else {
842
912
  this.homePage = this.setIframeType({
@@ -845,28 +915,40 @@ export default {
845
915
  id: '0',
846
916
  appCode: 'indexUrl'
847
917
  });
848
- this.tabs = [this.homePage];
849
- this.activeName = '0';
918
+ if (!this.appCode) {
919
+ this.tabs = [this.homePage];
920
+ this.activeName = '0';
921
+ if (this.homePage.method == 'router') {
922
+ let params = util.getParams({ url: this.homePage.url });
923
+ this.$router.push({
924
+ path: this.homePage.path,
925
+ query: params
926
+ });
927
+ }
928
+ }
850
929
  }
851
- }
852
- if (this.initApps && this.initApps.length) {
930
+ } else if (
931
+ this.initApps &&
932
+ this.initApps.length &&
933
+ !this.appCode
934
+ ) {
853
935
  let obj = this.getMenu(
854
936
  this.menus,
855
937
  this.initApps[this.initApps.length - 1]
856
938
  );
857
939
  if (obj) {
858
- this.tabs.push(this.setIframeType(obj));
859
- this.activeName = obj.id;
940
+ let tab = this.setIframeType(obj);
941
+ this.tabs.push(tab);
942
+ this.activeName = tab.id;
943
+ if (tab.method == 'router') {
944
+ let params = util.getParams({ url: tab.url });
945
+ this.$router.push({
946
+ path: tab.path,
947
+ query: params
948
+ });
949
+ }
860
950
  }
861
951
  }
862
- if (this.appCode) {
863
- let subMenus = this.getMenu(this.menus, res.code, 'appCode');
864
- this.subMenus = subMenus ? subMenus : null;
865
- this.showMenu = subMenus !== false;
866
- this.showApps = false;
867
- this.width = '296px';
868
- this.$refs.subMenus && this.$refs.subMenus.clearSubmenu();
869
- }
870
952
  } else {
871
953
  this.$message.error('未分配菜单权限,请联系管理员!');
872
954
  }
@@ -876,6 +958,7 @@ export default {
876
958
  }
877
959
  })
878
960
  .catch((err) => {
961
+ loading.close();
879
962
  if (err.message && err.message !== 'canceled') {
880
963
  this.$message.error(err.message);
881
964
  }
@@ -891,9 +974,6 @@ export default {
891
974
  let urls = url.split('?');
892
975
  if (urls[0].indexOf('.js') > 1 && !isIE) {
893
976
  res.method = 'wujie';
894
- this.$nextTick(() => {
895
- res.refresh = true;
896
- });
897
977
  } else if (
898
978
  urls[0].indexOf('.dhtml') > 0 ||
899
979
  (urls[0].indexOf('.html') > 0 && urls[0].indexOf('.html#') === -1)
@@ -908,14 +988,7 @@ export default {
908
988
  let path = this.hasRouter(routes, urls[0], res.appCode);
909
989
  if (path) {
910
990
  res.method = 'router';
911
- let params = util.getParams({ url: url });
912
- this.$router.push({
913
- path: path,
914
- query: params
915
- });
916
- this.$nextTick(() => {
917
- res.refresh = true;
918
- });
991
+ res.path = path;
919
992
  } else {
920
993
  let urlopenmode = util.getParams({
921
994
  url: url,
@@ -930,9 +1003,6 @@ export default {
930
1003
  res.method = 'iframe';
931
1004
  } else {
932
1005
  res.method = 'wujie';
933
- this.$nextTick(() => {
934
- res.refresh = true;
935
- });
936
1006
  }
937
1007
  }
938
1008
  } else if (
@@ -940,14 +1010,12 @@ export default {
940
1010
  urls[0].indexOf('/#/') > -1
941
1011
  ) {
942
1012
  res.method = 'wujie';
943
- this.$nextTick(() => {
944
- res.refresh = true;
945
- });
946
1013
  } else {
947
1014
  res.method = 'iframe';
948
1015
  }
949
1016
  }
950
1017
  }
1018
+ res.refresh = true;
951
1019
  return res;
952
1020
  },
953
1021
  /**
@@ -987,6 +1055,37 @@ export default {
987
1055
  }
988
1056
  return false;
989
1057
  },
1058
+ /**
1059
+ * @desc:获取菜单第一条数据
1060
+ * @author huangbo
1061
+ * @date 2024年9月7日
1062
+ **/
1063
+ getFirst(obj) {
1064
+ if (!obj) {
1065
+ return '';
1066
+ }
1067
+ let openIdex = 0;
1068
+ if (
1069
+ obj.extendData &&
1070
+ (obj.extendData.subDefOpenIndex || obj.extendData.subDefOpen)
1071
+ ) {
1072
+ openIdex = parseInt(
1073
+ obj.extendData.subDefOpenIndex || obj.extendData.subDefOpen,
1074
+ 10
1075
+ );
1076
+ }
1077
+ if (obj.children && obj.children.length && obj.children[openIdex]) {
1078
+ return this.getFirst(obj.children[openIdex]);
1079
+ } else if (
1080
+ obj.fourthTabs &&
1081
+ obj.fourthTabs.length &&
1082
+ obj.fourthTabs[openIdex]
1083
+ ) {
1084
+ return this.getFirst(obj.fourthTabs[openIdex]);
1085
+ } else if (obj.url) {
1086
+ return obj;
1087
+ }
1088
+ },
990
1089
  /**
991
1090
  * @desc:遍历设置菜单气泡提醒
992
1091
  * @author huangbo
@@ -1116,7 +1215,7 @@ export default {
1116
1215
  this.subMenus = res;
1117
1216
  this.showMenu = true;
1118
1217
  this.showApps = false;
1119
- this.width = '296px';
1218
+ this.width = this.menuWidth;
1120
1219
  this.$refs.subMenus && this.$refs.subMenus.clearSubmenu();
1121
1220
  } else {
1122
1221
  let set = true;
@@ -1131,16 +1230,25 @@ export default {
1131
1230
  let i = util.indexOfObj(this.tabs, res, 'id');
1132
1231
  this.activeName = res.id;
1133
1232
  if (i == -1) {
1134
- this.tabs.push(this.setIframeType(res));
1233
+ let tab = this.setIframeType(res);
1234
+ this.tabs.push(obj);
1235
+ if (tab.method == 'router') {
1236
+ let params = util.getParams({ url: tab.url });
1237
+ this.$router.push({
1238
+ path: tab.path,
1239
+ query: params
1240
+ });
1241
+ }
1135
1242
  }
1136
1243
  }
1137
1244
  }
1138
1245
  if (set && res.code) {
1139
1246
  let subMenus = this.getMenu(this.menus, res.code, 'appCode');
1247
+ console.log(subMenus);
1140
1248
  this.subMenus = subMenus ? subMenus : null;
1141
1249
  this.showMenu = subMenus !== false;
1142
1250
  this.showApps = false;
1143
- this.width = '296px';
1251
+ this.width = this.menuWidth;
1144
1252
  this.$refs.subMenus && this.$refs.subMenus.clearSubmenu();
1145
1253
  }
1146
1254
  }
@@ -1186,13 +1294,21 @@ export default {
1186
1294
  **/
1187
1295
  handlerClickMenu(res) {
1188
1296
  if (typeof res === 'number') {
1189
- let num = 296;
1190
- this.width = num * res + 'px';
1297
+ let num = this.menuWidth;
1298
+ this.width = num * res;
1191
1299
  } else {
1192
1300
  let i = util.indexOfObj(this.tabs, res, 'id');
1193
1301
  this.activeName = res.id;
1194
1302
  if (i == -1) {
1195
- this.tabs.push(this.setIframeType(res));
1303
+ let tab = this.setIframeType(res);
1304
+ this.tabs.push(tab);
1305
+ if (tab.method == 'router') {
1306
+ let params = util.getParams({ url: tab.url });
1307
+ this.$router.push({
1308
+ path: tab.path,
1309
+ query: params
1310
+ });
1311
+ }
1196
1312
  }
1197
1313
  this.showMenu = false;
1198
1314
  }
@@ -1231,28 +1347,6 @@ export default {
1231
1347
  this.webSocket.destroy();
1232
1348
  }
1233
1349
  },
1234
- /**
1235
- * @desc:选中iframe页签刷新
1236
- * @author huangbo
1237
- * @date 2024年9月7日
1238
- **/
1239
- handleTab(res) {
1240
- let index;
1241
- if (res) {
1242
- index = parseInt(res.index);
1243
- } else {
1244
- index = util.indexOfObj(this.tabs, this.activeName, 'id');
1245
- }
1246
- let item = this.tabs[index];
1247
- if (item.method == 'iframe') {
1248
- item.url = util.handlerUrl(item.url);
1249
- } else {
1250
- item.refresh = false;
1251
- this.$nextTick(() => {
1252
- item.refresh = true;
1253
- });
1254
- }
1255
- },
1256
1350
  /**
1257
1351
  * @desc:刷新选中iframe页签
1258
1352
  * @author huangbo
@@ -1624,10 +1718,19 @@ export default {
1624
1718
  let obj = this.getMenu(this.menus, apps[apps.length - 1]);
1625
1719
  if (obj) {
1626
1720
  let i = util.indexOfObj(this.tabs, obj, 'id');
1721
+ let n = util.indexOfObj(this.tabs, this.activeName, 'id');
1722
+ this.activeName = obj.id;
1627
1723
  if (i == -1) {
1628
- this.tabs.push(this.setIframeType(obj));
1724
+ let tab = this.setIframeType(obj);
1725
+ this.tabs.splice(n + 1, 0, tab);
1726
+ if (tab.method == 'router') {
1727
+ let params = util.getParams({ url: tab.url });
1728
+ this.$router.push({
1729
+ path: tab.path,
1730
+ query: params
1731
+ });
1732
+ }
1629
1733
  }
1630
- this.activeName = obj.id;
1631
1734
  } else {
1632
1735
  this.$message.error('没有此菜单!');
1633
1736
  }