头像上传组件调整

This commit is contained in:
wangxuemei
2024-08-07 17:06:23 +08:00
parent 4e963fc9cf
commit 5adb182c1f
5 changed files with 164 additions and 16 deletions

View File

@@ -232,7 +232,20 @@
<a-radio :value="0">未认证</a-radio>
<a-radio :value="1">已认证</a-radio>
<span> <a-button type="text" class="moreidbtn" v-if="formParam.certStatus==1">上传凭证</a-button></span>
<span>
<a-upload
multiple
:headers="headers"
:show-upload-list="false"
:before-upload="beforeUpload2"
>
<a-button type="text" class="moreidbtn" v-if="formParam.certStatus==1">上传凭证</a-button>
</a-upload>
<!-- <span>
支持.pdf,.ppt,.pptx,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.gif,.zip
</span> -->
</span>
</a-radio-group>
<!-- <FJUpload v-if="formParam.certStatus==1" v-model:value="formParam.workEnclosureAddress"/> -->
</a-form-item>
@@ -349,7 +362,7 @@
</div>
</a-modal>
</div>
<AddContent v-model:showContent="showContent" @AddContentList="AddContentList" />
<AddContent v-model:showContent="showContent" @AddContentList="AddContentList" :Addtitle="Addtitle" />
<!-- <div> <Upload/> </div> -->
</div>
</template>
@@ -365,7 +378,8 @@ import Editor from "@/components/project/Editor";
import ProjectManager from "@/components/project/ProjectManagerNew";
import { message } from "ant-design-vue";
import { useRouter } from "vue-router";
import { getTeacherSystemList, getTeacherList, getPayRollPlace, getLevel, insertTeacher, deleteInTeacher, updateInTeacher, getTeacherById, updateTeacherState, getTeacherExpertise, getTeacherExpertiseByPid, infoteacher, fileUp } from "../../api/Lecturer";
import { getTeacherSystemList, getTeacherList, getPayRollPlace, getLevel, insertTeacher, deleteInTeacher, updateInTeacher, getTeacherById, updateTeacherState } from "../../api/Lecturer";
import { fileUp } from "../../api/indexEval";
import {getCookieForName} from "@/api/method";
// import {getProjSt} from "../../api/indexProjStu";
import AddContent from "../../components/project/AddContent.vue"
@@ -384,6 +398,7 @@ export default {
setup() {
const router = useRouter();
const state = reactive({
Addtitle:'选择教师专长',
showContent: false,
moreid: 1,
byPid: null,
@@ -435,6 +450,8 @@ export default {
activeName: 'first'
})
const headers = { token: getCookieForName("token") };
//图片上传
const imageUrl = ref('')
const beforeUpload = (file) => {
const isJpgOrPng =
file.type === "image/jpg" ||
@@ -457,6 +474,7 @@ export default {
const formDatas = new FormData();
formDatas.append("file", file);
console.log("file", file)
fileUp(formDatas).then((res) => {
if (res.data.code === 200) {
console.log(res.data.data, 45);
@@ -468,6 +486,47 @@ export default {
});
return false;
};
//附件上传
const beforeUpload2 = (file) => {
console.log(6765555);
console.log(file);
const fileType = [
"jpg",
"jpeg",
"png",
"gif",
"pdf",
"ppt",
"pptx",
"doc",
"docx",
"xls",
"xlsx",
"zip",
];
if (!fileType.includes(file.name.split(".")[1])) {
message.error(
"仅支持.pdf,.ppt,.pptx,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.gif,.zip格式!"
);
return false;
}
const formData = new FormData();
formData.append("file", file);
console.log(file);
fileUp(formData).then((res) => {
if (res.data.code === 200) {
state.imgList.push({
img: res.data.data,
name: file.name,
size: file.size,
});
console.log(state.imgList);
// state.hasImgName = res.data.data;
}
});
return false;
};
const LecturerSystemList = ref([
// { value: 0, systemName: "讲师体系" },
]);
@@ -1039,6 +1098,7 @@ console.log( "讲师体系id" +val);
managerChange,
headers,
beforeUpload,
imageUrl,
handlemoreid,
// changeSelect,
handleExport,
@@ -1078,6 +1138,7 @@ console.log( "讲师体系id" +val);
getinfoteacher,
addContentData,
AddContentList,
beforeUpload2,
}
},
};