tools.js 23 KB

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