const app = getApp(); Page({ data: { fold: true, show1: false, show2: false, show3: false, showArea: false, fieldNames: { text: "label", value: "value", children: "children" }, nav: "0", area: [], caseStatusList: {}, fileTypeList: {}, reasonList: {}, pagination: { page: 1, pages: 1, count: 1, }, list: [], hostilatSearch: "", hostipalList: [], hospitalClassification: {}, hospitalLevel: {}, hostipalPagination: { page: 1, pages: 1, count: 1, }, deptList: [] as any, labelList: [] as any, caseStatusName: "全部", hospitalName: "全部", deptName: "全部", provinceName: "", cityName: "", countyName: "", search: "", caseStatus: [] as any, hospitalId: [] as any, submitTimeBegin: "", submitTimeEnd: "", feedbackTimeBegin: "", feedbackTimeEnd: "", deptId: [] as any, labelId: [] as any, provinceId: "", cityId: "", countyId: "", isReject: "", isHighQuality: "", isOpen: "", needDeal: "", orderType: "", }, onLoad() { this.getTabBar().setData({ active: 2, }); app.waitLogin().then(() => { this.getBaseInfo(); this.getList(); this.getHospitalsList(); this.getHostipalDict(); this.getDoctorDict(); this.getArea(); }); }, getBaseInfo() { wx.ajax({ method: "GET", url: "?r=takeda/case/get-base-info", data: {}, }).then((res) => { this.setData({ caseStatusList: res.caseStatusList, fileTypeList: res.fileTypeList, reasonList: res.reasonList, }); }); }, getArea() { wx.ajax({ method: "GET", url: "/js/area.json", isJSON: true, }).then((res) => { this.setData({ area: res, }); }); }, handleNav(e) { const { nav } = e.currentTarget.dataset; this.setData({ nav, isOpen: nav === "1" ? "1" : "", isHighQuality: nav === "2" ? "1" : "", }); this.handleSearch(); }, getList(newPage = 1) { wx.ajax({ method: "POST", url: "?r=takeda/case/get-list", data: { page: newPage, search: this.data.search, caseStatus: this.data.caseStatus, submitTimeBegin: this.data.submitTimeBegin, submitTimeEnd: this.data.submitTimeEnd, feedbackTimeBegin: this.data.feedbackTimeBegin, feedbackTimeEnd: this.data.feedbackTimeEnd, deptId: this.data.deptId, labelId: this.data.labelId, provinceId: this.data.provinceId, cityId: this.data.cityId, countyId: this.data.countyId, hospitalId: this.data.hospitalId, isReject: this.data.isReject, isHighQuality: this.data.isHighQuality, isOpen: this.data.isOpen, needDeal: this.data.needDeal, orderType: this.data.orderType, }, }).then((res) => { const list = res.page === 1 ? res.list : [...this.data.list, ...res.list]; this.setData({ list, pagination: { page: res.page, pages: res.pages, count: res.count, }, }); }); }, onReachBottom() { const { page, pages } = this.data.pagination; if (pages > page) { this.getList(page + 1); } }, handleSearch() { this.getList(); }, handleCaseShow() { this.setData({ show1: true, }); }, handleCase(e) { const { value } = e.currentTarget.dataset; const { caseStatus, caseStatusList } = this.data; if (!value) { this.setData({ caseStatus: [], caseStatusName: "全部", }); return; } if (caseStatus.includes(value)) { this.setData({ caseStatus: caseStatus.filter((item) => item !== value), caseStatusName: caseStatus .filter((item) => item !== value) .map((item) => caseStatusList[item]) .join(","), }); } else { this.setData({ caseStatus: [...caseStatus, value], caseStatusName: [...caseStatus, value].map((item) => caseStatusList[item]).join(","), }); } }, handleCaseSubmit() { this.setData({ show1: false, }); this.handleSearch(); }, onClose() { this.setData({ show1: false, show2: false, show3: false, showArea: false, }); }, handleImagePreview(e) { const { url } = e.currentTarget.dataset; wx.previewImage({ urls: [url], }); }, handleDetail() { wx.navigateTo({ url: "/module1/pages/casesDetail/index", }); }, // 医院选择弹窗 handleHostipalShow() { this.setData({ show2: true, }); }, getHostipalDict() { wx.ajax({ method: "GET", url: "?r=takeda/reg/hospital-dict", data: {}, }).then((res) => { this.setData({ hospitalClassification: res.hospitalClassification, hospitalLevel: res.hospitalLevel, }); }); }, handleSearchHostipal() { this.getHospitalsList(); }, getHospitalsList(newPage = 1) { wx.ajax({ method: "GET", url: "?r=takeda/reg/hospitals", data: { page: newPage, Search: this.data.hostilatSearch, }, }).then((res) => { const hostipalList = res.page === 1 ? res.list : [...this.data.hostipalList, ...res.list]; this.setData({ hostipalList, hostipalPagination: { page: res.page, pages: res.pages, count: res.count, }, }); }); }, handleHostipalBottom(e) { const hostipalPagination = this.data.hostipalPagination; if (e.detail.direction === "botttom" && hostipalPagination.page < hostipalPagination.pages) { this.getHospitalsList(Number(hostipalPagination.page) + 1); } }, handleHostipal(e) { const { params } = e.currentTarget.dataset; this.setData({ show2: false, hospitalId: this.data.hospitalId.includes(params.HospitalId) ? [] : [params.HospitalId], hospitalName: this.data.hospitalId.includes(params.HospitalId) ? "全部" : params.Name, }); }, getDoctorDict() { wx.ajax({ method: "POST", url: "?r=takeda/reg/doctor-dict", data: {}, }).then((res) => { this.setData({ deptList: res.DoctorSpecialtyLabel, }); }); }, handleTagShow() { this.setData({ show3: true, }); }, handleDept(e) { const { params } = e.currentTarget.dataset; const deptId = this.data.deptId; const newDeptId: any = deptId.includes(params.value) ? deptId.filter((item) => item !== params.value) : [...deptId, params.value]; const newDeptName = this.data.deptList .filter((item) => newDeptId.includes(item.value)) .map((item) => item.label) .join(","); const labelList = this.data.deptList .filter((item) => newDeptId.includes(item.value)) .reduce((pre, cur) => { return [...pre, ...cur.options]; }, []); this.setData({ deptId: newDeptId, deptName: newDeptName || "全部", labelList, labelId: [], }); }, handleLabel(e) { const { params } = e.currentTarget.dataset; const labelId = this.data.labelId; const newDeptId = labelId.includes(params.value) ? labelId.filter((item) => item !== params.value) : [...labelId, ...params.value]; this.setData({ labelId: newDeptId, }); }, handleTagSubmit() { this.setData({ show3: false, }); this.handleSearch(); }, handleArea() { this.setData({ showArea: true, }); }, onFinish(e: any) { this.setData({ provinceId: e.detail.selectedOptions[0].value, provinceName: e.detail.selectedOptions[0].label, cityId: e.detail.selectedOptions[1].value, cityName: e.detail.selectedOptions[1].label, countyId: e.detail.selectedOptions[2].value, countyName: e.detail.selectedOptions[2].label, showArea: false, }); this.handleSearch(); }, handleRadio(e) { const { key } = e.currentTarget.dataset; this.setData({ [key]: this.data[key] === "1" ? "" : "1", }); this.handleSearch(); }, handleOrder(e) { const { value } = e.currentTarget.dataset; this.setData({ orderType: value, }); this.handleSearch(); }, handleFold() { this.setData({ fold: !this.data.fold, }); }, handleDel(e) { const { index } = e.currentTarget.dataset; const params: any = this.data.list[index]; wx.showModal({ title: "确认删除该病历?", success: (e) => { if (e.confirm) { wx.ajax({ method: "POST", url: "?r=takeda/case/delete-case", data: { caseId: params.caseId, }, }).then(() => { this.setData({ list: this.data.list.filter((item: any) => item.caseId !== params.caseId), }); }); } }, }); }, }); export {};