mtx-process-export-modal.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <span>
  3. <a-modal
  4. ref="icicmatrixExportModal"
  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>2)覆盖式导入,删除已经存在的数据,重新导入;</p>
  34. <p
  35. >导入模式:
  36. <a-select v-model="importType" style="width:40%;" @change="changedImportType">
  37. <a-select-option checked="true" value="over">覆盖式导入</a-select-option>
  38. <a-select-option value="inter">增量式导入</a-select-option>
  39. <a-select-option value="update">修改式导入</a-select-option>
  40. </a-select>
  41. </p>
  42. <a-form-item>
  43. <span v-if="Message !== ''" style="padding:0 15px">
  44. {{ Message }}
  45. </span>
  46. <br v-if="Message !== '' && !hasattach" />
  47. <sd-attachment :max="1" :group-id="groupId" accept=".xls,.xlsx" @change="fnchangefile">
  48. </sd-attachment>
  49. </a-form-item>
  50. </div>
  51. </a-form>
  52. </a-modal>
  53. <a-modal
  54. v-model="isErrorInfo"
  55. title="错误信息"
  56. :width="700"
  57. @ok="isErrorInfo = false"
  58. @cancel="isErrorInfo = false"
  59. >
  60. <a-descriptions bordered>
  61. <a-descriptions-item label="错误信息">
  62. <p v-for="(item, index) in errorInfo" :key="index">{{ item }}</p>
  63. </a-descriptions-item>
  64. </a-descriptions>
  65. </a-modal>
  66. </span>
  67. </template>
  68. <script>
  69. import { Modal, Message } from 'ant-design-vue'
  70. import download from '@/common/services/download'
  71. import MtxProcessService from './mtx-process-service'
  72. import components from './_import-components/mtx-process-export-modal-import'
  73. export default {
  74. name: 'MtxProcessExportModal',
  75. metaInfo: {
  76. title: 'MtxProcessExportModal',
  77. },
  78. components,
  79. props: {
  80. // 弹出窗标题
  81. title: {
  82. type: String,
  83. default: '内控矩阵导入',
  84. },
  85. // 弹出窗宽度
  86. modalWidth: {
  87. type: String,
  88. default: '700px',
  89. },
  90. // 弹出窗显示参数
  91. visible: {
  92. type: Boolean,
  93. default: false,
  94. },
  95. },
  96. data() {
  97. return {
  98. bodyStyle: {
  99. padding: 0,
  100. },
  101. level: 2,
  102. errorInfo: [],
  103. isErrorInfo: false,
  104. groupId: Math.round(Math.random() * 100000000000000000).toString(),
  105. hasattach: false,
  106. Message: '',
  107. importType: 'inter',
  108. }
  109. },
  110. created() {},
  111. methods: {
  112. handleOk(e) {
  113. if (!this.hasattach) {
  114. // 未上传附件,给出提示
  115. Message.error('请上传文件!')
  116. return
  117. }
  118. // 导入
  119. const groupId = this.groupId
  120. const orgId = this.$parent.$parent.$refs.icmatrixCatalogTree.depvalue
  121. const versionId = this.$parent.$parent.$refs.icmatrixCatalogTree.versionId
  122. MtxProcessService.importItemTemplate(this.importType, groupId, versionId, orgId).then(
  123. (res) => {
  124. if (res.data.length > 0) {
  125. Message.error('导入数据失败!')
  126. this.isErrorInfo = true
  127. this.errorInfo = res.data
  128. this.$emit('import', false)
  129. return false
  130. } else {
  131. Message.success('导入成功!')
  132. this.hasattach = false
  133. this.groupId = Math.round(Math.random() * 100000000000000000).toString()
  134. this.level = 2
  135. this.$parent.$parent.visible = !this.$parent.$parent.visible
  136. this.$emit('import', true)
  137. }
  138. }
  139. )
  140. },
  141. handleCancel(e) {
  142. this.hasattach = false
  143. this.groupId = Math.round(Math.random() * 100000000000000000).toString()
  144. this.$parent.$parent.visible = !this.$parent.$parent.visible
  145. this.level = 2
  146. },
  147. changedImportType() {},
  148. exportItemTemplate() {
  149. MtxProcessService.exportItemTemplate(this.level).then((res) => {
  150. if (res.status === 200) {
  151. const url = URL.createObjectURL(res.data)
  152. const filename = res.headers['content-disposition']
  153. const fname = filename.substring(filename.indexOf('filename=') + 9, filename.length)
  154. download(url, decodeURI(fname))
  155. } else {
  156. Modal.warning({
  157. title: '提示',
  158. content: '导出报错,请联系管理员!',
  159. })
  160. return false
  161. }
  162. })
  163. },
  164. fnchangefile(attach) {
  165. if (attach.length > 0) {
  166. this.hasattach = true
  167. } else {
  168. this.hasattach = false
  169. }
  170. },
  171. },
  172. }
  173. </script>
  174. <style module lang="scss">
  175. @use '@/common/design' as *;
  176. </style>