publist.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. // 公共渠道列表
  2. import React, { Component } from "react";
  3. import {
  4. Form,
  5. Button,
  6. message,
  7. Spin,
  8. Input,
  9. DatePicker,
  10. Select,
  11. Tabs,
  12. Table,
  13. Modal,
  14. AutoComplete,
  15. } from "antd";
  16. import { ChooseList } from "../../../manageCenter/order/orderNew/chooseList";
  17. import { provinceList } from "../../../NewDicProvinceList";
  18. import $ from "jquery/src/ajax";
  19. import { ShowModal } from "@/tools";
  20. import moment from "moment";
  21. import AddChannel from "./addchannel"; //新增渠道
  22. import ChannelLog from "./channellog"; //转交日志
  23. import ChangeLog from "./changelog"; //更名日志
  24. import ChannelDetail from "./channeldetail"; //渠道详情
  25. import FollowDetail from "../../../../component/manageCenter/customer/NEW/intentionCustomer/followDetail";
  26. import ShowModalDiv from "@/showModal.jsx";
  27. const { TabPane } = Tabs;
  28. const FormItem = Form.Item;
  29. const Option = Select.Option;
  30. const { RangePicker } = DatePicker;
  31. class ChannelUnit extends Component {
  32. constructor(props) {
  33. super(props);
  34. this.state = {
  35. query: { type: 1 },
  36. changeList: undefined,
  37. selectedRowKeys: [],
  38. columns: [
  39. {
  40. title: "渠道名称",
  41. dataIndex: "name",
  42. key: "name",
  43. },
  44. {
  45. title: "地区",
  46. dataIndex: "province",
  47. key: "province",
  48. render: (text, record) => {
  49. return (record.province || "") + " " + (record.city || "") + " " + (record.area || "");
  50. },
  51. },
  52. {
  53. title: "渠道类别",
  54. dataIndex: "type",
  55. key: "type",
  56. width: 200,
  57. render: (text) =>
  58. [
  59. "",
  60. "其他",
  61. "民主党派",
  62. "园区",
  63. "民间组织",
  64. "战略合作单位",
  65. ][text],
  66. },
  67. {
  68. title: "初始时间",
  69. dataIndex: "transferTime",
  70. key: "transferTime",
  71. width: 200,
  72. },
  73. {
  74. title: "操作",
  75. dataIndex: "op",
  76. key: "op",
  77. render: (text, record) => (
  78. <Button
  79. type="primary"
  80. onClick={(e) => {
  81. e.stopPropagation(), this.receive(record);
  82. }}
  83. >
  84. 领取
  85. </Button>
  86. ),
  87. },
  88. ],
  89. dataSource: [],
  90. pagination: {
  91. defaultCurrent: 1,
  92. defaultPageSize: 10,
  93. showQuickJumper: true,
  94. pageSize: 10,
  95. onChange: function (page) {
  96. this.loadData(page);
  97. }.bind(this),
  98. showTotal: function (total) {
  99. return "共" + total + "条数据";
  100. },
  101. },
  102. channeOb: [
  103. { name: "民主党派", val: 2 },
  104. { name: "园区", val: 3 },
  105. { name: "民间组织", val: 4 },
  106. { name: "战略合作单位", val: 5 },
  107. { name: "其他", val: 1 },
  108. ],
  109. fjlist: [], // 查询到的更进人列表
  110. loading: false,
  111. cityList: [],
  112. areaList: [],
  113. searchInfor: {}, // 查询条件
  114. mvisible: "", //控制弹窗变量
  115. };
  116. }
  117. componentWillMount() {
  118. this.loadData();
  119. }
  120. /*单个领取*/
  121. receive(e) {
  122. this.setState({
  123. loading: true,
  124. selectedRowKeys: [],
  125. });
  126. $.ajax({
  127. method: "get",
  128. dataType: "json",
  129. crossDomain: false,
  130. url: globalConfig.context + "/api/admin/customer/receiveCustomer",
  131. data: {
  132. uid: e.id,
  133. },
  134. }).done(
  135. function (data) {
  136. if (!data.error.length) {
  137. message.success("领取成功!");
  138. this.setState({
  139. loading: false,
  140. });
  141. } else {
  142. message.warning(data.error[0].message);
  143. }
  144. this.loadData(this.state.pageNo);
  145. }.bind(this)
  146. );
  147. }
  148. //
  149. getVal(arr, val) {
  150. if (!val || arr.length == 0) {
  151. return undefined;
  152. } else {
  153. for (const items of arr) {
  154. if (items.id == val) {
  155. return items.name;
  156. }
  157. }
  158. }
  159. }
  160. changeList(arr) {
  161. const newArr = [];
  162. this.state.columns.forEach((item) => {
  163. arr.forEach((val) => {
  164. if (val === item.title) {
  165. newArr.push(item);
  166. }
  167. });
  168. });
  169. this.setState({
  170. changeList: newArr,
  171. });
  172. }
  173. // 重置
  174. resetAll() {
  175. this.setState(
  176. {
  177. searchInfor: JSON.parse(JSON.stringify({})),
  178. selectedRowKeys: [],
  179. cityList: [],
  180. areaList: [],
  181. },
  182. () => {
  183. this.loadData();
  184. }
  185. );
  186. }
  187. // 列表接口
  188. loadData(pageNo) {
  189. const { searchInfor, pagination } = this.state;
  190. this.setState({
  191. loading: true,
  192. });
  193. let datas = Object.assign(searchInfor, {
  194. pageNo: pageNo || 1,
  195. pageSize: pagination.pageSize,
  196. });
  197. // delete datas.aname
  198. $.ajax({
  199. method: "get",
  200. dataType: "json",
  201. crossDomain: false,
  202. url: globalConfig.context + "/api/admin/customer/publicChannelUserList",
  203. data: datas,
  204. success: function (data) {
  205. ShowModal(this);
  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. });
  222. } else {
  223. this.setState({
  224. dataSource: data.data,
  225. pagination: false,
  226. });
  227. }
  228. } else {
  229. message.warning(data.error[0].message);
  230. }
  231. }.bind(this),
  232. }).always(
  233. function () {
  234. this.setState({
  235. loading: false,
  236. });
  237. }.bind(this)
  238. );
  239. }
  240. // 选择行
  241. onSelectChange(selectedRowKeys) {
  242. this.setState({ selectedRowKeys });
  243. }
  244. // 关闭弹窗
  245. closeDesc() {
  246. this.setState({
  247. mvisible: "",
  248. });
  249. this.loadData(this.state.pageNo);
  250. }
  251. render() {
  252. const {
  253. columns,
  254. selectedRowKeys,
  255. cityList,
  256. areaList,
  257. changeList,
  258. searchInfor,
  259. channeOb,
  260. dataSource,
  261. } = this.state;
  262. const rowSelection = {
  263. selectedRowKeys,
  264. onChange: this.onSelectChange.bind(this),
  265. hideDefaultSelections: true,
  266. type: "radio",
  267. };
  268. const hasSelected = this.state.selectedRowKeys.length > 0;
  269. return (
  270. <div className="user-content">
  271. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  272. <div className="content-title" style={{ marginBottom: 10 }}>
  273. <span style={{ fontWeight: 900, fontSize: 16 }}>公共渠道列表</span>
  274. </div>
  275. <Tabs defaultActiveKey="1" >
  276. <TabPane tab="搜索" key="1">
  277. <div>
  278. <Form layout="inline">
  279. <FormItem>
  280. <Input
  281. placeholder={"请输入渠道名称"}
  282. value={searchInfor.name || undefined}
  283. onChange={(e) => {
  284. this.setState({
  285. searchInfor: Object.assign(searchInfor, {
  286. name: e.target.value,
  287. }),
  288. });
  289. }}
  290. />
  291. </FormItem>
  292. <FormItem>
  293. <Select
  294. placeholder={"选择省份"}
  295. style={{ width: 100 }}
  296. value={this.getVal(provinceList, searchInfor.province)}
  297. onChange={(e) => {
  298. for (const items of provinceList) {
  299. if (items.id == e) {
  300. this.setState({
  301. cityList: items.cityList,
  302. areaList: [],
  303. searchInfor: Object.assign(searchInfor, {
  304. province: items.id,
  305. city: undefined,
  306. area: undefined,
  307. }),
  308. });
  309. }
  310. }
  311. }}
  312. >
  313. {provinceList.map((item, index) => (
  314. <Option key={item.id}>{item.name}</Option>
  315. ))}
  316. </Select>
  317. </FormItem>
  318. <FormItem>
  319. <Select
  320. placeholder={"选择城市"}
  321. style={{ width: 100 }}
  322. value={this.getVal(cityList, searchInfor.city)}
  323. onChange={(e) => {
  324. for (const items of cityList) {
  325. if (items.id == e) {
  326. this.setState({
  327. areaList: items.areaList,
  328. searchInfor: Object.assign(searchInfor, {
  329. city: items.id,
  330. area: undefined,
  331. }),
  332. });
  333. }
  334. }
  335. }}
  336. >
  337. {cityList.map((cit, cin) => (
  338. <Option key={cit.id}>{cit.name}</Option>
  339. ))}
  340. </Select>
  341. </FormItem>
  342. <FormItem>
  343. <Select
  344. placeholder={"选择地区"}
  345. style={{ width: 100 }}
  346. value={this.getVal(areaList, searchInfor.area)}
  347. onChange={(e) => {
  348. for (const items of areaList) {
  349. if (items.id == e) {
  350. this.setState({
  351. searchInfor: Object.assign(searchInfor, {
  352. area: items.id,
  353. }),
  354. });
  355. }
  356. }
  357. }}
  358. >
  359. {areaList.map((cit, cin) => (
  360. <Option key={cit.id}>{cit.name}</Option>
  361. ))}
  362. </Select>
  363. </FormItem>
  364. <FormItem>
  365. <Select
  366. placeholder={"渠道类型"}
  367. style={{ width: 130 }}
  368. value={searchInfor.type || undefined}
  369. onChange={(e) => {
  370. this.setState({
  371. searchInfor: Object.assign(searchInfor, {
  372. type: e,
  373. }),
  374. });
  375. }}
  376. >
  377. {channeOb.map((it, ins) => (
  378. <Option key={it.val}>{it.name}</Option>
  379. ))}
  380. </Select>
  381. </FormItem>
  382. <FormItem>
  383. <RangePicker
  384. value={[
  385. searchInfor.startDate
  386. ? moment(searchInfor.startDate)
  387. : null,
  388. searchInfor.endDate ? moment(searchInfor.endDate) : null,
  389. ]}
  390. onChange={(data, dataString) => {
  391. this.setState({
  392. searchInfor: Object.assign(searchInfor, {
  393. startDate: dataString[0],
  394. endDate: dataString[1],
  395. }),
  396. });
  397. }}
  398. />
  399. </FormItem>
  400. <Button
  401. type="primary"
  402. onClick={() => {
  403. this.loadData();
  404. }}
  405. style={{ marginRight: "10px" }}
  406. >
  407. 搜索
  408. </Button>
  409. <Button
  410. onClick={this.resetAll.bind(this)}
  411. style={{ marginRight: "10px" }}
  412. >
  413. 重置
  414. </Button>
  415. </Form>
  416. </div>
  417. </TabPane>
  418. <TabPane tab="操作" key="2">
  419. <div
  420. style={{
  421. marginLeft: 10,
  422. paddingBottom: 10,
  423. display: "flex",
  424. }}
  425. >
  426. <div style={{ flex: 1 }}>
  427. <Button
  428. type="primary"
  429. onClick={() => {
  430. this.setState({
  431. mvisible: "channellog",
  432. });
  433. }}
  434. style={{ marginLeft: "10px" }}
  435. disabled={!hasSelected}
  436. >
  437. 渠道日志
  438. </Button>
  439. <Button
  440. type="primary"
  441. onClick={() => {
  442. this.setState({
  443. mvisible: "changelog",
  444. });
  445. }}
  446. style={{ marginLeft: "10px" }}
  447. disabled={!hasSelected}
  448. >
  449. 更改日志
  450. </Button>
  451. </div>
  452. </div>
  453. </TabPane>
  454. <TabPane tab="更改表格显示数据" key="3">
  455. <div style={{ marginLeft: 10 }}>
  456. <ChooseList
  457. columns={columns}
  458. changeFn={this.changeList.bind(this)}
  459. changeList={changeList}
  460. top={55}
  461. margin={11}
  462. />
  463. </div>
  464. </TabPane>
  465. </Tabs>
  466. <div className="patent-table">
  467. <Spin spinning={this.state.loading}>
  468. <Table
  469. bordered
  470. size="middle"
  471. columns={changeList ? changeList : columns}
  472. dataSource={this.state.dataSource}
  473. pagination={this.state.pagination}
  474. rowSelection={rowSelection}
  475. />
  476. </Spin>
  477. </div>
  478. {this.state.mvisible == "channellog" && (
  479. <ChannelLog
  480. cancel={this.closeDesc.bind(this)}
  481. visible={this.state.mvisible}
  482. id={dataSource[selectedRowKeys[0]].id}
  483. />
  484. )}
  485. {this.state.mvisible == "changelog" && (
  486. <ChangeLog
  487. cancel={this.closeDesc.bind(this)}
  488. visible={this.state.mvisible}
  489. id={dataSource[selectedRowKeys[0]].id}
  490. />
  491. )}
  492. </div>
  493. );
  494. }
  495. }
  496. export default ChannelUnit;