diff --git a/src/config/router.js b/src/config/router.js index f9f79d8..639a691 100644 --- a/src/config/router.js +++ b/src/config/router.js @@ -75,6 +75,8 @@ module.exports = [ ['/api/mp/messageDetail', 'mp/messageDetail'], ['/api/mp/unreadCount', 'mp/unreadCount'], ['/api/mp/subscribeConfig', 'mp/subscribeConfig'], + ['/api/mp/sampleInfo', 'mp/sampleInfo'], + ['/api/mp/saveSampleInfo', 'mp/saveSampleInfo', 'post'], ['/api/mp/regenerateSign', 'mp/regenerateSign'], ['/api/mp/regenerateSignByUrl', 'mp/regenerateSignByUrl', 'post'], diff --git a/src/controller/mp.js b/src/controller/mp.js index be0dcb1..e400354 100644 --- a/src/controller/mp.js +++ b/src/controller/mp.js @@ -431,7 +431,7 @@ module.exports = class extends Base { async saveMyInfoAction() { const mpUser = this.mpUser; if (!mpUser) return this.json({ code: 1009, msg: '请先登录' }); - const { gender, province_code, city_code, district_code, address, hospital, emergency_contact, emergency_phone, documents, tag, sample_types, wax_return, return_name, return_phone, return_province_code, return_city_code, return_district_code, return_address, report_email, sample_tracking_no, sample_photos, sign_income, sign_privacy, sign_privacy_jhr, sign_promise, income_amount, guardian_name, guardian_id_card, guardian_relation, mp_env_version } = this.post(); + const { gender, province_code, city_code, district_code, address, hospital, emergency_contact, emergency_phone, documents, tag, sign_income, sign_privacy, sign_privacy_jhr, sign_promise, income_amount, guardian_name, guardian_id_card, guardian_relation, mp_env_version } = this.post(); const user = await this.model('wechat_user').where({ id: mpUser.id, status: 1 }).find(); if (think.isEmpty(user) || !user.patient_id) return this.json({ code: 1, msg: '请先完成实名认证' }); if (!province_code || !city_code || !district_code) return this.json({ code: 1, msg: '请选择省市区' }); @@ -451,17 +451,6 @@ module.exports = class extends Base { emergency_contact: emergency_contact || '', emergency_phone: emergency_phone || '', tag: tag || '', documents: JSON.stringify(documents || []), - sample_types: JSON.stringify(sample_types || []), - wax_return: (sample_types && sample_types.length && wax_return) ? 1 : 0, - return_name: (sample_types && sample_types.length && wax_return) ? (return_name || '') : '', - return_phone: (sample_types && sample_types.length && wax_return) ? (return_phone || '') : '', - return_province_code: (sample_types && sample_types.length && wax_return) ? (return_province_code || '') : '', - return_city_code: (sample_types && sample_types.length && wax_return) ? (return_city_code || '') : '', - return_district_code: (sample_types && sample_types.length && wax_return) ? (return_district_code || '') : '', - return_address: (sample_types && sample_types.length && wax_return) ? (return_address || '') : '', - report_email: (sample_types && sample_types.length) ? (report_email || '') : '', - sample_tracking_no: (sample_types && sample_types.length) ? (sample_tracking_no || '') : '', - sample_photos: (sample_types && sample_types.length) ? JSON.stringify(sample_photos || []) : '[]', sign_income: sign_income || '', sign_privacy: sign_privacy || '', sign_privacy_jhr: sign_privacy_jhr || '', @@ -656,6 +645,97 @@ module.exports = class extends Base { } } + /** + * 获取送检信息(回显) + * GET /api/mp/sampleInfo + */ + async sampleInfoAction() { + const mpUser = this.mpUser; + if (!mpUser) return this.json({ code: 1009, msg: '请先登录' }); + try { + const user = await this.model('wechat_user').where({ id: mpUser.id, status: 1 }).find(); + if (think.isEmpty(user) || !user.patient_id) return this.json({ code: 1, msg: '请先完成实名认证' }); + const patient = await this.model('patient').where({ id: user.patient_id, is_deleted: 0 }).find(); + if (think.isEmpty(patient)) return this.json({ code: 1, msg: '患者信息不存在' }); + if (patient.status !== 1) return this.json({ code: 1, msg: '请先通过审核' }); + + // 查省市区名称 + const codes = [patient.province_code, patient.city_code, patient.district_code].filter(Boolean); + const regionMap = {}; + if (codes.length) { + const regions = await this.model('sys_region').where({ code: ['in', codes] }).select(); + regions.forEach(r => { regionMap[r.code] = r.name; }); + } + const regionText = [regionMap[patient.province_code], regionMap[patient.city_code], regionMap[patient.district_code]].filter(Boolean).join(' '); + + let sampleTypes = []; + try { sampleTypes = JSON.parse(patient.sample_types || '[]'); } catch (e) { sampleTypes = []; } + let samplePhotos = []; + try { samplePhotos = JSON.parse(patient.sample_photos || '[]'); } catch (e) { samplePhotos = []; } + + return this.json({ code: 0, data: { + patient: { + name: patient.name, gender: patient.gender, id_card: patient.id_card, + phone: patient.phone, address: patient.address, hospital: patient.hospital || '', + tag: patient.tag || '', region_text: regionText, + province_code: patient.province_code, city_code: patient.city_code, district_code: patient.district_code + }, + sample_types: sampleTypes, + wax_return: patient.wax_return || 0, + return_name: patient.return_name || '', + return_phone: patient.return_phone || '', + return_province_code: patient.return_province_code || '', + return_city_code: patient.return_city_code || '', + return_district_code: patient.return_district_code || '', + return_address: patient.return_address || '', + report_email: patient.report_email || '', + sample_tracking_no: patient.sample_tracking_no || '', + sample_photos: samplePhotos + }}); + } catch (error) { + think.logger.error('sampleInfo error:', error); + return this.json({ code: 1, msg: '获取失败' }); + } + } + + /** + * 保存送检信息(不改变审核状态) + * POST /api/mp/saveSampleInfo + */ + async saveSampleInfoAction() { + const mpUser = this.mpUser; + if (!mpUser) return this.json({ code: 1009, msg: '请先登录' }); + const { sample_types, wax_return, return_name, return_phone, return_province_code, return_city_code, return_district_code, return_address, report_email, sample_tracking_no, sample_photos } = this.post(); + + try { + const user = await this.model('wechat_user').where({ id: mpUser.id, status: 1 }).find(); + if (think.isEmpty(user) || !user.patient_id) return this.json({ code: 1, msg: '请先完成实名认证' }); + const patient = await this.model('patient').where({ id: user.patient_id, is_deleted: 0 }).find(); + if (think.isEmpty(patient)) return this.json({ code: 1, msg: '患者信息不存在' }); + if (patient.status !== 1) return this.json({ code: 1, msg: '请先通过审核' }); + + const hasSample = sample_types && sample_types.length > 0; + await this.model('patient').where({ id: user.patient_id }).update({ + sample_types: JSON.stringify(sample_types || []), + wax_return: (hasSample && wax_return) ? 1 : 0, + return_name: (hasSample && wax_return) ? (return_name || '') : '', + return_phone: (hasSample && wax_return) ? (return_phone || '') : '', + return_province_code: (hasSample && wax_return) ? (return_province_code || '') : '', + return_city_code: (hasSample && wax_return) ? (return_city_code || '') : '', + return_district_code: (hasSample && wax_return) ? (return_district_code || '') : '', + return_address: (hasSample && wax_return) ? (return_address || '') : '', + report_email: hasSample ? (report_email || '') : '', + sample_tracking_no: hasSample ? (sample_tracking_no || '') : '', + sample_photos: hasSample ? JSON.stringify(sample_photos || []) : '[]' + }); + + return this.json({ code: 0, data: {}, msg: '提交成功' }); + } catch (error) { + think.logger.error('saveSampleInfo error:', error); + return this.json({ code: 1, msg: '保存失败: ' + error.message }); + } + } + /** * 批量重新生成声明与承诺签署图并更新数据库 * GET /api/mp/regenerateSign diff --git a/view/admin/patient_detail.html b/view/admin/patient_detail.html index 704a27e..3dfe06f 100644 --- a/view/admin/patient_detail.html +++ b/view/admin/patient_detail.html @@ -62,6 +62,7 @@
提交时间:${ patient.create_time }
+
医院名称:${ patient.hospital || '—' }
紧急联系人:${ patient.emergency_contact || '—' }
紧急联系电话:${ patient.emergency_phone || '—' }
年可支配收入:${ patient.income_amount } 元
@@ -71,45 +72,6 @@ - -
-

情况描述

-
-
医院名称:${ patient.hospital || '—' }
-
瘤种: - - ${ patient.tag } - 未选择 - -
-
送检样本: - - - 未选择 - -
-
样本需寄回:
-
收件人:${ patient.return_name }
-
收件电话:${ patient.return_phone }
-
收件地址: - ${ patient.return_province_name || '' } ${ patient.return_city_name || '' } ${ patient.return_district_name || '' } ${ patient.return_address } -
-
报告邮箱:${ patient.report_email }
-
物流单号:${ patient.sample_tracking_no }
-
-
-
送检单照片
-
-
- -
-
-
-
-

实名认证照片

@@ -177,6 +139,38 @@
+ +
+

送检信息

+
+
送检样本: + + + 未选择 + +
+
样本需寄回:
+
收件人:${ patient.return_name }
+
收件电话:${ patient.return_phone }
+
收件地址: + ${ patient.return_province_name || '' } ${ patient.return_city_name || '' } ${ patient.return_district_name || '' } ${ patient.return_address } +
+
报告邮箱:${ patient.report_email }
+
物流单号:${ patient.sample_tracking_no }
+
+
+
送检单照片
+
+
+ +
+
+
+
+

审核记录