mysuspend.jsx 17 KB

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