工单添加BOM组成信息

This commit is contained in:
JinLu.Yin 2022-05-10 00:46:54 +08:00
parent 93ef031093
commit 0c3b0ecb19
3 changed files with 392 additions and 62 deletions

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询生产工单BOM组成列表
export function listWorkorderbom(query) {
return request({
url: '/mes/pro/workorderbom/list',
method: 'get',
params: query
})
}
// 查询生产工单BOM组成详细
export function getWorkorderbom(lineId) {
return request({
url: '/mes/pro/workorderbom/' + lineId,
method: 'get'
})
}
// 新增生产工单BOM组成
export function addWorkorderbom(data) {
return request({
url: '/mes/pro/workorderbom',
method: 'post',
data: data
})
}
// 修改生产工单BOM组成
export function updateWorkorderbom(data) {
return request({
url: '/mes/pro/workorderbom',
method: 'put',
data: data
})
}
// 删除生产工单BOM组成
export function delWorkorderbom(lineId) {
return request({
url: '/mes/pro/workorderbom/' + lineId,
method: 'delete'
})
}

View File

@ -0,0 +1,235 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['mes:pro:workorderbom:export']"
>导出</el-button>
</el-col>
<right-toolbar @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="workorderbomList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="BOM物料编号" width="120" align="center" prop="itemCode" />
<el-table-column label="BOM物料名称" width="200" align="center" prop="itemName" :show-overflow-tooltip="true"/>
<el-table-column label="规格型号" align="center" prop="itemSpc" :show-overflow-tooltip="true"/>
<el-table-column label="单位" align="center" prop="unitOfMeasure" />
<el-table-column label="物料/产品" align="center" prop="itemOrProduct" >
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_item_product" :value="scope.row.itemOrProduct"/>
</template>
</el-table-column>
<el-table-column label="预计使用量" align="center" prop="quantity" />
<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-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['mes:pro:workorderbom:edit']"
>修改</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改生产工单BOM组成对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="预计使用量" prop="quantity">
<el-input v-model="form.quantity" placeholder="请输入预计使用量" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</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>
<script>
import { listWorkorderbom, getWorkorderbom, delWorkorderbom, addWorkorderbom, updateWorkorderbom } from "@/api/mes/pro/workorderbom";
export default {
name: "Workorderbom",
dicts: ['mes_item_product'],
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
// BOM
workorderbomList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
workorderId: null,
itemId: null,
itemCode: null,
itemName: null,
itemSpc: null,
unitOfMeasure: null,
itemOrProduct: null,
quantity: null,
},
//
form: {},
//
rules: {
workorderId: [
{ required: true, message: "生产工单ID不能为空", trigger: "blur" }
],
itemId: [
{ required: true, message: "BOM物料ID不能为空", trigger: "blur" }
],
itemCode: [
{ required: true, message: "BOM物料编号不能为空", trigger: "blur" }
],
itemName: [
{ required: true, message: "BOM物料名称不能为空", trigger: "blur" }
],
unitOfMeasure: [
{ required: true, message: "单位不能为空", trigger: "blur" }
],
itemOrProduct: [
{ required: true, message: "物料产品标识不能为空", trigger: "blur" }
],
quantity: [
{ required: true, message: "预计使用量不能为空", trigger: "blur" }
],
}
};
},
props: {
optType: undefined,
workorderId: undefined
},
created() {
this.getList();
},
methods: {
/** 查询生产工单BOM组成列表 */
getList() {
this.loading = true;
this.queryParams.workorderId = this.workorderId;
listWorkorderbom(this.queryParams).then(response => {
this.workorderbomList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
lineId: null,
workorderId: null,
itemId: null,
itemCode: null,
itemName: null,
itemSpc: null,
unitOfMeasure: null,
itemOrProduct: null,
quantity: null,
remark: null,
attr1: null,
attr2: null,
attr3: null,
attr4: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.lineId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const lineId = row.lineId || this.ids
getWorkorderbom(lineId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改生产工单BOM组成";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.lineId != null) {
updateWorkorderbom(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addWorkorderbom(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 导出按钮操作 */
handleExport() {
this.download('mes/pro/workorderbom/export', {
...this.queryParams
}, `workorderbom_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@ -17,7 +17,6 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="来源单据" prop="sourceCode">
<el-input
v-model="queryParams.sourceCode"
@ -74,7 +73,7 @@
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
@ -82,7 +81,7 @@
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['pro:workorder:add']"
v-hasPermi="['mes:pro:workorder:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
@ -93,7 +92,7 @@
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['pro:workorder:edit']"
v-hasPermi="['mes:pro:workorder:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
@ -104,7 +103,7 @@
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['pro:workorder:remove']"
v-hasPermi="['mes:pro:workorder:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
@ -114,22 +113,27 @@
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['pro:workorder:export']"
v-hasPermi="['mes:pro:workorder:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="workorderList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="工单编码" width="150" align="center" prop="workorderCode" />
<el-table
v-loading="loading"
:data="workorderList"
row-key="workorderId"
default-expand-all
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column label="工单编码" width="180" prop="workorderCode" />
<el-table-column label="工单名称" width="200" align="center" prop="workorderName" :show-overflow-tooltip="true"/>
<el-table-column label="来源类型" align="center" prop="orderSource" >
<el-table-column label="工单来源" align="center" prop="orderSource" >
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_workorder_sourcetype" :value="scope.row.orderSource"/>
</template>
</el-table-column>
<el-table-column label="订单编号" align="center" prop="sourceCode" />
<el-table-column label="订单编号" width="120" align="center" prop="sourceCode" />
<el-table-column label="产品编号" width="120" align="center" prop="productCode" />
<el-table-column label="产品名称" width="200" align="center" prop="productName" :show-overflow-tooltip="true"/>
<el-table-column label="规格型号" align="center" prop="productSpc" :show-overflow-tooltip="true"/>
@ -147,35 +151,35 @@
<dict-tag :options="dict.type.mes_order_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="100px" class-name="small-padding fixed-width">
<el-table-column label="操作" width="150px" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
v-if="scope.row.status =='PREPARE'"
@click="handleUpdate(scope.row)"
v-if="scope.row.status == 'PREPARE'"
v-hasPermi="['mes:pro:workorder:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
v-if="scope.row.status =='CONFIRMED'"
@click="handleAdd(scope.row)"
v-hasPermi="['mes:pro:workorder:add']"
>新增</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
v-if="scope.row.status =='PREPARE'"
@click="handleDelete(scope.row)"
v-if="scope.row.status == 'PREPARE'"
v-hasPermi="['mes:pro:workorder:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改生产工单对话框 -->
<el-dialog :title="title" :visible.sync="open" width="960px" append-to-body>
@ -191,7 +195,7 @@
<el-switch v-model="autoGenFlag"
active-color="#13ce66"
active-text="自动生成"
@change="handleAutoGenChange(autoGenFlag)" v-if="optType != 'view'">
@change="handleAutoGenChange(autoGenFlag)" v-if="optType != 'view' && form.status =='PREPARE'">
</el-switch>
</el-form-item>
</el-col>
@ -311,9 +315,16 @@
</el-col>
</el-row>
</el-form>
<el-tabs type="border-card" v-if="form.workorderId != null">
<el-tab-pane label="BOM组成">
<Workorderbom ref="bomlist" :optType="optType" :workorderId="form.workorderId"></Workorderbom>
</el-tab-pane>
<el-tab-pane label="物料需求"></el-tab-pane>
</el-tabs>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="cancel" v-if="optType =='view'">返回</el-button>
<el-button type="primary" @click="submitForm" v-else> </el-button>
<el-button type="primary" @click="cancel" v-if="optType =='view' || form.status !='PREPARE' ">返回</el-button>
<el-button type="primary" @click="submitForm" v-if="form.status =='PREPARE' && optType !='view' "> </el-button>
<el-button type="success" @click="handleFinish" v-if="form.status =='PREPARE' && optType !='view' && form.workorderId !=null">完成</el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@ -322,13 +333,22 @@
<script>
import { listWorkorder, getWorkorder, delWorkorder, addWorkorder, updateWorkorder } from "@/api/mes/pro/workorder";
import Workorderbom from "./bom/bom.vue";
import ItemSelect from "@/components/itemSelect/single.vue";
import ClientSelect from "@/components/clientSelect/single.vue";
import {genCode} from "@/api/system/autocode/rule"
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "Workorder",
dicts: ['mes_order_status','mes_workorder_sourcetype'],
components: { ItemSelect ,ClientSelect},
components: {
Treeselect,
ItemSelect ,
ClientSelect,
Workorderbom
},
data() {
return {
//
@ -336,26 +356,22 @@ export default {
optType: undefined,
//
loading: true,
//
ids: [],
//
showSearch: true,
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
workorderList: [],
//
workorderOptions: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
workorderCode: null,
workorderName: null,
orderSource: null,
@ -370,6 +386,8 @@ export default {
clientCode: null,
clientName: null,
requestDate: null,
parentId: null,
ancestors: null,
status: null,
},
//
@ -386,7 +404,7 @@ export default {
{ required: true, message: "来源类型不能为空", trigger: "blur" }
],
productId: [
{ required: true, message: "产品ID不能为空", trigger: "blur" }
{ required: true, message: "产品不能为空", trigger: "blur" }
],
productCode: [
{ required: true, message: "产品编号不能为空", trigger: "blur" }
@ -414,11 +432,30 @@ export default {
getList() {
this.loading = true;
listWorkorder(this.queryParams).then(response => {
this.workorderList = response.rows;
this.total = response.total;
this.workorderList = this.handleTree(response.data, "workorderId", "parentId");
this.loading = false;
});
},
/** 转换生产工单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.workorderId,
label: node.workorderName,
children: node.children
};
},
/** 查询生产工单下拉树结构 */
getTreeselect() {
listWorkorder().then(response => {
this.workorderOptions = [];
const data = { workorderId: 0, workorderName: '顶级节点', children: [] };
data.children = this.handleTree(response.data, "workorderId", "parentId");
this.workorderOptions.push(data);
});
},
//
cancel() {
this.open = false;
@ -442,12 +479,9 @@ export default {
clientCode: null,
clientName: null,
requestDate: null,
status: 'PREPARE',
parentId: null,
status: "PREPARE",
remark: null,
attr1: null,
attr2: null,
attr3: null,
attr4: null,
createBy: null,
createTime: null,
updateBy: null,
@ -458,7 +492,6 @@ export default {
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
@ -466,26 +499,36 @@ export default {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.workorderId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
handleAdd(row) {
this.reset();
this.getTreeselect();
if (row != null && row.workorderId) {
this.form.parentId = row.workorderId;
this.form.orderSource = row.orderSource;
this.form.sourceCode = row.sourceCode;
this.form.clientId = row.clientId;
this.form.clientCode = row.clientCode;
this.form.clientName = row.clientName;
} else {
this.form.parentId = 0;
}
this.open = true;
this.title = "添加生产工单";
this.optType="add";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const workorderId = row.workorderId || this.ids
getWorkorder(workorderId).then(response => {
this.getTreeselect();
if (row != null) {
this.form.parentId = row.workorderId;
}
getWorkorder(row.workorderId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改生产工单";
this.optType="edit";
});
},
/** 提交按钮 */
@ -495,13 +538,15 @@ export default {
if (this.form.workorderId != null) {
updateWorkorder(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
//this.open = false;
this.$refs["bomlist"].getList();
this.getList();
});
} else {
addWorkorder(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
//this.open = false;
this.form.workorderId = response.data;
this.getList();
});
}
@ -510,25 +555,31 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
const workorderIds = row.workorderId || this.ids;
this.$modal.confirm('是否确认删除生产工单编号为"' + workorderIds + '"的数据项?').then(function() {
return delWorkorder(workorderIds);
this.$modal.confirm('是否确认删除生产工单编号为"' + row.workorderId + '"的数据项?').then(function() {
return delWorkorder(row.workorderId);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
handleSelectProduct(){
this.$refs.itemSelect.showFlag = true;
},
handleSelectClient(){
this.$refs.clientSelect.showFlag = true;
},
/** 导出按钮操作 */
handleExport() {
this.download('mes/pro/workorder/export', {
...this.queryParams
}, `workorder_${new Date().getTime()}.xlsx`)
},
handleSelectProduct(){
this.$refs.itemSelect.showFlag = true;
},
handleSelectClient(){
this.$refs.clientSelect.showFlag = true;
handleFinish(){
let that = this;
this.$modal.confirm('是否完成工单编制?【完成后将不能更改】').then(function(){
that.form.status = 'CONFIRMED';
that.submitForm();
});
},
//
onItemSelected(obj){