index.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. import React, { Component } from "react";
  2. import { Button, Steps, notification, message } from "antd";
  3. import $ from "jquery/src/ajax";
  4. import "./index.less";
  5. /**
  6. * 开单、变更流程图
  7. * 派单传订单编号
  8. * 变更传变更id
  9. */
  10. const Step = Steps.Step;
  11. let num = 1;
  12. class FlowChart extends Component {
  13. constructor(props) {
  14. super(props);
  15. this.state = {
  16. details: {},
  17. processStatus: 0,
  18. list: [],
  19. };
  20. this.openNotification = this.openNotification.bind(this);
  21. this.handleClick = this.handleClick.bind(this);
  22. }
  23. componentDidMount() {
  24. }
  25. componentWillUnmount() {
  26. this.handleClick();
  27. }
  28. componentWillReceiveProps(nextProps) {
  29. // 防止重复请求
  30. if (num < 2) {
  31. (!!this.props.orderNo || !!this.props.id) &&
  32. (
  33. this.getData(),
  34. num++
  35. )
  36. }
  37. }
  38. // 派单流程/变更流程
  39. getData() {
  40. const { orderNo, id } = this.props
  41. // 派单流程
  42. if (!!orderNo) {
  43. $.ajax({
  44. method: "get",
  45. dataType: "json",
  46. crossDomain: false,
  47. url: globalConfig.context + "/api/admin/newOrder/getProcessName",
  48. data: {
  49. orderNo,
  50. },
  51. success: function (data) {
  52. let theArr = [];
  53. if (!data.data) {
  54. if (data.error && data.error.length) {
  55. message.warning(data.error[0].message);
  56. }
  57. } else {
  58. let pstatus = -1;
  59. let info = data.data;
  60. // 0非特批 1总裁待审核 2总裁通过 3总裁驳回 4董事长待审核 5董事长通过 6董事长驳回 7副总裁待审核 8副总裁通过 9副总裁驳回
  61. let tpname = ["-", info.approvalName, info.approvalName, info.approvalName, info.dsz, info.dsz, info.dsz][info.approval];
  62. theArr = [
  63. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  64. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  65. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  66. { status: 3, title: "财务/复审/技术总监审核", name: info.cwzy, time: "" },
  67. { status: 4, title: "运营保障审核 ", name: info.yybz, time: "" },
  68. { status: 5, title: "特批审核", name: tpname, time: "" },
  69. { status: 6, title: "技术总监派单", name: info.zxsgly, time: "" },
  70. { status: 7, title: "技术接单", name: "", time: "" },
  71. ]
  72. // name为“-”不需要显示
  73. let list = theArr.filter(v => {
  74. return v.name != "-"
  75. })
  76. list.forEach((item, index) => {
  77. if (item.status == info.processStatus) {
  78. pstatus = index
  79. }
  80. })
  81. // 状态为7就是全部分配 同样显示技术接单
  82. if (info.processStatus == 8) {
  83. pstatus = list.length - 1
  84. }
  85. this.setState({
  86. details: info,
  87. list: list,
  88. processStatus: pstatus,
  89. }, () => {
  90. this.openNotification(1)
  91. })
  92. }
  93. }.bind(this),
  94. }).always(
  95. function () {
  96. this.setState({
  97. loading: false,
  98. });
  99. }.bind(this)
  100. );
  101. }
  102. // 变更流程
  103. if (!!id) {
  104. $.ajax({
  105. method: "get",
  106. dataType: "json",
  107. crossDomain: false,
  108. url: globalConfig.context + "/api/admin/orderChange/getChangeProcessName",
  109. data: {
  110. id,
  111. },
  112. success: function (data) {
  113. let theArr = [];
  114. if (!data.data) {
  115. if (data.error && data.error.length) {
  116. message.warning(data.error[0].message);
  117. }
  118. } else {
  119. let info = data.data;
  120. let pstatus = -1;
  121. // 0 退单退款
  122. let theArr0 = [
  123. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  124. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  125. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  126. { status: 3, title: "技术员审核", name: info.zxs, time: "" },
  127. { status: 4, title: "技术经理审核", name: info.zxsjl, time: "" },
  128. { status: 5, title: "技术总监审核", name: info.zxsgly, time: "" },
  129. { status: 6, title: "财务专员审核", name: info.cwzy, time: "" },
  130. { status: 7, title: "财务总监审核", name: info.cwgly, time: "" },
  131. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  132. { status: 9, title: "公司/部门管理审核", name: info.special == 1 ? "-" : info.approvalName },
  133. { status: 10, title: "董事长审核", name: info.special == 1 ? info.dsz : (info.changeAmount > 0.2 ? info.dsz : "-"), time: "" },
  134. ]
  135. // 1 项目&金额
  136. let theArr1 = [
  137. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  138. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  139. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  140. { status: 3, title: "技术员审核", name: info.zxs, time: "" },
  141. { status: 4, title: "技术经理审核", name: info.zxsjl, time: "" },
  142. { status: 5, title: "技术总监审核", name: info.zxsgly, time: "" },
  143. { status: 6, title: "财务专员审核", name: info.cwzy, time: "" },
  144. { status: 7, title: "财务总监审核", name: info.cwgly, time: "" },
  145. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  146. { status: 9, title: "公司/部门管理审核", name: info.approvalName, time: "" },
  147. ]
  148. // 2 仅项目
  149. let theArr2 = [
  150. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  151. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  152. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  153. { status: 3, title: "技术员审核", name: info.zxs, time: "" },
  154. // { status: 4, title: "技术经理审核", name: info.zxsjl, time: "" },
  155. { status: 5, title: "技术总监审核", name: info.zxsgly, time: "" },
  156. { status: 6, title: "财务专员审核", name: info.cwzy, time: "" },
  157. { status: 7, title: "财务总监审核", name: info.cwgly, time: "" },
  158. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  159. { status: 9, title: "公司/部门管理审核", name: info.approvalName, time: "" },
  160. ]
  161. // 3 仅金额
  162. let theArr3 = [
  163. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  164. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  165. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  166. { status: 5, title: "技术总监审核", name: info.zxsgly, time: "" },
  167. { status: 6, title: "财务专员审核", name: info.cwzy, time: "" },
  168. { status: 7, title: "财务总监审核", name: info.cwgly, time: "" },
  169. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  170. { status: 9, title: "公司/部门管理审核", name: info.approvalName, time: "" },
  171. ]
  172. // 4 重报
  173. let theArr4 = [
  174. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  175. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  176. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  177. { status: 3, title: "技术员审核", name: info.zxs, time: "" },
  178. // { status: 4, title: "技术经理审核", name: info.zxsjl, time: "" },
  179. { status: 6, title: "财务专员审核", name: info.cwzy, time: "" },
  180. { status: 7, title: "财务总监审核", name: info.cwgly, time: "" },
  181. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  182. { status: 9, title: "公司/部门管理审核", name: info.approvalName, time: "" },
  183. ]
  184. // 5 赠送
  185. let theArr5 = [
  186. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  187. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  188. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  189. { status: 6, title: "财务专员审核", name: info.cwzy, time: "" },
  190. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  191. { status: 9, title: "公司/部门管理审核", name: info.approvalName, time: "" },
  192. ]
  193. // 6 退单不退款
  194. let theArr6 = [
  195. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  196. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  197. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  198. { status: 3, title: "技术员审核", name: info.zxs, time: "" },
  199. { status: 4, title: "技术经理审核", name: info.zxsjl, time: "" },
  200. { status: 5, title: "技术总监审核", name: info.zxsgly, time: "" },
  201. { status: 6, title: "财务专员审核", name: info.cwzy, time: "" },
  202. { status: 7, title: "财务总监审核", name: info.cwgly, time: "" },
  203. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  204. { status: 9, title: "公司/部门管理审核", name: info.approvalName, time: "" },
  205. ]
  206. // 7 仅变更合同
  207. let theArr7 = [
  208. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  209. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  210. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  211. ]
  212. // 8 框架协议
  213. let theArr8 = [
  214. { status: 0, title: "营销员发起", name: info.yxy, time: "" },
  215. { status: 1, title: "经理审核", name: !info.yxjl ? "-" : info.yxjl, time: "" },
  216. { status: 2, title: "营销管理员审核", name: info.yxgly, time: "" },
  217. { status: 6, title: "财务专员审核", name: info.cwzy, time: "" },
  218. { status: 8, title: "运营保障审核", name: info.yybz, time: "" },
  219. ]
  220. theArr = info.type == 0
  221. ? theArr0 : info.type == 1
  222. ? theArr1 : info.type == 2
  223. ? theArr2 : info.type == 3
  224. ? theArr3 : info.type == 4
  225. ? theArr4 : info.type == 5
  226. ? theArr5 : info.type == 6
  227. ? theArr6 : info.type == 7
  228. ? theArr7 : info.type == 8 && theArr8
  229. // name为“-”不需要显示
  230. let list = theArr.filter(v => {
  231. return v.name != "-"
  232. })
  233. // 如果是曹津
  234. if (info.special == 1) {
  235. for (var i = 0; i < list.length; i++) {
  236. // 如果是 退单退款
  237. if (info.type == 0) {
  238. // 去掉 董事长审核
  239. list.splice(9, 1);
  240. }
  241. // 把 总裁审核 改成 董事长审核
  242. if (list[i].status == 9) {
  243. list[i].status = 10;
  244. list[i].title = "董事长审核";
  245. list[i].name = info.dsz;
  246. }
  247. }
  248. }
  249. if (info.type == 0 || info.type == 6) {
  250. list.push({ status: 11, title: "财务退票", name: info.cwzy, time: "" },)
  251. }
  252. list.push({ status: 12, title: "完成", name: "", time: "" },)
  253. // 显示当前流程处理
  254. if (info.status == 0 || info.status == 1 || info.status == 3) {
  255. list.forEach((item, index) => {
  256. if (info.processState == 11 && item.status == 8) { // 副总裁审核processState == 11
  257. pstatus = index
  258. } else if ((item.status == info.processState) && info.processState != 11) {
  259. pstatus = index
  260. }
  261. })
  262. } else if (info.status == 2) {
  263. pstatus = list.length - 2
  264. } else if (info.status == 4) {
  265. pstatus = list.length - 1
  266. } else if (info.status == 5) {
  267. list = [{ status: -1, title: "变更已取消", name: "", time: "" }]
  268. pstatus = 0
  269. }
  270. this.setState({
  271. details: info,
  272. list: list,
  273. processStatus: pstatus,
  274. }, () => {
  275. this.openNotification(1)
  276. })
  277. }
  278. }.bind(this),
  279. }).always(
  280. function () {
  281. this.setState({
  282. loading: false,
  283. });
  284. }.bind(this)
  285. );
  286. }
  287. }
  288. openNotification(key) {
  289. const { list, details, processStatus } = this.state
  290. const { orderNo, id } = this.props
  291. notification.open({
  292. message: <div style={{ color: "#58A3FF" }}>{!!orderNo && "派单流程"}{!!id && "变更流程"}</div>,
  293. description: <Steps direction="vertical" size="default" current={processStatus}>
  294. {
  295. list.map((item) =>
  296. <Step title={item.title} description={item.name} key={item.status} />
  297. )
  298. }
  299. </Steps>,
  300. duration: null,
  301. key,
  302. style: {
  303. width: 250,
  304. }
  305. });
  306. }
  307. handleClick() {
  308. this.setState({
  309. details: {},
  310. processStatus: 0,
  311. list: [],
  312. })
  313. num = 1
  314. notification.close(1)
  315. }
  316. render() {
  317. return (
  318. <Button type="primary"
  319. style={{ marginLeft: 10 }}
  320. onClick={() => { this.getData() }}
  321. >查看流程</Button>
  322. );
  323. }
  324. }
  325. export default FlowChart;