score.jsx 13 KB

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