detail.jsx 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. import React from 'react';
  2. import { Form, Table, Spin, message, Modal, Button, Select } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. const Detail = React.createClass({
  6. getInitialState() {
  7. return {
  8. visible: false,
  9. loading: false,
  10. dataSource: [],
  11. gdataSource: [],
  12. columns: [
  13. {
  14. title: '业务名称',
  15. dataIndex: 'businessProjectName',
  16. key: 'businessProjectName',
  17. },
  18. {
  19. title: '签单时间',
  20. dataIndex: 'lockTime',
  21. key: 'lockTime',
  22. },
  23. {
  24. title: '营销员',
  25. dataIndex: 'salesmanName',
  26. key: 'salesmanName',
  27. }
  28. ],
  29. gcolumns: [
  30. {
  31. title: '限定项目',
  32. dataIndex: 'projectName',
  33. key: 'projectName',
  34. },
  35. {
  36. title: '状态',
  37. dataIndex: 'type',
  38. key: 'type',
  39. render: (text) =>
  40. <span>
  41. {["公共", "私有", "签单"][text]}
  42. </span>
  43. },
  44. {
  45. title: '营销员',
  46. dataIndex: 'adminName',
  47. key: 'adminName',
  48. },
  49. {
  50. title: '操作',
  51. dataIndex: 'op',
  52. key: 'op',
  53. render: (text, record) =>
  54. (record.type == 0 && this.props.data.shareType == 2) &&
  55. <Button
  56. type="primary"
  57. onClick={() => {
  58. this.setState({
  59. visible: true,
  60. pid: record.pid,
  61. pName: record.projectName,
  62. })
  63. }}
  64. >
  65. 领取
  66. </Button>
  67. },
  68. ],
  69. followList: [
  70. { key: "已发项目介绍资料", value: 0 },
  71. { key: "已约面谈", value: 1 },
  72. { key: "已发合同计划书", value: 2 },
  73. { key: "已报价", value: 3 },
  74. { key: "已发合同", value: 4 },
  75. { key: "已签合同", value: 5 },
  76. { key: "面谈中", value: 6 },
  77. { key: "已面签", value: 7 },
  78. { key: "无进度", value: 8 },
  79. ],
  80. customerList: [
  81. { key: "新客户", value: 0 },
  82. { key: "意向客户", value: 1 },
  83. { key: "重点客户", value: 2 },
  84. { key: "面谈客户", value: 3 },
  85. { key: "签单客户", value: 4 },
  86. { key: "被拒客户", value: 5 },
  87. { key: "停止跟进", value: 6 },
  88. ],
  89. followSituation: 6,
  90. customerStatus: 4,
  91. }
  92. },
  93. loadData(data, apiUrl) {
  94. this.setState({
  95. loading: true,
  96. });
  97. $.ajax({
  98. method: "get",
  99. dataType: "json",
  100. crossDomain: false,
  101. url: globalConfig.context + apiUrl,
  102. data: {
  103. uid: data.id,
  104. },
  105. success: function (data) {
  106. let listArr = [];
  107. let thedata = data.data;
  108. if (!thedata) {
  109. if (data.error && data.error.length) {
  110. message.warning(data.error[0].message);
  111. };
  112. thedata = {};
  113. return;
  114. };
  115. for (let i = 0; i < data.data.length; i++) {
  116. let thisdata = data.data[i];
  117. listArr.push({
  118. id: thisdata.id,
  119. businessProjectName: thisdata.businessProjectName,
  120. salesmanName: thisdata.salesmanName,
  121. lockTime: thisdata.lockTime && thisdata.lockTime.split(' ')[0],
  122. });
  123. };
  124. this.setState({
  125. dataSource: listArr,
  126. });
  127. }.bind(this),
  128. }).always(function () {
  129. this.setState({
  130. loading: false
  131. });
  132. }.bind(this));
  133. },
  134. gloadData(id) {
  135. this.setState({
  136. loading: true,
  137. });
  138. $.ajax({
  139. method: "get",
  140. dataType: "json",
  141. crossDomain: false,
  142. url: globalConfig.context + '/api/restrict/Project/list',
  143. data: {
  144. uid: id,
  145. },
  146. success: function (data) {
  147. let thedata = data.data;
  148. if (!thedata) {
  149. if (data.error && data.error.length) {
  150. message.warning(data.error[0].message);
  151. };
  152. } else {
  153. this.setState({
  154. gdataSource: thedata
  155. })
  156. }
  157. }.bind(this),
  158. }).always(function () {
  159. this.setState({
  160. loading: false
  161. });
  162. }.bind(this));
  163. },
  164. visitCancel() {
  165. this.setState({
  166. visitModul: false
  167. })
  168. this.props.closeDesc(false);
  169. },
  170. add() {
  171. if (!this.state.followSituation && this.state.followSituation != 0) {
  172. message.warning("请选择跟进进度!")
  173. return
  174. }
  175. if (!this.state.customerStatus && this.state.customerStatus != 0) {
  176. message.warning("请选择客户状态!")
  177. return
  178. }
  179. this.setState({
  180. loading: true,
  181. });
  182. $.ajax({
  183. method: "post",
  184. dataType: "json",
  185. crossDomain: false,
  186. url: globalConfig.context + "/api/restrict/Project/add",
  187. data: {
  188. pid: this.state.pid,
  189. uid: this.state.uid,
  190. followSituation: this.state.followSituation,
  191. customerStatus: this.state.customerStatus,
  192. },
  193. success: function (data) {
  194. if (data.error && data.error.length) {
  195. message.warning(data.error[0].message);
  196. } else {
  197. Modal.success({
  198. title: '领取成功!',
  199. content: (
  200. <div>
  201. 本次领取的项目为
  202. <span style={{ color: "red" }}>【{this.state.pName}】</span>
  203. ,请在我的“客户管理-限定项目列表“查看
  204. </div>),
  205. });
  206. this.setState({
  207. visible: false,
  208. followSituation: 6,
  209. customerStatus: 4,
  210. })
  211. this.gloadData(this.state.uid)
  212. }
  213. }.bind(this),
  214. }).always(
  215. function () {
  216. this.setState({
  217. loading: false,
  218. });
  219. }.bind(this)
  220. );
  221. },
  222. componentWillReceiveProps(nextProps) {
  223. if (nextProps.visitModul) {
  224. this.setState({
  225. visitModul: true,
  226. uid: nextProps.data.id,
  227. })
  228. this.loadData(nextProps.data, nextProps.detailApi);
  229. this.gloadData(nextProps.data.id)
  230. }
  231. },
  232. render() {
  233. const FormItem = Form.Item
  234. return (
  235. <Modal
  236. className="customeDetails"
  237. footer=''
  238. title=""
  239. width='800px'
  240. visible={this.state.visitModul}
  241. onOk={this.visitCancel}
  242. onCancel={this.visitCancel}
  243. >
  244. <Spin spinning={this.state.loading}>
  245. <div style={{ fontSize: "16px", fontWeight: "bold" }}>限定项目</div>
  246. <Table
  247. size="middle"
  248. columns={this.state.gcolumns}
  249. dataSource={this.state.gdataSource}
  250. pagination={false}
  251. />
  252. <div style={{ marginTop: 50, fontSize: "16px", fontWeight: "bold" }}>已签业务</div>
  253. <Table
  254. size="middle"
  255. columns={this.state.columns}
  256. dataSource={this.state.dataSource}
  257. pagination={false}
  258. />
  259. </Spin>
  260. <Modal
  261. title="领取限定项目"
  262. visible={this.state.visible}
  263. onOk={this.add}
  264. onCancel={() => {
  265. this.setState({
  266. visible: false,
  267. followSituation: 6,
  268. customerStatus: 4,
  269. })
  270. }}
  271. >
  272. <FormItem
  273. labelCol={{ span: 8 }}
  274. wrapperCol={{ span: 10 }}
  275. label="跟进进度"
  276. >
  277. <Select
  278. placeholder="跟进进度"
  279. value={this.state.followSituation}
  280. style={{ width: 200 }}
  281. onChange={(e) => {
  282. this.setState({ followSituation: e });
  283. }}
  284. >
  285. {this.state.followList.map(function (item) {
  286. return (
  287. <Select.Option key={item.value} value={item.value}>
  288. {item.key}
  289. </Select.Option>
  290. );
  291. })}
  292. </Select>
  293. </FormItem>
  294. <FormItem
  295. labelCol={{ span: 8 }}
  296. wrapperCol={{ span: 10 }}
  297. label="客户状态"
  298. >
  299. <Select
  300. placeholder="客户状态"
  301. value={this.state.customerStatus}
  302. style={{ width: 200 }}
  303. onChange={(e) => {
  304. this.setState({ customerStatus: e });
  305. }}
  306. >
  307. {this.state.customerList.map(function (item) {
  308. return (
  309. <Select.Option key={item.value} value={item.value}>
  310. {item.key}
  311. </Select.Option>
  312. );
  313. })}
  314. </Select>
  315. </FormItem>
  316. </Modal>
  317. </Modal>
  318. )
  319. }
  320. })
  321. export default Detail;