SingleComment.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div>
  3. <div
  4. class="single-item"
  5. :style="`padding-bottom:${props.problemData.isReplied === REPLY_STATUS.REPLIED ? '16px' : '38px'}`"
  6. >
  7. <div v-show="props.problemData.isUserDeleted === 1" class="delete-label"></div>
  8. <div :style="{ opacity: props.problemData.isUserDeleted === 1 ? 0.6 : 1 }">
  9. <div style="display: flex; font-size: 12px">
  10. <div style="color: #00000073">
  11. 评论人:{{ props.problemData.realname }}({{ props.problemData.userName }} )
  12. </div>
  13. <div style="margin-left: 20px; color: #00000073">日期:{{ props.problemData.createdAt }}</div>
  14. <!-- <img src="@/assets/icons/phone.png" alt="" /> -->
  15. <div class="single-contact">联系方式:{{ props.problemData.mobile }}</div>
  16. </div>
  17. <div class="buttonBar">
  18. <el-button
  19. v-show="props.problemData.status === COMMENT_STATUS.PASSED"
  20. type="primary"
  21. class="label-button"
  22. style="margin-left: auto; margin-right: 0"
  23. @click="showDialogBox('隐藏', '取消展示')"
  24. :disabled="props.problemData.isUserDeleted"
  25. >
  26. 隐藏
  27. </el-button>
  28. <el-button
  29. v-show="props.problemData.status !== COMMENT_STATUS.PASSED"
  30. type="primary"
  31. class="label-button"
  32. style="margin-left: auto; margin-right: 0"
  33. @click="showDialogBox('显示', '公开展示')"
  34. :disabled="props.problemData.isUserDeleted"
  35. >
  36. 显示
  37. </el-button>
  38. <el-button
  39. v-show="
  40. props.problemData.isReplied === REPLY_STATUS.UN_REPLIED &&
  41. props.problemData.status === COMMENT_STATUS.PASSED
  42. "
  43. class="label-button"
  44. type="primary"
  45. @click="openReply = true"
  46. :disabled="props.problemData.isUserDeleted"
  47. >
  48. 回复
  49. </el-button>
  50. <el-button v-show="props.problemData.isReplied === REPLY_STATUS.REPLIED" class="label-button" disabled>
  51. 已回复
  52. </el-button>
  53. </div>
  54. <el-divider />
  55. <div class="problem-describe">
  56. <div>评论内容:</div>
  57. <div class="problem-content">{{ props.problemData.comment }}</div>
  58. </div>
  59. <div class="problem-picture">
  60. <div class="picture-content" v-for="(item, index) in problemImageUrls" :key="index">
  61. <el-image
  62. style="width: 80px; height: 80px"
  63. :src="item"
  64. :zoom-rate="1.2"
  65. :max-scale="7"
  66. :min-scale="0.2"
  67. :preview-src-list="problemImageUrls"
  68. :initial-index="index"
  69. fit="cover"
  70. />
  71. </div>
  72. </div>
  73. <div v-if="openReply === true" style="position: relative">
  74. <el-input
  75. placeholder="请输入回复(不超过200个字符)"
  76. type="textarea"
  77. v-model="replyContent"
  78. rows="4"
  79. maxlength="200"
  80. resize="none"
  81. >
  82. </el-input>
  83. <span v-show="replyContent.length > 185" class="word-count">
  84. <span style="line-height: normal" :style="replyContent.length === 200 ? 'color:red' : ''">
  85. {{ replyContent.length }}
  86. </span>
  87. <span style="line-height: normal">/200</span>
  88. </span>
  89. <div class="reply-button-area">
  90. <el-button
  91. style="margin-top: 3px"
  92. type="primary"
  93. size="small"
  94. @click="submitReply"
  95. :disabled="replyContent.length === 0"
  96. >
  97. 发布
  98. </el-button>
  99. <el-button style="margin-top: 3px" size="small" @click="openReply = false">取消</el-button>
  100. </div>
  101. </div>
  102. <div v-if="props.problemData.isReplied === REPLY_STATUS.REPLIED" style="position: relative">
  103. <el-input type="textarea" v-model="props.problemData.reply" rows="3" disabled> </el-input>
  104. </div>
  105. </div>
  106. </div>
  107. <el-dialog v-model="showDialog" width="424px" top="20%" class="dialog">
  108. <template #header="">
  109. <div class="dialogHeader">
  110. <img src="@/assets/icons/deleteTip.png" class="deleteTip" />
  111. <span class="titleSpan">请确认是否{{ title }}</span>
  112. </div>
  113. </template>
  114. <span style="margin-left: 37px">{{ title }}后,该评论将在前台{{ result }}</span>
  115. <div class="dialogBottom">
  116. <el-button class="dialogBtn" type="primary" @click="submit">确定</el-button>
  117. <el-button class="dialogBtn" @click="showDialog = false">取消</el-button>
  118. </div>
  119. </el-dialog>
  120. </div>
  121. </template>
  122. <script setup lang="ts">
  123. import { ref, computed } from 'vue';
  124. import { undateCommentStatus, replyComment } from '@/api/comments/comments';
  125. import { REPLY_STATUS, COMMENT_STATUS } from '@/types/comments/constant';
  126. import { Records } from '@/types/comments/type';
  127. const props = defineProps<{
  128. problemData: Records;
  129. }>();
  130. const emit = defineEmits(['reFreshList']);
  131. const problemImageUrls = computed(() => {
  132. const imageUrlString = props.problemData.picUrl;
  133. return imageUrlString ? imageUrlString.split(',') : [];
  134. });
  135. const showDialog = ref(false);
  136. const title = ref('显示'); //该值为显示或隐藏
  137. const result = ref('公开展示'); //该值为公开展示或取消展示
  138. const showDialogBox = (setTitle: string, setResult: string) => {
  139. title.value = setTitle;
  140. result.value = setResult;
  141. showDialog.value = true;
  142. };
  143. const submit = () => {
  144. if (title.value === '显示') {
  145. displayComment();
  146. } else {
  147. hideComment();
  148. }
  149. };
  150. const hideComment = () => {
  151. undateCommentStatus({ id: props.problemData.id, status: COMMENT_STATUS.REJECTED }).then(() => {
  152. showDialog.value = false;
  153. emit('reFreshList');
  154. });
  155. };
  156. const displayComment = () => {
  157. undateCommentStatus({ id: props.problemData.id, status: COMMENT_STATUS.PASSED }).then(() => {
  158. showDialog.value = false;
  159. emit('reFreshList');
  160. });
  161. };
  162. const submitReply = () => {
  163. replyComment({ id: props.problemData.id, reply: replyContent.value }).then(() => {
  164. openReply.value = false;
  165. emit('reFreshList');
  166. });
  167. };
  168. const openReply = ref(false);
  169. const replyContent = ref('');
  170. </script>
  171. <style scoped>
  172. .single-item {
  173. background: #ffffff;
  174. box-shadow: 0px 1px 8px 0px rgba(0, 0, 0, 0.09);
  175. border-radius: 6px;
  176. padding: 16px 12px 0px 12px;
  177. position: relative;
  178. margin-top: 22px;
  179. margin-bottom: 2px;
  180. }
  181. .delete-label {
  182. width: 80px;
  183. height: 70px;
  184. position: absolute;
  185. right: 40px;
  186. top: 50px;
  187. background-image: url('@/assets/icons/deleted.png');
  188. background-size: 100% 100%;
  189. z-index: 99;
  190. }
  191. .label-button {
  192. width: 74px;
  193. }
  194. .single-contact {
  195. margin-left: 20px;
  196. margin-right: 40px;
  197. color: #00000073;
  198. }
  199. .buttonBar {
  200. position: absolute;
  201. display: flex;
  202. width: 200px;
  203. top: 11px;
  204. right: 12px;
  205. }
  206. .single-handle {
  207. position: relative;
  208. top: 11px;
  209. right: 12px;
  210. }
  211. .el-divider--horizontal {
  212. margin: 16px 0;
  213. }
  214. .problem-type,
  215. .problem-describe {
  216. font-size: 14px;
  217. white-space: nowrap;
  218. word-break: break-word;
  219. display: flex;
  220. margin-bottom: 8px;
  221. }
  222. .type-content,
  223. .problem-content {
  224. white-space: pre-wrap;
  225. word-break: break-word;
  226. }
  227. .type-content {
  228. font-weight: 600;
  229. }
  230. .problem-picture {
  231. display: flex;
  232. gap: 20px;
  233. }
  234. .word-count {
  235. position: absolute;
  236. left: 10px;
  237. padding-bottom: 5px;
  238. bottom: 2px;
  239. color: grey;
  240. background-color: #fff;
  241. line-height: 0;
  242. font-size: 12px;
  243. }
  244. .reply-button-area {
  245. position: absolute;
  246. height: 32px;
  247. right: 10px;
  248. padding-bottom: 5px;
  249. bottom: 2px;
  250. }
  251. .dialog {
  252. .dialogHeader {
  253. display: flex;
  254. .deleteTip {
  255. height: 24px;
  256. width: 24px;
  257. }
  258. .titleSpan {
  259. height: 24px;
  260. font-size: 16px;
  261. color: rgba(0, 0, 0, 0.88);
  262. line-height: 24px;
  263. text-align: center;
  264. margin-left: 12px;
  265. }
  266. }
  267. .dialogBottom {
  268. display: flex;
  269. justify-content: flex-end;
  270. margin-top: 12px;
  271. }
  272. }
  273. :deep(.el-collapse-item__header) {
  274. border-bottom: none;
  275. }
  276. :deep(.el-collapse-item__wrap) {
  277. border-bottom: none;
  278. }
  279. :deep(.el-collapse-item__content) {
  280. padding-bottom: 0px;
  281. }
  282. :deep(.el-collapse) {
  283. border-top: none;
  284. }
  285. </style>
  286. @/types/comments/constant