Browse Source

引用/回读不切换模式,清空后以设置为准

zhouna 5 years ago
parent
commit
fcd87dc30b

+ 4 - 4
src/components/Banner/ModeChange/index.jsx

@@ -11,7 +11,7 @@ class ModeChange extends Component {
     render(){
         const {closeConfigModal, changeType, confirmType, mode,hideBtn} = this.props;
         const domNode = document.getElementById('root');
-        const isOpen = mode==='1';
+        const isOpen = +mode===0;
         return ReactDom.createPortal(<React.Fragment>
             <div className={style['modal']}>
               <div className={style['shade']} onClick={closeConfigModal}></div>
@@ -20,9 +20,9 @@ class ModeChange extends Component {
                 <div className={style["oper"]}>
                     <p>
                       <span>开启模板智能推送:</span>
-                      <a className={style['switch']} href="javascript:void(0)" onClick={()=>changeType(isOpen?'0':'1')}>
-                        {hideBtn?<img src={isOpen?sclose:sopen} alt=""/>:''}
-                        {isOpen?'关':'开'}
+                      <a className={style['switch']} href="javascript:void(0)" onClick={()=>changeType(isOpen?'1':'0')}>
+                        {hideBtn?<img src={isOpen?sopen:sclose} alt=""/>:''}
+                        {isOpen?'开':'关'}
                         </a>
                     </p>
                 </div>

+ 4 - 3
src/components/CurrentIll/index.jsx

@@ -88,7 +88,7 @@ class CurrentIll extends Component{
     fetchModules&&fetchModules({id:questionId,index:focusIndex,name,span,conceptId});
   }
 
-  getInlineTag(){  
+  getInlineTag(){
     const {data,showArr,selecteds,saveText,insertProcess,symptomIds,allModules} = this.props;
     const boxMark = '2';
 
@@ -116,10 +116,11 @@ class CurrentIll extends Component{
   }
 
   render(){
-    const {fuzhen,isChronic,type,fetchPushInfos,handleInput,isRead,saveText,searchData,totalHide,editClear,data} = this.props;
+    const {readMode,fuzhen,isChronic,type,fetchPushInfos,handleInput,isRead,saveText,searchData,totalHide,editClear,data} = this.props;
     const {forbidInput,boxLeft,boxTop} = this.state;
     const searchFlag = searchData.length > 0 ? true : false;
-    if(+type===1){      //文本模式
+    const mode = readMode===-1?type:readMode;
+    if(+mode===1){      //文本模式
       return <Textarea  title='现病史' boxMark='2'
                         isRead={isRead}
                         value={saveText[0]}

+ 10 - 35
src/components/DiagnosticItem/index.jsx

@@ -62,42 +62,17 @@ class DiagnosticItem extends Component{
         getTips && getTips({id:item.id,type:7,name: item.name, position: 1});
     }
     addDiagodal(diagType){
-        const {item, isChronicMag,mode} = this.props;
+        const {item, isChronicMag} = this.props;
         item.type = diagType;
-        // setTimeout(()=>{
-        //     this.setState({
-        //         visible: false,
-        //     },()=>{
-                const { diagnosticList, addDiagnostic, clearInput, hideSearch } = this.props;
-                // for (let i = 0; i < diagnosticList.length; i++) {
-                //     if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
-                //         Notify.info('该诊断已存在');
-                //         return
-                //     }
-                // }
-                if(item.type == 2&&mode==0) {
-                    isChronicMag(item);
-                }
-                // 从缓存取慢病列表
-                // let chronicList = JSON.parse(storageLocal.get('chronic'));
-                // if(!chronicList){
-                //     getChronic();
-                //     chronicList = JSON.parse(storageLocal.get('chronic'));
-                // }
-                // console.log(999,chronicList)
-                // for(let i=0; i<chronicList.length; i++){
-                //     if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
-                //         //弹窗提示 “是否引用往期病例”?--往期病例接口、弹窗、引用
-                //         // 是--引用   否--走慢病流程
-                //         console.log("是慢病!")
-                //     }
-                // }
-                addDiagnostic&&addDiagnostic(item);
-                clearInput&&clearInput();
-                hideSearch&&hideSearch()
-        //     })
-        // }, 0)
-        document.getElementById("diagnosisResult").scrollIntoView(true)
+         const {  addDiagnostic, clearInput, hideSearch } = this.props;
+
+         if(item.type == 2) {
+             isChronicMag(item);
+         }
+         addDiagnostic&&addDiagnostic(item);
+         clearInput&&clearInput();
+         hideSearch&&hideSearch();
+         document.getElementById("diagnosisResult").scrollIntoView(true)
     }
     handleMouseEnterDrug() {
         this.setState({

+ 10 - 9
src/components/HistoryCaseContainer/HistoryList/index.jsx

@@ -11,7 +11,7 @@ import { dragBox } from '@utils/drag';
 import $ from 'jquery';
 import { ConfirmModal } from '@commonComp';
 import {showHistory} from "@store/actions/historyTemplates";
-import { CONFIRM_TYPE } from "@store/types/typeConfig";
+import { SET_READ_MODE } from "@store/types/typeConfig";
 import {billing} from '@store/async-actions/pushMessage';
 import {getHistempDetail} from '@store/async-actions/historyTemplates';
 
@@ -59,17 +59,18 @@ class HistoryCaseContainer extends React.Component {
       })
     }
     makeSure(){
-        const {activeHis} = this.state
-        this.setState({visible:false})
-        store.dispatch(showHistory(false))
+        const {activeHis} = this.state;
+        this.setState({visible:false});
+        store.dispatch(showHistory(false));
         //store.dispatch({type: CONFIRM_TYPE, confirmType: activeHis.sign});
-        store.dispatch(getHistempDetail(activeHis))
+        //store.dispatch({type: SET_READ_MODE, readMode: activeHis.sign});
+        store.dispatch(getHistempDetail(activeHis));
         if(didPushParamChange()){
-          store.dispatch(billing())
+          store.dispatch(billing());
         }
-        const {handleQuoteClick} = this.props
-        handleQuoteClick&&handleQuoteClick()
-        dragBox('hisWrapMove','closeHis','del')
+        const {handleQuoteClick} = this.props;
+        handleQuoteClick&&handleQuoteClick();
+        dragBox('hisWrapMove','closeHis','del');
     }
     close(){
       this.setState({

+ 3 - 3
src/components/MainSuit/index.jsx

@@ -6,7 +6,6 @@ import CommonSymptom from '@components/CommonSymptom';
 import chooseType from '@containers/eleType.js';
 import config from "@config/index";
 import {isIE,getPageCoordinate,windowEventHandler,filterDataArr,getAllDataList,getAllDataStringList,ifOtherClear} from "@utils/tools.js";
-import $ from 'jquery';
 import store from '@store';
 import {getFeature} from '@store/async-actions/fetchModules';
 
@@ -249,13 +248,14 @@ class MainSuit extends Component{
 
 
   render(){
-    const {type,CommonSymptoms,searchData,fetchPushInfos,isRead,totalHide,handleInput,fuzhen,saveText,editClear,datas,commSymHide} = this.props;
+    const {readMode,type,CommonSymptoms,searchData,fetchPushInfos,isRead,totalHide,handleInput,fuzhen,saveText,editClear,datas,commSymHide} = this.props;
     const {symptom,boxLeft,boxTop} = this.state;
     const symptomFlag = CommonSymptoms.length>0 ? true : false;
     const searchFlag = searchData.length>0 ? true : false;
     const boxTop1 = datas.length>0?boxTop:45;
     const boxLeft1 = datas.length>0?boxLeft:85;
-    if(+type===1){      //文本模式
+    const mode = readMode===-1?type:readMode;
+    if(+mode===1){      //文本模式
       return <Textarea title='主诉' boxMark='1' isRead={isRead} value={saveText[0]} handlePush={fetchPushInfos} handleInput={handleInput} />;
     }
     return  <div className={style['main-suit']}>

+ 3 - 2
src/components/OtherHistory/index.jsx

@@ -56,10 +56,11 @@ class OtherHistory extends Component{
     this.getData();
   }
   render(){
-    const {hasMain,totalHide,searchData,isRead,type,fetchPushInfos,handleInput,saveText} = this.props;
+    const {readMode,hasMain,totalHide,searchData,isRead,type,fetchPushInfos,handleInput,saveText} = this.props;
     const {boxLeft,boxTop} = this.state;
+    const mode = readMode===-1?type:readMode;
     //智能模式有数据时不切换文本,文本模式有数据时不切换智能
-    if(+type===1){      //文本模式
+    if(+mode===1){      //文本模式
       return <Textarea title='其他史' boxMark='3'
                        isRead={isRead}
                        value={saveText[0]}

+ 3 - 3
src/components/PushContainer/index.jsx

@@ -65,7 +65,7 @@ class PushContainer extends Component {
    */
   handleActiveClick(id) {
     if (id == '1') {
-      store.dispatch(initItemList("",1));
+      store.dispatch(initItemList(1));
     }
     store.dispatch(tabChange(id))
   }
@@ -206,7 +206,7 @@ class PushContainer extends Component {
   }
   handleClickGetMore(page){
     let tmpPage = ++page
-    store.dispatch(initItemList("",tmpPage,true))
+    store.dispatch(initItemList(tmpPage,true))
   }
   
   makeSure() {
@@ -229,7 +229,7 @@ class PushContainer extends Component {
       store.dispatch(changeTitleAsync(tempObj))
     } else if (this.state.type == 4) {        //模板引入
       const { items } = this.props;
-      store.dispatch(setPageView(this.state.id,items[0].type))
+      store.dispatch(setPageView(this.state.id))
       items && items.map((part) => {
         if (this.state.id == part.id) {
           let typeConfig = part.type;

+ 3 - 2
src/containers/CurrentIll.js

@@ -11,7 +11,7 @@ import {didPushParamChange} from '@utils/tools';
 import {Notify} from '@commonComp';
 
 function mapStateToProps(state) {
-  const {homePage,currentIll,mainSuit,diagnosticList} = state;
+  const {homePage,currentIll,mainSuit,diagnosticList,typeConfig} = state;
     return {
         data:currentIll.data,//主诉模板
         emptyData:currentIll.emptyData,//空模板
@@ -25,7 +25,7 @@ function mapStateToProps(state) {
         mainData:mainSuit.data,//主诉使用的模板
         symptomFeature:mainSuit.symptomFeature,//主诉分词数据
         moduleNum:mainSuit.moduleNum,//主诉使用的模板
-        type: state.typeConfig.typeConfig,
+        type: typeConfig.typeConfig,
         mainIds:mainSuit.mainIds,//主诉症状选中的id(去重用)
         mainTailIds:mainSuit.mainTailIds,//主诉症状选中的id(去重用)
         totalHide: homePage.totalHide,
@@ -38,6 +38,7 @@ function mapStateToProps(state) {
         allModules:homePage.allModules,
         // isChronic:!!diagnosticList.chronicMagItem,
         isChronic:mainSuit.chronicDesease?mainSuit.chronicDesease:diagnosticList.chronicMagItem,
+        readMode:typeConfig.readMode,       //回读回来的模式(与当前模式并存)
 
     }
 }

+ 3 - 2
src/containers/MainSuit.js

@@ -14,7 +14,7 @@ import {getInitModules} from '@store/async-actions/homePage.js';
 import {SHOW_REFER_RECORD} from '@store/types/diagnosticList';
 
 function mapStateToProps(state) {//console.log(state)
-  const {mainSuit,homePage,diagnosticList} = state;
+  const {mainSuit,homePage,diagnosticList,typeConfig} = state;
   return {
     showDrop:mainSuit.showDrop,//用于更新
     update:mainSuit.update,
@@ -23,7 +23,7 @@ function mapStateToProps(state) {//console.log(state)
     selecteds:mainSuit.selecteds,//数据源
     saveText:mainSuit.saveText,
 	  searchData:mainSuit.searchDatas,//搜索结果
-    type: state.typeConfig.typeConfig,
+    type: typeConfig.typeConfig,
     showArr:homePage.showDrop,
     totalHide:homePage.totalHide,
     focusIndex:mainSuit.focusIndex,
@@ -39,6 +39,7 @@ function mapStateToProps(state) {//console.log(state)
     chronicDesease:mainSuit.chronicDesease?mainSuit.chronicDesease:diagnosticList.chronicMagItem,
     items:state.historyTemplates.items,
     showHisBox:mainSuit.showHisBox,
+    readMode:typeConfig.readMode,       //回读回来的模式(与当前模式并存)
   }
 }
 

+ 1 - 0
src/containers/OtherHistory.js

@@ -27,6 +27,7 @@ function mapStateToProps(state){
     selecteds:otherHistory.selecteds,       //普通多选选中状态
     editClear:otherHistory.editClear,       //编辑状态
     isRead:state.homePage.isRead,
+    readMode:typeConfig.readMode,       //回读回来的模式(与当前模式并存)
   }
 }
 

+ 4 - 6
src/containers/TypeConfigContainer.js

@@ -1,7 +1,7 @@
 import React from "react";
 import { connect } from "react-redux";
 import Banner from "../components/Banner";
-import { SHOW_CONFIG_MODAL, CLOSE_CONFIG_MODAL, CHANGE_TYPE, CONFIRM_TYPE } from "../store/types/typeConfig";
+import { SHOW_CONFIG_MODAL, CLOSE_CONFIG_MODAL, CONFIRM_TYPE } from "../store/types/typeConfig";
 import {pushAllDataList} from '@utils/tools';
 import {saveMode,getOtherHisRecord} from '@store/async-actions/fetchModules';
 import config from "@config/index";
@@ -20,9 +20,10 @@ function mapStateToProps(state) {
   const main = state.mainSuit;
   const current = state.currentIll;
   const other = state.otherHistory;
+  const typeConfig = state.typeConfig;
   return {
-    typeConfig:state.typeConfig.typeConfig||config.defaultValue.mode,
-    visible:state.typeConfig.visible,
+    typeConfig:typeConfig.typeConfig||config.defaultValue.mode,
+    visible:typeConfig.visible,
     hasMain:ifHasData(main.data,main.saveText),
     hasCurrent:ifHasData(current.data,current.saveText),
     hasOther:ifHasData(other.data,other.saveText),
@@ -37,9 +38,6 @@ function mapDispatchToProps(dispatch) {
     closeConfigModal: () => {
       dispatch({type: CLOSE_CONFIG_MODAL})
     },
-    changeType: typeConfig => {
-      dispatch({type: CHANGE_TYPE, typeConfig})
-    },
     confirmType: confirmType => {
       //保存模式切换结果
       dispatch(saveMode(confirmType)).then((res)=>{

+ 1 - 1
src/store/actions/currentIll.js

@@ -38,7 +38,7 @@ export const setModule = (state,action)=>{
     if(v.flag && v.flag==2){
       sliceIdx = i;
     }
-  })
+  });
   res.addModule = data&&data.slice(0,sliceIdx+1);//截取到flag=2 有无治疗
   res.update=Math.random();
   return res;

+ 6 - 0
src/store/actions/typeConfig.js

@@ -14,4 +14,10 @@ export const confirmType=(state,action)=>{
   const res=Object.assign({},state);
   res.typeConfig = action.confirmType;
   return res;
+};
+
+export const setReadMode=(state,action)=>{
+  const res=Object.assign({},state);
+  res.readMode = action.readMode;
+  return res;
 };

+ 4 - 0
src/store/async-actions/diagnosticList.js

@@ -1,6 +1,7 @@
 import { SET_DIAG_TO_MAINSUIT, SET_CHRONIC_MAG_ITEM, SHOW_REFER_RECORD,SHOW_LOADING } from '@store/types/diagnosticList';
 import {getAllDataList,getAllDataStringList,isAllClear,filterDataArr} from '@utils/tools';
 import {getChronic,getInitModules} from '@store/async-actions/homePage.js';
+import { SET_READ_MODE } from "@store/types/typeConfig";
 import {storageLocal} from '@utils/tools'
 import { SAVE_FREE } from '@store/types/mainSuit';
 import {ISREAD,MODI_LOADING} from "../types/homePage";
@@ -47,6 +48,7 @@ export const isChronicMag = (item) => {
                         if(chronicList[i].conceptId==item.conceptId&&chronicList[i].name==item.name){
                             //弹窗提示 “是否引用往期病例”?--往期病例接口、弹窗、引用
                             // 是--引用   否--走慢病流程
+                            dispatch({type: SET_READ_MODE, readMode: '0'});     //慢病流程设为结构化
                             dispatch({
                                 type: SET_CHRONIC_MAG_ITEM,
                                 chronicMagItem: item
@@ -70,6 +72,8 @@ export const isChronicMag = (item) => {
                     if(chronicList[i].conceptId==item.conceptId&&chronicList[i].name==item.name){
                         //弹窗提示 “是否引用往期病例”?--往期病例接口、弹窗、引用
                         // 是--引用   否--走慢病流程
+
+                        dispatch({type: SET_READ_MODE, readMode: '0'});
                         dispatch({
                             type: SET_CHRONIC_MAG_ITEM,
                             chronicMagItem: item

+ 1 - 12
src/store/async-actions/patInfo.js

@@ -67,18 +67,7 @@ export const initHistoryDetails = (dispatch) => {
                 dispatch({
                   type:ISREAD
                 });
-                // 设置初始模式
-                if(detail.sign == 1 || detail.sign == 0){
-                    dispatch({
-                        type: CONFIRM_TYPE,
-                        confirmType: detail.sign
-                    })
-                    if(baseList.tabTemplate.items.length == 0){
-                      dispatch(initItemList("",1));        //模板列表没有就获取模板列表用于保存时做数据对比是否保存过
-                    }
-                }else{
-                  dispatch(initItemList(baseList.typeConfig.typeConfig,1))
-                }
+                dispatch(initItemList(1));        //模板列表没有就获取模板列表用于保存时做数据对比是否保存过
                 dispatch({type:MODI_LOADING,flag:false});
             } else {
                 dispatch({type:MODI_LOADING,flag:false});

+ 4 - 5
src/store/async-actions/tabTemplate.js

@@ -16,9 +16,8 @@ import {
   pushAllDataList
 } from '@utils/tools';
 
-export const initItemList = (type,current,flg) => { //初始化数据
+export const initItemList = (current,flg) => { //初始化数据
   let baseList = store.getState();
-  let whichSign = baseList.typeConfig.typeConfig;
   let state = baseList.patInfo.message;
 
   return (dispatch) => {
@@ -26,7 +25,6 @@ export const initItemList = (type,current,flg) => { //初始化数据
       "doctorId": state.doctorId,
       "hospitalDeptId": state.hospitalDeptId,
       "hospitalId": state.hospitalId,
-      "type": type || whichSign,
       "current": current,
       "sex":[1,2,3],
       "size": 9999
@@ -160,14 +158,15 @@ export const changeTitleAsync = (obj) => { //改标题
   }
 };
 
-export const setPageView = (id,typeConfig) => { //批量删除
+export const setPageView = (id) => { //获取模板结构化数据
   return (dispatch) => {
     axios.json('/templateInfo/getTemplateIdAlls', {
       id: id
     }).then((res) => {
       let data = res.data;
       if (data.code == 0) {
-        pushAllDataList(typeConfig, 'push', data.data, 'template')//引用
+        //模板列表不筛选模式后,单个模式引用时看本身的模式
+        pushAllDataList(data.data.type, 'push', data.data, 'template')//引用
       } else {
         Notify.error(data.msg);
       }

+ 5 - 2
src/store/reducers/typeConfig.js

@@ -1,10 +1,11 @@
-import { SHOW_CONFIG_MODAL, CLOSE_CONFIG_MODAL, CONFIRM_TYPE } from "../types/typeConfig";
-import { showConfigModal, closeConfigModal, changeType, confirmType } from "../actions/typeConfig";
+import { SHOW_CONFIG_MODAL, CLOSE_CONFIG_MODAL, CONFIRM_TYPE, SET_READ_MODE} from "../types/typeConfig";
+import { showConfigModal, closeConfigModal, confirmType, setReadMode} from "../actions/typeConfig";
 import config from '@config/index';
 
 const initState = {
   visible: false,
   typeConfig: config.defaultValue.mode, // 0:智能推送模式, 1:纯文本模式,用于切换选中状态
+  readMode:-1,  //回读回来的模式,-1即没有回读模式
 };
 export default function(state = initState, action) {
   switch (action.type) {
@@ -14,6 +15,8 @@ export default function(state = initState, action) {
       return closeConfigModal(state, action);
     case CONFIRM_TYPE:
       return confirmType(state, action);
+    case SET_READ_MODE:
+      return setReadMode(state, action);
     default:
       return state;
   }

+ 2 - 2
src/store/types/typeConfig.js

@@ -1,4 +1,4 @@
 export const SHOW_CONFIG_MODAL = 'SHOW_CONFIG_MODAL';
 export const CLOSE_CONFIG_MODAL = 'CLOSE_CONFIG_MODAL';
-export const CHANGE_TYPE = 'CHANGE_TYPE';
-export const CONFIRM_TYPE = 'CONFIRM_TYPE';
+export const CONFIRM_TYPE = 'CONFIRM_TYPE';
+export const SET_READ_MODE = 'SET_READ_MODE';

+ 5 - 1
src/utils/tools.js

@@ -11,7 +11,8 @@ import {ISREAD, SETREADDITEMS} from "../store/types/homePage";
 import {CLEAR_FIRST_MAIN_DIAG, CLEAR_ALL_TREAT} from "../store/types/treat";
 import {tabChange} from '@store/actions/tabTemplate';
 import {CLEAR_ASSESS_RESULT_VALUE} from '@types/assessResult';
-import config from '@config/index.js';
+import { SET_READ_MODE } from "@store/types/typeConfig";
+import config from '@config/index';
 import up from '@images/up.png';
 import down from '@images/down.png';
 
@@ -235,6 +236,7 @@ const getAllDataStringList =(baseList) =>{           //获取所有模块文本
 const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清空所有的数据
     if(action == 'clear'){     //清空
       const block = Object.assign(JSON.parse(config.textLabel),{full:true});//空白时保留一个自由文本标签
+      store.dispatch({type: SET_READ_MODE, readMode: -1});      //清除回读模式值
       store.dispatch({type: CLEAR_MAIN_SUIT,data:[],saveText:[],selecteds:[],editClear:true,mainIds:[],mainTailIds:[],clearAction:true,symptomFeature:[],chronicDesease:null,mainReadSonM:[]});
         store.dispatch({type: CLEAR_CURRENT_ILL,data:[],saveText:[],selecteds:[],editClear:true,symptomIds:[],currReadSonM:[]});
         store.dispatch({type: CLEAROTHERHISTORY,data:[block],isEmpty:true,saveText:[],selecteds:[],editClear:true,yjs_1:'',yjs_2:'',yjs_3:'',yjs_4:''});
@@ -283,6 +285,8 @@ const pushAllDataList =(whichSign,action,reData,type) =>{           //回读清
         storageLocal.remove('emrParam');
        // Notify.success('页面已清空')
     }else{
+        //回读/引用设置回读模式值(主诉-其他史使用)
+        store.dispatch({type: SET_READ_MODE, readMode: whichSign});
         if (whichSign == 0) {
           let dataJson = JSON.parse(reData.dataJson);
           //其他史data