mysuspend.jsx 18 KB

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