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
<template>
<div class="batchDxStLocation-com">
<dee-form
ref="AddForm"
:form="form"
:form-data="AddData"
form-btn-position="center"
:rules="rules"
:inline="true"
>
<span style="display:flex">
<el-button
type="primary"
class="searchBtn"
@click="addDxStLocation"
>确定</el-button>
<el-button
class="searchBtn"
@click="handleClose"
>取消</el-button>
</span>
</dee-form>
</div>
</template>
<script>
export default {
name: 'BatchDxStLocation',
components: {},
props: {
basicData: {
type: Object,
default: null
}
},
data() {
return {
dxStAreaOptions: [],
dxStLocationOptions: [],
form: {},
rules: {
dxStArea: [
{ required: true, message: '请选择库区', trigger: 'change' }
],
dxStLocation: [
{ required: true, message: '请选择库位', trigger: 'change' }
]
}
}
},
computed: {
AddData() {
return [
{
split: 1,
data: [{
key: 'dxStArea',
title: '库区',
component: {
name: 'el-select',
valueKey: 'id',
options: this.dxStAreaOptions
},
handler: {
change: (val) => {
this.getDxStLocationOptions(val)
}
}
},
{
key: 'dxStLocation',
title: '库位',
component: {
name: 'el-select',
valueKey: 'id',
options: this.dxStLocationOptions
}
}]
}
]
}
},
watch: {
basicData: {
deep: true,
immediate: true,
handler: function(val) {
if (val && val.dxStHouseId) {
this.getDxStAreaOptions()
}
}
}
},
created() {
},
mounted() {
},
methods: {
getDxStAreaOptions() {
const params = {
'searchItems': {
'items': [
{
'fieldName': 'parentId',
'operator': 'EQ',
'value': this.basicData.dxStHouseId
}
],
'operator': 'AND'
},
'sortItem': [
{
'fieldName': 'name',
'sortOrder': 'ASC'
}
]
}
this.$api.searchApi('DxStOrgArea', params).then(res => {
this.dxStAreaOptions = res.items.content.map(r => {
return {
label: r.name,
value: r
}
})
})
},
// 查询库位
getDxStLocationOptions(val) {
this.dxStLocationOptions = []
this.$set(this.form, 'dxStLocation', null)
const params = {
'searchItems': {
'children': [
{
'items': [
{
'fieldName': 'parentId',
'operator': 'EQ',
'value': val.id
}
],
'operator': 'AND'
}
],
'operator': 'AND'
}
}
this.$api.searchApi('DxStOrgLocation', params).then(res => {
this.dxStLocationOptions = res.items.content.map(r => {
return {
label: r.serialNumber,
value: r
}
})
})
},
// 批量添加库位
addDxStLocation() {
this.$refs.AddForm.$refs.form.validate((valid) => {
if (valid) {
this.$emit('addDxStLocation', this.form)
this.handleClose()
}
})
},
handleClose() {
this.$emit('handleClose')
}
}
}
</script>
<style lang="scss">
</style>