diff --git a/api/xFetch.js b/api/xFetch.js index 568c715..4705bbc 100644 --- a/api/xFetch.js +++ b/api/xFetch.js @@ -15,7 +15,7 @@ export default function xFetch({ url, method, data, type }) { return new Promise((resolve, rejects) => { dd.httpRequest({ headers: { - "Content-Type": "application/json;charset=UTF-8", + "Content-Type": "application/json; charset=utf-8", timeZone: timeZone[`timeZone${offSet}`], Authorization: `Bearer ${getApp().globalData.token}` }, diff --git a/components/fileList/fileList.axml b/components/fileList/fileList.axml index eb84c22..aa72d01 100644 --- a/components/fileList/fileList.axml +++ b/components/fileList/fileList.axml @@ -2,7 +2,7 @@ <view class="desc" a:if='{{fileView.remark}}'> {{fileView.remark}} </view> - <view class="file-list" a:for="{{ fileView.fileDetailList}}"> + <view class="file-list" a:for="{{ fileView.fileInfos}}"> <view class="file-box {{isCanDelete ? 'file-box-close': ''}}" catchTap="preview" data-file="{{item}}"> <view class="file-icon {{item.mimeType}}"></view> <view class="file-title"> diff --git a/components/fileList/fileList.js b/components/fileList/fileList.js index 6170b57..f01ae8c 100644 --- a/components/fileList/fileList.js +++ b/components/fileList/fileList.js @@ -38,49 +38,14 @@ create.Component({ return } const file = e.target.dataset.file - const imageType = ['jpg', 'bmp', 'png', 'gif', 'jpeg'] - previewOss(file.fileId).then(res => { - if (res.data.code === 0) { - if (imageType.includes(file.fileType)) { - dd.previewImage({ - current: 1, - urls: [res.data.data], - success: (res) => { - console.log(JSON.stringify(res)) - }, - fail: (err) => { - console.log(JSON.stringify(err)) - } - }) - } else { - openLink({ - url: res.data.data - }) - } - } + dd.previewFileInDingTalk({ + corpId: dd.corpId, + spaceId: file.spaceId, + fileId: file.fileId, + fileName: file.name, + fileSize: file.size, + fileType: file.mimeType, }) - - - - // console.log(e) - - - // const data = { - // ddUserId: getApp().globalData.userid, - // type: 'download', - // fileIds: file.fileId, - // projectName: 'MING_MEETING' - // } - // previewPermissions(data).then(res => { - // dd.previewFileInDingTalk({ - // corpId: dd.corpId, - // spaceId: res.data.data, - // fileId: file.fileId, - // fileName: file.fileName, - // fileSize: file.fileSize, - // fileType: file.fileType - // }) - // }) }, //显示操作框 showOperate(e) { diff --git a/pages/createMeeting/createMeeting.axml b/pages/createMeeting/createMeeting.axml index e094185..a059050 100644 --- a/pages/createMeeting/createMeeting.axml +++ b/pages/createMeeting/createMeeting.axml @@ -1,13 +1,14 @@ <view class="createMeeting "> + <button size="default" onTap="click" type="primary">Button</button> <!-- title remark 标题 描述 --> <view class="createTitle"> <view class="title"> - <input placeholder-class="placeholder" placeholder="{{placeholder}}" class="text" onInput="onInput" data-type="title" value="{{title}}" focus="{{false}}"/> - <view class="icon iconfont iconicon_description1" onTap="addRemark" a:if="{{!isShowRemark}}"> + <input placeholder-class="placeholder" placeholder="{{placeholder}}" class="text" onInput="handleChangeTitle" value="{{title}}" focus="{{false}}"/> + <view class="icon iconfont iconicon_description1" onTap="handleOpenRemark" a:if="{{!isShowRemark}}"> </view> </view> <view class="remark" a:if="{{isShowRemark}}"> - <input placeholder-class="placeholder" placeholder="请添加描述" class="text" onInput="onInput" data-type="remark" value="{{remark}}" focus="{{true}}" /> + <input placeholder-class="placeholder" placeholder="请添加描述" class="text" onInput="handleChangeRemark" value="{{remark}}" focus="{{true}}" /> </view> </view> <!-- $data.$data.roomId locationName 地点 --> @@ -17,13 +18,13 @@ <view class="iconicon_location1 iconfont icon {{$data.locationName ? '' : 'noValueIcon'}}" a:else> </view> <view class="placeContaint"> - <view class="noPlace" a:if="{{!$data.locationName}}" onTap="nextPage" data-nextPage="location"> + <view class="noPlace" a:if="{{!$data.locationName}}" onTap="goSelectPlace"> 添加地点 </view> - <view class="hasplace" onTap="nextPage" data-nextPage="location" a:else> + <view class="hasplace" onTap="goSelectPlace" a:else> {{$data.locationName}} </view> - <view class=" icon iconfont iconicon_close close" a:if="{{!!$data.locationName}}" data-close="location" catchTap="close"> + <view class=" icon iconfont iconicon_close close" a:if="{{!!$data.locationName}}" catchTap="handleDeletePlace"> </view> </view> </view> @@ -33,14 +34,8 @@ </view> <view class="timeContaint"> <view> - <view class="timeText" catchTap="showPopup" data-type='time'> - <text a:if="{{isAcrossDay}}"> - {{`${$data.startTime.substring(5, 7)}月${$data.startTime.substring(8, 10)}日 ${$data.startTime.substring(11, 16)}-${$data.endTime.substring(5, 7)}月${$data.endTime.substring(8, 10)}日 ${$data.endTime.substring(11, 16)}`}} - </text> - <text a:else> - {{`${$data.startTime.substring(5, 7)}月${$data.startTime.substring(8, 10)}日 ${week} ${$data.startTime.substring(11, 16)}-${$data.endTime.substring(11, 16)}`}} - </text> - <!-- 3月1日 周日 14:00-16:00 --> + <view class="timeText" catchTap="handleTime"> + {{showTime}} </view> <view class="repeatModal" a:if="{{comListData.comSelectListId !== 0}}" catchTap="showPopup" data-type='repeat'> {{comListData.repeatList[comListData.comSelectListId].text}}重复 @@ -55,7 +50,7 @@ <view class="iconicon_attender iconfont icon {{$data.participatorList.length>1 ? '' : 'noValueIcon'}}"> </view> <view class="participatorContaint"> - <view class="participatorText" a:if="{{$data.participatorList.length < 2}}" catchTap="showPopup" data-type='participator'> + <view class="participatorText" a:if="{{$data.participatorList.length < 2}}" catchTap="handleAddParticipator" data-type='participator'> 添加参会人 </view> <view class="participatorList" a:else> @@ -87,24 +82,6 @@ </view> </view> </view> - <!-- meetingWay 会议方式 --> - <view class="meetingWay"> - <view a:if="{{comListData.meetingWayModelId === null}}" class="iconicon_meet iconfont icon noValueIcon"> - </view> - <view a:else class="meetingWayImageUrl"> - <image mode="scaleToFill" src="{{comListData.meetingWayList[comListData.meetingWayModelId].imageUrl}}"/> - </view> - <view class="meetingWayContent"> - <view class="noWay" a:if="{{comListData.meetingWayModelId == null}}" catchTap="showPopup" data-type='meetingWayModel'> - 会议方式 - </view> - <view class="hasWay" a:else catchTap="showPopup" data-type='meetingWayModel'> - {{comListData.meetingWayList[comListData.meetingWayModelId].text}} - </view> - <view class=" icon iconfont iconicon_close close" a:if="{{comListData.meetingWayModelId !== null}}" data-close="meetingWayModel" catchTap="close"> - </view> - </view> - </view> <!-- 保存 --> <view class="save" onTap="addSchedule1"> <view class="button {{limitClick ? 'gray' : ''}}"> @@ -113,11 +90,10 @@ <view class="tabBarBottom" a:if="{{isIPX}}"> </view> </view> - <popup title="{{popupTitle}}" show="{{popupShow}}" mask="true" onClose="closePopup"> - <meeting-time-picker a:if="{{'time' === comType}}" onComplete="onComplete" isIPX="{{isIPX}}"></meeting-time-picker> - <hlist a:if="{{'participator' === comType}}" dataComList="{{comHListData.contactData}}" onSelectComHList="selectComHList"></hlist> - <list a:if="{{comType=='repeat'}}" dataComList="{{comType=='repeat' ? comListData.repeatList : comListData.meetingWayList}}" onComSelectList="selectComList" comSelectListId="{{comType=='repeat' ? comListData.comSelectListId : comListData.meetingWayModelId}}" iconType="{{comListData.iconType}}"> + <popup title="{{popup.title}}" show="{{popup.show}}" mask="{{popup.mask}}" onClose="closePopup"> + <meeting-time-picker a:if="{{'time' === popup.type}}" onComplete="onComplete" isIPX="{{isIPX}}"></meeting-time-picker> + <hlist a:if="{{'participator' === popup.type}}" dataComList="{{comHListData.contactData}}" onSelectComHList="selectComHList"></hlist> + <list a:if="{{popup.type=='repeat'}}" dataComList="{{comType=='repeat' ? comListData.repeatList : comListData.meetingWayList}}" onComSelectList="selectComList" comSelectListId="{{comType=='repeat' ? comListData.comSelectListId : comListData.meetingWayModelId}}" iconType="{{comListData.iconType}}"> </list> - <list a:if="{{comType == 'meetingWayModel'}}" dataComList="{{relatedAppPlatform.includes('zoom') ? comListData.meetingWayList: [comListData.meetingWayList[0]] }}" onComSelectList="selectComList" comSelectListId="{{comListData.meetingWayModelId}}" iconType="{{comListData.iconType}}"></list> </popup> </view> \ No newline at end of file diff --git a/pages/createMeeting/createMeeting.js b/pages/createMeeting/createMeeting.js index bb4e4aa..65f26c3 100644 --- a/pages/createMeeting/createMeeting.js +++ b/pages/createMeeting/createMeeting.js @@ -1,5 +1,5 @@ -import { addSchedule, getUserScheduleInTime, getDeviceBySn } from '../../api/request.js' -import { throttle, getInterTime } from './../../utils/utils.js' +import { addSchedule, updateMeetingTask, getUserScheduleInTime, getDeviceBySn } from '../../api/request.js' +import { throttle, getInterTime, getShowTime } from './../../utils/utils.js' import { checkFullScren } from "../../utils/checkFullScren"; import create from 'dd-store' import pageStore from '../meetingDetail/store'; @@ -34,39 +34,30 @@ create.Page({ ] }, title: ``, + remark: '', + isShowRemark: false, + popup: { + show: false, + title: '', + mask: '', + type: '' + }, + showTime: '', + repeatable: 0, recurrenceModel: { model: 'no_repeat' }, - isShowRemark: false, repeatWeek: ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'], popupTitle: '会议重复', popupShow: false, comType: '', - remark: '', comTimeType: '', - meetingWayModel: { model: null }, weekList: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'], week: '', - isAcrossDay: false, conflictPeople: [], placeholder: '', isIPX: false, limitClick: false, }, - - showPop(event) { - this.setData({ - show: true - }) - }, - closePop() { - this.setData({ - show: false - }) - - }, - Complete(data) { - this.closePop(); - }, onLoad(query) { if (query && query.sn) { getDeviceBySn(query.sn).then(res => { @@ -93,44 +84,121 @@ create.Page({ this.update() }, 100) }, - // 添加描述 - addRemark() { + click() { + + updateMeetingTask() + }, + + // 添加标题 + handleChangeTitle(event) { + this.setData({ + title: event.detail.value + }) + }, + + + // 打开添加描述 + handleOpenRemark() { this.setData({ isShowRemark: true }) + }, + // 添加描述 + handleChangeRemark(event) { + this.setData({ + remark: event.detail.value + }) + }, + + + // 跳转选择地点 + goSelectPlace() { + dd.navigateTo({ url: './../place/place' }) + }, + // 删除地点 + handleDeletePlace() { + this.$store.data.locationName = '' + this.$store.data.roomId = '' this.update() + }, + // 选择时间 + handleTime() { + this.setData({ + popup: { + show: true, + title: "选择会议时间", + mask: true, + type: 'time' + } + }) }, - // 输入框输入事件 - onInput(event) { - switch (event.target.dataset.type) { - case 'title': - this.setData({ - title: event.detail.value - }) - break - case 'remark': - this.setData({ - remark: event.detail.value - }) - break + // 选择时间点击完成 + onComplete(event) { + this.$store.data.startTime = `${event.startTime}:00` + this.$store.data.endTime = `${event.endTime}:00` + this.update() + this.setData({ + showTime: getShowTime(this.$store.data.startTime, this.$store.data.endTime) + }) + this.closePopup() + this.conflictPeople() + this.resetRepeatList() + + /* + 改时间 改掉重复规则 + 先选重复规则 再改时间 重复规则也要改变 + 暂时修改每周 每月重复问题 + */ + if (this.data.recurrenceModel.model === 'weekly' && this.data.recurrenceModel.weekDayList.length === 1) { + this.setData({ + recurrenceModel: this.data.comListData.repeatList[2].recurrenceModel + }) + } else if (this.data.recurrenceModel.model === 'absolute_Monthly') { + this.setData({ + recurrenceModel: this.data.comListData.repeatList[4].recurrenceModel + }) } + + }, + // 关闭popup + closePopup() { + this.setData({ + popup: { + show: false, + title: "", + mask: true, + type: '' + } + }) }, + // 初始化 reset() { this.$store.resetData() this.$store.data.startTime = this.getTimes() this.$store.data.endTime = this.getTimes(new Date().setMinutes(new Date().getMinutes() + 30)) this.update() + this.setData({ + showTime: getShowTime(this.$store.data.startTime, this.$store.data.endTime) + }) this.resetRepeatList() - this.acrossDay(this.$store.data.startTime, this.$store.data.endTime) }, + + + + Complete(data) { + this.closePop(); + }, + + + + + + // 跳转下一页 nextPage(event) { switch (event.target.dataset.nextPage) { - case 'location': - dd.navigateTo({ url: './../place/place' }) - break case 'participantsDetail': dd.navigateTo({ url: './../participantsDetail/participantsDetail' }) break @@ -139,11 +207,6 @@ create.Page({ // 所有的关闭操作 close(event) { switch (event.target.dataset.close) { - case 'location': - this.$store.data.locationName = '' - this.$store.data.roomId = '' - this.update() - break case 'meetingWayModel': this.setData({ 'comListData.meetingWayModelId': null, @@ -151,12 +214,7 @@ create.Page({ }) } }, - // 关闭popup 点击mark - closePopup() { - this.setData({ - popupShow: false - }) - }, + // 选择循环机制 选择会议方式 选择时间 出现popup弹窗 showPopup(event) { let iconType = '' @@ -173,9 +231,7 @@ create.Page({ case 'participator': popupTitle = '选择参会人' break - case 'time': - popupTitle = '选择会议时间' - break + } this.setData({ popupTitle: popupTitle, @@ -256,16 +312,16 @@ create.Page({ return year + '-' + month + '-' + day }, // 添加参会人 - addParticipator: throttle(function () { + handleAddParticipator: throttle(function () { const _that = this let require = [] let select = [] - let outLookConcat = [] - for (let participator of _that.$store.data.participatorList) { - if (participator.platform === 'outlook') { - outLookConcat.push(participator) - } - } + // let outLookConcat = [] + // for (let participator of _that.$store.data.participatorList) { + // if (participator.platform === 'outlook') { + // outLookConcat.push(participator) + // } + // } select = this.$store.data.participatorUserId require = [getApp().globalData.userid] select = _that.selectedelRequired(require, select).pickedUsers @@ -319,35 +375,7 @@ create.Page({ } return Object.values(containt) }, - // 点击完成 - onComplete(event) { - this.$store.data.startTime = `${event.startTime}:00` - this.$store.data.endTime = `${event.endTime}:00` - this.update() - this.acrossDay(this.$store.data.startTime, this.$store.data.endTime) - this.setData({ - popupShow: false, - week: this.data.weekList[new Date(this.$store.data.startTime).getDay()], - }) - this.conflictPeople() - this.resetRepeatList() - - /* - 改时间 改掉重复规则 - 先选重复规则 再改时间 重复规则也要改变 - 暂时修改每周 每月重复问题 - */ - if (this.data.recurrenceModel.model === 'weekly' && this.data.recurrenceModel.weekDayList.length === 1) { - this.setData({ - recurrenceModel: this.data.comListData.repeatList[2].recurrenceModel - }) - } else if (this.data.recurrenceModel.model === 'absolute_Monthly') { - this.setData({ - recurrenceModel: this.data.comListData.repeatList[4].recurrenceModel - }) - } - }, addSchedule1: throttle(async function () { if (this.data.limitClick) { return @@ -371,8 +399,7 @@ create.Page({ repeatable: this.data.repeatable, remark: this.data.remark, recurrenceModel: this.data.recurrenceModel, - meetingRoomId: this.$store.data.roomId, - meetingWayModel: this.data.meetingWayModel + meetingWayModel: { model: null } } const res = await addSchedule(data).catch(err => { this.setData({ limitClick: false }); @@ -413,18 +440,7 @@ create.Page({ return `${year}/${month}/${day} ${hour}:${miunutes}:00` }, - // 是否跨天 - acrossDay(time1, time2) { - let isAcrossDay = '' - if (JSON.stringify(this.getTimes(time1).substring(0, 10)) === JSON.stringify(this.getTimes(time2).substring(0, 10))) { - isAcrossDay = false - } else { - isAcrossDay = true - } - this.setData({ - isAcrossDay: isAcrossDay - }) - }, + // 会议冲突 conflictPeople() { let userIds = [] diff --git a/pages/meetingDetail/constant.js b/pages/meetingDetail/constant.js new file mode 100644 index 0000000..1dce454 --- /dev/null +++ b/pages/meetingDetail/constant.js @@ -0,0 +1,7 @@ +export const fileSelectPopup = { + show: false, + list: [ + { text: "本地", type: 'oss' }, + { text: "钉盘", type: 'dd' }, + ] +} \ No newline at end of file diff --git a/pages/meetingDetail/meetingDetail.axml b/pages/meetingDetail/meetingDetail.axml index f507c77..05f9f5f 100644 --- a/pages/meetingDetail/meetingDetail.axml +++ b/pages/meetingDetail/meetingDetail.axml @@ -116,46 +116,6 @@ </view> </view> </view> - <!-- meetingWay 会议方式 --> - <view class="permissionContant" a:if="{{comListData.meetingWayList[comListData.meetingWayModelId].text || currentPeople === organizer}}"> - <!--<view class="iconicon_attender iconfont icon {{$data.participatorList.length>1 ? '' : 'noValueIcon'}}"></view> --> - <view class="meetingWay"> - <view a:if="{{comListData.meetingWayModelId === null}}" class="iconicon_meet iconfont icon noValueIcon"> - </view> - <view a:else class="meetingWayImageUrl"> - <image mode="scaleToFill" src="{{comListData.meetingWayList[comListData.meetingWayModelId].imageUrl}}"/> - </view> - <view class="meetingWayContent"> - <view class="noWay" a:if="{{comListData.meetingWayModelId == null}}" catchTap="showPopup" data-type='meetingWayModel'> - 会议方式 - </view> - <view class="hasWay" a:else catchTap="showPopup" data-type='meetingWayModel'> - {{comListData.meetingWayList[comListData.meetingWayModelId].text}} - </view> - <view class=" icon iconfont iconicon_close close" a:if="{{comListData.meetingWayModelId !== null&&(currentPeople == organizer)}}" data-close="meetingWayModel" catchTap="close"> - </view> - </view> - </view> - <view class="permission" a:if="{{currentPeople != organizer}}"> - </view> - </view> - <view class="meetingWayShow" a:if="{{comListData.meetingWayModelId == 1 && meetingWayModelData.data}}"> - <view class="meetingWayShowTop"> - <view class=" icon iconfont iconicon_camera1"></view> - <view class="meetingWayText"> - <view onTap="setCopy" data-item="{{meetingWayModelData.data.joinUrl}}" data-type="url"> - Zoom - </view> - <view class="mettingWayText" onTap="setCopy" data-item="{{meetingWayModelData.data.meetingId}}"> - <text>ID:{{meetingWayModelData.data.meetingId}}</text> - <text class="icon iconfont iconicon_icon"></text></view> - <view class="mettingWayText passWord" onTap="setCopy" data-item="{{meetingWayModelData.data.password}}"> - <text >密码:{{meetingWayModelData.data.password}}</text> - <text class="icon iconfont iconicon_icon"></text> - </view> - </view> - </view> - </view> <!-- 删除该会议 --> <template is="deleteBtn" onhandleDelete="" data="{{title: '删除该会议' }}"/> </view> @@ -203,7 +163,7 @@ <text class="iconfont iconicon_task1"></text>任务 </view> <!--<view onTap="addMeetingFile"><text class="iconfont iconicon_data"></text>文件</view> --> - <view onTap="addOssFile"> + <view onTap="handleAddFile"> <text class="iconfont iconicon_data"></text> <view> 文件 @@ -217,6 +177,7 @@ <view class="tabBarBottom" a:if="{{isIPX}}"> </view> </view> + <selectpopup showSelectPopup="{{fileSelectPopup.show}}" selectPopupList="{{fileSelectPopup.list}}" onSelectPopup="fileSelectPopup" onSelectPopupCancel="closeFileSelectPopup"></selectpopup> <centerpopup centerPopup="{{centerPopup.showCenterPopup}}" centerPopupList="{{centerPopup.centerPopupList}}" onSelectSend="onSelectSend"></centerpopup> <toast showToast="{{conToastData.showToast}}" title="{{conToastData.title}}" onToastHidden="onToastHidden"></toast> <selectpopup showSelectPopup="{{conSelectPopupData.showSelectPopup}}" selectPopupList="{{conSelectPopupData.selectType==='noParticipateStatus' ? conSelectPopupData.noParticipateStatusList : conSelectPopupData.selectType==='delSheudle' ? conSelectPopupData.delSheudleList : (conSelectPopupData.selectType === 'participateStatus' ? conSelectPopupData.participateStatusList : conSelectPopupData.editSaveList)}}" onSelectPopup="onSelectPopup" onSelectPopupCancel="onSelectPopupCancel"></selectpopup> diff --git a/pages/meetingDetail/meetingDetail.js b/pages/meetingDetail/meetingDetail.js index d94ab69..80f83b6 100644 --- a/pages/meetingDetail/meetingDetail.js +++ b/pages/meetingDetail/meetingDetail.js @@ -2,11 +2,11 @@ import create from 'dd-store'; import { checkFullScren } from "../../utils/checkFullScren"; import pageStore from './store'; import { saveFileInfo, getMeetingRoomAffairs, createMeetingTask, deleteMeetingTask, updateMeetingTask, uploadPermissions } from '../../api/request'; -import { getOssPermission, getuploadResource, isParticipate, deleteSchedule, getScheduleDetail, getUserScheduleInTime, modifySchedule, getMeetingRoomRepeatAffairs } from '../../api/request.js' +import { getuploadResource, isParticipate, deleteSchedule, getScheduleDetail, getUserScheduleInTime, modifySchedule, getMeetingRoomRepeatAffairs } from '../../api/request.js' import { throttle, getCreateShowTime } from './../../utils/utils.js' import { observer } from '/utils/observer.js' import { resolve } from 'path'; -import { getFileInfoFromOss } from './uploadFile'; +import { getFileInfo, getFileInfoFromOss } from './uploadFile.js'; import { comShareData } from './const.js'; create.Page({ store: pageStore, @@ -113,6 +113,7 @@ create.Page({ isExpand: false, placeholder: '', mrReserveStatus: '', + id: '' }, onShow() { console.log(this.$store.data.originUsers) @@ -245,6 +246,7 @@ create.Page({ } } this.setData({ + id: res.data.data.id, currentPeople: getApp().globalData.userid, aheadTimes: !!res.data.data.aheadTimes ? res.data.data.aheadTimes : [], 'comListData.aheadTimesListId': !!res.data.data.aheadTimes ? res.data.data.aheadTimes : [-1], @@ -1642,43 +1644,12 @@ create.Page({ this.store.data.currentTask = currentTask; this.update(); }, - // 添加文件 - addMeetingFile() { - //重置 - this.setData({ - loading: true - }) - this.store.data.description = ''; - this.store.data.fileInfos = null; - let data = { - ddUserId: getApp().globalData.userid, - type: 'add', - projectName: 'MING_MEETING' - } - uploadPermissions(data).then(res => { - if (res.data.code === 0) { - this.setData({ - loading: false - }) - dd.uploadAttachmentToDingTalk({ - image: { multiple: true, compress: true, max: 9, spaceId: res.data.data }, - space: { spaceId: res.data.data, compress: true, isCopy: 1, max: 9 }, - types: ["photo", "camera", "space"], - success: (res) => { - this.store.data.fileInfos = res.data; - dd.navigateTo({ url: `./../uploadFile/uploadFile` }) - }, - fail: (err) => { - } - }) - } - }) - }, - // 上传oss文件 - async addOssFile() { + + // 上传文件 + async handleAddFile() { this.store.data.description = ''; this.store.data.fileInfos = null; - const res = await getFileInfoFromOss(); + const res = await getFileInfo(); if (res.code === -1) { dd.alert({ content: res.msg, @@ -1686,9 +1657,21 @@ create.Page({ }) return } - this.store.data.fileInfos = res.data + let data = [] + res.data.map(it => { + data.push({ + fileId: it.fileId, + name: it.fileName, + size: it.fileSize, + spaceId: it.spaceId, + platform: "dingTalk", + mimeType: it.fileType + }) + }) + + this.store.data.fileInfos = data this.update() - dd.navigateTo({ url: `./../uploadFile/uploadFile` }) + dd.navigateTo({ url: `./../uploadFile/uploadFile?id=${this.data.id}` }) }, //隐藏文件操作浮窗 diff --git a/pages/meetingDetail/uploadFile.js b/pages/meetingDetail/uploadFile.js index 86abc5c..d5ed5e1 100644 --- a/pages/meetingDetail/uploadFile.js +++ b/pages/meetingDetail/uploadFile.js @@ -1,73 +1,34 @@ -import { getRndInteger } from '../../utils/utils.js' -import { getOssPermission } from '../../api/request.js' -import { saveFileInfo, getMeetingRoomAffairs, createMeetingTask, deleteMeetingTask, updateMeetingTask, uploadPermissions } from '../../api/request'; -import pageStore from './store' +import { uploadPermissions } from '../../api/request'; -// 选择图片 -function getImg() { - return new Promise((resolve, rejects) => { - dd.chooseImage({ - count: 1, - success: (res) => { - if (res.files[0].size > 20 * 1024 * 1024) { - rejects({ code: -1, msg: '文件小一点', ...res }) - } else { - resolve(res) - } - }, - fail: (err) => { - rejects({ code: -1, msg: '选择图片失败', ...err }) +// 获取权限 +async function getPermission() { + let data = { + ddUserId: getApp().globalData.userid, + type: 'add', + projectName: 'MING_MEETING' + } + return new Promise((resolve) => { + uploadPermissions(data).then(res => { + if (res.data.code === 0) { + resolve(res) } - }); + }) }) } - -// 获取的图片上传到oss -async function uploadImg(imgInfo) { - const permisson = await getOssPermission() - const timestamp = new Date().getTime() - const random = getRndInteger(1000, 10000) - const fileName = timestamp.toString() + random.toString() + '.' + imgInfo.files[0].fileType; - const key = permisson.data.data.dir + fileName; - return new Promise((resolve, rejects) => { - dd.uploadFile({ - url: permisson.data.data.host, - fileType: 'image', - fileName: 'file', - filePath: imgInfo.filePaths[0], - formData: { - key: key, - policy: permisson.data.data.policy, - OSSAccessKeyId: permisson.data.data.accessId, - success_action_status: 200, - signature: permisson.data.data.signature - }, +// 获取文件信息 +export async function getFileInfo() { + const permission = await getPermission() + return new Promise((resolve) => { + dd.uploadAttachmentToDingTalk({ + image: { multiple: true, compress: true, max: 9, spaceId: permission.data.data }, + space: { spaceId: permission.data.data, compress: true, isCopy: 1, max: 9 }, + types: ["photo", "camera", "space"], success: (res) => { - resolve([{ - fileId: key, - fileName: fileName, - fileType: imgInfo.files[0].fileType, - fileSize: imgInfo.files[0].size - }]) + console.log(res) + resolve(res) }, fail: (err) => { - rejects({ code: -1, msg: '选上传图片失败', ...err }) } }) }) } -// 从OSS获取fileInfo -export async function getFileInfoFromOss() { - try { - const imgInfo = await getImg(); - dd.showLoading({ - content: '正在上传...', - }); - const fileInfo = await uploadImg(imgInfo); - dd.hideLoading() - return { code: 0, msg: 'success', data: fileInfo } - } catch (err) { - dd.hideLoading() - return err - } -} \ No newline at end of file diff --git a/pages/uploadFile/uploadFile.js b/pages/uploadFile/uploadFile.js index 885d76c..dbe6bd7 100644 --- a/pages/uploadFile/uploadFile.js +++ b/pages/uploadFile/uploadFile.js @@ -2,27 +2,24 @@ import create from 'dd-store' import { saveFileInfo, addSchedule, uploadPermissions, previewPermissions, updateMeetingTask } from '../../api/request.js' import { throttle, debounce } from './../../utils/utils.js' import pageStore from '../meetingDetail/store'; -import { getFileInfoFromOss } from '../meetingDetail/uploadFile'; +import { getFileInfo } from '../meetingDetail/uploadFile'; create.Page({ store: pageStore, data: { fileInfos: null, //store description: '',//store - id: '' + id: '', }, onLoad(query) { dd.setNavigationBar({ - title: '添加会议文件' + title: '会议文件' }); // 编辑的时候传了文件ID if (query && query.id) { this.setData({ id: query.id }); - dd.setNavigationBar({ - title: '编辑会议文件' - }); } }, onShow() { @@ -35,38 +32,29 @@ create.Page({ this.update(); } }, 100), + //添加会议文件 async add() { - const res = await getFileInfoFromOss(); + const res = await getFileInfo(); if (res.code === -1) { dd.alert({ content: res.msg }) return } - this.store.data.fileInfos.push(...res.data) + let data = [] + res.data.map(it => { + data.push({ + fileId: it.fileId, + name: it.fileName, + size: it.fileSize, + spaceId: it.spaceId, + mimeType: it.fileType + }) + }) + this.store.data.fileInfos.push(data) this.update(); - // const data = { - // ddUserId: getApp().globalData.userid, - // type: 'add', - // projectName: 'MING_MEETING' - // } - // uploadPermissions(data).then(res => { - // if (res.data.code === 0) { - // const _that = this - // dd.uploadAttachmentToDingTalk({ - // image: { multiple: true, compress: true, max: 9, spaceId: res.data.data }, - // space: { spaceId: res.data.data, compress: true, isCopy: 1, max: 9 }, - // types: ["photo", "camera", "space"], - // success: (res) => { - // _that.store.data.fileInfos.push(...res.data) - // _that.update(); - // }, - // fail: (err) => { - // } - // }) - // } - // }) + }, // 保存 @@ -88,38 +76,20 @@ create.Page({ } const data = { - resourceType: 'accessory', - creatorId: getApp().globalData.userid, - category: '2', - scheduleId: this.store.data.scheduleId, - groupId: this.store.data.groupId, - uploader: getApp().globalData.userid, - creatorInfo: getApp().globalData.userInfo, - thirdStoreTenant: 'oss', - fileInfos: JSON.stringify(fileInfos), - description: description, - logType: 'schedule_accessory_add' - } - - //编辑文件 - if (this.data.id) { - data.logType = 'schedule_accessory_modify'; - data.id = this.data.id - updateMeetingTask(data).then(res => { - this.store.data.isNeedReloadList = true; - this.store.data.fileInfos = [] - this.store.data.description = '' - this.update(); - dd.navigateBack() - }) - } - //新增文件 - else { - saveFileInfo(data).then(res => { - this.store.data.isNeedReloadList = true; - this.update(); - dd.navigateBack() - }) + meetingId: this.data.id, + platform: 'dingTalk', + remark: description, + fileModel: { + fileList: fileInfos + } } + updateMeetingTask(data).then(res => { + console.log(res) + this.store.data.isNeedReloadList = true; + this.store.data.fileInfos = [] + this.store.data.description = '' + this.update(); + dd.navigateBack() + }) }, 1000) }); diff --git a/utils/utils.js b/utils/utils.js index 4fb9597..b1a563d 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -160,4 +160,23 @@ max = 100 区间范围 默认100 */ export function getRndInteger(min = 0, max = 100) { return Math.floor(Math.random() * (max - min)) + min; -} \ No newline at end of file +} + +/* +展示时间 +startTime 开始时间 +endTime 结束时间 + */ + +export function getShowTime(startTime, endTime) { + const weekList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'] + const weekIndex = new Date(startTime).getDay() + let isAcrossDay = false + if (startTime.substring(0, 10) !== endTime.substring(0, 10)) { + isAcrossDay = true + } + if (isAcrossDay) { + return `${startTime.substring(5, 7)}月${startTime.substring(8, 10)}日 ${startTime.substring(11, 16)}-${endTime.substring(5, 7)}月${endTime.substring(8, 10)}日 ${endTime.substring(11, 16)}` + } + return `${startTime.substring(5, 7)}月${startTime.substring(8, 10)}日 ${weekList[weekIndex]} ${startTime.substring(11, 16)}-${endTime.substring(11, 16)}` +}