

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

/** 证件资料 certificate*/
export const certificateColumns = self => {
  return [
    { dataIndex: 'id', title: 'ID', hidden: true },
    {
      dataIndex: 'picture',
      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] : '',
              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: 'code', title: '证件号码'
    },
    {
      dataIndex: 'type', title: '证件类型',
      customRender: (text, data) => {

        return ['身份证','行驶证','驾驶证'][+text-1]
      }
    },
    {
      dataIndex: 'status', title: '状态',
      align: "center",
      customRender: (text,data) => {
        return self._c('a-badge', {
          attrs: {
            color:text>0?'cyan':'red',
            text:text>0?'启用':'停用',
        }})
      }
    },
    { dataIndex: 'issuingAuthority', title: '发证机关'},
    { dataIndex: 'issuingDate', title: '发证日期' },
    { dataIndex: 'startDate', title: '有效期始', width: 100 },
    { dataIndex: 'endDate', title: '有效期止', width: 100 },
    { dataIndex: 'memo', title: '备注' },
    {
      key: 'operation',
      title: '操作',
      get width() {
        return self.st===3?60:200
      },
      fixed: 'right',
      align: 'center',
      scopedSlots: { customRender: 'operation' }
    }
  ]
}


