效果图:

 
 
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. 技术分享|MySQL caching_sha2_password认证异常问题分析

    欢迎来到 GreatSQL社区分享的MySQL技术文章,如有疑问或想学习的内容,可以在下方评论区留言,看到后会进行解答 0. 导读 相同的账号.密码,手动客户端连接可以成功,通过MySQL Conne ...

  2. GreatSQL MGR FAQ

    欢迎来到 GreatSQL社区分享的MySQL技术文章,如有疑问或想学习的内容,可以在下方评论区留言,看到后会进行解答 目录 0. GreatSQL简介 1. GreatSQL的特色有哪些 2. Gr ...

  3. OpenSSF的开源软件风险评估工具:Scorecards

    对于IT从业者来说,Marc Andreessen 十年前提出"软件吞噬世界"的观点早已耳熟能详.无论是私人生活还是公共领域,软件为现代社会的方方面面提供动力,对现代经济和国家安全 ...

  4. ASP.NET Core 6框架揭秘实例演示[32]:错误页面的集中呈现方式

    由于ASP.NET是一个同时处理多个请求的Web应用框架,所以在处理某个请求过程中出现异常并不会导致整个应用的中止.出于安全方面的考量,为了避免敏感信息外泄,客户端在默认情况下并不会得到详细的出错信息 ...

  5. linux centos 系统盘文件系统损坏-已解决

    当我们使用的Linux虚拟机(云服务器/vps)磁盘出现xfs文件系统损坏时,该如何进行修复? xfs格式文件系统损坏,是运维常见的一个场景,经常发生在强制重启.异常关机.软件冲突.误删文件等事件后, ...

  6. 【2022知乎爬虫】我用Python爬虫爬了2300多条知乎评论!

    您好,我是 @马哥python说,一枚10年程序猿. 一.爬取目标 前些天我分享过一篇微博的爬虫: https://www.cnblogs.com/mashukui/p/16414027.html 但 ...

  7. 状态 :睡眠中,进程ID:13431,yum提示Another app is currently holding the yum lock; waiting for it to exit...

    问题描述: 今天想在虚拟机上重新安装docker然后使用到yum命令报错: 解决办法: [root@localhost ~]# rm -f /var/run/yum.pid 然后重新运行刚才的yum命 ...

  8. 【读书笔记】C#高级编程 第二十一章 任务、线程和同步

    (一)概述 所有需要等待的操作,例如,因为文件.数据库或网络访问都需要一定的时间,此时就可以启动一个新的线程,同时完成其他任务. 线程是程序中独立的指令流. (二)Paraller类 Paraller ...

  9. byte[]数组转换string类型

    byte[] OutData = new byte[2048];//交易返回数据 string pBusiCardInfoStr = Encoding.Default.GetString(OutDat ...

  10. 【疑难杂症】关于用pydotplus生成iris.pdf报错问题

    在使用刘建平老师博客中DecisionTreeClassifier实例时,遇到报错:InvocationException: GraphViz's executables not found 源代码如 ...