businessDetails.jsx 9.2 KB

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