This commit is contained in:
Your Name
2026-05-18 11:20:24 +08:00
parent 1d66f84bd3
commit 08290b329e
8 changed files with 157 additions and 43 deletions
+7 -2
View File
@@ -319,8 +319,13 @@ export function prescriptionEdit(params: any) {
return request.post({ url: '/tcm.prescription/edit', params })
}
/** 仅修正处方笺患者姓名手机号(不改审核状态),写入业务订单日志表 */
export function prescriptionPatchPatient(params: { id: number; patient_name: string; phone: string }) {
/** 仅修正处方笺患者姓名手机号与性别(不改审核状态),写入业务订单日志表 */
export function prescriptionPatchPatient(params: {
id: number
patient_name: string
phone: string
gender: number
}) {
return request.post({ url: '/tcm.prescription/patchPatient', params })
}
@@ -992,7 +992,7 @@
<!-- 修正处方笺姓名 / 手机号(zyt_tcm_prescription,写入订单日志) -->
<el-dialog
v-model="patchPatientVisible"
title="修正处方姓名与手机号"
title="修正姓名、性别与手机号"
width="440px"
:close-on-click-modal="false"
destroy-on-close
@@ -1010,12 +1010,18 @@
<el-form-item label="患者姓名" prop="patient_name">
<el-input v-model="patchPatientForm.patient_name" maxlength="50" show-word-limit placeholder="处方笺展示姓名" />
</el-form-item>
<el-form-item label="性别" prop="gender">
<el-radio-group v-model="patchPatientForm.gender">
<el-radio :label="1">男</el-radio>
<el-radio :label="0">女</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="手机号" prop="phone">
<el-input v-model="patchPatientForm.phone" maxlength="20" placeholder="处方笺展示手机号" />
</el-form-item>
</el-form>
<p class="text-xs text-gray-500 -mt-2 mb-2">
仅更新处方表 patient_name、phone,不改变审核状态;记录写入业务订单操作日志(有关联订单时可在此订单日志中查看)。
仅更新处方表 patient_name、gender、phone,不改变审核状态;记录写入业务订单操作日志(有关联订单时可在此订单日志中查看)。
</p>
<template #footer>
<el-button @click="patchPatientVisible = false">取消</el-button>
@@ -1584,16 +1590,20 @@ const patchPatientFormRef = ref<FormInstance>()
const patchPatientForm = reactive({
id: 0,
patient_name: '',
gender: 1 as 0 | 1,
phone: ''
})
const patchPatientRules: FormRules = {
patient_name: [{ required: true, message: '请输入患者姓名', trigger: 'blur' }],
gender: [{ required: true, message: '请选择性别', trigger: 'change' }],
phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }]
}
function openPatchPatientDialog(row: Record<string, unknown>) {
patchPatientForm.id = Number(row.id) || 0
patchPatientForm.patient_name = String(row.patient_name ?? '').trim()
const g = Number(row.gender)
patchPatientForm.gender = g === 0 || g === 1 ? (g as 0 | 1) : 1
patchPatientForm.phone = String(row.phone ?? '').trim()
patchPatientVisible.value = true
}
@@ -1601,6 +1611,7 @@ function openPatchPatientDialog(row: Record<string, unknown>) {
function resetPatchPatientForm() {
patchPatientForm.id = 0
patchPatientForm.patient_name = ''
patchPatientForm.gender = 1
patchPatientForm.phone = ''
patchPatientFormRef.value?.clearValidate()
}
@@ -1618,7 +1629,8 @@ async function submitPatchPatient() {
await prescriptionPatchPatient({
id: patchPatientForm.id,
patient_name: patchPatientForm.patient_name.trim(),
phone: patchPatientForm.phone.trim()
phone: patchPatientForm.phone.trim(),
gender: patchPatientForm.gender
})
feedback.msgSuccess('已保存')
patchPatientVisible.value = false
@@ -495,7 +495,7 @@
>修改单号</el-button>
<el-button
v-if="canShipRow(row)"
v-perms="['tcm.prescriptionOrder/ship']"
v-perms="['tcm.prescriptionOrder/ship', 'tcm.prescriptionOrder/submitGancaoRecipel']"
type="primary"
link
@click="openShip(row)"
@@ -606,7 +606,7 @@
</el-button>
<el-button
v-if="canShipRow(detailData)"
v-perms="['tcm.prescriptionOrder/ship']"
v-perms="['tcm.prescriptionOrder/ship', 'tcm.prescriptionOrder/submitGancaoRecipel']"
type="primary"
size="small"
plain
@@ -1917,6 +1917,15 @@
:close-on-click-modal="false"
>
<el-alert
v-if="shipForm.ship_mode === 'gancao'"
title="甘草药方由甘草侧履约配送,无需填写快递单号。点击下方按钮将提交处方至甘草药管家(与「上传药方」相同)。"
type="info"
:closable="false"
show-icon
class="mb-4"
/>
<el-alert
v-else
title="确认后订单状态将变更为「已发货」,请核对快递信息无误。"
type="warning"
:closable="false"
@@ -1930,6 +1939,7 @@
<el-radio label="direct">药房直发</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="shipForm.ship_mode === 'direct'">
<el-form-item label="承运商">
<el-select v-model="shipForm.express_company" class="w-full">
<el-option label="自动识别" value="auto" />
@@ -1946,11 +1956,16 @@
clearable
/>
</el-form-item>
</template>
</el-form>
<template #footer>
<el-button @click="shipVisible = false">取消</el-button>
<el-button type="primary" :loading="shipSaving" @click="submitShip">
确认发货
<el-button
type="primary"
:loading="shipSaving || (shipForm.ship_mode === 'gancao' && gancaoSubmitId === shipRowId)"
@click="submitShip"
>
{{ shipForm.ship_mode === 'gancao' ? '确认并上传药方' : '确认发货' }}
</el-button>
</template>
</el-dialog>
@@ -2589,6 +2604,7 @@ import { getDictData } from '@/api/app'
import { deptAll } from '@/api/org/department'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import { hasPermission } from '@/utils/perm'
import { ElMessageBox } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import useUserStore from '@/stores/modules/user'
@@ -4747,13 +4763,31 @@ const shipForm = reactive({
function openShip(row: { id: number; express_company?: unknown; tracking_number?: unknown; ship_mode?: unknown }) {
shipRowId.value = row.id
shipForm.ship_mode = String(row.ship_mode || 'gancao') || 'gancao'
const tn = String(row.tracking_number ?? '').trim()
const sm = String(row.ship_mode ?? '').trim()
if (sm === 'direct' || sm === 'gancao') {
shipForm.ship_mode = sm
} else if (tn) {
//
shipForm.ship_mode = 'direct'
} else {
shipForm.ship_mode = 'gancao'
}
shipForm.express_company = String(row.express_company || 'auto') || 'auto'
shipForm.tracking_number = String(row.tracking_number || '')
shipVisible.value = true
}
async function submitShip() {
if (shipForm.ship_mode !== 'direct') {
if (!hasPermission(['tcm.prescriptionOrder/submitGancaoRecipel'])) {
feedback.msgError('暂无上传甘草药方权限,请改用「药房直发」并填写快递单号,或联系管理员开通权限')
return
}
shipVisible.value = false
await confirmSubmitGancaoRecipel({ id: shipRowId.value })
return
}
if (!shipForm.tracking_number.trim()) {
feedback.msgError('请先填写快递单号再确认发货')
return
@@ -4762,7 +4796,7 @@ async function submitShip() {
try {
await prescriptionOrderShip({
id: shipRowId.value,
ship_mode: shipForm.ship_mode === 'direct' ? 'direct' : 'gancao',
ship_mode: 'direct',
express_company: shipForm.express_company || 'auto',
tracking_number: shipForm.tracking_number.trim()
})
@@ -49,7 +49,7 @@ class PrescriptionController extends BaseAdminController
}
/**
* @notes 修正处方患者姓名手机
* @notes 修正处方患者姓名手机性别
*/
public function patchPatient()
{
@@ -58,6 +58,7 @@ class PrescriptionController extends BaseAdminController
(int) $params['id'],
(string) $params['patient_name'],
(string) $params['phone'],
(int) $params['gender'],
(int) $this->adminId,
$this->adminInfo
);
@@ -495,7 +495,7 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
if ($prescriptionIds !== []) {
$prescriptions = \app\common\model\tcm\Prescription::whereIn('id', $prescriptionIds)
->whereNull('delete_time')
->field(['id', 'creator_id', 'doctor_name', 'phone'])
->field(['id', 'creator_id', 'doctor_name', 'phone', 'assistant_id'])
->select()
->toArray();
$doctorIds = [];
@@ -508,6 +508,7 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
'doctor_id' => $doctorId,
'doctor_name' => $doctorName,
'phone' => (string) ($rx['phone'] ?? ''),
'assistant_id' => (int) ($rx['assistant_id'] ?? 0),
];
if ($doctorId > 0) {
$doctorIds[] = $doctorId;
@@ -533,7 +534,20 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
if ($diagIdsForAssist !== []) {
$assistantByDiag = Diagnosis::whereIn('id', $diagIdsForAssist)->whereNull('delete_time')->column('assistant_id', 'id');
}
$assistantIds = array_values(array_unique(array_filter(array_map('intval', array_values($assistantByDiag)))));
$assistantIds = [];
foreach (array_values($assistantByDiag) as $v) {
$vid = (int) $v;
if ($vid > 0) {
$assistantIds[] = $vid;
}
}
foreach ($prescriptionCreators as $pc) {
$aid = (int) ($pc['assistant_id'] ?? 0);
if ($aid > 0) {
$assistantIds[] = $aid;
}
}
$assistantIds = array_values(array_unique($assistantIds));
$assistantNames = $assistantIds !== []
? \app\common\model\auth\Admin::whereIn('id', $assistantIds)->column('name', 'id')
: [];
@@ -558,16 +572,18 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
$creatorId = (int) ($item['creator_id'] ?? 0);
$item['creator_name'] = $creatorId > 0 ? ($creatorNames[$creatorId] ?? '') : '';
// 添加医助(来自诊单 assistant_id
// 医助:与处方列表一致优先关联处方 assistant_id,否则诊单 assistant_id(见 PrescriptionOrderLogic::resolveAssistantAdminIdForPrescriptionOrderRow
$diagIdForAssist = (int) ($item['diagnosis_id'] ?? 0);
$assistantIdForItem = (int) ($assistantByDiag[$diagIdForAssist] ?? 0);
$diagAst = (int) ($assistantByDiag[$diagIdForAssist] ?? 0);
$rxId = (int) ($item['prescription_id'] ?? 0);
$rxAst = $rxId > 0 ? (int) (($prescriptionCreators[$rxId] ?? [])['assistant_id'] ?? 0) : 0;
$assistantIdForItem = PrescriptionOrderLogic::resolveAssistantAdminIdForPrescriptionOrderRow($rxAst, $diagAst);
$item['assistant_id'] = $assistantIdForItem;
$item['assistant_name'] = $assistantIdForItem > 0
? ($assistantNames[$assistantIdForItem] ?? '')
: '';
// 添加开方人姓名、处方登记手机(与业务订单收货手机比对用)
$rxId = (int) ($item['prescription_id'] ?? 0);
$item['doctor_name'] = $rxId > 0 ? ($prescriptionCreators[$rxId]['doctor_name'] ?? '') : '';
$item['prescription_phone'] = $rxId > 0 ? ($prescriptionCreators[$rxId]['phone'] ?? '') : '';
}
@@ -437,9 +437,9 @@ class PrescriptionLogic
}
/**
* 仅修正处方笺展示用患者姓名手机号(zyt_tcm_prescription),不改变审核状态与其它字段
* 仅修正处方笺展示用患者姓名手机号与性别zyt_tcm_prescription),不改变审核状态与其它字段
*/
public static function patchPatientContact(int $rxId, string $patientName, string $phone, int $adminId, array $adminInfo): bool
public static function patchPatientContact(int $rxId, string $patientName, string $phone, int $gender, int $adminId, array $adminInfo): bool
{
self::$error = '';
$prescription = Prescription::find($rxId);
@@ -476,20 +476,38 @@ class PrescriptionLogic
return false;
}
if (!in_array($gender, [0, 1], true)) {
self::setError('性别无效');
return false;
}
$oldName = trim((string) ($prescription->patient_name ?? ''));
$oldPhone = trim((string) ($prescription->phone ?? ''));
$oldGender = (int) ($prescription->gender ?? 0);
if ($oldName === $patientName && $oldPhone === $phone) {
if ($oldName === $patientName && $oldPhone === $phone && $oldGender === $gender) {
self::setError('信息未变更');
return false;
}
$genderText = static function (int $g): string {
if ($g === 1) {
return '男';
}
if ($g === 0) {
return '女';
}
return '未知';
};
try {
$prescription->save([
'patient_name' => $patientName,
'phone' => $phone,
'gender' => $gender,
]);
$latestPo = PrescriptionOrder::where('prescription_id', $rxId)
@@ -500,13 +518,17 @@ class PrescriptionLogic
$nameFrom = $oldName === '' ? '—' : $oldName;
$phoneFrom = $oldPhone === '' ? '—' : $oldPhone;
$genderFrom = $genderText($oldGender);
$genderTo = $genderText($gender);
$summary = sprintf(
'处方 #%d:患者姓名「%s」→「%s」,手机「%s」→「%s」',
'处方 #%d:患者姓名「%s」→「%s」,手机「%s」→「%s」,性别「%s」→「%s」',
$rxId,
$nameFrom,
$patientName,
$phoneFrom,
$phone
$phone,
$genderFrom,
$genderTo
);
PrescriptionOrderLogic::appendRxPatientPatchLog($logOrderId, $adminId, $adminInfo, $summary);
@@ -2486,6 +2486,25 @@ class PrescriptionOrderLogic
return $m[$fs] ?? ('状态' . (string) $fs);
}
/**
* 业务订单列表/导出:「诊单医助」admin id。
* 与 {@see PrescriptionLists} 一致优先 {@see Prescription::$assistant_id}(开方时从诊单快照到处方表);
* 为 0 时再取诊单当前 {@see Diagnosis::$assistant_id}(兼容历史处方或未写入快照列的数据)。
*/
public static function resolveAssistantAdminIdForPrescriptionOrderRow(
int $prescriptionAssistantId,
int $diagnosisAssistantId
): int {
if ($prescriptionAssistantId > 0) {
return $prescriptionAssistantId;
}
if ($diagnosisAssistantId > 0) {
return $diagnosisAssistantId;
}
return 0;
}
/**
* 导出用:诊单医助在 admin_dept 中的部门路径(多部门「;」、路径内「 / 」)
*/
@@ -2656,7 +2675,7 @@ class PrescriptionOrderLogic
$rxById = [];
if ($rxIdList !== []) {
$rxRows = Prescription::whereIn('id', $rxIdList)->whereNull('delete_time')
->field(['id', 'prescription_type', 'need_decoction', 'dose_unit'])
->field(['id', 'prescription_type', 'need_decoction', 'dose_unit', 'assistant_id'])
->select()
->toArray();
foreach ($rxRows as $xr) {
@@ -2697,13 +2716,17 @@ class PrescriptionOrderLogic
$diagId = (int) ($item['diagnosis_id'] ?? 0);
$dg = $diagById[$diagId] ?? null;
$rxId = (int) ($item['prescription_id'] ?? 0);
$rx = $rxById[$rxId] ?? [];
$item['export_patient_name'] = \is_array($dg) ? (string) ($dg['patient_name'] ?? '') : '';
if (\is_array($dg)) {
$g = (int) ($dg['gender'] ?? 0);
$item['export_patient_gender'] = $g === 1 ? '男' : '女';
$item['export_patient_age'] = (string) ($dg['age'] ?? '');
$item['export_patient_phone'] = (string) ($dg['phone'] ?? '');
$astId = (int) ($dg['assistant_id'] ?? 0);
$rxAst = \is_array($rx) ? (int) ($rx['assistant_id'] ?? 0) : 0;
$diagAst = (int) ($dg['assistant_id'] ?? 0);
$astId = self::resolveAssistantAdminIdForPrescriptionOrderRow($rxAst, $diagAst);
if ($astId > 0) {
if (!isset($assistantDeptCache[$astId])) {
$assistantDeptCache[$astId] = self::formatAssistantDeptPathForExport($astId);
@@ -2719,8 +2742,6 @@ class PrescriptionOrderLogic
$item['export_assistant_dept'] = '';
}
$rxId = (int) ($item['prescription_id'] ?? 0);
$rx = $rxById[$rxId] ?? [];
$item['export_medication_form'] = self::formatMedicationFormForExport(\is_array($rx) ? $rx : []);
$item['export_channel'] = (string) ($item['service_channel'] ?? '');
@@ -15,6 +15,7 @@ class PrescriptionValidate extends BaseValidate
'dosage_bag_count' => 'integer|between:1,5',
'patient_name' => 'require',
'phone' => 'require|max:20',
'gender' => 'require|in:0,1',
'clinical_diagnosis' => 'require',
'herbs' => 'require|array',
'action' => 'require|in:approve,reject',
@@ -27,6 +28,8 @@ class PrescriptionValidate extends BaseValidate
'patient_name.require' => '患者姓名不能为空',
'phone.require' => '手机号不能为空',
'phone.max' => '手机号过长',
'gender.require' => '请选择性别',
'gender.in' => '性别无效',
'clinical_diagnosis.require' => '临床诊断不能为空',
'herbs.require' => '请添加中药',
];
@@ -68,7 +71,7 @@ class PrescriptionValidate extends BaseValidate
public function scenePatchPatient()
{
return $this->only(['id', 'patient_name', 'phone']);
return $this->only(['id', 'patient_name', 'phone', 'gender']);
}
public function sceneAudit()