createOrEditSchedule.js 24 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
import create from 'dd-store'
import exampleStore from '/stores/exampleStore'
import { deleteSchedule, modifySchedule, addSchedule, getUserScheduleInTime, getHomeUserSchedule, getScheduleDetail } from '../../api/request.js'
import { throttle } from './../../utils/utils.js'
create.Page({
  store: exampleStore,
  useAll: true,
  data: {
    modifyModel: 'only',
    deleteModel: 'only',
    timeStaus: '',
    isShowModal: false,
    title: '',
    time1: '',
    week1: '',
    time2: '',
    week2: '',
    propsTime: '',
    weekList: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
    repeatWeek: ['每周一重复', '每周二重复', '每周三重复', '每周四重复', '每周五重复', '每周六重复', '每周日重复'],
    scheduleItem: '', // 日程ID 从详情页面传过来
    buttonText: '立即创建',
    // 人员增量信息 减量信息 只有在编辑的时候使用
    addUserList: [],
    deleteUserList: [],
    originUserList: [],
    requireUsers: [],
    requireUsersInfo: [],
    organizer: '',
    isRepeat: '',
    permissions: '',
    showPage: false,
    popupWindowList: [
      { id: 0, text: '向参会人发送通知?' },
      { id: 1, text: '发送' },
      { id: 2, text: '不发送' },
      { id: 3, text: '继续编辑' },
    ],
    needNotice: '',
    isShowPopupWindowList: false,
    isClicked: false,
    showList: false,
    showItem: [],
    type: ''
  },
  onLoad(event) {
    let index = new Date().getDay()
    let title = `${getApp().globalData.name}创建的会议`
    this.data.repeatWeek = this.data.repeatWeek[index - 1]
    this.store.data.remark = ''
    this.store.data.recurrenceModel = {
      model: "no_repeat"
    }
    this.store.data.repeatable = 0
    this.store.data.locationName = ''
    this.store.data.roomId = ''
    this.store.data.conflictPeople = []
    this.store.data.participatorList = []
    this.store.data.locationName = ''
    this.store.data.participatorUserId = [getApp().globalData.userid]
    this.update()
    var date = new Date();
    var y = date.getFullYear();
    var m = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1);//获取当前月份的日期,不足10补0
    var d = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();//获取当前几号,不足10补0
    var weekList = this.data.weekList
    var w = weekList[date.getDay()];
    var h = date.getHours()
    var min = date.getMinutes();
    let DateTimeStr = `${y}/${m}/${d} ${min < 30 ? h < 10 ? '0' + h : h : (h + 1) < 10 ? '0' + (h + 1) : h + 1}:${min < 30 ? '30' : '00'}:00`
    let date1 = new Date(DateTimeStr)
    let date2 = new Date(DateTimeStr);
    date2.setMinutes(date2.getMinutes() + 30)
    this.setData({
      time1: `${date1.getFullYear()}/${date1.getMonth() < 9 ? '0' + (date1.getMonth() + 1) : date1.getMonth() + 1}/${date1.getDate() < 10 ? "0" + date1.getDate() : date1.getDate()} ${date1.getHours() < 10 ? '0' + date1.getHours() : date1.getHours()}:${date1.getMinutes() < 10 ? '0' + date1.getMinutes() : date1.getMinutes()}:00`,
      time2: `${date2.getFullYear()}/${date2.getMonth() < 9 ? '0' + (date2.getMonth() + 1) : date2.getMonth() + 1}/${date2.getDate() < 10 ? "0" + date2.getDate() : date2.getDate()} ${date2.getHours() < 10 ? '0' + date2.getHours() : date2.getHours()}:${date2.getMinutes() < 10 ? '0' + date2.getMinutes() : date2.getMinutes()}:00`,
      week1: w,
      week2: w,
      type: event.type,
      permissions: getApp().globalData.userid,
      repeatWeek: this.data.repeatWeek,
      title: title
    })
    if (!!event.scheduleItem) {
      let scheduleItem = JSON.parse(event.scheduleItem)
      dd.setNavigationBar({
        title: '编辑会议'
      })
      this.setData({
        buttonText: '保存编辑',
        scheduleItem: scheduleItem
      })
      this.getScheduleInfo()
      this.update()
    } else {
      dd.setNavigationBar({
        title: '创建会议'
      })
      this.store.data.startTime = this.data.time1
      this.store.data.endTime = this.data.time2
      this.store.data.aheadTimes = [15]
      this.update()
      setTimeout(() => {
        this.setData({
          showPage: true
        })
      }, 300)
    }
  },
  onShow() {
    const _that = this
    _that.conflict()
    _that.arrayPoor(_that.data.originUserList, _that.store.data.participatorList)
    setTimeout(function () {
      _that.update()
    }, 100)
    if (this.store.data.startTime && this.store.data.endTime) {
      var weekList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
      var date1 = new Date(this.store.data.startTime.replace(/-/g, '/'));
      var date2 = new Date(this.store.data.endTime.replace(/-/g, '/'));
      this.setData({
        time1: this.store.data.startTime.replace(/-/g, '/'),
        time2: this.store.data.endTime.replace(/-/g, '/'),
        week1: weekList[date1.getDay()],
        week2: weekList[date2.getDay()]
      })
    }
  },
  // 选择时间
  selectTime(event) {
    this.setData({
      timeStaus: event.target.dataset.timeStaus,
      isShowModal: true,
      propsTime: event.target.dataset.timeStaus == 0 ? this.data.time1 : this.data.time2
    })
  },
  // 选择时间组件回调
  changeSelectTime(e) {
    let that = this
    let timeStr = e.status === 1 ? e.time.substr(0, 16) : ''
    if (e.status === 1) {
      var date1 = new Date(timeStr.substr(0, 16));
      var weekList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
      var w1 = weekList[date1.getDay()];
      if (this.data.timeStaus == 0) {
        if (new Date(timeStr).getTime() > new Date(this.data.time2).getTime()) {
          var date = new Date(timeStr);
          date.setMinutes(date.getMinutes() + 30)
          var y = date.getFullYear();
          var m = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1);//获取当前月份的日期,不足10补0
          var d = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();//获取当前几号,不足10补0
          var w2 = weekList[date.getDay()];
          var h = date.getHours()
          var min = date.getMinutes();
          this.setData({
            time1: `${timeStr}:00`,
            time2: `${y}/${m}/${d} ${h < 10 ? "0" + date.getHours() : date.getHours()}:${min < 10 ? "0" + min : min}:00`,
            isShowModal: false,
            week1: w1,
            week2: w2,
            timeStaus: ''
          }, () => {
            that.store.data.startTime = that.data.time1
            that.store.data.endTime = that.data.time2
            that.conflict()
          })
        } else {
          this.setData({
            time1: `${timeStr}:00`,
            isShowModal: false,
            week1: w1,
            timeStaus: ''
          }, () => {
            that.store.data.startTime = that.data.time1
            that.store.data.endTime = that.data.time2
            that.conflict()
          })
        }
      } else {
        if (new Date(timeStr).getTime() < new Date(this.data.time1).getTime() || (new Date(timeStr).getTime() == new Date(this.data.time1).getTime())) {
          
          dd.alert({
            title: '提示',
            content: '会议结束时间不能小于等于开始时间',
            buttonText: '我知道了',
            success: () => {
            },
          });
        } else {
          this.setData({
            time2: `${timeStr}:00`,
            isShowModal: false,
            week2: w1,
            timeStaus: ''
          }, () => {
            that.store.data.startTime = that.data.time1
            that.store.data.endTime = that.data.time2
            that.conflict()
          })
        }
      }
    } else {
      this.setData({
        isShowModal: false,
        timeStaus: ''
      })
    }
  },
  // input 输入事件
  getTitle(event) {
    this.setData({
      title: event.detail.value
    })
  },
  // 添加参会人
  addParticipants() {
    const _that = this
    let require = []
    let select = []
    if (!this.data.scheduleItem || this.data.organizer === getApp().globalData.userid) {
      select = this.store.data.participatorUserId
      require = [getApp().globalData.userid]
      if (!!select.length) {
        select.forEach((item, index) => {
          if (item.userId == getApp().globalData.userid) {
            select.splice(index, 1)
          }
        })
      }
    } else {
      select = [...this.store.data.participatorUserId]
      require = [...this.data.requireUsers]
    }
    select = _that.selectedelRequired(require, select).pickedUsers
    dd.complexChoose({
      title: "选择参会人",            //标题
      multiple: true,            //是否多选
      pickedUsers: select, //已选用户
      requiredUsers: require,            //必选用户(不可取消选中状态)
      responseUserOnly: true,        //返回人,或者返回人和部门
      success: function (res) {
        if (!_that.data.scheduleItem || _that.data.organizer === getApp().globalData.userid) {
          _that.store.data.participatorList = []
          _that.store.data.participatorUserId = []
          _that.store.data.participatorList.push({ userId: getApp().globalData.userid, username: getApp().globalData.name, headUrl: getApp().globalData.avatar })
          _that.store.data.participatorUserId.push(getApp().globalData.userid)
          res.users.forEach((item, index) => {
            _that.store.data.participatorList.push({ userId: item.userId, username: item.name, headUrl: item.avatar })
            _that.store.data.participatorUserId.push(item.userId)
          })
        } else {
          _that.store.data.participatorList = []
          _that.store.data.participatorUserId = []
          _that.data.requireUsersInfo.forEach((item, index) => {
            _that.store.data.participatorList.push({ userId: item.userId, username: item.username, headUrl: item.headUrl })
            _that.store.data.participatorUserId.push(item.userId)
          })
          res.users.forEach((item, index) => {
            _that.store.data.participatorList.push({ userId: item.userId, username: item.name, headUrl: item.avatar })
            _that.store.data.participatorUserId.push(item.userId)
          })
        }
        _that.store.data.participatorList = _that.setArrary(_that.store.data.participatorList)
        _that.store.data.participatorUserId = [...new Set(_that.store.data.participatorUserId)]
        _that.update()
        _that.conflict()
        _that.arrayPoor(_that.data.originUserList, _that.store.data.participatorList)
      },
      fail: function (err) {
      }
    })
  },
  // 跳转下一页
  nextPage(event) {
    let time = {
      time1: this.data.time1,
      time2: this.data.time2
    }
    switch (event.target.dataset.nextPage) {
      case 'participantsDetail':
        dd.navigateTo({ url: `./../participantsDetail/participantsDetail?scheduleItem=${JSON.stringify(this.data.scheduleItem)}&organizer=${this.data.organizer}&requireUsers=${JSON.stringify(this.data.requireUsers)}&requireUsersInfo=${JSON.stringify(this.data.requireUsersInfo)}` })
        break;
      case 'place':
        this.store.data.startTime = this.data.time1
        this.store.data.endTime = this.data.time2
        this.update()
        dd.navigateTo({ url: './../place/place' })
        break;
      case 'remind':
        dd.navigateTo({ url: './../remind/remind' })
        break;
      case 'repeatMechanism':
        dd.navigateTo({ url: './../repeatMechanism/repeatMechanism' })
        break;
      case 'addRemark':
        dd.navigateTo({ url: './../addRemark/addRemark' })
        break;
    }
  },
  // 数组去重
  setArrary(arr, userId) {
    let containt = {}
    for (let x of arr) {
      containt['id' + x.userId] = x
    }
    return Object.values(containt)
  },
  // 获取两年后的今天
  getTwoYearToday() {
    let date = new Date()
    date.setYear(date.getFullYear() + 2)
    let year = date.getFullYear();
    let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
    let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
    return year + '-' + month + '-' + day
  },
  resetStore() {
    this.store.data = {
      participatorList: [], // 参会人列表
      locationName: '',
      conflictPeople: [],
      participatorUserId: [], // 参会人的userId
      userList: [],
      // 重复 重复机制
      repeatable: 0,
      recurrenceModel: {
        model: "no_repeat",
      },
      editList: [{ icon: 'icondingwei', text: '地点' }, { icon: 'iconhuiqiantixing', text: '提醒' }, { icon: 'iconchongfu', text: '重复' }, { icon: 'icondidianmiaoshu', text: '描述' }, { icon: 'iconshanchu', text: '删除' }],
      remark: '', // 会议描述
      aheadTimes: [],
      requireUserList: [],
      startTime: '',
      endTime: '',
      roomId: ''
    }
    this.update()
  },
  // 保存
  saveCreate(e) {
    if (!!this.data.scheduleItem) {
      if (this.store.data.recurrenceModel.forever == '1') {
        this.store.data.recurrenceModel.terminateTime = this.getTwoYearToday();
        this.update()
      }
      let data = {
        shcheduleType: 'common',
        deleteUserList: this.data.deleteUserList,
        addUserList: this.data.addUserList,
        modifyModel: this.data.modifyModel,
        planDate: this.data.scheduleItem.planDate,
        title: this.data.title || `${getApp().globalData.name}创建的会议`,
        scheduleId: this.data.scheduleItem.id,
        templateId: this.data.scheduleItem.scheduleTemplateId,
        location: {
          longitude: '10',
          latitude: '10',
          locationName: this.store.data.locationName || ''
        },
        startTime: `${this.data.time1.replace(/\//g, "-")}`,
        endTime: `${this.data.time2.replace(/\//g, '-')}`,
        scheduleType: this.store.data.roomId ? 'meeting' : 'common',
        noticeType: 'dd_notice',
        participatorList: !!this.store.data.participatorList.length ? this.store.data.participatorList : [{ userId: getApp().globalData.userid, username: getApp().globalData.name, headUrl: getApp().globalData.avatar }],
        repeatable: this.store.data.repeatable,
        aheadTimes: this.store.data.aheadTimes,
        recurrenceModel: this.store.data.recurrenceModel,
        meetingRoomId: this.store.data.roomId,
        remark: this.store.data.remark,
        needNotice: this.data.needNotice
      }
      this.resetStore()
      modifySchedule(data).then(res => {
        console.log(JSON.stringify(res))
        dd.navigateBack({
          delta: 2
        })
      })

    } else {
      let data = {
        title: this.data.title || `${getApp().globalData.name}创建的会议`,
        location: {
          longitude: '10',
          latitude: '10',
          locationName: this.store.data.locationName || ''
        },
        startTime: `${this.data.time1.replace(/\//g, "-")}`,
        endTime: `${this.data.time2.replace(/\//g, '-')}`,
        scheduleType: this.store.data.roomId ? 'meeting' : 'common',
        noticeType: 'dd_notice',
        participatorList: !!this.store.data.participatorList.length ? this.store.data.participatorList : [{ userId: getApp().globalData.userid, username: getApp().globalData.name, headUrl: getApp().globalData.avatar }],
        repeatable: this.store.data.repeatable,
        aheadTimes: this.store.data.aheadTimes,
        recurrenceModel: this.store.data.recurrenceModel,
        meetingRoomId: this.store.data.roomId,
        needNotice: this.data.needNotice
      }
      addSchedule(data).then(res => {
        dd.navigateBack({
          delta: 1
        })
      })
    }
  },
  // 关闭编辑项
  closeEditList(event) {
    switch (event.target.dataset.icon) {
      case 'iconchongfu':
        this.store.data.repeatable = 0
        this.store.data.recurrenceModel = {
          model: "no_repeat"
        }
        break;
      case 'icondidianmiaoshu':
        this.store.data.remark = ''
        break;
      case 'iconhuiqiantixing':
        this.store.data.aheadTimes = []
        break;
      case 'icondingwei':
        this.store.data.locationName = null
        this.store.data.roomId = null
        break;
    }
    this.update()
  },
  // 会议冲突
  conflict() {
    // this.store.data.conflictPeople = []
    let conflictPeople = []
    let data = {
      startTime: `${this.data.time1.replace(/\//g, "-")}`,
      endTime: `${this.data.time2.replace(/\//g, "-")}`,
      userIds: this.store.data.participatorUserId
    }
    getUserScheduleInTime(data).then(res => {
      for (let value in res.data.data) {
        if (!!this.data.scheduleItem) {
          if (res.data.data[value].length > 1) {
            conflictPeople.push(value)
          }
        } else {
          if (res.data.data[value].length > 0) {
            conflictPeople.push(value)
          }
        }
      }
      this.store.data.conflictPeople = conflictPeople
      this.update()
    })
  },
  // 编辑时获取详情页内容
  getScheduleInfo() {
    let that = this
    let data = {
      id: this.data.scheduleItem.id,
      planDate: this.data.scheduleItem.planDate,
      templateId: this.data.scheduleItem.scheduleTemplateId
    }
    getScheduleDetail(data).then(res => {
      let participatorUserId = []
      let participatorList = []
      res.data.data.userList.forEach((item, index) => {
        participatorUserId.push(item.participator.userId)
        participatorList.push(item.participator)
      })
      this.store.data.locationName = res.data.data.location.locationName
      this.store.data.roomId = res.data.data.meetingRoomId
      this.store.data.repeatable = res.data.data.repeatable
      this.store.data.aheadTimes = res.data.data.aheadTimes
      this.store.data.participatorUserId = participatorUserId
      this.store.data.requireUserList = participatorUserId
      this.store.data.participatorList = participatorList
      this.store.data.remark = res.data.data.remark || ''
      this.store.data.recurrenceModel = res.data.data.recurrenceModel || { model: 'no-repeat' }
      this.store.data.startTime = res.data.data.startTime
      this.store.data.endTime = res.data.data.endTime
      this.setData({
        isRepeat: res.data.data.repeatable,
        organizer: res.data.data.organizer,
        requireUsersInfo: participatorList,
        requireUsers: participatorUserId,
        originUserList: [...participatorList],
        title: res.data.data.title,
        time1: res.data.data.startTime.replace(/-/g, '/'),
        time2: res.data.data.endTime.replace(/-/g, '/'),
        week1: that.data.weekList[new Date(res.data.data.startTime.replace(/-/g, "/")).getDay()],
        week2: that.data.weekList[new Date(res.data.data.endTime.replace(/-/g, "/")).getDay()],
      })
      this.update()
      setTimeout(() => {
        this.setData({
          showPage: true
        })
      }, 300)
      this.conflict()
    })
  },
  // 编辑日程
  editSchedule: throttle(function (event) {
    switch (event.target.dataset.icon) {
      case 'iconchongfu':
        dd.navigateTo({ url: `./../repeatMechanism/repeatMechanism` })
        break;
      case 'icondidianmiaoshu':
        dd.navigateTo({ url: './../addRemark/addRemark' })
        break;
      case 'iconhuiqiantixing':
        dd.navigateTo({ url: './../remind/remind' })
        break;
      case 'icondingwei':
        this.store.data.startTime = this.data.time1;
        this.store.data.endTime = this.data.time2;
        this.update()
        dd.navigateTo({ url: './../place/place' })
        break;
      case 'iconshanchu':
        let identify = 'major'
        if (!!this.data.scheduleItem) {
          if (this.data.organizer == this.data.permissions) {
            identify = 'major'
          } else {
            identify = 'secondary'
          }
        }
        let data = {
          scheduleId: this.data.scheduleItem.id,
          identify: identify,
          deleteModel: 'only'
        }
        dd.confirm({
          title: '删除会议',
          content: '确认删除会议吗?',
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          success: (success) => {
            if (!!success.confirm) {
              deleteSchedule(data).then(res => {
                dd.navigateBack({
                  delta: 2
                })
              })
            }
          }
        })
        break;
    }
  }, 1000),
  // 选择终止时间
  selectTerminal() {
    dd.navigateTo(({ url: `./../repetitionTime/repetitionTime` }))
  },
  // 数组取差值 原先的数组与现在的比较 增加与减少
  arrayPoor(origin, now) {
    let originMap = new Map()
    let nowMap = new Map()
    let add = []
    let del = []
    for (let x of origin) {
      originMap.set(x.userId, x)
    }
    for (let x of now) {
      nowMap.set(x.userId, x)
      let status1 = originMap.get(x.userId)
      if (!status1) {
        add.push(x)
      }
    }
    for (let x of origin) {
      let status2 = nowMap.get(x.userId)
      if (!status2) {
        del.push(x)
      }
    }
    this.setData({
      addUserList: add,
      deleteUserList: del
    })
  },
  // 保存重复日程
  saveRepeat(event) {
    let id = event.target.dataset.item.id
    let modifyModel = ''
    if (id == 0) {
      modifyModel = 'only'
    } else if (id == 1) {
      modifyModel = 'future'
    } else {
      modifyModel = 'all'
    }
    this.setData({
      modifyModel: modifyModel,
      showList: false
    })
    this.showModel()
  },
  // 删除重复日程
  deleteRepeatSchedule(event) {
    let id = event.target.dataset.item.id
    let deleteModel = ''
    let identify = 'major'
    if (!!this.data.scheduleItem) {
      if (this.data.organizer == this.data.permissions) {
        identify = 'major'
      } else {
        identify = 'secondary'
      }
    }
    if (id == 0) {
      deleteModel = 'only';
    } else if (id == 1) {
      deleteModel = 'future';
    } else {
      deleteModel = 'all';
    }
    this.setData({
      deleteModel: deleteModel,
      showList: false
    })
    let data = {
      planDate: this.data.scheduleItem.planDate,
      templateId: this.data.scheduleItem.scheduleTemplateId,
      identify: identify,
      deleteModel: deleteModel
    }
    deleteSchedule(data).then(res => {
      dd.navigateBack({
        delta: 2
      })
    })
  },
  // 已选用户去中去掉必选用户
  selectedelRequired(req, pic) {
    for (let i = 0; i < req.length; i++) {
      for (let m = 0; m < pic.length; m++) {
        if (req[i] == pic[m]) {
          pic.splice(m, 1)
          m--;
        }
      }
    }
    return {
      requiredUsers: req,
      pickedUsers: pic
    }
  },
  // 选择发送不发送通知
  selectSend(event) {
    let needNotice = ''
    let isShowPopupWindowList = false
    switch (event.target.dataset.item.id) {
      case 1:
        needNotice = '1'
        isShowPopupWindowList = false
        this.setData({
          needNotice: needNotice,
          isShowPopupWindowList: isShowPopupWindowList
        })
        this.saveCreate()
        break;
      case 2:
        needNotice = ''
        isShowPopupWindowList = false
        this.setData({
          needNotice: needNotice,
          isShowPopupWindowList: isShowPopupWindowList
        })
        this.saveCreate()
        break;
      case 3:
        needNotice = ''
        isShowPopupWindowList = false
        break;
    }
    this.setData({
      needNotice: needNotice,
      isShowPopupWindowList: isShowPopupWindowList
    })
  },
  // 展示弹窗
  showModel: throttle(function (e) {
    if (!!this.data.scheduleItem && this.store.data.userList.length > 1) {
      this.setData({
        isShowPopupWindowList: true
      })
    }
    else {
      this.saveCreate()
    }
  }, 1000),
  // 展示选择列表
  showList(event) {
    let type = event.target.dataset.type
    let showItem = []
    // 点击参加按钮
    if (type == "save") {
      showItem = [{ id: 0, content: '仅保存本次' }, { id: 1, content: '保存以后' }, { id: 2, content: '保存所有' }]
    }
    // 点击不参加按钮
    else {
      showItem = [{ id: 0, content: '仅删除本次' }, { id: 1, content: '删除以后' }, { id: 2, content: '删除所有' }]
    }
    this.setData({
      showItem: showItem,
      showList: true,
      type: type
    })
    // this.showModel()
  },
  // listHide
  listHide() {
    this.setData({
      showList: false
    })
  }
});