importGuideModal.vue 6.6 KB

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