index.jsx 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. import React,{Component} from "react";
  2. import {AutoComplete, Button, Form, Input, message, Modal, Radio, Select, Spin} from "antd";
  3. import {boutique} from "../../dataDic";
  4. import $ from "jquery";
  5. import {getboutique} from "../../tools";
  6. const FormItem = Form.Item;
  7. const formItemLayout = {
  8. labelCol: { span: 8 },
  9. wrapperCol: { span: 14 },
  10. };
  11. class ProjectOperation extends Component{
  12. constructor(props) {
  13. super(props);
  14. this.state={
  15. commodityName:'',
  16. commodityQuantity:'',
  17. patentType:0,
  18. officialCost:'',
  19. costReduction:'',
  20. commodityPrice:'',
  21. main:'',
  22. taskComment:'',
  23. declarationBatch:'',
  24. ifCertificationFee:'',
  25. displayFees: "none",
  26. customerArr:[],
  27. patentTypeList:[],
  28. loading:false,
  29. patentTransfer:props.dataInfor ? props.dataInfor.patentTransfer : 0 //收否为专利转让 0 否 1 是
  30. }
  31. this.onSubmit = this.onSubmit.bind(this);
  32. this.httpChange = this.httpChange.bind(this);
  33. this.selectAuto = this.selectAuto.bind(this);
  34. this.getpatentTypeList = this.getpatentTypeList.bind(this);
  35. this.setValue = this.setValue.bind(this);
  36. }
  37. componentDidMount() {
  38. this.getpatentTypeList();
  39. this.setValue();
  40. }
  41. setValue(){
  42. const {dataInfor} = this.props;
  43. if(!(dataInfor && Object.keys(dataInfor).length > 0)){return;}
  44. if (dataInfor.type === 1){
  45. this.setState({
  46. displayFees: "block",
  47. costReduction: dataInfor.costReduction,
  48. officialCost: dataInfor.officialCost,
  49. patentType: dataInfor.patentType ? dataInfor.patentType : 0,
  50. });
  51. }else{
  52. this.setState({
  53. displayFees: "none",
  54. });
  55. }
  56. this.setState({
  57. jid: dataInfor.id, //项目ID
  58. kid: dataInfor.commodityId, //商品ID
  59. commodityName: dataInfor.commodityName, //项目名称
  60. commodityPrice: dataInfor.commodityPrice, //金额
  61. commodityQuantity: dataInfor.commodityQuantity, //数量
  62. patentTypeName:dataInfor.patentTypeName,//专利类型名称
  63. taskComment: dataInfor.taskComment, //备注
  64. main: dataInfor.main.toString(), //是否为主要
  65. addState: 0,
  66. addnextVisible: true,
  67. addProjectType: dataInfor.type,
  68. declarationBatch: dataInfor.declarationBatch || 1,//申报批次(只有高新有)
  69. ifCertificationFee: isNaN(parseInt(dataInfor.ifCertificationFee)) ? '' : dataInfor.ifCertificationFee,//是否包含认证费
  70. isIso: dataInfor.commodityName.indexOf("贯标") !== -1,
  71. });
  72. }
  73. onSubmit(){
  74. if (this.state.gid === undefined || !this.state.gid) {
  75. message.warning("服务名称不匹配!");
  76. return false;
  77. }
  78. if (this.state.displayFees==='block') {
  79. if (this.state.patentType === "" && !this.state.patentTransfer) {
  80. message.warning("请选择专利类型!");
  81. return false;
  82. }
  83. if(this.state.officialCost===''){
  84. message.warning("请选择官费!");
  85. return false;
  86. }
  87. if (this.state.costReduction === "" && (this.state.patentType === 0 || this.state.patentType === 2) && this.state.officialCost === 1) {
  88. message.warning("请选择费减!");
  89. return false;
  90. }
  91. }
  92. if(isNaN(parseFloat(this.state.commodityPrice))){
  93. message.warning("请输入正确的金额!");
  94. return false;
  95. }
  96. let reg = /^([0]|[1-9][0-9]*)$/;
  97. if (
  98. !this.state.commodityQuantity ||
  99. !reg.test(this.state.commodityQuantity)
  100. ) {
  101. message.warning("请输入正确商品数量!");
  102. return false;
  103. }
  104. if (!this.state.main) {
  105. message.warning("请选择是否为主要项目!");
  106. return false;
  107. }
  108. if(this.state.addProjectType === 5 && !this.state.declarationBatch){
  109. message.warning("请选择企业要求申报批次!");
  110. return false;
  111. }
  112. if(this.state.isIso && !this.state.ifCertificationFee){
  113. message.warning("请选择是否包含认证费用!");
  114. return false;
  115. }
  116. this.setState({
  117. loading: true,
  118. });
  119. let infor = {
  120. commodityId: this.state.gid, //商品ID
  121. orderNo: this.props.orderNo, //订单编号
  122. commodityName: this.state.commodityName, //商品名称
  123. commodityQuantity: this.state.commodityQuantity, //商品数量
  124. commodityPrice: this.state.commodityPrice, //签单总价
  125. taskComment: this.state.taskComment, //服务说明
  126. main: this.state.main, //是否为主要项目
  127. officialCost: this.state.displayFees==='block' ? this.state.officialCost : '', //是否有官费
  128. costReduction: this.state.displayFees==='block' ? ((this.state.patentType === 0 || this.state.patentType === 2) ? (this.state.officialCost === 1 ? this.state.costReduction : 0) : 0) : '', //是否有费减
  129. patentType: this.state.displayFees==='block' && !this.state.patentTransfer ? this.state.patentType : undefined, // 专利类型
  130. }
  131. if(this.state.addProjectType === 5){
  132. infor.declarationBatch = this.state.declarationBatch || 1//申报批次
  133. }
  134. if(this.state.isIso){
  135. infor.ifCertificationFee = this.state.ifCertificationFee || undefined;//是否包含认证费用
  136. }
  137. $.ajax({
  138. method: "POST",
  139. dataType: "json",
  140. crossDomain: false,
  141. url: globalConfig.context + "/api/admin/newOrder/addOrderTask",
  142. data: infor,
  143. }).done(
  144. function (data) {
  145. this.setState({
  146. loading: false,
  147. });
  148. if (!data.error.length) {
  149. message.success("保存成功!");
  150. this.props.onCancel();
  151. } else {
  152. message.warning(data.error[0].message);
  153. }
  154. }.bind(this)
  155. );
  156. }
  157. onChange() {
  158. if(isNaN(parseFloat(this.state.commodityPrice))){
  159. message.warning("请输入正确的金额!");
  160. return false;
  161. }
  162. let reg = /^([0]|[1-9][0-9]*)$/;
  163. if (
  164. !this.state.commodityQuantity ||
  165. !reg.test(this.state.commodityQuantity)
  166. ) {
  167. message.warning("请输入正确商品数量!");
  168. return false;
  169. }
  170. if (!this.state.main) {
  171. message.warning("请选择是否为主要项目!");
  172. return false;
  173. }
  174. this.setState({
  175. loading: true,
  176. });
  177. $.ajax({
  178. method: "POST",
  179. dataType: "json",
  180. crossDomain: false,
  181. url: globalConfig.context + "/api/admin/newOrder/updateOrderTask",
  182. data: {
  183. id: this.state.jid, //项目ID
  184. commodityId: this.state.kid, //商品ID
  185. orderNo: this.props.orderNo, //订单编号
  186. main: this.state.main, //是否为主要
  187. commodityPrice: this.state.commodityPrice, //金额
  188. commodityQuantity: this.state.commodityQuantity, //数量
  189. taskComment: this.state.taskComment, //备注
  190. officialCost: this.state.displayFees==='block' ? this.state.officialCost : '', //是否有官费
  191. costReduction: this.state.displayFees==='block' ? ((this.state.patentType === 0 || this.state.patentType === 2) ? (this.state.officialCost === 1 ? this.state.costReduction : 0) : 0) : '', //是否有费减
  192. patentType: this.state.displayFees==='block' ? this.state.patentType : '', //专利类型
  193. declarationBatch: this.state.declarationBatch || undefined,//申报批次
  194. ifCertificationFee: isNaN(parseInt(this.state.ifCertificationFee)) ? undefined : this.state.ifCertificationFee,
  195. },
  196. }).done(
  197. function (data) {
  198. this.setState({
  199. loading: false,
  200. });
  201. if (!data.error.length) {
  202. message.success("保存成功!");
  203. this.props.onCancel();
  204. } else {
  205. message.warning(data.error[0].message);
  206. }
  207. }.bind(this)
  208. );
  209. }
  210. httpChange(e) {
  211. this.setState({
  212. commodityName: e,
  213. });
  214. if (e.length >= 1) {
  215. this.supervisor(e, false);
  216. }
  217. }
  218. //加载(自动补全)
  219. supervisor(e, state) {
  220. //客户名称与服务名称自动补全
  221. let api = state
  222. ? "/api/admin/customer/getCustomerByName"
  223. : "/api/admin/order/getBusinessProjectByName";
  224. $.ajax({
  225. method: "get",
  226. dataType: "json",
  227. crossDomain: false,
  228. url: globalConfig.context + api,
  229. data: state
  230. ? {
  231. name: e,
  232. type: this.state.customType,
  233. }
  234. : {
  235. businessName: e,
  236. },
  237. success: function (data) {
  238. let thedata = data.data;
  239. if (!thedata) {
  240. if (data.error && data.error.length) {
  241. message.warning(data.error[0].message);
  242. }
  243. thedata = {};
  244. }
  245. this.setState({
  246. states: state,
  247. customerArr: thedata,
  248. });
  249. }.bind(this),
  250. }).always(
  251. function () {
  252. }.bind(this)
  253. );
  254. }
  255. //上级主管输入框失去焦点是判断客户是否存在
  256. selectAuto(value) {
  257. let kid = {};
  258. let fwList = this.state.customerArr;
  259. fwList.map(function (item) {
  260. if (value == item.bname) {
  261. kid = item;
  262. }
  263. });
  264. if (kid.type == "1") {
  265. this.setState({
  266. displayFees: "block",
  267. patentTransfer: kid.patentTransfer,
  268. });
  269. } else {
  270. this.setState({
  271. displayFees: "none",
  272. });
  273. }
  274. console.log(value.indexOf("贯标"),'value.indexOf("贯标")')
  275. //0通用 1专利 2软著 3审计 4双软 5高新 6商标
  276. this.setState({
  277. commodityName: value,
  278. gid: kid.id,
  279. addProjectType: kid.type,
  280. isIso: value.indexOf("贯标") !== -1,// 是否为贯标项目
  281. });
  282. }
  283. getpatentTypeList() {
  284. $.ajax({
  285. method: "get",
  286. dataType: "json",
  287. crossDomain: false,
  288. url: globalConfig.context + '/api/admin/orderProject/getPatentType',
  289. success: function (data) {
  290. if (data.error.length === 0) {
  291. this.setState({
  292. patentTypeList:data.data
  293. })
  294. }else{
  295. message.warning(data.error[0].message);
  296. };
  297. }.bind(this)
  298. });
  299. }
  300. render() {
  301. let options = this.state.states
  302. ? this.state.customerArr.map((group) => (
  303. <Select.Option key={group.id} value={group.name}>
  304. {group.name}
  305. </Select.Option>
  306. ))
  307. : this.state.customerArr.map((group, index) => (
  308. <Select.Option key={index} value={group.bname}>
  309. {group.bname}
  310. </Select.Option>
  311. ));
  312. const {readOnly} = this.props;
  313. return (
  314. <Modal
  315. maskClosable={false}
  316. visible={this.props.visible}
  317. onOk={this.props.onCancel}
  318. onCancel={this.props.onCancel}
  319. width="800px"
  320. title={readOnly ? "项目任务详情" : "添加项目任务" }
  321. footer=""
  322. className="admin-desc-content"
  323. >
  324. <Form
  325. layout="horizontal"
  326. >
  327. <Spin spinning={this.state.loading}>
  328. <div className="clearfix">
  329. <FormItem
  330. className="half-item"
  331. {...formItemLayout}
  332. label="服务名称"
  333. >
  334. {this.state.jid ? this.state.commodityName : <AutoComplete
  335. className="certain-category-search"
  336. dropdownClassName="certain-category-search-dropdown"
  337. dropdownMatchSelectWidth={false}
  338. style={{ width: "200px" }}
  339. dataSource={options}
  340. placeholder="输入服务名称"
  341. value={this.state.commodityName}
  342. onChange={this.httpChange}
  343. filterOption={true}
  344. onSelect={this.selectAuto}
  345. >
  346. <Input />
  347. </AutoComplete>}
  348. <span className="mandatory">*</span>
  349. </FormItem>
  350. <FormItem
  351. className="half-item"
  352. {...formItemLayout}
  353. label="服务数量"
  354. >
  355. {readOnly ? this.state.commodityQuantity : <Input
  356. placeholder="请输入服务数量"
  357. value={this.state.commodityQuantity}
  358. style={{ width: "200px" }}
  359. onChange={(e) => {
  360. this.setState({ commodityQuantity: e.target.value });
  361. }}
  362. ref="commodityQuantity"
  363. />}
  364. <span className="mandatory">*</span>
  365. </FormItem>
  366. {!this.state.patentTransfer && <FormItem
  367. className="half-item"
  368. labelCol={{ span: 4 }}
  369. wrapperCol={{ span: 14 }}
  370. label="专利类型:"
  371. style={{
  372. display: this.state.displayFees,
  373. marginLeft: "63px",
  374. }}
  375. >
  376. {readOnly ? this.state.patentTypeName : <Select
  377. placeholder="请选择专利类型"
  378. style={{ width: "200px" }}
  379. value={this.state.patentType}
  380. onChange={(e) => {
  381. this.setState({ patentType: e });
  382. if(e !== 0 && e !== 2){
  383. this.setState({
  384. costReduction: ''
  385. })
  386. }
  387. }}
  388. >
  389. {this.state.patentTypeList.map(function (v,k) {
  390. return (
  391. <Select.Option key={k} value={v.id}>{v.name}</Select.Option>
  392. );
  393. })}
  394. </Select>}
  395. <span style={{ color: "red", marginLeft: "8px" }}>
  396. *
  397. </span>
  398. </FormItem>}
  399. <FormItem
  400. className="half-item"
  401. labelCol={{ span: 3 }}
  402. wrapperCol={{ span: 14 }}
  403. label="官费:"
  404. style={{
  405. display: this.state.displayFees,
  406. marginLeft: "63px",
  407. }}
  408. >
  409. {readOnly ? (this.state.officialCost === 1 ? '含官费': this.state.officialCost === 0 ? '不含官费' : '') : <Radio.Group
  410. value={this.state.officialCost}
  411. onChange={(e) => {
  412. this.setState({ officialCost: e.target.value });
  413. if(e.target.value === 0){
  414. this.setState({
  415. costReduction: ''
  416. })
  417. }
  418. }}
  419. >
  420. <Radio value={1}>含官费</Radio>
  421. <Radio value={0}>不含官费</Radio>
  422. </Radio.Group>}
  423. <span style={{ color: "red", marginLeft: "8px" }}>
  424. *
  425. </span>
  426. </FormItem>
  427. <FormItem
  428. className="half-item"
  429. labelCol={{ span: 3 }}
  430. wrapperCol={{ span: 14 }}
  431. label="费减:"
  432. style={{
  433. display: this.state.displayFees,
  434. marginLeft: "63px",
  435. }}
  436. >
  437. {/*不含官费或者专利类型不为复审或者申请时置灰*/}
  438. {readOnly ? (this.state.costReduction === 1 ? '有费减': this.state.costReduction === 0 ? '无费减' : '') : <Radio.Group
  439. disabled={this.state.officialCost === 0 || (this.state.patentType !== 0 && this.state.patentType !== 2)}
  440. value={this.state.costReduction}
  441. onChange={(e) => {
  442. this.setState({ costReduction: e.target.value });
  443. }}
  444. >
  445. <Radio value={1}>有费减</Radio>
  446. <Radio value={0}>无费减</Radio>
  447. </Radio.Group>}
  448. <span style={{ color: "red", marginLeft: "8px" }}>
  449. *
  450. </span>
  451. </FormItem>
  452. <FormItem
  453. className="half-item"
  454. {...formItemLayout}
  455. label="实签价格(万元)"
  456. >
  457. {readOnly ? this.state.commodityPrice : <Input
  458. type='number'
  459. placeholder="请输入实签价格"
  460. value={this.state.commodityPrice}
  461. style={{ width: "200px" }}
  462. onChange={(e) => {
  463. this.setState({ commodityPrice: e.target.value });
  464. }}
  465. ref="commodityPrice"
  466. />}
  467. <span className="mandatory">*</span>
  468. </FormItem>
  469. <FormItem
  470. className="half-item"
  471. {...formItemLayout}
  472. label="主要业务"
  473. >
  474. {readOnly ? getboutique(this.state.main) : <Select
  475. placeholder="选择是否为主要业务"
  476. style={{ width: "200px" }}
  477. value={this.state.main}
  478. onChange={(e) => {
  479. this.setState({ main: e });
  480. }}
  481. >
  482. {boutique.map(function (item) {
  483. return (
  484. <Select.Option key={item.value}>
  485. {item.key}
  486. </Select.Option>
  487. );
  488. })}
  489. </Select>}
  490. <span className="mandatory">*</span>
  491. </FormItem>
  492. <div className="clearfix">
  493. <FormItem
  494. labelCol={{ span: 4 }}
  495. wrapperCol={{ span: 16 }}
  496. label="服务说明"
  497. >
  498. {readOnly ? this.state.taskComment : <Input
  499. type="textarea"
  500. placeholder="请输入服务说明"
  501. value={this.state.taskComment}
  502. onChange={(e) => {
  503. this.setState({ taskComment: e.target.value });
  504. }}
  505. />}
  506. </FormItem>
  507. </div>
  508. {/*0通用 1专利 2软著 3审计 4双软 5高新 6商标*/}
  509. {this.state.addProjectType === 5 ?
  510. <div className="clearfix">
  511. <FormItem
  512. className="half-item"
  513. {...formItemLayout}
  514. label="企业要求申报批次"
  515. >
  516. {readOnly ? (
  517. this.state.declarationBatch === 1 ? '第一批' :
  518. this.state.declarationBatch === 2 ? '第二批' :
  519. this.state.declarationBatch === 3 ? '第三批' :
  520. this.state.declarationBatch === 4 ? '第四批' : '未知'
  521. ) : <Select
  522. placeholder="请选择企业要求申报批次"
  523. style={{ width: "200px" }}
  524. value={this.state.declarationBatch}
  525. onChange={(e) => {
  526. this.setState({ declarationBatch: e });
  527. }}
  528. >
  529. <Select.Option value={1}>
  530. 第一批
  531. </Select.Option>
  532. <Select.Option value={2}>
  533. 第二批
  534. </Select.Option>
  535. <Select.Option value={3}>
  536. 第三批
  537. </Select.Option>
  538. <Select.Option value={4}>
  539. 第四批
  540. </Select.Option>
  541. </Select>}
  542. <span className="mandatory">*</span>
  543. </FormItem>
  544. </div>: null
  545. }
  546. {
  547. this.props.isIso || this.state.isIso?<div className="clearfix">
  548. <FormItem
  549. className="half-item"
  550. {...formItemLayout}
  551. label="是否包含认证费用"
  552. >
  553. {readOnly ? (
  554. this.state.ifCertificationFee === 1 ? '包含' :
  555. this.state.ifCertificationFee === 0 ? '不包含' :'未知'
  556. ) : <Select
  557. placeholder="请选择是否包含认证费用"
  558. style={{ width: "200px" }}
  559. value={this.state.ifCertificationFee}
  560. onChange={(e) => {
  561. this.setState({ ifCertificationFee: e });
  562. }}
  563. >
  564. <Select.Option value={0}>
  565. </Select.Option>
  566. <Select.Option value={1}>
  567. </Select.Option>
  568. </Select>}
  569. <span className="mandatory">*</span>
  570. </FormItem>
  571. </div>: null
  572. }
  573. {readOnly ? null : <FormItem
  574. wrapperCol={{ span: 12, offset: 4 }}
  575. className="half-middle"
  576. >
  577. <Button
  578. className="submitSave"
  579. type="primary"
  580. onClick={()=>{
  581. if(this.state.jid){
  582. this.onChange();
  583. }else{
  584. this.onSubmit();
  585. }
  586. }}
  587. >
  588. 保存
  589. </Button>
  590. <Button
  591. className="submitSave"
  592. type="ghost"
  593. onClick={this.props.onCancel}
  594. >
  595. 取消
  596. </Button>
  597. </FormItem>}
  598. </div>
  599. </Spin>
  600. </Form>
  601. </Modal>
  602. )
  603. }
  604. }
  605. export default ProjectOperation;