Home.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="home">
  3. <a-alert :message="message" type="info" />
  4. <!-- 重置密码 -->
  5. <a-modal
  6. class="resetPwdModal"
  7. title="重置密码"
  8. width="60%"
  9. centered
  10. :footer="null"
  11. :closable="false"
  12. :maskClosable="false"
  13. :destroyOnClose="true"
  14. @cancel="openResetPwd=false"
  15. v-model="openResetPwd">
  16. <ResetPwd />
  17. </a-modal>
  18. <!-- 新产品上线提醒 -->
  19. <a-modal
  20. class="newProductTips"
  21. :title="'新产品'+(onlineFalg=='1'?'上':'下')+'线提醒'"
  22. :width="800"
  23. centered
  24. :footer="null"
  25. :maskClosable="false"
  26. :destroyOnClose="true"
  27. @cancel="cancelProductTips"
  28. v-model="openNewProduct">
  29. <newProduct :onlineFalg="onlineFalg" @seeMore="seeMore"></newProduct>
  30. </a-modal>
  31. </div>
  32. </template>
  33. <script>
  34. import { commonMixin } from '@/utils/mixin'
  35. import { mapGetters, mapActions } from 'vuex'
  36. import ResetPwd from '@/views/user/ResetPwd.vue'
  37. import newProduct from '@/views/productManagement/newProduct/modal.vue'
  38. import { queryNewProductPage } from '@/api/product'
  39. export default {
  40. name: 'Home',
  41. mixins: [commonMixin],
  42. components: { ResetPwd, newProduct },
  43. data () {
  44. return {
  45. message: '欢迎登录' + process.env.VUE_APP_PRO_NAME,
  46. openResetPwd: false, // 重置密码是否显示
  47. openNewProduct: false,
  48. onlineFalg: '1' // 上下线标识 1为上线,0为下线
  49. }
  50. },
  51. computed: {
  52. ...mapGetters(['mustChangePwd'])
  53. },
  54. created () {
  55. },
  56. methods: {
  57. ...mapActions(['GetEmployeeList', 'getReturnReasonData']),
  58. hasNewProduct () {
  59. this.GetEmployeeList()
  60. queryNewProductPage({ pageNo: 1, pageSize: 20, onlineFalg: this.onlineFalg }).then(res => {
  61. if (res.status == 200) {
  62. if (res.data.count > 0) {
  63. this.openNewProduct = true
  64. } else {
  65. if (this.onlineFalg == '1') {
  66. this.onlineFalg = '0'
  67. this.hasNewProduct()
  68. }
  69. }
  70. }
  71. })
  72. },
  73. // 查看更多产品
  74. seeMore () {
  75. this.openNewProduct = false
  76. this.$router.push({ name: 'newProductList', params: { onlineFalg: this.onlineFalg } })
  77. },
  78. // 关闭弹框
  79. cancelProductTips () {
  80. const _this = this
  81. this.openNewProduct = false
  82. if (this.onlineFalg == '1') {
  83. this.onlineFalg = '0'
  84. setTimeout(() => { _this.hasNewProduct() }, 100)
  85. }
  86. }
  87. },
  88. beforeRouteEnter (to, from, next) {
  89. next(vm => {
  90. // 判断登录用户是否重置过密码(首次登陆需强制重置密码)
  91. if (vm.mustChangePwd == 0) {
  92. vm.openResetPwd = false
  93. if (from.name == 'login') {
  94. // 判断是否有新产品上线
  95. vm.hasNewProduct()
  96. }
  97. } else {
  98. vm.openResetPwd = true
  99. }
  100. vm.getReturnReasonData('RETURN_REASON')
  101. })
  102. }
  103. }
  104. </script>
  105. <style scoped>
  106. .home {
  107. /* width: 900px;
  108. margin: 0 auto;
  109. padding: 25px 0; */
  110. }
  111. </style>