importGuideModal.vue 5.0 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. @cancle="isShow=false"
  10. :width="750">
  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. <p>所有允许导入的数据字段请参考模板,数据字段不符合规则,整条不予以导入。</p>
  18. <ul>
  19. <li>1) “产品编码”字段为必填项。</li>
  20. <li>2) “起订量限制“为选项,只可选择”按整箱‘或者“按设置数量”,选择“按设置数量”时,“起订数量”为必填项。</li>
  21. </ul>
  22. <a-button type="link" icon="download">下载导入模板</a-button>
  23. </div>
  24. <div class="explain-item">
  25. <div class="explain-tit">
  26. <span>2</span>上传数据文件
  27. </div>
  28. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  29. <p>
  30. <Upload
  31. id="importGuide-attachList"
  32. ref="importUpload"
  33. :maxNums="1"
  34. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  35. uploadType="import"
  36. :action="attachAction"
  37. :uploadParams="uploadParams"
  38. upText="添加文件"
  39. @change="changeImport"></Upload>
  40. </p>
  41. </div>
  42. </div>
  43. <!-- 按钮 -->
  44. <div class="btn-con">
  45. <a-button
  46. type="primary"
  47. id="importGuide-nextStep"
  48. size="large"
  49. class="button-primary"
  50. @click="handlerNextStep"
  51. style="padding: 0 60px;">下一步</a-button>
  52. <a-button
  53. id="importGuide-cancel"
  54. size="large"
  55. class="button-cancel"
  56. @click="isShow=false"
  57. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  58. </div>
  59. </div>
  60. <!-- 导入 -->
  61. <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  62. </a-modal>
  63. </template>
  64. <script>
  65. import ChooseImportModal from '@/views/common/chooseImportModal.vue'
  66. import { Upload } from '@/components'
  67. export default {
  68. name: 'ImportGuideModal',
  69. components: { ChooseImportModal, Upload },
  70. props: {
  71. openModal: { // 弹框显示状态
  72. type: Boolean,
  73. default: false
  74. },
  75. params: {
  76. type: Object,
  77. default: null
  78. },
  79. type: { // 类型,促销promo
  80. type: String,
  81. default: ''
  82. }
  83. },
  84. data () {
  85. return {
  86. isShow: this.openModal, // 是否打开弹框
  87. openImportModal: false, // 导入
  88. attachAction: process.env.VUE_APP_API_BASE_URL + '/upload',
  89. paramsData: null
  90. }
  91. },
  92. computed: {
  93. uploadParams () {
  94. const obj = {
  95. savePathType: 'local'
  96. }
  97. return obj
  98. }
  99. },
  100. methods: {
  101. // 下一步
  102. handlerNextStep () {
  103. if (this.paramsData) {
  104. this.openImportModal = true
  105. } else {
  106. this.$message.warning('添加文件后再进行下一步操作!')
  107. }
  108. },
  109. // 上传文件 change
  110. changeImport (file) {
  111. if (file) {
  112. this.paramsData = {
  113. promoRuleType: this.params.promoRuleType || '',
  114. promoGoodsType: this.params.promoGoodsType || '',
  115. path: file
  116. }
  117. }
  118. },
  119. // 导入
  120. hanldeOk (obj) {
  121. if (obj && obj.length > 0) {
  122. this.$emit('ok', obj)
  123. this.isShow = false
  124. }
  125. },
  126. // 关闭
  127. handleClose () {
  128. this.openImportModal = false
  129. this.isShow = false
  130. }
  131. },
  132. watch: {
  133. // 父页面传过来的弹框状态
  134. openModal (newValue, oldValue) {
  135. this.isShow = newValue
  136. },
  137. // 重定义的弹框状态
  138. isShow (newValue, oldValue) {
  139. if (!newValue) {
  140. this.$emit('close')
  141. this.paramsData = null
  142. this.$refs.importUpload.setFileList('')
  143. }
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="less" scoped>
  149. .importGuide-modal{
  150. .importGuide-con{
  151. .explain-con{
  152. .explain-item{
  153. margin-bottom: 10px;
  154. .explain-tit{
  155. font-weight: bold;
  156. span{
  157. display: inline-block;
  158. width: 18px;
  159. height: 18px;
  160. line-height: 16px;
  161. text-align: center;
  162. margin-right: 5px;
  163. border-radius: 50%;
  164. border: 1px solid rgba(0, 0, 0, 0.3);
  165. }
  166. }
  167. p{
  168. margin: 8px 0;
  169. padding-left: 23px;
  170. }
  171. ul{
  172. list-style: none;
  173. padding: 0;
  174. padding-left: 23px;
  175. margin: 0;
  176. li{
  177. line-height: 26px;
  178. }
  179. }
  180. }
  181. }
  182. .btn-con{
  183. margin: 60px 0 20px;
  184. .button-cancel{
  185. font-size: 12px;
  186. }
  187. }
  188. }
  189. }
  190. </style>