
import ywgdjs from "@/assets/ywgdjs.png"
import yjs from "@/assets/yjs.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 == "已完工") {
                  return (
                    <img src={ywgdjs} style="width:16px;height:16px;margin:0 3px;" />
                  )
                } else if (item.tagName == "已结算") {
                  return (
                    <img src={yjs} style="width:16px;height:16px;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
    },
  }
}
