chooseImportDealerModal.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseImport-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="确认导入"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. width="80%">
  11. <div class="chooseImport-con">
  12. <!-- 可导入数据 -->
  13. <p class="">可导入数据{{ loadData.length }}条</p>
  14. <a-table
  15. class="sTable"
  16. ref="table"
  17. size="small"
  18. :rowKey="(record) => record.allocateSn"
  19. :columns="nowColumns"
  20. :dataSource="loadData"
  21. :loading="loading"
  22. :scroll="{ y: 200 }"
  23. :pagination="false"
  24. bordered>
  25. </a-table>
  26. <a-divider />
  27. <!-- 不可导入数据 -->
  28. <p class="red">不可导入数据{{ unLoadData.length }}条</p>
  29. <a-table
  30. class="unTable"
  31. ref="unTable"
  32. size="small"
  33. :rowKey="(record) => record.errorDesc"
  34. :columns="nowUnColumns"
  35. :dataSource="unLoadData"
  36. :loading="loading"
  37. :scroll="{ y: 200 }"
  38. :pagination="false"
  39. bordered>
  40. </a-table>
  41. <!-- 按钮 -->
  42. <div class="btn-con">
  43. <a-button
  44. type="primary"
  45. id="chooseImport-submit"
  46. size="large"
  47. class="button-primary"
  48. @click="handleSubmit"
  49. style="padding: 0 40px;">确认导入</a-button>
  50. <a-button
  51. id="chooseImport-cancel"
  52. size="large"
  53. class="button-cancel"
  54. @click="isShow=false"
  55. style="padding: 0 40px;margin-left: 15px;">取消</a-button>
  56. <a-button
  57. type="primary"
  58. id="chooseImport-error"
  59. size="large"
  60. class="button-error"
  61. @click="handleError"
  62. style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
  63. </div>
  64. </div>
  65. </a-modal>
  66. </template>
  67. <script>
  68. import { commonMixin } from '@/utils/mixin'
  69. import { hdExportExcel } from '@/libs/exportExcel'
  70. import {downDealerFail } from '@/api/promotion'
  71. export default {
  72. name: 'ChooseImportModal',
  73. mixins: [commonMixin],
  74. props: {
  75. openModal: { // 弹框显示状态
  76. type: Boolean,
  77. default: false
  78. },
  79. paramsData: {
  80. type: Object,
  81. default: () => {
  82. return {}
  83. }
  84. }
  85. },
  86. data () {
  87. return {
  88. isShow: this.openModal, // 是否打开弹框
  89. loadData: [],
  90. unLoadData: [],
  91. loading: false
  92. }
  93. },
  94. computed: {
  95. nowColumns () {
  96. const _this = this
  97. let columnsArr = [
  98. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  99. { title: '经销商名称', dataIndex: 'dealerName', width: '90%', align: 'center', customRender: function (text) { return text || '--' } }
  100. ]
  101. return columnsArr
  102. },
  103. nowUnColumns () {
  104. const _this = this
  105. const unColumnsArr = [
  106. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  107. { title: '经销商名称', dataIndex: 'dealerName', width: '50%', align: 'center', customRender: function (text) { return text || '--' },ellipsis: true },
  108. { title: '备注',dataIndex: 'remarks', width: '40%', align: 'center', customRender: function (text) { return text || '--' } ,ellipsis: true}
  109. ]
  110. return unColumnsArr
  111. }
  112. },
  113. methods: {
  114. getData () {
  115. const paramsData = JSON.parse(JSON.stringify(this.paramsData))
  116. this.loadData = paramsData.rightList || []
  117. this.unLoadData = paramsData.errorList || []
  118. this.loadData.map((item, index) => {
  119. item.no = index + 1
  120. })
  121. this.unLoadData.map((item, index) => {
  122. item.no = index + 1
  123. item.importErrorMsgSet = item.remarks.split(',')
  124. })
  125. },
  126. // 确认导入
  127. handleSubmit () {
  128. if (this.loadData.length == 0) {
  129. this.$message.warning('没有可导入的数据!')
  130. } else {
  131. const data = this.paramsData.rightList
  132. this.$emit('ok', data)
  133. this.isShow = false
  134. }
  135. },
  136. // 导出错误项
  137. handleError () {
  138. const _this = this
  139. if (_this.unLoadData.length < 1) {
  140. _this.$message.info('暂无可导出的错误项~')
  141. return
  142. }
  143. _this.spinning = true
  144. hdExportExcel(downDealerFail, _this.unLoadData, '导出参与客户错误项', function () {
  145. _this.spinning = false
  146. })
  147. }
  148. },
  149. watch: {
  150. // 父页面传过来的弹框状态
  151. openModal (newValue, oldValue) {
  152. this.isShow = newValue
  153. },
  154. // 重定义的弹框状态
  155. isShow (newValue, oldValue) {
  156. if (!newValue) {
  157. this.$emit('close')
  158. this.loadData = []
  159. this.unLoadData = []
  160. } else {
  161. this.getData()
  162. }
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="less" scoped>
  168. .chooseImport-modal{
  169. .chooseImport-con{
  170. .red{
  171. color: #f30;
  172. }
  173. .btn-con{
  174. text-align: center;
  175. margin: 30px 0 20px;
  176. .button-cancel,.button-error{
  177. font-size: 12px;
  178. }
  179. }
  180. }
  181. }
  182. </style>