importGuideModal.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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="attach"
  43. :action="attachAction"
  44. :uploadParams="uploadParams"
  45. upText="选择导入文件"
  46. @remove="resetSearchForm"
  47. @change="changeImport"></Upload>
  48. </div>
  49. </div>
  50. </div>
  51. <!-- 按钮 -->
  52. <div class="btn-con">
  53. <a-button
  54. type="primary"
  55. id="importGuide-nextStep"
  56. size="large"
  57. class="button-primary"
  58. @click="handlerNextStep"
  59. style="padding: 0 60px;">下一步</a-button>
  60. <a-button
  61. id="importGuide-cancel"
  62. size="large"
  63. class="button-cancel"
  64. @click="isShow=false"
  65. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  66. </div>
  67. </div>
  68. <!-- 导入 -->
  69. <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  70. </a-modal>
  71. </template>
  72. <script>
  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 + '/shelfTemplate/detail/importDetail',
  93. filePath: location.protocol + '//' + location.host + '/templ/绑定产品导入模板.xlsx',
  94. paramsData: null,
  95. uploadParams: { // 参数
  96. savePathType: 'local',
  97. templateSn: this.params.templateSn
  98. }
  99. }
  100. },
  101. methods: {
  102. // 清空数据
  103. resetSearchForm () {
  104. this.$refs.importUpload.setFileList() // 清空导入文件
  105. this.paramsData = null // 清空上传数据
  106. },
  107. // 下一步
  108. handlerNextStep () {
  109. if (this.paramsData) {
  110. this.openImportModal = true
  111. } else {
  112. this.$message.warning('添加文件后再进行下一步操作!')
  113. }
  114. },
  115. // 上传文件 change
  116. changeImport (file) {
  117. if (file && JSON.parse(file).length > 0) {
  118. this.paramsData = Object.assign({}, JSON.parse(file)[0] || null, this.params)
  119. } else {
  120. this.paramsData = null
  121. }
  122. },
  123. // 导入
  124. hanldeOk (obj) {
  125. if (obj && obj.length > 0) {
  126. this.$emit('ok', obj)
  127. this.isShow = false
  128. }
  129. },
  130. // 关闭
  131. handleClose () {
  132. this.openImportModal = false
  133. this.isShow = false
  134. }
  135. },
  136. watch: {
  137. // 父页面传过来的弹框状态
  138. openModal (newValue, oldValue) {
  139. this.isShow = newValue
  140. },
  141. // 重定义的弹框状态
  142. isShow (newValue, oldValue) {
  143. if (!newValue) {
  144. this.$emit('close')
  145. this.paramsData = null
  146. this.$refs.importUpload.setFileList('')
  147. }
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="less" scoped>
  153. .importGuide-modal{
  154. .importGuide-con{
  155. .explain-con{
  156. .explain-item{
  157. margin-bottom: 10px;
  158. .explain-tit{
  159. font-weight: bold;
  160. span{
  161. display: inline-block;
  162. width: 18px;
  163. height: 18px;
  164. line-height: 16px;
  165. text-align: center;
  166. margin-right: 5px;
  167. border-radius: 50%;
  168. border: 1px solid rgba(0, 0, 0, 0.3);
  169. }
  170. }
  171. p{
  172. margin: 8px 0;
  173. padding-left: 23px;
  174. }
  175. ul{
  176. list-style: none;
  177. padding: 0;
  178. padding-left: 23px;
  179. margin: 0;
  180. li{
  181. line-height: 26px;
  182. }
  183. }
  184. }
  185. #importGuide-attachList{
  186. width: 100%;
  187. }
  188. }
  189. .btn-con{
  190. margin: 10px 0 20px;
  191. text-align: center;
  192. .button-cancel{
  193. font-size: 12px;
  194. }
  195. }
  196. }
  197. }
  198. </style>