businessDetails.jsx 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. import React from 'react';
  2. import $ from 'jquery/src/ajax';
  3. import { Modal, message, Spin, Upload, Button, Form } from 'antd';
  4. import { getprovince, splitUrl } from '@/tools.js';
  5. const DemandDetail = Form.create()(
  6. React.createClass({
  7. getInitialState() {
  8. return {
  9. visible: false,
  10. loading: false,
  11. auditStatus: 0,
  12. textFileList: [],
  13. videoFileList: [],
  14. pictureUrl: []
  15. };
  16. },
  17. loadData(id) {
  18. this.setState({
  19. loading: true
  20. });
  21. $.ajax({
  22. method: 'get',
  23. dataType: 'json',
  24. crossDomain: false,
  25. url: globalConfig.context + '/api/user/jtBusiness/project/detail',
  26. data: {
  27. id: id
  28. },
  29. success: function(data) {
  30. let thisData = data.data;
  31. if (!thisData) {
  32. if (data.error && data.error.length) {
  33. message.warning(data.error[0].message);
  34. }
  35. thisData = {};
  36. }
  37. let firstData = this.props.firstData,name='';
  38. firstData.map(item=>{
  39. if(item.id==thisData.categoryId){
  40. name=item.name;
  41. }
  42. })
  43. this.setState({
  44. id: thisData.id,
  45. data: thisData,
  46. name:name,
  47. auditStatus: thisData.auditStatus,
  48. orgCodeUrl: thisData.minImgUrl
  49. ? splitUrl(thisData.minImgUrl, ',', globalConfig.avatarHost + '/upload')
  50. : [],
  51. companyLogoUrl: thisData.maxImgUrl
  52. ? splitUrl(thisData.maxImgUrl, ',', globalConfig.avatarHost + '/upload')
  53. : []
  54. });
  55. }.bind(this)
  56. }).always(
  57. function() {
  58. this.setState({
  59. loading: false
  60. });
  61. }.bind(this)
  62. );
  63. },
  64. cancelFun() {
  65. this.props.closeDesc();
  66. },
  67. //刷新发布
  68. updateFun(inex) {
  69. this.setState({
  70. loading: true
  71. });
  72. $.ajax({
  73. method: 'get',
  74. dataType: 'json',
  75. crossDomain: false,
  76. url: globalConfig.context + '/api/user/jtBusiness/project/refreshPublish',
  77. data: {
  78. id: this.state.id,
  79. auditStatus: this.state.auditStatus
  80. }
  81. }).done(
  82. function(data) {
  83. if (!data.error.length) {
  84. message.success('刷新成功!');
  85. this.setState({
  86. loading: false
  87. });
  88. } else {
  89. message.warning(data.error[0].message);
  90. }
  91. this.props.handOk();
  92. }.bind(this)
  93. );
  94. },
  95. //撤销发布
  96. revokeFun() {
  97. this.setState({
  98. loading: true
  99. });
  100. $.ajax({
  101. method: 'get',
  102. dataType: 'json',
  103. crossDomain: false,
  104. url: globalConfig.context + '/api/user/jtBusiness/project/offShelf',
  105. data: {
  106. id: this.state.id,
  107. auditStatus:this.state.auditStatus
  108. }
  109. }).done(
  110. function(data) {
  111. if (!data.error.length) {
  112. message.success('撤销成功!');
  113. this.setState({
  114. loading: false
  115. });
  116. } else {
  117. message.warning(data.error[0].message);
  118. }
  119. this.props.handOk();
  120. }.bind(this)
  121. );
  122. },
  123. componentWillMount() {
  124. if (this.props.data.id) {
  125. this.loadData(this.props.data.id);
  126. } else {
  127. this.state.data = {};
  128. }
  129. },
  130. componentWillReceiveProps(nextProps) {
  131. if (!this.props.visible && nextProps.visible) {
  132. this.state.textFileList = [];
  133. this.state.videoFileList = [];
  134. if (nextProps.data.id) {
  135. this.loadData(nextProps.data.id);
  136. } else {
  137. this.state.data = {};
  138. this.state.pictureUrl = [];
  139. }
  140. this.props.form.resetFields();
  141. }
  142. },
  143. render() {
  144. const theData = this.state.data || {};
  145. const FormItem = Form.Item;
  146. return (
  147. <div className="patent-desc">
  148. <Form
  149. layout="horizontal"
  150. onSubmit={(e) => {
  151. this.handleSubmit(e, 0);
  152. }}
  153. id="demand-form"
  154. >
  155. <Spin spinning={this.state.loading}>
  156. <div className="clearfix">
  157. <FormItem
  158. className="half-item"
  159. labelCol={{ span:8 }}
  160. wrapperCol={{ span: 12 }}
  161. label="项目名称"
  162. >
  163. <span>{theData.name}</span>
  164. </FormItem>
  165. <FormItem
  166. className="half-item"
  167. labelCol={{ span: 8 }}
  168. wrapperCol={{ span: 12 }}
  169. label="业务品类"
  170. >
  171. <span>{this.state.name}</span>
  172. </FormItem>
  173. </div>
  174. <div className="clearfix">
  175. <FormItem
  176. className="half-item"
  177. labelCol={{ span:8 }}
  178. wrapperCol={{ span: 12 }}
  179. label="省份"
  180. >
  181. <span>{theData.province!='0'?getprovince(theData.province):'全国'}</span>
  182. </FormItem>
  183. <FormItem
  184. className="half-item"
  185. labelCol={{ span: 8 }}
  186. wrapperCol={{ span: 12 }}
  187. label="热点"
  188. >
  189. <span>{theData.isHot ? '是' : '否'}</span>
  190. </FormItem>
  191. </div>
  192. <div className="clearfix">
  193. <FormItem
  194. className="half-item"
  195. labelCol={{ span:8 }}
  196. wrapperCol={{ span: 12 }}
  197. label="市场价"
  198. >
  199. <span>{theData.price}万元</span>
  200. </FormItem>
  201. <FormItem
  202. className="half-item"
  203. labelCol={{ span:8 }}
  204. wrapperCol={{ span: 12 }}
  205. label="活动价"
  206. >
  207. <span>{theData.activityPrice}万元</span>
  208. </FormItem>
  209. <FormItem
  210. className="half-item"
  211. labelCol={{ span:8 }}
  212. wrapperCol={{ span: 12 }}
  213. label="最低折扣"
  214. >
  215. <span>{theData.offset} 万元</span>
  216. </FormItem>
  217. <FormItem
  218. className="half-item"
  219. labelCol={{ span:8 }}
  220. wrapperCol={{ span: 12 }}
  221. label="会员价"
  222. >
  223. <span>{theData.memberPrice} 万元</span>
  224. </FormItem>
  225. <FormItem
  226. className="half-item"
  227. labelCol={{ span: 8 }}
  228. wrapperCol={{ span: 12 }}
  229. label="活动生效"
  230. >
  231. <span>{theData.activityFlag ? '有效' : '无效'}</span>
  232. </FormItem>
  233. <FormItem
  234. className="half-item"
  235. labelCol={{ span: 8}}
  236. wrapperCol={{ span: 12 }}
  237. label="创建时间"
  238. >
  239. <span>{this.state.createTime}</span>
  240. </FormItem>
  241. </div>
  242. <div className="clearfix">
  243. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="业务项目服务内容">
  244. <span>{theData.introduce}</span>
  245. </FormItem>
  246. </div>
  247. <div className="clearfix">
  248. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="业务项目价值及作用">
  249. <span>{theData.value}</span>
  250. </FormItem>
  251. </div>
  252. <div className="clearfix">
  253. <FormItem labelCol={{ span: 4 }} wrapperCol={{ span: 12 }} label="业务项目客户基本条件">
  254. <span>{theData.applyConditions}</span>
  255. </FormItem>
  256. </div>
  257. <div className="clearfix pictures">
  258. <FormItem
  259. className="half-item"
  260. labelCol={{ span: 8 }}
  261. wrapperCol={{ span: 10 }}
  262. label="业务项目图标(小)"
  263. >
  264. <Upload
  265. className="demandDetailShow-upload"
  266. listType="picture-card"
  267. fileList={this.state.orgCodeUrl}
  268. onPreview={(file) => {
  269. this.setState({
  270. previewImage: file.url || file.thumbUrl,
  271. previewVisible: true
  272. });
  273. }}
  274. />
  275. <Modal
  276. maskClosable={false}
  277. footer={null}
  278. visible={this.state.previewVisible}
  279. onCancel={() => {
  280. this.setState({ previewVisible: false });
  281. }}
  282. >
  283. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  284. </Modal>
  285. </FormItem>
  286. <FormItem
  287. className="half-item"
  288. labelCol={{ span: 8 }}
  289. wrapperCol={{ span: 12 }}
  290. label="业务项目图标(大)"
  291. >
  292. <Upload
  293. className="demandDetailShow-upload"
  294. listType="picture-card"
  295. fileList={this.state.companyLogoUrl}
  296. onPreview={(file) => {
  297. this.setState({
  298. previewImage: file.url || file.thumbUrl,
  299. previewVisible: true
  300. });
  301. }}
  302. />
  303. <Modal
  304. maskClosable={false}
  305. footer={null}
  306. visible={this.state.previewVisible}
  307. onCancel={() => {
  308. this.setState({ previewVisible: false });
  309. }}
  310. >
  311. <img alt="" style={{ width: '100%' }} src={this.state.previewImage || ''} />
  312. </Modal>
  313. </FormItem>
  314. </div>
  315. <div className="clearfix">
  316. {this.props.data.auditStatus == '2' && (
  317. <FormItem wrapperCol={{ span: 12, offset: 3 }}>
  318. <Button
  319. className="set-submit"
  320. type="primary"
  321. onClick={(e) => {
  322. this.updateFun();
  323. }}
  324. >
  325. 刷新发布
  326. </Button>
  327. <Button
  328. type="danger"
  329. style={{ marginRight: 20 }}
  330. onClick={(e) => {
  331. this.revokeFun();
  332. }}
  333. >
  334. 撤销发布
  335. </Button>
  336. <Button className="set-submit" type="ghost" onClick={this.cancelFun}>
  337. 取消
  338. </Button>
  339. </FormItem>
  340. )}
  341. </div>
  342. </Spin>
  343. </Form>
  344. </div>
  345. );
  346. }
  347. })
  348. );
  349. export default DemandDetail;