audit-advanced-export.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <span>
  3. <slot></slot>
  4. <a-button v-if="vIf" :class="classStyle" @click="exportdata">导出</a-button>
  5. </span>
  6. </template>
  7. <script>
  8. import download from '@/common/services/download'
  9. import { Modal } from 'ant-design-vue'
  10. import AuditAdvancedExportService from './audit-advanced-export-service'
  11. import components from './_import-components/audit-advanced-export-import'
  12. export default {
  13. name: 'AuditAdvancedExport',
  14. metaInfo: {
  15. title: 'AuditAdvancedExport',
  16. },
  17. components,
  18. props: {
  19. /*
  20. expressions 搜索表达式
  21. */
  22. expressions: {
  23. type: Array,
  24. default: () => [],
  25. },
  26. classStyle: {
  27. type: Array,
  28. default: null,
  29. },
  30. tableId: {
  31. type: String,
  32. default: '',
  33. },
  34. /**
  35. * 系统维护的配置表ID
  36. */
  37. configId: {
  38. Type: Number,
  39. default: 1,
  40. },
  41. /**
  42. * 判断导出按钮 显示条件,为true 则显示
  43. */
  44. vIf: {
  45. Type: Boolean,
  46. default: false,
  47. },
  48. /**
  49. * 必须选行判断标志,如果是定制的导出,不需要必选行,则传false,默认是必会判断是否选择导出行
  50. */
  51. exclebxh: {
  52. Type: Boolean,
  53. default: true,
  54. },
  55. },
  56. data() {
  57. return {}
  58. },
  59. methods: {
  60. exportdata1() {
  61. let selectedRowKeys = []
  62. if (this.exclebxh) {
  63. selectedRowKeys = this.$parent.$parent.$refs[`${this.tableId}`].getSelectedRowKeys()
  64. // if (selectedRowKeys.length === 0) {
  65. // Modal.warning({
  66. // title: '提示',
  67. // content: '请选择导出文档!',
  68. // })
  69. // return false
  70. // }
  71. }
  72. let exs = []
  73. if (this.expressions !== null) {
  74. exs = this.expressions
  75. }
  76. const params = {
  77. configId: this.configId,
  78. selectIds: selectedRowKeys,
  79. expressions: exs,
  80. }
  81. AuditAdvancedExportService.Export(params).then((res) => {
  82. if (res.status === 200) {
  83. const url = URL.createObjectURL(res.data)
  84. const filename = res.headers['content-disposition']
  85. const fname = filename.substring(filename.indexOf('filename=') + 9, filename.length)
  86. download(url, decodeURI(fname))
  87. } else {
  88. Modal.warning({
  89. title: '提示',
  90. content: '导出报错,请联系管理员!',
  91. })
  92. return false
  93. }
  94. })
  95. },
  96. exportdata(containsSub) {
  97. let selectedRowKeys = []
  98. if (this.exclebxh) {
  99. selectedRowKeys = this.$parent.$parent.$refs[`${this.tableId}`].getSelectedRowKeys()
  100. if (selectedRowKeys.length === 0) {
  101. Modal.warning({
  102. title: '提示',
  103. content: '请选择导出文档!',
  104. })
  105. return false
  106. }
  107. }
  108. let exs = []
  109. if (this.expressions !== null) {
  110. exs = this.expressions
  111. const p = exs.find((e) => e.name === 'parentId')
  112. if (p && p.stringValue && p.stringValue === 564) {
  113. if (containsSub) {
  114. p.stringValue = '' + p.stringValue + '1'
  115. } else {
  116. p.stringValue = '' + p.stringValue + '0'
  117. }
  118. }
  119. }
  120. const params = {
  121. configId: this.configId,
  122. selectIds: selectedRowKeys,
  123. expressions: exs,
  124. }
  125. AuditAdvancedExportService.Export(params).then((res) => {
  126. if (res.status === 200) {
  127. const url = URL.createObjectURL(res.data)
  128. const filename = res.headers['content-disposition']
  129. const fname = filename.substring(filename.indexOf('filename=') + 9, filename.length)
  130. download(url, decodeURI(fname))
  131. } else {
  132. Modal.warning({
  133. title: '提示',
  134. content: '导出报错,请联系管理员!',
  135. })
  136. return false
  137. }
  138. })
  139. },
  140. exportdataRisk() {
  141. let selectedRowKeys = []
  142. if (this.exclebxh) {
  143. selectedRowKeys = this.$parent.$refs[`${this.tableId}`].getSelectedRowKeys()
  144. if (selectedRowKeys.length === 0) {
  145. Modal.warning({
  146. title: '提示',
  147. content: '请选择导出文档!',
  148. })
  149. return false
  150. }
  151. }
  152. let exs = []
  153. if (this.expressions !== null) {
  154. exs = this.expressions
  155. }
  156. const params = {
  157. configId: this.configId,
  158. selectIds: selectedRowKeys,
  159. expressions: exs,
  160. }
  161. AuditAdvancedExportService.ExportRisk(params).then((res) => {
  162. if (res.status === 200) {
  163. const url = URL.createObjectURL(res.data)
  164. const filename = res.headers['content-disposition']
  165. const fname = filename.substring(filename.indexOf('filename=') + 9, filename.length)
  166. download(url, decodeURI(fname))
  167. } else {
  168. Modal.warning({
  169. title: '提示',
  170. content: '导出报错,请联系管理员!',
  171. })
  172. return false
  173. }
  174. })
  175. },
  176. },
  177. }
  178. </script>
  179. <style module lang="scss">
  180. @use '@/common/design' as *;
  181. </style>