对接比稿价导入

This commit is contained in:
wangchengming 2025-09-01 11:27:02 +08:00
parent 64c38d66e1
commit 54be2dc03b
4 changed files with 100 additions and 11 deletions

Binary file not shown.

View File

@ -38,3 +38,15 @@ export function getBusSupplierComparePrice(priceId) {
method: 'post'
})
}
// 导入供应商比稿价详情
export function importSupplierComparePrice(query) {
return request({
url: '/admin/busSupplierComparePrice/import',
method: 'post',
data: query,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}

View File

@ -3,9 +3,9 @@
<div class="searchPanel">
<el-form :inline="true" class="searchPanelForm">
<el-form-item label="供应商:">
<el-select class="filterSelect" v-model="queryParams.busSupplierId" filterable remote
reserve-keyword :remote-method="getSupplierList" :loading="selectLoading" placeholder="请输入"
remote-show-suffix clearable style="min-width: 70px;">
<el-select class="filterSelect" v-model="queryParams.supplierId" filterable remote reserve-keyword
:remote-method="getSupplierList" :loading="selectLoading" placeholder="请输入" remote-show-suffix
clearable style="min-width: 70px;">
<el-option v-for="item in supplierList" :key="item.supplierId" :label="item.supplierName"
:value="item.supplierId" />
</el-select>
@ -195,13 +195,39 @@
</div>
</template>
</el-dialog>
<!-- 导入对话框 -->
<el-dialog title="导入" v-model="uploadOpen" width="650px" class="my_dialog" align-center :destroy-on-close="true"
:close-on-click-modal="false">
<el-upload ref="uploadRef" class="upload-demo" drag action="#" :http-request="requestDocUpload"
:file-list="docUploadList" :before-upload="beforeDocUpload" :on-remove="removeDocUpload">
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">
将文件拖曳至此区域 <em>点击上传</em>
</div>
<!-- <div class="el-upload__text">
支持扩展名.xlsx, .xls
</div> -->
<template #tip>
<div class="el-upload__tip text-center">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" underline="never" style="font-size: 12px; vertical-align: baseline"
@click="importTemplate">下载示例模板</el-link>
</div>
</template>
</el-upload>
<template #footer>
<div class="dialog-footer">
<el-button class="my-cancel-btn" @click="uploadOpen = false"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="Post">
import { onMounted, ref } from 'vue';
import { listBusSupplier } from "@/api/supplier"
import { busSupplierComparePricePage, addBusSupplierComparePrice, updateBusSupplierComparePrice, deleteBusSupplierComparePrice, getBusSupplierComparePrice } from "@/api/pitchPrice"
import { busSupplierComparePricePage, addBusSupplierComparePrice, updateBusSupplierComparePrice, deleteBusSupplierComparePrice, getBusSupplierComparePrice, importSupplierComparePrice } from "@/api/pitchPrice"
import { useBackgroundStore } from '@/store/modules/background'
import otherbg from '@/assets/images/otherbg.png'
const bgStore = useBackgroundStore()
@ -219,6 +245,8 @@ const types = ref([
const title = ref('新建')
const open = ref(false)
const uploadOpen = ref(false)
const docUploadList = ref([])
const loading = ref(true)
const selectLoading = ref(false)
const total = ref(0)
@ -228,7 +256,7 @@ const data = reactive({
queryParams: {
pageIndex: 1,
pageSize: 10,
busSupplierId: undefined,
supplierId: undefined,
type: 1 //1- 2- 3-
},
rules: {
@ -311,11 +339,6 @@ const handleUpdate = (row) => {
})
}
//
const handleImport = () => {
}
const cancel = () => {
open.value = false
form.value = {}
@ -351,6 +374,58 @@ const handleDelete = (row) => {
}).catch(() => { })
}
//
const handleImport = () => {
uploadOpen.value = true
}
//
const requestDocUpload = (options) => {
proxy.$modal.loading('正在上传文件,请耐心等待...')
const { file } = options
var formData = new FormData();
formData.append('file', file);
importSupplierComparePrice(formData).then(res => {
console.log('接口接口', res)
if (res.code == 200) {
proxy.$modal.msgSuccess("导入成功")
proxy.$modal.closeLoading()
uploadOpen.value = false
getPitchPricePage()
} else {
console.log('接口异常', res)
proxy.$modal.closeLoading()
proxy.$modal.msgError(res.msg);
}
})
}
//
const beforeDocUpload = (file) => {
const type = [
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-excel'
];
const isXlsx = type.includes(file.type);
//
if (!isXlsx) {
proxy.$modal.msgError("文件格式错误,请上传.xls.xlsx后缀的文件。");
return false;
}
}
//
const removeDocUpload = (file, fileList) => {
docUploadList.value = docUploadList.value.filter(
item => item.name != file.name
);
}
//
const importTemplate = () => {
const link = document.createElement('a')
link.href = '/比稿价导入示例模板.xlsx'
link.download = '比稿价导入示例模板.xlsx' //
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
//
onMounted(() => {
bgStore.setBgImage(otherbg)

View File

@ -389,12 +389,14 @@ const requestDocUpload = (options) => {
var formData = new FormData();
formData.append('file', file);
importSupplier(formData).then(res => {
console.log('接口接口', res)
if (res.code == 200) {
proxy.$modal.msgSuccess("导入成功")
proxy.$modal.closeLoading()
uploadOpen.value = false
getSupplierPageList()
} else {
console.log('接口异常', res)
proxy.$modal.closeLoading()
proxy.$modal.msgError(res.msg);
}