1.订单管理页面和商品管理页面类似,都是一个搜索组件+列表组件

2.搜索框search组件

  1. import React from 'react';
  2.  
  3. class ListSearch extends React.Component{
  4.     constructor(props){
  5.         super(props);
  6.         this.state = {
  7.             orderNumber : ''
  8.         }
  9.     }
  10.     // 数据变化的时候
  11.     onValueChange(e){
  12.         let name = e.target.name,
  13.             value = e.target.value.trim();
  14.         this.setState({
  15.             [name] : value
  16.         });
  17.     }
  18.     // 点击搜索按钮的时候
  19.     onSearch(){
  20.         this.props.onSearch(this.state.orderNumber);
  21.     }
  22.     // 输入关键字后按回车,自动提交
  23.     onSearchKeywordKeyUp(e){
  24.         if(e.keyCode === 13){
  25.             this.onSearch();
  26.         }
  27.     }
  28.     render(){
  29.         return (
  30.             <div className="row search-wrap">
  31.                 <div className="col-md-12">
  32.                     <div className="form-inline">
  33.                         <div className="form-group">
  34.                             <select className="form-control">
  35.                                 <option value="">按订单号查询</option>
  36.                             </select>
  37.                         </div>
  38.                         <div className="form-group">
  39.                             <input type="text"
  40.                                 className="form-control"
  41.                                 placeholder="订单号"
  42.                                 name="orderNumber"
  43.                                 onKeyUp={(e) => this.onSearchKeywordKeyUp(e)}
  44.                                 onChange={(e) => this.onValueChange(e)}/>
  45.                         </div>
  46.                         <button className="btn btn-primary"
  47.                             onClick={(e) => this.onSearch()}>搜索</button>
  48.                     </div>
  49.                 </div>
  50.             </div>
  51.         )
  52.     }
  53. }
  54. export default ListSearch;

3.订单列表组件

  1. import React from 'react';
  2. import { Link } from 'react-router-dom';
  3. import MUtil from 'util/mm.jsx'
  4. import Order from 'service/order-service.jsx'
  5.  
  6. import PageTitle from 'component/page-title/index.jsx';
  7. import ListSearch from './index-list-search.jsx';
  8. import TableList from 'util/table-list/index.jsx';
  9. import Pagination from 'util/pagination/index.jsx';
  10.  
  11.  
  12. const _mm = new MUtil();
  13. const _order = new Order();
  14.  
  15. class OrderList extends React.Component{
  16.     constructor(props){
  17.         super(props);
  18.         this.state = {
  19.             list : [],
  20.             pageNum : 1,
  21.             listType : 'list' // list / search
  22.         };
  23.     }
  24.     componentDidMount(){
  25.         this.loadOrderList();
  26.     }
  27.     // 加载商品列表
  28.     loadOrderList(){
  29.         let listParam = {};
  30.         listParam.listType = this.state.listType;
  31.         listParam.pageNum = this.state.pageNum;
  32.         // 如果是搜索的话,需要传入搜索类型和搜索关键字
  33.         if(this.state.listType === 'search'){
  34.             listParam.orderNo = this.state.orderNumber;
  35.         }
  36.         // 请求接口
  37.         _order.getOrderList(listParam).then(res => {
  38.             this.setState(res);
  39.         }, errMsg => {
  40.             this.setState({
  41.                 list : []
  42.             });
  43.             _mm.errorTips(errMsg);
  44.         });
  45.     }
  46.     // 搜索
  47.     onSearch(orderNumber){
  48.         let listType = orderNumber === '' ? 'list' : 'search';
  49.         this.setState({
  50.             listType : listType,
  51.             pageNum : 1,
  52.             orderNumber : orderNumber
  53.         }, () => {
  54.             this.loadOrderList();
  55.         });
  56.     }
  57.     // 页数发生变化的时候
  58.     onPageNumChange(pageNum){
  59.         this.setState({
  60.             pageNum : pageNum
  61.         }, () => {
  62.             this.loadOrderList();
  63.         });
  64.     }
  65.     render(){
  66.         let tableHeads = ['订单号', '收件人', '订单状态', '订单总价', '创建时间', '操作'];
  67.         return (
  68.             <div id="page-wrapper">
  69.                 <PageTitle title="订单列表" />
  70.                 <ListSearch onSearch={(orderNumber) => {this.onSearch(orderNumber)}}/>
  71.                 <TableList tableHeads={tableHeads}>
  72.                     {
  73.                         this.state.list.map((order, index) => {
  74.                             return (
  75.                                 <tr key={index}>
  76.                                     <td>
  77.                                         <Link to={ `/order/detail/${order.orderNo}` }>{order.orderNo}</Link>
  78.                                     </td>
  79.                                     <td>{order.receiverName}</td>
  80.                                     <td>{order.statusDesc}</td>
  81.                                     <td>¥{order.payment}</td>
  82.                                     <td>{order.createTime}</td>
  83.                                     <td>
  84.                                         <Link to={ `/order/detail/${order.orderNo}` }>详情</Link>
  85.                                     </td>
  86.                                 </tr>
  87.                             );
  88.                         })
  89.                     }
  90.                 </TableList>
  91.                 <Pagination current={this.state.pageNum}
  92.                     total={this.state.total}
  93.                     onChange={(pageNum) => this.onPageNumChange(pageNum)}/>
  94.             </div>
  95.         );
  96.     }
  97. }
  98.  
  99. export default OrderList;

4.详情detail组件

  1. import React from 'react';
  2. import MUtil from 'util/mm.jsx'
  3. import Order from 'service/order-service.jsx'
  4. import PageTitle from 'component/page-title/index.jsx';
  5. import TableList from 'util/table-list/index.jsx';
  6.  
  7. import './detail.scss';
  8. const _mm = new MUtil();
  9. const _order = new Order();
  10.  
  11. class OrderDetail extends React.Component{
  12.     constructor(props){
  13.         super(props);
  14.         this.state = {
  15.             orderNumber : this.props.match.params.orderNumber,
  16.             orderInfo : {}
  17.         }
  18.     }
  19.     componentDidMount(){
  20.         this.loadOrderDetail();
  21.     }
  22.     // 加载商品详情
  23.     loadOrderDetail(){
  24.         _order.getOrderDetail(this.state.orderNumber).then((res) => {
  25.             this.setState({
  26.                 orderInfo : res
  27.             });
  28.         }, (errMsg) => {
  29.             _mm.errorTips(errMsg);
  30.         });
  31.     }
  32.     // 发货操作
  33.     onSendGoods(){
  34.         if(window.confirm('是否确认该订单已经发货?')){
  35.             _order.sendGoods(this.state.orderNumber).then((res) => {
  36.                 _mm.successTips('发货成功');
  37.                 this.loadOrderDetail();
  38.             }, (errMsg) => {
  39.                 _mm.errorTips(errMsg);
  40.             });
  41.         }
  42.     }
  43.     render(){
  44.         let receiverInfo = this.state.orderInfo.shippingVo || {},
  45.             productList = this.state.orderInfo.orderItemVoList || [];
  46.         let tableHeads = [
  47.             {name: '商品图片', width: '10%'},
  48.             {name: '商品信息', width: '45%'},
  49.             {name: '单价', width: '15%'},
  50.             {name: '数量', width: '15%'},
  51.             {name: '合计', width: '15%'}
  52.         ];
  53.         return (
  54.             <div id="page-wrapper">
  55.                 <PageTitle title="订单详情" />
  56.                 <div className="form-horizontal">
  57.                     <div className="form-group">
  58.                         <label className="col-md-2 control-label">订单号</label>
  59.                         <div className="col-md-5">
  60.                             <p className="form-control-static">{this.state.orderInfo.orderNo}</p>
  61.                         </div>
  62.                     </div>
  63.                     <div className="form-group">
  64.                         <label className="col-md-2 control-label">创建时间</label>
  65.                         <div className="col-md-5">
  66.                             <p className="form-control-static">{this.state.orderInfo.createTime}</p>
  67.                         </div>
  68.                     </div>
  69.                     <div className="form-group">
  70.                         <label className="col-md-2 control-label">收件人</label>
  71.                         <div className="col-md-5">
  72.                             <p className="form-control-static">
  73.                                 {receiverInfo.receiverName},
  74.                                 {receiverInfo.receiverProvince}
  75.                                 {receiverInfo.receiverCity}
  76.                                 {receiverInfo.receiverAddress}
  77.                                 {receiverInfo.receiverMobile || receiverInfo.receiverPhone}
  78.                             </p>
  79.                         </div>
  80.                     </div>
  81.                     <div className="form-group">
  82.                         <label className="col-md-2 control-label">订单状态</label>
  83.                         <div className="col-md-5">
  84.                             <p className="form-control-static">
  85.                                 {this.state.orderInfo.statusDesc}
  86.                                 {
  87.                                     this.state.orderInfo.status === 20
  88.                                     ? <button className="btn btn-default btn-sm btn-send-goods"
  89.                                         onClick={(e) => {this.onSendGoods(e)}}>立即发货</button>
  90.                                     : null
  91.                                 }
  92.                             </p>
  93.                         </div>
  94.                     </div>
  95.                     <div className="form-group">
  96.                         <label className="col-md-2 control-label">支付方式</label>
  97.                         <div className="col-md-5">
  98.                             <p className="form-control-static">
  99.                                 {this.state.orderInfo.paymentTypeDesc}
  100.                             </p>
  101.                         </div>
  102.                     </div>
  103.                     <div className="form-group">
  104.                         <label className="col-md-2 control-label">订单金额</label>
  105.                         <div className="col-md-5">
  106.                             <p className="form-control-static">
  107.                                 ¥{this.state.orderInfo.payment}
  108.                             </p>
  109.                         </div>
  110.                     </div>
  111.                     <div className="form-group">
  112.                         <label className="col-md-2 control-label">商品列表</label>
  113.                         <div className="col-md-10">
  114.                             <TableList tableHeads={tableHeads}>
  115.                                 {
  116.                                     productList.map((product, index) => {
  117.                                         return (
  118.                                             <tr key={index}>
  119.                                                 <td>
  120.                                                     <img className="p-img" alt={product.productName}
  121.                                                         src={`${this.state.orderInfo.imageHost}${product.productImage}`}/>
  122.                                                 </td>
  123.                                                 <td>{product.productName}</td>
  124.                                                 <td>¥{product.currentUnitPrice}</td>
  125.                                                 <td>{product.quantity}</td>
  126.                                                 <td>¥{product.totalPrice}</td>
  127.                                             </tr>
  128.                                         );
  129.                                     })
  130.                                 }
  131.                             </TableList>
  132.                         </div>
  133.                     </div>
  134.                 </div>
  135.             </div>
  136.         )
  137.     }
  138. }
  139. export default OrderDetail;

React后台管理系统-订单管理的更多相关文章

  1. React后台管理系统-商品管理列表组件

    1.商品列表页面结构 <div id="page-wrapper">              <PageTitle title="商品列表" ...

  2. 【共享单车】—— React后台管理系统开发手记:城市管理和订单管理

    前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...

  3. 【共享单车】—— React后台管理系统开发手记:主页面架构设计

    前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...

  4. 《React后台管理系统实战 :一》:目录结构、引入antd、引入路由、写login页面、使用antd的form登录组件、form前台验证、高阶函数/组件

    实战 上接,笔记:https://blog.csdn.net/u010132177/article/details/104150177 https://gitee.com/pasaulis/react ...

  5. 《React后台管理系统实战 :二》antd左导航:cmd批量创建子/目录、用antd进行页面布局、分离左导航为单独组件、子路由、动态写左导航、css样式相对陷阱

    一.admin页面布局及路由创建 0)cmd批量创建目录及子目录 //创建各个目录,及charts和子目录bar md home category product role user charts\b ...

  6. react后台管理系统路由方案及react-router原理解析

        最近做了一个后台管理系统主体框架是基于React进行开发的,因此系统的路由管理,选用了react-router(4.3.1)插件进行路由页面的管理配置. 实现原理剖析 1.hash的方式   ...

  7. 【共享单车】—— React后台管理系统开发手记:项目工程化开发

    前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...

  8. springboot学习笔记:11.springboot+shiro+mysql+mybatis(通用mapper)+freemarker+ztree+layui实现通用的java后台管理系统(权限管理+用户管理+菜单管理)

    一.前言 经过前10篇文章,我们已经可以快速搭建一个springboot的web项目: 今天,我们在上一节基础上继续集成shiro框架,实现一个可以通用的后台管理系统:包括用户管理,角色管理,菜单管理 ...

  9. 【共享单车】—— React后台管理系统开发手记:员工管理之增删改查

    前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...

随机推荐

  1. spring aop 原理学习

    @EnableAspectJAutoProxy: @Import(AspectJAutoProxyRegistrar.class) 实际是创建了一个以org.springframework.aop.c ...

  2. AUTO Uninstaller 下载 (maya/3dsmax/cad/Inventor/Revit uninstall tool 卸载修复工具)

    小伙伴是不是遇到 MAYA/CAD/3DSMAX/INVENTOR/REVIT 安装失败或者安装不了的问题了呢?AUTODESK系列软件着实令人头疼,MAYA/CAD/3DSMAX/INVENTOR/ ...

  3. 性能测试工具LoadRunner05-LR之Virtual User Generator html模式与url模式

    “HTML-based script”说明 在默认情况下,选择“HTML-based script”,说明脚本中采用HTML页面的形式来表示,这种方式的脚本容易维护,容易理解,推荐这种方式录制 “UR ...

  4. Murano为镜像包添加Root用户密码

    1. 安装dib-utils Dib Utils 是 diskimage-builder 工程的一部分,但是他们也用于 diskimage-builder 工程外部. 因为基于云的磁盘空间已经溢出,推 ...

  5. (转) awk学习

     awk学习  原文:http://blog.chinaunix.net/uid-23302288-id-3785105.html http://www.zsythink.net/archives/t ...

  6. 【Linux】Debian 8 设置命令行界面的文本颜色

    平时我们操作的系统命令行界面文本默认黑底白字,有时候会看不惯这种全篇都是白色字符,这个时候可以通过改变PS1环境变量来改变文本颜色.我个人喜欢黑底绿字的搭配,以下是我个人的命令行界面样式: 注意:以下 ...

  7. DEDECMS v5.7 完美实现导航条下拉二级菜单

    一.引言 好多人都问,织梦的下拉导航怎么做呢?其实很简单!即使你对代码一点也不熟悉,没关系! 按照我的步骤走!记住一步也不能错哦! 二.实现过程 1.首先: 将下面这段代码贴到templets\def ...

  8. Spring boot-(3) Spring Boot特性1

    本节将深入Spring Boot的细节,可以学到你想使用的或定制的Spring Boot的主要特性. 1. SpringApplication SpringApplication类为引导一个Sprin ...

  9. 基于JQUERY 的图片查看插件

    viewer是一款功能强大的图片查看器.它可以实现ACDsee等看图软件的部分功能.它可以对图片进行移动,缩放,旋转,翻转,可以前后浏览一组图片.该图片查看器还支持移动设备,支持键盘控制,功能十分强大 ...

  10. c# 使用泛型序列化

    static void Serialize<T>(T instance , string fileName) { using(XmlWriter writer = new XmlWrite ...