{{ isSigned ? currentUser.name : '未签名' }}
+ >{{ isSigned ? signatureDoctor : '未签名' }}
签名时间:
@@ -398,6 +400,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import useUserStore from '@/store/modules/user'
import { checkPassword } from '@/api/surgicalschedule'
import { savePrescription } from '@/views/clinicmanagement/bargain/component/api.js'
+import { parseTime } from '@/utils/openhis'
// 定义props
const props = defineProps({
@@ -507,16 +510,11 @@ const displayAdvicesList = computed(() => {
return advicesExpanded.value ? all : all.slice(0, PAGE_SIZE)
})
-// 响应式数据 - isSigned 从父组件传入的 prop 初始化
-const isSigned = ref(props.isSignedProp)
-
-// 🔧 修复 Bug #446: 同步父组件 isSignedProp 的变化到本地 isSigned
-// ref(props.isSignedProp) 只在初始化时读取一次,父组件后续更新不会自动同步
-watch(() => props.isSignedProp, (newVal) => {
- isSigned.value = newVal
-})
+const isSigned = ref(false)
+const signatureDoctor = ref(userStore.nickName || userStore.name || '未知用户')
const signatureTime = ref('')
+
const showSignDialog = ref(false)
const signPassword = ref('')
const showEditDialog = ref(false)
@@ -531,7 +529,7 @@ const editForm = ref({
// 计算属性
const currentUser = computed(() => ({
- name: userStore.name || '未知用户',
+ name: userStore.nickName || userStore.name || '未知用户',
id: userStore.id
}))
@@ -554,10 +552,10 @@ const totalAmount = computed(() => {
// 将计费药品转换为临时医嘱数据
const convertedAdvices = computed(() => {
return props.billingMedicines.map((medicine, index) => {
- // 解析规格中的数值和单位
- const specMatch = medicine.specification ? medicine.specification.match(/(\d+)(\D+)/) : null
- const specValue = specMatch ? parseInt(specMatch[1]) : 1
- const specUnit = specMatch ? specMatch[2] : 'ml'
+ // 解析规格中的数值和单位(支持小数,去除 ×、:、/、* 等多余字符)
+ const specMatch = medicine.specification ? medicine.specification.match(/([\d.]+)\s*([a-zA-Z一-龥]+)/) : null
+ const specValue = specMatch ? parseFloat(specMatch[1]) : 1
+ const specUnit = specMatch ? specMatch[2] : ''
// 计算剂量 = 规格数值 × 数量
const dosage = specValue * (medicine.quantity || 1)
@@ -583,8 +581,8 @@ const convertedAdvices = computed(() => {
unit: specUnit,
usage: usageCode, // 🔧 修复:使用后端字典的正确编码
usageLabel: usageLabel, // 🔧 新增:保存显示名称
- frequency: '临时',
- executeTime: new Date().toLocaleString('zh-CN'),
+ frequency: '立即',
+ executeTime: '',
originalMedicine: medicine
}
})
@@ -640,6 +638,24 @@ const handleSign = () => {
showSignDialog.value = true
}
+// 点击已生成列表行 → 回显该行的签名信息
+const handleAdviceRowClick = (row) => {
+ const om = row?.originalMedicine
+ if (!om) return
+ const contentJson = om.contentJson || om.content_json
+ if (!contentJson) return
+ try {
+ const cd = typeof contentJson === 'string' ? JSON.parse(contentJson) : contentJson
+ if (cd.signDoctorName) {
+ signatureDoctor.value = cd.signDoctorName
+ }
+ if (cd.signDate) {
+ signatureTime.value = cd.signDate
+ }
+ isSigned.value = true
+ } catch (e) {}
+}
+
// 编辑医嘱
const handleEditAdvice = (index) => {
const advice = displayAdvices.value[index]
@@ -662,7 +678,7 @@ const handleEditAdvice = (index) => {
}
// 保存编辑
-const handleSaveEdit = () => {
+const handleSaveEdit = async () => {
if (!editForm.value.dosage && editForm.value.dosage !== 0) {
ElMessage.warning('请填写剂量')
return
@@ -720,8 +736,8 @@ const handleSaveEdit = () => {
// 如果用户修改了剂量,重新计算数量
if (originalMedicine.specification) {
- const specMatch = originalMedicine.specification.match(/(\d+)(\D+)/)
- const specValue = specMatch ? parseInt(specMatch[1]) : 1
+ const specMatch = originalMedicine.specification.match(/([\d.]+)\s*([a-zA-Z一-龥]+)/)
+ const specValue = specMatch ? parseFloat(specMatch[1]) : 1
if (specValue > 0) {
const newQuantity = editForm.value.dosage / specValue
contentData.quantity = newQuantity
@@ -731,12 +747,9 @@ const handleSaveEdit = () => {
updatedAdvice.quantity = newQuantity
}
}
-
- // 更新 contentJson
- updatedAdvice.originalMedicine = {
- ...originalMedicine,
- contentJson: JSON.stringify(contentData)
- }
+
+ // 🔧 修复:原地修改 contentJson,保存使用最新数据
+ originalMedicine.contentJson = JSON.stringify(contentData)
} catch (e) {
console.error('解析 originalMedicine.contentJson 失败', e)
}
@@ -750,7 +763,49 @@ const handleSaveEdit = () => {
emit('update:temporary-advices', updatedAdvices)
showEditDialog.value = false
- ElMessage.success('编辑成功(已暂存本地,请点击"一键签名并生成医嘱"按钮提交到服务器)')
+
+ // 🔧 修复 Bug #604: 编辑保存后直接提交到服务器
+ const editMedicine = updatedAdvice.originalMedicine
+ if (editMedicine) {
+ let contentJsonData = {}
+ try { contentJsonData = JSON.parse(editMedicine.contentJson || '{}') } catch (e) {}
+ const quantity = editMedicine.quantity || contentJsonData.quantity || 1
+ const unitPrice = editMedicine.unitPrice || contentJsonData.unitPrice || 0
+ contentJsonData.dose = editForm.value.dosage
+ contentJsonData.doseUnitCode = editForm.value.unit
+ contentJsonData.methodCode = updatedAdvice.usage
+ contentJsonData.quantity = quantity
+ contentJsonData.totalPrice = unitPrice * quantity
+ contentJsonData.adviceName = updatedAdvice.adviceName
+
+ const saveItem = {
+ ...contentJsonData,
+ dbOpType: editMedicine.requestId ? '2' : '1',
+ adviceType: editMedicine.adviceType || 1,
+ requestId: editMedicine.requestId,
+ chargeItemId: editMedicine.chargeItemId,
+ contentJson: JSON.stringify(contentJsonData),
+ quantity,
+ unitCode: editMedicine.unitCode || editForm.value.unit,
+ unitPrice,
+ totalPrice: unitPrice * quantity,
+ adviceName: updatedAdvice.adviceName,
+ patientId: props.patientInfo.patientId,
+ encounterId: props.patientInfo.visitId,
+ orgId: props.patientInfo.orgId,
+ methodCode: updatedAdvice.usage,
+ dose: editForm.value.dosage,
+ doseUnitCode: editForm.value.unit,
+ generateSourceEnum: 6,
+ sourceBillNo: props.patientInfo?.operCode || ''
+ }
+ try {
+ await savePrescription({ organizationId: props.patientInfo.orgId || 1, adviceSaveList: [saveItem] }, '2')
+ ElMessage.success('医嘱修改已保存到服务器')
+ } catch (e) {
+ ElMessage.error('保存失败,请重试')
+ }
+ }
}
// 取消编辑
@@ -762,7 +817,7 @@ const handleCancelEdit = () => {
dosage: '',
unit: '',
usage: '',
- frequency: '临时'
+ frequency: '立即'
}
}
@@ -777,10 +832,10 @@ const confirmSign = async () => {
const response = await checkPassword({
password: signPassword.value
})
-
if (response.code === 200 && response.data) {
isSigned.value = true
- signatureTime.value = new Date().toLocaleString('zh-CN')
+ signatureDoctor.value = userStore.nickName || userStore.name
+ signatureTime.value = parseTime(new Date())
showSignDialog.value = false
signPassword.value = ''
ElMessage.success('签名成功')
@@ -799,10 +854,8 @@ const confirmSign = async () => {
const handleSignAndSubmit = () => {
if (isSigned.value) {
- // 如果已经签名,直接提交
handleSubmit()
} else {
- // 如果未签名,打开签名弹窗
handleSign()
}
}
@@ -907,6 +960,8 @@ const handleSubmit = async () => {
contentJsonData.dose = advice.dosage;
contentJsonData.doseUnitCode = advice.unit;
contentJsonData.rateCode = advice.frequency;
+ contentJsonData.signDoctorName = signatureDoctor.value
+ contentJsonData.signDate = signatureTime.value
// 重新序列化contentJson
const updatedContentJson = JSON.stringify(contentJsonData);
@@ -993,7 +1048,7 @@ const handleSubmit = async () => {
billingMedicines: props.billingMedicines,
temporaryAdvices: itemsToSign,
signature: {
- doctorName: currentUser.value.name,
+ doctorName: signatureDoctor.value,
signatureTime: signatureTime.value
}
}