risk-event-export-modal.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <span>
  3. <a-modal
  4. ref="riskEventExportModal"
  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>提示:重复的分类编号、分类名称、风险事项编号、风险事项名称,请合并单元格后导入。</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 RiskService from '../risk-service'
  73. import components from './_import-components/risk-event-export-modal-import'
  74. export default {
  75. name: 'RiskEventExportModal',
  76. metaInfo: {
  77. title: 'RiskEventExportModal',
  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.riskCategoryTree.depvalue
  122. const versionId = this.$parent.$parent.$refs.riskCategoryTree.versionId
  123. RiskService.importItemTemplate(this.importType, groupId, versionId, orgId).then((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. handleCancel(e) {
  141. this.hasattach = false
  142. this.groupId = Math.round(Math.random() * 100000000000000000).toString()
  143. this.$parent.$parent.visible = !this.$parent.$parent.visible
  144. this.level = 2
  145. },
  146. changedImportType() {},
  147. exportItemTemplate() {
  148. RiskService.exportItemTemplate(this.level).then((res) => {
  149. if (res.status === 200) {
  150. const url = URL.createObjectURL(res.data)
  151. const filename = res.headers['content-disposition']
  152. const fname = filename.substring(filename.indexOf('filename=') + 9, filename.length)
  153. download(url, decodeURI(fname))
  154. } else {
  155. Modal.warning({
  156. title: '提示',
  157. content: '导出报错,请联系管理员!',
  158. })
  159. return false
  160. }
  161. })
  162. },
  163. fnchangefile(attach) {
  164. if (attach.length > 0) {
  165. this.hasattach = true
  166. } else {
  167. this.hasattach = false
  168. }
  169. },
  170. },
  171. }
  172. </script>
  173. <style module lang="scss">
  174. @use '@/common/design' as *;
  175. </style>