123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <template>
- <el-select
- v-model="value"
- :placeholder="attrs.placeholder?attrs.placeholder:'请选择'"
- :disabled="attrs.disabled"
- :size="attrs.size"
- :clearable="attrs.clearable"
- @clear="onChange"
- @change="onChange"
- filterable
- >
- <el-option
- v-for="item in options"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </template>
- <script lang="ts">
- /*
- 配置说明
- config:{
- attrs:{
- disabled:true/false //是否禁用
- size:medium/small/mini //尺寸
- clearable:true/false //是否清空
- placeholder:'' //占位符
- },
- request:{}
- }
- */
- import { Component, Prop, Vue, Watch } from "vue-property-decorator";
- import VueViews from '@/benyun/compVue/VueViews'
- @Component
- export default class Warehouse extends VueViews {
- value:any='';
- options:Array<any>=[]
- @Watch('propValue')
- propValueChange(v:any){
- this.setValue(v);
- }
- created(){
- if(this.propConfig){
- this.setConfig(this.propConfig)
- }
- if(this.propValue){
- this.setValue(this.propValue)
- }
- }
- mounted(){
- (this.$root as any).eventHub.$on('warehouseChange',(data:any) => {
- this.value='';
- this.onChange();
- if(data && data.subList){
- this.setOptions(data.subList)
- }
- });
- }
- setValue(data:any){
- if(data){
- this.value = (this as any).$lodash.cloneDeep(data);
- }else{
- this.value = '';
- }
- }
- getValue(){
- return (this as any).$lodash.cloneDeep(this.value);
- }
- setOptions(data:Array<any>){
- this.options = data;
- }
- onChange(){
- this.$emit('onChange',this.value);
- }
- // 清空数据
- clearValue(){
- this.value = ''
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|