ImportHistory.vue 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="import-history">
  3. <div class="import-history__hd">
  4. <span class="import-history__title">查看历史导入记录</span>
  5. <span class="import-history__des">(错误数据只保存七天,七天后将自动失效)</span>
  6. <el-button
  7. class="xr-icon-close-btn"
  8. icon="el-icon-close"
  9. @click="closeClick" />
  10. </div>
  11. <el-table
  12. :data="tableList"
  13. class="import-history__bd"
  14. height="250"
  15. style="width: 100%">
  16. <el-table-column
  17. prop="createTime"
  18. label="导入时间"
  19. width="120">
  20. <template slot-scope="scope">
  21. {{ scope.row.createTime | createTime }}
  22. </template>
  23. </el-table-column>
  24. <el-table-column
  25. prop="realname"
  26. label="操作人"
  27. width="80"/>
  28. <el-table-column
  29. prop="address"
  30. label="导入结果">
  31. <template slot-scope="scope">
  32. {{ `导入总数据${scope.row.title}条,${getImportContent(scope.row.title, scope.row.content)}` }}
  33. </template>
  34. </el-table-column>
  35. <el-table-column
  36. prop="option"
  37. width="150"
  38. label="操作">
  39. <template slot-scope="scope">
  40. <template v-if="getErrorNum(scope.row.content) > 0">
  41. <el-button
  42. v-if="scope.row.valid == 1"
  43. type="text"
  44. @click="downloadError(scope.row.messageId)">下载错误数据</el-button>
  45. <span v-else-if="scope.row.valid == 0" class="invalid-tips">已失效</span>
  46. </template>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <div class="import-history__ft">
  51. <el-button
  52. type="primary"
  53. @click="closeClick">关闭</el-button>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import { systemMessageListAPI } from '@/api/common'
  59. import {
  60. crmDownImportErrorAPI
  61. } from '@/api/crm/common'
  62. import { downloadExcelWithResData } from '@/utils/index'
  63. export default {
  64. // 导入历史
  65. name: 'CRMImportHistory',
  66. components: {},
  67. filters: {
  68. createTime(time) {
  69. const times = time.split(' ')
  70. return times.length > 0 ? times[0] : ''
  71. }
  72. },
  73. props: {
  74. show: {
  75. type: Boolean,
  76. default: false
  77. },
  78. // CRM类型
  79. crmType: {
  80. type: String,
  81. default: ''
  82. },
  83. // moduleType
  84. props: Object
  85. },
  86. data() {
  87. return {
  88. loading: false,
  89. tableList: []
  90. }
  91. },
  92. computed: {},
  93. watch: {
  94. show(value) {
  95. if (value) {
  96. this.getList()
  97. }
  98. }
  99. },
  100. mounted() {},
  101. beforeDestroy() {},
  102. methods: {
  103. getList() {
  104. this.loading = true
  105. systemMessageListAPI({
  106. page: 1,
  107. limit: 9999,
  108. type: {
  109. customer: 14,
  110. contacts: 16,
  111. leads: 18,
  112. product: 20,
  113. hrm: 50
  114. }[this.crmType] || this.props.moduleType
  115. })
  116. .then(res => {
  117. this.loading = false
  118. this.tableList = res.data.list
  119. })
  120. .catch(() => {
  121. this.loading = false
  122. })
  123. },
  124. /**
  125. * 下载错误数据
  126. */
  127. downloadError(messageId) {
  128. crmDownImportErrorAPI({ messageId })
  129. .then(res => {
  130. downloadExcelWithResData(res)
  131. })
  132. .catch(() => {
  133. })
  134. },
  135. getImportContent(totalSize, content) {
  136. const list = content.split(',') || []
  137. const updateSize = Number(list[1] || '0')
  138. const errSize = Number(list[0] || '0')
  139. return `覆盖${updateSize}条,导入成功${totalSize - errSize}条,导入失败${errSize}条。`
  140. },
  141. /**
  142. * 获取错误数据数
  143. */
  144. getErrorNum(content) {
  145. const list = content.split(',') || []
  146. const errSize = Number(list[0] || '0')
  147. return parseInt(errSize)
  148. },
  149. /**
  150. * 关闭
  151. */
  152. closeClick() {
  153. this.$emit('close')
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .import-history {
  160. &__hd {
  161. padding: 20px;
  162. padding-bottom: 10px;
  163. }
  164. &__title {
  165. font-size: 16px;
  166. font-weight: 600;
  167. color: #333;
  168. }
  169. &__des {
  170. font-size: 12px;
  171. color: #ccc;
  172. }
  173. &__bd {
  174. border-top: 1px solid #e6e6e6;
  175. }
  176. &__ft {
  177. padding: 10px;
  178. background-color: #F7F8FA;
  179. text-align: right;
  180. }
  181. .xr-icon-close-btn {
  182. float: right;
  183. }
  184. }
  185. .invalid-tips {
  186. color: #999;
  187. }
  188. </style>