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

export const setCol = (self) => {
  return [
    {
      title: '异常图片',
      dataIndex: 'abnormalPhoto',
      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 ''
      },
    },
    {
      title: '异常类型',
      dataIndex: 'abnormalTypeName',
      sorter: (a, b) => {
        return ~~a.abnormalType - ~~b.abnormalType
      },
    },
    {
      title: '异常事件',
      dataIndex: 'abnormalEventName',
      sorter: (a, b) => {
        return ~~a.abnormalEvent - ~~b.abnormalEvent
      },
    },
    {
      title: '客户投诉',
      dataIndex: 'abnormalComplainName',
      sorter: (a, b) => {
        return ~~a.abnormalComplain - ~~b.abnormalComplain
      },
    },
    { title: '异常内容', dataIndex: 'abnormalContent' },

    {
      title: '异常发生时间',
      dataIndex: 'abnormalTime',
      sorter: (a, b) => {
        return +new Date(a.abnormalTime) - +new Date(b.abnormalTime)
      },
    },
    {
      title: '异常状态',
      dataIndex: 'abnormalStatusNanme',
      sorter: (a, b) => {
        return ~~a.abnormalStatus - ~~b.abnormalStatus
      },
    },
    { title: '创建人', dataIndex: 'createperson' },
    {
      title: '创建时间',
      dataIndex: 'createtime',

      sorter: (a, b) => {
        return +new Date(a.createtime) - +new Date(b.createtime)
      },
    },
    {
      key: 'operation',
      title: '操作',
      fixed: 'right',
      align: 'center',
      scopedSlots: { customRender: 'operation' },
      width: 100,
    },
  ]
}
