tools.js 21 KB

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