7adb767ec4493eeedb9748afc3f16f42adc232c7.svn-base 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 PostDataByNames(data) {
  83. return request({
  84. url: '/authdata/PostDataByNames',
  85. method: 'post',
  86. data
  87. })
  88. }
  89. export function ExecDataByConfig(data) {
  90. return request({
  91. url: '/authdata/ExecDataByConfig',
  92. method: 'post',
  93. data
  94. })
  95. }
  96. export function removeimage(data) {
  97. return request({
  98. url: '/authdata/removeimage',
  99. method: 'post',
  100. data
  101. })
  102. }
  103. export function getRecuData(data) {
  104. return request({
  105. url: '/authdata/GetRecuDataByName',
  106. method: 'post',
  107. data
  108. })
  109. }
  110. export function failproccess(data, notify) {
  111. if (data.data.includes('Duplicate')) {
  112. notify({
  113. title: '失败',
  114. message: '不可以录入重复数据',
  115. type: 'error',
  116. duration: 2000
  117. })
  118. } else {
  119. notify({
  120. title: '失败',
  121. message: '数据存在错误,请校验好重新录入,不可以录入数据',
  122. type: 'error',
  123. duration: 2000
  124. })
  125. }
  126. }
  127. export function UpdateDataRelation(data) {
  128. return request({
  129. url: '/authdata/UpdateDataRelation',
  130. method: 'post',
  131. data
  132. })
  133. }
  134. export function transData(a, idStr, pidStr, chindrenStr) {
  135. var r = []; var hash = {}; var id = idStr; var pid = pidStr; var children = chindrenStr; var i = 0; var j = 0; var len = a.length
  136. for (; i < len; i++) {
  137. hash[a[i][id]] = a[i]
  138. }
  139. for (; j < len; j++) {
  140. var aVal = a[j]; var hashVP = hash[aVal[pid]]
  141. if (hashVP) {
  142. !hashVP[children] && (hashVP[children] = [])
  143. hashVP[children].push(aVal)
  144. } else {
  145. r.push(aVal)
  146. }
  147. }
  148. return r
  149. }
  150. export function checkButtons(buttonsList, PermissionButtons) {
  151. console.log(PermissionButtons)
  152. for (let i = 0; i < buttonsList.length; i++) {
  153. console.log(buttonsList)
  154. // if (buttonsList[i].path === PermissionButtons && buttonsList[i].menu_id && buttonsList[i].path) { // path不为空且menu_id不为空时返回true
  155. if (buttonsList[i].path === PermissionButtons && buttonsList[i].editbutton === 1) { // path不为空且menu_id不为空时返回true
  156. return true
  157. }
  158. }
  159. return false
  160. }
  161. export function formatJson(filterVal, jsonData) {
  162. return jsonData.map(v =>
  163. filterVal.map(j => {
  164. if (j === 'timestamp') {
  165. return parseTime(v[j])
  166. } else {
  167. return v[j]
  168. }
  169. })
  170. )
  171. }
  172. export function DownloadExcel(data, filename) {
  173. const content = data
  174. const blob = new Blob([content])
  175. const fileName = filename + '.xlsx'
  176. if ('download' in document.createElement('a')) { // 非IE下载
  177. const elink = document.createElement('a')
  178. elink.download = fileName
  179. elink.style.display = 'none'
  180. elink.href = URL.createObjectURL(blob)
  181. document.body.appendChild(elink)
  182. elink.click()
  183. URL.revokeObjectURL(elink.href) // 释放URL 对象
  184. document.body.removeChild(elink)
  185. } else { // IE10+下载
  186. navigator.msSaveBlob(blob, fileName)
  187. }
  188. }