projecCount.jsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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",marginRight:'10px',marginBottom:'10px'}}>
  339. <span>项目名称:</span>
  340. <AutoComplete
  341. className="certain-category-search"
  342. dropdownClassName="certain-category-search-dropdown"
  343. dropdownMatchSelectWidth={false}
  344. dropdownStyle={{ width: 200 }}
  345. style={{ width: 100,marginLeft:'10px' }}
  346. dataSource={options}
  347. placeholder="输入服务名称"
  348. value={this.state.commodityName}
  349. onChange={this.httpChangeCui}
  350. filterOption={true}
  351. onSelect={this.selectAuto}
  352. >
  353. <Input/>
  354. </AutoComplete>
  355. </span>
  356. <span style={{display:"inline-block"}}>
  357. <span style={{marginRight:'10px',marginBottom:'10px'}}>项目类别 :</span>
  358. <Select
  359. value={this.state.projectStatus || undefined}
  360. placeholder="请选择项目类别"
  361. notFoundContent="未获取到上级品类列表"
  362. style={{ width: 100,marginRight:'10px',marginBottom:'10px' }}
  363. onChange={(e) => {
  364. let infor = this.state.contactsOptionData.filter((v)=>v.id === e);
  365. this.setState({
  366. projectStatus: e,
  367. },()=>{
  368. if((infor[0].cname === '高新') && typeof this.state.projectType !== 'number'){
  369. this.setState({
  370. columns: highTechColumns,
  371. changeList: [],
  372. status: 1,
  373. },()=>{
  374. this.loadData();
  375. })
  376. }else if (typeof this.state.projectType !== 'number'){
  377. this.setState({
  378. columns: currency,
  379. changeList: [],
  380. status: 0,
  381. },()=>{
  382. this.loadData();
  383. })
  384. }else{
  385. this.loadData();
  386. }
  387. })
  388. }}
  389. >
  390. {this.state.contactsOption}
  391. </Select>
  392. </span>
  393. <span style={{display:"inline-block"}}>
  394. <span style={{marginRight:'10px',marginBottom:'10px'}}>项目分类 :</span>
  395. <Select
  396. value={typeof this.state.projectType === 'number' ? this.state.projectType : undefined}
  397. placeholder="请选择项目分类"
  398. style={{ width: 100,marginRight:'10px',marginBottom:'10px' }}
  399. onChange={(e) => {
  400. this.setState({
  401. columns:
  402. e === 0 ? currency :
  403. e === 1 ? invention :
  404. e === 2 ? softWriting :
  405. e === 3 ? currency :
  406. e === 4 ? currency:
  407. e === 5 ? highTechColumns :
  408. e === 6 ? otherTrademarks :[],
  409. changeList: [],
  410. projectType: e,
  411. status: e === 1 ? 2 : e === 2 ? 4 : e === 5 ? 1 : e === 6 ? 5 : 0, // 0通用 1高新 2发明专利 3实用新型 4软著 5商标
  412. },()=>{
  413. this.loadData();
  414. })
  415. }}
  416. >
  417. <Option value={0}>通用</Option>
  418. <Option value={1}>专利</Option>
  419. <Option value={2}>软著</Option>
  420. <Option value={3}>审计</Option>
  421. <Option value={4}>双软</Option>
  422. <Option value={5}>高新</Option>
  423. <Option value={6}>商标</Option>
  424. </Select>
  425. </span>
  426. <span style={{display: "inline-block",marginRight:'10px',marginBottom:'10px'}}>
  427. <span>派单省份:</span>
  428. <Select
  429. placeholder="请选择省份"
  430. style={{ width: 100,marginRight:'10px',marginLeft:'10px',marginBottom:'10px' }}
  431. value={getNewDiccityArr(this.state.province)}
  432. onChange={e => {
  433. this.setState({ province: e });
  434. }}
  435. >
  436. {citySelect().map(function(item) {
  437. return (
  438. <Select.Option key={item.value} value={item.value}>{item.label}</Select.Option>
  439. );
  440. })}
  441. </Select>
  442. </span>
  443. <span style={{display: "inline-block",marginRight:'10px',marginBottom:'10px'}}>
  444. <span>负责部门:</span>
  445. <Select
  446. placeholder="请选择部门"
  447. style={{ width: 200,marginRight:'10px',marginLeft:'10px',marginBottom:'10px' }}
  448. value={this.state.depId || undefined}
  449. onChange={e => {
  450. this.setState({ depId: e });
  451. }}
  452. >
  453. {
  454. this.state.departmentArr.map(function (item) {
  455. return <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
  456. })
  457. }
  458. </Select>
  459. </span>
  460. <span style={{display:"inline-block"}}>
  461. <span style={{marginRight:'10px',marginBottom:'10px'}}>派单时间 :</span>
  462. <RangePicker
  463. style={{marginRight:'10px',marginBottom:'10px'}}
  464. value={[
  465. this.state.releaseDate[0]
  466. ? moment(this.state.releaseDate[0])
  467. : null,
  468. this.state.releaseDate[1]
  469. ? moment(this.state.releaseDate[1])
  470. : null,
  471. ]}
  472. onChange={(data, dataString) => {
  473. this.setState({ releaseDate: dataString });
  474. }}
  475. />
  476. </span>
  477. <Button type="primary" onClick={()=>{
  478. if(this.state.commodityName.length === 0){
  479. this.setState({
  480. kid: ''
  481. },()=>{
  482. this.loadData();
  483. })
  484. }else{
  485. this.loadData();
  486. }
  487. }} style={{marginRight:'10px',marginBottom:'10px'}}>搜索</Button>
  488. <Button onClick={this.resetAll} style={{marginRight:'10px',marginBottom:'10px'}}>重置</Button>
  489. </div>
  490. </TabPane>
  491. <TabPane tab="更改表格显示数据" key="2">
  492. <div style={{ marginLeft: 10 }}>
  493. <ChooseList
  494. columns={this.state.columns}
  495. changeFn={this.changeList}
  496. changeList={this.state.changeList}
  497. top={55}
  498. margin={11}
  499. />
  500. </div>
  501. </TabPane>
  502. <TabPane tab="导出EXCEL" key="3">
  503. <Button type="primary" style={{margin: '10px'}} onClick={this.exportPending}>导出</Button>
  504. </TabPane>
  505. </Tabs>
  506. <div className="patent-table">
  507. <Spin spinning={this.state.loading}>
  508. <Table
  509. bordered
  510. size="middle"
  511. scroll={{ x: 800, y: 0 }}
  512. columns={
  513. this.state.changeList.length > 0
  514. ? this.state.changeList
  515. : this.state.columns
  516. }
  517. dataSource={this.state.dataSource}
  518. pagination={this.state.pagination}
  519. />
  520. </Spin>
  521. </div>
  522. </div>
  523. )
  524. }
  525. }
  526. export default ProjecCount;