businessLibrary.jsx 18 KB

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