/**
 * 导出页面的所有数据合并为一个Excel
 */
// 导出表格为excel格式
export default{
  install (Vue, options) {
    console.log(options)
    Vue.prototype.exportAllData = function () {
        var title = this.tableTitle
        let tHeader = [];
        let filterVal = [];
        let refArr = Object.values(this.$refs);
        var list = [];
        refArr.forEach((e) => {
            console.log(e)
            e.dataColumnData.forEach((e1) => {
              if(tHeader.indexOf(e1.label) === -1){
                tHeader.push(e1.label)
              }
              if(filterVal.indexOf(e1.prop) === -1){
                filterVal.push(e1.prop)
              }
            })
            if(filterVal.indexOf(e.dataColumnData.prop) === -1){
                filterVal.push(e.dataColumnData.prop)
            }
            list = list.concat(e.dataTabel)
        })
      //导出为excel
      this.downloadLoading = true
      require.ensure([], () => {
      const { export_json_to_excel } = require("@/assets/excel/Export2Excel.js"); //这里必须使用绝对路径，使用@/+存放export2Excel的路径
      // let list = this.$refs.excelDom.dataTabel;
      let data = list.map((v) => filterVal.map((j) => v[j]));//3.formatJson格式转换
      export_json_to_excel(tHeader, data, title); // (title)导出的表格名称
    });
    }
  },
}