importPriceModal.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. <ul>
  18. <li>1)必填项为"产品编码"、"经销商批发价"、"终端价"和"车主价"。</li>
  19. <li>2)产品编码必须是已存在的产品(注:若已存在的产品已有价格,最新导入价格会替换原有价格)。</li>
  20. <li>3)支持上传文件格式:.xls、.xlsx。</li>
  21. <li><a :href="templUrl" id="importGuide-tpl-link"><a-icon type="download" />下载导入模板</a></li>
  22. </ul>
  23. </div>
  24. <div class="explain-item">
  25. <div class="explain-tit">
  26. <span>2</span>上传数据文件
  27. </div>
  28. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  29. <div style="overflow: hidden;padding-left: 23px;">
  30. <Upload
  31. id="importGuide-attachList"
  32. ref="importUpload"
  33. :maxNums="1"
  34. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  35. uploadType="import"
  36. :action="attachAction"
  37. :uploadParams="uploadParams"
  38. upText="选择导入文件"
  39. @change="changeImport"></Upload>
  40. </div>
  41. </div>
  42. </div>
  43. <!-- 按钮 -->
  44. <div class="btn-con">
  45. <a-button
  46. type="primary"
  47. id="importGuide-nextStep"
  48. size="large"
  49. class="button-primary"
  50. @click="handlerNextStep"
  51. style="padding: 0 60px;">下一步</a-button>
  52. <a-button
  53. id="importGuide-cancel"
  54. size="large"
  55. class="button-cancel"
  56. @click="isShow=false"
  57. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  58. </div>
  59. </div>
  60. <!-- 导入 -->
  61. <chooseImportPriceModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  62. </a-modal>
  63. </template>
  64. <script>
  65. // 组件
  66. import { Upload } from '@/components'
  67. import chooseImportPriceModal from './chooseImportPriceModal.vue'
  68. export default {
  69. name: 'ChooseImportPriceModal',
  70. components: { chooseImportPriceModal, Upload },
  71. props: {
  72. openModal: { // 弹框显示状态
  73. type: Boolean,
  74. default: false
  75. },
  76. params: {
  77. type: Object,
  78. default: null
  79. }
  80. },
  81. data () {
  82. return {
  83. isShow: this.openModal, // 是否打开弹框
  84. openImportModal: false, // 导入
  85. attachAction: process.env.VUE_APP_API_BASE_URL + '/upload',
  86. paramsData: null,
  87. uploadParams: {
  88. savePathType: 'local'
  89. },
  90. templUrl: location.protocol + '//' + location.host + '/templ/批量修改产品价格模板.xlsx'
  91. }
  92. },
  93. methods: {
  94. // 清空数据
  95. resetSearchForm () {
  96. this.$refs.importUpload.setFileList() // 清空导入文件
  97. this.paramsData = null // 清空上传数据
  98. },
  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. console.log(file)
  110. if (file) {
  111. this.paramsData = {
  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. watch: {
  130. // 父页面传过来的弹框状态
  131. openModal (newValue, oldValue) {
  132. this.isShow = newValue
  133. },
  134. // 重定义的弹框状态
  135. isShow (newValue, oldValue) {
  136. if (!newValue) {
  137. this.$emit('close')
  138. this.paramsData = null
  139. this.$refs.importUpload.setFileList('')
  140. }
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="less" scoped>
  146. .importGuide-modal{
  147. .importGuide-con{
  148. .explain-con{
  149. .explain-item{
  150. margin-bottom: 10px;
  151. .explain-tit{
  152. font-weight: bold;
  153. span{
  154. display: inline-block;
  155. width: 18px;
  156. height: 18px;
  157. line-height: 16px;
  158. text-align: center;
  159. margin-right: 5px;
  160. border-radius: 50%;
  161. border: 1px solid rgba(0, 0, 0, 0.3);
  162. }
  163. }
  164. p{
  165. margin: 8px 0;
  166. padding-left: 23px;
  167. }
  168. ul{
  169. list-style: none;
  170. padding: 0;
  171. padding-left: 23px;
  172. margin: 0;
  173. li{
  174. line-height: 26px;
  175. }
  176. }
  177. }
  178. #importGuide-attachList{
  179. width: 100%;
  180. }
  181. }
  182. .btn-con{
  183. margin: 10px 0 20px;
  184. text-align: center;
  185. .button-cancel{
  186. font-size: 12px;
  187. }
  188. }
  189. }
  190. }
  191. </style>