tools.js 23 KB

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