limit.jsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import moment from "moment";
  4. import {
  5. Button,
  6. Form,
  7. Input,
  8. Spin,
  9. Table,
  10. Select,
  11. message,
  12. Tabs,
  13. DatePicker,
  14. AutoComplete,
  15. Modal,
  16. Tooltip,
  17. Tag,
  18. } from "antd";
  19. import { ChooseList } from "../../../order/orderNew/chooseList";
  20. import { ShowModal, } from "@/tools.js"
  21. import { accountType, accountStatus } from "@/dataDic";
  22. import ZhuanjiaoDetail from "@/zhuanjiaoDetail.jsx";
  23. import IntentionDetail from "./intentionDetail/intentionDetail";
  24. import ShowModalDiv from "@/showModal.jsx";
  25. import FollowDetail from "./followDetail"
  26. import './limit.less';
  27. const FormItem = Form.Item;
  28. const { RangePicker } = DatePicker;
  29. const { TabPane } = Tabs;
  30. const LimitedProject = React.createClass({
  31. getInitialState() {
  32. return {
  33. searchValues: {
  34. type: ''
  35. }, // 列表筛选条件
  36. loading: false, //加载动画
  37. changeList: undefined, // 更改后的表格显示数据
  38. dataSource: [], // 列表数据
  39. pagination: {
  40. defaultCurrent: 1,
  41. defaultPageSize: 10,
  42. showQuickJumper: true,
  43. pageSize: 10,
  44. onChange: function (page) {
  45. this.loadData(page);
  46. }.bind(this),
  47. showTotal: function (total) {
  48. return "共" + total + "条数据";
  49. },
  50. },
  51. columns: [
  52. {
  53. title: "客户名称",
  54. dataIndex: "name",
  55. key: "name",
  56. width: 300,
  57. render: (text, record) => {
  58. return (
  59. <span>
  60. <span>{text}</span>
  61. </span>
  62. );
  63. },
  64. },
  65. {
  66. title: "限定项目名称",
  67. dataIndex: "projectName",
  68. key: "projectName",
  69. render: (text, record) => {
  70. return (
  71. <div>
  72. {text}
  73. </div>
  74. );
  75. },
  76. },
  77. {
  78. title: "项目状态",
  79. dataIndex: "type",
  80. key: "type",
  81. render: (text, record) => {
  82. return (
  83. <div>
  84. {['公共', '私有', '签单'][text]}
  85. </div>
  86. );
  87. },
  88. },
  89. {
  90. title: "客户所属",
  91. dataIndex: "userAdmin",
  92. key: "userAdmin",
  93. render: (text, record) => {
  94. return (
  95. <div>
  96. {text}
  97. </div>
  98. );
  99. },
  100. },
  101. {
  102. title: "项目所属",
  103. dataIndex: "adminName",
  104. key: "adminName",
  105. render: (text, record) => {
  106. return (
  107. <div>
  108. {text}
  109. </div>
  110. );
  111. },
  112. },
  113. // {
  114. // title: "项目初始时间",
  115. // dataIndex: "lockTime",
  116. // key: "lockTime",
  117. // render: (text, record) => {
  118. // return (
  119. // <div>
  120. // {text}
  121. // </div>
  122. // );
  123. // },
  124. // },
  125. {
  126. title: "剩余私有天数",
  127. dataIndex: "privateDays",
  128. key: "privateDays",
  129. render: (text, record) => {
  130. return (
  131. <div>
  132. {record.type == 1
  133. ? text : record.type == 2
  134. ? record.signDays : ""}
  135. </div>
  136. );
  137. },
  138. },
  139. {
  140. title: "最新跟进时间",
  141. dataIndex: "lockTime",
  142. key: "lockTime",
  143. render: (text, record) => {
  144. return (
  145. <div>
  146. {text}
  147. </div>
  148. );
  149. },
  150. },
  151. {
  152. title: "操作",
  153. dataIndex: "op",
  154. key: "op",
  155. render: (text, record) => {
  156. return (
  157. <div>
  158. <Button
  159. style={{ marginLeft: 10 }}
  160. type="primary"
  161. onClick={(e) => {
  162. e.stopPropagation();
  163. let obj = {
  164. id: record.id
  165. }
  166. this.setState({
  167. visitModuls: true,
  168. followData: obj,
  169. RowData: record,
  170. })
  171. }}
  172. >
  173. 跟进限定项目
  174. </Button>
  175. </div>
  176. );
  177. },
  178. },
  179. ],
  180. customerArr: [],
  181. selectedRowKeys: [],
  182. zhuanjiaoVisible: false,
  183. categoryArr: [],
  184. followData:{}
  185. };
  186. },
  187. componentWillMount() {
  188. this.loadData();
  189. this.category();
  190. },
  191. // 列表接口
  192. loadData(pageNo) {
  193. const { searchValues, pagination } = this.state;
  194. this.setState({
  195. loading: true,
  196. });
  197. let datas = Object.assign(searchValues, {
  198. pageNo: pageNo || 1,
  199. pageSize: pagination.pageSize,
  200. });
  201. $.ajax({
  202. method: "get",
  203. dataType: "json",
  204. crossDomain: false,
  205. url: globalConfig.context + "/api/restrict/Project/pageList",
  206. data: datas,
  207. success: function (data) {
  208. ShowModal(this);
  209. this.setState({
  210. loading: false,
  211. });
  212. let theArr = [];
  213. if (data.error && data.error.length === 0) {
  214. if (data.data) {
  215. pagination.current = data.data.pageNo;
  216. pagination.total = data.data.totalCount;
  217. if (data.data && data.data.list && !data.data.list.length) {
  218. pagination.current = 0
  219. pagination.total = 0
  220. };
  221. for (var i = 0; i < data.data.list.length; i++) {
  222. let thisdata = data.data.list[i];
  223. let diqu =
  224. (thisdata.province == null ? "" : thisdata.province) +
  225. (thisdata.city == null ? "" : "-" + thisdata.city) +
  226. (thisdata.area == null ? "" : "-" + thisdata.area);
  227. thisdata.opId = thisdata.id;
  228. thisdata.id = thisdata.uid;
  229. thisdata.locationProvince = diqu;
  230. theArr.push(thisdata);
  231. }
  232. this.setState({
  233. dataSource: theArr,
  234. pagination: this.state.pagination,
  235. pageNo: data.data.pageNo,
  236. });
  237. }
  238. } else {
  239. message.warning(data.error[0].message);
  240. }
  241. }.bind(this),
  242. }).always(
  243. function () {
  244. this.setState({
  245. loading: false,
  246. });
  247. }.bind(this)
  248. );
  249. },
  250. // 搜索
  251. search() {
  252. this.loadData();
  253. },
  254. // 重置
  255. reset() {
  256. this.setState({
  257. searchValues: {
  258. type: ''
  259. },
  260. }, () => {
  261. this.loadData();
  262. })
  263. },
  264. changeList(arr) {
  265. const newArr = [];
  266. this.state.columns.forEach((item) => {
  267. arr.forEach((val) => {
  268. if (val === item.title) {
  269. newArr.push(item);
  270. }
  271. });
  272. });
  273. this.setState({
  274. changeList: newArr,
  275. });
  276. },
  277. supervisor(e) {
  278. $.ajax({
  279. method: "get",
  280. dataType: "json",
  281. crossDomain: false,
  282. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  283. data: {
  284. adminName: e,
  285. },
  286. success: function (data) {
  287. let thedata = data.data;
  288. if (!thedata) {
  289. if (data.error && data.error.length) {
  290. message.warning(data.error[0].message);
  291. }
  292. thedata = {};
  293. }
  294. this.setState({
  295. customerArr: thedata,
  296. });
  297. }.bind(this),
  298. }).always(
  299. function () {
  300. this.setState({
  301. loading: false,
  302. });
  303. }.bind(this)
  304. );
  305. },
  306. selectAuto(value, options) {
  307. this.setState({
  308. auto: value,
  309. });
  310. },
  311. blurChange(e) {
  312. let theType = "";
  313. let contactLists = this.state.customerArr || [];
  314. if (e) {
  315. contactLists.map(function (item) {
  316. if (item.name == e.toString()) {
  317. theType = item.id;
  318. }
  319. });
  320. }
  321. this.setState({
  322. theTypes: theType,
  323. });
  324. },
  325. httpChange(e) {
  326. if (e.length >= 1) {
  327. this.supervisor(e);
  328. }
  329. this.setState({
  330. auto: e,
  331. });
  332. },
  333. showConfirm() {
  334. let _this = this;
  335. Modal.confirm({
  336. title: "提示",
  337. content: (
  338. <span style={{ color: "red" }}>
  339. 确定要转交以下项目吗?
  340. {this.state.selectedRows.map((value, index) => (
  341. <div key={index} style={{ marginTop: "5px", color: "#000" }}>
  342. {value.projectName}
  343. </div>
  344. ))}
  345. </span>
  346. ),
  347. onOk() {
  348. _this.changeAssigner(1)
  349. },
  350. onCancel() { },
  351. });
  352. },
  353. showConfirms() {
  354. let _this = this;
  355. Modal.confirm({
  356. title: "您确定将以下项目移至公共项目吗?",
  357. content: (
  358. <span style={{ color: "red" }}>
  359. 移除后,以下项目将被别人领取!
  360. {this.state.selectedRows.map((value, index) => (
  361. <div key={index} style={{ marginTop: "5px", color: "#000" }}>
  362. {value.projectName}
  363. </div>
  364. ))}
  365. </span>
  366. ),
  367. onOk() {
  368. _this.changeAssigner(0);
  369. },
  370. onCancel() { },
  371. });
  372. },
  373. changeAssigner(type) {
  374. const _this = this;
  375. if (type == 1 && !this.state.theTypes) {
  376. message.warning("请输入转交人姓名");
  377. return
  378. }
  379. let changeIds = "";
  380. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  381. let rowItem = this.state.selectedRows[idx];
  382. if (rowItem.opId) {
  383. changeIds =
  384. this.state.selectedRows.length - 1 === idx
  385. ? changeIds + rowItem.opId
  386. : changeIds + rowItem.opId + ",";
  387. }
  388. }
  389. let loading = message.loading("加载中...");
  390. $.ajax({
  391. method: "post",
  392. dataType: "json",
  393. crossDomain: false,
  394. url: globalConfig.context + "/api/restrict/Project/update",
  395. data: {
  396. id: changeIds,
  397. type,
  398. takeAid: type == 1 ? this.state.theTypes : undefined,
  399. },
  400. }).done(
  401. function (data) {
  402. loading();
  403. this.setState({
  404. selList: [],
  405. })
  406. if (!data.error.length) {
  407. this.setState({
  408. auto: "",
  409. loading: false,
  410. selectedRowKeys: [],
  411. });
  412. if (data.data == 1) {
  413. message.success(type == 1 ? "转交成功!" : "移除成功!");
  414. _this.loadData();
  415. } else {
  416. data.data.forEach(function (e) { message.warning(e) })
  417. }
  418. } else {
  419. message.warning(data.error[0].message);
  420. }
  421. }.bind(this)
  422. );
  423. },
  424. zhuanjiaoDetail(record) {
  425. this.setState({
  426. zhuanjiaoVisible: true,
  427. zhuanjiaoId: record.id,
  428. });
  429. },
  430. zhuanjiaoDetailCancel() {
  431. this.setState({
  432. zhuanjiaoVisible: false,
  433. });
  434. },
  435. tableRowClick(record, index) {
  436. this.state.visitModul = false;
  437. this.setState({
  438. // selectedRowKeys: [],
  439. modalVisible: true,
  440. basicState: true,
  441. contactState: true,
  442. modalName: record.name,
  443. RowData: record,
  444. });
  445. },
  446. closeDesc(e, s) {
  447. this.state.basicState = e;
  448. this.state.visitModul = e;
  449. this.state.modalVisible = e;
  450. this.state.visitModuls = e;
  451. this.state.showDesc = e;
  452. this.setState({
  453. tabsKey: "",
  454. });
  455. if (s) {
  456. this.loadData(this.state.ispage);
  457. }
  458. },
  459. //品类数据获取
  460. category() {
  461. $.ajax({
  462. method: "get",
  463. dataType: "json",
  464. crossDomain: false,
  465. url: globalConfig.context + "/api/admin/Varieties/getSuperList",
  466. data: {},
  467. success: function (data) {
  468. let thedata = data.data;
  469. let theArr = [];
  470. if (!thedata) {
  471. if (data.error && data.error.length) {
  472. message.warning(data.error[0].message);
  473. }
  474. } else {
  475. thedata.map(function (item, index) {
  476. theArr.push({
  477. value: item.id,
  478. key: item.cname,
  479. });
  480. });
  481. }
  482. this.setState({
  483. categoryArr: theArr,
  484. });
  485. }.bind(this),
  486. });
  487. },
  488. //查看跟进记录列表
  489. loadVisit(pageNo) {
  490. this.setState({
  491. loading: true
  492. });
  493. $.ajax({
  494. method: "get",
  495. dataType: "json",
  496. crossDomain: false,
  497. url: globalConfig.context + '/api/admin/customer/listFollowHistory',
  498. data: {
  499. pageNo: pageNo || 1,
  500. pageSize: this.state.paginations.pageSize,
  501. uid: this.state.RowData.id, //名称1
  502. },
  503. success: function (data) {
  504. let theArr = [];
  505. if (data.error.length || data.data.list == "") {
  506. if (data.error && data.error.length) {
  507. message.warning(data.error[0].message);
  508. };
  509. } else {
  510. for (let i = 0; i < data.data.list.length; i++) {
  511. let thisdata = data.data.list[i];
  512. theArr.push(thisdata);
  513. };
  514. this.state.paginations.current = data.data.pageNo;
  515. this.state.paginations.total = data.data.totalCount;
  516. this.setState({
  517. ispage: data.data.pageNo
  518. })
  519. };
  520. if (data.data.list && !data.data.list.length) {
  521. this.state.paginations.current = 0;
  522. this.state.paginations.total = 0;
  523. };
  524. this.setState({
  525. visitArrList: theArr,
  526. paginations: this.state.paginations
  527. });
  528. }.bind(this),
  529. }).always(function () {
  530. this.setState({
  531. loading: false
  532. });
  533. }.bind(this));
  534. },
  535. render() {
  536. const { searchValues, } = this.state
  537. const rowSelection = {
  538. hideDefaultSelections: true,
  539. selectedRowKeys: this.state.selectedRowKeys,
  540. onChange: (selectedRowKeys, selectedRows) => {
  541. this.setState({
  542. modalVisible: false,
  543. selectedRows: selectedRows,
  544. selectedRowKeys: selectedRowKeys,
  545. });
  546. },
  547. onSelect: (recordt, selected, selectedRows) => {
  548. this.setState({
  549. modalVisible: false,
  550. recordt: recordt.opId,
  551. });
  552. },
  553. };
  554. const hasSelected = this.state.selectedRowKeys.length > 0;
  555. const dataSources = this.state.customerArr || [];
  556. const options = dataSources.map((group) => (
  557. <Select.Option key={group.id} value={group.name}>
  558. {group.name}
  559. </Select.Option>
  560. ));
  561. return (
  562. <div className="user-content">
  563. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  564. <div className="content-title" style={{ marginBottom: 10 }}>
  565. <span style={{ fontWeight: 900, fontSize: 16 }}>限定项目</span>
  566. </div>
  567. <Tabs defaultActiveKey="1" className="test">
  568. <TabPane tab="搜索" key="1">
  569. <div className="user-search" style={{ marginLeft: 10 }}>
  570. <Input
  571. placeholder="客户名称"
  572. value={searchValues["userName"]
  573. ? searchValues["userName"]
  574. : ""}
  575. onChange={(e) => {
  576. searchValues["userName"] = e.target.value;
  577. this.setState({
  578. searchValues: searchValues,
  579. });
  580. }}
  581. />
  582. <Input
  583. placeholder="请输入限定项目全称"
  584. value={searchValues["projectName"]
  585. ? searchValues["projectName"]
  586. : ""}
  587. onChange={(e) => {
  588. searchValues["projectName"] = e.target.value;
  589. this.setState({
  590. searchValues: searchValues,
  591. });
  592. }}
  593. />
  594. <Select
  595. style={{ width: 140 }}
  596. placeholder=""
  597. value={searchValues["type"]}
  598. onChange={(e) => {
  599. searchValues["type"] = e;
  600. this.setState({
  601. searchValues: searchValues,
  602. });
  603. }}
  604. >
  605. <Option value="">全部</Option>
  606. <Option value="1">私有</Option>
  607. <Option value="2">已签</Option>
  608. </Select>
  609. <span>时间:</span>
  610. <RangePicker
  611. style={{ width: 300 }}
  612. value={[
  613. searchValues.startTime ? moment(searchValues.startTime) : null,
  614. searchValues.endTime ? moment(searchValues.endTime) : null,
  615. ]}
  616. onChange={(data, dataString) => {
  617. this.setState({
  618. searchValues: Object.assign(searchValues, {
  619. startTime: dataString[0],
  620. endTime: dataString[1],
  621. }),
  622. });
  623. }}
  624. />
  625. <Button
  626. type="primary"
  627. onClick={this.search}
  628. style={{ margin: "0 10px" }}
  629. >搜索</Button>
  630. <Button onClick={this.reset}>重置</Button>
  631. </div>
  632. </TabPane>
  633. <TabPane tab="操作" key="2">
  634. <div className="user-search" style={{ marginLeft: 10 }}>
  635. <AutoComplete
  636. className="certain-category-search"
  637. dropdownClassName="certain-category-search-dropdown"
  638. dropdownMatchSelectWidth={false}
  639. style={{ width: "120px" }}
  640. dataSource={options}
  641. placeholder="输入转交人姓名"
  642. value={this.state.auto}
  643. onChange={this.httpChange}
  644. filterOption={true}
  645. onBlur={this.blurChange}
  646. onSelect={this.selectAuto}
  647. disabled={!hasSelected}
  648. >
  649. <Input />
  650. </AutoComplete>
  651. <Button
  652. type="primary"
  653. onClick={(e) => {
  654. e.stopPropagation();
  655. this.showConfirm();
  656. }}
  657. disabled={!hasSelected}
  658. style={{ marginRight: 10 }}
  659. >
  660. 转交
  661. </Button>
  662. <Button
  663. style={{ marginLeft: 10 }}
  664. onClick={(e) => {
  665. e.stopPropagation();
  666. this.showConfirms();
  667. }}
  668. type="primary"
  669. disabled={!hasSelected}
  670. >
  671. 移除项目
  672. </Button>
  673. <Button
  674. style={{ marginLeft: 10 }}
  675. onClick={(e) => {
  676. e.stopPropagation();
  677. this.zhuanjiaoDetail(this.state.selectedRows[0]);
  678. }}
  679. type="primary"
  680. disabled={!hasSelected || this.state.selectedRows.length > 1}
  681. >
  682. 项目日志
  683. </Button>
  684. </div>
  685. </TabPane>
  686. <TabPane tab="更改表格显示数据" key="3">
  687. <div style={{ marginLeft: 10 }}>
  688. <ChooseList
  689. columns={this.state.columns}
  690. changeFn={this.changeList}
  691. changeList={this.state.changeList}
  692. top={55}
  693. margin={11}
  694. />
  695. </div>
  696. </TabPane>
  697. </Tabs>
  698. <div className="patent-table">
  699. <Spin spinning={this.state.loading}>
  700. <Table
  701. size="middle"
  702. bordered
  703. columns={
  704. this.state.changeList == undefined
  705. ? this.state.columns
  706. : this.state.changeList
  707. }
  708. dataSource={this.state.dataSource}
  709. rowSelection={rowSelection}
  710. pagination={this.state.pagination}
  711. onRowDoubleClick={this.tableRowClick}
  712. />
  713. </Spin>
  714. </div>
  715. {
  716. this.state.zhuanjiaoVisible &&
  717. <ZhuanjiaoDetail
  718. cancel={this.zhuanjiaoDetailCancel}
  719. visible={this.state.zhuanjiaoVisible}
  720. id={this.state.zhuanjiaoId}
  721. />
  722. }
  723. {
  724. this.state.modalVisible &&
  725. <IntentionDetail
  726. isLimit={true}
  727. isCustomerAdmin={true}
  728. tabsKey={this.state.tabsKey}
  729. categoryArr={this.state.categoryArr}
  730. detailApi={'/api/admin/customer/findOrganizationCustomerDetail'}
  731. IntentionData={this.state.RowData}
  732. modalVisible={this.state.modalVisible}
  733. name={this.state.modalName}
  734. closeDesc={this.closeDesc}
  735. basicState={this.state.basicState}
  736. contactState={this.state.contactState}
  737. />
  738. }
  739. {
  740. <FollowDetail
  741. isLimit={true}
  742. details={this.state.RowData}
  743. categoryArr={this.state.categoryArr}
  744. followData={this.state.followData}
  745. visitModul={this.state.visitModuls}
  746. closeDesc={this.closeDesc}
  747. loadData={this.loadVisit}
  748. />
  749. }
  750. </div>
  751. );
  752. },
  753. });
  754. export default LimitedProject;