tuiDan.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. import React from 'react';
  2. import $ from 'jquery/src/ajax';
  3. import moment from 'moment';
  4. import './public.less';
  5. import { Button,InputNumber,Select , Input, Spin, Table, message, DatePicker } from 'antd';
  6. import Receivable from './receivable';
  7. import Examine from './examine';
  8. import OrderDesc from '../orderDetail/orderDesc';
  9. import {getLiquidationStatus,getNewOrderStatus,getRefundStatus} from '@/tools';
  10. import { ChooseList } from "../../order/orderNew/chooseList";
  11. const TuiDan = React.createClass({
  12. departmentList() {
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "get",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  21. data: {},
  22. success: function(data) {
  23. let thedata = data.data;
  24. let theArr = [];
  25. if (!thedata) {
  26. if (data.error && data.error.length) {
  27. message.warning(data.error[0].message);
  28. }
  29. } else {
  30. thedata.map(function(item, index) {
  31. theArr.push({
  32. key: index,
  33. name: item.name,
  34. id: item.id
  35. });
  36. });
  37. }
  38. this.setState({
  39. departmentArr: theArr
  40. });
  41. }.bind(this)
  42. }).always(
  43. function() {
  44. this.setState({
  45. loading: false
  46. });
  47. }.bind(this)
  48. );
  49. },
  50. loadData(pageNo) {
  51. this.state.data = [];
  52. this.setState({
  53. selectedRowKeys: [],
  54. selectedRowKey: [],
  55. page: pageNo,
  56. loading: true
  57. });
  58. $.ajax({
  59. method: "get",
  60. dataType: "json",
  61. crossDomain: false,
  62. url: globalConfig.context + "/api/admin/financial/getRefundList",
  63. data: {
  64. pageNo: pageNo || 1,
  65. pageSize: this.state.pagination.pageSize,
  66. id: this.state.orderRefundSearch,
  67. buyName: this.state.nameSearch, //客户名称
  68. orderNo: this.state.orderNoSearch,
  69. refundStatus: this.state.refundStatus,
  70. startTime: this.state.releaseDate[0],
  71. endTime: this.state.releaseDate[1],
  72. departmentId: this.state.departmenttList
  73. },
  74. success: function(data) {
  75. let theArr = [];
  76. if (!data.data || !data.data.list) {
  77. if (data.error && data.error.length) {
  78. message.warning(data.error[0].message);
  79. }
  80. } else {
  81. for (let i = 0; i < data.data.list.length; i++) {
  82. let thisdata = data.data.list[i];
  83. theArr.push({
  84. key: i,
  85. id: thisdata.id,
  86. orderNo: thisdata.orderNo,
  87. orderType: thisdata.orderType,
  88. buyName: thisdata.buyName,
  89. companyName: thisdata.buyName,
  90. buyerName: thisdata.saleName,
  91. contractNo: thisdata.contractNo,
  92. buyerId: "0",
  93. refundAmount: thisdata.refundAmount,
  94. companyId: thisdata.buyid,
  95. orderStatus: thisdata.orderStatus,
  96. liquidationStatus: thisdata.liquidationStatus,
  97. refundStatus: thisdata.refundStatus,
  98. saleName: thisdata.saleName,
  99. createTime: thisdata.createTime
  100. ? new Date(thisdata.createTime).toLocaleString()
  101. : ""
  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. totalPage: data.data.totalPage,
  113. dataSource: theArr,
  114. pagination: this.state.pagination
  115. });
  116. }.bind(this)
  117. }).always(
  118. function() {
  119. this.setState({
  120. loading: false
  121. });
  122. }.bind(this)
  123. );
  124. },
  125. getInitialState() {
  126. return {
  127. searchMore: true,
  128. assignVisible: false,
  129. releaseDate: [],
  130. totalPage: 0,
  131. assignData: [],
  132. // 子组件改变的表格title数组
  133. changeList: undefined,
  134. boHuivisible: false,
  135. selectedRowKeys: [],
  136. selectedRows: [],
  137. loading: false,
  138. pagination: {
  139. defaultCurrent: 1,
  140. defaultPageSize: 10,
  141. showQuickJumper: true,
  142. pageSize: 10,
  143. onChange: function(page) {
  144. this.loadData(page);
  145. }.bind(this),
  146. showTotal: function(total) {
  147. return "共" + total + "条数据";
  148. }
  149. },
  150. columns: [
  151. {
  152. title: "退单编号",
  153. dataIndex: "id",
  154. key: "id"
  155. // fixed: "left"
  156. },
  157. {
  158. title: "申请退单时间",
  159. dataIndex: "createTime",
  160. key: "createTime"
  161. },
  162. {
  163. title: "订单编号",
  164. dataIndex: "orderNo",
  165. key: "orderNo"
  166. },
  167. {
  168. title: "客户名称",
  169. dataIndex: "buyName",
  170. key: "buyName"
  171. },
  172. {
  173. title: "订单状态",
  174. dataIndex: "orderStatus",
  175. key: "orderStatus",
  176. render: text => {
  177. return getNewOrderStatus(text);
  178. }
  179. },
  180. {
  181. title: "订单负责人",
  182. dataIndex: "saleName",
  183. key: "saleName"
  184. },
  185. {
  186. title: "结算状态",
  187. dataIndex: "liquidationStatus",
  188. key: "liquidationStatus",
  189. render: text => {
  190. return getLiquidationStatus(text);
  191. }
  192. },
  193. {
  194. title: "审批状态",
  195. dataIndex: "refundStatus",
  196. key: "refundStatus",
  197. render: text => {
  198. return getRefundStatus(text);
  199. }
  200. },
  201. {
  202. title: "操作",
  203. dataIndex: "caozuo",
  204. key: "caouzo",
  205. render: (text, recard) => {
  206. return (
  207. <div>
  208. {recard.refundStatus == 1 && (
  209. <Button
  210. type="primary"
  211. onClick={e => {
  212. e.stopPropagation(), this.evaluate(recard);
  213. }}
  214. >
  215. 添加退款记录
  216. </Button>
  217. )}
  218. {recard.refundStatus == 0 && (
  219. <Button
  220. type="primary"
  221. onClick={e => {
  222. e.stopPropagation(), this.reject(recard);
  223. }}
  224. >
  225. 审批
  226. </Button>
  227. )}
  228. </div>
  229. );
  230. }
  231. }
  232. ],
  233. dataSource: [],
  234. examineData: {},
  235. searchTime: [,]
  236. };
  237. },
  238. /* 添加收款记录 */
  239. evaluate(recard) {
  240. this.state.assignData = recard;
  241. this.setState({
  242. assignVisible: true
  243. });
  244. },
  245. /* 驳回 */
  246. reject(recard) {
  247. this.setState({
  248. examineData: recard,
  249. examineVisible: true
  250. });
  251. },
  252. componentWillMount() {
  253. this.loadData();
  254. this.departmentList();
  255. },
  256. tableRowClick(record) {
  257. this.state.RowData = record;
  258. this.setState({
  259. showDesc: true
  260. });
  261. },
  262. closeExamine(e, s, nub) {
  263. this.state.examineData = {};
  264. this.state.examineVisible = e;
  265. if (s) {
  266. if (nub == "2") {
  267. if (
  268. this.state.pagination.current == this.state.totalPage &&
  269. this.state.pagination.total % 10 == 1
  270. ) {
  271. this.loadData(this.state.page - 1);
  272. } else {
  273. this.loadData(this.state.page);
  274. }
  275. } else {
  276. this.loadData(this.state.page);
  277. }
  278. }
  279. },
  280. closeDesc(e, s) {
  281. this.state.RowData = {};
  282. this.state.showDesc = e;
  283. if (s) {
  284. this.loadData(this.state.page);
  285. }
  286. },
  287. closeAssign(e, s) {
  288. this.state.assignData = {};
  289. this.state.assignVisible = e;
  290. if (s) {
  291. this.loadData(this.state.page);
  292. }
  293. },
  294. search() {
  295. this.loadData();
  296. },
  297. reset() {
  298. this.state.nameSearch = "";
  299. this.state.orderRefundSearch = "";
  300. this.state.releaseDate = [];
  301. this.state.orderNoSearch = "";
  302. this.state.departmenttList = undefined;
  303. this.state.refundStatus = undefined;
  304. this.loadData();
  305. },
  306. searchSwitch() {
  307. this.setState({
  308. searchMore: !this.state.searchMore
  309. });
  310. },
  311. changeList(arr) {
  312. const newArr = [];
  313. this.state.columns.forEach(item => {
  314. arr.forEach(val => {
  315. if (val === item.title) {
  316. newArr.push(item);
  317. }
  318. });
  319. });
  320. this.setState({
  321. changeList: newArr
  322. });
  323. },
  324. render() {
  325. const { RangePicker } = DatePicker;
  326. var departmentArr = this.state.departmentArr || [];
  327. return (
  328. <div className="user-content">
  329. <div className="content-title">
  330. <span>退单管理</span>
  331. </div>
  332. <div className="user-search">
  333. <InputNumber
  334. min={0}
  335. max={2147483647}
  336. formatter={value =>
  337. `${value && !isNaN(value) ? parseInt(value) : ""}`
  338. }
  339. style={{ marginRight: 10, width: 120 }}
  340. placeholder="退单编号"
  341. value={this.state.orderRefundSearch}
  342. onChange={e => {
  343. this.setState({ orderRefundSearch: e });
  344. }}
  345. />
  346. <Input
  347. placeholder="订单编号"
  348. value={this.state.orderNoSearch}
  349. onChange={e => {
  350. this.setState({ orderNoSearch: e.target.value });
  351. }}
  352. />
  353. <Input
  354. placeholder="客户名称"
  355. value={this.state.nameSearch}
  356. onChange={e => {
  357. this.setState({ nameSearch: e.target.value });
  358. }}
  359. />
  360. <Select
  361. placeholder="订单部门"
  362. style={{ width: 150, marginRight: 10 }}
  363. value={this.state.departmenttList}
  364. onChange={e => {
  365. this.setState({ departmenttList: e });
  366. }}
  367. >
  368. {departmentArr.map(function(item) {
  369. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  370. })}
  371. </Select>
  372. <Select
  373. onChange={e => {
  374. this.setState({ refundStatus: e });
  375. }}
  376. style={{ width: 160, marginRight: 5 }}
  377. placeholder="审核状态"
  378. value={this.state.refundStatus}
  379. >
  380. <Option value="0">未审核</Option>
  381. <Option value="1">审核通过</Option>
  382. <Option value="2">审核拒绝</Option>
  383. </Select>
  384. <span style={{ marginRight: 10 }}>退单时间 :</span>
  385. <RangePicker
  386. value={[
  387. this.state.releaseDate[0]
  388. ? moment(this.state.releaseDate[0])
  389. : null,
  390. this.state.releaseDate[1]
  391. ? moment(this.state.releaseDate[1])
  392. : null
  393. ]}
  394. onChange={(data, dataString) => {
  395. this.setState({ releaseDate: dataString });
  396. }}
  397. />
  398. <Button
  399. type="primary"
  400. onClick={this.search}
  401. style={{ marginLeft: 10 }}
  402. >
  403. 搜索
  404. </Button>
  405. <Button onClick={this.reset}>重置</Button>
  406. </div>
  407. <ChooseList
  408. columns={this.state.columns}
  409. changeFn={this.changeList}
  410. changeList={this.state.changeList}
  411. top={55}
  412. />
  413. <div className="patent-table">
  414. <Spin spinning={this.state.loading}>
  415. <Table
  416. bordered
  417. columns={
  418. this.state.changeList == undefined
  419. ? this.state.columns
  420. : this.state.changeList
  421. }
  422. dataSource={this.state.dataSource}
  423. scroll={{ x: 1500, y: 0 }}
  424. rowSelection={false}
  425. pagination={this.state.pagination}
  426. onRowClick={this.tableRowClick.bind(this)}
  427. bordered
  428. size="small"
  429. />
  430. </Spin>
  431. </div>
  432. <Receivable
  433. title="退款记录"
  434. api="/api/admin/financial/addRefundFlow"
  435. data={this.state.assignData}
  436. showDesc={this.state.assignVisible}
  437. closeDesc={this.closeAssign.bind(this)}
  438. />
  439. <Examine
  440. data={this.state.examineData}
  441. showDesc={this.state.examineVisible}
  442. closeDesc={this.closeExamine.bind(this)}
  443. />
  444. <OrderDesc
  445. data={this.state.RowData}
  446. showDesc={this.state.showDesc}
  447. closeDesc={this.closeDesc.bind(this)}
  448. />
  449. </div>
  450. );
  451. }
  452. });
  453. export default TuiDan;