liuying
2024-04-25 acc8fe777aa6348abed17cb30767a66deda74253
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
<template>
  <div class="zz-inverting-storages-search-compontent">
    <a-row :gutter="6">
      <a-col :md="12" :sm="24">
        <a-select v-model="form.Areaid" style="width:100%;" placeholder="请选择库区" @change="onAreaChange">
          <a-select-option v-for="(item,index) in areas" :key="'area-sel-'+index" :value="item.id">{{item.areaName}}</a-select-option>
        </a-select>
      </a-col>
      <a-col :md="12" :sm="24">
        <a-select v-model="form.Rowno" style="width:100%;" placeholder="请选择排" allowClear @change="onRowChange">
          <a-select-option v-for="(item,index) in rows" :key="'row-sel-'+index" :value="item">{{item}}</a-select-option>
        </a-select>
      </a-col>
    </a-row>
  </div>
</template>
 
<script>
import { GetArea, GetPalceRowno } from '@/api/modular/main/LocationViewManage'
export default {
  name:'zzInvertingStorageSearchCompontent',
  emits:['change'],
  props:{
    areas:{
      type:Array,
      default:function(){
        return []
      }
    },
    rows:{
      type:Array,
      default:function(){
        return []
      }
    }
  },
  data(){
    return {
      form:{
        Areaid :undefined,
        Rowno:undefined
      },
      selectList:{
        areas:[],
        rows:[]
      }
    }
  },
  methods:{
    setAreaValue(val){
      this.form.Areaid = val
    },
    setRowValue(val){
      this.form.Rowno = val
    },
    onAreaChange(val){
      this.$emit('change','area',val)
    },
    onRowChange(val){
      this.$emit('change','row',val)
    },
    getValues(){
      return {...this.form}
    }
    /* 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){
      let params = {Areaid:this.form.Areaid}
      GetPalceRowno(params).then((d)=>{
        this.selectList.rows = d.data || [];
        if (this.selectList.rows.length>0) {
          if (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.$loading.show()
      this.getSelectListRows(()=>{
         this.$loading.hide()
      })
    },
    onSearch(){
      if (!this.form.Areaid) {
        this.$error({
          title: '系统提示',
          content: '请选择库区!',
        });
        return false;
      }
      this.$emit('search',{...this.form})
    } */
  }
}
</script>
 
<style lang="less" scoped>
 
</style>