9f542de59ba44a020c684979ea4c9e3916a01043.svn-base 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import request from '@/utils/request'
  2. import parseTime from '@/utils/index.js'
  3. export function GetDataByName(data) {
  4. return request({
  5. url: '/authdata/GetDataByName',
  6. method: 'post',
  7. data
  8. })
  9. }
  10. export function GetReportform(data) {
  11. return request({
  12. url: '/authdata/GetReportform',
  13. method: 'post',
  14. data
  15. })
  16. }
  17. export function requestbyname(data, requestname) {
  18. return request({
  19. url: '/authdata/' + requestname,
  20. method: 'post',
  21. data
  22. })
  23. }
  24. export function GetDataByNameXlsx(data) {
  25. return request({
  26. url: '/authdata/GetDataByName',
  27. method: 'post',
  28. data,
  29. responseType: 'blob'
  30. })
  31. }
  32. export function GetDataByNames(data) {
  33. return request({
  34. url: '/authdata/GetDataByNames',
  35. method: 'post',
  36. data
  37. })
  38. }
  39. export function PostDataByName(data) {
  40. return request({
  41. url: '/authdata/PostDataByName',
  42. method: 'post',
  43. data
  44. })
  45. }
  46. export function GetUpkeepPlan(data) {
  47. return request({
  48. url: '/authdata/GetUpkeepPlan',
  49. method: 'post',
  50. data
  51. })
  52. }
  53. export function GetAccount(data) {
  54. return request({
  55. url: '/authdata/GetAccount',
  56. method: 'post',
  57. timeout: 600000,
  58. data
  59. })
  60. }
  61. export function PostDataByNames(data) {
  62. return request({
  63. url: '/authdata/PostDataByNames',
  64. method: 'post',
  65. data
  66. })
  67. }
  68. export function ExecDataByConfig(data) {
  69. return request({
  70. url: '/authdata/ExecDataByConfig',
  71. method: 'post',
  72. data
  73. })
  74. }
  75. export function removeimage(data) {
  76. return request({
  77. url: '/authdata/removeimage',
  78. method: 'post',
  79. data
  80. })
  81. }
  82. export function getRecuData(data) {
  83. return request({
  84. url: '/authdata/GetRecuDataByName',
  85. method: 'post',
  86. data
  87. })
  88. }
  89. export function failproccess(data, notify) {
  90. if (data.data.includes('Duplicate')) {
  91. notify({
  92. title: '失败',
  93. message: '不可以录入重复数据',
  94. type: 'error',
  95. duration: 2000
  96. })
  97. } else {
  98. notify({
  99. title: '失败',
  100. message: '数据存在错误,请校验好重新录入,不可以录入数据',
  101. type: 'error',
  102. duration: 2000
  103. })
  104. }
  105. }
  106. export function UpdateDataRelation(data) {
  107. return request({
  108. url: '/authdata/UpdateDataRelation',
  109. method: 'post',
  110. data
  111. })
  112. }
  113. export function transData(a, idStr, pidStr, chindrenStr) {
  114. var r = []; var hash = {}; var id = idStr; var pid = pidStr; var children = chindrenStr; var i = 0; var j = 0; var len = a.length
  115. for (; i < len; i++) {
  116. hash[a[i][id]] = a[i]
  117. }
  118. for (; j < len; j++) {
  119. var aVal = a[j]; var hashVP = hash[aVal[pid]]
  120. if (hashVP) {
  121. !hashVP[children] && (hashVP[children] = [])
  122. hashVP[children].push(aVal)
  123. } else {
  124. r.push(aVal)
  125. }
  126. }
  127. return r
  128. }
  129. export function checkButtons(buttonsList, PermissionButtons) {
  130. // console.log(PermissionButtons)
  131. for (let i = 0; i < buttonsList.length; i++) {
  132. if (buttonsList[i].path === PermissionButtons && buttonsList[i].menu_id && buttonsList[i].path) { // path不为空且menu_id不为空时返回true
  133. return true
  134. }
  135. }
  136. return false
  137. }
  138. export function formatJson(filterVal, jsonData) {
  139. return jsonData.map(v =>
  140. filterVal.map(j => {
  141. if (j === 'timestamp') {
  142. return parseTime(v[j])
  143. } else {
  144. return v[j]
  145. }
  146. })
  147. )
  148. }
  149. export function DownloadExcel(data, filename) {
  150. const content = data
  151. const blob = new Blob([content])
  152. const fileName = filename + '.xlsx'
  153. if ('download' in document.createElement('a')) { // 非IE下载
  154. const elink = document.createElement('a')
  155. elink.download = fileName
  156. elink.style.display = 'none'
  157. elink.href = URL.createObjectURL(blob)
  158. document.body.appendChild(elink)
  159. elink.click()
  160. URL.revokeObjectURL(elink.href) // 释放URL 对象
  161. document.body.removeChild(elink)
  162. } else { // IE10+下载
  163. navigator.msSaveBlob(blob, fileName)
  164. }
  165. }