index.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import React, { Component } from 'react';
  2. import { createPage, createPageIcon, cardCache, high } from 'nc-lightapp-front';
  3. import { initTemplate } from './events/initTemplate';
  4. import { buttonClick } from './events/buttonClick';
  5. import { searchBtnClick } from './events/searchBtnClick';
  6. import { selectedEvent, selectedAllEvent } from './events/selectedEvent';
  7. import { LIST_BUTTON, SEARCH_CACHE, LIST, MULTILANG, PRIMARY_KEY, BILL_TYPE_CODE } from '../constant';
  8. import { pageInfoClick, handleDoubleClick, listCommit } from './events/listOperator';
  9. class List extends Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. json: {},
  14. showUploader: false,
  15. billInfo: {},
  16. compositeData: null, //指派信息
  17. compositeDisplay: false, //是否显示指派
  18. curPk: null, //当前选中数据的pk
  19. showApproveDetail: false, //是否显示审批详情
  20. billId: null
  21. };
  22. }
  23. componentWillMount() {
  24. // json: 多语json格式参数;
  25. // status: 是否请求到json多语,可用来判断多语资源是否请求到并进行一些别的操作;
  26. // inlt: 可用来进行占位符的一些操作
  27. let callback = (json, status, inlt) => {
  28. if (status) {
  29. initTemplate.call(this, this.props); // 如模板内也有多语处理,平台推荐模板加载操作放于此处, 在取到json多语资源后用传参的方式传入intemplate模板函数中
  30. // 保存json和inlt到页面state中并刷新页面
  31. this.setState({ json, inlt })
  32. }
  33. }
  34. this.props.MultiInit.getMultiLang({ moduleId: MULTILANG.moduleId, domainName: MULTILANG.domainName, callback });
  35. }
  36. componentDidMount() {
  37. let { getDefData } = cardCache;
  38. if (getDefData(SEARCH_CACHE.key, SEARCH_CACHE.dataSource)) {
  39. this.props.button.setDisabled({
  40. [LIST_BUTTON.refresh]: false
  41. });
  42. } else {
  43. this.props.button.setDisabled({
  44. [LIST_BUTTON.refresh]: true
  45. });
  46. }
  47. }
  48. handlePageInfoChange = (props, config, pks) => {
  49. pageInfoClick({ ...props, json: this.state.json }, config, pks);
  50. }
  51. onRowDoubleClick = (record, index, props) => {
  52. handleDoubleClick(record, index, { ...props, json: this.state.json });
  53. }
  54. clickSearchBtn = (props) => {
  55. searchBtnClick({ ...props, json: this.state.json });
  56. }
  57. clickSelectBtn = (props, moduleId, record, index, status) => {
  58. selectedEvent(props, moduleId, record, index, status);
  59. }
  60. clickSelectAllBtn = (props, moduleId, status, length) => {
  61. selectedAllEvent(props, moduleId, status, length);
  62. }
  63. //指派提交
  64. getAssignUser = (value) => {
  65. listCommit({ ...this.props, json: this.state.json }, {
  66. pks: this.state.curPk,
  67. userObj: value
  68. });
  69. this.compositeTurnOff();
  70. };
  71. //关闭指派
  72. compositeTurnOff = () => {
  73. this.setState({
  74. compositeData: null,
  75. compositeDisplay: false
  76. });
  77. };
  78. render() {
  79. let { table, search } = this.props;
  80. let { createSimpleTable } = table;
  81. let { NCCreateSearch } = search;
  82. let { NCUploader, BillTrack, ApprovalTrans, ApproveDetail } = high;
  83. return (
  84. <div className="nc-bill-list">
  85. <div className="nc-bill-header-area">
  86. <div className="header-title-search-area">
  87. {createPageIcon()}
  88. <h2 className="title-search-detail">{this.state.json[LIST.page_title]}</h2>
  89. </div>
  90. <div className="header-button-area">
  91. {this.props.button.createButtonApp({
  92. area: LIST.head_btn_code,
  93. onButtonClick: buttonClick.bind(this)
  94. })}
  95. </div>
  96. </div>
  97. <div className="nc-bill-search-area">
  98. {NCCreateSearch(LIST.search_id, {
  99. clickSearchBtn: this.clickSearchBtn
  100. })}
  101. </div>
  102. <div className="table-area">
  103. {createSimpleTable(LIST.table_id, {
  104. showCheck: true,
  105. dataSource: SEARCH_CACHE.dataSource,
  106. pkname: PRIMARY_KEY.head_id,
  107. handlePageInfoChange: this.handlePageInfoChange,
  108. onRowDoubleClick: this.onRowDoubleClick,
  109. onSelected: this.clickSelectBtn,
  110. onSelectedAll: this.clickSelectAllBtn,
  111. })}
  112. </div>
  113. {/* 附件 */}
  114. {this.state.showUploader && (
  115. <NCUploader
  116. placement={'bottom'}
  117. {...this.state.billInfo}
  118. onHide={() => {
  119. this.setState({
  120. showUploader: false
  121. });
  122. }}
  123. />
  124. )}
  125. {/*联查单据追溯*/}
  126. {
  127. <BillTrack
  128. show={this.state.showBillTrack}
  129. close={() => {
  130. this.setState({ showBillTrack: false });
  131. }}
  132. pk={this.state.billTrackBillId}
  133. type={this.state.billTrackBillType}
  134. />
  135. }
  136. {/* 指派 */}
  137. {this.state.compositeDisplay && (
  138. <ApprovalTrans
  139. title={this.state.json['96H10119-000018']} /* 国际化处理: 指派*/
  140. data={this.state.compositeData}
  141. display={this.state.compositeDisplay}
  142. getResult={this.getAssignUser}
  143. cancel={this.compositeTurnOff}
  144. />
  145. )}
  146. {/* 联查审批详情 */}
  147. {
  148. <ApproveDetail
  149. show={this.state.showApproveDetail}
  150. billtype={BILL_TYPE_CODE}
  151. billid={this.state.billId}
  152. close={() => {
  153. this.setState({
  154. showApproveDetail: false
  155. });
  156. }}
  157. />
  158. }
  159. </div>
  160. );
  161. }
  162. }
  163. List = createPage({
  164. })(List);
  165. export default List;