businessLibrary.jsx 20 KB

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