tools.js 22 KB

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