businessProject.jsx 20 KB

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