index.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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 立项金额 18
  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[18]) && setUpAmount){
  114. this.state.dataInfor[18]={title:'立项金额'};
  115. this.state.dataInfor[18]['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'}}>{this.state.dataInfor[v.id] && this.state.dataInfor[v.id][d]}</span> :
  170. d === 'date' ?
  171. <DatePicker
  172. style={{ marginRight: '5px',width:'120px' }}
  173. showTime
  174. format="YYYY-MM-DD"
  175. onOk={() => {}}
  176. value={
  177. this.state.dataInfor[v.id][d] ? moment(this.state.dataInfor[v.id][d]) : null
  178. }
  179. onChange={(data, dataString) => {
  180. this.state.dataInfor[v.id][d] = dataString;
  181. this.setState({
  182. dataInfor:this.state.dataInfor,
  183. })
  184. }}
  185. /> :
  186. d === 'setUpAmount' || d === 'certificateNumber'? <Input
  187. placeholder={v.placeholder}
  188. value={this.state.dataInfor[v.id][d]}
  189. style={{ width: '120px',marginRight: '5px', }}
  190. onChange={(e) => {
  191. this.state.dataInfor[v.id][d] = e.target.value;
  192. this.setState({
  193. dataInfor:this.state.dataInfor,
  194. })
  195. }}
  196. /> : null
  197. ))
  198. }
  199. <span style={{color:'#f00',marginLeft:'15px'}}>{v.explain}</span>
  200. </div>
  201. ))
  202. }
  203. </Radio.Group>
  204. <div style={{
  205. display:'flex',
  206. justifyContent:'center',
  207. paddingTop:'20px',
  208. paddingBottom: '20px',
  209. }}>
  210. <Button
  211. className="cancel"
  212. type="ghost"
  213. onClick={()=>{
  214. this.updateProjectStatus();
  215. }}
  216. >
  217. 保存
  218. </Button>
  219. </div>
  220. <div style={{textAlign:'center',color:'#f00'}}>注:请根据实际项目情况填写</div>
  221. </div>
  222. </div>
  223. </Modal>
  224. )
  225. }
  226. }
  227. export default NowProjectStatus;