Explorar o código

价格权限控制

lilei %!s(int64=2) %!d(string=hai) anos
pai
achega
4dcc3033c5
Modificáronse 2 ficheiros con 28 adicións e 19 borrados
  1. 11 3
      src/utils/util.js
  2. 17 16
      src/views/salesManagement/salesQuery/detail.vue

+ 11 - 3
src/utils/util.js

@@ -83,14 +83,15 @@ export function treeFind (tree, func) {
   return null
 }
 // 是否有价格权限
-export function hasPriceAuth(authNode, priceOptions){
+export function hasPriceAuth(authNode, priceOptions, userAuthCode){
   const codes = []
   const ret = []
   // 过滤当前节点下的非价格权限菜单
   authNode.map(item=>{
     const a = item.code.split('_')
     const hasCode = priceOptions.find(k => k.value == a[a.length-1])
-    if(hasCode){
+    const hasRoles = userAuthCode.includes(item.code)
+    if(hasCode && hasRoles){
       codes.push(a[a.length-1])
     }
   })
@@ -106,6 +107,13 @@ export function getAuthPriceCode (config, router, store) {
   const curActionPermission = store.state.app.curActionPermission
   const priceOptions = store.state.app.priceAuthOptions
   const authCode = curActionPermission || permission
+  // 当前角色的价格配置
+  const roles = store.state.user.roles
+  const userAuthCode = roles.permissionList.filter(item => {
+    const a = item.split('_')
+    return priceOptions.find(k => k.value == a[a.length-1])
+  })
+  // console.log(userAuthCode)
   console.log(authCode)
   if(authCode){
     const url = config.url
@@ -115,7 +123,7 @@ export function getAuthPriceCode (config, router, store) {
     const hasReqUrl = authNode.permission.split(',').find(item => url.replace(/\//g,'_').indexOf(item)>=0)
     
     if(hasReqUrl&&authNode.children&&authNode.children.length){
-      return hasPriceAuth(authNode.children,priceOptions)
+      return hasPriceAuth(authNode.children,priceOptions,userAuthCode)
     }
     return []
   }

+ 17 - 16
src/views/salesManagement/salesQuery/detail.vue

@@ -75,19 +75,19 @@
                 待下推数量:<strong>{{ detailData&&(detailData.totalUnpushedQty || detailData.totalUnpushedQty==0) ? detailData.totalUnpushedQty : '--' }}</strong>;
                 已发货数量:<strong>{{ detailData&&(detailData.totalDispatchQty || detailData.totalDispatchQty==0) ? detailData.totalDispatchQty : '--' }}</strong>;
                 待发货数量:<strong>{{ detailData&&(detailData.totalUndispatchQty || detailData.totalUndispatchQty==0) ? detailData.totalUndispatchQty : '--' }}</strong>;<br/>
-                <span v-if="$hasPermissions('B_salesDetail_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
-                <span v-if="$hasPermissions('B_salesDetail_costPrice')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;</span>
-                <span v-if="$hasPermissions('B_salesDetail_costPrice')">总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;</span>
-                <span v-if="$hasPermissions('B_salesDetail_salesPrice')">已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? toThousands(detailData.totalCancelAmount) : '--' }}</strong>;</span>
-                <span v-if="$hasPermissions('B_salesDetail_salesPrice')">已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? toThousands(detailData.totalPushedAmount) : '--' }}</strong>;</span>
-                <span v-if="$hasPermissions('B_salesDetail_salesPrice')">待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? toThousands(detailData.totalUnpushedAmount) : '--' }}</strong>;</span>
-                <span v-if="$hasPermissions('B_salesDetail_salesPrice')">已发货金额:<strong>{{ detailData&&(detailData.totalDispatchAmount || detailData.totalDispatchAmount==0) ? toThousands(detailData.totalDispatchAmount) : '--' }}</strong>;</span>
-                <span v-if="$hasPermissions('B_salesDetail_salesPrice')">待发货金额:<strong>{{ detailData&&(detailData.totalUndispatchAmount || detailData.totalUndispatchAmount==0) ? toThousands(detailData.totalUndispatchAmount) : '--' }}</strong>;</span>
+                <span v-if="$hasPermissions(authCode + '_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalAmount || detailData.totalAmount==0) ? toThousands(detailData.totalAmount) : '--' }}</strong>;</span>
+                <span v-if="$hasPermissions(authCode + '_costPrice')">总成本:<strong>{{ detailData&&(detailData.totalCost || detailData.totalCost==0) ? toThousands(detailData.totalCost) : '--' }}</strong>;</span>
+                <span v-if="$hasPermissions(authCode + '_costPrice')">总毛利:<strong>{{ detailData&&(detailData.grossProfit || detailData.grossProfit==0) ? toThousands(detailData.grossProfit) : '--' }}</strong>;</span>
+                <span v-if="$hasPermissions(authCode + '_salesPrice')">已取消金额:<strong>{{ detailData&&(detailData.totalCancelAmount || detailData.totalCancelAmount==0) ? toThousands(detailData.totalCancelAmount) : '--' }}</strong>;</span>
+                <span v-if="$hasPermissions(authCode + '_salesPrice')">已下推金额:<strong>{{ detailData&&(detailData.totalPushedAmount || detailData.totalPushedAmount==0) ? toThousands(detailData.totalPushedAmount) : '--' }}</strong>;</span>
+                <span v-if="$hasPermissions(authCode + '_salesPrice')">待下推金额:<strong>{{ detailData&&(detailData.totalUnpushedAmount || detailData.totalUnpushedAmount==0) ? toThousands(detailData.totalUnpushedAmount) : '--' }}</strong>;</span>
+                <span v-if="$hasPermissions(authCode + '_salesPrice')">已发货金额:<strong>{{ detailData&&(detailData.totalDispatchAmount || detailData.totalDispatchAmount==0) ? toThousands(detailData.totalDispatchAmount) : '--' }}</strong>;</span>
+                <span v-if="$hasPermissions(authCode + '_salesPrice')">待发货金额:<strong>{{ detailData&&(detailData.totalUndispatchAmount || detailData.totalUndispatchAmount==0) ? toThousands(detailData.totalUndispatchAmount) : '--' }}</strong>;</span>
                 <span v-if="isCityPrice">市级总售价:<strong>{{ detailData&&(detailData.totalCityAmount || detailData.totalCityAmount==0) ? toThousands(detailData.totalCityAmount) : '--' }}</strong>;</span>
               </div>
               <div>
                 <a-button v-if="detailData && (detailData.billStatus == 'WAIT_AUDIT' || detailData.billStatus == 'HQ_CHANGE')" type="link" @click="openStockOut">缺货明细</a-button>
-                <a-checkbox v-model="isCityPrice" v-if="$hasPermissions('B_salesDetail_cityPrice')"><span style="display: inline-block;margin-top: 1px;">市级价</span></a-checkbox>
+                <a-checkbox v-model="isCityPrice" v-if="$hasPermissions(authCode + '_cityPrice')"><span style="display: inline-block;margin-top: 1px;">市级价</span></a-checkbox>
               </div>
             </div>
           </div>
@@ -219,6 +219,7 @@ export default {
       disabled: false,
       showDsModal: false,
       showStockOut: false,
+      authCode: '',
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
@@ -303,22 +304,22 @@ export default {
         { title: '已下推数', dataIndex: 'pushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '已取消数', dataIndex: 'cancelQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
       ]
-      if (this.$hasPermissions('B_salesDetail_costPrice')) { //  成本价权限
+      if (this.$hasPermissions(this.authCode + '_costPrice')) { //  成本价权限
         arr.splice(4, 0, { title: '成本价', dataIndex: 'showCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
       }
 
-      const ind = this.$hasPermissions('B_salesDetail_costPrice') ? 5 : 4
-      if(this.$hasPermissions('B_salesDetail_provincePrice')){
+      const ind = this.$hasPermissions(this.authCode + '_costPrice') ? 5 : 4
+      if(this.$hasPermissions(this.authCode + '_provincePrice')){
         arr.splice(ind, 0, { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
       }
       // 是否勾选市级价格
       if (this.isCityPrice) {
         arr.splice(ind + 1, 0, { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
-        if (this.$hasPermissions('B_salesDetail_salesPrice')) { //  售价权限
+        if (this.$hasPermissions(this.authCode + '_salesPrice')) { //  售价权限
           arr.splice(ind + 2, 0, { title: '销售价', dataIndex: 'price', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
         }
       } else {
-        if (this.$hasPermissions('B_salesDetail_salesPrice')) { //  售价权限
+        if (this.$hasPermissions(this.authCode + '_salesPrice')) { //  售价权限
           arr.splice(ind + 1, 0, { title: '销售价', dataIndex: 'price', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
         }
       }
@@ -421,8 +422,7 @@ export default {
       // 销售分类导出
       if (type == 'typeExport') {
         const params = {
-          salesBillSn: this.bizSn || this.$route.params.sn,
-          showCostFlag: this.$hasPermissions('B_salesDetail_costPrice')
+          salesBillSn: this.bizSn || this.$route.params.sn
         }
         _this.spinning = true
         exportExcel(salesDetailTypeExcel, params, '销售分类' + moment().format('YYYYMMDDHHmmss'), () => { 
@@ -470,6 +470,7 @@ export default {
   beforeRouteEnter (to, from, next) {
     next(vm => {
       vm.fromRouter = from
+      vm.authCode = to.meta.permission
     })
   }
 }