businessProject.jsx 19 KB

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