paiDan.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import moment from "moment";
  4. import "./public.less";
  5. import {
  6. Button,
  7. Form,
  8. Input,
  9. Select,
  10. Spin,
  11. Table,
  12. message,
  13. DatePicker,
  14. Modal, Tabs
  15. } from "antd";
  16. import OrderDesc from "@/manageCenter/financialManage/orderDetail/orderDesc";
  17. import Assign from "@/manageCenter/publicComponent/assign";
  18. import { getProcessStatus, getApproval } from "@/tools";
  19. import {ChooseList} from "../../order/orderNew/chooseList";
  20. import DepartmentList from "../../../common/departmentList";
  21. const FormItem = Form.Item;
  22. const {TabPane} = Tabs;
  23. const PaiDan = React.createClass({
  24. loadData(pageNo) {
  25. this.state.data = [];
  26. this.setState({
  27. selectedRowKeys: [],
  28. selectedRowKey: [],
  29. page: pageNo,
  30. loading: true
  31. });
  32. $.ajax({
  33. method: "get",
  34. dataType: "json",
  35. crossDomain: false,
  36. url: globalConfig.context + "/api/admin/financial/allUnassignedOrder",
  37. data: {
  38. pageNo: pageNo || 1,
  39. pageSize: this.state.pagination.pageSize,
  40. buyerName: this.state.nameSearch, //客户名称
  41. orderNo: this.state.orderNoSearch,
  42. startTime: this.state.releaseDate[0],
  43. endTime: this.state.releaseDate[1],
  44. processStatus: this.state.processStatusSearch,
  45. contractNo: this.state.contractNoSearch,
  46. departmentId: this.state.departmenttList,
  47. outsource: 0
  48. },
  49. success: function(data) {
  50. let theArr = [];
  51. if (!data.data || !data.data.list) {
  52. if (data.error && data.error.length) {
  53. message.warning(data.error[0].message);
  54. }
  55. } else {
  56. for (let i = 0; i < data.data.list.length; i++) {
  57. let thisdata = data.data.list[i];
  58. theArr.push({
  59. key: i,
  60. orderNo: thisdata.orderNo,
  61. approval: thisdata.approval,
  62. orderType: thisdata.orderType,
  63. processStatus: thisdata.processStatus,
  64. signTotalAmount: thisdata.signTotalAmount,
  65. buyerName: thisdata.buyerName,
  66. sellerName: thisdata.sellerName,
  67. createTime: thisdata.createTime
  68. ? new Date(thisdata.createTime).toLocaleString()
  69. : "",
  70. signTime: thisdata.signTime,
  71. contractNo: thisdata.contractNo,
  72. financeId: thisdata.financeId,
  73. departmentName: thisdata.departmentName
  74. });
  75. }
  76. }
  77. this.state.pagination.current = data.data.pageNo;
  78. this.state.pagination.total = data.data.totalCount;
  79. if (data.data && data.data.list && !data.data.list.length) {
  80. this.state.pagination.current = 0;
  81. this.state.pagination.total = 0;
  82. }
  83. this.setState({
  84. totalPage: data.data.totalPage,
  85. dataSource: theArr,
  86. pagination: this.state.pagination
  87. });
  88. }.bind(this)
  89. }).always(
  90. function() {
  91. this.setState({
  92. loading: false
  93. });
  94. }.bind(this)
  95. );
  96. },
  97. getInitialState() {
  98. return {
  99. searchMore: true,
  100. assignVisible: false,
  101. releaseDate: [],
  102. totalPage: 0,
  103. processStatusSearch: "2",
  104. boHuivisible: false,
  105. selectedRowKeys: [],
  106. selectedRows: [],
  107. loading: false,
  108. pagination: {
  109. defaultCurrent: 1,
  110. defaultPageSize: 10,
  111. showQuickJumper: true,
  112. pageSize: 10,
  113. onChange: function(page) {
  114. this.loadData(page);
  115. }.bind(this),
  116. showTotal: function(total) {
  117. return "共" + total + "条数据";
  118. }
  119. },
  120. columns: [
  121. {
  122. title: "订单编号",
  123. dataIndex: "orderNo",
  124. key: "orderNo"
  125. },
  126. {
  127. title: "合同编号",
  128. dataIndex: "contractNo",
  129. key: "contractNo"
  130. },
  131. {
  132. title: "下单时间",
  133. dataIndex: "createTime",
  134. key: "createTime"
  135. },
  136. {
  137. title: "签单时间",
  138. dataIndex: "signTime",
  139. key: "signTime"
  140. },
  141. {
  142. title: "签单客户",
  143. dataIndex: "buyerName",
  144. key: "buyerName",
  145. render: text => {
  146. return text && text.length > 8 ? text.substr(0, 8) + "..." : text;
  147. }
  148. },
  149. {
  150. title: "流程状态",
  151. dataIndex: "processStatus",
  152. key: "processStatus",
  153. render: text => {
  154. return getProcessStatus(text);
  155. }
  156. },
  157. {
  158. title: "订单部门",
  159. dataIndex: "departmentName",
  160. key: "departmentName",
  161. render: text => {
  162. return text && text.length > 8 ? text.substr(0, 8) + "..." : text;
  163. }
  164. },
  165. {
  166. title: "订单总金额(万)",
  167. dataIndex: "signTotalAmount",
  168. key: "signTotalAmount"
  169. },
  170. {
  171. title: "是否特批",
  172. dataIndex: "approval",
  173. key: "approval",
  174. render: text => {
  175. return getApproval(text);
  176. }
  177. },
  178. {
  179. title: "订单负责人",
  180. dataIndex: "sellerName",
  181. key: "sellerName"
  182. },
  183. {
  184. title: "操作",
  185. dataIndex: "caozuo",
  186. key: "caouzo",
  187. render: (text, recard) => {
  188. return <div>{this.judgeFenpai(recard)}</div>;
  189. }
  190. }
  191. ],
  192. dataSource: [],
  193. searchTime: [,]
  194. };
  195. },
  196. /* 判断是否有分派按钮 */
  197. judgeFenpai(recard) {
  198. if (recard.approval === 2) {
  199. if (recard.financeId === null || recard.financeId === "") {
  200. return (
  201. <Button
  202. type="primary"
  203. onClick={e => {
  204. e.stopPropagation(), this.evaluate(recard);
  205. }}
  206. >
  207. 分派
  208. </Button>
  209. );
  210. } else {
  211. return undefined;
  212. }
  213. } else if (recard.processStatus <= 2) {
  214. return (
  215. <Button
  216. type="primary"
  217. onClick={e => {
  218. e.stopPropagation(), this.evaluate(recard);
  219. }}
  220. >
  221. 分派
  222. </Button>
  223. );
  224. } else {
  225. return undefined;
  226. }
  227. },
  228. /* 分派 */
  229. evaluate(recard) {
  230. this.state.assignData = recard;
  231. this.setState({
  232. assignVisible: true
  233. });
  234. },
  235. /* 驳回 */
  236. reject(recard) {
  237. this.setState({
  238. bohuiData: recard,
  239. boHuiVisible: true,
  240. content: ""
  241. });
  242. },
  243. boHuiOk() {
  244. this.setState({
  245. boHuiVisible: false
  246. });
  247. if (
  248. this.state.pagination.current == this.state.totalPage &&
  249. this.state.pagination.total % 10 == 1
  250. ) {
  251. this.loadData(this.state.page - 1);
  252. } else {
  253. this.loadData(this.state.page);
  254. }
  255. },
  256. boHuiCancel() {
  257. this.setState({
  258. boHuiVisible: false
  259. });
  260. },
  261. componentWillMount() {
  262. this.loadData();
  263. },
  264. tableRowClick(record) {
  265. this.state.RowData = record;
  266. this.setState({
  267. showDesc: true
  268. });
  269. },
  270. closeDesc(e, s) {
  271. this.state.showDesc = e;
  272. if (s) {
  273. this.loadData(this.state.page);
  274. }
  275. },
  276. closeAssign(e, s) {
  277. this.state.assignVisible = e;
  278. if (s) {
  279. if (
  280. this.state.pagination.current == this.state.totalPage &&
  281. this.state.pagination.total % 10 == 1
  282. ) {
  283. this.loadData(this.state.page - 1);
  284. } else {
  285. this.loadData(this.state.page);
  286. }
  287. }
  288. },
  289. search() {
  290. this.loadData();
  291. },
  292. reset() {
  293. this.state.nameSearch = "";
  294. this.state.releaseDate = [];
  295. this.state.orderNoSearch = "";
  296. this.state.departmenttList = undefined;
  297. this.state.processStatus = [];
  298. this.state.contractNoSearch = "";
  299. this.loadData();
  300. },
  301. searchSwitch() {
  302. this.setState({
  303. searchMore: !this.state.searchMore
  304. });
  305. },
  306. changeList(arr) {
  307. const newArr = [];
  308. this.state.columns.forEach(item => {
  309. arr.forEach(val => {
  310. if (val === item.title) {
  311. newArr.push(item);
  312. }
  313. });
  314. });
  315. this.setState({
  316. changeList: newArr
  317. });
  318. },
  319. render() {
  320. const { RangePicker } = DatePicker;
  321. return (
  322. <div className="user-content">
  323. <div className="content-title">
  324. <span>派单管理</span>
  325. </div>
  326. <Tabs defaultActiveKey="1" className="test">
  327. <TabPane tab="搜索" key="1">
  328. <div className="user-search">
  329. <Input
  330. placeholder="客户名称"
  331. value={this.state.nameSearch}
  332. onChange={e => {
  333. this.setState({ nameSearch: e.target.value });
  334. }}
  335. />
  336. <Input
  337. placeholder="订单编号"
  338. value={this.state.orderNoSearch}
  339. onChange={e => {
  340. this.setState({ orderNoSearch: e.target.value });
  341. }}
  342. />
  343. <DepartmentList
  344. value={this.state.departmenttList}
  345. onChange={e => {
  346. this.setState({ departmenttList: e });
  347. }}/>
  348. <Select
  349. placeholder="流程状态"
  350. onChange={e => {
  351. this.setState({ processStatusSearch: e });
  352. }}
  353. style={{ width: 160, marginRight: 5 }}
  354. value={this.state.processStatusSearch}
  355. >
  356. <Option value="2">未分配</Option>
  357. <Option value="3">已分配</Option>
  358. </Select>
  359. <Input
  360. placeholder="合同编号"
  361. value={this.state.contractNoSearch}
  362. onChange={e => {
  363. this.setState({
  364. contractNoSearch: e.target.value
  365. });
  366. }}
  367. />
  368. <span style={{ marginRight: 10 }}>下单时间 :</span>
  369. <RangePicker
  370. value={[
  371. this.state.releaseDate[0]
  372. ? moment(this.state.releaseDate[0])
  373. : null,
  374. this.state.releaseDate[1]
  375. ? moment(this.state.releaseDate[1])
  376. : null
  377. ]}
  378. onChange={(data, dataString) => {
  379. this.setState({ releaseDate: dataString });
  380. }}
  381. />
  382. <Button
  383. type="primary"
  384. onClick={this.search}
  385. style={{ marginLeft: 10 }}
  386. >
  387. 搜索
  388. </Button>
  389. <Button onClick={this.reset}>重置</Button>
  390. </div>
  391. </TabPane>
  392. <TabPane tab="更改表格显示数据" key="2">
  393. <div style={{ marginLeft: 10 }}>
  394. <ChooseList
  395. columns={this.state.columns}
  396. changeFn={this.changeList}
  397. changeList={this.state.changeList}
  398. top={55}
  399. margin={11}
  400. />
  401. </div>
  402. </TabPane>
  403. </Tabs>
  404. <div className="patent-table">
  405. <Spin spinning={this.state.loading}>
  406. <Table
  407. columns={
  408. this.state.changeList
  409. ? this.state.changeList
  410. : this.state.columns
  411. }
  412. dataSource={this.state.dataSource}
  413. scroll={{ x: 1500, y: 0 }}
  414. rowSelection={false}
  415. pagination={this.state.pagination}
  416. onRowClick={this.tableRowClick.bind(this)}
  417. bordered
  418. size="small"
  419. />
  420. </Spin>
  421. </div>
  422. <OrderDesc
  423. data={this.state.RowData}
  424. showDesc={this.state.showDesc}
  425. closeDesc={this.closeDesc.bind(this)}
  426. />
  427. <Assign
  428. title="订单"
  429. selApi="/api/admin/financial/distributionFinance"
  430. data={this.state.assignData}
  431. fenpaiData={4}
  432. showDesc={this.state.assignVisible}
  433. closeDesc={this.closeAssign.bind(this)}
  434. roleName={"财务专员"}
  435. requestMethod={"post"}
  436. />
  437. <Modal
  438. visible={this.state.boHuiVisible}
  439. width="400px"
  440. title="驳回备注"
  441. footer=""
  442. onOk={this.boHuiOk}
  443. onCancel={this.boHuiCancel}
  444. >
  445. <Form layout="horizontal" onSubmit={this.boHuiSubmit}>
  446. <Spin spinning={this.state.loading}>
  447. <FormItem
  448. labelCol={{ span: 5 }}
  449. wrapperCol={{ span: 16 }}
  450. label={
  451. <span>
  452. <strong style={{ color: "#f00" }}>*</strong>驳回原因
  453. </span>
  454. }
  455. >
  456. <Input
  457. type="textarea"
  458. rows={4}
  459. placeholder="请输入驳回原因"
  460. value={this.state.content}
  461. onChange={e => {
  462. this.setState({ content: e.target.value });
  463. }}
  464. />
  465. </FormItem>
  466. <FormItem wrapperCol={{ span: 12, offset: 5 }}>
  467. <Button
  468. type="primary"
  469. htmlType="submit"
  470. style={{ marginRight: 20 }}
  471. >
  472. 驳回
  473. </Button>
  474. <Button
  475. type="default"
  476. onClick={() => {
  477. this.boHuiCancel();
  478. }}
  479. >
  480. 取消
  481. </Button>
  482. </FormItem>
  483. </Spin>
  484. </Form>
  485. </Modal>
  486. </div>
  487. );
  488. }
  489. });
  490. export default PaiDan;