| | |
| | | }, |
| | | openDialog() { |
| | | this.$axios.get(this.$api.deviceScope.treeDevice).then(res => { |
| | | this.cascaderList = res.data; |
| | | this.cascaderList = res.data |
| | | }); |
| | | this.$nextTick(() => { |
| | | this.$refs['form'].clearValidate() |
| | |
| | | downLoadPost(row) { |
| | | this.$axios.get(this.$api.facilitiesAndEnvironment.exportFeIllumination + '?intensityIlluminationId=' + row.intensityIlluminationId,{responseType: "blob"}).then(res => { |
| | | this.outLoading = false |
| | | this.$message.success('导出成功') |
| | | const blob = new Blob([res],{ type: 'application/msword' }); |
| | | const url = URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = '照度记录' + '.docx'; |
| | | link.click(); |
| | | //将Blob 对象转换成字符串 |
| | | let reader = new FileReader(); |
| | | reader.readAsText(blob, 'utf-8'); |
| | | reader.onload = () => { |
| | | try { |
| | | let result = JSON.parse(reader.result); |
| | | if (result.message) { |
| | | this.$message.error(result.message); |
| | | } else { |
| | | const url = URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = '照度记录' + '.docx'; |
| | | link.click(); |
| | | this.$message.success('导出成功') |
| | | } |
| | | } catch (err) { |
| | | console.log(err); |
| | | const url = URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = '照度记录' + '.docx'; |
| | | link.click(); |
| | | this.$message.success('导出成功') |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | } |