index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div>
  3. <el-row class="app-toptool" type="flex">
  4. <el-col :span="16">
  5. <Search
  6. size="small"
  7. :search-visible="searchVisible"
  8. :search-data.sync="searchData"
  9. :search-form="searchForm"
  10. @refesh_list="searchgo"
  11. />
  12. </el-col>
  13. </el-row>
  14. <el-table
  15. ref="multipleTable"
  16. v-loading="loading"
  17. :row-class-name="rowClass"
  18. :tree-props="{children: 'children'}"
  19. :default-expand-all="expand"
  20. row-key="id"
  21. :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
  22. :border="false"
  23. :stripe="true"
  24. class="eltable"
  25. :data="list"
  26. style="width: 100%"
  27. >
  28. <el-table-column
  29. align="center"
  30. type=""
  31. property="id"
  32. label="编号"
  33. show-overflow-tooltip
  34. width="70"
  35. />
  36. <el-table-column align="center" property="head_img_url" label="头像" show-overflow-tooltip width="90">
  37. <template slot-scope="scope">
  38. <div class="demo-image__preview">
  39. <el-image
  40. v-if="scope.row.head_img_url"
  41. class="table_list_pic"
  42. :src="scope.row.head_img_url"
  43. :preview-src-list="[scope.row.head_img_url]"
  44. />
  45. </div>
  46. </template>
  47. </el-table-column>
  48. <el-table-column
  49. align="left"
  50. property="nick_name"
  51. label="微信昵称"
  52. show-overflow-tooltip
  53. width=""
  54. />
  55. <el-table-column
  56. align="left"
  57. property="goodsName"
  58. label="产品/服务"
  59. show-overflow-tooltip
  60. width=""
  61. />
  62. <el-table-column
  63. align="left"
  64. property="level"
  65. label="评分(总分5分)"
  66. show-overflow-tooltip
  67. width=""
  68. />
  69. <el-table-column
  70. align="left"
  71. property="content"
  72. label="评语"
  73. show-overflow-tooltip
  74. width=""
  75. />
  76. <el-table-column
  77. align="left"
  78. property="create_time"
  79. label="评价时间"
  80. show-overflow-tooltip
  81. width=""
  82. />
  83. <el-table-column
  84. align="center"
  85. property="status"
  86. label="状态"
  87. show-overflow-tooltip
  88. width=""
  89. >
  90. <template slot-scope="scope">
  91. <el-switch
  92. v-model="scope.row.status"
  93. :active-value="1"
  94. :inactive-value="0"
  95. @change="listUpdate(scope.row,'status')"
  96. />
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <Pagination
  101. :total="page_data.total"
  102. :page.sync="page_data.page"
  103. :limit.sync="page_data.limit"
  104. @pagination="getList"
  105. />
  106. </div>
  107. </template>
  108. <script>
  109. import Search from '@/components/common/Search'
  110. import Pagination from '@/components/Pagination'
  111. import waves from '@/directive/waves' // waves directive
  112. import {
  113. param2Obj
  114. } from '@/utils/common'
  115. export default {
  116. name: 'Comment',
  117. directives: { waves },
  118. components: {
  119. Search,
  120. Pagination
  121. },
  122. data() {
  123. return {
  124. ids: [],
  125. single: true,
  126. multiple: true,
  127. list: [],
  128. loading: false,
  129. page_data: {
  130. limit: 20,
  131. page: 1,
  132. total: 20
  133. },
  134. searchVisible: true,
  135. searchForm: [],
  136. searchData: {},
  137. expand: true
  138. }
  139. },
  140. mounted() {
  141. this.getList()
  142. },
  143. methods: {
  144. searchgo() {
  145. this.page_data.page = 1;
  146. this.getList()
  147. },
  148. getList() {
  149. const param = {
  150. limit: this.page_data.limit,
  151. page: this.page_data.page
  152. }
  153. Object.assign(param, this.searchData)
  154. Object.assign(param, param2Obj(this.$route.fullPath))
  155. this.loading = true
  156. this.$api.post('/Comment/index', param).then(res => {
  157. this.list = res.data.data
  158. this.page_data.total = res.data.total
  159. this.loading = false
  160. this.searchForm = [{
  161. type: 'Input',
  162. label: '关键词',
  163. prop: 'keyword',
  164. width: '230px'
  165. }
  166. ]
  167. })
  168. },
  169. listUpdate(row, field) {
  170. if (row.id) {
  171. this.$api.post('/Comment/listUpdate', {
  172. id: row.id,
  173. [field]: row[field]
  174. }).then(res => {
  175. this.$message({
  176. message: '操作成功',
  177. type: 'success'
  178. })
  179. })
  180. }
  181. },
  182. rowClass({
  183. row,
  184. rowIndex
  185. }) {
  186. for (let i = 0; i < this.ids.length; i++) {
  187. if (row.id === this.ids[i]) {
  188. return 'rowLight'
  189. }
  190. }
  191. },
  192. toggleRowExpansion() {
  193. this.expand = !this.expand
  194. this.list.forEach(item => {
  195. this.$refs.multipleTable.toggleRowExpansion(item, this.expand)
  196. })
  197. }
  198. }
  199. }
  200. </script>
  201. <style scoped>
  202. .edit-input {
  203. padding-right: 100px;
  204. }
  205. .cancel-btn {
  206. position: absolute;
  207. right: 15px;
  208. top: 10px;
  209. }
  210. </style>