score.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. import React from 'react';
  2. import {
  3. DatePicker,
  4. Tooltip,
  5. Button,
  6. Input,
  7. Select,
  8. Spin,
  9. Table,
  10. message,
  11. Form,
  12. Tabs,
  13. } from 'antd';
  14. import $ from 'jquery/src/ajax';
  15. import moment from 'moment';
  16. import { ShowModal, } from "@/tools.js";
  17. import { station } from "@/dataDic";
  18. import ShowModalDiv from "@/showModal.jsx";
  19. import { ChooseList } from "../../order/orderNew/chooseList";
  20. const TabPane = Tabs.TabPane;
  21. const ProjecScore = Form.create()(React.createClass({
  22. getInitialState() {
  23. return {
  24. searchValues: {},
  25. loading: false,
  26. exportPendingLoading: false,
  27. changeList: undefined,
  28. dataSource: [],
  29. pagination: {
  30. defaultCurrent: 1,
  31. defaultPageSize: 10,
  32. showQuickJumper: true,
  33. pageSize: 10,
  34. onChange: function (page) {
  35. this.loadData(page);
  36. }.bind(this),
  37. showTotal: function (total) {
  38. return '共' + total + '条数据';
  39. }
  40. },
  41. columns: [
  42. {
  43. title: "用户姓名",
  44. dataIndex: "name",
  45. key: "name",
  46. },
  47. {
  48. title: "高新&科技评分",
  49. dataIndex: "htSatScoreAverage",
  50. key: "htSatScoreAverage",
  51. render: (text, record) => {
  52. return (
  53. <div>{text}分</div>
  54. )
  55. },
  56. },
  57. {
  58. title: '会员评分',
  59. dataIndex: 'memberScoreAverage',
  60. key: 'memberScoreAverage',
  61. render: (text, record) => {
  62. return (
  63. <div>{text}分</div>
  64. )
  65. },
  66. },
  67. {
  68. title: "高新&科技总数/待评/已评",
  69. dataIndex: "htSatCount",
  70. key: "htSatCount",
  71. render: (text, record) => {
  72. return (
  73. <div>{text + " / " + record.htSatNotScoreCount + " / " + record.htSatScoreCount}</div>
  74. )
  75. },
  76. },
  77. {
  78. title: "会员总数/待评/已评",
  79. dataIndex: "memberCount",
  80. key: "memberCount",
  81. render: (text, record) => {
  82. return (
  83. <div>{text + " / " + record.memberNotScoreCount + " / " + record.memberScoreCount}</div>
  84. )
  85. },
  86. },
  87. {
  88. title: '部门',
  89. dataIndex: 'depName',
  90. key: 'depName',
  91. },
  92. {
  93. title: "上级主管姓名",
  94. dataIndex: "superName",
  95. key: "superName",
  96. },
  97. {
  98. title: "状态",
  99. dataIndex: "status",
  100. key: "status",
  101. render: (text, record) => {
  102. return (
  103. <div style={{ color: ["green", "red"][text] }}>{["正常", "锁定"][text]}</div>
  104. )
  105. }
  106. },
  107. {
  108. title: '最后登录时间',
  109. dataIndex: 'lastLoginTime',
  110. key: 'lastLoginTime',
  111. },
  112. ],
  113. dataSource: [],
  114. departmentArr: [],
  115. roleArr: [],
  116. };
  117. },
  118. componentWillMount() {
  119. this.departmentList();
  120. this.rolesList();
  121. },
  122. loadData(pageNo) {
  123. const { searchValues, pagination } = this.state;
  124. this.setState({
  125. loading: true,
  126. });
  127. let datas = Object.assign(searchValues, {
  128. pageNo: pageNo || 1,
  129. pageSize: pagination.pageSize,
  130. });
  131. $.ajax({
  132. method: "get",
  133. dataType: "json",
  134. crossDomain: false,
  135. url: globalConfig.context + "/api/admin/taskScore/list",
  136. data: datas,
  137. success: function (data) {
  138. ShowModal(this);
  139. this.setState({
  140. loading: false,
  141. });
  142. if (data.error && data.error.length === 0) {
  143. if (data.data.list) {
  144. pagination.current = data.data.pageNo;
  145. pagination.total = data.data.totalCount;
  146. if (data.data && data.data.list && !data.data.list.length) {
  147. pagination.current = 0;
  148. pagination.total = 0;
  149. }
  150. this.setState({
  151. dataSource: data.data.list,
  152. pagination: this.state.pagination,
  153. pageNo: data.data.pageNo,
  154. });
  155. } else {
  156. this.setState({
  157. dataSource: data.data,
  158. pagination: false,
  159. });
  160. }
  161. } else {
  162. message.warning(data.error[0].message);
  163. }
  164. }.bind(this),
  165. }).always(
  166. function () {
  167. this.setState({
  168. loading: false,
  169. });
  170. }.bind(this)
  171. );
  172. },
  173. // 部门
  174. departmentList() {
  175. const { searchValues } = this.state
  176. this.setState({
  177. loading: true,
  178. });
  179. $.ajax({
  180. method: "get",
  181. dataType: "json",
  182. crossDomain: false,
  183. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  184. data: {},
  185. success: function (data) {
  186. let thedata = data.data;
  187. let theArr = [];
  188. if (!thedata) {
  189. if (data.error && data.error.length) {
  190. message.warning(data.error[0].message);
  191. }
  192. thedata = {};
  193. } else {
  194. thedata.map(function (item, index) {
  195. theArr.push({
  196. key: index,
  197. name: item.name,
  198. id: item.id,
  199. });
  200. if (item.name == "科德-研发服务事业部") {
  201. searchValues["depId"] = item.id
  202. }
  203. });
  204. }
  205. this.setState({
  206. departmentArr: theArr,
  207. searchValues: searchValues,
  208. }, () => {
  209. this.loadData();
  210. });
  211. }.bind(this),
  212. }).always(
  213. function () {
  214. this.setState({
  215. loading: false,
  216. });
  217. }.bind(this)
  218. );
  219. },
  220. //角色
  221. rolesList() {
  222. this.setState({
  223. loading: true
  224. });
  225. $.ajax({
  226. method: "get",
  227. dataType: "json",
  228. crossDomain: false,
  229. url: globalConfig.context + "/api/roles",
  230. data: {
  231. },
  232. success: function (data) {
  233. let thedata = data.data;
  234. let theArr = [];
  235. if (!thedata) {
  236. if (data.error && data.error.length) {
  237. message.warning(data.error[0].message);
  238. };
  239. thedata = {};
  240. } else {
  241. thedata.map(function (item, index) {
  242. theArr.push({
  243. key: index,
  244. roleName: item.roleName,
  245. id: item.id,
  246. })
  247. })
  248. }
  249. this.setState({
  250. roleArr: theArr,
  251. })
  252. }.bind(this),
  253. }).always(function () {
  254. this.setState({
  255. loading: false
  256. });
  257. }.bind(this));
  258. },
  259. changeList(arr) {
  260. const newArr = [];
  261. let list = this.state.columns
  262. list.forEach((item) => {
  263. arr.forEach((val) => {
  264. if (val === item.title) {
  265. newArr.push(item);
  266. }
  267. });
  268. });
  269. this.setState({
  270. changeList: newArr,
  271. });
  272. },
  273. exportAll() {
  274. message.config({
  275. duration: 20,
  276. });
  277. let loading = message.loading("下载中...");
  278. this.setState({
  279. exportPendingLoading: true,
  280. });
  281. let data = JSON.parse(JSON.stringify(this.state.searchValues));
  282. $.ajax({
  283. method: "get",
  284. dataType: "json",
  285. crossDomain: false,
  286. url: "/api/admin/taskScore/list/export",
  287. data,
  288. success: function (data) {
  289. if (data.error.length === 0) {
  290. this.download(data.data);
  291. } else {
  292. message.warning(data.error[0].message);
  293. }
  294. }.bind(this),
  295. }).always(
  296. function () {
  297. loading();
  298. this.setState({
  299. exportPendingLoading: false,
  300. });
  301. }.bind(this)
  302. );
  303. },
  304. download(fileName) {
  305. window.location.href =
  306. globalConfig.context + "/open/download?fileName=" + fileName;
  307. },
  308. search() {
  309. this.loadData();
  310. },
  311. reset() {
  312. this.setState({
  313. searchValues: JSON.parse(JSON.stringify({})),
  314. }, () => {
  315. this.loadData();
  316. })
  317. },
  318. render() {
  319. const { searchValues, roleArr } = this.state
  320. let departmentArr = this.state.departmentArr || [];
  321. return (
  322. <div className="user-content">
  323. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  324. <div className="content-title" style={{ marginBottom: 10 }}>
  325. <span style={{ fontWeight: 900, fontSize: 16 }}>科德研发服务评价系统</span>
  326. </div>
  327. <div className="user-search">
  328. <Tabs
  329. defaultActiveKey="1"
  330. className="test">
  331. <TabPane tab="搜索" key="1">
  332. <div
  333. className="user-search"
  334. style={{
  335. marginTop: "10px",
  336. marginLeft: "10px",
  337. marginRight: "10px",
  338. }}
  339. >
  340. <Input
  341. placeholder="用户名称"
  342. style={{
  343. width: 220,
  344. marginRight: "10px",
  345. }}
  346. value={searchValues["name"]
  347. ? searchValues["name"]
  348. : ""}
  349. onChange={(e) => {
  350. searchValues["name"] = e.target.value;
  351. this.setState({
  352. searchValues: searchValues,
  353. });
  354. }}
  355. />
  356. <Select
  357. placeholder="选择负责部门"
  358. style={{ width: 170, }}
  359. value={searchValues["depId"]
  360. ? searchValues["depId"]
  361. : undefined}
  362. onChange={(e) => {
  363. searchValues["depId"] = e
  364. this.setState({
  365. searchValues: searchValues,
  366. });
  367. }}
  368. >
  369. {departmentArr.map(function (item) {
  370. return (
  371. <Select.Option key={item.id}>{item.name}</Select.Option>
  372. );
  373. })}
  374. </Select>
  375. <Select
  376. placeholder="角色"
  377. style={{ width: 180 }}
  378. value={this.state.rolesSearch}
  379. onChange={e => {
  380. this.setState({ rolesSearch: e });
  381. }}
  382. >
  383. {roleArr.map(function (item) {
  384. return (
  385. <Select.Option key={item.id}>
  386. {item.roleName}
  387. </Select.Option>
  388. );
  389. })}
  390. </Select>
  391. <Select
  392. placeholder="岗位"
  393. style={{ width: 100 }}
  394. value={searchValues["position"]
  395. ? searchValues["position"]
  396. : undefined}
  397. onChange={e => {
  398. searchValues["position"] = e
  399. this.setState({
  400. searchValues: searchValues,
  401. });
  402. }}
  403. >
  404. {station.map(function (item) {
  405. return (
  406. <Select.Option key={item.value}>
  407. {item.key}
  408. </Select.Option>
  409. );
  410. })}
  411. </Select>
  412. <Button type="primary" onClick={this.search} style={{ marginRight: 10 }}>
  413. 搜索
  414. </Button>
  415. <Button onClick={this.reset}>重置</Button>
  416. </div>
  417. </TabPane>
  418. <TabPane tab="更改表格显示数据" key="2">
  419. <div style={{ marginLeft: 10 }}>
  420. <ChooseList
  421. columns={this.state.columns}
  422. changeFn={this.changeList}
  423. changeList={this.state.changeList}
  424. top={55}
  425. margin={11}
  426. />
  427. </div>
  428. </TabPane>
  429. <TabPane tab="导出EXCEL" key="3">
  430. <Button
  431. type="primary"
  432. loading={this.state.exportPendingLoading}
  433. onClick={this.exportAll}
  434. style={{ margin: 10 }}
  435. >
  436. 导出excel
  437. </Button>
  438. </TabPane>
  439. </Tabs>
  440. </div>
  441. <div className="patent-table">
  442. <Spin spinning={this.state.loading}>
  443. <Table
  444. columns={this.state.changeList
  445. ? this.state.changeList
  446. : this.state.columns}
  447. dataSource={this.state.dataSource}
  448. pagination={this.state.pagination}
  449. bordered
  450. />
  451. </Spin>
  452. </div>
  453. </div >
  454. );
  455. }
  456. }));
  457. export default ProjecScore;