222
schangxiang@126.com
2025-09-24 68941a04cb2320daa22ba0d5ac79a4447c29998d
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
<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.Rowno" class="slect-width">
        <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, 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) {
          this.getSelectListRows((f2)=>{
            if (f2) {
              callback && callback(true,{...this.form})
            } else {
              callback && callback(false)
            }
          })
        } else {
          callback && callback(false)
        }
      })
    },
    getSelectListAreas(callback){
      GetArea().then((d)=>{
        this.selectList.areas = d.data || [];
        if (this.selectList.areas.length>0) {
          this.form.Areaid = this.selectList.areas[0].id
          callback && callback(true)
        } else {
          callback && callback(false)
        }
      }).catch(()=>{
        callback && callback(false)
      })
    },
    getSelectListRows(callback,init=true){
      let params = {Areaid:this.form.Areaid}
      GetPalceRowno(params).then((d)=>{
        this.selectList.rows = d.data || [];
        if (this.selectList.rows.length>0) {
          if (init || this.selectList.rows.length===1) {
            this.form.Rowno = this.selectList.rows[0]
          } else {
            this.form.Rowno = null
          }
          callback && callback(true)
        } else {
          this.form.Rowno = null
          callback && callback(false)
        }
      }).catch(()=>{
        this.selectList.rows = []
        this.form.Rowno = null
        callback && callback(false)
      })
    },
    onAreaChange() {
      this.$emit('update:loading',true)
      this.getSelectListRows(()=>{
         this.$emit('update:loading',false)
      },false)
    },
    onSearch(){
      if (!this.form.Areaid) {
        this.$error({
          title: '系统提示',
          content: '请选择库区!',
        });
        return false;
      }
      if (!this.form.Rowno) {
        this.$error({
          title: '系统提示',
          content: '请选择排!',
        });
        return false;
      }
      this.$emit('search',{...this.form})
    }
  }
}
</script>
 
<style lang="less" scoped>
.slect-width{
  width:180px
}
</style>