importGuideModal.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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="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. <ul>
  18. <li>1) 请先下载导入模板,模板中已标示出必填项</li>
  19. <li>2) 产品编码具有唯一性,{{ guideType=='1'?'系统中已存在的无法导入':'下线导入,必须是系统中已存在的产品编码' }}</li>
  20. <li v-if="guideType=='1'">3) 产品品牌、产品分类、单位、包装数单位,必须是系统中已经存在的值,否则无法导入</li>
  21. <li v-if="guideType=='2'"><a :href="filePath" style="margin: 5px 0 0 15px;display: block;">
  22. <a-icon type="download" style="padding-right: 5px;" />下载导入模板
  23. </a></li>
  24. </ul>
  25. <a-button
  26. v-if="guideType=='1'"
  27. type="link"
  28. icon="download"
  29. style="padding: 0 0 0 23px;"
  30. :loading="exportLoading"
  31. @click="handleExport">下载导入模板</a-button>
  32. </div>
  33. <div class="explain-item">
  34. <div class="explain-tit">
  35. <span>2</span>上传数据文件
  36. </div>
  37. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  38. <div style="overflow: hidden;padding-left: 23px;">
  39. <Upload
  40. id="importGuide-attachList"
  41. ref="importUpload"
  42. :maxNums="1"
  43. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  44. uploadType="import"
  45. :action="attachAction"
  46. :uploadParams="uploadParams"
  47. upText="添加文件"
  48. @change="changeImport"></Upload>
  49. </div>
  50. </div>
  51. </div>
  52. <!-- 按钮 -->
  53. <div class="btn-con">
  54. <a-button
  55. type="primary"
  56. id="importGuide-nextStep"
  57. size="large"
  58. class="button-primary"
  59. @click="handlerNextStep"
  60. style="padding: 0 60px;">下一步</a-button>
  61. <a-button
  62. id="importGuide-cancel"
  63. size="large"
  64. class="button-cancel"
  65. @click="isShow=false"
  66. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  67. </div>
  68. </div>
  69. <!-- 导入 -->
  70. <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  71. <offlineImportModal :openModal="openOfflineImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  72. </a-modal>
  73. </template>
  74. <script>
  75. import { commonMixin } from '@/utils/mixin'
  76. import ChooseImportModal from './chooseImportModal.vue'
  77. import offlineImportModal from './offlineImportModal.vue'
  78. import { Upload } from '@/components'
  79. export default {
  80. name: 'SalesImportGuideModal',
  81. mixins: [commonMixin],
  82. components: { ChooseImportModal, offlineImportModal, Upload },
  83. props: {
  84. openModal: { // 弹框显示状态
  85. type: Boolean,
  86. default: false
  87. },
  88. params: {
  89. type: Object,
  90. default: null
  91. },
  92. guideType: {
  93. type: String,
  94. default: ''
  95. }
  96. },
  97. data () {
  98. return {
  99. isShow: this.openModal, // 是否打开弹框
  100. openImportModal: false, // 导入
  101. attachAction: process.env.VUE_APP_API_BASE_URL + '/upload',
  102. paramsData: null,
  103. uploadParams: {
  104. savePathType: 'local'
  105. },
  106. exportLoading: false,
  107. openOfflineImportModal: false,
  108. filePath: location.protocol + '//' + location.host + '/templ/批量下线导入模板.xlsx'
  109. }
  110. },
  111. methods: {
  112. // 下一步
  113. handlerNextStep () {
  114. const _this = this
  115. if (_this.paramsData) {
  116. if (_this.guideType == 1) {
  117. _this.openImportModal = true
  118. } else {
  119. _this.openOfflineImportModal = true
  120. }
  121. } else {
  122. _this.$message.warning('添加文件后再进行下一步操作!')
  123. }
  124. },
  125. // 上传文件 change
  126. changeImport (file) {
  127. if (file) {
  128. this.paramsData = {
  129. path: file
  130. }
  131. }
  132. },
  133. // 导入
  134. hanldeOk (obj) {
  135. if (obj) {
  136. this.$emit('ok', obj)
  137. this.isShow = false
  138. }
  139. },
  140. // 关闭
  141. handleClose () {
  142. this.openImportModal = false
  143. this.openOfflineImportModal = false
  144. this.isShow = false
  145. },
  146. // 下载模板
  147. handleExport () {
  148. this.exportLoading = true
  149. setTimeout(() => {
  150. this.exportLoading = false
  151. }, 1000)
  152. const link = document.createElement('a')
  153. link.style.display = 'none'
  154. // link.href = 'https://jg-ocs.oss-cn-beijing.aliyuncs.com/templ/promo/productImport.xlsx?t=' + new Date().getTime()
  155. link.href = location.protocol + '//' + location.host + '/templ/产品批量导入模板.xlsx'
  156. link.setAttribute('download', '产品批量导入模板' + '.xlsx')
  157. document.body.appendChild(link)
  158. link.click()
  159. document.body.removeChild(link)
  160. }
  161. },
  162. watch: {
  163. // 父页面传过来的弹框状态
  164. openModal (newValue, oldValue) {
  165. this.isShow = newValue
  166. },
  167. // 重定义的弹框状态
  168. isShow (newValue, oldValue) {
  169. if (!newValue) {
  170. this.$emit('close')
  171. this.paramsData = null
  172. this.$refs.importUpload.setFileList('')
  173. }
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="less" scoped>
  179. .importGuide-modal{
  180. .importGuide-con{
  181. .explain-con{
  182. .explain-item{
  183. margin-bottom: 10px;
  184. .explain-tit{
  185. font-weight: bold;
  186. span{
  187. display: inline-block;
  188. width: 18px;
  189. height: 18px;
  190. line-height: 16px;
  191. text-align: center;
  192. margin-right: 5px;
  193. border-radius: 50%;
  194. border: 1px solid rgba(0, 0, 0, 0.3);
  195. }
  196. }
  197. p{
  198. margin: 8px 0;
  199. padding-left: 23px;
  200. }
  201. ul{
  202. list-style: none;
  203. padding: 0;
  204. padding-left: 23px;
  205. margin: 0;
  206. li{
  207. line-height: 26px;
  208. }
  209. }
  210. }
  211. #importGuide-attachList{
  212. width: 100%;
  213. }
  214. }
  215. .btn-con{
  216. margin: 10px 0 20px;
  217. text-align: center;
  218. .button-cancel{
  219. font-size: 12px;
  220. }
  221. }
  222. }
  223. }
  224. </style>