chenrui před 1 rokem
rodič
revize
b119d26dba

binární
public/templ/促销规则导入产品.xlsx


binární
public/templ/促销规则导入特价产品.xlsx


+ 18 - 0
src/api/promotion.js

@@ -126,3 +126,21 @@ export const promotionIsOver = (params) => {
     method: 'get'
   })
 }
+
+// 导入门槛、正价、促销产品
+export const importNormalProduct = params => {
+  return axios({
+    url: '/promotion/importNormalProduct',
+    data: params,
+    method: 'post'
+  })
+}
+
+// 导入特价产品
+export const importSpecialProduct = params => {
+  return axios({
+    url: '/promotion/importSpecialProduct ',
+    data: params,
+    method: 'post'
+  })
+}

+ 174 - 0
src/views/promotionRulesManagement/dealerPromotions/chooseImportModal.vue

@@ -0,0 +1,174 @@
+<template>
+  <a-modal
+    centered
+    class="chooseImport-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="确认导入"
+    v-model="isShow"
+    @cancel="isShow=false"
+    width="80%">
+    <div class="chooseImport-con">
+      <!-- 可导入数据 -->
+      <p class="">可导入数据{{ loadData.length }}条</p>
+      <a-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.allocateSn"
+        :columns="nowColumns"
+        :dataSource="loadData"
+        :loading="loading"
+        :scroll="{ y: 200 }"
+        :pagination="false"
+        bordered>
+      </a-table>
+      <a-divider />
+      <!-- 不可导入数据 -->
+      <p class="red">不可导入数据{{ unLoadData.length }}条</p>
+      <a-table
+        class="unTable"
+        ref="unTable"
+        size="small"
+        :rowKey="(record) => record.errorDesc"
+        :columns="nowUnColumns"
+        :dataSource="unLoadData"
+        :loading="loading"
+        :scroll="{ y: 200 }"
+        :pagination="false"
+        bordered>
+        <template slot="errorMsg" slot-scope="text,record">
+          <a-popover placement="topRight">
+            <template slot="content">
+              <p v-for="d in record.importErrorMsgSet">{{ d }}</p>
+            </template>
+            <a-button type="link">
+              查看
+            </a-button>
+          </a-popover>
+        </template>
+      </a-table>
+      <!-- 按钮 -->
+      <div class="btn-con">
+        <a-button
+          type="primary"
+          id="chooseImport-submit"
+          size="large"
+          :class="unLoadData.length?'button-grey':'button-primary'"
+          @click="handleSubmit"
+          style="padding: 0 40px;">确认导入</a-button>
+        <a-button
+          id="chooseImport-cancel"
+          size="large"
+          class="button-cancel"
+          @click="isShow=false"
+          style="padding: 0 40px;margin-left: 15px;">取消</a-button>
+        <!-- <a-button
+          type="primary"
+          id="chooseImport-error"
+          size="large"
+          class="button-error"
+          @click="handleError"
+          style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button> -->
+      </div>
+    </div>
+  </a-modal>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { hdExportExcel } from '@/libs/exportExcel'
+import { salesReturnDetailImportError } from '@/api/salesReturn.js'
+export default {
+  name: 'ChooseImportModal',
+  mixins: [commonMixin],
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    paramsData: {
+      type: Object,
+      default: () => {
+        return {}
+      }
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      nowColumns: [
+        { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
+        { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名字', dataIndex: 'product.name', width: '70%', align: 'center', customRender: function (text) { return text || '--' } }
+      ],
+      loadData: [],
+      nowUnColumns: [
+        { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
+        { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'product.name', width: '60%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '20%', align: 'center' }
+      ],
+      unLoadData: [],
+      loading: false
+    }
+  },
+  methods: {
+    getData () {
+      const paramsData = JSON.parse(JSON.stringify(this.paramsData))
+      this.loadData = paramsData.rightList || []
+      this.unLoadData = paramsData.errorList || []
+      this.loadData.map((item, index) => {
+        item.no = index + 1
+      })
+      this.unLoadData.map((item, index) => {
+        item.no = index + 1
+        item.importErrorMsgSet = item.remarks.split(',')
+      })
+    },
+    // 确认导入
+    handleSubmit () {
+      if (this.unLoadData.length) {
+        this.$message.warning('有错误数据不可导入,请修改正确后再试!')
+      } else {
+        const data = this.paramsData.rightList
+        this.$emit('ok', data)
+        this.isShow = false
+      }
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.loadData = []
+        this.unLoadData = []
+      } else {
+        this.getData()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .chooseImport-modal{
+    .chooseImport-con{
+      .red{
+        color: #f30;
+      }
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel,.button-error{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 199 - 0
src/views/promotionRulesManagement/dealerPromotions/importGuideModal.vue

@@ -0,0 +1,199 @@
+<template>
+  <a-modal
+    centered
+    class="importGuide-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="导入产品"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="800">
+    <div class="importGuide-con">
+      <div class="explain-con">
+        <div class="explain-item">
+          <div class="explain-tit">
+            <span>1</span>准备导入
+          </div>
+          <ul>
+            <li v-if="goodFlag==1">1) 导入的Excel文件中必须包含名为“产品编码”的列,“产品编码”必填</li>
+            <li v-else>1) 导入的Excel文件中必须包含名为“产品编码”、“省价特价”、“市价特价”和“特约特价”的列,都为必填</li>
+            <li>2) 如果导入的产品已经存在,则不会导入该行</li>
+            <li>
+              <a :href="filePath" style="margin: 5px 0 0;display: block;">
+                <a-icon type="download" style="padding-right: 5px;" />下载导入模板
+              </a>
+            </li>
+          </ul>
+        </div>
+        <div class="explain-item">
+          <div class="explain-tit">
+            <span>2</span>上传数据文件
+          </div>
+          <p>目前支持的文件类型*.xls,*.xlsx.</p>
+          <div style="overflow: hidden;padding-left: 23px;">
+            <Upload
+              id="importGuide-attachList"
+              ref="importUpload"
+              :maxNums="1"
+              fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
+              uploadType="attach"
+              :action="goodFlag==='1'?attachAction:attachAction1"
+              upText="选择导入文件"
+              @remove="resetSearchForm"
+              @change="changeImport"></Upload>
+          </div>
+        </div>
+      </div>
+      <!-- 按钮 -->
+      <div class="btn-con">
+        <a-button
+          type="primary"
+          id="importGuide-nextStep"
+          size="large"
+          class="button-primary"
+          @click="handlerNextStep"
+          style="padding: 0 60px;">下一步</a-button>
+        <a-button
+          id="importGuide-cancel"
+          size="large"
+          class="button-cancel"
+          @click="isShow=false"
+          style="padding: 0 60px;margin-left: 15px;">取消</a-button>
+      </div>
+    </div>
+    <!-- 导入 -->
+    <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
+  </a-modal>
+</template>
+
+<script>
+import ChooseImportModal from './chooseImportModal.vue'
+import { Upload } from '@/components'
+export default {
+  name: 'ImportGuideModal',
+  components: { ChooseImportModal, Upload },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    params: {
+      type: Object,
+      default: null
+    },
+    goodFlag: {
+      type: [String, Number],
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      openImportModal: false, //  导入
+      attachAction: process.env.VUE_APP_API_BASE_URL + '/promotion/importNormalProduct',
+      attachAction1: process.env.VUE_APP_API_BASE_URL + '/promotion/importSpecialProduct',
+      paramsData: null,
+      filePath: ''
+    }
+  },
+  methods: {
+    // 清空数据
+    resetSearchForm () {
+      this.$refs.importUpload.setFileList() //  清空导入文件
+      this.paramsData = null //  清空上传数据
+    },
+    // 下一步
+    handlerNextStep () {
+      if (this.paramsData) {
+        this.openImportModal = true
+      } else {
+        this.$message.warning('添加文件后再进行下一步操作!')
+      }
+    },
+    // 上传文件  change
+    changeImport (file) {
+      // console.log(file, JSON.parse(file))
+      if (file && JSON.parse(file).length > 0) {
+        this.paramsData = Object.assign({}, JSON.parse(file)[0] || null, this.params)
+      } else {
+        this.paramsData = null
+      }
+    },
+    // 导入
+    hanldeOk (obj) {
+      if (obj && obj.length > 0) {
+        this.$emit('ok', obj)
+        this.isShow = false
+      }
+    },
+    // 关闭
+    handleClose () {
+      this.openImportModal = false
+      this.isShow = false
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.resetSearchForm()
+      } else {
+        this.filePath = location.protocol + '//' + location.host + (this.goodFlag == 1 ? '/templ/促销规则导入产品.xlsx' : '/templ/促销规则导入特价产品.xlsx')
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .importGuide-modal{
+    .importGuide-con{
+      .explain-con{
+        .explain-item{
+          margin-bottom: 10px;
+          .explain-tit{
+            font-weight: bold;
+            span{
+              display: inline-block;
+              width: 18px;
+              height: 18px;
+              line-height: 16px;
+              text-align: center;
+              margin-right: 5px;
+              border-radius: 50%;
+              border: 1px solid rgba(0, 0, 0, 0.3);
+            }
+          }
+          p{
+            margin: 8px 0;
+            padding-left: 23px;
+          }
+          ul{
+            list-style: none;
+            padding: 0;
+            padding-left: 23px;
+            margin: 0;
+            li{
+              line-height: 26px;
+            }
+          }
+        }
+        #importGuide-attachList{
+          width: 100%;
+        }
+      }
+      .btn-con{
+        margin: 10px 0 20px;
+        text-align: center;
+        .button-cancel{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 23 - 2
src/views/promotionRulesManagement/dealerPromotions/sendAmountModal.vue

@@ -180,6 +180,7 @@
             size="small"
             type="link"
             class="button-info"
+            @click="openGuideModal=true"
             id="promotionList-edit-btn">+导入产品</a-button>
         </div>
         <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct"></tableType1></div>
@@ -191,6 +192,8 @@
         <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
       </div>
     </a-spin>
+    <!-- 导入产品 -->
+    <importGuideModal goodsFlag="1" :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
   </a-modal>
 </template>
 
@@ -200,10 +203,11 @@ import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType2 from './tableType2.vue'
 import { promotionSave, getRuleDetail } from '@/api/promotion'
+import ImportGuideModal from './importGuideModal.vue'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
-  components: { VSelect, tableType1, tableType2 },
+  components: { VSelect, tableType1, tableType2, ImportGuideModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -254,10 +258,27 @@ export default {
         scopeFlag: [{ required: true, message: '请选择采购额适用范围', trigger: 'change' }]
       },
       chooseVal: 'a',
-      scaleNum: 0
+      scaleNum: 0,
+      openGuideModal: false
     }
   },
   methods: {
+    // 导入
+    closeGuideModel () {
+      this.openGuideModal = false
+    },
+    hanldeOk (arr) {
+      const resultArr = []
+      arr.forEach(item => {
+        const obj = {
+          productCode: item.productCode,
+          productSn: item.product.productSn
+        }
+        resultArr.push(obj)
+      })
+      const name = this.chooseVal == 'a' ? 'cill' : this.chooseVal == 'b' ? 'normalPrice' : 'offer'
+      this.$refs[name + 'Product'].importRow(resultArr)
+    },
     // 计算百分比
     calculatePrice () {
       const _this = this

+ 24 - 2
src/views/promotionRulesManagement/dealerPromotions/sendProductsModal.vue

@@ -185,6 +185,7 @@
             size="small"
             type="link"
             class="button-info"
+            @click="openGuideModal=true"
             id="promotionList-edit-btn">+导入产品</a-button>
         </div>
         <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct"></tableType1></div>
@@ -196,6 +197,8 @@
         <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
       </div>
     </a-spin>
+    <!-- 导入产品 -->
+    <importGuideModal goodsFlag="1" :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
   </a-modal>
 </template>
 
@@ -205,10 +208,11 @@ import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType2 from './tableType2.vue'
 import { promotionSave, getRuleDetail } from '@/api/promotion'
+import ImportGuideModal from './importGuideModal.vue'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
-  components: { VSelect, tableType1, tableType2 },
+  components: { VSelect, tableType1, tableType2, ImportGuideModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -259,10 +263,28 @@ export default {
         upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }],
         regularPromotionSameFlag: [{ required: true, message: '请选择促销品与正品是否一致', trigger: 'change' }]
       },
-      chooseVal: 'a'
+      chooseVal: 'a',
+      openGuideModal: false// 导入弹窗
     }
   },
   methods: {
+    // 导入
+    closeGuideModel () {
+      this.openGuideModal = false
+    },
+    hanldeOk (arr) {
+      const resultArr = []
+      arr.forEach(item => {
+        const obj = {
+          productCode: item.productCode,
+          productSn: item.product.productSn
+        }
+        resultArr.push(obj)
+      })
+      const name = this.chooseVal == 'a' ? 'cill' : this.chooseVal == 'b' ? 'normalPrice' : 'offer'
+      this.$refs[name + 'Product'].importRow(resultArr)
+    },
+    // 限制正价产品款数
     onChange (e) {
       this.form.restrictFlag = e.target.checked ? '1' : '0'
     },

+ 26 - 4
src/views/promotionRulesManagement/dealerPromotions/specialOfferModal.vue

@@ -127,7 +127,9 @@
               size="small"
               type="link"
               class="button-info"
-              id="promotionList-edit-btn">+导入产品</a-button>
+              id="promotionList-edit-btn"
+              @click="openGuideModal=true"
+            >+导入产品</a-button>
             <a-button
               v-show="chooseVal==='d'"
               style="margin-left:10px;"
@@ -153,6 +155,8 @@
       :chooseData="chooseProducts"
       @close="openProductsModal=false"
       @ok="handleProductsOk" />
+    <!-- 导入产品 -->
+    <importGuideModal :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
   </a-modal>
 </template>
 
@@ -163,10 +167,11 @@ import tableType1 from './tableType1.vue'
 import tableType3 from './tableType3.vue'
 import { promotionSave, getRuleDetail, getNewScopeSn } from '@/api/promotion'
 import chooseProductsModal from './chooseProductsModal.vue'
+import ImportGuideModal from './importGuideModal.vue'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
-  components: { VSelect, tableType1, tableType3, chooseProductsModal },
+  components: { VSelect, tableType1, tableType3, chooseProductsModal, ImportGuideModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -209,10 +214,15 @@ export default {
       },
       chooseVal: 'a',
       openProductsModal: false,
-      chooseProducts: []
+      chooseProducts: [],
+      openGuideModal: false// 导入弹窗
     }
   },
   methods: {
+    // 导入
+    closeGuideModel () {
+      this.openGuideModal = false
+    },
     // 门槛产品
     handleChange (e) {
       if (e.target.value == '1') {
@@ -371,6 +381,15 @@ export default {
       })
       return list
     },
+    hanldeOk (arr) {
+      const resultArr = []
+      arr.forEach(item => {
+        item = { ...item, ...item.product }
+        item.code = item.productCode
+        resultArr.push(item)
+      })
+      this.handleProductsOk(resultArr)
+    },
     // +新增产品
     handleProductsOk (con) {
       const chooseProductsList = []
@@ -391,7 +410,10 @@ export default {
               }],
               provincePrice: item.provincePrice,
               cityPrice: item.cityPrice,
-              specialPrice: item.specialPrice
+              specialPrice: item.specialPrice,
+              provinceDiscountPrice: item.provinceDiscountPriceText,
+              cityDiscountPrice: item.cityDiscountPriceText,
+              specialDiscountPrice: item.specialDiscountPriceText
             }
             const obj = {}
             if (item.productTypeSn1) {

+ 23 - 0
src/views/promotionRulesManagement/dealerPromotions/tableType1.vue

@@ -200,6 +200,29 @@ export default {
         }
       })
     },
+    // 导入新增一行
+    importRow (list) {
+      const _this = this
+      const dataList = _this.setShowData('This')
+      dataList.forEach(item => {
+        const pos = list.indexOf(con => con.productSn == item.goodsSn)
+        list.splice(pos, 1)
+      })
+      if (list.length > 0) {
+        _this.spinning = true
+        getNewScopeSn({}).then(res => {
+          if (res.status == 200) {
+            const newData = {
+              productScopeSn: res.data,
+              productThisList: list
+            }
+            _this.dataSource.push(newData)
+          } else {
+            _this.spinning = false
+          }
+        })
+      }
+    },
     // 删除一行
     handleDel (row) {
       const pos = this.dataSource.findIndex(con => con.productScopeSn == row.productScopeSn)

+ 22 - 0
src/views/promotionRulesManagement/dealerPromotions/tableType2.vue

@@ -171,6 +171,28 @@ export default {
         }
       })
     },
+    // 导入新增一行
+    importRow (list) {
+      const _this = this
+      const dataList = _this.setShowData('This')
+      dataList.forEach(item => {
+        const pos = list.indexOf(con => con.productSn == item.goodsSn)
+        list.splice(pos, 1)
+      })
+      if (list.length > 0) {
+        getNewScopeSn({}).then(res => {
+          if (res.status == 200) {
+            const newData = {
+              productScopeSn: res.data,
+              productThisList: list
+            }
+            _this.dataSource.push(newData)
+          } else {
+            _this.spinning = false
+          }
+        })
+      }
+    },
     // 删除一行
     handleDel (row) {
       const pos = this.dataSource.findIndex(con => con.productScopeSn == row.productScopeSn)