Commit d0b4ff7e by wuqian

入库单按钮操作

parent ba93e883
......@@ -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,11 +8,11 @@ import {
InterskuList,
InterWarehouseList,
ILocation,
InRecordEditForm,
} from '@/types/api/warehouse'
export interface LogListData {
createTime: string
description: string
createdTime?: string | null
}
export interface PrintData{
code:string
......@@ -274,8 +274,22 @@ export function warehouseInRecordListPageApi(
},
)
}
export function addInRecordApi(form: InRecordEditForm) {
export function rejectInRecordApi({
ids,
rejectReason,
}: {
ids: string
rejectReason: string
}) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/turnDown',
{
ids,
rejectReason,
},
)
}
export function addInRecordApi(form: InterWarehouseDetail) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/add',
{
......@@ -284,7 +298,7 @@ export function addInRecordApi(form: InRecordEditForm) {
)
}
export function updateInRecordApi(form: InRecordEditForm) {
export function updateInRecordApi(form: InterWarehouseDetail) {
return axios.post<never, BaseRespData<never>>(
'factory/warehouseInRecord/update',
{
......@@ -292,8 +306,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: {
......@@ -302,7 +316,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',
{
......@@ -314,7 +328,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[]>>(
......@@ -339,8 +353,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[]
}
......@@ -87,7 +87,14 @@
style="width: 160px"
/>
</ElFormItem>
<ElFormItem style="margin-right: 10px" label="ID">
<ElInput
v-model="searchForm.id"
clearable
placeholder="请输入ID"
style="width: 160px"
/>
</ElFormItem>
<ElFormItem>
<ElButton type="primary" @click="search">查询</ElButton>
</ElFormItem>
......@@ -97,22 +104,57 @@
</ElForm>
</div>
<div class="btn-list">
<el-button type="primary" @click="addDialog(1)"> 新增 </el-button>
<el-button type="danger" @click="rejectOrder"> 驳回 </el-button>
<el-button type="danger" @click="handleBatchDelete">
<el-button
v-if="nodeCode === 'PENDING_SUBMIT'"
type="primary"
@click="addDialog(1, null)"
>
新增
</el-button>
<el-button
v-if="nodeCode === 'PENDING_AUDIT'"
type="danger"
@click="rejectedInRecord"
>
驳回
</el-button>
<el-button
v-if="nodeCode === 'PENDING_SUBMIT'"
type="danger"
@click="handleBatchDelete"
>
删除
</el-button>
<el-button type="warning" @click="importExcel"> 导入 </el-button>
<el-button type="success" @click="exportExcel"> 导出 </el-button>
<el-button type="primary" @click="exportExcel">
<el-button type="success" @click="handleExport"> 导出 </el-button>
<el-button type="primary" @click="getPrintData">
打印SKU标签
</el-button>
<el-button type="warning" @click="exportExcel"> 审核 </el-button>
<el-button type="success" @click="exportExcel">
<el-button
v-if="nodeCode === 'PENDING_AUDIT'"
type="warning"
@click="auditOrder('audit')"
>
审核
</el-button>
<el-button
v-if="nodeCode === 'PENDING_SUBMIT'"
type="success"
@click="auditOrder('submitAudit')"
>
提交审核
</el-button>
<el-button type="danger" @click="rejectOrder"> 作废 </el-button>
<el-button type="success" @click="auditOrder('archive')">
<el-button
v-if="nodeCode === 'PENDING_AUDIT'"
type="danger"
@click="auditOrder('invalid')"
>
作废
</el-button>
<el-button
v-if="nodeCode === 'COMPLETED'"
type="success"
@click="auditOrder('archiving')"
>
归档
</el-button>
</div>
......@@ -149,15 +191,14 @@
label="入库单号"
show-overflow-tooltip
prop="inNo"
width="110"
width="130"
header-align="center"
align="center"
></ElTableColumn>
<ElTableColumn
label="单据状态"
show-overflow-tooltip
width="130"
prop="billStatus"
width="80"
header-align="center"
align="center"
></ElTableColumn>
......@@ -165,7 +206,7 @@
label="仓库名称"
show-overflow-tooltip
prop="warehouseName"
min-width="100"
width="130"
header-align="center"
align="center"
></ElTableColumn>
......@@ -173,7 +214,7 @@
label="工厂编号"
show-overflow-tooltip
prop="factoryCode"
min-width="100"
width="90"
header-align="center"
align="center"
></ElTableColumn>
......@@ -197,7 +238,7 @@
label="SKU数量"
header-align="center"
prop="skuAmount"
width="130"
width="90"
align="center"
show-overflow-tooltip
>
......@@ -206,15 +247,21 @@
label="总数量"
header-align="center"
prop="total"
width="120"
width="90"
align="center"
show-overflow-tooltip
>
</ElTableColumn>
<ElTableColumn
label="驳回原因"
show-overflow-tooltip
prop="rejectReason"
header-align="center"
align="center"
></ElTableColumn>
<ElTableColumn
label="备注"
show-overflow-tooltip
width="240"
prop="remark"
header-align="center"
align="center"
......@@ -261,14 +308,15 @@
<ElTableColumn
show-overflow-tooltip
align="center"
width="100"
label="SKU图片"
prop="factory_order_number"
>
<template #default="{ row }">
<ImageView
:src="row.skuImage"
width="80px"
height="80px"
width="40px"
height="40px"
/>
</template>
</ElTableColumn>
......@@ -295,12 +343,18 @@
<ElTableColumn
show-overflow-tooltip
align="center"
label="总成本(¥)"
prop="buyStored"
label="成本价(¥)"
prop="costPrice"
/>
<ElTableColumn
show-overflow-tooltip
align="center"
label="总成本(¥)"
prop="totalPrice"
/>
<!-- <ElTableColumn
show-overflow-tooltip
align="center"
label="不良品数量"
prop="rejectsAmount"
/>
......@@ -309,7 +363,7 @@
align="center"
label="不良品原因"
prop="rejectsAeason"
/>
/> -->
<ElTableColumn
show-overflow-tooltip
align="center"
......@@ -332,7 +386,7 @@
</ElTable>
</div>
<ElPagination
<!-- <ElPagination
v-model:current-page="detailPager.page"
v-model:page-size="detailPager.rows"
:page-sizes="[100, 200, 300, 400, 500]"
......@@ -342,9 +396,9 @@
style="margin: 10px auto 0; text-align: right"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
></ElPagination>
></ElPagination> -->
</el-tab-pane>
<!-- <el-tab-pane name="1" label="操作日志">
<el-tab-pane name="1" label="操作日志">
<ul
style="
color: #333;
......@@ -359,7 +413,7 @@
style="display: flex"
>
<span style="display: inline-block">
{{ item.createdTime }}
{{ item.createdTime }}&emsp;&emsp;
</span>
<span style="display: inline-block">{{
item.description
......@@ -367,24 +421,6 @@
</li>
</ul>
</el-tab-pane>
<el-tab-pane name="2" label="物流轨迹">
<ul
v-if="logisticsData.length > 0"
style="
color: #333;
font-size: 12px;
height: 100%;
overflow: auto;
"
>
<li v-for="(item, index) in logisticsData" :key="index">
<span class="log-desc">
{{ item.time + ' ' + item.context }}
</span>
</li>
</ul>
<div v-else class="empty">{{ $t('暂无数据') }}</div>
</el-tab-pane> -->
</el-tabs>
</template>
</splitDiv>
......@@ -398,22 +434,26 @@
:close-on-click-modal="false"
>
<div class="import-dialog">
<div class="import-header">
<!-- <div class="import-header">
<el-button type="primary" link @click="downloadTemplate">
<el-icon><Download /></el-icon>
下载模板
</el-button>
</div>
</div> -->
<div class="import-content">
<UploadExcel v-model="importedFileUrl" />
<UploadExcel
v-model="importedFileUrl"
:import-type="'local'"
@imported="handleLocalImport"
/>
</div>
</div>
<template #footer>
<!-- <template #footer>
<span class="dialog-footer">
<el-button @click="importDialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitConfirmOrder">确认</el-button>
<el-button type="primary" @click="packedData">确认</el-button>
</span>
</template>
</template> -->
</ElDialog>
<ElDialog
v-model="newDialogVisible"
......@@ -432,6 +472,9 @@
<ElFormItem label="入库单号" prop="account">
<ElInput v-model="editForm.inNo" clearable disabled />
</ElFormItem>
<ElFormItem label="工厂:" prop="factoryCode">
<span>{{ editForm.factoryCode }}</span>
</ElFormItem>
<ElFormItem label="仓库" prop="warehouseId" required>
<ElSelect
v-model="editForm.warehouseId"
......@@ -447,9 +490,6 @@
></ElOption>
</ElSelect>
</ElFormItem>
<ElFormItem label="工厂:" prop="factoryCode">
<span>{{ editForm.factoryCode }}</span>
</ElFormItem>
<ElFormItem label="备注" prop="remark" style="width: 45%">
<ElInput
v-model="editForm.remark"
......@@ -520,21 +560,13 @@
label="总成本(¥)"
prop="totalPrice"
/>
<ElTableColumn
show-overflow-tooltip
align="center"
label="不良品数量"
prop="rejectsAmount"
/>
<ElTableColumn
show-overflow-tooltip
align="center"
label="不良品原因"
prop="rejectsAeason"
/>
<ElTableColumn align="center" label="库位" prop="loacationCode">
<template #default="{ row }">
<!-- +后有就正常展示,没有则通过搜索接口自己添加 -->
<!-- remote
:remote-method="(query) => handleLocationSearch(query, row)"
:loading="locationLoading"
@change="(val) => handleLocationChange(val, row)" -->
<span v-if="row.loacationCode">{{ row.loacationCode }}</span>
<ElSelect
v-else
......@@ -543,10 +575,6 @@
placeholder="请输入库位"
style="width: 120px"
filterable
remote
:remote-method="(query) => handleLocationSearch(query, row)"
:loading="locationLoading"
@change="(val) => handleLocationChange(val, row)"
>
<ElOption
v-for="item in locationList"
......@@ -633,7 +661,7 @@
label="操作"
>
<template #default="{ row }">
<el-icon :size="32" color="#67C23A"
<el-icon :size="32" color="#67C23A" class="cursor-pointer"
><CirclePlusFilled @click="skudblclick(row)"
/></el-icon>
</template>
......@@ -691,51 +719,71 @@
</div>
</template>
</ElDialog>
<ElDialog
v-model="exportVisible"
title="导出选项"
width="500px"
:close-on-click-modal="false"
>
<el-form :model="exportForm" label-width="80px">
<el-form-item label="" prop="resource">
<el-radio-group v-model="exportForm.resource">
<el-radio :label="0">导出本页</el-radio>
<el-radio :label="1">导出选中</el-radio>
<el-radio :label="2">全部</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="">
<el-checkbox v-model="exportForm.delivery"> 包含详情 </el-checkbox>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="exportVisible = false">取消</el-button>
<el-button type="primary" @click="submitExportForm">确认</el-button>
</span>
</template>
</ElDialog>
</template>
<script setup lang="ts">
import { ElMessage, ElRadioGroup, ElTree, TableColumnCtx } from 'element-plus'
import { Download, CirclePlusFilled } from '@element-plus/icons-vue'
import { ElMessage, ElRadioGroup, ElTree } from 'element-plus'
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'
import { useValue } from '@/utils/hooks/useValue'
import {
auditOrderApi,
rejectOrderApi,
getLogListApi,
exportExcelApi,
} from '@/api/order'
import {
getOutRecordStatusTree,
warehouseOutRecordListPage,
getInRecordStatusTree,
warehouseInRecordListPageApi,
getWarehouseInRecordDetailApi,
getBySkuApi,
getWarehouseListApi,
getByWareHouseIdAndCodeApi,
addInRecordApi,
updateInRecordApi,
deleteWarehouseOutRecordApi,
deleteWarehouseInRecordApi,
auditOrderApi,
getInRecordLogApi,
rejectInRecordApi,
LogListData,
} from '@/api/warehouse'
import BigNumber from 'bignumber.js'
import { ref, onMounted, watch, nextTick } from 'vue'
import 'element-plus/dist/index.css'
import { LogList } from '@/types/api/billOrder.ts'
import {
warehouseSearchForm,
InterWarehousePage,
InterWarehouseDetail,
InterWarehouseTree,
InterProductList,
InterskuList,
InterWarehouseList,
ILocation,
InterWarehouseDetail,
} from '@/types/api/warehouse'
import ImageView from '@/components/ImageView.vue'
import { showConfirm } from '@/utils/ui'
import UploadExcel from '@/components/UploadExcel.vue'
import { debounce } from 'lodash-es'
// import UploadExcel from '@/components/INgoVopy.vue'
// import { debounce } from 'lodash-es'
const warehouseList = ref<InterWarehouseList[]>([])
const pickerOptions = {
shortcuts: [
......@@ -860,15 +908,17 @@ const [searchForm, resetSearchForm] = useValue<warehouseSearchForm>({})
const tradingTime = ref<string[]>([])
const selections = ref<InterWarehousePage[]>([])
const detailList = ref<InterWarehouseDetail[]>([])
const detailList = ref<InterProductList[]>([])
const tabsValue = ref<string>('0')
const singleTableRef = ref<InstanceType<typeof ElTable>>()
const currentRow = ref<InterWarehousePage | null>(null)
const logList = ref<LogList[]>([])
const logList = ref<LogListData[]>([])
const rules = {
warehouseId: [{ required: true, message: '请选择仓库', trigger: 'change' }],
}
const nodeId = ref<number | string>(10)
const nodeCode = ref<string>(
sessionStorage.getItem('InRecord_NodeCode') || 'all',
)
const treeRef = ref<InstanceType<typeof ElTree>>()
const {
......@@ -881,10 +931,10 @@ const {
onPageSizeChange: handleSizeChange,
} = usePageList({
query: (page, pageSize) =>
warehouseOutRecordListPage(
warehouseInRecordListPageApi(
{
...searchForm.value,
billStatus: nodeId.value === -1 ? null : nodeId.value,
billStatus: nodeCode.value == 'all' ? 'all' : nodeCode.value,
createTimeStart: tradingTime.value && tradingTime.value[0],
createTimeEnd: tradingTime.value && tradingTime.value[1],
},
......@@ -897,29 +947,175 @@ const setCostPrice = (item: InterProductList) => {
ElMessage.warning('商品成本价为空,请完善商品成本价')
return
}
const amount = new BigNumber(item.buyStored)
.multipliedBy(item.costPrice)
.toFixed(2)
if (item) {
const buyStored = item.buyStored ?? 0
const costPrice = item.costPrice ?? 0
const amount = new BigNumber(buyStored).multipliedBy(costPrice).toFixed(2)
item.totalPrice = Number(amount)
}
}
const getTreeNum = async () => {
try {
const res = await getOutRecordStatusTree()
res.data = [{ code: -1, name: '全部', children: res.data }]
const res = await getInRecordStatusTree()
res.data = [{ code: 'all', name: '全部', children: res.data }]
treeData.value = res.data
await nextTick(() => {
treeRef.value!.setCurrentKey(nodeId.value, true)
treeRef.value!.setCurrentKey(nodeCode.value, true)
})
} catch (e) {
console.error(e)
}
}
const getPrintData = () => {
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
}
const excelFieldMap: Record<string, keyof InterProductList> = {
SKU图片: 'skuImage',
商品SKU: 'warehouseSku',
SKU名称: 'skuName',
入库数量: 'buyStored',
'成本价(¥)': 'costPrice',
'总成本(¥)': 'totalPrice',
库位: 'locationCode',
备注: 'remark',
}
const handleLocalImport = ({
path,
data,
}: {
path: string
data: InterProductList[]
}) => {
const result: InterProductList[] = data.map((item) => {
const obj = {} as InterProductList
Object.keys(excelFieldMap).forEach((excelKey) => {
const field = excelFieldMap[excelKey] as keyof InterProductList
const value = item[excelKey]
// // 类型转换和默认值
// if (['buyStored', 'costPrice', 'totalPrice'].includes(field)) {
// value = value == null || value === '' ? 0 : Number(value)
// } else {
// value = value == null ? '' : value
// }
obj[field] = value as InterProductList[typeof field]
})
return obj
})
otherPurchaseData.value = result
importedFileUrl.value = path
importDialogVisible.value = false
}
const exportVisible = ref(false)
const exportForm = ref({
delivery: false,
resource: '',
})
const handleExport = () => {
exportVisible.value = true
// exportForm.value.delivery = false
// exportForm.value.resource = ''
}
const submitExportForm = () => {
// if (exportForm.value.resource === '') {
// return ElMessage.error('请选择导出类型')
// }
// let purchaseIds = [],
// otherIds = [],
// total = 0,
// params = {}
// if (exportForm.value.resource === 0) {
// purchaseIds = userData.value
// .filter((el) => el.dataType === 0)
// .map((el) => el.id)
// .join(',')
// otherIds = userData.value
// .filter((el) => el.dataType === 1)
// .map((el) => el.id)
// .join(',')
// } else if (exportForm.value.resource === 1) {
// purchaseIds = selections.value
// .filter((el) => el.dataType === 0)
// .map((el) => el.id)
// .join(',')
// otherIds = selections.value
// .filter((el) => el.dataType === 1)
// .map((el) => el.id)
// .join(',')
// } else {
// purchaseIds = ''
// otherIds = ''
// // total = this.paginationOptions.total
// }
// params = {
// purchaseIds,
// otherIds,
// total,
// }
// if (exportForm.value.resource !== 2) {
// delete params.total
// } else {
// // params.billStatus = this.billStatus
// // params.type = this.treeType || ''
// // params.otherStatus = this.otherStatus
// if (
// this.treeLabel.indexOf(this.$t('待入库')) !== -1 ||
// this.treeLabel.indexOf(this.$t('已入库')) !== -1
// ) {
// params.purchaseAll = true
// params.otherAll = true
// }
// if (
// this.treeLabel.indexOf(this.$t('采购')) !== -1 ||
// this.treeLabel.indexOf(this.$t('生产')) !== -1
// ) {
// params.purchaseAll = true
// }
// if (this.treeLabel.indexOf(this.$t('其他')) !== -1) {
// params.otherAll = true
// }
// if (this.treeLabel.indexOf(this.$t('归档')) !== -1) {
// params.purchaseAll = true
// }
// if (this.treeLabel.indexOf(this.$t('作废')) !== -1) {
// params.purchaseAll = true
// params.otherAll = true
// }
// }
// const loading = this.$loading({
// background: 'rgba(0, 0, 0, 0.3)',
// })
// Axios.post(
// window.apiHostSetting.VUE_APP_API_URL +
// 'api/purchaseStoreBill/exportPurchaseExcel',
// {
// includeSku: exportForm.value.delivery,
// ...params,
// ...this.searchForm,
// },
// {
// headers: {
// 'jwt-token': localStorage.getItem('token'),
// },
// },
// )
// .then((res) => {
// console.log(filePath)
// window.open(filePath + res.data.message)
// exportVisible.value = false
// })
// .finally(() => {
// loading.close()
// })
}
const getWarehouseList = async () => {
try {
const res = await getWarehouseListApi()
warehouseList.value = res.data
await nextTick(() => {
treeRef.value!.setCurrentKey(nodeId.value, true)
treeRef.value!.setCurrentKey(nodeCode.value, true)
})
} catch (e) {
console.error(e)
......@@ -938,7 +1134,6 @@ const selectbySku = async () => {
try {
const res = await getBySkuApi(editForm.value.warehouseId, selectSku.value)
skuData.value = res.data || []
fetchLocationList('') //获取该仓库下的所有库位
} catch (e) {
console.error(e)
}
......@@ -952,7 +1147,7 @@ const skudblclick = (val: InterskuList) => {
sku = '',
skuName = '',
image = '',
locationId = '',
locationId = 0,
} = val || {}
otherPurchaseData.value = [
...otherPurchaseData.value,
......@@ -962,8 +1157,8 @@ const skudblclick = (val: InterskuList) => {
skuName,
productNo,
locationCode: locationCode ?? '', // 确保空值处理
locationId: locationId ?? '', // 确保空值处理
costPrice: factoryPrice, ////添加时成本价字段是啥?要提交吗?
locationId: locationId ?? 0, // 确保空值处理
costPrice: factoryPrice,
buyStored: null,
totalPrice: null,
},
......@@ -987,30 +1182,26 @@ const tabsClick = async () => {
searchDetail()
} else if (tabsValue.value === '1') {
getLogList()
} else {
getLogisticsData()
}
}
const [editForm, resetEditForm] = useValue({
const [editForm, resetEditForm] = useValue<InterWarehouseDetail>({
inNo: '',
warehouseId: '',
remark: '',
factoryCode: '',
factoryId: '',
factoryId: 0,
productList: [],
})
const newDialogVisible = ref(false)
const editFormRef = ref()
const editForm2 = ref({})
const formId = ref<number | undefined>(undefined)
const otherPurchaseData = ref<InterProductList[]>([])
const addDialog = async (i: number, v: InterWarehousePage) => {
const addDialog = async (i: number, v: InterWarehousePage | null) => {
if (i === 2) {
if (v) formId.value = v.id
// getProduct(v.id)
if (v) getProduct(v.id)
if (!formId.value) return ElMessage('请勾选至少一条记录')
// v.inWarehouseId = v.warehouseId
// v.inType = v.type
// v.handleUserId = v.makerUserId
editForm.value = JSON.parse(JSON.stringify(v))
} else {
await nextTick()
......@@ -1031,19 +1222,14 @@ const addDialog = async (i: number, v: InterWarehousePage) => {
}
newDialogVisible.value = true
}
// const getProduct = (id: number) => {
// let url = `otherInWarehouseProductDetails/getProductList?otherOutWarehouseId=${id}`
// get(url).then((res) => {
// if (res.code == 200) {
// otherPurchaseData.value = res.data;
// productData.value = res.data;
// } else {
// this.$alert(res.message, this.$t('错误提示'), {
// dangerouslyUseHTMLString: true,
// })
// }
// })
// }
const getProduct = async (id: number | undefined) => {
try {
const res = await getWarehouseInRecordDetailApi(id)
otherPurchaseData.value = res.data?.productList || []
} catch (e) {
console.error(e)
}
}
const handleSelectionChange = (v: InterWarehousePage[]) => {
selections.value = v
}
......@@ -1052,34 +1238,50 @@ const productSelectionChange = (v: InterProductList[]) => {
otherWarehouseSelection.value = v
}
const auditOrder = (key: string) => {
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
let url = ''
let text = ''
switch (key) {
case 'pay':
url = 'reconciliation/payment'
text = '确认付款'
case 'invalid':
url = 'factory/warehouseInRecord/invalid'
text = '作废'
break
case 'archive':
url = 'reconciliation/archiving'
text = '确认归档'
case 'archiving':
url = 'factory/warehouseInRecord/archive'
text = '归档'
break
case 'submitAudit':
url = 'factory/warehouseInRecord/submitAudit'
text = '提交审核'
break
case 'audit':
url = 'factory/warehouseInRecord/audit'
text = '审核'
break
}
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
ElMessageBox.confirm(`${text}对账单?`, '重要提示', {
const confimText =
key === 'audit'
? '确定进行审核?点“确定”将会直接更改库存数量,请在审核前确认数量是否正确。'
: `确定对选中的信息进行${text}?`
ElMessageBox.confirm(confimText, '重要提示', {
confirmButtonText: '确定',
type: 'warning',
}).then(async () => {
const ids = selections.value.map((el) => el.id).join(',')
await auditOrderApi(url, ids)
const data = selections.value.map(
({ id, dataVersion }: InterWarehousePage) => ({
id,
dataVersion,
}),
)
await auditOrderApi(url, data)
ElMessage.success('操作成功')
search()
await getTreeNum()
})
}
const rejectOrder = () => {
const rejectedInRecord = () => {
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
......@@ -1091,10 +1293,12 @@ const rejectOrder = () => {
customClass: 'reject',
inputErrorMessage: '请输入驳回原因',
inputPlaceholder: '驳回原因',
}).then(async ({ value }) => {
const ids = selections.value.map((el) => el.id).join(',')
}).then(async ({ value }: { value: string }) => {
const ids = selections.value
.map((el: InterWarehousePage) => el.id)
.join(',')
try {
await rejectOrderApi({ ids: ids, description: value, pass: 0 })
await rejectInRecordApi({ ids: ids, rejectReason: value })
ElMessage.success('操作成功')
search()
await getTreeNum()
......@@ -1117,6 +1321,15 @@ watch(
},
{ immediate: true },
)
watch(
() => editForm.value.warehouseId,
(newVal: number | string | undefined) => {
if (newVal) {
fetchLocationList('')
}
},
)
const addOtherCurrency = async () => {
try {
await editFormRef.value?.validate()
......@@ -1232,8 +1445,11 @@ const deleteOtherWarehousing = () => {
(item: InterProductList) => !idList.includes(item.warehouseSku),
)
}
const importDialogVisible = ref(false)
const importedFileUrl = ref('')
const importData = async () => {
if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
// if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
importDialogVisible.value = true
}
const handleBatchDelete = async () => {
if (!selections.value.length) {
......@@ -1245,69 +1461,36 @@ const handleBatchDelete = async () => {
type: 'warning',
})
const str = selections.value.map((el: InterWarehousePage) => el.id).join(',')
await deleteWarehouseOutRecordApi(str)
await deleteWarehouseInRecordApi(str)
ElMessage.success('删除成功')
await search()
}
const nodeClick = (data: InterWarehouseTree) => {
nodeId.value = data.code ?? ''
nodeCode.value = data.code ?? ''
sessionStorage.setItem('InRecord_NodeCode', data.code ?? '')
search()
}
const detailPager = ref({
page: 1,
rows: 100,
total: 0,
})
// const detailPager = ref({
// page: 1,
// rows: 100,
// total: 0,
// })
const searchDetail = async () => {
try {
const res = await getWarehouseInRecordDetailApi(currentRow.value?.id)
detailList.value = res.data.records || []
detailPager.value.total = res.data.total
detailList.value = res.data?.productList || []
} catch (e) {
console.error(e)
}
}
const getLogList = async () => {
try {
const res = await getLogListApi(currentRow.value?.id)
const res = await getInRecordLogApi(currentRow.value?.id)
logList.value = res.data
} catch (e) {
console.error(e)
}
}
// const logisticsData = ref([])
const getLogisticsData = async () => {
// try {
// const res = await getLogisticsDataApi(currentRow.value?.id)
// logisticsData.value = res.data
// } catch (e) {
// console.error(e)
// }
}
const importDialogVisible = ref(false)
const importedFileUrl = ref('')
const importExcel = () => {
importDialogVisible.value = true
}
const downloadTemplate = () => {
// TODO: 实现下载模板功能
window.open('/api/template/download')
}
const exportExcel = async () => {
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
const ids = selections.value.map((el) => el.id).join(',')
try {
const res = await exportExcelApi(ids)
window.open(res.data)
} catch (e) {
console.error(e)
}
}
const locationList = ref<ILocation[]>([])
const locationLoading = ref(false)
......@@ -1336,13 +1519,13 @@ const fetchLocationList = async (query: string) => {
}
}
// 输入2秒后再调用接口(节流)
const handleLocationSearch = debounce(fetchLocationList, 2000)
const handleLocationChange = (val: number, row: InterProductList) => {
const found = locationList.value.find(
(item: InterProductList) => item.locationId === val,
)
row.locationCode = found ? found.locationCode : ''
}
// const handleLocationSearch = debounce(fetchLocationList, 2000)
// const handleLocationChange = (val: number, row: InterProductList) => {
// const found = locationList.value.find(
// (item: InterProductList) => item.locationId === val,
// )
// row.locationCode = found ? found.locationCode : ''
// }
onMounted(() => {
getTreeNum()
getWarehouseList()
......@@ -1355,6 +1538,9 @@ onMounted(() => {
width: 500px;
text-align: center;
}
.cursor-pointer {
cursor: pointer;
}
.header-filter-form {
:deep(.el-form-item) {
margin-right: 14px;
......
......@@ -87,7 +87,14 @@
style="width: 160px"
/>
</ElFormItem>
<ElFormItem style="margin-right: 10px" label="ID">
<ElInput
v-model="searchForm.id"
clearable
placeholder="请输入ID"
style="width: 160px"
/>
</ElFormItem>
<ElFormItem>
<ElButton type="primary" @click="search">查询</ElButton>
</ElFormItem>
......@@ -100,14 +107,14 @@
<el-button
v-if="nodeCode === 'PENDING_SUBMIT'"
type="primary"
@click="addDialog(1)"
@click="addDialog(1, null)"
>
新增
</el-button>
<el-button
v-if="nodeCode === 'PENDING_AUDIT'"
type="danger"
@click="auditOrder('rejected')"
@click="rejectedInRecord"
>
驳回
</el-button>
......@@ -118,16 +125,9 @@
>
删除
</el-button>
<el-button
v-if="nodeCode === 'PENDING_SUBMIT'"
type="warning"
@click="importExcel"
>
导入
</el-button>
<el-button type="success" @click="handleExport"> 导出 </el-button>
<el-button type="primary" @click="exportExcel">
打印SKU标签
<el-button type="primary" @click="printProductTag">
打印商品SKU标签
</el-button>
<el-button
v-if="nodeCode === 'PENDING_AUDIT'"
......@@ -253,6 +253,13 @@
>
</ElTableColumn>
<ElTableColumn
label="驳回原因"
show-overflow-tooltip
prop="rejectReason"
header-align="center"
align="center"
></ElTableColumn>
<ElTableColumn
label="备注"
show-overflow-tooltip
prop="remark"
......@@ -406,7 +413,7 @@
style="display: flex"
>
<span style="display: inline-block">
{{ item.createdTime }}
{{ item.createdTime }}&emsp;&emsp;
</span>
<span style="display: inline-block">{{
item.description
......@@ -427,22 +434,26 @@
:close-on-click-modal="false"
>
<div class="import-dialog">
<div class="import-header">
<!-- <div class="import-header">
<el-button type="primary" link @click="downloadTemplate">
<el-icon><Download /></el-icon>
下载模板
</el-button>
</div>
</div> -->
<div class="import-content">
<UploadExcel v-model="importedFileUrl" />
<UploadExcel
v-model="importedFileUrl"
:import-type="'local'"
@imported="handleLocalImport"
/>
</div>
</div>
<template #footer>
<!-- <template #footer>
<span class="dialog-footer">
<el-button @click="importDialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitConfirmOrder">确认</el-button>
<el-button type="primary" @click="packedData">确认</el-button>
</span>
</template>
</template> -->
</ElDialog>
<ElDialog
v-model="newDialogVisible"
......@@ -552,6 +563,10 @@
<ElTableColumn align="center" label="库位" prop="loacationCode">
<template #default="{ row }">
<!-- +后有就正常展示,没有则通过搜索接口自己添加 -->
<!-- remote
:remote-method="(query) => handleLocationSearch(query, row)"
:loading="locationLoading"
@change="(val) => handleLocationChange(val, row)" -->
<span v-if="row.loacationCode">{{ row.loacationCode }}</span>
<ElSelect
v-else
......@@ -560,10 +575,6 @@
placeholder="请输入库位"
style="width: 120px"
filterable
remote
:remote-method="(query) => handleLocationSearch(query, row)"
:loading="locationLoading"
@change="(val) => handleLocationChange(val, row)"
>
<ElOption
v-for="item in locationList"
......@@ -733,16 +744,59 @@
</span>
</template>
</ElDialog>
<el-dialog v-model="showPrintDialog" title="打印参数设置">
<el-table height="400px" :data="selections" border>
<el-table-column
width="60"
align="center"
type="index"
label="序号"
></el-table-column>
<el-table-column
align="center"
prop="skuName"
label="商品名称"
></el-table-column>
<el-table-column
align="center"
prop="warehouseSku"
label="商品SKU"
></el-table-column>
<el-table-column
align="center"
prop="locationCode"
label="库位编码"
></el-table-column>
<el-table-column
align="center"
prop="productNumber"
label="货号 "
></el-table-column>
<el-table-column align="center" prop="number" label="打印数量">
<template #default="{ row }">
<el-input
v-model="row.number"
oninput="value=value.replace(/[^\-?\d.]/g,'')"
placeholder="打印数量"
clearable
></el-input>
</template>
</el-table-column>
</el-table>
<template #footer>
<el-button @click="showPrintDialog = false">取消</el-button>
<el-button type="primary" @click="handlePrintProductTag">打印</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { ElMessage, ElRadioGroup, ElTree, TableColumnCtx } from 'element-plus'
import { Download, CirclePlusFilled } from '@element-plus/icons-vue'
import { ElMessage, ElRadioGroup, ElTree } from 'element-plus'
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'
import { useValue } from '@/utils/hooks/useValue'
import { exportExcelApi } from '@/api/order'
import {
getInRecordStatusTree,
warehouseInRecordListPageApi,
......@@ -755,11 +809,14 @@ import {
deleteWarehouseInRecordApi,
auditOrderApi,
getInRecordLogApi,
rejectInRecordApi,
LogListData,
factoryWarehouseInventoryPrint,
} from '@/api/warehouse'
import { filePath } from '@/api/axios.ts'
import BigNumber from 'bignumber.js'
import { ref, onMounted, watch, nextTick } from 'vue'
import 'element-plus/dist/index.css'
import { LogList } from '@/types/api/billOrder.ts'
import {
warehouseSearchForm,
InterWarehousePage,
......@@ -768,12 +825,11 @@ import {
InterskuList,
InterWarehouseList,
ILocation,
InterWarehouseDetail,
} from '@/types/api/warehouse'
import ImageView from '@/components/ImageView.vue'
import { showConfirm } from '@/utils/ui'
import UploadExcel from '@/components/UploadExcel.vue'
import { debounce } from 'lodash-es'
// import UploadExcel from '@/components/INgoVopy.vue'
// import { debounce } from 'lodash-es'
const warehouseList = ref<InterWarehouseList[]>([])
const pickerOptions = {
shortcuts: [
......@@ -902,11 +958,13 @@ const detailList = ref<InterProductList[]>([])
const tabsValue = ref<string>('0')
const singleTableRef = ref<InstanceType<typeof ElTable>>()
const currentRow = ref<InterWarehousePage | null>(null)
const logList = ref<LogList[]>([])
const logList = ref<LogListData[]>([])
const rules = {
warehouseId: [{ required: true, message: '请选择仓库', trigger: 'change' }],
}
const nodeCode = ref<string | null>('all')
const nodeCode = ref<string>(
sessionStorage.getItem('InRecord_NodeCode') || 'all',
)
const treeRef = ref<InstanceType<typeof ElTree>>()
const {
......@@ -935,10 +993,12 @@ const setCostPrice = (item: InterProductList) => {
ElMessage.warning('商品成本价为空,请完善商品成本价')
return
}
const amount = new BigNumber(item.buyStored)
.multipliedBy(item.costPrice)
.toFixed(2)
if (item) {
const buyStored = item.buyStored ?? 0
const costPrice = item.costPrice ?? 0
const amount = new BigNumber(buyStored).multipliedBy(costPrice).toFixed(2)
item.totalPrice = Number(amount)
}
}
const getTreeNum = async () => {
try {
......@@ -952,6 +1012,74 @@ const getTreeNum = async () => {
console.error(e)
}
}
const showPrintDialog = ref(false)
const printProductTag = async () => {
if (!selections.value.length) {
return ElMessage.warning('请选择要删除的数据')
}
showPrintDialog.value = true
// selections.value.forEach((el:InterWarehousePage) => {
// el.number = ''
// })
}
async function handlePrintProductTag() {
// const flag = selections.value.every((el:InterWarehousePage) => el.number && el.number != '0')
// if (!flag) {
// return ElMessage.warning('打印数量需大于0')
// }
// const list = selections.value.map((item:InterWarehousePage) => {
// return {
// skuName: item.skuName,
// warehouseSku: item.warehouseSku,
// supplierItemNo: item.productNumber,
// number: item.number,
// locationName: item.locationCode,
// }
// })
// const res = await factoryWarehouseInventoryPrint({
// list,
// code: 'PT002',
// })
// showPrintDialog.value = false
// window.open(filePath + res.message, '_blank')
}
const excelFieldMap: Record<string, keyof InterProductList> = {
SKU图片: 'skuImage',
商品SKU: 'warehouseSku',
SKU名称: 'skuName',
入库数量: 'buyStored',
'成本价(¥)': 'costPrice',
'总成本(¥)': 'totalPrice',
库位: 'locationCode',
备注: 'remark',
}
const handleLocalImport = ({
path,
data,
}: {
path: string
data: InterProductList[]
}) => {
const result: InterProductList[] = data.map((item) => {
const obj = {} as InterProductList
Object.keys(excelFieldMap).forEach((excelKey) => {
const field = excelFieldMap[excelKey] as keyof InterProductList
const value = item[excelKey]
// // 类型转换和默认值
// if (['buyStored', 'costPrice', 'totalPrice'].includes(field)) {
// value = value == null || value === '' ? 0 : Number(value)
// } else {
// value = value == null ? '' : value
// }
obj[field] = value as InterProductList[typeof field]
})
return obj
})
otherPurchaseData.value = result
importedFileUrl.value = path
importDialogVisible.value = false
}
const exportVisible = ref(false)
const exportForm = ref({
delivery: false,
......@@ -962,100 +1090,98 @@ const handleExport = () => {
// exportForm.value.delivery = false
// exportForm.value.resource = ''
}
// const submitExportForm = () => {
// if (exportForm.value.resource === '') {
// return ElMessage.error('请选择导出类型')
// }
// let purchaseIds = [],
// otherIds = [],
// total = 0,
// params = {}
// if (exportForm.value.resource === 0) {
// purchaseIds = userData.value
// .filter((el) => el.dataType === 0)
// .map((el) => el.id)
// .join(',')
// otherIds = userData.value
// .filter((el) => el.dataType === 1)
// .map((el) => el.id)
// .join(',')
// } else if (exportForm.value.resource === 1) {
// purchaseIds = selections.value
// .filter((el) => el.dataType === 0)
// .map((el) => el.id)
// .join(',')
// otherIds = selections.value
// .filter((el) => el.dataType === 1)
// .map((el) => el.id)
// .join(',')
// } else {
// purchaseIds = ''
// otherIds = ''
// // total = this.paginationOptions.total
// }
// params = {
// purchaseIds,
// otherIds,
// total,
// }
// if (exportForm.value.resource !== 2) {
// delete params.total
// } else {
// // params.billStatus = this.billStatus
// // params.type = this.treeType || ''
// // params.otherStatus = this.otherStatus
// if (
// this.treeLabel.indexOf(this.$t('待入库')) !== -1 ||
// this.treeLabel.indexOf(this.$t('已入库')) !== -1
// ) {
// params.purchaseAll = true
// params.otherAll = true
// }
// if (
// this.treeLabel.indexOf(this.$t('采购')) !== -1 ||
// this.treeLabel.indexOf(this.$t('生产')) !== -1
// ) {
// params.purchaseAll = true
// }
// if (this.treeLabel.indexOf(this.$t('其他')) !== -1) {
// params.otherAll = true
// }
// if (this.treeLabel.indexOf(this.$t('归档')) !== -1) {
// params.purchaseAll = true
// }
// if (this.treeLabel.indexOf(this.$t('作废')) !== -1) {
// params.purchaseAll = true
// params.otherAll = true
// }
// }
// const loading = this.$loading({
// background: 'rgba(0, 0, 0, 0.3)',
// })
// Axios.post(
// window.apiHostSetting.VUE_APP_API_URL +
// 'api/purchaseStoreBill/exportPurchaseExcel',
// {
// includeSku: exportForm.value.delivery,
// ...params,
// ...this.searchForm,
// },
// {
// headers: {
// 'jwt-token': localStorage.getItem('token'),
// },
// },
// )
// .then((res) => {
// console.log(filePath)
// window.open(filePath + res.data.message)
// exportVisible.value = false
// })
// .finally(() => {
// loading.close()
// })
// }
const submitExportForm = () => {
// if (exportForm.value.resource === '') {
// return ElMessage.error('请选择导出类型')
// }
// let purchaseIds = [],
// otherIds = [],
// total = 0,
// params = {}
// if (exportForm.value.resource === 0) {
// purchaseIds = userData.value
// .filter((el) => el.dataType === 0)
// .map((el) => el.id)
// .join(',')
// otherIds = userData.value
// .filter((el) => el.dataType === 1)
// .map((el) => el.id)
// .join(',')
// } else if (exportForm.value.resource === 1) {
// purchaseIds = selections.value
// .filter((el) => el.dataType === 0)
// .map((el) => el.id)
// .join(',')
// otherIds = selections.value
// .filter((el) => el.dataType === 1)
// .map((el) => el.id)
// .join(',')
// } else {
// purchaseIds = ''
// otherIds = ''
// // total = this.paginationOptions.total
// }
// params = {
// purchaseIds,
// otherIds,
// total,
// }
// if (exportForm.value.resource !== 2) {
// delete params.total
// } else {
// // params.billStatus = this.billStatus
// // params.type = this.treeType || ''
// // params.otherStatus = this.otherStatus
// if (
// this.treeLabel.indexOf(this.$t('待入库')) !== -1 ||
// this.treeLabel.indexOf(this.$t('已入库')) !== -1
// ) {
// params.purchaseAll = true
// params.otherAll = true
// }
// if (
// this.treeLabel.indexOf(this.$t('采购')) !== -1 ||
// this.treeLabel.indexOf(this.$t('生产')) !== -1
// ) {
// params.purchaseAll = true
// }
// if (this.treeLabel.indexOf(this.$t('其他')) !== -1) {
// params.otherAll = true
// }
// if (this.treeLabel.indexOf(this.$t('归档')) !== -1) {
// params.purchaseAll = true
// }
// if (this.treeLabel.indexOf(this.$t('作废')) !== -1) {
// params.purchaseAll = true
// params.otherAll = true
// }
// }
// const loading = this.$loading({
// background: 'rgba(0, 0, 0, 0.3)',
// })
// Axios.post(
// window.apiHostSetting.VUE_APP_API_URL +
// 'api/purchaseStoreBill/exportPurchaseExcel',
// {
// includeSku: exportForm.value.delivery,
// ...params,
// ...this.searchForm,
// },
// {
// headers: {
// 'jwt-token': localStorage.getItem('token'),
// },
// },
// )
// .then((res) => {
// console.log(filePath)
// window.open(filePath + res.data.message)
// exportVisible.value = false
// })
// .finally(() => {
// loading.close()
// })
}
const getWarehouseList = async () => {
try {
const res = await getWarehouseListApi()
......@@ -1093,7 +1219,7 @@ const skudblclick = (val: InterskuList) => {
sku = '',
skuName = '',
image = '',
locationId = '',
locationId = 0,
} = val || {}
otherPurchaseData.value = [
...otherPurchaseData.value,
......@@ -1103,7 +1229,7 @@ const skudblclick = (val: InterskuList) => {
skuName,
productNo,
locationCode: locationCode ?? '', // 确保空值处理
locationId: locationId ?? '', // 确保空值处理
locationId: locationId ?? 0, // 确保空值处理
costPrice: factoryPrice,
buyStored: null,
totalPrice: null,
......@@ -1130,22 +1256,23 @@ const tabsClick = async () => {
getLogList()
}
}
const [editForm, resetEditForm] = useValue({
const [editForm, resetEditForm] = useValue<InterWarehouseDetail>({
inNo: '',
warehouseId: '',
remark: '',
factoryCode: '',
factoryId: '',
factoryId: 0,
productList: [],
})
const newDialogVisible = ref(false)
const editFormRef = ref()
const editForm2 = ref({})
const formId = ref<number | undefined>(undefined)
const otherPurchaseData = ref<InterProductList[]>([])
const addDialog = async (i: number, v: InterWarehousePage) => {
const addDialog = async (i: number, v: InterWarehousePage | null) => {
if (i === 2) {
if (v) formId.value = v.id
getProduct(v.id)
if (v) getProduct(v.id)
if (!formId.value) return ElMessage('请勾选至少一条记录')
editForm.value = JSON.parse(JSON.stringify(v))
} else {
......@@ -1165,13 +1292,12 @@ const addDialog = async (i: number, v: InterWarehousePage) => {
otherPurchaseData.value = []
formId.value = undefined
}
fetchLocationList('') //获取该仓库下的所有库位
newDialogVisible.value = true
}
const getProduct = async (id: number) => {
const getProduct = async (id: number | undefined) => {
try {
const res = await getWarehouseInRecordDetailApi(id)
otherPurchaseData.value = res.data.productList || []
otherPurchaseData.value = res.data?.productList || []
} catch (e) {
console.error(e)
}
......@@ -1184,13 +1310,12 @@ const productSelectionChange = (v: InterProductList[]) => {
otherWarehouseSelection.value = v
}
const auditOrder = (key: string) => {
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
let url = ''
let text = ''
switch (key) {
case 'rejected':
url = 'factory/warehouseInRecord/turnDown'
text = '驳回'
break
case 'invalid':
url = 'factory/warehouseInRecord/invalid'
text = '作废'
......@@ -1208,10 +1333,6 @@ const auditOrder = (key: string) => {
text = '审核'
break
}
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
const confimText =
key === 'audit'
? '确定进行审核?点“确定”将会直接更改库存数量,请在审核前确认数量是否正确。'
......@@ -1232,30 +1353,32 @@ const auditOrder = (key: string) => {
await getTreeNum()
})
}
// const rejectOrder = () => {
// if (selections.value.length === 0) {
// return ElMessage.warning('请选择要操作的数据')
// }
// ElMessageBox.prompt('请输入驳回原因', '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning',
// inputPattern: /.+/,
// customClass: 'reject',
// inputErrorMessage: '请输入驳回原因',
// inputPlaceholder: '驳回原因',
// }).then(async ({ value }) => {
// const ids = selections.value.map((el) => el.id).join(',')
// try {
// await rejectOrderApi({ ids: ids, description: value, pass: 0 })
// ElMessage.success('操作成功')
// search()
// await getTreeNum()
// } catch (e) {
// console.error(e)
// }
// })
// }
const rejectedInRecord = () => {
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
ElMessageBox.prompt('请输入驳回原因', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
inputPattern: /.+/,
customClass: 'reject',
inputErrorMessage: '请输入驳回原因',
inputPlaceholder: '驳回原因',
}).then(async ({ value }: { value: string }) => {
const ids = selections.value
.map((el: InterWarehousePage) => el.id)
.join(',')
try {
await rejectInRecordApi({ ids: ids, rejectReason: value })
ElMessage.success('操作成功')
search()
await getTreeNum()
} catch (e) {
console.error(e)
}
})
}
watch(
() => tableData.value,
() => {
......@@ -1270,6 +1393,15 @@ watch(
},
{ immediate: true },
)
watch(
() => editForm.value.warehouseId,
(newVal: number | string | undefined) => {
if (newVal) {
fetchLocationList('')
}
},
)
const addOtherCurrency = async () => {
try {
await editFormRef.value?.validate()
......@@ -1385,8 +1517,11 @@ const deleteOtherWarehousing = () => {
(item: InterProductList) => !idList.includes(item.warehouseSku),
)
}
const importDialogVisible = ref(false)
const importedFileUrl = ref('')
const importData = async () => {
if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
// if (!editForm.value.warehouseId) return ElMessage.error('请选择仓库')
importDialogVisible.value = true
}
const handleBatchDelete = async () => {
if (!selections.value.length) {
......@@ -1404,18 +1539,18 @@ const handleBatchDelete = async () => {
}
const nodeClick = (data: InterWarehouseTree) => {
nodeCode.value = data.code ?? ''
sessionStorage.setItem('InRecord_NodeCode', data.code ?? '')
search()
}
const detailPager = ref({
page: 1,
rows: 100,
total: 0,
})
// const detailPager = ref({
// page: 1,
// rows: 100,
// total: 0,
// })
const searchDetail = async () => {
try {
const res = await getWarehouseInRecordDetailApi(currentRow.value?.id)
detailList.value = res.data.productList || []
// detailPager.value.total = res.data.total
detailList.value = res.data?.productList || []
} catch (e) {
console.error(e)
}
......@@ -1428,30 +1563,6 @@ const getLogList = async () => {
console.error(e)
}
}
const importDialogVisible = ref(false)
const importedFileUrl = ref('')
const importExcel = () => {
importDialogVisible.value = true
}
const downloadTemplate = () => {
// TODO: 实现下载模板功能
window.open('/api/template/download')
}
const exportExcel = async () => {
if (selections.value.length === 0) {
return ElMessage.warning('请选择要操作的数据')
}
const ids = selections.value.map((el) => el.id).join(',')
try {
const res = await exportExcelApi(ids)
window.open(res.data)
} catch (e) {
console.error(e)
}
}
const locationList = ref<ILocation[]>([])
const locationLoading = ref(false)
......@@ -1480,13 +1591,13 @@ const fetchLocationList = async (query: string) => {
}
}
// 输入2秒后再调用接口(节流)
const handleLocationSearch = debounce(fetchLocationList, 2000)
const handleLocationChange = (val: number, row: InterProductList) => {
const found = locationList.value.find(
(item: InterProductList) => item.locationId === val,
)
row.locationCode = found ? found.locationCode : ''
}
// const handleLocationSearch = debounce(fetchLocationList, 2000)
// const handleLocationChange = (val: number, row: InterProductList) => {
// const found = locationList.value.find(
// (item: InterProductList) => item.locationId === val,
// )
// row.locationCode = found ? found.locationCode : ''
// }
onMounted(() => {
getTreeNum()
getWarehouseList()
......
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