diff --git a/src/views/trials/trials-panel/hirVisit/components/edit-study-list.vue b/src/views/trials/trials-panel/hirVisit/components/edit-study-list.vue index 76ad331..dc99e98 100644 --- a/src/views/trials/trials-panel/hirVisit/components/edit-study-list.vue +++ b/src/views/trials/trials-panel/hirVisit/components/edit-study-list.vue @@ -238,6 +238,7 @@ export default { handleSelectChange() {}, // 可选检查添加 add(item) {}, + addTrials() {}, }, }; diff --git a/src/views/trials/trials-panel/hirVisit/index.vue b/src/views/trials/trials-panel/hirVisit/index.vue index 4a57e47..4a1aa6b 100644 --- a/src/views/trials/trials-panel/hirVisit/index.vue +++ b/src/views/trials/trials-panel/hirVisit/index.vue @@ -5,16 +5,24 @@ - + - + - + - + @@ -95,66 +103,92 @@ > + + > + + - + /> --> + > + + {{ $t("trials:hirVisit:button:editStudy") }} {{ $t("common:button:submit") }} {{ $t("common:button:delete") }} {{ $t("trials:adReview:title:result") }} {{ $t("trials:reading:button:uploadImages") }} - {{ - $t("trials:reading:button:uploadReport") - }} + {{ $t("trials:reading:button:uploadReport") }} @@ -233,13 +270,31 @@ import BaseContainer from "@/components/BaseContainer"; import Pagination from "@/components/Pagination"; import editStudyList from "./components/edit-study-list.vue"; +import { + getPatientSubejctVisitList, + getSubjectImageZipInfo, +} from "@/api/trials/visit.js"; +import JSZip from "jszip"; +import axios from "axios"; +import { saveAs } from "file-saver"; +const defaultSearchData = () => { + return { + subjectCode: null, + subjectShortName: null, + subjectSex: null, + pageIndex: 1, + pageSize: 20, + asc: false, + sortField: "SubmitTime", + }; +}; export default { name: "hirVisit", components: { BaseContainer, Pagination, editStudyList }, data() { return { // 查询 - searchData: {}, + searchData: defaultSearchData(), visitOptions: [], // 列表 list: [ @@ -253,15 +308,47 @@ export default { editStudyVisible: false, }; }, + created() { + this.getList(); + }, methods: { // 查询 - handleSearch() {}, + handleSearch() { + this.getList(); + }, // 重置 - handleSearch() {}, + handleReset() { + this.searchData = defaultSearchData(); + this.getList(); + }, // 排序 - handleSortByColumn() {}, + handleSortByColumn(sort) { + this.searchData.SortField = sort.prop; + if (sort.order === "ascending") this.searchData.Asc = true; + if (sort.order === "descending") this.searchData.Asc = false; + if (!sort.order) this.searchData.SortField = null; + this.getList(); + }, // 获取列表 - getList() {}, + async getList() { + let data = {}; + Object.keys(this.searchData).forEach((key) => { + data[key] = this.searchData[key]; + }); + data.TrialId = this.$route.query.trialId; + try { + this.loading = true; + let res = await getPatientSubejctVisitList(data); + this.loading = false; + if (res.IsSuccess) { + this.list = res.Result.CurrentPageData; + this.total = res.Result.TotalCount; + } + } catch (err) { + this.loading = false; + console.log(err); + } + }, // 修改检查 editStudy(item) { this.editStudyVisible = true; @@ -272,10 +359,109 @@ export default { remove() {}, // 评估结果 result() {}, - // 下载影像 - downloadImage() {}, // 下载报告 downloadReport() {}, + // 下载影像 + async downloadImage(item) { + try { + let res = await getSubjectImageZipInfo(item.SubjectId); + if (res.IsSuccess) { + let item = res.Result; + await this.setfolder(item); + } + } catch (err) { + console.log(err); + } + }, + async setfolder(item) { + const zip = new JSZip(); // 创建实例对象 + let zipObj = {}; + const promises = []; + for (let patient of item.PatientList) { + if (!zipObj[patient.PatientIdStr]) { + zipObj[patient.PatientIdStr] = zip.folder(patient.PatientIdStr); + console.log(zipObj[patient.PatientIdStr]); + } + for (let visit of patient.VisitList) { + for (let study of visit.StudyList) { + let date = study.StudyTime.split(" ")[0]; + if (!zipObj[`${patient.PatientIdStr}${date}`]) { + zipObj[`${patient.PatientIdStr}${date}`] = + zipObj[patient.PatientIdStr].folder(date); + } + for (let series of study.SeriesList) { + if (!zipObj[`${patient.PatientIdStr}${date}${series.Modality}`]) { + zipObj[`${patient.PatientIdStr}${date}${series.Modality}`] = + zipObj[`${patient.PatientIdStr}${date}`].folder( + series.Modality + ); + } + for (let instance of series.InstancePathList) { + let obj = { + subjectCode: item.SubjectCode, + patientIdStr: patient.PatientIdStr, + visitName: visit.VisitName, + date: study.StudyTime.split(" ")[0], + modality: series.Modality, + instancePath: instance.Path, + dicomName: instance.Path.split("/Dicom/")[1], + }; + const promise = this.handleBatchDown( + obj, + zipObj[`${patient.PatientIdStr}${date}${series.Modality}`] + ); + promises.push(promise); + } + } + } + } + } + // 生成 zip 文件 + Promise.all(promises) + .then(() => { + // 生成zip 文件 + zip + .generateAsync({ + type: "blob", + compression: "DEFLATE", // STORE: 默认不压缩, DEFLATE:需要压缩 + compressionOptions: { + level: 9, // 压缩等级 1~9 1 压缩速度最快, 9 最优压缩方式 + }, + }) + .then((res) => { + saveAs(res, item.SubjectCode + new Date().getTime() + "_CV.zip"); // 使用FileSaver.saveAs保存文件,文件名可自定义 + zipObj = null; + }); + }) + .catch((reason) => {}); + }, + async handleBatchDown(item, zip) { + return new Promise((resolve) => { + let path = `/${item.subjectCode}_${item.patientIdStr}/${item.visitName}/${item.date}_${item.modality}${item.instancePath}`; + this.getFileData( + this.OSSclientConfig.basePath + path + // "https://th.bing.com/th/id/OIP.duz6S7Fvygrqd6Yj_DcXAQHaF7?rs=1&pid=ImgDetMain" + ).then((res) => { + const fileName = item.dicomName + ".dcm"; + zip.file(fileName, res.data, { binary: true }); + resolve(); + }); + }); + }, + getFileData(fileUrl) { + return new Promise((resolve, reject) => { + axios(fileUrl, { + method: "GET", + responseType: "blob", // 返回的数据会被强制转为blob类型 ,转换成arraybuffer 也行 + }) + .then((res) => { + resolve(res); + }) + .catch((error) => { + reject(error); + }); + }); + }, }, };