warehousePosition.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <el-select
  3. v-model="value"
  4. :placeholder="attrs.placeholder?attrs.placeholder:'请选择'"
  5. :disabled="attrs.disabled"
  6. :size="attrs.size"
  7. :clearable="attrs.clearable"
  8. @clear="onChange"
  9. @change="onChange"
  10. filterable
  11. >
  12. <el-option
  13. v-for="item in options"
  14. :key="item.id"
  15. :label="item.name"
  16. :value="item.id">
  17. </el-option>
  18. </el-select>
  19. </template>
  20. <script lang="ts">
  21. /*
  22. 配置说明
  23. config:{
  24. attrs:{
  25. disabled:true/false //是否禁用
  26. size:medium/small/mini //尺寸
  27. clearable:true/false //是否清空
  28. placeholder:'' //占位符
  29. },
  30. request:{}
  31. }
  32. */
  33. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  34. import VueViews from '@/benyun/compVue/VueViews'
  35. @Component
  36. export default class Warehouse extends VueViews {
  37. value:any='';
  38. options:Array<any>=[]
  39. @Watch('propValue')
  40. propValueChange(v:any){
  41. this.setValue(v);
  42. }
  43. created(){
  44. if(this.propConfig){
  45. this.setConfig(this.propConfig)
  46. }
  47. if(this.propValue){
  48. this.setValue(this.propValue)
  49. }
  50. }
  51. mounted(){
  52. (this.$root as any).eventHub.$on('warehouseChange',(data:any) => {
  53. this.value='';
  54. this.onChange();
  55. if(data && data.subList){
  56. this.setOptions(data.subList)
  57. }
  58. });
  59. }
  60. setValue(data:any){
  61. if(data){
  62. this.value = (this as any).$lodash.cloneDeep(data);
  63. }else{
  64. this.value = '';
  65. }
  66. }
  67. getValue(){
  68. return (this as any).$lodash.cloneDeep(this.value);
  69. }
  70. setOptions(data:Array<any>){
  71. this.options = data;
  72. }
  73. onChange(){
  74. this.$emit('onChange',this.value);
  75. }
  76. // 清空数据
  77. clearValue(){
  78. this.value = ''
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. </style>