index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <div class="out-box">
  3. <div class="top-view">
  4. <div class="main-content clearfix">
  5. <div class="logo-img float_left">
  6. <img src="../../assets/img/logo-21249f@2x.png" alt="logo" />
  7. <span class="line"></span>
  8. <span class="txt">企业中心</span>
  9. </div>
  10. <div class="float_right" style="color: #0a001f">
  11. <el-popover placement="bottom" width="200" trigger="hover">
  12. <div slot="reference">
  13. <img :src="avatar" alt="用户头像" class="user-avatar" />
  14. <span>{{ userName }}</span>
  15. </div>
  16. <p class="logo-out" @click="loginOut">退出登录</p>
  17. </el-popover>
  18. </div>
  19. </div>
  20. </div>
  21. <!-- <div class="tab">-->
  22. <div class="tab-list clearfix">
  23. <div
  24. class="tab-li"
  25. :class="[tab_index === 1 ? 'tab-on' : '']"
  26. @click="changeTab(false, 1)"
  27. >
  28. 企业中心
  29. </div>
  30. <div
  31. class="tab-li"
  32. :class="[tab_index === 2 ? 'tab-on' : '']"
  33. @click="changeTab(true, 2)"
  34. >
  35. 到期企业
  36. </div>
  37. <div class="add-btn float_right" @click="addModel">新建企业</div>
  38. </div>
  39. <!-- </div>-->
  40. <div class="e-main-div">
  41. <ul v-if="enterprise_list.length" class="enterprise-ul">
  42. <li
  43. v-for="(item, index) in enterprise_list"
  44. :key="index"
  45. class="enterprise-li"
  46. >
  47. <div class="center-div clearfix">
  48. <div class="float_left">
  49. <img :src="item.logo" class="enter-logo" alt="" />
  50. </div>
  51. <div class="float_left enter-name">
  52. {{ item.enterpriseName }}
  53. <i class="iconfont icon-bianji" @click="editData(item)"></i>
  54. </div>
  55. </div>
  56. <div class="left-div">
  57. <div class="tag-li info-tag">
  58. {{ item.scope === 4 ? "单店铺" : "连锁店铺" }}
  59. </div>
  60. <div v-if="item.expireStatus" class="tag-li warning-tag">到期</div>
  61. <div class="tag-li success-tag">正常</div>
  62. <div class="tag-li danger-tag" @click="dle(item)">删除</div>
  63. </div>
  64. <div class="clearfix bottom-div">
  65. <div class="time-p float_left">
  66. <img src="@/assets/img/ic-yxtime.png" class="ic-yxtime" alt="" />
  67. {{ $_common.formatDate(item.expireTime) }}
  68. </div>
  69. <div class="float_right btn-ul" @click="goEnterprise(item)">
  70. 进入企业
  71. </div>
  72. </div>
  73. </li>
  74. </ul>
  75. <div v-else class="no_enterprise-div">
  76. <img
  77. class="no_enterprise"
  78. src="../../assets/img/no_enterprise.png"
  79. alt=""
  80. />
  81. <p>
  82. 您还没有企业,快去创建吧!
  83. <el-button type="text" @click="$router.push('/CreateStore')">
  84. 立即创建
  85. </el-button>
  86. </p>
  87. </div>
  88. <div class="bottom-slogin">
  89. ©2019- {{ fullYear }} {{ enterprise_title }} -
  90. 为传统企业量身打造的全渠道产业互联网线上线下一体化新零售营销系统!
  91. </div>
  92. </div>
  93. <el-dialog
  94. title="新建企业"
  95. :visible.sync="centerDialogVisible"
  96. width="40%"
  97. :close-on-press-escape="false"
  98. :close-on-click-modal="false"
  99. @close="centerDialogVisible = false"
  100. >
  101. <CreateStore
  102. v-if="centerDialogVisible"
  103. :enterprise-id="enterpriseId"
  104. @confirm="confirmAdd"
  105. @cancel="centerDialogVisible = false"
  106. ></CreateStore>
  107. </el-dialog>
  108. </div>
  109. </template>
  110. <script>
  111. import {
  112. getAllEnterprise,
  113. createToken,
  114. getAclList,
  115. getStaffByToken,
  116. deleteEnterprise,
  117. } from "@/api/user";
  118. import CreateStore from "./CreateStore.vue";
  119. import { recordRoute } from "@/config/settings";
  120. import { mapActions, mapGetters } from "vuex";
  121. import router from "@/router";
  122. export default {
  123. name: "SystemIndex",
  124. components: {
  125. CreateStore,
  126. },
  127. data() {
  128. return {
  129. enterpriseId: 0,
  130. centerDialogVisible: false,
  131. fullYear: new Date().getFullYear(),
  132. enterprise_list: [],
  133. enterprise_all: [],
  134. overdue_list: [],
  135. tab_index: 1,
  136. page: 1,
  137. page_size: 10,
  138. total_count: 0,
  139. user_info: "18888888888",
  140. };
  141. },
  142. computed: {
  143. ...mapGetters({
  144. avatar: "user/avatar",
  145. }),
  146. },
  147. mounted() {
  148. this.getAllEnterprise();
  149. },
  150. methods: {
  151. async dle(e){
  152. console.log(e,'0000000')
  153. let that=this
  154. let data=e
  155. this.$confirm("确定要删除吗?", "提示", {
  156. confirmButtonText: "确定",
  157. cancelButtonText: "取消",
  158. type: "warning",
  159. }).then(() => {
  160. deleteEnterprise({
  161. data
  162. }).then((res)=>{
  163. location.reload()
  164. })
  165. });
  166. },
  167. addModel() {
  168. sessionStorage.removeItem("enToken");
  169. this.enterpriseId = 0;
  170. this.centerDialogVisible = true;
  171. },
  172. confirmAdd() {
  173. this.centerDialogVisible = false;
  174. this.getAllEnterprise();
  175. },
  176. ...mapActions({
  177. setAccessToken: "user/setAccessToken",
  178. setEnToken: "user/setEnToken",
  179. changeExpireTime: "MUser/changeExpireTime",
  180. changeUserName: "MUser/changeUserName",
  181. changeShelfLifeSetUp: "MUser/changeShelfLifeSetUp",
  182. changeUserCenterId: "MUser/changeUserCenterId",
  183. changeEnterpriseScope: "MUser/changeEnterpriseScope",
  184. changeEnterprise: "MUser/changeEnterprise",
  185. }),
  186. // 获取企业列表
  187. async getAllEnterprise() {
  188. const { data } = await getAllEnterprise();
  189. if (data.length) {
  190. this.enterprise_list = data.filter((item) => {
  191. return !item.expireStatus;
  192. });
  193. this.overdue_list = data.filter((item) => {
  194. return item.expireStatus;
  195. });
  196. this.enterprise_all = data;
  197. }
  198. },
  199. changeTab(val, index) {
  200. this.enterprise_list = this.enterprise_all.filter((item) => {
  201. return item.expireStatus === val;
  202. });
  203. this.tab_index = index;
  204. },
  205. // 进入企业
  206. async goEnterprise(row) {
  207. const Loading = this.$baseColorfullLoading(1, "正在进入企业...");
  208. this.setEnToken(row.token);
  209. /*const { data } = await createToken({
  210. userCenterId: row.userCenterId,
  211. });
  212. // 重新生成token
  213. this.setAccessToken(data.token);*/
  214. // 保存店铺类型 区分单店和连锁
  215. this.changeEnterpriseScope(row.scope);
  216. this.changeEnterprise(row);
  217. this.changeExpireTime(row.expireTime);
  218. // 存储开启保质期设置状态
  219. this.changeShelfLifeSetUp(row.shelfLifeSetUp);
  220. sessionStorage.setItem("roleType", row.roleType);
  221. await this.$store.dispatch("user/getUserInfo", row.roleType);
  222. await this.getAclList(row.roleType);
  223. // await this.getStaffByToken(row.roleType);
  224. if (!this.$route.params.isCashier) {
  225. // await this.$router.push(`/`);
  226. this.$router.push(`/SelectStore`);
  227. } else {
  228. this.$router.push(`/CashierShop/CashierShop`);
  229. }
  230. Loading.close();
  231. },
  232. // 获取当前登录员工信息
  233. async getStaffByToken(roleType) {
  234. const { data } = await getStaffByToken(roleType);
  235. if (data.name) {
  236. this.changeUserName(data.name);
  237. }
  238. this.changeUserCenterId(data.userCenterId);
  239. if (!this.$route.params.isCashier) {
  240. // await this.$router.push(`/`);
  241. this.$router.push(`/SelectStore`);
  242. } else {
  243. this.$router.push(`/CashierShop/CashierShop`);
  244. }
  245. },
  246. // 获取员工权限
  247. async getAclList(roleType) {
  248. const { data } = await getAclList(roleType);
  249. sessionStorage.setItem("dataField", JSON.stringify(data.dataField));
  250. sessionStorage.setItem("isSuper", data.isAdministrator);
  251. sessionStorage.setItem("nodes", JSON.stringify(data.custom));
  252. // 进入企业设置,根据权限设置菜单
  253. let accessRoutes = await this.$store.dispatch("routes/setRoutes");
  254. router.addRoutes(accessRoutes);
  255. },
  256. editData(item) {
  257. sessionStorage.removeItem("enToken");
  258. setTimeout(() => {
  259. this.enterpriseId = item.enterpriseId;
  260. sessionStorage.setItem("enToken", item.token);
  261. }, 100);
  262. setTimeout(() => {
  263. this.centerDialogVisible = true;
  264. }, 500);
  265. },
  266. async logout() {
  267. await this.$store.dispatch("user/logout");
  268. if (recordRoute) {
  269. const fullPath = this.$route.fullPath;
  270. this.$router.push(`/login?redirect=${fullPath}`);
  271. } else if (this.systemType === 3) {
  272. this.$router.push("/MerchantsLogin");
  273. } else {
  274. this.$router.push("/login");
  275. }
  276. },
  277. loginOut() {
  278. this.$confirm("确定要退出登录吗?", "提示", {
  279. confirmButtonText: "确定",
  280. cancelButtonText: "取消",
  281. type: "warning",
  282. }).then(() => {
  283. sessionStorage.clear();
  284. this.logout();
  285. });
  286. },
  287. },
  288. };
  289. </script>
  290. <style scoped lang="scss">
  291. .out-box {
  292. background-color: #f8fafd;
  293. height: 100vh;
  294. }
  295. .top-view {
  296. height: 80px;
  297. line-height: 80px;
  298. position: relative;
  299. background-color: #ffffff;
  300. box-shadow: 0 2px 20px 0 rgba(202, 208, 215, 0.3);
  301. .main-content {
  302. width: 1200px;
  303. margin: 0 auto;
  304. .logo-img {
  305. width: 320px;
  306. font-size: 18px;
  307. img {
  308. height: 36px;
  309. display: inline-block;
  310. vertical-align: middle;
  311. }
  312. .line {
  313. margin: 0 20px;
  314. width: 1px;
  315. height: 24px;
  316. display: inline-block;
  317. background-color: #e6e6e6;
  318. vertical-align: middle;
  319. /*margin-left: 20px;*/
  320. }
  321. .txt {
  322. font-size: 18px;
  323. font-weight: 400;
  324. color: #000000;
  325. margin-top: 20px;
  326. vertical-align: center;
  327. }
  328. }
  329. .float_right {
  330. cursor: pointer;
  331. .user-avatar {
  332. width: 48px;
  333. height: 48px;
  334. border-radius: 100%;
  335. vertical-align: middle;
  336. margin-right: 8px;
  337. }
  338. }
  339. }
  340. }
  341. .right {
  342. position: relative;
  343. top: 10px;
  344. right: 10px;
  345. }
  346. .tab-list {
  347. font-weight: bold;
  348. margin: 36px auto 0;
  349. height: 64px;
  350. line-height: 64px;
  351. background-color: #ffffff;
  352. width: 1200px;
  353. padding-left: 28px;
  354. border-radius: 2px 2px 0px 0px;
  355. border-bottom: 1px solid #dee2ee;
  356. .add-btn {
  357. margin-top: 12px;
  358. margin-right: 20px;
  359. width: 103px;
  360. height: 40px;
  361. line-height: 40px;
  362. background: #2153d4;
  363. border-radius: 6px;
  364. color: #ffffff;
  365. text-align: center;
  366. cursor: pointer;
  367. }
  368. .tab-li {
  369. float: left;
  370. margin-right: 32px;
  371. font-size: 16px;
  372. cursor: pointer;
  373. color: #4f5e7b;
  374. font-weight: 400;
  375. }
  376. .tab-on {
  377. font-weight: bold;
  378. color: #2153d4;
  379. position: relative;
  380. &::after {
  381. display: block;
  382. content: "";
  383. width: 32px;
  384. height: 2px;
  385. background: #2153d4;
  386. border-radius: 1px;
  387. bottom: 0;
  388. left: 50%;
  389. transform: translate(50%, -2px);
  390. }
  391. }
  392. }
  393. .btn {
  394. float: right;
  395. margin-top: -7px;
  396. }
  397. .tab-li:hover {
  398. color: #2153d4;
  399. }
  400. .e-label {
  401. font-size: 24px;
  402. padding-top: 40px;
  403. }
  404. .e-main-div {
  405. width: 1200px;
  406. margin: 0 auto;
  407. padding-bottom: 50px;
  408. }
  409. .head-div {
  410. padding: 20px 0 40px;
  411. line-height: 50px;
  412. }
  413. .i {
  414. width: 24px;
  415. height: 26px;
  416. /*background: #4f5e7b;*/
  417. }
  418. .enterprise-ul {
  419. padding-top: 30px;
  420. }
  421. .enterprise-li {
  422. width: 390px;
  423. border-radius: 6px;
  424. margin-bottom: 16px;
  425. padding: 16px;
  426. margin-right: 15px;
  427. background-color: #ffffff;
  428. display: inline-block;
  429. &:nth-child(3n) {
  430. margin-right: 0;
  431. }
  432. .center-div {
  433. .enter-name {
  434. vertical-align: center;
  435. line-height: 40px;
  436. font-size: 20px;
  437. color: #333;
  438. font-weight: bold;
  439. .iconfont {
  440. font-size: 16px;
  441. margin-left: 16px;
  442. color: #6c6c6c;
  443. font-weight: normal;
  444. cursor: pointer;
  445. &:hover {
  446. color: #2153d4;
  447. }
  448. }
  449. }
  450. .enter-logo {
  451. width: 40px;
  452. height: 40px;
  453. object-fit: contain;
  454. border-radius: 100%;
  455. margin-right: 8px;
  456. border: 1px solid #ddd;
  457. overflow: hidden;
  458. }
  459. }
  460. .left-div {
  461. padding-left: 48px;
  462. padding-top: 6px;
  463. .tag-li {
  464. width: 80px;
  465. height: 28px;
  466. line-height: 28px;
  467. border: 1px solid #cad0d7;
  468. text-align: center;
  469. display: inline-block;
  470. border-radius: 3px;
  471. font-size: 14px;
  472. margin-right: 8px;
  473. &:last-child {
  474. margin-right: 0;
  475. }
  476. &.info-tag {
  477. color: #4f5e7b;
  478. }
  479. &.warning-tag {
  480. color: #f7bd1b;
  481. border-color: #f7bd1b;
  482. background: rgba(247, 189, 27, 0.2);
  483. }
  484. &.success-tag {
  485. color: #36b365;
  486. border-color: #36b365;
  487. background: rgba(54, 179, 101, 0.16);
  488. }
  489. &.danger-tag{
  490. cursor: pointer;
  491. color: #ffffff;
  492. border-color: #ff0000;
  493. background:#ff0000;
  494. }
  495. }
  496. }
  497. .bottom-div {
  498. padding-top: 20px;
  499. .btn-ul {
  500. width: 103px;
  501. height: 36px;
  502. border-radius: 4px;
  503. text-align: center;
  504. border: 1px solid #2153d4;
  505. font-size: 14px;
  506. font-weight: 500;
  507. color: #2153d4;
  508. line-height: 36px;
  509. cursor: pointer;
  510. &:hover {
  511. background-color: #2153d4;
  512. color: #ffffff;
  513. }
  514. }
  515. .time-p {
  516. font-size: 16px;
  517. color: #2d405e;
  518. padding-top: 5px;
  519. line-height: 20px;
  520. font-family: DINCond-Medium, DINCond;
  521. .ic-yxtime {
  522. width: 20px;
  523. height: 20px;
  524. vertical-align: middle;
  525. margin-right: 6px;
  526. transform: translateY(-2px);
  527. }
  528. }
  529. }
  530. }
  531. .logo-out {
  532. text-align: center;
  533. cursor: pointer;
  534. line-height: 30px;
  535. }
  536. .logo-out:hover {
  537. background-color: #f4f4f4;
  538. }
  539. .bottom-slogin {
  540. height: 52px;
  541. line-height: 52px;
  542. font-size: 12px;
  543. color: #4f5e7b;
  544. text-align: center;
  545. position: fixed;
  546. left: 0;
  547. background-color: #ffffff;
  548. bottom: 0;
  549. width: 100%;
  550. }
  551. .no_enterprise {
  552. width: 200px;
  553. margin-bottom: 20px;
  554. }
  555. .no_enterprise-div {
  556. font-size: 14px;
  557. text-align: center;
  558. padding: 40px 0;
  559. }
  560. </style>