businessLibrary.jsx 18 KB

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