generalService.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import Http from './http'
  2. import Apis from './api'
  3. import ProvinceJson from '../constants/provinceCity'
  4. //存session
  5. export const storageSave = (key, value) => {
  6. sessionStorage.setItem(key, JSON.stringify(value))
  7. }
  8. //取session
  9. export const storageGet = (key) => {
  10. // return new Promise((resolve) => {
  11. // resolve(JSON.parse(sessionStorage.getItem(key)))
  12. // })
  13. return JSON.parse(sessionStorage.getItem(key))
  14. }
  15. //获取用户id
  16. export const getUserIdentity = () => {
  17. return Http.get(Apis.USER.GET_USER_IDENTITY)
  18. }
  19. //获取所有测评能力
  20. export const getAllAbilities = () => {
  21. return ['接口测试', '兼容性测试', '可靠性测试', '稳定性测试', '功能测试', '性能测试', '安全测试','易用性测试', '应用故障诊断', '应用漏洞扫描', '代码安全审计', '风险评估', '等保测评', '评估评价', '定制测试']
  22. //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES)
  23. }
  24. //获取所有测评资源种类
  25. export const getAllAgencyResourceTypes = () => {
  26. return ['人力资源', '服务器资源', '专用设备']
  27. //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES)
  28. }
  29. //获取所有服务类型
  30. export const getAllServiceTypes = () => {
  31. const data = ['接口测试', '兼容性测试', '可靠性测试', '稳定性测试', '功能测试', '性能测试', '安全测试','易用性测试', '应用故障诊断', '应用漏洞扫描', '代码安全审计', '风险评估', '等保测评', '评估评价', '定制测试']
  32. return new Promise((resolve) => {
  33. resolve(data)
  34. })
  35. //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES)
  36. }
  37. //获取所有报告类型
  38. export const getAllReportTypes = () => {
  39. const data = ['可行性报告', '测试方案', '测试报告', '缺陷报告', '用例报告', '其他']
  40. return new Promise((resolve) => {
  41. resolve(data)
  42. })
  43. //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES)
  44. }
  45. //获取所有平台类型
  46. export const getAllPlatformTypes = () => {
  47. return ['Android APP', 'IOS APP', 'Web应用', 'C/S应用软件', '嵌入式软件', '工业控制软件', '信息技术产品', '其他']
  48. // return Http.get(Apis.GENERAL.GET_ALL_ApplicationType)
  49. }
  50. export const getAllFields = () => {
  51. return ['科技服务', '互联网服务', '集成电路', '工业控制', '北斗应用', '其他']
  52. }
  53. //获取所有定向发布的目标
  54. export const getAllInstitutions = () => {
  55. return Http.get(Apis.GENERAL.GET_ALL_INSTITUTIONS)
  56. }
  57. //获取所有测评机构
  58. export const getAllAgencies = () => {
  59. // const data = [{
  60. // id: 1,
  61. // name: '慕测'
  62. // }, {
  63. // id: 2,
  64. // name: '南大'
  65. // }]
  66. //
  67. // return new Promise((resolve) => {
  68. // resolve(data)
  69. // })
  70. return Http.get(Apis.GENERAL.GET_ALL_AGENCIES)
  71. }
  72. //通过代码获取省、市名称
  73. export const getProvinceNameByProvinceCode = (provinceCode, cityCode) => {
  74. for (var i = 0; i < ProvinceJson.provinces.length; i++) {
  75. if (ProvinceJson.provinces[i].code == provinceCode) {
  76. for (var j = 0; j < ProvinceJson.provinces[i].cities.length; j++) {
  77. if (ProvinceJson.provinces[i].cities[j].code == cityCode) {
  78. return {
  79. 'provinceCode': ProvinceJson.provinces[i].name,
  80. 'cityCode': ProvinceJson.provinces[i].cities[j].name
  81. }
  82. }
  83. }
  84. }
  85. }
  86. // return {
  87. // 'provinceCode': '江苏省',
  88. // 'cityCode': '南京市'
  89. // }
  90. }
  91. //通过名称获取省、市代码
  92. export const getProvinceCodeByProvinceName = (provinceName, cityName) => {
  93. for (var i = 0; i < ProvinceJson.provinces.length; i++) {
  94. if (ProvinceJson.provinces[i].name == provinceName) {
  95. for (var j = 0; j < ProvinceJson.provinces[i].cities.length; j++) {
  96. if (ProvinceJson.provinces[i].cities[j].name == cityName) {
  97. return {
  98. 'provinceCode': ProvinceJson.provinces[i].code,
  99. 'cityCode': ProvinceJson.provinces[i].cities[j].code
  100. }
  101. }
  102. }
  103. }
  104. }
  105. // return {
  106. // 'provinceCode': '3200',
  107. // 'cityCode': '3201'
  108. // }
  109. }
  110. //获取批量上传项目模板文件
  111. export const getGreenChannelAddProjectExcelTemplateFile = (getTemplateExcelSuccess, getTemplateExcelFail) => {
  112. const data = {
  113. fileUrl: 'http://mooctest-crowd-service.oss-cn-hangzhou.aliyuncs.com/Others/%E9%A1%B9%E7%9B%AE%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx'
  114. }
  115. new Promise((resolve) => {
  116. resolve(data)
  117. }).then((res) => {
  118. getTemplateExcelSuccess(res)
  119. }).catch((error) => {
  120. getTemplateExcelFail(error)
  121. })
  122. // Http.get(Apis.FILE.GET_TEMPLATE_EXCEL_FILE).then((res) => {
  123. // getTemplateExcelSuccess(res)
  124. // }).catch((error) => {
  125. // getTemplateExcelFail(error)
  126. // })
  127. }
  128. Date.prototype.Format = function (fmt) {
  129. var o = {
  130. 'M+': this.getMonth() + 1, //月份
  131. 'd+': this.getDate(), //日
  132. 'h+': this.getHours(), //小时
  133. 'm+': this.getMinutes(), //分
  134. 's+': this.getSeconds(), //秒
  135. 'q+': Math.floor((this.getMonth() + 3) / 3), //季度
  136. 'S': this.getMilliseconds() //毫秒
  137. }
  138. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
  139. for (var k in o) {
  140. if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  141. }
  142. return fmt
  143. }
  144. export const getFormalTimeFromDate = (date) => {
  145. return date.Format('yyyy-MM-dd hh:mm:ss')
  146. }
  147. //
  148. export const getIndexStatisticsInfo = () => {
  149. const data = {
  150. userNum: 100,
  151. agencyNum: 200,
  152. deviceNum: 345,
  153. projectNum: 23,
  154. taskNum: 123
  155. }
  156. return new Promise((resolve) => {
  157. resolve(data)
  158. })
  159. }