单来源新需求实现
- 一 createTransferTable方法多增加一个searchAreaCode参数,传查询区编码,用来缓存查询条件,方便切换查看已选和全部列表按钮及跳转页面的时候保存查询条件
- 二 因多来源做了勾选数据联动处理, 所以业务组在查询数据的时候以及全选的时候需将之前自定义合计方法清零的逻辑删掉
单来源转单API
转单组件分为两部分:上游列表(createTransferTable)和下游转单(createTransferList)。上游列表分为单来源和多来源。
import React, { Component } from 'react';import { Row,Col } from "tinper-bee";import { Router, Route, hashHistory } from 'react-router';import { initTemplate, initTemplateFull, initTransferTemplate, initTransferListTemplate,setTransferListValue,btnClick} from './events';import { createForm } from 'src/Page/Form';import { createPage } from 'src';import NCButton from 'src/base/nc_Button';import './list.less'class TransferTable extends Component {constructor(props) {super(props);this.headTableId = "reva_revecont";this.transformFormId = "formAreaId";this.state = {tableData: [] //表格数据}}componentDidMount() {setTimeout( () => {let transferData ={data:[{head:{reva_revecont:{rows:[{values: {vbillcode: {value: Math.ceil(Math.random() * 100000000)},pk_org_v: {display: '辅导辅导费',value: '1001A11000000000058I'},ts: {value: '2018-03-21 10:53:18'},switch1: {value: true},crevecontid: {display: 'jykukuk',value: '1001A310008780005SC8'},ccustomerid: {display: '434r32tt',value: '1001A11000000000223R'},pk_org: {display: '8i87i78i87i',value: '0001A11000000000246T'},ctrantypeid: {display: 'e32e32e',value: '1001Z510000000004JMJ'},bcloseflag: {value: false},vname: {value: 'wew'},dbilldate: {value: '2018-05-12'},cdeptvid: {display: "研发部",value: "1001Z510000000004JMJ"},fstatusflag: {display: "自由态",value: "0"},noritotalmny: {value: "245456.70"},ndealtotalmny: {value: "245456.70"},fstageflag: {display: "已识别合同",value: "1"},isstartpf: {display: "",value: "35"},fpfstatusflag: {display: "",value: "35"},ccurrencyid: {display: "人民币",value: "u6u6u6u6u6u"},ts: {display: "",value: "23435454545"},datepicker: {display: "",value: "654645757575"},dmakedate: {display: "",value: "6ui6i77000"},vtrantypecode: {display: "",value: "5u5uut4t"},}}]}},body:{revecont_b:{rows: [{status: 0,values: {crevecontbid: { value: "43t4t22222" },crowno: { value: '2018-2-10' },cpobid: { value: '北京市海淀区第一仓库' },"cpobid.vname": { value: '张三' },fconfirmpoint: { value: '0' },npobnum: { value: 65 },cunitid: { value: '北京市用友产业园中区' },nallotmny: { value: '北京市蓝蓝科技公司' },nfinishnum: { value: '自由' },nfinishmny: { value: '自由' },cmaterialvid: { value: '自由' },ts: { value: '自由11' },vrownote: { value: '自由' },}},{status: 0,values: {crevecontbid: { value: "878787878" },crowno: { value: '2018-2-10' },cpobid: { value: '北京市海淀区第一仓库' },"cpobid.vname": { value: '张三' },fconfirmpoint: { value: '0' },npobnum: { value: 65 },cunitid: { value: '北京市用友产业园中区' },nallotmny: { value: '北京市蓝蓝科技公司' },nfinishnum: { value: '自由' },nfinishmny: { value: '自由' },cmaterialvid: { value: '自由' },ts: { value: '22' },vrownote: { value: '自由' },}},{status: 0,values: {crevecontbid: { value: "9809090" },crowno: { value: '2018-2-10' },cpobid: { value: '北京市海淀区第一仓库' },"cpobid.vname": { value: '张三' },fconfirmpoint: { value: '0' },npobnum: { value: 65 },cunitid: { value: '北京市用友产业园中区' },nallotmny: { value: '北京市蓝蓝科技公司' },nfinishnum: { value: '自由' },nfinishmny: { value: '自由' },cmaterialvid: { value: '自由' },ts: { value: '33' },vrownote: { value: '自由' },}},{status: 0,values: {crevecontbid: { value: "3r3r3r3" },crowno: { value: '2018-2-10' },cpobid: { value: '北京市海淀区第一仓库' },"cpobid.vname": { value: '张三' },fconfirmpoint: { value: '0' },npobnum: { value: 65 },cunitid: { value: '北京市用友产业园中区' },nallotmny: { value: '北京市蓝蓝科技公司' },nfinishnum: { value: '自由' },nfinishmny: { value: '自由' },cmaterialvid: { value: '自由' },ts: { value: '44' },vrownote: { value: '自由' },}}]}}},]}this.props.transferTable.setTransferTableValue(this.headTableId,'revecont_b', transferData.data,"crevecontid",'crevecontbid');this.setState({tableData: transferData.data})}, 100)}// react:界面渲染函数render() {const { transferTable, form, button, search, editTable } = this.props;const { NCCreateSearch } = search;const { createForm } = form;const { createButton } = button;const { createEditTable } = editTable;const { createTransferTable, createTransferList } = transferTable;let selectedShow = transferTable.getSelectedListDisplay(this.headTableId);this.setTransferListValue = setTransferListValue;this.initTransferTemplate = initTransferTemplate;this.initTransferListTemplate = initTransferListTemplate;return (<div className="nc-bill-list" id="transferDemo">{!selectedShow ?<div><div className='nc-bill-header-area'><div className='header-title-search-area'><h2 className='title-search-detail'>选择订单/入库单</h2></div></div><div className='nc-bill-search-area'><a href="javascript:;" style={{float: 'right'}} onClick={() => {if (!this.props.meta.getMeta()['reva_revecont_main']) {initTemplateFull(this.props); //加载主子拉平模板}this.props.transferTable.changeViewType(this.headTableId);}}>切换</a>{NCCreateSearch('reve_search',//模块id)}</div></div>: ''}<div className='nc-bill-transferTable-area'>{ createTransferTable({searchAreaCode: 'search30', // 用于缓存查询条件tableType: 'full',//选填 表格默认显示的类型 full:主子拉平 nest:主子表headTableId: this.headTableId,//表格组件idbodyTableId: 'revecont_b',//子表模板idfullTableId: 'reva_revecont_main',//主子拉平模板idtransferBtnText: '生成采购单', //转单按钮显示文字containerSelector: '#transferDemo', //容器的选择器 必须唯一,用于设置底部已选区域宽度showChangeViewBtn:true,//控制已选列表页面 切换主子表/拉平表 切换按钮的显示 Boolean,默认是true显示,需要隐藏未falseselectArea: () => {//已选列表自定义区域return <span><span>本次开票数量:5000.00</span><span>本次开票金额:58500.00</span><NCButton>一键制单</NCButton><NCButton>单据对冲</NCButton></span>},onExpandedChange:(pks)=>{//pks Array类型 是当前转单展开的所有主表的pk},onTransferBtnClick: (ids) => { //点击转单按钮钩子函数console.log(ids)hashHistory.push({pathname: '/transferList?type=transfer'})},onChangeViewClick: () => { //点击切换视图钩子函数if (!this.props.meta.getMeta()['reva_revecont_main']) {initTemplateFull(this.props); //加载主子拉平模板}this.props.transferTable.changeViewType(this.headTableId);},onCheckedChange: (flag, record, index, bodys) => { //勾选的回调函数console.log('勾选', flag, record, index)bodys && console.log('子表', bodys)},onClearAll: () => {console.log('清空啦')}})}</div></div>);}}export default createPage({initTemplate: initTemplate})(TransferTable);
| 参数 | 参数说明 | 使用说明 |
|---|---|---|
| customAreaOfSelectedHead | 单转单已选列表右上角自定义区域 | customAreaOfSelectedHead : () => {return test} |
| maxHeight | 传入此参数进行设置转单表格最大高度,由此调整表格滚动条的位置 | maxHeight : 500 |
| 方法名 | 参数 | 说明 |
|---|---|---|
| createTransferTable({ searchAreaCode, headTableId, bodyTableId, fullTableId, transferBtnText, onTransferBtnClick, containerSelector, onChangeViewClick, tableType, selectArea showMasterIndex showChildIndex showChangeViewBtn, }) |
searchAreaCode: 如果在页面跳转的时候需要缓存查询区的查询条件,传此参数, tableType:表格默认显示的类型,可不填,不填默认为主子表模式 full:主子拉平 nest:主子表 simple:单表 headTableId:表格主表组件id bodyTableId:表格子表模板id fullTableId:主子拉平模板id transferBtnText:转单按钮显示文字 onTransferBtnClick:点击转单按钮钩子函数 containerSelector:容器的选择器 必须唯一,用于设置底部已选区域宽度 onChangeViewClick:点击切换视图钩子函数 selectArea:已选列表底部自定义区域 showMasterIndex:是否显示主表序号 showChildIndex:是否显示子表序号 showChangeViewBtn:true,//控制已选列表页面 切换主子表/拉平表 切换按钮的显示 Boolean,默认是true显示,需要隐藏未false |
创建单来源转单 |
| setTransferTableValue(id, childCode, newData, rowId, childId) | id:主表id childCode:子表id newData:放入表格的数据 rowId:主表主键字段,如果是全部多来源转单需要传数组,其他页签主表主键放到数组中 childId:子表主键字段,如果是全部多来源转单需要传数组,其他页签子表主键放到数组中 |
| 设置转单表格数据
单来源:this.props.transferTable.setTransferTableValue(“reva_revecont”,’revecont_b’, transferData.data,”crevecontid”,’crevecontbid’)
单来源单表的子表id和子表主键需要传空字符串:this.props.transferTable.setTransferTableValue(this.headTableId, ‘’, simpleData.data.reva_revecont,”crevecontid”,’’);
多来源(后两个参数需要将其他页签的主/子表主键字段放到数组中传进来):this.props.transferTable.setTransferTableValue(META.allHeadTableId, ‘revecont_b_all’, listTableAll.data, [‘crevecontid’,’pk1’], [‘crevecontbid’,’pk2’]) |
| getTransferTableValue(headTableId) | 当前页签的headTableId | 获取当前页签转单所有数据 |
| getTransferTableSelectedValue() | | 获取表格所有勾选数据 |
| getSelectedListDisplay() | | 获取已选列表显示状态 |
| changeViewType() | | 切换视图 |
| setMultiSelectedValue(headId, bodyId, data, rowId, childId) | headId:主表id
bodyId:子表id
data:要设置的数据
rowId:各页签主表主键字段数组
childId:各页签子表主键字段数组 | 设置全部多来源转单已选列表的数据
this.props.transferTable.setMultiSelectedValue(META.allHeadTableId, ‘revecont_b_all’, listTableAll.data, [‘crevecontid’, ‘crevecontid1’], [‘crevecontbid’, ‘crevecontbid2’]); |
| onCheckedChange(flag,record,index,bodys) | flag:勾选状态
record:该条勾选的数据
index:勾选的index
bodys:勾选主表的子表数据,如果勾选的不是主表,该参数没有值 | 勾选的钩子函数 |
| onClearAll() | | 已选列表清空的钩子函数 |
| onSelectedItemRemove(headData, bodyData) | headData移除的表头数据, 移除的表体数据 | 已选列表移除回调函数在回调函数中可进行合计的处理 |
