myWater.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. import React from 'react';
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import moment from 'moment';
  5. import '../distribute/public.less';
  6. import { Button, Input, Spin, Table, Switch, Select, message, DatePicker, Tabs } from 'antd';
  7. import { getTransactionProject, ShowModal } from "@/tools";
  8. import WaterDesc from './waterDetail';
  9. import { ChooseList } from "../../order/orderNew/chooseList";
  10. import ShowModalDiv from "@/showModal.jsx";
  11. const { TabPane } = Tabs
  12. const MyWater = React.createClass({
  13. departmentList() {
  14. this.setState({
  15. loading: true
  16. });
  17. $.ajax({
  18. method: "get",
  19. dataType: "json",
  20. crossDomain: false,
  21. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  22. data: {},
  23. success: function (data) {
  24. let thedata = data.data;
  25. let theArr = [];
  26. if (!thedata) {
  27. if (data.error && data.error.length) {
  28. message.warning(data.error[0].message);
  29. }
  30. thedata = {};
  31. } else {
  32. thedata.map(function (item, index) {
  33. theArr.push({
  34. key: index,
  35. name: item.name,
  36. id: item.id
  37. });
  38. });
  39. }
  40. this.setState({
  41. departmentArr: theArr
  42. });
  43. }.bind(this)
  44. }).always(
  45. function () {
  46. this.setState({
  47. loading: false
  48. });
  49. }.bind(this)
  50. );
  51. },
  52. loadData(pageNo) {
  53. this.state.data = [];
  54. this.setState({
  55. selectedRowKeys: [],
  56. selectedRowKey: [],
  57. page: pageNo,
  58. loading: true
  59. });
  60. $.ajax({
  61. method: "get",
  62. dataType: "json",
  63. crossDomain: false,
  64. url: globalConfig.context + "/api/admin/financial/myBillList",
  65. data: {
  66. pageNo: pageNo || 1,
  67. pageSize: this.state.pagination.pageSize,
  68. payeeName: this.state.payeeNameSearch,
  69. payerName: this.state.payerNameSearch,
  70. startTime: this.state.releaseDate[0],
  71. endTime: this.state.releaseDate[1],
  72. orderNo: this.state.orderNo,
  73. departmentId: this.state.departmentId
  74. },
  75. success: function (data) {
  76. ShowModal(this);
  77. let theArr = [];
  78. if (!data.data || !data.data.list) {
  79. if (data.error && data.error.length) {
  80. message.warning(data.error[0].message);
  81. }
  82. } else {
  83. for (let i = 0; i < data.data.list.length; i++) {
  84. let thisdata = data.data.list[i];
  85. theArr.push({
  86. key: i,
  87. orderNo: thisdata.orderNo,
  88. billNo: thisdata.billNo,
  89. transactionAmount: thisdata.transactionAmount,
  90. payeeName: thisdata.payeeName,
  91. payerName: thisdata.payerName,
  92. transactionSubject: thisdata.transactionSubject,
  93. transactionChannel: thisdata.transactionChannel,
  94. financialPayTimes: thisdata.financialPayTimes
  95. ? new Date(thisdata.financialPayTimes).toLocaleDateString()
  96. : "",
  97. financialPayNo: thisdata.financialPayNo,
  98. createrName: thisdata.createrName,
  99. saleName: thisdata.saleName,
  100. createTimes: thisdata.createTimes,
  101. type: thisdata.type == 0 ? "手工" : "批量"
  102. });
  103. }
  104. }
  105. this.state.pagination.current = data.data.pageNo;
  106. this.state.pagination.total = data.data.totalCount;
  107. if (data.data && data.data.list && !data.data.list.length) {
  108. this.state.pagination.current = 0;
  109. this.state.pagination.total = 0;
  110. }
  111. this.setState({
  112. dataSource: theArr,
  113. pagination: this.state.pagination
  114. });
  115. }.bind(this)
  116. }).always(
  117. function () {
  118. this.setState({
  119. loading: false
  120. });
  121. }.bind(this)
  122. );
  123. },
  124. getInitialState() {
  125. return {
  126. searchMore: true,
  127. releaseDate: [],
  128. RowData: {},
  129. selectedRowKeys: [],
  130. selectedRows: [],
  131. loading: false,
  132. // 子组件改变的表格title数组
  133. changeList: undefined,
  134. pagination: {
  135. defaultCurrent: 1,
  136. defaultPageSize: 10,
  137. showQuickJumper: true,
  138. pageSize: 10,
  139. onChange: function (page) {
  140. this.loadData(page);
  141. }.bind(this),
  142. showTotal: function (total) {
  143. return "共" + total + "条数据";
  144. }
  145. },
  146. columns: [
  147. {
  148. title: "平台流水号",
  149. dataIndex: "billNo",
  150. key: "billNo"
  151. // fixed: "left"
  152. },
  153. {
  154. title: "金额(万元)",
  155. dataIndex: "transactionAmount",
  156. key: "transactionAmount"
  157. },
  158. {
  159. title: "收款方",
  160. dataIndex: "payeeName",
  161. key: "payeeName"
  162. },
  163. {
  164. title: "付款方",
  165. dataIndex: "payerName",
  166. key: "payerName"
  167. },
  168. {
  169. title: "流水科目",
  170. dataIndex: "transactionSubject",
  171. key: "transactionSubject",
  172. render: text => {
  173. return getTransactionProject(text);
  174. }
  175. },
  176. {
  177. title: "收款类型",
  178. dataIndex: "type",
  179. key: "type"
  180. },
  181. {
  182. title: "财务流水时间",
  183. dataIndex: "financialPayTimes",
  184. key: "financialPayTimes"
  185. },
  186. {
  187. title: "财务流水号",
  188. dataIndex: "financialPayNo",
  189. key: "financialPayNo"
  190. },
  191. {
  192. title: "订单编号",
  193. dataIndex: "orderNo",
  194. key: "orderNo"
  195. },
  196. {
  197. title: "订单负责人",
  198. dataIndex: "saleName",
  199. key: "saleName"
  200. },
  201. {
  202. title: "创建时间",
  203. dataIndex: "createTimes",
  204. key: "createTimes"
  205. }
  206. ],
  207. dataSource: [],
  208. searchTime: [,]
  209. };
  210. },
  211. componentWillMount() {
  212. this.loadData();
  213. this.departmentList();
  214. },
  215. tableRowClick(record, index) {
  216. this.state.RowData = record;
  217. this.setState({
  218. showDesc: true
  219. });
  220. },
  221. closeDesc(e, s) {
  222. this.state.RowData = {};
  223. this.state.showDesc = e;
  224. if (s) {
  225. this.loadData(this.state.page);
  226. }
  227. },
  228. search() {
  229. this.loadData();
  230. },
  231. reset() {
  232. this.state.orderNo = "";
  233. this.state.payeeNameSearch = "";
  234. this.state.releaseDate = [];
  235. this.state.departmentId = undefined;
  236. this.state.payerNameSearch = "";
  237. this.loadData();
  238. },
  239. searchSwitch() {
  240. this.setState({
  241. searchMore: !this.state.searchMore
  242. });
  243. },
  244. changeList(arr) {
  245. const newArr = [];
  246. this.state.columns.forEach(item => {
  247. arr.forEach(val => {
  248. if (val === item.title) {
  249. newArr.push(item);
  250. }
  251. });
  252. });
  253. this.setState({
  254. changeList: newArr
  255. });
  256. },
  257. render() {
  258. const rowSelection = {
  259. selectedRowKeys: this.state.selectedRowKeys,
  260. onChange: (selectedRowKeys, selectedRows) => {
  261. this.setState({
  262. selectedRows: selectedRows.slice(-1),
  263. selectedRowKeys: selectedRowKeys.slice(-1)
  264. });
  265. }
  266. };
  267. const hasSelected = this.state.selectedRowKeys.length > 0;
  268. const { RangePicker } = DatePicker;
  269. var departmentArr = this.state.departmentArr || [];
  270. return (
  271. <div className="user-content">
  272. <ShowModalDiv ShowModal={this.state.showModal} />
  273. <div className="content-title" style={{ marginBottom: 10 }}>
  274. <span style={{ fontWeight: 900, fontSize: 16 }}>我的流水订单</span>
  275. </div>
  276. <Tabs
  277. defaultActiveKey="1"
  278. onChange={this.callback}
  279. className="test">
  280. <TabPane tab="搜索" key="1">
  281. <div className="user-search">
  282. <Input
  283. placeholder="订单编号"
  284. value={this.state.orderNo}
  285. style={{ marginLeft: 10 }}
  286. onChange={e => {
  287. this.setState({ orderNo: e.target.value });
  288. }}
  289. />
  290. <Input
  291. placeholder="收款方"
  292. value={this.state.payeeNameSearch}
  293. onChange={e => {
  294. this.setState({ payeeNameSearch: e.target.value });
  295. }}
  296. />
  297. <Input
  298. placeholder="付款方"
  299. value={this.state.payerNameSearch}
  300. onChange={e => {
  301. this.setState({ payerNameSearch: e.target.value });
  302. }}
  303. />
  304. <Select
  305. placeholder="订单部门"
  306. style={{ width: 150, marginRight: 10 }}
  307. value={this.state.departmentId}
  308. onChange={e => {
  309. this.setState({ departmentId: e });
  310. }}
  311. >
  312. {departmentArr.map(function (item) {
  313. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  314. })}
  315. </Select>
  316. <span style={{ marginRight: 10 }}>流水时间 :</span>
  317. <RangePicker
  318. value={[
  319. this.state.releaseDate[0]
  320. ? moment(this.state.releaseDate[0])
  321. : null,
  322. this.state.releaseDate[1]
  323. ? moment(this.state.releaseDate[1])
  324. : null
  325. ]}
  326. onChange={(data, dataString) => {
  327. this.setState({ releaseDate: dataString });
  328. }}
  329. />
  330. <Button
  331. type="primary"
  332. onClick={this.search}
  333. style={{ marginLeft: 10 }}
  334. >
  335. 搜索
  336. </Button>
  337. <Button onClick={this.reset}>重置</Button>
  338. </div>
  339. </TabPane>
  340. <TabPane tab="更改表格数据" key="2">
  341. <div style={{ marginTop: 10, marginLeft: 10 }}>
  342. <ChooseList
  343. columns={this.state.columns}
  344. changeFn={this.changeList}
  345. changeList={this.state.changeList}
  346. top={55}
  347. />
  348. </div>
  349. </TabPane>
  350. </Tabs>
  351. <div className="patent-table">
  352. <Spin spinning={this.state.loading}>
  353. <Table
  354. bordered
  355. columns={
  356. this.state.changeList == undefined
  357. ? this.state.columns
  358. : this.state.changeList
  359. }
  360. dataSource={this.state.dataSource}
  361. scroll={{ x: 1500, y: 0 }}
  362. rowSelection={false}
  363. pagination={this.state.pagination}
  364. onRowClick={this.tableRowClick}
  365. bordered
  366. size="small"
  367. />
  368. </Spin>
  369. </div>
  370. <WaterDesc
  371. data={this.state.RowData}
  372. showDesc={this.state.showDesc}
  373. closeDesc={this.closeDesc.bind(this)}
  374. />
  375. </div>
  376. );
  377. }
  378. });
  379. export default MyWater;