单来源新需求实现

  • 一 createTransferTable方法多增加一个searchAreaCode参数,传查询区编码,用来缓存查询条件,方便切换查看已选和全部列表按钮及跳转页面的时候保存查询条件
  • 二 因多来源做了勾选数据联动处理, 所以业务组在查询数据的时候以及全选的时候需将之前自定义合计方法清零的逻辑删掉

单来源转单API

转单组件分为两部分:上游列表(createTransferTable)和下游转单(createTransferList)。上游列表分为单来源和多来源。

  1. import React, { Component } from 'react';
  2. import { Row,Col } from "tinper-bee";
  3. import { Router, Route, hashHistory } from 'react-router';
  4. import { initTemplate, initTemplateFull, initTransferTemplate, initTransferListTemplate,setTransferListValue,btnClick} from './events';
  5. import { createForm } from 'src/Page/Form';
  6. import { createPage } from 'src';
  7. import NCButton from 'src/base/nc_Button';
  8. import './list.less'
  9. class TransferTable extends Component {
  10. constructor(props) {
  11. super(props);
  12. this.headTableId = "reva_revecont";
  13. this.transformFormId = "formAreaId";
  14. this.state = {
  15. tableData: [] //表格数据
  16. }
  17. }
  18. componentDidMount() {
  19. setTimeout( () => {
  20. let transferData =
  21. {
  22. data:[
  23. {
  24. head:{
  25. reva_revecont:{
  26. rows:[
  27. {
  28. values: {
  29. vbillcode: {
  30. value: Math.ceil(Math.random() * 100000000)
  31. },
  32. pk_org_v: {
  33. display: '辅导辅导费',
  34. value: '1001A11000000000058I'
  35. },
  36. ts: {
  37. value: '2018-03-21 10:53:18'
  38. },
  39. switch1: {
  40. value: true
  41. },
  42. crevecontid: {
  43. display: 'jykukuk',
  44. value: '1001A310008780005SC8'
  45. },
  46. ccustomerid: {
  47. display: '434r32tt',
  48. value: '1001A11000000000223R'
  49. },
  50. pk_org: {
  51. display: '8i87i78i87i',
  52. value: '0001A11000000000246T'
  53. },
  54. ctrantypeid: {
  55. display: 'e32e32e',
  56. value: '1001Z510000000004JMJ'
  57. },
  58. bcloseflag: {
  59. value: false
  60. },
  61. vname: {
  62. value: 'wew'
  63. },
  64. dbilldate: {
  65. value: '2018-05-12'
  66. },
  67. cdeptvid: {
  68. display: "研发部",
  69. value: "1001Z510000000004JMJ"
  70. },
  71. fstatusflag: {
  72. display: "自由态",
  73. value: "0"
  74. },
  75. noritotalmny: {
  76. value: "245456.70"
  77. },
  78. ndealtotalmny: {
  79. value: "245456.70"
  80. },
  81. fstageflag: {
  82. display: "已识别合同",
  83. value: "1"
  84. },
  85. isstartpf: {
  86. display: "",
  87. value: "35"
  88. },
  89. fpfstatusflag: {
  90. display: "",
  91. value: "35"
  92. },
  93. ccurrencyid: {
  94. display: "人民币",
  95. value: "u6u6u6u6u6u"
  96. },
  97. ts: {
  98. display: "",
  99. value: "23435454545"
  100. },
  101. datepicker: {
  102. display: "",
  103. value: "654645757575"
  104. },
  105. dmakedate: {
  106. display: "",
  107. value: "6ui6i77000"
  108. },
  109. vtrantypecode: {
  110. display: "",
  111. value: "5u5uut4t"
  112. },
  113. }
  114. }
  115. ]
  116. }
  117. },
  118. body:{
  119. revecont_b:{
  120. rows: [
  121. {
  122. status: 0,
  123. values: {
  124. crevecontbid: { value: "43t4t22222" },
  125. crowno: { value: '2018-2-10' },
  126. cpobid: { value: '北京市海淀区第一仓库' },
  127. "cpobid.vname": { value: '张三' },
  128. fconfirmpoint: { value: '0' },
  129. npobnum: { value: 65 },
  130. cunitid: { value: '北京市用友产业园中区' },
  131. nallotmny: { value: '北京市蓝蓝科技公司' },
  132. nfinishnum: { value: '自由' },
  133. nfinishmny: { value: '自由' },
  134. cmaterialvid: { value: '自由' },
  135. ts: { value: '自由11' },
  136. vrownote: { value: '自由' },
  137. }
  138. },
  139. {
  140. status: 0,
  141. values: {
  142. crevecontbid: { value: "878787878" },
  143. crowno: { value: '2018-2-10' },
  144. cpobid: { value: '北京市海淀区第一仓库' },
  145. "cpobid.vname": { value: '张三' },
  146. fconfirmpoint: { value: '0' },
  147. npobnum: { value: 65 },
  148. cunitid: { value: '北京市用友产业园中区' },
  149. nallotmny: { value: '北京市蓝蓝科技公司' },
  150. nfinishnum: { value: '自由' },
  151. nfinishmny: { value: '自由' },
  152. cmaterialvid: { value: '自由' },
  153. ts: { value: '22' },
  154. vrownote: { value: '自由' },
  155. }
  156. },
  157. {
  158. status: 0,
  159. values: {
  160. crevecontbid: { value: "9809090" },
  161. crowno: { value: '2018-2-10' },
  162. cpobid: { value: '北京市海淀区第一仓库' },
  163. "cpobid.vname": { value: '张三' },
  164. fconfirmpoint: { value: '0' },
  165. npobnum: { value: 65 },
  166. cunitid: { value: '北京市用友产业园中区' },
  167. nallotmny: { value: '北京市蓝蓝科技公司' },
  168. nfinishnum: { value: '自由' },
  169. nfinishmny: { value: '自由' },
  170. cmaterialvid: { value: '自由' },
  171. ts: { value: '33' },
  172. vrownote: { value: '自由' },
  173. }
  174. },
  175. {
  176. status: 0,
  177. values: {
  178. crevecontbid: { value: "3r3r3r3" },
  179. crowno: { value: '2018-2-10' },
  180. cpobid: { value: '北京市海淀区第一仓库' },
  181. "cpobid.vname": { value: '张三' },
  182. fconfirmpoint: { value: '0' },
  183. npobnum: { value: 65 },
  184. cunitid: { value: '北京市用友产业园中区' },
  185. nallotmny: { value: '北京市蓝蓝科技公司' },
  186. nfinishnum: { value: '自由' },
  187. nfinishmny: { value: '自由' },
  188. cmaterialvid: { value: '自由' },
  189. ts: { value: '44' },
  190. vrownote: { value: '自由' },
  191. }
  192. }
  193. ]
  194. }
  195. }
  196. },
  197. ]
  198. }
  199. this.props.transferTable.setTransferTableValue(this.headTableId,'revecont_b', transferData.data,"crevecontid",'crevecontbid');
  200. this.setState({
  201. tableData: transferData.data
  202. })
  203. }, 100)
  204. }
  205. // react:界面渲染函数
  206. render() {
  207. const { transferTable, form, button, search, editTable } = this.props;
  208. const { NCCreateSearch } = search;
  209. const { createForm } = form;
  210. const { createButton } = button;
  211. const { createEditTable } = editTable;
  212. const { createTransferTable, createTransferList } = transferTable;
  213. let selectedShow = transferTable.getSelectedListDisplay(this.headTableId);
  214. this.setTransferListValue = setTransferListValue;
  215. this.initTransferTemplate = initTransferTemplate;
  216. this.initTransferListTemplate = initTransferListTemplate;
  217. return (
  218. <div className="nc-bill-list" id="transferDemo">
  219. {
  220. !selectedShow ?
  221. <div>
  222. <div className='nc-bill-header-area'>
  223. <div className='header-title-search-area'>
  224. <h2 className='title-search-detail'>选择订单/入库单</h2>
  225. </div>
  226. </div>
  227. <div className='nc-bill-search-area'>
  228. <a href="javascript:;" style={{float: 'right'}} onClick={() => {
  229. if (!this.props.meta.getMeta()['reva_revecont_main']) {
  230. initTemplateFull(this.props); //加载主子拉平模板
  231. }
  232. this.props.transferTable.changeViewType(this.headTableId);
  233. }}>切换</a>
  234. {NCCreateSearch(
  235. 'reve_search',//模块id
  236. )}
  237. </div>
  238. </div>
  239. : ''
  240. }
  241. <div className='nc-bill-transferTable-area'>
  242. { createTransferTable(
  243. {
  244. searchAreaCode: 'search30', // 用于缓存查询条件
  245. tableType: 'full',//选填 表格默认显示的类型 full:主子拉平 nest:主子表
  246. headTableId: this.headTableId,//表格组件id
  247. bodyTableId: 'revecont_b',//子表模板id
  248. fullTableId: 'reva_revecont_main',//主子拉平模板id
  249. transferBtnText: '生成采购单', //转单按钮显示文字
  250. containerSelector: '#transferDemo', //容器的选择器 必须唯一,用于设置底部已选区域宽度
  251. showChangeViewBtn:true,//控制已选列表页面 切换主子表/拉平表 切换按钮的显示 Boolean,默认是true显示,需要隐藏未false
  252. selectArea: () => {//已选列表自定义区域
  253. return <span>
  254. <span>本次开票数量:5000.00</span>
  255. <span>本次开票金额:58500.00</span>
  256. <NCButton>一键制单</NCButton>
  257. <NCButton>单据对冲</NCButton>
  258. </span>
  259. },
  260. onExpandedChange:(pks)=>{
  261. //pks Array类型 是当前转单展开的所有主表的pk
  262. },
  263. onTransferBtnClick: (ids) => { //点击转单按钮钩子函数
  264. console.log(ids)
  265. hashHistory.push({
  266. pathname: '/transferList?type=transfer'
  267. })
  268. },
  269. onChangeViewClick: () => { //点击切换视图钩子函数
  270. if (!this.props.meta.getMeta()['reva_revecont_main']) {
  271. initTemplateFull(this.props); //加载主子拉平模板
  272. }
  273. this.props.transferTable.changeViewType(this.headTableId);
  274. },
  275. onCheckedChange: (flag, record, index, bodys) => { //勾选的回调函数
  276. console.log('勾选', flag, record, index)
  277. bodys && console.log('子表', bodys)
  278. },
  279. onClearAll: () => {
  280. console.log('清空啦')
  281. }
  282. }
  283. )}
  284. </div>
  285. </div>
  286. );
  287. }
  288. }
  289. export default createPage({
  290. initTemplate: initTemplate
  291. })(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移除的表头数据, 移除的表体数据 | 已选列表移除回调函数在回调函数中可进行合计的处理 |