questionItem.vue 6.8 KB

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