修复采购入库,修改必须点击一次二维码的bug

pull/744/head
没钱 2025-03-17 16:02:12 +08:00
parent ec1b0a80f5
commit 432022ef86
7 changed files with 691 additions and 170 deletions

View File

@ -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 })
}
}

View File

@ -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 })
}
}

View File

@ -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
}

View File

@ -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 {

View File

@ -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 = {

View File

@ -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) // 12
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>

View File

@ -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>