morphone1995 пре 4 година
родитељ
комит
3447c278ec

+ 103 - 39
src/components/Operation/index.jsx

@@ -43,6 +43,8 @@ class Operation extends Component {
       folderId:'',//选中文件夹名称
       folderListShow:false, //文件夹列表展示
       medicalName: '', //保存病历名称
+      showValit: false, // 显示校验的文字
+      saveVisible: false //保存病历模态框
     }
     this.showPrint = this.showPrint.bind(this);
     this.closePrint = this.closePrint.bind(this);
@@ -63,9 +65,44 @@ class Operation extends Component {
     this.spellFst = this.spellFst.bind(this);
     this.hideFolderList = this.hideFolderList.bind(this)
     this.handleMedicalChange = this.handleMedicalChange.bind(this)
+
+
+    this.makeSureSave = this.makeSureSave.bind(this);
+    this.closeSave = this.closeSave.bind(this);
     this.$inp = React.createRef()
   }
 
+  // 保存病历  _lcq
+  makeSureSave(){
+    if (this.state.medicalName.trim() === '') {
+      // Notify.info('请输入病历名称')
+      this.setState({
+        showValit: true
+      })
+      return
+    }
+    // // 清除store中 medicalName的值
+    // const { clearmedicalName } = this.props
+    // clearmedicalName && clearmedicalName()
+    // diagShowTmp(false)
+    // this.setState({ title: '' })
+    this.setState({
+      medicalName: '',
+      saveVisible: false,
+    })
+    this.props.save();
+  }
+
+  // 取消编辑病历
+  closeSave() {
+    this.setState({
+      saveVisible: false,
+      showValit:false,
+      medicalName: ''
+      // templateName: ''
+    })
+  }
+
   showPrint() {
     this.setState({
       zIndex:240
@@ -127,36 +164,27 @@ class Operation extends Component {
       Notify.info('门诊号不能为空');
       return;
     }   
-    // }else if(keepState == 2){
-    //     Notify.info('诊断不能为空');
-    //     return;
-    // }else{
-    //   this.setState({
-    //     type: type,
-    //     okText: '保存',
-    //     borderColor: '#3B9ED0',
-    //     okColor: '#fff',
-    //     oKBg: '#3B9ED0',
-    //     msg: <p className={style['msg']}>是否保存该病历?</p>
-    //   })
-    //   this.props.diagShowTmp(true)
-    // }
-    // 清除store中 medicalName的值
-    const { clearmedicalName} = this.props
-    clearmedicalName && clearmedicalName()
-    this.setState({            
-      type: type,
-      okText: '保存',
-      borderColor: '#3B9ED0',
-      okColor: '#fff',
-      oKBg: '#3B9ED0',
-      // msg: <p className={style['msg']}>是否保存该病历?</p>
-      msg: <div className={style.outBox}><span>病历名称:</span><input type="text" placeholder="请输入病历名称" value={this.state.medicalName} onChange={this.handleMedicalChange} autocomplete="off" /></div>
+
+    // this.setState({            
+    //   type: type,
+    //   okText: '保存',
+    //   borderColor: '#3B9ED0',
+    //   okColor: '#fff',
+    //   oKBg: '#3B9ED0',
+    //   msg: <div className={style.outBox}><div><span>病历名称:</span><input type="text" placeholder="请输入病历名称" value={this.state.medicalName} onChange={this.handleMedicalChange} autocomplete="off" /> </div></div>
+    // })
+    // this.props.diagShowTmp(true)
+    this.setState({
+      saveVisible: true
     })
-    this.props.diagShowTmp(true)
   }
 
   handleMedicalChange(e){
+    if (e.target.value.length > 0) {
+      this.setState({
+        showValit: false
+      })
+    }
     const { setmedicalName} = this.props
     this.setState({
       medicalName: e.target.value
@@ -354,18 +382,26 @@ class Operation extends Component {
     const { type,deptId,sex,title,fstName,folderId,folderNameVal } = this.state;
     // console.log(type,'======type');
     if (type == 1) {     
-      if (this.state.medicalName === '') {
-        Notify.info('请输入病历名称')
-        return 
-      }
-      diagShowTmp(false)
-      this.setState({ title: '' })
-      if (type == 1) {
-        this.setState({
-          medicalName: ''
-        })
-      }
-      save();
+      // if (this.state.medicalName === '') {
+      //   Notify.info('请输入病历名称')
+      //   this.setState({
+      //     showValit: true
+      //   },()=>{
+      //       // console.log(this.state.showValit,'-=-=-=-');
+      //   })
+      //   return 
+      // }
+      // // 清除store中 medicalName的值
+      // const { clearmedicalName } = this.props
+      // clearmedicalName && clearmedicalName()
+      // diagShowTmp(false)
+      // this.setState({ title: '' })
+      // if (type == 1) {
+      //   this.setState({
+      //     medicalName: ''
+      //   })
+      // }
+      // save();
     } else if (type == 2) {
       // type === 2 清除数据
       diagShowTmp(false);
@@ -507,6 +543,7 @@ class Operation extends Component {
     const {winWidth,cancelDelTag,departLis,handleChangeValue,admin,floderListAdmin,folderModalShow,
       floderModal,folderOrderShow,folderOrder,adminItems,patInfo,saveOrderFolder,hideLabel} = this.props;
     const {zIndex,type,le,value,folder,folderListShow} = this.state;
+    // console.log(this.state.showValit,this.state.msg,'====================');
     return <div className={style['container']} style={{left:le}}>
       {/*<span className={style['button']} onClick={showPrint}><img src={printImg} /> 打印病历</span>*/}
       {/* <span className={style['preButton']} onClick={showPreview}><img src={preview} /> 预览</span> */}
@@ -516,6 +553,28 @@ class Operation extends Component {
       <span className={winWidth<=1082?`${style['clearButton']} ${style['saveButton']} ${style['minstyle']}`:`${style['clearButton']} ${style['saveButton']}`} onClick={() => { this.clearAll(2) }}>清除</span>
       {visible?<PrintPreviewContainer visible={visible} onClose={closePrint} />:null}
       {preVisible?<PreviewContainer visible={preVisible} onClose={closePreview} />:null}
+      
+      {<ConfirmModal
+        visible={this.state.saveVisible}
+        confirm={this.makeSureSave}
+        close={this.closeSave}
+        cancel={this.closeSave}
+        okText={"保存"}
+        okBorderColor={'#3B9ED0'}
+        okColor={'#fff'}
+        oKBg={'#3B9ED0'}
+        title={'保存病历'}
+        height={200}
+      >
+        <div className={style.outBox}>
+          <div className={style.innerInp}>
+            <span>病历名称:</span>
+            <input type="text" placeholder="请输入病历名称" value={this.state.medicalName} onChange={this.handleMedicalChange} autocomplete="off" /> 
+          </div>
+          {this.state.showValit ? (<div className={style.valit}>请输入病历名称</div>) : null}
+        </div>
+      </ConfirmModal>}
+
       {<ConfirmModal
         visible={diagShow}        //改为全局控制
         confirm={() => { this.makeSure() }}
@@ -581,7 +640,12 @@ class Operation extends Component {
           </div>
           </div>:null
         }
-      </ConfirmModal>}
+      </ConfirmModal>
+      }
+      {/* 保存病历 */}
+
+
+
       <FolderName 
         folderModalShow={folderModalShow}
         floderModal={floderModal}

+ 19 - 4
src/components/Operation/index.less

@@ -338,10 +338,25 @@
     cursor: pointer;
   }
 
-  .outBox{
+.outBox{
     padding-left: 18px;
-    height: 100px;
+    height: 60px;
     width: 100%;
-    display: flex;
-    align-items: center;
+    position: relative;
+    top: 41px;
+    // display: flex;
+    // flex-direction: column;
+    // justify-content: center;
+    margin-bottom: 40px;
+    .innerInp{
+    }
+    .valit{
+        float: left;
+        margin-top: 8px;
+        color: #D9001B;
+        position: relative;
+        top: 0;
+        left: 70px;
+        height: 20px;
+    }
 }

+ 1 - 0
src/containers/OperationContainer.js

@@ -98,6 +98,7 @@ function mapDispatchToProps(dispatch) {
     save: () => {
       // 埋点事件,点击保存时调用
       // dispatch(saveClickNum);
+
       dispatch(() => saveMessage())
     },
     clear: (flag) => {

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

@@ -68,7 +68,7 @@ export const setMedicalName = (state, action) => {
 // clearMedicalName
 export const clearMedicalName = (state, action) => {
   const res = Object.assign({}, state);
-  // res.medicalName = ''
+  res.medicalName = ''
   return res
 }
 

+ 4 - 1
src/store/async-actions/print.js

@@ -3,6 +3,7 @@ import {
 } from "../../utils/ajax";
 import store from '@store';
 import {MODI_LOADING} from '@store/types/homePage.js';
+import { CLEARMEDICALNAME } from '@store/types/patInfo.js';
 import Notify from '@commonComp/Notify';
 import {tellPred} from '@store/async-actions/preIcss.js';
 import {
@@ -48,6 +49,7 @@ export const getConceptDetails = (bool) => {
 }
 export const saveMessage=(bool)=>{
     store.dispatch({type:MODI_LOADING,flag:true});
+    // store.dispatch({ type: CLEARMEDICALNAME});
     // getConceptDetails(bool)  //保存病历 老版本
     saveMedicalData()
 }
@@ -160,7 +162,8 @@ export const saveMedicalData = () =>{
     }
     json('/demo/templateInfo/saveTemplateInfo', params).then(res=>{
         let data = res.data
-        if (data.code == 0) {            
+        if (data.code == 0) {       
+            store.dispatch({ type: CLEARMEDICALNAME });     // 清除病历名称 
             Notify.success('病历保存成功');
         } else {
             Notify.info(data.msg);