Browse Source

ETA商家接口权限联调

cxmo 1 year ago
parent
commit
43640f0234
2 changed files with 73 additions and 12 deletions
  1. 16 0
      src/api/modules/businessCustom.js
  2. 57 12
      src/views/business_ETA_manage/businessAuth.vue

+ 16 - 0
src/api/modules/businessCustom.js

@@ -121,5 +121,21 @@ export const businessCustomInterence = {
      */
     setAuthList:(params)=>{
         return http.post('/eta_business/menu/relate/save',params)
+    },
+    /**
+     * 获取商家接口权限
+     * @returns 
+     */
+    getConfigList:(params)=>{
+        return http.get('/eta_business/api/config/list',params)
+    },
+    /**
+     * 设置商家接口权限
+     * @param EtaBusinessId 商家ID
+     * @param List 接口权限列表
+     * @returns 
+     */
+    setConfigList:(params)=>{
+        return http.post('/eta_business/api/config/set',params)
     }
 }

+ 57 - 12
src/views/business_ETA_manage/businessAuth.vue

@@ -29,13 +29,13 @@
         <div class="interence-wrap" v-show="model==='interence'">
             <div class="interence-item">
                 <span>研报审批</span>
-                <el-radio-group v-model="temp">
+                <el-radio-group v-model="isApprove">
                     <el-radio :label="0">否</el-radio>
                     <el-radio :label="1">是</el-radio>
                 </el-radio-group>
-                <el-checkbox-group v-model="checkList" v-show="temp===1">
-                    <el-checkbox label="智能研报" :value="3"></el-checkbox>
-                    <el-checkbox label="研报列表" :value="4"></el-checkbox>
+                <el-checkbox-group v-model="approveList" v-show="isApprove===1">
+                    <el-checkbox :label="2">智能研报</el-checkbox>
+                    <el-checkbox :label="1">研报列表</el-checkbox>
                 </el-checkbox-group>
             </div>
         </div>
@@ -53,7 +53,8 @@ export default {
             checkAll:false,
             isIndeterminate:false,
             model:'auth',
-            temp:'',
+            isApprove:'',
+            approveList:[],
             checkList:[]
         };
     },
@@ -68,13 +69,37 @@ export default {
                 }
             }
         },
-        temp(newVal){
+        isApprove(newVal){
             if(newVal===0){
-                this.checkList=[]
+                this.approveList=[]
             }
         }
     },
     methods: {
+        getBusinessConfigList(){
+            const EtaBusinessId = this.$route.query.id
+            if(!EtaBusinessId) return 
+            businessCustomInterence.getConfigList({
+                EtaBusinessId:Number(EtaBusinessId)
+            }).then(res=>{
+                if(res.Ret!==200) return
+                const list = res.Data||[]
+                const approveItem = list.find(i=>i.ConfigCode==='approval_flow')
+                if(!approveItem) return
+                if(!approveItem.ConfigValue.length){
+                    this.isApprove = approveItem.ConfigValue
+                    return
+                }
+                if(Number(approveItem.ConfigValue)===0){
+                    this.isApprove = Number(approveItem.ConfigValue)
+                    return
+                }
+                if(Number(approveItem.ConfigValue)>0){
+                    this.isApprove = 1
+                    this.approveList = approveItem.ConfigValue==3?[1,2]:[Number(approveItem.ConfigValue)]
+                }
+            })
+        },
         getBusinessAuthList(){
             const EtaBusinessId = this.$route.query.id
             if(!EtaBusinessId) return 
@@ -142,11 +167,6 @@ export default {
                     this.$message.warning('请至少选择一个权限')
                     return
                 }
-                if(typeof(this.temp) === 'string'){
-                    this.$message.warning('请配置接口权限')
-                    this.model='interence'
-                    return
-                }
                 //合成一个数组并去重
                 const ChoiceList = Array.from(new Set([...keys,...halfKeys]))
                 //请求接口
@@ -157,6 +177,30 @@ export default {
                 })
                 if(res.Ret!==200) return 
                 this.$message.success('权限设置成功')
+
+                if(typeof(this.isApprove)==='string'){
+                    this.$message.warning('请配置接口权限')
+                    this.model='interence'
+                    return
+                }else{
+                    if(this.isApprove&&!this.approveList.length){
+                        this.$message.warning('请选择接口权限')
+                        return
+                    }
+                    let configValue = ''
+                    if(this.isApprove){
+                        configValue = this.approveList.length>1?"3":this.approveList[0]+"" //3表示全选
+                    }else{
+                        configValue = this.isApprove+""
+                    }
+                    const list = [{ConfigCode:"approval_flow",ConfigValue:configValue}] //目前只有一项
+                    const interenceRes = await businessCustomInterence.setConfigList({
+                        EtaBusinessId:Number(this.$route.query.id),
+                        List:list
+                    })
+                    if(interenceRes.Ret!==200) return 
+                    this.$message.success('接口权限设置成功')
+                }
             }
             this.$router.push('/businessETAList')
         },
@@ -180,6 +224,7 @@ export default {
         }
     },
     mounted(){
+        this.getBusinessConfigList()
         this.getBusinessAuthList()
     }
 };