Commit 9369d724 by 夏超

[fix] 修改前端工艺设计

parent a8553116
...@@ -292,17 +292,7 @@ ...@@ -292,17 +292,7 @@
<el-table ref="tabelRef" :data="isEdit?keyMaterialsCopyList:keyMaterialsList" <el-table ref="tabelRef" :data="isEdit?keyMaterialsCopyList:keyMaterialsList"
:height="tabelHeight" :header-cell-style="{backgroundColor:'#f5f7fa'}" style="width: 100%"> :height="tabelHeight" :header-cell-style="{backgroundColor:'#f5f7fa'}" style="width: 100%">
<el-table-column type="index" label="序号" align="center" width="50"></el-table-column> <el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
<el-table-column label="物料名称" align="center"> <el-table-column align="center" prop="product_name" label="物料名称"></el-table-column>
<template slot-scope="scope">
<el-select v-if="isEdit" v-model="scope.row.product_id" placeholder="请选择物料"
style="width: 100%;">
<el-option v-for="(item,index) in productList" :key="index" :label="item.name"
:value="item.id">
</el-option>
</el-select>
<span v-else>[[scope.row.product_name]]</span>
</template>
</el-table-column>
<el-table-column label="数量" align="center"> <el-table-column label="数量" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input-number v-if="isEdit" size="medium" v-model="scope.row.qty" <el-input-number v-if="isEdit" size="medium" v-model="scope.row.qty"
...@@ -310,15 +300,11 @@ ...@@ -310,15 +300,11 @@
<span v-else>[[scope.row.qty]]</span> <span v-else>[[scope.row.qty]]</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="必投" align="center"> <el-table-column align="center" label="防错码">
<template slot-scope="scope"> <template slot-scope="scope">
<div v-if="isEdit"> <el-input v-if="isEdit" size="medium" v-model="scope.row.protection_code">
<el-radio-group v-model="scope.row.must"> </el-input>
<el-radio :label="true"></el-radio> <span v-else>[[scope.row.protection_code]]</span>
<el-radio :label="false"></el-radio>
</el-radio-group>
</div>
<span v-else>[[ scope.row.must?'是':'否']]</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="!isEdit && prohibitedStateShow" label="操作" align="center" width="80"> <el-table-column v-if="!isEdit && prohibitedStateShow" label="操作" align="center" width="80">
...@@ -329,17 +315,19 @@ ...@@ -329,17 +315,19 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="buttonRowBoxClass" v-if="prohibitedStateShow"> <div style="padding: 10px;">
<el-button type="primary" size="small" :disabled="!selProductProcessData||isEdit" <el-button type="primary" size="small" :disabled="!selProductProcessData"
@click="addInfoHandle('关键物料')"> @click="keyMaterialBtnClick('添加')">
添加 添加
</el-button> </el-button>
<el-button type="primary" size="small" @click="editInfoHandle('关键物料')" <el-button type="primary" size="small" :disabled="!selProductProcessData"
:disabled="!selProductProcessData"> @click="keyMaterialBtnClick('编辑')">
[[isEdit?'取消编辑':'编辑']] [[isEdit?'取消保存':'编辑']]
</el-button>
<el-button type="primary" size="small" :disabled="!isEdit"
@click="keyMaterialBtnClick('保存')">
保存
</el-button> </el-button>
<el-button type="primary" :disabled="!isEdit" size="small"
@click="saveInfoHandle('关键物料')">保存</el-button>
</div> </div>
</div> </div>
<!-- 产线以及工位 --> <!-- 产线以及工位 -->
...@@ -481,34 +469,54 @@ ...@@ -481,34 +469,54 @@
</el-dialog> </el-dialog>
<!-- 添加关键物料 --> <!-- 添加关键物料 -->
<el-dialog title="添加关键物料" :visible.sync="keyMaterialsDialogShow" destroy-on-close width="50%" <el-dialog title="添加关键物料" :visible.sync="keyMaterialsDialogShow" destroy-on-close width="50%"
@close="dialogCloseHandle('添加关键物料')"> @close="dialogCloseHandle('添加关键物料')" @open="selMaterialDialogOpen">
<div style="max-height: 60vh; overflow-y: scroll; overflow-x: hidden;"> <div class="selectMaterialsBoxClass">
<el-form class="fromBox" :model="materialsForm" :rules="materialsRules" ref="materialsFormRef" <div class="tagBoxClass">
label-width="6rem"> <label>已选择物料:</label>
<el-form-item label="物料:" prop="product_id"> <el-tag class="tagClass" v-for="item in selmaterialList" :key="item.id" closable
<el-select v-model="materialsForm.product_id" placeholder="请选择物料" style="width: 100%;" @close="tagClosehandle(item)">
@change="selectTyleChange" filterable> [[item.name]]
<el-option v-for="(item,index) in productList" :key="index" :label="item.name" </el-tag>
:value="item.id"> </div>
</el-option> <div class="selMaterialsFiltrateBox">
</el-select> <el-input style="width: 30%;" size="medium" v-model="selMaterialValue" placeholder="请输入物料名称"
</el-form-item> @change="selMaterialCategoryChange"></el-input>
<el-form-item label="数量:" prop="qty"> <el-select style="width: 30%; margin-left: 20px;" size="medium" clearable
<el-input-number v-model="materialsForm.qty" placeholder="请填写标准下限" :min="0"></el-input-number> v-model="selMaterialCategoryId" placeholder="请选择类别" @change="selMaterialCategoryChange">
</el-form-item> <el-option v-for="item in materialCategoryList" :key="item.id" :label="item.name"
<el-form-item label="是否必投:" prop="must"> :value="item.id">
<div> </el-option>
<el-radio-group v-model="materialsForm.must"> </el-select>
<el-radio label="是"></el-radio> </div>
<el-radio label="否"></el-radio> <div class="selMaterialsContentBox">
</el-radio-group> <div v-for="(item,index) in materialList" :key="index" class="materialItemClass">
</div> <el-checkbox v-model="item.show" @change="materialsChangeHandle($event,item)">
</el-form-item> <el-tooltip effect="dark" :disabled="item.name.length<7" :content="item.name"
</el-form> placement="top">
<span class="nameLabelClass">[[item.name]]</span>
</el-tooltip>
<el-tooltip effect="dark" content="BOM内" placement="bottom"
:disabled="!(materialCheckList.includes(item.id))">
<span class="iconLabelClass">
<i v-if="materialCheckList.includes(item.id)" class="el-icon-paperclip"
style="color: #409EFF;"></i>
</span>
</el-tooltip>
</el-checkbox>
</div>
</div>
</div> </div>
<span slot="footer" class="dialog-footer"> <!-- 789 -->
<el-button size="small" @click="dialogCloseHandle('添加关键物料')">取消</el-button> <span slot="footer" class="selMaterialsBottonBox">
<el-button size="small" type="primary" @click="dialogSaveHandle('添加关键物料')">确定</el-button> <div class="selMaterialsPaginationBox">
<el-pagination @current-change="materialsCurrentChange" :current-page.sync="materialPageCount"
:page-size="materialPageSize" layout="prev, pager, next, jumper" :total="materialTotal">
</el-pagination>
</div>
<div class="dialog-footer">
<el-button size="small" @click="dialogCloseHandle('添加关键物料')">取消</el-button>
<el-button size="small" type="primary" @click="dialogSaveHandle('添加关键物料')">确定</el-button>
</div>
</span> </span>
</el-dialog> </el-dialog>
<!-- 维护工位弹窗 --> <!-- 维护工位弹窗 -->
...@@ -622,18 +630,14 @@ ...@@ -622,18 +630,14 @@
keyMaterialsList: [], //关键物料列表 keyMaterialsList: [], //关键物料列表
keyMaterialsCopyList: [], //关键物料列表备份 keyMaterialsCopyList: [], //关键物料列表备份
keyMaterialsDialogShow: false, // 关键物料添加弹窗状态 keyMaterialsDialogShow: false, // 关键物料添加弹窗状态
// 新建关键物料表单数据 materialList: [], // 物料列表
materialsForm: { selmaterialList: [], // 选中的物料列表
product_id: null, // 物料id selMaterialValue: '', // 选择物料弹窗输入框的值
qty: null, // 数量 selMaterialCategoryId: '', // 选择物料弹窗下拉框的值
must: null // 是否必投 materialCategoryList: [], // 物料类别列表
}, materialPageCount: 1, // 物料列表页码
// 添加关键物料 必填效验 materialPageSize: 30, // 物料列表每页数量
materialsRules: { materialTotal: 0, // 物料列表总条数
product_id: [{ required: true, trigger: 'blur', message: '请选择物料' }],
qty: [{ required: true, trigger: 'blur', message: '请输入数量' }],
must: [{ required: true, trigger: 'blur', message: '请选择是否必投' }],
},
productionLineStationList: [], // 产线工位列表 productionLineStationList: [], // 产线工位列表
maintainStationDialogShow: false, // 维护工位弹窗状态 maintainStationDialogShow: false, // 维护工位弹窗状态
productionLineList: [], // 产线列表 productionLineList: [], // 产线列表
...@@ -1051,6 +1055,7 @@ ...@@ -1051,6 +1055,7 @@
item['show'] = false item['show'] = false
}) })
this.keyMaterialsList = result.result.data this.keyMaterialsList = result.result.data
this.keyMaterialsCopyList = result.result.data
}).catch(error => { }).catch(error => {
this.errorHandle(error) this.errorHandle(error)
}) })
...@@ -1174,11 +1179,10 @@ ...@@ -1174,11 +1179,10 @@
this.selBadnessTypeData = [] this.selBadnessTypeData = []
} else if (type == '添加关键物料') { } else if (type == '添加关键物料') {
this.keyMaterialsDialogShow = false this.keyMaterialsDialogShow = false
this.materialsForm = { this.selMaterialValue = ''
product_id: null, this.selMaterialCategoryId = ''
qty: null, this.materialList = []
must: null this.selmaterialList = []
}
} else if (type == '绑定工位') { } else if (type == '绑定工位') {
this.maintainStationDialogShow = false this.maintainStationDialogShow = false
} }
...@@ -1390,39 +1394,41 @@ ...@@ -1390,39 +1394,41 @@
this.errorHandle(error, true) this.errorHandle(error, true)
}) })
} else if (type == '添加关键物料') { } else if (type == '添加关键物料') {
this.$refs.materialsFormRef.validate((valid) => { let oldList = []
if (valid) { this.keyMaterialsList.forEach(item => {
let config = { if (this.selmaterialList.find(it => it.id == item.product_id)) {
routing_line_id: this.selProductProcessData.line_id, let data = {
product_id: this.materialsForm.product_id, id: item.id,
qty: this.materialsForm.qty, product_id: item.product_id,
must: this.materialsForm.qty == '是' ? true : false product_name: item.product_name,
product_code: item.product_code,
qty: item.qty,
protection_code: item.protection_code
} }
this.loading = true oldList.push(data)
this.requestApi('/roke/workstation/craft_design/workstation_bom/create', config).then(data => {
if (data.result.code == 0) {
let config = {
routing_line_id: this.selProductProcessData.line_id
}
this.getRoutingLineBomApi(config).then(result => {
result.result.data.forEach(item => {
item['show'] = false
})
this.keyMaterialsList = result.result.data
}).catch(error => {
this.errorHandle(error, true)
})
}
this.loading = false
this.$message.success(data.result.message)
this.dialogCloseHandle('添加关键物料')
}).catch(error => {
this.errorHandle(error, true)
})
} else {
return false
} }
}) })
let newList = []
let oldIdList = []
this.keyMaterialsList.forEach(item => {
oldIdList.push(item.product_id)
})
this.selmaterialList.forEach(item => {
if (!(oldIdList.includes(item.id))) {
let data = {
id: '',
product_id: item.id,
product_name: this.materialList.find(it => it.id == item.id).name,
product_code: this.materialList.find(it => it.id == item.id).code,
qty: 1,
protection_code: ""
}
newList.push(data)
}
})
this.keyMaterialsCopyList = [...oldList, ...newList]
this.isEdit = true
this.dialogCloseHandle('添加关键物料')
} }
}, },
// 内容信息区域表格删除事件 // 内容信息区域表格删除事件
...@@ -1562,6 +1568,51 @@ ...@@ -1562,6 +1568,51 @@
} }
} }
}, },
// 关键物料页签功能按钮点击事件
keyMaterialBtnClick(type) {
if (type == '添加') {
this.keyMaterialsDialogShow = true
} else if (type == '编辑') {
if (this.isEdit) {
this.keyMaterialsList = JSON.parse(JSON.stringify(this.keyMaterialsCopyList))
}
this.isEdit = !this.isEdit
} else if (type == '保存') {
let product_data = []
this.keyMaterialsCopyList.forEach(item => {
let data = {
id: item.id ? item.id : false,
product_id: item.product_id,
qty: item.qty ? +item.qty : 1,
protection_code: item.protection_code ? item.protection_code : ''
}
product_data.push(data)
})
let config = {
routing_line_id: this.selProductProcessData.line_id,
product_data
}
this.loading = true
this.requestApi('/roke/dws/pd/primary/material/update', config, "更新失败,请稍后重试!").then(async result => {
await this.requestApi("/roke/dws/pd/primary/material/list", {
routing_line_id: this.selProductProcessData.line_id
}).then(res => {
this.loading = false
res.result.data.sort((a, b) => {
return a.id - b.id
})
this.keyMaterialsList = res.result.data
this.keyMaterialsCopyList = JSON.parse(JSON.stringify(res.result.data))
this.$message.success(result.result.message)
this.isEdit = false
}).catch(error => {
this.errorHandle(error, true)
})
}).catch(error => {
this.errorHandle(error, true)
})
}
},
// 内容信息区域表格保存事件 // 内容信息区域表格保存事件
saveInfoHandle(type) { saveInfoHandle(type) {
if (type == '工艺参数') { if (type == '工艺参数') {
...@@ -1613,6 +1664,7 @@ ...@@ -1613,6 +1664,7 @@
item['show'] = false item['show'] = false
}) })
this.keyMaterialsList = result.result.data this.keyMaterialsList = result.result.data
this.keyMaterialsCopyList = JSON.parse(JSON.stringify(result.result.data))
}).catch(error => { }).catch(error => {
this.errorHandle(error, true) this.errorHandle(error, true)
}) })
...@@ -1879,6 +1931,152 @@ ...@@ -1879,6 +1931,152 @@
this.errorHandle(error, true) this.errorHandle(error, true)
}) })
}, },
// 获取物料列表
getMaterialListApi() {
return new Promise((resolve, reject) => {
let id = this.treeActiveData.type == 'bom' ? this.treeActiveData.product_id : this.treeActiveData.id
let config = {
model: 'roke.product',
domain: [["id", "not in", [id]]],
fields: ['id', 'name', 'code'],
offset: (this.materialPageCount - 1) * this.materialPageSize,
limit: this.materialPageSize
}
if (this.selMaterialValue) {
config.domain.push(["name", "ilike", this.selMaterialValue])
}
if (this.selMaterialCategoryId) {
config.domain.push(["category_id", "=", this.selMaterialCategoryId])
}
axios({
method: "POST",
url: this.baseURL + "/roke/workstation/search_read",
data: config,
headers: {
'Content-Type': 'application/json',
},
}).then((result) => {
if (result?.data?.result?.code == 0) {
this.materialTotal = result.data.result.count
// 对数据进行排序
let accordArr = []
let otherArr = []
result.data.result.data.forEach(item => {
if (this.selmaterialList.find(it => item.id == it.id)) {
item['show'] = true
} else {
item['show'] = false
}
if (this.materialCheckList.includes(item.id)) {
accordArr.push(item)
} else {
otherArr.push(item)
}
})
// 789
result.data.result.data = accordArr.concat(otherArr)
this.materialList = result.data.result.data
resolve()
} else if (result?.data?.result?.code == 1) {
reject(result.data.result.message)
} else if (result?.data?.error) {
reject(result.data.error.message)
}
}).catch((error) => {
reject("获取工位列表失败!")
})
})
},
// 选择物料弹窗打开事件
async selMaterialDialogOpen() {
let selIdList = []
this.keyMaterialsList.forEach(item => {
let obj = {
id: item.product_id,
name: item.product_name,
code: item.product_code
}
selIdList.push(obj)
})
this.selmaterialList = selIdList
this.loading = true
// 获取物料类别列表
this.requestApi("/roke/workstation/search_read", {
model: 'roke.product.category',
domain: [["is_finished", "=", true]],
fields: ['id', 'name'],
offset: 0,
limit: 999999
}, '获取物料类别列表失败!').then(data => {
this.materialCategoryList = data.result.data
}).catch(error => {
this.errorHandle(error, true)
})
await this.getMaterialListApi().then(data => {
this.loading = false
}).catch(error => {
this.errorHandle(error, true)
})
},
// 选择物料弹窗选择框change事件
selMaterialCategoryChange(el) {
this.loading = true
this.materialPageCount = 1
this.getMaterialListApi().then(data => {
this.loading = false
}).catch(error => {
this.errorHandle(error, true)
})
},
// 物料选中事件
materialsChangeHandle(el, data) {
if (el) {
// 选中
// if (!this.materialCheckList.includes(data.id)) {
// // 选中且该物料不在产品bom中
// this.$confirm('选中的物料不在产品BOM中,是否添加?', '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
// this.selmaterialList.push(JSON.parse(JSON.stringify(data)))
// }).catch(() => {
// // 点击取消把本次选择的数据取消选中
// data.show = false
// })
// } else {
// 选中且该物料在产品bom中
this.selmaterialList.push(JSON.parse(JSON.stringify(data)))
// }
} else {
// 取消选中 把选中列表中的这条数据删除掉
let index = this.selmaterialList.findIndex(item => item.id == data.id)
if (index || index == 0) {
this.selmaterialList.splice(index, 1)
}
}
},
// 标签关闭事件
tagClosehandle(data) {
let index = this.selmaterialList.findIndex(item => item.id == data.id)
if (index || index == 0) {
this.selmaterialList.splice(index, 1)
}
this.materialList.forEach(item => {
if (item.id == data.id) {
item.show = false
}
})
},
// 选择物料弹窗页码改变事件
materialsCurrentChange(prev, pager, next, jumper) {
this.loading = true
this.getMaterialListApi().then(data => {
this.loading = false
}).catch(error => {
this.errorHandle(error, true)
})
},
}, },
}) })
</script> </script>
...@@ -2230,6 +2428,78 @@ ...@@ -2230,6 +2428,78 @@
.el-menu-item { .el-menu-item {
padding: 0 10px; padding: 0 10px;
} }
.selectMaterialsBoxClass {
display: flex;
flex-direction: column;
align-items: center;
height: 60vh;
.tagBoxClass {
width: 100%;
border-bottom: 1px solid #D9D9D9;
.tagClass {
margin: 0 8px 8px 0;
}
}
.selMaterialsFiltrateBox {
width: 100%;
height: 50px;
display: flex;
align-items: center;
}
.selMaterialsContentBox {
flex: auto;
height: 1px;
width: 100%;
display: flex;
align-content: flex-start;
flex-wrap: wrap;
.materialItemClass {
display: flex;
align-items: center;
height: 35px;
margin-right: 8px;
.el-checkbox {
margin-right: 4px;
display: flex;
align-items: center;
}
.nameLabelClass {
width: 6rem;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
display: inline-block;
}
.iconLabelClass {
display: inline-block;
width: 14px;
height: 14px;
}
}
}
}
.selMaterialsBottonBox {
display: flex;
align-items: center;
justify-content: space-between;
.selMaterialsPaginationBox {
height: 40px;
display: flex;
align-items: flex-end;
justify-content: center;
}
}
</style> </style>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment