shelfList.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { shelfList } from '@/api/shelf'
  2. const shelfSList = {
  3. template: `
  4. <a-select
  5. placeholder="请选择货架"
  6. :maxTagCount="3"
  7. :maxTagTextLength="mode=='default'?20:8"
  8. :mode="mode"
  9. :id="id"
  10. allowClear
  11. :value="defaultVal"
  12. :showSearch="true"
  13. @change="handleChange"
  14. option-filter-prop="children"
  15. :dropdownMatchSelectWidth="false"
  16. :filter-option="filterOption">
  17. <a-select-option v-for="item in shelfList" :key="item.shelfSn" :value="item.shelfSn">{{ item.shelfName }}</a-select-option>
  18. </a-select>
  19. `,
  20. props: {
  21. value: {
  22. type: [String,Array],
  23. defatut: ''
  24. },
  25. id: {
  26. type: String,
  27. default: ''
  28. },
  29. mode: {
  30. type: String,
  31. defatut: 'default'
  32. }
  33. },
  34. data () {
  35. return {
  36. defaultVal: this.value,
  37. shelfList: []
  38. }
  39. },
  40. mounted () {
  41. this.getShelf()
  42. },
  43. watch: {
  44. value (newValue, oldValue) {
  45. this.defaultVal = newValue
  46. }
  47. },
  48. methods: {
  49. filterOption (input, option) {
  50. console.log(input, option)
  51. return (
  52. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  53. )
  54. },
  55. handleChange (value) {
  56. console.log(value)
  57. const row = this.shelfList.find(item => item.shelfSn == value)
  58. this.defaultVal = value
  59. this.$emit('change', value, row)
  60. this.$emit('input', value, row)
  61. },
  62. // 货架列表
  63. getShelf () {
  64. shelfList({ pageNo: 1, pageSize: 1000 }).then(res => {
  65. if (res.status == 200) {
  66. this.shelfList = res.data && res.data.list ? res.data.list : []
  67. } else {
  68. this.shelfList = []
  69. }
  70. })
  71. }
  72. }
  73. }
  74. export default shelfSList