|
@@ -1,58 +1,64 @@
|
|
|
<template>
|
|
|
- <el-upload :accept="accept" :action="action" :before-remove="delUploadData" :before-upload="beforeUpload" :data="uploadData"
|
|
|
- :disabled="uploadDisabled" :file-list="fileListData" :headers="getTokenHeader()" :on-error="uploadError"
|
|
|
- :on-exceed="uploadExceed" :on-preview="uploadPreview" :on-progress="uploadprogress"
|
|
|
- :on-remove="uploadRemove" :on-success="uploadSuccess" class="hc-upload-border"
|
|
|
- drag multiple>
|
|
|
+ <el-upload
|
|
|
+ :accept="accept" :action="action" :before-remove="delUploadData" :before-upload="beforeUpload" :data="uploadData"
|
|
|
+ :disabled="uploadDisabled" :file-list="fileListData" :headers="getTokenHeader()" :on-error="uploadError"
|
|
|
+ :on-exceed="uploadExceed" :on-preview="uploadPreview" :on-progress="uploadprogress"
|
|
|
+ :on-remove="uploadRemove" :on-success="uploadSuccess" class="hc-upload-border"
|
|
|
+ drag multiple
|
|
|
+ >
|
|
|
<div v-loading="uploadDisabled" :element-loading-text="loadingText" class="hc-upload-loading">
|
|
|
- <HcIcon name="backup" ui="text-5xl mt-4"/>
|
|
|
+ <HcIcon name="backup" ui="text-5xl mt-4" />
|
|
|
<div class="el-upload__text">拖动文件到这里 或 <em>点击这里选择文件</em> 并上传</div>
|
|
|
</div>
|
|
|
<template #tip>
|
|
|
- <div class="el-upload__tip" style="font-size: 14px;">允许格式:jpg/png/pdf/excel/word, 文件大小 小于 60MB
|
|
|
+ <div class="el-upload__tip" style="font-size: 14px;">
|
|
|
+ 允许格式:jpg/png/pdf/excel/word, 文件大小 小于 60MB
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-upload>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import {ref, watch, onMounted} from "vue";
|
|
|
-import {getTokenHeader} from '~src/api/request/header';
|
|
|
-import wbsApi from "~api/data-fill/wbs"
|
|
|
-import {isFileSize} from "js-fast-way"
|
|
|
+import { onMounted, ref, watch } from 'vue'
|
|
|
+import { getTokenHeader } from '~src/api/request/header'
|
|
|
+import wbsApi from '~api/data-fill/wbs'
|
|
|
+import { isFileSize } from 'js-fast-way'
|
|
|
+import { toPdfPage } from '~uti/btn-auth'
|
|
|
|
|
|
const props = defineProps({
|
|
|
fileList: {
|
|
|
type: Array,
|
|
|
- default: () => ([])
|
|
|
+ default: () => ([]),
|
|
|
},
|
|
|
datas: {
|
|
|
type: Object,
|
|
|
- default: () => ({})
|
|
|
+ default: () => ({}),
|
|
|
},
|
|
|
baseData: {
|
|
|
type: Object,
|
|
|
- default: () => ({})
|
|
|
+ default: () => ({}),
|
|
|
},
|
|
|
contractId: {
|
|
|
type: String,
|
|
|
- default: () => ('')
|
|
|
+ default: () => (''),
|
|
|
},
|
|
|
tableTypeValue: {
|
|
|
- type: String,Number,
|
|
|
- default: () => ('')
|
|
|
- }
|
|
|
+ type: String, Number,
|
|
|
+ default: () => (''),
|
|
|
+ },
|
|
|
})
|
|
|
|
|
|
+//事件
|
|
|
+const emit = defineEmits(['change'])
|
|
|
//变量
|
|
|
const uploadData = ref(props.datas)
|
|
|
-const fileListData = ref(props.fileList);
|
|
|
-const contractId = ref(props.contractId);
|
|
|
-const tableType = ref(props.tableTypeValue);
|
|
|
-const baseData = ref(props.baseData);
|
|
|
+const fileListData = ref(props.fileList)
|
|
|
+const contractId = ref(props.contractId)
|
|
|
+const tableType = ref(props.tableTypeValue)
|
|
|
+const baseData = ref(props.baseData)
|
|
|
|
|
|
-const action = '/api/blade-business/detection/self/add-buss-file';
|
|
|
-const accept = 'image/png,image/jpg,image/jpeg,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/pdf,.doc,.docx,application/msword';
|
|
|
+const action = '/api/blade-business/detection/self/add-buss-file'
|
|
|
+const accept = 'image/png,image/jpg,image/jpeg,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/pdf,.doc,.docx,application/msword'
|
|
|
const uploadDisabled = ref(false)
|
|
|
|
|
|
//监听
|
|
@@ -71,24 +77,21 @@ onMounted(() => {
|
|
|
errorFileNum.value = 0
|
|
|
})
|
|
|
|
|
|
-//事件
|
|
|
-const emit = defineEmits(['change'])
|
|
|
-
|
|
|
//上传前
|
|
|
const beforeFileNum = ref(0)
|
|
|
const beforeUpload = async (file) => {
|
|
|
if (isFileSize(file?.size, 60)) {
|
|
|
- beforeFileNum.value++;
|
|
|
- return true;
|
|
|
+ beforeFileNum.value++
|
|
|
+ return true
|
|
|
} else {
|
|
|
- window?.$message?.warning('文件大小, 不能过60M!');
|
|
|
- return false;
|
|
|
+ window?.$message?.warning('文件大小, 不能过60M!')
|
|
|
+ return false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//超出限制时
|
|
|
const uploadExceed = () => {
|
|
|
- window?.$message?.warning('请上传 jpg/png/pdf/excel/word 的文件,文件大小 不超过60M');
|
|
|
+ window?.$message?.warning('请上传 jpg/png/pdf/excel/word 的文件,文件大小 不超过60M')
|
|
|
}
|
|
|
|
|
|
//上传中
|
|
@@ -101,45 +104,46 @@ const uploadprogress = () => {
|
|
|
//上传完成
|
|
|
const finishFileNum = ref(0)
|
|
|
const uploadSuccess = () => {
|
|
|
- finishFileNum.value++;
|
|
|
+ finishFileNum.value++
|
|
|
if (beforeFileNum.value === finishFileNum.value) {
|
|
|
uploadDisabled.value = false
|
|
|
- emit('change', {type: 'success'})
|
|
|
+ emit('change', { type: 'success' })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//上传失败
|
|
|
const errorFileNum = ref(0)
|
|
|
const uploadError = (data) => {
|
|
|
- let errInfo=JSON.parse(data['message'])
|
|
|
+ let errInfo = JSON.parse(data['message'])
|
|
|
|
|
|
- window?.$message?.error(errInfo['msg']);
|
|
|
- errorFileNum.value++;
|
|
|
+ window?.$message?.error(errInfo['msg'])
|
|
|
+ errorFileNum.value++
|
|
|
|
|
|
- const num = finishFileNum.value + errorFileNum.value;
|
|
|
+ const num = finishFileNum.value + errorFileNum.value
|
|
|
if (beforeFileNum.value === num) {
|
|
|
uploadDisabled.value = false
|
|
|
- emit('change', {type: 'success'})
|
|
|
+ emit('change', { type: 'success' })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//预览
|
|
|
-const uploadPreview = ({url}) => {
|
|
|
- if (url) {
|
|
|
+const uploadPreview = ({ url }) => {
|
|
|
+ toPdfPage(url)
|
|
|
+ /*if (url) {
|
|
|
window.open(url, '_blank')
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
//删除文件
|
|
|
-const delUploadData = async ({id}) => {
|
|
|
+const delUploadData = async ({ id }) => {
|
|
|
loadingText.value = '删除中...'
|
|
|
uploadDisabled.value = true
|
|
|
- if(id){
|
|
|
- const {error, code} = await wbsApi.removeBussFile1({
|
|
|
+ if (id) {
|
|
|
+ const { error, code } = await wbsApi.removeBussFile1({
|
|
|
ids: id,
|
|
|
tableType: tableType.value,
|
|
|
contractId: contractId.value,
|
|
|
- id: baseData.value.id
|
|
|
+ id: baseData.value.id,
|
|
|
})
|
|
|
uploadDisabled.value = false
|
|
|
if (!error && code === 200) {
|
|
@@ -148,7 +152,7 @@ const delUploadData = async ({id}) => {
|
|
|
} else {
|
|
|
return false
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
loadingText.value = ''
|
|
|
uploadDisabled.value = false
|
|
|
}
|
|
@@ -157,7 +161,7 @@ const delUploadData = async ({id}) => {
|
|
|
|
|
|
const uploadRemove = () => {
|
|
|
if (fileListData.value.length <= 0) {
|
|
|
- emit('change', {type: 'del'})
|
|
|
+ emit('change', { type: 'del' })
|
|
|
}
|
|
|
}
|
|
|
</script>
|