Commit 3b929b2c by wuqian

导入模板修改

parent 8046b71d
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
/> />
<div class="custom-tip"> <div class="custom-tip">
<span>请上传Excel文件(.xls 或 .xlsx)</span> <span>请上传Excel文件(.xls 或 .xlsx)</span>
<div class="down-load" @click="downloadTemplate">
<el-icon><Download /></el-icon>
<span> 下载{{ importName }}模板</span>
</div>
</div> </div>
</div> </div>
<div v-if="fileList.length > 0"> <div v-if="fileList.length > 0">
...@@ -54,7 +58,12 @@ import { ...@@ -54,7 +58,12 @@ import {
computed, computed,
defineExpose, defineExpose,
} from 'vue' } 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 { ElMessage } from 'element-plus'
import { uploadFileApi } from '@/api/common' import { uploadFileApi } from '@/api/common'
interface FileItem { interface FileItem {
...@@ -64,6 +73,8 @@ interface FileItem { ...@@ -64,6 +73,8 @@ interface FileItem {
const props = defineProps<{ const props = defineProps<{
modelValue: string modelValue: string
importType: string importType: string
importName: string
importUrl:string
}>() }>()
const emit = defineEmits(['update:modelValue', 'imported']) const emit = defineEmits(['update:modelValue', 'imported'])
...@@ -149,7 +160,6 @@ const onFileChange = async (e: Event) => { ...@@ -149,7 +160,6 @@ const onFileChange = async (e: Event) => {
emit('imported', { path: file.name, data: jsonData }) emit('imported', { path: file.name, data: jsonData })
fileList.value = [{ path: file.name, filename: file.name }] fileList.value = [{ path: file.name, filename: file.name }]
value.value = file.name || '' value.value = file.name || ''
ElMessage.success('导入成功')
loading.value = false loading.value = false
} }
reader.readAsBinaryString(file) reader.readAsBinaryString(file)
...@@ -189,7 +199,20 @@ const fileUpload = async (file: File) => { ...@@ -189,7 +199,20 @@ const fileUpload = async (file: File) => {
loading.value = false 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) => { const removeFile = (idx: number) => {
fileList.value.splice(idx, 1) fileList.value.splice(idx, 1)
value.value = '' value.value = ''
...@@ -262,9 +285,17 @@ const removeFile = (idx: number) => { ...@@ -262,9 +285,17 @@ const removeFile = (idx: number) => {
display: flex; display: flex;
align-items: center; align-items: center;
color: #666; color: #666;
margin-top: 12px; padding-top: 15px;
i { .down-load {
margin-right: 6px; display: flex;
align-items: center;
color: #409eff;
text-decoration: none;
}
.down-load:hover {
cursor: pointer;
text-decoration: underline; /* 鼠标划过时添加下划线 */
} }
} }
} }
......
...@@ -395,21 +395,17 @@ ...@@ -395,21 +395,17 @@
</div> </div>
<ElDialog <ElDialog
v-model="importDialogVisible" v-model="importDialogVisible"
title="导入" title="导入出库单"
width="500px" width="500px"
:close-on-click-modal="false" :close-on-click-modal="false"
> >
<div class="import-dialog"> <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"> <div class="import-content">
<UploadExcel <UploadExcel
v-model="importedFileUrl" v-model="importedFileUrl"
:import-type="'localAndXlsx'" :import-type="'localAndXlsx'"
:import-name="'出库单'"
:import-url="'/files/outboundOrder.xlsx'"
@imported="handleLocalImport" @imported="handleLocalImport"
/> />
</div> </div>
...@@ -797,7 +793,7 @@ ...@@ -797,7 +793,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ElMessage, ElRadioGroup, ElTree } from 'element-plus' 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 splitDiv from '@/components/splitDiv/splitDiv.vue'
import { ElTable } from 'element-plus' import { ElTable } from 'element-plus'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
...@@ -957,14 +953,6 @@ function getStartTime() { ...@@ -957,14 +953,6 @@ function getStartTime() {
const day = date.getDate() const day = date.getDate()
return `${year}-${month}-${day} 00:00:00` 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 selectSku = ref('')
const treeData = ref<InterWarehouseTree[]>() const treeData = ref<InterWarehouseTree[]>()
const [searchForm, resetSearchForm] = useValue<warehouseSearchForm>({}) const [searchForm, resetSearchForm] = useValue<warehouseSearchForm>({})
...@@ -1999,11 +1987,6 @@ $border: solid 1px #ddd; ...@@ -1999,11 +1987,6 @@ $border: solid 1px #ddd;
} }
.import-dialog { .import-dialog {
.import-header {
display: flex;
justify-content: flex-end;
}
.import-content { .import-content {
padding-bottom: 20px; padding-bottom: 20px;
} }
......
...@@ -14,7 +14,6 @@ import { ...@@ -14,7 +14,6 @@ import {
importWarehouseLocation, importWarehouseLocation,
} from '@/api/warehouse.ts' } from '@/api/warehouse.ts'
const uploadExcelRef = ref() const uploadExcelRef = ref()
import { Download } from '@element-plus/icons-vue'
import { nextTick, ref } from 'vue' import { nextTick, ref } from 'vue'
import SplitDiv from '@/components/splitDiv/splitDiv.vue' import SplitDiv from '@/components/splitDiv/splitDiv.vue'
import { filePath } from '@/api/axios.ts' import { filePath } from '@/api/axios.ts'
...@@ -55,14 +54,6 @@ const handleLocalImport = async ({ ...@@ -55,14 +54,6 @@ const handleLocalImport = async ({
importedFileUrl.value = '' 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 importLoading = ref(false)
const searchForm = ref({ const searchForm = ref({
warehouseId: '', warehouseId: '',
...@@ -490,24 +481,20 @@ getWarehouse() ...@@ -490,24 +481,20 @@ getWarehouse()
</el-card> </el-card>
</template> </template>
</split-div> </split-div>
<ElDialog <ElDialog
v-model="importDialogVisible" v-model="importDialogVisible"
title="导入" title="导入库位"
width="500px" width="500px"
:close-on-click-modal="false" :close-on-click-modal="false"
> >
<div class="import-dialog"> <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"> <div class="import-content">
<UploadExcel <UploadExcel
ref="uploadExcelRef" ref="uploadExcelRef"
v-model="importedFileUrl" v-model="importedFileUrl"
:import-type="'localAndUpload'" :import-type="'localAndUpload'"
:import-name="'库位'"
:import-url="'/files/warehouseLocationTemplate.xlsx'"
@imported="handleLocalImport" @imported="handleLocalImport"
/> />
</div> </div>
......
...@@ -427,21 +427,17 @@ ...@@ -427,21 +427,17 @@
</div> </div>
<ElDialog <ElDialog
v-model="importDialogVisible" v-model="importDialogVisible"
title="导入" title="导入入库单"
width="500px" width="500px"
:close-on-click-modal="false" :close-on-click-modal="false"
> >
<div class="import-dialog"> <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"> <div class="import-content">
<UploadExcel <UploadExcel
v-model="importedFileUrl" v-model="importedFileUrl"
:import-type="'localAndXlsx'" :import-type="'localAndXlsx'"
:import-name="'入库单'"
:import-url="'/files/warehousingEntry.xlsx'"
@imported="handleLocalImport" @imported="handleLocalImport"
/> />
</div> </div>
...@@ -827,7 +823,7 @@ ...@@ -827,7 +823,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ElMessage, ElRadioGroup, ElTree } from 'element-plus' 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 splitDiv from '@/components/splitDiv/splitDiv.vue'
import { ElTable } from 'element-plus' import { ElTable } from 'element-plus'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
...@@ -987,14 +983,6 @@ function getStartTime() { ...@@ -987,14 +983,6 @@ function getStartTime() {
const day = date.getDate() const day = date.getDate()
return `${year}-${month}-${day} 00:00:00` 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 selectSku = ref('')
const treeData = ref<InterWarehouseTree[]>() const treeData = ref<InterWarehouseTree[]>()
const [searchForm, resetSearchForm] = useValue<warehouseSearchForm>({}) const [searchForm, resetSearchForm] = useValue<warehouseSearchForm>({})
...@@ -1156,7 +1144,7 @@ const excelFieldMap: Record<string, keyof InterProductList> = { ...@@ -1156,7 +1144,7 @@ const excelFieldMap: Record<string, keyof InterProductList> = {
入库数量: 'buyStored', 入库数量: 'buyStored',
// '成本价(¥)': 'costPrice', // '成本价(¥)': 'costPrice',
// '总成本(¥)': 'totalPrice', // '总成本(¥)': 'totalPrice',
库位: 'locationCode', 库位编码: 'locationCode',
备注: 'remark', 备注: 'remark',
} }
...@@ -1223,11 +1211,9 @@ const handleLocalImport = async ({ ...@@ -1223,11 +1211,9 @@ const handleLocalImport = async ({
const importedItem = importedData.find( const importedItem = importedData.find(
(item) => item.warehouseSku === skuItem.sku, (item) => item.warehouseSku === skuItem.sku,
) )
// console.log(skuItem,'importedItem', importedItem) const target = locationList.value.find((item:InterProductList) => {
const target = locationList.value.find((item) => {
return item.locationCode == importedItem?.locationCode return item.locationCode == importedItem?.locationCode
}) })
// console.log(importedItem, '11111@', locationList.value, target)
return { return {
skuImage: skuItem.image, skuImage: skuItem.image,
warehouseSku: skuItem.sku, warehouseSku: skuItem.sku,
...@@ -1972,11 +1958,6 @@ $border: solid 1px #ddd; ...@@ -1972,11 +1958,6 @@ $border: solid 1px #ddd;
} }
.import-dialog { .import-dialog {
.import-header {
display: flex;
justify-content: flex-end;
}
.import-content { .import-content {
padding-bottom: 20px; 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