武田小程序
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.

282 lines
6.3 KiB

6 months ago
const app = getApp<IAppOption>();
Page({
data: {
show1: false,
show2: false,
6 months ago
6 months ago
isInvite: false,
6 months ago
deptList: [] as any,
labelList: [] as any,
6 months ago
images: [] as any,
description: "",
audios: [] as any,
6 months ago
files: [] as any,
6 months ago
deptId: "",
labelIds: [] as any,
6 months ago
DoctorLevel: 1,
6 months ago
caseId: "",
6 months ago
},
6 months ago
onLoad(options) {
6 months ago
app.waitLogin().then(() => {
this.getDoctorDict();
6 months ago
this.getInviteDoctorList();
app.getUserInfo(this, (res) => {
this.setData({
DoctorLevel: res.DoctorLevel,
});
});
6 months ago
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] || '',
6 months ago
labelIds: res.caseLabels.map((item) => item.labelId),
});
6 months ago
});
},
getDoctorDict() {
wx.ajax({
method: "GET",
url: "?r=takeda/reg/doctor-dict",
data: {},
}).then((res) => {
this.setData({
deptList: res.DoctorSpecialtyLabel,
});
});
},
6 months ago
getInviteDoctorList() {
wx.ajax({
method: "GET",
url: "?r=takeda/case/get-invite-doctor-list",
data: {},
}).then((res) => {
this.setData({
isInvite: Boolean(res.list.length),
});
6 months ago
});
},
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,
},
],
});
6 months ago
},
6 months ago
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,
{
6 months ago
fileType: e.detail.fileType,
6 months ago
name: e.detail.name,
url: e.detail.fileUrl,
size: e.detail.size,
isRepeat: 2,
6 months ago
videoUrl: e.detail.videoUrl,
duration: e.detail.duration,
6 months ago
},
],
});
},
6 months ago
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,
6 months ago
showMenu: true,
6 months ago
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,
});
},
});
}
},
});
},
6 months ago
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,
});
},
6 months ago
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() {
6 months ago
const { caseId } = this.data;
6 months ago
const params = this.formatParams();
6 months ago
const url = caseId ? "?r=takeda/case/save-case" : "?r=takeda/case/create-case";
6 months ago
wx.ajax({
method: "POST",
6 months ago
url,
6 months ago
data: {
...params,
6 months ago
isSubmit: 0,
caseId,
6 months ago
},
}).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`,
6 months ago
success: (res) => {
6 months ago
res.eventChannel.emit("acceptDataFromOpenerPage", {
6 months ago
caseId: this.data.caseId,
6 months ago
params,
});
},
});
},
handleSave() {},
handleSubmit() {},
handleBack() {
wx.showModal({
title: "您的病历还未保存,是否要存为草稿?",
confirmText: "存为草稿",
cancelColor: "退出",
success: (res) => {
if (res.confirm) {
this.handleCache();
} else {
wx.navigateBack();
}
},
});
},
6 months ago
});
6 months ago
export {};