mysuspend.jsx 17 KB

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