investment.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import {
  4. Button, Input, Spin, Table, DatePicker, TreeSelect,
  5. Form, message, Tabs, Modal, Select, AutoComplete,
  6. } from "antd";
  7. import { ShowModal } from "@/tools";
  8. import moment from "moment";
  9. import "./index.less";
  10. import ShowModalDiv from "@/showModal.jsx";
  11. import { ChooseList } from "../../order/orderNew/chooseList"
  12. import InvestmentLog from "../../../common/logPopup/investmentlog";
  13. import LaunchInvest from "../../amiba/component/launchinvest"; // 发起投资
  14. const { TabPane } = Tabs;
  15. const { RangePicker } = DatePicker;
  16. const FormItem = Form.Item;
  17. // 投资列表
  18. const Investment = React.createClass({
  19. //
  20. getInitialState() {
  21. return {
  22. searchValues: {}, // 列表筛选条件
  23. loading: false, //加载动画
  24. changeList: undefined, // 更改后的表格显示数据
  25. dataSource: [], // 列表数据
  26. pagination: {
  27. defaultCurrent: 1,
  28. defaultPageSize: 10,
  29. showQuickJumper: true,
  30. pageSize: 10,
  31. onChange: function (page) {
  32. this.loadData(page);
  33. }.bind(this),
  34. showTotal: function (total) {
  35. return "共" + total + "条数据";
  36. },
  37. },
  38. columns: [
  39. {
  40. title: "投资时间",
  41. dataIndex: "createTimes",
  42. key: "createTimes",
  43. width: "10%",
  44. },
  45. {
  46. title: "金额(万元)",
  47. dataIndex: "amount",
  48. key: "amount",
  49. width: "10%",
  50. },
  51. {
  52. title: "累计金额(万元)",
  53. dataIndex: "countAmount",
  54. key: "countAmount",
  55. width: "10%",
  56. },
  57. {
  58. title: "投资方",
  59. dataIndex: "initiateName",
  60. key: "initiateName",
  61. width: "10%",
  62. },
  63. {
  64. title: "接收方",
  65. dataIndex: "acceptName",
  66. key: "acceptName",
  67. width: "10%",
  68. },
  69. {
  70. title: "操作人",
  71. dataIndex: "operator",
  72. key: "operator",
  73. width: "10%",
  74. },
  75. {
  76. title: "状态",
  77. dataIndex: "status",
  78. key: "status",
  79. width: "8%",
  80. render: (text, record) =>
  81. <span style={{ color: text === 3 && "red" }}>
  82. {["草稿", "待审核", "同意", "驳回"][text]}
  83. </span>
  84. },
  85. {
  86. title: "备注",
  87. dataIndex: "comment",
  88. key: "comment",
  89. width: "20%",
  90. },
  91. {
  92. title: "操作",
  93. dataIndex: "operate",
  94. key: "operate",
  95. width: "12%",
  96. render: (text, record) =>
  97. <div>
  98. {
  99. record.status === 1 && this.props.type == "cwzy" &&
  100. <Button
  101. type="primary"
  102. onClick={() => {
  103. this.setState({
  104. checkVisible: true,
  105. rowData: record
  106. })
  107. }}
  108. >审核</Button>
  109. }
  110. {
  111. record.status === 3 && this.props.type == "my" &&
  112. <Button
  113. type="primary"
  114. onClick={() => {
  115. this.setState({
  116. visible: "invest",
  117. rowData: record
  118. })
  119. }}
  120. >重新发起</Button>
  121. }
  122. <InvestmentLog id={record.id} />
  123. </div >
  124. }
  125. ],
  126. checkVisible: false,
  127. rowData: {},
  128. visible: "",
  129. };
  130. },
  131. componentWillMount() {
  132. const { searchValues } = this.state
  133. this.getList();
  134. if (this.props.type == "cwzy") {
  135. searchValues.status = 1
  136. this.setState({
  137. searchValues,
  138. }, () => {
  139. this.loadData();
  140. })
  141. } else {
  142. this.loadData();
  143. }
  144. },
  145. // 导出当前列表
  146. exportAll() {
  147. const { searchValues } = this.state
  148. message.config({
  149. duration: 20,
  150. });
  151. let loading = message.loading("下载中...");
  152. this.setState({
  153. exportPendingLoading: true,
  154. });
  155. let data = Object.assign(searchValues, {
  156. pageNo: 1,
  157. pageSize: 9999,
  158. });
  159. $.ajax({
  160. method: "get",
  161. dataType: "json",
  162. crossDomain: false,
  163. url: "/api/admin/orderProject/selectProjectStop/export",
  164. data,
  165. success: function (data) {
  166. if (data.error.length === 0) {
  167. this.download(data.data);
  168. } else {
  169. message.warning(data.error[0].message);
  170. }
  171. }.bind(this),
  172. }).always(
  173. function () {
  174. loading();
  175. this.setState({
  176. exportPendingLoading: false,
  177. });
  178. }.bind(this)
  179. );
  180. },
  181. // 下载
  182. download(fileName) {
  183. window.location.href =
  184. globalConfig.context + "/open/download?fileName=" + fileName;
  185. },
  186. // 更改表格显示数据
  187. changeList(arr) {
  188. const newArr = [];
  189. this.state.columns.forEach((item) => {
  190. arr.forEach((val) => {
  191. if (val === item.title) {
  192. newArr.push(item);
  193. }
  194. });
  195. });
  196. this.setState({
  197. changeList: newArr,
  198. });
  199. },
  200. // 搜索
  201. search() {
  202. this.loadData();
  203. },
  204. // 重置
  205. reset() {
  206. this.setState({
  207. auto: "",
  208. searchValues: JSON.parse(JSON.stringify({})),
  209. }, () => {
  210. this.loadData();
  211. })
  212. },
  213. // 列表接口
  214. loadData(pageNo) {
  215. const { searchValues, pagination } = this.state;
  216. this.setState({
  217. loading: true,
  218. });
  219. let datas = Object.assign(searchValues, {
  220. pageNo: pageNo || 1,
  221. pageSize: pagination.pageSize,
  222. roleType: this.props.type == "cwzy" ? 1
  223. : this.props.type == "my" && 0, //0 巴主发起列表 1财务审核列表
  224. });
  225. $.ajax({
  226. method: "get",
  227. dataType: "json",
  228. crossDomain: false,
  229. url: globalConfig.context + "/api/admin/amb/Invest/InvestList",
  230. data: datas,
  231. success: function (data) {
  232. ShowModal(this);
  233. this.setState({
  234. loading: false,
  235. });
  236. if (data.error && data.error.length === 0) {
  237. if (data.data.list) {
  238. pagination.current = data.data.pageNo;
  239. pagination.total = data.data.totalCount;
  240. if (data.data && data.data.list && !data.data.list.length) {
  241. pagination.current = 0;
  242. pagination.total = 0;
  243. }
  244. this.setState({
  245. dataSource: data.data.list,
  246. pagination: this.state.pagination,
  247. pageNo: data.data.pageNo,
  248. });
  249. } else {
  250. this.setState({
  251. dataSource: data.data,
  252. pagination: false,
  253. });
  254. }
  255. } else {
  256. message.warning(data.error[0].message);
  257. }
  258. }.bind(this),
  259. }).always(
  260. function () {
  261. this.setState({
  262. loading: false,
  263. });
  264. }.bind(this)
  265. );
  266. },
  267. // 双击行
  268. rowClick(record) {
  269. if (this.props.type == "cwzy") {
  270. this.setState({
  271. checkVisible: true,
  272. rowData: record
  273. })
  274. }
  275. },
  276. // 审核
  277. examineTransfer(status) {
  278. if (!this.state.emReason) {
  279. message.warning("请填写审核说明~");
  280. return;
  281. }
  282. if (!this.state.emReason.replace(/\s+/g, '')) {
  283. message.warning("请填写审核说明~");
  284. return;
  285. }
  286. this.setState({
  287. loading: true,
  288. });
  289. $.ajax({
  290. method: "POST",
  291. dataType: "json",
  292. crossDomain: false,
  293. url: globalConfig.context + "/api/admin/amb/Invest/examineTransfer",
  294. data: {
  295. id: this.state.rowData.id,
  296. comment: this.state.emReason,
  297. status,
  298. },
  299. }).done(
  300. function (data) {
  301. if (!data.error.length) {
  302. this.setState({
  303. loading: false,
  304. })
  305. message.success("审核成功!");
  306. this.loadData()
  307. this.setState({
  308. checkVisible: false,
  309. emReason: "",
  310. })
  311. } else {
  312. message.warning(data.error[0].message);
  313. }
  314. }.bind(this)
  315. );
  316. },
  317. // 关闭重新发起
  318. onCancel(e) {
  319. if (e) {
  320. this.loadData()
  321. }
  322. this.setState({
  323. visible: "",
  324. })
  325. },
  326. // 树状默认数据处理
  327. handleTreeData(treeData) {
  328. let nodeDta = [];
  329. treeData.map(item => {
  330. let treeObj = {};
  331. treeObj.key = item.id
  332. treeObj.id = item.id
  333. treeObj.value = item.id
  334. treeObj.label = item.name
  335. treeObj.title = item.name
  336. treeObj.lvl = item.lvl
  337. treeObj.parentId = item.parentId
  338. item.list ? treeObj.children = this.handleTreeData(item.list) : null;
  339. nodeDta.push(treeObj)
  340. })
  341. return nodeDta
  342. },
  343. // 巴筛选数据
  344. getList() {
  345. this.setState({
  346. loading: true,
  347. });
  348. $.ajax({
  349. method: "get",
  350. dataType: "json",
  351. crossDomain: false,
  352. url: globalConfig.context + "/api/admin/amb/selectAll",
  353. success: function (data) {
  354. this.setState({
  355. loading: false,
  356. });
  357. if (data.error && data.error.length === 0) {
  358. let menuList = data.data
  359. this.setState({
  360. level1Data: menuList ? this.handleTreeData(menuList) : []
  361. });
  362. } else {
  363. message.warning(data.error[0].message);
  364. }
  365. }.bind(this),
  366. }).always(
  367. function () {
  368. this.setState({
  369. loading: false,
  370. });
  371. }.bind(this)
  372. );
  373. },
  374. supervisor(e) {
  375. $.ajax({
  376. method: "get",
  377. dataType: "json",
  378. crossDomain: false,
  379. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  380. data: {
  381. adminName: e,
  382. status: "0",
  383. },
  384. success: function (data) {
  385. if (data.error && data.error.length === 0) {
  386. this.setState({
  387. customerArr: data.data,
  388. });
  389. } else {
  390. message.warning(data.error[0].message);
  391. }
  392. }.bind(this),
  393. }).always(function () { }.bind(this));
  394. },
  395. httpChange(e) {
  396. if (e.length >= 1) {
  397. this.supervisor(e);
  398. }
  399. this.setState({
  400. auto: e,
  401. })
  402. },
  403. blurChange(e) {
  404. let contactLists = this.state.customerArr || [];
  405. if (e) {
  406. let id = ""
  407. contactLists.map(function (item) {
  408. if (item.name == e.toString()) {
  409. id = item.id;
  410. }
  411. });
  412. this.setState({
  413. searchValues: Object.assign(this.state.searchValues, {
  414. operator: id,
  415. }),
  416. })
  417. }
  418. },
  419. selectAuto(value, options) {
  420. this.setState({
  421. auto: value,
  422. })
  423. },
  424. render() {
  425. const { searchValues, rowData, level1Data } = this.state
  426. const formItemLayout = {
  427. labelCol: { span: 8 },
  428. wrapperCol: { span: 14 },
  429. };
  430. const dataSources = this.state.customerArr || [];
  431. const options = dataSources.map((group) => (
  432. <Select.Option key={group.id} value={group.name}>
  433. {group.name}
  434. </Select.Option>
  435. ));
  436. return (
  437. <div className="user-content">
  438. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  439. <div className="content-title" style={{ marginBottom: 10 }}>
  440. <span style={{ fontWeight: 900, fontSize: 16 }}>
  441. {this.props.type == "cwzy" ? "投资审核" : "我的投资"}
  442. </span>
  443. </div>
  444. <Tabs defaultActiveKey="1" onChange={this.callback}>
  445. <TabPane tab="搜索" key="1">
  446. <div className="user-search" style={{ marginLeft: 10 }}>
  447. <TreeSelect
  448. style={{ width: 200 }}
  449. value={searchValues.initiateAmbId}
  450. dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
  451. treeData={level1Data}
  452. placeholder="投资方"
  453. showSearch
  454. treeNodeFilterProp="title"
  455. onChange={(e) => {
  456. searchValues["initiateAmbId"] = e;
  457. this.setState({
  458. searchValues: searchValues,
  459. });
  460. }}
  461. />
  462. <TreeSelect
  463. style={{ width: 200 }}
  464. value={searchValues.acceptAmbId}
  465. dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
  466. treeData={level1Data}
  467. placeholder="接收方"
  468. showSearch
  469. treeNodeFilterProp="title"
  470. onChange={(e) => {
  471. searchValues["acceptAmbId"] = e;
  472. this.setState({
  473. searchValues: searchValues,
  474. });
  475. }}
  476. />
  477. <AutoComplete
  478. className="certain-category-search"
  479. dropdownClassName="certain-category-search-dropdown"
  480. dropdownMatchSelectWidth={false}
  481. style={{ width: "200px" }}
  482. dataSource={options}
  483. placeholder="操作投资人"
  484. value={this.state.auto}
  485. onChange={this.httpChange}
  486. filterOption={true}
  487. onBlur={this.blurChange}
  488. onSelect={this.selectAuto}
  489. >
  490. <Input />
  491. </AutoComplete>
  492. <Select
  493. placeholder="选择状态"
  494. style={{ width: 200 }}
  495. value={searchValues.status}
  496. onChange={e => {
  497. this.setState({
  498. searchValues: Object.assign(searchValues, {
  499. status: e,
  500. }),
  501. })
  502. }}
  503. >
  504. <Select.Option value={1}>待审核</Select.Option>
  505. <Select.Option value={2}>已同意</Select.Option>
  506. <Select.Option value={3}>已驳回</Select.Option>
  507. </Select>
  508. <RangePicker
  509. style={{ width: 300 }}
  510. value={[
  511. searchValues.startTime ? moment(searchValues.startTime) : null,
  512. searchValues.endTime ? moment(searchValues.endTime) : null,
  513. ]}
  514. onChange={(data, dataString) => {
  515. this.setState({
  516. searchValues: Object.assign(searchValues, {
  517. startTime: dataString[0],
  518. endTime: dataString[1],
  519. }),
  520. });
  521. }}
  522. />
  523. <Button
  524. type="primary"
  525. onClick={this.search}
  526. style={{ marginLeft: 10 }}
  527. >
  528. 搜索
  529. </Button>
  530. <Button
  531. onClick={this.reset}
  532. >重置</Button>
  533. </div>
  534. </TabPane>
  535. <TabPane tab="更改表格显示数据" key="2">
  536. <div style={{ marginLeft: 10 }}>
  537. <ChooseList
  538. columns={this.state.columns}
  539. changeFn={this.changeList}
  540. changeList={this.state.changeList}
  541. top={55}
  542. margin={11}
  543. />
  544. </div>
  545. </TabPane>
  546. <TabPane tab="导出Excel" key="3">
  547. <Button
  548. type="primary"
  549. style={{ margin: "11px 0px 10px 10px" }}
  550. onClick={this.exportAll}
  551. >
  552. 导出当前列表
  553. </Button>
  554. </TabPane>
  555. </Tabs>
  556. <div className="patent-table">
  557. <Spin spinning={this.state.loading}>
  558. <Table
  559. bordered
  560. size="middle"
  561. columns={
  562. this.state.changeList == undefined
  563. ? this.state.columns
  564. : this.state.changeList
  565. }
  566. dataSource={this.state.dataSource}
  567. pagination={this.state.pagination}
  568. onRowDoubleClick={this.rowClick}
  569. />
  570. </Spin>
  571. </div>
  572. {
  573. //审核弹窗
  574. this.state.checkVisible &&
  575. <Modal
  576. visible={this.state.checkVisible}
  577. width="33%"
  578. title=""
  579. footer=""
  580. onCancel={() => { this.setState({ checkVisible: false }) }}
  581. >
  582. <Spin spinning={this.state.loading}>
  583. <div>
  584. <div style={{ textAlign: "center", fontSize: "20px", marginBottom: 40 }}>拨款</div>
  585. <Form>
  586. <FormItem
  587. className="half-item"
  588. {...formItemLayout}
  589. label="投资方"
  590. >
  591. <span>{rowData.initiateName}</span>
  592. </FormItem>
  593. <FormItem
  594. className="half-item"
  595. {...formItemLayout}
  596. label="接受方"
  597. >
  598. <span>{rowData.acceptName}</span>
  599. </FormItem>
  600. <FormItem
  601. className="half-item"
  602. {...formItemLayout}
  603. label="投资款(万元)"
  604. >
  605. <span>{rowData.amount}</span>
  606. </FormItem>
  607. <FormItem
  608. labelCol={{ span: 4 }}
  609. wrapperCol={{ span: 16 }}
  610. label="投资备注"
  611. >
  612. <span>{rowData.comment}</span>
  613. </FormItem>
  614. <FormItem
  615. className="half-item"
  616. {...formItemLayout}
  617. label="发起人"
  618. >
  619. <span>{rowData.operator}</span>
  620. </FormItem>
  621. <FormItem
  622. className="half-item"
  623. {...formItemLayout}
  624. label="发起时间"
  625. >
  626. <span>{rowData.createTimes}</span>
  627. </FormItem>
  628. {
  629. rowData.status === 1 && this.props.type == "cwzy" &&
  630. <div>
  631. <FormItem
  632. labelCol={{ span: 4 }}
  633. wrapperCol={{ span: 16 }}
  634. label={
  635. <span>
  636. <strong style={{ color: "#f00" }}>*</strong>
  637. 备注
  638. </span>
  639. }
  640. >
  641. <Input
  642. type="textarea"
  643. rows={4}
  644. placeholder="请填写审核说明"
  645. value={this.state.emReason}
  646. onChange={(e) => {
  647. this.setState({ emReason: e.target.value });
  648. }}
  649. />
  650. </FormItem>
  651. <FormItem wrapperCol={{ span: 12, offset: 7 }}>
  652. <Button
  653. type="primary"
  654. onClick={() => { this.examineTransfer(2) }}
  655. style={{ marginRight: 20 }}
  656. >
  657. 确定拨款
  658. </Button>
  659. <Button
  660. type="primary"
  661. onClick={() => { this.examineTransfer(3) }}
  662. style={{ marginRight: 20 }}
  663. >
  664. 驳回
  665. </Button>
  666. <Button
  667. type="default"
  668. onClick={() => { this.setState({ checkVisible: false }) }}
  669. >
  670. 取消
  671. </Button>
  672. </FormItem>
  673. </div>
  674. }
  675. </Form>
  676. </div>
  677. </Spin>
  678. </Modal>
  679. }
  680. {
  681. // 重新发起投资
  682. this.state.visible == "invest" &&
  683. <LaunchInvest
  684. myAmbId={this.state.rowData.initiateAmbId} //发起方的阿米巴id
  685. details={this.state.rowData}
  686. visible={this.state.visible}
  687. onCancel={this.onCancel.bind(this)}
  688. />
  689. }
  690. </div>
  691. );
  692. },
  693. });
  694. export default Investment;