importGuideModal.vue 5.7 KB

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