paiDan.jsx 14 KB

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