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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/**
* @Description: 入库登账-标准物料单位
* @author wx
* @date 2022/12/13
*/
<template>
<div class="warehousingAccounting-com">
<dee-up-table
table-height="auto"
:index-row="indexRow"
:columns="tableColums"
:data="tableData"
selection-row
@selection-change="selectionChange"
>
<div slot="header" class="table-title-wrap">
<dee-tools :tools="tools" mode="normal" />
<div>
<div>
<span>申请:{{ row.inComeQuantity }}{{ row.dxStResUnitName }}</span>
<span class="countLabel">已存:<span>{{ totalNums ? totalNums : row.recordQuantity }}</span></span>
</div>
</div>
</div>
</dee-up-table>
<span style="display:flex;justify-content: center;">
<el-button
type="primary"
class="searchBtn"
@click="handleSubmit"
>确定</el-button>
<el-button
class="searchBtn"
@click="handleClose"
>取消</el-button>
</span>
</div>
</template>
<script>
import view from './view.js'
export default {
componentName: '入库登账-标准物料单位',
name: 'WarehousingAccounting',
// import引入的组件需要注入到对象中才能使用
components: { },
mixins: [view],
props: {
row: {
type: Object,
default: null
}
},
data() {
// 这里存放数据
return {
dialogVisible: false,
tools: [{
name: '新增',
icon: '/icons/c-add.png',
handler: {
click: () => {
this.handleAdd()
}
}
}],
indexRow: {
title: '序号',
align: 'center',
width: '70'
},
tableData: [],
dxStAreaOptions: [],
totalNums: 0,
selectionRow: []
}
},
// 监听属性 类似于data概念
computed: {
},
// 监控data中的数据变化
watch: {
},
// 生命周期 - 创建完成(可以访问当前this实例)
created() {
},
// 生命周期 - 挂载完成(可以访问DOM元素)
mounted() {
},
activated() {
},
// 方法集合
methods: {
selectionChange(val) {
this.selectionRow = val
},
handleAdd() {
console.log('this.row', this.row)
const obj = {
show: true,
afdId: this.row.afdId,
appDetailId: this.row.afdId,
dxResInstId: this.row.dxResInstId,
batchNumber: this.row.batchNumber,
// 原始单位code
dxStResUnitCode: this.row.dxStResUnitCode,
dxStResUnitName: this.row.dxStResUnitName,
dxStHouseId: this.row.dxStHouseId,
dxStHouseName: this.row.dxStHouseName,
dxStAreaId: '',
dxStAreaName: '',
dxStLocationId: '',
dxStLocationName: '',
// dxStQuantity: '',
dxRealQuantity: '',
dxStLocationOptions: []
}
this.tableData.unshift(obj)
// 查库区
if (this.row.dxStAreaOptions.length) {
this.dxStAreaOptions = this.row.dxStAreaOptions
} else {
this.getDxStAreaOptions(this.row.dxStInComeAF.dxStHouse.id)
}
},
findEditIndex(index, row) {
const findIndex = this.tableData.findIndex(r => r.id && r.id === row.id)
const deleteArr = this.tableData.filter(r => r.operator === 'REMOVE')
return findIndex > -1 ? findIndex : index + deleteArr.length
},
handleSubmit() {
if (!this.selectionRow.length) {
this.$utils.showMessageWarning('请先选择需要添加的数据!')
return
}
if (this.selectionRow.length && this.selectionRow.some(a =>
a.dxStHouseId === '' || a.dxStAreaId === '' || a.count === '' || a.dxRealQuantity === '' ||
(a.dxStLocationOptions.length && a.dxStLocationId === '')
)) {
this.$utils.showMessageWarning('请完善页面必填信息!')
return
}
// 相同库位的生产单位累加要小于等于同库位的课内可存数量的生产单位
// const dxStLocationName = this.checkDxStQuantity()
// if (dxStLocationName) {
// this.$utils.showMessageWarning(dxStLocationName + '库位超过可入库数量!')
// return
// }
if (this.totalNums > this.row.inComeQuantity) {
this.$utils.showMessageError('超出待入库数量!')
return
}
this.$emit('handleAdd', this.selectionRow)
this.handleClose()
},
// 校验相同库位的申请入库数量的生产单位累加要小于等于同库位的库内可存数量的生产单位
checkDxStQuantity() {
const arr = []
this.selectionRow.forEach(x => {
if (x.dxStLocationId) {
const findDxStLocationIdIndex = arr.findIndex(el => el.dxStLocationId === x.dxStLocationId)
if (findDxStLocationIdIndex > -1) {
arr[findDxStLocationIdIndex]['totalInCount'] = Number(arr[findDxStLocationIdIndex]['totalInCount']) + Number(x.dxRealQuantity)
} else {
arr.push({
dxStLocationName: x.dxStLocationName,
dxStLocationId: x.dxStLocationId,
dxStQuantity: x.dxStQuantity,
totalInCount: x.dxRealQuantity
})
}
}
})
let dxStLocationName = ''
arr.forEach(y => {
if (y.totalInCount > y.dxStQuantity) {
dxStLocationName = y.dxStLocationName
}
})
return dxStLocationName
},
handleClose() {
this.$emit('handleClose')
}
}
}
</script>
<style lang='scss'>
.warehousingAccounting-com{
height: calc(100% - 46px);
.table-title-wrap{
width: 100%;
display: flex;
justify-content: space-between;
}
.countLabel{
margin-left: 10px;
}
.btn-wrap{
display: flex;
justify-content: center;
margin-top:20px;
}
.tableCellFormCheck-com{
.el-form-item--small.el-form-item{
margin-bottom:0;
}
}
}
</style>