importGuideModal.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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>2) “产品编码”必须是系统中已存在的产品</li>
  20. <li>3) “仓库”必须是系统中已存在的仓库</li>
  21. <li>4) “货位编号”可为空,为空表示此产品没有货位信息</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="import"
  41. :action="attachAction"
  42. :uploadParams="uploadParams"
  43. upText="添加文件"
  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 :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. },
  85. data () {
  86. return {
  87. isShow: this.openModal, // 是否打开弹框
  88. openImportModal: false, // 导入
  89. attachAction: process.env.VUE_APP_API_BASE_URL + '/upload',
  90. paramsData: null,
  91. uploadParams: {
  92. savePathType: 'local'
  93. },
  94. exportLoading: false,
  95. filePath: location.protocol + '//' + location.host + '/templ/货位编号管理导入模板.xlsx'
  96. }
  97. },
  98. methods: {
  99. // 下一步
  100. handlerNextStep () {
  101. if (this.paramsData) {
  102. this.openImportModal = true
  103. } else {
  104. this.$message.warning('添加文件后再进行下一步操作!')
  105. }
  106. },
  107. // 上传文件 change
  108. changeImport (file) {
  109. if (file) {
  110. this.paramsData = {
  111. path: file
  112. }
  113. }
  114. },
  115. // 导入
  116. hanldeOk (obj) {
  117. if (obj && obj.length > 0) {
  118. this.$emit('ok', obj)
  119. this.isShow = false
  120. }
  121. },
  122. // 关闭
  123. handleClose () {
  124. this.openImportModal = false
  125. this.isShow = false
  126. }
  127. },
  128. watch: {
  129. // 父页面传过来的弹框状态
  130. openModal (newValue, oldValue) {
  131. this.isShow = newValue
  132. },
  133. // 重定义的弹框状态
  134. isShow (newValue, oldValue) {
  135. if (!newValue) {
  136. this.$emit('close')
  137. this.paramsData = null
  138. this.$refs.importUpload.setFileList('')
  139. }
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="less" scoped>
  145. .importGuide-modal{
  146. .importGuide-con{
  147. .explain-con{
  148. .explain-item{
  149. margin-bottom: 10px;
  150. .explain-tit{
  151. font-weight: bold;
  152. span{
  153. display: inline-block;
  154. width: 18px;
  155. height: 18px;
  156. line-height: 16px;
  157. text-align: center;
  158. margin-right: 5px;
  159. border-radius: 50%;
  160. border: 1px solid rgba(0, 0, 0, 0.3);
  161. }
  162. }
  163. p{
  164. margin: 8px 0;
  165. padding-left: 23px;
  166. }
  167. ul{
  168. list-style: none;
  169. padding: 0;
  170. padding-left: 23px;
  171. margin: 0;
  172. li{
  173. line-height: 26px;
  174. }
  175. }
  176. }
  177. #importGuide-attachList{
  178. width: 100%;
  179. }
  180. }
  181. .btn-con{
  182. margin: 10px 0 20px;
  183. text-align: center;
  184. .button-cancel{
  185. font-size: 12px;
  186. }
  187. }
  188. }
  189. }
  190. </style>