import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import vueBus from './vueBus'

let dictOptions = [];
let type = "";

// 统计页字段
const tjColunms = [
  {
    title: '#',
    dataIndex: '',
    key: 'rowIndex',
    width: 60,
    align: "center",
    customRender: function (t, r, index) {
      return parseInt(index) + 1;
    }
  },
  {
    title: '单位名称',
    align: "center",
    dataIndex: 'sysOrgCode_dictText'
  },
  {
    title: '地块名称',
    align: "center",
    dataIndex: 'dk'
  },
  {
    title: '证书/合同/文件编号',
    align: "center",
    dataIndex: 'wjbh'
  },
  {
    title: '土地使用权人',
    align: "center",
    dataIndex: 'tdsyqr'
  },
  {
    title: '使用权使用方式',
    align: "center",
    dataIndex: 'syqsyfs'
  },
  {
    title: '实际用途',
    align: "center",
    dataIndex: 'sjyt',
    // dataIndex: 'sjyt_dictText',
    customRender: (text) => (text ? filterMultiDictText(dictOptions['sjyt'], text) : '')
  },
  {
    title: '操作',
    dataIndex: 'action',
    align: "center",
    fixed: "right",
    width: 147,
    scopedSlots: {customRender: 'action'}
  }
];

// 省属企业审核字段
const CompanyauditColumns = [
  {
    title: '#',
    dataIndex: '',
    key:'rowIndex',
    width:60,
    align:"center",
    customRender:function (t,r,index) {
      return parseInt(index)+1;
    }
  },
  {
    title:'单位名称',
    align:"center",
    dataIndex: 'sysOrgCode_dictText'
  },
  {
    title:'地块名称',
    align:"center",
    dataIndex: 'dk'
  },
  {
    title:'文件类型',
    align:"center",
    dataIndex: 'wjlx_dictText'
  },
  {
    title:'证书/合同/文件编号',
    align:"center",
    dataIndex: 'wjbh'
  },
  {
    title:'土地使用权人',
    align:"center",
    dataIndex: 'tdsyqr'
  },
  {
    title:'使用权使用方式',
    align:"center",
    dataIndex: 'syqsyfs'
  },
  {
    title:'实际用途',
    align:"center",
    dataIndex: 'sjyt',
    customRender:
      (text) => (text ? filterMultiDictText(dictOptions['sjyt'], text) : '')
  },
  {
    title:'是否上报',
    align:"center",
    dataIndex: 'sfsb_dictText'
  },
  {
    title: '操作',
    dataIndex: 'action',
    align:"center",
    fixed:"right",
    width:147,
    scopedSlots: { customRender: 'action' }
  }
];

// 省直单位审核字段
const departAuditColumns = [
  {
    title: '#',
    dataIndex: '',
    key:'rowIndex',
    width:60,
    align:"center",
    customRender:function (t,r,index) {
      return parseInt(index)+1;
    }
  },
  {
    title:'单位名称',
    align:"center",
    dataIndex: 'sysOrgCode_dictText'
  },
  {
    title:'地块名称',
    align:"center",
    dataIndex: 'dk'
  },
  {
    title:'证书类型',
    align:"center",
    dataIndex: 'zslx'
  },
  {
    title:'证书/合同/文件编号',
    align:"center",
    dataIndex: 'wjbh'
  },
  {
    title:'土地使用权人',
    align:"center",
    dataIndex: 'tdsyqr'
  },
  {
    title:'使用权使用方式',
    align:"center",
    dataIndex: 'syqsyfs'
  },
  {
    title:'实际用途',
    align:"center",
    dataIndex: 'sjyt',
    customRender:
      (text) => (text ? filterMultiDictText(dictOptions['sjyt'], text) : '')
  },
  {
    title:'是否上报',
    align:"center",
    dataIndex: 'sfsb_dictText'
  },
  {
    title: '操作',
    dataIndex: 'action',
    align:"center",
    fixed:"right",
    width:147,
    scopedSlots: { customRender: 'action' }
  }
];

// 获取实际用途类型
export function getDictOption(data) {
  console.log("columns...data", data)
  dictOptions = data;
}

// 获取传参页面
export function getViewType(data) {
  type = data;
  let num = (tjColunms[3].title ==='证书类型' || tjColunms[3].title ==='文件类型') ? 1 : 0;
  if (data === 'ss') {
    console.log("tjColunms[3].title", tjColunms[3].title);

    tjColunms.splice(3, num,
      {
        title: '文件类型',
        align: "center",
        dataIndex: 'wjlx_dictText'
      },);
  } else {
    tjColunms.splice(3, num, {
      title: '证书类型',
      align: "center",
      dataIndex: 'zslx_dictText'
    },);
  }
}

export { tjColunms, CompanyauditColumns, departAuditColumns };