|
|
@@ -1,49 +1,127 @@
|
|
|
+const _Http = getApp().globalData.http
|
|
|
Page({
|
|
|
data: {
|
|
|
- currentMonth: '2025-12',
|
|
|
- selectedDate: '2025-12-15',
|
|
|
viewMode: 'month', // month / week
|
|
|
-
|
|
|
- tasks: [
|
|
|
- { id: 1, title: '参加扬州大学附属医院产品推介会', date: '2025-12-15' },
|
|
|
- { id: 2, title: '跟台上海天伦医院手术3场', date: '2025-12-15' }
|
|
|
- ],
|
|
|
- records: [
|
|
|
- { id: 1, title: '参加扬州大学附属医院产品推介会', date: '2025-12-15' },
|
|
|
- { id: 2, title: '跟台上海天伦医院手术3场', date: '2025-12-15' }
|
|
|
- ],
|
|
|
currentDate: '', // 当前选择的日期
|
|
|
currentYear: '', // 当前显示的年份
|
|
|
currentMonth: '', // 当前显示的月份
|
|
|
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
|
|
|
days: [], // 当前月份的日期数组
|
|
|
selectedDate: '', // 格式:'2025-04-05'
|
|
|
-
|
|
|
+ prevList: [],
|
|
|
+ currentList: [],
|
|
|
+ nextList: [],
|
|
|
+ userid: '',
|
|
|
+ prev_year: '',
|
|
|
+ prev_month: '',
|
|
|
+ next_year: '',
|
|
|
+ next_month: '',
|
|
|
+ taskData: [],
|
|
|
+ followData: [],
|
|
|
+ nowday: '',
|
|
|
+ types: [{
|
|
|
+ value: '新建任务',
|
|
|
+ name: '新建任务',
|
|
|
+ }, {
|
|
|
+ value: '新建跟进',
|
|
|
+ name: '新建跟进',
|
|
|
+ }],
|
|
|
+ actionShow: false,
|
|
|
+ canlendar_name:'我',
|
|
|
+ showFiltrate:false
|
|
|
},
|
|
|
|
|
|
onLoad() {
|
|
|
- // this.generateCalendar();
|
|
|
- // this.updateCalendar(new Date());
|
|
|
const now = new Date();
|
|
|
const year = now.getFullYear();
|
|
|
const month = now.getMonth() + 1; // 月份从 0 开始
|
|
|
const today = this.formatDate(now);
|
|
|
+ const prev_year = month == 1 ? year - 1 : year
|
|
|
+ const prev_month = month == 1 ? 12 : month - 1
|
|
|
+ const next_year = month == 12 ? year + 1 : year
|
|
|
+ const next_month = month == 12 ? 1 : month + 1
|
|
|
+
|
|
|
+ const userid = wx.getStorageSync('userMsg').userid
|
|
|
|
|
|
this.setData({
|
|
|
- selectedDate: today
|
|
|
+ selectedDate: today,
|
|
|
+ userid: userid,
|
|
|
+ currentYear: year,
|
|
|
+ currentMonth: month,
|
|
|
+ prev_year,
|
|
|
+ prev_month,
|
|
|
+ next_year,
|
|
|
+ next_month,
|
|
|
+ nowday: today
|
|
|
});
|
|
|
+ // this.prevData()
|
|
|
|
|
|
- this.renderCalendar(year, month);
|
|
|
},
|
|
|
- // 格式化日期为 YYYY-MM-DD
|
|
|
- formatDate(date) {
|
|
|
+ async prevData() {
|
|
|
+ console.log('prevData')
|
|
|
+ let prevList = []
|
|
|
+ _Http.basic({
|
|
|
+ "id": 2025122210193402,
|
|
|
+ "content": {
|
|
|
+ "year": this.data.prev_year,
|
|
|
+ "month": this.data.prev_month,
|
|
|
+ "taskUserid": this.data.userid,
|
|
|
+ },
|
|
|
+ }).then(res => {
|
|
|
+ prevList = res.data
|
|
|
+ console.log(prevList)
|
|
|
+ this.currentData()
|
|
|
+ this.setData({
|
|
|
+ prevList
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async currentData() {
|
|
|
+ let currentList = []
|
|
|
+ _Http.basic({
|
|
|
+ "id": 2025122210193402,
|
|
|
+ "content": {
|
|
|
+ "year": this.data.currentYear,
|
|
|
+ "month": this.data.currentMonth,
|
|
|
+ "taskUserid": this.data.userid,
|
|
|
+ },
|
|
|
+ }).then(res => {
|
|
|
+ currentList = res.data
|
|
|
+ console.log(currentList)
|
|
|
+ this.nextData()
|
|
|
+ this.setData({
|
|
|
+ currentList
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async nextData() {
|
|
|
+ let nextList = []
|
|
|
+ _Http.basic({
|
|
|
+ "id": 2025122210193402,
|
|
|
+ "content": {
|
|
|
+ "year": this.data.next_year,
|
|
|
+ "month": this.data.next_month,
|
|
|
+ "taskUserid": this.data.userid,
|
|
|
+ },
|
|
|
+ }).then(res => {
|
|
|
+ nextList = res.data
|
|
|
+ console.log(nextList)
|
|
|
+ this.setData({
|
|
|
+ nextList
|
|
|
+ })
|
|
|
+ this.renderCalendar(this.data.currentYear, this.data.currentMonth);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 格式化日期为 YYYY-MM-DD
|
|
|
+ formatDate(date) {
|
|
|
const y = date.getFullYear();
|
|
|
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
const d = String(date.getDate()).padStart(2, '0');
|
|
|
return `${y}-${m}-${d}`;
|
|
|
},
|
|
|
// 渲染日历
|
|
|
- renderCalendar(year, month) {
|
|
|
+ async renderCalendar(year, month) {
|
|
|
+ console.log(this.data.selectedDate, '选择日期2025')
|
|
|
const today = this.formatDate(new Date());
|
|
|
const selected = this.data.selectedDate;
|
|
|
|
|
|
@@ -57,43 +135,49 @@ Page({
|
|
|
for (let i = firstDay - 1; i >= 0; i--) {
|
|
|
const day = prevMonthDays - i;
|
|
|
const fullDate = this.formatDate(new Date(year, month - 2, day));
|
|
|
+ // 默认值
|
|
|
+ let hasTask = false;
|
|
|
+ let hasFollow = false;
|
|
|
+
|
|
|
+ // 如果 daysData 包含当前日期,则更新 hasTask 和 hasFollow
|
|
|
+ if (this.data.prevList[fullDate]) {
|
|
|
+ hasTask = Array.isArray(this.data.prevList[fullDate].task) && this.data.prevList[fullDate].task.length > 0;
|
|
|
+ hasFollow = Array.isArray(this.data.prevList[fullDate].follow) && this.data.prevList[fullDate].follow.length > 0;
|
|
|
+ }
|
|
|
+ if (this.data.prevList[this.data.selectedDate]) {
|
|
|
+ this.setData({
|
|
|
+ taskData: this.data.prevList[this.data.selectedDate].task,
|
|
|
+ followData: this.data.prevList[this.data.selectedDate].follow
|
|
|
+ })
|
|
|
+ }
|
|
|
days.push({
|
|
|
day,
|
|
|
- type: 'other',
|
|
|
+ type: 'current',
|
|
|
fullDate,
|
|
|
- isToday: false,
|
|
|
- isSelected: false
|
|
|
+ isSelected: fullDate === selected,
|
|
|
+ hasTask,
|
|
|
+ hasFollow
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 本月
|
|
|
for (let i = 1; i <= daysInMonth; i++) {
|
|
|
const fullDate = this.formatDate(new Date(year, month - 1, i));
|
|
|
- const daysData = {
|
|
|
- '2026-01-06':{
|
|
|
- follow:[
|
|
|
- {followobj:'经销商'},
|
|
|
- {followobj:'临床'}
|
|
|
- ],
|
|
|
- task:[]
|
|
|
- },
|
|
|
- '2026-01-08':{
|
|
|
- follow:[
|
|
|
- {followobj:'经销商'},
|
|
|
- {followobj:'临床'}
|
|
|
- ],
|
|
|
- task:[]
|
|
|
- },
|
|
|
- }
|
|
|
// 默认值
|
|
|
- let hasTask = false;
|
|
|
- let hasFollow = false;
|
|
|
+ let hasTask = false;
|
|
|
+ let hasFollow = false;
|
|
|
|
|
|
- // 如果 daysData 包含当前日期,则更新 hasTask 和 hasFollow
|
|
|
- if (daysData[fullDate]) {
|
|
|
- hasTask = Array.isArray(daysData[fullDate].task) && daysData[fullDate].task.length > 0;
|
|
|
- hasFollow = Array.isArray(daysData[fullDate].follow) && daysData[fullDate].follow.length > 0;
|
|
|
- }
|
|
|
+ // 如果 daysData 包含当前日期,则更新 hasTask 和 hasFollow
|
|
|
+ if (this.data.currentList[fullDate]) {
|
|
|
+ hasTask = Array.isArray(this.data.currentList[fullDate].task) && this.data.currentList[fullDate].task.length > 0;
|
|
|
+ hasFollow = Array.isArray(this.data.currentList[fullDate].follow) && this.data.currentList[fullDate].follow.length > 0;
|
|
|
+ }
|
|
|
+ if (this.data.currentList[this.data.selectedDate]) {
|
|
|
+ this.setData({
|
|
|
+ taskData: this.data.currentList[this.data.selectedDate].task,
|
|
|
+ followData: this.data.currentList[this.data.selectedDate].follow
|
|
|
+ })
|
|
|
+ }
|
|
|
days.push({
|
|
|
day: i,
|
|
|
type: 'current',
|
|
|
@@ -110,121 +194,146 @@ Page({
|
|
|
const remaining = totalCells - days.length;
|
|
|
for (let i = 1; i <= remaining; i++) {
|
|
|
const fullDate = this.formatDate(new Date(year, month, i));
|
|
|
+ // 默认值
|
|
|
+ let hasTask = false;
|
|
|
+ let hasFollow = false;
|
|
|
+
|
|
|
+ // 如果 daysData 包含当前日期,则更新 hasTask 和 hasFollow
|
|
|
+ if (this.data.nextList[fullDate]) {
|
|
|
+ hasTask = Array.isArray(this.data.nextList[fullDate].task) && this.data.nextList[fullDate].task.length > 0;
|
|
|
+ hasFollow = Array.isArray(this.data.nextList[fullDate].follow) && this.data.nextList[fullDate].follow.length > 0;
|
|
|
+ }
|
|
|
+ if (this.data.nextList[this.data.selectedDate]) {
|
|
|
+ this.setData({
|
|
|
+ taskData: this.data.nextList[this.data.selectedDate].task,
|
|
|
+ followData: this.data.nextList[this.data.selectedDate].follow
|
|
|
+ })
|
|
|
+ }
|
|
|
days.push({
|
|
|
day: i,
|
|
|
- type: 'other',
|
|
|
+ type: 'current',
|
|
|
fullDate,
|
|
|
- isToday: false,
|
|
|
- isSelected: false
|
|
|
+ isSelected: fullDate === selected,
|
|
|
+ hasTask,
|
|
|
+ hasFollow
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+ if (!this.data.selectedDate) {
|
|
|
+ this.setData({
|
|
|
+ taskData: [],
|
|
|
+ followData: []
|
|
|
+ })
|
|
|
+ }
|
|
|
this.setData({
|
|
|
currentYear: year,
|
|
|
currentMonth: month,
|
|
|
- days
|
|
|
+ days,
|
|
|
+ today
|
|
|
});
|
|
|
},
|
|
|
// 切换月份
|
|
|
onMonthChange(e) {
|
|
|
const [year, month] = e.detail.value.split('-').map(Number);
|
|
|
- this.renderCalendar(year, month);
|
|
|
+ const prev_year = month == 1 ? year - 1 : year
|
|
|
+ const prev_month = month == 1 ? 12 : month - 1
|
|
|
+ const next_year = month == 12 ? year + 1 : year
|
|
|
+ const next_month = month == 12 ? 1 : month + 1
|
|
|
+ console.log(prev_year, prev_month, next_year, next_month)
|
|
|
+ this.setData({
|
|
|
+ selectedDate: '',
|
|
|
+ currentYear: year,
|
|
|
+ currentMonth: month,
|
|
|
+ prev_year,
|
|
|
+ prev_month,
|
|
|
+ next_year,
|
|
|
+ next_month
|
|
|
+ });
|
|
|
+ this.prevData()
|
|
|
+ // this.renderCalendar(year, month);
|
|
|
},
|
|
|
|
|
|
// 点击日期
|
|
|
onDayTap(e) {
|
|
|
- const fullDate = e.currentTarget.dataset.date;
|
|
|
- this.setData({ selectedDate: fullDate });
|
|
|
+ const fullDate = e.currentTarget.dataset.date;
|
|
|
+ this.setData({
|
|
|
+ selectedDate: fullDate
|
|
|
+ });
|
|
|
// 重新渲染以更新 isSelected
|
|
|
this.renderCalendar(this.data.currentYear, this.data.currentMonth);
|
|
|
},
|
|
|
-
|
|
|
- updateCalendar(date) {
|
|
|
- const year = date.getFullYear();
|
|
|
- const month = date.getMonth() + 1; // 获取月份(从0开始)
|
|
|
- const firstDayOfMonth = new Date(year, month - 1, 1).getDay(); // 当月第一天是星期几
|
|
|
- const totalDaysInMonth = new Date(year, month, 0).getDate(); // 当月总天数
|
|
|
-
|
|
|
- let days = [];
|
|
|
- // 添加上个月末尾的空白天数
|
|
|
- for (let i = 0; i < firstDayOfMonth; i++) {
|
|
|
- days.push({ day: '', type: 'empty' });
|
|
|
- }
|
|
|
- // 添加当月的天数
|
|
|
- for (let i = 1; i <= totalDaysInMonth; i++) {
|
|
|
- days.push({ day: i, type: 'day' });
|
|
|
- }
|
|
|
-
|
|
|
+ onShow(){
|
|
|
+ this.prevData()
|
|
|
+ },
|
|
|
+ goToday() {
|
|
|
+ // const today = new Date().toISOString().split('T')[0];
|
|
|
+ const now = new Date();
|
|
|
+ const year = now.getFullYear();
|
|
|
+ const month = now.getMonth() + 1; // 月份从 0 开始
|
|
|
+ const today = this.formatDate(now);
|
|
|
+ const prev_year = month == 1 ? year - 1 : year
|
|
|
+ const prev_month = month == 1 ? 12 : month - 1
|
|
|
+ const next_year = month == 12 ? year + 1 : year
|
|
|
+ const next_month = month == 12 ? 1 : month + 1
|
|
|
this.setData({
|
|
|
- currentDate: `${year}-${String(month).padStart(2, '0')}`,
|
|
|
+ selectedDate: today,
|
|
|
currentYear: year,
|
|
|
currentMonth: month,
|
|
|
- days: days
|
|
|
+ prev_year,
|
|
|
+ prev_month,
|
|
|
+ next_year,
|
|
|
+ next_month,
|
|
|
+ nowday: today
|
|
|
});
|
|
|
+ this.prevData()
|
|
|
},
|
|
|
-
|
|
|
- generateCalendar() {
|
|
|
- const { currentMonth } = this.data;
|
|
|
- const year = parseInt(currentMonth.split('-')[0]);
|
|
|
- const month = parseInt(currentMonth.split('-')[1]) - 1;
|
|
|
-
|
|
|
- const date = new Date(year, month, 1);
|
|
|
- const firstDay = date.getDay(); // 0=Sun, 1=Mon...
|
|
|
- const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
|
-
|
|
|
- let days = [];
|
|
|
- // 填充前面空格
|
|
|
- for (let i = 0; i < firstDay; i++) {
|
|
|
- days.push({ day: '', date: '', isCurrent: false, hasTask: false });
|
|
|
- }
|
|
|
-
|
|
|
- // 填充当月日期
|
|
|
- for (let i = 1; i <= daysInMonth; i++) {
|
|
|
- const currentDate = `${year}-${String(month + 1).padStart(2, '0')}-${String(i).padStart(2, '0')}`;
|
|
|
- const hasTask = this.data.tasks.some(t => t.date === currentDate);
|
|
|
- const isCurrent = currentDate === this.data.selectedDate;
|
|
|
-
|
|
|
- days.push({
|
|
|
- day: i,
|
|
|
- date: currentDate,
|
|
|
- isCurrent,
|
|
|
- hasTask,
|
|
|
- taskCount: this.data.tasks.filter(t => t.date === currentDate).length
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- this.setData({ days });
|
|
|
+ onSelect() {
|
|
|
+ this.setData({
|
|
|
+ actionShow: true
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
- bindDateChange(e) {
|
|
|
- // const value = e.detail.value;
|
|
|
- // this.setData({ currentMonth: value });
|
|
|
- // this.generateCalendar();
|
|
|
- const selectedDate = e.detail.value.split('-');
|
|
|
- const year = parseInt(selectedDate[0], 10);
|
|
|
- const month = parseInt(selectedDate[1], 10);
|
|
|
- this.updateCalendar(new Date(year, month - 1));
|
|
|
+ /* 选择合作协议类型 */
|
|
|
+ selectType({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ console.log(detail.value,'选择')
|
|
|
+ if (detail.value) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/prsx/calendar/task/index?select=' + this.data.selectedDate,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.onCancel();
|
|
|
},
|
|
|
-
|
|
|
- goToday() {
|
|
|
- const today = new Date().toISOString().split('T')[0];
|
|
|
- this.setData({ currentMonth: today.substring(0, 7), selectedDate: today });
|
|
|
- this.generateCalendar();
|
|
|
+ /* 取消选择合作协议类型 */
|
|
|
+ onCancel() {
|
|
|
+ this.setData({
|
|
|
+ actionShow: false
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
- switchView(e) {
|
|
|
- const mode = e.currentTarget.dataset.view;
|
|
|
- this.setData({ viewMode: mode });
|
|
|
+ filtrateShow() {
|
|
|
+ this.setData({
|
|
|
+ showFiltrate:true
|
|
|
+ })
|
|
|
+ let page = this.selectComponent("#personnel")
|
|
|
+ page.userList()
|
|
|
},
|
|
|
-
|
|
|
- onDayClick(e) {
|
|
|
- const date = e.currentTarget.dataset.date;
|
|
|
- this.setData({ selectedDate: date });
|
|
|
+ handleFilter({
|
|
|
+ detail
|
|
|
+ }){
|
|
|
+ console.log('shuchu',detail)
|
|
|
+ let page = this.selectComponent("#personnel")
|
|
|
+ console.log(page.data.result,'555')
|
|
|
+ console.log(page.data.users.active,'输出active')
|
|
|
+ this.setData({
|
|
|
+ canlendar_name:page.data.result.name,
|
|
|
+ userid:page.data.result.userid
|
|
|
+ })
|
|
|
+ this.prevData()
|
|
|
},
|
|
|
-
|
|
|
- addNew() {
|
|
|
+ taskSelect(item){
|
|
|
+ console.log('选中',item)
|
|
|
+ let data = item.currentTarget.dataset.data
|
|
|
wx.navigateTo({
|
|
|
- url: '../add/add'
|
|
|
- });
|
|
|
+ url: '/prsx/calendar/task/detail?id=' + data.sys_taskid
|
|
|
+ })
|
|
|
}
|
|
|
});
|