Procházet zdrojové kódy

管理员模板修改删除

luolei před 5 roky
rodič
revize
012bf219b6

+ 1 - 1
src/components/Operation/index.jsx

@@ -239,7 +239,7 @@ class Operation extends Component {
     }
   }
   makeSure() {
-    const { save, clear, saveDataAll,diagShowTmp ,chronicMagItem,chronicDesease,admin} = this.props;
+    const { save, clear, saveDataAll,saveDataAlls,diagShowTmp ,chronicMagItem,chronicDesease,admin} = this.props;
     const { type,deptId,sex,title } = this.state;
     if (type == 1) {
       diagShowTmp(false)

+ 49 - 7
src/components/PushContainer/index.jsx

@@ -1,8 +1,8 @@
 import React, { Component } from 'react';
 import style from './index.less';
 import { Tab, ConfirmModal, Notify } from '@commonComp';
-import { tabChange, allChecked, changeVisible, keepPushData, allCheckedShow } from '@store/actions/tabTemplate';
-import { initItemList, delItem, delBatchItem, changeTitleAsync, setPageView } from '@store/async-actions/tabTemplate';
+import { tabChange, allChecked, changeVisible, keepPushData, allCheckedShow,allCheckedAdmin,allCheckedShowAdmin } from '@store/actions/tabTemplate';
+import { initItemList, delItem,delItemAdmin, delBatchItem, delBatchItemAdmin,changeTitleAsync, setPageView,changeTitleAsyncAdmin } from '@store/async-actions/tabTemplate';
 import { connect } from "react-redux";
 import store from '@store';
 import { billing } from '@store/async-actions/pushMessage';
@@ -51,7 +51,9 @@ class PushContainer extends Component {
     this.handleTemplateDel = this.handleTemplateDel.bind(this)
     this.handleTitleChange = this.handleTitleChange.bind(this)
     this.handleAllCheckbox = this.handleAllCheckbox.bind(this)
+    this.handleAllCheckboxAdmin = this.handleAllCheckboxAdmin.bind(this)
     this.handleMangerTemplate = this.handleMangerTemplate.bind(this)
+    this.handleMangerTemplateAdmin = this.handleMangerTemplateAdmin.bind(this)
     this.handleDelList = this.handleDelList.bind(this)
     this.makeSure = this.makeSure.bind(this)
     this.handleClose = this.handleClose.bind(this);
@@ -178,6 +180,22 @@ class PushContainer extends Component {
     })
   }
 
+  handleAllCheckboxAdmin() {        //全.反选
+    let tmpFlg = this.props.allCheckedAdmin;
+    if (this.props.checkItemsAdmin.length < this.props.adminItems.length && this.props.allCheckedAdmin) {
+      tmpFlg = false;
+    } else if (this.props.checkItemsAdmin.length == this.props.adminItems.length && !this.props.allCheckedAdmin) {
+      tmpFlg = true;
+    }  //两种特殊情况处理
+    store.dispatch(allCheckedAdmin(!tmpFlg))
+  }
+
+  handleMangerTemplateAdmin() {      //管理
+    let tmpFlg = this.props.allCheckShowAdmin;
+    store.dispatch(allCheckedAdmin(false))
+    store.dispatch(allCheckedShowAdmin(!tmpFlg))
+  }
+
   handleAllCheckbox() {        //全.反选
     let tmpFlg = this.props.allChecked;
     if (this.props.checkItems.length < this.props.items.length && this.props.allChecked) {
@@ -211,10 +229,18 @@ class PushContainer extends Component {
   
   makeSure() {
     if (this.state.type == 1) {
-      store.dispatch(delItem(this.state.id))
+      if(this.props.admin){
+        store.dispatch(delItemAdmin(this.state.id))
+      }else{
+        store.dispatch(delItem(this.state.id))
+      }
       store.dispatch(changeVisible(false))
     } else if (this.state.type == 2) {
-      store.dispatch(delBatchItem(this.props.checkItems))
+      if(this.props.admin){
+        store.dispatch(delBatchItemAdmin(this.props.checkItemsAdmin))
+      }else{
+        store.dispatch(delBatchItem(this.props.checkItems))
+      }
       store.dispatch(changeVisible(false))
     } else if (this.state.type == 3) {
       if (this.state.title == this.state.text) {
@@ -230,7 +256,11 @@ class PushContainer extends Component {
         id: this.state.currId,
         title: this.state.title
       }
-      store.dispatch(changeTitleAsync(tempObj))
+      if(this.state.admin){
+        store.dispatch(changeTitleAsyncAdmin(tempObj))
+      }else{
+        store.dispatch(changeTitleAsync(tempObj))
+      }
     } else if (this.state.type == 4) {        //模板引入
       const { items } = this.props;
       store.dispatch(setPageView(this.state.id))
@@ -251,7 +281,7 @@ class PushContainer extends Component {
     store.dispatch(changeVisible(false));
   }
   render() {
-    const { activeId, checkItems, visible, showMsg,hasMore,current, items, allCheckShow } = this.props;
+    const { activeId, checkItems, visible, showMsg,hasMore,current, items, allCheckShow,allCheckShowAdmin,adminItems,admin,checkItemsAdmin } = this.props;
     return <div className={style["container"]} ref={this.$cont} >
       <Tab tabs={this.state.tabs}
         activeId={activeId}
@@ -262,10 +292,16 @@ class PushContainer extends Component {
           <CaseQuailty></CaseQuailty>
           <TemplateItems
             items={items}
+            adminItems={adminItems}
+            admin={admin}
+            handleAllCheckboxAdmin={this.handleAllCheckboxAdmin}
+            handleMangerTemplateAdmin={this.handleMangerTemplateAdmin}
             current={current}
             hasMore={hasMore}
             checkItems={checkItems}
+            checkItemsAdmin={checkItemsAdmin}
             allCheckShow={allCheckShow}
+            allCheckShowAdmin={allCheckShowAdmin}
             handleContentClick={this.handleContentClick}
             handleTemplateDel={this.handleTemplateDel}
             handleTitleChange={this.handleTitleChange}
@@ -295,9 +331,11 @@ class PushContainer extends Component {
   }
 }
 
-const mapStateToProps = (state) => {
+const mapStateToProps = (state) => {//console.log(state)
   return {
     items: state.tabTemplate.items,
+    adminItems: state.tabTemplate.adminItems,
+    admin: state.homePage.admin,
     current: state.tabTemplate.current,
     hasMore: state.tabTemplate.hasMore,
     activeId: state.tabTemplate.activeId,
@@ -306,6 +344,10 @@ const mapStateToProps = (state) => {
     visible: state.tabTemplate.visible,
     showMsg: state.tabTemplate.showMsg,
     allCheckShow: state.tabTemplate.allCheckShow,
+
+    allCheckedAdmin: state.tabTemplate.allCheckedAdmin,
+    allCheckShowAdmin: state.tabTemplate.allCheckShowAdmin,
+    checkItemsAdmin: state.tabTemplate.checkItemsAdmin,
   }
 }
 

+ 0 - 1
src/components/PushItems/index.jsx

@@ -138,7 +138,6 @@ class PushItems extends Component {
   componentDidMount() {
     const height = getWindowInnerHeight() - 190;
     this.$cont.current.style.height = height + "px";
-
     windowEventHandler('resize', ()=>{
       if(this.$cont.current){
         const height = getWindowInnerHeight() - 190;

+ 77 - 21
src/components/TemplateItems/TemplateItem/index.jsx

@@ -11,7 +11,7 @@ import editing_icon from './img/edit_blue.png';
 import check_circle from './img/check-circle.png';
 import check_right from './img/check-right.png';
 import store from '@store'
-import { checkItems } from '@store/actions/tabTemplate';
+import { checkItems,checkItemsAdmin } from '@store/actions/tabTemplate';
 import $ from 'jquery';
 
 class TemplateItem extends React.Component {
@@ -26,6 +26,8 @@ class TemplateItem extends React.Component {
     };
     this.isConfirmClick = false;
     this.handleTitleClick = this.handleTitleClick.bind(this)
+    this.getStyleFst = this.getStyleFst.bind(this)
+    this.getStyleSec = this.getStyleSec.bind(this)
   }
 
   getArrow() {
@@ -40,15 +42,27 @@ class TemplateItem extends React.Component {
   handleCheckboxClick(e, id) {          //点击复选框
     e.stopPropagation();
     let tempCheck = this.state.checkBox;
-    this.setState({
-      checkBox: !tempCheck
-    })
-    store.dispatch(checkItems(id))
+    let sign = this.props.admin;
+    // this.setState({
+    //   checkBox: !tempCheck
+    // })
+    if(sign){
+      store.dispatch(checkItemsAdmin(id))
+    }else{
+      store.dispatch(checkItems(id))
+    }
   }
 
   getCheckIcon() {
-    let tempCheckItems = this.props.checkItems;
-    if (tempCheckItems.indexOf(this.props.id) != -1) {
+    const {checkItemsAdmin,checkItems,admin,adminflg,id} = this.props
+    if(admin||adminflg){
+      if (checkItemsAdmin.indexOf(id) != -1) {
+        return [check_right, 'title-wrapper-bg']
+      } else {
+        return [check_circle, '']
+      }
+    }
+    if (checkItems.indexOf(id) != -1) {
       return [check_right, 'title-wrapper-bg']
     } else {
       return [check_circle, '']
@@ -147,24 +161,66 @@ class TemplateItem extends React.Component {
       }
     }
   }
-
+  getStyleFst() {
+    const { allCheckShow, id, name, preview, sex,admin,checkItemsAdmin,allCheckShowAdmin,adminflg } = this.props;
+    if(admin) {
+      if(allCheckShowAdmin){
+        return `${style["title-wrapper"]} ${style["clearfix"]} ${style[this.getCheckIcon()[1]]}`
+      }
+      return `${style["title-wrapper"]} ${style["clearfix"]}`
+    }else{
+      if(adminflg){
+        if(allCheckShowAdmin){
+          return `${style["title-wrapper"]} ${style["clearfix"]} ${style[this.getCheckIcon()[1]]}`
+        }
+        return `${style["title-wrapper"]} ${style["clearfix"]}`
+      }
+      if(allCheckShow){
+        return `${style["title-wrapper"]} ${style["clearfix"]} ${style[this.getCheckIcon()[1]]}`
+      }
+      return `${style["title-wrapper"]} ${style["clearfix"]}`
+    }
+  }
+  getStyleSec(){
+    const { allCheckShow, id, name, preview, sex,admin,checkItemsAdmin,allCheckShowAdmin,adminflg } = this.props;
+    if(admin) {
+      if(allCheckShowAdmin){
+        return <div className={style['check-wrap']} onClick={(e) => { this.handleCheckboxClick(e, id) }}>
+        <img className={`${style['fl-element']} ${style['check-box']}`}
+          src={this.getCheckIcon()[0]}
+        /></div>
+      }
+      return null
+    }else{
+      if(adminflg){
+        if(allCheckShowAdmin){
+          return <div className={style['check-wrap']} onClick={(e) => { this.handleCheckboxClick(e, id) }}>
+          <img className={`${style['fl-element']} ${style['check-box']}`}
+            src={this.getCheckIcon()[0]}
+          /></div>
+        }
+        return null
+      }
+      if(allCheckShow){
+        return <div className={style['check-wrap']} onClick={(e) => { this.handleCheckboxClick(e, id) }}>
+        <img className={`${style['fl-element']} ${style['check-box']}`}
+          src={this.getCheckIcon()[0]}
+        /></div>
+      }
+      return null
+    }
+  }
   render() {
-    const { allCheckShow, id, name, preview, sex } = this.props;
+    const { allCheckShow, id, name, preview, sex,admin,checkItemsAdmin,allCheckShowAdmin,adminflg } = this.props;
     let previewJson = JSON.parse(preview);
     let sexStr = sex == 2 ? ' (女)' : sex == 1 ? ' (男)' : ' (通用)';
     return (
       <div className={style.wrapper}>
-        <div className={
-          allCheckShow ?
-            `${style["title-wrapper"]} ${style["clearfix"]} ${style[this.getCheckIcon()[1]]}` :
-            `${style["title-wrapper"]} ${style["clearfix"]}`}
+        <div className={this.getStyleFst()}
           onClick={this.handleTitleClick}
         >
           {
-            allCheckShow ? <div className={style['check-wrap']} onClick={(e) => { this.handleCheckboxClick(e, id) }}>
-              <img className={`${style['fl-element']} ${style['check-box']}`}
-                src={this.getCheckIcon()[0]}
-              /></div> : null
+            this.getStyleSec()
           }
           <i
             className={style['title']}
@@ -173,22 +229,22 @@ class TemplateItem extends React.Component {
             {name + sexStr}
           </i>
           <img className={style.arrow} src={arrow_icon} />
-          <img title={'删除模板'}
+          {!admin&&adminflg?null:<img title={'删除模板'}
             className={style.del}
             style={{ display: allCheckShow ? 'none' : 'block' }}
             src={this.getDelIcon()}
             onMouseEnter={() => this.handleDelIconMouseEnter()}
             onMouseLeave={() => this.handleDelIconMouseLeave()}
             onClick={(e) => this.handleTemplateDel(e)}
-          />
+          />}
           <span className={style.quote} onClick={(e) => this.handleContentClick(e, sex)}>引用</span>
-          <img title={'修改模板标题'}
+          {!admin&&adminflg?null:<img title={'修改模板标题'}
             className={style.edit}
             src={this.getEditIcon()}
             onMouseEnter={() => this.handleEditIconMouseEnter()}
             onMouseLeave={() => this.handleEditIconMouseLeave()}
             onClick={(e) => this.handleEditIconClick(e, name)}
-          />
+          />}
         </div>
         <div
           ref={(content) => this.content = content}

+ 133 - 30
src/components/TemplateItems/index.jsx

@@ -14,9 +14,11 @@ class TemplateItems extends React.Component {
         super(props);
         this.state = {
             msg:'还没有保存模板',
-            val:''
+            val:'',
+            height:''
         }
         this.$cont = React.createRef();
+        this.$conts = React.createRef();
         this.$search = React.createRef();
         this.genItems = this.genItems.bind(this);
         this.templateSearch = this.templateSearch.bind(this);
@@ -25,18 +27,56 @@ class TemplateItems extends React.Component {
         this.clear = this.clear.bind(this);
     }  
     componentDidMount(){
+        const {admin} = this.props;
+        console.log(admin)
+        
         const height = getWindowInnerHeight()-195;
-        this.$cont.current.style.height = height+"px";
+        // this.$conts.current.style.height = height+"px";
+        this.setState({
+            height:height
+        })
         windowEventHandler('resize', ()=>{
-            if(this.$cont.current){
+            if(this.$conts.current){
                 const height = getWindowInnerHeight()-195;
-                this.$cont.current.style.height = height+"px";
+                // this.$conts.current.style.height = height+"px";
+                this.setState({
+                    height:height
+                })
             }
         });
+        // if(admin){
+        //     const heights = getWindowInnerHeight()-195;
+        //     this.$conts.current.style.height = heights+"px";
+        //     windowEventHandler('resize', ()=>{
+        //         if(this.$conts.current){
+        //             const height = getWindowInnerHeight()-195;
+        //             this.$conts.current.style.height = height+"px";
+        //         }
+        //     });
+        // }else{
+        //     const height = getWindowInnerHeight()-195;
+        //     this.$cont.current.style.height = height/2+"px";
+        //     windowEventHandler('resize', ()=>{
+        //         if(this.$cont.current){
+        //             const height = getWindowInnerHeight()-195;
+        //             this.$cont.current.style.height = height/2+"px";
+        //         }
+        //     });
+        //     const heights = getWindowInnerHeight()-195;
+        //     this.$conts.current.style.height = heights/2+"px";
+        //     windowEventHandler('resize', ()=>{
+        //         if(this.$conts.current){
+        //             const height = getWindowInnerHeight()-195;
+        //             this.$conts.current.style.height = height/2+"px";
+        //         }
+        //     });
+
+        // }
     }
-    genItems() {
+    genItems(items,flg) {
         const Items = [];
-        this.props.items.forEach((v,idx) => {
+        const {admin,adminItems,checkItemsAdmin} = this.props;
+        items.forEach((v,idx) => {
             Items.push(
                 <TemplateItem
                     {...v}
@@ -47,13 +87,26 @@ class TemplateItems extends React.Component {
                     handleContentClick={this.props.handleContentClick}
                     handleTemplateDel={this.props.handleTemplateDel}
                     handleTitleChange={this.props.handleTitleChange}
+
+                    admin={this.props.admin}
+                    adminflg={flg}
+                    checkItemsAdmin={checkItemsAdmin}
+                    allCheckShowAdmin={this.props.allCheckShowAdmin}
                 />
             );
         });
         return Items;
     }
     getCheckIcon() {
-        if (this.props.items.length == this.props.checkItems.length && this.props.checkItems.length != 0) {
+        const {admin,checkItems,items,checkItemsAdmin,adminItems} = this.props;
+        if(admin){
+            if (adminItems.length == checkItemsAdmin.length && checkItemsAdmin.length != 0) {
+                return check_right;
+            } else {
+                return check_circle;
+            }
+        }
+        if (items.length == checkItems.length && checkItems.length != 0) {
             return check_right;
         } else {
             return check_circle;
@@ -83,16 +136,10 @@ class TemplateItems extends React.Component {
         const value = (this.$search.current.value).substring(0,30);
         // this.$search.current.value = value
         setTimeout(() => {
-            
             this.setState({
                 val: value
             });
         }, 30);
-        // if (value === '') {
-        //     this.setState({
-        //         val: ''
-        //     });
-        // }
     }
 
     clear(){
@@ -100,25 +147,25 @@ class TemplateItems extends React.Component {
         this.setState({
             val:''
         })
-        
         this.$search.current.focus();
     }
 
     render() {
-        const { allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore } = this.props;
-        // console.log(allCheckShow,7877877)
+        const { checkItemsAdmin,handleAllCheckboxAdmin,handleMangerTemplateAdmin,allCheckShowAdmin,admin,adminItems,allCheckShow, handleMangerTemplate,handleClickGetMore, handleDelList, handleAllCheckbox, items,checkItems,current,hasMore } = this.props;
+        const {height} = this.state
+        // console.log(checkItemsAdmin,7877877)
         return (
-            <div className={style.wrapper}>
-                {
-                    items ? (allCheckShow ?
+            <div className={style.wrapper} >
+                {//管理员操作
+                    adminItems&&admin ? (allCheckShowAdmin ?
                         <div className={style.wrapperTop}>
-                            <div className={style['check-wrap']} onClick={handleAllCheckbox}>
+                            <div className={style['check-wrap']} onClick={handleAllCheckboxAdmin}>
                                 <img className={`${style['fl-element']} ${style['check-box']}`} src={this.getCheckIcon()} />
                             </div>
-                            <span onClick={handleAllCheckbox}>全选</span>
-                            <span className={`${style['fr-element']} ${style['done']}`} onClick={handleMangerTemplate}>完成</span>
+                            <span onClick={handleAllCheckboxAdmin}>全选</span>
+                            <span className={`${style['fr-element']} ${style['done']}`} onClick={handleMangerTemplateAdmin}>完成</span>
                             {
-                                checkItems.length>0?<span className={`${style['fr-element']} ${style['del-items']}`} onClick={handleDelList}>删除</span>:
+                                checkItemsAdmin.length>0?<span className={`${style['fr-element']} ${style['del-items']}`} onClick={handleDelList}>删除</span>:
                                 <span className={`${style['fr-element']} ${style['del-items-gray']}`}>删除</span>
                             }
                         </div> :
@@ -129,19 +176,75 @@ class TemplateItems extends React.Component {
                                 <div className={style.search} onClick={this.templateSearch}>搜索</div>
                             </div>
                             {
-                                items.length > 0&&<span className={`${style['fr-element']} ${style['manger']}`} onClick={handleMangerTemplate}>管理</span>
+                                adminItems.length > 0&&<span className={`${style['fr-element']} ${style['manger']}`} onClick={handleMangerTemplateAdmin}>管理</span>
+                            }
+                    </div>) : null
+                }
+                {//个人
+                    items&&!admin ? 
+                        <div className={style.wrapperTop}>
+                            <div className={style.templateSearch}>
+                                <input placeholder="模板搜索" maxLength="30" ref={this.$search} type="text" onInput={this.handleChange} onPropertyChange={this.handleChange} onKeyUp={this.handleEnter}/>
+                                {this.state.val?<img src={delIcon} alt="清空" onClick={this.clear}/>:''}
+                                <div className={style.search} onClick={this.templateSearch}>搜索</div>
+                            </div>
+                    </div> : null
+                }
+                {
+                    <div className={style.comAdminWrp}>
+                        <div className={style.tempLists} ref={this.$cont} style={{display:admin?'none':'block',height:height/2+'px'}}>
+                            {//个人
+                                allCheckShow&&!admin ?<div className={`${style.wrapperTop} ${style.wrapperTopM}`}>
+                                    <div className={style['check-wrap']} onClick={handleAllCheckbox}>
+                                        <img className={`${style['fl-element']} ${style['check-box']}`} src={this.getCheckIcon()} />
+                                    </div>
+                                    <span onClick={handleAllCheckbox}>全选</span>
+                                    <span className={`${style['fr-element']} ${style['done']}`} onClick={handleMangerTemplate}>完成</span>
+                                    {
+                                        checkItems.length>0?<span className={`${style['fr-element']} ${style['del-items']}`} onClick={handleDelList}>删除</span>:
+                                        <span className={`${style['fr-element']} ${style['del-items-gray']}`}>删除</span>
+                                    }
+                                </div>:null
+                            }
+                            {
+                                items.length > 0&&!allCheckShow&&<span className={`${style['fr-element']} ${style['manger']}`} onClick={handleMangerTemplate}>管理</span>
+                            }
+                            {
+                                this.genItems(items).length > 0?this.genItems(items): <Empty message={this.state.msg}></Empty>
+                            }
+                        </div>
+                        <div className={style.tempLists} ref={this.$conts} style={{height:admin?height+'px':height/2+'px'}}>
+                            {//管理员
+                                allCheckShowAdmin&&!admin ?<div className={`${style.wrapperTop} ${style.wrapperTopM}`}>
+                                    <div className={style['check-wrap']} onClick={handleAllCheckboxAdmin}>
+                                        <img className={`${style['fl-element']} ${style['check-box']}`} src={this.getCheckIcon()} />
+                                    </div>
+                                    <span onClick={handleAllCheckboxAdmin}>全选</span>
+                                    <span className={`${style['fr-element']} ${style['done']}`} onClick={handleMangerTemplateAdmin}>完成</span>
+                                    {
+                                        checkItems.length>0?<span className={`${style['fr-element']} ${style['del-items']}`} onClick={handleDelList}>删除</span>:
+                                        <span className={`${style['fr-element']} ${style['del-items-gray']}`}>删除</span>
+                                    }
+                                </div>:null
+                            }
+                            {
+                                // adminItems.length > 0&&!admin&&!allCheckShowAdmin&&<span className={`${style['fr-element']} ${style['manger']}`} onClick={handleMangerTemplateAdmin}>管理</span>
+                                adminItems.length > 0&&!admin&&!allCheckShowAdmin&&<div>标准模板</div>
+                            }
+                            {
+                                this.genItems(adminItems,true).length > 0?this.genItems(adminItems,true): <Empty message={this.state.msg}></Empty>
                             }
-                    </div>) : <div style={{height:'36px'}}></div>
+                        </div>
+                    </div>
                 }
-                <div className={style.tempLists} ref={this.$cont}>
+                {/* <div className={style.tempLists} ref={this.$cont}>
                     {
                         this.genItems().length > 0?this.genItems(): <Empty message={this.state.msg}></Empty>
                     }
-                    {/* {//注释掉的暂时没有分也功能
+                    {//注释掉的暂时没有分也功能
                       hasMore?<p onClick={()=>handleClickGetMore(current)} className={style.loadMore}>点击查看更多</p>:null
-                    } */}
-                    
-                </div>
+                    } 
+                </div> */}
             </div>
         )
     }

+ 16 - 1
src/components/TemplateItems/index.less

@@ -24,7 +24,7 @@
     }
     .wrapperTop {
         height: 46px;
-        padding: 0 15px;
+        padding: 0 30px;
         margin-top: 10px;
         // background-color: #EAEDF1;
         cursor: pointer;
@@ -65,6 +65,9 @@
             color: @template-color;
         }
     }
+    .wrapperTopM {
+        padding: 0 15px;
+    }
     .loadMore {
       text-align: center;
       color: #2a9bd5;
@@ -105,5 +108,17 @@
             cursor: pointer;
         }
     }
+    
+    .comAdminWrp {
+        padding: 0 15px;
+    }
 }
 
+
+.fr-element {
+    // float: right;
+    color: #3B9ED0;
+    display: inline-block;
+    height: 36px;
+    line-height: 36px;
+}

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

@@ -11,13 +11,23 @@ import {
     KEEP_PUSH_DATA,
     ALL_CHECKED_SHOW,
     GET_DPT_LIS,
-    INIT_ADMIN_ITEMS
+    INIT_ADMIN_ITEMS,
+    ALL_CHECKED_ADMIN,
+    ALL_CHECKED_SHOW_ADMIN,
+    CKECK_ITEMS_ADMIN,
+    DEL_ITEMS_ADMIN,
+    BATCH_DEL_ITEMS_ADMIN,
+    CHANGE_TITLE_ADMIN
 } from '@store/types/tabTemplate';
 
 export const delItems = (id) => ({ //删除模板
     type: DEL_ITEMS,
     id
 });
+export const delItemsAdmin = (id) => ({ //删除模板
+    type: DEL_ITEMS_ADMIN,
+    id
+});
 export const tabChange = (idx) => ({ //tab切换
     type: TAB_CHANGE,
     idx
@@ -34,18 +44,34 @@ export const checkItems = (id) => ({ //选中的模板
     type: CKECK_ITEMS,
     id
 });
+export const checkItemsAdmin = (id) => ({ //选中的模板
+    type: CKECK_ITEMS_ADMIN,
+    id
+});
 export const batchDelItems = (ids) => ({ //删除选中的模板
     type: BATCH_DEL_ITEMS,
     ids
 });
+export const batchDelItemsAdmin = (ids) => ({ //删除选中的模板
+    type: BATCH_DEL_ITEMS_ADMIN,
+    ids
+});
 export const allChecked = (bool, flg) => ({ //全选反选
     type: ALL_CHECKED,
     bool
 });
-export const changeTitle = (obj) => ({ //全选反选
+export const allCheckedAdmin = (bool, flg) => ({ //全选反选
+    type: ALL_CHECKED_ADMIN,
+    bool
+});
+export const changeTitle = (obj) => ({ 
     type: CHANGE_TITLE,
     obj
 });
+export const changeTitleAdmin = (obj) => ({ 
+    type: CHANGE_TITLE_ADMIN,
+    obj
+});
 export const changeVisible = (bool) => ({ //弹窗
     type: CHANGE_VISIBLE,
     bool
@@ -63,6 +89,10 @@ export const allCheckedShow = (bool) => ({
     type: ALL_CHECKED_SHOW,
     bool
 });
+export const allCheckedShowAdmin = (bool) => ({ 
+    type: ALL_CHECKED_SHOW_ADMIN,
+    bool
+});
 export const getDptLis = (list) => ({ 
     type: GET_DPT_LIS,
     list

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

@@ -7,7 +7,10 @@ import {
   keepPushData,
   changeVisible,
   getDptLis,
-  initAdminItems
+  initAdminItems,
+  delItemsAdmin,
+  batchDelItemsAdmin,
+  changeTitleAdmin,
 } from '@store/actions/tabTemplate';
 import {DIAG_SHOW} from "@store/types/print";
 import Notify from '@commonComp/Notify';
@@ -218,6 +221,24 @@ export const delItem = (id) => { //删除
     })
   }
 };
+export const delItemAdmin = (id) => { //删除
+  let baseList = store.getState().patInfo.message;
+  return (dispatch) => {
+    axios.json('/templateAdmin/cancelTemplateAdminb', {
+      "ids": id, 
+      "doctorId": baseList.doctorId,
+      "hospitalId": baseList.hospitalId,
+    }).then((res) => {
+      let data = res.data;
+      if (data.code == 0) {
+        dispatch(delItemsAdmin(id));
+        Notify.success('模板删除成功');
+      } else {
+        Notify.error(data.msg);
+      }
+    })
+  }
+};
 export const delBatchItem = (ids) => { //批量删除
   return (dispatch) => {
     axios.json('/templateInfo/cancelTemplateInfos', {
@@ -232,7 +253,49 @@ export const delBatchItem = (ids) => { //批量删除
     })
   }
 };
+export const delBatchItemAdmin = (ids) => { //批量删除
+  let baseList = store.getState().patInfo.message;
+  return (dispatch) => {
+    axios.json('/templateAdmin/cancelTemplateAdminb', {
+      "ids": ids.join(","), 
+      "doctorId": baseList.doctorId,
+      "hospitalId": baseList.hospitalId,
+    }).then((res) => {
+      let data = res.data;
+      if (data.code == 0) {
+        dispatch(batchDelItemsAdmin(ids));
+      } else {
+        Notify.error(data.msg);
+      }
+    })
+  }
+};
 
+export const changeTitleAsyncAdmin = (obj) => { //改标题
+  let baseList = store.getState();
+  let whichSign = baseList.typeConfig.mode;
+  let state = baseList.patInfo.message;
+  return (dispatch) => {
+    axios.json('/templateAdmin/updateByAdminNames', {
+      "doctorId": state.doctorId,
+      "hospitalDeptId": state.hospitalDeptId,
+      "hospitalId": state.hospitalId,
+      "id": obj.id,
+      "modeName": obj.title,
+      "type": whichSign
+    }).then((res) => {
+      let data = res.data;
+      if (data.code == 0) {
+        dispatch(changeTitleAdmin(obj));
+        Notify.success('标题修改成功');
+        store.dispatch(changeVisible(false))
+      } else {
+        // console.log(data)
+        Notify.error(data.msg)
+      }
+    })
+  }
+};
 export const changeTitleAsync = (obj) => { //改标题
   let baseList = store.getState();
   let whichSign = baseList.typeConfig.mode;

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

@@ -12,6 +12,12 @@ import {
   ALL_CHECKED_SHOW,
   GET_DPT_LIS,
   INIT_ADMIN_ITEMS,
+  ALL_CHECKED_ADMIN,
+  ALL_CHECKED_SHOW_ADMIN,
+  CKECK_ITEMS_ADMIN,
+  DEL_ITEMS_ADMIN,
+  BATCH_DEL_ITEMS_ADMIN,
+  CHANGE_TITLE_ADMIN,
 } from '../types/tabTemplate';
 
 
@@ -26,10 +32,13 @@ const initDataList = {
   items: [],
   adminItems:[],
   allChecked: false, //全选反选
+  allCheckedAdmin:false,//全选反选管理员模板
   checkItems: [], //选中要删除的元素
+  checkItemsAdmin: [], //选中要删除的元素管理员
   activeItem: {}, //引用的模板
   activeItemHis: {}, //引用的历史病例
   allCheckShow: false, //全选反选是否显示
+  allCheckShowAdmin: false, //全选反选是否显示管理员
   current:1,//当前页
   hasMore:true,//是否显示更多
   departLis:[],//搜索的科室列表
@@ -50,6 +59,16 @@ export default (state = initDataList, action) => {
     // }
     return newState;
   }
+  if (action.type === DEL_ITEMS_ADMIN) {
+    const newState = Object.assign({}, state);
+    let tempArr = newState.adminItems;
+    tempArr.splice(tempArr.findIndex(item => item.id == action.id), 1)
+    newState.adminItems = [...tempArr];
+    // if(tempArr.length == 0){
+    //   newState.allCheckShow = false
+    // }
+    return newState;
+  }
   if (action.type === BATCH_DEL_ITEMS) {
     const newState = Object.assign({}, state);
     let tempArr = newState.items;
@@ -64,6 +83,20 @@ export default (state = initDataList, action) => {
     newState.checkItems = [];
     return newState;
   }
+  if (action.type === BATCH_DEL_ITEMS_ADMIN) {
+    const newState = Object.assign({}, state);
+    let tempArr = newState.adminItems;
+    for (let i = 0; i < action.ids.length; i++) {
+      let currentId = action.ids[i];
+      tempArr.splice(tempArr.findIndex(item => item.id == currentId), 1)
+    }
+    newState.adminItems = [...tempArr];
+    // if(tempArr.length == 0){
+    //   newState.allCheckShow = false
+    // }
+    newState.checkItemsAdmin = [];
+    return newState;
+  }
   if (action.type === INIT_ITEMS) {
     const newState = Object.assign({}, state);
     // let tmpItems = JSON.parse(JSON.stringify(newState.items))
@@ -121,6 +154,17 @@ export default (state = initDataList, action) => {
     newState.items = [...tempArr];
     return newState;
   }
+  if (action.type === CHANGE_TITLE_ADMIN) {
+    const newState = Object.assign({}, state);
+    let tempArr = newState.adminItems;
+    for (let i = 0; i < tempArr.length; i++) {
+      if (tempArr[i].id == action.obj.id) {
+        tempArr[i].name = action.obj.title
+      }
+    }
+    newState.adminItems = [...tempArr];
+    return newState;
+  }
   if (action.type === CKECK_ITEMS) {
     const newState = Object.assign({}, state);
     if (newState.checkItems.indexOf(action.id) == -1) {
@@ -134,6 +178,19 @@ export default (state = initDataList, action) => {
     }
     return newState;
   }
+  if (action.type === CKECK_ITEMS_ADMIN) {
+    const newState = Object.assign({}, state);
+    if (newState.checkItemsAdmin.indexOf(action.id) == -1) {
+      let tempArr = newState.checkItemsAdmin;
+      tempArr.push(action.id);
+      newState.checkItemsAdmin = [...tempArr]
+    } else {
+      let tempArr = newState.checkItemsAdmin;
+      tempArr.splice(tempArr.findIndex(item => item === action.id), 1)
+      newState.checkItemsAdmin = [...tempArr]
+    }
+    return newState;
+  }
   if (action.type === KEEP_PUSH_DATA) {
     const newState = Object.assign({}, state);
     action.flg == 'his' ? (newState.activeItemHis = action.data) : (newState.activeItem = action.data);
@@ -152,6 +209,20 @@ export default (state = initDataList, action) => {
     newState.allChecked = action.bool;
     newState.checkItems = [...tempArr];
     return newState;
+  }  
+  if (action.type === ALL_CHECKED_ADMIN) {//管理员全选反选
+    const newState = Object.assign({}, state);
+    let tempArr = [];
+    if (action.bool) {
+      newState.adminItems.forEach((val) => {
+        tempArr.push(val.id)
+      })
+    } else {
+      tempArr = []
+    }
+    newState.allCheckedAdmin = action.bool;
+    newState.checkItemsAdmin = [...tempArr];
+    return newState;
   }
 
   if (action.type === ALL_CHECKED_SHOW) {
@@ -159,5 +230,10 @@ export default (state = initDataList, action) => {
     newState.allCheckShow = action.bool;
     return newState;
   }
+  if (action.type === ALL_CHECKED_SHOW_ADMIN) {
+    const newState = Object.assign({}, state);
+    newState.allCheckShowAdmin = action.bool;
+    return newState;
+  }
   return state;
 }

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

@@ -11,3 +11,9 @@ export const KEEP_PUSH_DATA = 'KEEP_PUSH_DATA';
 export const ALL_CHECKED_SHOW = 'ALL_CHECKED_SHOW';
 export const GET_DPT_LIS = 'GET_DPT_LIS';
 export const INIT_ADMIN_ITEMS = 'INIT_ADMIN_ITEMS';
+export const ALL_CHECKED_ADMIN = 'ALL_CHECKED_ADMIN';
+export const ALL_CHECKED_SHOW_ADMIN = 'ALL_CHECKED_SHOW_ADMIN';
+export const CKECK_ITEMS_ADMIN = 'CKECK_ITEMS_ADMIN';
+export const DEL_ITEMS_ADMIN = 'DEL_ITEMS_ADMIN';
+export const BATCH_DEL_ITEMS_ADMIN = 'BATCH_DEL_ITEMS_ADMIN';
+export const CHANGE_TITLE_ADMIN = 'CHANGE_TITLE_ADMIN';