importGuideModal.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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
  23. id="importGuide-download"
  24. type="link"
  25. icon="download"
  26. style="padding: 0 0 0 23px;"
  27. :loading="exportLoading"
  28. @click="handleExport">下载导入模板</a-button>
  29. </div>
  30. <div class="explain-item">
  31. <div class="explain-tit">
  32. <span>2</span>上传数据文件
  33. </div>
  34. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  35. <div style="overflow: hidden;padding-left: 23px;">
  36. <Upload
  37. id="importGuide-attachList"
  38. ref="importUpload"
  39. :maxNums="1"
  40. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  41. uploadType="import"
  42. :action="attachAction"
  43. :uploadParams="uploadParams"
  44. upText="添加文件"
  45. @change="changeImport"></Upload>
  46. </div>
  47. </div>
  48. </div>
  49. <!-- 按钮 -->
  50. <div class="btn-con">
  51. <a-button
  52. type="primary"
  53. id="importGuide-nextStep"
  54. size="large"
  55. class="button-primary"
  56. @click="handlerNextStep"
  57. style="padding: 0 60px;">下一步</a-button>
  58. <a-button
  59. id="importGuide-cancel"
  60. size="large"
  61. class="button-cancel"
  62. @click="isShow=false"
  63. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  64. </div>
  65. </div>
  66. <!-- 导入 -->
  67. <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  68. </a-modal>
  69. </template>
  70. <script>
  71. import { hdExportExcel } from '@/libs/exportExcel'
  72. // 组件
  73. import ChooseImportModal from './chooseImportModal.vue'
  74. import { Upload } from '@/components'
  75. // 接口
  76. import { productPriceTplDownload } from '@/api/product'
  77. export default {
  78. name: 'ImportGuideModal',
  79. components: { ChooseImportModal, Upload },
  80. props: {
  81. openModal: { // 弹框显示状态
  82. type: Boolean,
  83. default: false
  84. },
  85. params: {
  86. type: Object,
  87. default: null
  88. }
  89. },
  90. data () {
  91. return {
  92. isShow: this.openModal, // 是否打开弹框
  93. exportLoading: false, // 导出按钮加载状态
  94. openImportModal: false, // 打开导入详情弹窗
  95. attachAction: process.env.VUE_APP_API_BASE_URL + '/upload', // 上传文件地址
  96. paramsData: null, // 导入数据
  97. uploadParams: {// 上传文件参数
  98. savePathType: 'local'
  99. }
  100. }
  101. },
  102. methods: {
  103. // 下一步
  104. handlerNextStep () {
  105. if (this.paramsData) {
  106. this.openImportModal = true
  107. } else {
  108. this.$message.warning('添加文件后再进行下一步操作!')
  109. }
  110. },
  111. // 上传文件 change
  112. changeImport (file) {
  113. if (file) {
  114. this.paramsData = {
  115. path: file
  116. }
  117. }
  118. },
  119. // 导入
  120. hanldeOk (obj) {
  121. if (obj && obj.length > 0) {
  122. this.$emit('ok', obj)
  123. this.isShow = false
  124. }
  125. },
  126. // 关闭
  127. handleClose () {
  128. this.openImportModal = false
  129. this.isShow = false
  130. },
  131. // 导出
  132. handleExport () {
  133. const _this = this
  134. _this.spinning = true
  135. _this.exportLoading = true
  136. setTimeout(() => {
  137. _this.exportLoading = false
  138. }, 1000)
  139. hdExportExcel(productPriceTplDownload, {}, '产品定价导入模板', function () {
  140. _this.spinning = false
  141. })
  142. }
  143. },
  144. watch: {
  145. // 父页面传过来的弹框状态
  146. openModal (newValue, oldValue) {
  147. this.isShow = newValue
  148. },
  149. // 重定义的弹框状态
  150. isShow (newValue, oldValue) {
  151. if (!newValue) {
  152. this.$emit('close')
  153. this.paramsData = null
  154. this.$refs.importUpload.setFileList('')
  155. }
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="less" scoped>
  161. .importGuide-modal{
  162. .importGuide-con{
  163. .explain-con{
  164. .explain-item{
  165. margin-bottom: 10px;
  166. .explain-tit{
  167. font-weight: bold;
  168. span{
  169. display: inline-block;
  170. width: 18px;
  171. height: 18px;
  172. line-height: 16px;
  173. text-align: center;
  174. margin-right: 5px;
  175. border-radius: 50%;
  176. border: 1px solid rgba(0, 0, 0, 0.3);
  177. }
  178. }
  179. p{
  180. margin: 8px 0;
  181. padding-left: 23px;
  182. }
  183. ul{
  184. list-style: none;
  185. padding: 0;
  186. padding-left: 23px;
  187. margin: 0;
  188. li{
  189. line-height: 26px;
  190. }
  191. }
  192. }
  193. #importGuide-attachList{
  194. width: 100%;
  195. }
  196. }
  197. .btn-con{
  198. margin: 10px 0 20px;
  199. text-align: center;
  200. .button-cancel{
  201. font-size: 12px;
  202. }
  203. }
  204. }
  205. }
  206. </style>