index.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. import React, { Component } from "react";
  2. import { Button, DatePicker, Input, message, Modal, Radio } from "antd";
  3. import {
  4. highTechColumns, //高新
  5. highTechColumnsVIP, //高新会员
  6. science, //科技
  7. patent, //专利
  8. currency, //软著和通用
  9. } from "./type";
  10. import moment from "moment";
  11. import $ from "jquery";
  12. import { splitUrl } from "@/tools";
  13. import ImgList from "../imgList";
  14. class NowProjectStatus extends Component {
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. projectStatus: parseInt(props.projectStatus),
  19. list:
  20. props.cSort === 3
  21. ? science
  22. : props.cSort === 6
  23. ? highTechColumnsVIP
  24. : props.projectType === 0 ||
  25. props.projectType === 2 ||
  26. props.projectType === 3 ||
  27. props.projectType === 4 ||
  28. props.projectType === 6
  29. ? currency
  30. : props.projectType === 1
  31. ? patent
  32. : props.projectType === 5
  33. ? highTechColumns
  34. : [], //projectType 0 正常 1专利 2软著 3审计 4双软 5高新 6商标 cSort: 3 科技项目 6: 会员
  35. dataInfor: Object.assign({}, props.projectTypeJSON),
  36. loading: false,
  37. fileList: [],
  38. value8: 0,
  39. };
  40. }
  41. updateProjectStatus() {
  42. let arr = this.state.list.filter((v) => v.id === this.state.projectStatus);
  43. let dataInforLength = this.state.dataInfor[this.state.projectStatus]
  44. ? Object.keys(this.state.dataInfor[this.state.projectStatus]).length
  45. : 0;
  46. if (
  47. this.state.dataInfor[this.state.projectStatus] &&
  48. this.state.dataInfor[this.state.projectStatus]["title"]
  49. ) {
  50. dataInforLength -= 1;
  51. }
  52. if (
  53. this.state.dataInfor[this.state.projectStatus] &&
  54. this.state.dataInfor[this.state.projectStatus]["suspendImg"]
  55. ) {
  56. dataInforLength -= 1;
  57. }
  58. if (
  59. arr.length !== 0 &&
  60. arr[0]["valueType"] &&
  61. dataInforLength !== arr[0]["valueType"].length
  62. ) {
  63. arr[0]["valueType"].map((v) => {
  64. if (!this.state.dataInfor[this.state.projectStatus][v]) {
  65. if (v === "date") {
  66. message.warning("请将" + arr[0]["name"] + "时间补充完整");
  67. }
  68. if (v === "certificateNumber") {
  69. message.warning("请将" + arr[0]["name"] + "的证书编号补充完整");
  70. }
  71. if (v === "setUpAmount") {
  72. message.warning("请将" + arr[0]["name"] + "的立项金额补充完整");
  73. }
  74. if (v === "appropriation") {
  75. message.warning("请将" + arr[0]["name"] + "的拨款金额补充完整");
  76. }
  77. return false;
  78. }
  79. });
  80. return false;
  81. }
  82. if (
  83. (this.state.projectStatus === 2 || this.state.projectStatus === 3) &&
  84. this.state.fileList.length === 0
  85. ) {
  86. message.warning("暂停附件未上传,请上传后保存!");
  87. return false;
  88. }
  89. this.setState({
  90. loading: true,
  91. });
  92. if (this.state.projectStatus === 2 || this.state.projectStatus === 3) {
  93. if (this.state.fileList.length) {
  94. let picArr = [];
  95. this.state.fileList.map(function (item) {
  96. if (
  97. item.response &&
  98. item.response.data &&
  99. item.response.data.length
  100. ) {
  101. picArr.push(item.response.data);
  102. }
  103. });
  104. if (!this.state.dataInfor[2]) {
  105. this.state.dataInfor[2] = {};
  106. }
  107. if (!this.state.dataInfor[3]) {
  108. this.state.dataInfor[3] = {};
  109. }
  110. this.state.dataInfor[2]["suspendImg"] = picArr.join(",");
  111. this.state.dataInfor[3]["suspendImg"] = picArr.join(",");
  112. }
  113. }
  114. let data = Object.assign({}, this.state.dataInfor);
  115. Object.keys(data).map((v) => {
  116. if (Object.keys(data[v]).length === 0) {
  117. delete data[v];
  118. }
  119. });
  120. if (data[this.state.projectStatus]) {
  121. data[this.state.projectStatus]["title"] =
  122. arr[0]["label"] || arr[0]["name"];
  123. }
  124. let obj = {
  125. tid: this.props.tid,
  126. projectStatus: this.state.projectStatus,
  127. timeRecord: JSON.stringify(data),
  128. };
  129. if (arr[0]["valueType"]) {
  130. //证书编号
  131. let type = arr[0]["valueType"].filter((v) => v === "certificateNumber");
  132. if (type.length > 0) {
  133. obj.certificateNumber =
  134. this.state.dataInfor[this.state.projectStatus]["certificateNumber"];
  135. }
  136. //立项金额
  137. let type1 = arr[0]["valueType"].filter((v) => v === "setUpAmount");
  138. if (type1.length > 0) {
  139. obj.setUpAmount =
  140. this.state.dataInfor[this.state.projectStatus]["setUpAmount"];
  141. }
  142. }
  143. $.ajax({
  144. url: globalConfig.context + "/api/admin/orderProject/updateProjectStatus",
  145. method: "post",
  146. data: obj,
  147. }).done(
  148. function (data) {
  149. this.setState({
  150. loading: false,
  151. });
  152. if (!data.error.length) {
  153. message.success("保存成功!");
  154. this.props.onPreservation(this.state.projectStatus);
  155. } else {
  156. message.warning(data.error[0].message);
  157. }
  158. }.bind(this)
  159. );
  160. }
  161. componentDidMount() {
  162. /*旧数据处理
  163. * endDate 完成时间 对应已提交时间 4
  164. * acceptDate 受理时间 对应已推荐时间 6
  165. * publicityDate 公示时间 对应已拟公示时间 8
  166. * licenceDate 发证时间 对应已下证时间 10
  167. * setUpAmount 立项金额 15
  168. * */
  169. const { endDate, acceptDate, publicityDate, licenceDate, setUpAmount } =
  170. this.props.oldData;
  171. if (!this.props.projectTypeJSON[4] && endDate) {
  172. this.state.dataInfor[4] = { title: "完成时间" };
  173. this.state.dataInfor[4]["date"] = endDate;
  174. }
  175. if (!this.props.projectTypeJSON[6] && acceptDate) {
  176. this.state.dataInfor[6] = { title: "受理时间" };
  177. this.state.dataInfor[6]["date"] = acceptDate;
  178. }
  179. if (!this.props.projectTypeJSON[8] && publicityDate) {
  180. this.state.dataInfor[8] = { title: "公示时间" };
  181. this.state.dataInfor[8]["date"] = publicityDate;
  182. }
  183. if (!this.props.projectTypeJSON[10] && licenceDate) {
  184. this.state.dataInfor[10] = { title: "发证时间" };
  185. this.state.dataInfor[10]["date"] = licenceDate;
  186. }
  187. // if((!this.props.projectTypeJSON[15]) && setUpAmount){
  188. // this.state.dataInfor[15]={title:'立项金额'};
  189. // this.state.dataInfor[15]['setUpAmount'] = setUpAmount;
  190. // }
  191. //图片
  192. if (
  193. this.props.projectTypeJSON[2] &&
  194. this.props.projectTypeJSON[2]["suspendImg"]
  195. ) {
  196. this.setState({
  197. fileList: splitUrl(
  198. this.props.projectTypeJSON[2]["suspendImg"],
  199. ",",
  200. globalConfig.avatarHost + "/upload"
  201. ),
  202. });
  203. } else {
  204. this.setState({
  205. fileList: [],
  206. });
  207. }
  208. this.setState({
  209. dataInfor: this.state.dataInfor,
  210. });
  211. }
  212. render() {
  213. return (
  214. <Modal
  215. className="customeDetails"
  216. footer=""
  217. title=""
  218. width="700px"
  219. visible={this.props.visible}
  220. onOk={() => {
  221. this.props.onCancel();
  222. }}
  223. onCancel={() => {
  224. this.props.onCancel();
  225. }}
  226. >
  227. <div>
  228. <div
  229. style={{
  230. paddingBottom: "15px",
  231. fontSize: "18px",
  232. fontWeight: "bolder",
  233. }}
  234. >
  235. 项目状态:
  236. </div>
  237. <div>
  238. <Radio.Group
  239. style={{
  240. dispaly: "flex",
  241. flexRow: "column",
  242. }}
  243. value={parseInt(this.state.projectStatus)}
  244. onChange={(e) => {
  245. if (e.target.value == 8) {
  246. this.setState({
  247. value8: 1,
  248. });
  249. }
  250. // console.log(this.state.list);
  251. if (!this.state.dataInfor[e.target.value]) {
  252. this.state.dataInfor[e.target.value] = {};
  253. }
  254. this.state.dataInfor[this.state.projectStatus] =
  255. this.props.projectTypeJSON[this.state.projectStatus] || {};
  256. this.setState({
  257. projectStatus: e.target.value,
  258. dataInfor: this.state.dataInfor,
  259. });
  260. }}
  261. >
  262. {this.state.list.map((v, k) => (
  263. <div key={k} style={{ paddingBottom: "15px" }}>
  264. <Radio value={v.id}>{v.name}</Radio>
  265. {(v.valueType || []).map((d) =>
  266. parseInt(this.state.projectStatus) !== parseInt(v.id) ? (
  267. <span style={{ marginRight: "15px" }}>
  268. {d === "appropriation"
  269. ? "拨款金额(万元):"
  270. : d === "certificateNumber"
  271. ? "已出高新证书编号,编号:"
  272. : d === "setUpAmount"
  273. ? "立项金额(万元):"
  274. : d === "exampleNumber"
  275. ? "公式网络链接:"
  276. : ""}
  277. {this.state.dataInfor[v.id] &&
  278. this.state.dataInfor[v.id][d]}
  279. </span>
  280. ) : d === "date" ? (
  281. <div style={{ display: "inline-block" }}>
  282. <DatePicker
  283. style={{ marginRight: "5px", width: "120px" }}
  284. showTime
  285. format="YYYY-MM-DD"
  286. onOk={() => {}}
  287. value={
  288. this.state.dataInfor[v.id] &&
  289. this.state.dataInfor[v.id][d]
  290. ? moment(this.state.dataInfor[v.id][d])
  291. : null
  292. }
  293. onChange={(data, dataString) => {
  294. // console.log(dataString);
  295. if (!this.state.dataInfor[v.id]) {
  296. this.state.dataInfor[v.id] = {};
  297. }
  298. if (!dataString && this.state.dataInfor[v.id][d]) {
  299. delete this.state.dataInfor[v.id][d];
  300. } else {
  301. this.state.dataInfor[v.id][d] = dataString;
  302. }
  303. this.setState({
  304. dataInfor: this.state.dataInfor,
  305. });
  306. }}
  307. />
  308. </div>
  309. ) : d === "setUpAmount" ||
  310. d === "certificateNumber" ||
  311. d === "appropriation" ||
  312. d === "exampleNumber" ? (
  313. <span>
  314. <span>
  315. {d === "appropriation"
  316. ? "拨款金额(万元)"
  317. : d === "certificateNumber"
  318. ? "已出高新证书编号,编号"
  319. : d === "setUpAmount"
  320. ? "立项金额(万元)"
  321. : d === "exampleNumber"
  322. ? "公式网络链接:"
  323. : ""}
  324. </span>
  325. <Input
  326. placeholder={v.placeholder}
  327. value={
  328. this.state.dataInfor[v.id]
  329. ? this.state.dataInfor[v.id][d]
  330. : ""
  331. }
  332. style={{ width: "120px", marginRight: "5px" }}
  333. onChange={(e) => {
  334. if (!this.state.dataInfor[v.id]) {
  335. this.state.dataInfor[v.id] = {};
  336. }
  337. if (
  338. !e.target.value &&
  339. this.state.dataInfor[v.id][d]
  340. ) {
  341. delete this.state.dataInfor[v.id][d];
  342. } else {
  343. this.state.dataInfor[v.id][d] = e.target.value;
  344. }
  345. this.setState({
  346. dataInfor: this.state.dataInfor,
  347. });
  348. }}
  349. />
  350. </span>
  351. ) : null
  352. )}
  353. <span style={{ color: "#f00", marginLeft: "15px" }}>
  354. {v.explain}
  355. </span>
  356. </div>
  357. ))}
  358. </Radio.Group>
  359. {(this.state.projectStatus === 2 ||
  360. this.state.projectStatus === 3 ||
  361. this.state.fileList.length > 0) && (
  362. <div>
  363. <div
  364. style={{
  365. paddingTop: "20px",
  366. paddingBottom: "10px",
  367. }}
  368. >
  369. <div>暂停附件:</div>
  370. <div style={{ color: "#f00" }}>(请上传截图证明)</div>
  371. </div>
  372. <div
  373. style={{
  374. display:
  375. this.state.projectStatus === 2 ||
  376. this.state.projectStatus === 3
  377. ? "block"
  378. : "none",
  379. }}
  380. >
  381. <ImgList
  382. domId="nowProjectStatus"
  383. uploadConfig={{
  384. action:
  385. globalConfig.context +
  386. "/api/admin/orderProject/uploadOrderTaskFile",
  387. data: { sign: "order_task_file" },
  388. multiple: true,
  389. listType: "picture-card",
  390. }}
  391. onChange={(info) => {
  392. let fileList = info.fileList;
  393. this.setState({ fileList });
  394. }}
  395. fileList={this.state.fileList}
  396. />
  397. </div>
  398. <div
  399. style={{
  400. display:
  401. this.state.projectStatus === 2 ||
  402. this.state.projectStatus === 3
  403. ? "none"
  404. : "block",
  405. }}
  406. >
  407. <ImgList
  408. domId="nowProjectStatus1"
  409. fileList={this.state.fileList}
  410. />
  411. </div>
  412. </div>
  413. )}
  414. <div
  415. style={{
  416. display: "flex",
  417. justifyContent: "center",
  418. paddingTop: "20px",
  419. paddingBottom: "20px",
  420. }}
  421. >
  422. <Button
  423. loading={this.state.loading}
  424. className="cancel"
  425. type="ghost"
  426. onClick={() => {
  427. this.updateProjectStatus();
  428. }}
  429. >
  430. 保存
  431. </Button>
  432. </div>
  433. <div style={{ textAlign: "center", color: "#f00" }}>
  434. 注:请根据实际项目情况填写
  435. </div>
  436. </div>
  437. </div>
  438. </Modal>
  439. );
  440. }
  441. }
  442. export default NowProjectStatus;