Commit 3b929b2c by wuqian

导入模板修改

parent 8046b71d
......@@ -17,6 +17,10 @@
/>
<div class="custom-tip">
<span>请上传Excel文件(.xls 或 .xlsx)</span>
<div class="down-load" @click="downloadTemplate">
<el-icon><Download /></el-icon>
<span> 下载{{ importName }}模板</span>
</div>
</div>
</div>
<div v-if="fileList.length > 0">
......@@ -54,7 +58,12 @@ import {
computed,
defineExpose,
} from 'vue'
import { UploadFilled, Document, Close } from '@element-plus/icons-vue'
import {
UploadFilled,
Document,
Close,
Download,
} from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { uploadFileApi } from '@/api/common'
interface FileItem {
......@@ -64,6 +73,8 @@ interface FileItem {
const props = defineProps<{
modelValue: string
importType: string
importName: string
importUrl:string
}>()
const emit = defineEmits(['update:modelValue', 'imported'])
......@@ -149,7 +160,6 @@ const onFileChange = async (e: Event) => {
emit('imported', { path: file.name, data: jsonData })
fileList.value = [{ path: file.name, filename: file.name }]
value.value = file.name || ''
ElMessage.success('导入成功')
loading.value = false
}
reader.readAsBinaryString(file)
......@@ -189,7 +199,20 @@ const fileUpload = async (file: File) => {
loading.value = false
}
}
const downloadTemplate = () => {
// 获取当前日期
const currentDate = new Date()
const year = currentDate.getFullYear()
const month = String(currentDate.getMonth() + 1).padStart(2, '0') // 月份从0开始,需要加1
const day = String(currentDate.getDate()).padStart(2, '0')
// 生成文件名
const fileName = `${props.importName}模板_${year}${month}${day}.xlsx`
// 设置链接的href和download属性
const link = document.createElement('a')
link.href = props.importUrl // 服务器上的文件路径
link.download = fileName // 设置下载文件的文件名
link.click() // 触发下载
}
const removeFile = (idx: number) => {
fileList.value.splice(idx, 1)
value.value = ''
......@@ -262,9 +285,17 @@ const removeFile = (idx: number) => {
display: flex;
align-items: center;
color: #666;
margin-top: 12px;
i {
margin-right: 6px;
padding-top: 15px;
.down-load {
display: flex;
align-items: center;
color: #409eff;
text-decoration: none;
}
.down-load:hover {
cursor: pointer;
text-decoration: underline; /* 鼠标划过时添加下划线 */
}
}
}
......
......@@ -395,21 +395,17 @@
</div>
<ElDialog
v-model="importDialogVisible"
title="导入"
title="导入出库单"
width="500px"
:close-on-click-modal="false"
>
<div class="import-dialog">
<div class="import-header">
<el-button type="primary" link @click="downloadTemplate">
<el-icon><Download /></el-icon>
下载模板
</el-button>
</div>
<div class="import-dialog">
<div class="import-content">
<UploadExcel
v-model="importedFileUrl"
:import-type="'localAndXlsx'"
:import-name="'出库单'"
:import-url="'/files/outboundOrder.xlsx'"
@imported="handleLocalImport"
/>
</div>
......@@ -797,7 +793,7 @@
<script setup lang="ts">
import { ElMessage, ElRadioGroup, ElTree } from 'element-plus'
import { CirclePlusFilled,Download } from '@element-plus/icons-vue'
import { CirclePlusFilled } from '@element-plus/icons-vue'
import splitDiv from '@/components/splitDiv/splitDiv.vue'
import { ElTable } from 'element-plus'
import usePageList from '@/utils/hooks/usePageList'
......@@ -957,14 +953,6 @@ function getStartTime() {
const day = date.getDate()
return `${year}-${month}-${day} 00:00:00`
}
const downloadTemplate = () => {
const link = document.createElement('a')
link.href = '/files/outboundOrder.xlsx'
link.download = 'outboundOrder.xlsx'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
const selectSku = ref('')
const treeData = ref<InterWarehouseTree[]>()
const [searchForm, resetSearchForm] = useValue<warehouseSearchForm>({})
......@@ -1999,11 +1987,6 @@ $border: solid 1px #ddd;
}
.import-dialog {
.import-header {
display: flex;
justify-content: flex-end;
}
.import-content {
padding-bottom: 20px;
}
......
......@@ -14,7 +14,6 @@ import {
importWarehouseLocation,
} from '@/api/warehouse.ts'
const uploadExcelRef = ref()
import { Download } from '@element-plus/icons-vue'
import { nextTick, ref } from 'vue'
import SplitDiv from '@/components/splitDiv/splitDiv.vue'
import { filePath } from '@/api/axios.ts'
......@@ -55,14 +54,6 @@ const handleLocalImport = async ({
importedFileUrl.value = ''
}
}
const downloadTemplate = () => {
const link = document.createElement('a')
link.href = '/files/warehouseLocationTemplate.xlsx'
link.download = 'warehouseLocationTemplate.xlsx'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
// const importLoading = ref(false)
const searchForm = ref({
warehouseId: '',
......@@ -490,24 +481,20 @@ getWarehouse()
</el-card>
</template>
</split-div>
<ElDialog
<ElDialog
v-model="importDialogVisible"
title="导入"
title="导入库位"
width="500px"
:close-on-click-modal="false"
>
<div class="import-dialog">
<div class="import-header">
<el-button type="primary" link @click="downloadTemplate">
<el-icon><Download /></el-icon>
下载模板
</el-button>
</div>
<div class="import-dialog">
<div class="import-content">
<UploadExcel
ref="uploadExcelRef"
ref="uploadExcelRef"
v-model="importedFileUrl"
:import-type="'localAndUpload'"
:import-name="'库位'"
:import-url="'/files/warehouseLocationTemplate.xlsx'"
@imported="handleLocalImport"
/>
</div>
......
......@@ -427,21 +427,17 @@
</div>
<ElDialog
v-model="importDialogVisible"
title="导入"
title="导入入库单"
width="500px"
:close-on-click-modal="false"
>
<div class="import-dialog">
<div class="import-header">
<el-button type="primary" link @click="downloadTemplate">
<el-icon><Download /></el-icon>
下载模板
</el-button>
</div>
<div class="import-content">
<UploadExcel
v-model="importedFileUrl"
:import-type="'localAndXlsx'"
:import-name="'入库单'"
:import-url="'/files/warehousingEntry.xlsx'"
@imported="handleLocalImport"
/>
</div>
......@@ -827,7 +823,7 @@
<script setup lang="ts">
import { ElMessage, ElRadioGroup, ElTree } from 'element-plus'
import { CirclePlusFilled, Download } from '@element-plus/icons-vue'
import { CirclePlusFilled} from '@element-plus/icons-vue'
import splitDiv from '@/components/splitDiv/splitDiv.vue'
import { ElTable } from 'element-plus'
import usePageList from '@/utils/hooks/usePageList'
......@@ -987,14 +983,6 @@ function getStartTime() {
const day = date.getDate()
return `${year}-${month}-${day} 00:00:00`
}
const downloadTemplate = () => {
const link = document.createElement('a')
link.href = '/files/warehousingEntry.xlsx'
link.download = 'warehousingEntry.xlsx'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
const selectSku = ref('')
const treeData = ref<InterWarehouseTree[]>()
const [searchForm, resetSearchForm] = useValue<warehouseSearchForm>({})
......@@ -1156,7 +1144,7 @@ const excelFieldMap: Record<string, keyof InterProductList> = {
入库数量: 'buyStored',
// '成本价(¥)': 'costPrice',
// '总成本(¥)': 'totalPrice',
库位: 'locationCode',
库位编码: 'locationCode',
备注: 'remark',
}
......@@ -1223,11 +1211,9 @@ const handleLocalImport = async ({
const importedItem = importedData.find(
(item) => item.warehouseSku === skuItem.sku,
)
// console.log(skuItem,'importedItem', importedItem)
const target = locationList.value.find((item) => {
const target = locationList.value.find((item:InterProductList) => {
return item.locationCode == importedItem?.locationCode
})
// console.log(importedItem, '11111@', locationList.value, target)
return {
skuImage: skuItem.image,
warehouseSku: skuItem.sku,
......@@ -1972,11 +1958,6 @@ $border: solid 1px #ddd;
}
.import-dialog {
.import-header {
display: flex;
justify-content: flex-end;
}
.import-content {
padding-bottom: 20px;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment