Commit 2654f046 authored by 赵啸非's avatar 赵啸非

Merge remote-tracking branch 'origin/master'

parents ddadaa3e d0e1b86a
......@@ -395,12 +395,13 @@ export default {
let { uid } = info.file;
if (code === 1) {
let obj = {
uid: uid,
uid,
name: fileName,
status: "done",
materialName: this.form.materialName,
fileName: fileName,
fileUrl: this.apiUrl + url,
url,
fileUrl: url,
filetype: num,
source: 1,
};
......
......@@ -12,8 +12,8 @@
:columns="columns"
:data-source="tableData"
>
<template slot="action" slot-scope="text">
<a @click="handleClick(text)">下载</a>
<template slot="action" slot-scope="text, record">
<a :href="record.fileUrl" :download="record.fileName">下载</a>
</template>
</a-table>
</a-modal>
......@@ -21,7 +21,7 @@
</template>
<script>
import { download } from "@/services/matter";
// import { download } from "@/services/matter";
// import axios from "axios";
const columns = [
{
......@@ -70,63 +70,60 @@ export default {
},
},
methods: {
downloadByBlob(url, name) {
let image = new Image();
image.setAttribute("crossOrigin", "anonymous");
image.src = url;
image.onload = () => {
let canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
let ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, image.width, image.height);
canvas.toBlob((blob) => {
let url = URL.createObjectURL(blob);
this.download(url, name);
// 用完释放URL对象
URL.revokeObjectURL(url);
});
};
},
download(href, name) {
let eleLink = document.createElement("a");
eleLink.style = "display: none";
eleLink.download = name;
eleLink.href = href;
document.body.appendChild(eleLink);
eleLink.click();
eleLink.remove();
},
async downloadFile(row, type) {
let res = await download(
{ datumId: row.datumId },
{ responseType: "blob" }
);
let data = res.data;
const blob = new Blob([data], {
type: type,
});
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.setAttribute("download", row.fileName); // 设置下载文件名称
document.body.appendChild(link);
link.click();
link.remove();
},
handleClick(row) {
let index = row.fileUrl.lastIndexOf(".");
let str = row.fileUrl.slice(index + 1);
if (str === "png" || str === "jpg" || str === "jpeg") {
this.downloadByBlob(row.fileUrl, row.fileName);
} else {
this.download(row.fileUrl, row.fileName);
}
},
// downloadByBlob(url, name) {
// let image = new Image();
// image.setAttribute("crossOrigin", "anonymous");
// image.src = url;
// image.onload = () => {
// let canvas = document.createElement("canvas");
// canvas.width = image.width;
// canvas.height = image.height;
// let ctx = canvas.getContext("2d");
// ctx.drawImage(image, 0, 0, image.width, image.height);
// canvas.toBlob((blob) => {
// let url = URL.createObjectURL(blob);
// this.download(url, name);
// // 用完释放URL对象
// URL.revokeObjectURL(url);
// });
// };
// },
// download(href, name) {
// let eleLink = document.createElement("a");
// eleLink.style = "display: none";
// eleLink.download = name;
// eleLink.href = href;
// document.body.appendChild(eleLink);
// eleLink.click();
// eleLink.remove();
// },
// async downloadFile(row, type) {
// let res = await download(
// { datumId: row.datumId },
// { responseType: "blob" }
// );
// let data = res.data;
// const blob = new Blob([data], {
// type: type,
// });
// const link = document.createElement("a");
// link.href = URL.createObjectURL(blob);
// link.setAttribute("download", row.fileName); // 设置下载文件名称
// document.body.appendChild(link);
// link.click();
// link.remove();
// },
// handleClick(row) {
// let index = row.fileUrl.lastIndexOf(".");
// let str = row.fileUrl.slice(index + 1);
// if (str === "png" || str === "jpg" || str === "jpeg") {
// this.downloadByBlob(row.fileUrl, row.fileName);
// } else {
// this.download(row.fileUrl, row.fileName);
// }
// },
},
};
</script>
<style lang="less" scoped>
</style>
\ No newline at end of file
<style lang="less" scoped></style>
......@@ -49,8 +49,8 @@
<img
class="cover"
v-if="text.cover"
:src="api2 + text.cover"
@click="handlePreview(api2 + text.cover)"
:src="text.cover"
@click="handlePreview(text.cover)"
/>
<span v-else>--</span>
</template>
......@@ -132,8 +132,6 @@ export default {
},
data() {
return {
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
columns,
siteId: local.getLocal("siteId"),
tableData: [], // 表格数据
......
......@@ -56,8 +56,8 @@
class="pointer"
height="20"
width="20"
:src="api2 + text.appIconPath"
@click="handlePreview(api2 + text.appIconPath)"
:src="text.appIconPath"
@click="handlePreview(text.appIconPath)"
/>
<span v-else>--</span>
</template>
......@@ -203,7 +203,6 @@ export default {
data() {
return {
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
columns,
siteId: local.getLocal("siteId"),
tableData: [], // 表格数据
......
......@@ -56,8 +56,8 @@
class="pointer"
height="20"
width="20"
:src="api2 + text.appIconPath"
@click="handlePreview(api2 + text.appIconPath)"
:src="text.appIconPath"
@click="handlePreview(text.appIconPath)"
/>
<span v-else>--</span>
</template>
......@@ -203,7 +203,6 @@ export default {
data() {
return {
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
columns,
siteId: local.getLocal("siteId"),
tableData: [], // 表格数据
......
......@@ -182,7 +182,6 @@ export default {
return {
accept: "image/jpeg,image/png,image/svg+xml",
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
iconFileList: [],
labelCol: {
span: 3,
......@@ -307,17 +306,25 @@ export default {
return isJpgOrPng && isLt5M;
},
// 上传图标
handleChangeIcon({ fileList }) {
handleChangeIcon({ file, fileList }) {
if (
file.status &&
file.status != "removed" &&
file.response &&
file.response.code == -1
) {
this.$message.error(file.response.msg);
fileList = fileList.filter((file) => file.response.code != -1);
}
this.iconFileList = [...fileList].slice(-1);
this.iconFileList = this.iconFileList.map((v) => {
if (v.response) {
v.url2 = v.response.url;
v.url = this.api2 + v.response.url;
v.url = v.response.url;
}
return v;
});
if (this.iconFileList[0]) {
this.form.appIconPath = this.iconFileList[0].url2;
this.form.appIconPath = this.iconFileList[0].url;
} else {
this.form.appIconPath = "";
}
......@@ -330,6 +337,17 @@ export default {
},
// 上传应用
handleChangeFile(info) {
if (
info.file.status &&
info.file.status != "removed" &&
info.file.response &&
info.file.response.code == -1
) {
this.$message.error(info.file.response.msg);
info.fileList = info.fileList.filter(
(file) => file.response.code != -1
);
}
let fileList = [...info.fileList];
fileList = fileList.slice(-1);
fileList = fileList.map((file) => {
......@@ -370,8 +388,7 @@ export default {
uid: "-2",
name: this.form.appIconPath,
status: "done",
url: this.api2 + this.form.appIconPath,
url2: this.form.appIconPath,
url: this.form.appIconPath,
},
];
});
......
......@@ -69,7 +69,6 @@ export default {
return {
accept: "image/jpeg,image/png",
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
fileList: [],
form: {
siteId: local.getLocal("siteId"), // 站点id
......@@ -117,8 +116,7 @@ export default {
uid: "-2",
name: this.form.cover,
status: "done",
url: this.api2 + this.form.cover,
url2: this.form.cover,
url: this.form.cover,
},
];
}
......@@ -158,17 +156,25 @@ export default {
return isJpgOrPng && isLt10M;
},
// 上传封面
handleChangeCover({ fileList }) {
handleChangeCover({ file, fileList }) {
if (
file.status &&
file.status != "removed" &&
file.response &&
file.response.code == -1
) {
this.$message.error(file.response.msg);
fileList = fileList.filter((file) => file.response.code != -1);
}
this.fileList = [...fileList].slice(-1);
this.fileList = this.fileList.map((v) => {
if (v.response) {
v.url2 = v.response.url;
v.url = this.api2 + v.response.url;
v.url = v.response.url;
}
return v;
});
if (this.fileList[0]) {
this.form.cover = this.fileList[0].url2;
this.form.cover = this.fileList[0].url;
} else {
this.form.cover = "";
}
......
......@@ -56,16 +56,13 @@
<!-- 模块图标 -->
<template slot="modelIcon" slot-scope="text">
<div v-if="text.modelIcon">
<!-- <div class="svg-box" v-if="isSvg(text.modelIcon)">
<img width="30" height="30" :src="api2 + text.modelIcon" />
</div> -->
<div class="svg-box">
<img
class="pointer"
width="30"
height="30"
:src="api2 + text.modelIcon"
@click="handlePreview({ url: api2 + text.modelIcon })"
:src="text.modelIcon"
@click="handlePreview({ url: text.modelIcon })"
/>
</div>
</div>
......@@ -301,7 +298,6 @@ export default {
return {
pageSizeOptions,
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
accept: "image/jpeg,image/png,image/svg+xml", // 上传类型
columns,
loading: true,
......@@ -404,8 +400,7 @@ export default {
uid: -1,
status: "done",
name: this.formData.modelIcon,
url: this.api2 + this.formData.modelIcon,
url2: this.formData.modelIcon,
url: this.formData.modelIcon,
},
];
}
......@@ -471,13 +466,12 @@ export default {
this.fileList = [...fileList].slice(-1);
this.fileList = this.fileList.map((v) => {
if (v.response) {
v.url2 = v.response.url;
v.url = this.api2 + v.response.url;
v.url = v.response.url;
}
return v;
});
if (this.fileList[0]) {
this.formData.modelIcon = this.fileList[0].url2;
this.formData.modelIcon = this.fileList[0].url;
} else {
this.formData.modelIcon = "";
}
......
......@@ -347,7 +347,6 @@ export default {
// };
return {
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
accept: "image/jpeg,image/png", // 上传类型
loading: false,
options: regionData, // 地区级联数据
......@@ -634,8 +633,7 @@ export default {
uid: -1,
status: "done",
name: this.formInfo.logoPath,
url: this.api2 + this.formInfo.logoPath,
url2: this.formInfo.logoPath,
url: this.formInfo.logoPath,
},
];
}
......@@ -680,17 +678,25 @@ export default {
return isJpgOrPng && isLt10M;
},
// 上传图片
handleChange({ fileList }) {
handleChange({ file, fileList }) {
if (
file.status &&
file.status != "removed" &&
file.response &&
file.response.code == -1
) {
this.$message.error(file.response.msg);
fileList = fileList.filter((file) => file.response.code != -1);
}
this.fileList = [...fileList].slice(-1);
this.fileList = this.fileList.map((v) => {
if (v.response) {
v.url2 = v.response.url;
v.url = this.api2 + v.response.url;
v.url = v.response.url;
}
return v;
});
if (this.fileList[0]) {
this.formInfo.logoPath = this.fileList[0].url2;
this.formInfo.logoPath = this.fileList[0].url;
} else {
this.formInfo.logoPath = "";
}
......
......@@ -183,9 +183,11 @@ export default {
// 文件上传
handleUpload({ file }) {
if (file.status === "done") {
let { code, url } = file.response;
let { code, url, msg } = file.response;
if (code == 1) {
this.form.paramValue = url;
} else {
this.$message.error(msg);
}
}
},
......
......@@ -385,7 +385,6 @@ export default {
};
return {
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
accept: "image/jpeg,image/png", // 上传类型
fileList: [],
loading: false,
......@@ -541,8 +540,7 @@ export default {
uid: -1,
status: "done",
name: this.form.photoPath,
url: this.api2 + this.form.photoPath,
url2: this.form.photoPath,
url: this.form.photoPath,
},
];
}
......@@ -564,17 +562,25 @@ export default {
this.$refs.formData.resetFields();
},
// 照片上传
handleChange({ fileList }) {
handleChange({ file, fileList }) {
if (
file.status &&
file.status != "removed" &&
file.response &&
file.response.code == -1
) {
this.$message.error(file.response.msg);
fileList = fileList.filter((file) => file.response.code != -1);
}
this.fileList = [...fileList].slice(-1);
this.fileList = this.fileList.map((v) => {
if (v.response) {
v.url2 = v.response.url;
v.url = this.api2 + v.response.url;
v.url = v.response.url;
}
return v;
});
if (this.fileList[0]) {
this.form.photoPath = this.fileList[0].url2;
this.form.photoPath = this.fileList[0].url;
} else {
this.form.photoPath = "";
}
......
......@@ -582,7 +582,7 @@ export default {
uid: -1,
status: "done",
name: this.form.photoPath,
url: this.api2 + this.form.photoPath,
url: this.form.photoPath,
url2: this.form.photoPath,
},
];
......@@ -599,17 +599,26 @@ export default {
},
// 照片上传
handleChange({ fileList }) {
handleChange({ file, fileList }) {
if (
file.status &&
file.status != "removed" &&
file.response &&
file.response.code == -1
) {
this.$message.error(file.response.msg);
fileList = fileList.filter((file) => file.response.code != -1);
}
this.fileList = [...fileList].slice(-1);
this.fileList = this.fileList.map((v) => {
if (v.response) {
v.url2 = v.response.url;
v.url = this.api2 + v.response.url;
// v.url2 = v.response.url;
v.url = v.response.url;
}
return v;
});
if (this.fileList[0]) {
this.form.photoPath = this.fileList[0].url2;
this.form.photoPath = this.fileList[0].url;
} else {
this.form.photoPath = "";
}
......
......@@ -228,8 +228,8 @@
<template slot="pic" slot-scope="text">
<img
v-if="text.photoPath"
:src="api2 + text.photoPath"
@click="handlePreview(api2 + text.photoPath)"
:src="text.photoPath"
@click="handlePreview(text.photoPath)"
class="pht"
/>
......@@ -408,7 +408,6 @@ export default {
visibleEditPwd: false,
editVisible: false,
api: process.env.VUE_APP_API_BASE_URL + "/",
api2: process.env.VUE_APP_API_IMG_URL,
siteId: local.getLocal("siteId"),
deptData: [], // 部门数据
windowData: [], // 窗口数据
......
......@@ -49,6 +49,11 @@ module.exports = {
},
// cookieDomainRewrite: 'localhost',
},
"/file": {
//此处要与 /services/api.js 中的 API_PROXY_PREFIX 值保持一致
target: process.env.VUE_APP_API_BASE_URL,
changeOrigin: true,
},
},
},
pluginOptions: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment