| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <template>
- <div @click="handlerClick">
- <el-autocomplete
- clearable
- id="autocompleteId"
- ref="autocomplete"
- style="width: 100%"
- v-model="selectItem"
- :fetch-suggestions="querySearchAsync"
- placeholder="请选择"
- :debounce="0"
- @select="handleSelect"
- ></el-autocomplete>
- </div>
- </template>
- <script>
- export default {
- props: {
- value: {
- type: [String, Number],
- default: ''
- },
- getData: {
- type: Function,
- default: () => {}
- },
- params: {
- type: Object,
- default: {
- type: '',
- brandId: ''
- }
- }
- },
- data() {
- return {
- selectItem: this.value
- }
- },
- watch: {
- value(newValue) {
- this.selectItem = newValue
- }
- },
- methods: {
- handlerClick() {
- this.$emit('click')
- },
- handleSelect(value) {
- this.selectItem = value.value
- this.$emit('input', value.value)
- this.$emit('change', value)
- },
- async querySearchAsync(queryString, cb) {
- let param = {
- pageNum: 1,
- pageSize: 100,
- params: [
- { param: 'a.product_brand_id', compare: '=', value: this.params.productBrandId },
- { param: 'a.main_id', compare: '=', value: this.params.mainId },
- { param: 'a.small_id', compare: '=', value: this.params.smallId },
- { param: 'a.series_id', compare: '=', value: this.params.seriesId },
- { param: 'a.name', compare: 'like', value: queryString }
- ]
- }
- let res = await this.getData(param)
- this.data = res.data.records.map(v => {
- return {
- value: `${v.name}`,
- other: {
- productId: v.productId,
- mainImg: v.mainImg,
- insideImg: v.insideImg,
- outImg: v.outImg,
- partImgs: v.partImgs,
- otherImgs: v.otherImgs,
- smallId: v.smallId,
- smallName: v.smallName,
- seriesId: v.seriesId,
- seriesName: v.seriesName
- }
- }
- })
- // let data = this.data.filter(item => ~item.value.indexOf(queryString))
- cb(this.data)
- }
- }
- }
- </script>
- <style></style>
|