效果图:

 
 
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. 万答#9,MySQL 中有哪些常用的日志

    欢迎来到 GreatSQL社区分享的MySQL技术文章,如有疑问或想学习的内容,可以在下方评论区留言,看到后会进行解答 GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 前 ...

  2. C++ 练气期之函数探幽

    1. 函数基础 一个C++程序中,往往需要包含若干个函数,可以说函数是C++程序的基础组成元件,是程序中的头等公民. 如果要理解程序中使用函数的具体意义,则需要了解语言发展过程中致力要解决的 2 问题 ...

  3. 越折腾越好用的 3 款开源 APP

    高中的时候我特别喜欢捣鼓手机,然后我一个哥们儿在我的强烈推荐下买了个 HTC Dream(G1) 手机. G1 作为谷歌的第一个亲儿子,它出厂搭载的是 Android 1.5 系统,但当时已经出到了 ...

  4. Docker 09 可视化

    参考源 https://www.bilibili.com/video/BV1og4y1q7M4?spm_id_from=333.999.0.0 https://www.bilibili.com/vid ...

  5. Linux 12 安装Docker

    参考源 https://www.bilibili.com/video/BV187411y7hF?spm_id_from=333.999.0.0 版本 本文章基于 CentOS 7.6 这里使用 yum ...

  6. 分布式id生成器,雪花算法IdWorker

    /** * <p>名称:IdWorker.java</p> * <p>描述:分布式自增长ID</p> * <pre> * Twitter的 ...

  7. [CF1536F] Omkar and Akmar(博弈论?组合数学)

    题面 [CF1536F] Omkar and Akmar 甲乙轮流在一个有 N N N 个位置的环上放字母(环上每个位置不同),每次可以放一个 A 或 B ,要求不能有相同的字母相邻,轮到某个人时不能 ...

  8. python使用pickle序列化对象读取输出二进制文件

    import pickle class tick: name = '牛牛牛' age = 10 samp = [1,2,3,'aaa',[12,3],tick()] with open('te.xxx ...

  9. luogu P2882 [USACO07MAR]Face The Right Way G

    题目描述 Farmer John has arranged his N (1 ≤ N ≤ 5,000) cows in a row and many of them are facing forwar ...

  10. DFS算法-求集合的所有子集

    目录 1. 题目来源 2. 普通方法 1. 思路 2. 代码 3. 运行结果 3. DFS算法 1. 概念 2. 解题思路 3. 代码 4. 运行结果 4. 对比 1. 题目来源 牛客网,集合的所有子 ...