浏览代码

模板名称重复弹窗不关闭

Luolei 6 年之前
父节点
当前提交
892cb82886

+ 26 - 13
src/components/Operation/index.jsx

@@ -6,7 +6,6 @@ import saveHistory from '@common/images/saveHistory.png';
 import PrintPreviewContainer from '@containers/PrintPreviewContainer';
 import PreviewContainer from '@containers/PreviewContainer';
 import { ConfirmModal, Notify } from '@commonComp';
-import { changeVisible } from '@store/actions/tabTemplate';
 import {getAllDataList,getAllDataStringList} from '@utils/tools';
 import { initItemList } from '@store/async-actions/tabTemplate';
 import store from '@store';
@@ -144,21 +143,22 @@ class Operation extends Component {
       title: val
     })
   }
-  keypress(e) {
+  keypress(event) {
+    let e = event?event:window.event;
     if (e.keyCode == 13) {
-      this.makeSure()
-      store.dispatch(changeVisible(false))
+      // this.makeSure()
+      // store.dispatch(changeVisible(false))
     }
   }
   saveHis(type) {
+    const { diagShowTmp } = this.props;
     let baseList = store.getState();
+    let flg = this.getAllData();
     if(baseList.tabTemplate.items.length == 0){
       store.dispatch(initItemList());         //获取模板列表
     }
-    let flg = this.getAllData();
     if(flg){
       this.setState({
-        visible: true,
         title: '',
         type: type,
         okText: '保存',
@@ -167,6 +167,7 @@ class Operation extends Component {
         oKBg: '#3B9ED0',
         msg: this.changeTitle()
       })
+      diagShowTmp(true)
     }
   }
   getAllData(){
@@ -185,7 +186,7 @@ class Operation extends Component {
       }
       if (
         JSON.stringify(jsonData.advice) == '{}' &&
-        jsonData.chief.length < 1 &&
+        (jsonData.chief.length < 1 && jsonStr.chief == '[]') &&
         jsonData.diag.length < 1 &&
         jsonData.vital.length < 1 &&
         jsonData.other.length < 1 &&
@@ -249,7 +250,7 @@ class Operation extends Component {
     </div>
   }
   makeSure() {
-    const { save, clear, saveDataAll } = this.props;
+    const { save, clear, saveDataAll,diagShowTmp } = this.props;
     const { type } = this.state;
     if (type == 1) {
       this.setState({ visible: false, title: '' })
@@ -262,15 +263,15 @@ class Operation extends Component {
         Notify.error('请输入模板名称')
         return;
       }
+      // diagShowTmp(false)
       saveDataAll(this.state.title);
-      this.setState({ visible: false, title: '' });
     }
   }
   render() {
     const { showPrint, closePrint, showPreview, closePreview } = this;
-    const { visible, preVisible } = this.props.print;
+    const { visible, preVisible,diagShow } = this.props.print;
+    const { diagShowTmp } = this.props;
     const {zIndex} = this.state;
-
     return <div className={style['container']} style={{zIndex:zIndex}}>
       <button className={style['button']} onClick={showPrint}><img src={printImg} /> 打印病历</button>
       <button className={style['preButton']} onClick={showPreview}><img src={preview} /> 预览</button>
@@ -282,8 +283,20 @@ class Operation extends Component {
       <ConfirmModal
         visible={this.state.visible}
         confirm={() => { this.makeSure() }}
-        close={() => { this.setState({ visible: false, title: '' }) }}
-        cancel={() => { this.setState({ visible: false, title: '' }) }}
+        close={() => {this.setState({ visible: false, title: '' }) }}
+        cancel={() => {this.setState({ visible: false, title: '' }) }}
+        okText={this.state.okText}
+        okBorderColor={this.state.borderColor}
+        okColor={this.state.okColor}
+        oKBg={this.state.oKBg}
+      >
+        {this.state.msg}
+      </ConfirmModal>
+      <ConfirmModal
+        visible={diagShow}
+        confirm={() => { this.makeSure() }}
+        close={() => { diagShowTmp(false); this.setState({ title: '' }) }}
+        cancel={() => { diagShowTmp(false); this.setState({ title: '' }) }}
         okText={this.state.okText}
         okBorderColor={this.state.borderColor}
         okColor={this.state.okColor}

+ 5 - 4
src/components/PushContainer/index.jsx

@@ -110,10 +110,11 @@ class PushContainer extends Component {
             })
         })
     }
-    keypress(e){
+    keypress(event){
+        let e = event?event:window.event;
         if(e.keyCode == 13) {
-            this.makeSure()
-            store.dispatch(changeVisible(false))
+            // this.makeSure()
+            // store.dispatch(changeVisible(false))
         }
     }
     changeTitle(){
@@ -192,7 +193,7 @@ class PushContainer extends Component {
         }else if(this.state.type == 3){
             if(this.state.title == this.state.obj.text){
                 store.dispatch(changeVisible(false))
-                Notify.info('标题修改成功');
+                Notify.success('标题修改成功');
                 return;
             }
             let tempObj = {

+ 10 - 5
src/containers/OperationContainer.js

@@ -5,15 +5,14 @@ import {
     SHOW_PRINT_PREVIEW,
     CLOSE_PRINT_PREVIEW,
     SHOW_PREVIEW,
-    CLOSE_PREVIEW
+    CLOSE_PREVIEW,
+    DIAG_SHOW
 } from "../store/types/print";
 import {saveMessage,clearMessages} from "../store/async-actions/print";
 import {saveTemplateDetail} from '@store/async-actions/tabTemplate';
 import {saveClickNum} from '@store/async-actions/homePage';
 
-function mapStateToProps({
-    print
-}) {
+function mapStateToProps({print}) {
     return ({
         print
     });
@@ -49,8 +48,14 @@ function mapDispatchToProps(dispatch) {
             clearMessages()
         },
         saveDataAll(val){
-            dispatch(saveTemplateDetail(val))
+          dispatch(saveTemplateDetail(val))
         },
+        diagShowTmp(bool){
+          dispatch({
+            type: DIAG_SHOW,
+            data:bool
+          });
+        }
     };
 }
 

+ 1 - 1
src/containers/OtherHistory.js

@@ -9,7 +9,7 @@ import {fullfillText} from '@common/js/func';
 import {didPushParamChange} from '@utils/tools.js';
 import {ISREAD} from "../store/types/homePage";
 
-function mapStateToProps(state){ console.log(state)
+function mapStateToProps(state){
   const {otherHistory,homePage,typeConfig,mainSuit} = state;
   const hasMain = mainSuit.saveText.join('')||mainSuit.data.length;
   return {

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

@@ -27,3 +27,9 @@ export const saveMessage=(state,action)=>{
   res.saveMessage = action.data
   return res;
 };
+
+export const diagShow=(state,action)=>{
+  const res=Object.assign({},state);
+  res.diagShow = action.data
+  return res;
+};

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

@@ -9,7 +9,7 @@ import {
     CHANGE_VISIBLE,
     SHOW_MESSAGE,
     KEEP_PUSH_DATA,
-    ALL_CHECKED_SHOW
+    ALL_CHECKED_SHOW,
 } from '@store/types/tabTemplate';
 
 export const delItems = (id) => ({ //删除模板

+ 18 - 2
src/store/async-actions/tabTemplate.js

@@ -4,8 +4,9 @@ import {
   delItems,
   batchDelItems,
   changeTitle,
-  keepPushData
+  keepPushData,
 } from '@store/actions/tabTemplate';
+import {DIAG_SHOW} from "@store/types/print";
 import Notify from '@commonComp/Notify';
 import store from '@store';
 import {
@@ -34,7 +35,7 @@ export const initItemList = (type) => { //初始化数据
   }
 };
 
-export const saveTemplateDetail = (val) => { //保存为模板(先判断是否引入模板,是的话需要判断是否改变了值)
+export const saveTemplateDetail = (val) => { //保存为模板
   let baseList = store.getState();
   let jsonData = getAllDataList(baseList);
   let jsonStr = getAllDataStringList(baseList);
@@ -69,7 +70,22 @@ export const saveTemplateDetail = (val) => { //保存为模板(先判断是否
         Notify.success('模板保存成功');
         dispatch(initItemList());
         dispatch(keepPushData(getdata(1),'part'));
+        dispatch({
+          type: DIAG_SHOW,
+          data:false
+        });
       } else {
+        if(data.msg == '该模板名存在'){         //存在不关闭弹窗
+          dispatch({
+            type: DIAG_SHOW,
+            data:true
+          });
+        }else{
+          dispatch({
+            type: DIAG_SHOW,
+            data:false
+          });
+        }
         Notify.error(data.msg);
       }
     })

+ 6 - 3
src/store/reducers/print.js

@@ -1,10 +1,11 @@
-import { SHOW_PRINT_PREVIEW, CLOSE_PRINT_PREVIEW, SAVE_MESSAGE, CLOSE_PREVIEW, SHOW_PREVIEW,CLEAR_MESSAGE } from "../types/print";
-import { showPrintPreview, closePrintPreview, saveMessage, showPreview, closePreview } from "../actions/print";
+import { SHOW_PRINT_PREVIEW, CLOSE_PRINT_PREVIEW, SAVE_MESSAGE, CLOSE_PREVIEW, SHOW_PREVIEW,CLEAR_MESSAGE,DIAG_SHOW } from "../types/print";
+import { showPrintPreview, closePrintPreview, saveMessage, showPreview, closePreview,diagShow } from "../actions/print";
 
 const initState = {
   visible: false,
   preVisible: false,
-  saveMessage: {}
+  saveMessage: {},
+  diagShow:false
 };
 export default function(state = initState, action) {
   switch (action.type) {
@@ -20,6 +21,8 @@ export default function(state = initState, action) {
       return saveMessage(state, action);
     case CLEAR_MESSAGE:
       return clearMessage(state, action);
+    case DIAG_SHOW:
+      return diagShow(state, action);
     default:
       return state;
   }

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

@@ -9,7 +9,7 @@ import {
   CHANGE_VISIBLE,
   SHOW_MESSAGE,
   KEEP_PUSH_DATA,
-  ALL_CHECKED_SHOW
+  ALL_CHECKED_SHOW,
 } from '../types/tabTemplate';
 
 

+ 2 - 1
src/store/types/print.js

@@ -3,4 +3,5 @@ export const CLOSE_PRINT_PREVIEW = 'CLOSE_PRINT_PREVIEW'
 export const SAVE_MESSAGE = 'SAVE_MESSAGE'
 export const CLEAR_MESSAGE = 'CLEAR_MESSAGE'
 export const SHOW_PREVIEW = 'SHOW_PREVIEW'
-export const CLOSE_PREVIEW = 'CLOSE_PREVIEW'
+export const CLOSE_PREVIEW = 'CLOSE_PREVIEW'
+export const DIAG_SHOW = 'DIAG_SHOW'