<template>
<mu-dialog class="selDialog" width="750px" :open.sync="isShowFriDialog">
<mu-sub-header>選擇好友<span style="float: right; color: #3279e5" @click="submitFriList">確定</span></mu-sub-header>
<!-- <mu-pagination v-if="friAllCount>=showCount" small :page-size="showCount" :total="friAllCount" :current.sync="currentPage" @change="showFriList"></mu-pagination> -->
<mu-sub-header>
<mu-checkbox v-model="checkedAll" label="全選" @change="changeState"></mu-checkbox>
</mu-sub-header>
<mu-list v-loading="friLoading" data-mu-loading-color="#3279e5" data-mu-loading-overlay-color="rgba(0, 0, 0, .12)">
<div class="list-wrapper" v-for="(vo, index) in friendsList[showCount]" :key="index">
<mu-list-item avatar button :ripple="false" >
<mu-list-item-action>
<mu-checkbox v-model="checkFriModel" :value="vo.friendWechatyId" @change="RecordFri($event)"></mu-checkbox>
</mu-list-item-action>
<mu-list-item-action>
<mu-avatar style="box-shadow: 0 3px 5px -1px rgba(0,0,0,.2), 0 5px 8px 0 rgba(0,0,0,.14), 0 1px 14px 0 rgba(0,0,0,.12);border: 2px solid;">
<img :src="vo.friendAvatar || ''" />
</mu-avatar>
</mu-list-item-action>
<mu-list-item-title>{{vo.friendAlias || vo.friendName}}</mu-list-item-title>
</mu-list-item>
<mu-divider></mu-divider>
</div>
</mu-list>
</mu-dialog>
</template>
<script>
import { getBotContacts } from '@/api/bot'
import { mapGetters } from 'vuex'
export default {
data() {
return {
friendsList: [],
checkedAll: false,
checkFriModel: [],
showCount: 500,
friAllCount: 0,
friLoading: false,
currentPage: 1,
isShowFriDialog: false
}
},
watch: {
checkFriModel: {
handler () {
console.log(this.checkFriModel)
let newFri = []
if(!Array.prototype.subsetTo){
Array.prototype.subsetTo=function(arr){
return this.every(v=>arr.includes(v))
}
}
this.friendsList[this.showCount].forEach(item=>{
newFri.push(item.friendWechatyId)
})
if(newFri.subsetTo(this.checkFriModel)) {
this.checkedAll = true
} else {
this.checkedAll = false
}
},
deep: true
}
},
// props: ['isShowFriDialog'],
computed: {
...mapGetters(['userId', 'botId'])
},
methods: {
// 好友全選
changeState(e) {
if (this.checkedAll == true) {
// this.checkFriModel = []
this.friendsList[this.showCount].forEach(item=>{
this.checkFriModel.push(item.friendWechatyId)
})
} else {
for(var i=0;i<this.friendsList[this.showCount].length;i++){
for(var j=0;j<this.checkFriModel.length;j++){
if(this.checkFriModel[j]==this.friendsList[this.showCount][i].friendWechatyId){
this.checkFriModel.splice(j,1);
j--;
}
}
}
}
},
submitFriList() {
this.$emit('submitFriList', this.checkFriModel)
},
RecordFri(data) {
this.friChecked = data
},
showFriList() {
console.log(this.botId)
this.isShowFriDialog = true
this.friLoading = true
if(!this.botId) return
getBotContacts({botId: this.botId, pageSize: 5000, pageNum: this.currentPage}).then(res=>{
if (res && res.status === 'success') {
var newFriList = []
this.friendsList[this.showCount] = res.data.botContactList
this.friendsList[this.showCount].forEach(item=>{
newFriList.push(item.friendWechatyId)
})
if(!Array.prototype.subsetTo){
Array.prototype.subsetTo=function(arr){
return this.every(v=>arr.includes(v))
}
}
this.checkedAll = newFriList.subsetTo(this.checkFriModel)
console.log(this.friendsList.length)
// this.friendsList = this.friendsList.concat(res.data.botContactList)
this.friAllCount = res.data.allCount
this.friLoading = false
}
})
},
hidden() {
this.isShowFriDialog = false
}
}
}
</script>
分頁下的全選組件
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門茂嗓,熙熙樓的掌柜王于貴愁眉苦臉地迎上來餐茵,“玉大人,你說我怎么就攤上這事述吸》拮澹” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵蝌矛,是天一觀的道長道批。 經(jīng)常有香客問我,道長入撒,這世上最難降的妖魔是什么隆豹? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮茅逮,結(jié)果婚禮上璃赡,老公的妹妹穿的比我還像新娘判哥。我一直安慰自己,他們只是感情好碉考,可當(dāng)我...
- 文/花漫 我一把揭開白布塌计。 她就那樣靜靜地躺著,像睡著了一般侯谁。 火紅的嫁衣襯著肌膚如雪锌仅。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼丽旅,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了纺棺?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布梭依,位于F島的核電站,受9級特大地震影響典尾,放射性物質(zhì)發(fā)生泄漏役拴。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一钾埂、第九天 我趴在偏房一處隱蔽的房頂上張望河闰。 院中可真熱鬧科平,春花似錦、人聲如沸姜性。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽污抬。三九已至汞贸,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間印机,已是汗流浹背矢腻。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 公共js文件寫省市區(qū)聯(lián)動 ** * @param grade 2省房铭,3市驻龟,4區(qū) * @param regionId...
- 前言 分頁其實很容易實現(xiàn),我自己寫了一個簡單的分頁組件龟梦,可以實現(xiàn)上下翻頁隐锭,輸入頁碼跳轉(zhuǎn)到指定頁,刷新頁面后不會回到...