index.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. class NowProjectStatus extends Component{
  13. constructor(props) {
  14. super(props);
  15. this.state={
  16. projectStatus: parseInt(props.projectStatus),
  17. list:
  18. props.cSort === 3 ? science :
  19. props.cSort === 6 ? highTechColumnsVIP :
  20. props.projectType === 0 || props.projectType === 2 || props.projectType === 3 || props.projectType === 4 || props.projectType === 6?
  21. currency:
  22. props.projectType === 1 ?
  23. patent:
  24. props.projectType === 5 ?
  25. highTechColumns :
  26. [],//projectType 0 正常 1专利 2软著 3审计 4双软 5高新 6商标 cSort: 3 科技项目 6: 会员
  27. dataInfor:Object.assign({},props.projectTypeJSON),
  28. loading: false,
  29. }
  30. }
  31. updateProjectStatus(){
  32. let arr = this.state.list.filter(v=>v.id === this.state.projectStatus);
  33. let dataInforLength = this.state.dataInfor[this.state.projectStatus] ? Object.keys(this.state.dataInfor[this.state.projectStatus]).length : 0;
  34. if(this.state.dataInfor[this.state.projectStatus] && this.state.dataInfor[this.state.projectStatus]['title']){
  35. dataInforLength -= 1;
  36. }
  37. if(arr.length !== 0 && arr[0]['valueType'] && dataInforLength !== arr[0]['valueType'].length){
  38. message.warning('有内容没有填写,请补充完整!')
  39. return false;
  40. }
  41. this.setState({
  42. loading: true,
  43. })
  44. let data = Object.assign({},this.state.dataInfor);
  45. Object.keys(data).map(v=>{
  46. if(Object.keys(data[v]).length === 0){
  47. delete data[v];
  48. }
  49. })
  50. if(data[this.state.projectStatus]){
  51. data[this.state.projectStatus]['title'] =arr[0]['label'] || arr[0]['name'];
  52. }
  53. let obj = {
  54. tid:this.props.tid,
  55. projectStatus: this.state.projectStatus,
  56. timeRecord: JSON.stringify(data)
  57. }
  58. if(arr[0]['valueType']){
  59. //证书编号
  60. let type = arr[0]['valueType'].filter(v=>v==='certificateNumber');
  61. if(type.length > 0){
  62. obj.certificateNumber = this.state.dataInfor[this.state.projectStatus]['certificateNumber']
  63. }
  64. //立项金额
  65. let type1 = arr[0]['valueType'].filter(v=>v==='setUpAmount');
  66. if(type1.length > 0){
  67. obj.setUpAmount = this.state.dataInfor[this.state.projectStatus]['setUpAmount']
  68. }
  69. }
  70. $.ajax({
  71. url: globalConfig.context + '/api/admin/orderProject/updateProjectStatus',
  72. method: 'post',
  73. data: obj,
  74. }).done(
  75. function (data) {
  76. this.setState({
  77. loading: false,
  78. })
  79. if (!data.error.length) {
  80. message.success('保存成功!');
  81. this.props.onPreservation(this.state.projectStatus);
  82. } else {
  83. message.warning(data.error[0].message)
  84. }
  85. }.bind(this)
  86. )
  87. }
  88. componentDidMount() {
  89. /*旧数据处理
  90. * endDate 完成时间 对应已提交时间 4
  91. * acceptDate 受理时间 对应已推荐时间 6
  92. * publicityDate 公示时间 对应已拟公示时间 8
  93. * licenceDate 发证时间 对应已下证时间 10
  94. * setUpAmount 立项金额 15
  95. * */
  96. const {endDate,acceptDate,publicityDate,licenceDate,setUpAmount} = this.props.oldData;
  97. if((!this.props.projectTypeJSON[4]) && endDate){
  98. this.state.dataInfor[4]={title:'完成时间'};
  99. this.state.dataInfor[4]['date'] = endDate;
  100. }
  101. if((!this.props.projectTypeJSON[6]) && acceptDate){
  102. this.state.dataInfor[6]={title:'受理时间'};
  103. this.state.dataInfor[6]['date'] = acceptDate;
  104. }
  105. if((!this.props.projectTypeJSON[8]) && publicityDate){
  106. this.state.dataInfor[8]={title:'公示时间'};
  107. this.state.dataInfor[8]['date'] = publicityDate;
  108. }
  109. if((!this.props.projectTypeJSON[10]) && licenceDate){
  110. this.state.dataInfor[10]={title:'发证时间'};
  111. this.state.dataInfor[10]['date'] = licenceDate;
  112. }
  113. if((!this.props.projectTypeJSON[15]) && setUpAmount){
  114. this.state.dataInfor[15]={title:'立项金额'};
  115. this.state.dataInfor[15]['setUpAmount'] = setUpAmount;
  116. }
  117. this.setState({
  118. dataInfor: this.state.dataInfor,
  119. })
  120. }
  121. render() {
  122. return(
  123. <Modal
  124. className="customeDetails"
  125. footer=""
  126. title=""
  127. width="700px"
  128. visible={this.props.visible}
  129. onOk={()=>{
  130. this.props.onCancel();
  131. }}
  132. onCancel={()=>{
  133. this.props.onCancel();
  134. }}
  135. >
  136. <div>
  137. <div style={{
  138. paddingBottom: '15px',
  139. fontSize:'18px',
  140. fontWeight:"bolder",
  141. }}>
  142. 项目状态:
  143. </div>
  144. <div>
  145. <Radio.Group
  146. style={{
  147. dispaly:'flex',
  148. flexRow:'column'
  149. }}
  150. value={parseInt(this.state.projectStatus)}
  151. onChange={(e) => {
  152. if(!this.state.dataInfor[e.target.value]){
  153. this.state.dataInfor[e.target.value] = {};
  154. }
  155. this.state.dataInfor[this.state.projectStatus] = this.props.projectTypeJSON[this.state.projectStatus] || {};
  156. this.setState({
  157. projectStatus: e.target.value,
  158. dataInfor:this.state.dataInfor,
  159. });
  160. }}
  161. >
  162. {
  163. this.state.list.map((v,k)=>(
  164. <div key={k} style={{paddingBottom:'15px'}}>
  165. <Radio value={v.id}>{v.name}</Radio>
  166. {
  167. (v.valueType || []).map(d=>(
  168. parseInt(this.state.projectStatus) !== parseInt(v.id) ?
  169. <span style={{marginRight:'15px'}}>
  170. {
  171. d === 'appropriation' ? '拨款金额(万元):' :
  172. d === 'certificateNumber' ? '已出高新证书编号,编号:' :
  173. d === 'setUpAmount' ? '立项金额(万元):' : ''
  174. }
  175. {
  176. this.state.dataInfor[v.id] && this.state.dataInfor[v.id][d]
  177. }
  178. </span>
  179. :d === 'date' ?
  180. <DatePicker
  181. style={{ marginRight: '5px',width:'120px' }}
  182. showTime
  183. format="YYYY-MM-DD"
  184. onOk={() => {}}
  185. value={
  186. this.state.dataInfor[v.id] && this.state.dataInfor[v.id][d] ? moment(this.state.dataInfor[v.id][d]) : null
  187. }
  188. onChange={(data, dataString) => {
  189. console.log(dataString)
  190. if(!this.state.dataInfor[v.id]){
  191. this.state.dataInfor[v.id] = {};
  192. }
  193. this.state.dataInfor[v.id][d] = dataString;
  194. this.setState({
  195. dataInfor:this.state.dataInfor,
  196. })
  197. }}
  198. /> :
  199. d === 'setUpAmount' || d === 'certificateNumber' || d === 'appropriation' ? <span>
  200. <span>
  201. {
  202. d === 'appropriation' ? '拨款金额(万元)' :
  203. d === 'certificateNumber' ? '已出高新证书编号,编号' :
  204. d === 'setUpAmount' ? '立项金额(万元)' : ''
  205. }
  206. </span>
  207. <Input
  208. placeholder={v.placeholder}
  209. value={this.state.dataInfor[v.id] ? this.state.dataInfor[v.id][d] : ''}
  210. style={{ width: '120px',marginRight: '5px', }}
  211. onChange={(e) => {
  212. if(!this.state.dataInfor[v.id]){
  213. this.state.dataInfor[v.id] = {};
  214. }
  215. this.state.dataInfor[v.id][d] = e.target.value;
  216. this.setState({
  217. dataInfor:this.state.dataInfor,
  218. })
  219. }}
  220. />
  221. </span> : null
  222. ))
  223. }
  224. <span style={{color:'#f00',marginLeft:'15px'}}>{v.explain}</span>
  225. </div>
  226. ))
  227. }
  228. </Radio.Group>
  229. <div style={{
  230. display:'flex',
  231. justifyContent:'center',
  232. paddingTop:'20px',
  233. paddingBottom: '20px',
  234. }}>
  235. <Button
  236. className="cancel"
  237. type="ghost"
  238. onClick={()=>{
  239. this.updateProjectStatus();
  240. }}
  241. >
  242. 保存
  243. </Button>
  244. </div>
  245. <div style={{textAlign:'center',color:'#f00'}}>注:请根据实际项目情况填写</div>
  246. </div>
  247. </div>
  248. </Modal>
  249. )
  250. }
  251. }
  252. export default NowProjectStatus;