Ver código fonte

模板搜索

zhangxc 5 anos atrás
pai
commit
5a1ef7fb1c

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

@@ -1,7 +1,7 @@
 import React, { Component } from 'react';
 import style from './index.less';
 import { Tab, ConfirmModal, Notify } from '@commonComp';
-import { tabChange, allChecked, changeVisible, keepPushData, allCheckedShow,allCheckedAdmin,allCheckedShowAdmin,whichTemp,floderSlide,floderAction,folderModal } from '@store/actions/tabTemplate';
+import { tabChange, allChecked, changeVisible, keepPushData, allCheckedShow,allCheckedAdmin,allCheckedShowAdmin,whichTemp,floderSlide,floderAction,folderModal,clearSearchTemplateNorms } from '@store/actions/tabTemplate';
 import { initItemList,initAdminItemList, delItem,delItemAdmin, delBatchItem, delBatchItemAdmin,changeTitleAsync, setPageView,changeTitleAsyncAdmin,setPageViewAdmin,getFloderList,delFloder } from '@store/async-actions/tabTemplate';
 import { connect } from "react-redux";
 import store from '@store';
@@ -69,6 +69,7 @@ class PushContainer extends Component {
     this.makeSure = this.makeSure.bind(this)
     this.handleClose = this.handleClose.bind(this);
     this.templateSearch = this.templateSearch.bind(this);
+    this.clearTemplateSearch = this.clearTemplateSearch.bind(this)
     this.whichTemp = this.whichTemp.bind(this);
     this.floderSlideToggle = this.floderSlideToggle.bind(this);
     this.floderRename = this.floderRename.bind(this);
@@ -80,8 +81,12 @@ class PushContainer extends Component {
     // const height = getWindowInnerHeight()-160;
     // this.$cont.current.style.height = height+"px";
   }
-  templateSearch(name){
-    store.dispatch(initItemList(1,name));
+
+  templateSearch(name,selectTemp){
+    store.dispatch(initItemList(1,name,selectTemp));
+  }
+  clearTemplateSearch(){
+    store.dispatch(clearSearchTemplateNorms());
   }
   /**
    * 
@@ -436,7 +441,7 @@ class PushContainer extends Component {
     store.dispatch(folderModal(flg))
   }
   render() {
-    const { activeId, checkItems,selectTemp,folderListContentArr, visible, showMsg,hasMore,current,floderListAdmin, items, allCheckShow,allCheckShowAdmin,adminItems,admin,checkItemsAdmin,clearSearch } = this.props;
+    const { activeId, checkItems,selectTemp,folderListContentArr, visible, showMsg,hasMore,current,floderListAdmin, items, allCheckShow,allCheckShowAdmin,adminItems,admin,checkItemsAdmin,clearSearch, templateNormsSearchList} = this.props;
     const { type,okBorderColor,okColor,oKBg,okText,message,folderListShow } = this.state
     return <div className={style["container"]} ref={this.$cont} >
       <Tab tabs={this.state.tabs}
@@ -474,6 +479,8 @@ class PushContainer extends Component {
             floderDelete={this.floderDelete}
             floderRename={this.floderRename}
             folderListContentArr={folderListContentArr}
+            templateNormsSearchList={templateNormsSearchList}
+            clearTemplateSearch={this.clearTemplateSearch}
           ></TemplateItems>
           <MedicalInfoContainer></MedicalInfoContainer>
         </TemplateContainer>
@@ -551,7 +558,7 @@ const mapStateToProps = (state) => {//console.log(state)
     selectTemp:state.tabTemplate.selectTemp,
     floderListAdmin:state.tabTemplate.floderListAdmin,
     folderListContentArr:state.tabTemplate.folderListContentArr,
-    
+    templateNormsSearchList: state.tabTemplate.templateNormsSearchList
   }
 }
 

+ 26 - 7
src/components/TemplateItems/index.jsx

@@ -22,7 +22,8 @@ class TemplateItems extends React.Component {
             msg:'还没有保存模板',
             val:'',
             height:'',
-            showTipContent:false
+            showTipContent:false,
+            hasSearch: false
         }
         this.$cont = React.createRef();
         this.$conts = React.createRef();
@@ -187,8 +188,16 @@ class TemplateItems extends React.Component {
         }
     }
     templateSearch(){
-        const {templateSearch} = this.props
-        templateSearch((this.$search.current.value).trim())
+        const {templateSearch,selectTemp,admin} = this.props
+        if(!(this.$search.current.value).trim()) {
+            return
+        }
+        if(admin) {
+            templateSearch((this.$search.current.value).trim(),2)
+        } else {
+            templateSearch((this.$search.current.value).trim(),selectTemp)
+
+        }
         if(this.$search.current.value.trim()){
             this.setState({
                 msg:'暂无模板信息'
@@ -198,6 +207,10 @@ class TemplateItems extends React.Component {
                 msg:'还没有保存模板'
             })
         }
+        if(admin||selectTemp ===2)
+        this.setState({
+            hasSearch: true
+        })
     }
     
     handleEnter(e){
@@ -217,12 +230,17 @@ class TemplateItems extends React.Component {
     }
 
     clear(){
+        const {clearTemplateSearch} = this.props
         this.$search.current.value = '';
         this.setState({
             val:''
         });
         this.$search.current.focus();
         this.templateSearch();
+        this.setState({
+            hasSearch: false
+        })
+        clearTemplateSearch&&clearTemplateSearch()
     }
     clickTabChange(){
 
@@ -234,8 +252,9 @@ class TemplateItems extends React.Component {
       }
     }
     render() {
-        const {selectTemp,whichTemp, checkItemsAdmin,handleAllCheckboxAdmin,handleMangerTemplateAdmin,allCheckShowAdmin,admin,adminItems,allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore } = this.props;
-        const {height,showTipContent} = this.state
+        const {selectTemp,whichTemp, checkItemsAdmin,handleAllCheckboxAdmin,handleMangerTemplateAdmin,allCheckShowAdmin,admin,adminItems,allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore,templateNormsSearchList } = this.props;
+
+        const {height,showTipContent,hasSearch} = this.state
         return (
             <div className={style.wrapper} >
                 {//管理员操作      
@@ -321,7 +340,7 @@ class TemplateItems extends React.Component {
                             {
                                 <div style={{height:height-54+'px',overflow:'auto'}}>
                                     {
-                                        selectTemp==1&&this.genItems(items).length > 0?this.genItems(items):selectTemp==2&&this.genAdminItems(adminItems,true).length > 0?this.genAdminItems(adminItems,true): <Empty message={this.state.msg}></Empty>
+                                        selectTemp==1&&this.genItems(items).length > 0?this.genItems(items):selectTemp==2&&this.genAdminItems(adminItems,true).length > 0?hasSearch ? this.genItems(templateNormsSearchList,true):this.genAdminItems(adminItems,true): <Empty message={this.state.msg}></Empty>
                                     }
                                 </div>
                             }
@@ -329,7 +348,7 @@ class TemplateItems extends React.Component {
                         {
                             admin&&<div className={style.tempLists} ref={this.$conts} style={{border:admin?'0':'1px solid #EAEDF1'}}>
                                 <div style={{height:height+'px',overflow:'auto'}}>
-                                    {this.genAdminItems(adminItems,true).length > 0?this.genAdminItems(adminItems,true): <Empty message={this.state.msg}></Empty>}
+                                    {this.genAdminItems(adminItems,true).length > 0?hasSearch ?this.genItems(templateNormsSearchList):this.genAdminItems(adminItems,true): <Empty message={this.state.msg}></Empty>}
                                 </div>
                             </div>
                         }

+ 10 - 2
src/store/actions/tabTemplate.js

@@ -23,9 +23,17 @@ import {
     FLODER_ACTION,
     FOLDER_LIST_ADMIN,
     FOLDER_MODAL,
-    FOLDER_ORDER_SHOW
+    FOLDER_ORDER_SHOW,
+    NORMS_TEMPLATE_SEARCH,
+    CLEAR_NORMS_TEMPLATE_SEARCH
 } from '@store/types/tabTemplate';
-
+export const clearSearchTemplateNorms = () => ({ //清除模板文件夹搜索
+    type: CLEAR_NORMS_TEMPLATE_SEARCH
+});
+export const setSearchTemplateNorms = (templateNormsSearchList) => ({
+    type: NORMS_TEMPLATE_SEARCH,
+    templateNormsSearchList
+});
 export const folderOrder = (show) => ({ //文件夹展开
     type: FOLDER_ORDER_SHOW,
     show

+ 33 - 16
src/store/async-actions/tabTemplate.js

@@ -12,7 +12,8 @@ import {
   batchDelItemsAdmin,
   changeTitleAdmin,
   floderListAdmin,
-  folderModal
+  folderModal,
+  setSearchTemplateNorms
 } from '@store/actions/tabTemplate';
 import {DIAG_SHOW} from "@store/types/print";
 import Notify from '@commonComp/Notify';
@@ -27,12 +28,12 @@ import {
 import { billing } from '@store/async-actions/pushMessage';
 import { func } from 'prop-types';
 
-export const initItemList = (current,name) => {
+export const initItemList = (current,name,selectTemp) => {
   let admin = store.getState().homePage.admin;
-  if(admin){
-    return initAdminItemList(current,name)
+  if(admin || selectTemp==2){
+    return initAdminItemList(current,name,selectTemp)
   }else{
-    return initCommonItemList(current,name)
+    return initCommonItemList(current,name,selectTemp)
   }
 }
 
@@ -61,22 +62,16 @@ export const initCommonItemList = (current,name) => { //初始化数据
     })
   }
 };
-export const initAdminItemList = (current,name) => { //初始化数据
+export const initAdminItemList = (current,name,selectTemp) => { //初始化数据
   let baseList = store.getState();
   // let searchVal = document.getElementById("searchTmp").value
   let state = baseList.patInfo.message;
   return (dispatch) => {
-    // axios.json('/templateAdmin/getTemplatePageAlls', {
+    if(selectTemp == 2) {
+      dispatch(findTemplateNorms(name))
+    }else {
       dispatch(getFloderListAll())
-    // axios.json('/templateAdmin/getTemplateNorms').then((res) => {
-    //   const data = res.data;
-    //   if (data.code == 0) {
-    //     // data.data.flg = flg||false  //获取下一页,暂时不用
-    //     dispatch(initAdminItems(data.data));
-    //   } else {
-    //     Notify.error(data.msg)
-    //   }
-    // })
+    }
   }
 };
 
@@ -475,6 +470,28 @@ export const getDepartments = (value) => { //获取模板结构化数据
     })
   }
 };
+export const findTemplateNorms = (name) => {
+    return (dispatch) => {
+      if(!name) {
+        dispatch(setSearchTemplateNorms([]));
+      } else {
+        axios.json('/templateInfo/findTemplateNorms',{
+          name,
+          templateType: 2
+        }).then((res) => {
+          const data = res.data;
+          if (data.code == 0) {
+            dispatch(setSearchTemplateNorms(data.data));
+          } else {
+            Notify.error(data.msg)
+          }
+        })
+      }
+      
+    }
+  
+}
+
 export const getFloderListAll = () => {
   return (dispatch) => {
     axios.json('/templateAdmin/getTemplateNorms').then((res) => {

+ 14 - 0
src/store/reducers/tabTemplate.js

@@ -24,6 +24,8 @@ import {
   FOLDER_LIST_ADMIN,
   FOLDER_MODAL,
   FOLDER_ORDER_SHOW,
+  NORMS_TEMPLATE_SEARCH,
+  CLEAR_NORMS_TEMPLATE_SEARCH
 } from '../types/tabTemplate';
 
 
@@ -53,8 +55,20 @@ const initDataList = {
   folderModalShow:false,//新建文件夹弹窗
   folderListContentArr :[],//管理员文件夹内模板合并
   folderOrderShow: false, //文件夹管理弹窗
+  templateNormsSearchList:[] //标准模板搜索
 }
 export default (state = initDataList, action) => {
+  if(action.type === CLEAR_NORMS_TEMPLATE_SEARCH) {
+    const newState = Object.assign({}, state);
+    newState.templateNormsSearchList = [];
+    return newState;
+  }
+  if(action.type === NORMS_TEMPLATE_SEARCH) {
+    const newState = Object.assign({}, state);
+    newState.templateNormsSearchList = JSON.parse(JSON.stringify(action.templateNormsSearchList));
+    return newState;
+  }
+
   if (action.type === FOLDER_ORDER_SHOW) {//文件夹管理员列表
     const newState = Object.assign({}, state);
     newState.folderOrderShow = action.show;

+ 2 - 0
src/store/types/tabTemplate.js

@@ -23,3 +23,5 @@ export const FLODER_ACTION = 'FLODER_ACTION';
 export const FOLDER_LIST_ADMIN = 'FOLDER_LIST_ADMIN';
 export const FOLDER_MODAL = 'FOLDER_MODAL';
 export const FOLDER_ORDER_SHOW = 'FOLDER_ORDER_SHOW';
+export const NORMS_TEMPLATE_SEARCH = 'NORMS_TEMPLATE_SEARCH';
+export const CLEAR_NORMS_TEMPLATE_SEARCH = 'CLEAR_NORMS_TEMPLATE_SEARCH';