fix: 修复 docs 页面 JS 失效 + 入库 locked_quantity 流水补全 + stock_store 查询条件补全 is_valid
1. docs.js: 修复模板字面量中 '\n' 被服务端解释为换行符导致客户端 JS SyntaxError,所有交互功能失效(搜索/发送按钮) 2. inbound_direct_log.js: batch_no 修正为 effectiveBatchNo;storage 表更新时补全 before_locked_quantity/after_locked_quantity;新增 stock_id 归属校验 3. stock_store.js: 多处查询/更新补全 is_valid='Y' 过滤条件,避免软删除/失效数据泄露或误操作 4. storage/entry.js: 入库完成时补全 storage 表 before_locked_quantity/after_locked_quantity 流水字段
This commit is contained in:
parent
358fef0f71
commit
3e7c9a7a10
@ -2043,7 +2043,7 @@ Content-Type: application/json
|
|||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
return res.text().then(function(txt) { return { status: res.status, body: txt }; });
|
return res.text().then(function(txt) { return { status: res.status, body: txt }; });
|
||||||
}).then(function(r) {
|
}).then(function(r) {
|
||||||
resultEl.textContent = 'HTTP ' + r.status + '\n' + r.body;
|
resultEl.textContent = 'HTTP ' + r.status + '\\n' + r.body;
|
||||||
resultEl.className = r.status === 200 ? 'req-result success' : 'req-result error';
|
resultEl.className = r.status === 200 ? 'req-result success' : 'req-result error';
|
||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
resultEl.textContent = '推送失败: ' + err.message;
|
resultEl.textContent = '推送失败: ' + err.message;
|
||||||
|
|||||||
@ -1042,7 +1042,7 @@ class InboundDirectLogService extends Service {
|
|||||||
where: {
|
where: {
|
||||||
space_id: spaceId,
|
space_id: spaceId,
|
||||||
stock_id: stockId,
|
stock_id: stockId,
|
||||||
batch_no: batchNo,
|
batch_no: effectiveBatchNo,
|
||||||
inventory_type: inventoryType,
|
inventory_type: inventoryType,
|
||||||
is_enabled: 1,
|
is_enabled: 1,
|
||||||
delete_at: null,
|
delete_at: null,
|
||||||
@ -1054,10 +1054,20 @@ class InboundDirectLogService extends Service {
|
|||||||
let sId = null;
|
let sId = null;
|
||||||
let sBeforeQty = 0;
|
let sBeforeQty = 0;
|
||||||
let sAfterQty = 0;
|
let sAfterQty = 0;
|
||||||
|
let sBeforeLockedQty = 0;
|
||||||
|
let sAfterLockedQty = 0;
|
||||||
|
|
||||||
if (sRecord) {
|
if (sRecord) {
|
||||||
|
if (Number(sRecord.stock_id) !== Number(stockId)) {
|
||||||
|
throw new Error(
|
||||||
|
`入库库存归属冲突: storage_id=${sRecord.id} 当前 stock_id=${sRecord.stock_id}, ` +
|
||||||
|
`本次入库 stock_id=${stockId}, space_id=${spaceId}, batch_no=${effectiveBatchNo}`
|
||||||
|
);
|
||||||
|
}
|
||||||
sBeforeQty = Number(sRecord.quantity) || 0;
|
sBeforeQty = Number(sRecord.quantity) || 0;
|
||||||
sAfterQty = sBeforeQty + qty;
|
sAfterQty = sBeforeQty + qty;
|
||||||
|
sBeforeLockedQty = Number(sRecord.locked_quantity) || 0;
|
||||||
|
sAfterLockedQty = sBeforeLockedQty;
|
||||||
|
|
||||||
await ctx.model.Storage.update({
|
await ctx.model.Storage.update({
|
||||||
quantity: app.Sequelize.literal(`quantity + ${qty}`),
|
quantity: app.Sequelize.literal(`quantity + ${qty}`),
|
||||||
@ -1077,6 +1087,8 @@ class InboundDirectLogService extends Service {
|
|||||||
} else {
|
} else {
|
||||||
sBeforeQty = 0;
|
sBeforeQty = 0;
|
||||||
sAfterQty = qty;
|
sAfterQty = qty;
|
||||||
|
sBeforeLockedQty = 0;
|
||||||
|
sAfterLockedQty = 0;
|
||||||
|
|
||||||
const createdStorage = await ctx.model.Storage.create({
|
const createdStorage = await ctx.model.Storage.create({
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
@ -1114,6 +1126,8 @@ class InboundDirectLogService extends Service {
|
|||||||
quantity: qty,
|
quantity: qty,
|
||||||
before_quantity: sBeforeQty,
|
before_quantity: sBeforeQty,
|
||||||
after_quantity: sAfterQty,
|
after_quantity: sAfterQty,
|
||||||
|
before_locked_quantity: sBeforeLockedQty,
|
||||||
|
after_locked_quantity: sAfterLockedQty,
|
||||||
batch_no: effectiveBatchNo,
|
batch_no: effectiveBatchNo,
|
||||||
inventory_type: inventoryType,
|
inventory_type: inventoryType,
|
||||||
order_type: 'entry_order',
|
order_type: 'entry_order',
|
||||||
|
|||||||
@ -1437,6 +1437,7 @@ class stockStoreService extends Service {
|
|||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
store_id: sourceData.store_id,
|
store_id: sourceData.store_id,
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
},
|
},
|
||||||
attributes: [ 'id' ],
|
attributes: [ 'id' ],
|
||||||
raw: true,
|
raw: true,
|
||||||
@ -1548,6 +1549,7 @@ class stockStoreService extends Service {
|
|||||||
goods_code: sourceData.goods_code,
|
goods_code: sourceData.goods_code,
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
is_valid: 'Y',
|
is_valid: 'Y',
|
||||||
|
deleted_at: null,
|
||||||
},
|
},
|
||||||
attributes: [ 'id' ],
|
attributes: [ 'id' ],
|
||||||
raw: true,
|
raw: true,
|
||||||
@ -2557,7 +2559,8 @@ class stockStoreService extends Service {
|
|||||||
where: {
|
where: {
|
||||||
id: { [Op.in]: ids },
|
id: { [Op.in]: ids },
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
delete_at: null,
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
},
|
},
|
||||||
attributes: [ 'id' ],
|
attributes: [ 'id' ],
|
||||||
});
|
});
|
||||||
@ -2784,6 +2787,8 @@ class stockStoreService extends Service {
|
|||||||
} else {
|
} else {
|
||||||
const StockWarehouseWhere = {
|
const StockWarehouseWhere = {
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
};
|
};
|
||||||
const StockStoreWhere = {};
|
const StockStoreWhere = {};
|
||||||
if (store_id) {
|
if (store_id) {
|
||||||
@ -2905,6 +2910,7 @@ class stockStoreService extends Service {
|
|||||||
where: {
|
where: {
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
id: warehouse_stock,
|
id: warehouse_stock,
|
||||||
},
|
},
|
||||||
attributes: [
|
attributes: [
|
||||||
@ -2985,6 +2991,7 @@ class stockStoreService extends Service {
|
|||||||
where: {
|
where: {
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
id,
|
id,
|
||||||
},
|
},
|
||||||
attributes: [
|
attributes: [
|
||||||
@ -3078,6 +3085,7 @@ class stockStoreService extends Service {
|
|||||||
where: {
|
where: {
|
||||||
id,
|
id,
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
warehouse_id: ctx.user.store_id,
|
warehouse_id: ctx.user.store_id,
|
||||||
},
|
},
|
||||||
transaction,
|
transaction,
|
||||||
@ -3325,6 +3333,7 @@ class stockStoreService extends Service {
|
|||||||
store_id: owner_id,
|
store_id: owner_id,
|
||||||
warehouse_id,
|
warehouse_id,
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (item_id) {
|
if (item_id) {
|
||||||
@ -3370,6 +3379,7 @@ class stockStoreService extends Service {
|
|||||||
[Op.and]: [
|
[Op.and]: [
|
||||||
{ id: { [Op.in]: ids } },
|
{ id: { [Op.in]: ids } },
|
||||||
{ deleted_at: null },
|
{ deleted_at: null },
|
||||||
|
{ is_valid: 'Y' },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3678,6 +3688,7 @@ class stockStoreService extends Service {
|
|||||||
const whereCondition = {
|
const whereCondition = {
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
};
|
};
|
||||||
|
|
||||||
// 如果有传入store_id,则添加store_id条件
|
// 如果有传入store_id,则添加store_id条件
|
||||||
@ -3923,6 +3934,7 @@ class stockStoreService extends Service {
|
|||||||
id: stock_id,
|
id: stock_id,
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
deleted_at: null,
|
deleted_at: null,
|
||||||
|
is_valid: 'Y',
|
||||||
},
|
},
|
||||||
attributes: [ 'id', 'item_code', 'item_name', 'sku_property', 'stock_unit', 'quantity', 'locked_quantity' ],
|
attributes: [ 'id', 'item_code', 'item_name', 'sku_property', 'stock_unit', 'quantity', 'locked_quantity' ],
|
||||||
raw: true,
|
raw: true,
|
||||||
|
|||||||
@ -1553,10 +1553,14 @@ class EntryService extends Service {
|
|||||||
let storageId = null;
|
let storageId = null;
|
||||||
let storageBeforeQty = 0;
|
let storageBeforeQty = 0;
|
||||||
let storageAfterQty = 0;
|
let storageAfterQty = 0;
|
||||||
|
let storageBeforeLockedQty = 0;
|
||||||
|
let storageAfterLockedQty = 0;
|
||||||
|
|
||||||
if (storageRecord) {
|
if (storageRecord) {
|
||||||
storageBeforeQty = Number(storageRecord.quantity) || 0;
|
storageBeforeQty = Number(storageRecord.quantity) || 0;
|
||||||
storageAfterQty = storageBeforeQty + planQty;
|
storageAfterQty = storageBeforeQty + planQty;
|
||||||
|
storageBeforeLockedQty = Number(storageRecord.locked_quantity) || 0;
|
||||||
|
storageAfterLockedQty = storageBeforeLockedQty;
|
||||||
|
|
||||||
await ctx.model.Storage.update({
|
await ctx.model.Storage.update({
|
||||||
quantity: app.Sequelize.literal(`quantity + ${planQty}`),
|
quantity: app.Sequelize.literal(`quantity + ${planQty}`),
|
||||||
@ -1573,6 +1577,8 @@ class EntryService extends Service {
|
|||||||
} else {
|
} else {
|
||||||
storageBeforeQty = 0;
|
storageBeforeQty = 0;
|
||||||
storageAfterQty = planQty;
|
storageAfterQty = planQty;
|
||||||
|
storageBeforeLockedQty = 0;
|
||||||
|
storageAfterLockedQty = 0;
|
||||||
|
|
||||||
const createdStorage = await ctx.model.Storage.create({
|
const createdStorage = await ctx.model.Storage.create({
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
@ -1608,6 +1614,8 @@ class EntryService extends Service {
|
|||||||
quantity: planQty,
|
quantity: planQty,
|
||||||
before_quantity: storageBeforeQty,
|
before_quantity: storageBeforeQty,
|
||||||
after_quantity: storageAfterQty,
|
after_quantity: storageAfterQty,
|
||||||
|
before_locked_quantity: storageBeforeLockedQty,
|
||||||
|
after_locked_quantity: storageAfterLockedQty,
|
||||||
batch_no: batchNo,
|
batch_no: batchNo,
|
||||||
inventory_type: inventoryType,
|
inventory_type: inventoryType,
|
||||||
order_type: 'entry_order',
|
order_type: 'entry_order',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user