<template>
|
<view class="page-calendar-atten">
|
<view class="container" v-if="attenLst.length > 0">
|
<view class="uni-panel-content">
|
<view v-for="(item,index) in attenLst" class="uni-panel-calendar-item" :key="item.ID"
|
@click="clickCalendarItem(item)">
|
<view class="uni-panel-item">
|
<text class="uni-panel-item-ico fs-calendar"></text>
|
<text class="uni-panel-item-text blue-text">{{item.CreatorName}}</text>
|
<text class="uni-panel-item-text">{{item.Name}}</text>
|
</view>
|
<text class="uni-panel-right-icon blue-text "
|
:class="item.checked ? 'fs-CheckBoxOk2' : 'fs-CheckBoxEmpty2'" style="transform:scale(0.8)" />
|
</view>
|
</view>
|
<view class="uni-panel-bottom">
|
<view class="button-clz">
|
<button class="uni-panel-button" @click="onAddAtten">新增关注</button>
|
<button class="uni-panel-button" @click="onOK">确定</button>
|
</view>
|
</view>
|
<view class="uni-panel-safe-bottom" :style="{height:safeAreaBottom + 'px'}" />
|
</view>
|
<view class="container justify-center items-center" v-else>
|
<view class="uni-panel-no-calendar" v-if="loaded">
|
<view class="uni-no-calendar-tip">没有关注的日历</view>
|
</view>
|
<view class="button-clz" v-if="loaded">
|
<button class="uni-panel-button" @click="onAddAtten">新增关注</button>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import Session from "@/common/utils.js"
|
// import {attenList,addAtten} from "@/common/api/app.js"
|
import {
|
|
attenList as calendarAttenList,
|
attenAdd as calendarAttenAdd,
|
attenRemove as calendarAttenRemove,
|
} from "@/api/gungho/calendar.js"
|
|
import {
|
showModal,
|
showToast,
|
showLoading,
|
hideLoading
|
} from "@/common/Page.js"
|
export default {
|
name: "pageCalendarAtten",
|
data() {
|
return {
|
safeAreaBottom: getApp().globalData.safeAreaBottom,
|
loaded: false,
|
attenLst: [],
|
}
|
},
|
methods: {
|
setData: function(obj) {
|
let that = this;
|
let keys = [];
|
let val, data;
|
|
Object.keys(obj).forEach(function(key) {
|
keys = key.split(".");
|
val = obj[key];
|
data = that.$data;
|
keys.forEach(function(key2, index) {
|
if (index + 1 == keys.length) {
|
that.$set(data, key2, val);
|
} else {
|
if (!data[key2]) {
|
that.$set(data, key2, {});
|
}
|
}
|
data = data[key2];
|
});
|
});
|
},
|
loadAttenList() {
|
const _this = this
|
_this.loaded = false
|
showLoading("加载中,请稍后...")
|
calendarAttenList(0x01).then((res) => {
|
const list = res || []
|
if (list.length > 0) {
|
list.forEach(function(item) {
|
item.checked = true
|
})
|
_this.setData({
|
attenLst: list
|
})
|
} else
|
_this.setData({
|
attenLst: []
|
})
|
hideLoading()
|
_this.loaded = true
|
}).catch((rej) => {
|
_this.setData({
|
attenLst: []
|
})
|
hideLoading()
|
_this.loaded = true
|
console.log("calendarAttenList catch", rej)
|
})
|
},
|
async onOK() {
|
try {
|
const listAdd = []
|
const listDel = []
|
this.attenLst.forEach(function(item) {
|
if (item.checked) {
|
listAdd.push(item)
|
} else {
|
listDel.push(item.ID)
|
}
|
})
|
if (listAdd.length > 0) {
|
for (let i in listAdd) {
|
const item = listAdd[i]
|
await calendarAttenAdd(item.Creator, item.ID)
|
}
|
}
|
if (listDel.length > 0) {
|
await calendarAttenAdd(listDel.join())
|
}
|
uni.$emit('calendarListChange')
|
uni.navigateBack()
|
} catch (ex) {
|
this.showError(ex)
|
}
|
|
},
|
clickCalendarItem(item) {
|
item.checked = !item.checked
|
},
|
onAddAtten(evt) {
|
const _this = this
|
uni.showActionSheet({
|
itemList: ["从共享给我的日历选", "从我的下属日历选", "从所有公开日历选"],
|
success: function(res) {
|
let value = res.tapIndex;
|
if (value < 3 && value >= 0) {
|
uni.navigateTo({
|
url: '/pages/calendar/list?type=' + value
|
})
|
}
|
},
|
fail: function(res) {
|
console.log(res.errMsg);
|
}
|
})
|
},
|
getBackList(list) {
|
var _this = this
|
list.forEach(function(item) {
|
let curIndex = _this.attenLst.findIndex((item2, index, arr) => {
|
return item2.ID == item.ID;
|
})
|
if (curIndex < 0) {
|
item.checked = true
|
_this.attenLst.push(item)
|
} else {
|
_this.attenLst[curIndex].checked = true
|
}
|
|
})
|
},
|
showError(ex) {
|
let tip = typeof ex == 'string' ? ex : typeof ex.err_msg == 'string' ? ex.err_msg : typeof ex.errMsg ==
|
'string' ? ex.errMsg : ""
|
showModal(tip, "提示", false)
|
},
|
},
|
onLoad(option) {
|
// #ifdef MP-DINGTALK
|
|
my.setNavigationBar({
|
backgroundColor: "#007AFF",
|
frontColor: "#ffffff"
|
})
|
// #endif
|
this.loadAttenList()
|
},
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import "../../common/css/button.scss";
|
|
page {
|
background-color: #e5eaee;
|
height: calc(100vh - 10px);
|
}
|
|
.page-calendar-atten {
|
width: 750rpx;
|
height: 100vh;
|
background-color: #e5eaee;
|
|
.container {
|
display: flex;
|
width: 100%;
|
height: 100%;
|
flex-direction: column;
|
|
.uni-panel-content {
|
display: flex;
|
flex: 1;
|
width: 100%;
|
padding: 8px 0;
|
overflow: auto;
|
flex-direction: column;
|
height: calc(100% - 64px);
|
}
|
|
.uni-panel-calendar-item {
|
display: flex;
|
flex-direction: row;
|
width: calc(750rpx - 30px);
|
margin: 5px 10px;
|
background-color: white;
|
border-radius: 8px;
|
padding: 10px 5px;
|
}
|
|
.uni-panel-item {
|
width: 100%;
|
flex: 1;
|
|
.uni-panel-item-ico {
|
// display: flex;
|
margin: 4px 8px 4px 4px;
|
font-size: 16px;
|
color: #333;
|
line-height: 50rpx;
|
}
|
|
.uni-panel-item-text {
|
// display: flex;
|
margin: 4px 8px 4px 4px;
|
font-size: 14px;
|
line-height: 50rpx;
|
}
|
|
|
}
|
|
.blue-text {
|
color: #007aff;
|
}
|
|
.uni-panel-right-icon {
|
height: 50rpx;
|
padding: 0px 4px;
|
line-height: 50rpx;
|
font-size: 24px;
|
text-align: right;
|
}
|
|
.button-clz {
|
display: flex;
|
width: 100%;
|
flex-direction: row;
|
font-size: 14px !important;
|
margin-top: 8px;
|
margin-bottom: 8px;
|
border-radius: 0px;
|
}
|
|
.uni-panel-button {
|
flex: 1;
|
border-radius: 12px;
|
margin: 5px 12px 16px;
|
background-color: #00aaff;
|
color: #fff;
|
|
.uni-panel-right-icon {
|
font-size: 14px;
|
}
|
}
|
|
.uni-panel-bottom {
|
display: flex;
|
justify-content: flex-end;
|
align-items: flex-end;
|
min-height: 20px;
|
padding: 8px 12px;
|
font-size: 14px;
|
}
|
|
.uni-panel-no-calendar {
|
padding: 20px;
|
}
|
|
.unino-calendar-tip {
|
color: #aaa;
|
padding-bottom: 20px;
|
font-size: 20px;
|
}
|
}
|
}
|
</style>
|