Ver código fonte

删除文件夹

zhangxc 5 anos atrás
pai
commit
650d27a1be

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

@@ -2,7 +2,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 { initItemList,initAdminItemList, delItem,delItemAdmin, delBatchItem, delBatchItemAdmin,changeTitleAsync, setPageView,changeTitleAsyncAdmin,setPageViewAdmin,getFloderList } from '@store/async-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';
 import { billing } from '@store/async-actions/pushMessage';
@@ -74,6 +74,7 @@ class PushContainer extends Component {
     this.floderRename = this.floderRename.bind(this);
     this.handleInputFloder = this.handleInputFloder.bind(this);
     this.setFolderId = this.setFolderId.bind(this);
+    this.floderDelete = this.floderDelete.bind(this)
   }
   componentDidMount() {
     // const height = getWindowInnerHeight()-160;
@@ -332,10 +333,22 @@ class PushContainer extends Component {
       </div>
     </div>
   }
-  floderDelete(id){//文件夹删除
-    console.log('id', id)
-    store.dispatch(delItemAdmin(id))
+  floderDelete(folderId){//文件夹删除
+    this.setState({
+      message: <p className={style['center']}>确认删除文件夹?</p>,
+      type: 6,
+      folderId:folderId,
+      okText: '删除',
+      okBorderColor: 'red',
+      okColor: 'red',
+      oKBg: '#fff'
+    }, () => {
+      store.dispatch(changeVisible(true))
+    })
+    // store.dispatch(delFloder(id))
+    
   }
+ 
 
   makeSure() {
     const {type,id,title,tmpFolder,folderNameVal,text,fstName,spell,currId,deptId,folderId} = this.state
@@ -383,6 +396,14 @@ class PushContainer extends Component {
         store.dispatch(setPageView(id))
       }
       store.dispatch(changeVisible(false))
+    } else if(type == 6) { //删除文件夹
+      if(this.props.admin){
+        store.dispatch(delFloder(folderId))
+        store.dispatch(changeVisible(false))
+      }else{
+        // store.dispatch(delFloder(folderId))
+        // store.dispatch(delBatchItem(this.props.checkItems))
+      }
     }
   }
   handleClose() {

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

@@ -66,6 +66,7 @@ class TemplateItems extends React.Component {
         })
     }
     floderSlide(e,item){
+        e.stopPropagation()
         const {floderSlide} = this.props
         if(!item.templateInfo){
             return;

+ 36 - 10
src/store/async-actions/tabTemplate.js

@@ -67,15 +67,16 @@ export const initAdminItemList = (current,name) => { //初始化数据
   let state = baseList.patInfo.message;
   return (dispatch) => {
     // axios.json('/templateAdmin/getTemplatePageAlls', {
-    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)
-      }
-    })
+      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)
+    //   }
+    // })
   }
 };
 
@@ -252,6 +253,7 @@ export const newFloder = (name,id) => { //新建管理员文件夹
         Notify.success('新建成功');
         dispatch(folderModal(false))
         dispatch(getFloderList())
+        dispatch(getFloderListAll())
       } else {
         Notify.error(data.msg);
       }
@@ -269,6 +271,17 @@ export const delFloder = (id) => { //文件夹删除
       let data = res.data;
       if (data.code == 0) {
         console.log(res,'管理员文件夹列表获取')
+        Notify.success('文件夹删除成功');
+        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)
+        //   }
+        // })
       } else {
         Notify.error(data.msg);
       }
@@ -466,4 +479,17 @@ export const getDepartments = (value) => { //获取模板结构化数据
       }
     })
   }
-};
+};
+export const getFloderListAll = () => {
+  return (dispatch) => {
+    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)
+      }
+    })
+  }
+}