importGuideModal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 { commonMixin } from '@/utils/mixin'
  66. import ChooseImportModal from './chooseImportModal.vue'
  67. import { Upload } from '@/components'
  68. import { hdExportExcel } from '@/libs/exportExcel'
  69. import { salesDownload } from '@/api/salesDetail'
  70. export default {
  71. name: 'SalesImportGuideModal',
  72. mixins: [commonMixin],
  73. components: { ChooseImportModal, Upload },
  74. props: {
  75. openModal: { // 弹框显示状态
  76. type: Boolean,
  77. default: false
  78. },
  79. params: {
  80. type: Object,
  81. default: null
  82. }
  83. },
  84. data () {
  85. return {
  86. isShow: this.openModal, // 是否打开弹框
  87. openImportModal: false, // 导入
  88. attachAction: process.env.VUE_APP_API_BASE_URL + '/upload',
  89. paramsData: null,
  90. uploadParams: {
  91. savePathType: 'local'
  92. },
  93. exportLoading: false
  94. }
  95. },
  96. methods: {
  97. // 下一步
  98. handlerNextStep () {
  99. if (this.paramsData) {
  100. this.openImportModal = true
  101. } else {
  102. this.$message.warning('添加文件后再进行下一步操作!')
  103. }
  104. },
  105. // 上传文件 change
  106. changeImport (file) {
  107. if (file) {
  108. this.paramsData = {
  109. salesBillSn: this.params.salesBillSn || '',
  110. path: file
  111. }
  112. }
  113. },
  114. // 导入
  115. hanldeOk (obj) {
  116. if (obj && obj.length > 0) {
  117. this.$emit('ok', obj)
  118. this.isShow = false
  119. }
  120. },
  121. // 关闭
  122. handleClose () {
  123. this.openImportModal = false
  124. this.isShow = false
  125. },
  126. // 导出
  127. handleExport () {
  128. const _this = this
  129. const params = { grabFlag: this.params.grabFlag }
  130. this.exportLoading = true
  131. this.spinning = true
  132. setTimeout(() => {
  133. _this.exportLoading = false
  134. }, 1000)
  135. hdExportExcel(salesDownload, params, '销售导入模板', function () {
  136. _this.spinning = false
  137. })
  138. }
  139. },
  140. watch: {
  141. // 父页面传过来的弹框状态
  142. openModal (newValue, oldValue) {
  143. this.isShow = newValue
  144. },
  145. // 重定义的弹框状态
  146. isShow (newValue, oldValue) {
  147. if (!newValue) {
  148. this.$emit('close')
  149. this.paramsData = null
  150. this.$refs.importUpload.setFileList('')
  151. }
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="less" scoped>
  157. .importGuide-modal{
  158. .importGuide-con{
  159. .explain-con{
  160. .explain-item{
  161. margin-bottom: 10px;
  162. .explain-tit{
  163. font-weight: bold;
  164. span{
  165. display: inline-block;
  166. width: 18px;
  167. height: 18px;
  168. line-height: 16px;
  169. text-align: center;
  170. margin-right: 5px;
  171. border-radius: 50%;
  172. border: 1px solid rgba(0, 0, 0, 0.3);
  173. }
  174. }
  175. p{
  176. margin: 8px 0;
  177. padding-left: 23px;
  178. }
  179. ul{
  180. list-style: none;
  181. padding: 0;
  182. padding-left: 23px;
  183. margin: 0;
  184. li{
  185. line-height: 26px;
  186. }
  187. }
  188. }
  189. #importGuide-attachList{
  190. width: 100%;
  191. }
  192. }
  193. .btn-con{
  194. margin: 10px 0 20px;
  195. text-align: center;
  196. .button-cancel{
  197. font-size: 12px;
  198. }
  199. }
  200. }
  201. }
  202. </style>