tools.js 23 KB

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