Commit af649391 by zhangquan

车系搜索优化

1 parent b7e7979c
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
</template> </template>
<script> <script>
import { mapState, mapActions } from 'vuex'
export default { export default {
name: 'report-app', name: 'report-app',
props: { props: {
...@@ -20,6 +21,14 @@ export default { ...@@ -20,6 +21,14 @@ export default {
created() { created() {
this.myMsg = this.msg this.myMsg = this.msg
this.myMessage = this.message this.myMessage = this.message
},
mounted(){
this.getCarSeriList()
},
methods:{
...mapActions({
getCarSeriList: 'channel/getCarSeriList'
}),
} }
} }
</script> </script>
......
...@@ -3,6 +3,8 @@ export default { ...@@ -3,6 +3,8 @@ export default {
namespaced: true, namespaced: true,
state: { state: {
videoList: [], videoList: [],
carSeriesData: [],
searchList: [],
topicDetail: {}, topicDetail: {},
merchantId: '', merchantId: '',
channelStyle: 1, channelStyle: 1,
...@@ -27,7 +29,24 @@ export default { ...@@ -27,7 +29,24 @@ export default {
}, },
['SET_CHANNEL_TYPE'](state, payload) { ['SET_CHANNEL_TYPE'](state, payload) {
state.channelType = payload.channelType state.channelType = payload.channelType
} },
['SET_CARSERI_LIST'](state, payload) {
state.carSeriesData = payload.list || []
},
['SET_SEARCH_LIST'](state, payload) {
let list = []
payload.list?.forEach(item =>{
list.push({id: `${item.id}`, value:item.name})
item.childs?.forEach(ele =>{
list.push({id: `${item.id}-${ele.id}`, value:ele.name})
ele.childs?.forEach(o =>{
list.push({id: `${item.id}-${ele.id}-${o.id}`, value:o.name})
})
})
})
console.log(list)
state.searchList = list
},
}, },
actions: { actions: {
// 获取视频列表 // 获取视频列表
...@@ -58,6 +77,14 @@ export default { ...@@ -58,6 +77,14 @@ export default {
} }
} }
}) })
},
getCarSeriList(conText, payload) {
apis.case.getCarSeriesApi({needCarSeries:true}).then(res => {
if(res?.length){
conText.commit('SET_CARSERI_LIST', { list: res })
conText.commit('SET_SEARCH_LIST', { list: res })
}
})
} }
} }
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</glsx-combi-form> </glsx-combi-form>
</div> </div>
<select-store v-if="relateStoreVisible" ref="relateStore" :dialogVisible="relateStoreVisible" :storeSelected="selectedList" :merchantInfo="editForm.merchantId" @handleRelateStoreConfirm="handleRelateStoreConfirm" @handleRelateStoreClose="handleRelateStoreClose"></select-store> <select-store v-if="relateStoreVisible" ref="relateStore" :dialogVisible="relateStoreVisible" :storeSelected="selectedList" :merchantInfo="editForm.merchantId" @handleRelateStoreConfirm="handleRelateStoreConfirm" @handleRelateStoreClose="handleRelateStoreClose"></select-store>
<selectCarDialog v-if="carDialogVisible" singleChoice @handleClose="handleClose" @handleConfirm="handleConfirm" :dialogVisible="carDialogVisible"></selectCarDialog> <selectCarDialog v-if="carDialogVisible" singleChoice @handleClose="handleClose" :echoData="editForm.vehicleSeriesRequests" @handleConfirm="handleConfirm" :dialogVisible="carDialogVisible"></selectCarDialog>
<GLFooter> <GLFooter>
<el-button @click="handleCancel">取消</el-button> <el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button> <el-button type="primary" @click="handleSave">确定</el-button>
......
...@@ -7,10 +7,23 @@ ...@@ -7,10 +7,23 @@
@onOk="handleConfirm" @onOk="handleConfirm"
@onCancel="handleClose"> @onCancel="handleClose">
<div class="search-wrap"> <div class="search-wrap">
<el-input size="small" placeholder="请输入搜索关键字" v-model="curbrandName"> <!-- <el-select clearable v-model="curbrandName" @change="changeFilterItem" filterable placeholder="请选择">
<i slot="suffix" class="el-input__icon el-icon-search"></i> <el-option
</el-input> v-for="item in searchList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select> -->
<el-autocomplete
debounce="1000"
v-model="curbrandName"
:fetch-suggestions="querySearchAsync"
placeholder="请输入内容"
@select="changeFilterItem"
></el-autocomplete>
</div> </div>
<div>{{ searchList.length }}</div>
<div v-if="loading" class="loading-wrap"> <div v-if="loading" class="loading-wrap">
<img class="loading-img" :src="url" alt=""> <img class="loading-img" :src="url" alt="">
</div> </div>
...@@ -42,18 +55,22 @@ ...@@ -42,18 +55,22 @@
<script> <script>
import url from '@/assets/loading.png' import url from '@/assets/loading.png'
import { mapState, mapActions } from 'vuex'
export default { export default {
name: 'selectStore', name: 'selectStore',
data() { data() {
return { return {
url, url,
loading: true, loading: false,
restaurants: [
{ "value": "三全鲜食(北新泾店)", "address": "长宁区新渔路144号" },
{ "value": "Hot honey 首尔炸鸡(仙霞路)", "address": "上海市长宁区淞虹路661号" }],
curbrandName: '', curbrandName: '',
carSeriesData: [], // searchList: [], //搜索列表
filterBrandList: [], filterBrandList: [], // 品牌数据
sonBrandList: [], sonBrandList: [], // 子品牌数据
carSeriesList: [], carSeriesList: [], //车系数据
selectdData: {}, selectdData: {}, //已选的数据
curBrandInfo: { curBrandInfo: {
id: '', id: '',
name: '' name: ''
...@@ -66,6 +83,10 @@ ...@@ -66,6 +83,10 @@
} }
}, },
computed:{ computed:{
...mapState({
carSeriesData: state => state.channel.carSeriesData, //品牌源数据
searchList: state => state.channel.searchList,
})
}, },
props: { props: {
dialogVisible:{ dialogVisible:{
...@@ -81,24 +102,29 @@ ...@@ -81,24 +102,29 @@
default: ()=>[] default: ()=>[]
}, },
}, },
watch:{
curbrandName:{
handler(nVal, oVal){
this.sonBrandList = []
this.carSeriesList = []
this.filterBrandList = this.carSeriesData.filter(item => item.name.indexOf(nVal)>-1)
},
deep: true
}
},
created(){ created(){
this.filterBrandList = this.carSeriesData
// this.flatData(this.carSeriesData)
this.echoDataFn() this.echoDataFn()
}, },
mounted() { mounted() {
this.getCarSeriesData() // this.getCarSeriesData()
}, },
methods:{ methods:{
querySearchAsync(queryString, cb){
var restaurants = this.searchList;
var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : [];
cb(results);
},
createStateFilter(queryString) {
return (state) => {
return (state.value.toLowerCase().indexOf(queryString.toLowerCase())>-1);
};
},
handleSelect(e){
console.log(e)
},
echoDataFn(){ echoDataFn(){
let obj = {} let obj = {}
this.echoData.forEach(item => { this.echoData.forEach(item => {
...@@ -117,6 +143,47 @@ ...@@ -117,6 +143,47 @@
} }
}) })
this.selectdData = obj this.selectdData = obj
console.log(this.echoData, this.selectdData,123)
},
changeFilterItem(e){
const _idList = e.id?.split('-') || []
const _target = this.carSeriesData.find(item => item.id == _idList[0])
if(!e.id){
this.filterBrandList = this.carSeriesData
return;
}
this.$nextTick(()=>{
if(_target) {
this.curBrandInfo = {
id: _target?.id,
name: _target?.name
}
this.filterBrandList = [_target]
if(_idList[1]){
const _sonTarget = _target.childs.find(item => item.id == _idList[1])
if(_sonTarget){
this.curSonBrandInfo = {
id: _sonTarget.id,
name: _sonTarget.name
}
this.sonBrandList = [_sonTarget]
if(_idList[2]){
const _carTarget = _sonTarget.childs.find(item => item.id == _idList[2])
if(_carTarget) this.carSeriesList = [_carTarget]
}else{
this.carSeriesList = _sonTarget?.childs || []
}
}
}else{
this.curSonBrandInfo = {
id: _target?.childs?.[0]?.id,
name: _target?.childs?.[0]?.name
}
this.sonBrandList = _target.childs || []
this.carSeriesList = this.sonBrandList?.[0]?.childs || []
}
}
})
}, },
changeBrandStatus(e, row, idx){ changeBrandStatus(e, row, idx){
this.curBrandInfo = { this.curBrandInfo = {
...@@ -247,24 +314,33 @@ ...@@ -247,24 +314,33 @@
} }
}, },
// 获取数据源 // 获取数据源
getCarSeriesData() { // getCarSeriesData() {
this.$apis.case.getCarSeriesApi({needCarSeries:true}).then(res => { // this.$apis.case.getCarSeriesApi({needCarSeries:true}).then(res => {
// if(res?.length){
// this.carSeriesData = res
// this.filterBrandList = res
// this.flatData(res)
// }
// }).finally(end =>{
// this.loading = false
// })
// },
// flatData(list, parentId){
// list?.forEach(item =>{
// let id = `${parentId ? parentId + '-': ''}${item.id}`
// this.searchList.push({id, name:item.name})
// this.flatData(item.childs, id)
// })
// },
getCarSeriList(conText, payload) {
apis.case.getCarSeriesApi({needCarSeries:true}).then(res => {
if(res?.length){ if(res?.length){
this.carSeriesData = res conText.commit('SET_CARSERI_LIST', { list: res })
this.filterBrandList = res
} }
}).finally(end =>{
this.loading = false
}) })
}, },
flatData(list){
// let
// list.forEach(item =>{
// })
},
handleConfirm(){ handleConfirm(){
console.log(this.selectdData) // console.log(this.selectdData)
this.$emit('handleConfirm', this.selectdData) this.$emit('handleConfirm', this.selectdData)
}, },
handleClose(){ handleClose(){
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!