Browse Source

修正代码风格

zhanghe 7 years atrás
parent
commit
1665614bf3

+ 37 - 32
src/components/RBCityCascader/city.js

@@ -21,8 +21,8 @@
     JSON.stringify(map)
     ```
 */
-let DICT = {
-  //修改过
+const DICT = {
+  // 修改过
   110000: '北京',
   110100: '东城区',
   110200: '西城区',
@@ -41,7 +41,7 @@ let DICT = {
   111500: '密云县',
   111600: '延庆县',
   111700: '其它区',
-  //修改过
+  // 修改过
   120000: '天津',
   120100: '和平区',
   120200: '河东区',
@@ -892,7 +892,7 @@ let DICT = {
   232723: '漠河县',
   232724: '加格达奇区',
   232725: '其它区',
-  //上海属于直辖市,做了修改
+  // 上海属于直辖市,做了修改
   310000: '上海',
   310100: '黄浦区',
   310200: '徐汇区',
@@ -2500,7 +2500,7 @@ let DICT = {
   469035: '保亭黎族苗族自治县',
   469036: '琼中黎族苗族自治县',
   471005: '其它区',
-  //重庆做了修改
+  // 重庆做了修改
   500000: '重庆',
   500100: '万州区',
   500200: '涪陵区',
@@ -4018,46 +4018,51 @@ let DICT = {
   820200: '离岛',
   990000: '海外',
   990100: '海外',
-}
+};
 
 // id pid/parentId name children
 const tree = (list) => {
-  let mapped = {}
-  let item
+  const mapped = {};
+  let item;
   for (let i = 0; i < list.length; i += 1) {
-    item = list[i]
-    if (!item || !item.id) continue
-    mapped[item.id] = item
+    item = list[i];
+    /* eslint-disable no-continue */
+    if (!item || !item.id) continue;
+    mapped[item.id] = item;
   }
 
-  let result = []
+  const result = [];
   for (let ii = 0; ii < list.length; ii += 1) {
-    item = list[ii]
+    item = list[ii];
 
-    if (!item) continue
+    /* eslint-disable no-continue */
+    if (!item) continue;
     /* jshint -W041 */
     if (item.pid === undefined && item.parentId === undefined) {
-      result.push(item)
-      continue
+      result.push(item);
+      /* eslint-disable no-continue */
+      continue;
     }
-    let parent = mapped[item.pid] || mapped[item.parentId]
-    if (!parent) continue
-    if (!parent.children) parent.children = []
-    parent.children.push(item)
+    const parent = mapped[item.pid] || mapped[item.parentId];
+    /* eslint-disable no-continue */
+    if (!parent) continue;
+    if (!parent.children) parent.children = [];
+    parent.children.push(item);
   }
-  return result
-}
+  return result;
+};
 
-let DICT_FIXED = (function () {
-  let fixed = []
-  for (let id in DICT) {
+const DICT_FIXED = (function () {
+  const fixed = [];
+  for (const id in DICT) {
     if ({}.hasOwnProperty.call(DICT, id)) {
-      let pid
+      let pid;
       if (id.slice(2, 6) !== '0000') {
-        if (id.slice(4,6) === '00') {
+        if (id.slice(4, 6) === '00') {
           pid = `${id.slice(0, 2)}0000`;
         } else {
-          continue; //去掉三级市区
+          /* eslint-disable no-continue */
+          continue; // 去掉三级市区
         }
       }
       fixed.push({
@@ -4066,12 +4071,12 @@ let DICT_FIXED = (function () {
         name: DICT[id],
         value: DICT[id],
         label: DICT[id],
-      })
+      });
     }
   }
-  return tree(fixed)
-}())
+  return tree(fixed);
+}());
 
 module.exports = {
   DICT_FIXED,
-}
+};

+ 3 - 3
src/components/RBCityCascader/index.js

@@ -1,7 +1,7 @@
 import React, { PureComponent } from 'react';
 import PropTypes from 'prop-types';
 import { Cascader } from 'antd';
-import { DICT_FIXED} from './city';
+import { DICT_FIXED } from './city';
 import styles from './index.less';
 
 class RBCityCascader extends PureComponent {
@@ -9,7 +9,7 @@ class RBCityCascader extends PureComponent {
     placeholder: PropTypes.string,
   };
   static defaultProps = {
-    placeholder: '请选择省市'
+    placeholder: '请选择省市',
   };
   handleOnChange = (value) => {
     this.props.onChange(value);
@@ -21,7 +21,7 @@ class RBCityCascader extends PureComponent {
         allowClear
         value={value}
         popupClassName={styles.cascader}
-        expandTrigger={'hover'}
+        expandTrigger="hover"
         options={DICT_FIXED}
         placeholder={placeholder}
         onChange={this.handleOnChange}

+ 2 - 2
src/components/RBItem/PictureItem.less

@@ -45,13 +45,13 @@
     max-height: 100%;
     max-width: 100%;
     vertical-align: middle;
-    heigth: auto;
+    height: auto;
   }
 }
 
 .metaData {
   position: absolute;
-  bottom: 0px;
+  bottom: 0;
   overflow: hidden;
   padding: 0 4px;
   width: 100%;

+ 31 - 30
src/components/RBList/StandardTableList.js

@@ -1,5 +1,5 @@
 import React, { PureComponent, Fragment } from 'react';
-import { Alert, Table, Select, Input, Button, Checkbox, Pagination } from 'antd';
+import { Alert, Table, Select, Input, Button, Pagination } from 'antd';
 import PropTypes from 'prop-types';
 import Authorized from '../../utils/Authorized';
 import styles from './StandardTableList.less';
@@ -33,6 +33,7 @@ export default class StandardTableList extends PureComponent {
       PropTypes.bool,
     ]),
     showStatusSelect: PropTypes.bool,
+    keepUIState: PropTypes.object,
   }
   constructor(props) {
     super(props);
@@ -75,17 +76,17 @@ export default class StandardTableList extends PureComponent {
         <div className={styles.headerSearch}>
           <div className={styles.basicSearch}>
             <div className={styles.left}>
-              {showStatusSelect &&
-                <Select
-                  onChange={this.handleStatusChange}
-                  value={this.state.selectedStatusKey}
-                  style={{ width: '20%', marginRight: 10 }}
-                >
-                  <Select.Option key="all" value="ALL">全部状态</Select.Option>
-                  <Select.Option key="normal" value="NORMAL">正常</Select.Option>
-                  <Select.Option key="delete" value="DEL">已删除</Select.Option>
-                </Select>
-              }
+              {showStatusSelect && (
+              <Select
+                onChange={this.handleStatusChange}
+                value={this.state.selectedStatusKey}
+                style={{ width: '20%', marginRight: 10 }}
+              >
+                <Select.Option key="all" value="ALL">全部状态</Select.Option>
+                <Select.Option key="normal" value="NORMAL">正常</Select.Option>
+                <Select.Option key="delete" value="DEL">已删除</Select.Option>
+              </Select>
+)}
               <Input.Search
                 value={this.state.searchInputValue}
                 style={{ width: '75%' }}
@@ -111,26 +112,26 @@ export default class StandardTableList extends PureComponent {
               />
             </div>
             <div className={styles.right}>
-              {onAdvanceFilterClick &&
-                <a
-                  className={styles.searchLevel}
-                  onClick={onAdvanceFilterClick}
-                >高级筛选
-                </a>
-              }
+              {onAdvanceFilterClick && (
+              <a
+                className={styles.searchLevel}
+                onClick={onAdvanceFilterClick}
+              >高级筛选
+              </a>
+)}
               <Button icon="sync" onClick={this.handleRefreshBtnClick}>刷新</Button>
               {/* noCreate 参数控制是否显示新建按钮 */}
-              {onCreateClick !== undefined &&
-                <Authorized authority="root" noMatch={null}>
-                  <Button
-                    icon="plus"
-                    type="primary"
-                    style={{ marginLeft: 5 }}
-                    onClick={onCreateClick}
-                  >新建
-                  </Button>
-                </Authorized>
-              }
+              {onCreateClick !== undefined && (
+              <Authorized authority="root" noMatch={null}>
+                <Button
+                  icon="plus"
+                  type="primary"
+                  style={{ marginLeft: 5 }}
+                  onClick={onCreateClick}
+                >新建
+                </Button>
+              </Authorized>
+)}
             </div>
           </div>
         </div>

+ 4 - 7
src/components/RBRemoteSelect/index.js

@@ -1,17 +1,14 @@
 import React, { PureComponent } from 'react';
 import PropTypes from 'prop-types';
 import { Select, Spin } from 'antd';
-import styles from './index.less';
 
 export default class RBRemoteSelect extends PureComponent {
   static defaultProps = {
-    dataSource: [],
     placeholder: '请输入检索内容进行选择',
   };
   static propTypes = {
     dataSource: PropTypes.array.isRequired,
     placeholder: PropTypes.string,
-    onFocus: PropTypes.func,
   };
   handleOnChange = (value) => {
     if (this.props.onChange) {
@@ -22,8 +19,8 @@ export default class RBRemoteSelect extends PureComponent {
   handleOnSearch = (value) => {
     const eventTimeStamp = new Date().getTime();
     this.lastTimeStamp = eventTimeStamp;
-    //800ms后比较时间时间戳与上次事件的时间戳是否相等
-    //相等说明800ms未进行赋值,则触发搜索; 不相等说明还在继续输入,不触发搜索
+    // 800ms后比较时间时间戳与上次事件的时间戳是否相等
+    // 相等说明800ms未进行赋值,则触发搜索; 不相等说明还在继续输入,不触发搜索
     setTimeout(() => {
       if (this.lastTimeStamp === eventTimeStamp) {
         this.props.onSearch(value);
@@ -32,7 +29,7 @@ export default class RBRemoteSelect extends PureComponent {
     }, 800);
   }
   render() {
-    const { value, dataSource, placeholder, onSearch, fetching } = this.props;
+    const { value, dataSource, placeholder, fetching } = this.props;
     return (
       <div>
         <Select
@@ -46,7 +43,7 @@ export default class RBRemoteSelect extends PureComponent {
         >
           {
             dataSource.map(
-              (option) => (
+              option => (
                 <Select.Option
                   key={option.value}
                   value={option.value}

+ 0 - 0
src/components/RBRemoteSelect/index.less


+ 52 - 52
src/components/RBSelectTable/RBSingleSelectTable.js

@@ -20,15 +20,6 @@ const options = [{
 }];
 
 export default class RBSingleSelectTable extends PureComponent {
-  constructor(props) {
-    super(props);
-    this.state = {
-      selectRowKey: props.value,
-      searchSelectKey: 'code',
-      searchInputValue: '',
-      selectRowName: props.currentName,
-    };
-  }
   static propTypes = {
     dataSource: PropTypes.array,
     loading: PropTypes.bool,
@@ -41,50 +32,24 @@ export default class RBSingleSelectTable extends PureComponent {
     columns: [],
     pagination: {},
   };
+  constructor(props) {
+    super(props);
+    this.state = {
+      selectRowKey: props.value,
+      searchSelectKey: 'code',
+      searchInputValue: '',
+      selectRowName: props.currentName,
+    };
+  }
   componentWillReceiveProps(nextProps) {
-    let stateProps = {};
+    const stateProps = {};
     if (nextProps.value && (nextProps.value !== this.props.value)) {
       stateProps.selectRowKey = nextProps.value;
     }
     if (nextProps.currentName && (nextProps.currentName !== this.props.currentName)) {
       stateProps.selectRowName = nextProps.currentName;
     }
-    this.setState({...stateProps});
-  }
-  handleSelectChange = (value) => {
-    this.setState({ searchSelectKey: value });
-  }
-  handleInputChange = (e) => {
-    this.setState({ searchInputValue: e.target.value });
-  }
-  handleFilterOperation = (kv) => {
-    const { searchSelectKey, searchInputValue } = this.state;
-    this.props.onFilterClick({
-      [searchSelectKey]: searchInputValue,
-      ...kv,
-    });
-  }
-  handleOnRowClick = (record) => {
-    this.setState({
-      selectRowKey: record.key,
-      selectRowName: record.name,
-    });
-    if (this.props.onChange) {
-      this.props.onChange(record.key);
-    }
-  }
-  handleSearchBtnClick = () => {
-    this.handleFilterOperation();
-  }
-  handleTableChange = (pagination) => {
-    const { current } = pagination;
-    this.handleFilterOperation({ pageNo: current });
-  }
-  handleListPageChange = (page, pageSize) => {
-    this.handleFilterOperation({
-      pageSize,
-      pageNo: page,
-    });
+    this.setState({ ...stateProps });
   }
   getListHeader = () => {
     const { pagination } = this.props;
@@ -93,7 +58,7 @@ export default class RBSingleSelectTable extends PureComponent {
       pageSize: pagination.pageSize,
       total: pagination.totalSize,
       onChange: this.handleListPageChange,
-      showTotal: (total) => `共 ${total} 条`,
+      showTotal: total => `共 ${total} 条`,
     };
     return (
       <div className={styles.header}>
@@ -152,11 +117,46 @@ export default class RBSingleSelectTable extends PureComponent {
       </span>
     );
   }
+  handleSelectChange = (value) => {
+    this.setState({ searchSelectKey: value });
+  }
+  handleInputChange = (e) => {
+    this.setState({ searchInputValue: e.target.value });
+  }
+  handleFilterOperation = (kv) => {
+    const { searchSelectKey, searchInputValue } = this.state;
+    this.props.onFilterClick({
+      [searchSelectKey]: searchInputValue,
+      ...kv,
+    });
+  }
+  handleOnRowClick = (record) => {
+    this.setState({
+      selectRowKey: record.key,
+      selectRowName: record.name,
+    });
+    if (this.props.onChange) {
+      this.props.onChange(record.key);
+    }
+  }
+  handleSearchBtnClick = () => {
+    this.handleFilterOperation();
+  }
+  handleTableChange = (pagination) => {
+    const { current } = pagination;
+    this.handleFilterOperation({ pageNo: current });
+  }
+  handleListPageChange = (page, pageSize) => {
+    this.handleFilterOperation({
+      pageSize,
+      pageNo: page,
+    });
+  }
 
   render() {
     const { columns, dataSource, loading } = this.props;
-    const addColumnOnFirst = (columns) => {
-      const newColumns = [...columns];
+    const addColumnOnFirst = (cols) => {
+      const newColumns = [...cols];
       newColumns.unshift({
         key: '-1',
         dataIndex: 'key',
@@ -168,15 +168,15 @@ export default class RBSingleSelectTable extends PureComponent {
               checked={this.state.selectRowKey === text}
             />
           );
-        }
+        },
       });
       return newColumns;
-    }
+    };
     const onRowClick = (record) => {
       return {
         onClick: () => this.handleOnRowClick(record),
       };
-    }
+    };
     return (
       <Table
         bordered={false}

+ 25 - 26
src/components/RBVideoPlayer/index.js

@@ -5,57 +5,57 @@ import styles from './index.less';
 
 export default class RBVideoPlayer extends PureComponent {
   static propTypes = {
-    url : PropTypes.string.isRequired,
-    autoplay : PropTypes.bool,
-    hlsConfig : PropTypes.object, //https://github.com/dailymotion/hls.js/blob/master/API.md#fine-tuning
-    controls : PropTypes.bool,
-    width : PropTypes.oneOfType([
+    url: PropTypes.string.isRequired,
+    autoplay: PropTypes.bool,
+    hlsConfig: PropTypes.object, // https://github.com/dailymotion/hls.js/blob/master/API.md#fine-tuning
+    controls: PropTypes.bool,
+    width: PropTypes.oneOfType([
       PropTypes.number,
       PropTypes.string,
     ]),
-    height : PropTypes.oneOfType([
+    height: PropTypes.oneOfType([
       PropTypes.number,
       PropTypes.string,
     ]),
-    poster : PropTypes.string,
-    videoProps : PropTypes.object,
+    poster: PropTypes.string,
+    videoProps: PropTypes.object,
   };
   static defaultProps = {
-    autoplay : false,
-    hlsConfig : {},
-    controls : true,
-    width : 500,
-    height : 375,
+    autoplay: false,
+    hlsConfig: {},
+    controls: true,
+    width: 500,
+    height: 375,
   };
-  constructor (props) {
+  constructor(props) {
     super(props);
     this.state = {
-      playerId : Date.now()
+      playerId: Date.now(),
     };
     this.hls = null;
   }
-  componentDidUpdate () {
+  componentDidUpdate() {
     if (this.props.isM3U8) {
       this._initPlayer();
     }
   }
-  componentDidMount () {
+  componentDidMount() {
     if (this.props.isM3U8) {
       this._initPlayer();
     }
   }
-  componentWillUnmount () {
+  componentWillUnmount() {
     if (this.hls) {
       this.hls.destroy();
     }
   }
-  _initPlayer () {
+  _initPlayer() {
     if (this.hls) {
       this.hls.destroy();
     }
-    let { url, autoplay, hlsConfig } = this.props;
-    let { video : $video } = this.refs;
-    let hls = new Hls(hlsConfig);
+    const { url, autoplay, hlsConfig } = this.props;
+    const { video: $video } = this.refs;
+    const hls = new Hls(hlsConfig);
     hls.loadSource(url);
     hls.attachMedia($video);
     hls.on(Hls.Events.MANIFEST_PARSED, () => {
@@ -66,8 +66,8 @@ export default class RBVideoPlayer extends PureComponent {
     this.hls = hls;
   }
 
-  render () {
-    let { playerId } = this.state;
+  render() {
+    const { playerId } = this.state;
     const { url, controls, width, height, poster, videoProps } = this.props;
 
     return (
@@ -82,8 +82,7 @@ export default class RBVideoPlayer extends PureComponent {
           src={url}
           poster={poster}
           {...videoProps}
-        >
-        </video>
+        />
       </div>
     );
   }

+ 2 - 2
src/models/campus.js

@@ -43,7 +43,7 @@ export default {
           type: 'querySuccess',
           payload: {
             currentItem: response.data || {},
-          }
+          },
         });
       }
     },
@@ -91,6 +91,6 @@ export default {
         ...state,
         currentItem: {},
       };
-    }
+    },
   },
 };

+ 3 - 3
src/models/merchant.js

@@ -44,7 +44,7 @@ export default {
           type: 'querySuccess',
           payload: {
             currentItem: response.data || {},
-          }
+          },
         });
       }
     },
@@ -87,7 +87,7 @@ export default {
           state: states,
         }));
       }
-    }
+    },
   },
 
   reducers: {
@@ -102,6 +102,6 @@ export default {
         ...state,
         currentItem: {},
       };
-    }
+    },
   },
 };

+ 1 - 1
src/models/resource.js

@@ -60,7 +60,7 @@ export default {
       if (response && response.success) {
         message.success('删除成功');
       }
-    }
+    },
   },
 
   reducers: {

+ 1 - 1
src/routes/Campus/Campus.js

@@ -7,7 +7,7 @@ import { getRoutes } from '../../utils/utils';
 @connect()
 export default class Campus extends Component {
   render() {
-    const { match, routerData, location } = this.props;
+    const { match, routerData } = this.props;
     const routes = getRoutes(match.path, routerData);
 
     return (

+ 16 - 32
src/routes/Campus/CampusCreate.js

@@ -1,6 +1,6 @@
 import React, { PureComponent } from 'react';
 import pathToRegexp from 'path-to-regexp';
-import { Card, Row, Col, Form, Input, Button, Switch, Popover, Icon } from 'antd';
+import { Card, Row, Col, Form, Input, Button, Popover, Icon } from 'antd';
 import { connect } from 'dva';
 import { routerRedux } from 'dva/router';
 import RBCityCascader from '../../components/RBCityCascader';
@@ -24,43 +24,26 @@ const fieldLabels = {
   depositBank: '开户行',
   bankAccount: '银行账户',
 };
-const formItemLayout = {
-  labelCol: {
-    xs: { span: 24 },
-    sm: { span: 2 },
-  },
-  wrapperCol: {
-    xs: { span: 24 },
-    sm: { span: 14 },
-    md: { span: 10 },
-  },
-};
-const submitFormLayout = {
-  wrapperCol: {
-    xs: { span: 24, offset: 0 },
-    sm: { span: 12, offset: 6 },
-  },
-};
 
 @Form.create()
-@connect(({loading, merchant, campus}) => ({
+@connect(({ loading, merchant, campus }) => ({
   campus,
   merchant,
   loading: loading.models.merchant,
 }))
 export default class CampusCreatePage extends PureComponent {
   componentDidMount() {
-    //加载商户列表
+    // 加载商户列表
     this.props.dispatch({
       type: 'merchant/fetchMerchantList',
       payload: {},
     });
-    //如果是编辑校区,加载校区详情
+    // 如果是编辑校区,加载校区详情
     const matchId = this.isEdit();
     if (matchId) {
       this.props.dispatch({
         type: 'campus/fetchCampusItem',
-        payload: {id: matchId},
+        payload: { id: matchId },
       });
     }
   }
@@ -88,8 +71,9 @@ export default class CampusCreatePage extends PureComponent {
     this.props.form.validateFieldsAndScroll((error, values) => {
       if (!error) {
         const { cityName, ...restProps } = values;
-        restProps.provinceCode = provinceNameToCode(cityName[0]);
-        restProps.cityName = cityName[1];
+        const [province, city] = cityName;
+        restProps.provinceCode = provinceNameToCode(province);
+        restProps.cityName = city;
         const matchId = this.isEdit();
         if (matchId) {
           restProps.id = matchId;
@@ -139,25 +123,25 @@ export default class CampusCreatePage extends PureComponent {
       title: '商户类型',
       key: 3,
       dataIndex: 'domain',
-      render: (text) => renderCategory(text),
+      render: text => renderCategory(text),
     }, {
       title: '该条状态',
       key: 4,
       dataIndex: 'status',
-      render: (text) => renderStatus(text),
+      render: text => renderStatus(text),
     }];
 
     const renderCityName = () => {
       const { provinceCode, cityName } = currentItem;
       if (!provinceCode && !cityName) {
-        return;
+
       } else {
         return [
           provinceCodeToName(provinceCode),
           cityName,
         ];
       }
-    }
+    };
 
     const errors = getFieldsError();
     const getErrorInfo = () => {
@@ -201,7 +185,7 @@ export default class CampusCreatePage extends PureComponent {
 
     return (
       <div>
-        <Card title={fieldLabels.merchant} {...cardProps} style={{marginBottom: 16}}>
+        <Card title={fieldLabels.merchant} {...cardProps} style={{ marginBottom: 16 }}>
           <Form>
             <Form.Item className={styles.firstFormItem}>
               {getFieldDecorator('merchantId', {
@@ -220,7 +204,7 @@ export default class CampusCreatePage extends PureComponent {
             </Form.Item>
           </Form>
         </Card>
-        <Card title="基本信息" {...cardProps} style={{marginBottom: 70}}>
+        <Card title="基本信息" {...cardProps} style={{ marginBottom: 70 }}>
           <Form>
             <Row gutter={16}>
               <Col lg={8} md={12} sm={24}>
@@ -302,9 +286,9 @@ export default class CampusCreatePage extends PureComponent {
             </Row>
           </Form>
         </Card>
-        <FooterToolbar style={{width: '100%'}}>
+        <FooterToolbar style={{ width: '100%' }}>
           {getErrorInfo()}
-          <Button onClick={this.handlePageBack} style={{marginRight: 10}}>
+          <Button onClick={this.handlePageBack} style={{ marginRight: 10 }}>
             取消
           </Button>
           <Button type="primary" onClick={this.handlePageSubmit}>

+ 29 - 27
src/routes/Campus/CampusList.js

@@ -1,11 +1,11 @@
-import React, { Component, Fragment } from 'react';
+import React, { Component } from 'react';
 import moment from 'moment';
 import { connect } from 'dva';
 import { routerRedux } from 'dva/router';
 import { Card, Modal, Form, Button, message } from 'antd';
 import { StandardTableList } from '../../components/RBList';
 import RBRemoteSelect from '../../components/RBRemoteSelect';
-import { renderCategory, addRowKey } from '../../utils/utils';
+import { addRowKey } from '../../utils/utils';
 import styles from './CampusList.less';
 
 const Message = message;
@@ -31,7 +31,7 @@ function merchantDataFormatter(data) {
 }
 
 @Form.create()
-@connect(({loading, campus, merchant}) => ({
+@connect(({ loading, campus, merchant }) => ({
   campus,
   merchant,
   fetching: loading.models.merchant,
@@ -50,7 +50,7 @@ export default class CampusListPage extends Component {
   componentDidMount() {
     this.props.dispatch({
       type: 'campus/fetchCampusList',
-      payload: {...this.state.Queryers},
+      payload: { ...this.state.Queryers },
     });
   }
   handleCreateOperation = () => {
@@ -122,7 +122,7 @@ export default class CampusListPage extends Component {
           </Button>
         </div>
       );
-    }
+    };
     const batchActions = [{
       key: 'delete',
       name: '批量删除',
@@ -149,7 +149,8 @@ export default class CampusListPage extends Component {
       key: 1,
       dataIndex: 'code',
       render: (text, record) => (
-        <a className={styles.link}
+        <a
+          className={styles.link}
           onClick={() => this.handleEditOperation(record)}
         >
           {text}
@@ -161,7 +162,8 @@ export default class CampusListPage extends Component {
       key: 2,
       dataIndex: 'name',
       render: (text, record) => (
-        <a className={styles.link}
+        <a
+          className={styles.link}
           onClick={() => this.handleEditOperation(record)}
         >
           {text}
@@ -187,7 +189,7 @@ export default class CampusListPage extends Component {
       title: '更新时间',
       key: 6,
       dataIndex: 'gmtModified',
-      render: (text) => moment(text).format('YYYY-MM-DD HH:mm:ss'),
+      render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
       width: '16%',
     }, {
       title: '操作',
@@ -213,23 +215,23 @@ export default class CampusListPage extends Component {
             batchActions,
             onBatchClick: this.handleBatchOperation,
           }}
-          keepUIState={{...this.state.UIParams}}
+          keepUIState={{ ...this.state.UIParams }}
           showStatusSelect={false}
         />
-        {!this.state.filterModalDestory &&
-          <Modal
-            width={600}
-            visible={true}
-            title="高级筛选"
-            okText="筛选"
-            cancelText="取消"
-            maskClosable={false}
-            onCancel={this.handleFilterModalDestory}
-            onOk={this.handleModalFilterOperation}
-          >
-            <Form>
-              <Form.Item label="所属商户" {...formItemLayout}>
-                {getFieldDecorator('merchantId', {
+        {!this.state.filterModalDestory && (
+        <Modal
+          width={600}
+          visible
+          title="高级筛选"
+          okText="筛选"
+          cancelText="取消"
+          maskClosable={false}
+          onCancel={this.handleFilterModalDestory}
+          onOk={this.handleModalFilterOperation}
+        >
+          <Form>
+            <Form.Item label="所属商户" {...formItemLayout}>
+              {getFieldDecorator('merchantId', {
                   initialValue: [],
                 })(
                   <RBRemoteSelect
@@ -238,10 +240,10 @@ export default class CampusListPage extends Component {
                     onSearch={this.handleRemoteSelectSearch}
                   />
                 )}
-              </Form.Item>
-            </Form>
-          </Modal>
-        }
+            </Form.Item>
+          </Form>
+        </Modal>
+)}
       </Card>
     );
   }

+ 1 - 1
src/routes/Merchant/Merchant.js

@@ -7,7 +7,7 @@ import { getRoutes } from '../../utils/utils';
 @connect()
 export default class Merchant extends Component {
   render() {
-    const { match, routerData, location } = this.props;
+    const { match, routerData } = this.props;
     const routes = getRoutes(match.path, routerData);
 
     return (

+ 6 - 6
src/routes/Merchant/MerchantCreate.js

@@ -60,14 +60,14 @@ const submitFormLayout = {
 };
 
 @Form.create()
-@connect(({loading, merchant}) => ({
+@connect(({ loading, merchant }) => ({
   merchant,
   submitting: loading.models.merchant,
 }))
 export default class MerchantCreatePage extends PureComponent {
   componentWillMount() {
-    //如果是添加商户操作,进入此页面时把state清一下
-    const { location, dispatch } = this.props;
+    // 如果是添加商户操作,进入此页面时把state清一下
+    const { location } = this.props;
     const match = pathToRegexp('/merchant/create').exec(location.pathname);
     if (match) {
       this.cleanPageState();
@@ -78,12 +78,12 @@ export default class MerchantCreatePage extends PureComponent {
     if (matchId) {
       this.props.dispatch({
         type: 'merchant/fetchMerchantItem',
-        payload: {id: matchId},
+        payload: { id: matchId },
       });
     }
   }
   isEdit = () => {
-    //根据路径判断操作类型并决定是否需加载该条目信息<create/edit>
+    // 根据路径判断操作类型并决定是否需加载该条目信息<create/edit>
     const { location } = this.props;
     const match = pathToRegexp('/merchant/edit/:id').exec(location.pathname);
     if (match) {
@@ -145,7 +145,7 @@ export default class MerchantCreatePage extends PureComponent {
       } else {
         return true;
       }
-    }
+    };
 
     return (
       <Card>

+ 2 - 2
src/routes/Merchant/MerchantDespoit.js

@@ -31,7 +31,7 @@ const submitFormLayout = {
 };
 
 @Form.create()
-@connect(({loading, merchant}) => ({
+@connect(({ loading, merchant }) => ({
   merchant,
   submitting: loading.models.merchant,
 }))
@@ -80,7 +80,7 @@ export default class MerchantDespoitPage extends PureComponent {
                   required: true, type: 'string', message: '充值金额不能为空!',
                 }, {
                   pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/, message: '充值金额格式错误!',
-                }
+                },
               ],
             })(
               <Input placeholder="请输入充值金额" addonAfter="元" />

+ 12 - 10
src/routes/Merchant/MerchantList.js

@@ -10,7 +10,7 @@ import styles from './MerchantList.less';
 
 const Message = message;
 
-@connect(({loading, merchant}) => ({
+@connect(({ loading, merchant }) => ({
   merchant,
   loading: loading.models.merchant,
 }))
@@ -26,7 +26,7 @@ export default class MerchantListPage extends Component {
   componentDidMount() {
     this.props.dispatch({
       type: 'merchant/fetchMerchantList',
-      payload: {...this.state.Queryers},
+      payload: { ...this.state.Queryers },
     });
   }
   handleCreateOperation = () => {
@@ -68,7 +68,7 @@ export default class MerchantListPage extends Component {
   handleDespoitOperation = (item) => {
     this.props.dispatch(routerRedux.push({
       pathname: `/merchant/despoit/${item.id}`,
-      state: {...this.state, currentItem: item},
+      state: { ...this.state, currentItem: item },
     }));
   }
   handleBatchOperation = () => {
@@ -104,7 +104,7 @@ export default class MerchantListPage extends Component {
           </Button>
         </div>
       );
-    }
+    };
 
     const batchActions = [{
       key: 'delete',
@@ -132,7 +132,8 @@ export default class MerchantListPage extends Component {
       key: 1,
       dataIndex: 'code',
       render: (text, record) => (
-        <a className={styles.link}
+        <a
+          className={styles.link}
           onClick={() => this.handleEditOperation(record)}
         >
           {text}
@@ -144,7 +145,8 @@ export default class MerchantListPage extends Component {
       key: 2,
       dataIndex: 'name',
       render: (text, record) => (
-        <a className={styles.link}
+        <a
+          className={styles.link}
           onClick={() => this.handleEditOperation(record)}
         >
           {text}
@@ -155,7 +157,7 @@ export default class MerchantListPage extends Component {
       title: '商户类型',
       key: 3,
       dataIndex: 'domain',
-      render: (text) => renderCategory(text),
+      render: text => renderCategory(text),
       width: '11%',
     }, {
       title: '账户余额(¥)',
@@ -166,13 +168,13 @@ export default class MerchantListPage extends Component {
       title: '状态',
       key: 5,
       dataIndex: 'status',
-      render: (text) => renderStatus(text),
+      render: text => renderStatus(text),
       width: '11%',
     }, {
       title: '更新时间',
       key: 6,
       dataIndex: 'gmtModified',
-      render: (text) => moment(text).format('YYYY-MM-DD HH:mm:ss'),
+      render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
       width: '20%',
     }, {
       title: '操作',
@@ -197,7 +199,7 @@ export default class MerchantListPage extends Component {
             batchActions,
             onBatchClick: this.handleBatchOperation,
           }}
-          keepUIState={{...this.state.UIParams}}
+          keepUIState={{ ...this.state.UIParams }}
         />
       </Card>
     );

+ 2 - 2
src/routes/Resource/PictureCardList.js

@@ -44,8 +44,8 @@ function PictureCardList({
       component={PictureItem}
       keepUIState={{ ...UIParams }}
       dataSource={pictureItemFormatter(dataSource)}
-      header={{basicSearch, onFilterClick, onCreateClick}}
-      footer={{pagination, batchActions, onBatchClick}}
+      header={{ basicSearch, onFilterClick, onCreateClick }}
+      footer={{ pagination, batchActions, onBatchClick }}
       grid={{ gutter: 16, xxl: 12, xl: 6, lg: 4, md: 3, sm: 2, xs: 1 }}
       onDelete={onDeleteClick}
     />

+ 4 - 4
src/routes/Resource/PictureCreateMultiple.js

@@ -58,10 +58,10 @@ export default class CreateMultiplePicture extends PureComponent {
         url: file.url,
         status: 'NORMAL',
       }));
-      // this.props.dispatch({
-      //   payload,
-      //   type: 'resource/createImage',
-      // });
+      this.props.dispatch({
+        payload,
+        type: 'resource/createImage',
+      });
     } else {
       Message.error('还有图片编号或名称未指定!');
     }

+ 1 - 6
src/routes/Resource/PictureCreateSingle.js

@@ -26,12 +26,7 @@ export default class CreateOnePicture extends PureComponent {
     return fileList;
   }
   handlePageBack = () => {
-    let UIParams = {};
-    let Queryers = {};
-    if (this.props.location.state) {
-      UIParams = this.props.location.state.UIParams; //no-eslint-disable
-      Queryers = this.props.location.state.Queryers; //no-eslint-disable
-    }
+    const { UIParams, Queryers } = this.props.location.state || {};
     this.props.dispatch(
       routerRedux.push({
         pathname: '/resource/image',

+ 4 - 4
src/routes/Resource/PictureList.js

@@ -28,7 +28,7 @@ export default class PictureListPage extends Component {
     });
   }
   handleShowTypeChange = () => {
-    this.setState({ isCard: !!!this.state.isCard });
+    this.setState({ isCard: !this.state.isCard });
   }
   // 增加
   handleCreateOperation = () => {
@@ -96,15 +96,15 @@ export default class PictureListPage extends Component {
     };
     return (
       <Card bordered={false}>
-        <Button.Group style={{marginBottom: 16}}>
+        <Button.Group style={{ marginBottom: 16 }}>
           <Button
-            style={{width: 50}}
+            style={{ width: 50 }}
             onClick={this.handleShowTypeChange}
             icon="appstore-o"
             type={this.state.isCard ? 'primary' : null}
           />
           <Button
-            style={{width: 50}}
+            style={{ width: 50 }}
             onClick={this.handleShowTypeChange}
             icon="table"
             type={this.state.isCard ? null : 'primary'}

+ 4 - 4
src/routes/Resource/PictureTableList.js

@@ -1,6 +1,6 @@
 import React from 'react';
 import moment from 'moment';
-import { Divider, message } from 'antd';
+import { Divider } from 'antd';
 import { ossHost } from '../../utils/config';
 import { renderStatus, addRowKey } from '../../utils/utils';
 import { StandardTableList } from '../../components/RBList';
@@ -104,9 +104,9 @@ function PictureTableList({
       columns={columns}
       loading={loading}
       dataSource={addRowKey(dataSource)}
-      keepUIState={{...UIParams}}
-      header={{basicSearch, onFilterClick, onCreateClick}}
-      footer={{pagination, batchActions, onBatchClick}}
+      keepUIState={{ ...UIParams }}
+      header={{ basicSearch, onFilterClick, onCreateClick }}
+      footer={{ pagination, batchActions, onBatchClick }}
     />
   );
 }

+ 1 - 1
src/routes/Resource/PictureTableList.less

@@ -11,7 +11,7 @@
     max-height: 100%;
     max-width: 100%;
     vertical-align: middle;
-    heigth: auto;
+    height: auto;
   }
 }
 

+ 17 - 17
src/routes/Resource/VideoList.js

@@ -1,7 +1,6 @@
 import React, { Component } from 'react';
 import { connect } from 'dva';
 import { Card, Button, message } from 'antd';
-import RBVideoPlayer from '../../components/RBVideoPlayer';
 import VideoPlayList from './VideoPlayList';
 import VideoTableList from './VideoTableList';
 import { addRowKey } from '../../utils/utils';
@@ -12,8 +11,8 @@ function deleteBlankKey(obj) {
   if (!(typeof obj === 'object')) {
     return;
   }
-  let newObj = {...obj};
-  for (let key in newObj) {
+  const newObj = { ...obj };
+  for (const key in newObj) {
     if (newObj.hasOwnProperty(key) && !newObj[key]) {
       delete newObj[key];
     }
@@ -32,7 +31,7 @@ export default class VideoListPage extends Component {
       isCard: true,
       destory: true,
       current: {},
-    }
+    };
   }
   componentDidMount() {
     this.props.dispatch({
@@ -41,7 +40,7 @@ export default class VideoListPage extends Component {
     });
   }
   handleShowTypeChange = () => {
-    this.setState({ isCard: !!!this.state.isCard });
+    this.setState({ isCard: !this.state.isCard });
   }
   handleFilterOperation = (params) => {
     const newParams = deleteBlankKey(params);
@@ -73,30 +72,31 @@ export default class VideoListPage extends Component {
     };
     return (
       <Card bordered={false}>
-        <Button.Group style={{marginBottom: 16}}>
+        <Button.Group style={{ marginBottom: 16 }}>
           <Button
-            style={{width: 50}}
+            style={{ width: 50 }}
             onClick={this.handleShowTypeChange}
             icon="appstore-o"
             type={this.state.isCard ? 'primary' : null}
           />
           <Button
-            style={{width: 50}}
+            style={{ width: 50 }}
             onClick={this.handleShowTypeChange}
             icon="table"
             type={this.state.isCard ? null : 'primary'}
           />
         </Button.Group>
         {this.state.isCard ?
-          <VideoPlayList {...publicProps} /> :
-          <VideoTableList
-            {...publicProps}
-            currentItem={this.state.current}
-            modalDestory={this.state.destory}
-            onModalDestory={this.handleModalDestory}
-            onModalCreate={this.handleModalCreate}
-            onBatchClick={this.handleBatchOperation}
-          />
+          <VideoPlayList {...publicProps} /> : (
+            <VideoTableList
+              {...publicProps}
+              currentItem={this.state.current}
+              modalDestory={this.state.destory}
+              onModalDestory={this.handleModalDestory}
+              onModalCreate={this.handleModalCreate}
+              onBatchClick={this.handleBatchOperation}
+            />
+          )
         }
       </Card>
     );

+ 14 - 14
src/routes/Resource/VideoPlayList.js

@@ -67,19 +67,19 @@ export default class VideoPlayList extends PureComponent {
       return (
         <div className={styles.meta}>
           <p>
-            <span>{'编号:  '}</span>
+            <span>编号:  </span>
             <a>{`${data.code}`}</a>
           </p>
           <p>
-            <span>{'名称:  '}</span>
+            <span>名称:  </span>
             {`${data.name}`}
           </p>
           <p>
-            <span>{'格式:  '}</span>
+            <span>格式:  </span>
             {`${renderQuality(data.quality)}[${data.format}]`}
           </p>
           <p>
-            <span>{'时间:  '}</span>
+            <span>时间:  </span>
             {`${moment(data.gmtModified).format('YYYY-MM-DD HH:mm:ss')}`}
           </p>
         </div>
@@ -90,15 +90,15 @@ export default class VideoPlayList extends PureComponent {
         const videoItem = dataSource[this.state.currentPlayingIndex];
         return (
           <RBVideoPlayer
-            width={'100%'}
-            height={'100%'}
+            width="100%"
+            height="100%"
             url={videoItem.url}
-            isM3U8={videoItem.format === 'm3u8' ? true : false}
+            isM3U8={videoItem.format === 'm3u8'}
           />
         );
       }
       return null;
-    }
+    };
     const columns = [{
       title: '名称/编号/状态/格式/质量/日期',
       key: 1,
@@ -110,7 +110,7 @@ export default class VideoPlayList extends PureComponent {
       total: totalSize,
       current: pageNo,
       simple: true,
-      showTotal: (total) => `共 ${total} 条`,
+      showTotal: total => `共 ${total} 条`,
       onChange: this.handleTablePageChange,
       onShowSizeChange: this.handleTablePageSizeChange,
     };
@@ -125,7 +125,7 @@ export default class VideoPlayList extends PureComponent {
       return {
         onClick: () => this.handleOnRowClick(index),
       };
-    }
+    };
     const renderHeader = () => {
       return (
         <Input.Search
@@ -152,7 +152,7 @@ export default class VideoPlayList extends PureComponent {
           onSearch={this.handleSearchBtnClick}
         />
       );
-    }
+    };
     return (
       <div className={styles.content}>
         <div className={styles.left}>
@@ -163,10 +163,10 @@ export default class VideoPlayList extends PureComponent {
             columns={columns}
             pagination={false}
             onRow={onRowClick}
-            rowKey={(record) => record.key}
+            rowKey={record => record.key}
             className={styles.table}
-            rowClassName={(_,index) =>
-              index === this.state.currentPlayingIndex ? styles.rowChecked: null
+            rowClassName={(_, index) =>
+              (index === this.state.currentPlayingIndex ? styles.rowChecked : null)
             }
             loading={loading}
             dataSource={dataSource}

+ 22 - 22
src/routes/Resource/VideoTableList.js

@@ -57,19 +57,19 @@ function VideoTableList({
     title: '视频质量',
     key: 4,
     dataIndex: 'quality',
-    render: (text) => renderQuality(text),
+    render: text => renderQuality(text),
     width: '10%',
   }, {
     title: '视频状态',
     key: 5,
     dataIndex: 'status',
-    render: (text) => renderStatus(text),
+    render: text => renderStatus(text),
     width: '10%',
   }, {
     title: '创建时间',
     key: 6,
     dataIndex: 'gmtModified',
-    render: (text) => moment(text).format('YYYY-MM-DD'),
+    render: text => moment(text).format('YYYY-MM-DD'),
     width: '15%',
   }, {
     title: '操作',
@@ -84,26 +84,26 @@ function VideoTableList({
         columns={columns}
         loading={loading}
         dataSource={dataSource}
-        header={{basicSearch, onFilterClick }}
-        footer={{pagination, batchActions, onBatchClick}}
+        header={{ basicSearch, onFilterClick }}
+        footer={{ pagination, batchActions, onBatchClick }}
       />
-      {!modalDestory &&
-        <Modal
-          title={currentItem.name}
-          visible={true}
-          footer={null}
-          onCancel={onModalDestory}
-          maskClosable={false}
-          width={800}
-        >
-          <RBVideoPlayer
-            width={'100%'}
-            height={'100%'}
-            url={currentItem.url}
-            isM3U8={currentItem.format === 'm3u8' ? true : false}
-          />
-        </Modal>
-      }
+      {!modalDestory && (
+      <Modal
+        title={currentItem.name}
+        visible
+        footer={null}
+        onCancel={onModalDestory}
+        maskClosable={false}
+        width={800}
+      >
+        <RBVideoPlayer
+          width="100%"
+          height="100%"
+          url={currentItem.url}
+          isM3U8={currentItem.format === 'm3u8'}
+        />
+      </Modal>
+)}
     </div>
   );
 }

+ 3 - 3
src/routes/tableColumns.js

@@ -6,7 +6,7 @@ const MerchantColumns = [{
   title: '',
   key: 0,
   dataIndex: 'key',
-  render: (text) => <Radio key={text} />,
+  render: text => <Radio key={text} />,
   width: 20,
 }, {
   title: '商户编号',
@@ -20,12 +20,12 @@ const MerchantColumns = [{
   title: '商户类型',
   key: 3,
   dataIndex: 'domain',
-  render: (text) => renderCategory(text),
+  render: text => renderCategory(text),
 }, {
   title: '该条状态',
   key: 4,
   dataIndex: 'status',
-  render: (text) => renderStatus(text),
+  render: text => renderStatus(text),
 }];
 
 export {

+ 3 - 3
src/utils/utils.js

@@ -205,7 +205,7 @@ export function isUrl(path) {
 }
 
 export function addRowKey(data) {
-  return data.map(item => {
+  return data.map((item) => {
     item.key = item.id;
     return item;
   });
@@ -233,13 +233,13 @@ export function renderStatus(status) {
       <Badge status="error" text="删除" />
     );
   }
-};
+}
 export function toDecimal2(x) {
   let f = parseFloat(x);
   if (isNaN(f)) {
     return false;
   }
-  f = Math.round(x*100)/100;
+  f = Math.round(x * 100) / 100;
   let s = f.toString();
   let rs = s.indexOf('.');
   if (rs < 0) {