Sfoglia il codice sorgente

Merge branch 'master' of http://192.168.1.41:3000/caipin/cld2_react

caipin 5 anni fa
parent
commit
825fcf7643

+ 15 - 0
src/common/staffHeader/index.js

@@ -32,6 +32,7 @@ class staffHeader extends PureComponent {
           
           <h1 className="subheader-title">
      					联系人
+               {/* {handeName} */}
      				</h1>
          
           <div className="ml-auto d-flex">
@@ -73,7 +74,21 @@ class staffHeader extends PureComponent {
 
 }
 
+const mapStateToProps = (state) => {
+  return {
+    menuActive: state.getIn(['common', 'menuActive']),
+  }
+}
+
 
+const mapDispathToProps = (dispatch) => {
+  return {
+    handleMenuActive(value) {
+      dispatch(actionCreators.menuActive(value));
+    },
+  }
+}
 
 
 export default staffHeader;
+// export default connect(mapStateToProps, mapDispathToProps)(staffHeader);

+ 19 - 38
src/common/staffHeader/store/actionCreators.js

@@ -7,46 +7,27 @@ import axios from '../../../common/axios_auth.js';
 
 
 //actionType
-export const searchFocus = () => ({
-    type: constants.SEARCH_FOCUS
-});
-
-export const getList = () => {
-    return (dispatch) => {
-        axios.get('/api/submenuList.json').then((res) => {
-            const data = res.data;
-            dispatch(changeList(data.data));
-        }).catch(() => {
-            console.log('error');
-        })
-    }
-};
-
-export const changeInputValue = (value) => (  {
-    type: constants.CHANGE_INPUTVALUE,
-    data:fromJS(value),
-});
-
-const changeList = (data) => ({
-    type: constants.CHANGE_LIST,
-    data: fromJS(data),
-    // totalPage: Math.ceil(data.length / 10)
-});
-
-// export const searchBlur = () => ({
-// 	type: constants.SEARCH_BLUR
+// export const searchFocus = () => ({
+//     type: constants.SEARCH_FOCUS
 // });
 
-// export const mouseEnter = () => ({
-// 	type: constants.MOUSE_ENTER
+// export const getList = () => {
+//     return (dispatch) => {
+//         axios.get('/api/submenuList.json').then((res) => {
+//             const data = res.data;
+//             dispatch(changeList(data.data));
+//         }).catch(() => {
+//             console.log('error');
+//         })
+//     }
+// };
+
+// export const changeInputValue = (value) => (  {
+//     type: constants.CHANGE_INPUTVALUE,
+//     data:fromJS(value),
 // });
 
-// export const mouseLeave = () => ({
-// 	type: constants.MOUSE_LEAVE
+// const changeList = (data) => ({
+//     type: constants.CHANGE_LIST,
+//     data: fromJS(data),
 // });
-
-// export const changePage = (page) => ({
-// 	type: constants.CHANGE_PAGE,
-// 	page
-// });
-

+ 20 - 53
src/common/staffHeader/store/reducer.js

@@ -3,56 +3,23 @@ import * as constants from './constants';
 import { fromJS } from 'immutable';
 
 
-const defaultState = fromJS({
-    menu: 'hello submenu-t!!!',
-    list:[],
-    inputValue:'',
-
-});
-
-
-export default (state = defaultState, action) => {
-
-    // switch(action.type) {
-	// 	case constants.SEARCH_FOCUS:
-	// 		return state.set('focused', true);
-	// 	case constants.SEARCH_BLUR:
-	// 		return state.set('focused', false);
-	// 	case constants.CHANGE_LIST:
-	// 		return state.merge({
-	// 			list: action.data,
-	// 			totalPage: action.totalPage
-	// 		});
-	// 	case constants.MOUSE_ENTER:
-	// 		return state.set('mouseIn', true);
-	// 	case constants.MOUSE_LEAVE:
-	// 		return state.set('mouseIn', false);
-	// 	case constants.CHANGE_PAGE:
-	// 		return state.set('page', action.page);
-	// 	default:
-	// 		return state;
-	// }
-    if(action.type===constants.CHANGE_INPUTVALUE){
-        return state.set('inputValue',action.data);
-
-    }
-
-
-
-    if(action.type===constants.SEARCH_FOCUS){
-        return state.set('menu','clicke me');
-        // return {
-        //     menu:'clicke me'
-        // }
-    }
-    if(action.type===constants.CHANGE_LIST){
-        return state.set('list',action.data);
-        //return state.set('menu','clicke me');
-
-        // return state.merge({
-        //     list: action.data,
-        //     //totalPage: action.totalPage
-        // });
-    }
-    return state;
-}
+// const defaultState = fromJS({
+//     menu: 'hello submenu-t!!!',
+//     list:[],
+//     inputValue:'',
+
+// });
+
+
+// export default (state = defaultState, action) => {
+//     if(action.type===constants.CHANGE_INPUTVALUE){
+//         return state.set('inputValue',action.data);
+//     }
+//     if(action.type===constants.SEARCH_FOCUS){
+//         return state.set('menu','clicke me');
+//     }
+//     if(action.type===constants.CHANGE_LIST){
+//         return state.set('list',action.data);
+//     }
+//     return state;
+// }

+ 20 - 8
src/product/lock_store/index.js

@@ -16,7 +16,7 @@ const { Search } = Input;
 
 class lock_store extends PureComponent {
     render() {
-      const {dataSource,columns,pagination,handleLockstoreList,handleSearch,columnsData,columnsNum,handleInputChange,handleColumnsShow} = this.props;
+      const {dataSource,columns,pagination,handleLockstoreList,handleSearch,columnsData,columnsNum,handleInputChange,handleColumnsShow,sortField,sort,handleLockstoreSortField,handleLockstoreSort} = this.props;
      
         return (
         <div>
@@ -64,11 +64,11 @@ class lock_store extends PureComponent {
                       <ul className="list-unstyled px-3 pt-2 mb-0">
                         <li className="mb-2">
                           {/* <Radio.Group onChange={this.onChange} value={value}> */}
-                          <Radio.Group onChange={this.onChange}>
-                            <Radio style={radioStyle} value={1}>
+                          <Radio.Group onChange={(e) => handleLockstoreSortField(pagination.toJS(), this.props, e)}value={sortField}>
+                            <Radio style={radioStyle} value='KEYNUM'>
                               锁号
                             </Radio>
-                            <Radio style={radioStyle} value={2}>
+                            <Radio style={radioStyle} value='UPDATETIME'>
                               出库时间
                             </Radio>
                           </Radio.Group>
@@ -76,11 +76,11 @@ class lock_store extends PureComponent {
                       </ul>
                       <ul className="list-unstyled px-3 pt-2 mb-0 border-top">
                         <li className="mb-2">
-                          <Radio.Group onChange={this.onChange}>
-                            <Radio style={radioStyle} value={3}>
+                          <Radio.Group onChange={(e) => handleLockstoreSort(pagination.toJS(), this.props, e)} value={sort}>
+                            <Radio style={radioStyle} value='DESC'>
                               降序
                             </Radio>
-                            <Radio style={radioStyle} value={4}>
+                            <Radio style={radioStyle} value='ASC'>
                               升序
                             </Radio>
                           </Radio.Group>
@@ -92,7 +92,7 @@ class lock_store extends PureComponent {
                 <div className="panel-container show">
                   <div className="panel-content">
                    <Table
-                   onChange={(pagination) => handleLockstoreList(pagination,this.props)}
+                    onChange={(pagination) => handleLockstoreList(pagination,this.props)}
                     pagination={pagination.toJS()}
                     bordered
                     dataSource={dataSource.toJS()}
@@ -132,6 +132,8 @@ const mapStateToProps = (state) => {
       searchValue: state.getIn(['lockstore', 'searchValue']),
       columnsData: state.getIn(['lockstore', 'columnsData']),
       columnsNum:state.getIn(['lockstore', 'columnsNum']),
+      sortField: state.getIn(['lockstore', 'sortField']),
+      sort: state.getIn(['lockstore', 'sort']),
     }
 }
 
@@ -151,6 +153,16 @@ const mapDispathToProps = (dispatch) => {
       handleLockstoreList(pagination,support){
         dispatch(actionCreators.getLockstoreList(pagination,support));
       },
+      //排序设置
+    handleLockstoreSortField(pagination, support, e) {
+      dispatch(actionCreators.changeSortField(e.target.value));
+      
+      dispatch(actionCreators.getLockstoreList(pagination, support));//,{sortField:e.target.value,sort:props.sort}
+    },
+    handleLockstoreSort(pagination, support, e) {
+      dispatch(actionCreators.changeSort(e.target.value));
+      dispatch(actionCreators.getLockstoreList(pagination, support));//,{sortField:props.sortField,sort:e.target.value}
+    },
       handleSearch(pagination,support,searchValue,keyup){
         if(keyup === 'keyup'){
           if(delaySwitch != null){

+ 36 - 0
src/product/lock_store/store/actionCreators.js

@@ -19,19 +19,55 @@ export const toggleColumnsAll = () => {
     }
 };
 
+//排序
+export const toggleSorter = () => {
+    return (dispatch) => {
+        dispatch({
+            type: constants.TOGGLE_SORTER,
+        });
+    }
+}
+export const changeSortField = (sortField) => {
+    return (dispatch) => {
+        dispatch({
+            type: constants.CHANGE_LOCKSTORE_SORTFIELD,
+            data: sortField,
+        });
+    }
+}
+export const changeSort = (sort) => {
+    return (dispatch) => {
+        dispatch({
+            type: constants.CHANGE_LOCKSTORE_SORT,
+            data: sort,
+        });
+    }
+}
+
 export const getLockstoreList = (pagination,support,searchValue) =>{
     return(dispatch) =>{
         // console.log('searchValue:'+searchValue);
         // console.log('support:'+searchValue);
         // console.log('typeof:'+typeof searchValue);
+        let sortField = localStorage.getItem("product_lock_store_sortField");
+        if(sortField===null){
+            sortField = support.sortField;
+        }
+        let sort = localStorage.getItem("product_lock_store_sort");
+        if(sort===null){
+            sort = support.sort;
+        }
         if(typeof searchValue === 'undefined'){
             searchValue = support.searchValue;
         }
+        // console.log();
         // console.log(config.CLD2API + '/contact/company')
         axios.get(config.CLD2API + '/contact/company', {
             params: {
                 current: pagination.current,
                 pageSize: pagination.pageSize,
+                sortField:sortField,
+                sort:sort,
                 searchValue:searchValue,
             },
         }).then((res) => {

+ 4 - 1
src/product/lock_store/store/constants.js

@@ -1,3 +1,6 @@
 export const CHANGE_LOCKSTORE_DATA = 'product/change_lockstore_data';
 export const TOGGLE_COLUMNS = 'product/toggle_columns';
-export const TOGGLE_COLUMNS_ALL = 'product/toggle_columns_all';
+export const TOGGLE_COLUMNS_ALL = 'product/toggle_columns_all';
+export const TOGGLE_SORTER= 'product/toggle_sorter';
+export const CHANGE_LOCKSTORE_SORTFIELD= 'product/change_lockstore_sortField';
+export const CHANGE_LOCKSTORE_SORT= 'product/change_lockstore_sort';

+ 24 - 1
src/product/lock_store/store/reducer.js

@@ -13,6 +13,8 @@ const defaultState = fromJS({
 	columnsNum: 0,
 	searchValue: '',
 	dataSource: [],
+	sortField: 'KEYNUM',
+	sort: 'DESC',
 	columns: [
 		{
 			title: '锁号',
@@ -75,7 +77,7 @@ export default (state = defaultState, action) => {
 	let columnNumData = 0;
 
 	switch (action.type) {
-		//排序
+		//显示列
 		case constants.TOGGLE_COLUMNS:
 			columnsData[action.data].columnsValue = !columnsData[action.data].columnsValue;
 			localStorage.setItem('product_lock_store_Column_' + action.data, columnsData[action.data].columnsValue);
@@ -110,6 +112,27 @@ export default (state = defaultState, action) => {
 				columnsNum: columnNumData,
 				columnsData: fromJS(columnsData),
 			});
+		//排序
+		case constants.TOGGLE_SORTER:
+			var sortField = localStorage.getItem("product_lock_store_sortField");
+			var sort = localStorage.getItem("product_lock_store_sort");
+			if(sortField!==null&&sort!==null){
+				return state.merge({
+					sortField: sortField,
+					sort: sort
+				});
+			}else if(sortField!==null){
+				return state.set('sortField', sortField);
+			}else if(sort!==null){
+				return state.set('sort', sort);
+			}
+		case constants.CHANGE_LOCKSTORE_SORTFIELD:
+			// console.log(action.data);
+			localStorage.setItem('product_lock_store_sortField', action.data);
+			return state.set('sortField', action.data);
+		case constants.CHANGE_LOCKSTORE_SORT:
+			localStorage.setItem('product_lock_store_sort', action.data);
+			return state.set('sort', action.data);
 		//表格
 		case constants.CHANGE_LOCKSTORE_DATA:
 			let pagination = {

+ 2 - 3
src/product/product.js

@@ -41,12 +41,12 @@ class product extends Component {
                   <ul>
                       <li className={menuActive=='lock_store'?'active':''} onClick={()=>handleMenuActive('lock_store')} >
                         <Link to='/product'>
-                          <span className="nav-link-text">公共锁库 {} </span>
+                          <span className="nav-link-text">公共锁库</span>
                         </Link>
                       </li>
                       <li className={menuActive=='lock_count'?'active':''} onClick={()=>handleMenuActive('lock_count')} >
                         <Link to='/product/lockCount'>
-                          <span className="nav-link-text">使用统计 {} </span>
+                          <span className="nav-link-text">使用统计</span>
                         </Link>
                       </li>
                   </ul>
@@ -102,7 +102,6 @@ const mapDispathToProps = (dispatch) => {
       dispatch(actionCreators.menuActive(value));
     },
   }
-  
 }
 // export default contact;
 export default connect(mapStateToProps, mapDispathToProps)(product);