storeList.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <a-select
  3. show-search
  4. label-in-value
  5. :value="dealerName"
  6. placeholder="请输入名称搜索"
  7. style="width: 100%"
  8. :filter-option="false"
  9. :not-found-content="fetching ? undefined : null"
  10. @search="fetchUser"
  11. @change="handleChange"
  12. >
  13. <a-spin v-if="fetching" slot="notFoundContent" size="small" />
  14. <a-select-option v-for="item in data" :key="item.sn" :value="item.sn">
  15. {{ item.name }}
  16. </a-select-option>
  17. </a-select>
  18. </template>
  19. <script>
  20. import debounce from 'lodash/debounce'
  21. import { getStoreList } from '@/api/power-superUser'
  22. export default {
  23. name: 'StoreList',
  24. props: {
  25. },
  26. data () {
  27. this.lastFetchId = 0
  28. this.fetchUser = debounce(this.fetchUser, 800)
  29. return {
  30. data: [],
  31. dealerName: [],
  32. fetching: false
  33. }
  34. },
  35. methods: {
  36. fetchUser (dealerName) {
  37. console.log('fetching user', dealerName)
  38. if (dealerName == '') return
  39. this.lastFetchId += 1
  40. const fetchId = this.lastFetchId
  41. this.data = []
  42. this.fetching = true
  43. getStoreList({ 'name': dealerName, pageNo: 1, pageSize: 20 }).then(res => {
  44. if (fetchId !== this.lastFetchId) {
  45. return
  46. }
  47. this.data = res.data.list || []
  48. this.fetching = false
  49. })
  50. },
  51. handleChange (value) {
  52. Object.assign(this, {
  53. dealerName: value,
  54. data: [],
  55. fetching: false
  56. })
  57. this.$emit('change', value)
  58. },
  59. resetForm () {
  60. this.dealerName = []
  61. },
  62. getInfo (con) {
  63. console.log('1111111111111', con)
  64. this.dealerName = [{ key: con.key, label: con.name }]
  65. },
  66. // 查询详细
  67. getDetail (sn) {
  68. // dealerFindUpdateInfoBySn({ sn: sn }).then(res => {
  69. // this.$emit('dealerDetail', res.data || null)
  70. // })
  71. }
  72. }
  73. }
  74. </script>