importGuideModal.vue 5.1 KB

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