完善库存管理,现在问题就是出入库移库以及撤回操作都是某个主表id带着的所有详情记录一并操作并不能单个修改,比如撤回某一条详情,如果想实现这一功能需要修改主表status字段和详情表添加status字段

This commit is contained in:
2025-07-19 14:34:48 +08:00
parent d28578d106
commit 0018513683
4 changed files with 151 additions and 26 deletions

View File

@@ -31,12 +31,9 @@
</el-form-item>
<el-form-item label="单据状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择单据状态" clearable>
<el-option
v-for="dict in dict.type.stock_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
<el-option :key="0" label="草稿" :value="0" />
<el-option :key="1" label="待审核" :value="1" />
<el-option :key="2" label="已完成" :value="2" />
</el-select>
</el-form-item>
<el-form-item>
@@ -107,7 +104,9 @@
</el-table-column>
<el-table-column label="单据状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.stock_status" :value="scope.row.status"/>
<el-tag :type="scope.row.status === 2 ? 'success' : (scope.row.status === 1 ? 'warning' : 'info')">
{{ scope.row.status === 2 ? '已完成' : (scope.row.status === 0 ? '草稿' : '待审核') }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />

View File

@@ -6,8 +6,8 @@
<el-descriptions-item label="类型">{{ stockIo.ioType }}</el-descriptions-item>
<el-descriptions-item label="业务类型">{{ stockIo.bizType }}</el-descriptions-item>
<el-descriptions-item label="状态">
<el-tag :type="stockIo.status === 2 ? 'success' : 'info'">
{{ stockIo.status === 2 ? '已审核' : (stockIo.status === 0 ? '草稿' : '审核') }}
<el-tag :type="stockIo.status === 2 ? 'success' : (stockIo.status === 1 ? 'warning' : 'info')">
{{ stockIo.status === 2 ? '已完成' : (stockIo.status === 0 ? '草稿' : '审核') }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="备注">{{ stockIo.remark }}</el-descriptions-item>
@@ -22,6 +22,7 @@
icon="el-icon-plus"
size="mini"
@click="handleAdd"
:disabled="stockIo.status >= 2"
v-hasPermi="['klp:stockIoDetail:add']"
>新增</el-button>
</el-col>
@@ -31,7 +32,7 @@
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
:disabled="single || stockIo.status >= 2"
@click="handleUpdate"
v-hasPermi="['klp:stockIoDetail:edit']"
>修改</el-button>
@@ -42,7 +43,7 @@
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
:disabled="multiple || stockIo.status >= 2"
@click="handleDelete"
v-hasPermi="['klp:stockIoDetail:remove']"
>删除</el-button>
@@ -82,6 +83,7 @@
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
:disabled="stockIo.status >= 2"
v-hasPermi="['klp:stockIoDetail:edit']"
>修改</el-button>
<el-button
@@ -89,6 +91,7 @@
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
:disabled="stockIo.status >= 2"
v-hasPermi="['klp:stockIoDetail:remove']"
>删除</el-button>
</template>
@@ -117,7 +120,15 @@
type="primary"
:loading="auditLoading"
@click="handleAudit"
>审核</el-button>
>{{ getAuditButtonText() }}</el-button>
<!-- 撤回按钮 -->
<el-button
v-if="stockIo.status === 2"
type="warning"
:loading="cancelLoading"
@click="handleCancel"
>撤回</el-button>
</div>
<!-- 明细编辑弹窗 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@@ -171,7 +182,7 @@
<script>
import { listStockIoDetail, getStockIoDetail, delStockIoDetail, addStockIoDetail, updateStockIoDetail } from "@/api/wms/stockIoDetail";
import { auditStockIo, updateStockIoStatus } from "@/api/wms/stockIo";
import { auditStockIo, updateStockIoStatus, cancelStockIo, getStockIo } from "@/api/wms/stockIo";
import WarehouseSelect from '@/components/WarehouseSelect';
export default {
@@ -220,7 +231,8 @@ export default {
ids: [],
single: true,
multiple: true,
statusLoading: false // 新增状态修改按钮加载状态
statusLoading: false, // 新增状态修改按钮加载状态
cancelLoading: false // 撤回按钮加载状态
};
},
watch: {
@@ -327,6 +339,8 @@ export default {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
// 新增明细后刷新主表状态
this.refreshStockIoStatus();
}).finally(() => {
this.buttonLoading = false;
});
@@ -343,6 +357,8 @@ export default {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
// 删除明细后刷新主表状态
this.refreshStockIoStatus();
}).catch(() => {
}).finally(() => {
this.loading = false;
@@ -374,24 +390,24 @@ export default {
},
getAuditButtonText() {
if (this.stockIo.ioType === 'in') {
return '确认入库/审核';
return '审核入库';
} else if (this.stockIo.ioType === 'out') {
return '确认出库/审核';
return '审核出库';
} else if (this.stockIo.ioType === 'transfer') {
return '确认移库/审核';
return '审核移库';
} else {
return '审核';
}
},
getStatusButtonText() {
if (this.stockIo.ioType === 'in') {
return '确认入库';
return '提交入库';
} else if (this.stockIo.ioType === 'out') {
return '确认出库';
return '提交出库';
} else if (this.stockIo.ioType === 'transfer') {
return '确认移库';
return '提交移库';
} else {
return '修改状态';
return '提交';
}
},
handleUpdateStatus() {
@@ -418,6 +434,41 @@ export default {
}).catch(() => {
// 用户取消状态更新
});
},
handleCancel() {
this.$modal.confirm('确认要撤回此出入库单吗?撤回后将回滚库存数据。').then(() => {
this.cancelLoading = true;
cancelStockIo(this.stockIo.stockIoId).then(response => {
this.$modal.msgSuccess('撤回成功');
// 更新主表状态
this.$set(this.stockIo, 'status', 1);
// 刷新明细列表
this.getList();
// 通知父组件状态已更新
this.$emit('status-changed', this.stockIo);
}).catch(error => {
console.error('撤回失败:', error);
this.$modal.msgError('撤回失败:' + (error.message || '未知错误'));
}).finally(() => {
this.cancelLoading = false;
});
}).catch(() => {
// 用户取消撤回
});
},
refreshStockIoStatus() {
// 刷新主表状态
if (this.stockIo && this.stockIo.stockIoId) {
getStockIo(this.stockIo.stockIoId).then(response => {
const updatedStockIo = response.data;
// 更新主表状态
this.$set(this.stockIo, 'status', updatedStockIo.status);
// 通知父组件状态已更新
this.$emit('status-changed', this.stockIo);
}).catch(error => {
console.error('刷新主表状态失败:', error);
});
}
}
}
}