businessProject.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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. Radio,
  16. Upload,
  17. Popconfirm,
  18. Cascader,
  19. } from 'antd';
  20. import { getGameState, getprovince, getReleaseStateList } from '@/tools.js';
  21. import TechDemandDesc from '@/account/business/businessDesc';
  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/user/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[0]? this.state.typeSearch[0]:'',
  93. secondId:this.state.typeSearch[1]?this.state.typeSearch[1]:'',
  94. name: this.state.nameSearch,
  95. privateProject: 0
  96. },
  97. success: function(data) {
  98. let theArr = [];
  99. if (!data.data || !data.data.list) {
  100. if (data.error && data.error.length) {
  101. message.warning(data.error[0].message);
  102. }
  103. } else {
  104. for (let i = 0; i < data.data.list.length; i++) {
  105. let thisdata = data.data.list[i],
  106. ProvinceCityArr = [],
  107. cname = '',
  108. superName = '',
  109. ProvinceS = thisdata.province, //getprovince
  110. citys = thisdata.city,
  111. Areas = thisdata.area;
  112. ProvinceCityArr.push(ProvinceS, citys, Areas);
  113. (this.state.categoryList).map((item,index) => {
  114. if((item.children).length){
  115. (item.children).map((atem,indexT)=>{
  116. if (thisdata.categoryId == atem.value) {
  117. console.log()
  118. cname = item.label;
  119. superName = atem.label;
  120. return;
  121. }
  122. })
  123. }
  124. });
  125. theArr.push({
  126. key: i,
  127. id: thisdata.id, //业务名称
  128. name: thisdata.name, //业务名称
  129. categoryId: thisdata.categoryId, //业务品类
  130. number: thisdata.number,
  131. price: thisdata.price, //市场价
  132. superName: superName,
  133. cname: cname,
  134. auditStatus: thisdata.auditStatus,
  135. city: thisdata.city,
  136. activityPrice: thisdata.activityPrice ? thisdata.activityPrice : '', //最低折扣
  137. memberPrice: thisdata.memberPrice ? thisdata.memberPrice : '', //会员价
  138. offset: thisdata.offset ? thisdata.offset : '',
  139. activityPrice: thisdata.activityPrice ? thisdata.activityPrice : '', //活动价
  140. activityFlag: thisdata.activityFlag, //活动生效标识
  141. status: thisdata.status, //项目状态
  142. province: thisdata.province,
  143. introduce: thisdata.introduce,
  144. createTime: thisdata.createTime ? new Date(thisdata.createTime).toLocaleString() : '',
  145. value: thisdata.value,
  146. applyConditions: thisdata.applyConditions,
  147. releaseDate:thisdata.releaseDate?(new Date(thisdata.releaseDate)).toLocaleString():''
  148. });
  149. }
  150. this.state.pagination.current = data.data.pageNo;
  151. this.state.pagination.total = data.data.totalCount;
  152. }
  153. this.setState({
  154. dataSource: theArr,
  155. pagination: this.state.pagination
  156. });
  157. }.bind(this)
  158. }).always(
  159. function() {
  160. this.setState({
  161. loading: false
  162. });
  163. }.bind(this)
  164. );
  165. },
  166. getInitialState() {
  167. return {
  168. searchMore: true,
  169. selectedRowKeys: [],
  170. selectedRows: [],
  171. loading: false,
  172. typeSearch:[],
  173. orgCodeUrl: [],
  174. companyLogoUrl: [],
  175. pagination: {
  176. defaultCurrent: 1,
  177. defaultPageSize: 10,
  178. showQuickJumper: true,
  179. pageSize: 10,
  180. onChange: function(page) {
  181. this.loadData(page);
  182. this.setState({
  183. selectedRowKeys: []
  184. });
  185. }.bind(this),
  186. showTotal: function(total) {
  187. return '共' + total + '条数据';
  188. }
  189. },
  190. columns: [
  191. {
  192. title: '项目名称',
  193. dataIndex: 'name',
  194. key: 'bname'
  195. },
  196. {
  197. title: '品类名称',
  198. dataIndex: 'cname',
  199. key: 'cname'
  200. },
  201. {
  202. title: '上级品类',
  203. dataIndex: 'superName',
  204. key: 'superName'
  205. },
  206. {
  207. title: '业务地区',
  208. dataIndex: 'area',
  209. key: 'area',
  210. render: (text, rocard) => {
  211. return (
  212. <div>
  213. {rocard.province != 0 ? (
  214. <span>{getprovince(rocard.province) + '-' + getprovince(rocard.city)}</span>
  215. ) : (
  216. '全国'
  217. )}
  218. </div>
  219. );
  220. }
  221. },
  222. {
  223. title: '市场价',
  224. dataIndex: 'price',
  225. key: 'price'
  226. },
  227. {
  228. title: '最低折扣',
  229. dataIndex: 'offset',
  230. key: 'offset'
  231. },
  232. {
  233. title: '会员价',
  234. dataIndex: 'memberPrice',
  235. key: 'memberPrice'
  236. },
  237. {
  238. title: '活动价',
  239. dataIndex: 'activityPrice',
  240. key: 'activityPrice'
  241. },
  242. {
  243. title: '发布状态',
  244. dataIndex: 'auditStatus',
  245. key: 'auditStatus',
  246. render: (text) => {
  247. return getReleaseStateList(text);
  248. }
  249. },
  250. {
  251. title: '发布时间',
  252. dataIndex: 'releaseDate',
  253. key: 'releaseDate'
  254. },
  255. {
  256. title: '活动生效标识',
  257. dataIndex: 'activityFlag',
  258. key: 'activityFlag',
  259. render: (text) => {
  260. return getGameState(text);
  261. }
  262. },
  263. {
  264. title: '审核',
  265. dataIndex: 'caozuo',
  266. key: 'caozuo',
  267. render: (text, recard) => {
  268. return (
  269. <div className="btnRight">
  270. {recard.auditStatus != '1' &&
  271. recard.auditStatus != '2' && (
  272. <Button
  273. type="primary"
  274. style={{ background: '#3fcf9e', border: 'none', color: '#fff' }}
  275. onClick={(e) => {
  276. e.stopPropagation(), this.submission(recard);
  277. }}
  278. >
  279. 提交审核
  280. </Button>
  281. )}
  282. {recard.auditStatus!='1'&&recard.auditStatus=='2'&&<Button type="success" onClick={(e)=>{ e.stopPropagation(),this.updateFun(recard)}}>刷新发布</Button>}
  283. {recard.auditStatus!='1'&&recard.auditStatus=='2'&&<Button type="danger" onClick={(e)=>{e.stopPropagation(),this.revokeFun(recard)}}>撤销发布</Button>}
  284. </div>
  285. );
  286. }
  287. }
  288. ],
  289. dataSource: []
  290. };
  291. },
  292. //提交审核
  293. submission(record) {
  294. this.setState({
  295. showDesc: false,
  296. loading: true
  297. });
  298. $.ajax({
  299. method: 'get',
  300. dataType: 'json',
  301. crossDomain: false,
  302. url: globalConfig.context + '/api/user/jtBusiness/project/publish',
  303. data: {
  304. id: record.id,
  305. auditStatus:1
  306. }
  307. }).done(
  308. function(data) {
  309. if (!data.error.length) {
  310. message.success('提交成功.');
  311. this.setState({
  312. loading: false
  313. });
  314. this.loadData(this.state.page);
  315. } else {
  316. message.warning(data.error[0].message);
  317. }
  318. }.bind(this)
  319. );
  320. },
  321. //业务品类列表获取
  322. topLevel() {
  323. $.ajax({
  324. method: 'get',
  325. dataType: 'json',
  326. crossDomain: false,
  327. url: globalConfig.context + '/portal/service/jtBusiness/getCategoryList',
  328. data: {
  329. },
  330. success: function(data) {
  331. let theArr = [],thisdata=data.data;
  332. if (!data.data) {
  333. if (data.error && data.error.length) {
  334. message.warning(data.error[0].message);
  335. }
  336. } else {
  337. thisdata.map((item,index) => {
  338. theArr.push({
  339. 'value':item.topLevelId,
  340. 'label':item.topLevel,
  341. 'children':[]
  342. })
  343. if (item.children) {
  344. item.children.map(atem => {
  345. (theArr[index].children).push({
  346. 'value':atem.id,
  347. 'label':atem.name
  348. })
  349. })
  350. }
  351. })
  352. }
  353. this.setState({
  354. categoryList: theArr,
  355. });
  356. this.loadData();
  357. }.bind(this)
  358. }).always(
  359. function() {
  360. this.setState({
  361. loading: false
  362. });
  363. }.bind(this)
  364. );
  365. },
  366. //刷新发布
  367. updateFun(recard){
  368. this.setState({
  369. loading:true
  370. })
  371. $.ajax({
  372. method: "get",
  373. dataType: "json",
  374. crossDomain: false,
  375. url: globalConfig.context +'/api/user/jtBusiness/project/refreshPublish',
  376. data: {
  377. id: recard.id,
  378. auditStatus:recard.auditStatus
  379. }
  380. }).done(function (data) {
  381. if (!data.error.length) {
  382. message.success('刷新成功!');
  383. this.setState({
  384. loading: false,
  385. });
  386. } else {
  387. message.warning(data.error[0].message);
  388. };
  389. this.loadData(this.state.page);
  390. }.bind(this));
  391. },
  392. //撤销发布
  393. revokeFun(recard){
  394. this.setState({
  395. loading:true
  396. })
  397. $.ajax({
  398. method: "get",
  399. dataType: "json",
  400. crossDomain: false,
  401. url: globalConfig.context + '/api/user/jtBusiness/project/offShelf',
  402. data: {
  403. id: recard.id,
  404. auditStatus:recard.auditStatus
  405. }
  406. }).done(function (data) {
  407. if (!data.error.length) {
  408. message.success('撤销成功!');
  409. this.setState({
  410. loading: false,
  411. });
  412. this.loadData(this.state.page);
  413. } else {
  414. message.warning(data.error[0].message);
  415. };
  416. }.bind(this));
  417. },
  418. componentWillMount() {
  419. this.topLevel();
  420. },
  421. //项目列表整行点击
  422. tableRowClick(record, index) {
  423. this.state.RowData = record;
  424. this.setState({
  425. showDesc: true
  426. });
  427. },
  428. //新增一个项目,保存
  429. addhandleSubmit(e) {
  430. e.preventDefault();
  431. if (!this.state.categoryName) {
  432. message.warning('请输入项目名称');
  433. return false;
  434. };
  435. if (this.state.categoryName.length>16) {
  436. message.warning('项目名称在16个字以内');
  437. return false;
  438. };
  439. if (!this.state.addCid||!this.state.addCid[1]) {
  440. message.warning('请选择项目二级品类');
  441. return false;
  442. }
  443. this.setState({
  444. loading: true
  445. });
  446. //上级组织字典
  447. $.ajax({
  448. method: 'post',
  449. dataType: 'json',
  450. crossDomain: false,
  451. url: globalConfig.context + '/api/user/jtBusiness/project/apply',
  452. data: {
  453. name: this.state.categoryName, //项目名称
  454. categoryId: this.state.addCid[1],
  455. isHot: this.state.isHot,
  456. province: this.state.ProvinceCity ? this.state.ProvinceCity[0] : '', //是否全国
  457. city: this.state.ProvinceCity ? this.state.ProvinceCity[1] : ''
  458. }
  459. }).done(
  460. function(data) {
  461. this.setState({
  462. loading: false
  463. });
  464. if (!data.error.length) {
  465. message.success('新增项目成功!');
  466. this.handleCancel();
  467. this.loadData(this.state.page);
  468. } else {
  469. message.warning(data.error[0].message);
  470. }
  471. }.bind(this)
  472. );
  473. },
  474. //项目整行删除
  475. delectRow() {
  476. let deletedIds = '';
  477. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  478. let rowItem = this.state.selectedRows[idx];
  479. if (rowItem.id) {
  480. deletedIds = rowItem.id;
  481. }
  482. }
  483. this.setState({
  484. selectedRowKeys: [],
  485. loading: deletedIds.length > 0
  486. });
  487. $.ajax({
  488. method: 'get',
  489. dataType: 'json',
  490. crossDomain: false,
  491. url: globalConfig.context + '/api/user/jtBusiness/project/delete',
  492. data: {
  493. id: deletedIds
  494. }
  495. }).done(
  496. function(data) {
  497. if (!data.error.length) {
  498. message.success('删除成功!');
  499. this.setState({
  500. loading: false
  501. });
  502. } else {
  503. message.warning(data.error[0].message);
  504. }
  505. this.loadData(this.state.page);
  506. }.bind(this)
  507. );
  508. },
  509. addClick() {
  510. this.state.RowData = {};
  511. this.setState({
  512. visible: true,
  513. isHot: 0
  514. });
  515. this.addReset();
  516. },
  517. closeDesc(e, s) {
  518. this.state.showDesc = e;
  519. if (s) {
  520. this.loadData(this.state.page);
  521. };
  522. },
  523. handleCancel() {
  524. this.setState({ visible: false });
  525. },
  526. search() {
  527. this.loadData();
  528. },
  529. //搜索部分的清零
  530. reset() {
  531. this.state.nameSearch = ''; //项目名称清零
  532. this.state.cid = undefined; //品类名称清零
  533. this.typeSearch=undefined;
  534. this.state.ressSearch = undefined; //省市区清零
  535. this.state.activityFlag = undefined; //活动生效清零
  536. this.state.status = undefined; //项目状态清零
  537. this.loadData();
  538. },
  539. //新增部分的清零
  540. addReset() {
  541. this.state.categoryName = ''; //项目名称清零
  542. this.state.ProvinceCity = undefined;
  543. this.state.addCid = undefined;
  544. this.state.boutique = '';
  545. },
  546. //更多搜索的显示与否
  547. searchSwitch() {
  548. this.setState({
  549. searchMore: !this.state.searchMore
  550. });
  551. },
  552. render() {
  553. const FormItem = Form.Item;
  554. const rowSelection = {
  555. selectedRowKeys: this.state.selectedRowKeys,
  556. onChange: (selectedRowKeys, selectedRows) => {
  557. this.setState({
  558. selectedRows: selectedRows.slice(-1),
  559. selectedRowKeys: selectedRowKeys.slice(-1)
  560. });
  561. }
  562. };
  563. const formItemLayout = {
  564. labelCol: { span: 8 },
  565. wrapperCol: { span: 14 }
  566. };
  567. const hasSelected = this.state.selectedRowKeys.length > 0;
  568. const { RangePicker } = DatePicker;
  569. return (
  570. <div className="user-content">
  571. <div className="content-title">
  572. <div className="user-search">
  573. <Button
  574. type="primary"
  575. className="addButton"
  576. onClick={this.addClick}
  577. style={{ float: 'right', marginRight: '50px' }}
  578. >
  579. 新增项目<Icon type="plus" />
  580. </Button>
  581. <Input
  582. placeholder="业务项目名称"
  583. style={{ width: '150px', marginRight: '10px', marginBottom: '10px' }}
  584. value={this.state.nameSearch}
  585. onChange={(e) => {
  586. this.setState({ nameSearch: e.target.value });
  587. }}
  588. />
  589. <Cascader placeholder='业务项目品类'
  590. options={this.state.categoryList}
  591. style={{width:200,marginRight:10}}
  592. value={this.state.typeSearch} onChange={(e)=>{this.setState({typeSearch:e})}}/>
  593. <Button type="primary" onClick={this.search} style={{ marginRight: '10px' }}>
  594. 搜索
  595. </Button>
  596. <Button onClick={this.reset} style={{ marginRight: '10px' }}>
  597. 重置
  598. </Button>
  599. <Popconfirm title="是否删除?" onConfirm={this.delectRow} okText="是" cancelText="否">
  600. <Button
  601. style={{
  602. background: '#ea0862',
  603. border: 'none',
  604. color: '#fff',
  605. marginRight: '10px',
  606. marginLeft: '10px'
  607. }}
  608. disabled={!hasSelected}
  609. >
  610. 删除<Icon type="minus" />
  611. </Button>
  612. </Popconfirm>
  613. </div>
  614. <div className="patent-table">
  615. <Spin spinning={this.state.loading}>
  616. <Table
  617. columns={this.state.columns}
  618. dataSource={this.state.dataSource}
  619. rowSelection={rowSelection}
  620. pagination={this.state.pagination}
  621. onRowClick={this.tableRowClick}
  622. current={this.state.aa}
  623. />
  624. </Spin>
  625. </div>
  626. <TechDemandDesc
  627. data={this.state.RowData}
  628. showDesc={this.state.showDesc}
  629. closeDesc={this.closeDesc}
  630. categoryList={this.state.categoryList}
  631. />
  632. <div className="patent-desc">
  633. <Modal
  634. maskClosable={false}
  635. visible={this.state.visible}
  636. onOk={this.checkPatentProcess}
  637. onCancel={this.handleCancel}
  638. width="400px"
  639. title="新增业务项目"
  640. footer=""
  641. className="admin-desc-content"
  642. >
  643. <Form layout="horizontal" onSubmit={this.addhandleSubmit} id="demand-form">
  644. <Spin spinning={this.state.loading}>
  645. <div className="clearfix">
  646. <FormItem labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} label="业务项目名称">
  647. <Input
  648. placeholder="业务项目名称"
  649. value={this.state.categoryName}
  650. style={{ width: '94%' }}
  651. onChange={(e) => {
  652. this.setState({ categoryName: e.target.value });
  653. }}
  654. required="required"
  655. />
  656. <span className="mandatory" style={{ color: 'red', marginLeft: '5px' }}>
  657. *
  658. </span>
  659. </FormItem>
  660. </div>
  661. <div className="clearfix">
  662. <FormItem labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} label="业务品类">
  663. <Cascader placeholder='业务项目品类'
  664. options={this.state.categoryList}
  665. value={this.state.addCid}
  666. style={{ width: '94%' }}
  667. onChange={(e)=>{this.setState({addCid:e})}}/>
  668. <span className="mandatory" style={{ color: 'red', marginLeft: '5px' }}>
  669. *
  670. </span>
  671. </FormItem>
  672. </div>
  673. <div className="clearfix">
  674. <FormItem labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} label="省-市">
  675. <Cascader
  676. options={citySelect()}
  677. value={this.state.ProvinceCity}
  678. placeholder="选择市"
  679. style={{ width: '94%' }}
  680. onChange={(e, pre) => {
  681. this.setState({ ProvinceCity: e });
  682. }}
  683. />
  684. <span style={{ color: 'red', marginLeft: '5px' }}>*</span>
  685. </FormItem>
  686. </div>
  687. <div className="clearfix">
  688. <FormItem labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} label="热点">
  689. <Radio.Group
  690. onChange={(e) => {
  691. this.setState({ isHot: e.target.value });
  692. }}
  693. value={this.state.isHot}
  694. >
  695. <Radio value={0}>否</Radio>
  696. <Radio value={1}>是</Radio>
  697. </Radio.Group>
  698. </FormItem>
  699. </div>
  700. <FormItem wrapperCol={{ span: 12, offset: 7 }}>
  701. <Button className="set-submit" type="primary" htmlType="submit">
  702. 保存
  703. </Button>
  704. <Button
  705. className="set-submit"
  706. type="ghost"
  707. onClick={this.handleCancel}
  708. style={{ marginLeft: '15px' }}
  709. >
  710. 取消
  711. </Button>
  712. </FormItem>
  713. </Spin>
  714. </Form>
  715. </Modal>
  716. </div>
  717. </div>
  718. </div>
  719. );
  720. }
  721. })
  722. );
  723. export default BusinessProject;