importGuideModal.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. <p>所有允许导入的数据字段请参考模板,数据字段不符合规则,整条不予以导入。</p>
  18. <ul>
  19. <li>1) “产品编码”字段为必填项。</li>
  20. <li>2) “起订量限制“为选项,只可选择”按整箱‘或者“按设置数量”,选择“按设置数量”时,“起订数量”为必填项。</li>
  21. </ul>
  22. <a :href="filePath" style="padding: 5px 0 0 23px;display: block;">
  23. <a-icon type="download" style="padding-right: 5px;" />下载导入模板
  24. </a>
  25. </div>
  26. <div class="explain-item">
  27. <div class="explain-tit">
  28. <span>2</span>上传数据文件
  29. </div>
  30. <p>目前支持的文件类型*.xls,*.xlsx.</p>
  31. <p>
  32. <Upload
  33. id="importGuide-attachList"
  34. ref="importUpload"
  35. :maxNums="1"
  36. fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
  37. uploadType="import"
  38. :action="attachAction"
  39. :uploadParams="uploadParams"
  40. upText="添加文件"
  41. @change="changeImport"></Upload>
  42. </p>
  43. </div>
  44. </div>
  45. <!-- 按钮 -->
  46. <div class="btn-con">
  47. <a-button
  48. type="primary"
  49. id="importGuide-nextStep"
  50. size="large"
  51. class="button-primary"
  52. @click="handlerNextStep"
  53. style="padding: 0 60px;">下一步</a-button>
  54. <a-button
  55. id="importGuide-cancel"
  56. size="large"
  57. class="button-cancel"
  58. @click="isShow=false"
  59. style="padding: 0 60px;margin-left: 15px;">取消</a-button>
  60. </div>
  61. </div>
  62. <!-- 导入 -->
  63. <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
  64. </a-modal>
  65. </template>
  66. <script>
  67. import ChooseImportModal from './chooseImportModal.vue'
  68. import { Upload } from '@/components'
  69. export default {
  70. name: 'ImportGuideModal',
  71. components: { ChooseImportModal, Upload },
  72. props: {
  73. openModal: { // 弹框显示状态
  74. type: Boolean,
  75. default: false
  76. },
  77. params: {
  78. type: Object,
  79. default: null
  80. },
  81. type: { // 类型,促销promo
  82. type: String,
  83. default: ''
  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. downUrlN: 'http://jg-ocs.oss-cn-beijing.aliyuncs.com/templ/promo/normal_product_templ.xlsx', // 正价品
  96. downUrlP: 'http://jg-ocs.oss-cn-beijing.aliyuncs.com/templ/promo/promo_product_templ.xlsx', // 促销品
  97. downUrlT: 'http://jg-ocs.oss-cn-beijing.aliyuncs.com/templ/promo/special_offer_templ.xlsx', // 特惠品
  98. downUrlA: 'http://jg-ocs.oss-cn-beijing.aliyuncs.com/templ/promo/exchange_price_templ.xlsx' // 换购品
  99. }
  100. },
  101. computed: {
  102. filePath () {
  103. let columns = this.downUrlN
  104. if ((this.params && this.params.promoRuleType == 'BUY_PROD_GIVE_PROD') || (this.params && this.params.promoRuleType == 'BUY_PROD_GIVE_MONEY')) { // 买产品送产品/买产品送采购额
  105. if (this.params && this.params.promoGoodsType == 'NORMAL_PROD') { // 正品
  106. columns = this.downUrlN
  107. } else if (this.params && this.params.promoGoodsType == 'PROMO_PROD') { // 促销
  108. columns = this.downUrlP
  109. }
  110. } else if (this.params && this.params.promoRuleType == 'PROMO_PROD') { // 特价产品
  111. if (this.params && this.params.promoGoodsType == 'PROMO_PROD') { // 促销
  112. columns = this.downUrlT
  113. }
  114. } else if (this.params && this.params.promoRuleType == 'ADD_PRICE_PURCH') { // 加价换购
  115. if (this.params && this.params.promoGoodsType == 'NORMAL_PROD') { // 正品
  116. columns = this.downUrlN
  117. } else if (this.params && this.params.promoGoodsType == 'PROMO_PROD') { // 促销
  118. columns = this.downUrlA
  119. }
  120. }
  121. return columns
  122. }
  123. },
  124. methods: {
  125. // 下一步
  126. handlerNextStep () {
  127. if (this.paramsData) {
  128. this.openImportModal = true
  129. } else {
  130. this.$message.warning('添加文件后再进行下一步操作!')
  131. }
  132. },
  133. // 上传文件 change
  134. changeImport (file) {
  135. if (file) {
  136. this.paramsData = {
  137. promoRuleType: this.params.promoRuleType || '',
  138. promoGoodsType: this.params.promoGoodsType || '',
  139. path: file
  140. }
  141. }
  142. },
  143. // 导入
  144. hanldeOk (obj) {
  145. if (obj && obj.length > 0) {
  146. this.$emit('ok', obj)
  147. this.isShow = false
  148. }
  149. },
  150. // 关闭
  151. handleClose () {
  152. this.openImportModal = false
  153. this.isShow = false
  154. }
  155. },
  156. watch: {
  157. // 父页面传过来的弹框状态
  158. openModal (newValue, oldValue) {
  159. this.isShow = newValue
  160. },
  161. // 重定义的弹框状态
  162. isShow (newValue, oldValue) {
  163. if (!newValue) {
  164. this.$emit('close')
  165. this.paramsData = null
  166. this.$refs.importUpload.setFileList('')
  167. }
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="less" scoped>
  173. .importGuide-modal{
  174. .importGuide-con{
  175. .explain-con{
  176. .explain-item{
  177. margin-bottom: 10px;
  178. .explain-tit{
  179. font-weight: bold;
  180. span{
  181. display: inline-block;
  182. width: 18px;
  183. height: 18px;
  184. line-height: 16px;
  185. text-align: center;
  186. margin-right: 5px;
  187. border-radius: 50%;
  188. border: 1px solid rgba(0, 0, 0, 0.3);
  189. }
  190. }
  191. p{
  192. margin: 8px 0;
  193. padding-left: 23px;
  194. }
  195. ul{
  196. list-style: none;
  197. padding: 0;
  198. padding-left: 23px;
  199. margin: 0;
  200. li{
  201. line-height: 26px;
  202. }
  203. }
  204. }
  205. }
  206. .btn-con{
  207. margin: 60px 0 20px;
  208. .button-cancel{
  209. font-size: 12px;
  210. }
  211. }
  212. }
  213. }
  214. </style>