对接比稿价导入
This commit is contained in:
parent
64c38d66e1
commit
54be2dc03b
BIN
public/比稿价导入示例模板.xlsx
Normal file
BIN
public/比稿价导入示例模板.xlsx
Normal file
Binary file not shown.
|
@ -37,4 +37,16 @@ export function getBusSupplierComparePrice(priceId) {
|
|||
url: '/admin/busSupplierComparePrice/getBusSupplierComparePrice/' + priceId,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
// 导入供应商比稿价详情
|
||||
export function importSupplierComparePrice(query) {
|
||||
return request({
|
||||
url: '/admin/busSupplierComparePrice/import',
|
||||
method: 'post',
|
||||
data: query,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
|
@ -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>仅允许导入xls、xlsx格式文件。</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)
|
||||
|
|
|
@ -231,7 +231,7 @@
|
|||
|
||||
</div>
|
||||
</template>
|
||||
<script setup name="Post">
|
||||
<script setup name="Post">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user