mysuspend.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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. <div>
  125. {
  126. record.stopType == 0 && record.stopStatus == 1 &&
  127. record.projectStopType == 0 && record.projectStopStatus == 1 &&
  128. <Button
  129. type="primary"
  130. onClick={() => {
  131. this.setState({
  132. title: "项目重启",
  133. type: "restart",
  134. visible: true,
  135. rowData: record,
  136. })
  137. }}
  138. >重启</Button>
  139. }
  140. {
  141. value == 2 &&
  142. <Button
  143. type="primary"
  144. onClick={() => {
  145. this.setState({
  146. type: record.stopType == 0
  147. ? "suspend" : record.stopType == 1
  148. ? "restart" : "",
  149. visible: true,
  150. rowData: record,
  151. again: true,
  152. })
  153. }}
  154. >重新发起</Button>
  155. }
  156. </div>
  157. </div>
  158. )
  159. },
  160. {
  161. title: "项目金额",
  162. dataIndex: "commodityPrice",
  163. key: "commodityPrice"
  164. },
  165. {
  166. title: "原因",
  167. dataIndex: "reason",
  168. key: "reason",
  169. width: 250,
  170. },
  171. {
  172. title: "日志",
  173. dataIndex: "rz",
  174. key: "rz",
  175. width: 90,
  176. render: (text, record) => (
  177. <div>
  178. <MySuspendLog id={record.id} stopType={record.stopType} />
  179. </div>
  180. )
  181. }
  182. ],
  183. dataSource: [],
  184. rowData: {},
  185. };
  186. },
  187. componentWillMount() {
  188. this.loadData();
  189. },
  190. // 列表数据
  191. loadData(pageNo, pageSize) {
  192. const { searchValues, pagination } = this.state
  193. this.setState({
  194. loading: true,
  195. });
  196. let datas = Object.assign(searchValues, {
  197. pageNo: pageNo || 1,
  198. pageSize: pageSize || 10,
  199. });
  200. $.ajax({
  201. method: "get",
  202. dataType: "json",
  203. crossDomain: false,
  204. url: globalConfig.context + "/api/admin/orderProject/selectProjectStop",
  205. data: datas,
  206. success: function (data) {
  207. this.setState({
  208. loading: false,
  209. });
  210. if (data.error && data.error.length === 0) {
  211. if (data.data.list) {
  212. pagination.current = data.data.pageNo;
  213. pagination.total = data.data.totalCount;
  214. if (data.data && data.data.list && !data.data.list.length) {
  215. pagination.current = 0;
  216. pagination.total = 0;
  217. }
  218. this.setState({
  219. dataSource: data.data.list,
  220. pagination: this.state.pagination,
  221. pageNo: data.data.pageNo,
  222. totalPage: data.data.totalPage,
  223. });
  224. } else {
  225. this.setState({
  226. dataSource: data.data,
  227. pagination: false,
  228. });
  229. }
  230. } else {
  231. message.warning(data.error[0].message);
  232. }
  233. }.bind(this),
  234. }).always(
  235. function () {
  236. this.setState({
  237. loading: false,
  238. });
  239. }.bind(this)
  240. );
  241. },
  242. // 导出当前列表
  243. exportAll() {
  244. const { searchValues } = this.state
  245. message.config({
  246. duration: 20,
  247. });
  248. let loading = message.loading("下载中...");
  249. this.setState({
  250. exportPendingLoading: true,
  251. });
  252. let data = Object.assign(searchValues, {
  253. pageNo: 1,
  254. pageSize: 9999,
  255. });
  256. $.ajax({
  257. method: "get",
  258. dataType: "json",
  259. crossDomain: false,
  260. url: "/api/admin/orderProject/selectProjectStop/export",
  261. data,
  262. success: function (data) {
  263. if (data.error.length === 0) {
  264. this.download(data.data);
  265. } else {
  266. message.warning(data.error[0].message);
  267. }
  268. }.bind(this),
  269. }).always(
  270. function () {
  271. loading();
  272. this.setState({
  273. exportPendingLoading: false,
  274. });
  275. }.bind(this)
  276. );
  277. },
  278. // 下载
  279. download(fileName) {
  280. window.location.href =
  281. globalConfig.context + "/open/download?fileName=" + fileName;
  282. },
  283. // 更改表格显示数据
  284. changeList(arr) {
  285. const newArr = [];
  286. this.state.columns.forEach((item) => {
  287. arr.forEach((val) => {
  288. if (val === item.title) {
  289. newArr.push(item);
  290. }
  291. });
  292. });
  293. this.setState({
  294. changeList: newArr,
  295. });
  296. },
  297. // 查询订单负责人列表
  298. followUp(e) {
  299. const { searchValues } = this.state;
  300. this.setState({
  301. searchValues: Object.assign(searchValues, {
  302. aname: e,
  303. }),
  304. });
  305. $.ajax({
  306. method: "get",
  307. dataType: "json",
  308. crossDomain: false,
  309. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  310. data: {
  311. adminName: e,
  312. },
  313. success: function (data) {
  314. let thedata = data.data;
  315. if (!thedata) {
  316. if (data.error && data.error.length) {
  317. message.warning(data.error[0].message);
  318. }
  319. thedata = {};
  320. }
  321. this.setState({
  322. fjlist: thedata,
  323. });
  324. }.bind(this),
  325. }).always(
  326. function () {
  327. this.setState({
  328. loading: false,
  329. });
  330. }.bind(this)
  331. );
  332. },
  333. // 选中订单负责人
  334. selectF(value) {
  335. const { searchValues, fjlist } = this.state;
  336. const newdataSources = JSON.stringify(fjlist) == "{}" ? [] : fjlist;
  337. this.setState({
  338. searchValues: Object.assign(searchValues, {
  339. receiverId: newdataSources.find((item) => item.name == value).id,
  340. }),
  341. });
  342. },
  343. // 失去焦点
  344. blurChange(e) {
  345. let theType = "";
  346. let contactLists = this.state.customerArr || [];
  347. if (e) {
  348. contactLists.map(function (item) {
  349. if (item.name == e.toString()) {
  350. theType = item.id;
  351. }
  352. });
  353. }
  354. this.setState({
  355. theTypes: theType,
  356. });
  357. },
  358. // 双击查看详情
  359. tableRowClick(record) {
  360. this.setState({
  361. visible: true,
  362. type: "details",
  363. rowData: record,
  364. })
  365. },
  366. // 搜索
  367. search() {
  368. this.setState({
  369. selectedRowKeys: []
  370. })
  371. this.loadData();
  372. },
  373. // 重置
  374. reset() {
  375. this.setState({
  376. pageNo: 1,
  377. searchValues: JSON.parse(JSON.stringify({})),
  378. }, () => {
  379. this.Cascaders.empty();
  380. this.loadData();
  381. })
  382. },
  383. render() {
  384. const { searchValues, rowData } = this.state
  385. const dataSources = this.state.fjlist || [];
  386. const options = dataSources.map((group) => (
  387. <Select.Option key={group.id} value={group.name}>
  388. {group.name}
  389. </Select.Option>
  390. ));
  391. return (
  392. <div className="user-content">
  393. <ShowModalDiv ShowModal={this.state.showModal} />
  394. <div className="content-title" style={{ marginBottom: 10 }}>
  395. <span style={{ fontWeight: 900, fontSize: 16 }}>我的暂停项目</span>
  396. </div>
  397. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  398. <TabPane tab="搜索" key="1">
  399. <div className="user-search" style={{ marginLeft: 10 }}>
  400. <Input
  401. placeholder="订单编号"
  402. style={{ width: 160 }}
  403. value={searchValues["orderNo"]
  404. ? searchValues["orderNo"]
  405. : ""}
  406. onChange={(e) => {
  407. searchValues["orderNo"] = e.target.value;
  408. this.setState({
  409. searchValues: searchValues,
  410. });
  411. }}
  412. />
  413. <Input
  414. placeholder="客户名称"
  415. style={{ width: 160 }}
  416. value={searchValues["userName"]
  417. ? searchValues["userName"]
  418. : ""}
  419. onChange={(e) => {
  420. searchValues["userName"] = e.target.value;
  421. this.setState({
  422. searchValues: searchValues,
  423. });
  424. }}
  425. />
  426. <Cascaders
  427. ref={node => this.Cascaders = node}
  428. placeholder="订单部门"
  429. id="id"
  430. name="name"
  431. children="list"
  432. height={28}
  433. onSel={(e) => {
  434. searchValues["deps"] = JSON.stringify(e);
  435. this.setState({
  436. searchValues: searchValues,
  437. });
  438. }}
  439. />
  440. <Input
  441. placeholder="合同编号"
  442. style={{ width: 160 }}
  443. value={searchValues["contractNo"]
  444. ? searchValues["contractNo"]
  445. : ""}
  446. onChange={(e) => {
  447. searchValues["contractNo"] = e.target.value;
  448. this.setState({
  449. searchValues: searchValues,
  450. });
  451. }}
  452. />
  453. <Input
  454. placeholder="项目名称"
  455. style={{ width: 160 }}
  456. value={searchValues["projectName"]
  457. ? searchValues["projectName"]
  458. : ""}
  459. onChange={(e) => {
  460. searchValues["projectName"] = e.target.value;
  461. this.setState({
  462. searchValues: searchValues,
  463. });
  464. }}
  465. />
  466. <Select
  467. style={{ width: 120 }}
  468. placeholder="项目暂停状态"
  469. value={searchValues["status"]
  470. ? searchValues["status"]
  471. : undefined}
  472. onChange={(e) => {
  473. searchValues["status"] = e;
  474. this.setState({
  475. searchValues: searchValues,
  476. });
  477. }}
  478. >
  479. <Option value="">全部</Option>
  480. <Option value="0">发起暂停</Option>
  481. <Option value="1">发起重启</Option>
  482. <Option value="2">项目已暂停</Option>
  483. <Option value="3">项目已重启</Option>
  484. <Option value="4">暂停已驳回</Option>
  485. <Option value="5">重启已驳回</Option>
  486. </Select>
  487. <AutoComplete
  488. dropdownMatchSelectWidth={false}
  489. style={{ width: 160 }}
  490. dataSource={options}
  491. placeholder="咨询师/经理"
  492. value={searchValues.aname || undefined}
  493. onChange={this.followUp.bind(this)}
  494. filterOption={true}
  495. onBlur={this.blurChange}
  496. onSelect={this.selectF.bind(this)}
  497. >
  498. <Input />
  499. </AutoComplete>
  500. <RangePicker
  501. style={{ width: 200 }}
  502. value={[
  503. searchValues.startTime
  504. ? moment(searchValues.startTime)
  505. : null,
  506. searchValues.endTime ? moment(searchValues.endTime) : null,
  507. ]}
  508. onChange={(data, dataString) => {
  509. this.setState({
  510. searchValues: Object.assign(searchValues, {
  511. startTime: dataString[0],
  512. endTime: dataString[1],
  513. }),
  514. });
  515. }}
  516. />
  517. <Button
  518. type="primary"
  519. onClick={this.search}
  520. style={{ marginLeft: 10 }}
  521. disabled={this.state.loading ? true : false}
  522. >
  523. 搜索
  524. </Button>
  525. <Button onClick={this.reset}>重置</Button>
  526. </div>
  527. </TabPane>
  528. <TabPane tab="更改表格显示数据" key="2">
  529. <div style={{ marginLeft: 10 }}>
  530. <ChooseList
  531. columns={this.state.columns}
  532. changeFn={this.changeList}
  533. changeList={this.state.changeList}
  534. top={55}
  535. margin={11}
  536. />
  537. </div>
  538. </TabPane>
  539. <TabPane tab="导出Excel" key="3">
  540. <Button
  541. type="primary"
  542. style={{ margin: "11px 0px 10px 10px" }}
  543. onClick={this.exportAll}
  544. >
  545. 导出当前列表
  546. </Button>
  547. </TabPane>
  548. </Tabs>
  549. <div className="patent-table">
  550. <Spin spinning={this.state.loading}>
  551. <Table
  552. bordered
  553. columns={
  554. this.state.changeList == undefined
  555. ? this.state.columns
  556. : this.state.changeList
  557. }
  558. dataSource={this.state.dataSource}
  559. pagination={this.state.pagination}
  560. onRowDoubleClick={this.tableRowClick.bind(this)}
  561. size="small"
  562. />
  563. </Spin>
  564. </div>
  565. <textarea id="copyText" style={{ opacity: 0 }} />
  566. {
  567. // 项目详情
  568. this.state.visible &&
  569. <MySuspend
  570. type={this.state.type}
  571. title={!this.state.title
  572. ? (rowData.stopType == 0 ? "项目暂停" : "项目重启")
  573. : this.state.title}
  574. contractNo={rowData.contractNo}
  575. orderNo={rowData.orderNo}
  576. userName={rowData.userName}
  577. reason={rowData.reason}
  578. annexUrl={rowData.annexUrl}
  579. rowData={rowData}
  580. selectedRowKeys={[rowData.tid]}//项目发起id
  581. again={this.state.again} //是否为驳回重新发起
  582. selectedRows={[{ "commodityName": rowData.projectName, "id": rowData.tid }]}
  583. visible={this.state.visible}
  584. subClose={() => {
  585. this.loadData(this.state.pageNo);
  586. this.setState({
  587. visible: false,
  588. again: false,
  589. rowData: {},
  590. type: "",
  591. title: "",
  592. })
  593. }}
  594. />
  595. }
  596. </div>
  597. );
  598. },
  599. });
  600. export default MySuspendList;