|  | @@ -398,7 +398,6 @@ const emrSnippetRef = ref(null)
 | 
	
		
			
				|  |  |  let loaded = $ref(false)
 | 
	
		
			
				|  |  |  // 是否 改变了数据
 | 
	
		
			
				|  |  |  let isEditorChange = $ref(false)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  // 是否开启审阅模式
 | 
	
		
			
				|  |  |  let reviewMode = $ref(0)
 | 
	
		
			
				|  |  |  // 跳转定位
 | 
	
	
		
			
				|  | @@ -476,7 +475,7 @@ const emrEvent = {
 | 
	
		
			
				|  |  |      // 判断是否只读
 | 
	
		
			
				|  |  |      readonlyPattern()
 | 
	
		
			
				|  |  |      // 每一个病历只能一个人编辑
 | 
	
		
			
				|  |  | -    editJudgment()
 | 
	
		
			
				|  |  | +    await editJudgment()
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    'contentchange': (event) => {
 | 
	
	
		
			
				|  | @@ -554,30 +553,35 @@ const editJudgment = async () => {
 | 
	
		
			
				|  |  |    if (stringIsBlank(documentId)) {
 | 
	
		
			
				|  |  |      return
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  if (categoryCode.includes('shoucibingchengjilu')) {
 | 
	
		
			
				|  |  | -    currentEditorUser = await lockMedicalRecords(documentId)
 | 
	
		
			
				|  |  | -    if (currentEditorUser === null) {
 | 
	
		
			
				|  |  | -      xcMessage.success('可以编辑')
 | 
	
		
			
				|  |  | -    } else {
 | 
	
		
			
				|  |  | -      ElMessageBox.alert(`【${currentEditorUser.name}】正在编辑当前病历,请医生先退出病历后才能编辑。`, '提示', {
 | 
	
		
			
				|  |  | -        type: 'error',
 | 
	
		
			
				|  |  | -        dangerouslyUseHTMLString: true,
 | 
	
		
			
				|  |  | -      })
 | 
	
		
			
				|  |  | -      editor.setEditorMode('readonly')
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -  } else {
 | 
	
		
			
				|  |  | -    if (readonlyPattern()) {
 | 
	
		
			
				|  |  | -      return;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    currentEditorUser = await lockMedicalRecords(documentId)
 | 
	
		
			
				|  |  | -    if (currentEditorUser === null) {
 | 
	
		
			
				|  |  | -      xcMessage.success('可以编辑')
 | 
	
		
			
				|  |  | +  await emrSocket.value.medicalRecordSwitching(userData.name + '正在编辑或查看【' + templateName + '】病历')
 | 
	
		
			
				|  |  | +  // 判断当前是否可以编辑病历
 | 
	
		
			
				|  |  | +  if (emrConfig.value.editor) {
 | 
	
		
			
				|  |  | +    // 因为病程记录谁都可以编写所以。
 | 
	
		
			
				|  |  | +    if (categoryCode.includes('shoucibingchengjilu')) {
 | 
	
		
			
				|  |  | +      currentEditorUser = await lockMedicalRecords(documentId)
 | 
	
		
			
				|  |  | +      if (currentEditorUser === null || currentEditorUser.code === userData.code) {
 | 
	
		
			
				|  |  | +        xcMessage.success('可以编辑')
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +        await ElMessageBox.alert(`【${currentEditorUser.name}】正在编辑当前病历,请医生先退出病历后才能编辑。`, '提示', {
 | 
	
		
			
				|  |  | +          type: 'error',
 | 
	
		
			
				|  |  | +          dangerouslyUseHTMLString: true,
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        editor.setEditorMode('readonly')
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |      } else {
 | 
	
		
			
				|  |  | -      ElMessageBox.alert(`【${currentEditorUser.name}】正在编辑当前病历,请医生先退出病历后才能编辑。`, '提示', {
 | 
	
		
			
				|  |  | -        type: 'error',
 | 
	
		
			
				|  |  | -        dangerouslyUseHTMLString: true,
 | 
	
		
			
				|  |  | -      })
 | 
	
		
			
				|  |  | -      editor.setEditorMode('readonly')
 | 
	
		
			
				|  |  | +      if (readonlyPattern()) {
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      currentEditorUser = await lockMedicalRecords(documentId)
 | 
	
		
			
				|  |  | +      if (currentEditorUser === null) {
 | 
	
		
			
				|  |  | +        xcMessage.success('可以编辑')
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +        await ElMessageBox.alert(`【${currentEditorUser.name}】正在编辑当前病历,请医生先退出病历后才能编辑。`, '提示', {
 | 
	
		
			
				|  |  | +          type: 'error',
 | 
	
		
			
				|  |  | +          dangerouslyUseHTMLString: true,
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        editor.setEditorMode('readonly')
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    readonlyPattern()
 | 
	
	
		
			
				|  | @@ -821,14 +825,6 @@ const positioningTime = (val, code) => {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -const monitorPageRefresh = (event) => {
 | 
	
		
			
				|  |  | -  if (isEditorChange) {
 | 
	
		
			
				|  |  | -    event.preventDefault();
 | 
	
		
			
				|  |  | -    clearMedicalRecordEditorUser(documentId)
 | 
	
		
			
				|  |  | -    event.returnValue = "是否确实要退出?还有未保存的数据!";
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 点击插入片段
 | 
	
		
			
				|  |  |   * @param content
 | 
	
	
		
			
				|  | @@ -1360,6 +1356,27 @@ const autoSaveFunc = () => {
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * 拦截
 | 
	
		
			
				|  |  | + * @param event
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +const monitorPageRefresh = (event) => {
 | 
	
		
			
				|  |  | +  if (readonlyPattern()) {
 | 
	
		
			
				|  |  | +    isEditorChange = false;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  if (isEditorChange) {
 | 
	
		
			
				|  |  | +    event.preventDefault();
 | 
	
		
			
				|  |  | +    event.returnValue = "是否确实要退出?还有未保存的数据!";
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * 用户刷新且点击了,确定后把锁释放
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +const unload = () => {
 | 
	
		
			
				|  |  | +  clearMedicalRecordEditorUser(documentId)
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  onMounted(async () => {
 | 
	
		
			
				|  |  |    autoSave = store.state.app.emrAutosave;
 | 
	
	
		
			
				|  | @@ -1375,7 +1392,9 @@ onMounted(async () => {
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    doctorLevelFunc()
 | 
	
		
			
				|  |  |    emrRef.value.parentElement.emr = currentEmr.value
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    window.addEventListener('beforeunload', monitorPageRefresh, {capture: true})
 | 
	
		
			
				|  |  | +  window.addEventListener('unload', unload, {capture: true})
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    getWardsApi().then((res) => {
 | 
	
		
			
				|  |  |      if (res.length > 0) {
 | 
	
	
		
			
				|  | @@ -1390,9 +1409,10 @@ onMounted(async () => {
 | 
	
		
			
				|  |  |  onDeactivated(() => {
 | 
	
		
			
				|  |  |    clearInterval(interval)
 | 
	
		
			
				|  |  |    window.removeEventListener('beforeunload', monitorPageRefresh, {capture: true})
 | 
	
		
			
				|  |  | +  window.removeEventListener('unload', unload, {capture: true})
 | 
	
		
			
				|  |  | +  unload()
 | 
	
		
			
				|  |  |  })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  onBeforeRouteLeave((to, from, next) => {
 | 
	
		
			
				|  |  |    checkEmrChange(() => {
 | 
	
		
			
				|  |  |      next();
 |