index.jsx 32 KB

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