<!--
|
* @Author: lzhe lzhe@example.com
|
* @Date: 2024-05-24 11:25:26
|
* @LastEditors: lzhe lzhe@example.com
|
* @LastEditTime: 2024-05-28 11:09:17
|
* @FilePath: /src/views/console/product-process/process-route/workmanship.vue
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
-->
|
<template>
|
<div class="workmanship">
|
<div class="main-content-left">
|
<div class="info-top-title">工艺路线</div>
|
<div style="margin-bottom: 12px;">
|
<el-button type="primary" @click="table_open">新增</el-button>
|
<el-button type="primary" v-if="isCustomization" @click="determineVersion">定版</el-button>
|
<el-button :disabled="mergeDisabled" @click="mergeBtn">并序</el-button>
|
</div>
|
<el-table ref="multipleTableRef0" :data="tableData" row-key="id" border :tree-props="{ children: 'children', hasChildren: 'has' }" style="width: 100%" class="multipleTableRef" @selection-change="HandleSelectionChange" @row-click="rowClick" default-expand-all>
|
<el-table-column type="selection" :selectable="setSelectable" width="55" />
|
<el-table-column prop="index" label="工序顺序">
|
<template #default="scope">
|
<span>{{scope.row.index || "-"}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="processCode" label="工序编号"></el-table-column>
|
<el-table-column prop="processName" label="工序名称"></el-table-column>
|
<el-table-column fixed="right" label="操作" width="200px">
|
<template #default="scope">
|
<el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">编辑</el-button>
|
<el-button text type="primary" size="small" @click="table_del(scope.row, scope.$index)" v-if="scope.row.index">删除</el-button>
|
<el-button text type="primary" size="small" @click="table_remove(scope.row, scope.$index)" v-if="!scope.row.index">移除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<div class="main-content-right">
|
<div class="main-info-title">工序信息</div>
|
<div class="addWorking" @click="table_open" v-if="!isCustomization">添加工序</div>
|
<ul v-if="isCustomization">
|
<li>工序编号<span></span></li>
|
<li>工序名称<span></span></li>
|
<li>工序顺序<span></span></li>
|
</ul>
|
</div>
|
</div>
|
<save-dialog v-if="dialog.save" ref="saveDialog" @success="addRouteSuccess" @closed="dialog.save=false"></save-dialog>
|
<el-drawer v-model="drawer" title="添加工序" direction="rtl" :before-close="handleClose" size="60%" modal-class="viewData">
|
<!-- 新增路线 -->
|
<div class="addworkmanship">
|
<add-workmanship ref="addworkmanship" @success="handleSuccess" :isClear="isClear" :craftId="craftId"></add-workmanship>
|
</div>
|
</el-drawer>
|
<!-- 并序弹窗 -->
|
<el-dialog title="并序" v-model="mergeVisible" :width="500" destroy-on-close>
|
<el-form :inline="true" ref="mergeVisibleData" :model="mergeVisibleData" :rules="mergeVisibleRules" label-width="80px">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="工序编号" prop="processCode" style="width: 100%">
|
<el-input v-model="mergeVisibleData.processCode" placeholder="请输入工序编号" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="工序名称" prop="processName" style="width: 100%">
|
<el-input v-model="mergeVisibleData.processName" placeholder="请输入工序名称" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<el-button @click="cencelMerge" >取消</el-button>
|
<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="mergeSubmit">确定</el-button>
|
</template>
|
</el-dialog>
|
</template>
|
|
<script>
|
import addWorkmanship from './addWorkmanship'
|
import saveDialog from './addWorking'
|
export default {
|
name: 'workmanship',
|
components: {saveDialog,addWorkmanship},
|
props: ["isCustomization","craftId"],
|
data() {
|
return {
|
mergeVisibleData: {
|
processCode: "",
|
processName: ""
|
},
|
mergeVisibleRules: {
|
processCode:[{required: true, message: '请输入工序编号'}],
|
processName:[{required: true, message: '请输入工序名称'}]
|
},
|
mergeVisible: false,
|
mergeDisabled: true,
|
isClear: false,
|
drawer: false,
|
tableData: [],
|
selection: [],
|
dialog: {
|
save: false
|
}
|
}
|
},
|
mounted(){
|
},
|
watch: {
|
craftId(val) {
|
if(val) {
|
this.getcraftlList();
|
}
|
}
|
},
|
methods: {
|
setSelectable(row,rowIndex) {
|
return !row.children && row.index;
|
},
|
cencelMerge() {
|
this.mergeVisible=false;
|
this.mergeVisibleData = {
|
processCode: "",
|
processName: ""
|
};
|
},
|
mergeSubmit() {
|
var that = this;
|
this.selection.forEach(item=> {
|
item.versionProcessId = item.id;
|
});
|
var obj = {
|
parallelVO: this.selection,
|
processCode: this.mergeVisibleData.processCode,
|
processName: this.mergeVisibleData.processName,
|
sort: 1,
|
versionId: this.craftId
|
}
|
this.$refs.mergeVisibleData.validate(async (valid) => {
|
if (valid) {
|
that.$HTTP.post("/api/blade-cps/production-craft-process/save-parallel",obj).then(res=> {
|
if(res.code == 200) {
|
that.mergeVisible = false;
|
that.$message.success("操作成功");
|
that.getcraftlList();
|
|
}else {
|
that.$alert(res.message, "提示", {type: 'error'});
|
}
|
})
|
}else{
|
return false;
|
}
|
})
|
},
|
mergeBtn() {
|
this.mergeVisible = true;
|
},
|
handleSuccess(value) {
|
this.drawer = false;
|
this.isClear = false;
|
this.getcraftlList();
|
},
|
getcraftlList() {
|
// this.$HTTP.get(`/api/blade-cps/production-craft-version/detail/${this.craftId}`).then(res=> {
|
// if(res.code == 200) {
|
// res.data.processList.forEach((item,index)=> {
|
// item.index = index + 1;
|
// });
|
// this.tableData = res.data.processList;
|
// }
|
// })
|
this.$HTTP.get(`/api/blade-cps/production-craft-process/child-tree?versionId=${this.craftId}`).then(res=> {
|
if(res.code == 200) {
|
res.data.forEach((item,index)=> {
|
if(item.children && item.children.length > 0) {
|
item.disabled = true;
|
}
|
item.index = index + 1;
|
})
|
this.tableData = res.data;
|
}
|
})
|
},
|
handleClose(done) {
|
this.isClear = true;
|
done();
|
},
|
determineVersion() {
|
var that = this;
|
this.$confirm(`工艺路线定版后,不支持编辑、删除、添加工序,请确认是否定版?`, '', {
|
type: 'warning'
|
}).then(() => {
|
this.$HTTP.put(`/api/blade-cps/production-craft-version/fix-version/${this.craftId}`).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
}else {
|
this.$message.error(res.msg);
|
}
|
})
|
}).catch(() => {
|
|
})
|
},
|
rowClick(row, column, event) {
|
// this.id = row.id;
|
// this.getWorkDetail();
|
// this.getPage1();
|
},
|
addRouteSuccess(selection) {
|
selection.forEach((item,i)=> {
|
item.index = i+1;
|
})
|
this.tableData = selection;
|
},
|
HandleSelectionChange(selection) {
|
this.selection = selection;
|
if(this.selection.length >= 2) {
|
this.mergeDisabled = false;
|
}else {
|
this.mergeDisabled = true;
|
}
|
},
|
table_open() {
|
if(this.isCustomization) { //首页的新建
|
this.drawer = true;
|
}else { //版本步骤中的新建
|
this.dialog.save = true
|
this.$nextTick(() => {
|
this.$refs.saveDialog.open();
|
})
|
}
|
},
|
table_edit(row,index) {
|
this.drawer = true;
|
this.$nextTick(()=> {
|
this.$refs.addworkmanship.setData(row);
|
})
|
},
|
table_del(row,index) {
|
var that = this;
|
this.$confirm(`确认要删除此工序吗?`, '', {
|
type: 'warning'
|
}).then(() => {
|
var obj = {
|
mainProcess: [],
|
normalProcess: that.tableData,
|
removeIds: [row.id],
|
versionId: that.craftId
|
}
|
this.$HTTP.post(`/api/blade-cps/production-craft-process/child-process-update`,obj).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.getcraftlList();
|
}
|
})
|
}).catch(() => {
|
|
})
|
},
|
table_remove(row,index) {
|
var that = this;
|
var tableData = [];
|
this.tableData.forEach(item=> {
|
if(item.children && item.children.lenght !=0) {
|
item.children.forEach(item1=> {
|
tableData.push(item1);
|
})
|
}else {
|
tableData.push(item);
|
}
|
})
|
this.$confirm(`此工序移除后,原并序将会转化为常规序。确定移除吗?`, '', {
|
type: 'warning'
|
}).then(() => {
|
var obj = {
|
mainProcess: [],
|
normalProcess: tableData,
|
removeIds: [row.parentId],
|
versionId: that.craftId
|
}
|
this.$HTTP.post(`/api/blade-cps/production-craft-process/child-process-update`,obj).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.getcraftlList();
|
}
|
})
|
}).catch(() => {
|
|
})
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.workmanship {
|
width: 100%;
|
display: flex;
|
}
|
.info-top-title {
|
padding-left: 8px;
|
border-left: 4px solid #86bffa;
|
line-height: 18px;
|
margin-bottom: 16px;
|
font-weight: 700;
|
font-size: 16px;
|
color: #333;
|
}
|
.main-content-left {
|
width: 60%;
|
}
|
.main-content-right {
|
flex: 1;
|
}
|
.main-content-right ul {
|
padding: 12px 30px;
|
}
|
.main-content-right ul li {
|
width: 50%;
|
float: left;
|
list-style: none;
|
margin-bottom:12px;
|
}
|
.main-content-right ul li span {
|
margin-left:12px;
|
}
|
.main-info-title {
|
font-size: 14px;
|
padding-left: 8px;
|
font-weight: 700;
|
font-size: 16px;
|
color: #333;
|
border-left: 4px solid #7ab3ee;
|
}
|
.addWorking {
|
color: #409eff;
|
padding: 12px 6px;
|
font-size: 14px;
|
cursor: pointer;
|
}
|
.addworkmanship {
|
padding: 0 40px;
|
}
|
</style>
|