businessName.jsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. import React from 'react'
  2. import ajax from 'jquery/src/ajax/xhr.js';
  3. import $ from 'jquery/src/ajax';
  4. import { Radio, Form, Modal, message, layout, Spin, Button,Tag } from 'antd';
  5. const BusName = React.createClass({
  6. loadData(ids) {
  7. this.setState({
  8. loading: true
  9. })
  10. $.ajax({
  11. method: "post",
  12. dataType: "json",
  13. url: globalConfig.context + '/api/admin/ProjectSize/listProject',
  14. data: {
  15. pageNo: 1,
  16. pageSize: 100,
  17. cid: ids,
  18. },
  19. success: function(data) {
  20. let listArr = [];
  21. let thedata = data.data;
  22. if(!thedata) {
  23. if(data.error && data.error.length) {
  24. message.warning(data.error[0].message);
  25. };
  26. thedata = {};
  27. };
  28. if(data.data && data.data.list) {
  29. for(let i = 0; i < data.data.list.length; i++) {
  30. let thisdata = data.data.list[i];
  31. listArr.push({
  32. id: thisdata.id,
  33. name: thisdata.bname,
  34. });
  35. };
  36. }
  37. this.setState({
  38. projectData: listArr,
  39. });
  40. }.bind(this),
  41. }).always(function() {
  42. this.setState({
  43. loading: false
  44. });
  45. }.bind(this));
  46. },
  47. getLockedProject(ids) {
  48. this.setState({
  49. loading: true
  50. })
  51. $.ajax({
  52. method: "get",
  53. dataType: "json",
  54. url: globalConfig.context + '/api/admin/customer/getLockedProject',
  55. data: {
  56. uid: ids
  57. },
  58. success: function(data) {
  59. let theData = data.data,
  60. businessProjectName = [];
  61. if(!theData) {
  62. if(data.err && data.err.length) {
  63. message.warning(data.error[0].message);
  64. }
  65. } else {
  66. theData.map(item => {
  67. businessProjectName.push(item.businessProjectName)
  68. })
  69. this.setState({
  70. businessData: businessProjectName
  71. })
  72. }
  73. }.bind(this)
  74. }).always(function() {
  75. this.setState({
  76. loading: false
  77. })
  78. }.bind(this));
  79. },
  80. getInitialState() {
  81. return {
  82. busModul: false
  83. }
  84. },
  85. visitCancel() {
  86. this.setState({
  87. busModul: false
  88. })
  89. this.props.closeBus(null, false, false)
  90. },
  91. selFn() {
  92. if(!this.state.contactType) {
  93. message.warning('未选定项目!')
  94. return false;
  95. };
  96. this.setState({
  97. busModul: false
  98. });
  99. let idData = {};
  100. idData.id = this.state.contactType;
  101. this.state.projectData.map(item => {
  102. if(this.state.contactType == item.id) {
  103. idData.name = item.name
  104. }
  105. })
  106. this.props.closeBus(idData, false, true);
  107. },
  108. componentWillReceiveProps(nextProps) {
  109. if(nextProps.busModul) {
  110. this.setState({
  111. busModul: true,
  112. loading: false
  113. })
  114. this.getLockedProject(nextProps.mid);
  115. this.loadData(nextProps.businessId);
  116. };
  117. },
  118. render() {
  119. const formItemLayout = {
  120. labelCol: {
  121. span: 4
  122. },
  123. wrapperCol: {
  124. span: 18
  125. },
  126. };
  127. const projectData = this.state.projectData || [];
  128. const businessData = this.state.businessData ||[]
  129. return(
  130. <Modal
  131. className="customeDetails"
  132. footer=''
  133. title="项目名称"
  134. width='600px'
  135. visible={this.state.busModul}
  136. onOk={this.visitCancel}
  137. onCancel={this.visitCancel}
  138. >
  139. <Form layout="horizontal" id="demand-form" >
  140. <Spin spinning={this.state.loading}>
  141. <div className="clearfix">
  142. <Form.Item
  143. {...formItemLayout}
  144. label="已签单业务" >
  145. {
  146. businessData.map((item,index)=>{
  147. // console.log(item)
  148. return <Tag key={index} color='#2db7f5'>{item}</Tag>
  149. })
  150. }
  151. <span>{}</span>
  152. </Form.Item>
  153. <Form.Item
  154. {...formItemLayout}
  155. label="项目名称" >
  156. <Radio.Group value={this.state.contactType} onChange={(e) => {
  157. this.setState({ contactType: e.target.value })
  158. }}>
  159. {
  160. projectData.map((item,index)=>{
  161. return <Radio key={index} value={item.id}>{item.name}</Radio>
  162. })
  163. }
  164. </Radio.Group>
  165. </Form.Item>
  166. <Form.Item wrapperCol={{ span: 12, offset: 4 }}>
  167. <Button onClick={this.selFn} type='primary'>选定</Button>
  168. <Button onClick={this.visitCancel} style={{marginLeft:'40px'}}>取消</Button>
  169. </Form.Item>
  170. </div>
  171. </Spin>
  172. </Form>
  173. </Modal>
  174. )
  175. }
  176. })
  177. export default BusName;