瀏覽代碼

促销规则

chenrui 1 年之前
父節點
當前提交
c26b01e2b1

+ 18 - 19
src/views/promotionRulesManagement/dealerPromotions/detail.vue

@@ -62,25 +62,32 @@
           <template slot="cillProduct" slot-scope="text, record">
             <div v-if="record.gateFlag === '1'">
               <span v-if="record.gateType==='RATIO_AMOUNT'">
-                购买门槛产品金额{{ record.gateAmount*100 }}%作为配额
+                购买门槛产品金额{{ record.gateValue*100 }}%作为配额
               </span>
               <span v-else-if="record.gateType==='MIN_AMOUNT'">
-                购买门槛产品满最低金额{{ record.gateAmount }}元,不限制配额
+                购买门槛产品满最低金额{{ record.gateValue }}元,不限制配额
+              </span>
+              <span v-else>
+                <span v-if="record.promotionRuleType!='PROMO_PROD'">购买满{{ record.gateValue }}元门槛产品,可使用 {{ record.quotaAmount }}元配额,采购规则中的正价商品</span>
+                <span>购买每满{{ record.gateValue }}{{ record.regularUnit==='YUAN'?'元':'个' }}门槛产品,可采购{{ record.quotaAmount }}个特价产品</span>
               </span>
-              <span v-else>购买满{{ record.gateAmount }}元门槛产品,可使用 {{ record.quotaAmount }}元配额,采购规则中的{{ record.promotionRuleType!='PROMO_PROD'?'正价':'特价' }}商品</span>
             </div>
             <span v-else>--</span>
           </template>
           <!-- 规则 -->
           <template slot="ruleProduct" slot-scope="text, record">
             <div v-if="record.promotionRuleType == 'BUY_PROD_GIVE_PROD'">
-              {{ record.regularSameFlag==1?'同款':'不同款' }}产品,购买满{{ record.regularQty }}个正价产品,送{{ record.promotionQty }}个促销产品{{ (record.accrualFlag&&record.accrualFlag==1)?',数量叠加':',数量不叠加' }}
+              <div>{{ record.accrualFlag==='1'?'数量叠加;':'' }}{{ record.convertExpenseFlag==='1'?'可转费用报销单;':'' }}</div>
+              <div v-if="record.restrictFlag==='1'">限制正价产品{{ record.restrictCategory }}款</div>
+              <!-- {{ record.regularSameFlag==1?'同款':'不同款' }}产品,购买满{{ record.regularQty }}个正价产品,送{{ record.promotionQty }}个促销产品{{ (record.accrualFlag&&record.accrualFlag==1)?',数量叠加':',数量不叠加' }} -->
             </div>
             <div v-else-if="record.promotionRuleType == 'BUY_PROD_GIVE_MONEY'">
               购买满{{ record.regularAmount }}元正价产品,送{{ record.giveAmount }}元促销品采购额{{ record.promotionRuleType ==='BUY_PROD_GIVE_MONEY'?(record.accrualFlag&&record.accrualFlag==1)?',金额叠加':',金额不叠加':'' }}
             </div>
             <div v-else>
-              特价产品
+              <span v-if="record.discountType ==='0'">手动输入特价</span>
+              <span v-else-if="record.discountType ==='1'">各级别价打折;省级折扣{{ record.provinceValue }}%,市级折扣{{ record.cityValue }}%,特约折扣{{ record.specialValue }}%</span>
+              <span v-else>各级别价直降;省级直降{{ record.provinceValue }},市级直降{{ record.cityValue }},特约直降{{ record.specialValue }}</span>
             </div>
           </template>
           <!-- 操作 -->
@@ -186,23 +193,15 @@ export default {
         })
       },
       detailSn: null,
-      mainContentList: []
-    }
-  },
-  computed: {
-    columns () {
-      const _this = this
-      const arr = [
+      mainContentList: [],
+      columns: [
         { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
         { title: '促销类型', dataIndex: 'promotionRuleTypeDictValue', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '规则简称', dataIndex: 'description', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '规则门槛', scopedSlots: { customRender: 'cillProduct' }, width: '20%', align: 'center' },
-        { title: '规则', scopedSlots: { customRender: 'ruleProduct' }, width: '20%', align: 'center' },
-        { title: '订单起订金额(元)', dataIndex: 'minOrderAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '活动经费上限(元)', dataIndex: 'upperLimitAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: '20%', align: 'center' }
+        { title: '规则简称', dataIndex: 'description', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '规则门槛', scopedSlots: { customRender: 'cillProduct' }, width: '23%', align: 'center' },
+        { title: '规则', scopedSlots: { customRender: 'ruleProduct' }, width: '33%', align: 'left' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ]
-      return arr
     }
   },
   methods: {

+ 3 - 4
src/views/promotionRulesManagement/dealerPromotions/sendAmountModal.vue

@@ -116,7 +116,7 @@
                 :max="999999"
                 :precision="0"
                 size="small"/>
-              <a-select default-value="YUAN" v-model="con.regularUnit" style="width: 50px;margin-left:5px;" size="small" allowClear>
+              <a-select default-value="YUAN" v-model="form.regularUnit" style="width: 50px;margin-left:5px;" size="small" allowClear>
                 <a-select-option value="YUAN">
                 </a-select-option>
@@ -195,13 +195,12 @@
 import { commonMixin } from '@/utils/mixin'
 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, ImportGuideModal },
+  components: { VSelect, tableType1, ImportGuideModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -232,7 +231,7 @@ export default {
         gateValue: undefined,
         quotaAmount: undefined,
         giveRuleType: 'SUM_MONEY',
-        regularUnit: 'YUAN',
+        regularUnit:'YUAN',
         scopeFlag: '1',
         giftProductMap: {}
       },

+ 12 - 13
src/views/promotionRulesManagement/dealerPromotions/sendProductsModal.vue

@@ -38,17 +38,17 @@
               @change="changeGateTypeFlag"
               allowClear></v-select>
             <div v-if="form.gateType==='RATIO_AMOUNT'">
-              购买门槛产品金额 <a-input-number v-model="form.gateAmount" :min="0" :max="999999" :precision="2" size="small"/> %作为配额
+              购买门槛产品金额 <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/> %作为配额
               <a-tooltip title="如:填写100%,则购买10000元门槛产品,可享受10000配额购买正价产品,根据门槛金额动态调整配额">
                 <a-icon type="question-circle" theme="filled" :style="{ fontSize: '14px', color: 'gray' }"/>
               </a-tooltip>
             </div>
             <div v-if="form.gateType==='MIN_AMOUNT'">
-              购买门槛产品满最低金额 <a-input-number v-model="form.gateAmount" :min="0" :max="999999" :precision="2" size="small"/>元,不限制配额。
+              购买门槛产品满最低金额 <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/>元,不限制配额。
             </div>
             <div class="ruleDescList" v-if="form.gateType==='FIXED_AMOUNT'">
               购买满
-              <a-input-number v-model="form.gateAmount" :min="0" :max="999999" :precision="2" size="small"/>
+              <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/>
               元门槛产品,可使用
               <a-input-number v-model="form.quotaAmount" :min="0" :max="999999" :precision="2" size="small"/>
               元配额,采购规则中的正价商品(配额算销售额)
@@ -198,13 +198,12 @@
 import { commonMixin } from '@/utils/mixin'
 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, ImportGuideModal },
+  components: { VSelect, tableType1, ImportGuideModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -237,7 +236,7 @@ export default {
         description: '', // 简称
         gateFlag: '0', // 门槛
         gateType: undefined,
-        gateAmount: undefined,
+        gateValue: undefined,
         quotaAmount: undefined,
         regularSameFlag: '1', // 满赠规则  同款不同款商品
         regularUnit: 'YUAN',
@@ -304,7 +303,7 @@ export default {
       if (e.target.value == '0') {
         this.chooseVal = 'b'
         this.form.gateType = undefined
-        this.form.gateAmount = undefined
+        this.form.gateValue = undefined
         this.form.quotaAmount = undefined
       } else {
         this.chooseVal = 'a'
@@ -312,7 +311,7 @@ export default {
     },
     changeGateTypeFlag (val) {
       this.form.gateType = val
-      this.form.gateAmount = undefined
+      this.form.gateValue = undefined
       this.form.quotaAmount = undefined
     },
     //  保存
@@ -326,7 +325,7 @@ export default {
               _this.$message.warning('请选择规则门槛设置类型!')
               return
             }
-            if (!_this.form.gateAmount) {
+            if (!_this.form.gateValue) {
               _this.$message.warning('规则门槛条件不能为空!')
               return
             }
@@ -343,7 +342,7 @@ export default {
           let rowFlag1, rowFlag2, rowFlag3
           if (form.gateFlag == '1') { // 门槛产品
             form.gateProductList = this.$refs.cillProduct.getResultVal()
-            form.gateAmount = form.gateType === 'RATIO_AMOUNT' ? form.gateAmount / 100 : form.gateAmount
+            form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
             if (form.gateProductList.length == 0) {
               _this.$message.warning('请添加门槛产品!')
               return
@@ -462,7 +461,7 @@ export default {
         description: '', // 简称
         gateFlag: '0', // 门槛
         gateType: undefined,
-        gateAmount: undefined,
+        gateValue: undefined,
         quotaAmount: undefined,
         regularSameFlag: '1', // 满赠规则  同款不同款商品
         regularUnit: 'YUAN',
@@ -496,7 +495,7 @@ export default {
           const resultObj = res.data
           _this.chooseVal = resultObj.gateFlag == '0' ? 'b' : 'a'
           if (resultObj.gateFlag === '1') {
-            resultObj.gateAmount = resultObj.gateType === 'RATIO_AMOUNT' ? resultObj.gateAmount * 100 : resultObj.gateAmount
+            resultObj.gateValue = resultObj.gateType === 'RATIO_AMOUNT' ? resultObj.gateValue * 100 : resultObj.gateValue
           }
           // 重新组成保存数据
           if (resultObj.gateProductList && resultObj.gateProductList.length > 0) {
@@ -623,4 +622,4 @@ export default {
     }
   }
 
-</style>
+</style>

+ 32 - 47
src/views/promotionRulesManagement/dealerPromotions/specialOfferModal.vue

@@ -89,7 +89,7 @@
             </a-select-option>
           </a-select>
           <a-table
-            v-if="form.discountType!=0"
+            v-show="form.discountType!=0"
             class="sTable"
             ref="setTable"
             size="small"
@@ -132,7 +132,7 @@
             <template slot="provincePrice" slot-scope="text, record">
               <a-input-number
                 size="small"
-                v-model="record.provinceSubtract"
+                v-model="record.provinceValue"
                 :min="0"
                 :step="1"
                 :precision="2"
@@ -142,7 +142,7 @@
             <template slot="cityPrice" slot-scope="text, record">
               <a-input-number
                 size="small"
-                v-model="record.citySubtract"
+                v-model="record.cityValue"
                 :min="0"
                 :step="1"
                 :precision="2"
@@ -152,7 +152,7 @@
             <template slot="specialPrice" slot-scope="text, record">
               <a-input-number
                 size="small"
-                v-model="record.specialSubtract"
+                v-model="record.specialValue"
                 :min="0"
                 :step="1"
                 :precision="2"
@@ -251,6 +251,7 @@ export default {
         gateFlag: '0', // 门槛
         gateType: undefined,
         gateValue: undefined,
+        regularUnit: 'YUAN',
         quotaAmount: undefined,
         discountType: '0'// 特价规则
       },
@@ -276,23 +277,18 @@ export default {
           { title: '市价折扣', scopedSlots: { customRender: 'cityDiscount' }, width: '33%', align: 'center' },
           { title: '特约折扣', scopedSlots: { customRender: 'specialDiscount' }, width: '33%', align: 'center' }
         ]
-        _this.setTableData = [{
-          provinceValue: '',
-          cityValue: '',
-          specialValue: ''
-        }]
       } else if (_this.form.discountType === '2') {
         arr = [
           { title: '省价直降', scopedSlots: { customRender: 'provincePrice' }, width: '33%', align: 'center' },
           { title: '市价直降', scopedSlots: { customRender: 'cityPrice' }, width: '33%', align: 'center' },
           { title: '特约直降', scopedSlots: { customRender: 'specialPrice' }, width: '33%', align: 'center' }
         ]
-        _this.specialProductList = [{
-          provinceSubtract: '',
-          citySubtract: '',
-          specialSubtract: ''
-        }]
       }
+      _this.setTableData = [{
+        provinceValue: undefined,
+        cityValue: undefined,
+        specialValue: undefined
+      }]
       return arr
     }
   },
@@ -323,7 +319,7 @@ export default {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           // 验证必填
-          if (_this.form.gateFlag == '1') {
+          if (_this.form.gateFlag === '1') {
             if (!_this.form.gateType) {
               _this.$message.warning('请选择规则门槛设置类型!')
               return
@@ -337,22 +333,8 @@ export default {
               return
             }
           }
-          if (_this.form.minOrderFlag == 1 && !_this.form.minOrderAmount) {
-            _this.$message.warning('请输入订单起订限制金额数!')
-            return
-          }
-          if (_this.form.minOrderFlag == 0) {
-            _this.form.minOrderAmount = undefined
-          }
-          if (_this.form.upperLimitFlag == 1 && !_this.form.upperLimitAmount) {
-            _this.$message.warning('请输入活动经费上限金额!')
-            return
-          }
-          if (_this.form.upperLimitFlag == 0) {
-            _this.form.upperLimitAmount = undefined
-          }
           const form = JSON.parse(JSON.stringify(_this.form))
-          if (form.gateFlag == '1') {
+          if (form.gateFlag === '1') {
             form.gateProductList = _this.$refs.cillProduct.getResultVal()
             form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
             if (form.gateProductList.length == 0) {
@@ -377,23 +359,19 @@ export default {
             form.gateType = undefined
           }
           form.specialProductList = _this.$refs.specialProduct.getResultVal()
-          if (form.specialProductList.length == 0) {
-            _this.$message.warning('请添加特价产品!')
+          // 为空判断
+          const isTypeEmpty = form.specialProductList.some(item => (item.productTypeList && item.productTypeList.length == 0) && (item.productBrandList && item.productBrandList.length == 0))
+          if (isTypeEmpty) {
+            _this.$message.warning('产品分类或品牌不能为空!')
             return
-          } else {
-            // 为空判断
-            const isTypeEmpty = form.specialProductList.some(item => (item.productTypeList && item.productTypeList.length == 0) && (item.productBrandList && item.productBrandList.length == 0))
-            if (isTypeEmpty) {
-              _this.$message.warning('产品分类或品牌不能为空!')
-              return
-            }
-            const isNumEmpty = form.specialProductList.some(item => (!item.unitType || !item.unitQty))
-            if (isNumEmpty) {
-              _this.$message.warning('订单起订量设置不能为空!')
-              return
-            }
+          }
+          const isNumEmpty = form.specialProductList.some(item => (!item.unitType || !item.unitQty))
+          if (isNumEmpty) {
+            _this.$message.warning('订单起订量设置不能为空!')
+            return
+          }
+          if (form.discountType === '0') {
             const isCountEmpty = _this.isNumEmpty(form.specialProductList)
-            const isMoneyEmpty = _this.isNumEmpty(form.specialProductList)
             if (isCountEmpty.flag) {
               _this.$message.warning('折扣不能为空!')
               return
@@ -402,6 +380,10 @@ export default {
               _this.$message.warning('折扣金额不能为空!')
               return
             }
+          } else {
+            form.provinceValue = _this.setTableData[0].provinceValue
+            form.cityValue = _this.setTableData[0].cityValue
+            form.specialValue = _this.setTableData[0].specialValue
           }
           form.promotionSn = _this.promotionSn
           _this.spinning = true
@@ -469,6 +451,7 @@ export default {
         gateFlag: '0', // 门槛
         gateType: undefined,
         gateValue: undefined,
+        regularUnit: 'YUAN',
         quotaAmount: undefined,
         discountType: '0', // 特价规则
         gateProductList: undefined,
@@ -478,7 +461,9 @@ export default {
         this.$refs.ruleForm.resetFields()
         this.$refs.cillProduct.reSetTableData()
         this.$refs.specialProduct.reSetTableData()
+        this.$refs[0].setTable.clearTable()
       })
+      this.setTableData = []
     },
     // 获取编辑详情
     getDetail () {
@@ -668,8 +653,8 @@ export default {
             provinceDiscountPrice: item.provinceDiscountPriceText,
             cityDiscountPrice: item.cityDiscountPriceText,
             specialDiscountPrice: item.specialDiscountPriceText,
-            unitType: item.unitType,
-            unitQty: item.unitQty,
+            unitType: item.unitType || 'SL',
+            unitQty: item.unitQty || '1',
             provinceDiscountRate: item.provinceDiscountRate ? item.provinceDiscountRate : undefined,
             cityDiscountRate: item.cityDiscountRate ? item.cityDiscountRate : undefined,
             specialDiscountRate: item.specialDiscountRate ? item.specialDiscountRate : undefined

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

@@ -1,611 +0,0 @@
-<template>
-  <div class="pages-wrap">
-    <!-- 列表 -->
-    <a-table
-      class="sTable"
-      style="margin-top:10px;"
-      ref="table"
-      size="small"
-      :pagination="false"
-      :rowKey="(record) => record.productScopeSn"
-      :columns="columns"
-      :data-source="dataSource"
-      bordered>
-      <!-- 产品分类 -->
-      <template slot="productType" slot-scope="text, record,index">
-        <div style="max-height:126px;width:100%;overflow-y:scroll;" v-if="!record.productThisList || record.productThisList.length==0">
-          <a-row v-if="record.productTypeArr && record.productTypeArr.length>0">
-            <a-col :span="18">
-              <div v-for="con in record.productTypeArr" :key="con.id">
-                <a-tooltip v-if="con.title&&con.title.length > 12" :title="con.title">
-                  <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,con,'typeList')">
-                    {{ `${con.title.slice(0, 12)}...` }}
-                  </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="6" style="text-align:right;">
-              <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
-                <a-icon type="plus" />
-              </a-tag>
-            </a-col>
-          </a-row>
-          <a-row v-else>
-            <a-col :span="24">
-              <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
-                <a-icon type="plus" />
-              </a-tag>
-            </a-col>
-          </a-row>
-        </div>
-        <div v-else>
-          <a-tag style="background: #fff; borderStyle: dashed;" :style="{color:'grey',cursor:'not-allowed'}">
-            <a-icon type="plus" />
-          </a-tag>
-        </div>
-      </template>
-      <!-- 品牌 -->
-      <template slot="productBrand" slot-scope="text, record,index">
-        <div style="max-height:126px;overflow-y:scroll;" v-if="!record.productThisList || record.productThisList.length==0">
-          <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
-            <a-col :span="18">
-              <a-tag v-for="item in record.productBrandArr" :key="item.brandSn" style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'brandList')">
-                {{ item.brandName }}
-              </a-tag>
-            </a-col>
-            <a-col :span="6" style="text-align:right;">
-              <a-tag style="background: #fff; borderStyle: dashed;" @click="addBrandTag(index, record)" color="blue">
-                <a-icon type="plus" />
-              </a-tag>
-            </a-col>
-          </a-row>
-          <a-row v-else>
-            <a-col :span="24">
-              <a-tag style="background: #fff; borderStyle: dashed;" @click="addBrandTag(index, record)" color="blue">
-                <a-icon type="plus" />
-              </a-tag>
-            </a-col>
-          </a-row>
-        </div>
-        <div v-else>
-          <a-tag style="background: #fff; borderStyle: dashed;" :style="{color:'grey',cursor:'not-allowed'}">
-            <a-icon type="plus" />
-          </a-tag>
-        </div>
-      </template>
-      <!-- 产品 -->
-      <template slot="product" slot-scope="text, record,index">
-        <div v-if="(record.productBrandArr && record.productBrandArr.length>0)||(record.productTypeArr && record.productTypeArr.length>0)">
-          <a-tag style="background: #fff; borderStyle: dashed;" :style="{color:'grey',cursor:'not-allowed'}">
-            <a-icon type="plus" />
-          </a-tag>
-        </div>
-        <div style="max-height:126px;overflow-y:scroll;" v-else>
-          <a-row v-if="record.productThisList && record.productThisList.length>0">
-            <a-col :span="18">
-              <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>
-            <a-col :span="6" style="text-align:right;">
-              <a-tag style="background: #fff; borderStyle: dashed;" @click="addProductTag(index, record)" color="blue">
-                <a-icon type="plus" />
-              </a-tag>
-            </a-col>
-          </a-row>
-          <a-row v-else>
-            <a-col :span="24">
-              <a-tag style="background: #fff; borderStyle: dashed;" @click="addProductTag(index, record)" color="blue">
-                <a-icon type="plus" />
-              </a-tag>
-            </a-col>
-          </a-row>
-        </div>
-      </template>
-      <!-- 操作 -->
-      <span slot="action" slot-scope="text,record">
-        <a-button
-          size="small"
-          type="link"
-          class="button-error"
-          @click="handleDel(record)"
-        >
-          删除
-        </a-button>
-      </span>
-    </a-table>
-    <div class="btn-cont">
-      <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
-    </div>
-    <!-- 选择产品品牌 -->
-    <chooseBrandModal
-      pageType="1"
-      ref="brandBox"
-      :openModal="openBrandModal"
-      :chooseData="chooseBrand"
-      @close="openBrandModal=false"
-      @ok="handleBrandOk" />
-    <!-- 选择产品分类 -->
-    <chooseTypeModal
-      ref="typeBox"
-      :openModal="openTypeModal"
-      :linkageStatus="false"
-      :chooseData="chooseType"
-      @close="openTypeModal=false"
-      @ok="handleTypeOk" />
-    <!-- 选择产品 -->
-    <chooseProductsModal
-      ref="productBox"
-      type="dealership"
-      :openModal="openProductsModal"
-      :chooseData="chooseProducts"
-      @close="openProductsModal=false"
-      @ok="handleProductsOk" />
-  </div>
-</template>
-
-<script>
-import { commonMixin } from '@/utils/mixin'
-import { VSelect } from '@/components'
-import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
-import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
-import chooseProductsModal from './chooseProductsModal.vue'
-import { getNewScopeSn } from '@/api/promotion'
-export default {
-  name: 'TableType1',
-  mixins: [commonMixin],
-  components: { VSelect, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
-  data () {
-    return {
-      spinning: false,
-      columns: [
-        { title: '产品分类', width: '30%', scopedSlots: { customRender: 'productType' }, align: 'center' },
-        { title: '品牌', width: '30%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
-        { title: '产品', width: '30%', scopedSlots: { customRender: 'product' }, align: 'center' },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
-      ],
-      dataSource: [],
-      openBrandModal: false,
-      openTypeModal: false,
-      openProductsModal: false,
-      chooseBrand: [],
-      chooseType: [],
-      brandTagIndex: null, // 所选品牌位置
-      classifyTagIndex: null, // 所选分类位置
-      productTagIndex: null, // 所选产品位置
-      chooseProducts: []
-    }
-  },
-  methods: {
-    // 新增一行
-    handleAddRow () {
-      const _this = this
-      _this.spinning = false
-      getNewScopeSn({}).then(res => {
-        if (res.status == 200) {
-          const newData = {
-            productScopeSn: res.data,
-            productTypeArr: [],
-            productTypeList: [],
-            productBrandArr: [],
-            productBrandList: [],
-            productThisList: []
-          }
-          _this.dataSource.push(newData)
-        } else {
-          _this.spinning = false
-        }
-      })
-    },
-    // 导入新增一行
-    importRow (list) {
-      const _this = this
-      const dataList = _this.setShowData('This')
-      dataList.forEach(item => {
-        const pos = list.indexOf(con => item.product.productSn == item.goodsSn)
-        list.splice(pos, 1)
-      })
-      if (list.length > 0) {
-        list.forEach(con => {
-          getNewScopeSn({}).then(res => {
-            if (res.status == 200) {
-              const newData = {
-                productScopeSn: res.data,
-                productThisList: [{
-                  productCode: con.productCode,
-                  productSn: con.product.productSn
-                }]
-              }
-              _this.dataSource.push(newData)
-            }
-          })
-        })
-      } else {
-        _this.$message.warning('请勿导入重复数据!')
-      }
-    },
-    // 删除一行
-    handleDel (row) {
-      const pos = this.dataSource.findIndex(con => con.productScopeSn == row.productScopeSn)
-      this.dataSource.splice(pos, 1)
-    },
-    // 添加产品分类
-    addClassifyTag (pos, row) {
-      this.classifyTagIndex = pos
-      this.openTypeModal = true
-      this.chooseType = this.handleRowData(row)
-      const getArr = this.setTypeShowData()
-      // 无品牌有分类的选择数据
-      const onlyTypeData = this.onlyType()
-      // 获取品牌重复数据
-      var flag = false
-      var c_typeArr = []
-      this.dataSource.forEach(item => {
-        if ((item.productTypeArr && item.productTypeArr.length > 0) && (item.productBrandList && item.productBrandList.length > 0)) {
-          item.productBrandList.forEach((con) => {
-            row.productBrandList.forEach(newCon => {
-              if (newCon.productBrandSn == con.productBrandSn) {
-                flag = true
-                c_typeArr = c_typeArr.concat(item.productTypeList)
-              }
-            })
-          })
-        }
-      })
-      const disTypeList = []
-      getArr.forEach(con => {
-        c_typeArr.forEach(item => {
-          for (const i in item) {
-            if (item[i] == con.goodsSn) {
-              disTypeList.push(con)
-            }
-          }
-        })
-      })
-      var uniqueArr = [...new Set(disTypeList)]
-
-      if (row.productBrandArr && row.productBrandArr.length == 0) {
-        this.$refs.typeBox.handleAllDisabled(onlyTypeData)
-      } else {
-        if (flag) {
-          this.$refs.typeBox.handleAllDisabled(uniqueArr)
-        } else {
-          this.chooseType = []
-          this.$refs.typeBox.handleAllDisabled([])
-        }
-      }
-    },
-    handleTypeOk (mainArr) {
-      const classifyArr = []
-      const newClassifyArr = []
-      mainArr.forEach(item => {
-        if (item.productTypeLevel == 1) {
-          if ((item.dataRef && !item.dataRef.children) || (!item.dataRef && !item.children)) {
-            const objType1 = {
-              productTypeSn1: item.snPaths
-            }
-            newClassifyArr.push(objType1)
-            const obj = JSON.parse(JSON.stringify(objType1))
-            obj.title = item.title
-            classifyArr.push(obj)
-          }
-        }
-        if (item.productTypeLevel == 2) {
-          if ((item.dataRef && !item.dataRef.children) || (!item.dataRef && !item.children)) {
-            const typeArr1 = item.snPaths ? item.snPaths.split(',') : []
-            const objType2 = {
-              productTypeSn1: typeArr1[0],
-              productTypeSn2: typeArr1[1]
-            }
-            newClassifyArr.push(objType2)
-            const obj = JSON.parse(JSON.stringify(objType2))
-            const newName = item.namePaths.split(',')
-            obj.title = newName[1]
-            classifyArr.push(obj)
-          }
-        }
-        if (item.productTypeLevel == 3) {
-          const typeArr2 = item.snPaths ? item.snPaths.split(',') : []
-          const objType3 = {
-            productTypeSn1: typeArr2[0],
-            productTypeSn2: typeArr2[1],
-            productTypeSn3: typeArr2[2]
-          }
-          newClassifyArr.push(objType3)
-          const obj = JSON.parse(JSON.stringify(objType3))
-          const newName = item.namePaths.split(',')
-          obj.title = newName[1] + '/' + newName[2]
-          obj.id = typeArr2[2]
-          classifyArr.push(obj)
-        }
-      })
-      this.dataSource[this.classifyTagIndex].productTypeList = newClassifyArr
-      this.dataSource[this.classifyTagIndex].productTypeArr = classifyArr
-    },
-    // 添加产品品牌
-    addBrandTag (pos, row) {
-      const _this = this
-      _this.brandTagIndex = pos
-      // 选中的所有品牌
-      const dataList = _this.setShowData('Brand')
-      _this.openBrandModal = true
-      // 回显当前行选中
-      const echoData = _this.handleEchoData('Brand', row.productBrandList)
-      _this.chooseBrand = echoData
-      // 只有品牌没有分类
-      const onlyBrandData = this.onlyBrand()
-      // 同行中分类是否与所选分类相同   已选分类
-      var flag = false
-      var c_brandArr = []
-      this.dataSource.forEach(item => {
-        if ((item.productTypeArr && item.productTypeArr.length > 0) && (item.productBrandList && item.productBrandList.length > 0)) {
-          item.productTypeArr.forEach((con) => {
-            row.productTypeArr.forEach(newCon => {
-              if (newCon.id == con.id) {
-                flag = true
-                c_brandArr = c_brandArr.concat(item.productBrandList)
-              }
-            })
-          })
-        }
-      })
-
-      const reBrandArr = c_brandArr.map(list => {
-        return list.productBrandSn
-      })
-      if (row.productTypeArr && row.productTypeArr.length == 0) {
-        _this.$refs.brandBox.handleDisabled(onlyBrandData)
-      } else {
-        if (flag) { // 当前行有重复分类
-          _this.$refs.brandBox.handleDisabled(reBrandArr)
-        } else {
-          _this.chooseBrand = []
-          _this.$refs.brandBox.handleDisabled([])
-        }
-      }
-    },
-    handleBrandOk (conList) {
-      const newConList = conList.map(con => {
-        return {
-          productBrandSn: con.brandSn
-        }
-      })
-      this.dataSource[this.brandTagIndex].productBrandArr = conList
-      this.dataSource[this.brandTagIndex].productBrandList = newConList
-    },
-    // 添加产品
-    addProductTag (pos, row) {
-      this.productTagIndex = pos
-      this.openProductsModal = true
-      const dataList = this.setShowData('This')
-      const echoData = this.handleEchoData('This', row.productThisList)
-      this.chooseProducts = echoData
-      this.$refs.productBox.handleDisabled(dataList)
-    },
-    handleProductsOk (arr) {
-      const newArr = []
-      arr.forEach(item => {
-        const obj = {
-          productCode: item.code,
-          productSn: item.productSn
-        }
-        newArr.push(obj)
-      })
-      this.dataSource[this.productTagIndex].productThisList = newArr
-    },
-    // 获取回显禁用数据
-    setShowData (name) {
-      const _this = this
-      const snArr = []
-      _this.dataSource.forEach(item => {
-        if (item['product' + name + 'List'] && item['product' + name + 'List'].length > 0) {
-          item['product' + name + 'List'].forEach(con => {
-            const newName = name === 'This' ? '' : name
-            snArr.push(con['product' + newName + 'Sn'])
-          })
-        }
-      })
-      return snArr
-    },
-    // 只有分类
-    onlyType (name, onlyName) {
-      const _this = this
-      const snArr = []
-      _this.dataSource.forEach(item => {
-        if (item.productTypeList && item.productTypeList.length > 0) {
-          if (!item.productBrandList || (item.productBrandList && item.productBrandList.length == 0)) {
-            item.productTypeList.forEach(con => {
-              for (const i in con) {
-                const newObj = {
-                  goodsSn: con[i]
-                }
-                if (i === 'productTypeSn1') {
-                  newObj.disabled = true
-                } else {
-                  newObj.disableCheckbox = true
-                }
-                snArr.push(newObj)
-              }
-            })
-          }
-        }
-      })
-      return snArr
-    },
-    // 只有品牌
-    onlyBrand () {
-      const _this = this
-      var snArr = []
-      _this.dataSource.forEach(item => {
-        if (item.productBrandList && item.productBrandList.length > 0) {
-          if (!item.productTypeArr || (item.productTypeArr && item.productTypeArr.length == 0)) {
-            item.productBrandList.forEach(con => {
-              snArr.push(con.productBrandSn)
-            })
-          }
-        }
-      })
-      return snArr
-    },
-    handleEchoData (name, conArr) {
-      if (conArr) {
-        conArr.map(item => {
-          if (name === 'This') {
-            item.code = item.productCode
-            item.goodsSn = item.productSn
-          } else {
-            item.goodsSn = item['product' + name + 'Sn']
-          }
-        })
-      } else {
-        conArr = []
-      }
-      return conArr
-    },
-    handleRowData (row) {
-      const echoData = []
-      row.productTypeList.forEach(item => {
-        for (const i in item) {
-          const newObj = {
-            goodsSn: item[i]
-          }
-          if (i === 'productTypeSn1') {
-            newObj.disabled = true
-          } else {
-            newObj.disableCheckbox = true
-          }
-          echoData.push(newObj)
-        }
-      })
-      return echoData
-    },
-    setTypeShowData () {
-      const _this = this
-      const snArr = []
-      _this.dataSource.forEach(item => {
-        if (item.productTypeList && item.productTypeList.length > 0) {
-          item.productTypeList.forEach(con => {
-            for (const i in con) {
-              const newObj = {
-                goodsSn: con[i]
-              }
-              if (i === 'productTypeSn1') {
-                newObj.disabled = true
-              } else {
-                newObj.disableCheckbox = true
-              }
-              snArr.push(newObj)
-            }
-          })
-        }
-      })
-      return snArr
-    },
-    // 获取表格数据
-    getResultVal () {
-      const resultObj = JSON.parse(JSON.stringify(this.dataSource))
-      resultObj.map(item => {
-        delete item.productTypeArr
-        delete item.productBrandArr
-        return item
-      })
-      return resultObj
-    },
-    setTabVal (formData) {
-      this.dataSource = formData
-    },
-    // 关闭时清空表格数据
-    reSetTableData () {
-      this.dataSource = []
-    },
-    // 删除标签
-    delLabel (sn, row, type) {
-      const pos = this.dataSource.findIndex(con => con.productScopeSn == sn)
-      if (type === 'typeList') {
-      // 判断品牌是否有重复 重复值有无分类
-        const isRepeatBrandFlag = this.isRepeatBrand(this.dataSource[pos])
-        const uniqueArr1 = this.dataSource[pos].productTypeList && this.dataSource[pos].productTypeList.length > 0 ? this.dataSource[pos].productTypeList : []
-        if (isRepeatBrandFlag.flag && isRepeatBrandFlag.noTypeFlag && uniqueArr1.length == 1) {
-          this.dataSource.splice(pos, 1)
-        } else {
-          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 isRepeatTypeFlag = this.isRepeatType(this.dataSource[pos])
-        const uniqueArr = this.dataSource[pos].productBrandList && this.dataSource[pos].productBrandList.length > 0 ? this.dataSource[pos].productBrandList : []
-        if (isRepeatTypeFlag.flag && isRepeatTypeFlag.noTypeFlag && uniqueArr.length == 1) {
-          this.dataSource.splice(pos, 1)
-        } else {
-          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].productThisList.findIndex(con => con.productSn == row.productSn)
-        this.dataSource[pos].productThisList.splice(k, 1)
-      }
-      this.$forceUpdate()
-    },
-    // 判断当前行是否有重复品牌
-    isRepeatBrand (row) {
-      var flag = false
-      var noTypeFlag = false
-      var c_typeArr = []
-      this.dataSource.forEach(item => {
-        if (item.productBrandList && item.productBrandList.length > 0) {
-          item.productBrandList.forEach((con) => {
-            row.productBrandList.forEach(newCon => {
-              if (newCon.productBrandSn == con.productBrandSn) {
-                flag = true
-                if (item.productTypeList && item.productTypeList.length == 0) {
-                  noTypeFlag = true
-                } else {
-                  c_typeArr = c_typeArr.concat(item.productTypeList)
-                }
-              }
-            })
-          })
-        }
-      })
-      return { list: c_typeArr, flag: flag, noTypeFlag: noTypeFlag }
-    },
-    isRepeatType (row) {
-      var flag = false
-      var noTypeFlag = false
-      var c_brandArr = []
-      this.dataSource.forEach(item => {
-        if (item.productTypeArr && item.productTypeArr.length > 0) {
-          item.productTypeArr.forEach((con) => {
-            row.productTypeArr.forEach(newCon => {
-              if (newCon.id == con.id) {
-                flag = true
-                if (item.productBrandList && item.productBrandList.length == 0) {
-                  noTypeFlag = true
-                } else {
-                  c_brandArr = c_brandArr.concat(item.productBrandList)
-                }
-              }
-            })
-          })
-        }
-      })
-      return { list: c_brandArr, flag: flag, noTypeFlag: noTypeFlag }
-    }
-  }
-}
-</script>
-
-<style lang="less" scoped>
-  .pages-wrap{
-    .btn-cont {
-      text-align: center;
-      margin: 10px 0;
-    }
-  }
-
-</style>

+ 83 - 34
src/views/promotionRulesManagement/dealerPromotions/tableType3.vue

@@ -98,9 +98,12 @@
           </div>
           <span v-else>--</span>
         </div>
-        <div v-else style="width:90%;background:#ccc;border-radius: 10px;text-align:center;">
-          <span v-if="rulesType=='1'">{{ setData[0].provinceValue }}</span>
-          <span v-else>{{}}</span>
+        <div v-else >
+          <div v-if="record.provincePrice" style="width:90%;background:#ccc;border-radius: 3px;text-align:center;">
+            <span v-if="rulesType=='1'">{{ (setData[0].provinceValue||setData[0].provinceValue==0)?(record.provincePrice*setData[0].provinceValue/100).toFixed(2):'--' }}</span>
+            <span v-else>{{ (setData[0].provinceValue||setData[0].provinceValue==0)?(record.provincePrice - setData[0].provinceValue):'--' }}</span>
+          </div>
+          <span v-else>--</span>
         </div>
       </template>
       <!-- 省价折扣 -->
@@ -121,25 +124,34 @@
         </div>
         <div v-else>
           <span v-if="rulesType=='1'">{{ (setData[0].provinceValue||setData[0].provinceValue==0)?setData[0].provinceValue+'%':'--' }}</span>
-          <span v-else>{{ (setData[0].provinceSubtract || setData[0].provinceSubtract==0)?'-'+setData[0].provinceSubtract:'--' }}</span>
+          <span v-else>{{ (setData[0].provinceValue || setData[0].provinceValue==0)?'-'+setData[0].provinceValue:'--' }}</span>
         </div>
       </template>
       <!-- 市价特价 -->
       <template slot="cityPrice" slot-scope="text, record">
-        <div v-if="record.dataSourceOrigin=='1'">
-          <a-input-number
-            size="small"
-            style="width:90%;"
-            v-model="record.cityDiscountPrice"
-            :min="record.provinceDiscountPrice || 0"
-            :step="1"
-            :precision="2"
-            placeholder="请输入"
-            :max="999999"
-            :disabled="rulesType!='0'"
-            @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'city')"/>
+        <div v-if="rulesType==='0'">
+          <div v-if="record.dataSourceOrigin=='1'">
+            <a-input-number
+              size="small"
+              style="width:90%;"
+              v-model="record.cityDiscountPrice"
+              :min="record.provinceDiscountPrice || 0"
+              :step="1"
+              :precision="2"
+              placeholder="请输入"
+              :max="999999"
+              :disabled="rulesType!='0'"
+              @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'city')"/>
+          </div>
+          <span v-else>--</span>
+        </div>
+        <div v-else >
+          <div v-if="record.cityPrice" style="width:90%;background:#ccc;border-radius: 3px;text-align:center;">
+            <span v-if="rulesType=='1'">{{ (setData[0].cityValue||setData[0].cityValue==0)?(record.cityPrice*setData[0].cityValue/100).toFixed(2):'--' }}</span>
+            <span v-else>{{ (setData[0].cityValue||setData[0].cityValue==0)?(record.cityPrice - setData[0].cityValue):'--' }}</span>
+          </div>
+          <span v-else>--</span>
         </div>
-        <span v-else>--</span>
       </template>
       <!-- 市价折扣 -->
       <template slot="cityDiscount" slot-scope="text, record">
@@ -159,25 +171,34 @@
         </div>
         <div v-else>
           <span v-if="rulesType=='1'">{{ (setData[0].cityValue||setData[0].cityValue==0)?setData[0].cityValue+'%':'--' }}</span>
-          <span v-else>{{ (setData[0].citySubtract || setData[0].citySubtract==0)?'-'+setData[0].citySubtract:'--' }}</span>
+          <span v-else>{{ (setData[0].cityValue || setData[0].cityValue==0)?'-'+setData[0].cityValue:'--' }}</span>
         </div>
       </template>
       <!-- 特约特价 -->
       <template slot="specialPrice" slot-scope="text, record">
-        <div v-if="record.dataSourceOrigin=='1'">
-          <a-input-number
-            size="small"
-            style="width:90%;"
-            v-model="record.specialDiscountPrice"
-            :min="record.cityDiscountPrice ||0"
-            :step="1"
-            :precision="2"
-            placeholder="请输入"
-            :max="999999"
-            :disabled="rulesType!='0'"
-            @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'special')"/>
+        <div v-if="rulesType==='0'">
+          <div v-if="record.dataSourceOrigin=='1'">
+            <a-input-number
+              size="small"
+              style="width:90%;"
+              v-model="record.specialDiscountPrice"
+              :min="record.cityDiscountPrice ||0"
+              :step="1"
+              :precision="2"
+              placeholder="请输入"
+              :max="999999"
+              :disabled="rulesType!='0'"
+              @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'special')"/>
+          </div>
+          <span v-else>--</span>
+        </div>
+        <div v-else>
+          <div v-if="record.specialPrice" style="width:90%;background:#ccc;border-radius: 3px;text-align:center;">
+            <span v-if="rulesType=='1'">{{ (setData[0].specialValue||setData[0].specialValue==0)?(record.specialPrice*setData[0].specialValue/100).toFixed(2):'--' }}</span>
+            <span v-else>{{ (setData[0].specialValue||setData[0].specialValue==0)?(record.specialPrice - setData[0].specialValue):'--' }}</span>
+          </div>
+          <span v-else>--</span>
         </div>
-        <span v-else>--</span>
       </template>
       <!-- 特约折扣 -->
       <template slot="specialDiscount" slot-scope="text, record">
@@ -197,7 +218,7 @@
         </div>
         <div v-else>
           <span v-if="rulesType=='1'">{{ (setData[0].specialValue||setData[0].specialValue==0)?setData[0].specialValue+'%':'--' }}</span>
-          <span v-else>{{ (setData[0].specialSubtract || setData[0].specialSubtract==0)?'-'+setData[0].specialSubtract:'--' }}</span>
+          <span v-else>{{ (setData[0].specialValue || setData[0].specialValue==0)?'-'+setData[0].specialValue:'--' }}</span>
         </div>
       </template>
       <!-- 设置起订量 -->
@@ -268,7 +289,7 @@ export default {
       type: [Number, String],
       default: ''
     },
-    rulesType: {
+    rulesType: {// 特价规则类型  0 手动 1折扣 2直降
       type: [Number, String],
       default: ''
     },
@@ -278,7 +299,6 @@ export default {
     }
   },
   data () {
-    const _this = this
     return {
       spinning: false,
       dataSource: [],
@@ -628,6 +648,35 @@ export default {
     },
     // 获取最后结果
     getResultVal () {
+      const _this = this
+      if (_this.dataSource) {
+        if (_this.rulesType === '1') { // 折扣
+          _this.dataSource.forEach(con => {
+            con.provinceDiscountRate = _this.setData[0].provinceValue
+            con.cityDiscountRate = _this.setData[0].cityValue
+            con.specialDiscountRate = _this.setData[0].specialValue
+            if (con.dataSourceOrigin === '1') {
+              con.provinceDiscountPrice = (_this.setData[0].provinceValue * con.provincePrice / 100).toFixed(2)
+              con.cityDiscountPrice = (_this.setData[0].cityValue * con.cityPrice / 100).toFixed(2)
+              con.specialDiscountPrice = (_this.setData[0].specialValue * con.specialPrice / 100).toFixed(2)
+            }
+          })
+        } else if (_this.rulesType === '2') { // 直降
+          _this.dataSource.forEach(con => {
+            con.provinceSubtract = _this.setData[0].provinceValue
+            con.citySubtract = _this.setData[0].cityValue
+            con.specialSubtract = _this.setData[0].specialValue
+            if (con.dataSourceOrigin === '1') {
+              con.provinceDiscountPrice = con.provincePrice - _this.setData[0].provinceValue
+              con.cityDiscountPrice = con.cityPrice - _this.setData[0].cityValue
+              con.specialDiscountPrice = con.specialPrice - _this.setData[0].specialValue
+            }
+          })
+        }
+      } else {
+        _this.$message.warning('请添加特价产品!')
+        return
+      }
       const resultObj = JSON.parse(JSON.stringify(this.dataSource))
       resultObj.map(item => {
         delete item.productTypeArr