xm-spic-problem-import-modal.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <span>
  3. <a-modal
  4. :body-style="bodyStyle"
  5. :title="title"
  6. :destroy-on-close="true"
  7. :visible="visible"
  8. :width="modalWidth"
  9. @ok="handleOk"
  10. @cancel="handleCancel"
  11. >
  12. <a-form>
  13. <div style="width:80%;margin-left: 10%;;margin-left: 5%;">
  14. <p>提示:填写分类层级,导出不带数据的模板;请填写2到10的层级数值。 </p>
  15. <p
  16. >导出分类层级:<a-input-number
  17. id="level"
  18. v-model="level"
  19. :min="2"
  20. :max="10"
  21. style="width:60%;"
  22. />
  23. </p>
  24. <p>
  25. <a @click="exportItemTemplate">
  26. 审计案例导入模板
  27. </a>
  28. </p>
  29. <p>
  30. 上传导入文件:
  31. </p>
  32. <a-form-item>
  33. <span v-if="Message !== ''" style="padding:0 15px">
  34. {{ Message }}
  35. </span>
  36. <br v-if="Message !== '' && !hasattach" />
  37. <sd-attachment :max="1" :group-id="groupId" accept=".xls,.xlsx" @change="fnchangefile">
  38. </sd-attachment>
  39. </a-form-item>
  40. </div>
  41. </a-form>
  42. </a-modal>
  43. <a-modal
  44. v-model="isErrorInfo"
  45. title="错误信息"
  46. :width="700"
  47. @ok="isErrorInfo = false"
  48. @cancel="isErrorInfo = false"
  49. >
  50. <a-descriptions bordered>
  51. <a-descriptions-item label="错误信息">
  52. <p v-for="(item, index) in errorInfo" :key="index">{{ item }}</p>
  53. </a-descriptions-item>
  54. </a-descriptions>
  55. </a-modal>
  56. </span>
  57. </template>
  58. <script>
  59. import { Modal, Message } from 'ant-design-vue'
  60. import download from '@/common/services/download'
  61. import auditMattersService from './xm-spic-problem-import-service'
  62. import components from './_import-components/xm-spic-problem-import-modal-import'
  63. export default {
  64. name: 'XmSpicProblemImportModal',
  65. components,
  66. props: {
  67. // 弹出窗标题
  68. title: {
  69. type: String,
  70. default: '导入审计案例',
  71. },
  72. // 弹出窗宽度
  73. modalWidth: {
  74. type: String,
  75. default: '700px',
  76. },
  77. // 弹出窗显示参数
  78. visible: {
  79. type: Boolean,
  80. default: false,
  81. },
  82. // 父节点id
  83. parentId: {
  84. type: String,
  85. default: null,
  86. },
  87. },
  88. data() {
  89. return {
  90. bodyStyle: {
  91. padding: 0,
  92. },
  93. level: 2,
  94. errorInfo: [],
  95. isErrorInfo: false,
  96. groupId: Math.round(Math.random() * 100000000000000000).toString(),
  97. hasattach: false,
  98. Message: '',
  99. importType: 'inter',
  100. }
  101. },
  102. created() {},
  103. methods: {
  104. handleOk(e) {
  105. if (!this.hasattach) {
  106. // 未上传附件,给出提示
  107. Message.error('请上传文件!')
  108. return
  109. }
  110. // 导入
  111. const groupId = this.groupId
  112. const orgId = this.$parent.$parent.$refs.problemTree.depvalue
  113. auditMattersService.importItemTemplate(this.parentId, groupId, orgId).then((res) => {
  114. if (res.data.length > 0) {
  115. Message.error('导入数据失败!')
  116. this.isErrorInfo = true
  117. this.errorInfo = res.data
  118. return false
  119. } else {
  120. Message.success('导入成功!')
  121. this.hasattach = false
  122. this.groupId = Math.round(Math.random() * 100000000000000000).toString()
  123. this.level = 2
  124. this.$parent.$parent.showImportModal()
  125. }
  126. })
  127. },
  128. handleCancel(e) {
  129. this.hasattach = false
  130. this.groupId = Math.round(Math.random() * 100000000000000000).toString()
  131. this.$parent.$parent.importVisible = !this.$parent.$parent.importVisible
  132. this.level = 2
  133. },
  134. changedImportType() {},
  135. exportItemTemplate() {
  136. auditMattersService.exportItemTemplate(this.level).then((res) => {
  137. if (res.status === 200) {
  138. const url = URL.createObjectURL(res.data)
  139. const filename = res.headers['content-disposition']
  140. const fname = filename.substring(filename.indexOf('filename=') + 9, filename.length)
  141. download(url, decodeURI(fname))
  142. } else {
  143. Modal.warning({
  144. title: '提示',
  145. content: '导出报错,请联系管理员!',
  146. })
  147. return false
  148. }
  149. })
  150. },
  151. fnchangefile(attach) {
  152. if (attach.length > 0) {
  153. this.hasattach = true
  154. } else {
  155. this.hasattach = false
  156. }
  157. },
  158. },
  159. }
  160. </script>
  161. <style module lang="scss">
  162. @use '@/common/design' as *;
  163. </style>