replyList.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div style="width: 100%">
  3. <Modal
  4. v-model="modals"
  5. scrollable footer-hide closable
  6. title="评论回复列表" :mask-closable="false"
  7. width="900"
  8. vertical-center-modal>
  9. <Form
  10. inline
  11. ref="replyFrom"
  12. :model="replyFrom"
  13. :label-width="labelWidth"
  14. :label-position="labelPosition"
  15. @submit.native.prevent
  16. >
  17. <FormItem label="时间选择:">
  18. <DatePicker
  19. :editable="false"
  20. @on-change="onchangeTime"
  21. :value="timeVal"
  22. format="yyyy/MM/dd"
  23. type="daterange"
  24. placement="bottom-end"
  25. placeholder="自定义时间"
  26. class="input-add"
  27. ></DatePicker>
  28. <Button type="primary" @click="getList(replyId)">查询</Button>
  29. </FormItem>
  30. </Form>
  31. <Table :loading="loading" highlight-row no-userFrom-text="暂无数据" no-filtered-userFrom-text="暂无筛选结果"
  32. ref="selection" :columns="columns" :data="dataList">
  33. <template slot-scope="{ row }" slot="info">
  34. <div v-if="fromType">{{row.uid?row.nickname:'作者'}}</div>
  35. <div v-else class="imgPic acea-row row-middle">
  36. <viewer>
  37. <div class="tabBox_img"><img v-lazy="row.user.avatar" /></div>
  38. </viewer>
  39. <div class="info">{{ row.user.nickname }}</div>
  40. </div>
  41. </template>
  42. <template slot-scope="{ row }" slot="merchantReply">
  43. <div>{{row.children?row.children.content:''}}</div>
  44. </template>
  45. <template slot-scope="{ row, index }" slot="action">
  46. <a @click="reply(row)" v-show="row.pid == 0 || row.uid > 0">回复</a>
  47. <Divider type="vertical" v-show="row.pid == 0 || row.uid > 0" />
  48. <a @click="del(row,'删除评论',index)">删除</a>
  49. </template>
  50. </Table>
  51. <div class="acea-row row-right page">
  52. <Page :total="total" show-elevator show-total :current="replyFrom.page" @on-change="pageChange"
  53. :page-size="replyFrom.limit" />
  54. </div>
  55. </Modal>
  56. <Modal v-model="replyModals" scrollable title="回复内容" closable>
  57. <Form
  58. ref="contents"
  59. :model="contents"
  60. :rules="ruleInline"
  61. @submit.native.prevent
  62. >
  63. <FormItem prop="content">
  64. <Input
  65. v-model="contents.content"
  66. type="textarea"
  67. :rows="4"
  68. placeholder="请输入回复内容"
  69. />
  70. </FormItem>
  71. </Form>
  72. <div slot="footer">
  73. <Button type="primary" @click="oks">确定</Button>
  74. <Button @click="cancels">取消</Button>
  75. </div>
  76. </Modal>
  77. </div>
  78. </template>
  79. <script>
  80. import { mapState } from "vuex";
  81. import {
  82. productReplycomment,
  83. productReplySave
  84. } from "@/api/product"
  85. import { videoCommentReply, videoReply } from "@/api/marketing";
  86. export default {
  87. name: 'userList',
  88. props: {
  89. fromType: {
  90. type: Number,
  91. default:0
  92. }
  93. },
  94. data() {
  95. return {
  96. contents: {
  97. content: "",
  98. },
  99. ruleInline: {
  100. content: [
  101. { required: true, message: "请输入回复内容", trigger: "blur" },
  102. ],
  103. },
  104. replyModals: false,
  105. modals: false,
  106. total: 0,
  107. replyFrom: {
  108. page: 1,
  109. limit: 15
  110. },
  111. time:'',
  112. loading: false,
  113. dataList: [],
  114. columns: [
  115. {
  116. title: "ID",
  117. key: "id",
  118. width: 80,
  119. },
  120. {
  121. title: '评论用户',
  122. slot: 'info',
  123. minWidth: 90
  124. },
  125. {
  126. title: "评论内容",
  127. key: "content",
  128. minWidth: 100,
  129. },
  130. // {
  131. // title: "后台回复",
  132. // slot: "merchantReply",
  133. // minWidth: 100,
  134. // },
  135. {
  136. title: "操作",
  137. slot: "action",
  138. width: 100,
  139. }
  140. ],
  141. rows: {},
  142. fromList: {
  143. title: "选择时间",
  144. custom: true,
  145. fromTxt: [
  146. { text: "全部", val: "" },
  147. { text: "今天", val: "today" },
  148. { text: "昨天", val: "yesterday" },
  149. { text: "最近7天", val: "lately7" },
  150. { text: "最近30天", val: "lately30" },
  151. { text: "本月", val: "month" },
  152. { text: "本年", val: "year" },
  153. ],
  154. },
  155. timeVal: [],
  156. replyId: 0
  157. }
  158. },
  159. computed: {
  160. ...mapState("admin/layout", ["isMobile"]),
  161. labelWidth() {
  162. return this.isMobile ? undefined : 75;
  163. },
  164. labelPosition() {
  165. return this.isMobile ? "top" : "left";
  166. },
  167. },
  168. created() {
  169. },
  170. methods: {
  171. oks() {
  172. this.$refs["contents"].validate((valid) => {
  173. if (valid) {
  174. let apiName = this.fromType?videoReply(this.contents, this.rows.id):
  175. productReplySave(this.contents, this.replyId, this.rows.id);
  176. apiName.then(async (res) => {
  177. this.$Message.success(res.msg);
  178. this.replyModals = false;
  179. this.$refs["contents"].resetFields();
  180. this.getList(this.replyId);
  181. })
  182. .catch((res) => {
  183. this.$Message.error(res.msg);
  184. });
  185. } else {
  186. return false;
  187. }
  188. });
  189. },
  190. // 具体日期
  191. onchangeTime(e) {
  192. this.timeVal = e;
  193. this.time = this.timeVal[0] ? this.timeVal.join("-") : "";
  194. this.replyFrom.page = 1;
  195. },
  196. // 选择时间
  197. selectChange(tab) {
  198. this.time = tab;
  199. this.timeVal = [];
  200. this.replyFrom.page = 1;
  201. this.getList(this.replyId);
  202. },
  203. cancels() {
  204. this.replyModals = false;
  205. this.$refs["contents"].resetFields();
  206. },
  207. reply(row){
  208. this.contents.content = row.children?row.children.content:'';
  209. this.rows = row;
  210. this.replyModals = true;
  211. },
  212. // 删除
  213. del (row, tit, num) {
  214. let urls = '';
  215. urls = this.fromType?`/marketing/video/comment/${row.id}`:`product/reply/delete_comment/${row.id}`;
  216. let delfromData = {
  217. title: tit,
  218. num: num,
  219. url: urls,
  220. method: 'DELETE',
  221. ids: ''
  222. };
  223. this.$modalSure(delfromData).then((res) => {
  224. this.$Message.success(res.msg);
  225. this.dataList.splice(num, 1);
  226. if (!this.dataList.length) {
  227. console.log('huhu');
  228. this.replyFrom.page =
  229. this.replyFrom.page == 1 ? 1 : this.replyFrom.page - 1;
  230. }
  231. this.getList(this.replyId);
  232. }).catch(err => {
  233. this.$Message.error(err.msg);
  234. });
  235. },
  236. //评论回复列表
  237. getList(id) {
  238. this.replyId = id;
  239. this.loading = true;
  240. let apiName = '';
  241. if(this.fromType){
  242. this.replyFrom.data = this.time;
  243. apiName = videoCommentReply;
  244. }else {
  245. this.replyFrom.time = this.time;
  246. apiName = productReplycomment;
  247. }
  248. apiName(this.replyFrom,id).then(res => {
  249. this.loading = false;
  250. this.total = res.data.count;
  251. this.dataList = res.data.list;
  252. }).catch(err => {
  253. this.loading = false;
  254. this.$Message.error(err.msg)
  255. })
  256. },
  257. pageChange(page){
  258. this.replyFrom.page = page;
  259. this.getList(this.replyId);
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="less" scoped>
  265. .input-add {
  266. width: 250px;
  267. margin-right:14px;
  268. }
  269. /deep/.ivu-table {
  270. height: 300px;
  271. overflow-x: hidden;
  272. overflow-y: auto;
  273. }
  274. /deep/.ivu-table-overflowX {
  275. overflow-x: hidden !important;
  276. }
  277. .tabBox_img {
  278. width: 36px;
  279. height: 36px;
  280. border-radius: 4px;
  281. cursor: pointer;
  282. margin-right: 10px;
  283. img {
  284. width: 100%;
  285. height: 100%;
  286. }
  287. }
  288. </style>