tuiDan.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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
  177. // style={{
  178. // maxWidth:'150px',
  179. // overflow:'hidden',
  180. // textOverflow: "ellipsis",
  181. // whiteSpace:'nowrap',
  182. // }}
  183. >{text}</div>
  184. </Tooltip>
  185. )
  186. },
  187. },
  188. {
  189. title: "订单状态",
  190. dataIndex: "orderStatus",
  191. key: "orderStatus",
  192. render: text => {
  193. return getNewOrderStatus(text);
  194. }
  195. },
  196. {
  197. title: "订单负责人",
  198. dataIndex: "saleName",
  199. key: "saleName"
  200. },
  201. {
  202. title: "结算状态",
  203. dataIndex: "liquidationStatus",
  204. key: "liquidationStatus",
  205. render: text => {
  206. return getLiquidationStatus(text);
  207. }
  208. },
  209. {
  210. title: "审批状态",
  211. dataIndex: "refundStatus",
  212. key: "refundStatus",
  213. render: text => {
  214. return getRefundStatus(text);
  215. }
  216. },
  217. {
  218. title: "操作",
  219. dataIndex: "caozuo",
  220. key: "caouzo",
  221. render: (text, recard) => {
  222. return (
  223. <div>
  224. {recard.refundStatus == 1 && (
  225. <Button
  226. type="primary"
  227. onClick={e => {
  228. e.stopPropagation(), this.evaluate(recard);
  229. }}
  230. >
  231. 添加退款记录
  232. </Button>
  233. )}
  234. {recard.refundStatus == 0 && (
  235. <Button
  236. type="primary"
  237. onClick={e => {
  238. e.stopPropagation(), this.reject(recard);
  239. }}
  240. >
  241. 审批
  242. </Button>
  243. )}
  244. </div>
  245. );
  246. }
  247. }
  248. ],
  249. dataSource: [],
  250. examineData: {},
  251. searchTime: [,]
  252. };
  253. },
  254. /* 添加收款记录 */
  255. evaluate(recard) {
  256. this.state.assignData = recard;
  257. this.setState({
  258. assignVisible: true
  259. });
  260. },
  261. /* 驳回 */
  262. reject(recard) {
  263. this.setState({
  264. examineData: recard,
  265. examineVisible: true
  266. });
  267. },
  268. componentWillMount() {
  269. this.loadData();
  270. this.departmentList();
  271. },
  272. tableRowClick(record) {
  273. this.state.RowData = record;
  274. this.setState({
  275. showDesc: true
  276. });
  277. },
  278. closeExamine(e, s, nub) {
  279. this.state.examineData = {};
  280. this.state.examineVisible = e;
  281. if (s) {
  282. if (nub == "2") {
  283. if (
  284. this.state.pagination.current == this.state.totalPage &&
  285. this.state.pagination.total % 10 == 1
  286. ) {
  287. this.loadData(this.state.page - 1);
  288. } else {
  289. this.loadData(this.state.page);
  290. }
  291. } else {
  292. this.loadData(this.state.page);
  293. }
  294. }
  295. },
  296. closeDesc(e, s) {
  297. this.state.RowData = {};
  298. this.state.showDesc = e;
  299. if (s) {
  300. this.loadData(this.state.page);
  301. }
  302. },
  303. closeAssign(e, s) {
  304. this.state.assignData = {};
  305. this.state.assignVisible = e;
  306. if (s) {
  307. this.loadData(this.state.page);
  308. }
  309. },
  310. search() {
  311. this.loadData();
  312. },
  313. reset() {
  314. this.state.nameSearch = "";
  315. this.state.orderRefundSearch = "";
  316. this.state.releaseDate = [];
  317. this.state.orderNoSearch = "";
  318. this.state.departmenttList = undefined;
  319. this.state.refundStatus = undefined;
  320. this.loadData();
  321. },
  322. searchSwitch() {
  323. this.setState({
  324. searchMore: !this.state.searchMore
  325. });
  326. },
  327. changeList(arr) {
  328. const newArr = [];
  329. this.state.columns.forEach(item => {
  330. arr.forEach(val => {
  331. if (val === item.title) {
  332. newArr.push(item);
  333. }
  334. });
  335. });
  336. this.setState({
  337. changeList: newArr
  338. });
  339. },
  340. render() {
  341. const { RangePicker } = DatePicker;
  342. var departmentArr = this.state.departmentArr || [];
  343. return (
  344. <div className="user-content">
  345. <div className="content-title" style={{ marginBottom: 10 }}>
  346. <span style={{ fontWeight: 900, fontSize: 16 }}>退单管理</span>
  347. </div>
  348. <Tabs
  349. defaultActiveKey="1"
  350. onChange={this.callback}
  351. className="test">
  352. <TabPane tab="搜索" key="1">
  353. <div className="user-search">
  354. <InputNumber
  355. min={0}
  356. max={2147483647}
  357. formatter={value =>
  358. `${value && !isNaN(value) ? parseInt(value) : ""}`
  359. }
  360. style={{ marginRight: 10, width: 120, marginLeft: 10 }}
  361. placeholder="退单编号"
  362. value={this.state.orderRefundSearch}
  363. onChange={e => {
  364. this.setState({ orderRefundSearch: e });
  365. }}
  366. />
  367. <Input
  368. placeholder="订单编号"
  369. value={this.state.orderNoSearch}
  370. onChange={e => {
  371. this.setState({ orderNoSearch: e.target.value });
  372. }}
  373. />
  374. <Input
  375. placeholder="客户名称"
  376. value={this.state.nameSearch}
  377. onChange={e => {
  378. this.setState({ nameSearch: e.target.value });
  379. }}
  380. />
  381. <Select
  382. placeholder="订单部门"
  383. style={{ width: 150, marginRight: 10 }}
  384. value={this.state.departmenttList}
  385. onChange={e => {
  386. this.setState({ departmenttList: e });
  387. }}
  388. >
  389. {departmentArr.map(function (item) {
  390. return <Select.Option key={item.id}>{item.name}</Select.Option>;
  391. })}
  392. </Select>
  393. <Select
  394. onChange={e => {
  395. this.setState({ refundStatus: e });
  396. }}
  397. style={{ width: 160, marginRight: 5 }}
  398. placeholder="审核状态"
  399. value={this.state.refundStatus}
  400. >
  401. <Option value="0">未审核</Option>
  402. <Option value="1">审核通过</Option>
  403. <Option value="2">审核拒绝</Option>
  404. </Select>
  405. <span style={{ marginRight: 10 }}>退单时间 :</span>
  406. <RangePicker
  407. value={[
  408. this.state.releaseDate[0]
  409. ? moment(this.state.releaseDate[0])
  410. : null,
  411. this.state.releaseDate[1]
  412. ? moment(this.state.releaseDate[1])
  413. : null
  414. ]}
  415. onChange={(data, dataString) => {
  416. this.setState({ releaseDate: dataString });
  417. }}
  418. />
  419. <Button
  420. type="primary"
  421. onClick={this.search}
  422. style={{ marginLeft: 10 }}
  423. >
  424. 搜索
  425. </Button>
  426. <Button onClick={this.reset}>重置</Button>
  427. </div>
  428. </TabPane>
  429. <TabPane tab="更改表格数据" key="2">
  430. <div style={{ marginLeft: 10, marginTop: 10 }}>
  431. <ChooseList
  432. columns={this.state.columns}
  433. changeFn={this.changeList}
  434. changeList={this.state.changeList}
  435. top={55}
  436. /></div>
  437. </TabPane>
  438. </Tabs>
  439. <div className="patent-table">
  440. <Spin spinning={this.state.loading}>
  441. <Table
  442. columns={
  443. this.state.changeList == undefined
  444. ? this.state.columns
  445. : this.state.changeList
  446. }
  447. dataSource={this.state.dataSource}
  448. scroll={{ x: 1500, y: 0 }}
  449. rowSelection={false}
  450. pagination={this.state.pagination}
  451. onRowClick={this.tableRowClick.bind(this)}
  452. bordered
  453. size="small"
  454. />
  455. </Spin>
  456. </div>
  457. <Receivable
  458. title="退款记录"
  459. api="/api/admin/financial/addRefundFlow"
  460. data={this.state.assignData}
  461. showDesc={this.state.assignVisible}
  462. closeDesc={this.closeAssign.bind(this)}
  463. />
  464. <Examine
  465. data={this.state.examineData}
  466. showDesc={this.state.examineVisible}
  467. closeDesc={this.closeExamine.bind(this)}
  468. />
  469. <OrderDesc
  470. data={this.state.RowData}
  471. showDesc={this.state.showDesc}
  472. closeDesc={this.closeDesc.bind(this)}
  473. />
  474. </div>
  475. );
  476. }
  477. });
  478. export default TuiDan;