index.jsx 18 KB

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