tools.js 22 KB

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