Browse Source

促销规则

chenrui 1 năm trước cách đây
mục cha
commit
ba71335c5d

+ 1 - 0
src/views/promotionRulesManagement/dealerPromotions/chooseProductsModal.vue

@@ -175,6 +175,7 @@ export default {
     //  重置
     resetSearchForm () {
       this.resetData()
+      console.log('1111111111111111')
       this.$refs.table.refresh()
       // this.$refs.table.clearTable()
     },

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

@@ -101,11 +101,13 @@
               class="button-info"
               id="promotionList-edit-btn">+导入产品</a-button>
             <a-button
+              v-show="chooseVal==='d'"
               style="margin-left:10px;"
               size="small"
               type="link"
               class="button-error"
-              id="promotionList-edit-btn">+新增产品</a-button>
+              id="promotionList-edit-btn"
+              @click="openProductsModal = true">+新增产品</a-button>
           </div>
         </div>
         <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct"></tableType1></div>
@@ -116,6 +118,13 @@
         <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
       </div>
     </a-spin>
+    <!-- 选择产品 -->
+    <chooseProductsModal
+      type="dealership"
+      :openModal="openProductsModal"
+      :chooseData="chooseProducts"
+      @close="openProductsModal=false"
+      @ok="handleProductsOk" />
   </a-modal>
 </template>
 
@@ -124,11 +133,12 @@ import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType3 from './tableType3.vue'
-import { promotionSave, sparePartsReturnInfo } from '@/api/promotion'
+import { promotionSave, sparePartsReturnInfo, getNewScopeSn } from '@/api/promotion'
+import chooseProductsModal from './chooseProductsModal.vue'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
-  components: { VSelect, tableType1, tableType3 },
+  components: { VSelect, tableType1, tableType3, chooseProductsModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -162,7 +172,9 @@ export default {
         minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
         upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }]
       },
-      chooseVal: 'a'
+      chooseVal: 'a',
+      openProductsModal: false,
+      chooseProducts: []
     }
   },
   methods: {
@@ -261,6 +273,58 @@ export default {
           this.detailsData = null
         }
       })
+    },
+    // +新增产品
+    handleProductsOk (con) {
+      debugger
+      const chooseProductsList = []
+      const _this = this
+      con.forEach(item => {
+        getNewScopeSn({}).then(res => {
+          if (res.status == 200) {
+            const newData = {
+              productScopeSn: res.data,
+              dataSourceOrigin: 'sel',
+              productTypeArr: [],
+              productTypeList: [],
+              productBrandArr: [{ brandSn: item.productBrandSn, brandName: item.productBrandName }],
+              productBrandList: [{ brandSn: item.productBrandSn }],
+              productThisList: [{
+                productSn: item.productSn,
+                productCode: item.code
+              }],
+              provincePrice: item.provincePrice,
+              cityPrice: item.cityPrice,
+              specialPrice: item.specialPrice
+            }
+            const obj = {}
+            if (item.productTypeSn1) {
+              obj.productType1 = item.productTypeSn1
+            }
+            if (item.productTypeSn2) {
+              obj.productType2 = item.productTypeSn2
+            }
+            if (item.productTypeSn3) {
+              obj.productType3 = item.productTypeSn3
+            }
+            const newObj = { ...obj, ...{} }
+            if (Object.keys(obj).length == 1) {
+              newObj.title = item.productTypeName1
+              newObj.id = item.productTypeSn1
+            } else if (Object.keys(obj).length == 2) {
+              newObj.title = item.productTypeName1 + '/' + item.productTypeName2
+              newObj.id = item.productTypeSn2
+            } else {
+              newObj.title = item.productTypeName1 + '/' + item.productTypeName2 + '/' + item.productTypeName3
+              newObj.id = item.productTypeSn3
+            }
+            newData.productTypeList[0] = obj
+            newData.productTypeArr[0] = newObj
+            chooseProductsList.push(newData)
+            _this.$refs.specialProduct.setSourceData(chooseProductsList)
+          }
+        })
+      })
     }
   },
   watch: {

+ 20 - 9
src/views/promotionRulesManagement/dealerPromotions/tableType1.vue

@@ -16,9 +16,16 @@
         <div style="max-height:80px;width:100%;overflow-y:scroll;">
           <a-row v-if="record.productTypeArr && record.productTypeArr.length>0">
             <a-col :span="18">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(index,con,'typeList')" v-for="(con,i) in record.productTypeArr" :key="i">
-                {{ con.title }}
-              </a-tag>
+              <div v-for="con in record.productTypeArr" :key="con.id">
+                <a-tooltip v-if="con.title&&con.title.length > 6" :title="con.title">
+                  <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,con,'typeList')">
+                    {{ `${con.title.slice(0, 6)}...` }}
+                  </a-tag>
+                </a-tooltip>
+                <a-tag v-else style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,con,'typeList')">
+                  {{ con.title }}
+                </a-tag>
+              </div>
             </a-col>
             <a-col :span="4" style="text-align:right;">
               <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
@@ -40,7 +47,7 @@
         <div style="max-height:106spx;overflow-y:scroll;">
           <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(index,item,'brandList')" v-for="(item,j) in record.productBrandArr" :key="j">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.brandSn">
                 {{ item.brandName }}
               </a-tag>
             </a-col>
@@ -64,7 +71,7 @@
         <div style="max-height:64px;overflow-y:scroll;">
           <a-row v-if="record.productThisList && record.productThisList.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(index,item,'productList')" v-for="(item,k) in record.productThisList" :key="k">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'productList')" v-for="item in record.productThisList" :key="item.productSn">
                 {{ item.productCode }}
               </a-tag>
             </a-col>
@@ -214,6 +221,7 @@ export default {
             newClassifyArr.push(objType1)
             const obj = JSON.parse(JSON.stringify(objType1))
             obj.title = item.title
+            obj.id = item.snPaths
             classifyArr.push(obj)
           }
         }
@@ -227,6 +235,7 @@ export default {
             newClassifyArr.push(objType2)
             const obj = JSON.parse(JSON.stringify(objType2))
             obj.title = item.namePaths.replace(/,/g, '/')
+            obj.id = typeArr1[1]
             classifyArr.push(obj)
           }
         }
@@ -240,6 +249,7 @@ export default {
           newClassifyArr.push(objType3)
           const obj = JSON.parse(JSON.stringify(objType3))
           obj.title = item.namePaths.replace(/,/g, '/')
+          obj.id = typeArr2[2]
           classifyArr.push(obj)
         }
       })
@@ -290,17 +300,18 @@ export default {
       this.dataSource = []
     },
     // 删除标签
-    delLabel (pos, row, type) {
+    delLabel (sn, row, type) {
+      const pos = this.dataSource.findIndex(con => con.productScopeSn == sn)
       if (type === 'typeList') {
-        const i = this.dataSource[pos].productTypeArr.findIndex(con => con.productType1 == row.productType1)
+        const i = this.dataSource[pos].productTypeArr.findIndex(con => con.id == row.id)
         this.dataSource[pos].productTypeArr.splice(i, 1)
         this.dataSource[pos].productTypeList.splice(i, 1)
       } else if (type === 'brandList') {
-        const j = this.dataSource[pos].productTypeArr.findIndex(con => con.brandSn == row.brandSn)
+        const j = this.dataSource[pos].productBrandArr.findIndex(con => con.brandSn == row.brandSn)
         this.dataSource[pos].productBrandArr.splice(j, 1)
         this.dataSource[pos].productBrandList.splice(j, 1)
       } else {
-        const k = this.dataSource[pos].productTypeArr.findIndex(con => con.productSn == row.productSn)
+        const k = this.dataSource[pos].productThisList.findIndex(con => con.productSn == row.productSn)
         this.dataSource[pos].productThisList.splice(k, 1)
       }
     }

+ 88 - 45
src/views/promotionRulesManagement/dealerPromotions/tableType3.vue

@@ -13,10 +13,10 @@
       bordered>
       <!-- 产品分类 -->
       <template slot="productType" slot-scope="text, record,index">
-        <div style="max-height:64px;overflow-y:scroll;">
+        <div style="max-height:64px;overflow-y:scroll;" v-if="!record.dataSourceOrigin">
           <a-row v-if="record.productTypeArr && record.productTypeArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="(con,i) in record.productTypeArr" :key="i">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="con in record.productTypeArr" :key="con.id">
                 {{ con.title }}
               </a-tag>
             </a-col>
@@ -34,13 +34,14 @@
             </a-col>
           </a-row>
         </div>
+        <span v-else v-for="con in record.productTypeArr" :key="con.id">{{ con.title }}</span>
       </template>
       <!-- 品牌 -->
       <template slot="productBrand" slot-scope="text, record,index">
-        <div style="max-height:64px;overflow-y:scroll;">
+        <div style="max-height:64px;overflow-y:scroll;" v-if="!record.dataSourceOrigin">
           <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="(item,j) in record.productBrandArr" :key="j">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.brandSn">
                 {{ item.brandName }}
               </a-tag>
             </a-col>
@@ -58,72 +59,100 @@
             </a-col>
           </a-row>
         </div>
+        <span v-else v-for="item in record.productBrandArr" :key="item.brandSn">{{ item.brandName }}</span>
+      </template>
+      <!-- 产品 -->
+      <template slot="product" slot-scope="text, record">
+        <span v-if="record.dataSourceOrigin" v-for="item in record.productThisList" :key="item.productSn">{{ item.productCode }}</span>
+        <span v-else>--</span>
       </template>
       <!-- 省价特价 -->
       <template slot="provincePrice" slot-scope="text, record">
         <a-input-number
           size="small"
-          style="width:80%;"
+          style="width:90%;"
           v-model="record.provinceDiscountPrice"
           :min="0"
           :step="1"
           :precision="2"
-          placeholder="请输入"/>
+          placeholder="请输入"
+          v-if="record.dataSourceOrigin"
+          :max="record.provincePrice"
+          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'province')"/>
+        <span v-else>--</span>
       </template>
       <!-- 省价折扣 -->
       <template slot="provinceDiscount" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.provinceDiscountRate"
-          :min="0"
-          :step="1"
-          :precision="0"
-          placeholder="请输入"/>%
+        <div v-if="!record.dataSourceOrigin">
+          <a-input-number
+            size="small"
+            style="width:90%;"
+            v-model="record.provinceDiscountRate"
+            :min="0"
+            :step="1"
+            :max="100"
+            placeholder="请输入"
+          />%
+        </div>
+        <span v-else>{{ record.provinceDiscountRate?record.provinceDiscountRate:'--' }}</span>
       </template>
       <!-- 市价特价 -->
       <template slot="cityPrice" slot-scope="text, record">
         <a-input-number
           size="small"
-          style="width:80%;"
+          style="width:90%;"
           v-model="record.cityDiscountPrice"
           :min="0"
           :step="1"
           :precision="2"
-          placeholder="请输入"/>
+          placeholder="请输入"
+          v-if="record.dataSourceOrigin"
+          :max="record.cityPrice"
+          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'city')"/>
+        <span v-else>--</span>
       </template>
       <!-- 市价折扣 -->
       <template slot="cityDiscount" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.cityDiscountRate"
-          :min="0"
-          :step="1"
-          :precision="0"
-          placeholder="请输入"/>%
+        <div v-if="!record.dataSourceOrigin">
+          <a-input-number
+            size="small"
+            style="width:90%;"
+            v-model="record.cityDiscountRate"
+            :min="0"
+            :step="1"
+            :max="100"
+            placeholder="请输入"/>%
+        </div>
+        <span v-else>{{ record.cityDiscountRate?record.cityDiscountRate:'--' }}</span>
       </template>
       <!-- 特约特价 -->
       <template slot="specialPrice" slot-scope="text, record">
         <a-input-number
           size="small"
-          style="width:80%;"
+          style="width:90%;"
           v-model="record.specialDiscountPrice"
           :min="0"
           :step="1"
           :precision="2"
-          placeholder="请输入"/>
+          placeholder="请输入"
+          v-if="record.dataSourceOrigin"
+          :max="record.specialPrice"
+          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'special')"/>
+        <span v-else>--</span>
       </template>
       <!-- 特约折扣 -->
       <template slot="specialDiscount" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.specialDiscountRate"
-          :min="0"
-          :step="1"
-          :precision="0"
-          placeholder="请输入"/>%
+        <div v-if="!record.dataSourceOrigin">
+          <a-input-number
+            size="small"
+            style="width:90%;"
+            v-model="record.specialDiscountRate"
+            :min="0"
+            :step="1"
+            :max="100"
+            placeholder="请输入"/>%
+        </div>
+        <span v-else>{{ record.specialDiscountRate ? record.specialDiscountRate:'--' }}</span>
       </template>
       <!-- 设置起订量 -->
       <template slot="setNum" slot-scope="text, record">
@@ -142,7 +171,7 @@
             v-model="record.unitQty"
             :min="0"
             :step="1"
-            :precision="2"
+            :precision="0"
             placeholder="请输入"/>
         </div>
       </template>
@@ -190,16 +219,16 @@ export default {
       columns: [
         { title: '产品分类', width: '11%', scopedSlots: { customRender: 'productType' }, align: 'center' },
         { title: '品牌', width: '11%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
-        { title: '产品', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品', scopedSlots: { customRender: 'product' }, width: '8%', align: 'center' },
         { title: '省价原价', dataIndex: 'provincePrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '省价特价', scopedSlots: { customRender: 'provincePrice' }, width: '6%', align: 'right' },
-        { title: '省价折扣', scopedSlots: { customRender: 'provinceDiscount' }, width: '6%', align: 'right' },
-        { title: '市价原价', dataIndex: 'cityPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '市价特价', scopedSlots: { customRender: 'cityPrice' }, width: '6%', align: 'right' },
-        { title: '市价折扣', scopedSlots: { customRender: 'cityDiscount' }, width: '6%', align: 'right' },
+        { title: '省价特价', scopedSlots: { customRender: 'provincePrice' }, width: '6%', align: 'center' },
+        { title: '省价折扣', scopedSlots: { customRender: 'provinceDiscount' }, width: '6%', align: 'center' },
+        { title: '市价原价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '市价特价', scopedSlots: { customRender: 'cityPrice' }, width: '6%', align: 'center' },
+        { title: '市价折扣', scopedSlots: { customRender: 'cityDiscount' }, width: '6%', align: 'center' },
         { title: '特约原价', dataIndex: 'specialPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '特约特价', scopedSlots: { customRender: 'specialPrice' }, width: '6%', align: 'right' },
-        { title: '特约折扣', scopedSlots: { customRender: 'specialDiscount' }, width: '6%', align: 'right' },
+        { title: '特约特价', scopedSlots: { customRender: 'specialPrice' }, width: '6%', align: 'center' },
+        { title: '特约折扣', scopedSlots: { customRender: 'specialDiscount' }, width: '6%', align: 'center' },
         { title: '设置起订量', width: '12%', scopedSlots: { customRender: 'setNum' }, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ],
@@ -209,10 +238,25 @@ export default {
       chooseBrand: [],
       chooseType: [],
       brandTagIndex: null, // 所选品牌位置
-      classifyTagIndex: null // 所选分类位置
+      classifyTagIndex: null, // 所选分类位置
+      dataSourceOrigin: null // 数据来源  sle  选择产品  null 新增一行品类
     }
   },
   methods: {
+    // 计算百分比
+    calculatePrice (val, sn, typePrice) {
+      const _this = this
+      const pos = _this.dataSource.findIndex(con => con.productScopeSn == sn)
+      const oldPrice = typePrice + 'Price'
+      const str = Math.floor(((val / _this.dataSource[pos][oldPrice]) * 100).toFixed(2)) + '%'
+      const name = typePrice + 'DiscountRate'
+      _this.dataSource[pos][name] = str
+      _this.$forceUpdate()
+    },
+    // 新增产品 数据
+    setSourceData (list) {
+      this.dataSource = list
+    },
     // 新增一行
     handleAddRow () {
       const _this = this
@@ -296,7 +340,6 @@ export default {
       this.dataSource[this.brandTagIndex].productBrandList = newConList
     },
     getResultVal () {
-      debugger
       const resultObj = JSON.parse(JSON.stringify(this.dataSource))
       resultObj.map(item => {
         delete item.productTypeArr