修复采购入库,修改必须点击一次二维码的bug
parent
ec1b0a80f5
commit
432022ef86
|
|
@ -0,0 +1,50 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// ERP 销售退货项二维码 VO
|
||||
export interface PurchaseReturnItemsQrVO {
|
||||
id: number // 主键
|
||||
qr: string // 二维码
|
||||
returnId: number // 采购退货编号
|
||||
orderItemId: number // 采购订单项编号
|
||||
orderReturnItemId: number // 采购退货单项编号
|
||||
warehouseId: number // 仓库编号
|
||||
productId: number // 产品编号
|
||||
productUnitId: number // 产品单位id
|
||||
productPrice: number // 产品单价
|
||||
taxPercent: number // 税率,百分比
|
||||
taxPrice: number // 税额,单位:元
|
||||
remark: string // 备注
|
||||
}
|
||||
|
||||
// ERP 销售退货项二维码 API
|
||||
export const PurchaseReturnItemsQrApi = {
|
||||
// 查询ERP 销售退货项二维码分页
|
||||
getPurchaseReturnItemsQrPage: async (params: any) => {
|
||||
return await request.get({ url: `/erp/purchase-return-items-qr/page`, params })
|
||||
},
|
||||
|
||||
// 查询ERP 销售退货项二维码详情
|
||||
getPurchaseReturnItemsQr: async (id: number) => {
|
||||
return await request.get({ url: `/erp/purchase-return-items-qr/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增ERP 销售退货项二维码
|
||||
createPurchaseReturnItemsQr: async (data: PurchaseReturnItemsQrVO) => {
|
||||
return await request.post({ url: `/erp/purchase-return-items-qr/create`, data })
|
||||
},
|
||||
|
||||
// 修改ERP 销售退货项二维码
|
||||
updatePurchaseReturnItemsQr: async (data: PurchaseReturnItemsQrVO) => {
|
||||
return await request.put({ url: `/erp/purchase-return-items-qr/update`, data })
|
||||
},
|
||||
|
||||
// 删除ERP 销售退货项二维码
|
||||
deletePurchaseReturnItemsQr: async (id: number) => {
|
||||
return await request.delete({ url: `/erp/purchase-return-items-qr/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出ERP 销售退货项二维码 Excel
|
||||
exportPurchaseReturnItemsQr: async (params) => {
|
||||
return await request.download({ url: `/erp/purchase-return-items-qr/export-excel`, params })
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// ERP 产品库存二维码 VO
|
||||
export interface StockQrVO {
|
||||
id: number // 编号
|
||||
qr: string // 二维码
|
||||
productId: number // 产品编号
|
||||
warehouseId: number // 仓库编号
|
||||
}
|
||||
|
||||
// ERP 产品库存二维码 API
|
||||
export const StockQrApi = {
|
||||
// 查询ERP 产品库存二维码分页
|
||||
getStockQrPage: async (params: any) => {
|
||||
return await request.get({ url: `/erp/stock-qr/page`, params })
|
||||
},
|
||||
|
||||
// 查询ERP 产品库存二维码详情
|
||||
getStockQr: async (id: number) => {
|
||||
return await request.get({ url: `/erp/stock-qr/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增ERP 产品库存二维码
|
||||
createStockQr: async (data: StockQrVO) => {
|
||||
return await request.post({ url: `/erp/stock-qr/create`, data })
|
||||
},
|
||||
|
||||
// 修改ERP 产品库存二维码
|
||||
updateStockQr: async (data: StockQrVO) => {
|
||||
return await request.put({ url: `/erp/stock-qr/update`, data })
|
||||
},
|
||||
|
||||
// 删除ERP 产品库存二维码
|
||||
deleteStockQr: async (id: number) => {
|
||||
return await request.delete({ url: `/erp/stock-qr/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出ERP 产品库存二维码 Excel
|
||||
exportStockQr: async (params) => {
|
||||
return await request.download({ url: `/erp/stock-qr/export-excel`, params })
|
||||
}
|
||||
}
|
||||
|
|
@ -238,6 +238,11 @@ const open = async (type: string, id?: number) => {
|
|||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await PurchaseInApi.getPurchaseIn(id)
|
||||
formData.value.items.forEach((item) => {
|
||||
if(item.ifQr===0){
|
||||
item.qrCodeLineCount = item.count
|
||||
}
|
||||
})
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,6 +289,19 @@ const submitForm = async () => {
|
|||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
await itemFormRef.value.validate()
|
||||
//校验每行的码的数量和入库数量是否一致
|
||||
const items = formData.value.items
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i]
|
||||
//先判断本行是否需要一物一码
|
||||
if (item.ifQr) {
|
||||
continue;
|
||||
}
|
||||
if (item.qrCodeLineCount !== item.count) {
|
||||
message.error(`第 ${i + 1} 行的入库数量和码的数量不同`)
|
||||
return
|
||||
}
|
||||
}
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,181 +1,166 @@
|
|||
<template>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
:disabled="disabled"
|
||||
>
|
||||
<el-table :data="formData" show-summary :summary-method="getSummaries" class="-mt-10px">
|
||||
<el-table-column label="序号" type="index" align="center" width="60" />
|
||||
<el-table-column label="仓库名称" min-width="125">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item
|
||||
:prop="`${$index}.warehouseId`"
|
||||
:rules="formRules.warehouseId"
|
||||
class="mb-0px!"
|
||||
>
|
||||
<el-select
|
||||
v-model="row.warehouseId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择仓库"
|
||||
@change="onChangeWarehouse($event, row)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in warehouseList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品名称" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.productName" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.stockCount" :formatter="erpCountInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="条码" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.productBarCode" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" min-width="80">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.productUnitName" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="已出库"
|
||||
fixed="right"
|
||||
min-width="80"
|
||||
v-if="formData[0]?.inCount != null"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.inCount" :formatter="erpCountInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="已退货"
|
||||
fixed="right"
|
||||
min-width="80"
|
||||
v-if="formData[0]?.returnCount != null"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.returnCount" :formatter="erpCountInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="count" fixed="right" min-width="140">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.count`" :rules="formRules.count" class="mb-0px!">
|
||||
<el-input-number
|
||||
v-model="row.count"
|
||||
controls-position="right"
|
||||
:min="0.001"
|
||||
:precision="3"
|
||||
class="!w-100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品单价" fixed="right" min-width="120">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.productPrice`" class="mb-0px!">
|
||||
<el-input-number
|
||||
v-model="row.productPrice"
|
||||
controls-position="right"
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
class="!w-100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" prop="totalProductPrice" fixed="right" min-width="100">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.totalProductPrice`" class="mb-0px!">
|
||||
<el-input
|
||||
disabled
|
||||
v-model="row.totalProductPrice"
|
||||
:formatter="erpPriceInputFormatter"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税率(%)" fixed="right" min-width="115">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.taxPercent`" class="mb-0px!">
|
||||
<el-input-number
|
||||
v-model="row.taxPercent"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
class="!w-100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税额" prop="taxPrice" fixed="right" min-width="120">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
|
||||
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
|
||||
<el-input disabled v-model="row.taxPrice" :formatter="erpPriceInputFormatter" />
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税额合计" prop="totalPrice" fixed="right" min-width="100">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.totalPrice`" class="mb-0px!">
|
||||
<el-input disabled v-model="row.totalPrice" :formatter="erpPriceInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="150">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.remark`" class="mb-0px!">
|
||||
<el-input v-model="row.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" fixed="right" label="操作" width="60">
|
||||
<template #default="{ $index }">
|
||||
<el-button :disabled="formData.length === 1" @click="handleDelete($index)" link>
|
||||
—
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
<div>
|
||||
<div>
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="0px"
|
||||
:inline-message="true" :disabled="disabled">
|
||||
<el-table :data="formData" show-summary :summary-method="getSummaries" class="-mt-10px">
|
||||
<el-table-column label="序号" type="index" align="center" width="60" />
|
||||
<el-table-column label="仓库名称" min-width="125">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.warehouseId`" :rules="formRules.warehouseId" class="mb-0px!">
|
||||
<el-select v-model="row.warehouseId" clearable filterable placeholder="请选择仓库"
|
||||
@change="onChangeWarehouse($event, row)">
|
||||
<el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品名称" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.productName" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.stockCount" :formatter="erpCountInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="条码" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.productBarCode" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="单位" min-width="80">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.productUnitName" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="已出库" fixed="right" min-width="80" v-if="formData[0]?.inCount != null">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.inCount" :formatter="erpCountInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="已退货" fixed="right" min-width="80" v-if="formData[0]?.returnCount != null">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.returnCount" :formatter="erpCountInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="码" fixed="right" min-width="40">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-button :disabled="row.ifQr" @click="openQrDialog($index)" link>
|
||||
<Icon icon="fa:qrcode" />
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="count" fixed="right" min-width="140">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.count`" :rules="formRules.count" class="mb-0px!">
|
||||
<el-input-number v-model="row.count" controls-position="right" :min="0.001" :precision="3"
|
||||
class="!w-100%" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品单价" fixed="right" min-width="120">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.productPrice`" class="mb-0px!">
|
||||
<el-input-number v-model="row.productPrice" controls-position="right" :min="0.01" :precision="2"
|
||||
class="!w-100%" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" prop="totalProductPrice" fixed="right" min-width="100">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.totalProductPrice`" class="mb-0px!">
|
||||
<el-input disabled v-model="row.totalProductPrice" :formatter="erpPriceInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税率(%)" fixed="right" min-width="115">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.taxPercent`" class="mb-0px!">
|
||||
<el-input-number v-model="row.taxPercent" controls-position="right" :min="0" :precision="2"
|
||||
class="!w-100%" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税额" prop="taxPrice" fixed="right" min-width="120">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
|
||||
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
|
||||
<el-input disabled v-model="row.taxPrice" :formatter="erpPriceInputFormatter" />
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税额合计" prop="totalPrice" fixed="right" min-width="100">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.totalPrice`" class="mb-0px!">
|
||||
<el-input disabled v-model="row.totalPrice" :formatter="erpPriceInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="150">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.remark`" class="mb-0px!">
|
||||
<el-input v-model="row.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" fixed="right" label="操作" width="60">
|
||||
<template #default="{ $index }">
|
||||
<el-button :disabled="formData.length === 1" @click="handleDelete($index)" link>
|
||||
—
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<!-- 一物一码扫码弹窗 -->
|
||||
<Dialog :title="productName" v-model="qrDialogVisible" :appendToBody="true">
|
||||
<!-- 显示有效行数 -->
|
||||
<div>输入的有效行数: {{ qrCodeLineCount }}</div>
|
||||
<div>需要扫描数: {{ qrNeedCount }}</div>
|
||||
|
||||
<el-input type="textarea" v-model="qrCodes" :rows="10" @input="onQrCodeChange" />
|
||||
<template #footer>
|
||||
<el-button @click="submitQr" type="primary">
|
||||
确 定
|
||||
</el-button>
|
||||
<el-button @click="qrDialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { WarehouseApi as WarehouseLocactionApi, WarehouseLocationVO } from '@/api/erp/warehouse'
|
||||
|
||||
import { StockApi } from '@/api/erp/stock/stock'
|
||||
import {
|
||||
erpCountInputFormatter,
|
||||
erpPriceInputFormatter,
|
||||
erpPriceMultiply,
|
||||
getSumValue
|
||||
getSumValue,
|
||||
matchRulesFromDictOptions
|
||||
|
||||
} from '@/utils'
|
||||
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
|
||||
|
||||
|
|
@ -193,6 +178,67 @@ const formRules = reactive({
|
|||
const formRef = ref([]) // 表单 Ref
|
||||
const warehouseList = ref<WarehouseVO[]>([]) // 仓库列表
|
||||
const defaultWarehouse = ref<WarehouseVO>(undefined) // 默认仓库
|
||||
//一物一码弹窗
|
||||
const qrDialogVisible = ref(false)
|
||||
// 扫码内容
|
||||
const qrCodes = ref('')
|
||||
// 当前点击行
|
||||
const currentRow = ref<typeof props.items[0]>(undefined)
|
||||
// 当前行号
|
||||
const currentRowIndex = ref(-1)
|
||||
// 一物一码弹窗名
|
||||
const productName = ref('')
|
||||
// 记录二维码文本域中的有效行数
|
||||
const qrCodeLineCount = ref(0);
|
||||
const message = useMessage() // 消息弹窗
|
||||
// 需要扫描二维码个数
|
||||
const qrNeedCount = computed(() => {
|
||||
return currentRow.value?.count
|
||||
})
|
||||
// 监听二维码文本域内容的变化
|
||||
const onQrCodeChange = () => {
|
||||
// 检查 qrCode.value 是否为 undefined 或 null
|
||||
if (qrCodes.value) {
|
||||
const lines = qrCodes.value.split('\n');
|
||||
// 先将每一行去除首尾空格
|
||||
const trimmedLines = lines.map(line => line.trim());
|
||||
const validLines = trimmedLines.filter(line =>{
|
||||
return matchRulesFromDictOptions(line)
|
||||
});
|
||||
// 去重
|
||||
const uniqueLines = [...new Set(validLines)];
|
||||
qrCodeLineCount.value = uniqueLines.length;
|
||||
|
||||
// 检查有效行数是否超过 row.count
|
||||
if (currentRow.value && qrCodeLineCount.value > currentRow.value.count) {
|
||||
message.warning('输入的有效行数不能超过该产品的数量!');
|
||||
// 截取多余的行数
|
||||
qrCodes.value = validLines.slice(0, currentRow.value.count).join('\n');
|
||||
qrCodeLineCount.value = currentRow.value.count;
|
||||
}
|
||||
} else {
|
||||
qrCodeLineCount.value = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/** 提交扫码 */
|
||||
const submitQr = async () => {
|
||||
// 扫码内容不能为空
|
||||
if (qrCodes.value == null || qrCodes.value == undefined || qrCodes.value === '') {
|
||||
return;
|
||||
}
|
||||
// 找到当前行在 formData 中的索引
|
||||
const index = currentRowIndex.value; // 获取当前行的索引
|
||||
if (index !== -1 && formData.value[index]) { // 确保索引有效且对应行存在
|
||||
// 更新 formData 中对应行的 qrcode 值
|
||||
formData.value[index].qrcodes = qrCodes.value;
|
||||
//更新有效行数
|
||||
formData.value[index].qrCodeLineCount = qrCodeLineCount.value;
|
||||
}
|
||||
// 关闭弹窗
|
||||
qrDialogVisible.value = false;
|
||||
};
|
||||
|
||||
|
||||
/** 初始化设置出库项 */
|
||||
watch(
|
||||
|
|
@ -232,6 +278,25 @@ watch(
|
|||
{ deep: true }
|
||||
)
|
||||
|
||||
// 控制一物一码弹窗
|
||||
const openQrDialog = (index: number) => {
|
||||
// 确保 currentRow 更新为当前点击的行
|
||||
currentRow.value = formData.value[index]; // 使用解构赋值确保创建一个新对象
|
||||
currentRowIndex.value = index;
|
||||
// 检查当前行是否有二维码数据
|
||||
if (currentRow.value.qrcodes) {
|
||||
qrCodes.value = currentRow.value.qrcodes;
|
||||
} else {
|
||||
qrCodes.value = ''; // 如果没有二维码数据,清空文本域
|
||||
}
|
||||
// 更新弹窗标题
|
||||
productName.value = currentRow.value.productName;
|
||||
// 重新计算有效行数
|
||||
onQrCodeChange();
|
||||
// 显示弹窗
|
||||
qrDialogVisible.value = true;
|
||||
};
|
||||
|
||||
/** 合计 */
|
||||
const getSummaries = (param: SummaryMethodProps) => {
|
||||
const { columns, data } = param
|
||||
|
|
@ -253,6 +318,36 @@ const getSummaries = (param: SummaryMethodProps) => {
|
|||
return sums
|
||||
}
|
||||
|
||||
|
||||
//仓库变更,同步变更货位列表
|
||||
const onChangeWarehouse = async (row: typeof props.items[0]) => {
|
||||
queryLocationParams.warehouseId = row.warehouseId;
|
||||
try {
|
||||
const response = await WarehouseLocactionApi.getWarehouseLocationPage(queryLocationParams);
|
||||
if (response) {
|
||||
if (response.list.length !== 0) {
|
||||
locationList.value = response.list;
|
||||
} else {
|
||||
console.error('获取货位列表失败,错误码:', response.code, ',错误信息:', response.msg);
|
||||
}
|
||||
} else {
|
||||
console.error('获取货位列表失败,响应为空');
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error.response) {
|
||||
// Axios错误,有响应体
|
||||
console.error('获取货位列表失败,HTTP错误码:', error.response.status, ',错误信息:', error.response.data);
|
||||
} else if (error.request) {
|
||||
// 发出了请求,但没有收到响应
|
||||
console.error('获取货位列表失败,没有收到响应');
|
||||
} else {
|
||||
// 其他错误
|
||||
console.error('获取货位列表时发生错误:', error.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
const row = {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="二维码" prop="qr">
|
||||
<el-input v-model="formData.qr" placeholder="请输入二维码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品编号" prop="productId">
|
||||
<el-select v-model="formData.productId" placeholder="请选择产品编号">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库编号" prop="warehouseId">
|
||||
<el-input v-model="formData.warehouseId" placeholder="请输入仓库编号" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { StockQrApi, StockQrVO } from '@/api/erp/stock/stock/stockqr'
|
||||
|
||||
/** ERP 产品库存二维码 表单 */
|
||||
defineOptions({ name: 'StockQrForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
qr: undefined,
|
||||
productId: undefined,
|
||||
warehouseId: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
qr: [{ required: true, message: '二维码不能为空', trigger: 'blur' }],
|
||||
productId: [{ required: true, message: '产品编号不能为空', trigger: 'change' }],
|
||||
warehouseId: [{ required: true, message: '仓库编号不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await StockQrApi.getStockQr(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as StockQrVO
|
||||
if (formType.value === 'create') {
|
||||
await StockQrApi.createStockQr(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await StockQrApi.updateStockQr(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
qr: undefined,
|
||||
productId: undefined,
|
||||
warehouseId: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="二维码" prop="qr">
|
||||
<el-input
|
||||
v-model="queryParams.qr"
|
||||
placeholder="请输入二维码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品编号" prop="productId">
|
||||
<el-select
|
||||
v-model="queryParams.productId"
|
||||
placeholder="请选择产品编号"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库编号" prop="warehouseId">
|
||||
<el-input
|
||||
v-model="queryParams.warehouseId"
|
||||
placeholder="请输入仓库编号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-220px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['erp:stock-qr:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['erp:stock-qr:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="编号" align="center" prop="id" />
|
||||
<el-table-column label="二维码" align="center" prop="qr" />
|
||||
<el-table-column label="产品编号" align="center" prop="productId" />
|
||||
<el-table-column label="仓库编号" align="center" prop="warehouseId" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" min-width="120px">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['erp:stock-qr:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['erp:stock-qr:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<StockQrForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { StockQrApi, StockQrVO } from '@/api/erp/stock/stock/stockqr'
|
||||
import StockQrForm from './StockQrForm.vue'
|
||||
|
||||
/** ERP 产品库存二维码 列表 */
|
||||
defineOptions({ name: 'ErpStockQr' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<StockQrVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
qr: undefined,
|
||||
productId: undefined,
|
||||
warehouseId: undefined,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await StockQrApi.getStockQrPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await StockQrApi.deleteStockQr(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await StockQrApi.exportStockQr(queryParams)
|
||||
download.excel(data, 'ERP 产品库存二维码.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue