Home.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. import { getYyMenuList } from '@/api/menu.js'
  40. export default {
  41. name: 'Home',
  42. mixins: [commonMixin],
  43. components: { ResetPwd, newProduct },
  44. data () {
  45. return {
  46. message: '欢迎登录' + process.env.VUE_APP_PRO_NAME,
  47. openResetPwd: false, // 重置密码是否显示
  48. openNewProduct: false,
  49. onlineFalg: '1' // 上下线标识 1为上线,0为下线
  50. }
  51. },
  52. computed: {
  53. ...mapGetters(['mustChangePwd'])
  54. },
  55. created () {
  56. },
  57. methods: {
  58. ...mapActions(['GetEmployeeList', 'getLookUpDataByCode']),
  59. // 获取菜单树列表
  60. getYyMenuList () {
  61. getYyMenuList().then(res => {
  62. if (res.status == 200) {
  63. this.$store.state.app.authMenusList = res.data
  64. }
  65. })
  66. },
  67. hasNewProduct () {
  68. this.GetEmployeeList()
  69. queryNewProductPage({ pageNo: 1, pageSize: 20, onlineFalg: this.onlineFalg }).then(res => {
  70. if (res.status == 200) {
  71. if (res.data.count > 0) {
  72. this.openNewProduct = true
  73. } else {
  74. if (this.onlineFalg == '1') {
  75. this.onlineFalg = '0'
  76. this.hasNewProduct()
  77. }
  78. }
  79. }
  80. })
  81. },
  82. // 查看更多产品
  83. seeMore () {
  84. this.openNewProduct = false
  85. this.$router.push({ name: this.onlineFalg == 1 ? 'newProductList' : 'oldProductList', params: { onlineFalg: this.onlineFalg, type: 'newProduct' } })
  86. },
  87. // 关闭弹框
  88. cancelProductTips () {
  89. const _this = this
  90. this.openNewProduct = false
  91. if (this.onlineFalg == '1') {
  92. this.onlineFalg = '0'
  93. setTimeout(() => { _this.hasNewProduct() }, 100)
  94. }
  95. }
  96. },
  97. beforeRouteEnter (to, from, next) {
  98. next(vm => {
  99. // 判断登录用户是否重置过密码(首次登陆需强制重置密码)
  100. if (vm.mustChangePwd == 0) {
  101. vm.openResetPwd = false
  102. if (from.name == 'login') {
  103. // 判断是否有新产品上线
  104. vm.hasNewProduct()
  105. }
  106. } else {
  107. vm.openResetPwd = true
  108. }
  109. // 退货原因列表
  110. vm.getLookUpDataByCode({
  111. code: 'GOOD_PRODUCT_RETURN',
  112. key: 'goodReturnReason',
  113. isEnable: 1
  114. })
  115. vm.getLookUpDataByCode({
  116. code: 'DEFECTIVE_PRODUCT_RETURN',
  117. key: 'defectiveReturnReason',
  118. isEnable: 1
  119. })
  120. // 菜单数据
  121. vm.getYyMenuList()
  122. vm.$store.state.app.priceAuthOptions = [
  123. { label: '售价', value: 'salesPrice' },
  124. { label: '成本价', value: 'costPrice' },
  125. { label: '省级价', value: 'provincePrice' },
  126. { label: '市级价', value: 'cityPrice' },
  127. { label: '特约价', value: 'specialPrice' },
  128. { label: '终端价', value: 'terminalPrice' },
  129. { label: '车主价', value: 'carOwnersPrice' }
  130. ]
  131. })
  132. }
  133. }
  134. </script>
  135. <style scoped>
  136. .home {
  137. /* width: 900px;
  138. margin: 0 auto;
  139. padding: 25px 0; */
  140. }
  141. </style>