You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
281 lines
6.3 KiB
281 lines
6.3 KiB
const app = getApp<IAppOption>(); |
|
|
|
Page({ |
|
data: { |
|
show1: false, |
|
show2: false, |
|
|
|
isInvite: false, |
|
|
|
deptList: [] as any, |
|
labelList: [] as any, |
|
|
|
images: [] as any, |
|
description: "", |
|
audios: [] as any, |
|
files: [] as any, |
|
deptId: "", |
|
labelIds: [] as any, |
|
|
|
DoctorLevel: 1, |
|
|
|
caseId: "", |
|
}, |
|
onLoad(options) { |
|
app.waitLogin().then(() => { |
|
this.getDoctorDict(); |
|
this.getInviteDoctorList(); |
|
app.getUserInfo(this, (res) => { |
|
this.setData({ |
|
DoctorLevel: res.DoctorLevel, |
|
}); |
|
}); |
|
if (options.id) { |
|
this.setData({ |
|
caseId: options.id, |
|
}); |
|
this.getDetail(); |
|
} |
|
}); |
|
}, |
|
getDetail() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=takeda/case/get-case-detail", |
|
data: { |
|
caseId: this.data.caseId, |
|
}, |
|
}).then((res) => { |
|
this.setData({ |
|
images: res.caseImages, |
|
description: res.description, |
|
audios: res.caseAudios, |
|
files: res.caseFiles, |
|
deptId: res.caseDeptId[0] || '', |
|
labelIds: res.caseLabels.map((item) => item.labelId), |
|
}); |
|
}); |
|
}, |
|
getDoctorDict() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=takeda/reg/doctor-dict", |
|
data: {}, |
|
}).then((res) => { |
|
this.setData({ |
|
deptList: res.DoctorSpecialtyLabel, |
|
}); |
|
}); |
|
}, |
|
getInviteDoctorList() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=takeda/case/get-invite-doctor-list", |
|
data: {}, |
|
}).then((res) => { |
|
this.setData({ |
|
isInvite: Boolean(res.list.length), |
|
}); |
|
}); |
|
}, |
|
handlePhoto(e) { |
|
const detail = e.detail; |
|
const images = this.data.images; |
|
this.setData({ |
|
images: [ |
|
...images, |
|
{ |
|
name: detail.name, |
|
url: detail.fileUrl, |
|
isRepeat: 2, |
|
}, |
|
], |
|
}); |
|
}, |
|
handleDelPhoto(e) { |
|
const { index } = e.currentTarget.dataset; |
|
this.setData({ |
|
images: this.data.images.filter((_, i) => i !== Number(index)), |
|
}); |
|
}, |
|
handleAudio(e) { |
|
this.setData({ |
|
audios: [ |
|
...this.data.audios, |
|
{ |
|
name: e.detail.name, |
|
url: e.detail.fileUrl, |
|
duration: e.detail.duration, |
|
isRepeat: 2, |
|
}, |
|
], |
|
}); |
|
}, |
|
handleDelAudio(e) { |
|
const { index } = e.currentTarget.dataset; |
|
this.setData({ |
|
audios: this.data.audios.filter((_, i) => i !== Number(index)), |
|
}); |
|
}, |
|
handleFile(e) { |
|
this.setData({ |
|
files: [ |
|
...this.data.files, |
|
{ |
|
fileType: e.detail.fileType, |
|
name: e.detail.name, |
|
url: e.detail.fileUrl, |
|
size: e.detail.size, |
|
isRepeat: 2, |
|
videoUrl: e.detail.videoUrl, |
|
duration: e.detail.duration, |
|
}, |
|
], |
|
}); |
|
}, |
|
handleDelFile(e) { |
|
const { index } = e.currentTarget.dataset; |
|
this.setData({ |
|
files: this.data.files.filter((_, i) => i !== Number(index)), |
|
}); |
|
}, |
|
handlePreviewFile(e) { |
|
const { index } = e.currentTarget.dataset; |
|
const item = this.data.files[index]; |
|
wx.downloadFile({ |
|
url: item.url, |
|
success(res) { |
|
wx.openDocument({ |
|
filePath: res.tempFilePath, |
|
showMenu: true, |
|
fail() { |
|
wx.showToast({ |
|
title: "该文件无法预览", |
|
icon: "none", |
|
}); |
|
}, |
|
}); |
|
}, |
|
}); |
|
}, |
|
handleDownloadFile(e) { |
|
const { index } = e.currentTarget.dataset; |
|
const item = this.data.files[index]; |
|
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({ |
|
title: "下载成功", |
|
icon: "none", |
|
mask: true, |
|
}); |
|
}, |
|
fail() { |
|
wx.showToast({ |
|
title: "下载失败,请重新尝试", |
|
icon: "none", |
|
mask: true, |
|
}); |
|
}, |
|
}); |
|
} |
|
}, |
|
}); |
|
}, |
|
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, |
|
}); |
|
}, |
|
|
|
formatParams() { |
|
const { images, description, audios, files, deptId, labelIds } = this.data; |
|
return { |
|
images: JSON.stringify(images), |
|
description, |
|
audios: JSON.stringify(audios), |
|
files: JSON.stringify(files), |
|
deptId, |
|
labelIds: JSON.stringify(labelIds), |
|
}; |
|
}, |
|
onClose() { |
|
this.setData({ |
|
show1: false, |
|
}); |
|
}, |
|
handleCache() { |
|
const { caseId } = this.data; |
|
const params = this.formatParams(); |
|
const url = caseId ? "?r=takeda/case/save-case" : "?r=takeda/case/create-case"; |
|
wx.ajax({ |
|
method: "POST", |
|
url, |
|
data: { |
|
...params, |
|
isSubmit: 0, |
|
caseId, |
|
}, |
|
}).then(() => { |
|
wx.navigateBack(); |
|
}); |
|
}, |
|
handleInvite() { |
|
const params = this.formatParams(); |
|
const images = this.data.images; |
|
if (images.length === 0) { |
|
wx.showToast({ |
|
title: "请上传病例图片", |
|
icon: "none", |
|
}); |
|
return; |
|
} |
|
wx.navigateTo({ |
|
url: `/module1/pages/setCaseDoctor/index`, |
|
success: (res) => { |
|
res.eventChannel.emit("acceptDataFromOpenerPage", { |
|
caseId: this.data.caseId, |
|
params, |
|
}); |
|
}, |
|
}); |
|
}, |
|
handleSave() {}, |
|
handleSubmit() {}, |
|
handleBack() { |
|
wx.showModal({ |
|
title: "您的病历还未保存,是否要存为草稿?", |
|
confirmText: "存为草稿", |
|
cancelColor: "退出", |
|
success: (res) => { |
|
if (res.confirm) { |
|
this.handleCache(); |
|
} else { |
|
wx.navigateBack(); |
|
} |
|
}, |
|
}); |
|
}, |
|
}); |
|
|
|
export {};
|
|
|