importGuideModal.vue 5.8 KB

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