audit-matters-export-modal.vue 5.1 KB

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