后端配置好模板
前端使用exportCsv
exportData() { var temp = JSON.parse(JSON.stringify(this.listParam)); //查询条件 temp.pageSize = -1; this.$api.Equipment.ShowData(temp).then(res => { this.listDataCsv = res.data.result.items; this.$refs.listCom.$refs.table.exportCsv({ filename: "设备设施", columns: this.columnsName.filter( (col, index) => index >= 0 && index < 8 ), // data: this.listDataCsv data: this.listDataCsv.filter((data, index) => { //所属系统 data.systemName = this.$helper.getTextByValue( "所属系统", data.systemName ); //所在房间 data.roomRowGuid = this.roomList.find(e => e.id === data.roomRowGuid) == undefined ? "--" : this.roomList.find(e => e.id === data.roomRowGuid).roomName; //设备型号 data.equipmentModel = data.equipmentModel != null && data.equipmentModel.indexOf("/") > 0 ? data.equipmentModel.replace("/", "") : "--"; //厂商信息 data.manufacturer = data.manufacturer != null && data.manufacturer != undefined && data.manufacturer != "" ? data.manufacturer : "--"; return data; }) }); }); }