订单Excel导入增加追加导入功能

This commit is contained in:
2025-05-14 09:31:00 +08:00
parent 2a91e4961d
commit db1048412f

View File

@@ -46,22 +46,16 @@
<el-button type="success" plain icon="download" @click="handleExport">{{ $t('btn.export') }}</el-button> <el-button type="success" plain icon="download" @click="handleExport">{{ $t('btn.export') }}</el-button>
</el-col> </el-col>
<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-col :span="1.5">
<el-button type="warning" plain icon="upload" @click="addImportDialog">追加导入</el-button> <el-button type="warning" plain icon="upload" @click="addImportDialog">追加{{ $t('btn.import') }}</el-button>
</el-col> </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>
<el-table <el-table :data="dataList" v-loading="loading" border header-cell-class-name="el-table-header-cell" highlight-current-row @sort-change="sortChange">
:data="dataList"
v-loading="loading"
border
header-cell-class-name="el-table-header-cell"
highlight-current-row
@sort-change="sortChange">
<el-table-column <el-table-column
prop="orderNoMes" prop="orderNoMes"
label="订单扫描号" label="订单扫描号"
@@ -81,13 +75,7 @@
<dict-tag :options="options.statusOptions" :value="scope.row.status" /> <dict-tag :options="options.statusOptions" :value="scope.row.status" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="variety" label="品种" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('variety')" min-width="100" />
prop="variety"
label="品种"
align="center"
:show-overflow-tooltip="true"
v-if="columns.showColumn('variety')"
min-width="100" />
<el-table-column <el-table-column
prop="materialName" prop="materialName"
label="物料" label="物料"
@@ -103,12 +91,7 @@
v-if="columns.showColumn('materialCode')" v-if="columns.showColumn('materialCode')"
min-width="120" /> min-width="120" />
<el-table-column prop="demandQuantity" label="需求数量" align="center" v-if="columns.showColumn('demandQuantity')" min-width="100" /> <el-table-column prop="demandQuantity" label="需求数量" align="center" v-if="columns.showColumn('demandQuantity')" min-width="100" />
<el-table-column <el-table-column prop="deliveryDate" label="交货日期" :show-overflow-tooltip="true" v-if="columns.showColumn('deliveryDate')" min-width="120" />
prop="deliveryDate"
label="交货日期"
:show-overflow-tooltip="true"
v-if="columns.showColumn('deliveryDate')"
min-width="120" />
<el-table-column prop="startDate" label="基本开始日期" :show-overflow-tooltip="true" v-if="columns.showColumn('startDate')" min-width="120" /> <el-table-column prop="startDate" label="基本开始日期" :show-overflow-tooltip="true" v-if="columns.showColumn('startDate')" min-width="120" />
<el-table-column prop="endDate" label="基本结束日期" :show-overflow-tooltip="true" v-if="columns.showColumn('endDate')" min-width="120" /> <el-table-column prop="endDate" label="基本结束日期" :show-overflow-tooltip="true" v-if="columns.showColumn('endDate')" min-width="120" />
<el-table-column prop="deliveryQuantity" label="实际交货数量" align="center" v-if="columns.showColumn('deliveryQuantity')" min-width="120" /> <el-table-column prop="deliveryQuantity" label="实际交货数量" align="center" v-if="columns.showColumn('deliveryQuantity')" min-width="120" />
@@ -144,19 +127,8 @@
<dict-tag :options="options.kdTypeOptions" :value="scope.row.kdType" /> <dict-tag :options="options.kdTypeOptions" :value="scope.row.kdType" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="documentDate" label="单据日期" :show-overflow-tooltip="true" v-if="columns.showColumn('documentDate')" min-width="120" />
prop="documentDate" <el-table-column prop="seller" label="售达方" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('seller')" min-width="120" />
label="单据日期"
:show-overflow-tooltip="true"
v-if="columns.showColumn('documentDate')"
min-width="120" />
<el-table-column
prop="seller"
label="售达方"
align="center"
:show-overflow-tooltip="true"
v-if="columns.showColumn('seller')"
min-width="120" />
<el-table-column <el-table-column
prop="salesArea" prop="salesArea"
label="销售地区" label="销售地区"
@@ -164,13 +136,7 @@
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
v-if="columns.showColumn('salesArea')" v-if="columns.showColumn('salesArea')"
min-width="120" /> min-width="120" />
<el-table-column <el-table-column prop="remark" label="备注" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('remark')" min-width="150" />
prop="remark"
label="备注"
align="center"
:show-overflow-tooltip="true"
v-if="columns.showColumn('remark')"
min-width="150" />
<el-table-column <el-table-column
prop="createdBy" prop="createdBy"
label="创建人" label="创建人"
@@ -189,13 +155,7 @@
<el-table-column prop="updatedTime" label="更新时间" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedTime')" min-width="150" /> <el-table-column prop="updatedTime" label="更新时间" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedTime')" min-width="150" />
<el-table-column prop="id" label="雪花id" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('id')" min-width="150" /> <el-table-column prop="id" label="雪花id" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('id')" min-width="150" />
<el-table-column prop="importDate" label="导入日期" :show-overflow-tooltip="true" v-if="columns.showColumn('importDate')" min-width="120" /> <el-table-column prop="importDate" label="导入日期" :show-overflow-tooltip="true" v-if="columns.showColumn('importDate')" min-width="120" />
<el-table-column <el-table-column prop="poitem" label="编号" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('poitem')" min-width="100" />
prop="poitem"
label="编号"
align="center"
:show-overflow-tooltip="true"
v-if="columns.showColumn('poitem')"
min-width="100" />
<el-table-column label="操作" width="160" fixed="right"> <el-table-column label="操作" width="160" fixed="right">
<template #default="scope"> <template #default="scope">
<el-button type="success" size="small" icon="edit" title="编辑" @click="handleUpdate(scope.row)"></el-button> <el-button type="success" size="small" icon="edit" title="编辑" @click="handleUpdate(scope.row)"></el-button>
@@ -359,12 +319,11 @@
</el-dialog> </el-dialog>
<!-- 导入对话框 --> <!-- 导入对话框 -->
<el-dialog title="导入数据" :lock-scroll="false" v-model="importOpen" width="40%" center> <el-dialog :title="importTitle" :lock-scroll="false" v-model="importOpen" width="40%" center append-to-body :close-on-click-modal="false">
<el-upload <el-upload
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"
@@ -393,8 +352,6 @@ import {
importOrderPurchase, importOrderPurchase,
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({
@@ -492,7 +449,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 uploadType = ref(false)
const state = reactive({ const state = reactive({
form: {}, form: {},
rules: { rules: {
@@ -521,7 +478,7 @@ const title = ref('')
const opertype = ref(0) const opertype = ref(0)
const open = ref(false) const open = ref(false)
const importOpen = ref(false) const importOpen = ref(false)
const importTitle = ref('覆盖导入')
function getList() { function getList() {
loading.value = true loading.value = true
listOrderPurchase(queryParams).then((res) => { listOrderPurchase(queryParams).then((res) => {
@@ -642,6 +599,8 @@ function handleExport() {
function handleImportDialog() { function handleImportDialog() {
importOpen.value = true importOpen.value = true
importTitle.value = '覆盖导入'
uploadType.value = false
} }
const formData = ref(new FormData()) const formData = ref(new FormData())
@@ -652,22 +611,13 @@ 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) => {
console.log(options.file); const forData = new FormData()
console.log(uploadValue.value); forData.append('file', options.file)
const forData = new FormData(); forData.append('uploadType', uploadType.value)
forData.append('file', options.file);
forData.append('value', uploadValue.value)
importOrderPurchase(forData) importOrderPurchase(forData)
.then((response) => { .then((response) => {
if (response.code === 200) { if (response.code === 200) {
@@ -681,7 +631,6 @@ const uploadFile = (options) => {
} }
) )
getList() getList()
uploadValue.value=false;
} }
}) })
.catch((error) => { .catch((error) => {
@@ -697,9 +646,10 @@ function handleDownloadTemplate() {
}) })
} }
function addImportDialog(){ function addImportDialog() {
importOpen.value = true importOpen.value = true
value =true; importTitle.value = '追加导入'
uploadType.value = true
} }
handleQuery() handleQuery()
</script> </script>