Commit f3d69c31 by yubin

修bug

parent e57792fc
...@@ -16,16 +16,15 @@ ...@@ -16,16 +16,15 @@
<!-- 页面容器 --> <!-- 页面容器 -->
<div class="page-container"> <div class="page-container">
<!-- 物料查询表单 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="主订单号" prop="mainOrderId"> <!-- <el-form-item label="主订单号" prop="orderId">
<el-input <el-input
v-model="queryParams.mainOrderId" v-model="queryParams.orderId"
placeholder="请输入主订单号" placeholder="请输入主订单号"
clearable clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item> -->
<el-form-item label="时间段" prop="dateRange"> <el-form-item label="时间段" prop="dateRange">
<el-date-picker <el-date-picker
v-model="queryParams.dateRange" v-model="queryParams.dateRange"
...@@ -253,7 +252,7 @@ ...@@ -253,7 +252,7 @@
style="width: 100%" style="width: 100%"
> >
<el-table-column type="index" label="序号" width="60" align="center" /> <el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column label="主订单号" align="center" prop="mainOrderId" width="150" /> <el-table-column label="主订单号" align="center" prop="orderId" width="150" />
<el-table-column label="物料名称" align="center" prop="materialName" min-width="150" show-overflow-tooltip /> <el-table-column label="物料名称" align="center" prop="materialName" min-width="150" show-overflow-tooltip />
<el-table-column label="批次" align="center" prop="batchCode" width="120" /> <el-table-column label="批次" align="center" prop="batchCode" width="120" />
<el-table-column label="仓库" align="center" prop="warehouseName" width="120" /> <el-table-column label="仓库" align="center" prop="warehouseName" width="120" />
...@@ -314,7 +313,7 @@ export default { ...@@ -314,7 +313,7 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
mainOrderId: null, orderId: null,
startDate: null, startDate: null,
endDate: null, endDate: null,
ownerId: null, ownerId: null,
...@@ -339,7 +338,7 @@ export default { ...@@ -339,7 +338,7 @@ export default {
detailQueryParams: { detailQueryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
mainOrderId: null, orderId: null,
materialId: null, materialId: null,
warehouseId: null, warehouseId: null,
warehousesCode: null, warehousesCode: null,
...@@ -466,7 +465,7 @@ export default { ...@@ -466,7 +465,7 @@ export default {
this.detailQueryParams = { this.detailQueryParams = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
mainOrderId: row.mainOrderId, orderId: row.orderId,
materialId: row.materialId, materialId: row.materialId,
warehouseId: null, warehouseId: null,
warehousesCode: null, warehousesCode: null,
......
...@@ -121,6 +121,41 @@ ...@@ -121,6 +121,41 @@
</div> </div>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="计划数量" prop="plannedQuantity" required>
<el-input
v-model.number="currentSelectedRow.plannedQuantity"
type="number"
min="1"
:max="(currentSelectedRow.quantity || 0) - (currentSelectedRow.lockedQuantity || 0)"
@input="handleRowPlannedQtyInput(currentSelectedRow); syncDetails(false)"
placeholder="输入计划数量"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="单价" prop="unitPrice" required>
<el-input
v-model.number="currentSelectedRow.unitPrice"
placeholder="请输入单价"
type="number"
min="0"
step="0.01"
@input="syncDetails(false)"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="凭证号" prop="voucherNumber">
<el-input
v-model="currentSelectedRow.voucherNumber"
placeholder="请输入凭证号"
@input="syncDetails(false)"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20" style="margin-top: 10px;">
<el-col :span="8">
<el-form-item label="约数" prop="divisor"> <el-form-item label="约数" prop="divisor">
<el-input <el-input
v-model.number="currentSelectedRow.divisor" v-model.number="currentSelectedRow.divisor"
...@@ -148,32 +183,6 @@ ...@@ -148,32 +183,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="计划数量" prop="plannedQuantity">
<el-input
v-model.number="currentSelectedRow.plannedQuantity"
type="number"
min="1"
:max="(currentSelectedRow.quantity || 0) - (currentSelectedRow.lockedQuantity || 0)"
@input="handleRowPlannedQtyInput(currentSelectedRow); syncDetails(false)"
placeholder="输入计划数量"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20" style="margin-top: 10px;">
<el-col :span="8">
<el-form-item label="单价" prop="unitPrice">
<el-input
v-model.number="currentSelectedRow.unitPrice"
placeholder="请输入单价"
type="number"
min="0"
step="0.01"
@input="syncDetails(false)"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="发货方" prop="shippedBy"> <el-form-item label="发货方" prop="shippedBy">
<el-input <el-input
v-model="currentSelectedRow.shippedBy" v-model="currentSelectedRow.shippedBy"
...@@ -182,16 +191,8 @@ ...@@ -182,16 +191,8 @@
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-form-item label="凭证号" prop="voucherNumber">
<el-input
v-model="currentSelectedRow.voucherNumber"
placeholder="请输入凭证号"
@input="syncDetails(false)"
/>
</el-form-item>
</el-col>
</el-row> </el-row>
<el-row :gutter="20" style="margin-top: 10px;"> <el-row :gutter="20" style="margin-top: 10px;">
<el-col :span="16"> <el-col :span="16">
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
...@@ -226,6 +227,7 @@ ...@@ -226,6 +227,7 @@
<el-table-column prop="batchId" label="批次ID" width="150" /> <el-table-column prop="batchId" label="批次ID" width="150" />
<el-table-column prop="warehousesName" label="仓库名称" width="120" /> <el-table-column prop="warehousesName" label="仓库名称" width="120" />
<el-table-column prop="locationName" label="库位名称" width="120" /> <el-table-column prop="locationName" label="库位名称" width="120" />
<el-table-column prop="plannedQuantity" label="计划数量" width="100" /> <el-table-column prop="plannedQuantity" label="计划数量" width="100" />
<el-table-column prop="actualQuantity" label="实际数量" width="100" fixed="right"/> <el-table-column prop="actualQuantity" label="实际数量" width="100" fixed="right"/>
<el-table-column prop="unitPrice" label="单价" width="100" /> <el-table-column prop="unitPrice" label="单价" width="100" />
...@@ -637,31 +639,18 @@ syncDetails(strict = true) { ...@@ -637,31 +639,18 @@ syncDetails(strict = true) {
if (row.plannedQuantity > availableQty) { if (row.plannedQuantity > availableQty) {
rowErrors.push(`计划数量不能超过可用库存(${availableQty})`); rowErrors.push(`计划数量不能超过可用库存(${availableQty})`);
} }
}else{
rowErrors.push(`请填写计划数量`);
} }
// 3. 除数(有值才校验,无值不提示) // 3. 除数(有值才校验,无值不提示)
if (row.divisor !== null && row.divisor !== undefined) { if (row.unitPrice !== null && row.unitPrice !== undefined) {
// 若有值但为0/负数,可补充校验(按需) // 若有值但为0/负数,可补充校验(按需)
if (row.divisor <= 0) { if (row.unitPrice <= 0) {
rowErrors.push('换算率(除数)必须大于0'); rowErrors.push('请填写单价');
} }
} }
// 4. 标签颜色(有值才校验,空字符串算不合规)
if (row.labelColor !== undefined && row.labelColor === '') {
rowErrors.push('请填写标签颜色');
}
// 5. 凭证号(有值才校验,空字符串算不合规)
if (row.voucherNumber !== undefined && row.voucherNumber === '') {
rowErrors.push('请填写凭证号');
}
// 6. 发货人(有值才校验,空字符串算不合规)
if (row.shippedBy !== undefined && row.shippedBy === '') {
rowErrors.push('请填写发货人');
}
// 收集当前行的错误(仅有值但不合规的字段) // 收集当前行的错误(仅有值但不合规的字段)
if (rowErrors.length > 0) { if (rowErrors.length > 0) {
errorMessages.push(`${rowName}${rowErrors.join('、')}`); errorMessages.push(`${rowName}${rowErrors.join('、')}`);
......
...@@ -125,6 +125,16 @@ ...@@ -125,6 +125,16 @@
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="出库日期" prop="inboundDate">
<el-date-picker
clearable
v-model="queryParams.inboundDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择出库日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="订单状态" prop="orderStatus"> <el-form-item label="订单状态" prop="orderStatus">
<el-select <el-select
v-model="queryParams.orderStatus" v-model="queryParams.orderStatus"
...@@ -140,16 +150,6 @@ ...@@ -140,16 +150,6 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="出库日期" prop="inboundDate">
<el-date-picker
clearable
v-model="queryParams.inboundDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择出库日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="目的地" prop="destination"> <el-form-item label="目的地" prop="destination">
<el-input <el-input
v-model="queryParams.destination" v-model="queryParams.destination"
...@@ -255,6 +255,7 @@ ...@@ -255,6 +255,7 @@
v-if="scope.row.orderStatus===1" v-if="scope.row.orderStatus===1"
@click="handleShip(scope.row)" @click="handleShip(scope.row)"
v-hasPermi="['inventory:orders:edit']" v-hasPermi="['inventory:orders:edit']"
:loading="shipLoading[scope.row.id]"
>出货</el-button> >出货</el-button>
<el-button <el-button
size="mini" size="mini"
...@@ -310,28 +311,7 @@ ...@@ -310,28 +311,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- 新增:订单类型表单项 --> <!-- 新增:订单类型表单项 -->
<el-col :span="12"> <el-col :span="12">
<el-form-item label="订单类型" prop="orderType">
<el-select v-model="form.orderType" placeholder="请选择订单类型" :disabled="isViewDetail || formDisabled.orderType" style="width: 100%">
<el-option
v-for="item in dict.type.order_type"
:key="item.value"
:label="item.label"
:value="item.value"
>
<span style="margin-left: 8px;">{{ item.label }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="批次ID" prop="batchCode">
<el-input v-model="form.batchCode" placeholder="请输入批次ID" :disabled="isViewDetail || formDisabled.batchCode" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="仓库" prop="warehouseId"> <el-form-item label="仓库" prop="warehouseId">
<el-input <el-input
v-model="form.warehouseName" v-model="form.warehouseName"
...@@ -356,6 +336,26 @@ ...@@ -356,6 +336,26 @@
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="批次ID" prop="batchCode">
<el-input v-model="form.batchCode" placeholder="请输入批次ID" :disabled="isViewDetail || formDisabled.batchCode" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="出库日期" prop="inboundDate">
<el-date-picker
clearable
v-model="form.inboundDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择出库日期"
:disabled="isViewDetail"
style="width: 100%"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="货主" prop="ownerId"> <el-form-item label="货主" prop="ownerId">
<el-input <el-input
v-model="form.ownerName" v-model="form.ownerName"
...@@ -377,19 +377,22 @@ ...@@ -377,19 +377,22 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="出库日期" prop="inboundDate"> <el-form-item label="订单类型" prop="orderType">
<el-date-picker <el-select v-model="form.orderType" placeholder="请选择订单类型" :disabled="isViewDetail || formDisabled.orderType" style="width: 100%">
clearable <el-option
v-model="form.inboundDate" v-for="item in dict.type.order_type"
type="date" :key="item.value"
value-format="yyyy-MM-dd" :label="item.label"
placeholder="请选择出库日期" :value="item.value"
:disabled="isViewDetail" >
style="width: 100%" <span style="margin-left: 8px;">{{ item.label }}</span>
/> </el-option>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
...@@ -514,20 +517,19 @@ ...@@ -514,20 +517,19 @@
@selected="handleLocationSelected" @selected="handleLocationSelected"
/> />
<import-excel <import-excel
ref="import" ref="import"
title="导入" title="导入"
import-url="/inventory/orders/import" import-url="/inventory/orders/import"
template-url="/inventory/orders/importTemplate" template-url="/inventory/orders/importTemplate"
template-name="出库单导入模板" template-name="出库单导入模板"
@success="getList" @success="getList"
:show-trdc-checkbox="true" :show-trdc-checkbox="true"
@orderTypeChange="handleOrderTypeChange" @orderTypeChange="handleOrderTypeChange"
:orderTypeRequired="true" :orderTypeRequired="true"
/> />
</div> </div>
</template> </template>
<script> <script>
import { listOrders, getOrders, delOrders, addOrders, updateOrders, ship } from "@/api/inventory/orders" import { listOrders, getOrders, delOrders, addOrders, updateOrders, ship } from "@/api/inventory/orders"
import { getMaterialsdicts } from "@/api/inventory/materials" import { getMaterialsdicts } from "@/api/inventory/materials"
...@@ -557,6 +559,8 @@ export default { ...@@ -557,6 +559,8 @@ export default {
tableKey: 1, tableKey: 1,
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 出货loading(按订单ID存储,支持多订单同时操作)
shipLoading: {}, // 新增:出货loading状态
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -657,9 +661,9 @@ export default { ...@@ -657,9 +661,9 @@ export default {
rules: { rules: {
orderId: [{ required: true, message: '请输入出库单号', trigger: 'blur' }], orderId: [{ required: true, message: '请输入出库单号', trigger: 'blur' }],
warehouseId: [{ required: true, message: '请选择仓库', trigger: 'blur' }], warehouseId: [{ required: true, message: '请选择仓库', trigger: 'blur' }],
ownerId: [{ required: true, message: '请选择货主', trigger: 'blur' }],
inboundDate: [{ required: true, message: '请选择出库日期', trigger: 'change' }], inboundDate: [{ required: true, message: '请选择出库日期', trigger: 'change' }],
orderType: [{ required: true, message: '请选择订单类型', trigger: 'change' }], // 新增:订单类型校验 orderTypeId: [{ required: true, message: '请选择出库类型', trigger: 'change' }],
batchCode: [{ required: true, message: '请选输入批次号', trigger: 'change' }],
}, },
// 货主/仓库选择相关 // 货主/仓库选择相关
ownerSelectorVisible: false, ownerSelectorVisible: false,
...@@ -678,13 +682,28 @@ export default { ...@@ -678,13 +682,28 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.getList() this.getList()
}) })
this.handleShip = this.debounce(this.handleShip, 500)
}, },
methods: { methods: {
handleOrderTypeChange(selection) { debounce(fn, delay = 300) {
let timer = null;
let pendingPromise = null;
return async function(...args) {
if (timer) clearTimeout(timer);
pendingPromise = new Promise((resolve) => {
timer = setTimeout(async () => {
const result = await fn.apply(this, args);
resolve(result);
timer = null;
}, delay);
});
return pendingPromise;
};
},
handleOrderTypeChange(selection) {
this.form.orderTypeId = selection this.form.orderTypeId = selection
}, },
/** 打开导入弹窗 */ /** 打开导入弹窗 */
handleImport() { handleImport() {
this.$refs.import.show() this.$refs.import.show()
}, },
...@@ -722,24 +741,24 @@ export default { ...@@ -722,24 +741,24 @@ export default {
this.ownerSelectorVisible = true this.ownerSelectorVisible = true
}, },
// 货主选择回调(核心缺失方法) // 货主选择回调(核心缺失方法)
handleOwnerSelected(owner) { handleOwnerSelected(owner) {
if (!owner) return if (!owner) return
if (this.ownerSelectTarget === 'query') { if (this.ownerSelectTarget === 'query') {
this.queryParams.ownerId = owner.ownerId || owner.id this.queryParams.ownerId = owner.ownerId || owner.id
this.queryOwnerName = owner.ownerName || owner.name this.queryOwnerName = owner.ownerName || owner.name
this.handleQuery() this.handleQuery()
} else { } else {
this.form.ownerId = owner.ownerId || owner.id this.form.ownerId = owner.ownerId || owner.id
this.form.ownerName = owner.ownerName || owner.name this.form.ownerName = owner.ownerName || owner.name
// 更新明细中的默认货主(可选) // 更新明细中的默认货主(可选)
if (this.currentDetailItem) { if (this.currentDetailItem) {
this.currentDetailItem.ownerId = owner.ownerId || owner.id this.currentDetailItem.ownerId = owner.ownerId || owner.id
this.currentDetailItem.ownerName = owner.ownerName || owner.name this.currentDetailItem.ownerName = owner.ownerName || owner.name
} }
} }
this.ownerSelectorVisible = false this.ownerSelectorVisible = false
}, },
// 打开仓库选择器 // 打开仓库选择器
openWarehouseSelector(target = 'form') { openWarehouseSelector(target = 'form') {
this.warehouseSelectTarget = target this.warehouseSelectTarget = target
...@@ -796,26 +815,35 @@ handleOwnerSelected(owner) { ...@@ -796,26 +815,35 @@ handleOwnerSelected(owner) {
calcGroupAmount(items) { calcGroupAmount(items) {
return items.reduce((sum, item) => sum + (Number(item.amount) || 0), 0).toFixed(2) return items.reduce((sum, item) => sum + (Number(item.amount) || 0), 0).toFixed(2)
}, },
// 核心出货方法 // 核心出货方法(添加loading+弹窗确认)
async handleShip(row) { async handleShip(row) {
try { // 新增:出货前弹窗确认
// 调用ship接口提交数据到后端 this.$modal.confirm(`是否确认对出库单【${row.orderId}】执行出货操作?`).then(async () => {
console.log("handleShip",row) try {
await ship({ // 设置当前订单出货loading
...row, this.$set(this.shipLoading, row.id, true)
orderId: row.orderId, // 用户填写的出货单号
outboundOrderId: row.id // 主表ID作为outboundOrderId // 原有业务逻辑
}) console.log("handleShip", row)
await ship({
// 提示成功并刷新列表 ...row,
this.$modal.msgSuccess("出货操作成功,数据已提交到后端") orderId: row.orderId, // 用户填写的出货单号
this.getList() outboundOrderId: row.id // 主表ID作为outboundOrderId
} catch (error) { })
// 错误处理 // 提示成功并刷新列表
this.$modal.msgError(error.msg || "出货操作失败") this.$modal.msgSuccess("出货操作成功,数据已提交到后端")
} this.getList()
}, } catch (error) {
// 修复:获取要传递给子组件的初始化明细数据(按物料分组) // 错误处理
this.$modal.msgError(error.msg || "出货操作失败")
} finally {
// 关闭loading
this.$delete(this.shipLoading, row.id)
}
}).catch(() => {
// 取消确认时不执行任何操作
})
}, // 修复:获取要传递给子组件的初始化明细数据(按物料分组)
getInitDetails() { getInitDetails() {
// 编辑场景:传递当前物料分组的所有明细(确保子组件反显) // 编辑场景:传递当前物料分组的所有明细(确保子组件反显)
if (this.isEditDetail && this.currentMaterialId) { if (this.isEditDetail && this.currentMaterialId) {
...@@ -941,116 +969,116 @@ handleOwnerSelected(owner) { ...@@ -941,116 +969,116 @@ handleOwnerSelected(owner) {
this.detailDialogOpen = true this.detailDialogOpen = true
}) })
}, },
handleDetailSubmit(details) { handleDetailSubmit(details) {
// 确保是数组格式 // 确保是数组格式
const detailList = Array.isArray(details) ? details : [details]; const detailList = Array.isArray(details) ? details : [details];
if (detailList.length === 0) { if (detailList.length === 0) {
this.$message.warning("请填写明细数据"); this.$message.warning("请填写明细数据");
return; return;
} }
const materialId = this.currentMaterialId || detailList[0]?.materialId;
if (!materialId) {
this.$message.warning("物料ID不能为空");
return;
}
// 初始化物料分组
if (!this.outboundOrderItemsGroup[materialId]) {
this.outboundOrderItemsGroup[materialId] = {
materialId: materialId,
materialName: detailList[0]?.materialName || '', // 【修改9】初始化分组的物料名称
items: []
};
}
const group = this.outboundOrderItemsGroup[materialId];
if (this.isEditDetail) { const materialId = this.currentMaterialId || detailList[0]?.materialId;
// 修复:编辑模式 - 全量替换分组数据(而非追加) if (!materialId) {
const newDetails = detailList.map((item, idx) => { this.$message.warning("物料ID不能为空");
const amount = (Number(item.actualQuantity) || 0) * (Number(item.unitPrice) || 0); return;
return { }
...item,
index: idx + 1,
orderId: null, // 明细的orderId设为空
outboundOrderId: this.form.id, // 使用主表ID作为outboundOrderId
materialId: materialId,
materialName: item.materialName || group.materialName || '', // 【修改10】保留物料名称
inventoryId: item.inventoryId || '',
itemStatus: Number(item.itemStatus) || 1,
labelColor: Number(item.labelColor) || 0,
divisor: Number(item.divisor) || 1,
shippedAt: this.form.inboundDate,
plannedQuantity: Number(item.plannedQuantity) || 0,
actualQuantity: Number(item.actualQuantity) || 0,
unitPrice: Number(item.unitPrice) || 0.00,
amount: amount,
isUsed: 1,
sortNo: 0,
remark: item.remark || '',
warehouseName: item.warehouseName || this.form.warehouseName || '',
locationName: item.locationName || '',
batchCode: item.batchId || '' // 新增:将子组件的batchId赋值给batchCode
};
});
// 全量替换分组数据 // 初始化物料分组
group.items = newDetails; if (!this.outboundOrderItemsGroup[materialId]) {
// 更新分组的物料名称(取第一条的物料名称) this.outboundOrderItemsGroup[materialId] = {
group.materialName = newDetails[0]?.materialName || group.materialName;
this.$message.success(`成功编辑${materialId}物料组,共${newDetails.length}条明细`);
} else {
// 新增模式:按库存ID去重后追加
const existingInventoryIds = new Set(group.items.map(item => item.inventoryId));
const newDetails = detailList
.filter(item => item.inventoryId && !existingInventoryIds.has(item.inventoryId))
.map((item, idx) => {
const newIndex = group.items.length + idx + 1;
const amount = (Number(item.actualQuantity) || 0) * (Number(item.unitPrice) || 0);
return {
...item,
index: newIndex,
orderId: null, // 明细的orderId设为空
outboundOrderId: this.form.id || null, // 使用主表ID作为outboundOrderId
materialId: materialId, materialId: materialId,
materialName: item.materialName || '', // 【修改11】保留物料名称 materialName: detailList[0]?.materialName || '', // 【修改9】初始化分组的物料名称
inventoryId: item.inventoryId || '', items: []
itemStatus: Number(item.itemStatus) || 1,
labelColor: Number(item.labelColor) || 0,
divisor: Number(item.divisor) || 1,
plannedQuantity: Number(item.plannedQuantity) || 0,
actualQuantity: Number(item.actualQuantity) || 0,
unitPrice: Number(item.unitPrice) || 0.00,
amount: amount,
isUsed: 1,
sortNo: 0,
remark: item.remark || '',
warehouseName: item.warehouseName || this.form.warehouseName || '',
locationName: item.locationName || '',
batchCode: item.batchId || '' // 新增:将子组件的batchId赋值给batchCode
}; };
}); }
const group = this.outboundOrderItemsGroup[materialId];
if (newDetails.length === 0) { if (this.isEditDetail) {
this.$message.warning("该库存明细已存在,无法重复添加"); // 修复:编辑模式 - 全量替换分组数据(而非追加)
this.detailDialogOpen = false; const newDetails = detailList.map((item, idx) => {
return; const amount = (Number(item.actualQuantity) || 0) * (Number(item.unitPrice) || 0);
} return {
...item,
index: idx + 1,
orderId: null, // 明细的orderId设为空
outboundOrderId: this.form.id, // 使用主表ID作为outboundOrderId
materialId: materialId,
materialName: item.materialName || group.materialName || '', // 【修改10】保留物料名称
inventoryId: item.inventoryId || '',
itemStatus: Number(item.itemStatus) || 1,
labelColor: Number(item.labelColor) || 0,
divisor: Number(item.divisor) || 1,
shippedAt: this.form.inboundDate,
plannedQuantity: Number(item.plannedQuantity) || 0,
actualQuantity: Number(item.actualQuantity) || 0,
unitPrice: Number(item.unitPrice) || 0.00,
amount: amount,
isUsed: 1,
sortNo: 0,
remark: item.remark || '',
warehouseName: item.warehouseName || this.form.warehouseName || '',
locationName: item.locationName || '',
batchCode: item.batchId || '' // 新增:将子组件的batchId赋值给batchCode
};
});
group.items = [...group.items, ...newDetails]; // 全量替换分组数据
// 更新分组的物料名称(如果为空,取第一条的物料名称) group.items = newDetails;
if (!group.materialName) { // 更新分组的物料名称(取第一条的物料名称)
group.materialName = newDetails[0]?.materialName || ''; group.materialName = newDetails[0]?.materialName || group.materialName;
} this.$message.success(`成功编辑${materialId}物料组,共${newDetails.length}条明细`);
this.$message.success(`成功新增${newDetails.length}条明细`); } else {
} // 新增模式:按库存ID去重后追加
const existingInventoryIds = new Set(group.items.map(item => item.inventoryId));
const newDetails = detailList
.filter(item => item.inventoryId && !existingInventoryIds.has(item.inventoryId))
.map((item, idx) => {
const newIndex = group.items.length + idx + 1;
const amount = (Number(item.actualQuantity) || 0) * (Number(item.unitPrice) || 0);
return {
...item,
index: newIndex,
orderId: null, // 明细的orderId设为空
outboundOrderId: this.form.id || null, // 使用主表ID作为outboundOrderId
materialId: materialId,
materialName: item.materialName || '', // 【修改11】保留物料名称
inventoryId: item.inventoryId || '',
itemStatus: Number(item.itemStatus) || 1,
labelColor: Number(item.labelColor) || 0,
divisor: Number(item.divisor) || 1,
plannedQuantity: Number(item.plannedQuantity) || 0,
actualQuantity: Number(item.actualQuantity) || 0,
unitPrice: Number(item.unitPrice) || 0.00,
amount: amount,
isUsed: 1,
sortNo: 0,
remark: item.remark || '',
warehouseName: item.warehouseName || this.form.warehouseName || '',
locationName: item.locationName || '',
batchCode: item.batchId || '' // 新增:将子组件的batchId赋值给batchCode
};
});
if (newDetails.length === 0) {
this.$message.warning("该库存明细已存在,无法重复添加");
this.detailDialogOpen = false;
return;
}
group.items = [...group.items, ...newDetails];
// 更新分组的物料名称(如果为空,取第一条的物料名称)
if (!group.materialName) {
group.materialName = newDetails[0]?.materialName || '';
}
this.$message.success(`成功新增${newDetails.length}条明细`);
}
// 重新计算总数和总金额 // 重新计算总数和总金额
this.calcTotalQuantity(); this.calcTotalQuantity();
this.detailDialogOpen = false; this.detailDialogOpen = false;
// 强制更新视图 // 强制更新视图
this.$forceUpdate(); this.$forceUpdate();
}, },
// 计算主表总数量和总金额 // 计算主表总数量和总金额
calcTotalQuantity() { calcTotalQuantity() {
let totalPlanned = 0 let totalPlanned = 0
...@@ -1213,28 +1241,28 @@ handleDetailSubmit(details) { ...@@ -1213,28 +1241,28 @@ handleDetailSubmit(details) {
resetQuery() { resetQuery() {
// 检查ref存在性 // 检查ref存在性
if (this.$refs.queryForm) { if (this.$refs.queryForm) {
this.queryParams= { this.queryParams = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
orderId: null, orderId: null,
systemNo: null, systemNo: null,
orderTypeId: null, orderTypeId: null,
orderType: null, // 新增:订单类型重置 orderType: null, // 新增:订单类型重置
batchCode: null, batchCode: null,
warehouseId: null, warehouseId: null,
ownerId: null, ownerId: null,
orderStatus: null, orderStatus: null,
inboundDate: null, inboundDate: null,
destination: null, destination: null,
totalPlannedQuantity: null, totalPlannedQuantity: null,
totalActualQuantity: null, totalActualQuantity: null,
totalPackages: null, totalPackages: null,
isUsed: null, isUsed: null,
sortNo: null, sortNo: null,
createUserCode: null, createUserCode: null,
updateUserCode: null updateUserCode: null
}
} }
}
this.queryOwnerName = '' this.queryOwnerName = ''
this.queryWarehouseName = '' this.queryWarehouseName = ''
...@@ -1436,82 +1464,88 @@ handleDetailSubmit(details) { ...@@ -1436,82 +1464,88 @@ handleDetailSubmit(details) {
this.$refs["form"].validate(async (valid) => { this.$refs["form"].validate(async (valid) => {
if (valid) { if (valid) {
// 检查是否有明细数据 // 新增:提交前弹窗确认
const hasDetails = Object.values(this.outboundOrderItemsGroup).some(group => group.items.length > 0) const confirmText = this.form.id ? '修改' : '新增'
if (!hasDetails) { this.$modal.confirm(`是否确认${confirmText}出库单【${this.form.orderId || '未命名'}】?`).then(async () => {
this.$message.warning('请至少添加一条明细数据') // 检查是否有明细数据
return const hasDetails = Object.values(this.outboundOrderItemsGroup).some(group => group.items.length > 0)
} if (!hasDetails) {
this.$message.warning('请至少添加一条明细数据')
// 扁平化分组数据用于提交 return
const outboundOrderItemsList = []
Object.values(this.outboundOrderItemsGroup).forEach(group => {
outboundOrderItemsList.push(...group.items)
})
// 修复:去重逻辑优化(保留最新数据)
const uniqueDetailsMap = new Map()
outboundOrderItemsList.forEach(item => {
if (item.inventoryId) {
uniqueDetailsMap.set(item.inventoryId, item)
} }
})
const uniqueDetails = Array.from(uniqueDetailsMap.values())
// 修改点7:构造提交数据,适配新的字段映射规则 // 扁平化分组数据用于提交
const submitData = { const outboundOrderItemsList = []
...this.form, Object.values(this.outboundOrderItemsGroup).forEach(group => {
outboundOrderId: this.form.id, outboundOrderItemsList.push(...group.items)
orderId: this.form.orderId,
orderType: this.form.orderType, // 新增:提交订单类型
outboundOrderItemsList: uniqueDetails.map(item => {
const { index, materialUuids, warehouseName, locationName, ...rest } = item
return {
...rest,
orderId: null,
outboundOrderId: this.form.id || null,
materialName: item.materialName || '', // 【修改16】提交物料名称
inventoryId: rest.inventoryId || '',
materialId: rest.materialId || '',
batchCode: rest.batchCode || '',
warehouseId: rest.warehouseId || this.form.warehouseId || '',
locationId: rest.locationId || '',
plannedQuantity: Number(rest.plannedQuantity) || 0,
actualQuantity: Number(rest.actualQuantity) || 0,
divisor: Number(rest.divisor) || 1,
labelColor: Number(rest.labelColor) || 0,
unitPrice: Number(rest.unitPrice) || 0.00,
amount: Number(rest.amount) || 0.00,
voucherNumber: rest.voucherNumber || '',
itemStatus: Number(rest.itemStatus) || 1,
shippedAt: rest.shippedAt || this.form.inboundDate || '',
shippedBy: rest.shippedBy || '',
remark: rest.remark || '',
isUsed: 1,
sortNo: Number(rest.sortNo) || 0
};
}) })
}
// 调试:打印最终提交的数据 // 修复:去重逻辑优化(保留最新数据)
console.log('最终提交的数据:', submitData) const uniqueDetailsMap = new Map()
outboundOrderItemsList.forEach(item => {
if (item.inventoryId) {
uniqueDetailsMap.set(item.inventoryId, item)
}
})
const uniqueDetails = Array.from(uniqueDetailsMap.values())
try { // 修改点7:构造提交数据,适配新的字段映射规则
if (this.form.id != null) { const submitData = {
await updateOrders(submitData) ...this.form,
this.$modal.msgSuccess("修改成功") outboundOrderId: this.form.id,
} else { orderId: this.form.orderId,
await addOrders(submitData) orderType: this.form.orderType, // 新增:提交订单类型
this.$modal.msgSuccess("新增成功") outboundOrderItemsList: uniqueDetails.map(item => {
const { index, materialUuids, warehouseName, locationName, ...rest } = item
return {
...rest,
orderId: null,
outboundOrderId: this.form.id || null,
materialName: item.materialName || '', // 【修改16】提交物料名称
inventoryId: rest.inventoryId || '',
materialId: rest.materialId || '',
batchCode: rest.batchCode || '',
warehouseId: rest.warehouseId || this.form.warehouseId || '',
locationId: rest.locationId || '',
plannedQuantity: Number(rest.plannedQuantity) || 0,
actualQuantity: Number(rest.actualQuantity) || 0,
divisor: Number(rest.divisor) || 1,
labelColor: Number(rest.labelColor) || 0,
unitPrice: Number(rest.unitPrice) || 0.00,
amount: Number(rest.amount) || 0.00,
voucherNumber: rest.voucherNumber || '',
itemStatus: Number(rest.itemStatus) || 1,
shippedAt: rest.shippedAt || this.form.inboundDate || '',
shippedBy: rest.shippedBy || '',
remark: rest.remark || '',
isUsed: 1,
sortNo: Number(rest.sortNo) || 0
};
})
} }
this.open = false
this.getList() // 调试:打印最终提交的数据
} catch (error) { console.log('最终提交的数据:', submitData)
if (error !== 'cancel') {
const errorMsg = error?.response?.data?.msg || '库存被修改请重新确认' try {
this.$modal.msgError(errorMsg) if (this.form.id != null) {
await updateOrders(submitData)
this.$modal.msgSuccess("修改成功")
} else {
await addOrders(submitData)
this.$modal.msgSuccess("新增成功")
}
this.open = false
this.getList()
} catch (error) {
if (error !== 'cancel') {
const errorMsg = error?.response?.data?.msg || '库存被修改请重新确认'
this.$modal.msgError(errorMsg)
}
} }
} }).catch(() => {
// 取消确认时不执行任何操作
})
} }
}) })
}, },
...@@ -1537,70 +1571,4 @@ handleDetailSubmit(details) { ...@@ -1537,70 +1571,4 @@ handleDetailSubmit(details) {
} }
} }
} }
</script> </script>
\ No newline at end of file
<style scoped>
/* 页面容器样式 */
.page-container {
background: #fff;
padding: 16px;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.04);
margin-top: 16px;
}
/* 表格容器样式 */
.table-container {
margin-top: 16px;
height: calc(100vh - 280px);
}
/* 弹窗内表单滚动优化 */
.el-dialog__body {
max-height: 70vh;
overflow-y: auto;
padding-right: 10px;
}
/* 自定义滚动条 */
.el-dialog__body::-webkit-scrollbar {
width: 6px;
}
.el-dialog__body::-webkit-scrollbar-thumb {
background-color: #ddd;
border-radius: 3px;
}
/* 明细表格样式优化 */
.el-table {
--el-table-row-hover-bg-color: #f8f9fa;
}
/* 空数据提示样式 */
.empty-tip {
color: #999;
font-size: 14px;
}
/* 物料分组样式 */
.material-group {
border: 1px solid #e6e6e6;
border-radius: 6px;
padding: 10px;
}
.group-header {
display: flex;
align-items: center;
justify-content: space-between;
}
.mb10 {
margin-bottom: 10px;
}
.mb8 {
margin-bottom: 8px;
}
</style>
\ No newline at end of file
...@@ -36,14 +36,7 @@ ...@@ -36,14 +36,7 @@
@click="handleExport" @click="handleExport"
v-hasPermi="['inventory:warehouses:export']" v-hasPermi="['inventory:warehouses:export']"
>导出</el-button> >导出</el-button>
<el-button
type="info"
plain
icon="el-icon-upload2"
size="medium"
@click="handleImport"
v-hasPermi="['inventory:warehouses:add']"
>导入</el-button>
</template> </template>
</PageTitle> </PageTitle>
......
...@@ -2,6 +2,7 @@ package com.ruoyi.inventory.domain; ...@@ -2,6 +2,7 @@ package com.ruoyi.inventory.domain;
import java.util.Date; import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
...@@ -13,6 +14,7 @@ import com.ruoyi.common.core.domain.BaseEntity; ...@@ -13,6 +14,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author ruoyi * @author ruoyi
* @date 2025-12-02 * @date 2025-12-02
*/ */
@Data
public class InventoryTransactions extends BaseEntity public class InventoryTransactions extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -91,218 +93,7 @@ public class InventoryTransactions extends BaseEntity ...@@ -91,218 +93,7 @@ public class InventoryTransactions extends BaseEntity
@Excel(name = "排序号") @Excel(name = "排序号")
private String updateUserCode; private String updateUserCode;
public String getInventoryId() { @Excel(name = "单价")
return inventoryId; private String unitPrice;
}
public void setInventoryId(String inventoryId) {
this.inventoryId = inventoryId;
}
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setTransactionType(Long transactionType)
{
this.transactionType = transactionType;
}
public Long getTransactionType()
{
return transactionType;
}
public void setReferenceId(String referenceId)
{
this.referenceId = referenceId;
}
public String getReferenceId()
{
return referenceId;
}
public void setReferenceItemId(String referenceItemId)
{
this.referenceItemId = referenceItemId;
}
public String getReferenceItemId()
{
return referenceItemId;
}
public void setMaterialId(String materialId)
{
this.materialId = materialId;
}
public String getMaterialId()
{
return materialId;
}
public void setBatchCode(String batchCode)
{
this.batchCode = batchCode;
}
public String getBatchCode()
{
return batchCode;
}
public void setWarehouseId(String warehouseId)
{
this.warehouseId = warehouseId;
}
public String getWarehouseId()
{
return warehouseId;
}
public void setLocationId(String locationId)
{
this.locationId = locationId;
}
public String getLocationId()
{
return locationId;
}
public void setOwnerId(String ownerId)
{
this.ownerId = ownerId;
}
public String getOwnerId()
{
return ownerId;
}
public void setQuantityBefore(Long quantityBefore)
{
this.quantityBefore = quantityBefore;
}
public Long getQuantityBefore()
{
return quantityBefore;
}
public void setQuantityChange(Long quantityChange)
{
this.quantityChange = quantityChange;
}
public Long getQuantityChange()
{
return quantityChange;
}
public void setQuantityAfter(Long quantityAfter)
{
this.quantityAfter = quantityAfter;
}
public Long getQuantityAfter()
{
return quantityAfter;
}
public void setTransactionTime(Date transactionTime)
{
this.transactionTime = transactionTime;
}
public Date getTransactionTime()
{
return transactionTime;
}
public void setOperatedBy(String operatedBy)
{
this.operatedBy = operatedBy;
}
public String getOperatedBy()
{
return operatedBy;
}
public void setIsUsed(Long isUsed)
{
this.isUsed = isUsed;
}
public Long getIsUsed()
{
return isUsed;
}
public void setSortNo(Long sortNo)
{
this.sortNo = sortNo;
}
public Long getSortNo()
{
return sortNo;
}
public void setCreateUserCode(String createUserCode)
{
this.createUserCode = createUserCode;
}
public String getCreateUserCode()
{
return createUserCode;
}
public void setUpdateUserCode(String updateUserCode)
{
this.updateUserCode = updateUserCode;
}
public String getUpdateUserCode()
{
return updateUserCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("transactionType", getTransactionType())
.append("referenceId", getReferenceId())
.append("referenceItemId", getReferenceItemId())
.append("materialId", getMaterialId())
.append("batchCode", getBatchCode())
.append("warehouseId", getWarehouseId())
.append("locationId", getLocationId())
.append("ownerId", getOwnerId())
.append("quantityBefore", getQuantityBefore())
.append("quantityChange", getQuantityChange())
.append("quantityAfter", getQuantityAfter())
.append("transactionTime", getTransactionTime())
.append("operatedBy", getOperatedBy())
.append("remark", getRemark())
.append("isUsed", getIsUsed())
.append("sortNo", getSortNo())
.append("createTime", getCreateTime())
.append("createUserCode", getCreateUserCode())
.append("updateTime", getUpdateTime())
.append("updateUserCode", getUpdateUserCode())
.toString();
}
} }
...@@ -66,7 +66,7 @@ public class OutboundOrderItems extends BaseEntity ...@@ -66,7 +66,7 @@ public class OutboundOrderItems extends BaseEntity
/** 单价 */ /** 单价 */
@Excel(name = "单价") @Excel(name = "单价")
private Long unitPrice; private Double unitPrice;
/** 计划数量 */ /** 计划数量 */
@Excel(name = "计划数量") @Excel(name = "计划数量")
......
...@@ -28,7 +28,7 @@ public class Owners extends BaseEntity ...@@ -28,7 +28,7 @@ public class Owners extends BaseEntity
@Excel(name = "货主名称") @Excel(name = "货主名称")
private String ownerName; private String ownerName;
@Excel(name = "货主名称") @Excel(name = "英文名称")
private String englishName; private String englishName;
/** 货主类型 1-供应商 2-客户 3-内部 检索条件 */ /** 货主类型 1-供应商 2-客户 3-内部 检索条件 */
......
...@@ -159,14 +159,16 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -159,14 +159,16 @@ public class InventoryServiceImpl implements IInventoryService
// 库存操作表插入数据 // 库存操作表插入数据
InventoryTransactions transactions = new InventoryTransactions(); InventoryTransactions transactions = new InventoryTransactions();
transactions.setId(IdUtils.simpleUUID()); transactions.setId(IdUtils.simpleUUID());
transactions.setTransactionType(2L);// 事务类型-盘点 transactions.setTransactionType(2L);// 事务类型-出库
transactions.setBatchCode(outboundOrderItem.getBatchCode());
transactions.setUnitPrice(String.valueOf(outboundOrderItem.getUnitPrice()));
transactions.setInventoryId(inventory.getId()); // 库存表Id transactions.setInventoryId(inventory.getId()); // 库存表Id
transactions.setReferenceId(outboundOrderItem.getOutboundOrderId()); //关联单号,相当于主记录-盘点主表 transactions.setReferenceId(outboundOrderItem.getOutboundOrderId()); //关联单号,相当于主记录-盘点主表
transactions.setReferenceItemId(outboundOrderItem.getId()); // 盘点子表id transactions.setReferenceItemId(outboundOrderItem.getId()); // 盘点子表id
transactions.setMaterialId(outboundOrderItem.getMaterialId()); transactions.setMaterialId(outboundOrderItem.getMaterialId());
transactions.setWarehouseId(outboundOrderItem.getWarehouseId()); transactions.setWarehouseId(outboundOrderItem.getWarehouseId());
transactions.setLocationId(outboundOrderItem.getLocationId()); transactions.setLocationId(outboundOrderItem.getLocationId());
OutboundOrders outboundOrders = outboundOrderMapper.selectOutboundOrdersById(outboundOrderItem.getWarehouseId()); OutboundOrders outboundOrders = outboundOrderMapper.selectOutboundOrdersById(outboundOrderItem.getOutboundOrderId());
transactions.setOwnerId(outboundOrders.getOwnerId()); transactions.setOwnerId(outboundOrders.getOwnerId());
transactions.setQuantityBefore(Long.valueOf(quantity));// 变更前数量 transactions.setQuantityBefore(Long.valueOf(quantity));// 变更前数量
transactions.setQuantityAfter(inventory.getQuantity());// 变更后数量 transactions.setQuantityAfter(inventory.getQuantity());// 变更后数量
...@@ -175,10 +177,7 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -175,10 +177,7 @@ public class InventoryServiceImpl implements IInventoryService
transactions.setTransactionTime(nowDate); transactions.setTransactionTime(nowDate);
transactions.setOperatedBy(SystemUtils.getUserName()); transactions.setOperatedBy(SystemUtils.getUserName());
int inventoryTransactions = insertInventoryTransactions.insertInventoryTransactions(transactions); insertInventoryTransactions.insertInventoryTransactions(transactions);
if (inventoryTransactions < 0) {
return -1;
}
} }
RefreshInventory(inventoryIds); RefreshInventory(inventoryIds);
} }
......
...@@ -413,6 +413,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService ...@@ -413,6 +413,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService
itemsList.setWarehousesId(itemDO.getWarehouseId()); itemsList.setWarehousesId(itemDO.getWarehouseId());
itemsList.setMaterialId(itemDO.getMaterialId()); itemsList.setMaterialId(itemDO.getMaterialId());
itemsList.setLocationId(itemDO.getLocationId()); itemsList.setLocationId(itemDO.getLocationId());
itemsList.setInventoryType(Long.valueOf(orderType));
List<Inventory> inventory = inventoryService.selectInventoryList(itemsList); List<Inventory> inventory = inventoryService.selectInventoryList(itemsList);
if (CollectionUtils.isEmpty(inventory)) { if (CollectionUtils.isEmpty(inventory)) {
throw new ServiceException(String.format( throw new ServiceException(String.format(
......
...@@ -50,16 +50,20 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService ...@@ -50,16 +50,20 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
public StorageLocations selectStorageLocationsById(String id) public StorageLocations selectStorageLocationsById(String id)
{ {
StorageLocations storageLocations = storageLocationsMapper.selectStorageLocationsById(id); StorageLocations storageLocations = storageLocationsMapper.selectStorageLocationsById(id);
String[] AllowedCategoryIds = storageLocations.getAllowedCategoryIds().split(",");
String AllowedCategoryName = ""; String AllowedCategoryName = "";
for (String AllowedCategoryId : AllowedCategoryIds) { if (storageLocations.getAllowedCategoryIds() != null) {
Materials materials = materialsMapper.selectMaterialsById(AllowedCategoryId); String[] AllowedCategoryIds = storageLocations.getAllowedCategoryIds().split(",");
if (materials != null && materials.getMaterialName() != null) { if (AllowedCategoryIds != null && AllowedCategoryIds.length > 0) {
String categoryName = materials.getMaterialName().trim(); // 去除首尾空格 for (String AllowedCategoryId : AllowedCategoryIds) {
if (AllowedCategoryName != "") { Materials materials = materialsMapper.selectMaterialsById(AllowedCategoryId);
AllowedCategoryName += ","; if (materials != null && materials.getMaterialName() != null) {
String categoryName = materials.getMaterialName().trim(); // 去除首尾空格
if (AllowedCategoryName != "") {
AllowedCategoryName += ",";
}
AllowedCategoryName += categoryName;
}
} }
AllowedCategoryName += categoryName;
} }
} }
storageLocations.setAllowedCategoryNames(AllowedCategoryName); storageLocations.setAllowedCategoryNames(AllowedCategoryName);
...@@ -260,6 +264,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService ...@@ -260,6 +264,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
StorageLocations storageLocations = new StorageLocations(); StorageLocations storageLocations = new StorageLocations();
// 拷贝基础属性 // 拷贝基础属性
BeanUtils.copyProperties(templateVO, storageLocations); BeanUtils.copyProperties(templateVO, storageLocations);
storageLocations.setLocationName(templateVO.getLocationCode());
// 字段类型转换与赋值 // 字段类型转换与赋值
storageLocations.setId(UUID.randomUUID().toString()); storageLocations.setId(UUID.randomUUID().toString());
...@@ -274,6 +279,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService ...@@ -274,6 +279,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
storageLocations.setCreateBy(operId); storageLocations.setCreateBy(operId);
storageLocations.setCreateTime(now); storageLocations.setCreateTime(now);
storageLocations.setCreateUserCode(operId); storageLocations.setCreateUserCode(operId);
storageLocations.setWarehousesCode("固定仓库");
storageLocations.setWarehousesId("572ba484-199c-45d9-9735-610928ed5c70"); storageLocations.setWarehousesId("572ba484-199c-45d9-9735-610928ed5c70");
// 设置默认值 // 设置默认值
......
...@@ -563,6 +563,9 @@ and inventory_status = '1' ...@@ -563,6 +563,9 @@ and inventory_status = '1'
and i.unit_price > 0 and i.unit_price > 0
and i.last_inbound_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') and i.last_inbound_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and i.last_inbound_time &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01') and i.last_inbound_time &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
where
m.is_used =1
and m.is_active =1
group by m.id, m.material_name group by m.id, m.material_name
order by value desc, m.material_name asc order by value desc, m.material_name asc
</select> </select>
...@@ -577,6 +580,9 @@ and inventory_status = '1' ...@@ -577,6 +580,9 @@ and inventory_status = '1'
and i.is_used = 1 and i.is_used = 1
and i.last_inbound_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') and i.last_inbound_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and i.last_inbound_time &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01') and i.last_inbound_time &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
where
m.is_used =1
and m.is_active =1
group by m.id, m.material_name group by m.id, m.material_name
order by value desc, m.material_name asc order by value desc, m.material_name asc
</select> </select>
......
...@@ -87,7 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -87,7 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createUserCode != null">create_user_code,</if> <if test="createUserCode != null">create_user_code,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="updateUserCode != null">update_user_code,</if> <if test="updateUserCode != null">update_user_code,</if>
</trim> <if test="unitPrice != null">unit_price,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
<if test="transactionType != null">#{transactionType},</if> <if test="transactionType != null">#{transactionType},</if>
...@@ -111,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -111,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createUserCode != null">#{createUserCode},</if> <if test="createUserCode != null">#{createUserCode},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="updateUserCode != null">#{updateUserCode},</if> <if test="updateUserCode != null">#{updateUserCode},</if>
<if test="unitPrice != null">#{unitPrice},</if>
</trim> </trim>
</insert> </insert>
......
...@@ -315,6 +315,9 @@ ...@@ -315,6 +315,9 @@
and ooi.is_used = 1 and ooi.is_used = 1
and ooi.shipped_at >= DATE_FORMAT(CURDATE(), '%Y-%m-01 00:00:00') and ooi.shipped_at >= DATE_FORMAT(CURDATE(), '%Y-%m-01 00:00:00')
and ooi.shipped_at &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01 00:00:00') and ooi.shipped_at &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01 00:00:00')
where
m.is_used =1
and m.is_active =1
group by m.id, m.material_name group by m.id, m.material_name
order by value desc order by value desc
limit 10; limit 10;
...@@ -330,6 +333,9 @@ ...@@ -330,6 +333,9 @@
and ooi.is_used = 1 and ooi.is_used = 1
and ooi.shipped_at >= DATE_FORMAT(CURDATE(), '%Y-%m-01 00:00:00') and ooi.shipped_at >= DATE_FORMAT(CURDATE(), '%Y-%m-01 00:00:00')
and ooi.shipped_at &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01 00:00:00') and ooi.shipped_at &lt; DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01 00:00:00')
where
m.is_used =1
and m.is_active =1
group by m.id, m.material_name group by m.id, m.material_name
order by value desc order by value desc
limit 10; limit 10;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论