Browse Source

改为全局弹窗显示

Luolei 6 năm trước cách đây
mục cha
commit
3bf089d960

+ 22 - 8
src/components/Operation/index.jsx

@@ -15,7 +15,6 @@ class Operation extends Component {
     super(props)
     this.state = {
       title: '',
-      visible: false,
       okText: '',
       borderColor: '',
       okColor: '',
@@ -68,13 +67,14 @@ class Operation extends Component {
     if(flg){
       this.setState({
         type: type,
-        visible: true,
         okText: '保存',
         borderColor: '#3B9ED0',
         okColor: '#fff',
         oKBg: '#3B9ED0',
         msg: <p className={style['msg']}>是否保存该病历?</p>
       })
+      
+      this.props.diagShowTmp(true)
     }
   }
   keepHistory(){
@@ -98,13 +98,14 @@ class Operation extends Component {
     if(flg){
       this.setState({
         type: type,
-        visible: true,
         okText: '清除',
         borderColor: 'red',
         okColor: 'red',
         oKBg: '#fff',
         msg: <p className={style['msg']}>是否清空所有内容?</p>
       })
+      
+      this.props.diagShowTmp(true)
     }
   }
   isClear(){
@@ -248,10 +249,12 @@ class Operation extends Component {
     const { save, clear, saveDataAll,diagShowTmp } = this.props;
     const { type } = this.state;
     if (type == 1) {
-      this.setState({ visible: false, title: '' })
+      diagShowTmp(false)
+      this.setState({ title: '' })
       save();
     } else if (type == 2) {
-      this.setState({ visible: false, title: '' })
+      diagShowTmp(false)
+      this.setState({ title: '' })
       clear();
     } else if (type == 3) {
       if (this.state.title.trim() == '') {
@@ -262,6 +265,17 @@ class Operation extends Component {
       saveDataAll(this.state.title);
     }
   }
+  closeDiagBox(){
+    const { diagShowTmp } = this.props;
+    const { type } = this.state;
+    if (type == 3){
+      diagShowTmp(false)
+      this.setState({ title: '' })
+    }else{
+      diagShowTmp(false)
+      this.setState({ title: '' }) 
+    }
+  }
   render() {
     const { showPrint, closePrint, showPreview, closePreview } = this;
     const { visible, preVisible,diagShow } = this.props.print;
@@ -276,10 +290,10 @@ class Operation extends Component {
       <PrintPreviewContainer visible={visible} onClose={closePrint} />
       <PreviewContainer visible={preVisible} onClose={closePreview} />
       <ConfirmModal
-        visible={this.state.visible}
+        visible={diagShow}        //改为全局控制
         confirm={() => { this.makeSure() }}
-        close={() => {this.setState({ visible: false, title: '' }) }}
-        cancel={() => {this.setState({ visible: false, title: '' }) }}
+        close={() => { this.closeDiagBox()}}
+        cancel={() => {this.closeDiagBox()}}
         okText={this.state.okText}
         okBorderColor={this.state.borderColor}
         okColor={this.state.okColor}

+ 1 - 0
src/store/actions/print.js

@@ -30,6 +30,7 @@ export const saveMessage=(state,action)=>{
 
 export const diagShow=(state,action)=>{
   const res=Object.assign({},state);
+  console.log(action)
   res.diagShow = action.data
   return res;
 };

+ 1 - 1
src/store/reducers/print.js

@@ -5,7 +5,7 @@ const initState = {
   visible: false,
   preVisible: false,
   saveMessage: {},
-  diagShow:false
+  diagShow: false
 };
 export default function(state = initState, action) {
   switch (action.type) {