importGuideModal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. <p>请按照下载的Excel模板填写数据</p>
  18. <a-button type="link" icon="download" style="padding: 0 0 0 23px;" @click="handleExport">下载模板</a-button>
  19. </div>
  20. <div class="explain-item">
  21. <div class="explain-tit">
  22. <span>2</span>准备导入数据
  23. </div>
  24. <ul>
  25. <li>1) 导入的Excel文件中必须包含名为“货位号”、“产品编码”、“销售价”、“结算价”、“最大库容”的列,且名称必须相同</li>
  26. <li>2) 除了“货位号”、“产品编码”、“销售价”、“结算价”、“最大库容”四列,其他列可自定义,不影响数据导入</li>
  27. </ul>
  28. </div>
  29. <div class="explain-item">
  30. <div class="explain-tit">
  31. <span>3</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 { hdPrint } from '@/libs/JGPrint.js'
  71. import ChooseImportModal from './chooseImportModal.vue'
  72. import { Upload } from '@/components'
  73. import { shelfProductDownload } from '@/api/shelf'
  74. export default {
  75. name: 'ImportGuideModal',
  76. components: { ChooseImportModal, Upload },
  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 + '/upload',
  92. paramsData: null,
  93. uploadParams: {
  94. savePathType: 'local'
  95. }
  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. shelfSn: this.params.shelfSn || '',
  112. path: file
  113. }
  114. }
  115. },
  116. // 导入
  117. hanldeOk (obj) {
  118. if (obj && obj.length > 0) {
  119. this.$emit('ok', obj)
  120. this.isShow = false
  121. }
  122. },
  123. // 关闭
  124. handleClose () {
  125. this.openImportModal = false
  126. this.isShow = false
  127. },
  128. // 导出
  129. handleExport () {
  130. const _this = this
  131. _this.spinning = true
  132. // 导出
  133. hdPrint('', 'export', shelfProductDownload, _this.params, '导入绑定产品模板', function () {
  134. _this.spinning = false
  135. })
  136. }
  137. },
  138. watch: {
  139. // 父页面传过来的弹框状态
  140. openModal (newValue, oldValue) {
  141. this.isShow = newValue
  142. },
  143. // 重定义的弹框状态
  144. isShow (newValue, oldValue) {
  145. if (!newValue) {
  146. this.$emit('close')
  147. this.paramsData = null
  148. this.$refs.importUpload.setFileList('')
  149. }
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="less" scoped>
  155. .importGuide-modal{
  156. .importGuide-con{
  157. .explain-con{
  158. .explain-item{
  159. margin-bottom: 10px;
  160. .explain-tit{
  161. font-weight: bold;
  162. span{
  163. display: inline-block;
  164. width: 18px;
  165. height: 18px;
  166. line-height: 16px;
  167. text-align: center;
  168. margin-right: 5px;
  169. border-radius: 50%;
  170. border: 1px solid rgba(0, 0, 0, 0.3);
  171. }
  172. }
  173. p{
  174. margin: 8px 0;
  175. padding-left: 23px;
  176. }
  177. ul{
  178. list-style: none;
  179. padding: 0;
  180. padding-left: 23px;
  181. margin: 0;
  182. li{
  183. line-height: 26px;
  184. }
  185. }
  186. }
  187. #importGuide-attachList{
  188. width: 100%;
  189. }
  190. }
  191. .btn-con{
  192. margin: 10px 0 20px;
  193. text-align: center;
  194. .button-cancel{
  195. font-size: 12px;
  196. }
  197. }
  198. }
  199. }
  200. </style>