index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <el-container class="box-all" v-loading="loading">
  3. <el-header>
  4. <div class="flex-box" style="height: 60px;min-width: 1200px;">
  5. <div class="logo-box flex-box flex-center-center" @click="openHome()">
  6. <img src="./assets/image/logo.png" class="logo" />
  7. <div>功道云积分制</div>
  8. </div>
  9. <div class="flex-1 hea-right flex-box flex-v-ce" >
  10. <div class="name" style="min-width: 200px;">{{ info.name }}</div>
  11. <div class="flex-1 flex-box-ce font-flex-word" style="cursor: pointer;padding: 0 20px;">
  12. <template v-if="$supremeAuthority()=='dept_manager'||$supremeAuthority()=='employee'">
  13. <template v-if="information.name">
  14. <img src="./assets/image/tz.png" style="width: 18px;height: 18px;"/>
  15. <span style="max-width: 500px;padding-left: 10px;" class="font-flex-word" @click="$router.push({path:'inform'})">{{information.name}}</span>
  16. </template>
  17. </template>
  18. <div v-else class="flex-box-ce" >
  19. <img src="./assets/image/tz.png" style="width: 18px;height: 18px;"/>
  20. <template v-if="information.name">
  21. <span style="max-width: 500px;padding-left: 10px;" class="font-flex-word" @click="$router.push({path:'inform'})">{{information.name}}</span>
  22. </template>
  23. <span v-else style="padding: 0 10px;cursor: pointer;color: #606266;" @click="$router.push({path:'inform'})">暂无公告,点击此处添加公告</span>
  24. </div>
  25. </div>
  26. <div class="flex-box flex-v-ce">
  27. <div>
  28. 您当前为
  29. <span class="blue">"{{ corpMessage.package_name }}"</span>
  30. ,有效期至
  31. <span style="color:#FF9600">{{ corpMessage.expire_time }}</span>
  32. </div>
  33. <el-button size="small" @click="isTz = true" class="upgrade" type="primary" icon="el-icon-upload">续费升级</el-button>
  34. <el-tooltip class="item" effect="dark" content="设置向导" placement="bottom" v-if="!this.$authoritys('employee') && !this.$authoritys('dept_manager')">
  35. <img src="./assets/image/wn.png" class="wn" @click="showWn" />
  36. </el-tooltip>
  37. <userImage :user_name="userData.name" :img_url="userData.img_url" width="44px" height="44px"></userImage>
  38. </div>
  39. </div>
  40. </div>
  41. </el-header>
  42. <el-container class="main">
  43. <el-aside>
  44. <el-menu :default-active="defaultActive" class="el-menu-vertical-demo" :router="true" @select="activeRouter" :unique-opened="true">
  45. <template v-for="(item, index) in routers">
  46. <div v-if="item.children.length != 0" :key="index">
  47. <el-submenu :index="index.toString()" :key="index" v-if="item.children.length >= 1 && item.name != '首页'">
  48. <template slot="title">
  49. <span class="iconfont titleIcon" :class="item.icon" style="font-size: 20px;"></span>
  50. <span style="margin-left: 5px;">{{ item.name }}</span>
  51. </template>
  52. <template v-for="(item2, index2) in item.children">
  53. <el-menu-item :index="returnIndex(index, index2)" :ref="item2.path" :route="item2.path" :key="index2" class="font-flex-word">
  54. <span slot="title" style="margin-left: 10px;width:120px">{{ item2.name }}</span>
  55. </el-menu-item>
  56. </template>
  57. </el-submenu>
  58. <el-menu-item :index="returnIndex(index, index)" :route="item.children[0].path" :ref="item.children[0].path" v-else>
  59. <span class="iconfont titleIcon" :class="item.icon" style="font-size: 20px;"></span>
  60. <span slot="title" style="margin-left: 5px;">{{ item.children[0].name }}</span>
  61. </el-menu-item>
  62. </div>
  63. </template>
  64. </el-menu>
  65. </el-aside>
  66. <el-main>
  67. <router-view />
  68. <div class="fontColorF" style="text-align: center;margin: 10px 0;">Copyright © 2021 广东功道云数字科技有限公司 All Rights Reserved</div>
  69. </el-main>
  70. </el-container>
  71. <!-- 续费升级 -->
  72. <el-dialog class="续费升级" :visible.sync="isTz" width="400px">
  73. <div style="border-radius: 15px;border: 1px solid #f1f1f1;padding: 10px; width: 276px;box-sizing: border-box;margin: 0 auto;">
  74. <img src="./assets/image/code.png" />
  75. </div>
  76. <div class="fontColorF" style="text-align: center;margin-top: 15px;font-size: 18px;">手机钉钉扫码,付费升级</div>
  77. </el-dialog>
  78. <el-dialog title="设置向导" :visible.sync="wn_show" width="600px">
  79. <div>
  80. <div class="wn-title fontColorF">三步轻松搭建积分管理体系:定人员、分责权、建制度</div>
  81. <div class="flex-box flex-v-ce wn-box">
  82. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(0)">
  83. <div><span class="iconfont " :class="routers_one[0].meta.icon"></span></div>
  84. <div>1、确定{{ routers_one[0].name }}</div>
  85. </div>
  86. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(1)">
  87. <div><span class="iconfont " :class="routers_one[1].meta.icon"></span></div>
  88. <div>2、分配{{ routers_one[1].name }}</div>
  89. </div>
  90. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(2)">
  91. <div><span class="iconfont " :class="routers_one[2].meta.icon"></span></div>
  92. <div>3、建立{{ routers_one[2].name }}</div>
  93. </div>
  94. </div>
  95. </div>
  96. <div>
  97. <div class="wn-title fontColorF">更有效地做好积分激励和认可,你还可以设置以下3项</div>
  98. <div class="flex-box flex-v-ce wn-box">
  99. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(3)">
  100. <div><span class="iconfont " :class="routers_one[3].meta.icon"></span></div>
  101. <div>{{ routers_one[3].name }}</div>
  102. </div>
  103. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(4)">
  104. <div><span class="iconfont " :class="routers_one[4].meta.icon"></span></div>
  105. <div>{{ routers_one[4].name }}</div>
  106. </div>
  107. <div class="flex-1 flex-box-v flex-v-ce" @click="openView(5)">
  108. <div><span class="iconfont " :class="routers_one[5].meta.icon"></span></div>
  109. <div>{{ routers_one[5].name }}</div>
  110. </div>
  111. </div>
  112. </div>
  113. </el-dialog>
  114. </el-container>
  115. </template>
  116. <script>
  117. import { createSocket,sendWSPush,sendPing } from './api/websocket'
  118. import { removeCache } from './api/auth'
  119. export default {
  120. data() {
  121. return {
  122. loading: false,
  123. userData: {},
  124. routers: [],
  125. routers_one: [],
  126. info: {},
  127. wn_show: false,
  128. defaultActive: '0-0',
  129. isShowWn: true,
  130. isTz: false,
  131. direction: 'rtl',
  132. corpMessage: {} ,//企业套餐信息
  133. information:{name:''},
  134. };
  135. },
  136. watch: {
  137. $route(to, from) {
  138. var str = to.path;
  139. this.routers.map((item, index) => {
  140. if (item.children.length > 0) {
  141. item.children.map((item2, index2) => {
  142. if (item2.path == str) {
  143. this.defaultActive = index + '-' + index2;
  144. localStorage.setItem('path', index + '-' + index2);
  145. }
  146. });
  147. }
  148. });
  149. if(localStorage.getItem('inform')){
  150. this.getInform()
  151. removeCache('inform')
  152. }
  153. }
  154. },
  155. created() {
  156. this.initRouter();
  157. this.getEmployee()//缓存人员列表
  158. this.getInform();
  159. },
  160. mounted() {
  161. this.getTypes();
  162. this.getInfo();
  163. var url = window.location.href;
  164. var str = this.GetRequest(url).corpId || '123';
  165. // var rUrl = this.GetRequest(url).url || '';
  166. var corpId = str.split('#')[0];
  167. if (corpId) {
  168. this.getCorp(corpId);
  169. }
  170. this.$nextTick(function() {
  171. if (!this.$authoritys('employee') && !this.$authoritys('dept_manager')) {
  172. if (localStorage.getItem('wn_show')) {
  173. this.wn_show = false;
  174. this.isShowWn = false;
  175. } else {
  176. this.wn_show = true;
  177. localStorage.setItem('wn_show', 'true');
  178. }
  179. }
  180. });
  181. },
  182. methods: {
  183. openWebSocket(){
  184. // 接收消息
  185. const getsocketData = e => { // 创建接收消息函数
  186. const data = e && e.detail.data
  187. console.log(data)
  188. }
  189. // 注册监听事件
  190. window.addEventListener('onmessageWS', getsocketData)
  191. // 在需要的时候卸载监听事件,比如离开页面
  192. window.removeEventListener('onmessageWS', getsocketData)
  193. },
  194. getInform(){
  195. let params = {
  196. page: 1,
  197. page_size: 1
  198. };
  199. this.$axios('get', '/api/information/index', params).then(res => {
  200. if (res.data.code == 1) {
  201. let data= res.data.data;
  202. if(data[0]){
  203. this.information=data[0]
  204. }else{
  205. this.information={name:''};
  206. }
  207. }
  208. });
  209. },
  210. initRouter() {
  211. this.routers = [
  212. { name: '首页', children: this.returnRoutersArr('home'), icon: 'icon-shouye' },
  213. { name: 'A/B分', children: this.returnRoutersArr('abPoint'), icon: 'icon-PC_gongzuotai_ABfen' },
  214. { name: '任务', children: this.returnRoutersArr('task'), icon: 'icon-kaoqin_kaoqinyuebaobiao' },
  215. { name: '统计', children: this.returnRoutersArr('ranking'), icon: 'icon-dingdingPC_tongji1' },
  216. // { name: '福利', children: this.returnRoutersArr('welfare'), icon: 'icon-fulizhongxin'}
  217. ];
  218. //this.$authoritys('权限名') 判断权限
  219. if (this.$authoritys('creator') || this.$authoritys('admin') || this.$authoritys('point_manager') || this.$authoritys('dept_manager')) {
  220. this.routers.splice(3, 0, { name: '审批', children: this.returnRoutersArr('workbench'), icon: 'icon-shezhi_jifenguize' });
  221. }
  222. if (this.$authoritys('creator') || this.$authoritys('admin') || this.$authoritys('point_manager')) {
  223. this.routers.push({ name: '设置', children: this.returnRoutersArr('set'), icon: 'icon-dingdingPC_shezhi1' });
  224. }
  225. //this.returnRoutersArr('set',true) 加true表示不限制路由
  226. this.routers_one = this.returnRoutersArr('set', true);
  227. this.userData = this.$getUserData();
  228. if (this.$route.path != '/home') {
  229. //当刷新页面是控制左边导航栏的选中
  230. this.defaultActive = localStorage.getItem('path');
  231. }
  232. },
  233. openHome() {
  234. this.$router.push({ path: '/home' });
  235. },
  236. GetRequest(urlStr) {
  237. if (typeof urlStr == 'undefined') {
  238. var url = decodeURI(location.search); //获取url中"?"符后的字符串
  239. } else {
  240. var url = '?' + urlStr.split('?')[1];
  241. }
  242. var theRequest = new Object();
  243. var strs;
  244. if (url.indexOf('?') != -1) {
  245. var str = url.substr(1);
  246. strs = str.split('&');
  247. for (var i = 0; i < strs.length; i++) {
  248. theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
  249. }
  250. }
  251. return theRequest;
  252. },
  253. //获取套餐信息
  254. getCorp(corpId) {
  255. this.$axios('get', 'api/order/corp', { corp_id: corpId }).then(res => {
  256. this.corpMessage = res.data.data;
  257. });
  258. },
  259. //当刷新页面是控制左边导航栏的选中
  260. activeRouter(index, indexPath) {
  261. localStorage.setItem('path', indexPath[1] ? indexPath[1] : indexPath[0]);
  262. },
  263. routerAstrict(data) {
  264. //限制路由
  265. let obj = [];
  266. let supAuthority = this.$supremeAuthority(); //$supremeAuthority获取当前登录者的最高权限
  267. data.forEach(item => {
  268. if (!item.hidden) {
  269. if (!item.meta.jurisdiction) {
  270. obj.push(item);
  271. } else {
  272. if (item.meta.jurisdiction.indexOf(supAuthority) == -1) {
  273. obj.push(item);
  274. }
  275. }
  276. }
  277. });
  278. return obj;
  279. },
  280. returnRoutersArr(str, bool) {
  281. var routers = this.$router.options.routes[0].children;
  282. var routersArr = [];
  283. routers.forEach(item => {
  284. if (item.meta.groupCode == str) {
  285. //获取对应模块的路由
  286. routersArr.push(item);
  287. }
  288. });
  289. if (bool) {
  290. return routersArr;
  291. }
  292. return this.routerAstrict(routersArr);
  293. },
  294. returnIndex(str, str2) {
  295. return str + '-' + str2;
  296. },
  297. openView(e) {
  298. this.wn_show = false;
  299. this.isShowWn = false;
  300. this.$router.push({ path: this.routers_one[e].path });
  301. },
  302. showWn() {
  303. this.wn_show = true;
  304. },
  305. getInfo() {
  306. var that = this;
  307. this.$axios('get', '/api/site/info').then(res => {
  308. that.info = res.data.data;
  309. });
  310. },
  311. getTypes() {
  312. var that = this;
  313. this.$axios('get', '/api/integral/types').then(res => {
  314. that.$setTyps(res.data.data.list);
  315. });
  316. },
  317. //获取员工列表
  318. getEmployee() {
  319. this.$axios('get', '/api/employee/index', { dept_id: 0, page: 1, page_size: 3000,is_official:1 }).then(res => {
  320. let map={};
  321. res.data.data.list.map(item=>{
  322. map[item.id]=item
  323. })
  324. localStorage.setItem("userList",JSON.stringify(map))
  325. })
  326. },
  327. },
  328. };
  329. </script>
  330. <style scoped="scoped" lang="scss">
  331. .wn-box {
  332. padding: 20px 0;
  333. }
  334. .wn-box .flex-1 {
  335. cursor: pointer;
  336. }
  337. .wn-box .flex-1 div:nth-child(1) {
  338. width: 55px;
  339. height: 55px;
  340. border-radius: 50%;
  341. text-align: center;
  342. line-height: 55px;
  343. background-color: #e0f2ff;
  344. color: #26a2ff;
  345. margin-bottom: 20px;
  346. }
  347. .wn-box .flex-1 div:nth-child(2) {
  348. width: 110px;
  349. border-radius: 25px;
  350. border: 1px solid #26a2ff;
  351. padding: 7px 10px;
  352. text-align: center;
  353. color: #26a2ff;
  354. }
  355. .wn-box .flex-1:hover div:nth-child(1) {
  356. color: #fff;
  357. background-color: #26a2ff;
  358. }
  359. .wn-box .flex-1:hover div:nth-child(2) {
  360. color: #fff;
  361. background-color: #26a2ff;
  362. }
  363. .el-menu-vertical-demo:not(.el-menu--collapse) {
  364. width: 180px;
  365. // min-height: 400px;
  366. }
  367. .el-header {
  368. background-color: #fff;
  369. // line-height: 60px;
  370. padding: 0 !important;
  371. border-bottom: 1px solid #f1f1f1;
  372. }
  373. .el-menu {
  374. overflow: hidden;
  375. border: none;
  376. }
  377. .el-aside {
  378. transition: width 0.28s;
  379. width: 180px !important;
  380. background-color: #fff;
  381. height: calc(100vh - 60px);
  382. }
  383. .el-aside::-webkit-scrollbar {
  384. width: 0px;
  385. background-color: #fff;
  386. }
  387. .el-aside::-webkit-scrollbar-thumb {
  388. background-color: #ccc;
  389. }
  390. .con_nav_left {
  391. background: #fff;
  392. overflow-y: scroll;
  393. }
  394. .box-all {
  395. height: 100%;
  396. overflow: hidden;
  397. }
  398. .el-main {
  399. background-color: #f4f6f9;
  400. height: calc(100vh - 60px);
  401. overflow-y: scroll;
  402. padding: 10px;
  403. min-width: 1000px;
  404. }
  405. .el-main::-webkit-scrollbar {
  406. width: 3px;
  407. height: 10px;
  408. background-color: #fff;
  409. }
  410. .el-main::-webkit-scrollbar-thumb {
  411. background-color: #d9d9d9;
  412. }
  413. .logo-box {
  414. width: 180px;
  415. cursor: pointer;
  416. }
  417. .logo-box .logo {
  418. width: 30px;
  419. height: 30px;
  420. margin-right: 5px;
  421. border-radius: 6px;
  422. }
  423. .logo-box div {
  424. font-size: 16px;
  425. font-weight: 600;
  426. }
  427. .wn {
  428. height: 26px;
  429. width: 26px;
  430. margin-right: 12px;
  431. cursor: pointer;
  432. }
  433. .hea-right {
  434. padding: 0 20px;
  435. }
  436. .upgrade {
  437. margin-left: 10px;
  438. margin-right: 10px;
  439. }
  440. ::v-deep .el-menu-item {
  441. padding-right: 10px !important;
  442. }
  443. ::v-deep .el-menu-item.is-active {
  444. color: #26a2ff;
  445. background-color: #ecf5ff;
  446. }
  447. </style>