dunningRecord.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. import React, { Component } from "react";
  2. import TabelContent from "../../../common/tabelContent";
  3. import { Button, Modal, Tag, Form, DatePicker, Input, message } from "antd";
  4. import ImgList from "../../../common/imgList";
  5. import $ from "jquery/src/ajax";
  6. import { splitUrl } from "../../../tools.js";
  7. import TablePopup from "../../legalAffairs/collectioning/tablePopup";
  8. import download from "downloadjs";
  9. const { TextArea } = Input;
  10. const formItemLayout = {
  11. labelCol: {
  12. xs: { span: 24 },
  13. sm: { span: 6 },
  14. },
  15. wrapperCol: {
  16. xs: { span: 24 },
  17. sm: { span: 14 },
  18. },
  19. };
  20. class DunningRecord extends Component {
  21. constructor(props) {
  22. super(props);
  23. this.state = {
  24. columns: [
  25. {
  26. title: "序号",
  27. dataIndex: "key",
  28. key: "key",
  29. width: 45,
  30. },
  31. {
  32. title: "操作人名称",
  33. dataIndex: "dumBy",
  34. key: "dumBy",
  35. width: 140,
  36. },
  37. {
  38. title: "客户名称",
  39. dataIndex: "userName",
  40. key: "userName",
  41. width: 140,
  42. },
  43. {
  44. title: "催款时间",
  45. dataIndex: "dumDate",
  46. key: "dumDate",
  47. width: 140,
  48. },
  49. {
  50. title: "情况",
  51. dataIndex: "remarks",
  52. key: "remarks",
  53. width: 140,
  54. },
  55. {
  56. title: "操作时间",
  57. dataIndex: "createDate",
  58. key: "dumTime",
  59. width: 140,
  60. },
  61. {
  62. title: "操作",
  63. dataIndex: "attachmentUrl",
  64. key: "attachmentUrl",
  65. width: 100,
  66. render: (text, record) => {
  67. return (
  68. <Button
  69. type="primary"
  70. disabled={record.name === 0}
  71. onClick={(attachmentUrl) => {
  72. let data = JSON.parse(text);
  73. this.setState({
  74. visibleDownload: true,
  75. downloadList: data,
  76. });
  77. // console.log(data);
  78. }}
  79. >
  80. {this.state.voucher}
  81. </Button>
  82. );
  83. },
  84. },
  85. ],
  86. visible: false,
  87. date: "",
  88. remarks: "",
  89. mainModalKeys: 0,
  90. voucher: "下载凭证",
  91. loading: false,
  92. downloadList: [],
  93. visibleDownload: false,
  94. };
  95. this.formRef = {};
  96. this.downloadAll = this.downloadAll.bind(this);
  97. this.addDunOrder = this.addDunOrder.bind(this);
  98. }
  99. downloadAll() {
  100. let list = this.state.downloadList;
  101. list.forEach((element, key) => {
  102. // console.log(element);
  103. setTimeout(() => {
  104. const a = document.createElement("a");
  105. a.style.display = "none";
  106. a.href = `${window.window.globalConfig.context}/open/download?fileName=${element.url}&delete=false&attName=${element.name}`;
  107. // console.log(a.href);
  108. document.body.appendChild(a);
  109. a.click(); // 自动触发点击a标签的click事件
  110. document.body.removeChild(a);
  111. }, key * 100);
  112. });
  113. }
  114. // getUrl(e, n) {
  115. // let url = splitUrl(e, ",", globalConfig.avatarHost + "/upload");
  116. // url.forEach((element) => {
  117. // download(element.url, n);
  118. // console.log(element.url, n);
  119. // });
  120. // }
  121. addDunOrder() {
  122. let theorgCodeUrl = [];
  123. if (!this.state.fileList) {
  124. message.warning("请上传凭证");
  125. return;
  126. } else {
  127. let picArr = [];
  128. this.state.fileList.map(function (item) {
  129. if (item.response && item.response.data && item.response.data.length) {
  130. picArr.push({ name: item.name, url: item.response.data });
  131. }
  132. });
  133. theorgCodeUrl = JSON.stringify(picArr);
  134. }
  135. if (!this.state.date) {
  136. message.warning("请选择时间");
  137. return;
  138. }
  139. this.setState({
  140. addDunOrderLoading: true,
  141. loading: true,
  142. });
  143. $.ajax({
  144. method: "post",
  145. dataType: "json",
  146. crossDomain: false,
  147. url: globalConfig.context + "/api/admin/lagalAffairs/addDunOrder",
  148. data: {
  149. orderNo: this.props.dataInfor.orderNo,
  150. date: this.state.date,
  151. remarks: this.state.remarks,
  152. attUrl: theorgCodeUrl.length ? theorgCodeUrl : "",
  153. },
  154. success: function (data) {
  155. if (data.error.length) {
  156. message.warning(data.error[0].message);
  157. } else {
  158. this.setState({
  159. visible: false,
  160. mainModalKeys: this.state.mainModalKeys + 1,
  161. loading: false,
  162. fileList: undefined,
  163. });
  164. message.success("添加成功");
  165. this.tabelContentRef && this.tabelContentRef.onRefresh();
  166. }
  167. }.bind(this),
  168. }).done(
  169. function () {
  170. this.setState({
  171. addDunOrderLoading: false,
  172. });
  173. }.bind(this)
  174. );
  175. }
  176. // onCancel() {
  177. // console.log(this.state.visible);
  178. // }
  179. render() {
  180. const { visibleDownload, downloadList } = this.state;
  181. // console.log(this.props.dataInfor);
  182. return (
  183. <Modal
  184. maskClosable={false}
  185. visible={this.props.visible}
  186. onOk={this.props.onCancel}
  187. onCancel={this.props.onCancel}
  188. width="1200px"
  189. title={
  190. <span
  191. style={{
  192. display: "flex",
  193. alignItems: "center",
  194. justifyContent: "space-between",
  195. paddingRight: "10px",
  196. }}
  197. >
  198. <span>
  199. <span style={{ marginRight: "5px" }}>催款记录列表</span>
  200. <Tag color="pink">
  201. 初始客户名称:{this.props.dataInfor.buyerName}
  202. </Tag>
  203. </span>
  204. <Button
  205. style={{ display: this.props.hid || "inline-block" }}
  206. type="primary"
  207. onClick={(e) => {
  208. e.stopPropagation();
  209. this.setState({
  210. visible: true,
  211. });
  212. }}
  213. >
  214. 添加催款记录
  215. </Button>
  216. </span>
  217. }
  218. footer=""
  219. className="admin-desc-content"
  220. >
  221. <TablePopup
  222. ref={(ref) => (this.tabelContentRef = ref)}
  223. columns={this.state.columns}
  224. tabelApi={"/api/admin/lagalAffairs/dunOrderList"}
  225. query={{ orderNo: this.props.dataInfor.orderNo }}
  226. dataProcessing={(data) => {
  227. // console.log(data.data);
  228. let theArr = [];
  229. for (let i = 0; i < data.data.length; i++) {
  230. let thisdata = data.data[i];
  231. thisdata.key = i + 1;
  232. // console.log(thisdata.attachmentUrl);
  233. // console.log(this.state.voucher);
  234. if (!thisdata.attachmentUrl) {
  235. thisdata.name = 0;
  236. }
  237. // console.log(thisdata);
  238. theArr.push(thisdata);
  239. }
  240. return theArr;
  241. }}
  242. />
  243. <Modal
  244. maskClosable={false}
  245. visible={this.state.visible}
  246. onOk={(e) =>
  247. this.setState({
  248. visible: false,
  249. })
  250. }
  251. onCancel={(e) =>
  252. this.setState({
  253. visible: false,
  254. mainModalKeys: this.state.mainModalKeys + 1,
  255. fileList: undefined,
  256. })
  257. }
  258. key={this.state.mainModalKeys}
  259. width="1200px"
  260. title="新增催款记录"
  261. footer=""
  262. className="admin-desc-content"
  263. >
  264. <Form onSubmit={this.handleSubmit} ref={this.formRef}>
  265. <Form.Item
  266. name="date"
  267. {...formItemLayout}
  268. label="催款时间"
  269. hasFeedback
  270. >
  271. <DatePicker
  272. onChange={(date, dateString) => {
  273. this.setState({
  274. date: dateString,
  275. });
  276. }}
  277. />
  278. </Form.Item>
  279. <Form.Item
  280. name="remarks"
  281. {...formItemLayout}
  282. label="催款情况"
  283. hasFeedback
  284. >
  285. <TextArea
  286. rows={4}
  287. onChange={(e) => {
  288. this.setState({
  289. remarks: e.target.value,
  290. });
  291. }}
  292. />
  293. </Form.Item>
  294. <Form.Item
  295. name="fileList"
  296. {...formItemLayout}
  297. label="催款附件"
  298. hasFeedback
  299. >
  300. <ImgList
  301. accept="application/pdf,image/png,application/msword"
  302. domId="nowProjectStatus"
  303. uploadConfig={{
  304. action:
  305. globalConfig.context +
  306. "/api/admin/newOrder/uploadDunLogFile",
  307. data: { sign: "dun_log_attachment" },
  308. multiple: true,
  309. listType: "text",
  310. }}
  311. onChange={(info) => {
  312. let fileList = info.fileList;
  313. this.setState({ fileList });
  314. }}
  315. fileList={this.state.fileList}
  316. />
  317. </Form.Item>
  318. <div style={{ display: "flex", justifyContent: "center" }}>
  319. <Button
  320. type="primary"
  321. onClick={this.addDunOrder}
  322. loading={this.state.loading}
  323. >
  324. 提交
  325. </Button>
  326. <Button
  327. type="dashed"
  328. style={{ marginLeft: "15px" }}
  329. onClick={(e) => {
  330. this.setState({
  331. visible: false,
  332. mainModalKeys: this.state.mainModalKeys + 1,
  333. fileList: undefined,
  334. });
  335. }}
  336. >
  337. 取消
  338. </Button>
  339. </div>
  340. </Form>
  341. </Modal>
  342. {/* */}
  343. <Modal
  344. maskClosable={false}
  345. visible={visibleDownload}
  346. onOk={(e) =>
  347. this.setState({
  348. visibleDownload: false,
  349. })
  350. }
  351. onCancel={(e) =>
  352. this.setState({
  353. visibleDownload: false,
  354. })
  355. }
  356. width="1200px"
  357. title="下载凭证"
  358. footer=""
  359. className="admin-desc-content"
  360. >
  361. <ul style={{ margin: "0 0 10px 0" }}>
  362. {downloadList.map((item, key) => (
  363. <li key={key}>
  364. <span style={{ fontSize: "18px" }}>{item.name}</span>
  365. <div
  366. style={{
  367. marginLeft: "10px",
  368. color: "#333",
  369. display: "inline-block",
  370. cursor: "pointer",
  371. fontSize: "18px",
  372. }}
  373. // onClick={() => this.getUrl(item.url, item.name)}
  374. >
  375. <a href={`${window.window.globalConfig.context}/open/download?fileName=${item.url}&delete=false&attName=${item.name}`}>下载附件</a>
  376. </div>
  377. </li>
  378. ))}
  379. </ul>
  380. <div style={{ display: "flex", justifyContent: "right" }}>
  381. <Button
  382. type="primary"
  383. onClick={this.downloadAll}
  384. loading={this.state.loading}
  385. >
  386. 下载全部
  387. </Button>
  388. <Button
  389. type="dashed"
  390. style={{ marginLeft: "15px" }}
  391. onClick={(e) => {
  392. this.setState({
  393. visibleDownload: false,
  394. });
  395. }}
  396. >
  397. 取消
  398. </Button>
  399. </div>
  400. </Modal>
  401. </Modal>
  402. );
  403. }
  404. }
  405. export default DunningRecord;