tools.js 21 KB

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