1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <template>
- <a-select
- show-search
- label-in-value
- :value="dealerName"
- placeholder="请输入名称搜索"
- style="width: 100%"
- :filter-option="false"
- :not-found-content="fetching ? undefined : null"
- @search="fetchUser"
- @change="handleChange"
- allowClear
- >
- <a-spin v-if="fetching" slot="notFoundContent" size="small" />
- <a-select-option v-for="item in data" :key="item.sn" :value="item.sn">
- {{ item.name }}
- </a-select-option>
- </a-select>
- </template>
- <script>
- import debounce from 'lodash/debounce'
- import { getStoreList } from '@/api/power-superUser'
- export default {
- name: 'StoreList',
- props: {
- },
- data () {
- this.lastFetchId = 0
- this.fetchUser = debounce(this.fetchUser, 800)
- return {
- data: [],
- dealerName: [],
- fetching: false
- }
- },
- methods: {
- fetchUser (dealerName) {
- console.log('fetching user', dealerName)
- if (dealerName == '') return
- this.lastFetchId += 1
- const fetchId = this.lastFetchId
- this.data = []
- this.fetching = true
- getStoreList({ 'name': dealerName, pageNo: 1, pageSize: 20 }).then(res => {
- if (fetchId !== this.lastFetchId) {
- return
- }
- this.data = res.data.list || []
- this.fetching = false
- })
- },
- handleChange (value) {
- Object.assign(this, {
- dealerName: value,
- data: [],
- fetching: false
- })
- this.$emit('change', value)
- },
- resetForm () {
- this.dealerName = []
- },
- getInfo (con) {
- this.dealerName = [{ key: con.key, label: con.name }]
- },
-
- getDetail (sn) {
-
-
-
- }
- }
- }
- </script>
|