|
@@ -50,7 +50,7 @@
|
|
|
</label>
|
|
|
|
|
|
|
|
|
- <input type="file" accept=".zip" ref="files" id="files" @change="uploadPic">
|
|
|
+ <input type="file" ref="files" id="files" @change="uploadPic">
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
@@ -80,12 +80,36 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ downloadIamge(imgsrc, name) { //下载图片地址和图片名
|
|
|
+ let image = new Image();
|
|
|
+ // 解决跨域 Canvas 污染问题
|
|
|
+ image.setAttribute("crossOrigin", "anonymous");
|
|
|
+ image.onload = function () {
|
|
|
+ let canvas = document.createElement("canvas");
|
|
|
+ canvas.width = image.width;
|
|
|
+ canvas.height = image.height;
|
|
|
+ let context = canvas.getContext("2d");
|
|
|
+ context.drawImage(image, 0, 0, image.width, image.height);
|
|
|
+ let url = canvas.toDataURL("image/png"); //得到图片的base64编码数据
|
|
|
+ let a = document.createElement("a"); // 生成一个a元素
|
|
|
+ let event = new MouseEvent("click"); // 创建一个单击事件
|
|
|
+ a.download = name || "photo"; // 设置图片名称
|
|
|
+ a.href = url; // 将生成的URL设置为a.href属性
|
|
|
+ a.dispatchEvent(event); // 触发a的单击事件
|
|
|
+ };
|
|
|
+ image.src = imgsrc;
|
|
|
+ },
|
|
|
downloadMap() {
|
|
|
axios.get(`/indoor/${sceneNum}/api/tiled_maps/download`).then(res => {
|
|
|
- console.log(this.downloadUrl + res.data.msg)
|
|
|
+ // console.log(res)
|
|
|
+ // console.log(this.downloadUrl + res.data.msg)
|
|
|
|
|
|
if (res.data.code == 0) {
|
|
|
- window.location.href = this.downloadUrl + res.data.msg
|
|
|
+ var name = res.data.msg.split('/')[res.data.msg.split('/').length - 1]
|
|
|
+ var file = this.downloadUrl + res.data.msg
|
|
|
+ // console.log(name)
|
|
|
+ this.downloadIamge(file, name)
|
|
|
+ // window.location.href = this.downloadUrl + res.data.msg
|
|
|
} else {
|
|
|
this.$message({
|
|
|
message: res.data.msg,
|
|
@@ -141,7 +165,7 @@
|
|
|
axios.get(`/indoor/${sceneNum}/api/tiled_maps/updateDisplay/${this.info.display}`).then(res => {
|
|
|
|
|
|
if (res.data.code == 0) {
|
|
|
-
|
|
|
+
|
|
|
IV.api.AuthenticationService.sendAuthenticationChanged()
|
|
|
} else {
|
|
|
this.$parent.hideLoading()
|
|
@@ -173,14 +197,14 @@
|
|
|
uploadPic(e) {
|
|
|
let file = e.target.files[0]
|
|
|
console.log(file)
|
|
|
- if (!this.isZip(file)) {
|
|
|
- this.$message({
|
|
|
- message: '请上传zip格式',
|
|
|
- type: 'error',
|
|
|
- duration: 2000,
|
|
|
- });
|
|
|
- return
|
|
|
- }
|
|
|
+ // if (!this.isZip(file)) {
|
|
|
+ // this.$message({
|
|
|
+ // message: '请上传zip格式',
|
|
|
+ // type: 'error',
|
|
|
+ // duration: 2000,
|
|
|
+ // });
|
|
|
+ // return
|
|
|
+ // }
|
|
|
let params = new FormData()
|
|
|
params.append('file', file)
|
|
|
this.$parent.showLoading('上传中...')
|
|
@@ -189,7 +213,7 @@
|
|
|
let file = this.$refs.files
|
|
|
file.value = ''
|
|
|
if (res.data.code == 0) {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
this.$message({
|
|
|
message: '上传成功',
|