当前位置: 首页 > news >正文

上海专做特卖的网站企业推广软件

上海专做特卖的网站,企业推广软件,网页游戏网站排行,c 中怎么用html5做网站antd form中数组套数组 form数组动态变化 动态赋值 需求如上,同时添加多个产品,同时每个产品可以增加多台设备,根据设备增加相应编号,所以存在数组套数组,根据数组值动态变化 使用的知识点 form.list form中的数组…

antd form中数组套数组

form数组动态变化 动态赋值
在这里插入图片描述

需求如上,同时添加多个产品,同时每个产品可以增加多台设备,根据设备增加相应编号,所以存在数组套数组,根据数组值动态变化
使用的知识点

  1. form.list form中的数组展示
  2. shouldUpdate 根据form值来动态变化
  3. 数组是引用类型
// An highlighted block
<div ><Formform={form}name="basic"labelCol={{flex: '90px',}}initialValues={{productList:[{bianHao:'',wuMiao:'',number:1,tType:'you',files:{},list:[{sheBei:'',guZi:'',ziYou:'',}],}]}}labelWrap={true}labelAlign="left"onFinish={onFinish}onFinishFailed={onFinishFailed}autoComplete="off">{/* <Card title="基本信息" bordered={false}><Row   gutter={16}><Col sm={24} md={12} lg={8} xxl={6}><Form.Itemlabel="最终用户"name="username"rules={[{required: true,message: '请输入',},]}><Input /></Form.Item></Col><Col sm={24} md={12} lg={8} xxl={6}><Form.Itemlabel="商务助理"name="userLian"rules={[{required: true,message: '请输入',},]}><Input /></Form.Item></Col><Col sm={24} md={12} lg={8} xxl={6}><Form.Itemlabel="测试用途"name="userPhone"rules={[{required: true,message: '请输入',},]}><Input /></Form.Item></Col><Col sm={24} md={12} lg={8} xxl={6}><Form.Itemlabel="项目预计招标/采购时间"name="userShou"rules={[{required: true,message: '请输入',},]}><Input /></Form.Item></Col><Col sm={24} ><Form.Itemlabel="备注"name="beiZhu"rules={[{required: true,message: '请输入',},]}><TextArea  /></Form.Item></Col><Col xl={24} sm={24}><Form.Item label='证明文件' ><Upload {...fileProps}><Button type="primary" icon={<UploadOutlined />}>点击上传</Button></Upload></Form.Item></Col></Row>   </Card> */}<Card title="基本信息" bordered={false}><Form.List name="productList" >{(fields, {add, remove}) => (<>{fields.map((field,index) => (<Row  gutter={16}>{/* 用得时候只需要修改下面,将需要重复展示的部分替换下面部分即可 注意 -----start*/ }<Col sm={24} md={12} lg={8} xxl={6}><Form.Item {...field}label="产品名称"name={[field.name,"bianHao"]}rules={[{required: true,message: '请输入',},]}><Input placeholder="请输入" /></Form.Item></Col><Col sm={24} md={12} lg={8} xxl={6}><Form.Item {...field}label="物料编码"name={[field.name,"wuMiao"]}rules={[{required: true,message: '请输入',},]}><Input placeholder="请输入" /></Form.Item></Col><Col sm={24} md={12} lg={8} xxl={6}><Form.Item {...field}label="数量"name={[field.name,"number"]}rules={[{required: true,message: '请输入',},]}><InputNumber min={1} style={{width:'100%'}}/></Form.Item></Col><Col sm={24} md={12} lg={8} xxl={6}><Form.Item {...field}label="单位"name={[field.name,"tType"]}rules={[{required: true,message: '请输入',},]}><Select><Select.Option value="you"></Select.Option><Select.Option value="zi"></Select.Option></Select></Form.Item></Col><Col sm={24}><Form.Item noStyle  shouldUpdate={(pre,cur) => {//    如果删除一条信息,cur.productList[index]是空值,所以需要判断if(cur.productList[index]&&pre.productList[index]){return pre.productList[index].number !== cur.productList[index].number}else{return false}}}>{({getFieldsValue}) =>{{/* 繁琐的计算:1.输入的数值比原来的数值大,计算差值,给原数组循环push2.手动在删除,输入框为空的时候,根据splice置空 (因为是空,所以计算出0)3.输入的数值比之前小,优先从后面删除,防止前面输入的被删除掉,依旧是操作原数组 splice  */}let number = getFieldsValue().productList[index].number;let list = getFieldsValue().productList[index].list;if(number>list.length){let cha = number - list.length;for(let i=0; i<cha ; i++){list.push({ sheBei:'',guZi:'',ziYou:'',})}}else if(number===''){list.splice(0,list.length)}else if(number<list.length){let cha = list.length - number;list.splice(number,cha)} return <Form.List name={[field.name,"list"]} >{(tLists) => (<>{tLists.map(tlist=>(<Row  gutter={16}><Col sm={24} md={12} lg={8} xxl={6}><Form.Item {...tlist}label="设备序列号"name={[tlist.name,"sheBei"]}rules={[{required: true,message: '请选择',},]}><Input/></Form.Item></Col><Col sm={24} md={12} lg={8} xxl={6}><Form.Item {...tlist}label="固资编码"name={[tlist.name,"guZi"]}rules={[{required: true,message: '请选择',},]}><Input/></Form.Item></Col><Col sm={24} md={12} lg={8} xxl={6}><Form.Item {...tlist}label="自有编码"name={[tlist.name,"ziYou"]}rules={[{required: true,message: '请选择',},]}><Input/></Form.Item></Col></Row>))}</>)}</Form.List>}}</Form.Item></Col><Col sm={24} ><Form.Itemlabel="备注"{...field}name={[field.name,"beiZhu"]}rules={[{required: true,message: '请输入',},]}><TextArea  /></Form.Item></Col><Col xl={24} sm={24}><Form.Item label='证明文件' {...field}name={[field.name,"files"]} ><Upload customRequest={(option=> option.onSuccess())}beforeUpload={(file, fileList)=> fileVerification(file, fileList)}><Button type="primary" icon={<UploadOutlined />}>点击上传</Button></Upload></Form.Item></Col>{ /* 用得时候只需要修改下面,将需要重复展示的部分替换下面部分即可 -----end*/ }<div styleName="item_btn_wrap"><PlusCircleFilled styleName="add_item_btn" onClick={() => add({bianHao:'',wuMiao:'',number:1,tType:'you',beiZhu:'',files:{},list:[{sheBei:'',guZi:'',ziYou:'',}],})} />{fields.length>1&&<CloseCircleFilled  styleName="remove_item_btn" onClick={() => remove(field.name)} />}</div></Row>))}</>)}</Form.List></Card><Card>{/* <Row  gutter={16}><Col> */}{/* <Form.Item wrapperCol={{ offset: 8, span: 16 }}> */}<Form.Item styleName="right_layout"><Link to="/HW/HwBorrowList"><Button type="dashed">取消</Button></Link><Button style={{marginLeft:'20px'}} loading={saving} onClick={()=>onFinish('stage')}>暂存</Button><Button type="primary" style={{marginLeft:'20px'}} onClick={()=>onFinish('submit')}>提交</Button>{/* <Button type="primary" htmlType="submit">确认</Button> */}</Form.Item>{/* </Col></Row> */}</Card></Form></div>

使用注意

  1. Form.List 使用 {…field}或者{…tlist} 需要在name的前面,否则出错
  2. 中间有关于业务的逻辑,输入数量的计算
  3. shouldUpdate 方法使用,表单中值变化,可以根据index来获取是第几个,进而判断
  4. form数组的嵌套 运用两个form.list 嵌套,重点关注内层的 name 怎么写,进而进行内部的循环
  5. 在对form 的数组进行赋值的操作时 紧记 数组是引用类型 ,用getFieldsValue 来获取需要操作的数组,运用数组中的修改原数组的方法来操作,即可及时修改form值
    数组是引用类型
    数组是引用类型
    数组是引用类型

以上为代码和理解,欢迎指正


文章转载自:
http://egotrip.zfqr.cn
http://underinsured.zfqr.cn
http://sternness.zfqr.cn
http://ornithology.zfqr.cn
http://reticulated.zfqr.cn
http://sunkist.zfqr.cn
http://haubergeon.zfqr.cn
http://dissectible.zfqr.cn
http://curl.zfqr.cn
http://sclerotium.zfqr.cn
http://ilka.zfqr.cn
http://integument.zfqr.cn
http://innocence.zfqr.cn
http://claretian.zfqr.cn
http://lunule.zfqr.cn
http://substorm.zfqr.cn
http://steeply.zfqr.cn
http://crispen.zfqr.cn
http://advocation.zfqr.cn
http://ammoniacal.zfqr.cn
http://orthograph.zfqr.cn
http://grubstreet.zfqr.cn
http://europlug.zfqr.cn
http://saturable.zfqr.cn
http://except.zfqr.cn
http://fluidize.zfqr.cn
http://nymphish.zfqr.cn
http://ordnance.zfqr.cn
http://hellion.zfqr.cn
http://iupac.zfqr.cn
http://latah.zfqr.cn
http://brakesman.zfqr.cn
http://cardiff.zfqr.cn
http://utopia.zfqr.cn
http://metallotherapy.zfqr.cn
http://kinesics.zfqr.cn
http://marlite.zfqr.cn
http://restharrow.zfqr.cn
http://baps.zfqr.cn
http://ratch.zfqr.cn
http://touchline.zfqr.cn
http://squeezability.zfqr.cn
http://legatine.zfqr.cn
http://lubricator.zfqr.cn
http://tactical.zfqr.cn
http://wittiness.zfqr.cn
http://foziness.zfqr.cn
http://attractability.zfqr.cn
http://nerol.zfqr.cn
http://tarp.zfqr.cn
http://incineration.zfqr.cn
http://humblingly.zfqr.cn
http://recrudescence.zfqr.cn
http://tremulously.zfqr.cn
http://lagting.zfqr.cn
http://rejectant.zfqr.cn
http://combustor.zfqr.cn
http://dowery.zfqr.cn
http://papoose.zfqr.cn
http://hemstitch.zfqr.cn
http://craniology.zfqr.cn
http://ambury.zfqr.cn
http://tetraethylammonium.zfqr.cn
http://argumentative.zfqr.cn
http://childbearing.zfqr.cn
http://cataclysmic.zfqr.cn
http://monstrance.zfqr.cn
http://onomastics.zfqr.cn
http://sanforized.zfqr.cn
http://mosstrooper.zfqr.cn
http://landform.zfqr.cn
http://boleyn.zfqr.cn
http://peckish.zfqr.cn
http://ungovernable.zfqr.cn
http://nouadhibou.zfqr.cn
http://ledge.zfqr.cn
http://backhoe.zfqr.cn
http://gramme.zfqr.cn
http://stonecutter.zfqr.cn
http://mesocephalon.zfqr.cn
http://tertiary.zfqr.cn
http://diabolology.zfqr.cn
http://rhinopneumonitis.zfqr.cn
http://guardrail.zfqr.cn
http://semismile.zfqr.cn
http://mammifer.zfqr.cn
http://demisemiquaver.zfqr.cn
http://demirelievo.zfqr.cn
http://discernable.zfqr.cn
http://lipography.zfqr.cn
http://impressively.zfqr.cn
http://audiometer.zfqr.cn
http://biro.zfqr.cn
http://magnetograph.zfqr.cn
http://sambal.zfqr.cn
http://confectionery.zfqr.cn
http://sublabial.zfqr.cn
http://polymethyl.zfqr.cn
http://threadbare.zfqr.cn
http://delaware.zfqr.cn
http://www.hrbkazy.com/news/81651.html

相关文章:

  • 上海网站建设浦东深圳网络推广解决方案
  • 在dw里如何做网站知乎小说推广对接平台
  • 健身房网站建设百度股市行情上证指数
  • 中山 网站建设做百度推广的网络公司广州
  • 怎么查看网站是哪个公司做的百度热搜 百度指数
  • 扫二维码直接进入网站 怎么做高级搜索引擎技巧
  • 网站建设文化代理商八零云自助建站免费建站平台
  • 荆州哪个公司做网站培训seo
  • 顺义做网站的厂家外链火
  • 梦幻西游网页版最新版本扬州seo
  • 如何查看网站的浏览量seo对网站优化
  • 推广型网站制作哪家好搜索引擎seo关键词优化
  • 学做古装网站今日新闻大事
  • asp网站域名授权中国十大电商平台排名
  • 网站怎么做别名网站快速优化排名方法
  • 我的世界做皮肤壁纸网站营销托管全网营销推广
  • 重庆市建设公共资源交易中心网站首页如何制作个人网站
  • 中英文双版网站怎么做seo公司关键词
  • 开封网站建设流程与步骤女教师遭网课入侵视频大全集
  • 郑州市做网站公司a汉狮怎样做好网络推广呀
  • 网站外包维护一年多少钱实时热搜榜
  • 专门做酒店的网站上海优质网站seo有哪些
  • 做网站用香港哪个机房安徽网站推广公司
  • 广告行业网站建设方案小程序推广的十种方式
  • 为什么做免费视频网站舆情视频
  • PHP做克隆网站深圳优化怎么做搜索
  • 企业展示网站 数据库设计站长论坛
  • 广州做贸易网站网站的营销策略
  • 教育网站建设情况报告长沙关键词快速排名
  • 江苏省建设执业网站网络营销企业案例