questionItem.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 | formatTime}}</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. const moment = require('@/pages-roadshow/utils/_moment.js');
  43. moment.locale('zh-cn');
  44. export default {
  45. props: {
  46. type: String,
  47. status: String,
  48. item: Object
  49. },
  50. filters: {
  51. formatTime(val) {
  52. return moment(val).format('YYYY-MM-DD HH:mm:ss')
  53. }
  54. },
  55. watch: {
  56. item(newval) {
  57. this.data = newval;
  58. },
  59. },
  60. data() {
  61. return {
  62. data: this.item,
  63. users_obj: this.select_users,
  64. statusMap: {
  65. 1: '待分配',
  66. 2: '待回答',
  67. 3: '已回答'
  68. },
  69. };
  70. },
  71. methods: {
  72. /* 打开弹窗 */
  73. openPicker() {
  74. const { CommunityQuestionId } = this.data;
  75. this.$emit('open_picker',CommunityQuestionId)
  76. },
  77. /* 操作*/
  78. actionHandle(key) {
  79. const actionmap = {
  80. 'del': this.delHandle,
  81. 'edit': this.editHandle,
  82. 'send': this.sendQuestionHandle,
  83. 'hot': this.setHotHandle
  84. }
  85. actionmap[key]()
  86. },
  87. /* 编辑 */
  88. editHandle() {
  89. this.$emit('edit',this.data)
  90. },
  91. /* 删除 */
  92. delHandle() {
  93. wx.showModal({
  94. title: "",
  95. content: `${this.type === 'question' ? '提问' : '评论'}删除后不可恢复,确认删除吗`,
  96. confirmColor: "#EE3636",
  97. cancelColor: '#333',
  98. success: async (res) => {
  99. if(res.cancel) return
  100. const { CommunityQuestionId,CommunityQuestionCommentId } = this.data;
  101. const { code } = this.type === 'question'
  102. ? await $api.apiDelQuestion({ QuestionId: CommunityQuestionId })
  103. : await $api.apiDelComment({ CommunityQuestionCommentId: CommunityQuestionCommentId });
  104. if( code !== 200 ) return
  105. wx.showToast({title: '删除成功'});
  106. this.$emit('del', this.type === 'question' ? CommunityQuestionId : CommunityQuestionCommentId)
  107. }
  108. })
  109. },
  110. /* 分配研究员 */
  111. async sendQuestionHandle() {
  112. console.log(this.data.select_users)
  113. if(!this.data.select_users) return
  114. const {first_id,second_id,user_id} = this.data.select_users;
  115. const { code } = await $api.apiDistribute({
  116. ResearchGroupFirstId: first_id,
  117. ResearchGroupSecondId: second_id,
  118. AdminId: user_id,
  119. QuestionId: this.data.CommunityQuestionId
  120. })
  121. if(code !== 200) return
  122. wx.showToast({title: '分配成功'})
  123. this.$emit('del', this.data.CommunityQuestionId)
  124. },
  125. /* 设置精选 */
  126. async setHotHandle() {
  127. const { CommunityQuestionCommentId } = this.data;
  128. const { code } = await $api.apiSetHotComment({CommunityQuestionCommentId})
  129. if(code !== 200) return
  130. wx.showToast({title: '设置成功'})
  131. this.$emit('hot',CommunityQuestionCommentId)
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .blue-color {
  138. color: #3385FF;
  139. }
  140. .red-color {
  141. color: #D63535;
  142. }
  143. .grey-color {
  144. color: #999;
  145. }
  146. .flex {
  147. display: flex;
  148. align-items: center;
  149. }
  150. .question-item {
  151. background: #fff;
  152. padding: 20rpx 0 0;
  153. border-radius: 8rpx;
  154. font-size: 28rpx;
  155. margin-bottom: 20rpx;
  156. color: #666;
  157. .cont {
  158. padding: 0 20rpx;
  159. }
  160. .item-title {
  161. color: #333;
  162. font-size: 32rpx;
  163. }
  164. .row {
  165. margin: 15rpx 0;
  166. }
  167. .item-bottom {
  168. justify-content: space-between;
  169. .select-wrapper {
  170. width: 250rpx;
  171. border: 1px solid #F1F2F6;
  172. padding: 0 40rpx 0 20rpx;
  173. position: relative;
  174. .ipt {
  175. height: 80rpx;
  176. line-height: 80rpx;
  177. }
  178. }
  179. }
  180. .action-bot {
  181. border-top: 1px solid #EAEAEA;
  182. margin-top: 30rpx;
  183. text {
  184. padding: 24rpx 0;
  185. flex: 1;
  186. text-align: center;
  187. border-right: 1px solid #EAEAEA;
  188. &:last-child { border: none; }
  189. }
  190. }
  191. }
  192. </style>