businessLibrary.jsx 19 KB

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