效果图:

 
 
import React from 'react';
import { Form, FormField, Layout,DataList,LayoutPanel,Panel, Label, CheckBox, TextBox,Tabs,TabPanel, DateBox, NumberBox, RadioButton, ComboBox, LinkButton } from 'rc-easyui';
import '../css/style.css';
import * as demo from 'rc-easyui/dist/locale/easyui-lang-zh_CN.js';
import { reqdoSQL } from '../../api/functions.js';
import 'rc-easyui/dist/themes/gray/radiobutton.css';
import 'rc-easyui/dist/themes/gray/checkbox.css';
export default class Page401 extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
     product:{},
     data:[],
     topic:["饮料","零食","速食产品","母婴用品","鞋包饰品","厨房日用品"],
     topicchecked:[],
     onlist:["上市","未上市"],
     onlists:"",
     datetime:new Date(),
     listtime:[]
    }
  }
  getImage(row) {
    return "/myServer/mybase/products/"+row.productid+".jpg";
  }
  async componentDidMount() {
    let p={};
    p.selectsql='select productid,productname,unitprice from products';
    let rs= await reqdoSQL(p);
    this.setState({data:rs.rows});
   
  }
  renderItem({ row }) {
    return (
      <div key={row.productid}>
        <img src={this.getImage(row)} style={{width:"100px",height:"100px"}} />
        <div>
          <p>{row.productid} - {row.productname}</p>
 
          <p>¥ {row.unitprice}</p>
        </div>
      </div>
    )
  }
  handleChange(name, value) {  //同一个函数,用name来区分
 
    let product = Object.assign({}, this.state.product);
    product[name] = value;
    this.setState({product: product,open:false });
    console.log(name,value);
  }
handleSelectionChange(row){
    this.setState({product:row})
    console.log(111111,row);
  }
  handleChangelist(value, checked) {
    if (checked) {
      this.setState({ onlists: value },() => {
        setTimeout(()=>{
          if(this.state.onlists=="上市"){
            var listtime=[];
            listtime.push(<div style={{ margin: '10px'}}>
          <Label htmlFor="onlisttime" align="left">上市时间:</Label>
          <DateBox inputId="onlisttime" id="onlisttime" value={this.state.datetime} onChange={(value) => this.datetimeChange(value)} format="yyyy-MM-dd"
          style={{width:"300px",fontFamily:"楷体",height:"30px"}}></DateBox>
          </div>);
            this.setState({listtime:listtime})
     
          }else{
     
            this.setState({listtime:[]});
          }
        },100);
     
    });
   
  }
}
  datetimeChange(value){
    this.setState({datetime: value});
  }
  render() {
    return (
      <div>
        <Layout style={{width:"100%",height:"100%",position:"absolute"}}>
          <LayoutPanel region="west" style={{width:200}}>
            <div>
            <DataList
          style={{ width: "100%", height: "100%" ,textAlign:"center"}}
          renderItem={this.renderItem.bind(this)}
          data={this.state.data}
          selectionMode="single"
          onSelectionChange={this.handleSelectionChange.bind(this)}
          />
                  </div>
          </LayoutPanel>
          <LayoutPanel region="center" >
       
         
        <Panel title="商品信息" collapsible >
          <div style={{position:'relative', height:120}} >
          <Label htmlFor="productid" className="labelStyle" style={{position:'absolute', top:'20px', left:'16px'}}>商品编号:</Label>
          <TextBox inputId="productid" id="productid" value={this.state.product.productid}
          onChange={(value) => this.handleChange("pid", value)}
          style={{position:'absolute', top:'20px', left:'85px', width:'200px'}}></TextBox>
          <Label htmlFor="productname" className="labelStyle" style={{position:'absolute', top:70, left:'16px'}}>商品名称:</Label>
          <TextBox inputId="productname" id="productname" value={this.state.product.productname} onChange={(value) => this.handleChange("productname", value)}
          style={{position:'absolute', top:'70px', left:'85px', width:200}}></TextBox>
         
         </div>
        </Panel>
        <div>
        <Tabs tabPosition='top'  >
       
        <TabPanel ref={ref => this.myTab1 = ref} key="myTab1" title="客户列表">
        <div style={{margin:"10px"}}>
            <Label htmlFor="customerid" align="left">客户编码:</Label>
            <TextBox inputId="customerid" iconCls="icon-man" style={{ width: '30%' }}></TextBox>
        </div>
         
        <div style={{margin:"10px"}}>
            <Label htmlFor="companyname" align="left">公司名称:</Label>
            <TextBox inputId="companyname" iconCls="icon-man" style={{ width: '30%' }}></TextBox>
        </div>
        <div style={{margin:"10px"}}>
        <Label htmlFor="companyname" align="left">售货类型:</Label>
        {
          this.state.topic.map(topic => {
            return (
              <div key={topic} style={{display:"inline-block"}}>
                <CheckBox inputId={topic} multiple value={topic} values={this.state.topicchecked} onChange={this.handleChange.bind(this)}></CheckBox>
                <Label htmlFor={topic} style={{margin:'0px 0px 0px 5px'}}>{topic}</Label>
              </div>
            )
          })
         
        }
        </div>
        <div style={{margin:"10px"}}>
        <Label htmlFor="onlist" align="left">公司类型:</Label>
        {
  this.state.onlist.map(onlist => {
    return (
      <div key={onlist} style={{display:"inline-block"}}>
        <RadioButton
          inputId={onlist}
          value={onlist}
          groupValue={this.state.onlists}
          onChange={(checked) => this.handleChangelist(onlist, checked)}
        />
        <Label htmlFor={onlist} style={{ margin: '0 5px' }}>{onlist}</Label>
      </div>
    )
  })
}
</div>
{this.state.listtime}
        <div style={{ margin: '10px' }}>
            <Label htmlFor="note" align="left">公司简历:</Label>
            <TextBox inputId="note" multiline value={this.state.description} style={{ width: '70%', height: 100 }}></TextBox>
        </div>
        </TabPanel>
        </Tabs>
      </div>
        </LayoutPanel>
        </Layout>
      </div>
    );
  }
}
 
 
 
 
做了个选中才出现的信息框,开始做有异步,点击“上市”不出现“上市时间”,点击“未上市”才出现,后来还是用setTimeout()做的,如果有更好的方法可以指点指点的。
 
 handleChangelist(value, checked) {
    if (checked) {
      this.setState({ onlists: value },() => {
        setTimeout(()=>{
          if(this.state.onlists=="上市"){
            var listtime=[];
            listtime.push(<div style={{ margin: '10px'}}>
          <Label htmlFor="onlisttime" align="left">上市时间:</Label>
          <DateBox inputId="onlisttime" id="onlisttime" value={this.state.datetime} onChange={(value) => this.datetimeChange(value)} format="yyyy-MM-dd"
          style={{width:"300px",fontFamily:"楷体",height:"30px"}}></DateBox>
          </div>);
            this.setState({listtime:listtime})
     
          }else{
     
            this.setState({listtime:[]});
          }
        },100);
     
    });
   
  }

}

 
 

react.js+easyui 做一个简单的商品表的更多相关文章

  1. 使用React并做一个简单的to-do-list

    1. 前言 说到React,我从一年之前就开始试着了解并且看了相关的入门教程,而且还买过一本<React:引领未来的用户界面开发框架 >拜读.React的轻量组件化的思想及其virtual ...

  2. 【 D3.js 入门系列 --- 3 】 做一个简单的图表!

    前面说了几节,都是对文字进行处理,这一节中将用 D3.js 做一个简单的柱形图. 做柱形图有很多种方法,比如用 HTML 的 div 标签,或用 svg . 推荐用 SVG 来做各种图形.SVG 意为 ...

  3. 【 D3.js 入门系列 — 3 】 做一个简单的图表!

    图1. 柱形图 1. 柱形图 前几章的例子,都是对文字进行处理.本章中将用 D3 做一个简单的柱形图.制作柱形图有很多种方法,比如用 HTML 的 <div> 标签,或在 SVG 上绘制 ...

  4. MUI框架-05-用MUI做一个简单App

    MUI框架-05-用MUI做一个简单App MUI 是一个前端框架,前端框架就像 Bootstrap,EasyUI,Vue ,为了做 app 呢,就有了更加高效的 MUI,我觉得前端框架有很多,也没有 ...

  5. 使用 jquery 的 上传文件插件 uploadify 3.1 配合 java 来做一个简单的文件上次功能。并且在界面上有radio 的选择内容也要上传

    使用 jquery 的 上传文件插件 uploadify 3.1 配合 java 来做一个简单的文件上次功能.并且在界面上有radio 的选择内容也要上传 uploadify 插件的 下载和文档地址  ...

  6. 第四章 .net core做一个简单的登录

    项目目标部署环境:CentOS 7+ 项目技术点:.netcore2.0 + Autofac +webAPI + NHibernate5.1 + mysql5.6 + nginx 开源地址:https ...

  7. .Net Core 3.0后台使用httpclient请求网络网页和图片_使用Core3.0做一个简单的代理服务器

    目标:使用.net core最新的3.0版本,借助httpclient和本机的host域名代理,实现网络请求转发和内容获取,最终显示到目标客户端! 背景:本人在core领域是个新手,对core的使用不 ...

  8. 【Bugly干货分享】一起用 HTML5 Canvas 做一个简单又骚气的粒子引擎

    Bugly 技术干货系列内容主要涉及移动开发方向,是由Bugly邀请腾讯内部各位技术大咖,通过日常工作经验的总结以及感悟撰写而成,内容均属原创,转载请标明出处. 前言 好吧,说是“粒子引擎”还是大言不 ...

  9. 一起用HTML5 canvas做一个简单又骚气的粒子引擎

    前言 好吧,说是"粒子引擎"还是大言不惭而标题党了,离真正的粒子引擎还有点远.废话少说,先看demo 本文将教会你做一个简单的canvas粒子制造器(下称引擎). 世界观 这个简单 ...

随机推荐

  1. fijkplayer问题反馈:暂停时拖动进度光标,在窗口模式与全屏模式间切换后,进度光标不能及时更新、正常跟进

    fijkplayer-0.8.4很优秀,造福苍生,非常感谢! 使用fijkplayer-0.8.4开发的过程中遇到以下问题,特此记录.提交上传:https://github.com/befovy/fi ...

  2. 实现一个会动的鸿蒙 LOGO

    本文将带大家简单实现一个会动的鸿蒙 LOGO. emmm,写本文的动机是之前在掘金看到一篇实现鸿蒙 LOGO 的文章 -- 产品经理:鸿蒙那个开场动画挺帅的 给咱们页面也整一个呗 鸿蒙的 LOGO 本 ...

  3. Redis 13 事务

    参考源 https://www.bilibili.com/video/BV1S54y1R7SB?spm_id_from=333.999.0.0 版本 本文章基于 Redis 6.2.6 概述 Redi ...

  4. 一文搞懂│mysql 中的备份恢复、分区分表、主从复制、读写分离

    目录 mysql 的备份和恢复 mysql 的分区分表 mysql 的主从复制读写分离 mysql 的备份和恢复 创建备份管理员 创建备份管理员,并授予管理员相应的权限 备份所需权限:select,r ...

  5. C++11实现的数据库连接池

    它什么是? 数据库连接池负责分配.管理和释放数据库连接,它允许应用程序重复使用一个现有的数据库连接,而不是再重新建立一个:类似的还有线程池. 为什么要用? 一个数据库连接对象均对应一个物理数据库连接, ...

  6. HTML引用CSS实现自适应背景图

    链接图片背景代码 body {background: url('链接') no-repeat center 0;} 颜色代码 body{background:#FFF} 链接图片背景代码2 <b ...

  7. 「学习笔记」字符串基础:Hash,KMP与Trie

    「学习笔记」字符串基础:Hash,KMP与Trie 点击查看目录 目录 「学习笔记」字符串基础:Hash,KMP与Trie Hash 算法 代码 KMP 算法 前置知识:\(\text{Border} ...

  8. 解决QIcon引用qrc不显示图片

    引用Qrc 对于Qt来说,添加qrc之后,可以使用":"来直接访问qrc的文件,比如 QIcon icon(":/icon/red.png"); 绝对路径 当然 ...

  9. kingbaseES R3 集群备库转换为单实例库案例

    案例说明: 在生产环境需要将集群中架构转换为单实例环境,本案例以备库转换为单实例库为案例,介绍了两种方案,一种在数据库数据量小的环境下采用 sys_dumpall 导出导入方式建立单实例库:另外一种是 ...

  10. 国产CPLD(AGM1280)试用记录——做个SPI接口的任意波形DDS [原创www.cnblogs.com/helesheng]

    我之前用过的CPLD有Altera公司的MAX和MAX-II系列,主要有两个优点:1.程序存储在片上Flash,上电即行,保密性高.2.CPLD器件规模小,成本和功耗低,时序不收敛情况也不容易出现.缺 ...