importGuideModal.vue 5.9 KB

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