businessProject.jsx 20 KB

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