mysuspend.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import { AutoComplete, Button, Input, Spin, Table, DatePicker, Select, message, Tabs, Tag, Tooltip, Modal } from "antd";
  4. import { ChooseList } from "../../order/orderNew/chooseList"
  5. import moment from "moment";
  6. import ShowModalDiv from "@/showModal.jsx";
  7. import { getStopStatus } from '@/tools';
  8. import Cascaders from "../../../common/cascaders";
  9. import MySuspend from '../../../common/mysuspend';
  10. import MySuspendLog from '../../../common/logPopup/mysuspendlog';
  11. const { TabPane } = Tabs;
  12. const { RangePicker } = DatePicker;
  13. //我的暂停项目列表
  14. const MySuspendList = React.createClass({
  15. //
  16. getInitialState() {
  17. return {
  18. type: "",
  19. title: "",
  20. visible: false,
  21. pageNo: 1,
  22. totalPage: 0,
  23. searchValues: {},//查询条件
  24. loading: false,
  25. changeList: undefined,// 子组件改变的表格title数组
  26. pagination: {
  27. defaultCurrent: 1,
  28. defaultPageSize: 10,
  29. showQuickJumper: true,
  30. pageSize: 10,
  31. onChange: function (page) {
  32. this.setState({
  33. pageNo: page,
  34. });
  35. this.loadData(page);
  36. }.bind(this),
  37. showTotal: function (total) {
  38. return "共" + total + "条数据";
  39. },
  40. },
  41. columns: [
  42. {
  43. title: "时间",
  44. dataIndex: "createTimes",
  45. key: "createTimes",
  46. width: 80,
  47. },
  48. {
  49. title: "省份",
  50. dataIndex: "province",
  51. key: "province"
  52. },
  53. {
  54. title: "合同编号",
  55. dataIndex: "contractNo",
  56. key: "contractNo",
  57. render: (text, record) => {
  58. return (
  59. <Tooltip
  60. title={
  61. <Button
  62. type="primary"
  63. onClick={(e) => {
  64. e.stopPropagation();
  65. let input = document.getElementById("copyText");
  66. input.value = text;
  67. input.select();
  68. document.execCommand("copy");
  69. message.success("复制成功");
  70. }}
  71. >
  72. 复制
  73. </Button>
  74. }
  75. >
  76. <div>{text}</div>
  77. </Tooltip>
  78. );
  79. },
  80. },
  81. {
  82. title: "订单编号",
  83. dataIndex: "orderNo",
  84. key: "orderNo"
  85. },
  86. {
  87. title: "签单客户",
  88. dataIndex: "userName",
  89. key: "userName"
  90. },
  91. {
  92. title: "项目类型",
  93. dataIndex: "cname",
  94. key: "cname"
  95. },
  96. {
  97. title: "项目名称",
  98. dataIndex: "projectName",
  99. key: "projectName"
  100. },
  101. {
  102. title: "数量",
  103. dataIndex: "commodityQuantity",
  104. key: "commodityQuantity",
  105. width: 50,
  106. },
  107. {
  108. title: "服务类型",
  109. dataIndex: "serviceType",
  110. key: "serviceType"
  111. },
  112. {
  113. title: "咨询师/咨询经理",
  114. dataIndex: "receiverName",
  115. key: "receiverName"
  116. },
  117. {
  118. title: "项目状态",
  119. dataIndex: "stopStatus",
  120. key: "stopStatus",
  121. render: (value, record) => (
  122. <div>
  123. {getStopStatus(record.stopType, value)}
  124. {
  125. // 新需求 除湖南和内蒙古外 不让其他省操作
  126. (adminData.province == "21" || adminData.province == "11") &&
  127. <div>
  128. {
  129. record.stopType == 0 && record.stopStatus == 1 &&
  130. record.projectStopType == 0 && record.projectStopStatus == 1 &&
  131. <Button
  132. type="primary"
  133. onClick={() => {
  134. this.setState({
  135. title: "项目重启",
  136. type: "restart",
  137. visible: true,
  138. rowData: record,
  139. })
  140. }}
  141. >重启</Button>
  142. }
  143. {
  144. value == 2 &&
  145. <Button
  146. type="primary"
  147. onClick={() => {
  148. this.setState({
  149. type: record.stopType == 0
  150. ? "suspend" : record.stopType == 1
  151. ? "restart" : "",
  152. visible: true,
  153. rowData: record,
  154. again: true,
  155. })
  156. }}
  157. >重新发起</Button>
  158. }
  159. </div>
  160. }
  161. </div>
  162. )
  163. },
  164. {
  165. title: "项目金额",
  166. dataIndex: "commodityPrice",
  167. key: "commodityPrice"
  168. },
  169. {
  170. title: "原因",
  171. dataIndex: "reason",
  172. key: "reason",
  173. width: 250,
  174. },
  175. {
  176. title: "日志",
  177. dataIndex: "rz",
  178. key: "rz",
  179. width: 90,
  180. render: (text, record) => (
  181. <div>
  182. <MySuspendLog id={record.id} stopType={record.stopType} />
  183. </div>
  184. )
  185. }
  186. ],
  187. dataSource: [],
  188. rowData: {},
  189. };
  190. },
  191. componentWillMount() {
  192. this.loadData();
  193. },
  194. // 列表数据
  195. loadData(pageNo, pageSize) {
  196. const { searchValues, pagination } = this.state
  197. this.setState({
  198. loading: true,
  199. });
  200. let datas = Object.assign(searchValues, {
  201. pageNo: pageNo || 1,
  202. pageSize: pageSize || 10,
  203. shiroType: 0, // 我的列表
  204. });
  205. $.ajax({
  206. method: "get",
  207. dataType: "json",
  208. crossDomain: false,
  209. url: globalConfig.context + "/api/admin/orderProject/selectProjectStop",
  210. data: datas,
  211. success: function (data) {
  212. this.setState({
  213. loading: false,
  214. });
  215. if (data.error && data.error.length === 0) {
  216. if (data.data.list) {
  217. pagination.current = data.data.pageNo;
  218. pagination.total = data.data.totalCount;
  219. if (data.data && data.data.list && !data.data.list.length) {
  220. pagination.current = 0;
  221. pagination.total = 0;
  222. }
  223. this.setState({
  224. dataSource: data.data.list,
  225. pagination: this.state.pagination,
  226. pageNo: data.data.pageNo,
  227. totalPage: data.data.totalPage,
  228. });
  229. } else {
  230. this.setState({
  231. dataSource: data.data,
  232. pagination: false,
  233. });
  234. }
  235. } else {
  236. message.warning(data.error[0].message);
  237. }
  238. }.bind(this),
  239. }).always(
  240. function () {
  241. this.setState({
  242. loading: false,
  243. });
  244. }.bind(this)
  245. );
  246. },
  247. // 导出当前列表
  248. exportAll() {
  249. const { searchValues } = this.state
  250. message.config({
  251. duration: 20,
  252. });
  253. let loading = message.loading("下载中...");
  254. this.setState({
  255. exportPendingLoading: true,
  256. });
  257. let data = Object.assign(searchValues, {
  258. pageNo: 1,
  259. pageSize: 9999,
  260. });
  261. $.ajax({
  262. method: "get",
  263. dataType: "json",
  264. crossDomain: false,
  265. url: "/api/admin/orderProject/selectProjectStop/export",
  266. data,
  267. success: function (data) {
  268. if (data.error.length === 0) {
  269. this.download(data.data);
  270. } else {
  271. message.warning(data.error[0].message);
  272. }
  273. }.bind(this),
  274. }).always(
  275. function () {
  276. loading();
  277. this.setState({
  278. exportPendingLoading: false,
  279. });
  280. }.bind(this)
  281. );
  282. },
  283. // 下载
  284. download(fileName) {
  285. window.location.href =
  286. globalConfig.context + "/open/download?fileName=" + fileName;
  287. },
  288. // 更改表格显示数据
  289. changeList(arr) {
  290. const newArr = [];
  291. this.state.columns.forEach((item) => {
  292. arr.forEach((val) => {
  293. if (val === item.title) {
  294. newArr.push(item);
  295. }
  296. });
  297. });
  298. this.setState({
  299. changeList: newArr,
  300. });
  301. },
  302. // 查询订单负责人列表
  303. followUp(e) {
  304. const { searchValues } = this.state;
  305. this.setState({
  306. searchValues: Object.assign(searchValues, {
  307. aname: e,
  308. }),
  309. });
  310. $.ajax({
  311. method: "get",
  312. dataType: "json",
  313. crossDomain: false,
  314. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  315. data: {
  316. adminName: e,
  317. },
  318. success: function (data) {
  319. let thedata = data.data;
  320. if (!thedata) {
  321. if (data.error && data.error.length) {
  322. message.warning(data.error[0].message);
  323. }
  324. thedata = {};
  325. }
  326. this.setState({
  327. fjlist: thedata,
  328. });
  329. }.bind(this),
  330. }).always(
  331. function () {
  332. this.setState({
  333. loading: false,
  334. });
  335. }.bind(this)
  336. );
  337. },
  338. // 选中订单负责人
  339. selectF(value) {
  340. const { searchValues, fjlist } = this.state;
  341. const newdataSources = JSON.stringify(fjlist) == "{}" ? [] : fjlist;
  342. this.setState({
  343. searchValues: Object.assign(searchValues, {
  344. receiverId: newdataSources.find((item) => item.name == value).id,
  345. }),
  346. });
  347. },
  348. // 失去焦点
  349. blurChange(e) {
  350. let theType = "";
  351. let contactLists = this.state.customerArr || [];
  352. if (e) {
  353. contactLists.map(function (item) {
  354. if (item.name == e.toString()) {
  355. theType = item.id;
  356. }
  357. });
  358. }
  359. this.setState({
  360. theTypes: theType,
  361. });
  362. },
  363. // 双击查看详情
  364. tableRowClick(record) {
  365. this.setState({
  366. visible: true,
  367. type: "details",
  368. rowData: record,
  369. })
  370. },
  371. // 搜索
  372. search() {
  373. this.setState({
  374. selectedRowKeys: []
  375. })
  376. this.loadData();
  377. },
  378. // 重置
  379. reset() {
  380. this.setState({
  381. pageNo: 1,
  382. searchValues: JSON.parse(JSON.stringify({})),
  383. }, () => {
  384. this.Cascaders.empty();
  385. this.loadData();
  386. })
  387. },
  388. render() {
  389. const { searchValues, rowData } = this.state
  390. const dataSources = this.state.fjlist || [];
  391. const options = dataSources.map((group) => (
  392. <Select.Option key={group.id} value={group.name}>
  393. {group.name}
  394. </Select.Option>
  395. ));
  396. return (
  397. <div className="user-content">
  398. <ShowModalDiv ShowModal={this.state.showModal} />
  399. <div className="content-title" style={{ marginBottom: 10 }}>
  400. <span style={{ fontWeight: 900, fontSize: 16 }}>我的暂停项目</span>
  401. </div>
  402. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  403. <TabPane tab="搜索" key="1">
  404. <div className="user-search" style={{ marginLeft: 10 }}>
  405. <Input
  406. placeholder="订单编号"
  407. style={{ width: 160 }}
  408. value={searchValues["orderNo"]
  409. ? searchValues["orderNo"]
  410. : ""}
  411. onChange={(e) => {
  412. searchValues["orderNo"] = e.target.value;
  413. this.setState({
  414. searchValues: searchValues,
  415. });
  416. }}
  417. />
  418. <Input
  419. placeholder="合同编号"
  420. style={{ width: 160 }}
  421. value={searchValues["contractNo"]
  422. ? searchValues["contractNo"]
  423. : ""}
  424. onChange={(e) => {
  425. searchValues["contractNo"] = e.target.value;
  426. this.setState({
  427. searchValues: searchValues,
  428. });
  429. }}
  430. />
  431. <Input
  432. placeholder="客户名称"
  433. style={{ width: 160 }}
  434. value={searchValues["userName"]
  435. ? searchValues["userName"]
  436. : ""}
  437. onChange={(e) => {
  438. searchValues["userName"] = e.target.value;
  439. this.setState({
  440. searchValues: searchValues,
  441. });
  442. }}
  443. />
  444. <Cascaders
  445. ref={node => this.Cascaders = node}
  446. placeholder="订单部门"
  447. id="id"
  448. name="name"
  449. children="list"
  450. height={28}
  451. onSel={(e) => {
  452. searchValues["deps"] = JSON.stringify(e);
  453. this.setState({
  454. searchValues: searchValues,
  455. });
  456. }}
  457. />
  458. <Input
  459. placeholder="项目名称"
  460. style={{ width: 160 }}
  461. value={searchValues["projectName"]
  462. ? searchValues["projectName"]
  463. : ""}
  464. onChange={(e) => {
  465. searchValues["projectName"] = e.target.value;
  466. this.setState({
  467. searchValues: searchValues,
  468. });
  469. }}
  470. />
  471. <Select
  472. style={{ width: 120 }}
  473. placeholder="项目暂停状态"
  474. value={searchValues["status"]
  475. ? searchValues["status"]
  476. : undefined}
  477. onChange={(e) => {
  478. searchValues["status"] = e;
  479. this.setState({
  480. searchValues: searchValues,
  481. });
  482. }}
  483. >
  484. <Option value="">全部</Option>
  485. <Option value="0">发起暂停</Option>
  486. <Option value="1">发起重启</Option>
  487. <Option value="2">项目已暂停</Option>
  488. <Option value="3">项目已重启</Option>
  489. <Option value="4">暂停已驳回</Option>
  490. <Option value="5">重启已驳回</Option>
  491. </Select>
  492. <AutoComplete
  493. dropdownMatchSelectWidth={false}
  494. style={{ width: 160 }}
  495. dataSource={options}
  496. placeholder="咨询师/经理"
  497. value={searchValues.aname || undefined}
  498. onChange={this.followUp.bind(this)}
  499. filterOption={true}
  500. onBlur={this.blurChange}
  501. onSelect={this.selectF.bind(this)}
  502. >
  503. <Input />
  504. </AutoComplete>
  505. <RangePicker
  506. style={{ width: 200 }}
  507. value={[
  508. searchValues.startTime
  509. ? moment(searchValues.startTime)
  510. : null,
  511. searchValues.endTime ? moment(searchValues.endTime) : null,
  512. ]}
  513. onChange={(data, dataString) => {
  514. this.setState({
  515. searchValues: Object.assign(searchValues, {
  516. startTime: dataString[0],
  517. endTime: dataString[1],
  518. }),
  519. });
  520. }}
  521. />
  522. <Button
  523. type="primary"
  524. onClick={this.search}
  525. style={{ marginLeft: 10 }}
  526. disabled={this.state.loading ? true : false}
  527. >
  528. 搜索
  529. </Button>
  530. <Button onClick={this.reset}>重置</Button>
  531. </div>
  532. </TabPane>
  533. <TabPane tab="更改表格显示数据" key="2">
  534. <div style={{ marginLeft: 10 }}>
  535. <ChooseList
  536. columns={this.state.columns}
  537. changeFn={this.changeList}
  538. changeList={this.state.changeList}
  539. top={55}
  540. margin={11}
  541. />
  542. </div>
  543. </TabPane>
  544. <TabPane tab="导出Excel" key="3">
  545. <Button
  546. type="primary"
  547. style={{ margin: "11px 0px 10px 10px" }}
  548. onClick={this.exportAll}
  549. >
  550. 导出当前列表
  551. </Button>
  552. </TabPane>
  553. </Tabs>
  554. <div className="patent-table">
  555. <Spin spinning={this.state.loading}>
  556. <Table
  557. bordered
  558. columns={
  559. this.state.changeList == undefined
  560. ? this.state.columns
  561. : this.state.changeList
  562. }
  563. dataSource={this.state.dataSource}
  564. pagination={this.state.pagination}
  565. onRowDoubleClick={this.tableRowClick.bind(this)}
  566. size="small"
  567. />
  568. </Spin>
  569. </div>
  570. <textarea id="copyText" style={{ opacity: 0 }} />
  571. {
  572. // 项目详情
  573. this.state.visible &&
  574. <MySuspend
  575. type={this.state.type}
  576. title={!this.state.title
  577. ? (rowData.stopType == 0 ? "项目暂停" : "项目重启")
  578. : this.state.title}
  579. contractNo={rowData.contractNo}
  580. orderNo={rowData.orderNo}
  581. userName={rowData.userName}
  582. reason={rowData.reason}
  583. annexUrl={rowData.annexUrl}
  584. rowData={rowData}
  585. selectedRowKeys={[rowData.tid]}//项目发起id
  586. again={this.state.again} //是否为驳回重新发起
  587. selectedRows={[{ "commodityName": rowData.projectName, "id": rowData.tid }]}
  588. visible={this.state.visible}
  589. subClose={() => {
  590. this.loadData(this.state.pageNo);
  591. this.setState({
  592. visible: false,
  593. again: false,
  594. rowData: {},
  595. type: "",
  596. title: "",
  597. })
  598. }}
  599. />
  600. }
  601. </div>
  602. );
  603. },
  604. });
  605. export default MySuspendList;