Browse Source

权限控制询价

yangc 7 years ago
parent
commit
c0da3c5d13

+ 4 - 2
components/applyPurchase/ApplyInfo.vue

@@ -303,8 +303,10 @@ export default {
             this.user.data.enterprise.isVendor !== '1690'
           ) {
             //              this.resetSayPrice()
-            purchaseMan.active = true
-            this.currentSayPriceIndex = index
+            this.authorityInterceptor(this.baseUrls.vendorBusinessSayPrice, () => {
+              purchaseMan.active = true
+              this.currentSayPriceIndex = index
+            })
           } else {
             this.$message.error('抱歉,您需开通卖家功能才可报价')
           }

+ 9 - 4
components/applyPurchase/PublishApply.vue

@@ -90,7 +90,7 @@
             <input type="text" class="form-control" v-model="applyObj.produceDate" @input="onProduceDateChange" />
           </div>-->
         </div>
-        <a @click="goPublish()">发布求购</a>
+        <a @click="authorityInterceptor(baseUrls.userPublishSeek, goPublish)">发布求购</a>
       </div>
       <div class="publish-upload">
         <h1>批量发布</h1>
@@ -479,10 +479,15 @@
       onSuccess: function (data) {
         if (!this.user.logged) {
           this.$router.push('/auth/login?returnUrl=' + window.location.href)
-        } else if (data.success) {
-          window.location.href = '/applyPurchase/' + data.data
         } else {
-          this.$message.error(data.message)
+          // 能拦截跳转但无法阻止上传
+          this.authorityInterceptor(this.baseUrls.userImportBom, () => {
+            if (data.success) {
+              window.location.href = '/applyPurchase/' + data.data
+            } else {
+              this.$message.error(data.message)
+            }
+          })
         }
       },
       onError: function () {

+ 4 - 2
components/home/floor/FloorList.vue

@@ -229,8 +229,10 @@
           if (this.user.data.enterprise.uu) {
             if (this.user.data.enterprise.isVendor && this.user.data.enterprise.isVendor !== '1690') {
 //              purchaseMan.active = true
-              this.changeInterval(false)
-              this.currentSayPriceIndex = index
+              this.authorityInterceptor(this.baseUrls.vendorBusinessSayPrice, () => {
+                this.changeInterval(false)
+                this.currentSayPriceIndex = index
+              })
             } else {
               this.$message.error('抱歉,您需开通卖家功能才可报价')
             }

+ 1 - 1
components/mobile/applyPurchase/PublishSeek.vue

@@ -57,7 +57,7 @@
           <span>生产日期:</span>
           <input type="text" v-model="applyObj.produceDate" @input="onProduceDateChange">
         </div>-->
-        <a @click="goPublish">确认发布</a>
+        <a @click="authorityInterceptor(baseUrls.userPublishSeek, goPublish)">确认发布</a>
       </div>
     </div>
   </div>

+ 1 - 1
components/mobile/applyPurchase/PublishSupplierSeek.vue

@@ -17,7 +17,7 @@
           <span>数量(PCS):</span>
           <input type="text" v-model="applyObj.amount" @blur="checkAmount" @input="onAmountInput">
         </div>
-        <a @click="goPublish">确认</a>
+        <a @click="authorityInterceptor(baseUrls.userPublishSeek, goPublish)">确认</a>
       </div>
     </div>
   </div>

+ 17 - 15
components/mobile/applyPurchase/SeekList.vue

@@ -88,9 +88,9 @@
               </p>
               <p class="remain-time" v-else><span>已截止</span></p>
               <!--<a v-if="!userType && item.quoted == 1">已报价</a>-->
-              <a v-if="isSelfSeek(item)" class="self-publish" @click="onRemind('此为贵公司的求购')">我要报价</a>
+              <a v-if="isSelfSeek(item)" class="self-publish" @click="setRemindText('此为贵公司的求购')">我要报价</a>
               <a v-if="canSayPrice(item)" @click="goSayPrice(item.itemId || item.id, index)">我要报价</a>
-              <!--<a v-if="item.newId" class="self-publish" @click="onRemind('您已报价')">我要报价</a>-->
+              <!--<a v-if="item.newId" class="self-publish" @click="setRemindText('您已报价')">我要报价</a>-->
               <a v-if="canSeeInfo(item)" @click="goSayPriceInfo(item.newId || item.quteId || item.id, item.agreed, index)">查看报价</a>
             </template>
           </div>
@@ -201,19 +201,21 @@ export default {
             this.user.data.enterprise.isVendor &&
             this.user.data.enterprise.isVendor !== '1690'
           ) {
-            this.$store.dispatch('applyPurchase/loadPurchaseManDetail', {
-              itemId: id,
-              enuu: this.$store.state.option.user.data.enterprise
-                ? this.$store.state.option.user.data.enterprise.uu
-                : null
+            this.authorityInterceptor(this.baseUrls.vendorBusinessSayPrice, () => {
+              this.$store.dispatch('applyPurchase/loadPurchaseManDetail', {
+                itemId: id,
+                enuu: this.$store.state.option.user.data.enterprise
+                  ? this.$store.state.option.user.data.enterprise.uu
+                  : null
+              })
+              this.showSayPriceBox = true
+              this.activeIndex = index
             })
-            this.showSayPriceBox = true
-            this.activeIndex = index
           } else {
-            this.onRemind('抱歉,您需开通卖家功能才可报价')
+            this.setRemindText('抱歉,您需开通卖家功能才可报价')
           }
         } else {
-          this.onRemind('个人账户暂不可报价')
+          this.setRemindText('个人账户暂不可报价')
         }
       } else {
         this.url = this.$route.fullPath
@@ -228,7 +230,7 @@ export default {
         this.activeIndex = index
       }, err => {
         console.log(err)
-        this.onRemind('获取报价信息失败')
+        this.setRemindText('获取报价信息失败')
       })
       //        '/mobile/applyPurchase/list/' + (userType ? (item.quteId || item.id) + '?type=' + userType : (item.quteId || item.id)) + (userType ? '&' : '?') + 'status=' + item.agreed
     },
@@ -249,18 +251,18 @@ export default {
       if (flag) {
         this.purchaseManListData[this.activeIndex].quoted = 1
         this.purchaseManListData[this.activeIndex].quteId = quteId
-        this.onRemind('感谢您参与报价,敬请期待回复')
+        this.setRemindText('感谢您参与报价,敬请期待回复')
       }
       this.showSayPriceBox = false
     },
     onSayPriceInfoCancel: function(flag) {
       if (flag) {
         this.purchaseManListData[this.activeIndex].agreed = 1
-        this.onRemind('采纳成功')
+        this.setRemindText('采纳成功')
       }
       this.showSayPriceInfoBox = false
     },
-    onRemind: function(str) {
+    setRemindText: function(str) {
       this.remindText = str
       this.timeoutCount++
     },

+ 1 - 1
components/supplier/details.vue

@@ -115,7 +115,7 @@
         </ul>
       </div>
       <span slot="footer" class="dialog-footer">
-        <button @click="goPublish" :disabled="isClick">询价提交</button>
+        <button @click="authorityInterceptor(baseUrls.userPublishSeek, goPublish)" :disabled="isClick">询价提交</button>
       </span>
     </el-dialog>
   </div>

+ 1 - 1
components/supplier/resource.vue

@@ -161,7 +161,7 @@
         </ul>
       </div>
       <span slot="footer" class="dialog-footer">
-        <button @click="goPublish" :disabled="isClick">询价提交</button>
+        <button @click="authorityInterceptor(baseUrls.userPublishSeek, goPublish)" :disabled="isClick">询价提交</button>
       </span>
     </el-dialog>
   </div>

+ 10 - 0
plugins/mixin.js

@@ -5,6 +5,7 @@
 import BScroll from 'better-scroll'
 import Vue from 'vue'
 import baseUtils from '~utils/baseUtils'
+import baseUrls from '~utils/baseUrls'
 // import { mapState } from 'vuex'
 
 Vue.mixin({
@@ -57,6 +58,12 @@ Vue.mixin({
     },
     baseUtils () {
       return baseUtils
+    },
+    baseUrls () {
+      return baseUrls
+    },
+    isMobile () {
+      return this.$store.state.option.isMobile
     }
   },
   methods: {
@@ -101,6 +108,9 @@ Vue.mixin({
       } else {
         this.login()
       }
+    },
+    authorityInterceptor: function (url, callback) {
+      this.baseUtils.getAuthority(this, url, callback, this.isMobile)
     }
   },
   filters: {

+ 14 - 0
utils/baseUrls.js

@@ -0,0 +1,14 @@
+export default {
+  // 买家-我的求购-单个求购-发布求购
+  userPublishSeek: '/authInquiry/inquiry/buyer/save',
+  // 买家-我的求购-单个求购-查看报价
+  userGetQuotations: '/authInquiry/inquiry/getQuotations',
+  // 买家-我的求购-BOM求购-导入新BOM
+  userImportBom: '/seek/importBom',
+  // 买家-我的求购-BOM求购-查看详情
+  userGetBomDetail: '/authInquiry/inquiry/public/findInquiryById',
+  // 卖家-商机管理-待报价-我要报价
+  vendorBusinessSayPrice: '/authInquiry/inquiry/sale/item/save',
+  // 卖家-商机管理-已报价-联系买家
+  vendorBusinessLinkBuyer: '/authInquiry/basic/enterprise/tels'
+}

+ 24 - 1
utils/baseUtils.js

@@ -347,6 +347,27 @@ const _filterStringEllipsis = (str, len) => {
   return str ? _getRealLen(str) > len ? _cutOutString(str, len) + '...' : str : null
 }
 
+const _setMessage = ($this, str = '系统错误', isMobile) => {
+  if (isMobile) {
+    $this.setRemindText(str)
+  } else {
+    $this.$message.error(str)
+  }
+}
+
+const _getAuthority = ($this, url, callBack, isMobile) => {
+  return $this.$http.get('/user/authentication/isauthority', {params: {resUrl: url}}).then(res => {
+    if (res.data.status === 'fail') {
+      _setMessage($this, res.data.msg, isMobile)
+    } else {
+      callBack.call($this)
+    }
+  }, err => {
+    console.log(err)
+    _setMessage($this, err.response.data, isMobile)
+  })
+}
+
 export default {
   // 获取字符串字符长度
   getRealLen: _getRealLen,
@@ -372,5 +393,7 @@ export default {
   // 立即购买或加入购物车
   buyOrCar: _buyOrCar,
   // 截取字符长度并补充省略号
-  filterStringEllipsis: _filterStringEllipsis
+  filterStringEllipsis: _filterStringEllipsis,
+  // 获取url权限
+  getAuthority: _getAuthority
 }

+ 0 - 1
utils/mixin.js

@@ -8,4 +8,3 @@ export const carousel = {
     }
   }
 }
-