importGuideModal.vue 4.9 KB

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