|  | @@ -19,7 +19,15 @@
 | 
	
		
			
				|  |  |                     @click="clickDelete">
 | 
	
		
			
				|  |  |            删除
 | 
	
		
			
				|  |  |          </el-button>
 | 
	
		
			
				|  |  | +        <el-button @click="recoveryDialog = true">
 | 
	
		
			
				|  |  | +          恢复
 | 
	
		
			
				|  |  | +        </el-button>
 | 
	
		
			
				|  |  |        </el-button-group>
 | 
	
		
			
				|  |  | +      <!--   恢复到上一次保存的状态   -->
 | 
	
		
			
				|  |  | +      <historical-emr v-if="recoveryDialog"
 | 
	
		
			
				|  |  | +                      @closed="recoveryDialog = false"
 | 
	
		
			
				|  |  | +                      :docunent-id="documentId"
 | 
	
		
			
				|  |  | +                      @restore-data="restoreData"/>
 | 
	
		
			
				|  |  |        <el-divider direction="vertical"/>
 | 
	
		
			
				|  |  |        <el-button-group>
 | 
	
		
			
				|  |  |          <el-button type="primary" icon="Printer" @click="frontEndPrinting"
 | 
	
	
		
			
				|  | @@ -45,6 +53,7 @@
 | 
	
		
			
				|  |  |            DRG分组
 | 
	
		
			
				|  |  |          </el-button>
 | 
	
		
			
				|  |  |        </el-button-group>
 | 
	
		
			
				|  |  | +      <!--   手术数据填充   -->
 | 
	
		
			
				|  |  |        <emr-assistant :data="openAssistant" :to-fill-in-data="clickToFillInData"/>
 | 
	
		
			
				|  |  |        <el-divider direction="vertical"/>
 | 
	
		
			
				|  |  |        <el-select v-model="reviewMode"
 | 
	
	
		
			
				|  | @@ -290,6 +299,8 @@ import XcDialogV2 from "@/components/xiao-chan/dialog/XcDialogV2.vue";
 | 
	
		
			
				|  |  |  import {getWardsApi} from "@/api/login";
 | 
	
		
			
				|  |  |  import {xcMessage} from "@/utils/xiaochan-element-plus";
 | 
	
		
			
				|  |  |  import EmrUnorderedList from "@/components/zhu-yuan-yi-sheng/emr/EmrUnorderedList.vue";
 | 
	
		
			
				|  |  | +import HistoricalEmr from "@/components/zhu-yuan-yi-sheng/emr/HistoricalEmr.vue";
 | 
	
		
			
				|  |  | +import {stringIsBlank} from "@/utils/blank-utils";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const props = defineProps({
 | 
	
		
			
				|  |  |    huanZheXinXi: {
 | 
	
	
		
			
				|  | @@ -309,7 +320,7 @@ const props = defineProps({
 | 
	
		
			
				|  |  |  const currentEmr = ref(null)
 | 
	
		
			
				|  |  |  const emrRef = ref(null)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +let recoveryDialog = $ref(false)
 | 
	
		
			
				|  |  |  let categoryCode = $ref('')
 | 
	
		
			
				|  |  |  // 文档 id 唯一值
 | 
	
		
			
				|  |  |  let documentId = $ref('')
 | 
	
	
		
			
				|  | @@ -440,7 +451,7 @@ const emrEvent = {
 | 
	
		
			
				|  |  |  const clickSaveData = async () => {
 | 
	
		
			
				|  |  |    // 只读模式无法保存数据
 | 
	
		
			
				|  |  |    if (readonlyPattern()) {
 | 
	
		
			
				|  |  | -    BizException(ExceptionEnum.LOGICAL_ERROR, "无法保存病历。");
 | 
	
		
			
				|  |  | +    BizException(ExceptionEnum.LOGICAL_ERROR, "当前为只读模式,无法保存病历。");
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    waitForLoadingToComplete()
 | 
	
		
			
				|  |  |    // 判断是否有必填项目
 | 
	
	
		
			
				|  | @@ -449,9 +460,9 @@ const clickSaveData = async () => {
 | 
	
		
			
				|  |  |    if (valid) {
 | 
	
		
			
				|  |  |      BizException(ExceptionEnum.MESSAGE_ERROR, "有必填项不能为空,请仔细检查,红色输入框.")
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +  await analysisIframeSrcSearch()
 | 
	
		
			
				|  |  |    let data = {
 | 
	
		
			
				|  |  | -    // 这个是 唯一 id 调用服务的雪花算法
 | 
	
		
			
				|  |  | -    emrDocumentId: documentId ? documentId : await getUuid(),
 | 
	
		
			
				|  |  | +    emrDocumentId: documentId,
 | 
	
		
			
				|  |  |      emrCategoryCode: categoryCode,
 | 
	
		
			
				|  |  |      patNo: props.huanZheXinXi.inpatientNo,
 | 
	
		
			
				|  |  |      times: props.huanZheXinXi.admissTimes,
 | 
	
	
		
			
				|  | @@ -460,12 +471,11 @@ const clickSaveData = async () => {
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    objectValuesCannotBeNull(data)
 | 
	
		
			
				|  |  |    data.emrDataElement = editor.getDataElements('business')
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |    ElMessageBox.prompt('请输入保存的名称', '提示', {
 | 
	
		
			
				|  |  |      inputErrorMessage: '长度为2 - 20 个,汉字',
 | 
	
		
			
				|  |  |      inputPattern: /^\S{2,20}$/,
 | 
	
		
			
				|  |  |      inputValue: templateName
 | 
	
		
			
				|  |  | -  }).then(async ({value}) => {
 | 
	
		
			
				|  |  | +  }).then(({value}) => {
 | 
	
		
			
				|  |  |      data.name = value
 | 
	
		
			
				|  |  |      currentEmr.value.saveDocument(data).then(res => {
 | 
	
		
			
				|  |  |        // 把提取到的数据放到 patientData 中.
 | 
	
	
		
			
				|  | @@ -625,7 +635,7 @@ const updateCaseHistoryUrl = async (val) => {
 | 
	
		
			
				|  |  |    if (temp === caseHistoryUrl) return
 | 
	
		
			
				|  |  |    loaded = true
 | 
	
		
			
				|  |  |    isEditorChange = false
 | 
	
		
			
				|  |  | -  documentId = val.documentId;
 | 
	
		
			
				|  |  | +  documentId = val.documentId
 | 
	
		
			
				|  |  |    categoryCode = val.categoryCode
 | 
	
		
			
				|  |  |    templateName = val.name
 | 
	
		
			
				|  |  |    categoryId = val.categoryId
 | 
	
	
		
			
				|  | @@ -731,8 +741,9 @@ const setEditorModeFun = () => {
 | 
	
		
			
				|  |  |      currentEmr.value.callMethod('setEditorMode', 'free')
 | 
	
		
			
				|  |  |      // 如果不是首次病程记录就需要执行下面的代码
 | 
	
		
			
				|  |  |      if (!categoryCode.includes('shoucibingchengjilu')) {
 | 
	
		
			
				|  |  | +      // 如果创建人是空的就说明是第一次创建
 | 
	
		
			
				|  |  |        if (createId === null) {
 | 
	
		
			
				|  |  | -        return currentEmr.value.callMethod('setEditorMode', 'readonly');
 | 
	
		
			
				|  |  | +        return currentEmr.value.callMethod('setEditorMode', 'free');
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        // 创建人不是自己就只能看
 | 
	
		
			
				|  |  |        if (doctorLevel === 1 && createId !== userData.code) {
 | 
	
	
		
			
				|  | @@ -1114,6 +1125,29 @@ const buttonClass = (val, activation = true) => {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * 解析 iframe 上面的参数保证一致
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +const analysisIframeSrcSearch = async () => {
 | 
	
		
			
				|  |  | +  // 先一步转成 url 不然 URLSearchParams 不会解析第一个参数
 | 
	
		
			
				|  |  | +  const url = new URL('http://localhost' + caseHistoryUrl);
 | 
	
		
			
				|  |  | +  const args = new URLSearchParams(url.search);
 | 
	
		
			
				|  |  | +  documentId = args.get('documentId')
 | 
	
		
			
				|  |  | +  // 如果没有的话就去服务器要一个
 | 
	
		
			
				|  |  | +  if (documentId === null || documentId === 'null') {
 | 
	
		
			
				|  |  | +    // 这个是 唯一 id 调用服务的雪花算法
 | 
	
		
			
				|  |  | +    documentId = await getUuid()
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 恢复历史数据
 | 
	
		
			
				|  |  | +const restoreData = (data) => {
 | 
	
		
			
				|  |  | +  editor.setDocument(data)
 | 
	
		
			
				|  |  | +  xcMessage.success('恢复成功,请点击保存。')
 | 
	
		
			
				|  |  | +  recoveryDialog = false
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  onMounted(() => {
 | 
	
		
			
				|  |  |    getExtractDataElement(props.huanZheXinXi.inpatientNo, props.huanZheXinXi.admissTimes).then((res) => {
 | 
	
		
			
				|  |  |      extractData = res
 |