tools.js 23 KB

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