const app = getApp(); Page({ data: { show1: false, // 驳回病例 show2: false, // 优质病例 show3: false, // 归档 show4: false, // 取消优质病例 show5: false, // 取消归档 show6: false, // 创建聊天室 show7: false, // 更改标签 showRejectReason: false, more: false, moreShow: false, showMoreAuth: 0, foldAuth: {}, deptList: [] as any, labelList: [] as any, deptId: "", labelIds: [] as any, id: "", auth: {}, userInfo: {}, dealDoctorInfo: {}, dealInfo: {}, detail: { dealCaseInfo: { dealDoctorInfo: {}, dealInfo: {}, }, createDoctorInfo: {}, caseLabels: {}, caseImages: {}, caseAudios: {}, caseFiles: {}, feedbackList: [], } as any, rejectReason: {}, fold: false, }, onLoad(options) { this.setData({ id: options.id, beforeClose2: (e: any) => { if (e === "confirm") { this.handleQualitySubmit(); } return true; }, beforeClose3: (e: any) => { if (e === "confirm") { this.handleArchiveSubmit(); } return true; }, beforeClose5: (e: any) => { if (e === "confirm") { this.handleUnArchiveSubmit(); } return true; }, }); }, onShow() { app.waitLogin().then(() => { this.handleResoure(); this.getDoctorDict(); app.getUserInfo(this); }); }, handleResoure() { this.getDetail(); this.getAuth(); }, getDetail() { wx.ajax({ method: "GET", url: "?r=takeda/case/get-case-detail", data: { caseId: this.data.id, }, }).then((res) => { this.setData({ detail: res, dealDoctorInfo: res.dealCaseInfo.dealDoctorInfo, dealInfo: res.dealCaseInfo.dealInfo, }); this.readFeedback(); }); }, readFeedback() { wx.ajax({ method: "POST", url: "?r=takeda/case/read-feedback", data: { caseId: this.data.id, }, }); }, getAuth() { wx.ajax({ method: "GET", url: "?r=takeda/case/get-case-detail-op-auth", data: { caseId: this.data.id }, }).then((res) => { let showMoreAuth = 0; const moreAuth = [ "canReject", "canViewRejectReason", "canCreateChatRoom", "canArchive", "canCancelArchive", "canEnterChatRoom", "canSetHighQuality", "canInvite", "canDel", "canEdit", "canSetOpen", ]; const foldAuth: any = {}; moreAuth.forEach((item) => { if (res[item]) { showMoreAuth += 1; if (showMoreAuth > 2) { foldAuth[item] = true; } } }); this.setData({ auth: res, foldAuth, showMoreAuth, more: Boolean(Object.keys(foldAuth).length), }); if (res.canViewRejectReason) { this.getRejectReason(); } }); }, onClose() { this.setData({ show1: false, show2: false, show3: false, show4: false, show5: false, show6: false, show7: false, }); }, handleImagePreview(e) { const { url } = e.currentTarget.dataset; wx.previewImage({ urls: [url], }); }, getRejectReason() { wx.ajax({ method: "GET", url: "?r=takeda/case/view-reject-reason", data: { caseId: this.data.id, }, }).then((res) => { this.setData({ rejectReason: res, }); }); }, handleShowRejectReason() { this.setData({ showRejectReason: !this.data.showRejectReason, }); }, handleShowLable() { this.setData({ show7: true, }); }, getDoctorDict() { wx.ajax({ method: "GET", url: "?r=takeda/reg/doctor-dict", data: {}, }).then((res) => { this.setData({ deptList: res.DoctorSpecialtyLabel, }); }); }, handleDept(e) { const { params } = e.currentTarget.dataset; this.setData({ deptId: params.value, labelList: params.options, labelIds: [], }); }, handleLabel(e) { const { params } = e.currentTarget.dataset; const labelIds = this.data.labelIds; const newLabelId = labelIds.includes(params.value) ? labelIds.filter((item: any) => item !== params.value) : [...labelIds, ...params.value]; this.setData({ labelIds: newLabelId, }); }, handleLableSubmit() { const { id, deptId, labelIds } = this.data; if (!deptId) { wx.showToast({ title: "请选择科室", icon: "none", }); return; } if (!labelIds.length) { wx.showToast({ title: "请选择标签", icon: "none", }); return; } wx.ajax({ method: "POST", url: "?r=takeda/case/save-case-label", data: { caseId: id, deptId, labelIds: JSON.stringify(labelIds), }, }).then(() => { this.setData({ show7: false, }); this.handleResoure(); }); }, handlePreviewFile(e) { const { item } = e.currentTarget.dataset; wx.downloadFile({ url: item.url, success(res) { wx.openDocument({ filePath: res.tempFilePath, showMenu: true, fail() { wx.showToast({ title: "该文件无法预览", icon: "none", }); }, }); }, }); }, handleDownloadFile(e) { const { item } = e.currentTarget.dataset; wx.downloadFile({ url: item.url, success(res) { if (res.statusCode === 200) { wx.hideLoading(); const tempFilePath = res.tempFilePath; const FileSystemManager = wx.getFileSystemManager(); FileSystemManager.saveFile({ tempFilePath, success() { wx.showToast({ icon: "none", title: "保存成功", }); }, fail() { wx.showToast({ title: "下载失败,请重新尝试", icon: "none", mask: true, }); }, }); } }, }); }, handleInvite() { wx.navigateTo({ url: `/module1/pages/setCaseDoctor/index`, success: (res) => { res.eventChannel.emit("acceptDataFromOpenerPage", { caseId: this.data.id, detailInvite: true, }); }, }); }, handleFeedBack() { wx.navigateTo({ url: `/module1/pages/casesFeedback/index?id=${this.data.id}`, }); }, handleToggleMore() { this.setData({ moreShow: !this.data.moreShow, }); }, handleArchive() { this.setData({ show3: true, }); }, handleArchiveSubmit() { const { id } = this.data; wx.ajax({ method: "POST", url: "?r=takeda/case/archive-case", data: { caseId: id, }, }).then(() => { this.handleResoure(); }); }, handleUnArchive() { this.setData({ show5: true, }); }, handleUnArchiveSubmit() { const { id } = this.data; wx.ajax({ method: "POST", url: "?r=takeda/case/cancel-archive-case", data: { caseId: id, }, }).then(() => { this.handleResoure(); }); }, handleOpen() { const { detail, id } = this.data; const isOpen = detail.isOpen === "1"; wx.showModal({ title: `确认${isOpen ? "取消公开" : "公开"}?`, success: (res) => { if (res.confirm) { wx.ajax({ method: "POST", url: "?r=takeda/case/set-open", data: { caseId: id, }, }).then(() => { this.handleResoure(); }); } }, }); }, handleQuality() { const { detail } = this.data; const isHighQuality = detail.isHighQuality === "1"; if (isHighQuality) { this.setData({ show4: true, }); } else { this.setData({ show2: true, }); } }, handleQualitySubmit() { const { id } = this.data; wx.ajax({ method: "POST", url: "?r=takeda/case/set-high-quality", data: { caseId: id, }, }).then(() => { this.handleResoure(); }); }, handleDel() { const { id } = this.data; wx.showModal({ title: `确认删除?`, success: (res) => { if (res.confirm) { wx.ajax({ method: "POST", url: "?r=takeda/case/delete-case", data: { caseId: id, }, }).then(() => { wx.reLaunch({ url: "/pages/cases/index", }); }); } }, }); }, handleEdit() { wx.navigateTo({ url: `/module1/pages/entryCases/index?id=${this.data.id}`, }); }, handleDelFeedBack(e) { const { index } = e.currentTarget.dataset; const { detail } = this.data; const item = detail.feedbackList[index]; wx.showModal({ title: `确认删除该反馈?`, success: (res) => { if (res.confirm) { wx.ajax({ method: "POST", url: "?r=takeda/case/delete-feedback", data: { feedbackId: item.feedbackId, }, }).then(() => { this.handleResoure(); }); } }, }); }, handleFold() { this.setData({ fold: !this.data.fold, }); }, handleFeedBackFold(e) { const { index } = e.currentTarget.dataset; const { detail } = this.data; const feedbackList = detail.feedbackList; feedbackList[index].fold = !feedbackList[index].fold; this.setData({ detail: { ...detail, feedbackList, }, }); }, }); export {};