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', 'getLookUpData']),
  58. hasNewProduct () {
  59. this.GetEmployeeList()
  60. this.getLookUpData('RETURN_REASON')
  61. queryNewProductPage({ pageNo: 1, pageSize: 20, onlineFalg: this.onlineFalg }).then(res => {
  62. if (res.status == 200) {
  63. if (res.data.count > 0) {
  64. this.openNewProduct = true
  65. } else {
  66. if (this.onlineFalg == '1') {
  67. this.onlineFalg = '0'
  68. this.hasNewProduct()
  69. }
  70. }
  71. }
  72. })
  73. },
  74. // 查看更多产品
  75. seeMore () {
  76. this.openNewProduct = false
  77. this.$router.push({ name: 'newProductList', params: { onlineFalg: this.onlineFalg } })
  78. },
  79. // 关闭弹框
  80. cancelProductTips () {
  81. const _this = this
  82. this.openNewProduct = false
  83. if (this.onlineFalg == '1') {
  84. this.onlineFalg = '0'
  85. setTimeout(() => { _this.hasNewProduct() }, 100)
  86. }
  87. }
  88. },
  89. beforeRouteEnter (to, from, next) {
  90. next(vm => {
  91. // 判断登录用户是否重置过密码(首次登陆需强制重置密码)
  92. if (vm.mustChangePwd == 0) {
  93. vm.openResetPwd = false
  94. if (from.name == 'login') {
  95. // 判断是否有新产品上线
  96. vm.hasNewProduct()
  97. }
  98. } else {
  99. vm.openResetPwd = true
  100. }
  101. })
  102. }
  103. }
  104. </script>
  105. <style scoped>
  106. .home {
  107. /* width: 900px;
  108. margin: 0 auto;
  109. padding: 25px 0; */
  110. }
  111. </style>