tuiDan.jsx 14 KB

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