import v4 from '@/assets/order/4.0@2x.png'
import gc from '@/assets/order/工程@2x.png'
import jj from '@/assets/order/加急@2x.png'
import ls from '@/assets/order/零售@2x.png'
import yjs from '@/assets/order/已结算@2x.png'
import ywg from '@/assets/order/已完工待结算@2x@2x.png'
import yc from '@/assets/order/异常@2x.png'
import zj from '@/assets/order/自建@2x.png'
import pjsq from '@/assets/order/配件申请中@2x.png'
import pjdh from '@/assets/order/配件已到货@2x.png'
import pjqx from '@/assets/order/配件已取消@2x.png'
export default {
  data() {
    return {}
  },
  methods: {
    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      if (item.jname === 'orderFlags') {
        defaultData.render = (h, { row, index, column }) => {
          return (
            <div style="padding:0 6px;display:flex;align-items:center;">
              {(row[column.columnAttributes.prop] || []).map(item => {
                if (item.tagName == '4.0工单') {
                  return <img src={v4} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '工程') {
                  return <img src={gc} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '加急') {
                  return <img src={jj} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '零售') {
                  return <img src={ls} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '已结算') {
                  return <img src={yjs} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '已完工') {
                  return <img src={ywg} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '异常') {
                  return <img src={yc} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '自建工单') {
                  return <img src={zj} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '配件申请中') {
                  return <img src={pjsq} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '配件已到货') {
                  return <img src={pjdh} style="width:20px;height:20px;margin:0 3px;" />
                } else if (item.tagName == '配件已取消') {
                  return <img src={pjqx} style="width:20px;height:20px;margin:0 3px;" />
                } else {
                  return (
                    <div style="display: inline-block;border:1px solid #409EFF; color:#409EFF;padding:4px;border-radius: 4px;margin:2px 2px 0 0; font-size: 12px!important; line-height: 12px !important;">
                      {item.tagName}
                    </div>
                  )
                }
              })}
            </div>
          )
        }
      }
      if (item.jname === 'appointmentTime') {
        defaultData.render = (h, { row, index, column }) => {
          return (
            <div style="padding:0 6px;cursor: pointer;">
              {row[column.columnAttributes.prop] ? row[column.columnAttributes.prop].split(' ')[0] : ''}
            </div>
          )
        }
      }
      if (item.jname === 'orderStatus') {
        defaultData.render = (h, { row, index, column }) => {
          var colors = {
            DJD: '#00acff',
            DSHPG: '#ff27bf',
            DWDPG: '#236cfe',
            DYY: '#0d07ff',
            FWZ: '#00ee5a',
            YCD: '#ff3030',
            YJS: '#02b100',
            YQX: '#ffbd2f',
            YWG: '#f77233',
            DQD: '#179f00'
          }
          return (
            <div
              style={`padding:0 6px;cursor: pointer;color:${
                colors[
                  Object.entries(row.selectMapData.orderStatus).find(([key, val]) => val == row.orderStatus)?.[0] || ''
                ]
              };`}
            >
              {row[column.columnAttributes.prop]}
            </div>
          )
        }
      }
      return defaultData
    }
  }
}
