f37614e1e913a906d77968facebd04a57d536a85.svn-base 4.3 KB

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