techProduct.jsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. import React from 'react';
  2. import { Icon, Upload, Form, Button, Radio, Input, Spin, Table, message, Select, Modal, DatePicker, Cascader, Transfer, InputNumber } from 'antd';
  3. import { techFieldList, technicalSourceList } from '../../dataDic.js';
  4. import { getTechField, getTechnicalSource, beforeUploadFile } from '../../tools.js';
  5. import './techProduct.less';
  6. import moment from 'moment';
  7. import ajax from 'jquery/src/ajax/xhr.js';
  8. import $ from 'jquery/src/ajax';
  9. const TechProductDescFrom = Form.create()(React.createClass({
  10. getInitialState() {
  11. return {
  12. loading: false,
  13. targetKeys: [],
  14. selectedKeys: [],
  15. technicalSourceOption: [],
  16. };
  17. },
  18. componentWillMount() {
  19. let _me = this;
  20. technicalSourceList.map(function (item) {
  21. _me.state.technicalSourceOption.push(
  22. <Select.Option value={item.value} key={10000 + item.value}>{item.key}</Select.Option>
  23. )
  24. });
  25. this.state.targetKeys = this.props.data.intellectualPropertyNumber;
  26. },
  27. componentWillReceiveProps(nextProps) {
  28. if (nextProps.data) {
  29. this.state.targetKeys = nextProps.data.intellectualPropertyNumber;
  30. };
  31. },
  32. handleSubmit(e) {
  33. e.preventDefault();
  34. this.props.form.validateFields((err, values) => {
  35. if (!err) {
  36. this.props.spinState(true);
  37. $.ajax({
  38. method: "POST",
  39. dataType: "json",
  40. crossDomain: false,
  41. url: globalConfig.context + "/techservice/cognizance/techProduct",
  42. data: {
  43. id: this.props.data.id,
  44. serialNumber: values.serialNumber,
  45. productName: values.productName,
  46. technicalField1: values.techField[0],
  47. technicalField2: values.techField[1],
  48. technicalField3: values.techField[2],
  49. technicalSource: values.technicalSource,
  50. lastYearRevenue: values.lastYearRevenue,
  51. mainProduct: values.mainProduct,
  52. intellectualPropertyNumber: this.state.targetKeys.join(","),
  53. keyTechnology: values.keyTechnology,
  54. competitiveEdge: values.competitiveEdge,
  55. conditionEffect: values.conditionEffect,
  56. accountUrl: this.state.accountUrl
  57. }
  58. }).done(function (data) {
  59. if (!data.error.length) {
  60. message.success('保存成功!');
  61. this.props.clickOk();
  62. this.props.form.resetFields();
  63. this.state.targetKeys = [];
  64. this.state.selectedKeys = [];
  65. this.props.spinState(false);
  66. } else {
  67. message.warning(data.error[0].message);
  68. this.props.spinState(false);
  69. }
  70. }.bind(this));
  71. }
  72. });
  73. },
  74. intellectualChange(nextTargetKeys, direction, moveKeys) {
  75. this.setState({ targetKeys: nextTargetKeys });
  76. },
  77. intellectualSelectChange(sourceSelectedKeys, targetSelectedKeys) {
  78. this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys] });
  79. },
  80. render() {
  81. const FormItem = Form.Item;
  82. const { getFieldDecorator } = this.props.form;
  83. const theData = this.props.data;
  84. const formItemLayout = {
  85. labelCol: { span: 10 },
  86. wrapperCol: { span: 12 },
  87. };
  88. const _me = this;
  89. return (
  90. <Form onSubmit={this.handleSubmit} className="activityCost-form">
  91. <div className="clearfix">
  92. <FormItem className="half-item"
  93. {...formItemLayout}
  94. label="编号:ps"
  95. >
  96. {getFieldDecorator('serialNumber', {
  97. rules: [{ required: true, message: '此项为必填项!' }],
  98. initialValue: theData.serialNumber
  99. })(
  100. <Input />
  101. )}
  102. </FormItem>
  103. <FormItem className="half-item"
  104. {...formItemLayout}
  105. label="产品(服务)名称"
  106. >
  107. {getFieldDecorator('productName', {
  108. rules: [{ required: true, message: '此项为必填项!' }],
  109. initialValue: theData.productName
  110. })(
  111. <Input />
  112. )}
  113. </FormItem>
  114. </div>
  115. <div className="clearfix">
  116. <FormItem className="half-item"
  117. {...formItemLayout}
  118. label="技术来源"
  119. >
  120. {getFieldDecorator('technicalSource', {
  121. rules: [{ required: true, message: '此项为必填项!' }],
  122. initialValue: theData.technicalSource
  123. })(
  124. <Select placeholder="选择技术来源"
  125. onChange={(e) => { this.setState({ technicalSource: e }) }}>
  126. {this.state.technicalSourceOption}
  127. </Select>
  128. )}
  129. </FormItem>
  130. <FormItem className="half-item"
  131. labelCol={{ span: 10 }}
  132. label="上年度销售收入(万元)"
  133. >
  134. {getFieldDecorator('lastYearRevenue', {
  135. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  136. initialValue: theData.lastYearRevenue ? Number(theData.lastYearRevenue) : 0
  137. })(
  138. <InputNumber />
  139. )}
  140. </FormItem>
  141. </div>
  142. <FormItem
  143. labelCol={{ span: 5 }}
  144. wrapperCol={{ span: 16 }}
  145. label="技术领域"
  146. >
  147. {getFieldDecorator('techField', {
  148. rules: [{ type: "array", required: true, message: '此项为必填项!' }],
  149. initialValue: theData.techField
  150. })(
  151. <Cascader
  152. options={techFieldList}
  153. onChange={(value, selectedOptions) => { this.setState({ techField: value }); console.log(value) }}
  154. placeholder="请选择"
  155. showSearch
  156. />
  157. )}
  158. </FormItem>
  159. <div className="clearfix">
  160. <FormItem className="half-item"
  161. {...formItemLayout}
  162. label="是否主要产品(服务)"
  163. >
  164. {getFieldDecorator('mainProduct', {
  165. rules: [{ type: "number", required: true, message: '此项为必填项!' }],
  166. initialValue: theData.mainProduct
  167. })(
  168. <Radio.Group>
  169. <Radio value={1}>是</Radio>
  170. <Radio value={0}>否</Radio>
  171. </Radio.Group>
  172. )}
  173. </FormItem>
  174. </div>
  175. <p>知识产权编号:</p>
  176. <Transfer
  177. dataSource={this.props.mockData}
  178. listStyle={{
  179. width: 200,
  180. height: 200,
  181. }}
  182. titles={['未选择', '已选择']}
  183. targetKeys={this.state.targetKeys}
  184. selectedKeys={this.state.selectedKeys}
  185. onChange={this.intellectualChange}
  186. onSelectChange={this.intellectualSelectChange}
  187. render={item => `${item.name}-${item.key}`}
  188. />
  189. <div className="clearfix">
  190. <FormItem className="half-item"
  191. labelCol={{ span: 0 }}
  192. wrapperCol={{ span: 22 }}
  193. >
  194. <p>关键技术及主要技术指标(限400字)</p>
  195. {getFieldDecorator('keyTechnology', {
  196. rules: [{ required: true, message: '此项为必填项!' }],
  197. initialValue: theData.keyTechnology
  198. })(
  199. <Input type='textarea' rows={6} onChange={(e) => { if (e.target.value.length > 400) { return; } }} />
  200. )}
  201. </FormItem>
  202. <FormItem className="half-item"
  203. labelCol={{ span: 0 }}
  204. wrapperCol={{ span: 22 }}
  205. >
  206. <p>与同类产品(服务)的竞争优势(限400字)</p>
  207. {getFieldDecorator('competitiveEdge', {
  208. rules: [{ required: true, message: '此项为必填项!' }],
  209. initialValue: theData.competitiveEdge
  210. })(
  211. <Input type='textarea' rows={6} onChange={(e) => { if (e.target.value.length > 400) { return; } }} />
  212. )}
  213. </FormItem>
  214. <p style={{ lineHeight: "32px" }}>知识产权获得情况及其对产品(服务)在技术上发挥的支持作用(限400字)*</p>
  215. <FormItem className="half-item"
  216. labelCol={{ span: 0 }}
  217. wrapperCol={{ span: 22 }}
  218. >
  219. {getFieldDecorator('conditionEffect', {
  220. rules: [{ required: true, message: '此项为必填项!' }],
  221. initialValue: theData.conditionEffect
  222. })(
  223. <Input type='textarea' rows={6} onChange={(e) => { if (e.target.value.length > 400) { return; } }} />
  224. )}
  225. </FormItem>
  226. </div>
  227. <div style={{ width: '50%' }}>
  228. <Upload
  229. name="ratepay"
  230. action={globalConfig.context + "/techservice/cognizance/upload"}
  231. data={{ 'sign': this.props.year + 'proof' }}
  232. beforeUpload={beforeUploadFile}
  233. onChange={(info) => {
  234. if (info.file.status !== 'uploading') {
  235. console.log(info.file, info.fileList);
  236. }
  237. if (info.file.status === 'done') {
  238. if (!info.file.response.error.length) {
  239. message.success(`${info.file.name} 文件上传成功!`);
  240. } else {
  241. message.warning(info.file.response.error[0].message);
  242. return;
  243. };
  244. this.state.accountUrl = info.file.response.data;
  245. } else if (info.file.status === 'error') {
  246. message.error(`${info.file.name} 文件上传失败。`);
  247. }
  248. }}
  249. >
  250. <Button><Icon type="upload" /> 上传台账 </Button>
  251. </Upload>
  252. </div>
  253. <FormItem style={{ marginTop: '20px' }}>
  254. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  255. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  256. </FormItem>
  257. </Form >
  258. );
  259. },
  260. }));
  261. const TechProductDesc = React.createClass({
  262. getInitialState() {
  263. return {
  264. visible: false,
  265. loading: false
  266. };
  267. },
  268. componentWillReceiveProps(nextProps) {
  269. this.state.visible = nextProps.showDesc
  270. },
  271. showModal() {
  272. this.setState({
  273. visible: true,
  274. });
  275. },
  276. handleOk() {
  277. this.setState({
  278. visible: false,
  279. });
  280. this.props.closeDesc(false, true);
  281. },
  282. handleCancel(e) {
  283. this.setState({
  284. visible: false,
  285. });
  286. this.props.closeDesc(false);
  287. },
  288. spinChange(e) {
  289. this.setState({
  290. loading: e
  291. });
  292. },
  293. render() {
  294. return (
  295. <div className="patent-addNew">
  296. <Spin spinning={this.state.loading} className='spin-box'>
  297. <Modal title="上年度高新技术产品(服务)情况表" visible={this.state.visible}
  298. onOk={this.handleOk} onCancel={this.handleCancel}
  299. width='1000px'
  300. footer=''
  301. >
  302. <TechProductDescFrom data={this.props.data} mockData={this.props.mockData}
  303. spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
  304. </Modal>
  305. </Spin>
  306. </div>
  307. );
  308. },
  309. });
  310. const TechProduct = React.createClass({
  311. loadData(pageNo) {
  312. this.state.data = [];
  313. this.setState({
  314. loading: true
  315. });
  316. $.when($.ajax({
  317. method: "get",
  318. dataType: "json",
  319. crossDomain: false,
  320. url: globalConfig.context + "/techservice/cognizance/techProductList",
  321. data: {
  322. pageNo: pageNo || 1,
  323. pageSize: this.state.pagination.pageSize
  324. }
  325. }), $.ajax({
  326. method: "get",
  327. dataType: "json",
  328. crossDomain: false,
  329. url: globalConfig.context + "/techservice/cognizance/intellectualList",
  330. data: {
  331. pageNo: pageNo || 1,
  332. pageSize: 99,
  333. }
  334. })).done((data1, data2) => {
  335. let data = data1[0];
  336. let intellectualList = data2[0];
  337. if (data.error.length || !data.data || !data.data.list) {
  338. message.warning(data.error[0].message);
  339. return;
  340. };
  341. if (intellectualList.error.length || !intellectualList.data || !intellectualList.data.list) {
  342. message.warning(intellectualList.error[0].message);
  343. return;
  344. };
  345. let theArr = [];
  346. for (let i = 0; i < intellectualList.data.list.length; i++) {
  347. theArr.push({
  348. key: intellectualList.data.list[i].intellectualPropertyNumber,
  349. name: intellectualList.data.list[i].intellectualPropertyName
  350. });
  351. };
  352. this.state.mockData = theArr;
  353. for (let i = 0; i < data.data.list.length; i++) {
  354. let thisdata = data.data.list[i];
  355. this.state.data.push({
  356. key: i,
  357. id: thisdata.id,
  358. uid: thisdata.uid,
  359. mockData: this.state.mockData,
  360. serialNumber: thisdata.serialNumber,
  361. productName: thisdata.productName,
  362. techField: [Number(thisdata.technicalField1), Number(thisdata.technicalField2), Number(thisdata.technicalField3)],
  363. technicalField: getTechField(thisdata.technicalField1, thisdata.technicalField2, thisdata.technicalField3),
  364. technicalField1: thisdata.technicalField1,
  365. technicalField2: thisdata.technicalField2,
  366. technicalField3: thisdata.technicalField3,
  367. technicalSource: String(thisdata.technicalSource),
  368. lastYearRevenue: thisdata.lastYearRevenue,
  369. mainProduct: thisdata.mainProduct,
  370. PropertyNumber: thisdata.intellectualPropertyNumber,
  371. intellectualPropertyNumber: thisdata.intellectualPropertyNumber ? thisdata.intellectualPropertyNumber.split(",") : [],
  372. keyTechnology: thisdata.keyTechnology,
  373. competitiveEdge: thisdata.competitiveEdge,
  374. conditionEffect: thisdata.conditionEffect,
  375. year: thisdata.year,
  376. createTime: thisdata.createTime,
  377. });
  378. };
  379. this.state.pagination.current = data.data.pageNo;
  380. this.state.pagination.total = data.data.totalCount;
  381. this.setState({
  382. dataSource: this.state.data,
  383. pagination: this.state.pagination
  384. });
  385. }).always(function () {
  386. this.setState({
  387. loading: false
  388. });
  389. }.bind(this));
  390. },
  391. getInitialState() {
  392. return {
  393. selectedRowKeys: [],
  394. selectedRows: [],
  395. loading: false,
  396. pagination: {
  397. defaultCurrent: 1,
  398. defaultPageSize: 10,
  399. showQuickJumper: true,
  400. pageSize: 10,
  401. onChange: function (page) {
  402. this.loadData(page);
  403. }.bind(this),
  404. showTotal: function (total) {
  405. return '共' + total + '条数据';
  406. }
  407. },
  408. columns: [
  409. {
  410. title: '产品编号',
  411. dataIndex: 'serialNumber',
  412. key: 'serialNumber'
  413. }, {
  414. title: '产品(服务)名称',
  415. dataIndex: 'productName',
  416. key: 'productName'
  417. }, {
  418. title: '技术领域',
  419. dataIndex: 'technicalField',
  420. key: 'technicalField'
  421. }, {
  422. title: '技术来源',
  423. dataIndex: 'technicalSource',
  424. key: 'technicalSource',
  425. render: (text) => { return getTechnicalSource(text) }
  426. }, {
  427. title: '上年度销售收入(万元)',
  428. dataIndex: 'lastYearRevenue',
  429. key: 'lastYearRevenue'
  430. }, {
  431. title: '是否主要产品(服务)',
  432. dataIndex: 'mainProduct',
  433. key: 'mainProduct',
  434. render: (text) => { if (text == "1") { return '是' } else { return '否' } }
  435. }, {
  436. title: '知识产权编号',
  437. dataIndex: 'PropertyNumber',
  438. key: 'PropertyNumber'
  439. }
  440. ],
  441. dataSource: []
  442. };
  443. },
  444. componentWillMount() {
  445. this.loadData();
  446. },
  447. tableRowClick(record, index) {
  448. this.state.RowData = record;
  449. this.setState({
  450. showDesc: true
  451. });
  452. },
  453. delectRow() {
  454. let deletedIds = [];
  455. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  456. let rowItem = this.state.selectedRows[idx];
  457. if (rowItem.id) {
  458. deletedIds.push(rowItem.id)
  459. }
  460. }
  461. this.setState({
  462. selectedRowKeys: [],
  463. loading: deletedIds.length > 0
  464. });
  465. $.ajax({
  466. method: "POST",
  467. dataType: "json",
  468. crossDomain: false,
  469. url: globalConfig.context + "/techservice/cognizance/deleteTechProduct",
  470. data: {
  471. ids: deletedIds
  472. }
  473. }).done(function (data) {
  474. if (!data.error.length) {
  475. message.success('保存成功!');
  476. this.setState({
  477. loading: false,
  478. });
  479. } else {
  480. message.warning(data.error[0].message);
  481. };
  482. this.loadData();
  483. }.bind(this));
  484. },
  485. closeDesc(e, s) {
  486. this.state.showDesc = e;
  487. if (s) {
  488. this.loadData();
  489. };
  490. },
  491. search() {
  492. this.loadData();
  493. },
  494. reset() {
  495. this.loadData();
  496. },
  497. render() {
  498. const rowSelection = {
  499. selectedRowKeys: this.state.selectedRowKeys,
  500. onChange: (selectedRowKeys, selectedRows) => {
  501. this.setState({
  502. selectedRows: selectedRows,
  503. selectedRowKeys: selectedRowKeys
  504. });
  505. }
  506. };
  507. const hasSelected = this.state.selectedRowKeys.length > 0;
  508. return (
  509. <div className="user-content" >
  510. <div className="content-title">
  511. <span>高新技术产品(服务)情况表</span>
  512. </div>
  513. <div className="user-search">
  514. <p>
  515. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  516. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  517. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  518. disabled={!hasSelected}
  519. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  520. </p>
  521. </div>
  522. <div className="patent-table">
  523. <Spin spinning={this.state.loading}>
  524. <Table columns={this.state.columns}
  525. dataSource={this.state.dataSource}
  526. pagination={this.state.pagination}
  527. rowSelection={rowSelection}
  528. onRowClick={this.tableRowClick} />
  529. </Spin>
  530. </div>
  531. <TechProductDesc data={this.state.RowData}
  532. mockData={this.state.mockData}
  533. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  534. </div >
  535. );
  536. }
  537. });
  538. export default TechProduct;