增加追加导入逻辑

This commit is contained in:
小魔仙 2025-05-13 10:46:50 +08:00
parent e18f095e82
commit 2a91e4961d

View File

@ -48,6 +48,10 @@
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="upload" @click="handleImportDialog">{{ $t('btn.import') }}</el-button> <el-button type="warning" plain icon="upload" @click="handleImportDialog">{{ $t('btn.import') }}</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="upload" @click="addImportDialog">追加导入</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
@ -360,6 +364,7 @@
ref="uploadRef" ref="uploadRef"
action="/mes/orderManagement/OrderPurchase/importData" action="/mes/orderManagement/OrderPurchase/importData"
accept=".xlsx, .xls" accept=".xlsx, .xls"
:data="{value: uploadValue}"
:before-upload="beforeUpload" :before-upload="beforeUpload"
:http-request="uploadFile" :http-request="uploadFile"
:auto-upload="false" :auto-upload="false"
@ -389,6 +394,7 @@ import {
downloadTemplate // API downloadTemplate // API
} from '@/api/orderPurchaseManagement/orderpurchase.js' } from '@/api/orderPurchaseManagement/orderpurchase.js'
var value = false;
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
import dayjs from 'dayjs' import dayjs from 'dayjs'
const queryParams = reactive({ const queryParams = reactive({
@ -486,7 +492,7 @@ const dataList = ref([])
const queryRef = ref() const queryRef = ref()
const loading = ref(false) const loading = ref(false)
const showSearch = ref(true) const showSearch = ref(true)
const uploadValue = ref(false)
const state = reactive({ const state = reactive({
form: {}, form: {},
rules: { rules: {
@ -646,11 +652,23 @@ const beforeUpload = (file) => {
} }
const uploadRef = ref(null) const uploadRef = ref(null)
const submitUpload = () => { const submitUpload = () => {
console.log(uploadRef.value );
if(value){
uploadValue.value=true;
value=false;
}
uploadRef.value.submit() uploadRef.value.submit()
} }
const uploadFile = (options) => { const uploadFile = (options) => {
importOrderPurchase(formData.value) console.log(options.file);
console.log(uploadValue.value);
const forData = new FormData();
forData.append('file', options.file);
forData.append('value', uploadValue.value)
importOrderPurchase(forData)
.then((response) => { .then((response) => {
if (response.code === 200) { if (response.code === 200) {
importOpen.value = false importOpen.value = false
@ -663,6 +681,7 @@ const uploadFile = (options) => {
} }
) )
getList() getList()
uploadValue.value=false;
} }
}) })
.catch((error) => { .catch((error) => {
@ -678,6 +697,10 @@ function handleDownloadTemplate() {
}) })
} }
function addImportDialog(){
importOpen.value = true
value =true;
}
handleQuery() handleQuery()
</script> </script>