Bläddra i källkod

:twisted_rightwards_arrows: Merge branch 'dev_user_auth' of remote/dev_user_auth into dev_user_auth

zhanghe 6 år sedan
förälder
incheckning
bc53aeb699

+ 3 - 0
src/common/menu.js

@@ -137,6 +137,9 @@ const menuData = () => {
     }, {
       name: '白名单',
       path: 'whitelist',
+    }, {
+      name: '用户权限',
+      path: 'resource',
     }],
     authority: ['admin', 'platform', 'channel'],
   }, {

+ 6 - 0
src/common/router.js

@@ -182,6 +182,12 @@ export const getRouterData = (app) => {
     '/terminal/whitelist/edit/:id': {
       component: dynamicWrapper(app, ['terminal'], () => import('../routes/Terminal/WhiteList/WhiteListCreate')),
     },
+    '/terminal/resource': {
+      component: dynamicWrapper(app, ['terminal'], () => import('../routes/Terminal/Resource')),
+    },
+    '/terminal/resource/list': {
+      component: dynamicWrapper(app, ['terminal'], () => import('../routes/Terminal/Resource/ResourceList')),
+    },
     // 产品管理相关路由注册
     '/product/courseware': {
       component: dynamicWrapper(app, [], () => import('../routes/Product/Courseware')),

+ 16 - 1
src/models/terminal.js

@@ -11,6 +11,7 @@ import {
   createSpecialTerminalItem,
   updateSpecialTerminalItem,
   deleteSpecialTerminalItem,
+  queryTerminalResourceList,
 } from '../services/terminal';
 
 export default {
@@ -143,7 +144,21 @@ export default {
           payload: states.Queryers,
         });
       }
-    }
+    },
+    *fetchTerminalResourceList({ payload }, { call, put }) {
+      const response = yield call(queryTerminalResourceList, payload);
+      if (response.success) {
+        yield put({
+          type: 'querySuccess',
+          payload: {
+            list: response.data.list || [],
+            pageSize: response.data.pageSize,
+            totalSize: response.data.totalSize,
+            pageNo: response.data.pageNo,
+          },
+        });
+      }
+    },
   },
 
   reducers: {

+ 127 - 0
src/routes/Terminal/Resource/ResourceList.js

@@ -0,0 +1,127 @@
+/* eslint-disable prefer-destructuring */
+import React, { Component } from 'react';
+import moment from 'moment';
+import { connect } from 'dva';
+import { Card, message } from 'antd';
+import { StandardTableList } from '../../../components/AXList';
+import { addRowKey, renderStatus } from '../../../utils/utils';
+
+const Message = message;
+
+@connect(({ terminal, loading }) => ({
+  terminal,
+  loading: loading.models.terminal,
+}))
+
+export default class TerminalResourceListPage extends Component {
+  constructor(props) {
+    super(props);
+    const { state } = props.location;
+    this.state = {
+      UIParams: (state || {}).UIParams, // 组件的状态参数
+      Queryers: (state || {}).Queryers, // 查询的条件参数
+    };
+  }
+  componentDidMount() {
+    this.props.dispatch({
+      type: 'terminal/fetchTerminalResourceList',
+      payload: { ...this.state.Queryers },
+    });
+  }
+  handleFilterOperation = (params, states) => {
+    this.props.dispatch({
+      type: 'terminal/fetchTerminalResourceList',
+      payload: params,
+    });
+    this.setState({
+      UIParams: states,
+      Queryers: params,
+    });
+  }
+  handleBatchOperation = () => {
+    Message.info('暂不支持批量操作!');
+  }
+  render() {
+    const { terminal, loading } = this.props;
+    const { pageNo, pageSize, totalSize, list } = terminal;
+    const basicSearch = {
+      keys: [{
+        name: '终端编号',
+        field: 'code',
+      }],
+    };
+    const batchActions = [{
+      key: 'delete',
+      name: '批量删除',
+    }];
+    const pagination = {
+      pageNo,
+      pageSize,
+      totalSize,
+    };
+    const columns = [{
+      title: '终端编号',
+      key: 1,
+      dataIndex: 'ucode',
+      width: '12%',
+    }, {
+      title: '终端名称',
+      key: 2,
+      dataIndex: 'uname',
+      width: '12%',
+    }, {
+      title: '产品名称',
+      key: 3,
+      dataIndex: 'pname',
+      width: '22%',
+    }, {
+      title: '产品编号',
+      key: 4,
+      dataIndex: 'pcode',
+      width: '14%',
+    }, {
+      title: '开始时间',
+      key: 5,
+      dataIndex: 'startTime',
+      render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
+      width: '10%',
+    }, {
+      title: '终止时间',
+      key: 6,
+      dataIndex: 'startTime',
+      render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
+      width: '10%',
+    }, {
+      title: '修改时间',
+      key: 7,
+      dataIndex: 'updateTime',
+      render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
+      width: '10%',
+    }, {
+      title: '状态',
+      dataIndex: 'status',
+      key: 8,
+      render: text => renderStatus(text),
+      width: '10%',
+    }];
+    return (
+      <Card>
+        <StandardTableList
+          columns={columns}
+          loading={loading}
+          dataSource={addRowKey(list)}
+          header={{
+            basicSearch,
+            onFilterClick: this.handleFilterOperation,
+          }}
+          footer={{
+            pagination,
+            batchActions,
+            onBatchClick: this.handleBatchOperation,
+          }}
+          keepUIState={{ ...this.state.UIParams }}
+        />
+      </Card>
+    );
+  }
+}

+ 32 - 0
src/routes/Terminal/Resource/index.js

@@ -0,0 +1,32 @@
+import React, { Component } from 'react';
+import { Redirect, Route, Switch } from 'dva/router';
+import { connect } from 'dva';
+import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
+import { getRoutes } from '../../../utils/utils';
+
+@connect()
+export default class Index extends Component {
+  render() {
+    const { match, routerData } = this.props;
+    const routes = getRoutes(match.path, routerData);
+    return (
+      <PageHeaderLayout>
+        <Switch>
+          {
+            routes.map(item =>
+              (
+                <Route
+                  key={item.key}
+                  path={item.path}
+                  component={item.component}
+                  exact={item.exact}
+                />
+              )
+            )
+          }
+          <Redirect exact from="/terminal/resource" to="/terminal/resource/list" />
+        </Switch>
+      </PageHeaderLayout>
+    );
+  }
+}

+ 8 - 0
src/services/terminal.js

@@ -75,3 +75,11 @@ export async function deviceUnbound({ id }) {
   };
   return request(`${api.terminalUnbound}/${id}`, options);
 }
+
+export async function queryTerminalResourceList(params) {
+  const newParams = {
+    pageSize: Hotax.PAGE_SIZE,
+    ...params,
+  };
+  return request(`${api.terminalResourceList}?${stringify(newParams)}`);
+}

+ 2 - 1
src/utils/config.js

@@ -1,6 +1,6 @@
 /* eslint-disable spaced-comment */
 /********************* 1.项目常量定义 **********************/
-class Hotax {};
+class Hotax {}
 
 // 资源类型 <视频|音频|直播|图片>
 Hotax.RESOURCE_VIDEO = 0;
@@ -101,6 +101,7 @@ const apiObj = {
   terminal: '/user/list',
   terminalItem: '/user',
   terminalUnbound: '/device/unbind',
+  terminalResourceList: '/user/auth/list',
   specialTerminal: '/white/user/list',
   specialTerminalItem: '/white/user',
   cmsUser: '/cms/user/list',