index.jsx 28 KB

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