evaluate.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div>
  3. <use-table ref="tbl"></use-table>
  4. <div class="container padding_b_0">
  5. <!-- <div class="dflex_wrap">
  6. <div class="dflex_vertical_c margin_r_40 margin_b_20">
  7. <div class="search_name">用户名称:</div>
  8. <el-input v-model="req.member_name" placeholder="请输入" @keyup.enter.native="loadData" class="search_input"></el-input>
  9. </div>
  10. <el-button size="mini" class="search_btn margin_b_20 margin_r_40" @click="loadData">搜索</el-button>
  11. </div> -->
  12. </div>
  13. <div class="container use-table">
  14. <!-- :height="tblHeight" -->
  15. <el-table :data="tableDatas" highlight-current-row>
  16. <el-table-column label="用户" align="center" width="200">
  17. <template slot-scope="scope">
  18. <div class="dflex_vertical_c">
  19. <el-image class="headimg_small" :src="scope.row.userImg || require('static/img/touxiang.png')" :preview-src-list="scope.row.imgs" fit="contain"></el-image>
  20. <div class="margin_l_5">{{ scope.row.userId || '未知' }}</div>
  21. </div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column property="reviewContent" label="评价内容" width="400" align="center"></el-table-column>
  25. <el-table-column property="createTime" label="评价时间" width="200" align="center"></el-table-column>
  26. <el-table-column label="评价图片" width="300" align="center">
  27. <template slot-scope="scope">
  28. <div class="dflex">
  29. <!-- (scope.row.reviewImgs).slipt(',') -->
  30. <!-- v-if="scope.row.reviewImgs.search(',')==(-1)" -->
  31. <el-image style="width: 100px; height: 80px;" :preview-src-list="scope.row.reviewImgs" :src="scope.row.reviewImgs || require('static/img/noimage.png')" fit="contain"></el-image>
  32. <!-- <el-image v-else style="width: 100px; height: 80px;" :preview-src-list="scope.row.reviewImgs" :src="((scope.row.reviewImgs).substring(0, ((scope.row.reviewImgs).indexOf(',')))) || require('static/img/noimage.png')" fit="contain"></el-image> -->
  33. <!-- <div class="margin_r_10" v-for="(item, i) in (scope.row.reviewImgs)" :key="i">
  34. <el-image style="width: 100px; height: 80px;" :preview-src-list="scope.row.reviewImgs" :src="item" fit="contain"></el-image>
  35. </div> -->
  36. </div>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="商品评分" width="200" align="center">
  40. <template slot-scope="scope">
  41. <el-rate v-model="scope.row.reviewCnt" :colors="colors" disabled show-text :texts="['差评', '中评', '中评', '好评', '好评']"></el-rate>
  42. </template>
  43. </el-table-column>
  44. <el-table-column property="createTime" label="评价时间" align="center"></el-table-column>
  45. <el-table-column label="状态" align="center" width="100">
  46. <template slot-scope="scope">
  47. <el-tooltip :content="scope.row.state == '1' ? '点击隐藏' : '点击显示'" placement="top" :hide-after="1000" :enterable="false" effect="light">
  48. <el-switch
  49. v-model="scope.row.state"
  50. active-color="#ff6a6c"
  51. inactive-color="#bbb"
  52. active-value="1"
  53. inactive-value="0"
  54. @change="stateChange(scope.row)"
  55. ></el-switch>
  56. </el-tooltip>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="操作" align="center" fixed="right" width="100">
  60. <template slot-scope="scope">
  61. <!-- <div v-if="!scope.row.replay_content">
  62. <el-tooltip content="回复" placement="top" :hide-after="1000" :enterable="false" effect="light">
  63. <el-button type="text" icon="el-icon-chat-dot-round" class="bbb" @click="reply(scope.row._id)"></el-button>
  64. </el-tooltip>
  65. </div> -->
  66. <el-tooltip content="删除" placement="top" :hide-after="1000" :enterable="false" effect="light">
  67. <el-button type="text" icon="iconfont iconshanchu" class="bbb"
  68. @click="remove(scope.row.id)"></el-button>
  69. </el-tooltip>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. <el-pagination
  74. :current-page="req.page"
  75. :page-sizes="[10, 20, 30, 50, 100]"
  76. :page-size="req.rows"
  77. layout="total, sizes, prev, pager, next, jumper"
  78. :total="tableTotal"
  79. @size-change="sizeChange"
  80. @current-change="currentChange"
  81. ></el-pagination>
  82. </div>
  83. <el-drawer title="回复内容" :visible.sync="replyDrawer" direction="rtl" :append-to-body="true">
  84. <el-form class="add_edit" :model="form" :rules="rules" ref="ruleForm" label-width="100px">
  85. <el-form-item label="回复内容" prop="reply" ref="reply"><el-input type="textarea" :autosize="{ minRows: 3 }" v-model="form.reply"></el-input></el-form-item>
  86. <el-form-item>
  87. <el-button class="confirm_btn" @click="submitForm('ruleForm')">确 定</el-button>
  88. <el-button @click="replyDrawer = false">返回列表</el-button>
  89. </el-form-item>
  90. </el-form>
  91. </el-drawer>
  92. </div>
  93. </template>
  94. <script>
  95. const __name = 'usemall-goods-comment';
  96. import {
  97. delPingjia
  98. } from '@/util/loginJie.js'
  99. export default {
  100. data() {
  101. return {
  102. req: {
  103. page: 1,
  104. rows: 10,
  105. orderby: 'sort asc',
  106. member_name: ''
  107. },
  108. colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
  109. replyDrawer: false,
  110. replyId: '',
  111. form: {
  112. reply: ''
  113. },
  114. rules: {
  115. reply: [
  116. {
  117. required: true,
  118. message: '请输入回复内容',
  119. trigger: 'change'
  120. }
  121. ]
  122. },
  123. tblHeight: 0,
  124. tableDatas: [],
  125. tableTotal: 0
  126. };
  127. },
  128. methods: {
  129. loadData() {
  130. this.$axios.get("/goodsComment/admin/list",
  131. {
  132. params:{
  133. 'curPage':this.req.page,
  134. 'pageSize':this.req.rows,
  135. // 'orderField':'sort',
  136. 'order':'asc'
  137. },
  138. headers:{
  139. 'Mall-Token': uni.getStorageSync("token")
  140. }
  141. }).then(response => {
  142. let res = response
  143. if (res.success) {
  144. res.data.list.forEach((row, idx) => {
  145. row.imgs = [row.reviewImgs];
  146. row.createTime = new Date(row.createTime).format();
  147. });
  148. this.tableDatas = res.data.list;
  149. console.log(this.tableDatas)
  150. this.tableTotal = res.data.totalCount;
  151. } else {
  152. }
  153. }).catch(res =>{
  154. });
  155. },
  156. reply(id) {
  157. this.replyDrawer = true;
  158. this.replyId = id;
  159. },
  160. submitForm(formName) {
  161. this.$refs[formName].validate((valid, obj) => {
  162. this.$api.set_unvalidated_form_focus(this, obj);
  163. if (valid) {
  164. this.$db[__name].update(this.replyId, { replay_content: this.form.reply }).then(res => {
  165. if (res.code == 200) {
  166. this.replyDrawer = false;
  167. this.loadData();
  168. }
  169. });
  170. }
  171. });
  172. },
  173. remove(id) {
  174. var data=[id]
  175. var headers={
  176. 'Content-Type': 'application/json; charset=utf-8',
  177. "Mall-Token": uni.getStorageSync('token')
  178. }
  179. this.$confirm('此操作将永久删除该数据!', '提示', {
  180. confirmButtonText: '确定',
  181. cancelButtonText: '取消',
  182. type: 'warning'
  183. }).then(() => {
  184. delPingjia(data,headers).then((res) => {
  185. if (res.success) {
  186. this.loadData();
  187. }
  188. })
  189. });
  190. },
  191. stateChange(row) {
  192. this.$axios.put(`/goodsComment/admin/${row.id}/${row.state}`,
  193. {},
  194. {
  195. headers:{
  196. 'Mall-Token': uni.getStorageSync("token")
  197. }
  198. }).then(response => {
  199. let res = response
  200. if (res.success) {
  201. this.loadData()
  202. } else {
  203. alert(res.message)
  204. }
  205. })
  206. // this.$db[__name].update(row._id, { state: row.state }).then(res => {
  207. // if (res.code == 200) this.loadData();
  208. // });
  209. },
  210. sizeChange(size) {
  211. this.req.rows = size;
  212. this.loadData();
  213. },
  214. currentChange(current) {
  215. this.req.page = current;
  216. this.loadData();
  217. }
  218. },
  219. created() {
  220. this.loadData();
  221. },
  222. updated() {
  223. // // if (!this.tblHeight) {
  224. // // this.tblHeight = this.$refs.tbl.tblHeight;
  225. // // }
  226. }
  227. };
  228. </script>
  229. <style>
  230. .add_edit .el-textarea {
  231. width: 90%;
  232. }
  233. </style>