<template>
|
<view class="page-calendar-schedule">
|
<view class="schedule-form">
|
<view class="uni-panel-body">
|
<view class="uni-panel-h">
|
<text class="uni-panel-ico fs-edit"></text>
|
<input style="flex: 1;" name="title" :disabled="!canEdit" comfirm-type="done" type="text" v-model="title"
|
placeholder="请输入主题" />
|
</view>
|
<view class="uni-panel-h">
|
<view class="uni-panel-body2" @click="clickShowMenu(0)">
|
<text class="fs-info_circle" style="color: #52a5f7;font-size: 18px;padding-right: 8px;"></text>
|
<text>{{important_text}}</text>
|
<text class="uni-panel-down-arrow"></text>
|
</view>
|
<view class="uni-panel-body2" @click="clickShowMenu(1)">
|
<view class="uni-panel-radius2" :style="{'background-color':tagColor ? tagColor:'#000'}">
|
</view>
|
<text>{{tagName ? tagName: '无标签'}}</text>
|
<text class="uni-panel-down-arrow"></text>
|
</view>
|
</view>
|
</view>
|
<view class="uni-panel-body">
|
<view class="uni-panel-h">
|
<view class="uni-panel-body3">
|
<text class="uni-panel-ico fs-task1"></text>
|
<view class="uni-panel-body4" @click="clickSetDate(0)">
|
<text style="color: #007aff; margin-bottom: 4px;">{{start_date}}</text>
|
<text style="color: gray;">{{start_time}}</text>
|
</view>
|
</view>
|
<view class="uni-panel-body3">
|
<view class="uni-panel-left" style="height: 42px;">
|
<text class=" fs-ArrowRight stretch" style="color: gray;"></text>
|
</view>
|
<view class="uni-panel-body4"></view>
|
<view class="uni-panel-body4" @click="clickSetDate(1)">
|
<text style="color: #007aff; margin-bottom: 4px;">{{end_date}}</text>
|
<text style="color: gray;">{{end_time}}</text>
|
</view>
|
</view>
|
</view>
|
<view v-if="showCalendar" class="uni-panel-date-content">
|
<view class="uni-panel-h2">
|
<view class="uni-panel-body3"></view>
|
<view class="uni-panel-body3">
|
<text class="uni-panel-body4 uni-panel-text"
|
:style="{'color':typeCalendar == 0?'#007aff':'black'}"
|
@click="changeDateType(0)">开始</text>
|
<text class="uni-panel-body4 uni-panel-text"
|
:style="{'color':typeCalendar == 1?'#007aff':'black'}"
|
@click="changeDateType(1)">结束</text>
|
</view>
|
<view class="uni-panel-body3"><text class="uni-panel-body4"></text><text
|
class="uni-panel-text-right " style="color: #007aff;" @click="closeCalendar">确认</text>
|
</view>
|
</view>
|
<uni-calendar :showMonth="false" :insert="true" :start-date="calendarRangeStart"
|
@change="selDate" />
|
<view class="uni-panel-h2">
|
<view class="uni-panel-body3"><text class="uni-panel-ico fs-time_x"
|
style="font-size: 16px;"></text><text class="uni-panel-text">时间</text></view>
|
<view class="uni-panel-body3">
|
<view class="uni-panel-body4"></view>
|
<picker mode="time" :value="time" start="00:00" end="23:59" @change="changeTime">
|
<view class="uni-panel-time">{{time}}</view>
|
</picker>
|
<text class="uni-panel-ico-right fs-ArrowRight" v-if="canEdit"></text>
|
</view>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<view class="uni-panel-body3"><text class="uni-panel-ico fs-alarm"></text><text
|
class="uni-panel-text">提醒</text></view>
|
<view class="uni-panel-body3" @click="clickSetRemind">
|
<view class="uni-panel-body4"></view><text>{{remindText}}</text><text
|
class="uni-panel-ico-right fs-ArrowRight" v-if="canEdit"></text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<view class="uni-panel-body3"><text class="uni-panel-ico fs-refresh_x"></text><text
|
class="uni-panel-text">重复</text></view>
|
<view class="uni-panel-body3" @click="clickSetRepeat">
|
<view class="uni-panel-body4"></view><text>{{repeatText}}</text><text
|
class="uni-panel-ico-right fs-ArrowRight" v-if="canEdit"></text>
|
</view>
|
</view>
|
<view class="uni-panel-h" v-if="isRepeat">
|
<view class="uni-panel-body3"><text class="uni-panel-ico fs-Due"></text><text
|
class="uni-panel-text">结束重复</text></view>
|
<view class="uni-panel-body3" @click="clickEndRepeat">
|
<view class="uni-panel-body4"></view><text>{{repeatEndText}}</text><text
|
class="uni-panel-ico-right fs-ArrowRight" v-if="canEdit"></text>
|
</view>
|
</view>
|
<view class="uni-panel-h">
|
<view class="uni-panel-body3"><text class="uni-panel-ico fs-time"></text><text
|
class="uni-panel-text">私密行程</text></view>
|
<view class="uni-panel-body3">
|
<view class="uni-panel-body4"></view>
|
<switch :checked="switchedPrivite" color="#007aff" :disabled="!canEdit" style="transform:scale(0.8)"
|
@change="changePriviteSwitched" />
|
</view>
|
</view>
|
</view>
|
<view class="uni-panel-body">
|
<view class="uni-panel-h">
|
<view class="uni-panel-text">描述:</view>
|
</view>
|
<view class="uni-panel-c">
|
<!-- <textarea auto-height fixed comfirm-type="done" show-confirm-bar="{{false}}" type="text" v-model="note" placeholder="请详细描述你的问题和意见..." /> placeholder-style="z-index:12" -->
|
<textarea :disabled="!canEdit" auto-height fixed show-confirm-bar="{{false}}" comfirm-type="done"
|
type="text" v-model="note" placeholder="输入日程的一些说明" />
|
</view>
|
</view>
|
</view>
|
<view class="uni-panel-bottom" v-if="canEdit">
|
<button v-if="isEdit" class="uni-panel-button" style="background-color: #ff5050;color: #fff;"
|
@click="clickDel"><text class="fs-recycle"></text> 删除日程</button>
|
<button class="uni-panel-button" @click="clickEditFinish"><text
|
class="fs-WD_Confirm"></text>{{isEdit?' 编辑完成':' 添加日程'}}</button>
|
</view>
|
<view class="uni-panel-safe-bottom" :style="{height:safeAreaBottom + 'px'}" />
|
<view>
|
<!-- 普通菜单 -->
|
<uni-popup ref="popupMenu" background-color="transparent" maskBackgroundColor="rgba(0, 0, 0, 0.2)">
|
<view class="popup-content" @click="closeMenu">
|
<view class="popup-content-menu ">
|
<button class="popup-content-menu-item" v-for="(item,index) in menuGroup" :key="item"
|
@click="menuSelChange(item,index)">{{item}}</button>
|
</view>
|
</view>
|
</uni-popup>
|
<!-- 带颜色菜单 -->
|
<uni-popup ref="popupMenu2" background-color="transparent" maskBackgroundColor="rgba(0, 0, 0, 0.2)">
|
<view class="popup-content" @click="closeMenu2">
|
<view class="popup-content-menu2 ">
|
<button class="popup-content-menu-item" v-for="(item,index) in menuGroup2" :key="item.text"
|
@click="menuSelChange2(item,index)">
|
<view class="uni-panel-radius2" :style="{'background-color':item.color}"></view>
|
{{item.text}}
|
</button>
|
</view>
|
</view>
|
</uni-popup>
|
<!-- 普通弹窗 -->
|
<uni-popup ref="popup" background-color="#fff">
|
<view class="popup-content" style="padding: 2px 4px 12px;">
|
<view class="uni-panel-h" style="padding: 4px 10px;">
|
<view style="flex: 1;">{{popupTitle}}</view>
|
<text class="uni-panel-text-right " style="color: #007aff;" @click="clickOkMenu">确认</text>
|
</view>
|
<view v-if="popupType==1" class="uni-panel-h" style="padding: 2px 10px;">
|
<view class="uni-panel-body3"><text class="uni-panel-text" style="padding-top: 8px;">开始:</text>
|
<picker mode="time" :value="repeatStartTime" start="00:00" :end="repeatEndTime"
|
@change="changeRepeatStartTime">
|
<view class="uni-panel-time2">{{repeatStartTime}}</view>
|
</picker>
|
</view>
|
<view class="uni-panel-body3"><text class="uni-panel-text" style="padding-top: 8px;">结束:</text>
|
<picker mode="time" :value="repeatEndTime" :start="repeatStartTime" end="23:59"
|
@change="changeRepeatEndTime">
|
<view class="uni-panel-time2">{{repeatEndTime}}</view>
|
</picker>
|
</view>
|
</view>
|
<radio-group @change="radioChange">
|
<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in menuGroup3"
|
:key="item.value">
|
<view class="uni-panel-body3">
|
<radio :value="index" color="#007aff" :checked="index === currentRadio" />
|
<text>{{item.value}}</text>
|
</view>
|
<picker class="uni-panel-body3" v-if="item.canSet" mode="time" :value="remindTime"
|
start="00:00" end="23:59" @change="changeRemindTime">
|
<view class="uni-panel-body3" style="flex-direction: row; width: 360rpx;">
|
<view class="uni-panel-body4"></view><text
|
class="uni-panel-ico-right fs-ArrowRight"></text>
|
</view>
|
</picker>
|
</label>
|
</radio-group>
|
</view>
|
</uni-popup>
|
<!-- 普通弹窗 -->
|
<uni-popup ref="popupEndRepeat" background-color="#fff">
|
<view class="popup-content" style="padding: 2px 4px 12px;">
|
<view class="uni-panel-h" style="padding: 4px 10px;">
|
<view style="flex: 1;">结束重复提醒</view>
|
<text class="uni-panel-text-right " style="color: #007aff;"
|
@click="clickEndRepeatMenu">确认</text>
|
</view>
|
<radio-group @change="radioEndRepeatChange">
|
<view class="uni-panel-h" style="padding: 2px 10px;">
|
<label class="radio">
|
<radio value="0" color="#007aff" :checked="repeatEndType ==0" />无
|
</label>
|
</view>
|
<view class="uni-panel-h" style="padding: 2px 10px;">
|
<label class="radio">
|
<radio value="1" color="#007aff" :checked="repeatEndType ==1" />结束次数
|
</label>
|
<view class="uni-panel-time2"><input name="repeatEndCount" type="number"
|
v-model="repeatEndCount" placeholder="" maxlength="10" /></view>
|
</view>
|
<view class="uni-panel-h" style="padding: 2px 10px;">
|
<label class="radio">
|
<radio value="2" color="#007aff" :checked="repeatEndType ==2" />结束日期
|
</label>
|
<picker mode="date" :value="repeatEndDate" :start="startDate" @change="changeRepeatEndDate">
|
<view class="uni-panel-time2">{{repeatEndDate}}</view>
|
</picker>
|
</view>
|
</radio-group>
|
</view>
|
</uni-popup>
|
|
</view>
|
<view class="clearfix"></view>
|
</view>
|
|
</template>
|
|
<script>
|
import {
|
Base64
|
} from 'js-base64';
|
import {
|
eventCreate as calendarEventCreate,
|
eventUpdate as calendarEventUpdate,
|
eventInfo as calendarEventInfo,
|
eventDelete as calendarEventDelete,
|
} from "@/api/gungho/calendar.js"
|
import parseHtml from "@/common/htmlParse.js"
|
import TaskInit from "@/common/extend.js"
|
import CalendarLunar from "@/common/calendarLunar.js"
|
import {
|
showModal,
|
showToast
|
} from "../../common/Page"
|
export default {
|
name: "pageCalendarSchedule",
|
data() {
|
return {
|
canEdit: true,
|
calendarId: "",
|
eventId: "",
|
options: {},
|
safeAreaBottom: getApp().globalData.safeAreaBottom,
|
scheduleData: {},
|
title: '',
|
note: '',
|
menuGroup: [],
|
menuGroup2: [],
|
menuGroup3: [],
|
switchedPrivite: true,
|
showCalendar: false,
|
typeCalendar: 0,
|
calendarRangeStart: "",
|
startDate: "",
|
endDate: "",
|
startTime: "",
|
endTime: "",
|
allDay: true,
|
time: "全天",
|
tagName: "",
|
tagColor: '',
|
importance: 2,
|
remindTime: '09:00',
|
remindDef: {
|
type: 'n',
|
value: "0"
|
},
|
isRepeat: false,
|
repeatInfo: {
|
RegularType: '',
|
Interval: '0',
|
RegularValue: '',
|
RegularRange: '',
|
Num: '',
|
},
|
repeatStartTime: '08:40',
|
repeatEndTime: '09:10',
|
repeatEndDate: '',
|
repeatEndCount: 1,
|
repeatEndType: 0,
|
currentRadio: 0,
|
popupType: 0
|
}
|
},
|
computed: {
|
isEdit() {
|
if (this.eventId) {
|
return true
|
} else
|
return false
|
},
|
important_text() {
|
if (this.importance == 1)
|
return '不重要'
|
else if (this.importance == 3)
|
return '重要'
|
else
|
return '一般'
|
},
|
start_date() {
|
return TaskInit.dateUtils.openinfo_formatter_ttime(this.startDate, "no")
|
},
|
end_date() {
|
return TaskInit.dateUtils.openinfo_formatter_ttime(this.endDate, "no")
|
},
|
start_time() {
|
if (this.allDay) {
|
return "全天"
|
} else {
|
return this.startTime
|
}
|
},
|
end_time() {
|
if (this.allDay) {
|
return "全天"
|
} else {
|
return this.endTime
|
}
|
},
|
remindText() {
|
if (this.remindDef.type == 'n') {
|
return "无提醒"
|
} else if (this.remindDef.type == 't') {
|
return this.remindDef.value
|
} else {
|
const unit = {
|
'm': '分',
|
'h': '小时',
|
'd': '天',
|
'w': '周'
|
};
|
return '提前' + this.remindDef.value + unit[this.remindDef.type]
|
}
|
},
|
repeatText() {
|
if (this.isRepeat) {
|
let repeat_type = parseInt(this.repeatInfo.RegularType);
|
let repeat_value = parseInt(this.repeatInfo.RegularValue);
|
let repeat_Interval = this.repeatInfo.Interval;
|
let repeat_text = ""
|
//console.log("repeatText",this.repeatInfo)
|
switch (repeat_type) {
|
case 0:
|
switch (repeat_value) {
|
case 0:
|
repeat_text = '每天'
|
break;
|
case 1:
|
repeat_text = '每个工作日'
|
break;
|
case 2:
|
repeat_text = '每个休息日'
|
break;
|
}
|
break;
|
case 1:
|
repeat_text = '每周';
|
if ((repeat_value & 0x01) == 0x01) {
|
repeat_text += ' 日'
|
}
|
if ((repeat_value & 0x02) == 0x02) {
|
repeat_text += ' 一'
|
}
|
if ((repeat_value & 0x04) == 0x04) {
|
repeat_text += ' 二'
|
}
|
if ((repeat_value & 0x08) == 0x08) {
|
repeat_text += ' 三'
|
}
|
if ((repeat_value & 0x10) == 0x10) {
|
repeat_text += ' 四'
|
}
|
if ((repeat_value & 0x20) == 0x20) {
|
repeat_text += ' 五'
|
}
|
if ((repeat_value & 0x40) == 0x40) {
|
repeat_text += ' 六'
|
}
|
break;
|
case 2:
|
repeat_text = '每月';
|
if (repeat_value > 0) {
|
repeat_text += repeat_value
|
}
|
break;
|
case 3:
|
repeat_text = this.repeatInfo.startDate;
|
break;
|
}
|
return repeat_text
|
} else {
|
return "无重复"
|
}
|
|
},
|
repeatEndText() {
|
if (this.repeatEndType == 1)
|
return this.repeatEndCount + "次 结束重复"
|
else if (this.repeatEndType == 2)
|
return this.repeatEndDate + " 结束重复"
|
else
|
return "未设置结束重复"
|
},
|
|
popupTitle() {
|
if (this.popupType == 1)
|
return "设置重复时间提醒"
|
else
|
return "设置提醒时间"
|
}
|
},
|
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];
|
});
|
});
|
},
|
async lodaData() {
|
try {
|
this.calendarId = this.options.calendarId || ""
|
this.eventId = this.options.eventId || ""
|
this.canEdit = this.options.canEdit ? true:false
|
|
if (this.isEdit) {
|
const info = await calendarEventInfo(this.calendarId, this.eventId)
|
|
|
let note = Base64.decode(info.Note || "")
|
let nodes = parseHtml(note)
|
note = ""
|
for (let i = 0; i < nodes.length; i++) {
|
//console.log("onLoad Note1:",nodes[i])
|
if (nodes[i].name == "p") {
|
if (nodes[i].children) {
|
note += nodes[i].children[0].text + "\n"
|
}
|
}
|
}
|
let date = TaskInit.dateUtils.parse(info.StartTime)
|
let startTime = TaskInit.dateUtils.toShortTimeString(date)
|
let startDate = TaskInit.dateUtils.toDateString(date)
|
date = TaskInit.dateUtils.parse(info.EndTime)
|
let endTime = TaskInit.dateUtils.toShortTimeString(date)
|
let endDate = TaskInit.dateUtils.toDateString(date)
|
let remind_def = info.RemindDef
|
if (info.RemindDef) {
|
remind_def = JSON.parse(info.RemindDef)
|
|
} else {
|
remind_def = {
|
type: 'n',
|
value: "0"
|
}
|
}
|
this.setData({
|
scheduleData: info,
|
title: info.Name,
|
note: note,
|
allDay: info.AllDay == '1' ? true : false,
|
startDate: startDate,
|
endDate: endDate,
|
startTime: startTime,
|
endTime: endTime,
|
remindDef: remind_def,
|
tagName: info.TagName,
|
tagColor: info.TagName ? info.BkColor : '',
|
importance: parseInt(info.Importance),
|
isRepeat: info.Repeat == '1' ? true : false,
|
repeatInfo: info.RepeatInfo || {
|
RegularType: '',
|
Interval: '0',
|
RegularValue: '',
|
RegularRange: '',
|
Num: '',
|
},
|
repeatStartTime: info.RepeatInfo?.StartTime || "",
|
repeatEndTime: info.RepeatInfo?.EndTime || "",
|
repeatEndType: parseInt(info.RepeatInfo?.RegularRange || "0"),
|
repeatEndCount: info.RepeatInfo?.RegularRange == "1" ? parseInt(info
|
.RepeatInfo?.Num || "0") : 1,
|
repeatEndDate: info.RepeatInfo?.RegularRange == "2" ? info.RepeatInfo?.DTEnd :
|
endDate || "",
|
})
|
|
|
} else {
|
let date = new Date()
|
if (this.options.date)
|
date = TaskInit.dateUtils.parse(this.options.date)
|
let dateStr = TaskInit.dateUtils.toDateString(date)
|
//console.log("onLoad date",date)
|
uni.setNavigationBarTitle({
|
title: "添加日程"
|
})
|
this.setData({
|
startDate: dateStr,
|
endDate: dateStr,
|
startTime: "00:00",
|
endTime: "23:59",
|
})
|
}
|
} catch (ex) {
|
this.showError(ex)
|
}
|
},
|
clickShowMenu(type) {
|
if (!this.canEdit)
|
return
|
if (type == 1) {
|
this.setData({
|
menuGroup2: [{
|
text: '无标签',
|
color: '#000'
|
},
|
{
|
text: '待办',
|
color: '#3a87ad'
|
},
|
{
|
text: '重要',
|
color: '#FF3030'
|
},
|
{
|
text: '会议',
|
color: '#FFFF00'
|
},
|
{
|
text: '约会',
|
color: '#CD661D'
|
},
|
{
|
text: '纪念日',
|
color: '#228B22'
|
},
|
{
|
text: '不公开',
|
color: '#8E388E'
|
},
|
{
|
text: '标记完成',
|
color: '#858585'
|
}
|
]
|
|
})
|
this.$refs.popupMenu2.open("top")
|
} else {
|
this.setData({
|
menuGroup: ['不重要', '一般', '重要']
|
})
|
this.$refs.popupMenu.open("top")
|
}
|
|
},
|
menuSelChange(item, index) {
|
this.$refs.popupMenu.close()
|
this.setData({
|
importance: index + 1,
|
});
|
},
|
menuSelChange2(item, index) {
|
//console.log("tasks taskMenuChange",item)
|
let tag = this.tagName
|
let color = this.tagColor
|
if (item.text == "无标签" || item.text == "无") {
|
tag = ""
|
color = ""
|
} else {
|
tag = item.text
|
color = item.color
|
}
|
this.$refs.popupMenu2.close()
|
this.setData({
|
tagName: tag,
|
tagColor: color,
|
});
|
|
},
|
closeMenu() {
|
//console.log("tasks closeMenu")
|
this.$refs.popupMenu.close()
|
},
|
closeMenu2() {
|
//console.log("tasks closeMenu")
|
this.$refs.popupMenu2.close()
|
},
|
changeDateType(type) {
|
this.setData({
|
typeCalendar: type
|
});
|
if (this.allDay) {
|
this.setData({
|
time: "全天"
|
});
|
} else {
|
let dateStr = ''
|
let dateStartStr = ''
|
if (type == 1) {
|
dateStr = this.endTime
|
dateStartStr = this.startDate
|
} else {
|
dateStr = this.startTime
|
}
|
this.setData({
|
time: dateStr,
|
calendarRangeStart: dateStartStr
|
});
|
}
|
},
|
clickSetDate(type) {
|
if (!this.canEdit)
|
return
|
if (this.showCalendar) {
|
if (this.typeCalendar == type) {
|
this.setData({
|
showCalendar: false
|
});
|
return
|
}
|
this.setData({
|
typeCalendar: type
|
});
|
} else {
|
this.setData({
|
typeCalendar: type,
|
showCalendar: !this.showCalendar
|
});
|
}
|
if (!this.showCalendar) {
|
return
|
}
|
if (this.allDay) {
|
this.time = "全天"
|
} else {
|
let dateStr = ''
|
let dateStartStr = ''
|
if (type == 1) {
|
dateStr = this.endTime
|
dateStartStr = this.startDate
|
} else {
|
dateStr = this.startTime
|
}
|
this.setData({
|
time: dateStr,
|
calendarRangeStart: dateStartStr
|
});
|
}
|
},
|
selDate(evt) {
|
//console.log("selDate",evt.fulldate)
|
if (this.typeCalendar == 1) {
|
this.setData({
|
endDate: evt.fulldate
|
});
|
} else {
|
this.setData({
|
startDate: evt.fulldate
|
});
|
}
|
},
|
changeTime(e) {
|
//console.log('changeTime', e.detail.value)
|
if (this.typeCalendar == 1) {
|
this.setData({
|
time: e.detail.value,
|
allDay: false,
|
endTime: e.detail.value
|
});
|
} else {
|
this.setData({
|
time: e.detail.value,
|
allDay: false,
|
startTime: e.detail.value
|
});
|
}
|
},
|
changeRepeatEndTime(e) {
|
//console.log('changeRepeatEndTime', e.detail.value)
|
this.setData({
|
repeatEndTime: e.detail.value,
|
});
|
},
|
changeRepeatStartTime(e) {
|
//console.log('changeRepeatStartTime', e.detail.value)
|
this.setData({
|
repeatStartTime: e.detail.value,
|
});
|
},
|
closeCalendar() {
|
this.setData({
|
showCalendar: false
|
});
|
},
|
|
clickSetRemind() {
|
if (!this.canEdit)
|
return
|
//console.log("clickSetRemind")
|
if (this.allDay) {
|
let time = this.remindTime
|
this.setData({
|
popupType: 0,
|
menuGroup3: [{
|
value: '无'
|
},
|
{
|
value: '当天(' + time + ')',
|
canSet: true
|
}
|
]
|
})
|
} else {
|
this.setData({
|
popupType: 0,
|
menuGroup3: [{
|
value: '无'
|
},
|
{
|
value: '提前5分钟'
|
},
|
{
|
value: '提前15分钟'
|
},
|
{
|
value: '提前30分钟'
|
},
|
{
|
value: '提前1小时'
|
},
|
{
|
value: '提前1天'
|
},
|
{
|
value: '提前2天'
|
},
|
{
|
value: '提前1周'
|
}
|
]
|
})
|
}
|
this.$refs.popup.open("bottom")
|
},
|
clickSetRepeat() {
|
if (!this.canEdit)
|
return
|
//console.log("clickSetRepeat")
|
let date = TaskInit.dateUtils.parse(this.startDate)
|
let lunar = CalendarLunar.solar2lunar(date.getFullYear(), date.getMonth() + 1, date.getDate())
|
//console.log("clickSetRepeat lunar",lunar)
|
let nWeek = lunar.nWeek
|
if (nWeek == 7)
|
nWeek = 0
|
let week = CalendarLunar.toChinaWeek(nWeek)
|
if (lunar.nWeek == 7)
|
week = "日"
|
if (this.repeatStartTime == "") {
|
this.repeatStartTime = "08:40"
|
}
|
if (this.repeatEndTime == "") {
|
this.repeatEndTime = "09:10"
|
}
|
this.setData({
|
popupType: 1,
|
menuGroup3: [{
|
value: '无'
|
},
|
{
|
value: '每天'
|
},
|
{
|
value: '每个工作日(周一至周五)'
|
},
|
{
|
value: '每周(周' + week + ')'
|
},
|
{
|
value: '每月(' + date.getDate() + '日)'
|
},
|
{
|
value: '每个休息日(周六至周日)'
|
}
|
]
|
})
|
this.$refs.popup.open("bottom")
|
},
|
changeRemindTime(e) {
|
let time = e.detail.value
|
//console.log("changeRemindTime",time)
|
|
this.setData({
|
remindTime: time,
|
currentRadio: 1,
|
menuGroup3: [{
|
value: '无'
|
},
|
{
|
value: '当天(' + time + ')',
|
canSet: true
|
}
|
]
|
})
|
},
|
clickEndRepeat() {
|
if (!this.canEdit)
|
return
|
this.$refs.popupEndRepeat.open("bottom")
|
if (this.repeatEndType != 2) {
|
this.repeatEndDate = this.endDate
|
}
|
},
|
clickEndRepeatMenu() {
|
this.$refs.popupEndRepeat.close()
|
let repeat_Info = this.repeatInfo
|
repeat_Info.RegularRange = '' + this.repeatEndType
|
this.setData({
|
repeatInfo: repeat_Info
|
});
|
},
|
|
changeRepeatEndDate(e) {
|
//console.log("changeRepeatEndDate",e)
|
this.setData({
|
repeatEndDate: e.detail.value
|
});
|
},
|
radioEndRepeatChange(e) {
|
this.setData({
|
repeatEndType: parseInt(e.detail.value)
|
});
|
//console.log("radioEndRepeatChange",e)
|
},
|
radioChange(e) {
|
this.setData({
|
currentRadio: parseInt(e.detail.value)
|
});
|
//console.log("radioChange",e)
|
},
|
clickOkMenu() {
|
|
this.$refs.popup.close()
|
if (this.popupType == 1) {
|
if (this.currentRadio == 0) {
|
this.setData({
|
isRepeat: false,
|
});
|
} else {
|
|
let item = this.menuGroup3[this.currentRadio]
|
let repeat_Info = this.repeatInfo
|
let date = TaskInit.dateUtils.parse(this.startDate)
|
//console.log("clickOkMenu",repeat_Info)
|
switch (this.currentRadio) {
|
case 1: //每天
|
repeat_Info.Interval = "1"
|
repeat_Info.RegularType = "0"
|
repeat_Info.RegularValue = "0"
|
break;
|
case 2: //每个工作日
|
repeat_Info.Interval = "0"
|
repeat_Info.RegularType = "0"
|
repeat_Info.RegularValue = "1"
|
break;
|
case 3: //每周
|
|
let lunar = CalendarLunar.solar2lunar(date.getFullYear(), date.getMonth() + 1, date
|
.getDate())
|
//console.log("clickSetRepeat lunar",lunar)
|
let nWeek = lunar.nWeek
|
let repeat_value = 0x01
|
if (nWeek == 1) {
|
repeat_value = 0x02
|
} else if (nWeek == 2) {
|
repeat_value = 0x04
|
} else if (nWeek == 3) {
|
repeat_value = 0x08
|
} else if (nWeek == 4) {
|
repeat_value = 0x10
|
} else if (nWeek == 5) {
|
repeat_value = 0x20
|
} else if (nWeek == 6) {
|
repeat_value = 0x40
|
}
|
repeat_Info.Interval = "1"
|
repeat_Info.RegularType = "1"
|
repeat_Info.RegularValue = '' + repeat_value + ''
|
break;
|
case 4: //每月
|
repeat_Info.Interval = "1"
|
repeat_Info.RegularType = "2"
|
repeat_Info.RegularValue = '' + date.getDate() + ''
|
break;
|
case 5: //每个休息日
|
repeat_Info.Interval = '0'
|
repeat_Info.RegularType = '0'
|
repeat_Info.RegularValue = '2'
|
break;
|
}
|
//console.log("clickOkMenu",repeat_Info)
|
this.setData({
|
isRepeat: true,
|
repeatInfo: repeat_Info
|
});
|
//console.log("clickOkMenu2",this.repeatInfo)
|
}
|
|
} else {
|
let remind_Def = ""
|
if (this.allDay) {
|
let item = this.menuGroup3[this.currentRadio]
|
switch (this.currentRadio) {
|
case 0:
|
remind_Def = {
|
type: "n",
|
value: "0",
|
note: ""
|
}
|
break;
|
case 1:
|
remind_Def = {
|
type: "t",
|
value: this.remindTime,
|
note: ""
|
}
|
break;
|
}
|
} else {
|
switch (this.currentRadio) {
|
case 0:
|
remind_Def = {
|
type: "n",
|
value: "0",
|
note: ""
|
}
|
break;
|
case 1:
|
remind_Def = {
|
type: "m",
|
value: "5",
|
note: ""
|
}
|
break;
|
case 2:
|
remind_Def = {
|
type: "m",
|
value: "15",
|
note: ""
|
}
|
break;
|
case 3:
|
remind_Def = {
|
type: "m",
|
value: "30",
|
note: ""
|
}
|
break;
|
case 4:
|
remind_Def = {
|
type: "h",
|
value: "1",
|
note: ""
|
}
|
break;
|
case 5:
|
remind_Def = {
|
type: "d",
|
value: "1",
|
note: ""
|
}
|
break;
|
case 6:
|
remind_Def = {
|
type: "d",
|
value: "2",
|
note: ""
|
}
|
break;
|
case 6:
|
remind_Def = {
|
type: "w",
|
value: "1",
|
note: ""
|
}
|
break;
|
}
|
|
}
|
this.setData({
|
remindDef: remind_Def,
|
});
|
}
|
},
|
changePriviteSwitched(evt) {
|
if (!this.canEdit)
|
return
|
//console.log("changePriviteSwitched",evt)
|
let checked = evt.detail.value;
|
this.setData({
|
switchedPrivite: checked
|
});
|
},
|
clickDel() {
|
var _this = this
|
calendarEventDelete(this.calendarId, this.eventId).then((res) => {
|
//console.log("delelteEvent calendarEventDelete",res)
|
_this.backAndChangeData('删除', true);
|
|
}).catch((rej) => {
|
console.log("delelteEvent calendarEventDelete catch", rej)
|
this.showError(rej)
|
})
|
},
|
async clickEditFinish() {
|
|
try {
|
let dt0 = ""
|
let dt1 = ""
|
let sName = this.title.trim()
|
if (sName == "") {
|
showToast("主题不能为空!", "none")
|
return
|
}
|
if (this.allDay) {
|
dt0 = this.startDate + " 00:00:00"
|
dt1 = this.endDate + " 23:59:59"
|
} else {
|
dt0 = this.startDate + " " + this.startTime
|
dt1 = this.endDate + " " + this.endTime
|
}
|
let repeat_Info = {
|
StartTime: this.repeatStartTime,
|
EndTime: this.repeatEndTime,
|
DTStart: this.startDate,
|
DTEnd: '',
|
RegularType: this.repeatInfo.RegularType,
|
Interval: this.repeatInfo.Interval,
|
RegularValue: this.repeatInfo.RegularValue,
|
RegularRange: this.repeatInfo.RegularRange,
|
Num: ''
|
}
|
if (this.repeatInfo.RegularRange == "2") {
|
repeat_Info.DTEnd = this.repeatEndDate
|
}
|
if (this.repeatInfo.RegularRange == "1") {
|
repeat_Info.Num = '' + this.repeatEndCount
|
}
|
let event = {
|
calendarId: this.calendarId,
|
startTime: dt0,
|
endTime: dt1,
|
isPrivate: this.switchedPrivite ? '1' : '0',
|
allDay: this.allDay ? "1" : '0',
|
importance: '' + this.importance + '',
|
place: "无",
|
remindID: '',
|
taskID: '',
|
rootID: '',
|
name: sName,
|
note: '',
|
group: '',
|
repeat: this.isRepeat ? '1' : '0',
|
repeatInfo: repeat_Info,
|
|
}
|
if (this.note != "") {
|
|
event.note = Base64.encode('<p>' + this.note + '</p>')
|
}
|
if (this.isEdit) {
|
event.txtColor = ''
|
if (this.tagName != "") {
|
event.tagName = this.tagName
|
event.bkColor = this.tagColor
|
} else {
|
event.tagName = ''
|
event.bkColor = ''
|
}
|
event.remindDef = ''
|
} else {
|
if (this.tagName != "") {
|
event.tagName = this.tagName
|
event.bkColor = this.tagColor
|
}
|
}
|
let remind_Def = ""
|
if (this.remindDef.type != "n") {
|
event.remindDef = JSON.stringify(this.remindDef)
|
let tip_dt = ""
|
let repeat_time = ""
|
if (this.remindDef.type == "t") {
|
tip_dt = this.startDate + ' ' + this.remindTime
|
repeat_time = this.remindTime
|
} else {
|
let dateStr = this.startDate + ' ' + this.startTime
|
let date = TaskInit.dateUtils.parse(dateStr)
|
let valueRemind = parseInt(this.remindDef.value)
|
if (this.remindDef.type == "m") {
|
date.setMinutes(date.getMinutes() - valueRemind)
|
repeat_time = TaskInit.dateUtils.toShortTimeString(date)
|
tip_dt = TaskInit.dateUtils.toDateString(date) + ' ' + repeat_time
|
} else if (this.remindDef.type == "h") {
|
date.setHours(date.getHours() - valueRemind)
|
repeat_time = TaskInit.dateUtils.toShortTimeString(date)
|
tip_dt = TaskInit.dateUtils.toDateString(date) + ' ' + repeat_time
|
} else if (this.remindDef.type == "d") {
|
repeat_time = TaskInit.dateUtils.toShortTimeString(date)
|
date.setDate(date.getDate() - valueRemind)
|
tip_dt = TaskInit.dateUtils.toDateString(date) + ' ' + repeat_time
|
} else if (this.remindDef.type == "w") {
|
repeat_time = TaskInit.dateUtils.toShortTimeString(date)
|
date.setDate(date.getDate() - (valueRemind * 7))
|
tip_dt = TaskInit.dateUtils.toDateString(date) + ' ' + repeat_time
|
}
|
}
|
|
event.remindInfo = {
|
RemindTime: tip_dt,
|
Type: 0,
|
InvalidDate: '',
|
From: '',
|
SendFlag: 1,
|
Content: "",
|
ContentType: 'Text/URL'
|
};
|
if (this.isRepeat) {
|
event.remindInfo.Repeat = {
|
RemindTime: repeat_time,
|
DTStart: this.startDate,
|
DTEnd: this.repeatEndDate,
|
RegularType: this.repeatInfo.RegularType,
|
Interval: this.repeatInfo.Interval,
|
RegularValue: this.repeatInfo.RegularValue,
|
RegularRange: '',
|
Num: '',
|
}
|
if (this.repeatInfo.RegularRange == "2") {
|
event.remindInfo.Repeat.DTEnd = this.repeatEndDate
|
}
|
if (this.repeatInfo.RegularRange == "1") {
|
event.remindInfo.Repeat.Num = '' + this.repeatEndCount
|
}
|
}
|
}
|
//console.log("clickEditFinish event",event)
|
if (this.isEdit) {
|
event.eventId = this.eventId
|
await calendarEventUpdate(event)
|
this.backAndChangeData('编辑', true);
|
} else {
|
await calendarEventCreate(event)
|
this.backAndChangeData('添加', true);
|
}
|
} catch (ex) {
|
this.showError(ex)
|
}
|
},
|
backAndChangeData(changeText, isBack) {
|
let param = {
|
id: this.eventId,
|
change: changeText
|
}
|
let pages = getCurrentPages();
|
let prepage = pages[pages.length - 2];
|
//console.log("backAndChangeData",this.options.evalfunction);
|
prepage.$vm[this.options.evalfunction](param)
|
if (isBack) {
|
uni.navigateBack({
|
delta: 1
|
})
|
}
|
},
|
showError(ex) {
|
console.log(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.options = option
|
if (!option.evalfunction)
|
this.options.evalfunction = 'eventDataChange'
|
this.lodaData()
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
page {
|
background-color: #e5eaee;
|
}
|
|
.page-calendar-schedule {
|
display: flex;
|
width: 750rpx;
|
background-color: #e5eaee;
|
height: 100vh;
|
flex-direction: column;
|
|
|
.schedule-form {
|
display: flex;
|
flex: 1;
|
width: 98%;
|
padding: 0px 1%;
|
flex-direction: column;
|
overflow: auto;
|
}
|
|
.uni-panel-body {
|
display: flex;
|
flex-direction: column;
|
margin: 8px 12px;
|
padding: 4px 4px;
|
border-radius: 8px;
|
background-color: #fff;
|
}
|
|
.uni-panel-h {
|
display: flex;
|
flex-direction: row !important;
|
align-items: center !important;
|
margin: 5px 8px 8px 8px;
|
font-size: 14px;
|
}
|
|
.uni-panel-h2 {
|
display: flex;
|
flex-direction: row !important;
|
align-items: center !important;
|
margin: 5px 0px 8px 0px;
|
font-size: 14px;
|
}
|
|
.uni-panel-date-content {
|
display: flex;
|
flex-direction: column !important;
|
margin: 5px 8px 8px 8px;
|
font-size: 14px;
|
}
|
|
.uni-panel-c {
|
display: flex;
|
margin: 4px 8px 4px 8px;
|
font-size: 14px;
|
}
|
|
.uni-panel-ico {
|
font-size: 20px;
|
padding-right: 4px;
|
margin-right: 8px;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.uni-panel-ico-right {
|
font-size: 16px;
|
padding-left: 5px;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.uni-panel-down-arrow {
|
margin-left: 8px;
|
margin-top: 5px;
|
border: 7px solid #ffffff;
|
border-color: transparent;
|
border-top-color: #000000
|
}
|
|
.uni-panel-body2 {
|
display: flex;
|
|
flex-direction: row;
|
padding: 5px 8px;
|
margin: 1px 8px;
|
border-radius: 18px;
|
border: 1px solid #dfdfdf;
|
}
|
|
.uni-panel-left {
|
display: flex;
|
flex-direction: column;
|
width: 20px;
|
margin: 0px 5px;
|
}
|
|
.uni-panel-body3 {
|
flex: 1;
|
display: flex;
|
flex-direction: row;
|
}
|
|
.uni-panel-body4 {
|
flex: 1;
|
display: flex;
|
flex-direction: column;
|
}
|
|
.uni-panel-time {
|
display: flex;
|
width: 64;
|
height: 20px;
|
}
|
|
.uni-panel-time2 {
|
display: flex;
|
width: 84;
|
height: 16px;
|
margin-left: 5px;
|
border: 1px solid #bfbfbf;
|
padding: 5px 12px 8px;
|
border-radius: 5px;
|
}
|
|
.uni-panel-radius {
|
display: flex;
|
margin: 2px 8px 2px 2px;
|
width: 16px;
|
height: 16px;
|
border-radius: 10px;
|
background-color: #3a87ad;
|
}
|
|
.uni-panel-radius2 {
|
display: flex;
|
margin: 2px 8px 2px 2px;
|
width: 16px;
|
height: 16px;
|
border-radius: 5px;
|
background-color: #3a87ad;
|
}
|
|
.uni-panel-text {
|
text-align: center;
|
}
|
|
.uni-panel-text-right {
|
text-align: right;
|
}
|
|
.uni-panel-bottom {
|
width: 98%;
|
padding: 0px 1%;
|
z-index: 11;
|
padding-top: 8px;
|
padding-bottom: 15px;
|
display: flex;
|
flex-direction: row;
|
}
|
|
.uni-panel-button {
|
flex: 1;
|
border-radius: 12px;
|
margin: 4px 12px;
|
/* background-color: #fff; */
|
flex-direction: row;
|
background-color: #00aaff;
|
color: #fff;
|
// padding: 12px 80rpx;
|
}
|
|
.uni-panel-button text {
|
justify-content: center;
|
align-items: center;
|
}
|
|
.popup-content {
|
display: flex;
|
justify-content: center;
|
flex-direction: column;
|
background-color: transparent;
|
}
|
|
.popup-content-menu {
|
margin-top: 84px;
|
margin-left: 32px;
|
width: 100px;
|
align-items: center;
|
justify-content: center;
|
flex-direction: column;
|
background-color: #fff;
|
border-radius: 5px;
|
border: 1px solid gray;
|
}
|
|
.popup-content-menu2 {
|
margin-top: 84px;
|
margin-left: 150px;
|
width: 120px;
|
align-items: center;
|
justify-content: center;
|
flex-direction: column;
|
background-color: #fff;
|
border-radius: 5px;
|
border: 1px solid gray;
|
}
|
|
.popup-content-menu-item {
|
display: flex;
|
flex-wrap: nowrap;
|
flex-direction: row !important;
|
align-items: center;
|
padding: 4px 8px;
|
font-size: 14px;
|
}
|
|
.uni-list-cell-pd {
|
padding: 11px 15px;
|
}
|
|
.uni-list-cell {
|
position: relative;
|
display: flex;
|
flex-direction: row;
|
font-size: 14px;
|
// justify-content: space-between;
|
align-items: center;
|
}
|
|
.stretch {
|
transform: scale(1, 3);
|
transform-origin: 0 0;
|
}
|
}
|
</style>
|