|
@@ -5,95 +5,97 @@
|
|
|
ref="sellRuleForm"
|
|
|
:model="sellForm"
|
|
|
:rules="sellRules"
|
|
|
+ class="setPromotion-form"
|
|
|
:label-col="sellFormItemLayout.labelCol"
|
|
|
:wrapper-col="sellFormItemLayout.wrapperCol">
|
|
|
<a-row>
|
|
|
<a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
- <a-form-model-item label="基本规则" prop="contentType">
|
|
|
+ <a-form-model-item label="基本规则" prop="ruleType">
|
|
|
<v-select
|
|
|
- v-model="sellForm.contentType"
|
|
|
+ v-model="sellForm.ruleType"
|
|
|
placeholder="请选择基本规则"
|
|
|
- ref="saleStatus"
|
|
|
- id="promotion-saleStatus"
|
|
|
- code="PROMO_CONTENT_TYPE"
|
|
|
+ id="setPromotion-ruleType"
|
|
|
+ code="PROMO_ACTIVE_RULE_TYPE"
|
|
|
:disabled="disabledVal"
|
|
|
allowClear></v-select>
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
|
|
|
- <a-form-model-item label="券名称" prop="title" :label-col="{span:4}" :wrapper-col="{span:18}">
|
|
|
+ <a-form-model-item label="券名称" :label-col="{span:4}" :wrapper-col="{span:16}" prop="ruleName">
|
|
|
<a-input
|
|
|
:disabled="disabledVal"
|
|
|
- id="setPromotion-title"
|
|
|
+ id="setPromotion-ruleName"
|
|
|
:maxLength="20"
|
|
|
- v-model.trim="sellForm.title"
|
|
|
+ v-model.trim="sellForm.ruleName"
|
|
|
placeholder="请输入券名称(最多20个字符)"
|
|
|
allowClear />
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
|
|
|
- <a-form-model-item label="券副标题" :label-col="{span:2}" :wrapper-col="{span:18}">
|
|
|
+ <a-form-model-item label="券副标题" :label-col="{span:4}" :wrapper-col="{span:16}">
|
|
|
<a-input
|
|
|
:disabled="disabledVal"
|
|
|
- id="setPromotion-title"
|
|
|
+ id="setPromotion-ruleTitle"
|
|
|
:maxLength="20"
|
|
|
- v-model.trim="sellForm.title"
|
|
|
+ v-model.trim="sellForm.ruleTitle"
|
|
|
placeholder="请输入券副标题(最多20个字符)"
|
|
|
allowClear />
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
<a-form-model-item label="产品范围">
|
|
|
- <div id="setPromotionRange" style="position:relative;">
|
|
|
+ <div id="setPromotion-productRange" style="position:relative;">
|
|
|
<a-tree-select
|
|
|
- v-model="con"
|
|
|
+ v-model="sellForm.productRangeList"
|
|
|
style="width: 100%"
|
|
|
- :tree-data="treeData"
|
|
|
+ :maxTagCount="12"
|
|
|
+ :tree-data="productTypeList"
|
|
|
tree-checkable
|
|
|
:disabled="disabledVal"
|
|
|
- :show-checked-strategy="SHOW_ALL"
|
|
|
:getPopupContainer="triggerNode => triggerNode.parentNode"
|
|
|
+ :replaceFields="{children:'children',title: 'productTypeName',key: 'productTypeSn',value: 'productTypeSn'}"
|
|
|
+ @blur="onChangeTree"
|
|
|
placeholder="请选择产品范围" />
|
|
|
- <!-- @change="onChangeTree" -->
|
|
|
</div>
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
- <a-form-model-item label="生成方式" prop="contentType">
|
|
|
- <a-radio-group v-model="sellForm.value" @change="onChangeType" :disabled="disabledVal">
|
|
|
- <a-radio :value="1">
|
|
|
- 按订单生成券
|
|
|
- </a-radio>
|
|
|
- <a-radio :value="2">
|
|
|
- 按产品款数生成券
|
|
|
- </a-radio>
|
|
|
- </a-radio-group>
|
|
|
+ <a-form-model-item label="生成方式" prop="ruleBaseType">
|
|
|
+ <v-select
|
|
|
+ v-model="sellForm.ruleBaseType"
|
|
|
+ ref="ruleBaseType"
|
|
|
+ id="setPromotion-ruleBaseType"
|
|
|
+ code="PROMO_RULE_BASE_TYPE"
|
|
|
+ showType="radio"
|
|
|
+ :disabled="disabledVal"
|
|
|
+ @change="handleRuleBaseType"
|
|
|
+ allowClear></v-select>
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
|
|
- <a-form-model-item label="券内容" prop="imageSet">
|
|
|
- <div class="couponCon">
|
|
|
- <a-row v-show="sellForm.value===1">
|
|
|
+ <a-form-model-item label="券内容" prop="ruleDetailList">
|
|
|
+ <div class="couponCon" v-if="couponList&&couponList.length>0">
|
|
|
+ <a-row v-for="(item,i) in couponList" :key="item.id">
|
|
|
<a-col :md="22" :sm="24">
|
|
|
<div class="couponList">
|
|
|
<!-- 具体内容 -->
|
|
|
- <a-form-model ref="couponRuleForm" :model="couponForm" :rules="couponRules" :label-col="couponFormLayout.labelCol" :wrapper-col="couponFormLayout.wrapperCol">
|
|
|
- <a-form-model-item ref="name" prop="name" style="margin-left:26px;">
|
|
|
+ <a-form-model :model="item" :label-col="couponFormLayout.labelCol" :wrapper-col="couponFormLayout.wrapperCol">
|
|
|
+ <a-form-model-item style="margin-left:26px;">
|
|
|
+ <span style="color:#ed1c24;font-size:15px;">*</span>
|
|
|
购买<a-input-number
|
|
|
style="margin:0 5px;"
|
|
|
- v-model="couponForm.regularValue"
|
|
|
+ v-model="item.productQty"
|
|
|
:step="1"
|
|
|
:max="99999999"
|
|
|
:precision="0"
|
|
|
- :disabled="disabledVal"
|
|
|
+ :disabled="true"
|
|
|
size="small"/>
|
|
|
<a-select
|
|
|
default-value="GE"
|
|
|
- :disabled="disabledVal"
|
|
|
- v-model="couponForm.regularUnit"
|
|
|
+ v-model="item.unit"
|
|
|
style="width: 60px;"
|
|
|
size="small"
|
|
|
- @change="handleChangeUnit">
|
|
|
+ :disabled="true">
|
|
|
<a-select-option value="GE">
|
|
|
个
|
|
|
</a-select-option>
|
|
@@ -102,104 +104,41 @@
|
|
|
</a-select-option>
|
|
|
</a-select>
|
|
|
活动产品,送<a-input-number
|
|
|
- v-model="couponForm.promotionValue"
|
|
|
- :disabled="disabledVal"
|
|
|
+ v-model="item.ruleValue"
|
|
|
style="margin:0 5px;"
|
|
|
:min="0"
|
|
|
:step="1"
|
|
|
:precision="2"
|
|
|
:max="99999999"
|
|
|
+ :disabled="pageType==='see'?disabledVal:!disabledVal"
|
|
|
size="small"/> 元
|
|
|
</a-form-model-item>
|
|
|
- <a-form-model-item label="活动产品" prop="region">
|
|
|
- <a-button type="primary" @click="handleAddProduct" :disabled="disabledVal" size="small">添加产品</a-button>
|
|
|
- <div class="productCon">
|
|
|
- <a-tag closable @close="delBuyerName(con)" :disabled="disabledVal">
|
|
|
- 产品编码
|
|
|
- </a-tag>
|
|
|
- <a-tag closable @close="delBuyerName(con)" :disabled="disabledVal">
|
|
|
- 产品编码
|
|
|
+ <a-form-model-item class="productName" label="活动产品" prop="ruleProductList">
|
|
|
+ <a-button type="primary" :disabled="pageType==='see'?disabledVal:!disabledVal" @click="handleAddProduct(item)" size="small">添加产品</a-button>
|
|
|
+ <div class="productCon" v-if="item.ruleProductList && item.ruleProductList.length>0">
|
|
|
+ <a-tag :closable="pageType==='see'?!disabledVal:disabledVal" @close="delBuyerName(item,con)" v-for="con in item.ruleProductList" :key="con.productSn">
|
|
|
+ {{ con.productCode }}
|
|
|
</a-tag>
|
|
|
</div>
|
|
|
</a-form-model-item>
|
|
|
- <a-form-model-item label="券适用范围" prop="desc">
|
|
|
+ <a-form-model-item class="productName" label="券适用范围" prop="range">
|
|
|
全部产品
|
|
|
</a-form-model-item>
|
|
|
- </a-form-model>
|
|
|
- </div>
|
|
|
- </a-col>
|
|
|
- <a-col :md="2" :sm="24">
|
|
|
- <a-button type="link" class="button-info" :disabled="disabledVal">+新增</a-button>
|
|
|
- <a-button type="link" :disabled="disabledVal">删除</a-button>
|
|
|
- </a-col>
|
|
|
- </a-row>
|
|
|
- <a-row v-show="sellForm.value===2" v-for="item in couponList" :key="item.id">
|
|
|
- <a-col :md="22" :sm="24">
|
|
|
- <div class="couponList">
|
|
|
- <!-- 具体内容 -->
|
|
|
- <a-form-model ref="couponRuleForm" :model="couponForm" :rules="couponRules" :label-col="couponFormLayout.labelCol" :wrapper-col="couponFormLayout.wrapperCol">
|
|
|
- <a-form-model-item ref="name" prop="name" style="margin-left:26px;">
|
|
|
- 购买<a-input-number
|
|
|
- style="margin:0 5px;"
|
|
|
- v-model="couponForm.regularValue"
|
|
|
- :step="1"
|
|
|
- :max="99999999"
|
|
|
- :precision="0"
|
|
|
- :disabled="disabledVal"
|
|
|
- size="small"/>
|
|
|
- <a-select
|
|
|
- default-value="GE"
|
|
|
- v-model="couponForm.regularUnit"
|
|
|
- style="width: 60px;"
|
|
|
- size="small"
|
|
|
- :disabled="disabledVal"
|
|
|
- @change="handleChangeUnit">
|
|
|
- <a-select-option value="GE">
|
|
|
- 个
|
|
|
- </a-select-option>
|
|
|
- <a-select-option value="YUAN">
|
|
|
- 元
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- 活动产品,送<a-input-number
|
|
|
- v-model="couponForm.promotionValue"
|
|
|
- style="margin:0 5px;"
|
|
|
- :min="0"
|
|
|
- :step="1"
|
|
|
- :precision="2"
|
|
|
- :max="99999999"
|
|
|
- :disabled="disabledVal"
|
|
|
- size="small"/> 元
|
|
|
- </a-form-model-item>
|
|
|
- <a-form-model-item label="活动产品" prop="region">
|
|
|
- <a-button type="primary" :disabled="disabledVal" @click="handleAddProduct" size="small">添加产品</a-button>
|
|
|
- <div class="productCon">
|
|
|
- <a-tag closable @close="delBuyerName(con)" :disabled="disabledVal">
|
|
|
- 产品编码
|
|
|
- </a-tag>
|
|
|
- <a-tag closable @close="delBuyerName(con)" :disabled="disabledVal">
|
|
|
- 产品编码
|
|
|
- </a-tag>
|
|
|
- </div>
|
|
|
- </a-form-model-item>
|
|
|
- <a-form-model-item label="券适用范围" prop="desc">
|
|
|
- 全部产品
|
|
|
- </a-form-model-item>
|
|
|
- <a-form-model-item label="使用说明" prop="desc">
|
|
|
+ <a-form-model-item label="使用说明" prop="detailExplain" v-show="sellForm.ruleBaseType==='category'">
|
|
|
<a-input
|
|
|
- v-model="couponForm.desc"
|
|
|
- :disabled="disabledVal"
|
|
|
+ v-model="item.detailExplain"
|
|
|
+ :disabled="pageType==='see'?disabledVal:!disabledVal"
|
|
|
style="width:80%;"
|
|
|
type="textarea"
|
|
|
placeholder="请输入使用说明"
|
|
|
- :maxLength="200" />
|
|
|
+ :maxLength="50" />
|
|
|
</a-form-model-item>
|
|
|
</a-form-model>
|
|
|
</div>
|
|
|
</a-col>
|
|
|
<a-col :md="2" :sm="24">
|
|
|
- <a-button type="link" v-if="i===0" class="button-info" @click="addCouponCon" :disabled="disabledVal">+新增</a-button>
|
|
|
- <a-button type="link" v-else @click="delCouponCon(item.id)" :disabled="disabledVal">删除</a-button>
|
|
|
+ <a-button type="link" v-show="i===0&&couponList.length<10" class="button-info" @click="addCouponCon" :disabled="pageType==='see'?disabledVal:!disabledVal">+新增</a-button>
|
|
|
+ <a-button type="link" v-show="i!=0" @click="delCouponCon(item.id)" :disabled="pageType==='see'?disabledVal:!disabledVal">删除</a-button>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
</div>
|
|
@@ -211,30 +150,31 @@
|
|
|
:md="12"
|
|
|
:lg="24"
|
|
|
:xl="24"
|
|
|
- v-show="sellForm.value===1">
|
|
|
- <a-form-model-item label="使用说明">
|
|
|
- <a-input v-model="sellForm.desc" type="textarea" placeholder="请输入使用说明" :disabled="disabledVal" :maxLength="200" />
|
|
|
+ v-if="sellForm.ruleBaseType!='category'">
|
|
|
+ <a-form-model-item label="使用说明" prop="ruleExplain">
|
|
|
+ <a-input v-model="sellForm.ruleExplain" type="textarea" placeholder="请输入使用说明" :disabled="disabledVal" :maxLength="50" />
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :xs="24" :sm="24" :md="12" :lg="24" :xl="24">
|
|
|
- <a-form-model-item label="券有效期">
|
|
|
- <a-radio-group v-model="sellForm.termVal" :disabled="disabledVal">
|
|
|
- <a-radio :style="radioStyle" :value="1">
|
|
|
+ <a-form-model-item label="券有效期" prop="validType">
|
|
|
+ <a-radio-group v-model="sellForm.validType" :disabled="disabledVal" @change="handleValidType">
|
|
|
+ <a-radio :style="radioStyle" value="FIXED">
|
|
|
<span>固定日期</span>
|
|
|
<a-range-picker
|
|
|
style="width:100%;margin-left:5px;"
|
|
|
- v-model="sellForm.time"
|
|
|
+ v-model="time"
|
|
|
:format="dateFormat"
|
|
|
@change="dateChange"
|
|
|
:disabled="disabledVal"
|
|
|
+ :disabled-date="disabledDate"
|
|
|
:placeholder="['开始时间', '结束时间']" />
|
|
|
- <!-- :disabled-date="disabledDate" -->
|
|
|
</a-radio>
|
|
|
- <a-radio :style="radioStyle" :value="2">
|
|
|
+ <a-radio :style="radioStyle" value="LIMIT">
|
|
|
<span>领取后,当天生效,有效期至</span><a-input-number
|
|
|
style="margin:0 5px;"
|
|
|
- v-model="sellForm.regularValue"
|
|
|
+ v-model="sellForm.validDays"
|
|
|
:step="1"
|
|
|
+ :min="1"
|
|
|
:max="99999999"
|
|
|
:disabled="disabledVal"
|
|
|
:precision="0"/>天
|
|
@@ -249,9 +189,10 @@
|
|
|
|
|
|
<script>
|
|
|
import { commonMixin } from '@/utils/mixin'
|
|
|
+import moment from 'moment'
|
|
|
import { VSelect } from '@/components'
|
|
|
-import { TreeSelect } from 'ant-design-vue'
|
|
|
-const SHOW_ALL = TreeSelect.SHOW_ALL
|
|
|
+import { productTypeQuery } from '@/api/productType'
|
|
|
+import { getNewScopeSn } from '@/api/promoActive'
|
|
|
export default {
|
|
|
name: 'PromotionAddModal',
|
|
|
mixins: [commonMixin],
|
|
@@ -260,17 +201,21 @@ export default {
|
|
|
disabledVal: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
+ },
|
|
|
+ pageType: {
|
|
|
+ type: String,
|
|
|
+ default: 'edit'
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
spinning: false,
|
|
|
- SHOW_ALL,
|
|
|
// form 表单label布局设置
|
|
|
sellFormItemLayout: {
|
|
|
labelCol: { span: 2 }, // 文字前距离设置
|
|
|
wrapperCol: { span: 20 }// 表单后距离设置 数字越大距离越小
|
|
|
},
|
|
|
+ // 卷内容 form 表单label布局设置
|
|
|
couponFormLayout: {
|
|
|
labelCol: { span: 3 },
|
|
|
wrapperCol: { span: 18 }
|
|
@@ -281,111 +226,246 @@ export default {
|
|
|
height: '50px',
|
|
|
lineHeight: '40px'
|
|
|
},
|
|
|
+ // 主要内容 提交数据
|
|
|
sellForm: {
|
|
|
- value: 2,
|
|
|
- termVal: undefined,
|
|
|
- enabledFlag: '0',
|
|
|
- con: []
|
|
|
+ ruleType: 'ticket', // 基本规则类型
|
|
|
+ productRangeFlag: '', // 产品范围标记 0无 1有产品范围
|
|
|
+ productRangeList: [], // 产品范围列表
|
|
|
+ ruleName: '', // 券名称
|
|
|
+ ruleTitle: '', // 副标题
|
|
|
+ ruleBaseType: 'category', // 券生成方式
|
|
|
+ ruleExplain: '', // 使用说明
|
|
|
+ validType: undefined, // 券有效期类型
|
|
|
+ validStartDate: undefined, // 券生效时间
|
|
|
+ validEndDate: undefined, // 券失效时间
|
|
|
+ validDays: undefined, // 券有效期天数
|
|
|
+ // ruleDetailName:undefined,
|
|
|
+ // 券内容
|
|
|
+ ruleDetailList: []
|
|
|
},
|
|
|
- dateFormat: 'YYYY-MM',
|
|
|
- con: [],
|
|
|
- couponList: [{
|
|
|
- val1: '',
|
|
|
- unit: ''
|
|
|
- }], // 按产品款数生成券 数据
|
|
|
- treeData: [],
|
|
|
- showProModal: false,
|
|
|
- couponForm: {},
|
|
|
- couponRules: {},
|
|
|
-
|
|
|
+ editFlag: true, // 编辑页面 可编辑内容
|
|
|
+ // 券内容 提交数据
|
|
|
+ couponList: [],
|
|
|
+ // 按产品款数生成券 数据
|
|
|
+ dateFormat: 'YYYY-MM-DD',
|
|
|
+ posNum: null, // 选择产品位置
|
|
|
sellRules: {
|
|
|
- promoBuyerList: [{
|
|
|
- required: true,
|
|
|
- message: '请选择参与经销商',
|
|
|
- trigger: 'change'
|
|
|
- }],
|
|
|
- time: [{
|
|
|
- required: true,
|
|
|
- message: '请选择促销时间',
|
|
|
- trigger: 'change'
|
|
|
- }],
|
|
|
- name: [{
|
|
|
- required: true,
|
|
|
- message: '请输入促销名称',
|
|
|
- trigger: 'blur'
|
|
|
- }],
|
|
|
- description: [{
|
|
|
- required: true,
|
|
|
- message: '请输入促销描述',
|
|
|
- trigger: 'blur'
|
|
|
- }]
|
|
|
- }
|
|
|
+ ruleType: [{ required: true, message: '请选择基本规则', trigger: 'change' }],
|
|
|
+ ruleName: [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
|
|
|
+ ruleBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
|
|
|
+ ruleExplain: [{ required: true, message: '请输入使用说明', trigger: ['change', 'blur'] }],
|
|
|
+ validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
|
|
|
+ ruleDetailList: [{ type: 'array', required: true, message: '请选择券内容', trigger: 'change' }]
|
|
|
+ },
|
|
|
+ productTypeList: [],
|
|
|
+ time: []
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- delBuyerName (row) {
|
|
|
-
|
|
|
+ // 禁用日期时间
|
|
|
+ disabledDate (current) {
|
|
|
+ return current && current < moment().startOf('day')
|
|
|
},
|
|
|
- onChange () {
|
|
|
-
|
|
|
+ // 删除产品
|
|
|
+ delBuyerName (row, conRow) {
|
|
|
+ const ind = this.couponList.findIndex(item => item.id === row.id)
|
|
|
+ const pos = this.couponList[ind].ruleProductList.findIndex(con => con.productSn === conRow.productSn)
|
|
|
+ this.couponList[ind].ruleProductList.splice(pos, 1)
|
|
|
},
|
|
|
- dateChange () {
|
|
|
-
|
|
|
+ dateChange (date, dateString) {
|
|
|
+ this.time = date
|
|
|
+ if (dateString[0] != '' && dateString[1] != '') {
|
|
|
+ this.sellForm.validStartDate = dateString[0] + ' 00:00:00'
|
|
|
+ this.sellForm.validEndDate = dateString[1] + ' 23:59:59'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 重置
|
|
|
+ clearContent () {
|
|
|
+ this.couponList = []
|
|
|
+ this.productTypeList = []
|
|
|
+ this.time = []
|
|
|
+ this.sellForm = {
|
|
|
+ ruleType: 'ticket', // 基本规则类型
|
|
|
+ productRangeFlag: '', // 产品范围标记 0无 1有产品范围
|
|
|
+ productRangeList: [], // 产品范围列表
|
|
|
+ ruleName: '', // 券名称
|
|
|
+ ruleTitle: '', // 副标题
|
|
|
+ ruleBaseType: 'category', // 券生成方式
|
|
|
+ ruleExplain: '', // 使用说明
|
|
|
+ validType: undefined, // 券有效期类型
|
|
|
+ validStartDate: undefined, // 券生效时间
|
|
|
+ validEndDate: undefined, // 券失效时间
|
|
|
+ validDays: undefined, // 券有效期天数
|
|
|
+ // 券内容
|
|
|
+ ruleDetailList: []
|
|
|
+ }
|
|
|
},
|
|
|
- handleChangeUnit () {},
|
|
|
// 添加产品
|
|
|
- handleAddProduct () {
|
|
|
- this.$emit('addProduct', true)
|
|
|
+ handleAddProduct (row) {
|
|
|
+ const pos = this.couponList.findIndex(item => item.id === row.id)
|
|
|
+ this.posNum = pos
|
|
|
+ const typeArr = this.sellForm.productRangeList || []
|
|
|
+ let productArr = []
|
|
|
+ this.couponList.forEach(item => {
|
|
|
+ if (item.ruleProductList && item.ruleProductList.length > 0) {
|
|
|
+ const arr = item.ruleProductList.map(con => { return con.productSn })
|
|
|
+ productArr = productArr.concat(arr)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$emit('addProduct', { typeArr, productArr })
|
|
|
},
|
|
|
- // 生成方式 change
|
|
|
- onChangeType (e) {
|
|
|
- this.couponList = [{}]
|
|
|
- this.sellForm.value = e.target.value
|
|
|
+ onChangeTree () {
|
|
|
+ this.couponList = []
|
|
|
+ this.addCouponCon()
|
|
|
},
|
|
|
// 新增券内容
|
|
|
- addCouponCon () {
|
|
|
- const obj = {
|
|
|
- val1: '',
|
|
|
- unit: ''
|
|
|
- }
|
|
|
+ async addCouponCon () {
|
|
|
if (this.couponList.length >= 10) {
|
|
|
this.$message.warning('最多只能新增10个!')
|
|
|
return
|
|
|
}
|
|
|
+ const result = await getNewScopeSn({})
|
|
|
+ const obj = {
|
|
|
+ id: result.data,
|
|
|
+ productQty: 1, // 产品数量
|
|
|
+ ruleValue: undefined, // 返利金额
|
|
|
+ detailExplain: undefined, // 使用说明
|
|
|
+ unit: 'GE',
|
|
|
+ range: '1',
|
|
|
+ ruleProductList: []
|
|
|
+ }
|
|
|
this.couponList.push(obj)
|
|
|
},
|
|
|
// 删除券内容
|
|
|
delCouponCon (id) {
|
|
|
-
|
|
|
+ const pos = this.couponList.findIndex(item => item.id === id)
|
|
|
+ this.couponList.splice(pos, 1)
|
|
|
+ },
|
|
|
+ // 获取产品范围数据
|
|
|
+ getTreeData () {
|
|
|
+ productTypeQuery({}).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.productTypeList = res.data
|
|
|
+ } else {
|
|
|
+ this.productTypeList = []
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
- onChangeTree (e) {
|
|
|
- debugger
|
|
|
+ // 券生成方式 change
|
|
|
+ handleRuleBaseType () {
|
|
|
+ const _this = this
|
|
|
+ _this.$confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: '改变生成方式,券内容也会改变,确认改变吗?',
|
|
|
+ centered: true,
|
|
|
+ onOk () {
|
|
|
+ _this.couponList.map(item => {
|
|
|
+ item.detailExplain = undefined
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 券有效期 change
|
|
|
+ handleValidType (con) {
|
|
|
+ this.sellForm.validType = con.target.value
|
|
|
+ if (con.target.value === 'FIXED') {
|
|
|
+ this.sellForm.validDays = undefined
|
|
|
+ } else {
|
|
|
+ this.time = []
|
|
|
+ this.sellForm.validStartDate = undefined
|
|
|
+ this.sellForm.validEndDate = undefined
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setProductSn (list) {
|
|
|
+ this.couponList[this.posNum].ruleProductList = list
|
|
|
+ },
|
|
|
+ // 验证必填项
|
|
|
+ testAndVerify (callBack) {
|
|
|
+ if (this.couponList && this.couponList.length > 0) {
|
|
|
+ let moneyFlag = this.couponList.some( con => !con.ruleValue)
|
|
|
+ let productFlag = this.couponList.some( con => con.ruleProductList && con.ruleProductList.length == 0)
|
|
|
+ if(moneyFlag){
|
|
|
+ this.$message.warning('请输入返利金额!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(productFlag){
|
|
|
+ this.$message.warning('请选择活动产品!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$refs.sellRuleForm.validate(valid => {
|
|
|
+ if (valid){
|
|
|
+ callBack(valid)
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 返回组件值
|
|
|
+ getPromotionVal () {
|
|
|
+ this.sellForm.ruleDetailList = this.couponList
|
|
|
+ this.sellForm.productRangeFlag = (this.sellForm.productRangeList && this.sellForm.productRangeList.length > 0) ? '1' : '0'
|
|
|
+ const newData = JSON.parse(JSON.stringify(this.sellForm))
|
|
|
+ newData.productRangeList = newData.productRangeList.map(item => {
|
|
|
+ return { productTypeSn: item }
|
|
|
+ })
|
|
|
+ return newData
|
|
|
+ },
|
|
|
+ // 详情赋值
|
|
|
+ setDetailData (info, arr) {
|
|
|
+ info.productRangeList = info.productRangeList.map(item => item.productTypeSn)
|
|
|
+ if (info.validType === 'FIXED') {
|
|
|
+ this.time = [info.validStartDate, info.validEndDate]
|
|
|
+ }
|
|
|
+ this.sellForm = { ...this.sellForm, ...info }
|
|
|
+ this.couponList = arr
|
|
|
}
|
|
|
-
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ this.getTreeData()
|
|
|
+ },
|
|
|
+ activated () {
|
|
|
+ this.getTreeData()
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
- .couponList{
|
|
|
- background: #EFEFEF;
|
|
|
- border-radius:5px;
|
|
|
- padding:15px 15px 2px;
|
|
|
- margin-bottom:5px;
|
|
|
- .ant-form-item{
|
|
|
- margin-bottom:12px;
|
|
|
+ .setPromotion-form{
|
|
|
+ .couponList{
|
|
|
+ background: #EFEFEF;
|
|
|
+ border-radius:5px;
|
|
|
+ padding:15px 15px 2px;
|
|
|
+ margin-bottom:5px;
|
|
|
+ .ant-form-item{
|
|
|
+ margin-bottom:12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .productCon{
|
|
|
+ width: 80%;
|
|
|
+ margin-left:12.3%;
|
|
|
+ max-height: 150px;
|
|
|
+ overflow-y: scroll;
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 5px;
|
|
|
+ padding: 10px 15px;
|
|
|
+ }
|
|
|
+ .productCon::-webkit-scrollbar {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ #setPromotion-productRange{
|
|
|
+ /deep/.ant-select-dropdown{
|
|
|
+ max-height:30vh !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .productName{
|
|
|
+ /deep/.ant-form-item-label > label::before {
|
|
|
+ content: '*';
|
|
|
+ color:#ed1c24;
|
|
|
+ font-size:15px;
|
|
|
+ margin-right:3px;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- .productCon{
|
|
|
- width: 80%;
|
|
|
- margin-left:12.3%;
|
|
|
- max-height: 150px;
|
|
|
- overflow-y: scroll;
|
|
|
- background: #fff;
|
|
|
- border-radius: 5px;
|
|
|
- padding: 10px 15px;
|
|
|
- }
|
|
|
- .productCon::-webkit-scrollbar {
|
|
|
- display: none;
|
|
|
}
|
|
|
</style>
|