questionItem.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="question-item">
  3. <view class="cont">
  4. <!-- 提问item -->
  5. <template v-if="type==='question'">
  6. <veiw class="item-title">{{data.QuestionContent}}</veiw>
  7. <view class="row">提问人:{{ data.RealName }}</view>
  8. <view class="row">提问时间:{{ data.CreateTime }}</view>
  9. <view class="item-bottom row flex">
  10. <view class="flex">
  11. 回答者:
  12. <view class="select-wrapper" @click="openPicker" v-if="!data.ReplierRealName">
  13. <input type="text" placeholder="请选择研究员" disabled class="ipt" v-model="data.select_users.user_name">
  14. <van-icon name="play" color="#999" style="transform: rotate(90deg);position: absolute;right: 20rpx;top: 30%;"/>
  15. </view>
  16. <view v-else> {{data.ReplierRealName}}</view>
  17. </view>
  18. <view class="status blue-color">{{statusMap[data.ReplyStatus]}}</view>
  19. </view>
  20. </template>
  21. <!-- 评论item -->
  22. <template v-else>
  23. <veiw class="item-title">{{data.Content}}</veiw>
  24. <view class="row">所属提问:{{data.QuestionContent}}</view>
  25. <view class="row">评论人:{{data.UserName}}</view>
  26. <view class="row">客户信息:{{data.CompanyName}} <text v-if="data.CompanyProductStatus">({{data.CompanyProductStatus}})</text> </view>
  27. <view class="row">评论时间:{{data.CreateTime}}</view>
  28. </template>
  29. </view>
  30. <view class="action-bot flex">
  31. <text class="red-color" @click="actionHandle('del')">删除</text>
  32. <template v-if="data.ReplyStatus === 1 && type === 'question'">
  33. <text class="blue-color" @click="actionHandle('edit')">编辑</text>
  34. <text :class="data.select_users.user_id ? 'blue-color' : 'grey-color'" @click="actionHandle('send')" >分配并通知</text>
  35. </template>
  36. <text class="blue-color" @click="actionHandle('hot')" v-if="type === 'comment'">{{ data.IsHot ? '取消精选': '精选' }}</text>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import * as $api from '@/api/question/index.js'
  42. export default {
  43. props: {
  44. type: String,
  45. status: String,
  46. item: Object
  47. },
  48. watch: {
  49. item(newval) {
  50. this.data = newval;
  51. },
  52. },
  53. data() {
  54. return {
  55. data: this.item,
  56. users_obj: this.select_users,
  57. statusMap: {
  58. 1: '待分配',
  59. 2: '待回答',
  60. 3: '已回答'
  61. },
  62. };
  63. },
  64. methods: {
  65. /* 打开弹窗 */
  66. openPicker() {
  67. const { CommunityQuestionId } = this.data;
  68. this.$emit('open_picker',CommunityQuestionId)
  69. },
  70. /* 操作*/
  71. actionHandle(key) {
  72. const actionmap = {
  73. 'del': this.delHandle,
  74. 'edit': this.editHandle,
  75. 'send': this.sendQuestionHandle,
  76. 'hot': this.setHotHandle
  77. }
  78. actionmap[key]()
  79. },
  80. /* 编辑 */
  81. editHandle() {
  82. this.$emit('edit',this.data)
  83. },
  84. /* 删除 */
  85. delHandle() {
  86. wx.showModal({
  87. title: "",
  88. content: `${this.type === 'question' ? '提问' : '评论'}删除后不可恢复,确认删除吗`,
  89. confirmColor: "#EE3636",
  90. cancelColor: '#333',
  91. success: async (res) => {
  92. if(res.cancel) return
  93. const { CommunityQuestionId,CommunityQuestionCommentId } = this.data;
  94. const { code } = this.type === 'question'
  95. ? await $api.apiDelQuestion({ QuestionId: CommunityQuestionId })
  96. : await $api.apiDelComment({ CommunityQuestionCommentId: CommunityQuestionCommentId });
  97. if( code !== 200 ) return
  98. wx.showToast({title: '删除成功'});
  99. this.$emit('del', this.type === 'question' ? CommunityQuestionId : CommunityQuestionCommentId)
  100. }
  101. })
  102. },
  103. /* 分配研究员 */
  104. async sendQuestionHandle() {
  105. console.log(this.data.select_users)
  106. if(!this.data.select_users) return
  107. const {first_id,second_id,user_id} = this.data.select_users;
  108. const { code } = await $api.apiDistribute({
  109. ResearchGroupFirstId: first_id,
  110. ResearchGroupSecondId: second_id,
  111. AdminId: user_id,
  112. QuestionId: this.data.CommunityQuestionId
  113. })
  114. if(code !== 200) return
  115. wx.showToast({title: '分配成功'})
  116. this.$emit('del', this.data.CommunityQuestionId)
  117. },
  118. /* 设置精选 */
  119. async setHotHandle() {
  120. const { CommunityQuestionCommentId } = this.data;
  121. const { code } = await $api.apiSetHotComment({CommunityQuestionCommentId})
  122. if(code !== 200) return
  123. wx.showToast({title: '设置成功'})
  124. this.$emit('hot',CommunityQuestionCommentId)
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .blue-color {
  131. color: #3385FF;
  132. }
  133. .red-color {
  134. color: #D63535;
  135. }
  136. .grey-color {
  137. color: #999;
  138. }
  139. .flex {
  140. display: flex;
  141. align-items: center;
  142. }
  143. .question-item {
  144. background: #fff;
  145. padding: 20rpx 0 0;
  146. border-radius: 8rpx;
  147. font-size: 28rpx;
  148. margin-bottom: 20rpx;
  149. color: #666;
  150. .cont {
  151. padding: 0 20rpx;
  152. }
  153. .item-title {
  154. color: #333;
  155. font-size: 32rpx;
  156. }
  157. .row {
  158. margin: 15rpx 0;
  159. }
  160. .item-bottom {
  161. justify-content: space-between;
  162. .select-wrapper {
  163. width: 250rpx;
  164. border: 1px solid #F1F2F6;
  165. padding: 0 40rpx 0 20rpx;
  166. position: relative;
  167. .ipt {
  168. height: 80rpx;
  169. line-height: 80rpx;
  170. }
  171. }
  172. }
  173. .action-bot {
  174. border-top: 1px solid #EAEAEA;
  175. margin-top: 30rpx;
  176. text {
  177. padding: 24rpx 0;
  178. flex: 1;
  179. text-align: center;
  180. border-right: 1px solid #EAEAEA;
  181. &:last-child { border: none; }
  182. }
  183. }
  184. }
  185. </style>