From 0cae652ee8edc36aee574c2538c4cf581b24d811 Mon Sep 17 00:00:00 2001 From: "liujw155@outlook.com" Date: Wed, 8 Dec 2021 16:48:26 +0800 Subject: [PATCH] add linkage --- src/pages/site/manage/manage.vue | 58 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/src/pages/site/manage/manage.vue b/src/pages/site/manage/manage.vue index 2e06ed9..ab660b4 100644 --- a/src/pages/site/manage/manage.vue +++ b/src/pages/site/manage/manage.vue @@ -228,6 +228,8 @@ export default { getVenueStatusnInfo(info){ // 超时未订 if(info.overdue&&info.type == 'empty_venue')return { zh_text: info.message || info.price, type: 'overdue', className: 'gray', } + // isLinkage + if(info.isLinkage&&info.isLinkage == true)return { zh_text: info.message || info.price || 0, type: 'linkage', className: 'gray', } switch(info.type){ case 'no_price_venue': return { zh_text: info.message || '无法订场', type: info.type, className: 'grey', } @@ -298,7 +300,7 @@ export default { stadium_id: curStoreInfo.id || '', date: curDateInfo.dateStr || '', }) - let _list = _res.dashboard || []; + let _list = _res || []; if(!_list.length)return util.showNone('没有场地信息!'); this.venueList = _list || []; @@ -350,7 +352,9 @@ export default { venueInfo: {...this.getVenueStatusnInfo(_curTarget)}, } } + if(_curTarget.type !== 'empty_venue')return; + if(_curTarget.isLinkage == true)return; _venueList[i].items[j]._isSelect = !_curTarget._isSelect; @@ -373,7 +377,13 @@ export default { // }) || []; // -----> - + // 联动赋值禁选 + _venueList = this.checkLinkageVenue({ + group: i, + venueList: _venueList, + selectedKey: '_isSelect', + linkageKey: 'isLinkage', + }) this.venueList = _venueList; this.$nextTick(_=>{ // if(_ctnList.length>1){ @@ -384,6 +394,39 @@ export default { this.getSelectedVenues(); }) }, + + // 检查&设置联动禁选场地 + checkLinkageVenue({ + group = 0, // 所点击场地列表 + venueList = [], // 所有场地 + selectedKey = 'selectedKey', // 选中key + linkageKey = 'linkageKey', // 联动禁用key + curTag + }){ + let _curGroupInfo = {...venueList[group]}; + for(let i=0; i{ + // 单列联动 + if(venueList[i].link_venue_ids && venueList[i].link_venue_ids.length == 1){ + venueList[i].items[ele._defineIndex][linkageKey] = !!_curGroupInfo.items[ele._defineIndex][selectedKey]; + } + // 多列联动 + if(venueList[i].link_venue_ids && venueList[i].link_venue_ids.length > 1){ + let _link_venueLs = venueList.filter(item=> venueList[i].link_venue_ids.includes(item.venue_id)); + // 已联动列表选中情况 ex: [ true, false ]; + let _link_venueLs_selectedLs = _link_venueLs.map(el=> el['items'][ele._defineIndex] && el['items'][ele._defineIndex][selectedKey]); + venueList[i].items[ele._defineIndex][linkageKey] = _link_venueLs_selectedLs.includes(true); // 多场联动,只要有一个被选中就禁止 + } + }); + } + + } + return venueList || []; + }, + // 获取已选列表 getSelectedVenues(){ let { venueList } = this; @@ -471,7 +514,15 @@ export default { return servers.get({ url: API.venue.venueList, data: { stadium_id, type_key, date }, - failMsg: '加载分类失败!' + failMsg: '加载场地列表失败!' + }) + .then(res=>{ + let _ls = res.dashboard || []; + _ls.map(ele => ele.items.map((item, index) =>{ + item._defineIndex = index; + return item; + })) + return _ls; }) }, // 球类列表 @@ -500,7 +551,6 @@ export default { }catch(err){ console.warn('get fixed nodes info err', err); } - console.warn(_fixedTopInfo, _fixedBotInfo) let _totalHeight = ( _fixedBotInfo.height || 0 ) + ( _fixedTopInfo.height || 0 ); this.venueAreaSize = `width:${ _sysInfo.screenWidth || 0 }px;height:${ ( _sysInfo.windowHeight || 0 ) - _totalHeight }px;` // util.getNodeMes('.sv-time-interval')