legalRecd.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. import React, { Component } from "react";
  2. import TabelContent from "../../../common/tabelContent";
  3. import {
  4. Button,
  5. Modal,
  6. Tag,
  7. Form,
  8. DatePicker,
  9. Input,
  10. message,
  11. Upload,
  12. Icon,
  13. Radio,
  14. Popconfirm,
  15. Table,
  16. } from "antd";
  17. import ImgList from "../../../common/imgList";
  18. import $ from "jquery/src/ajax";
  19. import { splitUrl } from "../../../tools.js";
  20. import download from "downloadjs";
  21. import TablePopup from "./tablePopup";
  22. import { element } from "prop-types";
  23. const { TextArea } = Input;
  24. const RadioGroup = Radio.Group;
  25. class LegalRecd extends Component {
  26. constructor(props) {
  27. super(props);
  28. this.state = {
  29. columns: [
  30. {
  31. title: "序号",
  32. dataIndex: "key",
  33. key: "key",
  34. width: 45,
  35. },
  36. {
  37. title: "操作人名称",
  38. dataIndex: "adminName",
  39. key: "adminName",
  40. width: 80,
  41. },
  42. {
  43. title: "客户名称",
  44. dataIndex: "userName",
  45. key: "userName",
  46. width: 140,
  47. },
  48. {
  49. title: "法务时间",
  50. dataIndex: "operationDate",
  51. key: "operationDate",
  52. width: 140,
  53. },
  54. {
  55. title: "详细",
  56. dataIndex: "remarks",
  57. key: "remarks",
  58. width: 140,
  59. },
  60. {
  61. title: "法务类型",
  62. dataIndex: "type",
  63. key: "type",
  64. width: 140,
  65. },
  66. {
  67. title: "操作时间",
  68. dataIndex: "createDate",
  69. key: "createDate",
  70. width: 140,
  71. },
  72. {
  73. title: "操作",
  74. dataIndex: "attachmentUrl",
  75. key: "attachmentUrl",
  76. width:100,
  77. render: (text, record) => {
  78. return (
  79. <Button
  80. type="primary"
  81. disabled={record.name === 0}
  82. onClick={(attachmentUrl) => {
  83. let data = JSON.parse(text);
  84. this.setState({
  85. visible: true,
  86. downloadList: data,
  87. });
  88. // console.log();
  89. // console.log(this.state.downloadList);
  90. // if (text) {
  91. // let url = splitUrl(
  92. // text,
  93. // ",",
  94. // globalConfig.avatarHost + "/upload"
  95. // );
  96. // url.forEach((element) => {
  97. // download(element.url);
  98. // });
  99. // } else {
  100. // message.info("暂无文件");
  101. // }
  102. // console.log(text,record);
  103. // e.stopPropagation();
  104. }}
  105. >
  106. {this.state.voucher}
  107. </Button>
  108. );
  109. },
  110. },
  111. ],
  112. visible: false,
  113. date: "",
  114. remarks: "",
  115. mainModalKeys: 0,
  116. voucher: "下载凭证",
  117. loading: false,
  118. downloadList: [],
  119. visibleLegal: false,
  120. LegalKeys: 10,
  121. };
  122. this.formRef = {};
  123. this.downloadAll = this.downloadAll.bind(this);
  124. this.tabelContentRef = null;
  125. this.addLegal = this.addLegal.bind(this);
  126. // this.getUrl = this.getUrl.bind(this);
  127. }
  128. downloadAll() {
  129. let list = this.state.downloadList;
  130. list.forEach((element, key) => {
  131. // console.log(element);
  132. setTimeout(() => {
  133. const a = document.createElement("a");
  134. a.style.display = "none";
  135. a.href = `${window.window.globalConfig.context}/open/download?fileName=${element.url}&delete=false&attName=${element.name}`;
  136. // console.log(a.href);
  137. document.body.appendChild(a);
  138. a.click(); // 自动触发点击a标签的click事件
  139. document.body.removeChild(a);
  140. }, key * 100);
  141. });
  142. }
  143. onCancel() {
  144. // console.log(this.state.visible);
  145. }
  146. addLegal() {
  147. let theorgCodeUrl = [];
  148. if (!this.state.fileList) {
  149. message.warning("请上传凭证");
  150. return;
  151. } else {
  152. let picArr = [];
  153. this.state.fileList.map(function (item) {
  154. if (item.response && item.response.data && item.response.data.length) {
  155. picArr.push({ name: item.name, url: item.response.data });
  156. }
  157. });
  158. theorgCodeUrl = JSON.stringify(picArr);
  159. // console.log(theorgCodeUrl);
  160. }
  161. if (!this.state.date) {
  162. message.warning("请选择时间");
  163. return;
  164. }
  165. this.setState({
  166. addDunOrderLoading: true,
  167. loading: true,
  168. });
  169. $.ajax({
  170. method: "post",
  171. dataType: "json",
  172. crossDomain: false,
  173. url: globalConfig.context + "/api/admin/lagalAffairs/addLagalAffairsLog",
  174. data: {
  175. orderNo: this.props.dataInfor.orderNo,
  176. type: this.state.type,
  177. status: this.state.status ? this.state.status : 0,
  178. date: this.state.date,
  179. remarks: this.state.remarks,
  180. attachmentUrl: theorgCodeUrl.length ? theorgCodeUrl : "",
  181. },
  182. success: function (data) {
  183. // console.log(data);
  184. if (data.error.length) {
  185. this.setState({
  186. loading: false,
  187. });
  188. message.warning(data.error[0].message);
  189. } else {
  190. this.setState({
  191. loading: false,
  192. visibleLegal: false,
  193. LegalKeys: this.state.LegalKeys + 2,
  194. fileList: undefined,
  195. });
  196. // console.log(typeof this.state.type);
  197. if (this.state.type == "2" || this.state.type == "1") {
  198. this.props.onFresh();
  199. this.setState({});
  200. }
  201. // this.props.visible = false
  202. message.success("添加成功");
  203. this.tabelContentRef && this.tabelContentRef.onRefresh();
  204. // console.log(this.tabelContentRef);
  205. }
  206. }.bind(this),
  207. }).done(
  208. function () {
  209. this.setState({
  210. addDunOrderLoading: false,
  211. });
  212. }.bind(this)
  213. );
  214. }
  215. render() {
  216. let downloadList = this.state.downloadList;
  217. const formItemLayout = {
  218. labelCol: { span: 10 },
  219. wrapperCol: { span: 12 },
  220. };
  221. // console.log(this.props.visibleRest);
  222. // console.log(this.props.infor);
  223. return (
  224. <Modal
  225. maskClosable={false}
  226. visible={this.props.visibleRecd}
  227. onOk={this.props.onCancel}
  228. onCancel={this.props.onCancel}
  229. width="1100px"
  230. title={
  231. <span
  232. style={{
  233. display: "flex",
  234. alignItems: "center",
  235. justifyContent: "space-between",
  236. paddingRight: "10px",
  237. }}
  238. >
  239. <span>
  240. <span style={{ marginRight: "5px" }}>法务记录列表</span>
  241. <Tag color="pink">客户名称:{this.props.dataInfor.buyerName}</Tag>
  242. </span>
  243. <Button
  244. style={{ display: this.props.hid || "inline-block" }}
  245. type="primary"
  246. onClick={(e) => {
  247. e.stopPropagation();
  248. this.setState({
  249. visibleLegal: true,
  250. });
  251. }}
  252. >
  253. 添加法务记录
  254. </Button>
  255. </span>
  256. }
  257. footer=""
  258. className="admin-desc-content"
  259. >
  260. {/* <TabelContent
  261. ref={(ref) => (this.tabelContentRef = ref)}
  262. columns={this.state.columns}
  263. tabelApi={"/api/admin/lagalAffairs/lagalAffairsLogList"}
  264. query={{ orderNo: this.props.dataInfor.orderNo }}
  265. dataProcessing={(data) => {
  266. // console.log(data.data);
  267. let theArr = [];
  268. for (let i = 0; i < data.data.length; i++) {
  269. let thisdata = data.data[i];
  270. thisdata.key = i + 1;
  271. // console.log(thisdata.attachmentUrl);
  272. // console.log(this.state.voucher);
  273. if (!thisdata.attachmentUrl) {
  274. thisdata.name = 0;
  275. }
  276. if (thisdata.type == 0) {
  277. thisdata.type = "法务催收中";
  278. } else if (thisdata.type == 1) {
  279. thisdata.type = "延期法务";
  280. } else if (thisdata.type == 2) {
  281. thisdata.type = "已坏账处理";
  282. }
  283. // console.log(thisdata);
  284. theArr.push(thisdata);
  285. }
  286. return theArr;
  287. }}
  288. /> */}
  289. <TablePopup
  290. ref={(ref) => (this.tabelContentRef = ref)}
  291. columns={this.state.columns}
  292. tabelApi={"/api/admin/lagalAffairs/lagalAffairsLogList"}
  293. query={{ orderNo: this.props.dataInfor.orderNo }}
  294. dataProcessing={(data) => {
  295. // console.log(data.data);
  296. let theArr = [];
  297. for (let i = 0; i < data.data.length; i++) {
  298. let thisdata = data.data[i];
  299. thisdata.key = i + 1;
  300. // console.log(thisdata.attachmentUrl);
  301. // console.log(this.state.voucher);
  302. if (!thisdata.attachmentUrl) {
  303. thisdata.name = 0;
  304. }
  305. //
  306. let status;
  307. if (thisdata.status == 0) {
  308. status = "否";
  309. } else if (thisdata.status == 1) {
  310. status = "已回款";
  311. } else if (thisdata.status == 2) {
  312. status = "已诉讼";
  313. } else if (thisdata.status == 3) {
  314. status = "已坏账处理";
  315. }
  316. //
  317. if (thisdata.type == 0) {
  318. thisdata.type = "法务催收中";
  319. } else if (thisdata.type == 1) {
  320. thisdata.type = "延期法务";
  321. } else if (thisdata.type == 2) {
  322. thisdata.type = `已完成法务/${status}`;
  323. } else if (thisdata.type == 3) {
  324. thisdata.type = "自动转交";
  325. } else if (thisdata.type == 4) {
  326. thisdata.type = "营销转交";
  327. }
  328. // console.log(thisdata);
  329. theArr.push(thisdata);
  330. }
  331. return theArr;
  332. }}
  333. />
  334. <div>
  335. <Modal
  336. maskClosable={false}
  337. visible={this.state.visibleLegal}
  338. key={this.state.LegalKeys + 2}
  339. onCancel={() => {
  340. this.setState({
  341. visibleLegal: false,
  342. LegalKeys: this.state.LegalKeys + 2,
  343. });
  344. }}
  345. width="1200px"
  346. title="新增法务数据"
  347. footer=""
  348. className="admin-desc-content"
  349. >
  350. <Form
  351. onSubmit={this.handleSubmit}
  352. ref={this.formRef}
  353. style={{ marginRight: "120px" }}
  354. >
  355. <Form.Item
  356. {...formItemLayout}
  357. label="法务类型"
  358. name="type"
  359. hasFeedback
  360. >
  361. <RadioGroup
  362. onChange={(e) => {
  363. this.setState({
  364. type: e.target.value,
  365. });
  366. }}
  367. >
  368. <Radio value="0">法务催收中</Radio>
  369. <Radio value="1">延期法务</Radio>
  370. <Radio value="2">法务已完成</Radio>
  371. </RadioGroup>
  372. </Form.Item>
  373. {this.state.type == 2 ? (
  374. <Form.Item
  375. {...formItemLayout}
  376. label="完成状态"
  377. name="status"
  378. hasFeedback
  379. >
  380. <RadioGroup
  381. onChange={(e) => {
  382. this.setState({
  383. status: e.target.value,
  384. });
  385. }}
  386. >
  387. <Radio value="1">已回款</Radio>
  388. <Radio value="2">以诉讼</Radio>
  389. <Radio value="3">以坏账处理</Radio>
  390. </RadioGroup>
  391. </Form.Item>
  392. ) : (
  393. ""
  394. )}
  395. <Form.Item
  396. name="date"
  397. {...formItemLayout}
  398. label="时间"
  399. hasFeedback
  400. >
  401. <DatePicker
  402. onChange={(date, dateString) => {
  403. this.setState({
  404. date: dateString,
  405. });
  406. }}
  407. />
  408. </Form.Item>
  409. <Form.Item
  410. name="remarks"
  411. {...formItemLayout}
  412. label="法务情况"
  413. hasFeedback
  414. >
  415. <TextArea
  416. rows={4}
  417. onChange={(e) => {
  418. this.setState({
  419. remarks: e.target.value,
  420. });
  421. }}
  422. />
  423. </Form.Item>
  424. <Form.Item
  425. name="fileList"
  426. {...formItemLayout}
  427. label="附件"
  428. hasFeedback
  429. >
  430. <ImgList
  431. accept="application/pdf,image/png,application/msword"
  432. domId="nowProjectStatus"
  433. uploadConfig={{
  434. action:
  435. globalConfig.context +
  436. "/api/admin/newOrder/uploadDunLogFile",
  437. data: { sign: "dun_log_attachment" },
  438. multiple: true,
  439. listType: "text",
  440. }}
  441. onChange={(info) => {
  442. let fileList = info.fileList;
  443. this.setState({ fileList });
  444. }}
  445. fileList={this.state.fileList}
  446. />
  447. </Form.Item>
  448. </Form>
  449. <div style={{ display: "flex", justifyContent: "center" }}>
  450. <Button type="primary" loading={this.state.loading}>
  451. <Popconfirm
  452. title="您确定此订单提交法务数据?"
  453. onConfirm={this.addLegal}
  454. onCancel={() => {
  455. this.setState({
  456. loading: false,
  457. });
  458. }}
  459. cancelText="取消"
  460. okText="确定"
  461. loading={this.state.loading}
  462. >
  463. <a href="#">提交</a>
  464. </Popconfirm>
  465. </Button>
  466. <Button
  467. type="dashed"
  468. style={{ marginLeft: "15px" }}
  469. onClick={() => {
  470. this.setState({
  471. visibleLegal: false,
  472. LegalKeys: this.state.LegalKeys + 2,
  473. });
  474. }}
  475. >
  476. 取消
  477. </Button>
  478. </div>
  479. </Modal>
  480. </div>
  481. <Modal
  482. maskClosable={false}
  483. visible={this.state.visible}
  484. onOk={(e) =>
  485. this.setState({
  486. visible: false,
  487. })
  488. }
  489. onCancel={(e) =>
  490. this.setState({
  491. visible: false,
  492. mainModalKeys: this.state.mainModalKeys + 1,
  493. fileList: undefined,
  494. })
  495. }
  496. key={this.state.mainModalKeys}
  497. width="1200px"
  498. title="下载凭证"
  499. footer=""
  500. className="admin-desc-content"
  501. >
  502. <ul style={{ margin: "0 0 10px 0" }}>
  503. {downloadList.map((item, key) => (
  504. <li key={key}>
  505. <span style={{ fontSize: "18px" }}>{item.name}</span>
  506. <div
  507. style={{
  508. marginLeft: "10px",
  509. color: "#333",
  510. display: "inline-block",
  511. cursor: "pointer",
  512. fontSize: "18px",
  513. }}
  514. // onClick={() => this.getUrl(item.url, item.name)}
  515. >
  516. <a
  517. href={`${window.window.globalConfig.context}/open/download?fileName=${item.url}&delete=false&attName=${item.name}`}
  518. >
  519. 下载附件
  520. </a>
  521. </div>
  522. </li>
  523. ))}
  524. </ul>
  525. <div style={{ display: "flex", justifyContent: "right" }}>
  526. <Button
  527. type="primary"
  528. onClick={this.downloadAll}
  529. loading={this.state.loading}
  530. >
  531. 下载全部
  532. </Button>
  533. <Button
  534. type="dashed"
  535. style={{ marginLeft: "15px" }}
  536. onClick={(e) => {
  537. this.setState({
  538. visible: false,
  539. mainModalKeys: this.state.mainModalKeys + 1,
  540. fileList: undefined,
  541. });
  542. }}
  543. >
  544. 取消
  545. </Button>
  546. </div>
  547. </Modal>
  548. </Modal>
  549. );
  550. }
  551. }
  552. export default LegalRecd;