Commit 9369d724 by 夏超

[fix] 修改前端工艺设计

parent a8553116
......@@ -292,17 +292,7 @@
<el-table ref="tabelRef" :data="isEdit?keyMaterialsCopyList:keyMaterialsList"
: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 label="物料名称" align="center">
<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 align="center" prop="product_name" label="物料名称"></el-table-column>
<el-table-column label="数量" align="center">
<template slot-scope="scope">
<el-input-number v-if="isEdit" size="medium" v-model="scope.row.qty"
......@@ -310,15 +300,11 @@
<span v-else>[[scope.row.qty]]</span>
</template>
</el-table-column>
<el-table-column label="必投" align="center">
<el-table-column align="center" label="防错码">
<template slot-scope="scope">
<div v-if="isEdit">
<el-radio-group v-model="scope.row.must">
<el-radio :label="true"></el-radio>
<el-radio :label="false"></el-radio>
</el-radio-group>
</div>
<span v-else>[[ scope.row.must?'是':'否']]</span>
<el-input v-if="isEdit" size="medium" v-model="scope.row.protection_code">
</el-input>
<span v-else>[[scope.row.protection_code]]</span>
</template>
</el-table-column>
<el-table-column v-if="!isEdit && prohibitedStateShow" label="操作" align="center" width="80">
......@@ -329,17 +315,19 @@
</template>
</el-table-column>
</el-table>
<div class="buttonRowBoxClass" v-if="prohibitedStateShow">
<el-button type="primary" size="small" :disabled="!selProductProcessData||isEdit"
@click="addInfoHandle('关键物料')">
<div style="padding: 10px;">
<el-button type="primary" size="small" :disabled="!selProductProcessData"
@click="keyMaterialBtnClick('添加')">
添加
</el-button>
<el-button type="primary" size="small" @click="editInfoHandle('关键物料')"
:disabled="!selProductProcessData">
[[isEdit?'取消编辑':'编辑']]
<el-button type="primary" size="small" :disabled="!selProductProcessData"
@click="keyMaterialBtnClick('编辑')">
[[isEdit?'取消保存':'编辑']]
</el-button>
<el-button type="primary" size="small" :disabled="!isEdit"
@click="keyMaterialBtnClick('保存')">
保存
</el-button>
<el-button type="primary" :disabled="!isEdit" size="small"
@click="saveInfoHandle('关键物料')">保存</el-button>
</div>
</div>
<!-- 产线以及工位 -->
......@@ -481,34 +469,54 @@
</el-dialog>
<!-- 添加关键物料 -->
<el-dialog title="添加关键物料" :visible.sync="keyMaterialsDialogShow" destroy-on-close width="50%"
@close="dialogCloseHandle('添加关键物料')">
<div style="max-height: 60vh; overflow-y: scroll; overflow-x: hidden;">
<el-form class="fromBox" :model="materialsForm" :rules="materialsRules" ref="materialsFormRef"
label-width="6rem">
<el-form-item label="物料:" prop="product_id">
<el-select v-model="materialsForm.product_id" placeholder="请选择物料" style="width: 100%;"
@change="selectTyleChange" filterable>
<el-option v-for="(item,index) in productList" :key="index" :label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="数量:" prop="qty">
<el-input-number v-model="materialsForm.qty" placeholder="请填写标准下限" :min="0"></el-input-number>
</el-form-item>
<el-form-item label="是否必投:" prop="must">
<div>
<el-radio-group v-model="materialsForm.must">
<el-radio label="是"></el-radio>
<el-radio label="否"></el-radio>
</el-radio-group>
</div>
</el-form-item>
</el-form>
@close="dialogCloseHandle('添加关键物料')" @open="selMaterialDialogOpen">
<div class="selectMaterialsBoxClass">
<div class="tagBoxClass">
<label>已选择物料:</label>
<el-tag class="tagClass" v-for="item in selmaterialList" :key="item.id" closable
@close="tagClosehandle(item)">
[[item.name]]
</el-tag>
</div>
<div class="selMaterialsFiltrateBox">
<el-input style="width: 30%;" size="medium" v-model="selMaterialValue" placeholder="请输入物料名称"
@change="selMaterialCategoryChange"></el-input>
<el-select style="width: 30%; margin-left: 20px;" size="medium" clearable
v-model="selMaterialCategoryId" placeholder="请选择类别" @change="selMaterialCategoryChange">
<el-option v-for="item in materialCategoryList" :key="item.id" :label="item.name"
:value="item.id">
</el-option>
</el-select>
</div>
<div class="selMaterialsContentBox">
<div v-for="(item,index) in materialList" :key="index" class="materialItemClass">
<el-checkbox v-model="item.show" @change="materialsChangeHandle($event,item)">
<el-tooltip effect="dark" :disabled="item.name.length<7" :content="item.name"
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>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogCloseHandle('添加关键物料')">取消</el-button>
<el-button size="small" type="primary" @click="dialogSaveHandle('添加关键物料')">确定</el-button>
<!-- 789 -->
<span slot="footer" class="selMaterialsBottonBox">
<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>
</el-dialog>
<!-- 维护工位弹窗 -->
......@@ -622,18 +630,14 @@
keyMaterialsList: [], //关键物料列表
keyMaterialsCopyList: [], //关键物料列表备份
keyMaterialsDialogShow: false, // 关键物料添加弹窗状态
// 新建关键物料表单数据
materialsForm: {
product_id: null, // 物料id
qty: null, // 数量
must: null // 是否必投
},
// 添加关键物料 必填效验
materialsRules: {
product_id: [{ required: true, trigger: 'blur', message: '请选择物料' }],
qty: [{ required: true, trigger: 'blur', message: '请输入数量' }],
must: [{ required: true, trigger: 'blur', message: '请选择是否必投' }],
},
materialList: [], // 物料列表
selmaterialList: [], // 选中的物料列表
selMaterialValue: '', // 选择物料弹窗输入框的值
selMaterialCategoryId: '', // 选择物料弹窗下拉框的值
materialCategoryList: [], // 物料类别列表
materialPageCount: 1, // 物料列表页码
materialPageSize: 30, // 物料列表每页数量
materialTotal: 0, // 物料列表总条数
productionLineStationList: [], // 产线工位列表
maintainStationDialogShow: false, // 维护工位弹窗状态
productionLineList: [], // 产线列表
......@@ -1051,6 +1055,7 @@
item['show'] = false
})
this.keyMaterialsList = result.result.data
this.keyMaterialsCopyList = result.result.data
}).catch(error => {
this.errorHandle(error)
})
......@@ -1174,11 +1179,10 @@
this.selBadnessTypeData = []
} else if (type == '添加关键物料') {
this.keyMaterialsDialogShow = false
this.materialsForm = {
product_id: null,
qty: null,
must: null
}
this.selMaterialValue = ''
this.selMaterialCategoryId = ''
this.materialList = []
this.selmaterialList = []
} else if (type == '绑定工位') {
this.maintainStationDialogShow = false
}
......@@ -1390,39 +1394,41 @@
this.errorHandle(error, true)
})
} else if (type == '添加关键物料') {
this.$refs.materialsFormRef.validate((valid) => {
if (valid) {
let config = {
routing_line_id: this.selProductProcessData.line_id,
product_id: this.materialsForm.product_id,
qty: this.materialsForm.qty,
must: this.materialsForm.qty == '是' ? true : false
let oldList = []
this.keyMaterialsList.forEach(item => {
if (this.selmaterialList.find(it => it.id == item.product_id)) {
let data = {
id: item.id,
product_id: item.product_id,
product_name: item.product_name,
product_code: item.product_code,
qty: item.qty,
protection_code: item.protection_code
}
this.loading = true
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
oldList.push(data)
}
})
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 @@
}
}
},
// 关键物料页签功能按钮点击事件
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) {
if (type == '工艺参数') {
......@@ -1613,6 +1664,7 @@
item['show'] = false
})
this.keyMaterialsList = result.result.data
this.keyMaterialsCopyList = JSON.parse(JSON.stringify(result.result.data))
}).catch(error => {
this.errorHandle(error, true)
})
......@@ -1879,6 +1931,152 @@
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>
......@@ -2230,6 +2428,78 @@
.el-menu-item {
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>
</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