<template>
  <div class="">
    <toolbar @on-filter="filterData" @on-reset="filterData" />

    <base-table
      class="m-10 bg-w p-20 br-10"
      :columns="columns"
      :items="items"
      :pagination="pagination"
      :page-change="pageChange"
    />
  </div>
</template>

<script>
import toolbar from './toolbar';
import mxFilterList from '@/mixins/filterList';
import { getPage } from '@/api/base/problemFeedback';

export default {
  name: 'ProblemFeedbackManagement',

  components: { toolbar },

  mixins: [
    mxFilterList({
      fetchList: getPage // 在下方data再声明一个 fetchList: iGetList 同等效果
    })
  ],

  data() {
    return {
      columns: [
        {
          key: 'nickname',
          name: '用户昵称',
          width: this.$col.s
        },
        {
          key: 'realName',
          name: '真实姓名',
          width: this.$col.s
        },
        {
          key: 'phonenumber',
          name: '手机号',
          width: this.$col.m
        },
        {
          key: 'content',
          name: '反馈内容',
          minWidth: this.$col.b,
          render: (h, { row }) => {
            let str = row.content;
            return h('BaseTooltip', {
              props: {
                txt: str
              }
            });
          }
        },
        {
          key: 'photo',
          name: '反馈图片',
          width: this.$col.m,
          render: (h, { row }) => {
            if (row.imgUrl === '') {
              return h('span', '-');
            }
            const items = row.imgUrl.split(',');
            const list = items.map(x => ({
              src: x
            }));
            if (list.length > 0) {
              return h('img', {
                style: {
                  width: '90px',
                  height: '90px'
                },
                class: 'pre-img',
                attrs: {
                  src: list[0].src
                },
                on: {
                  click: () =>
                    this.$AdvanceViewImageModal({
                      items: list
                    })
                }
              });
            } else {
              return h('span', '-');
            }
          }
        },
        {
          key: 'createAt',
          name: '反馈时间',
          width: this.$col.b
        }
      ]
    };
  }
};
</script>

<style type="scss" scoped></style>
