techProduct.jsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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.closeModal();
  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. message.success(`${info.file.name} 文件上传成功!`);
  239. this.state.accountUrl = info.file.response.data;
  240. } else if (info.file.status === 'error') {
  241. message.error(`${info.file.name} 文件上传失败。`);
  242. }
  243. }}
  244. >
  245. <Button><Icon type="upload" /> 上传台账 </Button>
  246. </Upload>
  247. </div>
  248. <FormItem style={{ marginTop: '20px' }}>
  249. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  250. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  251. </FormItem>
  252. </Form >
  253. );
  254. },
  255. }));
  256. const TechProductDesc = React.createClass({
  257. getInitialState() {
  258. return {
  259. visible: false,
  260. loading: false
  261. };
  262. },
  263. componentWillReceiveProps(nextProps) {
  264. this.state.visible = nextProps.showDesc
  265. },
  266. showModal() {
  267. this.setState({
  268. visible: true,
  269. });
  270. },
  271. handleOk() {
  272. this.setState({
  273. visible: false,
  274. });
  275. this.props.closeDesc(false);
  276. },
  277. handleCancel(e) {
  278. this.setState({
  279. visible: false,
  280. });
  281. this.props.closeDesc(false);
  282. },
  283. spinChange(e) {
  284. this.setState({
  285. loading: e
  286. });
  287. },
  288. render() {
  289. return (
  290. <div className="patent-addNew">
  291. <Spin spinning={this.state.loading} className='spin-box'>
  292. <Modal title="上年度高新技术产品(服务)情况表" visible={this.state.visible}
  293. onOk={this.handleOk} onCancel={this.handleCancel}
  294. width='800px'
  295. footer=''
  296. >
  297. <TechProductDescFrom data={this.props.data} mockData={this.props.mockData}
  298. spinState={this.spinChange} closeModal={this.handleCancel} />
  299. </Modal>
  300. </Spin>
  301. </div>
  302. );
  303. },
  304. });
  305. const TechProduct = React.createClass({
  306. loadData(pageNo) {
  307. this.state.data = [];
  308. this.setState({
  309. loading: true
  310. });
  311. $.when($.ajax({
  312. method: "get",
  313. dataType: "json",
  314. crossDomain: false,
  315. url: globalConfig.context + "/techservice/cognizance/techProductList",
  316. data: {
  317. pageNo: pageNo || 1,
  318. pageSize: this.state.pagination.pageSize
  319. }
  320. }), $.ajax({
  321. method: "get",
  322. dataType: "json",
  323. crossDomain: false,
  324. url: globalConfig.context + "/techservice/cognizance/intellectualList",
  325. data: {
  326. pageNo: pageNo || 1,
  327. pageSize: 99,
  328. }
  329. })).done((data1, data2) => {
  330. let data = data1[0];
  331. let intellectualList = data2[0];
  332. if (data.error.length || !data.data || !data.data.list) {
  333. message.warning(data.error[0].message);
  334. return;
  335. };
  336. if (intellectualList.error.length || !intellectualList.data || !intellectualList.data.list) {
  337. message.warning(intellectualList.error[0].message);
  338. return;
  339. };
  340. let theArr = [];
  341. for (let i = 0; i < intellectualList.data.list.length; i++) {
  342. theArr.push({
  343. key: intellectualList.data.list[i].intellectualPropertyNumber,
  344. name: intellectualList.data.list[i].intellectualPropertyName
  345. });
  346. };
  347. this.state.mockData = theArr;
  348. for (let i = 0; i < data.data.list.length; i++) {
  349. let thisdata = data.data.list[i];
  350. this.state.data.push({
  351. key: i,
  352. id: thisdata.id,
  353. uid: thisdata.uid,
  354. mockData: this.state.mockData,
  355. serialNumber: thisdata.serialNumber,
  356. productName: thisdata.productName,
  357. techField: [Number(thisdata.technicalField1), Number(thisdata.technicalField2), Number(thisdata.technicalField3)],
  358. technicalField: getTechField(thisdata.technicalField1, thisdata.technicalField2, thisdata.technicalField3),
  359. technicalField1: thisdata.technicalField1,
  360. technicalField2: thisdata.technicalField2,
  361. technicalField3: thisdata.technicalField3,
  362. technicalSource: String(thisdata.technicalSource),
  363. lastYearRevenue: thisdata.lastYearRevenue,
  364. mainProduct: thisdata.mainProduct,
  365. PropertyNumber: thisdata.intellectualPropertyNumber,
  366. intellectualPropertyNumber: thisdata.intellectualPropertyNumber ? thisdata.intellectualPropertyNumber.split(",") : [],
  367. keyTechnology: thisdata.keyTechnology,
  368. competitiveEdge: thisdata.competitiveEdge,
  369. conditionEffect: thisdata.conditionEffect,
  370. year: thisdata.year,
  371. createTime: thisdata.createTime,
  372. });
  373. };
  374. this.state.pagination.current = data.data.pageNo;
  375. this.state.pagination.total = data.data.totalCount;
  376. this.setState({
  377. dataSource: this.state.data,
  378. pagination: this.state.pagination
  379. });
  380. }).always(function () {
  381. this.setState({
  382. loading: false
  383. });
  384. }.bind(this));
  385. },
  386. getInitialState() {
  387. return {
  388. selectedRowKeys: [],
  389. selectedRows: [],
  390. loading: false,
  391. pagination: {
  392. defaultCurrent: 1,
  393. defaultPageSize: 10,
  394. showQuickJumper: true,
  395. pageSize: 10,
  396. onChange: function (page) {
  397. this.loadData(page);
  398. }.bind(this),
  399. showTotal: function (total) {
  400. return '共' + total + '条数据';
  401. }
  402. },
  403. columns: [
  404. {
  405. title: '产品编号',
  406. dataIndex: 'serialNumber',
  407. key: 'serialNumber'
  408. }, {
  409. title: '产品(服务)名称',
  410. dataIndex: 'productName',
  411. key: 'productName'
  412. }, {
  413. title: '技术领域',
  414. dataIndex: 'technicalField',
  415. key: 'technicalField'
  416. }, {
  417. title: '技术来源',
  418. dataIndex: 'technicalSource',
  419. key: 'technicalSource',
  420. render: (text) => { return getTechnicalSource(text) }
  421. }, {
  422. title: '上年度销售收入(万元)',
  423. dataIndex: 'lastYearRevenue',
  424. key: 'lastYearRevenue'
  425. }, {
  426. title: '是否主要产品(服务)',
  427. dataIndex: 'mainProduct',
  428. key: 'mainProduct',
  429. render: (text) => { if (text == "1") { return '是' } else { return '否' } }
  430. }, {
  431. title: '知识产权编号',
  432. dataIndex: 'PropertyNumber',
  433. key: 'PropertyNumber'
  434. }
  435. ],
  436. dataSource: []
  437. };
  438. },
  439. componentWillMount() {
  440. this.loadData();
  441. },
  442. tableRowClick(record, index) {
  443. this.state.RowData = record;
  444. this.setState({
  445. showDesc: true
  446. });
  447. },
  448. delectRow() {
  449. let deletedIds = [];
  450. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  451. let rowItem = this.state.selectedRows[idx];
  452. if (rowItem.id) {
  453. deletedIds.push(rowItem.id)
  454. }
  455. }
  456. this.setState({
  457. selectedRowKeys: [],
  458. loading: deletedIds.length > 0
  459. });
  460. $.ajax({
  461. method: "POST",
  462. dataType: "json",
  463. crossDomain: false,
  464. url: globalConfig.context + "/techservice/cognizance/deleteTechProduct",
  465. data: {
  466. ids: deletedIds
  467. }
  468. }).done(function (data) {
  469. if (!data.error.length) {
  470. message.success('保存成功!');
  471. this.setState({
  472. loading: false,
  473. });
  474. } else {
  475. message.warning(data.error[0].message);
  476. };
  477. this.loadData();
  478. }.bind(this));
  479. },
  480. closeDesc(e) {
  481. this.state.showDesc = e;
  482. this.loadData();
  483. },
  484. search() {
  485. this.loadData();
  486. },
  487. reset() {
  488. this.loadData();
  489. },
  490. render() {
  491. const rowSelection = {
  492. selectedRowKeys: this.state.selectedRowKeys,
  493. onChange: (selectedRowKeys, selectedRows) => {
  494. this.setState({
  495. selectedRows: selectedRows,
  496. selectedRowKeys: selectedRowKeys
  497. });
  498. }
  499. };
  500. const hasSelected = this.state.selectedRowKeys.length > 0;
  501. return (
  502. <div className="user-content" >
  503. <div className="content-title">
  504. <span>上年度高新技术产品(服务)情况表</span>
  505. </div>
  506. <div className="user-search">
  507. <p>
  508. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  509. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  510. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  511. disabled={!hasSelected}
  512. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  513. </p>
  514. </div>
  515. <div className="patent-table">
  516. <Spin spinning={this.state.loading}>
  517. <Table columns={this.state.columns}
  518. dataSource={this.state.dataSource}
  519. pagination={this.state.pagination}
  520. rowSelection={rowSelection}
  521. onRowClick={this.tableRowClick} />
  522. </Spin>
  523. </div>
  524. <TechProductDesc data={this.state.RowData}
  525. mockData={this.state.mockData}
  526. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  527. </div >
  528. );
  529. }
  530. });
  531. export default TechProduct;