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

Merge remote-tracking branch 'origin/master'

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