tools.js 19 KB

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