tools.js 19 KB

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