mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-17 06:46:46 +08:00
style:调研改为评估
This commit is contained in:
@@ -30,9 +30,7 @@
|
||||
list-type="picture-card"
|
||||
class="avatar-uploader"
|
||||
:show-upload-list="false"
|
||||
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
||||
:before-upload="beforeUpload"
|
||||
@change="handleChange"
|
||||
>
|
||||
<!-- <img v-if="imageUrl" :src="imageUrl" alt="avatar" />
|
||||
<div v-else>
|
||||
@@ -48,12 +46,12 @@ import { reactive, toRefs } from "vue";
|
||||
import AddVote from "../../components/drawers/AddVote";
|
||||
// import { PlusOutlined, LoadingOutlined } from "@ant-design/icons-vue";
|
||||
import { message } from "ant-design-vue";
|
||||
|
||||
function getBase64(img, callback) {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener("load", () => callback(reader.result));
|
||||
reader.readAsDataURL(img);
|
||||
}
|
||||
import * as api from "../../api/index1";
|
||||
// function getBase64(img, callback) {
|
||||
// const reader = new FileReader();
|
||||
// reader.addEventListener("load", () => callback(reader.result));
|
||||
// reader.readAsDataURL(img);
|
||||
// }
|
||||
export default {
|
||||
name: "SystemManage",
|
||||
components: {
|
||||
@@ -78,16 +76,29 @@ export default {
|
||||
};
|
||||
const handleChange = (info) => {
|
||||
if (info.file.status === "uploading") {
|
||||
console.log("uploading", info.file);
|
||||
state.loading = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.file.status === "done") {
|
||||
console.log("done", info.file);
|
||||
let obj = {
|
||||
file: info.file,
|
||||
};
|
||||
api
|
||||
.uploadFile(obj)
|
||||
.then((res) => {
|
||||
console.log("res", res);
|
||||
})
|
||||
.then((err) => {
|
||||
console.log("err", err);
|
||||
});
|
||||
// Get this url from response in real world.
|
||||
getBase64(info.file.originFileObj, (base64Url) => {
|
||||
state.imageUrl = base64Url;
|
||||
state.loading = false;
|
||||
});
|
||||
// getBase64(info.file.originFileObj, (base64Url) => {
|
||||
// state.imageUrl = base64Url;
|
||||
// state.loading = false;
|
||||
// });
|
||||
}
|
||||
|
||||
if (info.file.status === "error") {
|
||||
@@ -97,6 +108,7 @@ export default {
|
||||
};
|
||||
|
||||
const beforeUpload = (file) => {
|
||||
console.log("file", file);
|
||||
const isJpgOrPng =
|
||||
file.type === "image/jpeg" || file.type === "image/png";
|
||||
|
||||
@@ -109,8 +121,25 @@ export default {
|
||||
if (!isLt2M) {
|
||||
message.error("Image must smaller than 2MB!");
|
||||
}
|
||||
|
||||
return isJpgOrPng && isLt2M;
|
||||
if (isJpgOrPng && isLt2M) {
|
||||
let obj = {
|
||||
file: file,
|
||||
};
|
||||
api
|
||||
.uploadFile(obj)
|
||||
.then((res) => {
|
||||
console.log("res", res);
|
||||
})
|
||||
.then((err) => {
|
||||
console.log("err", err);
|
||||
});
|
||||
// Get this url from response in real world.
|
||||
// getBase64(info.file.originFileObj, (base64Url) => {
|
||||
// state.imageUrl = base64Url;
|
||||
// state.loading = false;
|
||||
// });
|
||||
}
|
||||
// return isJpgOrPng && isLt2M;
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user