projecCount.jsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. import React,{ Component } from 'react';
  2. import {AutoComplete, Button, DatePicker, Input, message, Select, Spin, Table, Tabs} from "antd";
  3. import {
  4. ShowModal,
  5. getNewDiccityArr
  6. } from "@/tools";
  7. import { citySelect } from '../../../NewDicProvinceList';
  8. import {ChooseList} from "../../order/orderNew/chooseList";
  9. import $ from "jquery/src/ajax";
  10. import moment from "moment";
  11. import {
  12. highTechColumns,
  13. invention,
  14. utilityModel,
  15. softWriting,
  16. otherTrademarks,
  17. currency,
  18. } from './projecCountConfig';
  19. const {TabPane} = Tabs;
  20. const { RangePicker } = DatePicker;
  21. const { Option } = Select;
  22. class ProjecCount extends Component{
  23. constructor(props) {
  24. super(props);
  25. this.state={
  26. loading:false,
  27. changeList:[],
  28. columns: currency,
  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. dataSource: [],
  42. releaseDate:[],
  43. searchOrderNo: '',
  44. searchContractNo: '',
  45. searchEnterpriseName: '',
  46. declarationBatch: '',
  47. projectType: '',
  48. projectStatus: '',
  49. province: '',
  50. depId: '',
  51. departmentArr:[],
  52. contactsOption: [],
  53. contactsOptionData: [],
  54. customerArr: [],
  55. commodityName: '',
  56. kid: '',
  57. status: 0,
  58. }
  59. this.loadData = this.loadData.bind(this);
  60. this.resetAll = this.resetAll.bind(this);
  61. this.changeList = this.changeList.bind(this);
  62. this.departmentList = this.departmentList.bind(this);
  63. this.exportPending = this.exportPending.bind(this);
  64. this.selectSuperId = this.selectSuperId.bind(this);
  65. this.supervisorCui = this.supervisorCui.bind(this);
  66. this.httpChangeCui = this.httpChangeCui.bind(this);
  67. this.selectAuto = this.selectAuto.bind(this);
  68. }
  69. changeList(arr) {
  70. const newArr = [];
  71. this.state.columns.forEach(item => {
  72. arr.forEach(val => {
  73. if (val === item.title) {
  74. newArr.push(item);
  75. }
  76. });
  77. });
  78. this.setState({
  79. changeList: newArr
  80. });
  81. }
  82. loadData(pageNo) {
  83. this.setState({
  84. page: pageNo,
  85. loading: true
  86. });
  87. $.ajax({
  88. method: "get",
  89. dataType: "json",
  90. crossDomain: false,
  91. url: globalConfig.context + "/api/admin/statistis/selectProvincialStatistics",
  92. data: {
  93. pageNo: pageNo || 1,
  94. pageSize: this.state.pagination.pageSize,
  95. startDate: this.state.releaseDate.length > 0 ? this.state.releaseDate[0]: undefined, //开始时间
  96. endDate: this.state.releaseDate.length > 0 ? this.state.releaseDate[1]: undefined, //结束时间
  97. province: this.state.province || undefined,
  98. projectStatus: this.state.projectStatus || undefined,//项目类别
  99. projectType: typeof this.state.projectType === 'number' ? this.state.projectType : undefined,//项目分类
  100. status: this.state.status,
  101. thchDepId: this.state.depId || undefined,
  102. projectId: this.state.kid || undefined,
  103. },
  104. success: function(data) {
  105. ShowModal(this);
  106. let theArr = [];
  107. if (!data.data || !data.data.list) {
  108. if (data.error && data.error.length) {
  109. message.warning(data.error[0].message);
  110. }
  111. } else {
  112. for (let i = 0; i < data.data.list.length; i++) {
  113. let thisdata = data.data.list[i];
  114. thisdata.key=(data.data.pageNo - 1) * data.data.pageSize + i + 1;
  115. theArr.push(thisdata);
  116. }
  117. }
  118. this.state.pagination.current = data.data.pageNo;
  119. this.state.pagination.total = data.data.totalCount;
  120. if (data.data && data.data.list && !data.data.list.length) {
  121. this.state.pagination.current = 0;
  122. this.state.pagination.total = 0;
  123. }
  124. this.setState({
  125. dataSource: theArr,
  126. pagination: this.state.pagination
  127. });
  128. }.bind(this)
  129. }).always(
  130. function() {
  131. this.setState({
  132. loading: false
  133. });
  134. }.bind(this)
  135. );
  136. }
  137. //部门
  138. departmentList() {
  139. $.ajax({
  140. method: "get",
  141. dataType: "json",
  142. crossDomain: false,
  143. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  144. data: {},
  145. success: function (data) {
  146. let thedata = data.data;
  147. let theArr = [];
  148. if (!thedata) {
  149. if (data.error && data.error.length) {
  150. message.warning(data.error[0].message);
  151. }
  152. } else {
  153. thedata.map(function (item, index) {
  154. theArr.push({
  155. key: index,
  156. name: item.name,
  157. id: item.id,
  158. });
  159. });
  160. }
  161. this.setState({
  162. departmentArr: theArr,
  163. });
  164. }.bind(this),
  165. })
  166. }
  167. resetAll() {
  168. this.setState({
  169. releaseDate: [],
  170. searchOrderNo: '',
  171. searchContractNo: '',
  172. searchEnterpriseName: '',
  173. declarationBatch: '',
  174. province: '',
  175. depId: '',
  176. projectType: '',
  177. projectStatus: '',
  178. columns: currency,
  179. commodityName: '',
  180. kid:'',
  181. status: 0,
  182. },()=>{
  183. this.loadData();
  184. })
  185. }
  186. exportPending() {
  187. let url = `/api/admin/statistis/exporProvincialList?status=${this.state.status}`;
  188. let dep = this.state.departmentArr.filter((e)=> e.id === this.state.depId);//责任部门名称
  189. let option = this.state.contactsOptionData.filter((e)=> e.id === this.state.projectStatus); //项目类别名称
  190. if(dep.length > 0){url = url+`&thchDepName=${dep[0].name}`;}
  191. if(option.length > 0){url = url+`&projectStatusName=${option[0].cname}`;}
  192. if(typeof this.state.projectType === 'number'){url = url+`&projectTypeName=${
  193. this.state.projectType === 0? '通用' :
  194. this.state.projectType === 1? '专利' :
  195. this.state.projectType === 2? '软著' :
  196. this.state.projectType === 3? '审计' :
  197. this.state.projectType === 4? '双软' :
  198. this.state.projectType === 5? '高新' :
  199. this.state.projectType === 6? '商标' :''
  200. }`;}
  201. if(this.state.commodityName){url = url+`&projectName=${this.state.commodityName}`;}
  202. if(this.state.province){url = url+`&provinceName=${getNewDiccityArr(this.state.province)}`;}
  203. let data ={
  204. startDate: this.state.releaseDate.length > 0 ? this.state.releaseDate[0]: undefined, //开始时间
  205. endDate: this.state.releaseDate.length > 0 ? this.state.releaseDate[1]: undefined, //结束时间
  206. thchDepId: this.state.depId || undefined,//责任部门ID
  207. projectStatus: this.state.projectStatus || undefined,//项目类别
  208. projectType: typeof this.state.projectType === 'number' ? this.state.projectType : undefined,//项目分类
  209. province: this.state.province || undefined,
  210. projectId: this.state.kid || undefined,
  211. }
  212. for(let key in data){
  213. if(data[key]){
  214. url = url+`&${key}=${data[key]}`;
  215. }
  216. }
  217. window.open(globalConfig.context +url);
  218. }
  219. //项目类别
  220. selectSuperId() {
  221. $.ajax({
  222. method: "get",
  223. dataType: "json",
  224. crossDomain: false,
  225. url: globalConfig.context + "/api/admin/ProjectSize/getAllCname",
  226. data: {
  227. flag: 0
  228. },
  229. success: function(data) {
  230. let theArr = [];
  231. let thedata = data.data;
  232. if (!thedata) {
  233. if (data.error && data.error.length) {
  234. message.warning(data.error[0].message);
  235. }
  236. }
  237. for (let i = 0; i < data.data.length; i++) {
  238. let theData = data.data[i];
  239. theArr.push(
  240. <Select.Option value={theData.id} key={theData.cname}>
  241. {theData.cname}
  242. </Select.Option>
  243. );
  244. }
  245. this.setState({
  246. contactsOption: theArr,
  247. contactsOptionData: data.data,
  248. });
  249. }.bind(this)
  250. }).always(
  251. );
  252. }
  253. supervisorCui(e) {
  254. //客户名称与服务名称自动补全
  255. let api = "/api/admin/order/getBusinessProjectByName";
  256. $.ajax({
  257. method: "get",
  258. dataType: "json",
  259. crossDomain: false,
  260. url: globalConfig.context + api,
  261. data: {
  262. businessName: e,
  263. },
  264. success: function (data) {
  265. let thedata = data.data;
  266. if (!thedata) {
  267. if (data.error && data.error.length) {
  268. message.warning(data.error[0].message);
  269. }
  270. thedata = {};
  271. }
  272. this.setState({
  273. customerArr: thedata,
  274. });
  275. }.bind(this),
  276. }).always(
  277. function () {
  278. this.setState({
  279. loading: false,
  280. });
  281. }.bind(this)
  282. );
  283. }
  284. httpChangeCui(e) {
  285. if (e.length >= 1) {
  286. this.supervisorCui(e, false);
  287. }
  288. this.setState({
  289. commodityName: e,
  290. });
  291. }
  292. //上级主管输入框失去焦点是判断客户是否存在
  293. selectAuto(value){
  294. let kid=[];
  295. let fwList=this.state.customerArr;
  296. fwList.map(function(item){
  297. if(value===item.bname){
  298. kid=item.id
  299. }
  300. })
  301. this.setState({
  302. kid:kid,
  303. commodityName:value,
  304. })
  305. }
  306. componentWillMount() {
  307. this.loadData();
  308. this.departmentList();
  309. this.selectSuperId();
  310. }
  311. render() {
  312. const dataSources=this.state.customerArr || [];
  313. const options = dataSources.map((group,index) =>
  314. <Select.Option key={index} value={group.bname}>{group.bname}</Select.Option>
  315. )
  316. return (
  317. <div className="user-content">
  318. <div className="content-title">
  319. <span>
  320. 项目统计
  321. (
  322. {
  323. this.state.status === 2 ? '专利' :
  324. this.state.status === 4 ? '软著' :
  325. this.state.status === 1 ? '高新' :
  326. this.state.status === 5 ? '商标' : '通用'
  327. }
  328. )
  329. </span>
  330. </div>
  331. <Tabs defaultActiveKey="1" className="test">
  332. <TabPane tab="搜索" key="1">
  333. <div className="user-search" style={{
  334. marginTop:'10px',
  335. marginLeft:'10px',
  336. marginRight:'10px'
  337. }}>
  338. <span style={{display:"inline-block"}}>
  339. <span style={{marginRight:'10px',marginBottom:'10px'}}>项目类别 :</span>
  340. <Select
  341. value={this.state.projectStatus}
  342. placeholder="请选择项目类别"
  343. notFoundContent="未获取到上级品类列表"
  344. style={{ width: 200,marginRight:'10px',marginBottom:'10px' }}
  345. onChange={(e) => {
  346. let infor = this.state.contactsOptionData.filter((v)=>v.id === e);
  347. this.setState({
  348. projectStatus: e,
  349. },()=>{
  350. if((infor[0].cname === '高新') && typeof this.state.projectType !== 'number'){
  351. this.setState({
  352. columns: highTechColumns,
  353. changeList: [],
  354. status: 1,
  355. },()=>{
  356. this.loadData();
  357. })
  358. }else if (typeof this.state.projectType !== 'number'){
  359. this.setState({
  360. columns: currency,
  361. changeList: [],
  362. status: 0,
  363. },()=>{
  364. this.loadData();
  365. })
  366. }else{
  367. this.loadData();
  368. }
  369. })
  370. }}
  371. >
  372. {this.state.contactsOption}
  373. </Select>
  374. </span>
  375. <span style={{display:"inline-block"}}>
  376. <span style={{marginRight:'10px',marginBottom:'10px'}}>项目分类 :</span>
  377. <Select
  378. value={this.state.projectType}
  379. placeholder="请选择项目分类"
  380. style={{ width: 200,marginRight:'10px',marginBottom:'10px' }}
  381. onChange={(e) => {
  382. this.setState({
  383. columns:
  384. e === 0 ? currency :
  385. e === 1 ? invention :
  386. e === 2 ? softWriting :
  387. e === 3 ? currency :
  388. e === 4 ? currency:
  389. e === 5 ? highTechColumns :
  390. e === 6 ? otherTrademarks :[],
  391. changeList: [],
  392. projectType: e,
  393. status: e === 1 ? 2 : e === 2 ? 4 : e === 5 ? 1 : e === 6 ? 5 : 0, // 0通用 1高新 2发明专利 3实用新型 4软著 5商标
  394. },()=>{
  395. this.loadData();
  396. })
  397. }}
  398. >
  399. <Option value={0}>通用</Option>
  400. <Option value={1}>专利</Option>
  401. <Option value={2}>软著</Option>
  402. <Option value={3}>审计</Option>
  403. <Option value={4}>双软</Option>
  404. <Option value={5}>高新</Option>
  405. <Option value={6}>商标</Option>
  406. </Select>
  407. </span>
  408. {/*<Input*/}
  409. {/* placeholder="订单编号"*/}
  410. {/* style={{ width: "150px",marginRight:'10px',marginBottom:'10px' }}*/}
  411. {/* value={this.state.searchOrderNo}*/}
  412. {/* onChange={e => {*/}
  413. {/* this.setState({ searchOrderNo: e.target.value });*/}
  414. {/* }}*/}
  415. {/*/>*/}
  416. {/*<Input*/}
  417. {/* placeholder="合同编号"*/}
  418. {/* style={{ width: "150px",marginRight:'10px',marginBottom:'10px' }}*/}
  419. {/* value={this.state.searchContractNo}*/}
  420. {/* onChange={e => {*/}
  421. {/* this.setState({ searchContractNo: e.target.value });*/}
  422. {/* }}*/}
  423. {/*/>*/}
  424. {/*<Input*/}
  425. {/* placeholder="企业名称"*/}
  426. {/* style={{ width: "150px",marginRight:'10px',marginBottom:'10px' }}*/}
  427. {/* value={this.state.searchEnterpriseName}*/}
  428. {/* onChange={e => {*/}
  429. {/* this.setState({ searchEnterpriseName: e.target.value });*/}
  430. {/* }}*/}
  431. {/*/>*/}
  432. {/*<span style={{display:"inline-block"}}>*/}
  433. {/* <span style={{marginRight:'10px',marginBottom:'10px'}}>时报批次 :</span>*/}
  434. {/* <Select*/}
  435. {/* value={this.state.declarationBatch}*/}
  436. {/* placeholder="请选择批次"*/}
  437. {/* style={{ width: 200,marginRight:'10px',marginBottom:'10px' }}*/}
  438. {/* onChange={(e) => {*/}
  439. {/* this.setState({*/}
  440. {/* declarationBatch: e,*/}
  441. {/* });*/}
  442. {/* }}*/}
  443. {/* >*/}
  444. {/* <Option value={1}>第一批</Option>*/}
  445. {/* <Option value={2}>第二批</Option>*/}
  446. {/* <Option value={3}>第三批</Option>*/}
  447. {/* <Option value={4}>第四批</Option>*/}
  448. {/* </Select>*/}
  449. {/*</span>*/}
  450. <span style={{display: "inline-block",marginRight:'10px',marginBottom:'10px'}}>
  451. <span>派单省份:</span>
  452. <Select
  453. placeholder="请选择省份"
  454. style={{ width: 200,marginRight:'10px',marginLeft:'10px',marginBottom:'10px' }}
  455. value={getNewDiccityArr(this.state.province)}
  456. onChange={e => {
  457. this.setState({ province: e });
  458. }}
  459. >
  460. {citySelect().map(function(item) {
  461. return (
  462. <Select.Option key={item.value} value={item.value}>{item.label}</Select.Option>
  463. );
  464. })}
  465. </Select>
  466. </span>
  467. <span style={{display: "inline-block",marginRight:'10px',marginBottom:'10px'}}>
  468. <span>项目名称:</span>
  469. <AutoComplete
  470. className="certain-category-search"
  471. dropdownClassName="certain-category-search-dropdown"
  472. dropdownMatchSelectWidth={false}
  473. dropdownStyle={{ width: 200 }}
  474. style={{ width: '200px',marginLeft:'10px' }}
  475. dataSource={options}
  476. placeholder="输入服务名称"
  477. value={this.state.commodityName}
  478. onChange={this.httpChangeCui}
  479. filterOption={true}
  480. onSelect={this.selectAuto}
  481. >
  482. <Input/>
  483. </AutoComplete>
  484. </span>
  485. <span style={{display: "inline-block",marginRight:'10px',marginBottom:'10px'}}>
  486. <span>负责部门:</span>
  487. <Select
  488. placeholder="请选择部门"
  489. style={{ width: 200,marginRight:'10px',marginLeft:'10px',marginBottom:'10px' }}
  490. value={this.state.depId}
  491. onChange={e => {
  492. this.setState({ depId: e });
  493. }}
  494. >
  495. {
  496. this.state.departmentArr.map(function (item) {
  497. return <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
  498. })
  499. }
  500. </Select>
  501. </span>
  502. <span style={{display:"inline-block"}}>
  503. <span style={{marginRight:'10px',marginBottom:'10px'}}>派单时间 :</span>
  504. <RangePicker
  505. style={{marginRight:'10px',marginBottom:'10px'}}
  506. value={[
  507. this.state.releaseDate[0]
  508. ? moment(this.state.releaseDate[0])
  509. : null,
  510. this.state.releaseDate[1]
  511. ? moment(this.state.releaseDate[1])
  512. : null,
  513. ]}
  514. onChange={(data, dataString) => {
  515. this.setState({ releaseDate: dataString });
  516. }}
  517. />
  518. </span>
  519. <Button type="primary" onClick={()=>{
  520. if(this.state.commodityName.length === 0){
  521. this.setState({
  522. kid: ''
  523. },()=>{
  524. this.loadData();
  525. })
  526. }else{
  527. this.loadData();
  528. }
  529. }} style={{marginRight:'10px',marginBottom:'10px'}}>搜索</Button>
  530. <Button onClick={this.resetAll} style={{marginRight:'10px',marginBottom:'10px'}}>重置</Button>
  531. </div>
  532. </TabPane>
  533. <TabPane tab="更改表格显示数据" key="2">
  534. <div style={{ marginLeft: 10 }}>
  535. <ChooseList
  536. columns={this.state.columns}
  537. changeFn={this.changeList}
  538. changeList={this.state.changeList}
  539. top={55}
  540. margin={11}
  541. />
  542. </div>
  543. </TabPane>
  544. <TabPane tab="导出EXCEL" key="3">
  545. <Button type="primary" style={{margin: '10px'}} onClick={this.exportPending}>导出</Button>
  546. </TabPane>
  547. </Tabs>
  548. <div className="patent-table">
  549. <Spin spinning={this.state.loading}>
  550. <Table
  551. bordered
  552. size="middle"
  553. scroll={{ x: 1200, y: 0 }}
  554. columns={
  555. this.state.changeList.length > 0
  556. ? this.state.changeList
  557. : this.state.columns
  558. }
  559. dataSource={this.state.dataSource}
  560. pagination={this.state.pagination}
  561. />
  562. </Spin>
  563. </div>
  564. </div>
  565. )
  566. }
  567. }
  568. export default ProjecCount;