businessProject.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. import React from 'react';
  2. import $ from 'jquery/src/ajax';
  3. import { citySelect } from '@/NewDicProvinceListAll';
  4. import {
  5. Form,
  6. Icon,
  7. Button,
  8. Input,
  9. Spin,
  10. Table,
  11. message,
  12. DatePicker,
  13. Modal,
  14. Radio,
  15. Cascader,
  16. } from 'antd';
  17. import { getGameState, getprovince, getReleaseStateList } from '@/tools.js';
  18. import TechDemandDesc from '@/account/business/businessDesc';
  19. //主体
  20. const BusinessProject = Form.create()(
  21. React.createClass({
  22. loadData(pageNo) {
  23. this.state.data = [];
  24. this.setState({
  25. loading: true,
  26. page: pageNo
  27. });
  28. $.ajax({
  29. method: 'get',
  30. dataType: 'json',
  31. crossDomain: false,
  32. url: globalConfig.context + '/portal/service/jtProject/list',
  33. data: {
  34. pageNo: pageNo || 1,
  35. pageSize: this.state.pagination.pageSize,
  36. topId: this.state.typeSearch? this.state.typeSearch[0]:'',
  37. secondId:this.state.typeSearch?this.state.typeSearch[1]:'',
  38. name: this.state.nameSearch,
  39. privateProject: 0
  40. },
  41. success: function(data) {
  42. let theArr = [];
  43. if (!data.data || !data.data.list) {
  44. if (data.error && data.error.length) {
  45. message.warning(data.error[0].message);
  46. }
  47. } else {
  48. for (let i = 0; i < data.data.list.length; i++) {
  49. let thisdata = data.data.list[i],
  50. ProvinceCityArr = [],
  51. cname = '',
  52. superName = '',
  53. ProvinceS = thisdata.province, //getprovince
  54. citys = thisdata.city,
  55. Areas = thisdata.area;
  56. ProvinceCityArr.push(ProvinceS, citys, Areas);
  57. (this.state.categoryList).map((item,index) => {
  58. if((item.children).length){
  59. (item.children).map((atem,indexT)=>{
  60. if (thisdata.categoryId == atem.value) {
  61. console.log()
  62. cname = item.label;
  63. superName = atem.label;
  64. return;
  65. }
  66. })
  67. }
  68. });
  69. theArr.push({
  70. key: i,
  71. id: thisdata.id, //业务名称
  72. name: thisdata.name, //业务名称
  73. categoryId: thisdata.categoryId, //业务品类
  74. number: thisdata.number,
  75. price: thisdata.price, //市场价
  76. superName: superName,
  77. cname: cname,
  78. auditStatus: thisdata.auditStatus,
  79. city: thisdata.city,
  80. activityPrice: thisdata.activityPrice ? thisdata.activityPrice : '', //最低折扣
  81. memberPrice: thisdata.memberPrice ? thisdata.memberPrice : '', //会员价
  82. offset: thisdata.offset ? thisdata.offset : '',
  83. activityPrice: thisdata.activityPrice ? thisdata.activityPrice : '', //活动价
  84. activityFlag: thisdata.activityFlag, //活动生效标识
  85. status: thisdata.status, //项目状态
  86. province: thisdata.province,
  87. introduce: thisdata.introduce,
  88. createTime: thisdata.createTime ? new Date(thisdata.createTime).toLocaleString() : '',
  89. value: thisdata.value,
  90. applyConditions: thisdata.applyConditions,
  91. releaseDate:thisdata.releaseDate?(new Date(thisdata.releaseDate)).toLocaleString():''
  92. });
  93. }
  94. this.state.pagination.current = data.data.pageNo;
  95. this.state.pagination.total = data.data.totalCount;
  96. }
  97. this.setState({
  98. dataSource: theArr,
  99. pagination: this.state.pagination
  100. });
  101. }.bind(this)
  102. }).always(
  103. function() {
  104. this.setState({
  105. loading: false
  106. });
  107. }.bind(this)
  108. );
  109. },
  110. getInitialState() {
  111. return {
  112. tagList:[],
  113. searchMore: true,
  114. selectedRowKeys: [],
  115. selectedRows: [],
  116. loading: false,
  117. typeSearch:[],
  118. orgCodeUrl: [],
  119. companyLogoUrl: [],
  120. pagination: {
  121. defaultCurrent: 1,
  122. defaultPageSize: 10,
  123. showQuickJumper: true,
  124. pageSize: 10,
  125. onChange: function(page) {
  126. this.loadData(page);
  127. this.setState({
  128. selectedRowKeys: []
  129. });
  130. }.bind(this),
  131. showTotal: function(total) {
  132. return '共' + total + '条数据';
  133. }
  134. },
  135. columns: [
  136. {
  137. title: '项目名称',
  138. dataIndex: 'name',
  139. key: 'bname'
  140. },
  141. {
  142. title: '品类名称',
  143. dataIndex: 'cname',
  144. key: 'cname'
  145. },
  146. {
  147. title: '上级品类',
  148. dataIndex: 'superName',
  149. key: 'superName'
  150. },
  151. {
  152. title: '业务地区',
  153. dataIndex: 'area',
  154. key: 'area',
  155. render: (text, rocard) => {
  156. return (
  157. <div>
  158. {rocard.province != 0 ? (
  159. <span>{getprovince(rocard.province) + '-' + getprovince(rocard.city)}</span>
  160. ) : (
  161. '全国'
  162. )}
  163. </div>
  164. );
  165. }
  166. },
  167. {
  168. title: '市场价(万元)',
  169. dataIndex: 'price',
  170. key: 'price'
  171. },
  172. {
  173. title: '最低折扣',
  174. dataIndex: 'offset',
  175. key: 'offset'
  176. },
  177. {
  178. title: '会员价(万元)',
  179. dataIndex: 'memberPrice',
  180. key: 'memberPrice'
  181. },
  182. {
  183. title: '活动价(万元)',
  184. dataIndex: 'activityPrice',
  185. key: 'activityPrice'
  186. },
  187. {
  188. title: '发布状态',
  189. dataIndex: 'auditStatus',
  190. key: 'auditStatus',
  191. render: (text) => {
  192. return getReleaseStateList(text);
  193. }
  194. },
  195. {
  196. title: '发布时间',
  197. dataIndex: 'releaseDate',
  198. key: 'releaseDate'
  199. },
  200. {
  201. title: '活动生效标识',
  202. dataIndex: 'activityFlag',
  203. key: 'activityFlag',
  204. render: (text) => {
  205. return getGameState(text);
  206. }
  207. },
  208. {
  209. title: '审核',
  210. dataIndex: 'caozuo',
  211. key: 'caozuo',
  212. render: (text, recard) => {
  213. return (
  214. <div className="btnRight">
  215. {recard.auditStatus != '1' &&
  216. recard.auditStatus != '2' && (
  217. <Button
  218. type="primary"
  219. style={{ background: '#3fcf9e', border: 'none', color: '#fff' }}
  220. onClick={(e) => {
  221. e.stopPropagation(), this.submission(recard);
  222. }}
  223. >
  224. 提交审核
  225. </Button>
  226. )}
  227. {recard.auditStatus!='1'&&recard.auditStatus=='2'&&<Button type="success" onClick={(e)=>{ e.stopPropagation(),this.updateFun(recard)}}>刷新发布</Button>}
  228. {recard.auditStatus!='1'&&recard.auditStatus=='2'&&<Button type="danger" onClick={(e)=>{e.stopPropagation(),this.revokeFun(recard)}}>撤销发布</Button>}
  229. </div>
  230. );
  231. }
  232. }
  233. ],
  234. dataSource: []
  235. };
  236. },
  237. //提交审核
  238. submission(record) {
  239. this.setState({
  240. showDesc: false,
  241. loading: true
  242. });
  243. $.ajax({
  244. method: 'get',
  245. dataType: 'json',
  246. crossDomain: false,
  247. url: globalConfig.context + '/api/user/jtBusiness/project/publish',
  248. data: {
  249. id: record.id,
  250. auditStatus:1
  251. }
  252. }).done(
  253. function(data) {
  254. if (!data.error.length) {
  255. message.success('提交成功.');
  256. this.setState({
  257. loading: false
  258. });
  259. this.loadData(this.state.page);
  260. } else {
  261. message.warning(data.error[0].message);
  262. }
  263. }.bind(this)
  264. );
  265. },
  266. //业务品类列表获取
  267. topLevel() {
  268. $.ajax({
  269. method: 'get',
  270. dataType: 'json',
  271. crossDomain: false,
  272. url: globalConfig.context + '/portal/service/jtBusiness/getCategoryList',
  273. data: {
  274. },
  275. success: function(data) {
  276. let theArr = [],thisdata=data.data;
  277. if (!data.data) {
  278. if (data.error && data.error.length) {
  279. message.warning(data.error[0].message);
  280. }
  281. } else {
  282. thisdata.map((item,index) => {
  283. theArr.push({
  284. 'value':item.topLevelId,
  285. 'label':item.topLevel,
  286. 'children':[]
  287. })
  288. if (item.children) {
  289. item.children.map(atem => {
  290. (theArr[index].children).push({
  291. 'value':atem.id,
  292. 'label':atem.name
  293. })
  294. })
  295. }
  296. })
  297. }
  298. this.setState({
  299. categoryList: theArr,
  300. });
  301. this.loadData();
  302. }.bind(this)
  303. }).always(
  304. function() {
  305. this.setState({
  306. loading: false
  307. });
  308. }.bind(this)
  309. );
  310. },
  311. //刷新发布
  312. updateFun(recard){
  313. this.setState({
  314. loading:true
  315. })
  316. $.ajax({
  317. method: "get",
  318. dataType: "json",
  319. crossDomain: false,
  320. url: globalConfig.context +'/api/user/jtBusiness/project/refreshPublish',
  321. data: {
  322. id: recard.id,
  323. auditStatus:recard.auditStatus
  324. }
  325. }).done(function (data) {
  326. if (!data.error.length) {
  327. message.success('刷新成功!');
  328. this.setState({
  329. loading: false,
  330. });
  331. } else {
  332. message.warning(data.error[0].message);
  333. };
  334. this.loadData(this.state.page);
  335. }.bind(this));
  336. },
  337. //撤销发布
  338. revokeFun(recard){
  339. this.setState({
  340. loading:true
  341. })
  342. $.ajax({
  343. method: "get",
  344. dataType: "json",
  345. crossDomain: false,
  346. url: globalConfig.context + '/api/user/jtBusiness/project/offShelf',
  347. data: {
  348. id: recard.id,
  349. auditStatus:recard.auditStatus
  350. }
  351. }).done(function (data) {
  352. if (!data.error.length) {
  353. message.success('撤销成功!');
  354. this.setState({
  355. loading: false,
  356. });
  357. this.loadData(this.state.page);
  358. } else {
  359. message.warning(data.error[0].message);
  360. };
  361. }.bind(this));
  362. },
  363. loadTag(){
  364. $.ajax({
  365. method: 'get',
  366. dataType: 'json',
  367. crossDomain: false,
  368. url: globalConfig.context + '/api/user/jtBusiness/tag/list',
  369. data: {
  370. pageNo: 1,
  371. pageSize:9999,
  372. },
  373. success:function(data){
  374. if(!data.data&&data.data.list.length){
  375. if(data.error&&data.error.length){
  376. message.error(data.error[0].message)
  377. return;
  378. }
  379. }else{
  380. let thisdata = data.data.list,theDate=[];
  381. thisdata.map((item,index)=>{
  382. theDate.push({
  383. key:index,
  384. id:item.id,
  385. name:item.name
  386. })
  387. })
  388. this.setState({
  389. tagList:theDate
  390. })
  391. }
  392. }.bind(this)
  393. })
  394. },
  395. componentWillMount() {
  396. this.loadTag();
  397. this.topLevel();
  398. },
  399. //项目列表整行点击
  400. tableRowClick(record, index) {
  401. this.state.RowData = record;
  402. this.setState({
  403. showDesc: true
  404. });
  405. },
  406. //新增一个项目,保存
  407. addhandleSubmit(e) {
  408. e.preventDefault();
  409. if (!this.state.categoryName) {
  410. message.warning('请输入项目名称');
  411. return false;
  412. };
  413. if (this.state.categoryName.length>16) {
  414. message.warning('项目名称在16个字以内');
  415. return false;
  416. };
  417. if (!this.state.addCid||!this.state.addCid[1]) {
  418. message.warning('请选择项目二级品类');
  419. return false;
  420. }
  421. this.setState({
  422. loading: true
  423. });
  424. //上级组织字典
  425. $.ajax({
  426. method: 'post',
  427. dataType: 'json',
  428. crossDomain: false,
  429. url: globalConfig.context + '/api/user/jtBusiness/project/apply',
  430. data: {
  431. name: this.state.categoryName, //项目名称
  432. categoryId: this.state.addCid[1],
  433. isHot: this.state.isHot,
  434. province: this.state.ProvinceCity ? this.state.ProvinceCity[0] : '', //是否全国
  435. city: this.state.ProvinceCity ? this.state.ProvinceCity[1] : ''
  436. }
  437. }).done(
  438. function(data) {
  439. this.setState({
  440. loading: false
  441. });
  442. if (!data.error.length) {
  443. message.success('新增项目成功!');
  444. this.handleCancel();
  445. this.loadData(this.state.page);
  446. } else {
  447. message.warning(data.error[0].message);
  448. }
  449. }.bind(this)
  450. );
  451. },
  452. //项目整行删除
  453. delectRow() {
  454. let deletedIds ='';
  455. let rowItem = this.state.selectedRowKeys[0];
  456. let data = this.state.dataSource ||[];
  457. if (data.length) {
  458. deletedIds=(data[rowItem].id);
  459. }
  460. console.log(deletedIds);
  461. this.setState({
  462. selectedRowKeys: [],
  463. loading: deletedIds.length > 0
  464. });
  465. $.ajax({
  466. method: 'get',
  467. dataType: 'json',
  468. crossDomain: false,
  469. url: globalConfig.context + '/api/user/jtBusiness/project/delete',
  470. data: {
  471. id: deletedIds
  472. }
  473. }).done(
  474. function(data) {
  475. if (!data.error.length) {
  476. message.success('删除成功!');
  477. this.setState({
  478. loading: false
  479. });
  480. } else {
  481. message.warning(data.error[0].message);
  482. }
  483. if(this.state.pagination.total%10==1){
  484. this.loadData((this.state.page)-1);
  485. }else{
  486. this.loadData(this.state.page);
  487. }
  488. }.bind(this)
  489. );
  490. },
  491. addClick() {
  492. this.state.RowData = {};
  493. this.setState({
  494. visible: true,
  495. isHot: 0
  496. });
  497. this.addReset();
  498. },
  499. closeDesc(e, s) {
  500. this.state.showDesc = e;
  501. if (s) {
  502. this.loadData(this.state.page);
  503. };
  504. },
  505. handleCancel() {
  506. this.setState({ visible: false });
  507. },
  508. search() {
  509. this.loadData();
  510. },
  511. //搜索部分的清零
  512. reset() {
  513. this.state.nameSearch = ''; //项目名称清零
  514. this.state.cid = undefined; //品类名称清零
  515. this.state.typeSearch=undefined;
  516. this.state.ressSearch = undefined; //省市区清零
  517. this.state.activityFlag = undefined; //活动生效清零
  518. this.state.status = undefined; //项目状态清零
  519. this.loadData();
  520. },
  521. //新增部分的清零
  522. addReset() {
  523. this.state.categoryName = ''; //项目名称清零
  524. this.state.ProvinceCity = undefined;
  525. this.state.addCid = undefined;
  526. this.state.boutique = '';
  527. },
  528. //更多搜索的显示与否
  529. searchSwitch() {
  530. this.setState({
  531. searchMore: !this.state.searchMore
  532. });
  533. },
  534. render() {
  535. const FormItem = Form.Item;
  536. const rowSelection = {
  537. selectedRowKeys: this.state.selectedRowKeys,
  538. onChange: (selectedRowKeys, selectedRows) => {
  539. this.setState({
  540. selectedRows: selectedRows.slice(-1),
  541. selectedRowKeys: selectedRowKeys.slice(-1)
  542. });
  543. }
  544. };
  545. const hasSelected = this.state.selectedRowKeys.length > 0;
  546. return (
  547. <div className="user-content">
  548. <div className="content-title">
  549. <span>项目业务列表</span>
  550. <div className="user-search">
  551. <Button
  552. type="primary"
  553. className="addButton"
  554. onClick={this.addClick}
  555. style={{ float: 'right', marginRight: '50px' }}
  556. >
  557. 新增项目<Icon type="plus" />
  558. </Button>
  559. <Input
  560. placeholder="业务项目名称"
  561. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  562. value={this.state.nameSearch}
  563. onChange={(e) => {
  564. this.setState({ nameSearch: e.target.value });
  565. }}
  566. />
  567. <Cascader placeholder='业务项目品类'
  568. options={this.state.categoryList}
  569. style={{width:200,marginRight:10}}
  570. value={this.state.typeSearch} onChange={(e)=>{this.setState({typeSearch:e})}}/>
  571. <Button type="primary" onClick={this.search} style={{ marginRight: '10px' }}>
  572. 搜索
  573. </Button>
  574. <Button onClick={this.reset} style={{ marginRight: '10px' }}>
  575. 重置
  576. </Button>
  577. <Button
  578. type="danger"
  579. onClick={this.delectRow}
  580. disabled={!hasSelected}
  581. >
  582. 删除<Icon type="minus" />
  583. </Button>
  584. </div>
  585. <div className="patent-table">
  586. <Spin spinning={this.state.loading}>
  587. <Table
  588. columns={this.state.columns}
  589. dataSource={this.state.dataSource}
  590. rowSelection={rowSelection}
  591. pagination={this.state.pagination}
  592. onRowClick={this.tableRowClick}
  593. current={this.state.aa}
  594. />
  595. </Spin>
  596. </div>
  597. <TechDemandDesc
  598. data={this.state.RowData}
  599. showDesc={this.state.showDesc}
  600. closeDesc={this.closeDesc}
  601. categoryList={this.state.categoryList}
  602. tagList={this.state.tagList}
  603. />
  604. <div className="patent-desc">
  605. <Modal
  606. maskClosable={false}
  607. visible={this.state.visible}
  608. onOk={this.checkPatentProcess}
  609. onCancel={this.handleCancel}
  610. width="400px"
  611. title="新增业务项目"
  612. footer=""
  613. className="admin-desc-content"
  614. >
  615. <Form layout="horizontal" onSubmit={this.addhandleSubmit} id="demand-form">
  616. <Spin spinning={this.state.loading}>
  617. <div className="clearfix">
  618. <FormItem labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} label="业务项目名称">
  619. <Input
  620. placeholder="业务项目名称"
  621. value={this.state.categoryName}
  622. style={{ width: '94%' }}
  623. onChange={(e) => {
  624. this.setState({ categoryName: e.target.value });
  625. }}
  626. required="required"
  627. />
  628. <span className="mandatory" style={{ color: 'red', marginLeft: '5px' }}>
  629. *
  630. </span>
  631. </FormItem>
  632. </div>
  633. <div className="clearfix">
  634. <FormItem labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} label="业务品类">
  635. <Cascader placeholder='业务项目品类'
  636. options={this.state.categoryList}
  637. value={this.state.addCid}
  638. style={{ width: '94%' }}
  639. onChange={(e)=>{this.setState({addCid:e})}}/>
  640. <span className="mandatory" style={{ color: 'red', marginLeft: '5px' }}>
  641. *
  642. </span>
  643. </FormItem>
  644. </div>
  645. <div className="clearfix">
  646. <FormItem labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} label="省-市">
  647. <Cascader
  648. options={citySelect()}
  649. value={this.state.ProvinceCity}
  650. placeholder="选择市"
  651. style={{ width: '94%' }}
  652. onChange={(e, pre) => {
  653. this.setState({ ProvinceCity: e });
  654. }}
  655. />
  656. <span style={{ color: 'red', marginLeft: '5px' }}>*</span>
  657. </FormItem>
  658. </div>
  659. <div className="clearfix" style={{"display":"none"}}>
  660. <FormItem labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} label="热点">
  661. <Radio.Group
  662. onChange={(e) => {
  663. this.setState({ isHot: e.target.value });
  664. }}
  665. value={this.state.isHot}
  666. >
  667. <Radio value={0}>否</Radio>
  668. <Radio value={1}>是</Radio>
  669. </Radio.Group>
  670. </FormItem>
  671. </div>
  672. <FormItem wrapperCol={{ span: 12, offset: 7 }}>
  673. <Button className="set-submit" type="primary" htmlType="submit">
  674. 保存
  675. </Button>
  676. <Button
  677. className="set-submit"
  678. type="ghost"
  679. onClick={this.handleCancel}
  680. style={{ marginLeft: '15px' }}
  681. >
  682. 取消
  683. </Button>
  684. </FormItem>
  685. </Spin>
  686. </Form>
  687. </Modal>
  688. </div>
  689. </div>
  690. </div>
  691. );
  692. }
  693. })
  694. );
  695. export default BusinessProject;