2e33d3a4663ee59f8484b40c326d177c342d8893.svn-base 4.6 KB

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