businessLibrary.jsx 19 KB

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