import { UPCLOUD_RDC_TMS_IMAGE_HOST } from '@/config/serviceSettings.js'

export const setEvaluateColumns = (self, expData = []) => {
  return [
    // { dataIndex: 'id', title: 'ID', hidden: true },
    {
      dataIndex: 'picUrl',
      title: '图片',
      width: 50,
      align: 'center',
      customRender(text, data) {
        let picture = text ? text.split(',') : ''
        if (Array.isArray(picture)) {
          return self._c('a-avatar', {
            attrs: {
              shape: 'square',
              src: picture[0]?UPCLOUD_RDC_TMS_IMAGE_HOST+'/'+picture[0] : null,
              size: 60,
            },
            style: 'border:1px solid #e8e8e8;backgroundColor: #fff',
            on: {
              click: () => {
                if (!picture[0]) return
                self.$refs.updateFormModal.previewVisible = true
                self.$refs.updateFormModal.previewImage =UPCLOUD_RDC_TMS_IMAGE_HOST+'/'+picture[0];
              },
            },
            scopedSlots: {
              icon() {
                return !picture[0] ? self._c('a-icon', { attrs: { type: 'picture', theme: 'twoTone' } }) : undefined
              },
            },
          })
        }
        return ''
      },
    },
    { dataIndex: 'id', title: '评价单号' },
    { dataIndex: 'evaluationTargetName', title: '评价对象' },

    { dataIndex: 'evaluationStar', title: '星数' },
    { dataIndex: 'problemTypeName', title: '问题类型' },
    { dataIndex: 'problemDesc', title: '问题描述' },

    {
      title: '评价人',
      dataIndex: 'evaluationUserName',
      type: 'txt',
      width: 120,
      align: 'center',

    },
    {
      title: '评价人类型',
      dataIndex: 'evaluationUserTypeName',
      width: 120,
      align: 'center',
      sorter: (a, b) => {
        return ~~a.evaluationUserType - ~~b.evaluationUserType
      },
    },
    {
      title: '评价时间',
      dataIndex: 'createtime',
      width: 120,
      align: 'center',
      sorter: (a, b) => {
        return +new Date(a.createtime) - +new Date(b.createtime)
      },
    },

    ...expData,
  ]
}
