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
<template>
<div class="ExtDxProductWorkUnitSelect">
<el-select
:value="selVal"
:loading="loading"
filterable
remote
:remote-method="remoteMethod"
:disabled="disabled"
loading-text="数据正在加载中..."
:placeholder="!options.length?'至少输入三位进行查询':'暂无数据'"
@change="change"
>
<el-option
v-for="item in options"
:key="item.key"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</template>
<script>
export default {
name: 'ExtDxProductWorkUnitSelect',
componentName: '远程搜索库位',
props: {
value: {
type: [String, Number],
default: ''
},
basicData: {
type: Object,
default: () => ({})
},
form: {
type: Object,
default: () => {}
},
scope: {
type: Object,
default: () => {}
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
loading: false,
options: [],
remoteFlag: true,
storageZoneId: '',
selVal: ''
}
},
computed: {},
watch: {
value: {
immediate: true,
handler(val) {
if (val) {
this.selVal = val
}
}
},
'scope.row': {
immediate: true,
deep: true,
handler: function(val) {
val && (this.storageZoneId = val.storageZoneId)
const inventoryJobResponses = val.inventoryJobResponses
let targetObject = null
if (inventoryJobResponses && inventoryJobResponses.length) {
targetObject = inventoryJobResponses.find(item => item.subTypeName === 'JobResponseInEntry')
}
if (targetObject && targetObject.extWorkUnit && !this.value) {
this.selVal = targetObject.extWorkUnit.extcode
}
}
}
},
methods: {
remoteMethod(query, id) {
if (!this.storageZoneId) return this.$utils.showMessageWarning('缺少库房信息!')
if ((!query || query.length < 3) && !id) return
if (this.remoteFlag) {
this.remoteFlag = false
const params = {
'pageFrom': 1,
'pageSize': 10,
'searchItems': {
'items': [
{
'fieldName': 'extCenterId', 'operator': 'EQ', 'value': this.storageZoneId
},
{
'fieldName': 'extcode', 'operator': 'LIKE', 'value': query
}
]
},
'openProps': []
}
this.loading = true
this.options = []
this.$api.searchApi('ExtDxProductWorkUnit', params).then(res => {
if (res.items && res.items.content.length) {
this.options = res.items.content.map((item) => {
return {
label: item.extcode,
value: `${item.id}+${item.extcode}`
}
})
} else {
this.locationList = []
}
})
.catch((err) => console.log(err))
.finally(() => {
this.loading = false
this.remoteFlag = true
})
} else {
this.$utils.showMessageWarning('上一步请求正在查询中,请稍后')
}
},
change(val) {
// this.$emit('input', val)
this.save(val)
},
save(val) {
if (!val) this.$utils.showMessageWarning('请选择库位')
const idValue = val.split('+')[0]
const codeValue = val.split('+')[1]
// this.selVal = codeValue
this.$emit('input', codeValue)
this.saveExtWorkUnit(idValue)
},
saveExtWorkUnit(resValue) {
let targetObject = null
const inventoryJobResponses = this.scope.row.inventoryJobResponses
if (inventoryJobResponses && inventoryJobResponses.length) {
targetObject = inventoryJobResponses.find(item => item.subTypeName === 'JobResponseInEntry')
}
if (!targetObject || !targetObject.id) return this.$utils.showMessageWarning('该条数据下无响应数据')
if (!resValue) return this.$utils.showMessageWarning('请选择库位')
const params = {
id: targetObject.id,
operator: 'MODIFY',
extWorkUnitId: resValue,
extWorkUnitIdType: 'ExtDxProductWorkUnit'
}
this.$api.recursion('JobResponseInStorage', params).then(res => {
this.$utils.showMessageSuccess('保存成功')
this.$bus.$emit('refreshUseItemConfirm')
})
}
}
}
</script>
<style lang="scss">
</style>