importGuideModal.vue 5.4 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="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 :href="filePath" style="padding: 5px 0 0 23px;display: block;">
  19. <a-icon type="download" style="padding-right: 5px;" />下载导入模板
  20. </a>
  21. </div>
  22. <div class="explain-item">
  23. <div class="explain-tit">
  24. <span>2</span>准备导入数据
  25. </div>
  26. <ul>
  27. <li>1) 导入的Excel文件中必须包含名为“货位号”、“产品编码”、“车主价”、“结算价”、“最大库容”的列,且名称必须相同</li>
  28. <li>2) 除了“货位号”、“产品编码”、“车主价”、“结算价”、“最大库容”四列,其他列可自定义,不影响数据导入</li>
  29. </ul>
  30. </div>
  31. <div class="explain-item">
  32. <div class="explain-tit">
  33. <span>3</span>上传数据文件
  34. </div>
  35. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  36. <div style="overflow: hidden;padding-left: 23px;">
  37. <Upload
  38. id="importGuide-attachList"
  39. ref="importUpload"
  40. :maxNums="1"
  41. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  42. uploadType="import"
  43. :action="attachAction"
  44. :uploadParams="uploadParams"
  45. upText="添加文件"
  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 { hdPrint } from '@/libs/JGPrint.js'
  73. import ChooseImportModal from './chooseImportModal.vue'
  74. import { Upload } from '@/components'
  75. export default {
  76. name: 'ImportGuideModal',
  77. components: { ChooseImportModal, Upload },
  78. props: {
  79. openModal: { // 弹框显示状态
  80. type: Boolean,
  81. default: false
  82. },
  83. params: { // 参数
  84. type: Object,
  85. default: null
  86. }
  87. },
  88. data () {
  89. return {
  90. isShow: this.openModal, // 是否打开弹框
  91. openImportModal: false, // 导入
  92. attachAction: process.env.VUE_APP_API_BASE_URL + '/upload',
  93. filePath: location.protocol + '//' + location.host + '/templ/绑定产品导入模板.xlsx',
  94. paramsData: null, // 参数
  95. uploadParams: {
  96. savePathType: 'local' // 保存到本地
  97. }
  98. }
  99. },
  100. methods: {
  101. // 下一步
  102. handlerNextStep () {
  103. if (this.paramsData) {
  104. this.openImportModal = true
  105. } else {
  106. this.$message.warning('添加文件后再进行下一步操作!')
  107. }
  108. },
  109. // 上传文件 change
  110. changeImport (file) {
  111. if (file) {
  112. this.paramsData = {
  113. shelfSn: this.params.shelfSn || '',
  114. path: file
  115. }
  116. }
  117. },
  118. // 导入
  119. hanldeOk (obj) {
  120. if (obj && obj.length > 0) {
  121. this.$emit('ok', obj)
  122. this.isShow = false
  123. }
  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.paramsData = null
  141. this.$refs.importUpload.setFileList('')
  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>