eoss-ui 0.5.81-beta2 → 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.
Files changed (40) hide show
  1. package/lib/eoss-ui.common.js +485 -243
  2. package/lib/form.js +40 -2
  3. package/lib/handle-user.js +16 -3
  4. package/lib/handler.js +9 -3
  5. package/lib/index.js +1 -1
  6. package/lib/main.js +383 -193
  7. package/lib/selector-panel.js +3 -8
  8. package/lib/theme-chalk/button-group.css +1 -1
  9. package/lib/theme-chalk/data-table.css +1 -1
  10. package/lib/theme-chalk/handler.css +1 -1
  11. package/lib/theme-chalk/index.css +1 -1
  12. package/lib/theme-chalk/main.css +1 -1
  13. package/lib/theme-chalk/nav.css +1 -1
  14. package/lib/theme-chalk/simplicity.css +1 -1
  15. package/lib/upload.js +6 -6
  16. package/package.json +1 -1
  17. package/packages/form/src/main.vue +38 -8
  18. package/packages/handle-user/src/main.vue +10 -3
  19. package/packages/handler/src/main.vue +2 -0
  20. package/packages/main/src/default/index.vue +3 -2
  21. package/packages/main/src/main.vue +0 -1
  22. package/packages/main/src/simplicity/avatar.vue +4 -5
  23. package/packages/main/src/simplicity/index.vue +303 -115
  24. package/packages/main/src/simplicity/menu-list.vue +5 -1
  25. package/packages/main/src/simplicity/sub-menu.vue +21 -10
  26. package/packages/selector-panel/src/main.vue +1 -6
  27. package/packages/theme-chalk/lib/button-group.css +1 -1
  28. package/packages/theme-chalk/lib/data-table.css +1 -1
  29. package/packages/theme-chalk/lib/handler.css +1 -1
  30. package/packages/theme-chalk/lib/index.css +1 -1
  31. package/packages/theme-chalk/lib/main.css +1 -1
  32. package/packages/theme-chalk/lib/nav.css +1 -1
  33. package/packages/theme-chalk/lib/simplicity.css +1 -1
  34. package/packages/theme-chalk/src/button-group.scss +3 -3
  35. package/packages/theme-chalk/src/data-table.scss +9 -9
  36. package/packages/theme-chalk/src/handler.scss +5 -1
  37. package/packages/theme-chalk/src/nav.scss +3 -2
  38. package/packages/theme-chalk/src/simplicity.scss +79 -42
  39. package/packages/upload/src/main.vue +3 -1
  40. package/src/index.js +1 -1
@@ -1,12 +1,14 @@
1
1
  <template>
2
2
  <div class="es-main">
3
3
  <div class="es-simplicity-side">
4
- <img
5
- class="es-simplicity-side-item es-simplicity-logo"
6
- v-if="mainLogo"
7
- :src="mainLogo"
8
- />
9
- <el-popover placement="right-start" width="360" trigger="click">
4
+ <img class="es-simplicity-logo" v-if="mainLogo" :src="mainLogo" />
5
+ <div class="es-simplicity-org-name">{{ userModel.orgName }}</div>
6
+ <el-popover
7
+ class="es-simplicity-user-popover"
8
+ placement="right-start"
9
+ width="360"
10
+ trigger="click"
11
+ >
10
12
  <!-- 用户信息 -->
11
13
  <user
12
14
  :user="user"
@@ -19,7 +21,7 @@
19
21
  <avatar slot="reference" :user="user"> </avatar>
20
22
  <!-- 用户信息 end -->
21
23
  </el-popover>
22
- <div class="es-simplicity-side-item es-simplicity-side-Application">
24
+ <div class="es-simplicity-side-Application">
23
25
  <!-- 常用应用 -->
24
26
  <el-scrollbar>
25
27
  <div
@@ -76,7 +78,7 @@
76
78
  class="es-simplicity-subMenus"
77
79
  direction="ltr"
78
80
  modal-class="es-simplicity-apps-modal"
79
- :size="width"
81
+ :size="width + 'px'"
80
82
  :modal-append-to-body="false"
81
83
  :with-header="false"
82
84
  :visible.sync="showMenu"
@@ -116,19 +118,18 @@
116
118
 
117
119
  <!-- AI -->
118
120
  <el-drawer
119
- class="es-simplicity-subMenus"
121
+ class="es-simplicity-public-drawer"
120
122
  direction="ltr"
121
123
  modal-class="es-simplicity-apps-modal"
122
124
  size="100%"
123
125
  show-close
124
126
  :modal-append-to-body="false"
125
- :with-header="false"
126
127
  :visible.sync="drawer.visible"
127
128
  >
128
- <i
129
+ <!-- <i
129
130
  class="es-icon-close es-simplicity-drawer-close"
130
131
  @click="handleCloseDrawer"
131
- ></i>
132
+ ></i> -->
132
133
  <template v-if="drawer.url">
133
134
  <template v-if="isIE || drawer.method !== 'wujie'">
134
135
  <iframe
@@ -194,7 +195,6 @@
194
195
  v-model="activeName"
195
196
  closable
196
197
  hide-bar
197
- @tab-click="handleTab"
198
198
  @tab-remove="handleRemove"
199
199
  @tab-contextmenu="handleContextmenu"
200
200
  >
@@ -210,6 +210,14 @@
210
210
  :notice-num="notice"
211
211
  @click="handleClick"
212
212
  ></handler>
213
+ <div
214
+ class="es-simplicity-unfold"
215
+ ref="box"
216
+ v-show="!showMenu && subMenus"
217
+ @click="handleShowMenus"
218
+ >
219
+ <i class="el-icon-s-unfold" ref="area"></i>
220
+ </div>
213
221
  <el-tab-pane
214
222
  v-for="item in tabs"
215
223
  :key="item.id"
@@ -238,10 +246,7 @@
238
246
  ></es-wujie>
239
247
  </template>
240
248
  <template v-else-if="item.method === 'router' && item.refresh">
241
- <router-view v-if="!isKeepAlive" :name="item.appCode" />
242
- <keep-alive>
243
- <router-view v-if="isKeepAlive" :name="item.appCode" />
244
- </keep-alive>
249
+ <router-view :name="item.appCode" />
245
250
  </template>
246
251
  </el-tab-pane>
247
252
  </el-tabs>
@@ -299,6 +304,7 @@ import notice from './notice.vue';
299
304
  import settings from './settings.vue';
300
305
  import {
301
306
  wss,
307
+ logout,
302
308
  topic,
303
309
  getUserAppWithTag,
304
310
  getComplexApplications,
@@ -448,7 +454,11 @@ export default {
448
454
  //无界微前端Props属性
449
455
  wjProps: Object,
450
456
  //无界微前端Attrs属性
451
- wjAttrs: Object
457
+ wjAttrs: Object,
458
+ menuWidth: {
459
+ type: Number,
460
+ default: 220
461
+ }
452
462
  },
453
463
  data() {
454
464
  return {
@@ -463,11 +473,11 @@ export default {
463
473
  //所有菜单
464
474
  menus: [],
465
475
  //子菜单
466
- subMenus: [],
476
+ subMenus: null,
467
477
  //展示菜单导航
468
478
  showMenu: false,
469
479
  //展示菜单导航宽度
470
- width: '296px',
480
+ width: this.menuWidth,
471
481
  //人工智能配置
472
482
  aiConfig: null,
473
483
  //公用窗口面板配置
@@ -526,7 +536,9 @@ export default {
526
536
  //页签对象
527
537
  pane: null,
528
538
  //选中菜单
529
- active: ''
539
+ active: '',
540
+ //单位名称
541
+ orgName: ''
530
542
  };
531
543
  },
532
544
  computed: {
@@ -598,6 +610,7 @@ export default {
598
610
  util.win.refresh = this.handleRefresh;
599
611
  util.win.jumpMenu = this.jumpMenu;
600
612
  util.win.windowOpen = this.openPage;
613
+ this.move();
601
614
  },
602
615
  methods: {
603
616
  /**
@@ -624,20 +637,20 @@ export default {
624
637
  let pathname = url.substring(url.indexOf('#/') + 1);
625
638
  pathname = pathname.split('?')[0];
626
639
  if (res.path !== '/' && pathname == path) {
627
- if (typeof res.component === 'function') {
628
- let component = {};
629
- component[code] = res.component;
630
- res.component = component;
631
- if (parentName) {
632
- this.$router.addRoute({ parentName, route: res });
633
- } else {
634
- this.$router.addRoute(res);
640
+ if (res.components) {
641
+ if (!res.components[code]) {
642
+ console.error('“命名视图”规范属性名称与菜单appCode不一致', res);
635
643
  }
644
+ } else {
645
+ console.error(
646
+ '请根据“命名视图”规范,正确添加components属性名称',
647
+ res
648
+ );
636
649
  }
637
650
  return pathname;
638
651
  }
639
652
  if (res && Object.prototype.hasOwnProperty.call(res, 'children')) {
640
- let path = this.hasRouter(res.children, url, code, parentName);
653
+ let path = this.hasRouter(res.children, url, code, res.name);
641
654
  if (path) {
642
655
  return path;
643
656
  }
@@ -654,7 +667,6 @@ export default {
654
667
  this.setConfig(results);
655
668
  if (this.remote) {
656
669
  this.getApplications();
657
- this.getMenus();
658
670
  }
659
671
  },
660
672
  /**
@@ -774,6 +786,7 @@ export default {
774
786
  * @date 2024年9月7日
775
787
  **/
776
788
  getApplications() {
789
+ let loading = util.loading('', '加载中...');
777
790
  util
778
791
  .ajax({
779
792
  url: this.appsUrl,
@@ -797,12 +810,15 @@ export default {
797
810
  } else {
798
811
  this.$message.error('未分配应用菜单权限,请联系管理员!');
799
812
  }
813
+ this.getMenus(loading);
800
814
  } else {
815
+ loading.close();
801
816
  let msg = res.msg || '系统错误,请联系管理员!';
802
817
  this.$message.error(msg);
803
818
  }
804
819
  })
805
820
  .catch((err) => {
821
+ loading.close();
806
822
  if (err.message && err.message !== 'canceled') {
807
823
  this.$message.error(err.message);
808
824
  }
@@ -813,21 +829,84 @@ export default {
813
829
  * @author huangbo
814
830
  * @date 2024年9月7日
815
831
  **/
816
- getMenus(appCode, url) {
817
- let params = appCode ? { menuCode: appCode } : {};
832
+ getMenus(loading) {
818
833
  util
819
- .ajax({ url: url || this._menuUrl, params: params })
834
+ .ajax({ url: this._menuUrl })
820
835
  .then((res) => {
836
+ loading.close();
821
837
  if (res.rCode === 0) {
822
838
  if (res.results && res.results.length) {
823
839
  this.menus = res.results;
824
840
  this.setTips(this.menus);
825
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
+ }
826
895
  if (this.indexUrl) {
827
896
  let obj = this.getMenu(this.menus, this.indexUrl);
828
897
  if (obj) {
829
- this.tabs = [this.setIframeType(obj)];
830
- 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
+ }
831
910
  this.homePage = obj;
832
911
  } else {
833
912
  this.homePage = this.setIframeType({
@@ -836,18 +915,38 @@ export default {
836
915
  id: '0',
837
916
  appCode: 'indexUrl'
838
917
  });
839
- this.tabs = [this.homePage];
840
- 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
+ }
841
929
  }
842
- }
843
- if (this.initApps && this.initApps.length) {
930
+ } else if (
931
+ this.initApps &&
932
+ this.initApps.length &&
933
+ !this.appCode
934
+ ) {
844
935
  let obj = this.getMenu(
845
936
  this.menus,
846
937
  this.initApps[this.initApps.length - 1]
847
938
  );
848
939
  if (obj) {
849
- this.tabs.push(this.setIframeType(obj));
850
- 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
+ }
851
950
  }
852
951
  }
853
952
  } else {
@@ -859,19 +958,22 @@ export default {
859
958
  }
860
959
  })
861
960
  .catch((err) => {
961
+ loading.close();
862
962
  if (err.message && err.message !== 'canceled') {
863
963
  this.$message.error(err.message);
864
964
  }
865
965
  });
866
966
  },
967
+ /**
968
+ * @desc:设置页面加载类型
969
+ * @author huangbo
970
+ * @date 2024年9月7日
971
+ **/
867
972
  setIframeType(res) {
868
973
  let { url } = res;
869
974
  let urls = url.split('?');
870
975
  if (urls[0].indexOf('.js') > 1 && !isIE) {
871
976
  res.method = 'wujie';
872
- this.$nextTick(() => {
873
- res.refresh = true;
874
- });
875
977
  } else if (
876
978
  urls[0].indexOf('.dhtml') > 0 ||
877
979
  (urls[0].indexOf('.html') > 0 && urls[0].indexOf('.html#') === -1)
@@ -885,14 +987,8 @@ export default {
885
987
  if (routes) {
886
988
  let path = this.hasRouter(routes, urls[0], res.appCode);
887
989
  if (path) {
888
- let params = util.getParams({ url: url });
889
- this.$router.push({
890
- path: path,
891
- query: params
892
- });
893
- this.$nextTick(() => {
894
- res.refresh = true;
895
- });
990
+ res.method = 'router';
991
+ res.path = path;
896
992
  } else {
897
993
  let urlopenmode = util.getParams({
898
994
  url: url,
@@ -907,9 +1003,6 @@ export default {
907
1003
  res.method = 'iframe';
908
1004
  } else {
909
1005
  res.method = 'wujie';
910
- this.$nextTick(() => {
911
- res.refresh = true;
912
- });
913
1006
  }
914
1007
  }
915
1008
  } else if (
@@ -917,14 +1010,12 @@ export default {
917
1010
  urls[0].indexOf('/#/') > -1
918
1011
  ) {
919
1012
  res.method = 'wujie';
920
- this.$nextTick(() => {
921
- res.refresh = true;
922
- });
923
1013
  } else {
924
1014
  res.method = 'iframe';
925
1015
  }
926
1016
  }
927
1017
  }
1018
+ res.refresh = true;
928
1019
  return res;
929
1020
  },
930
1021
  /**
@@ -964,6 +1055,37 @@ export default {
964
1055
  }
965
1056
  return false;
966
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
+ },
967
1089
  /**
968
1090
  * @desc:遍历设置菜单气泡提醒
969
1091
  * @author huangbo
@@ -983,31 +1105,29 @@ export default {
983
1105
  this.$set(obj, 'tips', false);
984
1106
  delete obj.tips;
985
1107
  }
986
- let flag = false;
1108
+ let flag = 0;
987
1109
  if (obj.children && obj.children.length) {
988
1110
  obj.children.forEach((item) => {
989
- if (this.setTips(item)) {
990
- flag = true;
991
- }
1111
+ let n = this.setTips(item);
1112
+ flag += n ? parseInt(n) : 0;
992
1113
  });
993
1114
  if (flag) {
994
- this.$set(obj, 'tips', true);
995
- return true;
1115
+ this.$set(obj, 'tips', flag);
1116
+ return flag;
996
1117
  }
997
1118
  } else if (obj.fourthTabs && obj.fourthTabs.length) {
998
1119
  obj.fourthTabs.forEach((item) => {
999
- if (this.setTips(item)) {
1000
- flag = true;
1001
- }
1120
+ let n = this.setTips(item);
1121
+ flag += n ? parseInt(n) : 0;
1002
1122
  });
1003
1123
  if (flag) {
1004
- this.$set(obj, 'tips', true);
1005
- return true;
1124
+ this.$set(obj, 'tips', flag);
1125
+ return flag;
1006
1126
  }
1007
1127
  } else {
1008
1128
  if (this.menuTips[obj.id] && Number(this.menuTips[obj.id])) {
1009
1129
  this.$set(obj, 'tips', Number(this.menuTips[obj.id]));
1010
- return true;
1130
+ return this.menuTips[obj.id];
1011
1131
  }
1012
1132
  }
1013
1133
  }
@@ -1095,37 +1215,57 @@ export default {
1095
1215
  this.subMenus = res;
1096
1216
  this.showMenu = true;
1097
1217
  this.showApps = false;
1098
- this.width = '296px';
1218
+ this.width = this.menuWidth;
1099
1219
  this.$refs.subMenus && this.$refs.subMenus.clearSubmenu();
1100
1220
  } else {
1101
- if (res.code) {
1221
+ let set = true;
1222
+ if (res.url) {
1223
+ if (res.urlopenmode == 1 || res.openModel == 1) {
1224
+ set = false;
1225
+ util.win.open(res.url);
1226
+ } else if (res.urlopenmode == 2 || res.openModel == 2) {
1227
+ set = false;
1228
+ util.win.location.href = res.url;
1229
+ } else {
1230
+ let i = util.indexOfObj(this.tabs, res, 'id');
1231
+ this.activeName = res.id;
1232
+ if (i == -1) {
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
+ }
1242
+ }
1243
+ }
1244
+ }
1245
+ if (set && res.code) {
1102
1246
  let subMenus = this.getMenu(this.menus, res.code, 'appCode');
1103
- this.subMenus = subMenus ? subMenus : [];
1247
+ console.log(subMenus);
1248
+ this.subMenus = subMenus ? subMenus : null;
1104
1249
  this.showMenu = subMenus !== false;
1105
1250
  this.showApps = false;
1106
- this.width = '296px';
1251
+ this.width = this.menuWidth;
1107
1252
  this.$refs.subMenus && this.$refs.subMenus.clearSubmenu();
1108
1253
  }
1109
1254
  }
1110
- if (res.url) {
1111
- if (res.urlopenmode == 1 || res.openModel == 1) {
1112
- util.win.open(res.url);
1113
- } else if (res.urlopenmode == 2 || res.openModel == 2) {
1114
- util.win.location.href = res.url;
1115
- } else {
1116
- let i = util.indexOfObj(this.tabs, res, 'id');
1117
- this.activeName = res.id;
1118
- if (i == -1) {
1119
- this.tabs.push(this.setIframeType(res));
1120
- }
1121
- }
1122
- }
1123
1255
  this.active = res.id;
1124
1256
  } else {
1125
1257
  this.showMenu = false;
1126
1258
  this.showApps = !this.showApps;
1127
1259
  }
1128
1260
  },
1261
+ /**
1262
+ * @desc:显示菜单界面
1263
+ * @author huangbo
1264
+ * @date 2024年9月7日
1265
+ **/
1266
+ handleShowMenus() {
1267
+ this.showMenu = true;
1268
+ },
1129
1269
  /**
1130
1270
  * @desc:显示Drawer界面
1131
1271
  * @author huangbo
@@ -1154,14 +1294,23 @@ export default {
1154
1294
  **/
1155
1295
  handlerClickMenu(res) {
1156
1296
  if (typeof res === 'number') {
1157
- let num = 296;
1158
- this.width = num * res + 'px';
1297
+ let num = this.menuWidth;
1298
+ this.width = num * res;
1159
1299
  } else {
1160
1300
  let i = util.indexOfObj(this.tabs, res, 'id');
1161
1301
  this.activeName = res.id;
1162
1302
  if (i == -1) {
1163
- 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
+ }
1164
1312
  }
1313
+ this.showMenu = false;
1165
1314
  }
1166
1315
  },
1167
1316
  /**
@@ -1198,28 +1347,6 @@ export default {
1198
1347
  this.webSocket.destroy();
1199
1348
  }
1200
1349
  },
1201
- /**
1202
- * @desc:选中iframe页签刷新
1203
- * @author huangbo
1204
- * @date 2024年9月7日
1205
- **/
1206
- handleTab(res) {
1207
- let index;
1208
- if (res) {
1209
- index = parseInt(res.index);
1210
- } else {
1211
- index = util.indexOfObj(this.tabs, this.activeName, 'id');
1212
- }
1213
- let item = this.tabs[index];
1214
- if (item.method == 'iframe') {
1215
- item.url = util.handlerUrl(item.url);
1216
- } else {
1217
- item.refresh = false;
1218
- this.$nextTick(() => {
1219
- item.refresh = true;
1220
- });
1221
- }
1222
- },
1223
1350
  /**
1224
1351
  * @desc:刷新选中iframe页签
1225
1352
  * @author huangbo
@@ -1591,13 +1718,74 @@ export default {
1591
1718
  let obj = this.getMenu(this.menus, apps[apps.length - 1]);
1592
1719
  if (obj) {
1593
1720
  let i = util.indexOfObj(this.tabs, obj, 'id');
1721
+ let n = util.indexOfObj(this.tabs, this.activeName, 'id');
1722
+ this.activeName = obj.id;
1594
1723
  if (i == -1) {
1595
- 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
+ }
1596
1733
  }
1597
- this.activeName = obj.id;
1598
1734
  } else {
1599
1735
  this.$message.error('没有此菜单!');
1600
1736
  }
1737
+ },
1738
+ //移动
1739
+ move() {
1740
+ let area = this.$refs.area;
1741
+ let box = this.$refs.box;
1742
+ let [sTime, eTime] = [0, 0];
1743
+ area.addEventListener('mousedown', (e) => {
1744
+ sTime = new Date().getTime();
1745
+ let { y: downY, x: downX } = e;
1746
+ let { height: winH, width: winW } =
1747
+ document.body.getBoundingClientRect();
1748
+ //防止拖动期间选中和复制网页文本
1749
+ document.body.onselectstart = document.body.oncontextmenu = () => {
1750
+ return false;
1751
+ };
1752
+ document.onmousemove = (eve) => {
1753
+ let size = 40;
1754
+ let { y: moveY, x: moveX } = eve;
1755
+ let { top: boxTop, left: boxLeft } = box.getBoundingClientRect();
1756
+ boxTop += moveY - downY;
1757
+ boxLeft += moveX - downX;
1758
+ boxTop >= winH - size && (boxTop = winH - size);
1759
+ boxTop <= -size && (boxTop = -size);
1760
+ boxLeft >= winW - size && (boxLeft = winW - size);
1761
+ boxLeft <= -size && (boxLeft = -size);
1762
+ if (boxTop < 60) {
1763
+ boxTop = 60;
1764
+ }
1765
+ if (boxLeft < 80) {
1766
+ boxLeft = 80;
1767
+ }
1768
+ box.style.top = boxTop + 'px';
1769
+ box.style.left = boxLeft + 'px';
1770
+ downY = moveY;
1771
+ downX = moveX;
1772
+ };
1773
+ document.onmouseup = () => {
1774
+ eTime = new Date().getTime();
1775
+ let isClick = eTime - sTime < 200;
1776
+ if (isClick) {
1777
+ let onArea = () => {
1778
+ this.subMenu = [];
1779
+ area.removeEventListener('click', onArea);
1780
+ };
1781
+ area.addEventListener('click', onArea);
1782
+ }
1783
+ document.onmousemove = null;
1784
+ document.body.onselectstart = document.body.oncontextmenu = () => {
1785
+ return true;
1786
+ };
1787
+ };
1788
+ });
1601
1789
  }
1602
1790
  },
1603
1791
  beforeDestroy() {