jwyu 2 years ago
parent
commit
9f55b1187d

+ 1 - 0
api/common.js

@@ -57,6 +57,7 @@ export const apiGetSceneToParams=params=>{
 
 /**
  * 获取标签树
+ * @param community_question_id 问答id
  */
 export const apiGetTagTree = params=>{
     return httpGet('/public/get_variety_tag_tree',params)

+ 22 - 0
api/question.js

@@ -24,6 +24,8 @@ export const apiOptionGroupList = params=>{
 /**
  * 发布提问
  * @param question_content
+ * @param variety_classify_id 
+ * @param variety_tag_id
  */
  export const apiPubAsk=params=>{
     return httpPost('/community/question/ask',params)
@@ -146,4 +148,24 @@ export const apiHotComment = params => {
  */
 export const apiMyComment = params => {
    return httpGet('/community/comment/my',params)
+}
+
+/**
+ * 终止问题
+ * @param community_question_id
+ * @param reason
+ */
+export const apiQuestionStop=params=>{
+   return httpPost('/community/question/stop',params)
+}
+
+/**
+ * 问题转移给其他研究员
+ * @param community_question_id 问答id
+ * @param variety_classify_id
+ * @param variety_tag_id
+ * @param admin_id
+ */
+export const apiQuestionTransfer=params=>{
+   return httpPost('/community/question/transfer',params)
 }

+ 38 - 5
pages-question/answerDetail.vue

@@ -77,7 +77,7 @@
             />
             <view>无录音(录音时长超过三分钟自动结束)</view>
 
-            <view class="black-btn" style="margin-top:100rpx">转移问题</view>
+            <view class="black-btn" style="margin-top:100rpx" @click.stop="showRemoveQ=true">转移问题</view>
             <view class="black-btn" style="margin-top:50rpx" @click.stop="stopQuestion.show=true">终止问答</view>
           </view>
           <!-- <view class="record-time" v-else>{{ audioTime }}</view> -->
@@ -273,20 +273,24 @@
         ></textarea>
       </view>
     </van-dialog>
+    <!-- 转移问答弹窗 -->
+    <removeQuestionDig :show="showRemoveQ" :qid="qid" @close="showRemoveQ=false" ></removeQuestionDig>
   </view>
 </template>
 
 <script>
 import mixin from "../mixin/questionMixin";
-import { apiReplayAsk, apiGetQuestion, apiSetRead,apiCountAudioClick } from "@/api/question";
+import { apiReplayAsk, apiGetQuestion, apiSetRead,apiCountAudioClick,apiQuestionStop } from "@/api/question";
 import { apiApplyPermission} from '@/api/user';
 import {apiGetSceneToParams} from "../api/common.js"
 import { uploadAudioToServer } from "@/utils/upload";
 import audioBox from '@/components/audioBox/audioBox.vue'
+import removeQuestionDig from './components/removeQuestionDig.vue'
 export default {
   mixins: [mixin],
   components:{
-    audioBox
+    audioBox,
+    removeQuestionDig
   },
   computed:{
 		showAudioPop(){//是否显示音频弹窗
@@ -311,6 +315,7 @@ export default {
 	},
   data() {
     return {
+      qid:0,
       questionItem: null /* {
         recordStatus: 1, //1:未录音;2:正在录音;3:已暂停;4:完成录音
         permission_info:{
@@ -351,7 +356,7 @@ export default {
         show:false,
         reason:'',
       },//终止问答
-
+      showRemoveQ:false,//展示转移问题弹窗
     };
   },
   async onLoad(options) {
@@ -364,6 +369,7 @@ export default {
 				obj=JSON.parse(res.data)
 			}
 		}
+    this.qid=obj.id || options.id
     this.getQuestionItem(obj.id || options.id);
   },
   onShow(){
@@ -844,8 +850,35 @@ export default {
       }
     },
     // 终止问答
-    handleConfirmStopQuestion(){
+    async handleConfirmStopQuestion(){
       console.log('stop question');
+      if(!this.stopQuestion.reason){
+        uni.showToast({
+          title:"请填写终止理由",
+          icon:"none"
+        })
+        return
+      }
+      const res=await apiQuestionStop({
+        community_question_id:this.questionItem.community_question_id,
+        reason:this.stopQuestion.reason
+      })
+      if(res.code===200){
+        uni.showToast({
+          title:"成功终止",
+          icon:"success"
+        })
+        setTimeout(() => {
+          uni.navigateBack({
+            delta:1,
+            fail(){
+              uni.switchTab({
+                url: '/pages/question/question'
+              })
+            }
+          })
+        }, 1500);
+      }
     }
   },
 };

+ 159 - 0
pages-question/components/removeQuestionDig.vue

@@ -0,0 +1,159 @@
+<template>
+    <van-popup 
+        :show="show" 
+        position="bottom"  
+        :close-on-click-overlay="true"
+        closeable
+        @close="handleClose"
+        round
+    >
+        <view class="remove-question-wrap">
+            <view class="title">转移问题</view>
+            <view class="main-box">
+                <view class="left">
+                    <view 
+                        :class="['item',index==fIndex&&'active']" 
+                        v-for="(item,index) in opts" 
+                        :key="item.classify_id" 
+                        @click="fIndex=index"
+                    >{{item.classify_name}}</view>
+                </view>
+                <view class="center">
+                    <view 
+                        :class="['item',index==secIndex&&'active']" 
+                        v-for="(item,index) in opts[fIndex].tags" 
+                        :key="item.tag_id" 
+                        @click="secIndex=index"
+                    >{{item.tag_name}}</view>
+                </view>
+                <view class="right">
+                    <view 
+                        :class="['item',item.admin_id==adminId&&'active',!item.allow_select&&'disabled']" 
+                        v-for="item in opts[fIndex].tags[secIndex].researcher_list" 
+                        :key="item.admin_id" 
+                        @click="handleSelectAdmin(item)"
+                    >{{item.admin_name}}</view>
+                </view>
+            </view>
+            <view class="btn" @click="handleConfirmTrans">确定</view>
+              
+        </view>
+    </van-popup>
+      
+</template>
+
+<script>
+import {apiGetTagTree} from '@/api/common'
+import {apiQuestionTransfer} from '@/api/question'
+export default {
+    props:{
+        qid:{
+            default:0
+        },
+        show:{
+            type:Boolean,
+            default:false
+        }
+    },
+    watch:{
+        qid(){
+            this.getOpts()
+        }
+    },
+    data() {
+        return {
+            opts:[],
+            fIndex:0,
+            secIndex:0,
+            adminId:0,//选择的人id
+        }
+    },
+    methods: {
+        async getOpts(){
+            const res=await apiGetTagTree({
+                community_question_id:this.qid||0
+            })
+            if(res.code===200){
+                this.opts=res.data||[]
+            }
+        },
+
+        // 选择转移人
+        handleSelectAdmin(item){
+            if(!item.allow_select) return
+            this.adminId=item.admin_id
+        },
+        
+        //确认转移
+        async handleConfirmTrans(){
+            if(!this.adminId){
+                uni.showToast({
+                    title:"请选择转移人",
+                    icon:'none'
+                })
+                return
+            }
+            const res=await apiQuestionTransfer({
+                community_question_id:Number(this.qid),
+                variety_classify_id:
+            })
+        },
+
+
+        handleClose(){
+            this.$emit('close')
+        }
+    },
+
+}
+</script>
+
+<style  lang="scss">
+.remove-question-wrap{
+    .title{
+        padding: 30rpx 0 10rpx 0;
+        font-size: 32rpx;
+        text-align: center;
+    }
+    .main-box{
+        height: 30vh;
+        display: flex;
+        .left,.center,.right{
+            flex: 1;
+            height: 100%;
+            overflow-y: auto;
+            &::-webkit-scrollbar{
+                width: 0;
+                height: 0;
+                display: none;
+            }
+            .item{
+                padding: 20rpx 10rpx;
+                font-size: 32rpx;
+            }
+            .active{
+                color: #E3B377;
+            }
+            .disabled{
+                color: #999;
+            }
+        }
+        .center{
+            border-left: 1px solid #ededed;
+            border-right: 1px solid #ededed;
+        }
+    }
+    .btn{
+        margin-top: 20rpx;
+        width: 80%;
+        text-align: center;
+        background: #333333;
+        border-radius: 40px;
+        margin-left: auto;
+        margin-right: auto;
+        color: #E3B377;
+        line-height: 80rpx;
+        font-size: 32rpx;
+    }
+}
+</style>

+ 16 - 10
pages-question/hasQuestion.vue

@@ -61,6 +61,7 @@ export default {
       options:[],
       mainActiveIndex:0,
       activeId:0,//选择的品种id
+      variety_classify_id:0,
       varietyVal:'',
     };
   },
@@ -84,10 +85,18 @@ export default {
         return
       }
       const res = await apiPubAsk({
-        question_content:this.text
+        question_content:this.text,
+        variety_classify_id:this.variety_classify_id,
+        variety_tag_id:this.activeId
       })
       if(res.code===200){
-        uni.navigateBack({delta:1})
+        uni.showToast({
+          title:"发布成功",
+          icon:'success'
+        })
+        setTimeout(() => {
+          uni.navigateBack({delta:1})
+        }, 1500);
       }
       
     },
@@ -124,7 +133,8 @@ export default {
           obj.children=item.tags.map(_item=>{
             return {
               text:_item.tag_name,
-              id:_item.tag_id
+              id:_item.tag_id,
+              variety_classify_id:_item.classify_id
             }
           })
           return obj
@@ -139,13 +149,9 @@ export default {
 
     onClickItem({detail}){
       console.log(detail);
-      if(this.activeId==detail.id){
-        this.activeId=0
-        this.varietyVal=''
-      }else{
-        this.activeId=detail.id
-        this.varietyVal=detail.text
-      }
+      this.activeId=detail.id
+      this.varietyVal=this.options[this.mainActiveIndex].text+'/'+detail.text
+      this.variety_classify_id=detail.variety_classify_id
       this.showFilter=false
     },