tools.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. import { message,Timeline,Select } from 'antd';
  2. import React from 'react';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import {
  6. patentTypeList,
  7. patentStateList,
  8. patentFieldList,
  9. technicalSourceList,
  10. catagoryList,
  11. intellectualGetList,
  12. conversionFormList,
  13. annualReportStateList,
  14. cognizanceStateList,
  15. technologyStateList,
  16. copyrightStateList,
  17. auditStatusList,
  18. scaleList,
  19. companyType,
  20. industryList,
  21. contractTypeList,
  22. contractStateList,
  23. demandTypeList,
  24. achievementCategoryList,
  25. techAuditStatusList,
  26. maturityList,
  27. transferModeList,
  28. innovationList,
  29. orderStatusList,
  30. activityForm,
  31. activityType
  32. } from './dataDic.js';
  33. module.exports = {
  34. splitUrl: function (string, i, url) {
  35. let theList = [];
  36. let theArr = [];
  37. if (string && string.length) {
  38. theArr = string.split(i);
  39. theArr.map(function (item, i) {
  40. theList.push({
  41. uid: -i-1,
  42. url: url + item,
  43. response: {
  44. data: item
  45. }
  46. });
  47. });
  48. }
  49. return theList;
  50. },
  51. getBase64: function (img, callback) {
  52. const reader = new FileReader();
  53. reader.addEventListener('load', () => callback(reader.result));
  54. reader.readAsDataURL(img);
  55. },
  56. beforeUpload: function (file) {
  57. // debugger
  58. // const isJPG = file.type === 'image/jpeg/document';
  59. // if (!isJPG) {
  60. // message.error('You can only upload JPG file!');
  61. // }
  62. // const isLt2M = file.size / 1024 / 1024 < 2;
  63. // if (!isLt2M) {
  64. // message.error('Image must smaller than 2MB!');
  65. // }
  66. // return isJPG && isLt2M;
  67. },
  68. beforeUploadFile: function (file) {
  69. // debugger
  70. // const isJPG = file.type === 'image/jpeg/document';
  71. // if (!isJPG) {
  72. // message.error('You can only upload JPG file!');
  73. // }
  74. // const isLt2M = file.size / 1024 / 1024 < 2;
  75. // if (!isLt2M) {
  76. // message.error('Image must smaller than 2MB!');
  77. // }
  78. // return isJPG && isLt2M;
  79. },
  80. getTime: function (e, t) {
  81. if (e && !t) {
  82. var d = new Date(e);
  83. d = d.getFullYear() + "-" +
  84. ((d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1)) + "-" +
  85. (d.getDate() < 10 ? '0' + d.getDate() : d.getDate()) + " ";
  86. // + (d.getHours() < 10 ? "0" + d.getHours() : d.getHours()) + ":" +
  87. // (d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes()) + ":" +
  88. // (d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds());
  89. return d;
  90. } else if (e && t) {
  91. var d1 = new Date(e);
  92. var d2 = new Date(e);
  93. d2 = d2.setMonth(d1.getMonth() + t);
  94. d2 = new Date(d2)
  95. d2 = d2.getFullYear() + "-" +
  96. ((d2.getMonth() + 1) < 10 ? '0' + (d2.getMonth() + 1) : (d2.getMonth() + 1)) + "-" +
  97. (d2.getDate() < 10 ? '0' + d2.getDate() : d2.getDate()) + " ";
  98. return d2;
  99. } else {
  100. return '';
  101. }
  102. },
  103. getPatentType: function (e) {
  104. if (e) {
  105. let theType = '';
  106. patentTypeList.map(function (item) {
  107. if (item.value == e) {
  108. theType = item.key;
  109. };
  110. });
  111. return theType;
  112. }
  113. },
  114. getPatentState: function (e) {
  115. if (e) {
  116. let theState = '';
  117. patentStateList.map(function (item) {
  118. if (item.value == e) {
  119. theState = item.key;
  120. };
  121. });
  122. return theState;
  123. }
  124. },
  125. getPatentField: function (e) {
  126. if (e) {
  127. let theState = '';
  128. patentFieldList.map(function (item) {
  129. if (item.value == e) {
  130. theState = item.key;
  131. };
  132. });
  133. return theState;
  134. }
  135. },
  136. getTechnicalSource: function (e) {
  137. if (e) {
  138. let theSource = '';
  139. technicalSourceList.map(function (item) {
  140. if (item.value == e) {
  141. theSource = item.key;
  142. };
  143. });
  144. return theSource;
  145. }
  146. },
  147. getCatagory: function (e) {
  148. if (e) {
  149. let theType = '';
  150. catagoryList.map(function (item) {
  151. if (item.value == e) {
  152. theType = item.key;
  153. };
  154. });
  155. return theType;
  156. }
  157. },
  158. getIntellectualObtainWay: function (e) {
  159. if (e) {
  160. let theType = '';
  161. intellectualGetList.map(function (item) {
  162. if (item.value == e) {
  163. theType = item.key;
  164. };
  165. });
  166. return theType;
  167. }
  168. },
  169. getConversionForm: function (e) {
  170. if (e) {
  171. let theType = '';
  172. conversionFormList.map(function (item) {
  173. if (item.value == e) {
  174. theType = item.key;
  175. };
  176. });
  177. return theType;
  178. }
  179. },
  180. getAnnualReportState: function (e) {
  181. if (e) {
  182. let theType = '';
  183. annualReportStateList.map(function (item) {
  184. if (item.value == e) {
  185. theType = item.key;
  186. };
  187. });
  188. return theType;
  189. }
  190. },
  191. getCognizanceState: function (e) {
  192. if (e) {
  193. let theType = '';
  194. cognizanceStateList.map(function (item) {
  195. if (item.value == e) {
  196. theType = item.key;
  197. };
  198. });
  199. return theType;
  200. }
  201. },
  202. getTechnologyState: function (e) {
  203. if (e) {
  204. let theType = '';
  205. technologyStateList.map(function (item) {
  206. if (item.value == e) {
  207. theType = item.key;
  208. };
  209. });
  210. return theType;
  211. }
  212. },
  213. //显示用户认证状态
  214. getAuditState: function (e) {
  215. if (e) {
  216. let theType = '';
  217. auditStatusList.map(function (item) {
  218. if (item.value == e) {
  219. theType = item.key;
  220. };
  221. });
  222. return theType;
  223. }
  224. },
  225. getCopyrightState: function (e) {
  226. if (e) {
  227. let theType = '';
  228. copyrightStateList.map(function (item) {
  229. if (item.value == e) {
  230. theType = item.key;
  231. };
  232. });
  233. return theType;
  234. }
  235. },
  236. downloadFile: function (path, fileName) {
  237. window.open(globalConfig.context + '/open/downloadFile?path=' + path + '&fileName=' + fileName)
  238. },
  239. techDownloadFile: function (url, id) {
  240. window.open(globalConfig.context + url + '?id=' + id)
  241. },
  242. copyrightDownloadFile: function (id, sign, url) {
  243. window.open(globalConfig.context + url + '?id=' + id + '&sign=' + sign)
  244. },
  245. newDownloadFile: function (id, sign, url,type) {
  246. if (!type ) {
  247. window.open(globalConfig.context + url + '?id=' + id + '&sign=' + sign);
  248. };
  249. if ( type ) {
  250. window.open(globalConfig.context + url + '?id=' + id + '&sign=' + sign + '&type=' + type);
  251. };
  252. },
  253. companySearch(input, option) {
  254. return option.props.children.indexOf(input) >= 0
  255. },
  256. getVacations(ccccc){
  257. let now = new Date();
  258. let theYear = now.getFullYear();
  259. $.ajax({
  260. type: "get",
  261. dataType: "json",
  262. crossDomain: false,
  263. url: globalConfig.context + '/open/html/json/vacations' + theYear,
  264. success: (data)=>{
  265. if (data) {
  266. ccccc(data);
  267. };
  268. }
  269. });
  270. },
  271. getInUrgentTime(date, inUrgent,vocations) {
  272. if ( vocations && vocations.length ){
  273. let now = new Date(date),addNum = 0;
  274. for (var i = 1; i <= inUrgent;) {
  275. now.setDate(now.getDate() + 1);
  276. let thebool = true;
  277. vocations.map((item)=>{
  278. if ( item == getKey(now)) {
  279. thebool= false;
  280. }
  281. });
  282. if ( thebool ) {
  283. i++
  284. };
  285. };
  286. return now;
  287. };
  288. function getKey(date) {
  289. var year = date.getFullYear(),
  290. month = date.getMonth() + 1,
  291. day = date.getDate();
  292. year = "" + year;
  293. month = (month > 9 ? "" : "0") + month;
  294. day = (day > 9 ? "" : "0") + day;
  295. return year + month + day;
  296. }
  297. },
  298. getStepList(pid,url) {
  299. let stepList = [];
  300. $.ajax({
  301. method: "get",
  302. dataType: "json",
  303. crossDomain: false,
  304. cache: false,
  305. url: globalConfig.context + url + "?pid=" + pid,
  306. success: function (data) {
  307. if (!data.data) {
  308. if (data.error && data.error.length ) {
  309. return;
  310. };
  311. };
  312. for (var item in data.data) {
  313. stepList.push(
  314. <Timeline.Item key={item}>
  315. <span>{module.exports.getPatentState(data.data[item].state)}</span>
  316. {module.exports.getTime(data.data[item].recordTime)}
  317. </Timeline.Item>
  318. )
  319. };
  320. }.bind(this),
  321. });
  322. return stepList;
  323. },
  324. //各种通过接口获取下拉列表
  325. setPatentStateOption(permission) {
  326. let theArr = [];
  327. patentStateList.map(function (item) {
  328. for (let i = 0; i < permission.length; i++) {
  329. if (item.value == permission[i]) {
  330. theArr.push(item);
  331. };
  332. };
  333. });
  334. return theArr;
  335. },
  336. setUserContactsList(){
  337. let theOption = [];
  338. $.ajax({
  339. method: "get",
  340. dataType: "json",
  341. crossDomain: false,
  342. url: globalConfig.context + '/api/user/getContacts',
  343. success: function (data) {
  344. if (!data.data) {
  345. if ( data.error && data.error.length ) {
  346. message.warning(data.error[0].message);
  347. };
  348. return;
  349. };
  350. for (let item in data.data) {
  351. let theData = data.data[item];
  352. theOption.push(
  353. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  354. );
  355. };
  356. }
  357. });
  358. return theOption;
  359. },
  360. setAdminContactsList(uid){
  361. let theOption = [];
  362. $.ajax({
  363. method: "get",
  364. dataType: "json",
  365. crossDomain: false,
  366. url: globalConfig.context + '/api/admin/getContacts',
  367. data:{ "uid": uid },
  368. success: function (data) {
  369. if (!data.data) {
  370. if ( data.error && data.error.length ) {
  371. message.warning(data.error[0].message);
  372. };
  373. return;
  374. };
  375. for (let item in data.data) {
  376. let theData = data.data[item];
  377. theOption.push(
  378. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  379. );
  380. };
  381. }
  382. });
  383. return theOption;
  384. },
  385. //高企培育资料完成情况(比重)
  386. getProportion(uid,callback){
  387. $.ajax({
  388. method: "get",
  389. dataType: "json",
  390. crossDomain: false,
  391. url: globalConfig.context + '/api/admin/proportion',
  392. data:{ "uid": uid },
  393. success: function (data) {
  394. if (!data.data) {
  395. if ( data.error && data.error.length ) {
  396. message.warning(data.error[0].message);
  397. };
  398. data.data = {}
  399. callback(data.data);
  400. };
  401. callback(data.data);
  402. }
  403. });
  404. },
  405. //保存高企培育资料完成情况
  406. saveProportion(id,uid,sign,status){
  407. $.ajax({
  408. method: "post",
  409. dataType: "json",
  410. crossDomain: false,
  411. url: globalConfig.context + '/api/admin/confirmProportion',
  412. data:{
  413. "id": id,
  414. "uid":uid,
  415. "sign":sign,
  416. "status":status
  417. },
  418. success: function (data) {
  419. if (!data.data) {
  420. if ( data.error && data.error.length ) {
  421. message.warning(data.error[0].message);
  422. };
  423. return;
  424. };
  425. }
  426. });
  427. },
  428. //获取window.location.search传的值
  429. getSearchUrl(e){
  430. let searchURL = e;
  431. let theObj = {};
  432. searchURL = searchURL.substring(1, searchURL.length);
  433. theObj[searchURL.split("&")[0].split("=")[0]] = searchURL.split("&")[0].split("=")[1];
  434. if ( searchURL.split("&")[1] ) {
  435. theObj[searchURL.split("&")[1].split("=")[0]] = searchURL.split("&")[1].split("=")[1];
  436. if ( searchURL.split("&")[2] ) {
  437. theObj[searchURL.split("&")[2].split("=")[0]] = searchURL.split("&")[2].split("=")[1];
  438. };
  439. };
  440. return theObj;
  441. },
  442. //预览接口
  443. getPreview(id,url,sign,callback){
  444. $.ajax({
  445. method: "get",
  446. dataType: "json",
  447. crossDomain: false,
  448. url: globalConfig.context + "/api/admin/preview/" + url,
  449. data:{
  450. "id": id,
  451. "sign": sign
  452. },
  453. success: function (data) {
  454. if (!data.data) {
  455. if ( data.error && data.error.length ) {
  456. message.warning(data.error[0].message);
  457. };
  458. };
  459. callback('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(location.origin + globalConfig.context + "/open/preview?" + data.data));
  460. }
  461. });
  462. },
  463. //获取企业规模
  464. getScaleState(e) {
  465. if (e) {
  466. let theType = '';
  467. scaleList.map(function (item) {
  468. if (item.value == e) {
  469. theType = item.key;
  470. };
  471. });
  472. return theType;
  473. }
  474. },
  475. //获取企业类型
  476. getCompanyType(type1, type2) {
  477. let companyTypeList = [];
  478. for (let i = 0; i < companyType.length; i++) {
  479. companyTypeList.push({
  480. value: companyType[i].value,
  481. label: companyType[i].label
  482. });
  483. if (companyType[i].children) {
  484. for (let j = 0; j < companyType[i].children.length; j++) {
  485. companyTypeList.push({
  486. value: companyType[i].children[j].value,
  487. label: companyType[i].children[j].label
  488. });
  489. };
  490. }
  491. };
  492. companyTypeList.sort(function (a, b) {
  493. return a.value - b.value
  494. });
  495. let typeKey = "";
  496. companyTypeList.map(function (item) {
  497. if (type1 == item.value) {
  498. typeKey = item.label;
  499. };
  500. if (type2 == item.value) {
  501. typeKey = typeKey + "/" + item.label;
  502. };
  503. });
  504. return typeKey;
  505. },
  506. //获取企业行业
  507. getIndustryType(e) {
  508. if (e) {
  509. let theType = '';
  510. industryList.map(function (item) {
  511. if (item.value == e) {
  512. theType = item.key;
  513. };
  514. });
  515. return theType;
  516. }
  517. },
  518. //获取合同状态
  519. getContractType: function (e) {
  520. if (e) {
  521. let theType = '';
  522. contractTypeList.map(function (item) {
  523. if (item.value == e) {
  524. theType = item.key;
  525. };
  526. });
  527. return theType;
  528. }
  529. },
  530. //获取合同类型
  531. getContractState: function (e) {
  532. if (e) {
  533. let theType = '';
  534. contractStateList.map(function (item) {
  535. if (item.value == e) {
  536. theType = item.key;
  537. };
  538. });
  539. return theType;
  540. }
  541. },
  542. //获取需求类型
  543. getDemandType: function (e) {
  544. if (e) {
  545. let theType = '';
  546. demandTypeList.map(function (item) {
  547. if (item.value == e) {
  548. theType = item.key;
  549. };
  550. });
  551. return theType;
  552. }
  553. },
  554. //获取成果类型
  555. getAchievementCategory: function (e) {
  556. if (e) {
  557. let theType = '';
  558. achievementCategoryList.map(function (item) {
  559. if (item.value == e) {
  560. theType = item.key;
  561. };
  562. });
  563. return theType;
  564. }
  565. },
  566. //获取需求和成果审核状态
  567. getTechAuditStatus: function (e) {
  568. if (e) {
  569. let theType = '';
  570. techAuditStatusList.map(function (item) {
  571. if (item.value == e) {
  572. theType = item.key;
  573. };
  574. });
  575. return theType;
  576. }
  577. },
  578. //获取需求和成果审核状态
  579. getMaturity: function (e) {
  580. if (e) {
  581. let theType = '';
  582. maturityList.map(function (item) {
  583. if (item.value == e) {
  584. theType = item.key;
  585. };
  586. });
  587. return theType;
  588. }
  589. },
  590. //获取需求和成果审核状态
  591. getTransferMode: function (e) {
  592. if (e) {
  593. let theType = '';
  594. transferModeList.map(function (item) {
  595. if (item.value == e) {
  596. theType = item.key;
  597. };
  598. });
  599. return theType;
  600. }
  601. },
  602. //获取创新度状态
  603. getInnovation: function (e) {
  604. if (e) {
  605. let theType = '';
  606. innovationList.map(function (item) {
  607. if (item.value == e) {
  608. theType = item.key;
  609. };
  610. });
  611. return theType;
  612. }
  613. },
  614. //获取创新度状态
  615. getOrderStatus: function (e) {
  616. if (e) {
  617. let theType = '';
  618. orderStatusList.map(function (item) {
  619. if (item.value == e) {
  620. theType = item.key;
  621. };
  622. });
  623. return theType;
  624. }
  625. },
  626. //科技管理
  627. //活动圈后台管理
  628. getActivityType: function (e) {
  629. if (e) {
  630. let theType = '';
  631. activityType.map(function (item) {
  632. if (item.value == e) {
  633. theType = item.key;
  634. };
  635. });
  636. return theType;
  637. }
  638. },
  639. getActivityForm: function (e) {
  640. if (e) {
  641. let theType = '';
  642. activityForm.map(function (item) {
  643. if (item.value == e) {
  644. theType = item.key;
  645. };
  646. });
  647. return theType;
  648. }
  649. },
  650. }