refactor: 入库计划修改

This commit is contained in:
LJW 2024-11-21 14:38:30 +08:00
parent 0e6a53ad70
commit ae1358bc71
3 changed files with 86 additions and 556 deletions

View File

@ -145,111 +145,92 @@
/>
<!-- 添加或修改入库计划对话框 -->
<div v-if="!isKnifeBack">
<el-dialog :title="title" :visible.sync="open" width="50%" append-to-body :close-on-click-modal="false">
<!--状态为1已执行 则禁用-->
<el-form ref="form" :model="form" :rules="rules" label-width="80px" inline :disabled="form.state === '1'">
<el-form-item label="计划编码" prop="planCode">
<el-input v-model="form.planCode" placeholder="请输入计划编码"></el-input>
</el-form-item>
<el-form-item label="入库类型" prop="planTypeId">
<el-select v-model="form.planTypeId" placeholder="请选择入库类型" @change="handlePlanTypeSelectChange">
<el-option :label="item.name" :value="item.typeId" v-for="item in inPlanTypeList"
:key="item.typeId"/>
</el-select>
</el-form-item>
<el-form-item label="源头单据" prop="relBillCode">
<el-input v-model="form.relBillCode" placeholder="请输入源头单据"></el-input>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注"></el-input>
</el-form-item>
<el-divider content-position="center">入库计划明细信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddWmsInPlanDetails">添加
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteWmsInPlanDetails">删除
</el-button>
</el-col>
</el-row>
<div>
<el-table :data="wmsInPlanDetailsList" :row-class-name="rowWmsInPlanDetailsIndex"
@selection-change="handleWmsInPlanDetailsSelectionChange" ref="wmsInPlanDetails"
:highlight-current-row="isKnifeBack" @current-change="handleWmsInPlanDetailsCurrentChange">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="物品" prop="materialId" width="170">
<template slot-scope="scope">
<el-select v-model="scope.row.materialId" placeholder="请选择物料" filterable remote
:remote-method="getMdItemList" clearable>
<el-option :label="item.itemName" :value="item.itemId.toString()" v-for="item in mdItemList"
:key="item.itemId">
<span style="float: left">{{ item.itemName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.itemCode }}</span>
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="批次" prop="batch" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.batch" plcaeholder="请输入批次"></el-input>
</template>
</el-table-column>
<el-table-column label="计划数量" prop="quantity" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.quantity" plcaeholder="请输入计划数量" type="number" :min="0"></el-input>
</template>
</el-table-column>
<el-table-column label="入库数量" prop="quantityIn" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.quantityIn" plcaeholder="请输入入库数量" type="number" :min="0"
@change="handleQuantityIn($event,scope.row)" :disabled="isKnifeBack"></el-input>
</template>
</el-table-column>
<el-table-column label="库位" prop="cellId" width="150">
<template slot-scope="scope">
<el-select v-model="scope.row.cellId" placeholder="请选择库位" filterable remote
:remote-method="getMdItemList" clearable>
<el-option :label="item.areaName" :value="item.areaId.toString()" v-for="item in areaList"
:key="item.areaId">
<span style="float: left">{{ item.areaName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.areaCode }}</span>
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="状态" prop="planInStatus" width="150">
<dict-tag :options="dict.type.in_plan_state" :value="form.state"></dict-tag>
</el-table-column>
</el-table>
</div>
<!--入库类型为整刀回库则显示-->
<!-- <div v-if="isKnifeBack && Object.keys(selectPlanDetail).length > 0">-->
<!-- <el-divider content-position="center">整刀实例</el-divider>-->
<!-- <wms-in-plan-detail-entity-table-cmps-->
<!-- :planDetail="wmsInPlanDetailsList[selectPlanDetail.index-1]"-->
<!-- :entityList.sync="wmsInPlanDetailsList[selectPlanDetail.index-1].wmsInPlanDetailEntityList"-->
<!-- @count="wmsInPlanDetailsList[selectPlanDetail.index-1].quantityIn = $event"-->
<!-- ></wms-in-plan-detail-entity-table-cmps>-->
<!-- </div>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
<el-dialog :title="title" :visible.sync="open" width="50%" append-to-body :close-on-click-modal="false">
<!--状态为1已执行 则禁用-->
<el-form ref="form" :model="form" :rules="rules" label-width="80px" inline :disabled="form.state === '1'">
<el-form-item label="计划编码" prop="planCode">
<el-input v-model="form.planCode" placeholder="请输入计划编码"></el-input>
</el-form-item>
<el-form-item label="入库类型" prop="planTypeId">
<el-select v-model="form.planTypeId" placeholder="请选择入库类型" @change="handlePlanTypeSelectChange">
<el-option :label="item.name" :value="item.typeId" v-for="item in inPlanTypeList"
:key="item.typeId"/>
</el-select>
</el-form-item>
<el-form-item label="源头单据" prop="relBillCode">
<el-input v-model="form.relBillCode" placeholder="请输入源头单据"></el-input>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注"></el-input>
</el-form-item>
<el-divider content-position="center">入库计划明细信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddWmsInPlanDetails">添加
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteWmsInPlanDetails">删除
</el-button>
</el-col>
</el-row>
<div>
<el-table :data="wmsInPlanDetailsList" :row-class-name="rowWmsInPlanDetailsIndex"
@selection-change="handleWmsInPlanDetailsSelectionChange" ref="wmsInPlanDetails"
@current-change="handleWmsInPlanDetailsCurrentChange">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="物品" prop="materialId" width="170">
<template slot-scope="scope">
<el-select v-model="scope.row.materialId" placeholder="请选择物料" filterable remote
:remote-method="getMdItemList" clearable>
<el-option :label="item.itemName" :value="item.itemId.toString()" v-for="item in mdItemList"
:key="item.itemId">
<span style="float: left">{{ item.itemName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.itemCode }}</span>
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="批次" prop="batch" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.batch" plcaeholder="请输入批次"></el-input>
</template>
</el-table-column>
<el-table-column label="计划数量" prop="quantity" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.quantity" plcaeholder="请输入计划数量" type="number" :min="0"></el-input>
</template>
</el-table-column>
<el-table-column label="入库数量" prop="quantityIn" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.quantityIn" plcaeholder="请输入入库数量" type="number" :min="0"
@change="handleQuantityIn($event,scope.row)" :disabled="isKnifeBack"></el-input>
</template>
</el-table-column>
<el-table-column label="库位" prop="cellId" width="150">
<template slot-scope="scope">
<el-select v-model="scope.row.cellId" placeholder="请选择库位" filterable remote
:remote-method="getMdItemList" clearable>
<el-option :label="item.areaName" :value="item.areaId.toString()" v-for="item in areaList"
:key="item.areaId">
<span style="float: left">{{ item.areaName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.areaCode }}</span>
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="状态" prop="planInStatus" width="150">
<dict-tag :options="dict.type.in_plan_state" :value="form.state"></dict-tag>
</el-table-column>
</el-table>
</div>
</el-dialog>
</div>
<!-- 添加或修改入库计划对话框 整刀回库 -->
<div v-if="isKnifeBack">
<wms-in-plan-knife-back-form-cmps :data-form.sync="form" :visible.sync="open" @confirm="getList"
@planTypeSelectChange="handlePlanTypeSelectChange"
></wms-in-plan-knife-back-form-cmps>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
@ -259,8 +240,6 @@ import {listTYPE} from "@/api/md/TYPE";
import {listMdItem} from "@/api/mes/md/mdItem"
import {listArea} from "@/api/mes/wm/area"
import {addWmsInTask} from "@/api/mes/wm/wmsInTask"
import WmsInPlanDetailEntityTableCmps from "@/views/mes/wm/inPlan/wmsInPlanDetailEntityTableCmps.vue";
import WmsInPlanKnifeBackFormCmps from "@/views/mes/wm/inPlan/wmsInPlanKnifeBackFormCmps.vue";
//
const planCodeValidator = (rule, value, callback) => {
@ -278,7 +257,6 @@ const planCodeValidator = (rule, value, callback) => {
}
export default {
name: "PLAN",
components: {WmsInPlanKnifeBackFormCmps, WmsInPlanDetailEntityTableCmps},
dicts: ['in_plan_state', 'plan_source_type'],
data() {
return {
@ -360,12 +338,7 @@ export default {
}
};
},
computed: {
/** 控制弹窗类型 */
isKnifeBack() {
return this.form.planTypeId == 9 || this.form.planTypeId == 7 || this.form.planTypeId == 15;
}
},
computed: {},
created() {
this.getList();
},

View File

@ -1,187 +0,0 @@
<script>
import {addWmsInPlanDetailsEntity, updateWmsInPlanDetailsEntity} from "@/api/mes/wm/wmsInPlanDetailsEntity";
import BaseKnifeSelectCmps from "@/views/mes/md/baseKnife/baseKnifeSelectCmps.vue";
import {listMdItem} from "@/api/mes/md/mdItem";
export default {
name: "wmsInPlanDetailEntityTableCmps",
components: {BaseKnifeSelectCmps},
props: {
entityList: {
type: Array,
require: true
},
planTypeId: {
type: String,
require: true
}
},
data() {
return {
localEntityList: [...this.entityList],
baseKnifeVisible: false,
selectIndex: -1
}
},
computed: {
getKnifeType() {
if (this.planTypeId == 9 || this.planTypeId == 15) {
return "整刀"
} else {
return "刀柄类"
}
}
},
methods: {
addEntity() {
const param = {
source: "",
knifeId: "",
consumeLife: 0
}
console.log(this.localEntityList)
if (!this.localEntityList) {
this.localEntityList = [param]
} else {
this.localEntityList.push(param)
}
this.$emit("count", this.localEntityList.length)
this.updateEntityList()
},
handleDelete(e) {
this.localEntityList.splice(e.$index, 1)
this.updateEntityList()
},
handleSelectionChange(e) {
},
updateEntityList() {
this.$emit("update:entityList", this.localEntityList)
},
selectBaseKnifeChange(e) {
if (this.selectIndex !== -1) {
this.localEntityList[this.selectIndex].knifeId = e.baseKnifeId
this.localEntityList[this.selectIndex].baseKnifeInfo = e
//
listMdItem({itemCode: e.knifeCode}).then(res => {
if (res.total > 0) {
this.localEntityList[this.selectIndex].materialInfo = res.rows[0];
} else {
console.error("没有查询到对应materialCode的物料信息")
}
//
this.selectIndex = -1
})
this.updateEntityList()
}
},
showBaseKnifeDialog(e) {
this.selectIndex = e.$index
this.baseKnifeVisible = true
}
},
watch: {
entityList(newValue, oldValue) {
this.localEntityList = [...newValue]
}
}
}
</script>
<template>
<div>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini"
@click="addEntity">添加
</el-button>
</el-col>
</el-row>
<!--整刀回库-->
<el-table :data="localEntityList" v-if="planTypeId==9" @selection-change="handleSelectionChange">
<el-table-column label="台账ID" align="center" prop="knifeId">
<template slot-scope="scope">
<el-input v-model="scope.row.knifeId" @change="updateEntityList">
<el-button slot="append" icon="el-icon-search" @click="showBaseKnifeDialog(scope)"></el-button>
</el-input>
</template>
</el-table-column>
<el-table-column label="来源" align="center" prop="source">
<template slot-scope="scope">
<el-input v-model="scope.row.source" @change="updateEntityList"></el-input>
</template>
</el-table-column>
<el-table-column label="消耗寿命" align="center" prop="consumeLife">
<template slot-scope="scope">
<el-input v-model="scope.row.consumeLife" type="number" min="0" @change="updateEntityList"></el-input>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope)"
v-hasPermi="['wm:wmsInPlanDetailsEntity:remove']"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!--刀柄入库-->
<el-table :data="localEntityList" v-if="planTypeId==7" @selection-change="handleSelectionChange">
<el-table-column label="RFID" align="center" prop="rfid">
<template slot-scope="scope">
<el-input v-model="scope.row.rfid" @change="updateEntityList"></el-input>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope)"
v-hasPermi="['wm:wmsInPlanDetailsEntity:remove']"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!--拆刀回库-->
<el-table :data="localEntityList" v-if=" planTypeId==15" @selection-change="handleSelectionChange">
<el-table-column label="台账ID" align="center" prop="knifeId">
<template slot-scope="scope">
<el-input v-model="scope.row.knifeId" @change="updateEntityList">
<el-button slot="append" icon="el-icon-search" @click="showBaseKnifeDialog(scope)"></el-button>
</el-input>
</template>
</el-table-column>
<el-table-column label="来源" align="center" prop="source">
<template slot-scope="scope">
<el-input v-model="scope.row.source" @change="updateEntityList"></el-input>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope)"
v-hasPermi="['wm:wmsInPlanDetailsEntity:remove']"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<base-knife-select-cmps :visible.sync="baseKnifeVisible" :knife-type="getKnifeType"
@change="selectBaseKnifeChange"></base-knife-select-cmps>
</div>
</template>
<style scoped lang="scss">
</style>

View File

@ -1,256 +0,0 @@
<script>
import {listArea} from "@/api/mes/wm/area";
import WmsInPlanDetailEntityTableCmps from "@/views/mes/wm/inPlan/wmsInPlanDetailEntityTableCmps.vue";
import {addPLAN, updatePLAN} from "@/api/wm/PLAN";
import {listMdItem} from "@/api/mes/md/mdItem";
import {listTYPE} from "@/api/md/TYPE";
import {isDuplicateRfid} from "@/api/mes/md/baseKnife";
export default {
name: "wmsInPlanKnifeBackFormCmps",
components: {WmsInPlanDetailEntityTableCmps},
props: {
dataForm: {
type: Object,
require: true
},
visible: {
type: Boolean,
require: true
}
},
data() {
return {
localDataForm: this.dataForm || {},
wmsInPlanDetailForm: {},
//
areaList: [],
//
wmsInPlanDetailEntityList: [],
//
rules: {
planCode: [{required: true}],
relBillCode: [{required: true}],
},
localVisible: this.visible,
//
inPlanTypeList: [],
mdItemList: []
}
},
computed: {
title() {
return this.localDataForm.planId ? "修改入库计划" : "新增入库计划"
},
},
methods: {
/** 获取库位列表 */
getAreaList(areaName = "") {
this.loading = true;
const params = {
pageNum: 1,
pageSize: 100,
//
itemName: areaName
}
listArea(params).then(response => {
this.areaList = response.rows;
});
},
/** 对话框关闭 */
handleClose() {
this.reset();
this.$emit("update:visible", false)
},
async validateRfid() {
const rfidList = this.wmsInPlanDetailEntityList.map(entity => entity.rfid);
if (rfidList.length === 0) return
const res = await isDuplicateRfid(rfidList.join(","));
return res.data
},
/** 提交按钮 */
async submitForm() {
const validateRfidResult = await this.validateRfid();
if (validateRfidResult.length > 0) {
this.$modal.msgError(`RFID重复${validateRfidResult}`);
return;
}
await this.$refs["form"].validate(valid => {
if (valid) {
this.localDataForm.wmsInPlanDetailsList = []
//
this.localDataForm.wmsInPlanDetailsList = this.wmsInPlanDetailEntityList.map(item => {
const materialId = this.wmsInPlanDetailForm.materialId || item.materialInfo.itemId
//
// delete item.materialInfo
// delete item.baseKnifeInfo
return {
materialId,
cellId: this.wmsInPlanDetailForm.cellId,
batch: this.wmsInPlanDetailForm.batch,
quantity: 1,
quantityIn: 1,
wmsInPlanDetailEntityList: [item]
}
})
if (this.localDataForm.planId != null) {
updatePLAN(this.localDataForm).then(response => {
this.$modal.msgSuccess("修改成功");
});
} else {
//
this.localDataForm.state = 0
//
this.localDataForm.sourceType = "SGLR"
addPLAN(this.localDataForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.$emit("confirm")
});
}
}
});
this.handleClose();
},
/** 获取入库计划类型 */
getPlanTypeList() {
this.loading = true;
const planTypeParams = {
pageNum: 1,
pageSize: 100,
// 1
flag: 1
}
listTYPE(planTypeParams).then(response => {
this.inPlanTypeList = response.rows;
});
},
handlePlanTypeSelectChange(typeId) {
this.$emit("planTypeSelectChange", typeId)
},
/**
* 获取物料列表
* @param itemName
*/
getMdItemList(itemName = "") {
this.loading = true;
const params = {
pageNum: 1,
pageSize: 100,
//
itemName: itemName
}
listMdItem(params).then(response => {
this.mdItemList = response.rows;
});
},
//
reset() {
this.form = {
planId: null,
state: null,
sourceType: null,
wareId: null,
cellCode: null,
workOrderCode: null,
expectDate: null,
publishName: null,
publishTime: null,
closerId: null,
closeTime: null,
relBillCode: null,
createBy: null,
createTime: null,
updateTime: null,
updateBy: null,
remark: null,
customerId: null,
poCode: null,
departmentId: null,
contractNo: null,
supplierId: null,
businessTypeId: null,
srcOutTaskId: null,
isActive: null,
isDelete: null,
planCode: null,
planTypeId: null,
wmsInPlanDetailsList: []
};
this.wmsInPlanDetailsList = [];
this.resetForm("form");
},
},
mounted() {
this.getAreaList();
this.getPlanTypeList();
this.getMdItemList();
},
watch: {
localDataForm(newVal) {
this.$emit("update:dataForm", newVal)
}
}
}
</script>
<template>
<el-dialog :title="title" :visible="visible" width="50%" append-to-body @close="handleClose"
:close-on-click-modal="false">
<!--状态为1已执行 则禁用-->
<el-form ref="form" :model="localDataForm" :rules="rules" label-width="80px" inline
:disabled="localDataForm.state === '1'">
<el-form-item label="计划编码" prop="planCode">
<el-input v-model="localDataForm.planCode" placeholder="请输入计划编码"></el-input>
</el-form-item>
<el-form-item label="入库类型" prop="planTypeId">
<el-select v-model="localDataForm.planTypeId" placeholder="请选择入库类型" @change="handlePlanTypeSelectChange">
<el-option :label="item.name" :value="item.typeId" v-for="item in inPlanTypeList"
:key="item.typeId"/>
</el-select>
</el-form-item>
<el-form-item label="源头单据" prop="relBillCode">
<el-input v-model="localDataForm.relBillCode" placeholder="请输入源头单据"></el-input>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="localDataForm.remark" placeholder="请输入备注"></el-input>
</el-form-item>
<el-form-item label="批次" prop="batch">
<el-input v-model="wmsInPlanDetailForm.batch" plcaeholder="请输入批次"></el-input>
</el-form-item>
<el-form-item label="库位" prop="cellId">
<el-select v-model="wmsInPlanDetailForm.cellId" placeholder="请选择库位" filterable remote
:remote-method="getAreaList" clearable>
<el-option :label="item.areaName" :value="item.areaId.toString()" v-for="item in areaList"
:key="item.areaId">
<span style="float: left">{{ item.areaName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.areaCode }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="物品" prop="materialId" v-if="localDataForm.planTypeId==7">
<el-select v-model="wmsInPlanDetailForm.materialId" placeholder="请选择物料" filterable remote
:remote-method="getMdItemList" clearable>
<el-option :label="item.itemName" :value="item.itemId.toString()" v-for="item in mdItemList"
:key="item.itemId">
<span style="float: left">{{ item.itemName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.itemCode }}</span>
</el-option>
</el-select>
</el-form-item>
<el-divider content-position="center">整刀实例</el-divider>
<wms-in-plan-detail-entity-table-cmps
:entityList.sync="wmsInPlanDetailEntityList"
:planTypeId="localDataForm.planTypeId"
></wms-in-plan-detail-entity-table-cmps>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="handleClose"> </el-button>
</div>
</el-dialog>
</template>
<style scoped lang="scss">
</style>