importDealerModa.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <a-modal
  3. centered
  4. class="importGuide-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="导入"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="800">
  11. <div class="importGuide-con">
  12. <div class="explain-con">
  13. <div class="explain-item">
  14. <div class="explain-tit">
  15. <span>1</span>准备导入
  16. </div>
  17. <ul>
  18. <li>1)请先下载导入模板,模板中已标示出必填项 </li>
  19. <li>2) “经销商名称”具有唯一性,需输入完整经销商名称,不能为空,不可重复,需是系统中已存在的经销商</li>
  20. <li>
  21. <a :href="filePath" style="margin: 5px 0 0;display: block;">
  22. <a-icon type="download" style="padding-right: 5px;" />下载导入模板
  23. </a>
  24. </li>
  25. </ul>
  26. </div>
  27. <div class="explain-item">
  28. <div class="explain-tit">
  29. <span>2</span>上传数据文件
  30. </div>
  31. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  32. <div style="overflow: hidden;padding-left: 23px;">
  33. <Upload
  34. id="importGuide-attachList"
  35. ref="importUpload"
  36. :maxNums="1"
  37. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  38. uploadType="attach"
  39. :action="attachAction"
  40. upText="选择导入文件"
  41. @remove="resetSearchForm"
  42. @change="changeImport"></Upload>
  43. </div>
  44. </div>
  45. </div>
  46. <!-- 按钮 -->
  47. <div class="btn-con">
  48. <a-button
  49. type="primary"
  50. id="importGuide-nextStep"
  51. size="large"
  52. class="button-primary"
  53. @click="handlerNextStep"
  54. style="padding: 0 60px;">下一步</a-button>
  55. <a-button
  56. id="importGuide-cancel"
  57. size="large"
  58. class="button-cancel"
  59. @click="isShow=false"
  60. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  61. </div>
  62. </div>
  63. <!-- 导入 -->
  64. <chooseImportModal ref="chooseImportBox" :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  65. </a-modal>
  66. </template>
  67. <script>
  68. import ChooseImportModal from './chooseImportDealerModal.vue'
  69. import { Upload } from '@/components'
  70. export default {
  71. name: 'ImportGuideModal',
  72. components: { ChooseImportModal, Upload },
  73. props: {
  74. openModal: { // 弹框显示状态
  75. type: Boolean,
  76. default: false
  77. },
  78. params: {
  79. type: Object,
  80. default: null
  81. }
  82. },
  83. data () {
  84. return {
  85. isShow: this.openModal, // 是否打开弹框
  86. openImportModal: false, // 导入
  87. attachAction: process.env.VUE_APP_API_BASE_URL + '/promotion/dealer/importDealer', // 导入门槛、正价、促销产品
  88. paramsData: null,
  89. filePath: ''
  90. }
  91. },
  92. methods: {
  93. // 清空数据
  94. resetSearchForm () {
  95. this.$refs.importUpload.setFileList() // 清空导入文件
  96. this.paramsData = null // 清空上传数据
  97. },
  98. // 下一步
  99. handlerNextStep () {
  100. if (this.paramsData) {
  101. this.openImportModal = true
  102. } else {
  103. this.$message.warning('添加文件后再进行下一步操作!')
  104. }
  105. },
  106. // 上传文件 change
  107. changeImport (file) {
  108. if (file && JSON.parse(file).length > 0) {
  109. this.paramsData = Object.assign({}, JSON.parse(file)[0] || null, this.params)
  110. } else {
  111. this.paramsData = null
  112. }
  113. },
  114. // 导入
  115. hanldeOk (obj) {
  116. if (obj && obj.length > 0) {
  117. this.$emit('ok', obj)
  118. this.isShow = false
  119. }
  120. },
  121. // 关闭
  122. handleClose () {
  123. this.openImportModal = false
  124. this.isShow = false
  125. }
  126. },
  127. watch: {
  128. // 父页面传过来的弹框状态
  129. openModal (newValue, oldValue) {
  130. this.isShow = newValue
  131. },
  132. // 重定义的弹框状态
  133. isShow (newValue, oldValue) {
  134. if (!newValue) {
  135. this.$emit('close')
  136. this.resetSearchForm()
  137. } else {
  138. this.filePath = location.protocol + '//' + location.host + '/templ/参与客户导入列表模板.xlsx'
  139. }
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="less" scoped>
  145. .importGuide-modal{
  146. .importGuide-con{
  147. .explain-con{
  148. .explain-item{
  149. margin-bottom: 10px;
  150. .explain-tit{
  151. font-weight: bold;
  152. span{
  153. display: inline-block;
  154. width: 18px;
  155. height: 18px;
  156. line-height: 16px;
  157. text-align: center;
  158. margin-right: 5px;
  159. border-radius: 50%;
  160. border: 1px solid rgba(0, 0, 0, 0.3);
  161. }
  162. }
  163. p{
  164. margin: 8px 0;
  165. padding-left: 23px;
  166. }
  167. ul{
  168. list-style: none;
  169. padding: 0;
  170. padding-left: 23px;
  171. margin: 0;
  172. li{
  173. line-height: 26px;
  174. }
  175. }
  176. }
  177. #importGuide-attachList{
  178. width: 100%;
  179. }
  180. }
  181. .btn-con{
  182. margin: 10px 0 20px;
  183. text-align: center;
  184. .button-cancel{
  185. font-size: 12px;
  186. }
  187. }
  188. }
  189. }
  190. </style>