schangxiang@126.com
2024-04-23 f47411fb53aeee0c7bd514cbc841f9030349f448
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
<template>
  <div class="wms-in-bound2-search-box">
    <div class="label-view" v-if="label" :style="{width:labelWidth?labelWidth:'auto'}">{{label}}:</div>
    <div class="input-view">
      <a-input :placeholder="placeholder" v-model.trim="innerValue" />
      <div v-if="msg" class="msg-row">
        <a-alert v-if="msgType==='error'" :message="msg" type="error" show-icon />
        <a-alert v-else :message="msg" type="info" show-icon />
      </div>
    </div>
    <div class="btns-view">
      <a-button type="primary" @click="onSearch" :disabled="btnDisabled">搜 索</a-button>
      <a-button @click="onReset" :disabled="btnDisabled">重 置</a-button>
    </div>
  </div>
</template>
 
<script>
export default {
  name:'wmsInBound2SearchBox',
  emits:['input','search','reset'],
  props:{
    label:{
      type:String,
      default:''
    },
    labelWidth:{
      type:String,
      default:''
    },
    placeholder:{
      type:String,
      default:''
    },
    msgType:{
      type:String,
      default:''
    },
    msg:{
      type:String,
      default:''
    },
    value:{
      type:[String,null],
      default:''
    },
    btnDisabled:{
      type:Boolean,
      default:false
    }
  },
  data(){
    return {
      innerValue:''
    }
  },
  created(){
    this.innerValue = this.value
  },
  watch:{
    innerValue(newVal,oldVal){
      if (newVal!==this.value) {
        this.$emit('input',newVal)
      }
    },
    value(newVal,oldVal){
      if (newVal!==this.innerValue) {
        this.innerValue = newVal;
      }
    }
  },
  methods:{
    onSearch(){
      this.$emit('search',this.innerValue)
    },
    onReset(){
      this.innerValue = ''
      this.$emit('reset')
    }
  }
}
</script>
 
<style lang="less" scoped>
.wms-in-bound2-search-box{
  width:600px;
  display:flex;
  margin:0 auto;
  .label-view,.btns-view{
    flex-shrink: 0;
  }
  .label-view{
    padding-top: 3.5px;
    text-align: right;
  }
  .btns-view{
    padding-left: 16px;
    .ant-btn + .ant-btn {
      margin-left:10px;
    }
  }
  .input-view{
    flex-grow:1;
    .msg-row{
      padding-top:4px;
    }
  }
}
</style>