businessLibrary.jsx 19 KB

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