1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import { findAreaListWithHouseId, getDxStInventoryAccount } from '@/api/storage'
import storageSelect from '@/components/storageSelect.vue'
export default {
props: {},
components: { storageSelect },
data() {
// const that = this
return {
optionsData: []
}
},
computed: {
tableColums() {
const that = this
return [
{
title: '库房', key: 'dxStHouseName', align: 'center'
},
{
title: '库区', key: 'dxStAreaId', align: 'center',
component: {
render: function(h, data, column, index) {
return (<el-select v-model={data.dxStAreaId} size='small'
on-change={(val) => {
data.dxStAreaId = val
that.$set(that.tableData[index], 'dxStAreaId', val)
const findItem = that.dxStAreaOptions.find(r => r.value === val)
that.$set(that.tableData[index], 'dxStAreaName', findItem.label)
that.getDxStLocationOptions(val, index)
}}>
{
that.dxStAreaOptions.map(x => <el-option label={x.label} value={x.value}/>)
}
</el-select>)
}
}
},
{
title: '库位', key: 'dxStLocationId', align: 'center',
component: {
render: function(h, data, column, index) {
return (<el-select v-model={data.dxStLocationId} size='small'
on-change={(val) => {
data.dxStLocationId = val
that.$set(that.tableData[index], 'dxStLocationId', val)
const findItem = that.tableData[index].dxStLocationOptions.find(r => r.value === val)
that.$set(that.tableData[index], 'dxStLocationName', findItem.label)
// 查询库内
// that.getDxStInventoryAccount('DxStLocation', val, index, that.tableData[index].dxStLocationOptions)
}}>
{
that.tableData[index].dxStLocationOptions.map(x => <el-option label={x.label} value={x.value}/>)
}
</el-select>)
}
}
},
// {
// title: '库内可存数量', key: 'dxStQuantity', align: 'center'
// },
{
title: '实际入库数量', key: 'dxRealQuantity', align: 'center', component: {
name: 'tableCellFormCheck',
show: true,
props: {
bindKey: 'dxRealQuantity',
component: {
name: 'el-input'
}
},
handler: {
changeForm: (val) => {
this.rowDataChange(val)
}
}
}
}
]
}
},
watch: {
},
created() {
},
methods: {
handleDelete(index, row) {
this.$utils.showConfirm(
`你是否确定删除选中的数据`,
'提示',
'warning',
'确定',
'取消',
() => {
this.tableData.splice(index, 1)
this.countNums()
}
)
},
countNums() {
this.totalNums = this.row.recordQuantity
this.tableData.forEach(r => {
this.totalNums = this.totalNums + Number(r.dxRealQuantity ? r.dxRealQuantity : 0)
})
},
// row数据修改
rowDataChange(val) {
this.tableData[val.index][val.key] = val.val
if (val.key === 'dxRealQuantity') {
this.countNums()
}
},
// 查询库区
getDxStAreaOptions(val) {
findAreaListWithHouseId(val, this.row.resourceClasscify.id).then(res => {
this.dxStAreaOptions = res.items.map(r => {
return {
label: r.name,
value: r.id,
data: r
}
})
})
},
// 查询库位
getDxStLocationOptions(val, index) {
const params = {
'searchItems': {
'children': [
{
'items': [
{
'fieldName': 'parentId',
'operator': 'EQ',
'value': val
}
],
'operator': 'AND'
}
],
'operator': 'AND'
}
}
this.$api.searchApi('DxStOrgLocation', params).then(res => {
const arr = res.items.content.map(r => {
return {
label: r.serialNumber,
value: r.id,
data: r
}
})
this.$set(this.tableData[index], 'dxStLocationOptions', arr)
// 查询库内
// !arr.length && this.getDxStInventoryAccount('DxStArea', val, index, this.dxStAreaOptions)
})
},
// 查询库内信息
getDxStInventoryAccount(type, locationId, index, options) {
getDxStInventoryAccount(type, locationId).then(res => {
const findItem = options.find(r => r.value === locationId)
const maxLimit = findItem ? findItem.data.dynamicAttrs.maxLimit : 0
this.tableData[index].dxStQuantity = maxLimit - res.items
if (res.items) {
// 生产单位的数量*(目标单位/原始单位)
this.tableData[index].inCount = this.tableData[index].dxStQuantity * (this.unitInfo.targetUnitAmount / this.unitInfo.resourceUnitAmount)
}
})
}
}
}