importGuideModal.vue 5.9 KB

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