Commit 5b373135 by zhuzhequan

Merge remote-tracking branch 'origin/zzq_bill_order' into zzq_bill_order

parents 4bf76094 e0a84a01
......@@ -21,7 +21,8 @@
"vue": "^3.4.19",
"vue-dompurify-html": "^5.1.0",
"vue-router": "^4.3.0",
"vue-tsc": "^2.1.10"
"vue-tsc": "^2.1.10",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@types/splitpanes": "^2.2.6",
......@@ -2509,6 +2510,15 @@
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/adler-32": {
"version": "1.3.1",
"resolved": "https://registry.npmmirror.com/adler-32/-/adler-32-1.3.1.tgz",
"integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==",
"license": "Apache-2.0",
"engines": {
"node": ">=0.8"
}
},
"node_modules/ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz",
......@@ -2714,6 +2724,19 @@
}
]
},
"node_modules/cfb": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/cfb/-/cfb-1.2.2.tgz",
"integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
"license": "Apache-2.0",
"dependencies": {
"adler-32": "~1.3.0",
"crc-32": "~1.2.0"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz",
......@@ -2754,6 +2777,15 @@
"fsevents": "~2.3.2"
}
},
"node_modules/codepage": {
"version": "1.15.0",
"resolved": "https://registry.npmmirror.com/codepage/-/codepage-1.15.0.tgz",
"integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==",
"license": "Apache-2.0",
"engines": {
"node": ">=0.8"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
......@@ -2800,6 +2832,18 @@
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
"dev": true
},
"node_modules/crc-32": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/crc-32/-/crc-32-1.2.2.tgz",
"integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
"license": "Apache-2.0",
"bin": {
"crc32": "bin/crc32.njs"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz",
......@@ -3498,6 +3542,15 @@
"node": ">= 6"
}
},
"node_modules/frac": {
"version": "1.1.2",
"resolved": "https://registry.npmmirror.com/frac/-/frac-1.1.2.tgz",
"integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==",
"license": "Apache-2.0",
"engines": {
"node": ">=0.8"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz",
......@@ -4904,6 +4957,18 @@
"url": "https://github.com/sponsors/antoniandre"
}
},
"node_modules/ssf": {
"version": "0.11.2",
"resolved": "https://registry.npmmirror.com/ssf/-/ssf-0.11.2.tgz",
"integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
"license": "Apache-2.0",
"dependencies": {
"frac": "~1.1.2"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/ssr-window": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ssr-window/-/ssr-window-3.0.0.tgz",
......@@ -5501,12 +5566,51 @@
"resolved": "https://registry.npmjs.org/wildcard/-/wildcard-1.1.2.tgz",
"integrity": "sha512-DXukZJxpHA8LuotRwL0pP1+rS6CS7FF2qStDDE1C7DDg2rLud2PXRMuEDYIPhgEezwnlHNL4c+N6MfMTjCGTng=="
},
"node_modules/wmf": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/wmf/-/wmf-1.0.2.tgz",
"integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==",
"license": "Apache-2.0",
"engines": {
"node": ">=0.8"
}
},
"node_modules/word": {
"version": "0.3.0",
"resolved": "https://registry.npmmirror.com/word/-/word-0.3.0.tgz",
"integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==",
"license": "Apache-2.0",
"engines": {
"node": ">=0.8"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true
},
"node_modules/xlsx": {
"version": "0.18.5",
"resolved": "https://registry.npmmirror.com/xlsx/-/xlsx-0.18.5.tgz",
"integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
"license": "Apache-2.0",
"dependencies": {
"adler-32": "~1.3.0",
"cfb": "~1.2.1",
"codepage": "~1.15.0",
"crc-32": "~1.2.1",
"ssf": "~0.11.2",
"wmf": "~1.0.1",
"word": "~0.3.0"
},
"bin": {
"xlsx": "bin/xlsx.njs"
},
"engines": {
"node": ">=0.8"
}
},
"node_modules/xml-name-validator": {
"version": "4.0.0",
"resolved": "https://registry.npmmirror.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz",
......
......@@ -23,7 +23,8 @@
"vue": "^3.4.19",
"vue-dompurify-html": "^5.1.0",
"vue-router": "^4.3.0",
"vue-tsc": "^2.1.10"
"vue-tsc": "^2.1.10",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@types/splitpanes": "^2.2.6",
......
......@@ -8,21 +8,21 @@ import {
InterskuList,
InterWarehouseList,
ILocation,
InRecordEditForm,
} from '@/types/api/warehouse'
export interface LogListData {
createTime: string
description: string
createdTime?: string | null
}
export interface PrintData{
code:string
list:{
locationName:string;
pickingLocation?:string
skuName?:string
warehouseSku?:string
supplierItemNo?:string
number?:string
export interface PrintData {
code: string
list: {
locationName: string
pickingLocation?: string
skuName?: string
warehouseSku?: string
supplierItemNo?: string
number?: string
}[]
}
export interface factoryWarehouseInfo {
......@@ -46,23 +46,22 @@ export interface ExportFactoryWarehouseInfo {
}
export interface WarehouseInventory {
pageSize: number;
currentPage: number;
total?: number;
warehouseId: string;
skuName: string;
warehouseSku: string;
occupyInventory: string;
inventoryStart: string;
inventoryEnd: string;
productNumber: string;
freezeInventory: string;
inventory: string;
usableInventoryStart: string;
usableInventoryEnd: string;
occupyInventoryEnd: string;
occupyInventoryStart: string;
pageSize: number
currentPage: number
total?: number
warehouseId: string
skuName: string
warehouseSku: string
occupyInventory: string
inventoryStart: string
inventoryEnd: string
productNumber: string
freezeInventory: string
inventory: string
usableInventoryStart: string
usableInventoryEnd: string
occupyInventoryEnd: string
occupyInventoryStart: string
}
export interface UpdateDefaulted {
......@@ -89,10 +88,10 @@ export interface warehouseInfo {
export interface WarehouseWarning {
id: number | string
locationCode: string
skuName: string;
warehouseSku: string;
productNumber: string;
number: string;
skuName: string
warehouseSku: string
productNumber: string
number: string
locationName: string
}
......@@ -189,17 +188,17 @@ export function factoryWarehouseInfoPrint(data: PrintData) {
)
}
export function importWarehouseLocation(data:FormData) {
export function importWarehouseLocation(data: FormData) {
return axios.post<never, BaseRespData<never[]>>(
'/factoryWarehouseLocation/importWarehouseLocation',
data
data,
)
}
export function factoryWarehouseInventoryPrint(data:PrintData) {
export function factoryWarehouseInventoryPrint(data: PrintData) {
return axios.post<never, BaseRespData<never[]>>(
'/factoryWarehouseInventory/print',
data
data,
)
}
......@@ -291,8 +290,22 @@ export function warehouseInRecordListPageApi(
},
)
}
export function addInRecordApi(form: InRecordEditForm) {
export function rejectInRecordApi({
list,
rejectReason,
}: {
list: WarehouseParams[]
rejectReason: string
}) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/reject',
{
list,
rejectReason,
},
)
}
export function addInRecordApi(form: InterWarehouseDetail) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/add',
{
......@@ -300,8 +313,13 @@ export function addInRecordApi(form: InRecordEditForm) {
},
)
}
export function updateInRecordApi(form: InRecordEditForm) {
export function exportOrder(ids: number[], status: string | number) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/exportData',
{ ids: ids, status },
)
}
export function updateInRecordApi(form: InterWarehouseDetail) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/update',
{
......@@ -309,8 +327,8 @@ export function updateInRecordApi(form: InRecordEditForm) {
},
)
}
export function getWarehouseInRecordDetailApi(id: number) {
return axios.get<never, BaseRespData<InterWarehouseDetail[]>>(
export function getWarehouseInRecordDetailApi(id: number | undefined) {
return axios.get<never, BaseRespData<InterWarehouseDetail>>(
'factory/warehouseInRecord/get',
{
params: {
......@@ -319,7 +337,7 @@ export function getWarehouseInRecordDetailApi(id: number) {
},
)
}
export function getBySkuApi(warehouseId: number, sku: string | null) {
export function getBySkuApi(warehouseId: number | string, sku: string | null) {
return axios.get<never, BaseRespData<InterskuList[]>>(
'customProductItem/getBySku',
{
......@@ -331,7 +349,7 @@ export function getBySkuApi(warehouseId: number, sku: string | null) {
)
}
export function getByWareHouseIdAndCodeApi(
wareHouseId: number,
wareHouseId: number | string | undefined,
code: string | null,
) {
return axios.get<never, BaseRespData<ILocation[]>>(
......@@ -356,8 +374,8 @@ export function getWarehouseListApi() {
)
}
interface WarehouseParams {
id: number
dataVersion: number
id?: number
dataVersion?: number
}
export function auditOrderApi(url: string, data: WarehouseParams[]) {
return axios.post(url, data)
......
......@@ -45,6 +45,7 @@
</template>
<script setup lang="ts">
import * as XLSX from 'xlsx'
import { ref, watch, defineProps, defineEmits, computed } from 'vue'
import { UploadFilled, Document, Close } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
......@@ -55,8 +56,9 @@ interface FileItem {
}
const props = defineProps<{
modelValue: string
importType: string
}>()
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue', 'imported'])
const fileList = ref<FileItem[]>([])
const fileInputRef = ref<HTMLInputElement | null>(null)
......@@ -118,8 +120,27 @@ const onFileChange = async (e: Event) => {
ElMessage.error('文件大小不能超过50MB')
return
}
if (props.importType === 'local') {
// 本地解析
const reader = new FileReader()
reader.onload = (evt) => {
const data = evt.target?.result
const workbook = XLSX.read(data, { type: 'binary' })
const firstSheetName = workbook.SheetNames[0]
const worksheet = workbook.Sheets[firstSheetName]
const jsonData = XLSX.utils.sheet_to_json(worksheet)
//emit 路径和数据
emit('imported', { path: file.name, data: jsonData })
fileList.value = [{ path: file.name, filename: file.name }]
value.value = file.name || ''
ElMessage.success('导入成功')
}
reader.readAsBinaryString(file)
if (fileInputRef.value) fileInputRef.value.value = ''
return
}
// 走原有上传逻辑
await fileUpload(file)
// 清空input
if (fileInputRef.value) fileInputRef.value.value = ''
}
......@@ -132,7 +153,7 @@ const fileUpload = async (file: File) => {
try {
const res = await uploadFileApi(formData)
fileList.value = [{ path: res.message ?? '', filename }]
value.value = res.message
value.value = res.message ?? ''
ElMessage.success('导入成功')
} catch (e) {
ElMessage.error('上传失败')
......
export interface warehouseSearchForm {
status?: string
billStatus?: string
batchNumber?: string
createTimeEnd?: string
createTimeStart?: string
orderNumber?: string
sku?: string
warehouseId?: number
id?: number
}
export interface InterProductList {
createTime?: string
......@@ -22,12 +23,13 @@ export interface InterProductList {
warehouseSku?: string
locationId?: number | null
locationCode?: string | null
[propName: string]: string | number | boolean | undefined | unknown
}
export interface InterWarehouseBase {
id: number
id?: number
factoryId?: number
factoryCode?: string
warehouseId?: number
warehouseId?: number | string
warehouseName?: string
inNo?: string
shipmentNumber?: string
......@@ -39,6 +41,7 @@ export interface InterWarehouseBase {
dataVersion?: number
createTime?: string | null
updateTime?: string | null
rejectReason?: string | null
}
// 主表列表ts
export interface InterWarehousePage extends InterWarehouseBase {}
......@@ -47,12 +50,12 @@ export interface InterWarehouseDetail extends InterWarehouseBase {
productList: InterProductList[]
}
export interface InterWarehouseTree {
id: number
code: string
name: string
countQuantity: string | null
children: null
leaf: boolean
id?: number
code?: string | null
name?: string
countQuantity?: string | null
children: InterWarehouseTree[] | null
leaf?: boolean
}
export interface InterProductList {
createTime?: string
......@@ -98,18 +101,3 @@ export interface ILocation {
locationId?: number | null
locationCode?: string | null
}
export interface InRecordEditForm {
id: number
factoryId?: number
factoryCode?: string
warehouseId?: number
warehouseName?: string
inNo?: string
shipmentNumber?: string
skuAmount?: string
total?: number
totalPrice?: number
billStatus?: string
remark?: string
productList?: InterProductList[]
}
// 允许通用对象类型
export type AnyObject = { [key: string]: unknown }
type IdType = string | number
function itemIsArray(obj: AnyObject): boolean {
for (const key in obj) {
if (Array.isArray(obj[key])) {
return true
}
}
return false
}
function isChange(arr: AnyObject[], arr1: AnyObject[]): boolean {
if (!arr1) return true
if (arr.length !== arr1.length) return true
for (const iterator of arr) {
const item = arr1.find((item: AnyObject) => item.id === iterator.id)
if (!item) return true
}
return false
}
export function checkUpdateParams(
newParams: AnyObject,
oldParams: AnyObject,
id: string = 'id',
other: Record<string, string> = {},
bool: boolean = false
): AnyObject | null {
oldParams = JSON.parse(JSON.stringify(oldParams))
if (!oldParams) return newParams
if ((newParams as { id?: unknown })?.id !== (oldParams as { id?: unknown })?.id) return newParams
const params: AnyObject = {
id: (newParams as { id?: unknown }).id
}
for (const key in newParams) {
if (typeof newParams[key] === 'object') {
if (Array.isArray(newParams[key])) {
const arr: AnyObject[] = newParams[key] as AnyObject[]
const arr1: AnyObject[] = (oldParams[key] as AnyObject[]) || []
const addList: AnyObject[] = []
const updateList: AnyObject[] = []
let removeList: IdType[] = []
const list: AnyObject[] = []
const keyname: string = other[key] || id
for (const iterator of arr) {
const obj: AnyObject = {}
const index = arr1.findIndex((item: AnyObject) => item[keyname] === iterator[keyname])
const isArray = itemIsArray(iterator)
if (index !== -1) {
const item = arr1[index]
arr1.splice(index, 1)
for (const key1 in iterator) {
if (key1 === keyname) continue
if (Array.isArray(iterator[key1])) {
if (isChange(iterator[key1] as AnyObject[], item[key1] as AnyObject[])) {
obj[key1] = iterator[key1]
}
} else if (iterator[key1] !== item[key1]) {
obj[key1] = iterator[key1]
}
}
if (Object.keys(obj).length > 0) {
if (isArray && !bool) {
list.push({
[keyname]: iterator[keyname],
...obj,
id: item.id
})
} else {
updateList.push({
[keyname]: iterator[keyname],
...obj,
id: item.id
})
}
}
} else {
if (isArray && !bool) {
list.push(iterator)
} else {
addList.push(iterator)
}
}
}
if (arr1.length > 0) {
removeList = arr1.map((item: AnyObject) => item['id'] as IdType)
}
const key_name = key.replace('List', 'Change')
params[key_name] = {}
if (addList.length > 0) {
(params[key_name] as AnyObject).addList = addList
}
if (updateList.length > 0) {
(params[key_name] as AnyObject).updateList = updateList
}
if (removeList.length > 0) {
(params[key_name] as AnyObject).removeList = removeList
}
if (list.length > 0) {
params[key_name] = list
}
if (Object.keys(params[key_name] as object).length === 0) {
delete params[key_name]
}
}
} else {
// 基础信息
// if (newParams[key] !== oldParams[key]) {
params[key] = newParams[key]
// }
}
}
if (Object.keys(params).length === 1) {
return null
}
return params
}
\ No newline at end of file
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