Selaa lähdekoodia

fix : 新增送检信息

master
leiyun 3 viikkoa sitten
vanhempi
commit
6b8682b665
3 muutettua tiedostoa jossa 127 lisäystä ja 51 poistoa
  1. +2
    -0
      src/config/router.js
  2. +92
    -12
      src/controller/mp.js
  3. +33
    -39
      view/admin/patient_detail.html

+ 2
- 0
src/config/router.js Näytä tiedosto

@@ -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'],



+ 92
- 12
src/controller/mp.js Näytä tiedosto

@@ -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


+ 33
- 39
view/admin/patient_detail.html Näytä tiedosto

@@ -62,6 +62,7 @@
</span>
</div>
<div class="info-item"><span class="label">提交时间:</span><span class="value">${ patient.create_time }</span></div>
<div class="info-item"><span class="label">医院名称:</span><span class="value">${ patient.hospital || '—' }</span></div>
<div class="info-item"><span class="label">紧急联系人:</span><span class="value">${ patient.emergency_contact || '—' }</span></div>
<div class="info-item"><span class="label">紧急联系电话:</span><span class="value">${ patient.emergency_phone || '—' }</span></div>
<div class="info-item" v-if="patient.income_amount"><span class="label">年可支配收入:</span><span class="value">${ patient.income_amount } 元</span></div>
@@ -71,45 +72,6 @@
</div>
</div>

<!-- 情况描述 -->
<div class="detail-panel">
<h3>情况描述</h3>
<div class="info-grid">
<div class="info-item"><span class="label">医院名称:</span><span class="value">${ patient.hospital || '—' }</span></div>
<div class="info-item"><span class="label">瘤种:</span>
<span class="value">
<el-tag v-if="patient.tag" type="danger" size="small">${ patient.tag }</el-tag>
<span v-else style="color:#999;">未选择</span>
</span>
</div>
<div class="info-item"><span class="label">送检样本:</span>
<span class="value">
<template v-if="patient.sample_types && patient.sample_types.length">
<el-tag v-for="st in patient.sample_types" :key="st" size="small" style="margin-right:4px;">${ st }</el-tag>
</template>
<span v-else style="color:#999;">未选择</span>
</span>
</div>
<div class="info-item" v-if="patient.wax_return"><span class="label">样本需寄回:</span><span class="value">是</span></div>
<div class="info-item" v-if="patient.return_name"><span class="label">收件人:</span><span class="value">${ patient.return_name }</span></div>
<div class="info-item" v-if="patient.return_phone"><span class="label">收件电话:</span><span class="value">${ patient.return_phone }</span></div>
<div class="info-item" v-if="patient.return_address"><span class="label">收件地址:</span>
<span class="value">${ patient.return_province_name || '' } ${ patient.return_city_name || '' } ${ patient.return_district_name || '' } ${ patient.return_address }</span>
</div>
<div class="info-item" v-if="patient.report_email"><span class="label">报告邮箱:</span><span class="value">${ patient.report_email }</span></div>
<div class="info-item" v-if="patient.sample_tracking_no"><span class="label">物流单号:</span><span class="value">${ patient.sample_tracking_no }</span></div>
</div>
<div v-if="patient.sample_photos && patient.sample_photos.length" style="margin-top:16px;">
<div style="font-size:13px;color:#909399;margin-bottom:8px;">送检单照片</div>
<div class="doc-images">
<div v-for="(photo, idx) in patient.sample_photos" :key="idx">
<el-image :src="photo" fit="cover" :preview-src-list="patient.sample_photos" :initial-index="idx"
style="width:200px;height:140px;border-radius:8px;border:1px solid #EBEEF5;" />
</div>
</div>
</div>
</div>

<!-- 实名认证照片 -->
<div class="detail-panel" v-if="patient.id_card_front || patient.id_card_back || patient.photo">
<h3>实名认证照片</h3>
@@ -177,6 +139,38 @@
</div>
</div>

<!-- 送检信息 -->
<div class="detail-panel">
<h3>送检信息</h3>
<div class="info-grid">
<div class="info-item"><span class="label">送检样本:</span>
<span class="value">
<template v-if="patient.sample_types && patient.sample_types.length">
<el-tag v-for="st in patient.sample_types" :key="st" size="small" style="margin-right:4px;">${ st }</el-tag>
</template>
<span v-else style="color:#999;">未选择</span>
</span>
</div>
<div class="info-item" v-if="patient.wax_return"><span class="label">样本需寄回:</span><span class="value">是</span></div>
<div class="info-item" v-if="patient.return_name"><span class="label">收件人:</span><span class="value">${ patient.return_name }</span></div>
<div class="info-item" v-if="patient.return_phone"><span class="label">收件电话:</span><span class="value">${ patient.return_phone }</span></div>
<div class="info-item" v-if="patient.return_address"><span class="label">收件地址:</span>
<span class="value">${ patient.return_province_name || '' } ${ patient.return_city_name || '' } ${ patient.return_district_name || '' } ${ patient.return_address }</span>
</div>
<div class="info-item" v-if="patient.report_email"><span class="label">报告邮箱:</span><span class="value">${ patient.report_email }</span></div>
<div class="info-item" v-if="patient.sample_tracking_no"><span class="label">物流单号:</span><span class="value">${ patient.sample_tracking_no }</span></div>
</div>
<div v-if="patient.sample_photos && patient.sample_photos.length" style="margin-top:16px;">
<div style="font-size:13px;color:#909399;margin-bottom:8px;">送检单照片</div>
<div class="doc-images">
<div v-for="(photo, idx) in patient.sample_photos" :key="idx">
<el-image :src="photo" fit="cover" :preview-src-list="patient.sample_photos" :initial-index="idx"
style="width:200px;height:140px;border-radius:8px;border:1px solid #EBEEF5;" />
</div>
</div>
</div>
</div>

<!-- 审核记录 -->
<div class="detail-panel">
<h3>审核记录</h3>


Ladataan…
Peruuta
Tallenna