Commit af73c5b4 by wuqian

三个导入

parent 422dd729
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<div class="upload-area" @click="triggerFileInput"> <div class="upload-area" @click="triggerFileInput">
<el-icon class="el-icon--upload"><UploadFilled /></el-icon> <el-icon class="el-icon--upload"><UploadFilled /></el-icon>
<div class="el-upload__text"> <div class="el-upload__text">
将文件拖到此处,或<span style="color: #409eff">点击上传</span> <span style="color: #409eff">点击上传</span>
</div> </div>
</div> </div>
<input <input
...@@ -46,7 +46,14 @@ ...@@ -46,7 +46,14 @@
<script setup lang="ts"> <script setup lang="ts">
import * as XLSX from 'xlsx' import * as XLSX from 'xlsx'
import { ref, watch, defineProps, defineEmits, computed } from 'vue' import {
ref,
watch,
defineProps,
defineEmits,
computed,
defineExpose,
} from 'vue'
import { UploadFilled, Document, Close } from '@element-plus/icons-vue' import { UploadFilled, Document, Close } 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'
...@@ -89,7 +96,7 @@ watch( ...@@ -89,7 +96,7 @@ watch(
const triggerFileInput = () => { const triggerFileInput = () => {
if (loading.value) return if (loading.value) return
fileInputRef.value?.click() if (fileInputRef.value) fileInputRef.value?.click()
} }
const downloadFile = (path: string) => { const downloadFile = (path: string) => {
window.open(path) window.open(path)
...@@ -120,8 +127,17 @@ const onFileChange = async (e: Event) => { ...@@ -120,8 +127,17 @@ const onFileChange = async (e: Event) => {
ElMessage.error('文件大小不能超过50MB') ElMessage.error('文件大小不能超过50MB')
return return
} }
if (props.importType === 'local') { if (props.importType === 'localAndUpload') {
// 本地解析 // 本地直接获取上传内容
emit('imported', { path: file.name, data: file })
if (fileInputRef.value) {
fileInputRef.value.value = ''
}
loading.value = false
return
}
if (props.importType === 'localAndXlsx') {
// 本地解析,并自行处理xlsx数据
const reader = new FileReader() const reader = new FileReader()
reader.onload = (evt) => { reader.onload = (evt) => {
const data = evt.target?.result const data = evt.target?.result
...@@ -134,6 +150,7 @@ const onFileChange = async (e: Event) => { ...@@ -134,6 +150,7 @@ const onFileChange = async (e: Event) => {
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('导入成功') ElMessage.success('导入成功')
loading.value = false
} }
reader.readAsBinaryString(file) reader.readAsBinaryString(file)
if (fileInputRef.value) fileInputRef.value.value = '' if (fileInputRef.value) fileInputRef.value.value = ''
...@@ -143,7 +160,18 @@ const onFileChange = async (e: Event) => { ...@@ -143,7 +160,18 @@ const onFileChange = async (e: Event) => {
await fileUpload(file) await fileUpload(file)
if (fileInputRef.value) fileInputRef.value.value = '' if (fileInputRef.value) fileInputRef.value.value = ''
} }
const resetUpload = () => {
fileList.value = []
value.value = ''
if (fileInputRef.value) {
fileInputRef.value.value = ''
}
}
// 暴露重置方法给父组件
defineExpose({
resetUpload,
})
const fileUpload = async (file: File) => { const fileUpload = async (file: File) => {
const formData = new FormData() const formData = new FormData()
const filename = file.name const filename = file.name
......
...@@ -400,10 +400,16 @@ ...@@ -400,10 +400,16 @@
: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="'local'" :import-type="'localAndXlsx'"
@imported="handleLocalImport" @imported="handleLocalImport"
/> />
</div> </div>
...@@ -791,7 +797,7 @@ ...@@ -791,7 +797,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 } from '@element-plus/icons-vue' import { CirclePlusFilled,Download } 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'
...@@ -951,6 +957,14 @@ function getStartTime() { ...@@ -951,6 +957,14 @@ 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>({})
...@@ -1097,9 +1111,9 @@ const batchAddCommodity = async (sku: string): Promise<InterskuList[]> => { ...@@ -1097,9 +1111,9 @@ const batchAddCommodity = async (sku: string): Promise<InterskuList[]> => {
} }
} }
interface InterImportData { interface InterImportData {
warehouseSku: string; warehouseSku: string
remark?: string | null; remark?: string | null
buyStored?: string | number | null | object; // 扩大 buyStored 类型,以兼容原始数据 buyStored?: string | number | null | object // 扩大 buyStored 类型,以兼容原始数据
[propName: string]: string | number | boolean | undefined | unknown [propName: string]: string | number | boolean | undefined | unknown
} }
// 前端导入Excel // 前端导入Excel
...@@ -1122,91 +1136,108 @@ const handleLocalImport = async ({ ...@@ -1122,91 +1136,108 @@ const handleLocalImport = async ({
data: Record<string, any>[] data: Record<string, any>[]
}) => { }) => {
// 1. 将原始导入数据映射到 InterImportData[] // 1. 将原始导入数据映射到 InterImportData[]
const importedData: InterImportData[] = data.map(item => { const importedData: InterImportData[] = data
const obj: InterImportData = { warehouseSku: '' }; .map((item) => {
Object.keys(excelFieldMap).forEach(excelKey => { const obj: InterImportData = { warehouseSku: '' }
const field = excelFieldMap[excelKey]; Object.keys(excelFieldMap).forEach((excelKey) => {
const value = item[excelKey]; const field = excelFieldMap[excelKey]
const value = item[excelKey]
if (field === 'warehouseSku') { if (field === 'warehouseSku') {
obj[field] = typeof value === 'string' ? value : String(value ?? ''); obj[field] = typeof value === 'string' ? value : String(value ?? '')
} else if (field === 'remark') { } else if (field === 'remark') {
obj[field] = typeof value === 'string' ? value : (value === null || value === undefined ? null : String(value)); obj[field] =
typeof value === 'string'
? value
: value === null || value === undefined
? null
: String(value)
} else if (field === 'buyStored') { } else if (field === 'buyStored') {
// 处理 buyStored: 确保它是一个数字、数字字符串,否则设置为 null // 处理 buyStored: 确保它是一个数字、数字字符串,否则设置为 null
if (typeof value === 'number') { if (typeof value === 'number') {
obj[field] = String(value); // 将数字转换为字符串 obj[field] = String(value) // 将数字转换为字符串
} else if (typeof value === 'string' && !isNaN(Number(value))) { } else if (typeof value === 'string' && !isNaN(Number(value))) {
obj[field] = value; // 保持有效的数字字符串 obj[field] = value // 保持有效的数字字符串
} else { } else {
// 如果不是数字或有效的数字字符串,则设置为 null // 如果不是数字或有效的数字字符串,则设置为 null
obj[field] = null; obj[field] = null
} }
} else { } else {
obj[field] = value; obj[field] = value
} }
}); })
return obj; return obj
}).filter(item => item.warehouseSku); })
.filter((item) => item.warehouseSku)
if (importedData.length === 0) { if (importedData.length === 0) {
ElMessage.warning('导入数据中没有有效的商品SKU'); ElMessage.warning('导入数据中没有有效的商品SKU')
importDialogVisible.value = false; importDialogVisible.value = false
return; return
} }
// 2. 提取导入的 SKU 列表 // 2. 提取导入的 SKU 列表
const importedSkus = importedData.map(item => item.warehouseSku).join(','); const importedSkus = importedData.map((item) => item.warehouseSku).join(',')
// 3. 调用 batchAddCommodity 获取商品的完整信息并过滤掉已有的 SKU // 3. 调用 batchAddCommodity 获取商品的完整信息并过滤掉已有的 SKU
const filteredSkusList = await batchAddCommodity(importedSkus); const filteredSkusList = await batchAddCommodity(importedSkus)
if (filteredSkusList.length === 0) { if (filteredSkusList.length === 0) {
ElMessage.warning('导入的商品SKU已存在或无效'); ElMessage.warning('导入的商品SKU已存在或无效')
importedFileUrl.value = path; importedFileUrl.value = path
importDialogVisible.value = false; importDialogVisible.value = false
return; return
} }
// 4. 将备注信息合并到获取到的商品列表中 // 4. 将备注信息合并到获取到的商品列表中
const mergedProductList = filteredSkusList.map(skuItem => { const mergedProductList = filteredSkusList.map((skuItem) => {
const importedItem = importedData.find(item => item.warehouseSku === skuItem.warehouseSku); const importedItem = importedData.find(
(item) => item.warehouseSku === skuItem.warehouseSku,
let outCountValueForBigNumber: string | number = '0'; // 初始化为安全默认值 )
if (importedItem?.buyStored !== null && importedItem?.buyStored !== undefined) { let outCountValueForBigNumber: string | number = '0' // 初始化为安全默认值
if (typeof importedItem.buyStored === 'string' && !isNaN(Number(importedItem.buyStored))) {
outCountValueForBigNumber = importedItem.buyStored; if (
} else if (typeof importedItem.buyStored === 'number') { importedItem?.buyStored !== null &&
outCountValueForBigNumber = importedItem.buyStored; importedItem?.buyStored !== undefined
} else { ) {
// 如果是对象或其他意外类型,则默认为 '0' if (
outCountValueForBigNumber = '0'; typeof importedItem.buyStored === 'string' &&
} !isNaN(Number(importedItem.buyStored))
) {
outCountValueForBigNumber = importedItem.buyStored
} else if (typeof importedItem.buyStored === 'number') {
outCountValueForBigNumber = importedItem.buyStored
} else {
// 如果是对象或其他意外类型,则默认为 '0'
outCountValueForBigNumber = '0'
} }
}
const calculatedOutCount = new BigNumber(outCountValueForBigNumber).toNumber();
return { const calculatedOutCount = new BigNumber(
skuImage: skuItem.image, outCountValueForBigNumber,
warehouseSku: skuItem.warehouseSku, ).toNumber()
skuName: skuItem.skuName,
productNo: skuItem.productNumber,
locationCode: skuItem.locationCode ?? '',
locationId: skuItem.locationId ?? null,
costPrice: skuItem.price,
outCount: calculatedOutCount,
totalPrice: new BigNumber(calculatedOutCount).multipliedBy(skuItem.price ?? 0).toNumber(),
usableInventory: skuItem.usableInventory,
inventoryId: skuItem.id,
remark: importedItem?.remark ?? skuItem.remark ?? null,
} as InterProductList;
});
return {
skuImage: skuItem.image,
warehouseSku: skuItem.warehouseSku,
skuName: skuItem.skuName,
productNo: skuItem.productNumber,
locationCode: skuItem.locationCode ?? '',
locationId: skuItem.locationId ?? null,
costPrice: skuItem.price,
outCount: calculatedOutCount,
totalPrice: new BigNumber(calculatedOutCount)
.multipliedBy(skuItem.price ?? 0)
.toNumber(),
usableInventory: skuItem.usableInventory,
inventoryId: skuItem.id,
remark: importedItem?.remark ?? skuItem.remark ?? null,
} as InterProductList
})
// 5. 更新 otherPurchaseData // 5. 更新 otherPurchaseData
otherPurchaseData.value = [...otherPurchaseData.value, ...mergedProductList]; otherPurchaseData.value = [...otherPurchaseData.value, ...mergedProductList]
importedFileUrl.value = path importedFileUrl.value = path
importDialogVisible.value = false importDialogVisible.value = false
...@@ -1974,7 +2005,7 @@ $border: solid 1px #ddd; ...@@ -1974,7 +2005,7 @@ $border: solid 1px #ddd;
} }
.import-content { .import-content {
padding: 20px 0; padding-bottom: 20px;
} }
} }
......
...@@ -13,11 +13,57 @@ import { ...@@ -13,11 +13,57 @@ import {
factoryWarehouseInfoPrint, factoryWarehouseInfoPrint,
importWarehouseLocation, importWarehouseLocation,
} from '@/api/warehouse.ts' } from '@/api/warehouse.ts'
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'
import UploadExcel from '@/components/UploadExcel.vue'
const importLoading = ref(false) const importDialogVisible = ref(false)
const importedFileUrl = ref('')
const importLocation = async () => {
importDialogVisible.value = true
importedFileUrl.value = ''
nextTick(() => {
uploadExcelRef.value?.resetUpload()
})
}
const handleLocalImport = async ({
path,
data,
}: {
path: string
data: Blob
}) => {
try {
const formData = new FormData()
formData.append('importExcel', data)
const res = await importWarehouseLocation(formData)
if (res.code == 200) {
importedFileUrl.value = path
ElMessage.success('导入成功')
await getData()
} else {
importedFileUrl.value = ''
ElMessage.error(res.message || '导入失败')
}
} catch (error) {
importedFileUrl.value = ''
ElMessage.error('导入失败')
} finally {
importDialogVisible.value = false
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({ const searchForm = ref({
warehouseId: '', warehouseId: '',
locationCode: '', locationCode: '',
...@@ -60,9 +106,7 @@ const rules = { ...@@ -60,9 +106,7 @@ const rules = {
pickingOrder: [ pickingOrder: [
{ required: true, message: '请输入拣货顺序', trigger: 'blur' }, { required: true, message: '请输入拣货顺序', trigger: 'blur' },
], ],
warehouseId: [ warehouseId: [{ required: true, message: '请选择仓库', trigger: 'change' }],
{ required: true, message: '请选择仓库', trigger: 'change' },
],
} }
const leftData = ref<positionInfo[]>([]) const leftData = ref<positionInfo[]>([])
const pagination = ref<factoryWarehouseInfo>({ const pagination = ref<factoryWarehouseInfo>({
...@@ -129,41 +173,43 @@ const handleBatchDelete = async (row: positionInfo | null) => { ...@@ -129,41 +173,43 @@ const handleBatchDelete = async (row: positionInfo | null) => {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
}) })
const str = row && row.id ? row.id?.toString() : selections.value.map((el) => el.id).join(',') const str =
row && row.id
? row.id?.toString()
: selections.value.map((el) => el.id).join(',')
await deleteLocationApi(str) await deleteLocationApi(str)
ElMessage.success('删除成功') ElMessage.success('删除成功')
await getData() await getData()
} }
const importLocation = async () => { // const importLocation = async () => {
const i = document.createElement('input') // const i = document.createElement('input')
i.type = 'file' // i.type = 'file'
i.style.display = 'none' // i.style.display = 'none'
i.accept = '.xlsx,.xls' // i.accept = '.xlsx,.xls'
i.click() // i.click()
i.onchange = async () => {
if (i && i.files) {
importLoading.value = true
try {
console.log(i.files[0])
const formData = new FormData()
formData.append('importExcel', i.files[0])
await importWarehouseLocation(formData)
ElMessage.success('导入成功')
await getData()
} finally {
importLoading.value = false
}
} // i.onchange = async () => {
} // if (i && i.files) {
} // importLoading.value = true
// try {
// console.log(i.files[0])
// // const formData = new FormData()
// // formData.append('importExcel', i.files[0])
// // await importWarehouseLocation(formData)
// // ElMessage.success('导入成功')
// // await getData()
// } finally {
// importLoading.value = false
// }
// }
// }
// }
const createWarehouse = () => { const createWarehouse = () => {
createData.value.show = true createData.value.show = true
createData.value.isEdit = false createData.value.isEdit = false
createData.value.title = '新增库位' createData.value.title = '新增库位'
const warehouse = warehouseList.value.find(w => w.defaulted === 1) const warehouse = warehouseList.value.find((w) => w.defaulted === 1)
form.value = { form.value = {
locationName: '', locationName: '',
locationCode: '', locationCode: '',
...@@ -207,7 +253,7 @@ const getWarehouse = async () => { ...@@ -207,7 +253,7 @@ const getWarehouse = async () => {
warehouseList.value = data warehouseList.value = data
} }
const warehouseChange = (v: number) => { const warehouseChange = (v: number) => {
const warehouse = warehouseList.value.find(w => w.id == v) const warehouse = warehouseList.value.find((w) => w.id == v)
form.value.warehouseName = warehouse ? warehouse.name : '' form.value.warehouseName = warehouse ? warehouse.name : ''
} }
getWarehouse() getWarehouse()
...@@ -219,37 +265,75 @@ getWarehouse() ...@@ -219,37 +265,75 @@ getWarehouse()
<el-card> <el-card>
<el-form inline :model="searchForm"> <el-form inline :model="searchForm">
<el-form-item label="仓库"> <el-form-item label="仓库">
<el-select v-model="searchForm.warehouseId" placeholder="请选择仓库" clearable filterable <el-select
style="width: 150px;"> v-model="searchForm.warehouseId"
<el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id"></el-option> placeholder="请选择仓库"
clearable
filterable
style="width: 150px"
>
<el-option
v-for="item in warehouseList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="库位名称"> <el-form-item label="库位名称">
<el-input <el-input
v-model="searchForm.locationName" style="width: 140px;" placeholder="请输入库位名称" v-model="searchForm.locationName"
clearable></el-input> style="width: 140px"
placeholder="请输入库位名称"
clearable
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="库位编码"> <el-form-item label="库位编码">
<el-input <el-input
v-model="searchForm.locationCode" style="width: 140px;" placeholder="请输入库位编码" v-model="searchForm.locationCode"
clearable></el-input> style="width: 140px"
placeholder="请输入库位编码"
clearable
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="备注"> <el-form-item label="备注">
<el-input <el-input
v-model="searchForm.remark" style="width: 140px;" placeholder="请输入备注" v-model="searchForm.remark"
clearable></el-input> style="width: 140px"
placeholder="请输入备注"
clearable
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="状态"> <el-form-item label="状态">
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable filterable style="width: 150px;"> <el-select
<el-option v-for="(item,index) in ['禁用','启用']" :key="index" :label="item" :value="index"></el-option> v-model="searchForm.status"
placeholder="请选择状态"
clearable
filterable
style="width: 150px"
>
<el-option
v-for="(item, index) in ['禁用', '启用']"
:key="index"
:label="item"
:value="index"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="getData">查询</el-button> <el-button type="primary" @click="getData">查询</el-button>
<el-button type="success" @click="createWarehouse">新增库位</el-button> <el-button type="success" @click="createWarehouse"
<el-button :loading="importLoading" type="primary" @click="importLocation">导入库位</el-button> >新增库位</el-button
<el-button type="primary" @click="printLocationTag">打印库位标签</el-button> >
<el-button type="danger" @click="handleBatchDelete(null)">删除</el-button> <el-button type="primary" @click="importLocation"
>导入库位</el-button
>
<el-button type="primary" @click="printLocationTag"
>打印库位标签</el-button
>
<el-button type="danger" @click="handleBatchDelete(null)"
>删除</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
...@@ -257,30 +341,66 @@ getWarehouse() ...@@ -257,30 +341,66 @@ getWarehouse()
<template #bottom> <template #bottom>
<el-card style="height: 100%"> <el-card style="height: 100%">
<div class="manage"> <div class="manage">
<div class="table-flex"> <div class="table-flex">
<div class="left-table"> <div class="left-table">
<div class="table-container"> <div class="table-container">
<el-table height="100%" :data="leftData" border @selection-change="handleSelectionChange"> <el-table
height="100%"
:data="leftData"
border
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" /> <el-table-column type="selection" />
<el-table-column type="index" label="序号" width="60" /> <el-table-column type="index" label="序号" width="60" />
<el-table-column width="100" label="启用状态" prop="status" align="center"> <el-table-column
<template #default="{row}"> width="100"
label="启用状态"
prop="status"
align="center"
>
<template #default="{ row }">
<el-switch <el-switch
v-model="row.status" :active-value="1" :inactive-value="0" v-model="row.status"
@click="updateStatus(row)"></el-switch> :active-value="1"
:inactive-value="0"
@click="updateStatus(row)"
></el-switch>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="所属仓库" prop="warehouseName"></el-table-column> <el-table-column
<el-table-column align="center" label="库位名称" prop="locationName"></el-table-column> align="center"
<el-table-column align="center" label="库位编码" prop="locationCode"></el-table-column> label="所属仓库"
<el-table-column align="center" label="拣货顺序" prop="pickingOrder"></el-table-column> prop="warehouseName"
<el-table-column align="center" label="备注" prop="remark"></el-table-column> ></el-table-column>
<el-table-column
align="center"
label="库位名称"
prop="locationName"
></el-table-column>
<el-table-column
align="center"
label="库位编码"
prop="locationCode"
></el-table-column>
<el-table-column
align="center"
label="拣货顺序"
prop="pickingOrder"
></el-table-column>
<el-table-column
align="center"
label="备注"
prop="remark"
></el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template #default="{row}"> <template #default="{ row }">
<el-button type="primary" @click="updateWarehouse(row)">编辑</el-button> <el-button type="primary" @click="updateWarehouse(row)"
<el-button type="danger" @click="handleBatchDelete(row)">删除</el-button> >编辑</el-button
>
<el-button type="danger" @click="handleBatchDelete(row)"
>删除</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -296,40 +416,68 @@ getWarehouse() ...@@ -296,40 +416,68 @@ getWarehouse()
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
/> />
</div> </div>
</div> </div>
</div> </div>
<el-dialog v-model="createData.show" width="500px" :title="createData.title"> <el-dialog
<el-form ref="formRef" label-width="110px" :rules="rules" :model="form"> v-model="createData.show"
width="500px"
:title="createData.title"
>
<el-form
ref="formRef"
label-width="110px"
:rules="rules"
:model="form"
>
<el-form-item label="库位名称" prop="locationName"> <el-form-item label="库位名称" prop="locationName">
<el-input v-model="form.locationName" clearable placeholder="请输入库位名称"></el-input> <el-input
v-model="form.locationName"
clearable
placeholder="请输入库位名称"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="库位编码" prop="locationCode"> <el-form-item label="库位编码" prop="locationCode">
<el-input v-model="form.locationCode" clearable placeholder="请输入库位编码(例如:A1-01-03)"></el-input> <el-input
v-model="form.locationCode"
clearable
placeholder="请输入库位编码(例如:A1-01-03)"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="拣货顺序" prop="pickingOrder"> <el-form-item label="拣货顺序" prop="pickingOrder">
<el-input-number v-model="form.pickingOrder" placeholder="拣货顺序"></el-input-number> <el-input-number
v-model="form.pickingOrder"
placeholder="拣货顺序"
></el-input-number>
</el-form-item> </el-form-item>
<el-form-item label="所属仓库" prop="warehouseId"> <el-form-item label="所属仓库" prop="warehouseId">
<el-select v-model="form.warehouseId" @change="warehouseChange"> <el-select v-model="form.warehouseId" @change="warehouseChange">
<el-option <el-option
v-for="item in warehouseList" :key="item.id" :label="item.name" v-for="item in warehouseList"
:value="item.id"></el-option> :key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input <el-input
v-model="form.remark" type="textarea" :rows="4" clearable v-model="form.remark"
placeholder="请输入备注"></el-input> type="textarea"
:rows="4"
clearable
placeholder="请输入备注"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-switch <el-switch
v-model="form.status" :active-value="1" :inactive-value="0" v-model="form.status"
:active-value="1"
:inactive-value="0"
></el-switch> ></el-switch>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="createData.show=false">取消</el-button> <el-button @click="createData.show = false">取消</el-button>
<el-button type="primary" @click="handleConfirm">确定</el-button> <el-button type="primary" @click="handleConfirm">确定</el-button>
</template> </template>
</el-dialog> </el-dialog>
...@@ -337,6 +485,29 @@ getWarehouse() ...@@ -337,6 +485,29 @@ getWarehouse()
</el-card> </el-card>
</template> </template>
</split-div> </split-div>
<ElDialog
v-model="importDialogVisible"
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
ref="uploadExcelRef"
v-model="importedFileUrl"
:import-type="'localAndUpload'"
@imported="handleLocalImport"
/>
</div>
</div>
</ElDialog>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -345,7 +516,16 @@ getWarehouse() ...@@ -345,7 +516,16 @@ getWarehouse()
height: 100%; height: 100%;
} }
} }
.import-dialog {
.import-header {
display: flex;
justify-content: flex-end;
}
.import-content {
padding-bottom: 20px;
}
}
.manage { .manage {
height: 100%; height: 100%;
display: flex; display: flex;
......
...@@ -432,16 +432,16 @@ ...@@ -432,16 +432,16 @@
:close-on-click-modal="false" :close-on-click-modal="false"
> >
<div class="import-dialog"> <div class="import-dialog">
<!-- <div class="import-header"> <div class="import-header">
<el-button type="primary" link @click="downloadTemplate"> <el-button type="primary" link @click="downloadTemplate">
<el-icon><Download /></el-icon> <el-icon><Download /></el-icon>
下载模板 下载模板
</el-button> </el-button>
</div> --> </div>
<div class="import-content"> <div class="import-content">
<UploadExcel <UploadExcel
v-model="importedFileUrl" v-model="importedFileUrl"
:import-type="'local'" :import-type="'localAndXlsx'"
@imported="handleLocalImport" @imported="handleLocalImport"
/> />
</div> </div>
...@@ -827,7 +827,7 @@ ...@@ -827,7 +827,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 } from '@element-plus/icons-vue' import { CirclePlusFilled,Download } 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'
...@@ -986,6 +986,14 @@ function getStartTime() { ...@@ -986,6 +986,14 @@ 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>({})
...@@ -1936,7 +1944,7 @@ $border: solid 1px #ddd; ...@@ -1936,7 +1944,7 @@ $border: solid 1px #ddd;
} }
.import-content { .import-content {
padding: 20px 0; 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