igengx
This commit is contained in:
@@ -10,6 +10,18 @@ export function systemLogLists(params: any) {
|
||||
return request.get({ url: '/setting.system.log/lists', params }, { ignoreCancelToken: true })
|
||||
}
|
||||
|
||||
export function desktopSessionLists(params: {
|
||||
date: string
|
||||
keyword: string
|
||||
page_no: number
|
||||
page_size: number
|
||||
}) {
|
||||
return request.get(
|
||||
{ url: '/setting.system.log/desktopSessions', params },
|
||||
{ ignoreCancelToken: true }
|
||||
)
|
||||
}
|
||||
|
||||
// 清除系统缓存
|
||||
export function systemCacheClear() {
|
||||
return request.post({ url: '/setting.system.cache/clear' })
|
||||
|
||||
+38
-7
@@ -380,6 +380,15 @@ export interface PrescriptionEsignConfig {
|
||||
review_enabled?: boolean
|
||||
}
|
||||
|
||||
export interface PrescriptionEsignLogEntry {
|
||||
event: string
|
||||
label: string
|
||||
time: number
|
||||
source: 'tsa' | 'system' | 'local'
|
||||
actor_name?: string
|
||||
message?: string
|
||||
}
|
||||
|
||||
export interface PrescriptionEsignStatus extends PrescriptionEsignConfig {
|
||||
required: boolean
|
||||
status: 'pending' | 'authenticating' | 'signing' | 'signed' | 'failed' | 'uncertain' | 'voided' | 'legacy'
|
||||
@@ -396,8 +405,17 @@ export interface PrescriptionEsignStatus extends PrescriptionEsignConfig {
|
||||
issued_at?: number
|
||||
signature_time?: number
|
||||
signature_time_source?: 'tsa' | 'local' | ''
|
||||
doctor_signer_name?: string
|
||||
review_required?: boolean
|
||||
review_state?: PrescriptionEsignReviewStatus['state']
|
||||
review_submitted_at?: number
|
||||
awaiting_upload?: boolean
|
||||
can_submit_for_review?: boolean
|
||||
can_review_prescription?: boolean
|
||||
review_signer_name?: string
|
||||
review_signature?: string
|
||||
review_signature_time?: number
|
||||
signing_log?: PrescriptionEsignLogEntry[]
|
||||
signed_at?: number
|
||||
auth_url?: string
|
||||
}
|
||||
@@ -449,6 +467,8 @@ export interface PrescriptionEsignDoctorStatus {
|
||||
enabled: boolean
|
||||
status: 'unbound' | 'needs_mobile' | 'renewal_required' | 'authenticating' | 'binding_required' | 'ready'
|
||||
cert_expires_at: number
|
||||
certificate_state?: 'valid' | 'renewal_required' | 'unconfirmed'
|
||||
can_edit_signer_name?: boolean
|
||||
identity_details_required?: boolean
|
||||
quicksign_enabled?: boolean
|
||||
quicksign_authorizing?: boolean
|
||||
@@ -463,8 +483,12 @@ export function prescriptionEsignConfig(): Promise<PrescriptionEsignConfig> {
|
||||
return request.get({ url: '/tcm.prescription/esignConfig' })
|
||||
}
|
||||
|
||||
export function prescriptionEsignStatus(params: { id: number }): Promise<PrescriptionEsignStatus> {
|
||||
return request.get({ url: '/tcm.prescription/esignStatus', params })
|
||||
export function prescriptionEsignSetConfig(params: { enabled: boolean }): Promise<PrescriptionEsignConfig> {
|
||||
return request.post({ url: '/tcm.prescription/esignSetConfig', params })
|
||||
}
|
||||
|
||||
export function prescriptionEsignStatus(params: { id: number }, signal?: AbortSignal): Promise<PrescriptionEsignStatus> {
|
||||
return request.get({ url: '/tcm.prescription/esignStatus', params, signal }, { ignoreCancelToken: true })
|
||||
}
|
||||
|
||||
/** Read-only identity readiness; this endpoint never submits a signature. */
|
||||
@@ -496,7 +520,7 @@ export function prescriptionEsignDoctorStatus(signal?: AbortSignal): Promise<Pre
|
||||
)
|
||||
}
|
||||
|
||||
export function prescriptionEsignDoctorStart(params: { mobile?: string }): Promise<PrescriptionEsignDoctorStatus> {
|
||||
export function prescriptionEsignDoctorStart(params: { mobile?: string; signer_name?: string }): Promise<PrescriptionEsignDoctorStatus> {
|
||||
return request.post(
|
||||
{ url: '/tcm.prescription/esignDoctorStart', params, timeout: 180000 },
|
||||
{ isOpenRetry: false, retryCount: 0, ignoreCancelToken: true }
|
||||
@@ -557,8 +581,8 @@ export function prescriptionDelete(params: { id: number }) {
|
||||
}
|
||||
|
||||
// 处方详情
|
||||
export function prescriptionDetail(params: { id: number }) {
|
||||
return request.get({ url: '/tcm.prescription/detail', params })
|
||||
export function prescriptionDetail(params: { id: number }, signal?: AbortSignal) {
|
||||
return request.get({ url: '/tcm.prescription/detail', params, signal }, signal ? { ignoreCancelToken: true } : undefined)
|
||||
}
|
||||
|
||||
// 根据诊单获取处方列表
|
||||
@@ -572,10 +596,17 @@ export function prescriptionGetByAppointment(params: { appointment_id: number })
|
||||
}
|
||||
|
||||
// 作废处方
|
||||
export function prescriptionVoid(params: { id: number }) {
|
||||
export function prescriptionVoid(params: { id: number; pending_only?: boolean }) {
|
||||
return request.post({ url: '/tcm.prescription/void', params })
|
||||
}
|
||||
|
||||
export function prescriptionSubmitForReview(params: {
|
||||
id: number
|
||||
}): Promise<{ review_submitted_at: number; can_submit_for_review: false }> {
|
||||
return request.post({ url: '/tcm.prescription/submitForReview', params },
|
||||
{ isOpenRetry: false, retryCount: 0, ignoreCancelToken: true })
|
||||
}
|
||||
|
||||
/** 处方审核:action approve | reject(驳回同时作废处方) */
|
||||
export function prescriptionAudit(params: {
|
||||
id: number
|
||||
@@ -816,7 +847,7 @@ export function prescriptionOrderSetShipMode(params: { id: number; ship_mode: 'g
|
||||
|
||||
// ========== 处方库 ==========
|
||||
|
||||
export type PrescriptionAiProfile = 'qwen' | 'openai'
|
||||
export type PrescriptionAiProfile = 'qwen' | 'openai' | 'doubao'
|
||||
|
||||
export interface PrescriptionLibraryHerb {
|
||||
medicine_id?: number
|
||||
|
||||
@@ -2,14 +2,19 @@
|
||||
<el-dialog
|
||||
:model-value="true"
|
||||
:title="reviewer ? '审核签署身份' : '医生电子签署身份'"
|
||||
:width="frameUrl ? 'min(760px, 94vw)' : 'min(520px, 94vw)'"
|
||||
width="min(760px, 94vw)"
|
||||
top="5vh"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:before-close="dismiss"
|
||||
>
|
||||
<p class="doctor-esign__message" role="status">{{ guidance }}</p>
|
||||
<dl v-if="state?.enabled && state.status === 'ready'" class="doctor-esign__expiry">
|
||||
<p v-if="statusNotice" class="doctor-esign__message" role="status">{{ statusNotice }}</p>
|
||||
<dl v-if="state && (certificateLabel || grantActive)" class="doctor-esign__expiry">
|
||||
<template v-if="certificateLabel">
|
||||
<dt>签署证书状态</dt>
|
||||
<dd>{{ certificateLabel }}</dd>
|
||||
</template>
|
||||
<template v-if="state.cert_expires_at">
|
||||
<dt>签署证书有效期至</dt>
|
||||
<dd>{{ formatExpiry(state.cert_expires_at) }}</dd>
|
||||
@@ -22,6 +27,17 @@
|
||||
</template>
|
||||
</dl>
|
||||
<p v-if="error" class="doctor-esign__error" role="alert">{{ error }}</p>
|
||||
<label v-if="needsSignerName" class="doctor-esign__field">
|
||||
证件姓名
|
||||
<el-input
|
||||
v-model="signerName"
|
||||
:disabled="!!pending"
|
||||
autocomplete="off"
|
||||
:spellcheck="false"
|
||||
required
|
||||
placeholder="请输入与本人有效证件一致的姓名"
|
||||
/>
|
||||
</label>
|
||||
<label v-if="needsMobile" class="doctor-esign__field">
|
||||
本人手机号码
|
||||
<el-input
|
||||
@@ -67,11 +83,18 @@
|
||||
{{ state?.quicksign_authorizing ? '确认快捷签授权' : '确认绑定签署身份' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canResume && !state?.quicksign_authorizing"
|
||||
v-if="canRestartWithSignerName"
|
||||
:disabled="!!pending"
|
||||
@click="enterSignerName"
|
||||
>修改证件姓名</el-button>
|
||||
<el-button
|
||||
v-if="canResume && !state?.quicksign_authorizing && !canRestartWithSignerName"
|
||||
:disabled="!!pending"
|
||||
@click="enterMobile"
|
||||
>重新输入手机号</el-button>
|
||||
<el-button :disabled="!!pending" @click="refresh">检查状态</el-button>
|
||||
<el-button :disabled="!!pending" @click="checkStatus">
|
||||
{{ checkingIdentity ? '检查认证状态' : '重新校验证书' }}
|
||||
</el-button>
|
||||
<el-button v-if="frameUrl" link @click="authenticationUnavailable">验证页面不可用</el-button>
|
||||
<el-button @click="dismiss">关闭</el-button>
|
||||
</div>
|
||||
@@ -112,21 +135,42 @@ const state = ref<ReturnType<typeof validateStatus> | null>(null)
|
||||
const pending = ref<DoctorRequest | null>(null)
|
||||
const frameUrl = ref('')
|
||||
const mobile = ref('')
|
||||
const signerName = ref('')
|
||||
const identityNumber = ref('')
|
||||
const editingMobile = ref(false)
|
||||
const error = ref('')
|
||||
const statusNotice = ref('')
|
||||
const now = ref(Date.now() + props.serverTimeOffsetMs)
|
||||
|
||||
const authUrl = computed(() => state.value?.auth_url ?? '')
|
||||
const authenticating = computed(() => state.value?.enabled === true && state.value.status === 'authenticating')
|
||||
const canResume = computed(() => authenticating.value && !!authUrl.value && !frameUrl.value && !editingMobile.value)
|
||||
const canEditSignerName = computed(() => props.reviewer === true && state.value?.enabled === true
|
||||
&& state.value.can_edit_signer_name === true && !state.value.quicksign_authorizing)
|
||||
const canRestartWithSignerName = computed(() => canEditSignerName.value && authenticating.value && !editingMobile.value)
|
||||
const needsSignerName = computed(() => canEditSignerName.value
|
||||
&& (state.value?.status === 'unbound' || state.value?.status === 'needs_mobile'
|
||||
|| (authenticating.value && editingMobile.value)))
|
||||
const canComplete = computed(() => state.value?.enabled === true && state.value.status === 'binding_required')
|
||||
const checkingIdentity = computed(() => authenticating.value || canComplete.value)
|
||||
const needsIdentityNumber = computed(() => canComplete.value && !state.value?.quicksign_authorizing
|
||||
&& state.value?.identity_details_required === true)
|
||||
const needsMobile = computed(() => state.value?.enabled === true
|
||||
&& (enrollmentStatuses.includes(state.value.status) || editingMobile.value))
|
||||
const certificateState = computed(() => {
|
||||
const current = state.value
|
||||
if (!current?.enabled) return ''
|
||||
if (current.status === 'unbound') return 'unbound'
|
||||
if (current.certificate_state === 'unconfirmed') return 'unconfirmed'
|
||||
if (current.status === 'renewal_required' || current.certificate_state === 'renewal_required') return 'renewal_required'
|
||||
if (current.status !== 'ready' && current.status !== 'needs_mobile') return ''
|
||||
return current.cert_expires_at * 1000 > now.value ? 'valid' : 'renewal_required'
|
||||
})
|
||||
const certificateLabel = computed(() => ({
|
||||
'': '', unbound: '未绑定', valid: '有效', renewal_required: '需要续期', unconfirmed: '暂无法确认'
|
||||
})[certificateState.value])
|
||||
const quickReady = computed(() => state.value?.enabled === true && state.value.status === 'ready'
|
||||
&& state.value.quicksign_enabled === true)
|
||||
&& certificateState.value === 'valid' && state.value.quicksign_enabled === true)
|
||||
const grantActive = computed(() => quickReady.value && !!state.value && !state.value.quicksign_unavailable_reason
|
||||
&& (state.value.quicksign_remaining_times ?? 0) > 0 && state.value.quicksign_expires_at * 1000 > now.value)
|
||||
const canAuthorizeQuick = computed(() => quickReady.value && !grantActive.value)
|
||||
@@ -137,15 +181,19 @@ const startLabel = computed(() => {
|
||||
})
|
||||
const guidance = computed(() => {
|
||||
const current = state.value
|
||||
if (!current) return pending.value === 'status' ? '正在查询医生签署身份…' : ''
|
||||
if (pending.value === 'status' && !checkingIdentity.value) return '正在向 e签宝校验证书…'
|
||||
if (!current) return ''
|
||||
if (!current.enabled) return '当前环境未启用医生电子签署身份。'
|
||||
if (needsSignerName.value) return '请填写与本人有效证件一致的姓名和本人手机号码,完成人脸认证。'
|
||||
switch (current.status) {
|
||||
case 'unbound':
|
||||
return '首次电子签署前,请验证本人身份并绑定签署证书。'
|
||||
case 'needs_mobile':
|
||||
return '请使用本人手机号码完成签署身份验证。'
|
||||
case 'renewal_required':
|
||||
return '签署证书需要续期,请使用本人手机号码完成人脸认证。'
|
||||
return certificateState.value === 'unconfirmed'
|
||||
? '暂无法确认证书状态,可重新校验,或使用本人手机号码发起续期认证。'
|
||||
: '签署证书需要续期,请使用本人手机号码完成人脸认证。'
|
||||
case 'authenticating':
|
||||
if (editingMobile.value) return '请使用本人手机号码完成人脸认证。'
|
||||
if (current.authUrlUnavailable) return '验证链接不可用,请检查状态后重试。'
|
||||
@@ -159,9 +207,11 @@ const guidance = computed(() => {
|
||||
if (needsIdentityNumber.value) return '人脸认证已通过。首次绑定证书需要补充与本次认证一致的身份证号码。'
|
||||
return '人脸认证已通过,请确认完成本人的签署身份认证。'
|
||||
case 'ready': {
|
||||
if (certificateState.value !== 'valid') return '请重新校验签署证书后继续。'
|
||||
if (!quickReady.value) return '医生签署身份已就绪。'
|
||||
if (grantActive.value) return props.reviewer ? '快捷签授权有效。每张处方由审核人本人确认签名。'
|
||||
: '快捷签授权有效。每张处方仍需开方医生本人确认签名。'
|
||||
if (grantActive.value) return props.reviewer
|
||||
? '快捷签授权有效。每张处方由药师本人确认签名。'
|
||||
: '快捷签授权有效。请回到处方中,由开方医生本人确认签名。'
|
||||
const reason = current.quicksign_unavailable_reason
|
||||
if (reason === 'expired' || (current.quicksign_expires_at > 0 && current.quicksign_expires_at * 1000 <= now.value)) {
|
||||
return '快捷签授权已过期,请重新授权。'
|
||||
@@ -190,11 +240,14 @@ function validTime(value: number) {
|
||||
|
||||
function validateStatus(result: PrescriptionEsignDoctorStatus) {
|
||||
const {
|
||||
enabled, status, cert_expires_at,
|
||||
enabled, status, cert_expires_at, certificate_state,
|
||||
can_edit_signer_name = false,
|
||||
identity_details_required = false, quicksign_enabled = false, quicksign_authorizing = false,
|
||||
quicksign_expires_at = 0, quicksign_remaining_times = 0, quicksign_unavailable_reason = ''
|
||||
} = result
|
||||
if (!statuses.includes(status) || typeof enabled !== 'boolean'
|
||||
|| typeof can_edit_signer_name !== 'boolean'
|
||||
|| (certificate_state !== undefined && !['valid', 'renewal_required', 'unconfirmed'].includes(certificate_state))
|
||||
|| typeof quicksign_enabled !== 'boolean' || typeof quicksign_authorizing !== 'boolean'
|
||||
|| !validTime(cert_expires_at) || !validTime(quicksign_expires_at)
|
||||
|| typeof identity_details_required !== 'boolean'
|
||||
@@ -207,7 +260,7 @@ function validateStatus(result: PrescriptionEsignDoctorStatus) {
|
||||
const providerUrl = enabled && status === 'authenticating' ? result.auth_url : undefined
|
||||
const auth_url = safeEsignAuthUrl(providerUrl)
|
||||
return {
|
||||
enabled, status, cert_expires_at, identity_details_required, quicksign_enabled, quicksign_authorizing,
|
||||
enabled, status, cert_expires_at, certificate_state, can_edit_signer_name, identity_details_required, quicksign_enabled, quicksign_authorizing,
|
||||
quicksign_expires_at, quicksign_remaining_times, quicksign_unavailable_reason, auth_url,
|
||||
authUrlUnavailable: Boolean(providerUrl && !auth_url)
|
||||
}
|
||||
@@ -215,6 +268,7 @@ function validateStatus(result: PrescriptionEsignDoctorStatus) {
|
||||
|
||||
function clearInputs() {
|
||||
mobile.value = ''
|
||||
signerName.value = ''
|
||||
identityNumber.value = ''
|
||||
}
|
||||
|
||||
@@ -239,6 +293,7 @@ function clearStatus() {
|
||||
state.value = null
|
||||
editingMobile.value = false
|
||||
error.value = ''
|
||||
statusNotice.value = ''
|
||||
}
|
||||
|
||||
function dismiss() {
|
||||
@@ -257,8 +312,9 @@ function accept(result: ReturnType<typeof validateStatus>) {
|
||||
editingMobile.value = false
|
||||
state.value = result
|
||||
if (!authenticating.value || (frameUrl.value && frameUrl.value !== authUrl.value)) stopAuthentication()
|
||||
if (grantActive.value) {
|
||||
const expiresIn = result.quicksign_expires_at * 1000 - now.value
|
||||
if (certificateState.value === 'valid') {
|
||||
const expiry = grantActive.value ? Math.min(result.cert_expires_at, result.quicksign_expires_at) : result.cert_expires_at
|
||||
const expiresIn = expiry * 1000 - now.value
|
||||
if (expiresIn <= 2147483647) {
|
||||
grantExpiryTimer = setTimeout(() => { now.value = Date.now() + props.serverTimeOffsetMs }, expiresIn)
|
||||
}
|
||||
@@ -292,6 +348,13 @@ function enterMobile() {
|
||||
error.value = ''
|
||||
}
|
||||
|
||||
function enterSignerName() {
|
||||
if (!canAct() || pending.value || !canRestartWithSignerName.value) return
|
||||
stopAuthentication()
|
||||
editingMobile.value = true
|
||||
error.value = ''
|
||||
}
|
||||
|
||||
async function submit(
|
||||
kind: DoctorRequest,
|
||||
request: () => Promise<PrescriptionEsignDoctorStatus>
|
||||
@@ -301,6 +364,7 @@ async function submit(
|
||||
clearInputs()
|
||||
clearTimeout(pollTimer)
|
||||
error.value = ''
|
||||
statusNotice.value = ''
|
||||
pending.value = kind
|
||||
try {
|
||||
const result = validateStatus(await request())
|
||||
@@ -309,7 +373,7 @@ async function submit(
|
||||
} catch {
|
||||
if (current !== generation || !canAct()) return
|
||||
clearStatus()
|
||||
error.value = '医生签署身份状态待确认,请检查状态后继续。'
|
||||
error.value = kind === 'status' ? '签署身份状态待确认,请重新校验证书或检查认证状态。' : '签署身份操作结果待确认,请检查状态后继续。'
|
||||
return
|
||||
} finally {
|
||||
if (current === generation) pending.value = null
|
||||
@@ -329,18 +393,35 @@ async function refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
async function checkStatus() {
|
||||
if (!canAct() || pending.value) return
|
||||
const checkingFlow = checkingIdentity.value
|
||||
await refresh()
|
||||
if (!canAct() || !state.value?.enabled || error.value) return
|
||||
if (checkingFlow) statusNotice.value = '认证状态已更新。'
|
||||
else if (certificateState.value === 'valid') statusNotice.value = '证书校验通过。'
|
||||
}
|
||||
|
||||
async function start() {
|
||||
if (!canAct() || pending.value) return
|
||||
if (canAuthorizeQuick.value) {
|
||||
await submit('start', () => prescriptionEsignDoctorStart({}))
|
||||
} else if (needsMobile.value) {
|
||||
const number = mobile.value.trim()
|
||||
clearInputs()
|
||||
const name = needsSignerName.value ? signerName.value.trim() : undefined
|
||||
if (!/^1[3-9]\d{9}$/.test(number)) {
|
||||
if (name === undefined) clearInputs()
|
||||
error.value = '请输入有效的大陆手机号码。'
|
||||
return
|
||||
}
|
||||
await submit('start', () => prescriptionEsignDoctorStart({ mobile: number }))
|
||||
if (name !== undefined && !/^[\p{Script=Han}A-Za-z][\p{Script=Han}A-Za-z·()\-]{1,49}$/u.test(name)) {
|
||||
error.value = '证件姓名须为 2 至 50 个字符,以汉字或英文字母开头,可包含间隔号(·)、半角括号和连字符。'
|
||||
return
|
||||
}
|
||||
await submit('start', () => prescriptionEsignDoctorStart({
|
||||
mobile: number,
|
||||
...(name !== undefined ? { signer_name: name } : {})
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +442,10 @@ async function complete() {
|
||||
|
||||
function onVisibilityChange() {
|
||||
if (document.visibilityState === 'visible') void refresh()
|
||||
else clearStatus()
|
||||
else {
|
||||
clearStatus()
|
||||
statusNotice.value = '身份验证已暂停,返回此页后会重新检查。'
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -393,6 +477,7 @@ onBeforeUnmount(() => {
|
||||
.doctor-esign__expiry dt { color: var(--el-text-color-secondary); }
|
||||
.doctor-esign__expiry dd { margin: 0; }
|
||||
.doctor-esign__field { display: grid; gap: 6px; max-width: 350px; }
|
||||
.doctor-esign__field + .doctor-esign__field { margin-top: 12px; }
|
||||
.doctor-esign__frame {
|
||||
display: block;
|
||||
width: 100%;
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
<template>
|
||||
<section v-show="showControls || signingTime || reviewState?.required" class="esign-panel" aria-label="处方电子签署" v-loading="busy">
|
||||
<section v-show="showControls || signingTime || showSteps || showSigningLog" class="esign-panel" aria-label="处方电子签署" :aria-busy="busy">
|
||||
<div class="esign-panel__heading">
|
||||
<strong>医师电子签署</strong>
|
||||
<el-tag v-if="confirmed && state?.environment === 'sandbox' && state.status !== 'legacy'" type="warning" size="small">
|
||||
<strong>{{ reviewRequired ? '处方电子签署' : '医师电子签署' }}</strong>
|
||||
<el-tag v-if="state?.environment === 'sandbox' && state.status !== 'legacy'" type="warning" size="small">
|
||||
沙箱测试
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-steps v-if="(confirmed || busy) && state?.required && state.status !== 'voided' && (!audit || state.can_sign || state.can_retry_verify)" :active="activeStep" finish-status="success" simple>
|
||||
<el-step title="处方草稿已保存" />
|
||||
<el-step :title="verificationMethod === 'quick' ? '核对快捷签授权' : verificationMethod === 'sms' ? '校验短信验证码' : '验证医生身份'" />
|
||||
<el-step title="签名并完成" />
|
||||
</el-steps>
|
||||
<div v-if="showSteps" class="esign-panel__progress">
|
||||
<el-steps
|
||||
:active="activeStep"
|
||||
:class="{ 'esign-panel__steps--review': reviewRequired }"
|
||||
finish-status="success"
|
||||
simple
|
||||
>
|
||||
<el-step title="处方草稿已保存" />
|
||||
<el-step v-if="tracksUpload" title="上传处方" />
|
||||
<el-step v-else :title="verificationMethod === 'quick' ? '核对快捷签授权' : verificationMethod === 'sms' ? '校验短信验证码' : '验证医生身份'" />
|
||||
<el-step :title="reviewRequired || tracksUpload ? '医师签署' : '签名并完成'" />
|
||||
<el-step v-if="reviewRequired" title="药师签署" />
|
||||
</el-steps>
|
||||
</div>
|
||||
<p v-if="message" class="esign-panel__message" aria-live="polite">{{ message }}</p>
|
||||
<p v-if="statusNotice" class="esign-panel__message" role="status">{{ statusNotice }}</p>
|
||||
<div v-if="signingTime" class="esign-panel__message" aria-live="polite">
|
||||
<div v-if="signingTime.issuedTime">开具时间:{{ signingTime.issuedTime }}(北京时间)</div>
|
||||
<div v-if="signingTime.signatureTime">
|
||||
@@ -21,11 +31,26 @@
|
||||
<div>签署时间待核实</div>
|
||||
<div v-if="signingTime.verifiedTime">系统验签完成时间:{{ signingTime.verifiedTime }}(北京时间)</div>
|
||||
</template>
|
||||
<div v-if="!audit && state?.review_signature_time">
|
||||
审核签署时间:{{ formatSigningTime(state.review_signature_time) }}(北京时间 · 可信时间戳)
|
||||
<span v-if="state.review_signer_name"> · {{ state.review_signer_name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="reviewSigning" class="esign-panel__message esign-panel__review-signature" aria-live="polite">
|
||||
药师签署时间:<span class="esign-panel__timestamp">{{ reviewSigning.time }}</span>(北京时间 · 可信时间戳)
|
||||
<span v-if="reviewSigning.name"> · {{ reviewSigning.name }}</span>
|
||||
</p>
|
||||
<details v-if="showSigningLog" :key="prescriptionId" class="esign-panel__log">
|
||||
<summary>签署日志</summary>
|
||||
<ol v-if="signingLog.length" class="esign-panel__log-list">
|
||||
<li v-for="(entry, index) in signingLog" :key="`${entry.event}-${entry.time}-${index}`">
|
||||
<strong>{{ entry.label }}</strong>
|
||||
<span v-if="entry.actor_name"> · {{ entry.actor_name }}</span>
|
||||
<div class="esign-panel__log-meta">
|
||||
<time :datetime="new Date(entry.time * 1000).toISOString()">{{ entry.timeText }}</time>
|
||||
(北京时间 · {{ entry.sourceLabel }})
|
||||
</div>
|
||||
<div v-if="entry.message" class="esign-panel__log-meta">{{ entry.message }}</div>
|
||||
</li>
|
||||
</ol>
|
||||
<p v-else class="esign-panel__message">暂无签署日志。</p>
|
||||
</details>
|
||||
<p v-if="error" class="esign-panel__error" role="alert">{{ error }}</p>
|
||||
<label v-if="identityDetailsRequired" class="esign-panel__identity">
|
||||
本次验证使用的身份证号
|
||||
@@ -52,19 +77,31 @@
|
||||
/>
|
||||
</label>
|
||||
<div v-if="showControls && prescriptionId > 0" class="esign-panel__actions">
|
||||
<el-button type="primary" size="small" :disabled="busy || dialogVisible || (action.run === sendSms && smsSendCoolingDown)" @click="action.run">
|
||||
<el-button type="primary" size="small" :disabled="busy || dialogVisible || (action.run === sendSms && smsSendCoolingDown)" @click="runAction">
|
||||
{{ action.label }}
|
||||
</el-button>
|
||||
<el-button v-if="smsCodeEntry" size="small" :disabled="busy || smsSendCoolingDown" @click="sendSms">
|
||||
{{ smsSendCoolingDown ? '请稍后重新发送' : '重新发送验证码' }}
|
||||
</el-button>
|
||||
<el-button v-if="readiness" size="small" :disabled="busy" @click="closeAuthentication">取消</el-button>
|
||||
<el-button v-if="readiness || smsCodeEntry" size="small" :disabled="busy" @click="closeAuthentication">退出签署</el-button>
|
||||
<el-button
|
||||
v-if="canOpenCertificate"
|
||||
size="small"
|
||||
:disabled="busy || dialogVisible"
|
||||
@click="doctorIdentityOpen = true"
|
||||
>签署身份与证书</el-button>
|
||||
</div>
|
||||
<EsignDoctorDialog
|
||||
v-if="doctorIdentityOpen"
|
||||
:server-time-offset-ms="userStore.serverTimeOffsetMs"
|
||||
@close="closeDoctorIdentity"
|
||||
/>
|
||||
<EsignReviewPanel
|
||||
v-if="audit && confirmed && state"
|
||||
v-if="audit && state"
|
||||
:prescription-id="prescriptionId"
|
||||
:order-id="reviewOrderId"
|
||||
:doctor-signed="state.status === 'signed'"
|
||||
:doctor-status-confirmed="confirmed"
|
||||
@change="updateReview"
|
||||
/>
|
||||
<el-dialog
|
||||
@@ -89,7 +126,7 @@
|
||||
/>
|
||||
<template #footer>
|
||||
<el-button link @click="authenticationUnavailable">验证页面不可用</el-button>
|
||||
<el-button @click="closeAuthentication">关闭</el-button>
|
||||
<el-button @click="closeAuthentication">退出签署</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</section>
|
||||
@@ -104,6 +141,7 @@ import {
|
||||
prescriptionEsignStart,
|
||||
prescriptionEsignStatus,
|
||||
prescriptionEsignVerifyWillingness,
|
||||
prescriptionSubmitForReview,
|
||||
type PrescriptionEsignIdentityStatus,
|
||||
type PrescriptionEsignReviewStatus,
|
||||
type PrescriptionEsignStatus
|
||||
@@ -119,12 +157,15 @@ import {
|
||||
validateEsignStatus
|
||||
} from '@/utils/prescription-esign'
|
||||
import EsignReviewPanel from '@/components/EsignReviewPanel.vue'
|
||||
import EsignDoctorDialog from '@/components/EsignDoctorDialog.vue'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
|
||||
const props = defineProps<{ prescriptionId: number; initialState?: PrescriptionEsignStatus; audit?: boolean; reviewOrderId?: number }>()
|
||||
const emit = defineEmits<{
|
||||
(e: 'status-change', state: PrescriptionEsignStatus): void
|
||||
(e: 'review-change', state: PrescriptionEsignReviewStatus | null): void
|
||||
}>()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const reviewState = ref<PrescriptionEsignReviewStatus | null>(null)
|
||||
function updateReview(result: PrescriptionEsignReviewStatus | null) {
|
||||
@@ -141,12 +182,52 @@ function initialStatus(): PrescriptionEsignStatus | null {
|
||||
}
|
||||
|
||||
const state = ref<PrescriptionEsignStatus | null>(initialStatus())
|
||||
const work = ref<'status' | 'start' | 'identity' | 'send-sms' | 'verify-sms' | 'sign' | 'verify' | 'download' | null>(null)
|
||||
const work = ref<'status' | 'upload' | 'start' | 'identity' | 'send-sms' | 'verify-sms' | 'sign' | 'verify' | 'download' | null>(null)
|
||||
const busy = computed(() => work.value !== null)
|
||||
const confirmed = ref(false)
|
||||
const awaitingUpload = computed(() => state.value?.awaiting_upload === true)
|
||||
const tracksUpload = computed(() => awaitingUpload.value || Number(state.value?.review_submitted_at) > 0)
|
||||
const showControls = computed(() => !props.audit || !confirmed.value || !canApprovePrescriptionEsign(state.value))
|
||||
const signingTime = computed(() => prescriptionEsignTiming(state.value))
|
||||
const logSourceLabels = { tsa: '可信时间戳', system: '系统记录', local: '签名记录时间' }
|
||||
const signingLog = computed(() => {
|
||||
const entries = state.value?.signing_log
|
||||
if (!Array.isArray(entries)) return []
|
||||
|
||||
return entries.flatMap((entry) => {
|
||||
if (!entry || typeof entry.event !== 'string' || !entry.event.trim()
|
||||
|| typeof entry.label !== 'string' || !entry.label.trim()
|
||||
|| !['tsa', 'system', 'local'].includes(entry.source)) return []
|
||||
const timeText = formatSigningTime(entry.time)
|
||||
return timeText ? [{ ...entry, timeText, sourceLabel: logSourceLabels[entry.source] }] : []
|
||||
}).sort((a, b) => a.time - b.time)
|
||||
})
|
||||
const showSigningLog = computed(() => signingLog.value.length > 0
|
||||
|| (!props.audit && (state.value?.required === true || Boolean(signingTime.value))))
|
||||
const reviewSigning = computed(() => {
|
||||
const current = state.value
|
||||
if (current?.status !== 'signed' && current?.status !== 'voided') return null
|
||||
|
||||
const time = formatSigningTime(current.review_signature_time)
|
||||
if (time) return { time, name: current.review_signer_name }
|
||||
|
||||
const review = reviewState.value
|
||||
if (review?.state !== 'signed') return null
|
||||
const auditTime = formatSigningTime(review.signature_time)
|
||||
return auditTime ? { time: auditTime, name: review.signer_name } : null
|
||||
})
|
||||
const reviewRequired = computed(() => state.value?.review_required === true || reviewState.value?.required === true
|
||||
|| Boolean(reviewSigning.value))
|
||||
const showSteps = computed(() => {
|
||||
const current = state.value
|
||||
if (!current) return false
|
||||
if (reviewRequired.value) return current.status !== 'voided' || Boolean(reviewSigning.value)
|
||||
return (confirmed.value || busy.value) && current.required && current.status !== 'voided'
|
||||
&& (!props.audit || current.can_sign || current.can_retry_verify === true)
|
||||
})
|
||||
const error = ref('')
|
||||
const statusNotice = ref('')
|
||||
const doctorIdentityOpen = ref(false)
|
||||
const dialogVisible = ref(false)
|
||||
const readiness = ref<'ready' | 'details' | null>(null)
|
||||
const restartRequired = ref(false)
|
||||
@@ -162,7 +243,7 @@ const verificationMethod = computed(() => state.value?.verification_method)
|
||||
const accountSetupMessage = computed(() => {
|
||||
const current = state.value
|
||||
if (!current?.can_sign || !verificationMethod.value) return ''
|
||||
const settings = '请返回页面右上角账号菜单,在「医生电子签署身份」中处理。完成后回到处方查询签署状态。'
|
||||
const settings = '请打开「签署身份与证书」处理后继续。'
|
||||
if (current.doctor_identity_required && !(verificationMethod.value === 'sms' && smsProfileReady.value)) {
|
||||
return `${current.message || '请先完成医生签署身份认证。'} ${settings}`
|
||||
}
|
||||
@@ -177,21 +258,25 @@ const smsCodeEntry = computed(() => confirmed.value && smsCodeState.value === 'e
|
||||
const identityResumable = computed(() => !verificationMethod.value && canCheckEsignIdentity(state.value)
|
||||
&& (state.value?.can_resume_identity === true || Boolean(authUrl.value)))
|
||||
const activeStep = computed(() => {
|
||||
if (state.value?.status === 'signed') return 3
|
||||
if (awaitingUpload.value) return 1
|
||||
if (reviewSigning.value) return 4
|
||||
if (state.value?.status === 'signed' && state.value.can_download) return 3
|
||||
if (tracksUpload.value) return 2
|
||||
if (readiness.value || work.value === 'sign' || work.value === 'verify'
|
||||
|| state.value?.status === 'signing' || state.value?.status === 'uncertain') return 2
|
||||
return 1
|
||||
})
|
||||
const message = computed(() => {
|
||||
if (props.prescriptionId <= 0) return '缺少关联处方,无法核对签署状态。'
|
||||
if (props.audit && work.value === 'status') return '正在查询签署状态…'
|
||||
if (work.value === 'identity' && verificationMethod.value === 'quick') return '正在核对快捷签授权…'
|
||||
if (work.value === 'identity' && verificationMethod.value === 'sms') return '正在查询短信验证状态…'
|
||||
if (work.value === 'status') return '正在查询签署状态…'
|
||||
if (work.value === 'upload') return '正在上传处方…'
|
||||
if (work.value === 'identity' && !readiness.value && verificationMethod.value === 'quick') return '正在核对快捷签授权…'
|
||||
if (work.value === 'identity' && !readiness.value && verificationMethod.value === 'sms') return '正在查询短信验证状态…'
|
||||
if (work.value === 'send-sms') return '正在向医生绑定的手机号发送验证码…'
|
||||
if (work.value === 'verify-sms') return '正在校验短信验证码…'
|
||||
if (work.value === 'sign') return '正在签署处方…'
|
||||
if (work.value === 'verify') return '正在校验已签文件…'
|
||||
if (!confirmed.value || error.value) return ''
|
||||
if (error.value || (!confirmed.value && !state.value)) return ''
|
||||
if (readiness.value) {
|
||||
if (verificationMethod.value === 'quick') return '快捷签授权已核对。请核对处方内容后确认签名。'
|
||||
if (verificationMethod.value === 'sms') return '短信验证码已通过。请核对处方内容后确认签名。'
|
||||
@@ -199,8 +284,18 @@ const message = computed(() => {
|
||||
}
|
||||
const current = state.value
|
||||
if (!current) return ''
|
||||
if (awaitingUpload.value) {
|
||||
if (current.can_submit_for_review !== true) return current.message || '请开方医生先上传处方。'
|
||||
if (current.status === 'signed' && current.can_download) return '医师已签署,请上传处方后进入审核。'
|
||||
return current.required ? '请先上传处方,再由开方医生本人签署。' : '请上传处方,提交药师审核。'
|
||||
}
|
||||
if (current.status === 'legacy' && !current.enabled) return current.message || '此处方使用手写签名。'
|
||||
if (current.status === 'signed') return current.can_download ? '处方已签署。' : '处方已签署,原件暂不可用。'
|
||||
if (current.status === 'signed') {
|
||||
if (reviewRequired.value && !reviewSigning.value) {
|
||||
return current.can_download ? '医师已签署,等待药师审核签署。' : '医师已签署,原件暂不可用,请查询签署状态。'
|
||||
}
|
||||
return current.can_download ? '处方已签署。' : '处方已签署,原件暂不可用。'
|
||||
}
|
||||
if (current.required && ['pending', 'authenticating', 'failed'].includes(current.status)) {
|
||||
if (accountSetupMessage.value) return accountSetupMessage.value
|
||||
if (canUseMethod(current, 'quick')) {
|
||||
@@ -224,6 +319,11 @@ const message = computed(() => {
|
||||
})
|
||||
const action = computed(() => {
|
||||
if (!confirmed.value) return { label: '查询签署状态', run: refresh }
|
||||
if (awaitingUpload.value) {
|
||||
return !props.audit && state.value?.can_submit_for_review === true
|
||||
? { label: '上传处方', run: upload }
|
||||
: { label: '查询签署状态', run: refresh }
|
||||
}
|
||||
if (state.value?.can_download && (state.value.status === 'signed' || state.value.status === 'voided')) {
|
||||
return { label: '下载已签 PDF', run: download }
|
||||
}
|
||||
@@ -246,6 +346,8 @@ const action = computed(() => {
|
||||
}
|
||||
return { label: '查询签署状态', run: refresh }
|
||||
})
|
||||
const canOpenCertificate = computed(() => confirmed.value
|
||||
&& (canUseMethod(state.value, 'quick') || canUseMethod(state.value, 'sms')))
|
||||
|
||||
const pollInterval = 5000
|
||||
const authenticationTimeout = 10 * 60 * 1000
|
||||
@@ -268,6 +370,7 @@ function isCurrent(current: number, id: number) {
|
||||
|
||||
function canUseMethod(result: PrescriptionEsignStatus | null, method: VerificationMethod): boolean {
|
||||
return result?.verification_method === method && result.enabled && result.required && result.can_sign
|
||||
&& result.awaiting_upload !== true
|
||||
&& ['pending', 'authenticating', 'failed'].includes(result.status)
|
||||
}
|
||||
|
||||
@@ -300,7 +403,17 @@ function cancelWork() {
|
||||
}
|
||||
|
||||
function closeAuthentication() {
|
||||
if (dialogVisible.value || readiness.value) cancelWork()
|
||||
if (dialogVisible.value || readiness.value || smsCodeEntry.value) {
|
||||
cancelWork()
|
||||
confirmed.value = false
|
||||
error.value = ''
|
||||
statusNotice.value = '已退出本次签署,可查询状态后继续。'
|
||||
}
|
||||
}
|
||||
|
||||
function closeDoctorIdentity() {
|
||||
doctorIdentityOpen.value = false
|
||||
void refresh()
|
||||
}
|
||||
|
||||
function stopVerification(message: string) {
|
||||
@@ -574,8 +687,9 @@ async function refresh() {
|
||||
work.value = 'status'
|
||||
confirmed.value = false
|
||||
error.value = ''
|
||||
statusNotice.value = ''
|
||||
try {
|
||||
const result = validateEsignStatus(await prescriptionEsignStatus({ id }))
|
||||
const result = validateEsignStatus(await requestIdentity((signal) => prescriptionEsignStatus({ id }, signal)))
|
||||
if (!isCurrent(current, id)) return
|
||||
accept(result)
|
||||
// A previous SMS failure can retain the setup flag after the doctor fixes the profile.
|
||||
@@ -602,6 +716,45 @@ async function refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
async function runAction() {
|
||||
const run = action.value.run
|
||||
const current = operation
|
||||
await run()
|
||||
if (run === refresh && operation === current + 1 && confirmed.value && !error.value && isCurrent(operation, props.prescriptionId)) {
|
||||
statusNotice.value = '签署状态已更新。'
|
||||
}
|
||||
}
|
||||
|
||||
async function upload() {
|
||||
const before = state.value
|
||||
if (!canAct() || !confirmed.value || props.audit || !awaitingUpload.value || before?.can_submit_for_review !== true) return
|
||||
const id = props.prescriptionId
|
||||
const current = ++operation
|
||||
work.value = 'upload'
|
||||
error.value = ''
|
||||
statusNotice.value = ''
|
||||
try {
|
||||
const result = await prescriptionSubmitForReview({ id })
|
||||
if (!isCurrent(current, id)) return
|
||||
if (!Number.isSafeInteger(result?.review_submitted_at) || result.review_submitted_at <= 0) {
|
||||
throw new Error('无法核对上传结果')
|
||||
}
|
||||
accept({
|
||||
...before,
|
||||
review_submitted_at: result.review_submitted_at,
|
||||
awaiting_upload: false,
|
||||
can_submit_for_review: false
|
||||
})
|
||||
} catch {
|
||||
if (isCurrent(current, id)) error.value = '暂未确认处方上传,请重试。'
|
||||
return
|
||||
} finally {
|
||||
if (isCurrent(current, id)) work.value = null
|
||||
}
|
||||
await refresh()
|
||||
if (isCurrent(current + 1, id)) statusNotice.value = '处方已上传。'
|
||||
}
|
||||
|
||||
async function download() {
|
||||
if (!canAct() || !confirmed.value || !state.value?.can_download
|
||||
|| (state.value.status !== 'signed' && state.value.status !== 'voided')) return
|
||||
@@ -610,7 +763,7 @@ async function download() {
|
||||
work.value = 'download'
|
||||
error.value = ''
|
||||
try {
|
||||
const result = validateEsignStatus(await prescriptionEsignStatus({ id }))
|
||||
const result = validateEsignStatus(await requestIdentity((signal) => prescriptionEsignStatus({ id }, signal)))
|
||||
if (!isCurrent(current, id)) return
|
||||
accept(result)
|
||||
if (result.can_download && (result.status === 'signed' || result.status === 'voided')) {
|
||||
@@ -627,7 +780,12 @@ async function download() {
|
||||
|
||||
function onVisibilityChange() {
|
||||
if (document.visibilityState === 'visible') return
|
||||
if (dialogVisible.value || readiness.value) {
|
||||
confirmed.value = false
|
||||
statusNotice.value = '签署验证已暂停,可查询状态后继续。'
|
||||
}
|
||||
if (work.value === 'sign') error.value = '签署结果待确认,请查询签署状态。'
|
||||
if (work.value === 'upload') error.value = '上传结果待确认,请查询处方状态。'
|
||||
if (work.value === 'verify') error.value = '校验结果待确认,请查询签署状态。'
|
||||
if (work.value === 'send-sms') error.value = '短信发送状态待确认,请查询签署状态。'
|
||||
if (work.value === 'verify-sms') error.value = '短信校验结果待确认,请查询签署状态。'
|
||||
@@ -639,11 +797,16 @@ function resetStatus() {
|
||||
restartRequired.value = false
|
||||
confirmed.value = false
|
||||
error.value = ''
|
||||
statusNotice.value = ''
|
||||
doctorIdentityOpen.value = false
|
||||
state.value = initialStatus()
|
||||
void refresh()
|
||||
}
|
||||
|
||||
watch(() => props.prescriptionId, resetStatus, { immediate: true })
|
||||
watch(() => props.prescriptionId, () => {
|
||||
reviewState.value = null
|
||||
resetStatus()
|
||||
}, { immediate: true })
|
||||
watch(() => props.initialState, (value) => {
|
||||
// An emitted state echoed by the parent preserves this interaction.
|
||||
if (toRaw(value) !== toRaw(state.value)) resetStatus()
|
||||
@@ -675,11 +838,40 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
.esign-panel :deep(.el-steps) { margin: 10px 0; padding: 10px 12px; }
|
||||
.esign-panel :deep(.el-step.is-simple .el-step__title) { font-size: 13px; line-height: 1.4; word-break: normal; }
|
||||
.esign-panel__progress { container-type: inline-size; }
|
||||
.esign-panel__steps--review {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 8px 12px;
|
||||
}
|
||||
.esign-panel__steps--review :deep(.el-step.is-simple:last-of-type) { max-width: none !important; }
|
||||
.esign-panel__steps--review :deep(.el-step.is-simple .el-step__title) { max-width: none; white-space: nowrap; }
|
||||
.esign-panel__steps--review :deep(.el-step.is-simple .el-step__arrow) { display: none; }
|
||||
.esign-panel__review-signature { overflow-wrap: anywhere; }
|
||||
.esign-panel__timestamp { white-space: nowrap; }
|
||||
.esign-panel__actions { margin-top: 10px; }
|
||||
.esign-panel__actions .el-button + .el-button { margin-left: 0; }
|
||||
.esign-panel__message, .esign-panel__error { margin: 8px 0; font-size: 13px; }
|
||||
.esign-panel__message { color: var(--el-text-color-secondary); }
|
||||
.esign-panel__error { color: var(--el-color-danger); }
|
||||
.esign-panel__log {
|
||||
margin: 10px 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
.esign-panel__log summary {
|
||||
width: fit-content;
|
||||
color: var(--el-color-primary);
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
}
|
||||
.esign-panel__log-list {
|
||||
margin: 8px 0 0;
|
||||
padding-inline-start: 24px;
|
||||
list-style: decimal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.esign-panel__log-list li + li { margin-top: 8px; }
|
||||
.esign-panel__log-meta { color: var(--el-text-color-secondary); }
|
||||
.esign-panel__identity { display: grid; gap: 6px; max-width: 320px; margin: 10px 0; font-size: 13px; }
|
||||
.esign-panel__frame {
|
||||
display: block;
|
||||
@@ -690,5 +882,15 @@ onBeforeUnmount(() => {
|
||||
border-radius: 4px;
|
||||
background: white;
|
||||
}
|
||||
@container (min-width: 280px) {
|
||||
.esign-panel__steps--review { grid-template-columns: repeat(2, minmax(max-content, 1fr)); }
|
||||
}
|
||||
@container (min-width: 480px) {
|
||||
.esign-panel__steps--review { grid-template-columns: repeat(4, minmax(max-content, 1fr)); gap: 0; }
|
||||
.esign-panel__steps--review :deep(.el-step.is-simple:not(:last-of-type) .el-step__arrow) {
|
||||
display: flex;
|
||||
min-width: 18px;
|
||||
}
|
||||
}
|
||||
@media print { .esign-panel { display: none; } }
|
||||
</style>
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
<template>
|
||||
<div v-if="state?.required || error" class="esign-review" v-loading="busy" aria-label="处方审核电子签署">
|
||||
<div v-if="state?.required || error || busy" class="esign-review" :aria-busy="busy" aria-label="处方审核电子签署">
|
||||
<strong>审核电子签署</strong>
|
||||
<p v-if="state?.actor_name">当前审核人 {{ state.actor_name }}</p>
|
||||
<p v-if="state?.state === 'signed'">
|
||||
{{ state.signer_name }} · {{ formatSigningTime(state.signature_time) }}(北京时间 · 可信时间戳)
|
||||
</p>
|
||||
<p v-if="state?.message" aria-live="polite">{{ state.message }}</p>
|
||||
<p v-if="busy && !state" role="status">正在查询药师签署状态…</p>
|
||||
<p v-if="statusNotice" role="status">{{ statusNotice }}</p>
|
||||
<p v-if="error" class="text-danger" role="alert">{{ error }}</p>
|
||||
<div class="esign-review__actions">
|
||||
<el-button v-if="state?.can_confirm" type="primary" size="small" :disabled="busy" @click="confirm(false)">
|
||||
<el-button v-if="state?.can_confirm" type="primary" size="small" :disabled="busy || !doctorStatusConfirmed" @click="confirm(false)">
|
||||
确认签名
|
||||
</el-button>
|
||||
<el-button v-if="state?.can_retry_verify" type="primary" size="small" :disabled="busy" @click="confirm(true)">
|
||||
<el-button v-if="state?.can_retry_verify" type="primary" size="small" :disabled="busy || !doctorStatusConfirmed" @click="confirm(true)">
|
||||
重试验签
|
||||
</el-button>
|
||||
<el-button v-if="state?.required && doctorSigned" size="small" :disabled="busy" @click="download">
|
||||
@@ -25,10 +24,7 @@
|
||||
>
|
||||
审核签署身份
|
||||
</el-button>
|
||||
<el-button v-if="state?.required && !state.can_approve" size="small" :disabled="busy" @click="switchReviewer">
|
||||
切换审核账号
|
||||
</el-button>
|
||||
<el-button v-if="error || state?.state !== 'signed'" size="small" :disabled="busy" @click="refresh">
|
||||
<el-button v-if="error || state?.state !== 'signed'" size="small" :disabled="busy" @click="checkStatus">
|
||||
刷新签署状态
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -43,7 +39,6 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import {
|
||||
prescriptionEsignReviewConfirm,
|
||||
@@ -52,18 +47,16 @@ import {
|
||||
} from '@/api/tcm'
|
||||
import EsignDoctorDialog from '@/components/EsignDoctorDialog.vue'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import feedback from '@/utils/feedback'
|
||||
import { downloadOriginalEsignPdf, formatSigningTime } from '@/utils/prescription-esign'
|
||||
import { downloadOriginalEsignPdf } from '@/utils/prescription-esign'
|
||||
|
||||
const props = defineProps<{ prescriptionId: number; orderId?: number; doctorSigned: boolean }>()
|
||||
const props = defineProps<{ prescriptionId: number; orderId?: number; doctorSigned: boolean; doctorStatusConfirmed: boolean }>()
|
||||
const emit = defineEmits<{ (e: 'change', value: PrescriptionEsignReviewStatus | null): void }>()
|
||||
const state = ref<PrescriptionEsignReviewStatus | null>(null)
|
||||
const identityOpen = ref(false)
|
||||
const busy = ref(false)
|
||||
const error = ref('')
|
||||
const statusNotice = ref('')
|
||||
const userStore = useUserStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
let generation = 0
|
||||
let statusRequest: AbortController | undefined
|
||||
|
||||
@@ -80,7 +73,7 @@ function accept(result: PrescriptionEsignReviewStatus) {
|
||||
throw new Error('登录账号或审核状态已变化,请刷新页面')
|
||||
}
|
||||
state.value = result
|
||||
emit('change', result)
|
||||
emit('change', props.doctorStatusConfirmed ? result : null)
|
||||
}
|
||||
|
||||
function target() {
|
||||
@@ -93,6 +86,7 @@ async function refresh() {
|
||||
statusRequest = new AbortController()
|
||||
busy.value = true
|
||||
error.value = ''
|
||||
statusNotice.value = ''
|
||||
emit('change', null)
|
||||
try {
|
||||
const result = await prescriptionEsignReviewStatus(target(), statusRequest.signal)
|
||||
@@ -106,7 +100,7 @@ async function refresh() {
|
||||
|
||||
async function confirm(verifyOnly: boolean) {
|
||||
const actorId = state.value?.actor_id
|
||||
if (busy.value || !actorId || !(verifyOnly ? state.value?.can_retry_verify : state.value?.can_confirm)) return
|
||||
if (busy.value || !props.doctorStatusConfirmed || !actorId || !(verifyOnly ? state.value?.can_retry_verify : state.value?.can_confirm)) return
|
||||
const ticket = ++generation
|
||||
busy.value = true
|
||||
error.value = ''
|
||||
@@ -125,19 +119,10 @@ async function confirm(verifyOnly: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
async function switchReviewer() {
|
||||
try {
|
||||
await feedback.confirm('当前账号将退出。请所选审核人本人登录。')
|
||||
if (busy.value) return
|
||||
busy.value = true
|
||||
const returnTo = router.resolve({
|
||||
path: route.path,
|
||||
query: props.orderId ? { review_order: props.orderId } : { review_prescription: props.prescriptionId }
|
||||
}).fullPath
|
||||
await userStore.logout(returnTo)
|
||||
} catch {
|
||||
busy.value = false
|
||||
}
|
||||
async function checkStatus() {
|
||||
const current = generation
|
||||
await refresh()
|
||||
if (generation === current + 1 && state.value && !error.value) statusNotice.value = '药师签署状态已更新。'
|
||||
}
|
||||
|
||||
async function download() {
|
||||
@@ -158,11 +143,16 @@ async function download() {
|
||||
|
||||
function closeIdentity() {
|
||||
identityOpen.value = false
|
||||
void refresh()
|
||||
void checkStatus()
|
||||
}
|
||||
|
||||
watch(() => [props.prescriptionId, props.orderId, props.doctorSigned, userStore.userInfo.id],
|
||||
() => { if (props.prescriptionId > 0) void refresh() }, { immediate: true })
|
||||
watch(() => [props.prescriptionId, props.orderId, userStore.userInfo.id], () => {
|
||||
identityOpen.value = false
|
||||
state.value = null
|
||||
if (props.prescriptionId > 0) void refresh()
|
||||
}, { immediate: true })
|
||||
watch(() => props.doctorSigned, () => { if (props.prescriptionId > 0) void refresh() })
|
||||
watch(() => props.doctorStatusConfirmed, (confirmed) => emit('change', confirmed && !busy.value && !error.value ? state.value : null))
|
||||
onBeforeUnmount(() => {
|
||||
generation++
|
||||
statusRequest?.abort()
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<div v-if="prescriptionId !== null" class="prescription-audit-layout">
|
||||
<section class="prescription-audit-preview" aria-label="处方单" :aria-busy="loading">
|
||||
<PrescriptionSlip v-if="detail" :data="detail" compact />
|
||||
<el-skeleton v-else-if="loading" :rows="8" animated />
|
||||
<div v-if="error" class="prescription-audit-preview__error" role="status">
|
||||
<span>{{ error }}</span>
|
||||
<el-button v-if="prescriptionId > 0" size="small" @click="retry++">重试加载处方</el-button>
|
||||
</div>
|
||||
</section>
|
||||
<section class="prescription-audit-controls" aria-label="签署和审核">
|
||||
<slot />
|
||||
</section>
|
||||
</div>
|
||||
<slot v-else />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { prescriptionDetail } from '@/api/tcm'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
prescriptionId: number | null
|
||||
doctorSignedAt?: number
|
||||
pharmacistSignedAt?: number
|
||||
}>()
|
||||
|
||||
const detail = ref<Record<string, any> | null>(null)
|
||||
const retry = ref(0)
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
watch([
|
||||
() => props.prescriptionId,
|
||||
() => props.doctorSignedAt,
|
||||
() => props.pharmacistSignedAt,
|
||||
retry
|
||||
], async ([id, doctorAt, pharmacistAt, attempt], previous, onCleanup) => {
|
||||
if (id !== previous?.[0]) detail.value = null
|
||||
loading.value = false
|
||||
error.value = ''
|
||||
if (id === null) return
|
||||
if (!Number.isSafeInteger(id) || id <= 0) {
|
||||
error.value = '当前订单未关联处方'
|
||||
return
|
||||
}
|
||||
const current = detail.value?.esign
|
||||
if (detail.value && attempt === previous?.[3]
|
||||
&& (!doctorAt || doctorAt === (current?.signature_time || current?.signed_at))
|
||||
&& (!pharmacistAt || pharmacistAt === current?.review_signature_time)) return
|
||||
|
||||
const controller = new AbortController()
|
||||
onCleanup(() => controller.abort())
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await prescriptionDetail({ id }, controller.signal)
|
||||
const result = response?.data ?? response
|
||||
if (controller.signal.aborted) return
|
||||
if (Number(result?.id) !== id) throw new Error('处方编号不匹配')
|
||||
detail.value = result
|
||||
} catch {
|
||||
if (!controller.signal.aborted) error.value = '无法加载处方单,请重试。'
|
||||
} finally {
|
||||
if (!controller.signal.aborted) loading.value = false
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.prescription-audit-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.42fr) minmax(320px, 1fr);
|
||||
gap: 18px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.prescription-audit-preview,
|
||||
.prescription-audit-controls {
|
||||
min-width: 0;
|
||||
max-height: min(68vh, 780px);
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.prescription-audit-preview {
|
||||
padding: 10px;
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.prescription-audit-controls { padding-right: 3px; }
|
||||
|
||||
.prescription-audit-preview__error {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
@media (max-width: 840px) {
|
||||
.prescription-audit-layout {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.prescription-audit-preview { max-height: min(50vh, 560px); }
|
||||
.prescription-audit-controls { max-height: none; overflow: visible; }
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div ref="paperRef" class="rx-paper">
|
||||
<div ref="paperRef" class="rx-paper" :class="{ 'rx-paper--compact': compact }">
|
||||
<div class="rx-title">{{ isInternal ? '药房联' : slipTitle }}</div>
|
||||
<div class="rx-notice">
|
||||
<span class="rx-notice-text">
|
||||
@@ -154,21 +154,34 @@
|
||||
</div>
|
||||
|
||||
<div class="rx-bottom">
|
||||
<div class="rx-bot-row rx-bot-row-1" :class="{ 'rx-bot-row-1--user': !isInternal }">
|
||||
<div
|
||||
class="rx-bot-row rx-bot-row-1"
|
||||
:class="{ 'rx-bot-row-1--user': !isInternal, 'rx-bot-row-1--reviewed': reviewerName }"
|
||||
>
|
||||
<div class="rx-bot-cell rx-bot-doctor">
|
||||
<div class="rx-bot-label rx-bot-label--doctor">医师</div>
|
||||
<div class="rx-bot-label rx-bot-label--inline">医师</div>
|
||||
<div class="rx-bot-doctor-body">
|
||||
<img
|
||||
v-if="data?.doctor_signature"
|
||||
:src="data.doctor_signature"
|
||||
alt="医师签名"
|
||||
v-if="doctorSignature"
|
||||
:src="doctorSignature"
|
||||
:alt="doctorName"
|
||||
class="rx-bot-sign-img"
|
||||
@error="onDoctorSignatureError"
|
||||
/>
|
||||
<span v-if="!data?.doctor_signature" class="rx-bot-doctor-name">
|
||||
{{ data?.doctor_name || '—' }}
|
||||
</span>
|
||||
<span v-else class="rx-bot-doctor-name">{{ doctorName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="reviewerName" class="rx-bot-cell rx-bot-reviewer">
|
||||
<span class="rx-bot-label rx-bot-label--inline">药师审核</span>
|
||||
<img
|
||||
v-if="reviewerSignature"
|
||||
:src="reviewerSignature"
|
||||
:alt="reviewerName"
|
||||
class="rx-bot-sign-img"
|
||||
@error="onReviewerSignatureError"
|
||||
/>
|
||||
<span v-else class="rx-bot-reviewer-name">{{ reviewerName }}</span>
|
||||
</div>
|
||||
<div v-if="isInternal" class="rx-bot-cell rx-bot-meta">
|
||||
<span class="rx-bot-meta-key">类型:</span>
|
||||
<span class="rx-bot-meta-val">{{ typeText }}</span>
|
||||
@@ -192,6 +205,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import {
|
||||
getAuxHerbs,
|
||||
getMainHerbs,
|
||||
@@ -226,6 +240,7 @@ const props = withDefaults(
|
||||
auxLibraryName?: string
|
||||
/** 抬头(处方联) */
|
||||
title?: string
|
||||
compact?: boolean
|
||||
}>(),
|
||||
{
|
||||
variant: 'internal',
|
||||
@@ -237,6 +252,45 @@ const props = withDefaults(
|
||||
const paperRef = ref<HTMLElement | null>(null)
|
||||
const isInternal = computed(() => props.variant !== 'user')
|
||||
const slipTitle = computed(() => props.title || '成都双流甄养堂互联网医院 处方笺')
|
||||
const verifiedDoctor = computed(() => {
|
||||
const signing: PrescriptionEsignStatus | undefined = props.data?.esign
|
||||
if (signing?.status === 'signed' || (signing?.status === 'voided' && signing.can_download)) return signing
|
||||
return null
|
||||
})
|
||||
const doctorName = computed(() => {
|
||||
const signer = verifiedDoctor.value?.doctor_signer_name
|
||||
return (typeof signer === 'string' && signer.trim()) || props.data?.doctor_name || '—'
|
||||
})
|
||||
const failedDoctorSignature = ref('')
|
||||
const doctorSignature = computed(() => {
|
||||
const signature = props.data?.doctor_signature
|
||||
if (verifiedDoctor.value && !isVerifiedSignaturePng(signature)) return ''
|
||||
if (!verifiedDoctor.value && props.data?.esign?.required) return ''
|
||||
return typeof signature === 'string' && signature !== failedDoctorSignature.value ? signature : ''
|
||||
})
|
||||
const reviewerName = computed(() => {
|
||||
const signing = props.data?.esign
|
||||
if (!signing || !['signed', 'voided'].includes(signing.status)
|
||||
|| !Number.isInteger(signing.review_signature_time) || signing.review_signature_time <= 0) return ''
|
||||
return typeof signing.review_signer_name === 'string' ? signing.review_signer_name.trim() : ''
|
||||
})
|
||||
const failedReviewerSignature = ref('')
|
||||
const reviewerSignature = computed(() => {
|
||||
const signature = props.data?.esign?.review_signature
|
||||
return reviewerName.value && isVerifiedSignaturePng(signature) && signature !== failedReviewerSignature.value ? signature : ''
|
||||
})
|
||||
|
||||
function isVerifiedSignaturePng(signature: unknown): signature is string {
|
||||
return typeof signature === 'string' && /^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/.test(signature)
|
||||
}
|
||||
|
||||
function onDoctorSignatureError(event: Event) {
|
||||
if (event.currentTarget instanceof HTMLImageElement) failedDoctorSignature.value = event.currentTarget.getAttribute('src') ?? ''
|
||||
}
|
||||
|
||||
function onReviewerSignatureError(event: Event) {
|
||||
if (event.currentTarget instanceof HTMLImageElement) failedReviewerSignature.value = event.currentTarget.src
|
||||
}
|
||||
|
||||
const dateText = computed(() => rxDateText(props.data))
|
||||
const prescriptionSnText = computed(() => rxPrescriptionSnText(props.data))
|
||||
@@ -612,6 +666,14 @@ defineExpose({
|
||||
grid-template-columns: 1.6fr 0.6fr;
|
||||
}
|
||||
|
||||
.rx-bot-row-1--reviewed {
|
||||
grid-template-columns: minmax(164px, 1.15fr) minmax(188px, 1.3fr) 1.4fr 0.75fr 0.85fr;
|
||||
}
|
||||
|
||||
.rx-bot-row-1--user.rx-bot-row-1--reviewed {
|
||||
grid-template-columns: minmax(164px, 1.6fr) minmax(188px, 1.6fr) 0.6fr;
|
||||
}
|
||||
|
||||
.rx-hospital-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -662,7 +724,7 @@ defineExpose({
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.rx-bot-label--doctor {
|
||||
.rx-bot-label--inline {
|
||||
flex-shrink: 0;
|
||||
margin-bottom: 0;
|
||||
margin-right: 6px;
|
||||
@@ -670,6 +732,14 @@ defineExpose({
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.rx-bot-reviewer-name {
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.rx-bot-doctor {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
@@ -692,13 +762,13 @@ defineExpose({
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.rx-bot-sign-img {
|
||||
flex-shrink: 0;
|
||||
max-height: 40px;
|
||||
max-width: 110px;
|
||||
object-fit: contain;
|
||||
}
|
||||
.rx-bot-sign-img {
|
||||
flex-shrink: 0;
|
||||
max-height: 24px;
|
||||
max-width: 72px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.rx-bot-meta {
|
||||
@@ -721,6 +791,38 @@ defineExpose({
|
||||
line-height: 2.5;
|
||||
}
|
||||
}
|
||||
|
||||
.rx-paper.rx-paper--compact {
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
padding: clamp(10px, 2.4vw, 24px);
|
||||
container-type: inline-size;
|
||||
|
||||
.rx-title { font-size: 22px; margin: 6px 0 18px; }
|
||||
.rx-notice { padding: 10px; }
|
||||
.rx-notice .rx-notice-meta { flex-wrap: wrap; overflow: visible; gap: 2px 14px; }
|
||||
.rx-notice .rx-notice-meta .rx-meta-item { border: 0; padding: 0; margin: 0; }
|
||||
.rx-info-cell { padding: 9px; min-width: 0; overflow-wrap: anywhere; }
|
||||
.rx-herb-name { white-space: normal; overflow-wrap: anywhere; }
|
||||
.rx-herb-cell { line-height: 1.65; }
|
||||
.rx-text { overflow-wrap: anywhere; }
|
||||
.rx-bot-row-1 { display: flex; flex-wrap: wrap; min-height: 0; }
|
||||
.rx-bot-row-1 > .rx-bot-cell { flex: 1 0 auto; max-width: 100%; border: 0; flex-wrap: wrap; }
|
||||
.rx-bot-doctor .rx-bot-doctor-name { white-space: normal; overflow-wrap: anywhere; }
|
||||
}
|
||||
|
||||
@container (max-width: 465px) {
|
||||
.rx-paper--compact .rx-info-row:not(.rx-info-row-full) {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
|
||||
.rx-info-cell:nth-child(even) { border-right: none; }
|
||||
.rx-info-cell:nth-child(n + 3) { border-top: 1px solid #c8c8c8; }
|
||||
}
|
||||
|
||||
.rx-paper--compact .rx-rp-cols-head,
|
||||
.rx-paper--compact .rx-herbs { grid-template-columns: minmax(0, 1fr); }
|
||||
.rx-paper--compact .rx-rp-col-head + .rx-rp-col-head { display: none; }
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- 全局打印样式:body * 选择器不能放进 scoped -->
|
||||
|
||||
@@ -514,7 +514,7 @@
|
||||
{{ esignError }} <el-button link type="primary" @click="loadEsignConfig">重试</el-button>
|
||||
</el-alert>
|
||||
<el-alert v-else-if="esignEnabled" type="info" :closable="false" class="mb-3"
|
||||
:title="esignConfig?.environment === 'sandbox' ? '沙箱测试。保存草稿后,由开方医生本人确认签署。' : '保存草稿后,由开方医生本人确认签署。'" />
|
||||
:title="esignConfig?.environment === 'sandbox' ? '沙箱测试。保存草稿后,先上传处方,再由开方医生本人签署。' : '保存草稿后,先上传处方,再由开方医生本人签署。'" />
|
||||
<el-form-item v-else-if="esignReady" label="医师签名" prop="doctor_signature" required>
|
||||
<div class="signature-pad-wrap">
|
||||
<canvas
|
||||
@@ -553,7 +553,7 @@
|
||||
v-else-if="Number(savedPrescription.audit_status) === 0"
|
||||
type="warning"
|
||||
size="small"
|
||||
>待审核</el-tag>
|
||||
>{{ pendingPrescriptionReviewLabel(savedPrescription) }}</el-tag>
|
||||
<el-tag v-else-if="Number(savedPrescription.audit_status) === 2" type="danger" size="small">已驳回</el-tag>
|
||||
<div class="flex-1" />
|
||||
</div>
|
||||
@@ -877,7 +877,7 @@ import { getDictData } from '@/api/app'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
|
||||
import { usePrescriptionEsignConfig } from '@/hooks/usePrescriptionEsignConfig'
|
||||
import { downloadPrescriptionPdfIfRequired, requiresOriginalEsignPdf } from '@/utils/prescription-esign'
|
||||
import { downloadPrescriptionPdfIfRequired, pendingPrescriptionReviewLabel, requiresOriginalEsignPdf } from '@/utils/prescription-esign'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import html2canvas from 'html2canvas'
|
||||
import { jsPDF } from 'jspdf'
|
||||
|
||||
@@ -68,7 +68,9 @@ function closeEsign() {
|
||||
reviewEsignOpen.value = false
|
||||
}
|
||||
|
||||
watch([() => userStore.token, () => userInfo.value.id, canManageDoctorEsign, canManageReviewEsign], closeEsign, { flush: 'sync' })
|
||||
watch([() => userStore.token, () => userInfo.value.id], closeEsign, { flush: 'sync' })
|
||||
watch(canManageDoctorEsign, (allowed) => { if (!allowed) doctorEsignOpen.value = false }, { flush: 'sync' })
|
||||
watch(canManageReviewEsign, (allowed) => { if (!allowed) reviewEsignOpen.value = false }, { flush: 'sync' })
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const config = await prescriptionEsignConfig()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
prescriptionDetail,
|
||||
prescriptionEsignDownload,
|
||||
prescriptionEsignStatus,
|
||||
type PrescriptionEsignFile,
|
||||
@@ -55,7 +56,9 @@ export function validateEsignStatus(value: unknown): PrescriptionEsignStatus {
|
||||
|| ['enabled', 'required', 'can_sign', 'can_download'].some((key) => typeof (state as any)[key] !== 'boolean')
|
||||
|| (state.verification_method !== undefined && !['quick', 'sms'].includes(state.verification_method))
|
||||
|| [state.can_resume_identity, state.can_retry_verify, state.doctor_identity_required,
|
||||
state.signing_authorization_required, state.sms_sent].some((flag) => flag !== undefined && typeof flag !== 'boolean')) {
|
||||
state.signing_authorization_required, state.sms_sent, state.awaiting_upload,
|
||||
state.can_submit_for_review, state.can_review_prescription]
|
||||
.some((flag) => flag !== undefined && typeof flag !== 'boolean')) {
|
||||
throw new Error('无法核对处方签署状态,请刷新后重试')
|
||||
}
|
||||
return state
|
||||
@@ -104,6 +107,39 @@ export function canApprovePrescriptionEsign(status: unknown): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function pendingPrescriptionReviewLabel(row: {
|
||||
review_submitted_at?: number | string
|
||||
can_review_prescription?: boolean
|
||||
esign?: PrescriptionEsignStatus
|
||||
}): string {
|
||||
const submittedAt = row.esign?.review_submitted_at ?? row.review_submitted_at
|
||||
if (!(Number(submittedAt) > 0)) return '待上传'
|
||||
if ((row.esign?.can_review_prescription ?? row.can_review_prescription) === true) return '待审核'
|
||||
return row.esign?.status === 'signed' ? '签署待核实' : '待医师签署'
|
||||
}
|
||||
|
||||
export async function updatePrescriptionSlipEsign(data: Record<string, unknown> | null, state: PrescriptionEsignStatus): Promise<void> {
|
||||
if (!data) return
|
||||
const previous = data.esign as PrescriptionEsignStatus | undefined
|
||||
data.esign = state
|
||||
if (state.status !== 'signed' || previous?.status === 'signed') return
|
||||
|
||||
// The verified physician seal is stored on the prescription detail after signing.
|
||||
data.doctor_signature = ''
|
||||
const id = Number(data.id)
|
||||
if (!Number.isInteger(id) || id <= 0) return
|
||||
try {
|
||||
const response = await prescriptionDetail({ id })
|
||||
const detail = response?.data ?? response
|
||||
if (Number(detail?.id) === id && (data.esign as PrescriptionEsignStatus).status === 'signed'
|
||||
&& typeof detail?.doctor_signature === 'string') {
|
||||
data.doctor_signature = detail.doctor_signature
|
||||
}
|
||||
} catch {
|
||||
// The slip falls back to the verified name when the seal cannot be loaded.
|
||||
}
|
||||
}
|
||||
|
||||
/** Verify the received bytes before creating a download; never render or alter the signed PDF. */
|
||||
export async function verifyEsignPdf(file: PrescriptionEsignFile): Promise<Uint8Array> {
|
||||
if (!/^[a-f\d]{64}$/i.test(file.sha256 || '')) throw new Error('签署文件缺少有效校验信息')
|
||||
|
||||
@@ -402,7 +402,8 @@ const ReportList = defineComponent({
|
||||
|
||||
const models: Array<{ profile: PrescriptionAiProfile; label: string; name: string }> = [
|
||||
{ profile: 'qwen', label: '千问', name: 'qwen3.6-35b' },
|
||||
{ profile: 'openai', label: 'OpenAI', name: 'gpt-5.6-sol' }
|
||||
{ profile: 'openai', label: 'OpenAI', name: 'gpt-5.6-sol' },
|
||||
{ profile: 'doubao', label: '豆包', name: 'doubao-seed-2.1-pro' }
|
||||
]
|
||||
|
||||
const AI_REPORT_EDIT_PERMISSIONS = [
|
||||
@@ -436,7 +437,8 @@ const canRefreshFromBackend = ref(false)
|
||||
const canEditFromBackend = ref(false)
|
||||
const states = reactive<Record<PrescriptionAiProfile, ReportState>>({
|
||||
qwen: createState(),
|
||||
openai: createState()
|
||||
openai: createState(),
|
||||
doubao: createState()
|
||||
})
|
||||
|
||||
const herbSummary = computed(() => {
|
||||
|
||||
@@ -1440,6 +1440,8 @@ function canAddPrescriptionOrderLog() {
|
||||
|
||||
/** 与后端 canAuditPrescriptionOrder 同档:超管或 prescription_audit_roles */
|
||||
const canSetRxAuditOnAddLog = computed(() => {
|
||||
if (Number(detailData.value?.prescription_audit_status) === 0
|
||||
&& detailData.value?.can_review_prescription === false) return false
|
||||
const u = userStore.userInfo
|
||||
if (!u || Number(u.root) === 1) return true
|
||||
const ids = Array.isArray(u.role_ids) ? u.role_ids.map((n: unknown) => Number(n)) : []
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
|
||||
const doctorSigningStatus = {
|
||||
pending: { label: '待医师签署', type: 'warning' },
|
||||
authenticating: { label: '待医师确认签署', type: 'warning' },
|
||||
signing: { label: '医师签署中', type: 'primary' },
|
||||
failed: { label: '医师签署未完成', type: 'danger' },
|
||||
uncertain: { label: '医师签署待核实', type: 'warning' }
|
||||
} as const
|
||||
|
||||
const pharmacistSigningStatus = {
|
||||
pending: { label: '待药师签署', type: 'warning' },
|
||||
signing: { label: '药师签署中', type: 'primary' },
|
||||
verifying: { label: '药师验签中', type: 'primary' },
|
||||
failed: { label: '药师签署未完成', type: 'danger' },
|
||||
uncertain: { label: '药师签署待核实', type: 'warning' },
|
||||
signed: { label: '已完成双签', type: 'success' }
|
||||
} as const
|
||||
|
||||
const unknownSigningStatus = { label: '签署状态待核实', type: 'warning' } as const
|
||||
|
||||
export function prescriptionListSigningStatus(row: {
|
||||
void_status?: number | string
|
||||
esign?: PrescriptionEsignStatus | null
|
||||
}) {
|
||||
const { esign } = row
|
||||
if (Number(row.void_status) === 1 || esign?.status === 'voided') {
|
||||
return { label: '已作废', type: 'danger' } as const
|
||||
}
|
||||
if (esign?.required && esign.awaiting_upload === true && esign.status !== 'signed') {
|
||||
return { label: '上传后签署', type: 'info' } as const
|
||||
}
|
||||
|
||||
switch (esign?.status) {
|
||||
case 'pending':
|
||||
case 'authenticating':
|
||||
case 'signing':
|
||||
case 'failed':
|
||||
case 'uncertain':
|
||||
return doctorSigningStatus[esign.status]
|
||||
case 'legacy':
|
||||
return { label: '历史处方', type: 'info' } as const
|
||||
case 'signed': {
|
||||
if (esign.can_download !== true) return doctorSigningStatus.uncertain
|
||||
if (esign.awaiting_upload === true) return { label: '医师已签署', type: 'success' } as const
|
||||
if (esign.review_state !== undefined) {
|
||||
return pharmacistSigningStatus[esign.review_state] ?? unknownSigningStatus
|
||||
}
|
||||
const pharmacistSignedAt = esign.review_signature_time ?? 0
|
||||
if (Number.isInteger(pharmacistSignedAt) && pharmacistSignedAt > 0) {
|
||||
return pharmacistSigningStatus.signed
|
||||
}
|
||||
return esign.review_required === true
|
||||
? pharmacistSigningStatus.pending
|
||||
: { label: '医师已签署', type: 'success' } as const
|
||||
}
|
||||
default:
|
||||
return unknownSigningStatus
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
<span class="pl-toolbar__sep" aria-hidden="true" />
|
||||
<span
|
||||
class="pl-toolbar__k"
|
||||
title="「未通过」含待审核与已驳回"
|
||||
title="「未通过」含待上传、待医师签署、待审核与已驳回"
|
||||
>审核</span>
|
||||
<el-radio-group
|
||||
v-model="formData.audit_filter"
|
||||
@@ -103,6 +103,9 @@
|
||||
<div class="pl-table-head">
|
||||
<span class="pl-table-head__title">处方列表</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<el-button v-if="canManageCaSigning" @click="openCaSigningSettings">
|
||||
CA 签名设置
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['tcm.prescriptionOrder/lists']"
|
||||
@click="goBusinessOrderList"
|
||||
@@ -169,9 +172,6 @@
|
||||
<el-tag :type="listAuditStatusTagType(row)">
|
||||
{{ listAuditStatusLabel(row) }}
|
||||
</el-tag>
|
||||
<el-tag v-if="pendingEsignAudit(row)" type="warning" size="small" effect="plain">
|
||||
{{ row.esign.status_label }}
|
||||
</el-tag>
|
||||
<span
|
||||
v-if="Number(row.business_prescription_audit_rejected) === 1"
|
||||
class="text-xs text-gray-500"
|
||||
@@ -192,6 +192,13 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="签署状态" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="prescriptionListSigningStatus(row).type" size="small" effect="plain">
|
||||
{{ prescriptionListSigningStatus(row).label }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="作废" min-width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.void_status === 1" type="danger" size="small">作废</el-tag>
|
||||
@@ -214,7 +221,7 @@
|
||||
{{ formatListCreateTime(row.create_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300" fixed="right">
|
||||
<el-table-column label="操作" width="340" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="handleView(row)" v-perms="['cf.prescription/read']">
|
||||
查看
|
||||
@@ -238,7 +245,7 @@
|
||||
创建订单
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!isApprovedActivePrescription(row)"
|
||||
v-if="!isApprovedActivePrescription(row) && (Number(row.void_status) !== 1 || row.can_restore_rejected === true)"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
@@ -247,14 +254,44 @@
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="isPendingPrescriptionAudit(row)"
|
||||
v-if="canReissuePrescription(row)"
|
||||
type="primary"
|
||||
link
|
||||
:loading="reissuingPrescriptionId === Number(row.id)"
|
||||
:disabled="reissuingPrescriptionId !== 0"
|
||||
@click="handleReissue(row)"
|
||||
>
|
||||
重新开方
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.can_submit_for_review === true"
|
||||
type="primary"
|
||||
link
|
||||
:loading="uploadingPrescriptionId === Number(row.id)"
|
||||
:disabled="uploadingPrescriptionId !== 0"
|
||||
@click="submitPrescriptionForReview(row)"
|
||||
>
|
||||
上传处方
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canOpenPrescriptionAudit(row)"
|
||||
type="warning"
|
||||
link
|
||||
v-perms="['cf.prescription/audit']"
|
||||
@click="openAuditDialog(Number(row.id))"
|
||||
@click="openAuditDialog(row)"
|
||||
>
|
||||
审核
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canVoidPendingPrescription(row)"
|
||||
type="danger"
|
||||
link
|
||||
:loading="voidingPrescriptionId === Number(row.id)"
|
||||
:disabled="voidingPrescriptionId !== 0"
|
||||
@click="voidPendingPrescription(row)"
|
||||
>
|
||||
作废
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!isApprovedActivePrescription(row)"
|
||||
type="danger"
|
||||
@@ -274,10 +311,68 @@
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
v-if="canManageCaSigning"
|
||||
v-model="caSigningSettingsVisible"
|
||||
title="CA 签名设置"
|
||||
width="min(440px, calc(100vw - 24px))"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!caSigningSettingsSaving"
|
||||
:show-close="!caSigningSettingsSaving"
|
||||
>
|
||||
<p v-if="esignLoading" role="status">正在读取 CA 签名设置…</p>
|
||||
<template v-else-if="esignReady">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<span>全局 CA 签名</span>
|
||||
<el-switch
|
||||
v-model="caSigningSettingsEnabled"
|
||||
aria-label="全局 CA 签名"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
:disabled="caSigningSettingsSaving"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="esignConfig?.enabled && esignConfig.review_enabled !== true" class="mt-3">
|
||||
当前仅启用医师 CA 签名。
|
||||
</p>
|
||||
<p class="mt-3 leading-relaxed">
|
||||
保存为开启时,处方上传后依次由医师、药师完成 CA 签名。
|
||||
保存为关闭时,新开的普通处方使用手写签名,上传后进入原有审核流程。
|
||||
已进入 CA 流程的处方仍按该流程处理。
|
||||
</p>
|
||||
<el-alert
|
||||
v-if="caSigningSettingsSaveError"
|
||||
class="mt-3"
|
||||
type="error"
|
||||
:closable="false"
|
||||
:title="caSigningSettingsSaveError"
|
||||
/>
|
||||
</template>
|
||||
<el-alert v-else type="error" :closable="false" title="未能读取 CA 签名设置">
|
||||
<el-button link type="primary" @click="loadCaSigningSettings">重新加载</el-button>
|
||||
</el-alert>
|
||||
<template #footer>
|
||||
<el-button
|
||||
:disabled="caSigningSettingsSaving"
|
||||
@click="caSigningSettingsVisible = false"
|
||||
>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
:disabled="!canSaveCaSigningSettings"
|
||||
:loading="caSigningSettingsSaving"
|
||||
@click="saveCaSigningSettings"
|
||||
>
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 新增/编辑/查看抽屉 -->
|
||||
<el-drawer
|
||||
v-model="showEdit"
|
||||
:title="editMode === 'add' ? '新增处方' : editMode === 'edit' ? '编辑处方' : '查看处方'"
|
||||
:title="editMode === 'add' ? (reissueContext ? '重新开方' : '新增处方') : editMode === 'edit' ? '编辑处方' : '查看处方'"
|
||||
:size="editMode === 'view' ? '920px' : '860px'"
|
||||
class="cf-prescription-drawer"
|
||||
:close-on-click-modal="false"
|
||||
@@ -285,10 +380,15 @@
|
||||
@close="showEdit = false"
|
||||
@closed="onEditDialogClosed"
|
||||
>
|
||||
<!-- 查看:A4 处方笺(药房联样式) -->
|
||||
<div v-if="editMode === 'view'" v-loading="viewDetailLoading" class="rx-wrap">
|
||||
<!-- 查看:A4 处方笺 -->
|
||||
<div v-if="editMode === 'view'" :aria-busy="viewDetailLoading" class="rx-wrap">
|
||||
<p v-if="viewDetailLoading" class="rx-status" role="status">正在加载处方详情…</p>
|
||||
<div v-if="viewDetailError" class="rx-status rx-status-danger" role="alert">
|
||||
{{ viewDetailError }}
|
||||
<el-button v-if="slipView?.id" link type="primary" @click="handleView(slipView)">重试加载</el-button>
|
||||
</div>
|
||||
<EsignPrescriptionPanel
|
||||
v-if="showEdit && slipView?.id && !viewDetailLoading"
|
||||
v-if="showEdit && slipView?.id && !viewDetailLoading && !viewDetailError"
|
||||
:key="slipView.id"
|
||||
:prescription-id="Number(slipView.id)"
|
||||
:initial-state="slipView.esign"
|
||||
@@ -317,19 +417,27 @@
|
||||
v-else-if="slipView && Number(slipView.audit_status) === 0"
|
||||
type="warning"
|
||||
size="small"
|
||||
>待审核</el-tag>
|
||||
>{{ listAuditStatusLabel(slipView) }}</el-tag>
|
||||
<el-tag v-else-if="slipView" type="danger" size="small">已驳回</el-tag>
|
||||
<el-tag v-if="slipView && pendingEsignAudit(slipView)" type="warning" size="small" effect="plain">
|
||||
{{ slipView.esign.status_label }}
|
||||
</el-tag>
|
||||
<div class="flex-1" />
|
||||
<el-button
|
||||
v-if="slipView && !viewDetailLoading && isPendingPrescriptionAudit(slipView)"
|
||||
<el-button
|
||||
v-if="slipView && !viewDetailLoading && canOpenPrescriptionAudit(slipView)"
|
||||
v-perms="['cf.prescription/audit']"
|
||||
type="warning"
|
||||
size="small"
|
||||
@click="openAuditDialog(Number(slipView.id))"
|
||||
@click="openAuditDialog(slipView)"
|
||||
>审核</el-button>
|
||||
<el-button
|
||||
v-if="slipView && !viewDetailLoading && !viewDetailError && canReissuePrescription(slipView)"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="reissuingPrescriptionId === Number(slipView.id)"
|
||||
:disabled="reissuingPrescriptionId !== 0"
|
||||
@click="handleReissue(slipView)"
|
||||
>重新开方</el-button>
|
||||
<el-button v-if="!requiresOriginalEsignPdf(slipView?.esign)" :icon="Printer" size="small" @click="handlePrintSlip">打印</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@@ -364,8 +472,19 @@
|
||||
<div v-if="slipView.audit_remark" class="mt-1">驳回意见:{{ slipView.audit_remark }}</div>
|
||||
</div>
|
||||
|
||||
<!-- A4 处方纸:统一组件,与全端药房联一比一 -->
|
||||
<PrescriptionSlip v-if="slipView" ref="rxSlipRef" :data="slipView" />
|
||||
<el-tabs
|
||||
v-if="slipView"
|
||||
v-model="prescriptionTabType"
|
||||
class="rx-slip-tabs"
|
||||
:before-leave="() => !downloadingSlip"
|
||||
>
|
||||
<el-tab-pane label="药房联" name="internal">
|
||||
<PrescriptionSlip v-if="prescriptionTabType === 'internal'" ref="rxSlipRef" :data="slipView" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="处方联" name="user">
|
||||
<PrescriptionSlip v-if="prescriptionTabType === 'user'" ref="rxSlipRef" :data="slipView" variant="user" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- 审核痕迹(不进入打印区) -->
|
||||
<div
|
||||
@@ -403,7 +522,7 @@
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb-4"
|
||||
title="保存修改后,该处方将重新进入「待审核」,需审核人员再次通过后方可生效。"
|
||||
title="保存修改后,请由开方医生重新上传并完成签署,再交药师审核。"
|
||||
/>
|
||||
<el-alert
|
||||
v-if="editMode === 'edit' && Number(editForm.audit_status) === 2"
|
||||
@@ -414,7 +533,7 @@
|
||||
>
|
||||
<template #title>当前消费者处方为「已驳回」</template>
|
||||
<div class="text-sm mt-1">
|
||||
保存修改后将清除驳回并变为「待审核」。{{
|
||||
保存修改后将清除驳回并恢复为「待上传」。{{
|
||||
editForm.audit_remark ? `上次意见:${editForm.audit_remark}` : ''
|
||||
}}
|
||||
</div>
|
||||
@@ -464,7 +583,7 @@
|
||||
<el-input
|
||||
v-model="editForm.patient_name"
|
||||
placeholder="请输入患者姓名"
|
||||
:disabled="editMode === 'edit'"
|
||||
:disabled="editMode === 'edit' || (!!reissueContext && editForm.diagnosis_id > 0)"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -1010,7 +1129,7 @@
|
||||
{{ esignError }} <el-button link type="primary" @click="loadEsignConfig">重试</el-button>
|
||||
</el-alert>
|
||||
<el-alert v-else-if="esignEnabled" type="info" :closable="false" class="mb-3"
|
||||
:title="esignConfig?.environment === 'sandbox' ? '沙箱测试。保存草稿后,由开方医生本人确认签署。' : '保存草稿后,由开方医生本人确认签署。'" />
|
||||
:title="esignConfig?.environment === 'sandbox' ? '沙箱测试。保存草稿后,先上传处方,再由开方医生本人签署。' : '保存草稿后,先上传处方,再由开方医生本人签署。'" />
|
||||
<el-form-item v-else-if="esignReady" label="医师签名" prop="doctor_signature" required>
|
||||
<div class="signature-pad-wrap">
|
||||
<canvas
|
||||
@@ -1557,31 +1676,35 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="auditDialogVisible" title="处方审核" width="480px" destroy-on-close @closed="auditRemark = ''">
|
||||
<EsignPrescriptionPanel
|
||||
v-if="auditDialogVisible"
|
||||
:key="auditTargetId"
|
||||
<el-dialog v-model="auditDialogVisible" title="处方审核" width="min(1280px, 96vw)" top="5vh" append-to-body destroy-on-close @closed="auditRemark = ''">
|
||||
<PrescriptionAuditLayout
|
||||
:prescription-id="auditTargetId"
|
||||
audit
|
||||
@review-change="auditReview = $event"
|
||||
class="mb-3"
|
||||
@status-change="onAuditEsignStatusChange"
|
||||
/>
|
||||
<p class="text-sm text-gray-600 mb-3">
|
||||
通过:处方保持有效。驳回:将同时作废此处方(与诊间「驳回/作废处方」一致)。
|
||||
</p>
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="审核意见">
|
||||
<el-input
|
||||
v-model="auditRemark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
placeholder="通过可简要说明;驳回必填"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
:doctor-signed-at="auditEsign?.signature_time || auditEsign?.signed_at"
|
||||
:pharmacist-signed-at="auditReview?.signature_time || auditEsign?.review_signature_time"
|
||||
>
|
||||
<EsignPrescriptionPanel
|
||||
v-if="auditDialogVisible"
|
||||
:key="auditTargetId"
|
||||
:prescription-id="auditTargetId"
|
||||
audit
|
||||
@review-change="onAuditReviewChange"
|
||||
class="mb-3"
|
||||
@status-change="onAuditEsignStatusChange"
|
||||
/>
|
||||
<p class="text-sm text-gray-600 mb-3">驳回将同时作废处方。通过时审核意见选填。</p>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="审核意见">
|
||||
<el-input
|
||||
v-model="auditRemark"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
placeholder="驳回时必填"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</PrescriptionAuditLayout>
|
||||
<template #footer>
|
||||
<el-button @click="auditDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="auditLoading" :disabled="!canApproveAudit" @click="submitAudit('approve')">审核通过</el-button>
|
||||
@@ -1601,7 +1724,10 @@ import {
|
||||
prescriptionEdit,
|
||||
prescriptionPatchPatient,
|
||||
prescriptionDelete,
|
||||
prescriptionVoid,
|
||||
prescriptionAudit,
|
||||
prescriptionEsignSetConfig,
|
||||
prescriptionSubmitForReview,
|
||||
prescriptionDetail,
|
||||
prescriptionOrderCreate,
|
||||
prescriptionOrderPaidPayOrders,
|
||||
@@ -1620,10 +1746,12 @@ import type { FormInstance, FormRules } from 'element-plus'
|
||||
import DaterangePicker from '@/components/daterange-picker/index.vue'
|
||||
import MedicineNameSelect from '@/components/medicine-name-select/index.vue'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import PrescriptionAuditLayout from '@/components/PrescriptionAuditLayout.vue'
|
||||
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
|
||||
import { usePrescriptionEsignConfig } from '@/hooks/usePrescriptionEsignConfig'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, requiresOriginalEsignPdf } from '@/utils/prescription-esign'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, pendingPrescriptionReviewLabel, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import { prescriptionListSigningStatus } from './components/prescription-list-signing-status'
|
||||
import { Search, Download, Printer, EditPen } from '@element-plus/icons-vue'
|
||||
import { computed, onMounted, onActivated, onDeactivated, reactive, ref, watch, nextTick, defineAsyncComponent } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
@@ -1811,15 +1939,72 @@ const SIGNATURE_CSS_H = 168
|
||||
const slipView = ref<Record<string, any> | null>(null)
|
||||
const { config: esignConfig, enabled: esignEnabled, ready: esignReady, loading: esignLoading, error: esignError, load: loadEsignConfig } = usePrescriptionEsignConfig()
|
||||
|
||||
const canManageCaSigning = computed(() => Number(userStore.userInfo?.root) === 1)
|
||||
const caSigningSettingsVisible = ref(false)
|
||||
const caSigningSettingsEnabled = ref(false)
|
||||
const caSigningSettingsSaving = ref(false)
|
||||
const caSigningSettingsSaveError = ref('')
|
||||
const canSaveCaSigningSettings = computed(
|
||||
() => canManageCaSigning.value && esignReady.value && !esignLoading.value && !caSigningSettingsSaving.value
|
||||
)
|
||||
|
||||
async function loadCaSigningSettings() {
|
||||
if (!canManageCaSigning.value || caSigningSettingsSaving.value) return
|
||||
caSigningSettingsSaveError.value = ''
|
||||
if (await loadEsignConfig()) {
|
||||
caSigningSettingsEnabled.value = esignConfig.value?.enabled === true
|
||||
}
|
||||
}
|
||||
|
||||
function openCaSigningSettings() {
|
||||
if (!canManageCaSigning.value) return
|
||||
caSigningSettingsVisible.value = true
|
||||
void loadCaSigningSettings()
|
||||
}
|
||||
|
||||
async function saveCaSigningSettings() {
|
||||
if (!canSaveCaSigningSettings.value) return
|
||||
caSigningSettingsSaving.value = true
|
||||
caSigningSettingsSaveError.value = ''
|
||||
try {
|
||||
const enabled = caSigningSettingsEnabled.value
|
||||
const config = await prescriptionEsignSetConfig({ enabled })
|
||||
if (config?.enabled !== enabled) throw new Error('保存结果与所选设置不一致')
|
||||
esignConfig.value = config
|
||||
caSigningSettingsVisible.value = false
|
||||
feedback.msgSuccess('CA 签名设置已保存')
|
||||
void getLists({ silent: true }).catch(() => {})
|
||||
} catch {
|
||||
caSigningSettingsSaveError.value = '保存未完成,当前选择已保留,请重试。'
|
||||
} finally {
|
||||
caSigningSettingsSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onEsignStatusChange = (state: PrescriptionEsignStatus) => {
|
||||
if (slipView.value) slipView.value.esign = state
|
||||
void getLists()
|
||||
const previous = slipView.value?.esign
|
||||
if (slipView.value && state.review_submitted_at !== undefined) {
|
||||
slipView.value.review_submitted_at = state.review_submitted_at
|
||||
slipView.value.can_submit_for_review = state.can_submit_for_review === true
|
||||
slipView.value.can_review_prescription = state.can_review_prescription === true
|
||||
}
|
||||
void updatePrescriptionSlipEsign(slipView.value, state)
|
||||
if (previous?.status !== state.status || previous?.review_signature_time !== state.review_signature_time
|
||||
|| previous?.review_submitted_at !== state.review_submitted_at
|
||||
|| previous?.can_review_prescription !== state.can_review_prescription) {
|
||||
void getLists({ silent: true }).catch(() => {})
|
||||
}
|
||||
}
|
||||
const viewDetailLoading = ref(false)
|
||||
const viewDetailError = ref('')
|
||||
let viewDetailRequest: AbortController | undefined
|
||||
|
||||
const roleOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
const auditDialogVisible = ref(false)
|
||||
const uploadingPrescriptionId = ref(0)
|
||||
const voidingPrescriptionId = ref(0)
|
||||
const reissuingPrescriptionId = ref(0)
|
||||
const auditTargetId = ref(0)
|
||||
const auditRemark = ref('')
|
||||
const auditLoading = ref(false)
|
||||
@@ -2415,9 +2600,9 @@ const editReviveHint = computed(() => {
|
||||
const v = editingWasVoid.value
|
||||
const r = editingWasRejected.value
|
||||
if (!v && !r) return ''
|
||||
if (v && r) return '当前处方已作废且已驳回。保存后将取消作废、清除驳回,并重新进入待审核。'
|
||||
if (v) return '当前为已作废处方。保存后将取消作废,并重新进入待审核。'
|
||||
return '当前为已驳回处方。保存后将清除驳回,并重新进入待审核。'
|
||||
if (v && r) return '当前处方已作废且已驳回。保存后将取消作废、清除驳回,请重新上传处方。'
|
||||
if (v) return '当前为已作废处方。保存后将取消作废,请重新上传处方。'
|
||||
return '当前为已驳回处方。保存后将清除驳回,请重新上传处方。'
|
||||
})
|
||||
|
||||
const slipHerbsList = computed(() => {
|
||||
@@ -2460,6 +2645,7 @@ const slipDietaryText = computed(() => {
|
||||
* A4 处方笺(药房联)相关计算
|
||||
* ============================================================ */
|
||||
const rxSlipRef = ref<InstanceType<typeof PrescriptionSlip> | null>(null)
|
||||
const prescriptionTabType = ref<'internal' | 'user'>('internal')
|
||||
const downloadingSlip = ref(false)
|
||||
|
||||
function getRxPaperEl(): HTMLElement | null {
|
||||
@@ -2828,6 +3014,14 @@ const editForm = reactive({
|
||||
aux_usage: defaultAuxUsage('浓缩水丸')
|
||||
})
|
||||
|
||||
const reissueContext = ref<{
|
||||
appointment_id: number
|
||||
patient_id: number
|
||||
phone: string
|
||||
prescription_name: string
|
||||
case_record?: unknown
|
||||
} | null>(null)
|
||||
|
||||
/** 编辑页:关联业务订单上的服用天数、医助备注(与处方提示一致) */
|
||||
const rxLinkedOrderHint = reactive({
|
||||
loading: false,
|
||||
@@ -2970,7 +3164,8 @@ async function fetchPrescriptionLists(params: Record<string, unknown>) {
|
||||
|
||||
const { pager, getLists, resetPage } = usePaging({
|
||||
fetchFun: fetchPrescriptionLists,
|
||||
params: formData
|
||||
params: formData,
|
||||
latestOnly: true
|
||||
})
|
||||
|
||||
function pad2(n: number) {
|
||||
@@ -3090,8 +3285,16 @@ function auditStatusTagType(v: number | undefined) {
|
||||
}
|
||||
|
||||
/** 业务订单处方审核驳回时,列表「审核状态」主标签显示为已驳回 */
|
||||
function listAuditStatusLabel(row: { audit_status?: number; business_prescription_audit_rejected?: number }) {
|
||||
function listAuditStatusLabel(row: {
|
||||
audit_status?: number
|
||||
void_status?: number
|
||||
review_submitted_at?: number
|
||||
can_review_prescription?: boolean
|
||||
esign?: PrescriptionEsignStatus
|
||||
business_prescription_audit_rejected?: number
|
||||
}) {
|
||||
if (Number(row.business_prescription_audit_rejected) === 1) return '已驳回'
|
||||
if (isPendingPrescriptionAudit(row)) return pendingPrescriptionReviewLabel(row)
|
||||
return auditStatusLabel(row.audit_status)
|
||||
}
|
||||
|
||||
@@ -3127,8 +3330,44 @@ function isPendingPrescriptionAudit(row: { audit_status?: number | string; void_
|
||||
return (row.audit_status === 0 || row.audit_status === '0') && Number(row.void_status) !== 1
|
||||
}
|
||||
|
||||
type VoidablePrescriptionRow = Parameters<typeof isPendingPrescriptionAudit>[0] & {
|
||||
id?: number | string
|
||||
can_void?: boolean
|
||||
can_submit_for_review?: boolean
|
||||
can_review_prescription?: boolean
|
||||
}
|
||||
|
||||
function canVoidPendingPrescription(row: VoidablePrescriptionRow) {
|
||||
return isPendingPrescriptionAudit(row) && row.can_void === true
|
||||
}
|
||||
|
||||
async function voidPendingPrescription(row: VoidablePrescriptionRow) {
|
||||
const id = Number(row.id)
|
||||
if (!Number.isSafeInteger(id) || id <= 0 || voidingPrescriptionId.value || !canVoidPendingPrescription(row)) return
|
||||
voidingPrescriptionId.value = id
|
||||
try {
|
||||
await feedback.confirm('确定作废这张处方吗?作废后可重新开方。')
|
||||
await prescriptionVoid({ id, pending_only: true })
|
||||
row.void_status = 1
|
||||
row.can_void = false
|
||||
row.can_submit_for_review = false
|
||||
row.can_review_prescription = false
|
||||
feedback.msgSuccess('处方已作废')
|
||||
await getLists({ silent: true })
|
||||
} catch {
|
||||
// The request interceptor reports failures. Canceling leaves the row untouched.
|
||||
} finally {
|
||||
voidingPrescriptionId.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
function canOpenPrescriptionAudit(row: { audit_status?: number | string; void_status?: number | string; can_review_prescription?: boolean }) {
|
||||
return isPendingPrescriptionAudit(row) && row.can_review_prescription === true
|
||||
}
|
||||
|
||||
function pendingEsignAudit(row: { audit_status?: number | string; void_status?: number | string; esign?: PrescriptionEsignStatus }) {
|
||||
return isPendingPrescriptionAudit(row) && row.esign?.required === true && !canApprovePrescriptionEsign(row.esign)
|
||||
return isPendingPrescriptionAudit(row) && row.esign?.required === true && row.esign.awaiting_upload !== true
|
||||
&& !canApprovePrescriptionEsign(row.esign)
|
||||
}
|
||||
|
||||
function formatAuditTime(ts: number | null | undefined) {
|
||||
@@ -3199,6 +3438,10 @@ function rowToSlipView(row: any) {
|
||||
}
|
||||
|
||||
function onEditDialogClosed() {
|
||||
viewDetailRequest?.abort()
|
||||
viewDetailRequest = undefined
|
||||
viewDetailLoading.value = false
|
||||
viewDetailError.value = ''
|
||||
slipView.value = null
|
||||
signatureActivePointerId.value = null
|
||||
}
|
||||
@@ -3305,6 +3548,7 @@ function scheduleEditSignatureInit() {
|
||||
if (sig && String(sig).trim().startsWith('data:image') && signatureCanvasRef.value) {
|
||||
const img = new Image()
|
||||
img.onload = () => {
|
||||
if (editForm.doctor_signature !== sig) return
|
||||
const canvas = signatureCanvasRef.value
|
||||
const ctx = canvas?.getContext('2d')
|
||||
if (!canvas || !ctx) return
|
||||
@@ -3312,7 +3556,7 @@ function scheduleEditSignatureInit() {
|
||||
commitSignatureImage()
|
||||
}
|
||||
img.onerror = () => {
|
||||
commitSignatureImage()
|
||||
if (editForm.doctor_signature === sig) commitSignatureImage()
|
||||
}
|
||||
img.src = sig
|
||||
}
|
||||
@@ -3339,9 +3583,38 @@ function normalizeVisibleRoleIds(row: any): number[] {
|
||||
return []
|
||||
}
|
||||
|
||||
function openAuditDialog(id: number) {
|
||||
if (auditLoading.value) return
|
||||
auditTargetId.value = id
|
||||
async function submitPrescriptionForReview(row: Record<string, any>) {
|
||||
if (uploadingPrescriptionId.value || row.can_submit_for_review !== true) return
|
||||
const id = Number(row.id)
|
||||
if (!Number.isSafeInteger(id) || id <= 0) return
|
||||
uploadingPrescriptionId.value = id
|
||||
try {
|
||||
const result = await prescriptionSubmitForReview({ id })
|
||||
const submittedAt = Number(result?.review_submitted_at)
|
||||
if (!Number.isSafeInteger(submittedAt) || submittedAt <= 0) {
|
||||
feedback.msgError('无法确认上传结果,请刷新处方状态后重试')
|
||||
return
|
||||
}
|
||||
for (const target of [row, pager.lists.find((item: any) => Number(item.id) === id), slipView.value]) {
|
||||
if (!target || Number(target.id) !== id) continue
|
||||
target.review_submitted_at = submittedAt
|
||||
target.can_submit_for_review = false
|
||||
if (target.esign) target.esign = { ...target.esign, ...result, awaiting_upload: false }
|
||||
}
|
||||
const needsDoctorSignature = row.esign?.required === true && row.esign.status !== 'signed'
|
||||
feedback.msgSuccess(needsDoctorSignature ? '处方已上传,请完成医师签署' : '处方已上传')
|
||||
if (needsDoctorSignature) await handleView(row)
|
||||
await getLists({ silent: true })
|
||||
} catch {
|
||||
// 请求失败时由拦截器显示提示,可重新上传。
|
||||
} finally {
|
||||
uploadingPrescriptionId.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
function openAuditDialog(row: Record<string, any>) {
|
||||
if (auditLoading.value || !canOpenPrescriptionAudit(row)) return
|
||||
auditTargetId.value = Number(row.id)
|
||||
auditEsign.value = null
|
||||
auditReview.value = null
|
||||
auditRemark.value = ''
|
||||
@@ -3357,6 +3630,16 @@ function onAuditEsignStatusChange(state: PrescriptionEsignStatus) {
|
||||
else void getLists()
|
||||
}
|
||||
}
|
||||
|
||||
function onAuditReviewChange(state: import('@/api/tcm').PrescriptionEsignReviewStatus | null) {
|
||||
auditReview.value = state
|
||||
if (!state?.required) return
|
||||
const row = pager.lists.find((row: any) => Number(row.id) === auditTargetId.value)
|
||||
if (row?.esign && state.state !== row.esign.review_state) {
|
||||
row.esign.review_state = state.state
|
||||
void getLists()
|
||||
}
|
||||
}
|
||||
|
||||
async function submitAudit(action: 'approve' | 'reject') {
|
||||
if (auditLoading.value || (action === 'approve' && !canApproveAudit.value)) return
|
||||
@@ -3723,6 +4006,7 @@ const removeHerb = (index: number) => {
|
||||
|
||||
// 重置表单
|
||||
const resetForm = () => {
|
||||
reissueContext.value = null
|
||||
editForm.id = 0
|
||||
editForm.prescription_type = '浓缩水丸'
|
||||
editForm.dosage_amount = 1
|
||||
@@ -3734,7 +4018,7 @@ const resetForm = () => {
|
||||
editForm.gender = 1
|
||||
editForm.age = 0
|
||||
editForm.visit_no = ''
|
||||
editForm.prescription_date = new Date().toISOString().split('T')[0]
|
||||
editForm.prescription_date = dayRangeStrings(new Date()).start.slice(0, 10)
|
||||
editForm.tongue = ''
|
||||
editForm.tongue_image = ''
|
||||
editForm.pulse = ''
|
||||
@@ -3768,42 +4052,89 @@ const resetForm = () => {
|
||||
}
|
||||
|
||||
// 新增处方
|
||||
const handleAdd = () => {
|
||||
const handleAdd = () => openNewPrescription()
|
||||
|
||||
function openNewPrescription(source?: Record<string, any>) {
|
||||
void loadEsignConfig()
|
||||
isLoadingData.value = !!source
|
||||
resetForm()
|
||||
if (source) {
|
||||
fillPrescriptionContents(source)
|
||||
editForm.diagnosis_id = Number(source.diagnosis_id) || 0
|
||||
editForm.visit_no = source.visit_no === source.sn ? '' : String(source.visit_no || '')
|
||||
reissueContext.value = {
|
||||
appointment_id: Number(source.appointment_id) || 0,
|
||||
patient_id: Number(source.patient_id) || 0,
|
||||
phone: String(source.phone || ''),
|
||||
prescription_name: String(source.prescription_name || ''),
|
||||
case_record: editForm.diagnosis_id > 0 ? undefined : source.case_record
|
||||
}
|
||||
}
|
||||
editForm.doctor_name = String(userStore.userInfo?.name || '')
|
||||
editingWasVoid.value = false
|
||||
editingWasRejected.value = false
|
||||
editMode.value = 'add'
|
||||
// 新建时允许watch自动设置默认值
|
||||
isLoadingData.value = false
|
||||
showEdit.value = true
|
||||
nextTick(() => {
|
||||
isLoadingData.value = false
|
||||
formRef.value?.clearValidate()
|
||||
scheduleEditSignatureInit()
|
||||
})
|
||||
}
|
||||
|
||||
function canReissuePrescription(row: { creator_id?: number | string; void_status?: number | string }) {
|
||||
const doctorId = Number(userStore.userInfo?.id)
|
||||
return Number(row.void_status) === 1 && doctorId > 0 && Number(row.creator_id) === doctorId
|
||||
&& hasPermission(['cf.prescription/add'])
|
||||
}
|
||||
|
||||
async function handleReissue(row: { id?: number | string; creator_id?: number | string; void_status?: number | string }) {
|
||||
const id = Number(row.id)
|
||||
if (!Number.isSafeInteger(id) || id <= 0 || reissuingPrescriptionId.value || !canReissuePrescription(row)) return
|
||||
const fromDetail = showEdit.value
|
||||
reissuingPrescriptionId.value = id
|
||||
try {
|
||||
const detail = await prescriptionDetail({ id })
|
||||
if (fromDetail ? !showEdit.value || editMode.value !== 'view' || Number(slipView.value?.id) !== id : showEdit.value) return
|
||||
if (Number(detail?.id) !== id || !canReissuePrescription(detail)) {
|
||||
feedback.msgWarning('这张处方当前无法重新开方,请刷新后查看')
|
||||
return
|
||||
}
|
||||
openNewPrescription(detail)
|
||||
} catch {
|
||||
feedback.msgError('无法加载作废处方,请重试')
|
||||
} finally {
|
||||
reissuingPrescriptionId.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
// 查看处方(处方笺样式,详情接口补全电话、签名等)
|
||||
const handleView = async (row: any) => {
|
||||
const id = Number(row.id)
|
||||
if (!Number.isSafeInteger(id) || id <= 0) return
|
||||
viewDetailRequest?.abort()
|
||||
const request = new AbortController()
|
||||
viewDetailRequest = request
|
||||
editingWasVoid.value = false
|
||||
editingWasRejected.value = false
|
||||
editMode.value = 'view'
|
||||
prescriptionTabType.value = 'internal'
|
||||
slipView.value = rowToSlipView(row)
|
||||
showEdit.value = true
|
||||
viewDetailLoading.value = true
|
||||
viewDetailError.value = ''
|
||||
try {
|
||||
const d = await prescriptionDetail({ id: row.id })
|
||||
if (d && typeof d === 'object') {
|
||||
slipView.value = {
|
||||
...d,
|
||||
herbs: normalizeSlipHerbs((d as any).herbs)
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
feedback.msgError(e?.msg || '加载处方详情失败')
|
||||
const d = await prescriptionDetail({ id }, request.signal)
|
||||
if (request.signal.aborted) return
|
||||
if (Number(d?.id) !== id) throw new Error('处方详情与当前处方不一致')
|
||||
slipView.value = rowToSlipView(d)
|
||||
} catch {
|
||||
if (!request.signal.aborted) viewDetailError.value = '无法加载处方详情,请重试。'
|
||||
} finally {
|
||||
viewDetailLoading.value = false
|
||||
if (viewDetailRequest === request) {
|
||||
viewDetailRequest = undefined
|
||||
viewDetailLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3829,8 +4160,34 @@ const handleEdit = async (row: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 深拷贝数据到表单
|
||||
editForm.id = src.id
|
||||
fillPrescriptionContents(src)
|
||||
editForm.visit_no = src.visit_no || ''
|
||||
editForm.prescription_date = src.prescription_date || ''
|
||||
editForm.doctor_name = src.doctor_name || ''
|
||||
editForm.doctor_signature = String(src.doctor_signature || '')
|
||||
editForm.is_shared = src.is_shared ?? 0
|
||||
editForm.visible_role_ids = normalizeVisibleRoleIds(src)
|
||||
editForm.audit_status = src.audit_status ?? 1
|
||||
editForm.audit_time = src.audit_time ?? null
|
||||
editForm.audit_by_name = src.audit_by_name || ''
|
||||
editForm.audit_remark = src.audit_remark || ''
|
||||
editForm.diagnosis_id = src.diagnosis_id ?? 0
|
||||
editForm.creator_id = Number(src.creator_id) > 0 ? Number(src.creator_id) : 0
|
||||
editForm.is_system_auto = Number(src.is_system_auto) === 1 ? 1 : 0
|
||||
editForm.business_prescription_audit_rejected = Number(src.business_prescription_audit_rejected) === 1 ? 1 : 0
|
||||
editForm.business_prescription_audit_remark = String(src.business_prescription_audit_remark || '')
|
||||
|
||||
nextTick(() => {
|
||||
isLoadingData.value = false
|
||||
formRef.value?.clearValidate()
|
||||
scheduleEditSignatureInit()
|
||||
})
|
||||
showEdit.value = true
|
||||
void loadRxLinkedOrderHintForEdit(Number(editForm.id))
|
||||
}
|
||||
|
||||
function fillPrescriptionContents(src: Record<string, any>) {
|
||||
editForm.prescription_type = src.prescription_type || '浓缩水丸'
|
||||
|
||||
// 确保 dosage_amount 是数字类型,以匹配下拉框的 :value
|
||||
@@ -3857,14 +4214,12 @@ const handleEdit = async (row: any) => {
|
||||
editForm.patient_name = src.patient_name || ''
|
||||
editForm.gender = src.gender ?? 1
|
||||
editForm.age = src.age ?? 0
|
||||
editForm.visit_no = src.visit_no || ''
|
||||
editForm.prescription_date = src.prescription_date || ''
|
||||
editForm.tongue = src.tongue || ''
|
||||
editForm.tongue_image = src.tongue_image || ''
|
||||
editForm.pulse = src.pulse || ''
|
||||
editForm.pulse_condition = src.pulse_condition || ''
|
||||
editForm.clinical_diagnosis = src.clinical_diagnosis || ''
|
||||
editForm.herbs = src.herbs ? (src.herbs as any[]).map((h) => normalizeHerbRow(h)) : []
|
||||
editForm.herbs = normalizeSlipHerbs(src.herbs)
|
||||
editForm.dose_count = src.dose_count ?? 7
|
||||
editForm.dose_unit = src.dose_unit || '剂'
|
||||
editForm.usage_days = src.usage_days ?? 7
|
||||
@@ -3873,39 +4228,13 @@ const handleEdit = async (row: any) => {
|
||||
editForm.usage_time = src.usage_time || '饭后'
|
||||
editForm.usage_way = src.usage_way || '温水送服'
|
||||
editForm.dietary_taboo = src.dietary_taboo
|
||||
? (Array.isArray(src.dietary_taboo) ? src.dietary_taboo : String(src.dietary_taboo).split(',').filter((v: string) => v))
|
||||
? (Array.isArray(src.dietary_taboo) ? [...src.dietary_taboo] : String(src.dietary_taboo).split(',').filter((v: string) => v))
|
||||
: []
|
||||
editForm.usage_notes = src.usage_notes || ''
|
||||
editForm.doctor_name = src.doctor_name || ''
|
||||
editForm.doctor_signature = String(src.doctor_signature || '')
|
||||
editForm.is_shared = src.is_shared ?? 0
|
||||
editForm.visible_role_ids = normalizeVisibleRoleIds(src)
|
||||
editForm.audit_status = src.audit_status ?? 1
|
||||
editForm.audit_time = src.audit_time ?? null
|
||||
editForm.audit_by_name = src.audit_by_name || ''
|
||||
editForm.audit_remark = src.audit_remark || ''
|
||||
editForm.diagnosis_id = src.diagnosis_id ?? 0
|
||||
editForm.creator_id = Number(src.creator_id) > 0 ? Number(src.creator_id) : 0
|
||||
editForm.is_system_auto = Number(src.is_system_auto) === 1 ? 1 : 0
|
||||
editForm.business_prescription_audit_rejected = Number(src.business_prescription_audit_rejected) === 1 ? 1 : 0
|
||||
editForm.business_prescription_audit_remark = String(src.business_prescription_audit_remark || '')
|
||||
Object.assign(
|
||||
editForm.aux_usage,
|
||||
normalizeAuxUsageForm(src.aux_usage, editForm.prescription_type)
|
||||
)
|
||||
|
||||
// 数据加载完成,重新启用watch
|
||||
// 使用 setTimeout 确保所有数据都已经渲染完成
|
||||
setTimeout(() => {
|
||||
isLoadingData.value = false
|
||||
}, 0)
|
||||
|
||||
showEdit.value = true
|
||||
void loadRxLinkedOrderHintForEdit(Number(editForm.id))
|
||||
nextTick(() => {
|
||||
formRef.value?.clearValidate()
|
||||
scheduleEditSignatureInit()
|
||||
})
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
@@ -3949,6 +4278,10 @@ const handleSubmit = async () => {
|
||||
let result: any
|
||||
if (editMode.value === 'add') {
|
||||
params.audit_status = 0
|
||||
if (reissueContext.value) {
|
||||
Object.assign(params, reissueContext.value)
|
||||
if (!editForm.visit_no.trim()) delete params.visit_no
|
||||
}
|
||||
result = await prescriptionAdd(params)
|
||||
} else {
|
||||
result = await prescriptionEdit(params)
|
||||
@@ -3958,7 +4291,7 @@ const handleSubmit = async () => {
|
||||
feedback.msgSuccess(result?.esign?.required ? '处方草稿已保存' : '处方已保存,请核对电子签署状态')
|
||||
await handleView({ ...editForm, id, audit_status: 0, esign: result?.esign })
|
||||
} else {
|
||||
feedback.msgSuccess('保存成功,处方已进入待审核')
|
||||
feedback.msgSuccess('处方已保存,请在「已开处方」上传')
|
||||
showEdit.value = false
|
||||
}
|
||||
getLists()
|
||||
@@ -4008,7 +4341,17 @@ onMounted(async () => {
|
||||
}
|
||||
getLists()
|
||||
const reviewId = Number(route.query.review_prescription)
|
||||
if (Number.isSafeInteger(reviewId) && reviewId > 0) openAuditDialog(reviewId)
|
||||
if (Number.isSafeInteger(reviewId) && reviewId > 0 && hasPermission(['cf.prescription/audit'])) {
|
||||
try {
|
||||
const detail = await prescriptionDetail({ id: reviewId })
|
||||
if (canOpenPrescriptionAudit(detail)) openAuditDialog(detail)
|
||||
else if (isPendingPrescriptionAudit(detail)) feedback.msgWarning(
|
||||
Number(detail.review_submitted_at) > 0 ? '请等开方医生签署并通过验签后再审核' : '请开方医生先上传处方'
|
||||
)
|
||||
} catch {
|
||||
// 请求失败时由拦截器显示提示。
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -4177,6 +4520,10 @@ onMounted(async () => {
|
||||
margin: -20px;
|
||||
}
|
||||
|
||||
.rx-slip-tabs :deep(.el-tabs__content) {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.rx-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1273,7 +1273,8 @@
|
||||
<el-dialog
|
||||
v-model="auditVisible"
|
||||
:title="auditTitle"
|
||||
width="480px"
|
||||
:width="auditKind === 'prescription' ? 'min(1280px, 96vw)' : '480px'"
|
||||
:top="auditKind === 'prescription' ? '5vh' : undefined"
|
||||
destroy-on-close
|
||||
@closed="auditRemark = ''"
|
||||
>
|
||||
@@ -1297,18 +1298,24 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
<EsignPrescriptionPanel
|
||||
v-if="auditVisible && auditKind === 'prescription'"
|
||||
:key="auditTargetId"
|
||||
:prescription-id="Number(auditRowData?.prescription_id) || 0"
|
||||
audit
|
||||
:review-order-id="Number(auditTargetId)"
|
||||
@review-change="auditReview = $event"
|
||||
class="mb-3"
|
||||
@status-change="auditEsign = $event"
|
||||
/>
|
||||
<p class="text-[13px] text-gray-500 mb-3 bg-gray-50/80 border border-gray-100 p-2 rounded">驳回时必须填写意见;通过时意见选填。</p>
|
||||
<el-input v-model="auditRemark" type="textarea" :rows="4" maxlength="500" show-word-limit placeholder="在此输入审核意见..." />
|
||||
<PrescriptionAuditLayout
|
||||
:prescription-id="auditKind === 'prescription' ? Number(auditRowData?.prescription_id) || 0 : null"
|
||||
:doctor-signed-at="auditEsign?.signature_time || auditEsign?.signed_at"
|
||||
:pharmacist-signed-at="auditReview?.signature_time || auditEsign?.review_signature_time"
|
||||
>
|
||||
<EsignPrescriptionPanel
|
||||
v-if="auditVisible && auditKind === 'prescription'"
|
||||
:key="auditTargetId"
|
||||
:prescription-id="Number(auditRowData?.prescription_id) || 0"
|
||||
audit
|
||||
:review-order-id="Number(auditTargetId)"
|
||||
@review-change="auditReview = $event"
|
||||
class="mb-3"
|
||||
@status-change="auditEsign = $event"
|
||||
/>
|
||||
<p class="text-[13px] text-gray-500 mb-3 bg-gray-50/80 border border-gray-100 p-2 rounded">驳回时必须填写意见;通过时意见选填。</p>
|
||||
<el-input v-model="auditRemark" type="textarea" :rows="4" maxlength="500" show-word-limit placeholder="在此输入审核意见..." />
|
||||
</PrescriptionAuditLayout>
|
||||
<template #footer>
|
||||
<el-button @click="auditVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="auditSubmitting" :disabled="!canApproveAudit" @click="submitAudit('approve')">同意通过</el-button>
|
||||
@@ -1820,6 +1827,7 @@
|
||||
v-model="prescriptionTabType"
|
||||
class="mx-4 mt-2"
|
||||
style="margin-bottom: 0; z-index: 1; position: relative"
|
||||
:before-leave="() => !prescriptionSlipExporting"
|
||||
>
|
||||
<el-tab-pane label="药房联" name="internal" />
|
||||
<el-tab-pane label="处方联" name="user" />
|
||||
@@ -1878,7 +1886,7 @@
|
||||
:key="prescriptionViewData.id"
|
||||
:prescription-id="Number(prescriptionViewData.id)"
|
||||
:initial-state="prescriptionViewData.esign"
|
||||
@status-change="prescriptionViewData.esign = $event"
|
||||
@status-change="updatePrescriptionSlipEsign(prescriptionViewData, $event)"
|
||||
/>
|
||||
<PrescriptionSlip
|
||||
v-if="prescriptionViewData"
|
||||
@@ -2149,8 +2157,9 @@ import {
|
||||
} from '@/api/tcm'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
|
||||
import PrescriptionAuditLayout from '@/components/PrescriptionAuditLayout.vue'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, requiresOriginalEsignPdf } from '@/utils/prescription-esign'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import html2canvas from 'html2canvas'
|
||||
import { jsPDF } from 'jspdf'
|
||||
import { getDictData } from '@/api/app'
|
||||
@@ -2966,10 +2975,10 @@ function canEditRow(row: {
|
||||
return fs === 1 || fs === 2
|
||||
}
|
||||
|
||||
function canRxAudit(row: { prescription_audit_status?: number; fulfillment_status?: number }) {
|
||||
function canRxAudit(row: { prescription_audit_status?: number; fulfillment_status?: number; can_review_prescription?: boolean }) {
|
||||
const fs = Number(row.fulfillment_status)
|
||||
if (fs === 3 || fs === 4 || fs === 6) return false
|
||||
return Number(row.prescription_audit_status) === 0
|
||||
return Number(row.prescription_audit_status) === 0 && row.can_review_prescription === true
|
||||
}
|
||||
|
||||
function canPayAudit(row: {
|
||||
@@ -3729,6 +3738,7 @@ const auditTitle = computed(() =>
|
||||
|
||||
function openAudit(row: Record<string, any>, kind: 'prescription' | 'payment') {
|
||||
if (auditSubmitting.value) return
|
||||
if (kind === 'prescription' && !canRxAudit(row)) return
|
||||
auditKind.value = kind
|
||||
auditTargetId.value = Number(row.id)
|
||||
auditRowData.value = row
|
||||
|
||||
@@ -1840,7 +1840,8 @@
|
||||
<el-dialog
|
||||
v-model="auditVisible"
|
||||
:title="auditTitle"
|
||||
width="92%"
|
||||
:width="auditKind === 'prescription' ? 'min(1280px, 96vw)' : '92%'"
|
||||
:top="auditKind === 'prescription' ? '5vh' : undefined"
|
||||
destroy-on-close
|
||||
class="po-h5-dialog"
|
||||
@closed="auditRemark = ''"
|
||||
@@ -1865,18 +1866,24 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
<EsignPrescriptionPanel
|
||||
v-if="auditVisible && auditKind === 'prescription'"
|
||||
:key="auditTargetId"
|
||||
:prescription-id="Number(auditRowData?.prescription_id) || 0"
|
||||
audit
|
||||
:review-order-id="Number(auditTargetId)"
|
||||
@review-change="auditReview = $event"
|
||||
class="mb-3"
|
||||
@status-change="auditEsign = $event"
|
||||
/>
|
||||
<p class="text-[13px] text-gray-500 mb-3 bg-gray-50/80 border border-gray-100 p-2 rounded">驳回时必须填写意见;通过时意见选填。</p>
|
||||
<el-input v-model="auditRemark" type="textarea" :rows="4" maxlength="500" show-word-limit placeholder="在此输入审核意见..." />
|
||||
<PrescriptionAuditLayout
|
||||
:prescription-id="auditKind === 'prescription' ? Number(auditRowData?.prescription_id) || 0 : null"
|
||||
:doctor-signed-at="auditEsign?.signature_time || auditEsign?.signed_at"
|
||||
:pharmacist-signed-at="auditReview?.signature_time || auditEsign?.review_signature_time"
|
||||
>
|
||||
<EsignPrescriptionPanel
|
||||
v-if="auditVisible && auditKind === 'prescription'"
|
||||
:key="auditTargetId"
|
||||
:prescription-id="Number(auditRowData?.prescription_id) || 0"
|
||||
audit
|
||||
:review-order-id="Number(auditTargetId)"
|
||||
@review-change="auditReview = $event"
|
||||
class="mb-3"
|
||||
@status-change="auditEsign = $event"
|
||||
/>
|
||||
<p class="text-[13px] text-gray-500 mb-3 bg-gray-50/80 border border-gray-100 p-2 rounded">驳回时必须填写意见;通过时意见选填。</p>
|
||||
<el-input v-model="auditRemark" type="textarea" :rows="4" maxlength="500" show-word-limit placeholder="在此输入审核意见..." />
|
||||
</PrescriptionAuditLayout>
|
||||
<template #footer>
|
||||
<el-button @click="auditVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="auditSubmitting" :disabled="!canApproveAudit" @click="submitAudit('approve')">同意通过</el-button>
|
||||
@@ -2420,6 +2427,7 @@
|
||||
v-model="prescriptionTabType"
|
||||
class="mx-4 mt-2"
|
||||
style="margin-bottom: 0; z-index: 1; position: relative"
|
||||
:before-leave="() => !prescriptionSlipExporting"
|
||||
>
|
||||
<el-tab-pane label="药房联" name="internal" />
|
||||
<el-tab-pane label="处方联" name="user" />
|
||||
@@ -2478,7 +2486,7 @@
|
||||
:key="prescriptionViewData.id"
|
||||
:prescription-id="Number(prescriptionViewData.id)"
|
||||
:initial-state="prescriptionViewData.esign"
|
||||
@status-change="prescriptionViewData.esign = $event"
|
||||
@status-change="updatePrescriptionSlipEsign(prescriptionViewData, $event)"
|
||||
/>
|
||||
<PrescriptionSlip
|
||||
v-if="prescriptionViewData"
|
||||
@@ -2713,8 +2721,9 @@ import {
|
||||
} from './components/prescription-order-utils'
|
||||
import PrescriptionSlip from '@/components/prescription-slip/index.vue'
|
||||
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
|
||||
import PrescriptionAuditLayout from '@/components/PrescriptionAuditLayout.vue'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, requiresOriginalEsignPdf } from '@/utils/prescription-esign'
|
||||
import { canApprovePrescriptionEsign, downloadPrescriptionPdfIfRequired, requiresOriginalEsignPdf, updatePrescriptionSlipEsign } from '@/utils/prescription-esign'
|
||||
import html2canvas from 'html2canvas'
|
||||
import { jsPDF } from 'jspdf'
|
||||
import { getDictData } from '@/api/app'
|
||||
@@ -3445,10 +3454,10 @@ function canEditRow(row: {
|
||||
return fs === 1 || fs === 2
|
||||
}
|
||||
|
||||
function canRxAudit(row: { prescription_audit_status?: number; fulfillment_status?: number }) {
|
||||
function canRxAudit(row: { prescription_audit_status?: number; fulfillment_status?: number; can_review_prescription?: boolean }) {
|
||||
const fs = Number(row.fulfillment_status)
|
||||
if (fs === 3 || fs === 4 || fs === 6) return false
|
||||
return Number(row.prescription_audit_status) === 0
|
||||
return Number(row.prescription_audit_status) === 0 && row.can_review_prescription === true
|
||||
}
|
||||
|
||||
function canPayAudit(row: {
|
||||
@@ -4696,6 +4705,7 @@ const auditTitle = computed(() =>
|
||||
|
||||
function openAudit(row: Record<string, any>, kind: 'prescription' | 'payment') {
|
||||
if (auditSubmitting.value) return
|
||||
if (kind === 'prescription' && !canRxAudit(row)) return
|
||||
auditKind.value = kind
|
||||
auditTargetId.value = Number(row.id)
|
||||
auditRowData.value = row
|
||||
|
||||
@@ -31,32 +31,45 @@
|
||||
</template>
|
||||
</prescription-order-detail-drawer>
|
||||
|
||||
<el-dialog v-model="auditVisible" :title="auditTitle" width="480px" append-to-body destroy-on-close>
|
||||
<EsignPrescriptionPanel
|
||||
v-if="auditVisible && auditKind === 'prescription'"
|
||||
:key="actionRow.id"
|
||||
:prescription-id="Number(actionRow.prescription_id) || 0"
|
||||
audit
|
||||
:review-order-id="Number(actionRow.id)"
|
||||
@review-change="auditReview = $event"
|
||||
class="mb-3"
|
||||
@status-change="auditEsign = $event"
|
||||
/>
|
||||
<el-alert
|
||||
title="通过时审核意见可不填;驳回时必须填写明确原因。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb-4"
|
||||
/>
|
||||
<el-input
|
||||
v-model="auditRemark"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
placeholder="请输入审核意见"
|
||||
/>
|
||||
<el-dialog
|
||||
v-model="auditVisible"
|
||||
:title="auditTitle"
|
||||
:width="auditKind === 'prescription' ? 'min(1280px, 96vw)' : '480px'"
|
||||
:top="auditKind === 'prescription' ? '5vh' : undefined"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
>
|
||||
<PrescriptionAuditLayout
|
||||
:prescription-id="auditKind === 'prescription' ? Number(actionRow.prescription_id) || 0 : null"
|
||||
:doctor-signed-at="auditEsign?.signature_time || auditEsign?.signed_at"
|
||||
:pharmacist-signed-at="auditReview?.signature_time || auditEsign?.review_signature_time"
|
||||
>
|
||||
<EsignPrescriptionPanel
|
||||
v-if="auditVisible && auditKind === 'prescription'"
|
||||
:key="actionRow.id"
|
||||
:prescription-id="Number(actionRow.prescription_id) || 0"
|
||||
audit
|
||||
:review-order-id="Number(actionRow.id)"
|
||||
@review-change="auditReview = $event"
|
||||
class="mb-3"
|
||||
@status-change="auditEsign = $event"
|
||||
/>
|
||||
<el-alert
|
||||
title="通过时审核意见可不填;驳回时必须填写明确原因。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="mb-4"
|
||||
/>
|
||||
<el-input
|
||||
v-model="auditRemark"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
placeholder="请输入审核意见"
|
||||
/>
|
||||
</PrescriptionAuditLayout>
|
||||
<template #footer>
|
||||
<el-button @click="auditVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" :disabled="!canApproveAudit" @click="submitAudit('approve')">同意通过</el-button>
|
||||
@@ -254,6 +267,7 @@ import { ArrowDown } from '@element-plus/icons-vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EsignPrescriptionPanel from '@/components/EsignPrescriptionPanel.vue'
|
||||
import PrescriptionAuditLayout from '@/components/PrescriptionAuditLayout.vue'
|
||||
import type { PrescriptionEsignStatus } from '@/api/tcm'
|
||||
import { canApprovePrescriptionEsign } from '@/utils/prescription-esign'
|
||||
import PrescriptionOrderDetailDrawer from '@/views/consumer/prescription/components/PrescriptionOrderDetailDrawer.vue'
|
||||
@@ -406,6 +420,7 @@ async function openEdit(row: Record<string, any>) {
|
||||
|
||||
function openAction(row: Record<string, any>, action: MyPatientOrderAction) {
|
||||
if (submitting.value && (action === 'audit_prescription' || action === 'audit_payment')) return
|
||||
if (action === 'audit_prescription' && row.can_review_prescription !== true) return
|
||||
actionRow.value = row
|
||||
switch (action) {
|
||||
case 'edit':
|
||||
|
||||
@@ -50,6 +50,7 @@ export function myPatientOrderActions(row: Record<string, any>): MyPatientOrderA
|
||||
}
|
||||
if (
|
||||
permitted('tcm.prescriptionOrder/auditPrescription')
|
||||
&& row.can_review_prescription === true
|
||||
&& prescriptionAudit === 0
|
||||
&& ![3, 4, 6].includes(fulfillment)
|
||||
) {
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<el-form :model="filters" inline @submit.prevent="resetPage">
|
||||
<el-form-item label="统计日期">
|
||||
<el-date-picker
|
||||
v-model="filters.date"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
:clearable="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户">
|
||||
<el-input v-model.trim="filters.keyword" placeholder="账号或姓名" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button native-type="submit" type="primary">查询</el-button>
|
||||
<el-button @click="resetFilters">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-loading="pager.loading" class="!border-none mt-4" shadow="never">
|
||||
<div class="flex flex-wrap items-baseline gap-x-4 gap-y-1 mb-4">
|
||||
<h2 class="text-lg font-medium">桌面登录记录</h2>
|
||||
<span v-if="pager.extend?.total_day_seconds != null">
|
||||
当日会话累计 {{ durationText(pager.extend.total_day_seconds) }}
|
||||
</span>
|
||||
<span class="text-tx-secondary text-sm">按北京时间自然日统计</span>
|
||||
</div>
|
||||
<el-table :data="pager.lists" row-key="id" empty-text="当日没有匹配的桌面登录记录">
|
||||
<el-table-column
|
||||
label="账号"
|
||||
prop="account"
|
||||
min-width="120"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="姓名" prop="name" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column label="登录时间" prop="login_time" width="176" />
|
||||
<el-table-column label="退出时间" width="176">
|
||||
<template #default="{ row }">{{ row.logout_time || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="本次登录时长" min-width="130">
|
||||
<template #default="{ row }">{{ durationText(row.duration_seconds) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计入当日" min-width="130">
|
||||
<template #default="{ row }">{{ durationText(row.day_seconds) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tooltip
|
||||
v-if="row.status === 'timeout'"
|
||||
content="连续 3 分钟未收到心跳,退出时间按最后一次确认在线的时间记录"
|
||||
placement="top"
|
||||
>
|
||||
<el-tag type="warning" effect="plain">{{ row.status_label }}</el-tag>
|
||||
</el-tooltip>
|
||||
<el-tag
|
||||
v-else
|
||||
:type="row.status === 'online' ? 'success' : 'info'"
|
||||
effect="plain"
|
||||
>
|
||||
{{ row.status_label }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="desktopSessions">
|
||||
import { desktopSessionLists } from '@/api/setting/system'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
|
||||
const beijingDate = () =>
|
||||
new Intl.DateTimeFormat('sv-SE', {
|
||||
timeZone: 'Asia/Shanghai',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit'
|
||||
}).format(new Date())
|
||||
|
||||
const filters = reactive({ date: beijingDate(), keyword: '' })
|
||||
const { pager, getLists, resetPage } = usePaging({
|
||||
fetchFun: desktopSessionLists,
|
||||
params: filters,
|
||||
latestOnly: true,
|
||||
firstLoading: true
|
||||
})
|
||||
|
||||
function resetFilters() {
|
||||
filters.date = beijingDate()
|
||||
filters.keyword = ''
|
||||
resetPage()
|
||||
}
|
||||
|
||||
function durationText(seconds: number) {
|
||||
const hours = Math.floor(seconds / 3600)
|
||||
const minutes = Math.floor((seconds % 3600) / 60)
|
||||
if (hours) return `${hours}小时${minutes}分${seconds % 60}秒`
|
||||
if (minutes) return `${minutes}分${seconds % 60}秒`
|
||||
return `${seconds % 60}秒`
|
||||
}
|
||||
|
||||
onMounted(() => getLists())
|
||||
</script>
|
||||
Reference in New Issue
Block a user