generalService.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 ['AndroidAPP', 'IOSAPP', 'Web应用', 'C/S应用软件', '嵌入式软件', '工业控制软件', '信息技术产品', '其他']
  48. //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES)
  49. }
  50. //获取所有定向发布的目标
  51. export const getAllInstitutions = () => {
  52. return Http.get(Apis.GENERAL.GET_ALL_INSTITUTIONS)
  53. }
  54. //获取所有测评机构
  55. export const getAllAgencies = () => {
  56. // const data = [{
  57. // id: 1,
  58. // name: '慕测'
  59. // }, {
  60. // id: 2,
  61. // name: '南大'
  62. // }]
  63. //
  64. // return new Promise((resolve) => {
  65. // resolve(data)
  66. // })
  67. return Http.get(Apis.GENERAL.GET_ALL_AGENCIES)
  68. }
  69. //通过代码获取省、市名称
  70. export const getProvinceNameByProvinceCode = (provinceCode, cityCode) => {
  71. for (var i = 0; i < ProvinceJson.provinces.length; i++) {
  72. if (ProvinceJson.provinces[i].code == provinceCode) {
  73. for (var j = 0; j < ProvinceJson.provinces[i].cities.length; j++) {
  74. if (ProvinceJson.provinces[i].cities[j].code == cityCode) {
  75. return {
  76. 'provinceCode': ProvinceJson.provinces[i].name,
  77. 'cityCode': ProvinceJson.provinces[i].cities[j].name
  78. }
  79. }
  80. }
  81. }
  82. }
  83. // return {
  84. // 'provinceCode': '江苏省',
  85. // 'cityCode': '南京市'
  86. // }
  87. }
  88. //通过名称获取省、市代码
  89. export const getProvinceCodeByProvinceName = (provinceName, cityName) => {
  90. for (var i = 0; i < ProvinceJson.provinces.length; i++) {
  91. if (ProvinceJson.provinces[i].name == provinceName) {
  92. for (var j = 0; j < ProvinceJson.provinces[i].cities.length; j++) {
  93. if (ProvinceJson.provinces[i].cities[j].name == cityName) {
  94. return {
  95. 'provinceCode': ProvinceJson.provinces[i].code,
  96. 'cityCode': ProvinceJson.provinces[i].cities[j].code
  97. }
  98. }
  99. }
  100. }
  101. }
  102. // return {
  103. // 'provinceCode': '3200',
  104. // 'cityCode': '3201'
  105. // }
  106. }
  107. //获取批量上传项目模板文件
  108. export const getGreenChannelAddProjectExcelTemplateFile = (getTemplateExcelSuccess, getTemplateExcelFail) => {
  109. const data = {
  110. 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'
  111. }
  112. new Promise((resolve) => {
  113. resolve(data)
  114. }).then((res) => {
  115. getTemplateExcelSuccess(res)
  116. }).catch((error) => {
  117. getTemplateExcelFail(error)
  118. })
  119. // Http.get(Apis.FILE.GET_TEMPLATE_EXCEL_FILE).then((res) => {
  120. // getTemplateExcelSuccess(res)
  121. // }).catch((error) => {
  122. // getTemplateExcelFail(error)
  123. // })
  124. }
  125. Date.prototype.Format = function (fmt) {
  126. var o = {
  127. 'M+': this.getMonth() + 1, //月份
  128. 'd+': this.getDate(), //日
  129. 'h+': this.getHours(), //小时
  130. 'm+': this.getMinutes(), //分
  131. 's+': this.getSeconds(), //秒
  132. 'q+': Math.floor((this.getMonth() + 3) / 3), //季度
  133. 'S': this.getMilliseconds() //毫秒
  134. }
  135. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
  136. for (var k in o) {
  137. if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  138. }
  139. return fmt
  140. }
  141. export const getFormalTimeFromDate = (date) => {
  142. return date.Format('yyyy-MM-dd hh:mm:ss')
  143. }
  144. //
  145. export const getIndexStatisticsInfo = () => {
  146. const data = {
  147. userNum: 100,
  148. agencyNum: 200,
  149. deviceNum: 345,
  150. projectNum: 23,
  151. taskNum: 123
  152. }
  153. return new Promise((resolve) => {
  154. resolve(data)
  155. })
  156. }