commentDetail.vue 2.99 KB
<!-- 查看产品 - 评价信息 -->
<template>
  <div class="comment-detail container edit-container">
    <div style="padding: 20px">
      <!-- 表格区域 开始 -->
      <GLTable ref="commentRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :beforeSearchFn="beforeSearchFn" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
        <div slot="starLevel" slot-scope="scope">
          <img v-for="(item, index) in scope.scope.starLevel" :key="index" class="icon-star" src="@/assets/icon-star.png" />
        </div>
        <div slot="goodsImage" class="table-image" slot-scope="scope">
          <span v-if="!scope.scope.imgUrls">-</span>
          <img v-else class="img-60" :src="scope.scope.imgUrls[0]" @click="handleImgLook(scope.scope.imgUrls)" />
        </div>
      </GLTable>
      <el-dialog v-if="isImgVisible" title="查看" :visible.sync="isImgVisible" :close-on-click-modal="false">
        <div class="dialog-look">
          <span v-for="(item, index) in dialogObj.imgUrls" :key="index">
            <el-image style="width: 200px; height: 200px; margin-right: 10px" :src="item" :preview-src-list="[item]"></el-image>
          </span>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
export default {
  name: 'commentDetail',
  data() {
    return {
      size: 'small',
      url: url,
      searchForm: {
        goodsId: ''
      },
      isImgVisible: false,
      // imgUrls: [],,
      dialogObj: {
        imgUrls: [],
        uploadType: 'img'
      },
      // 表格
      getListApi: this.$apis.proManage.getGoodsCommentListApi,
      tableParams: {
        listName: 'list',
        tableColumns: [
          {
            label: '评价用户名称',
            prop: 'customerName'
          },
          {
            label: '评价时间',
            prop: 'createdDateStr'
          },
          {
            label: '评价星级',
            prop: 'starLevel',
            addHtml: 'starLevel'
          },
          {
            label: '评价内容',
            prop: 'commentContent',
            line: 3
          },
          {
            label: '图片',
            prop: 'goodsImage',
            addHtml: 'goodsImage'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' }
    }
  },

  props: {
    goodsId: {
      type: Object,
      default: () => {}
    }
  },

  methods: {
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchForm.goodsId = this.goodsId
        resolve()
      })
    },

    setTableFinishFun() {
      //接收到的数据为空
      // this.$refs.commentRef.data.length ? (this.$refs.commentRef.tableHeightValues = '') : this.$refs.commentRef.setTableHeightFun()
    },

    handleImgLook(imgUrls) {
      this.isImgVisible = !this.isImgVisible
      this.dialogObj = {
        imgUrls: imgUrls,
        uploadType: 'img'
      }
    }
  }
}
</script>
<style></style>