importGuideModal.vue 5.6 KB

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