index.jsx 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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. let reg = /^([0]|[1-9][0-9]*)$/;
  79. if (
  80. !this.state.commodityQuantity ||
  81. !reg.test(this.state.commodityQuantity)
  82. ) {
  83. message.warning("请输入正确商品数量!");
  84. return false;
  85. }
  86. if (this.state.displayFees === 'block') {
  87. if (this.state.patentType === "" && !this.state.patentTransfer) {
  88. message.warning("请选择专利类型!");
  89. return false;
  90. }
  91. if (this.state.officialCost === '') {
  92. message.warning("请选择官费!");
  93. return false;
  94. }
  95. if (this.state.costReduction === "" && (this.state.patentType === 0 || this.state.patentType === 2) && this.state.officialCost === 1) {
  96. message.warning("请选择费减!");
  97. return false;
  98. }
  99. }
  100. if (isNaN(parseFloat(this.state.commodityPrice))) {
  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="900px"
  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. <div style={{ marginTop: "33px", color: "red", textAlign: "right", position: "relative", top: "-8", left: "0" }}>如会员项目,服务一年,请填写1,服务二年,请填写2,依次类推</div>
  367. {!this.state.patentTransfer && <FormItem
  368. className="half-item"
  369. labelCol={{ span: 4 }}
  370. wrapperCol={{ span: 14 }}
  371. label="专利类型:"
  372. style={{
  373. display: this.state.displayFees,
  374. marginLeft: "63px",
  375. }}
  376. >
  377. {readOnly ? this.state.patentTypeName : <Select
  378. placeholder="请选择专利类型"
  379. style={{ width: "200px" }}
  380. value={this.state.patentType}
  381. onChange={(e) => {
  382. this.setState({ patentType: e });
  383. if (e !== 0 && e !== 2) {
  384. this.setState({
  385. costReduction: ''
  386. })
  387. }
  388. }}
  389. >
  390. {this.state.patentTypeList.map(function (v, k) {
  391. return (
  392. <Select.Option key={k} value={v.id}>{v.name}</Select.Option>
  393. );
  394. })}
  395. </Select>}
  396. <span style={{ color: "red", marginLeft: "8px" }}>
  397. *
  398. </span>
  399. </FormItem>}
  400. <FormItem
  401. className="half-item"
  402. labelCol={{ span: 3 }}
  403. wrapperCol={{ span: 14 }}
  404. label="官费:"
  405. style={{
  406. display: this.state.displayFees,
  407. marginLeft: "63px",
  408. }}
  409. >
  410. {readOnly
  411. ? (this.state.officialCost === 1 ? '含官费' : this.state.officialCost === 0 ? '不含官费' : '')
  412. : <Radio.Group
  413. value={this.state.officialCost}
  414. onChange={(e) => {
  415. this.setState({ officialCost: e.target.value });
  416. if (e.target.value === 0) {
  417. this.setState({
  418. costReduction: ''
  419. })
  420. }
  421. }}
  422. >
  423. <Radio value={1}>含官费</Radio>
  424. <Radio value={0}>不含官费</Radio>
  425. </Radio.Group>}
  426. <span style={{ color: "red", marginLeft: "8px" }}>
  427. *
  428. </span>
  429. </FormItem>
  430. {
  431. readOnly ?
  432. <FormItem
  433. className="half-item"
  434. labelCol={{ span: 3 }}
  435. wrapperCol={{ span: 14 }}
  436. label="费减:"
  437. style={{
  438. display: this.state.displayFees,
  439. marginLeft: "63px",
  440. }}
  441. >
  442. {this.state.costReduction === 1 ? '有费减' : this.state.costReduction === 0 ? '无费减' : ''}
  443. <span style={{ color: "red", marginLeft: "8px" }}>
  444. *
  445. </span>
  446. </FormItem>
  447. :
  448. (this.state.patentType === 0 || this.state.patentType === 2) && this.state.officialCost === 1 &&
  449. <FormItem
  450. className="half-item"
  451. labelCol={{ span: 3 }}
  452. wrapperCol={{ span: 14 }}
  453. label="费减:"
  454. style={{
  455. display: this.state.displayFees,
  456. marginLeft: "63px",
  457. }}
  458. >
  459. {/*不含官费或者专利类型不为复审或者申请时置灰*/}
  460. <Radio.Group
  461. disabled={this.state.officialCost === 0 || (this.state.patentType !== 0 && this.state.patentType !== 2)}
  462. value={this.state.costReduction}
  463. onChange={(e) => {
  464. this.setState({ costReduction: e.target.value });
  465. }}
  466. >
  467. <Radio value={1}>有费减</Radio>
  468. <Radio value={0}>无费减</Radio>
  469. </Radio.Group>
  470. <span style={{ color: "red", marginLeft: "8px" }}>
  471. *
  472. </span>
  473. </FormItem>
  474. }
  475. <FormItem
  476. className="half-item"
  477. {...formItemLayout}
  478. label="实签价格(万元)"
  479. >
  480. {readOnly ? this.state.commodityPrice : <Input
  481. type='number'
  482. placeholder="请输入实签价格"
  483. value={this.state.commodityPrice}
  484. style={{ width: "200px" }}
  485. onChange={(e) => {
  486. this.setState({ commodityPrice: e.target.value });
  487. }}
  488. ref="commodityPrice"
  489. />}
  490. <span className="mandatory">*</span>
  491. </FormItem>
  492. <FormItem
  493. className="half-item"
  494. {...formItemLayout}
  495. label="主要业务"
  496. >
  497. {readOnly ? getboutique(this.state.main) : <Select
  498. placeholder="选择是否为主要业务"
  499. style={{ width: "200px" }}
  500. value={this.state.main}
  501. onChange={(e) => {
  502. this.setState({ main: e });
  503. }}
  504. >
  505. {boutique.map(function (item) {
  506. return (
  507. <Select.Option key={item.value}>
  508. {item.key}
  509. </Select.Option>
  510. );
  511. })}
  512. </Select>}
  513. <span className="mandatory">*</span>
  514. </FormItem>
  515. <div className="clearfix">
  516. <FormItem
  517. labelCol={{ span: 4 }}
  518. wrapperCol={{ span: 16 }}
  519. label="项目说明"
  520. >
  521. {readOnly ? this.state.taskComment : <Input
  522. type="textarea"
  523. placeholder="如会员项目请详细描写会员项目的服务年限、详细服务时间段段,如第一年从2021年1月至2021年12月31日止,第二年从。。。"
  524. value={this.state.taskComment}
  525. onChange={(e) => {
  526. this.setState({ taskComment: e.target.value });
  527. }}
  528. />}
  529. </FormItem>
  530. </div>
  531. {/*0通用 1专利 2软著 3审计 4双软 5高新 6商标*/}
  532. {this.state.addProjectType === 5 ?
  533. <div className="clearfix">
  534. <FormItem
  535. className="half-item"
  536. {...formItemLayout}
  537. label="企业要求申报批次"
  538. >
  539. {readOnly ? (
  540. this.state.declarationBatch === 1 ? '第一批' :
  541. this.state.declarationBatch === 2 ? '第二批' :
  542. this.state.declarationBatch === 3 ? '第三批' :
  543. this.state.declarationBatch === 4 ? '第四批' : '未知'
  544. ) : <Select
  545. placeholder="请选择企业要求申报批次"
  546. style={{ width: "200px" }}
  547. value={this.state.declarationBatch}
  548. onChange={(e) => {
  549. this.setState({ declarationBatch: e });
  550. }}
  551. >
  552. <Select.Option value={1}>
  553. 第一批
  554. </Select.Option>
  555. <Select.Option value={2}>
  556. 第二批
  557. </Select.Option>
  558. <Select.Option value={3}>
  559. 第三批
  560. </Select.Option>
  561. <Select.Option value={4}>
  562. 第四批
  563. </Select.Option>
  564. </Select>}
  565. <span className="mandatory">*</span>
  566. </FormItem>
  567. </div> : null
  568. }
  569. {
  570. this.props.isIso || this.state.isIso ? <div className="clearfix">
  571. <FormItem
  572. className="half-item"
  573. {...formItemLayout}
  574. label="是否包含认证费用"
  575. >
  576. {readOnly ? (
  577. this.state.ifCertificationFee === 1 ? '包含' :
  578. this.state.ifCertificationFee === 0 ? '不包含' : '未知'
  579. ) : <Select
  580. placeholder="请选择是否包含认证费用"
  581. style={{ width: "200px" }}
  582. value={this.state.ifCertificationFee}
  583. onChange={(e) => {
  584. this.setState({ ifCertificationFee: e });
  585. }}
  586. >
  587. <Select.Option value={0}>
  588. </Select.Option>
  589. <Select.Option value={1}>
  590. </Select.Option>
  591. </Select>}
  592. <span className="mandatory">*</span>
  593. </FormItem>
  594. </div> : null
  595. }
  596. {readOnly ? null : <FormItem
  597. wrapperCol={{ span: 12, offset: 4 }}
  598. className="half-middle"
  599. >
  600. <Button
  601. className="submitSave"
  602. type="primary"
  603. onClick={() => {
  604. if (this.state.jid) {
  605. this.onChange();
  606. } else {
  607. this.onSubmit();
  608. }
  609. }}
  610. >
  611. 保存
  612. </Button>
  613. <Button
  614. className="submitSave"
  615. type="ghost"
  616. onClick={this.props.onCancel}
  617. >
  618. 取消
  619. </Button>
  620. </FormItem>}
  621. </div>
  622. </Spin>
  623. </Form>
  624. </Modal>
  625. )
  626. }
  627. }
  628. export default ProjectOperation;