Commit 9e2fbebf authored by zhangyichen's avatar zhangyichen

修改生产模型

parent f4ce47dd
......@@ -46,6 +46,7 @@
<el-table
v-loading="loading"
border
:key="tableNum"
style="padding-right: 10px;padding-left: 10px"
:data="positionList"
>
......@@ -90,7 +91,7 @@
size="mini"
type="primary"
style="margin-left: 10px"
@click="handleUpdateWork(scope.row)"
@click="editPosition(scope.row)"
>修改工站</el-link>
<el-link
size="mini"
......@@ -99,10 +100,11 @@
@click="handleConfigure(scope.row, scope)"
>配置物料</el-link>
<el-link
v-if="scope.$index !== 0 || positionList.length === 1"
size="mini"
type="danger"
style="margin-left: 10px"
@click="handleDelete(scope.row)"
@click="handleDeleteWord(scope.row)"
>删除</el-link>
</template>
</el-table-column>
......@@ -110,7 +112,7 @@
</el-col>
</el-row>
<!-- 添加工站-->
<el-dialog :close-on-click-modal="false" class="modelDialog" :title="title" :visible.sync="openPosition" width="70%" append-to-body>
<el-dialog :close-on-click-modal="false" class="modelDialog" :title="title" :visible.sync="openPosition" width="70%" :append-to-body="false">
<el-form ref="form" :model="queryParams" label-width="auto" :inline="true">
<el-form-item label="工站名称" prop="staName">
<div slot="label">
......@@ -138,6 +140,7 @@
border
ref="table"
style="padding-right: 10px;padding-left: 10px;margin-top: 10px"
:header-row-class-name="cellClassWork"
:data="addPositionList"
@selection-change="handleSelectionChange"
@select="handleSelection"
......@@ -187,8 +190,8 @@
<el-button class="redBtn" type="danger" @click="submitAddPosition">确 定 Confirm</el-button>
</div>
</el-dialog>
<!-- 选择成品料号-->
<el-dialog :close-on-click-modal="false" class="modelDialog" :title="'选择物料料号'" :visible.sync="openPartNo" width="70%" append-to-body>
<!-- 选择成品料号 物料料号-->
<el-dialog :close-on-click-modal="false" class="modelDialog" :title="title" :visible.sync="openPartNo" width="70%" :append-to-body="false">
<el-form ref="form" :model="queryParams" label-width="auto" :inline="true">
<el-form-item label="成品料号" prop="materCode">
<div slot="label">
......@@ -215,6 +218,7 @@
v-loading="loadingCode"
border
ref="materTable"
:header-row-class-name="cellClassMater"
style="padding-right: 10px;padding-left: 10px;margin-top: 10px"
:data="selectPartNum"
@selection-change="handleSelectionChangeMaterial"
......@@ -286,6 +290,7 @@
style="padding-right: 10px;padding-left: 10px;margin-top: 10px"
:data="configuringList"
@selection-change="handleSelectionMater"
@select="handleMater"
>
<el-table-column v-if="materType === '2'" type="selection" width="50" :selectable="materSelected"/>
<el-table-column type="index" label="序号" width="50" />
......@@ -331,7 +336,7 @@
size="mini"
type="danger"
style="margin-left: 10px"
@click="handleDelete(scope.row)"
@click="handleDeleteMater(scope.row)"
>删除</el-link>
</template>
</el-table-column>
......@@ -368,10 +373,14 @@ export default {
disposeMaterialId: '',
// 添加工站表格数据
addPositionList: [],
// 替代选中工站表格数据
// 替代选中工站表格数据 分页多选
addPositionListOne: [],
// 多选临时数据
addPositionMapOne: {},
// 物料多选数据
addMaterialList: [],
// 多选临时数据 物料
addMaterialMap: [],
// 选择成品表格料号数据
selectPartNum: [],
// 配置物料表格数据
......@@ -421,13 +430,37 @@ export default {
// 1为第一条表格数据 2为其他数据
materType: '',
// 配置物料临时保存数据
addMaterList: []
addMaterList: [],
// 其他工站已选择物料id集合
selectListId: [],
// 已选工站id
selectWordId: [],
// 记录当选选择工站已选物料
trueId: [],
// 1新增工站, 2修改工站
workType: ''
}
},
watch: {
positionList(val) {
if (val.length > 0) {
// 第一工站选择物料集合
this.firstTableData = val[0].nltModelStationMaters
// 其他工站已选择物料id集合
this.selectListId = []
val.forEach((item, index) => {
if (index !== 0) {
item.nltModelStationMaters.forEach(item1 => {
this.selectListId.push(item1.businessId)
})
}
})
console.log(this.selectListId, 'this.selectListId')
// 已选工站已id集合
this.selectWordId = []
val.forEach(item => {
this.selectWordId.push(item.businessId)
})
}
}
},
......@@ -440,6 +473,22 @@ export default {
aaa() {
console.log(this.configuringList, 'configuringList')
},
// 工单表样式
cellClassMater(row) {
if (this.type === '3') {
return 'disabledSelection'
} else {
return ''
}
},
// 工站表样式
cellClassWork(row) {
if (this.workType === '2') {
return 'disabledSelection'
} else {
return ''
}
},
listData() {
const params = {
dictType: 'modelType',
......@@ -481,6 +530,7 @@ export default {
this.openPartNo = true
this.title = '选择成品料号'
this.type = '3'
this.addMaterialMap = {}
this.partNum()
},
choiceOne(row) {
......@@ -493,6 +543,7 @@ export default {
}
this.openPartNo = true
this.title = '选择物料料号'
this.addMaterialMap = {}
this.partNum()
},
// 成品料号表格获取
......@@ -502,6 +553,15 @@ export default {
this.selectPartNum = res.rows
this.total = res.total
this.loadingCode = false
if (this.type === '1' || this.type === '2') {
this.selectPartNum.forEach(item => {
if (this.addMaterialMap[item.businessId]) {
this.$nextTick(() => {
this.$refs.materTable.toggleRowSelection(item)
})
}
})
}
if (this.type === '1') {
this.$nextTick(() => {
this.replaceMaterialList.forEach(item => {
......@@ -539,28 +599,84 @@ export default {
},
// 添加工站弹窗
addPosition() {
this.workType = '1'
this.openPosition = true
this.title = '添加工站'
this.addPositionMapOne = {}
this.getStaTable()
},
// 修改工站弹窗
editPosition(row) {
this.workType = '2'
this.disposeMaterialId = row.businessId
this.openPosition = true
this.title = '修改工站'
this.addPositionMapOne = {}
this.getStaTable()
},
/** 查询工站表方法 **/
getStaTable() {
this.loadingPosition = true
listStation(this.queryParams).then(response => {
let str = ''
if (this.selectWordId.length > 0) {
str = this.selectWordId.join(',')
} else {
str = ''
}
let params = {}
params = {
...this.queryParams,
businessIdList: str
}
listStation(params).then(response => {
this.addPositionList = response.rows
this.total = response.total
this.loadingPosition = false
if (this.workType === '1') {
this.addPositionList.forEach(item => {
if (this.addPositionMapOne[item.businessId]) {
this.$nextTick(() => {
this.$refs.table.toggleRowSelection(item)
})
}
})
}
})
},
// 工站选择框
handleSelectionChange(data) {
this.addPositionListOne = data
if (this.workType === '1') {
if (data.length === 0) {
this.addPositionList.forEach(item => {
delete this.addPositionMapOne[item.businessId]
})
}
// 勾选数据 添加
data.forEach(item => {
this.addPositionMapOne[item.businessId] = item
})
// 获取所有分页勾选的数据
this.addPositionListOne = []
for (const key in this.addPositionMapOne) {
this.addPositionListOne.push(this.addPositionMapOne[key])
}
}
if (this.workType === '2') {
this.addPositionListOne = data
}
},
// 禁用
handleSelection(selection, val) {
if (selection.length > 1) {
const del_row = selection.shift()
this.$refs.table.toggleRowSelection(del_row, false)//
handleSelection(selection, row) {
if (this.workType === '1') {
if (!selection.some(item => item.businessId === row.businessId)) {
delete this.addPositionMapOne[row.businessId]
}
}
if (this.workType === '2') {
if (selection.length > 1) {
const del_row = selection.shift()
this.$refs.table.toggleRowSelection(del_row, false)//
}
}
},
positionSelected(row) {
......@@ -579,11 +695,32 @@ export default {
},
// 配置物料选择框
handleSelectionChangeMaterial(data) {
this.addMaterialList = data
if (this.type !== '3') {
if (data.length === 0) {
this.selectPartNum.forEach(item => {
delete this.addMaterialMap[item.businessId]
})
}
// 勾选数据 添加
data.forEach(item => {
this.addMaterialMap[item.businessId] = item
})
// 获取所有分页勾选的数据
this.addMaterialList = []
for (const key in this.addMaterialMap) {
this.addMaterialList.push(this.addMaterialMap[key])
}
} else {
this.addMaterialList = data
}
},
// 禁用
handleSelectionMaterial(selection) {
if (this.type === '3') {
handleSelectionMaterial(selection, row) {
if (this.type !== '3') {
if (!selection.some(item => item.businessId === row.businessId)) {
delete this.addMaterialMap[row.businessId]
}
} else {
if (selection.length > 1) {
const del_row = selection.shift()
this.$refs.materTable.toggleRowSelection(del_row, false)//
......@@ -619,9 +756,31 @@ export default {
handleSelectionMater(data) {
this.addMaterList = data
},
// 物料禁用
// 禁用
handleMater(selection) {
},
// 物料禁用 筛选出其他已选择
materSelected(row) {
return true
let flag = true
// 判断如果为自己所选则不禁用
// 开始判断
if (this.selectListId.length === 0) {
return true
} else {
for (let i = 0; this.selectListId.length > i; i++) {
if (this.selectListId[i] === row.businessId) {
flag = false
continue
}
}
for (let i = 0; this.trueId.length > i; i++) {
if (this.trueId[i] === row.businessId) {
flag = true
continue
}
}
return flag
}
},
// 工站查询按钮
queryPosition() {
......@@ -633,16 +792,22 @@ export default {
this.queryParams.staName = undefined
this.getStaTable()
},
// 修改工站 不修改配置项
handleUpdateWork() {},
// 打开配置物料
handleConfigure(row, index) {
console.log(row, 'row')
this.disposeMaterialId = row.businessId
this.openConfiguring = true
if (index.$index === 0) {
this.materType = '1'
this.configuringList = row.nltModelStationMaters
} else {
this.materType = '2'
// 把第一站数据赋值
this.configuringList = this.firstTableData
// 获取当前站已选物料
this.trueId = []
row.nltModelStationMaters.forEach(item => {
this.trueId.push(item.businessId)
})
this.$nextTick(() => {
row.nltModelStationMaters.forEach(item => {
this.configuringList.forEach(item1 => {
......@@ -653,14 +818,21 @@ export default {
})
})
}
this.title = '配置物料'
this.disposeMaterialId = row.staId
this.openConfiguring = true
this.tableNum++
},
// 删除物料
handleDeleteMater(row) {
let list = []
list = this.selectListId.filter(item => item === row.businessId)
if (list.length > 0) {
this.$message.error('该物料已被其他工站选用')
} else {
this.configuringList = this.configuringList.filter(item => item.businessId !== row.businessId)
}
},
// 删除工站
handleDelete(row) {
handleDeleteWord(row) {
this.positionList = this.positionList.filter(item => item.businessId !== row.businessId)
},
// 返回模型页面
cancelPosition() {
......@@ -694,12 +866,27 @@ export default {
// 确定关闭添加工站弹窗
submitAddPosition() {
this.openPosition = false
this.addPositionListOne.forEach(item => {
item.nltModelStationMaters = []
item.staId = item.businessId
this.positionList.push(item)
})
console.log(this.positionList, 'this.positionList')
if (this.workType === '1') {
this.addPositionListOne.forEach(item => {
item.nltModelStationMaters = []
item.staId = item.businessId
this.positionList.push(item)
})
} else if (this.workType === '2') {
let list = []
list = JSON.parse(JSON.stringify(this.positionList))
this.positionList.forEach((item, index) => {
if (item.businessId === this.disposeMaterialId) {
const data = {
...item,
...this.addPositionListOne[0]
}
list[index] = data
this.positionList = list
this.tableNum++
}
})
}
},
// 关闭选择成品料号弹窗
cancelChoicePart() {
......@@ -726,6 +913,7 @@ export default {
item.nltModelStationMaterAlters = []
this.configuringList.push(item)
})
this.tableNum++
} else if (this.type === '3') {
console.log(this.addMaterialList[0], 'this.addMaterialList[0]')
this.form.modelCode = this.addMaterialList[0].materCode
......@@ -740,18 +928,22 @@ export default {
// 确定关闭配置物料窗口
submitConfiguring() {
if (this.materType === '1') {
this.positionList.forEach(item => {
if (item.staId === this.disposeMaterialId) {
const list = JSON.parse(JSON.stringify(this.positionList))
list.forEach(item => {
if (item.businessId === this.disposeMaterialId) {
item.nltModelStationMaters = this.configuringList
}
})
this.positionList = list
this.openConfiguring = false
} else {
this.positionList.forEach(item => {
if (item.staId === this.disposeMaterialId) {
const list = JSON.parse(JSON.stringify(this.positionList))
list.forEach(item => {
if (item.businessId === this.disposeMaterialId) {
item.nltModelStationMaters = this.addMaterList
}
})
this.positionList = list
this.openConfiguring = false
}
}
......@@ -761,6 +953,10 @@ export default {
<style lang="scss" scoped>
.model_details {
::v-deep .el-table .disabledSelection .cell .el-checkbox__inner {
display: none;
position: relative;
}
font-size: 18px;
.placeholder{
height:14px;
......
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