websiteChange.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. import React from 'react';
  2. import { Icon, Form, Button, Input, Select, Spin, Table, DatePicker, message, Modal, Checkbox, Upload } from 'antd';
  3. import { cognizanceStateList } from '../../../dataDic.js';
  4. import { getCognizanceState, beforeUpload, getBase64 } from '../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. class Avatar extends React.Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. imageUrl: ''
  12. }
  13. }
  14. handleChange(info) {
  15. if (!this.props.oid || this.props.oid === "") {
  16. message.warning('请先选择公司!');
  17. return;
  18. };
  19. if (info.file.status === 'done') {
  20. // Get this url from response in real world.
  21. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl }));
  22. this.props.urlData(info.file.response.data);
  23. }
  24. }
  25. render() {
  26. const imageUrl = this.state.imageUrl;
  27. return (
  28. <Upload
  29. className="avatar-uploader"
  30. name="avatar"
  31. showUploadList={false}
  32. action={globalConfig.context + "/techservice/patent/patentFile"}
  33. data={{ 'sign': this.props.name, 'oid': this.props.oid }}
  34. beforeUpload={beforeUpload}
  35. onChange={this.handleChange.bind(this)}
  36. >
  37. {
  38. imageUrl ?
  39. <img src={imageUrl} role="presentation" className="avatar" /> :
  40. <Icon type="plus" className="avatar-uploader-trigger" />
  41. }
  42. </Upload>
  43. );
  44. }
  45. };
  46. const WebsiteChangeFrom = Form.create()(React.createClass({
  47. loadData() {
  48. this.setState({
  49. loading: true
  50. });
  51. $.ajax({
  52. method: "post",
  53. dataType: "json",
  54. crossDomain: false,
  55. url: globalConfig.context + "/api/admintechproject/",
  56. data: {
  57. cid: this.props.data.cid,
  58. uid: this.props.data.uid,
  59. year: this.props.data.year
  60. },
  61. success: function (data) {
  62. if (data.error.length || !data.data) {
  63. message.warning(data.error[0].message);
  64. return;
  65. };
  66. this.state.data = data.data;
  67. this.state.cid = this.props.data.cid;
  68. this.state.moneyTable = [{
  69. key: 1,
  70. year: '第一年',
  71. netAsset: data.data.netAsset1,
  72. salesRevenue: data.data.salesRevenue1,
  73. grossProfit: data.data.grossProfit1
  74. }, {
  75. key: 2,
  76. year: '第二年',
  77. netAsset: data.data.netAsset2,
  78. salesRevenue: data.data.salesRevenue2,
  79. grossProfit: data.data.grossProfit2
  80. }, {
  81. key: 3,
  82. year: '第三年',
  83. netAsset: data.data.netAsset3,
  84. salesRevenue: data.data.salesRevenue3,
  85. grossProfit: data.data.grossProfit3
  86. }];
  87. }.bind(this),
  88. }).always(function () {
  89. this.setState({
  90. loading: false
  91. });
  92. }.bind(this));
  93. },
  94. getStateData() {
  95. this.setState({
  96. loading: true
  97. });
  98. $.ajax({
  99. method: "post",
  100. dataType: "json",
  101. crossDomain: false,
  102. url: globalConfig.context + "/api/admin/cognizanceLog",
  103. data: {
  104. cid: this.props.data
  105. },
  106. success: function (data) {
  107. if (data.error.length || !data.data) {
  108. message.warning(data.error[0].message);
  109. return;
  110. };
  111. this.state.stateTable = [];
  112. for (let i = 0; i < data.data.length; i++) {
  113. this.state.stateTable.push({
  114. key: i,
  115. recordTimeFormattedDate: data.data[i].recordTimeFormattedDate,
  116. state: data.data[i].state,
  117. principal: data.data[i].principal,
  118. comment: data.data[i].comment
  119. });
  120. };
  121. }.bind(this),
  122. }).always(function () {
  123. this.setState({
  124. loading: false
  125. });
  126. }.bind(this));
  127. },
  128. getInitialState() {
  129. return {
  130. loading: false,
  131. stateOption: [],
  132. introduce:'',
  133. projectCheck: 0,
  134. subsidy: 0,
  135. stateColumns: [{
  136. title: '专利状态',
  137. dataIndex: 'state',
  138. key: 'state',
  139. render: (text) => { return getCognizanceState(text) }
  140. }, {
  141. title: '处理时间',
  142. dataIndex: 'recordTimeFormattedDate',
  143. key: 'recordTimeFormattedDate',
  144. }, {
  145. title: '负责人',
  146. dataIndex: 'principal',
  147. key: 'principal',
  148. }, {
  149. title: '备注',
  150. dataIndex: 'comment',
  151. key: 'comment',
  152. }],
  153. stateTable: []
  154. };
  155. },
  156. componentWillMount() {
  157. let _me = this;
  158. cognizanceStateList.map(function (item) {
  159. _me.state.stateOption.push(
  160. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  161. )
  162. });
  163. this.loadData();
  164. this.getStateData();
  165. },
  166. handleSubmit(e) {
  167. e.preventDefault();
  168. this.props.form.validateFields((err, values) => {
  169. if (values.state || values.principal || values.recordTime || values.comment) {
  170. if (!values.state && !values.principal && !values.recordTime) {
  171. message.warning("请填写完整的状态流转信息!");
  172. return;
  173. };
  174. };
  175. if (!err) {
  176. this.props.spinState(true);
  177. $.ajax({
  178. method: "POST",
  179. dataType: "json",
  180. crossDomain: false,
  181. url: globalConfig.context + "/api/admin/disposeCognizanceDetail",
  182. data: {
  183. id: this.props.data.cid,
  184. technicalField: values.technicalField,
  185. basicResearchCost: values.basicResearchCost,
  186. accident: values.accident,
  187. recordTimeFormattedDate: values.recordTime ? values.recordTime.format("YYYY-MM-DD") : undefined,
  188. state: values.state,
  189. principal: values.principal,
  190. comment: values.comment,
  191. }
  192. }).done(function (data) {
  193. if (!data.error.length) {
  194. message.success('保存成功!');
  195. this.props.closeModal();
  196. this.props.form.resetFields();
  197. this.state.targetKeys = [];
  198. this.state.selectedKeys = [];
  199. this.props.spinState(false);
  200. } else {
  201. message.warning(data.error[0].message);
  202. this.props.spinState(false);
  203. }
  204. }.bind(this));
  205. }
  206. });
  207. },
  208. componentWillReceiveProps(nextProps) {
  209. if (!this.props.visible && nextProps.visible) {
  210. this.getStateData();
  211. this.loadData();
  212. };
  213. },
  214. projectEstablishmentCheck(e) {
  215. if (e.target.checked == true) {
  216. this.state.projectCheck = 1;
  217. } else if (e.target.checked == false) {
  218. this.state.projectCheck = 0;
  219. };
  220. },
  221. subsidyCheck(e) {
  222. if (e.target.checked == true) {
  223. this.state.subsidy = 1;
  224. } else if (e.target.checked == false) {
  225. this.state.subsidy = 0;
  226. };
  227. },
  228. avatarUrl(e) {
  229. this.state.avatarUrl = e;
  230. },
  231. render() {
  232. const FormItem = Form.Item;
  233. const { getFieldDecorator } = this.props.form;
  234. const theData = this.state.data;
  235. const formItemLayout = {
  236. labelCol: { span: 6 },
  237. wrapperCol: { span: 12 },
  238. };
  239. const _me = this;
  240. if (this.state.data) {
  241. return (
  242. <Form onSubmit={this.handleSubmit} id="highTechApply-form">
  243. <div className="clearfix">
  244. <div className="half-item">
  245. <span className="item-title">选择公司: </span>
  246. <Select
  247. placeholder="请选择公司"
  248. style={{ width: 200 }}
  249. showSearch
  250. onChange={(e)=>{ this.state.unitName = e;}}>
  251. {this.props.companyOption}
  252. </Select>
  253. </div>
  254. </div>
  255. <div className="clearfix">
  256. <div className="half-item">
  257. <span className="item-title">科技部门名称: </span>
  258. <Input value={this.state.department} onChange={(e) => { this.setState({ department: e.target.value }); }} style={{ width: 200 }} />
  259. </div>
  260. </div>
  261. <div className="clearfix">
  262. <div className="half-item">
  263. <span className="item-title">网址: </span>
  264. <Input value={this.state.website} onChange={(e) => { this.setState({ website: e.target.value }); }} style={{ width: 200 }} />
  265. </div>
  266. </div>
  267. <div className="clearfix">
  268. <div className="half-item">
  269. <span className="item-title">账号: </span>
  270. <Input value={this.state.accountNumber} onChange={(e) => { this.setState({ accountNumber: e.target.value }); }} style={{ width: 200 }} />
  271. </div>
  272. </div>
  273. <div className="clearfix">
  274. <div className="half-item">
  275. <span className="item-title">密码: </span>
  276. <Input value={this.state.password} onChange={(e) => { this.setState({ password: e.target.value }); }} style={{ width: 200 }} />
  277. </div>
  278. </div>
  279. </Form >
  280. );
  281. } else {
  282. return (<div></div>)
  283. };
  284. },
  285. }));
  286. const WebsiteChange = React.createClass({
  287. getInitialState() {
  288. return {
  289. visible: false,
  290. loading: false
  291. };
  292. },
  293. componentWillReceiveProps(nextProps) {
  294. this.state.visible = nextProps.showDesc
  295. },
  296. showModal() {
  297. this.setState({
  298. visible: true,
  299. });
  300. },
  301. handleOk() {
  302. this.setState({
  303. visible: false,
  304. });
  305. this.props.closeDesc(false);
  306. },
  307. handleCancel(e) {
  308. this.setState({
  309. visible: false,
  310. });
  311. this.props.closeDesc(false);
  312. },
  313. spinChange(e) {
  314. this.setState({
  315. loading: e
  316. });
  317. },
  318. render() {
  319. return (
  320. <div className="patent-addNew">
  321. <Spin spinning={this.state.loading} className='spin-box'>
  322. <Modal title="编辑科技部门网址" visible={this.state.visible}
  323. onOk={this.handleOk} onCancel={this.handleCancel}
  324. width='800px'
  325. footer=''
  326. >
  327. <WebsiteChangeFrom
  328. visible={this.state.visible}
  329. authorOption={this.props.authorOption}
  330. data={this.props.data}
  331. spinState={this.spinChange} closeModal={this.handleCancel} />
  332. </Modal>
  333. </Spin>
  334. </div>
  335. );
  336. }
  337. });
  338. export default WebsiteChange;