css
liuying
2024-04-25 e99c3b2d8f6b23a1e9663655236dd42bbdd67184
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
<template>
  <a-form layout="inline">
    <a-form-item label="库区">
      <a-select v-model="form.Areaid" class="slect-width" @change="onAreaChange">
        <a-select-option v-for="(item,index) in selectList.areas" :key="'area-sel-'+index" :value="item.id">{{item.areaName}}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="巷道">
      <a-select v-model="form.Aisleid" allowClear class="slect-width" @change="onAisleChange">
        <a-select-option v-for="(item,index) in selectList.aisles" :key="'aisle-sel-'+index" :value="item">{{item}}</a-select-option>
      </a-select>
    </a-form-item>
 
    <a-form-item label="排">
      <a-select v-model="form.Rowno" class="slect-width" allowClear>
        <a-select-option v-for="(item,index) in selectList.rows" :key="'row-sel-'+index" :value="item">{{item}}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item>
      <a-button type="primary" @click.stop="onSearch">查询</a-button>
    </a-form-item>
  </a-form>
</template>
 
<script>
import { GetArea, GetAisle,GetPalceRowno } from '@/api/modular/main/LocationViewManage'
export default {
  name:'wmsWarehouseLocationViewSearchCompontent',
  emits:['update:loading','search'],
  data(){
    return {
      loading:{
        type:Boolean,
        default:false
      },
      form:{
        Areaid :null,
        Rowno:null
      },
      selectList:{
        areas:[],
        rows:[]
      }
    }
  },
  methods:{
    init(callback){
      this.getSelectListAreas((f1)=>{
        if (f1) {
          callback && callback(true,{...this.form})
        } else {
          callback && callback(false)
        }
      })
    },
    getSelectListAreas(callback){
      GetArea().then((d)=>{
        this.selectList.areas = d.data || [];
        this.selectList.rows = []
        this.form.Aisleid = null
        this.form.Rowno = null
        if (this.selectList.areas.length>0) {
          this.form.Areaid = this.selectList.areas[0].id
          this.getSelectListAisles(()=>{
            callback && callback(true)
          })
        } else {
          this.form.Areaid = null
          this.selectList.aisles = []
          callback && callback(true)
        }
      }).catch(()=>{
        this.selectList.areas = []
        this.selectList.aisles = []
        this.selectList.rows = []
        this.form.Areaid = null
        this.form.Aisleid = null
        this.form.Rowno = null
        callback && callback(false)
      })
    },
    getSelectListAisles(callback){
      let params = {Areaid:this.form.Areaid}
      GetAisle(params).then((d)=>{
        this.selectList.aisles = d.data || [];
        this.form.Rowno = null
        if (this.selectList.aisles.length===1) {
          this.form.Aisleid = this.selectList.aisles[0]
          this.getSelectListRows(()=>{
            callback && callback(true)
          })
        } else {
          this.selectList.rows = []
          this.form.Aisleid = null
          callback && callback(true)
        }
      }).catch(()=>{
        this.selectList.aisles = []
        this.selectList.rows = []
        this.form.Aisleid = null
        this.form.Rowno = null
        callback && callback(false)
      })
    },
    getSelectListRows(callback){
      let params = {Areaid:this.form.Areaid,Aisleid:this.form.Aisleid}
      GetPalceRowno(params).then((d)=>{
        this.selectList.rows = d.data || [];
        if (this.selectList.rows.length===1) {
          this.form.Rowno = this.selectList.rows[0]
          callback && callback(true)
        } else {
          this.form.Rowno = null
          callback && callback(true)
        }
      }).catch(()=>{
        this.selectList.rows = []
        this.form.Rowno = null
        callback && callback(false)
      })
    },
    onAreaChange() {
      this.$emit('update:loading',true)
      this.getSelectListAisles(()=>{
         this.$emit('update:loading',false)
      })
    },
    onAisleChange() {
      this.$emit('update:loading',true)
      this.getSelectListRows(()=>{
         this.$emit('update:loading',false)
      })
    },
    onSearch(){
      if (!this.form.Areaid) {
        this.$error({
          title: '系统提示',
          content: '请选择库区!',
        });
        return false;
      }
      this.$emit('search',{...this.form})
    }
  }
}
</script>
 
<style lang="less" scoped>
.slect-width{
  width:180px
}
</style>