index.jsx 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. //0通用 1专利 2软著 3审计 4双软 5高新 6商标
  273. this.setState({
  274. commodityName: value,
  275. gid: kid.id,
  276. addProjectType: kid.type,
  277. isIso: value.indexOf("贯标") !== -1,// 是否为贯标项目
  278. });
  279. }
  280. getpatentTypeList() {
  281. $.ajax({
  282. method: "get",
  283. dataType: "json",
  284. crossDomain: false,
  285. url: globalConfig.context + '/api/admin/orderProject/getPatentType',
  286. success: function (data) {
  287. if (data.error.length === 0) {
  288. this.setState({
  289. patentTypeList:data.data
  290. })
  291. }else{
  292. message.warning(data.error[0].message);
  293. };
  294. }.bind(this)
  295. });
  296. }
  297. render() {
  298. let options = this.state.states
  299. ? this.state.customerArr.map((group) => (
  300. <Select.Option key={group.id} value={group.name}>
  301. {group.name}
  302. </Select.Option>
  303. ))
  304. : this.state.customerArr.map((group, index) => (
  305. <Select.Option key={index} value={group.bname}>
  306. {group.bname}
  307. </Select.Option>
  308. ));
  309. const {readOnly} = this.props;
  310. return (
  311. <Modal
  312. maskClosable={false}
  313. visible={this.props.visible}
  314. onOk={this.props.onCancel}
  315. onCancel={this.props.onCancel}
  316. width="800px"
  317. title={readOnly ? "项目任务详情" : "添加项目任务" }
  318. footer=""
  319. className="admin-desc-content"
  320. >
  321. <Form
  322. layout="horizontal"
  323. >
  324. <Spin spinning={this.state.loading}>
  325. <div className="clearfix">
  326. <FormItem
  327. className="half-item"
  328. {...formItemLayout}
  329. label="服务名称"
  330. >
  331. {this.state.jid ? this.state.commodityName : <AutoComplete
  332. className="certain-category-search"
  333. dropdownClassName="certain-category-search-dropdown"
  334. dropdownMatchSelectWidth={false}
  335. dropdownStyle={{ width: 200 }}
  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. placeholder="请输入实签价格"
  457. value={this.state.commodityPrice}
  458. style={{ width: "200px" }}
  459. onChange={(e) => {
  460. this.setState({ commodityPrice: e.target.value });
  461. }}
  462. ref="commodityPrice"
  463. />}
  464. <span className="mandatory">*</span>
  465. </FormItem>
  466. <FormItem
  467. className="half-item"
  468. {...formItemLayout}
  469. label="主要业务"
  470. >
  471. {readOnly ? getboutique(this.state.main) : <Select
  472. placeholder="选择是否为主要业务"
  473. style={{ width: "200px" }}
  474. value={this.state.main}
  475. onChange={(e) => {
  476. this.setState({ main: e });
  477. }}
  478. >
  479. {boutique.map(function (item) {
  480. return (
  481. <Select.Option key={item.value}>
  482. {item.key}
  483. </Select.Option>
  484. );
  485. })}
  486. </Select>}
  487. <span className="mandatory">*</span>
  488. </FormItem>
  489. <div className="clearfix">
  490. <FormItem
  491. labelCol={{ span: 4 }}
  492. wrapperCol={{ span: 16 }}
  493. label="服务说明"
  494. >
  495. {readOnly ? this.state.taskComment : <Input
  496. type="textarea"
  497. placeholder="请输入服务说明"
  498. value={this.state.taskComment}
  499. onChange={(e) => {
  500. this.setState({ taskComment: e.target.value });
  501. }}
  502. />}
  503. </FormItem>
  504. </div>
  505. {/*0通用 1专利 2软著 3审计 4双软 5高新 6商标*/}
  506. {this.state.addProjectType === 5 ?
  507. <div className="clearfix">
  508. <FormItem
  509. className="half-item"
  510. {...formItemLayout}
  511. label="企业要求申报批次"
  512. >
  513. {readOnly ? (
  514. this.state.declarationBatch === 1 ? '第一批' :
  515. this.state.declarationBatch === 2 ? '第二批' :
  516. this.state.declarationBatch === 3 ? '第三批' :
  517. this.state.declarationBatch === 4 ? '第四批' : '未知'
  518. ) : <Select
  519. placeholder="请选择企业要求申报批次"
  520. style={{ width: "200px" }}
  521. value={this.state.declarationBatch}
  522. onChange={(e) => {
  523. this.setState({ declarationBatch: e });
  524. }}
  525. >
  526. <Select.Option value={1}>
  527. 第一批
  528. </Select.Option>
  529. <Select.Option value={2}>
  530. 第二批
  531. </Select.Option>
  532. <Select.Option value={3}>
  533. 第三批
  534. </Select.Option>
  535. <Select.Option value={4}>
  536. 第四批
  537. </Select.Option>
  538. </Select>}
  539. <span className="mandatory">*</span>
  540. </FormItem>
  541. </div>: null
  542. }
  543. {
  544. this.props.isIso?<div className="clearfix">
  545. <FormItem
  546. className="half-item"
  547. {...formItemLayout}
  548. label="是否包含认证费用"
  549. >
  550. {readOnly ? (
  551. this.state.ifCertificationFee === 1 ? '包含' :
  552. this.state.ifCertificationFee === 0 ? '不包含' :'未知'
  553. ) : <Select
  554. placeholder="请选择是否包含认证费用"
  555. style={{ width: "200px" }}
  556. value={this.state.ifCertificationFee}
  557. onChange={(e) => {
  558. this.setState({ ifCertificationFee: e });
  559. }}
  560. >
  561. <Select.Option value={'0'}>
  562. </Select.Option>
  563. <Select.Option value={'1'}>
  564. </Select.Option>
  565. </Select>}
  566. <span className="mandatory">*</span>
  567. </FormItem>
  568. </div>: null
  569. }
  570. {readOnly ? null : <FormItem
  571. wrapperCol={{ span: 12, offset: 4 }}
  572. className="half-middle"
  573. >
  574. <Button
  575. className="submitSave"
  576. type="primary"
  577. onClick={()=>{
  578. if(this.state.jid){
  579. this.onChange();
  580. }else{
  581. this.onSubmit();
  582. }
  583. }}
  584. >
  585. 保存
  586. </Button>
  587. <Button
  588. className="submitSave"
  589. type="ghost"
  590. onClick={this.props.onCancel}
  591. >
  592. 取消
  593. </Button>
  594. </FormItem>}
  595. </div>
  596. </Spin>
  597. </Form>
  598. </Modal>
  599. )
  600. }
  601. }
  602. export default ProjectOperation;