|
@@ -0,0 +1,113 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-select
|
|
|
+ v-model="value"
|
|
|
+ ref="select"
|
|
|
+ placeholder="请选择存放货架"
|
|
|
+ filterable
|
|
|
+ remote
|
|
|
+ :remote-method="remoteMethod"
|
|
|
+ @change = "onChange">
|
|
|
+ <el-option
|
|
|
+ v-for="item in options"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ <el-option v-if="options.length > 0" label="加载更多" style="font-style: italic; color: #8a979e" value="undefined" @click.native="handleClick()"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ name: 'shelve-select',
|
|
|
+ props: ['warehouseId', 'shelveId'],
|
|
|
+ model: {
|
|
|
+ prop: 'shelveId',
|
|
|
+ event: 'select'
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ value: '',
|
|
|
+ current: 1,
|
|
|
+ size: 10,
|
|
|
+ // 货架名
|
|
|
+ name: '',
|
|
|
+ options: [],
|
|
|
+ loading: false,
|
|
|
+ noMore: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ this.init(this.warehouseId, this.shelveId)
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ shelveId (newVal) {
|
|
|
+ this.init(this.warehouseId, newVal)
|
|
|
+ },
|
|
|
+ warehouseId (newVal) {
|
|
|
+ this.warehouseId = newVal
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async init (whId, shelveId) {
|
|
|
+ this.options = []
|
|
|
+ this.current = 1
|
|
|
+ this.getList(whId, shelveId)
|
|
|
+ },
|
|
|
+ remoteMethod (query) {
|
|
|
+ this.options = []
|
|
|
+ this.current = 1
|
|
|
+ this.name = query
|
|
|
+ this.getList(this.warehouseId, this.shelveId)
|
|
|
+ },
|
|
|
+ getList (whId, shelveId) {
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/listShelves`),
|
|
|
+ method: 'get',
|
|
|
+ params: this.$http.adornParams({
|
|
|
+ 'current': this.current,
|
|
|
+ 'size': this.size,
|
|
|
+ 'name': this.name,
|
|
|
+ 'warehouseId': whId
|
|
|
+ })
|
|
|
+ }).then(({data}) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ if (this.current > data.data.pages) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ data.data.records.forEach(item => {
|
|
|
+ this.options.push({
|
|
|
+ label: item.shelveNumber + '(' + item.name + ')',
|
|
|
+ value: item.shelveId
|
|
|
+ })
|
|
|
+ })
|
|
|
+ if (shelveId) {
|
|
|
+ this.value = shelveId
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.options = []
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleClick () {
|
|
|
+ this.loadMore()
|
|
|
+ },
|
|
|
+ loadMore () {
|
|
|
+ this.current ++
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ onChange (item) {
|
|
|
+ if (item === 'undefined') {
|
|
|
+ this.value = null
|
|
|
+ }
|
|
|
+ this.$emit('select', item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|