根据采购单生成入库单
This commit is contained in:
@@ -39,10 +39,20 @@
|
||||
@click="handleExport"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
:disabled="!hasArrivalItems"
|
||||
@click="handleCreateStockIn"
|
||||
>创建入库单</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="purchasePlanDetailList" @selection-change="handleSelectionChange">
|
||||
<el-table v-loading="loading" :data="purchasePlanDetailList" @selection-change="handleSelectionChange" ref="purchasePlanDetailTable">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="明细ID" align="center" prop="detailId" v-if="true"/>
|
||||
<el-table-column label="采购计划ID" align="center" prop="planId" />
|
||||
@@ -50,6 +60,11 @@
|
||||
<el-table-column label="负责人" align="center" prop="owner" />
|
||||
<el-table-column label="计划采购数量" align="center" prop="quantity" />
|
||||
<el-table-column label="单位" align="center" prop="unit" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.pruchase_detail_status" :value="scope.row.status"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
@@ -65,6 +80,35 @@
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除</el-button>
|
||||
<!-- 状态修改按钮 -->
|
||||
<el-button
|
||||
v-if="scope.row.status === EPurchaseDetailStatus.NEW"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-refresh"
|
||||
@click="handleStatusChange(scope.row, EPurchaseDetailStatus.ONWAY, '在途')"
|
||||
>设为在途</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.status === EPurchaseDetailStatus.ONWAY"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-refresh"
|
||||
@click="handleStatusChange(scope.row, EPurchaseDetailStatus.ARRIVAL, '到货')"
|
||||
>设为到货</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.status === EPurchaseDetailStatus.ARRIVAL"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-refresh"
|
||||
@click="handleStatusChange(scope.row, EPurchaseDetailStatus.REVIEW, '待审核')"
|
||||
>设为待审核</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.status === EPurchaseDetailStatus.REVIEW"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-refresh"
|
||||
@click="handleStatusChange(scope.row, EPurchaseDetailStatus.FINISH, '采购完成')"
|
||||
>设为完成</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -104,22 +148,36 @@
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 入库单创建对话框 -->
|
||||
<stock-in-dialog
|
||||
:visible.sync="stockInVisible"
|
||||
:selected-items="selectedArrivalItems"
|
||||
@success="handleStockInSuccess"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listPurchasePlanDetail, getPurchasePlanDetail, delPurchasePlanDetail, addPurchasePlanDetail, updatePurchasePlanDetail } from "@/api/wms/purchasePlanDetail";
|
||||
import { EPurchaseDetailStatus } from "@/utils/enums";
|
||||
import StockInDialog from "./stockin.vue";
|
||||
|
||||
export default {
|
||||
name: "PurchasePlanDetail",
|
||||
components: {
|
||||
StockInDialog
|
||||
},
|
||||
props: {
|
||||
planId: {
|
||||
type: [String, Number],
|
||||
default: null
|
||||
}
|
||||
},
|
||||
dicts: ['pruchase_detail_status'],
|
||||
data() {
|
||||
return {
|
||||
EPurchaseDetailStatus,
|
||||
// 按钮loading
|
||||
buttonLoading: false,
|
||||
// 遮罩层
|
||||
@@ -169,9 +227,18 @@ export default {
|
||||
unit: [
|
||||
{ required: true, message: "单位不能为空", trigger: "blur" }
|
||||
],
|
||||
}
|
||||
},
|
||||
// 入库单相关
|
||||
stockInVisible: false,
|
||||
selectedArrivalItems: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
/** 是否有到货状态的明细 */
|
||||
hasArrivalItems() {
|
||||
return this.purchasePlanDetailList.some(item => item.status === EPurchaseDetailStatus.ARRIVAL);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
@@ -301,6 +368,48 @@ export default {
|
||||
this.download('klp/purchasePlanDetail/export', {
|
||||
...this.queryParams
|
||||
}, `purchasePlanDetail_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 状态修改按钮操作 */
|
||||
handleStatusChange(row, status, label) {
|
||||
this.$modal.confirm('是否确认将采购计划明细编号为"' + row.detailId + '"的状态改为"' + label + '"?').then(() => {
|
||||
this.loading = true;
|
||||
updatePurchasePlanDetail({ detailId: row.detailId, status: status }).then(response => {
|
||||
this.$modal.msgSuccess("状态修改成功");
|
||||
this.getList();
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
this.$modal.msgError("状态修改失败");
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 创建入库单按钮操作 */
|
||||
handleCreateStockIn() {
|
||||
// 获取用户选中的明细
|
||||
const selectedItems = this.$refs.purchasePlanDetailTable.selection;
|
||||
|
||||
if (selectedItems.length === 0) {
|
||||
this.$modal.msgWarning("请先选择要入库的明细");
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查选中的明细是否都是到货状态
|
||||
const nonArrivalItems = selectedItems.filter(item => item.status !== EPurchaseDetailStatus.ARRIVAL);
|
||||
if (nonArrivalItems.length > 0) {
|
||||
this.$modal.msgWarning("只能选择到货状态的明细进行入库操作");
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectedArrivalItems = selectedItems;
|
||||
this.stockInVisible = true;
|
||||
},
|
||||
/** 入库单创建成功后的回调 */
|
||||
handleStockInSuccess() {
|
||||
this.$modal.msgSuccess("入库单创建成功,相关明细状态已更新为采购完成");
|
||||
this.getList();
|
||||
this.stockInVisible = false;
|
||||
this.selectedArrivalItems = []; // 清空选中的明细
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user