importGuideModal.vue 5.0 KB

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