importGuideModal.vue 5.4 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. <ul>
  18. <li>1) 导入的Excel文件中必须包含名为“产品编码”的列,且名称必须相同</li>
  19. <li>2) “产品编码”必须是列表中已存在的产品</li>
  20. <li>3) 产品首次定价,省级价、市级价、特约价不可为空,再次定价导入时可为空,为空表示不对原有价格做改变</li>
  21. </ul>
  22. <a-button type="link" icon="download" style="padding: 0 0 0 23px;" :loading="exportLoading" @click="handleExport">下载导入模板</a-button>
  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. <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  62. </a-modal>
  63. </template>
  64. <script>
  65. import ChooseImportModal from './chooseImportModal.vue'
  66. import { Upload } from '@/components'
  67. import { hdExportExcel } from '@/libs/exportExcel'
  68. import { productPriceTplDownload } from '@/api/product'
  69. export default {
  70. name: 'ImportGuideModal',
  71. components: { ChooseImportModal, Upload },
  72. props: {
  73. openModal: { // 弹框显示状态
  74. type: Boolean,
  75. default: false
  76. },
  77. params: {
  78. type: Object,
  79. default: null
  80. }
  81. },
  82. data () {
  83. return {
  84. isShow: this.openModal, // 是否打开弹框
  85. openImportModal: false, // 导入
  86. attachAction: process.env.VUE_APP_API_BASE_URL + '/upload',
  87. paramsData: null,
  88. uploadParams: {
  89. savePathType: 'local'
  90. },
  91. exportLoading: false
  92. }
  93. },
  94. methods: {
  95. // 下一步
  96. handlerNextStep () {
  97. if (this.paramsData) {
  98. this.openImportModal = true
  99. } else {
  100. this.$message.warning('添加文件后再进行下一步操作!')
  101. }
  102. },
  103. // 上传文件 change
  104. changeImport (file) {
  105. if (file) {
  106. this.paramsData = {
  107. path: file
  108. }
  109. }
  110. },
  111. // 导入
  112. hanldeOk (obj) {
  113. if (obj && obj.length > 0) {
  114. this.$emit('ok', obj)
  115. this.isShow = false
  116. }
  117. },
  118. // 关闭
  119. handleClose () {
  120. this.openImportModal = false
  121. this.isShow = false
  122. },
  123. // 导出
  124. handleExport () {
  125. const _this = this
  126. _this.spinning = true
  127. _this.exportLoading = true
  128. setTimeout(() => {
  129. _this.exportLoading = false
  130. }, 1000)
  131. hdExportExcel(productPriceTplDownload, {}, '产品定价导入模板', function () {
  132. _this.spinning = false
  133. })
  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>