index.jsx 30 KB

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