This commit is contained in:
weipengfei 2023-09-02 18:34:47 +08:00
parent 03979613f3
commit bb2f84a630

View File

@ -380,16 +380,21 @@
</el-card> </el-card>
<el-card> <el-card>
<el-form label-width="100px"> <el-form label-width="100px">
<el-form-item v-if="isshow" label="合同上传" prop="field127"> <el-form-item
v-if="isshow || formData?.status == 0"
label="合同上传"
prop="field127"
>
<el-upload <el-upload
:headers="{ Token: userStore.token }" :headers="{ Token: userStore.token }"
v-model:file-list="fileList"
class="upload-demo" class="upload-demo"
:action="base_url + '/upload/file'" :action="base_url + '/upload/file'"
:on-success="handleAvatarSuccess_four" :on-success="handleAvatarSuccess_four"
multiple :before-upload="handleBeforeUpload"
:limit="1" :limit="1"
v-if="+formData?.check_status < 3" v-if="formData?.status == 0"
:on-exceed="handleExceed"
ref="upload"
> >
<el-button type="primary">{{ <el-button type="primary">{{
formData.file ? "重新上传" : "上传" formData.file ? "重新上传" : "上传"
@ -403,10 +408,10 @@
>合同已上传,点击查看</a >合同已上传,点击查看</a
> >
</el-form-item> </el-form-item>
<el-form-item v-if="isshow"> <el-form-item v-if="isshow || formData.status == 0">
<el-button type="primary" @click="submitContract">确定</el-button> <el-button type="primary" @click="submitContract">确定</el-button>
</el-form-item> </el-form-item>
<el-form-item v-else-if="formData.file"> <el-form-item v-else-if="formData.file && formData.status">
<a <a
v-if="formData.file" v-if="formData.file"
style="margin-left: 10px; color: #4a5dff" style="margin-left: 10px; color: #4a5dff"
@ -431,6 +436,7 @@ import { ref, reactive, defineExpose, computed, inject } from "vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { dictDataLists } from "@/api/setting/dict"; import { dictDataLists } from "@/api/setting/dict";
import { upContact } from "@/api/consumer"; import { upContact } from "@/api/consumer";
import { genFileId } from "element-plus";
const { query } = useRoute(); const { query } = useRoute();
import useUserStore from "@/stores/modules/user"; import useUserStore from "@/stores/modules/user";
import useMultipleTabs from "@/hooks/useMultipleTabs"; import useMultipleTabs from "@/hooks/useMultipleTabs";
@ -509,6 +515,23 @@ async function render() {
} }
} }
const handleBeforeUpload = (e: any) => {
if (e?.name?.substring(e.name.length - 4, e.name.length) != ".pdf") {
ElMessage.error("仅支持上传.pdf文件");
return false;
}
return true;
};
const upload = ref(null);
const handleExceed = (files: any) => {
upload.value!.clearFiles();
const file = files[0] as UploadRawFile;
file.uid = genFileId();
upload.value!.handleStart(file);
upload.value!.submit();
};
const handleAvatarSuccess_four: UploadProps["onSuccess"] = ( const handleAvatarSuccess_four: UploadProps["onSuccess"] = (
response, response,
uploadFile uploadFile