123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768 |
- <template>
- <div class="promotionEdit-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" class="promotionEdit-cont" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="promotionEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" />返回列表</a>
- <span v-if="$route.params.sn" style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">促销名称:{{ promotionName||'--' }}</span>
- </template>
- </a-page-header>
- <!-- 表单 -->
- <a-card :bordered="false" class="promotionEdit-cont">
- <a-form-model
- id="promotionEdit-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol"
- >
- <a-row>
- <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
- <a-form-model-item label="促销名称" prop="promoName" :label-col="{span:4}" :wrapper-col="{span:16}">
- <a-input
- id="promotionEdit-promoName"
- :maxLength="20"
- v-model.trim="form.promoName"
- placeholder="请输入促销名称(最多20个字符)"
- allowClear/>
- </a-form-model-item>
- </a-col>
- <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
- <a-form-model-item label="促销时间" prop="time" :label-col="{span:4}" :wrapper-col="{span:16}">
- <a-range-picker
- style="width:100%"
- id="promotionAdd-time"
- v-model="form.time"
- :format="dateFormat"
- :disabled-date="disabledDate"
- @change="dateChange"
- :placeholder="['开始时间', '结束时间']" />
- </a-form-model-item>
- </a-col>
- <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
- <a-form-model-item label="排序" prop="sort" :label-col="{span:4}" :wrapper-col="{span:16}">
- <a-input-number
- style="width:100%"
- id="promotionEdit-sort"
- :disabled="isDisabled"
- allowClear
- placeholder="请输入排序数字(数字越大越靠后)"
- v-model="form.sort"
- :min="0"
- :max="99999999"/>
- </a-form-model-item>
- </a-col>
- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
- <a-form-model-item label="参与经销商" prop="allDealerFlag">
- <a-row :gutter="15">
- <a-col :md="10" :sm="24">
- <a-select
- style="width:98%;"
- id="promotionList-allDealerFlag"
- v-model="form.allDealerFlag"
- placeholder="请选择参与经销商"
- @change="changeDealerScope"
- :disabled="true"
- allowClear>
- <a-select-option id="promotionList-dealerScope-all" value="1">全部经销商</a-select-option>
- <a-select-option id="promotionList-dealerScope-some" value="0">部分经销商</a-select-option>
- </a-select>
- </a-col>
- <a-col :md="3" :sm="24" v-show="form.dealerScope && form.dealerScope!='ALL_DEALER' ">
- <a-button id="promotionList-basicInfo-dealerScope" type="primary" :loading="spinning" @click="handleDealerModal">选择</a-button>
- </a-col>
- <a-col :md="5" :sm="24" v-show="chooseDealerList && chooseDealerList.length>0">
- 已{{ chooseDealerList.length }}选项
- </a-col>
- <a-col :md="24" :sm="24" v-show="chooseDealerList && chooseDealerList.length>0">
- <div class="buyerBox">
- <a-tag closable v-for="con in chooseDealerList" id="promotionList-dealerSn" :key="con.dealerSn" @close="delBuyerName(con)">
- {{ con.dealerName }}
- </a-tag>
- </div>
- </a-col>
- </a-row>
- </a-form-model-item>
- </a-col>
- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
- <a-form-model-item label="封面图片" prop="imageUrl" class="promotionEdit-img">
- <Upload
- class="upload"
- id="promotionEdit-imageUrl"
- v-model="form.imageUrl"
- ref="imageSet"
- :fileSize="10"
- :maxNums="1"
- @change="changeImage"
- listType="picture-card"></Upload>
- <span class="upload-desc">说明:单张大小小于10Mb;建议尺寸:宽(420px)*高(230px)</span>
- </a-form-model-item>
- </a-col>
- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
- <a-form-model-item label="促销描述" prop="description">
- <a-input
- v-model="form.description"
- :disabled="isDisabled"
- type="textarea"
- id="promotionEdit-description"
- placeholder="请输入促销描述(最多500个字符)"
- :maxLength="500" />
- </a-form-model-item>
- </a-col>
- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
- <a-form-model-item label="加盟商开关权限" prop="dealerOpenFlag">
- <v-select
- v-model="form.dealerOpenFlag"
- id="promotion-dealerOpenFlag"
- code="FLAG"
- showType="radio"
- :disabled="true"
- allowClear></v-select>
- </a-form-model-item>
- </a-col>
- <!-- 买产品送代金券 -->
- <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
- <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
- <a-form-model-item label="券名称" :label-col="{span:4}" :wrapper-col="{span:16}" prop="validName">
- <a-input
- id="promotionEdit-validName"
- :maxLength="20"
- v-model.trim="form.validName"
- placeholder="请输入券名称(最多20个字符)"
- allowClear />
- </a-form-model-item>
- </a-col>
- <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
- <a-form-model-item label="券副标题" :label-col="{span:4}" :wrapper-col="{span:16}">
- <a-input
- id="promotionEdit-validTitle"
- :maxLength="20"
- v-model.trim="form.validTitle"
- 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="生成方式" prop="validBaseType">
- <v-select
- style="width:40%;"
- v-model="form.validBaseType"
- id="promotionEdit-ruleBaseType"
- code="SHOP_PROMO_VALID_BASE_TYPE"
- placeholder="请选择生成方式"
- 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="validType">
- <v-select
- style="width:40%;"
- v-model="form.validType"
- placeholder="请选择券有效期"
- id="promotionEdit-validType"
- code="SHOP_PROMO_VALID_TYPE"
- @change="handleValidType"
- allowClear></v-select>
- <a-range-picker
- v-show="form.validType==='FIXED'"
- style="width:40%;margin-left:10px;"
- v-model="timeLimit"
- :format="dateFormat"
- id="promotionEdit-time"
- @change="dateLimitChange"
- :disabled-date="disabledDate"
- :placeholder="['开始时间', '结束时间']" />
- <span style="width:40%;margin-left:10px;" v-show="form.validType==='LIMIT'">
- 有效期<a-input-number
- style="margin:0 5px;"
- v-model="form.validDays"
- :step="1"
- id="promotionEdit-validDays"
- :max="99999999"
- :min="1"
- :precision="0"/>天
- </span>
- </a-form-model-item>
- </a-col>
- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
- <a-form-model-item class="productName" label="券适用范围" prop="validScope">
- 全部产品
- </a-form-model-item>
- </a-col>
- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
- <a-form-model-item label="使用说明" prop="validInfo">
- <a-input
- v-model="form.validInfo"
- type="textarea"
- id="promotionEdit-validInfo"
- placeholder="请输入使用说明(最多50个字符)"
- :maxLength="50" />
- </a-form-model-item>
- </a-col>
- </div>
- <div v-if="isShowNextStep">
- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
- <a-form-model-item prop="productNum" :label="pageType==='BUY_PROD_GIVE_PROD'?'满赠规则': pageType==='PROMO_PROD'?'优惠方式':'返券产品'">
- <div class="productInfo flex-center">
- <!-- 买产品送产品 -->
- <div v-if="pageType==='BUY_PROD_GIVE_PROD'">
- 同款产品买<a-input-number
- v-model="conditionValue"
- style="margin:0 5px;"
- :min="1"
- :step="1"
- :precision="0"
- :max="99999999"
- id="promotionEdit-conditionValue"
- size="small"/>赠
- <a-input-number
- v-model="resultValue"
- style="margin:0 5px;"
- :min="0"
- :step="1"
- :precision="0"
- :max="99999999"
- id="promotionEdit-resultValue"
- size="small"/>个(数量叠加)
- <a-button
- type="primary"
- id="promotionEdit-addSet-btn"
- class="button-primary"
- size="small"
- @click="handleBatchAdd">批量设置</a-button>
- </div>
- <!-- 特价产品 -->
- <div v-if="pageType==='PROMO_PROD'" style="width:80%;">
- <v-select
- v-model="form.discountType"
- ref="promoState"
- id="promotionList-discountType"
- code="SHOP_PROMO_DISCOUNT_TYPE"
- size="small"
- style="width:15%;margin-right:5px;"
- @change="handleDiscountType"
- placeholder="请选择"
- allowClear></v-select>
- <span>{{ form.discountType==='STRAIGHT_DOWN'? '直降':'折扣' }}</span>
- <a-input-number
- v-model="resultValue"
- style="width:15%;margin:0 5px;"
- :min="0"
- :step="1"
- :precision="2"
- :max="99999999"
- id="promotionEdit-resultValue"
- size="small"/>{{ form.discountType==='STRAIGHT_DOWN'? '元':'%' }}
- <a-button
- type="primary"
- id="promotionEdit-addSet-btn"
- class="button-primary"
- size="small"
- @click="handleBatchAdd">批量设置</a-button>
- </div>
- <!-- 买产品返代金券 -->
- <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
- 返券金额
- <a-input-number
- v-model="resultValue"
- style="margin:0 5px;"
- :min="0"
- :step="1"
- :precision="2"
- :max="99999999"
- id="promotionEdit-resultValue"
- size="small"/>元
- <a-button
- type="primary"
- id="promotionEdit-addSet-btn"
- :disabled="isDisabled"
- class="button-primary"
- size="small"
- @click="handleBatchAdd">批量设置</a-button>
- </div>
- <a-button type="primary" id="promotionEdit-add-btn" :disabled="isDisabled" @click="handleAddProduct" size="small">选择产品</a-button>
- </div>
- </a-form-model-item>
- </a-col>
- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
- <div style="width: 83%;margin:0 auto 10px;">
- <productTable ref="chooseProductList" :promoActiveSn="form.promoSn" :discountType="form.discountType" :activeType="pageType"></productTable>
- </div>
- </a-col>
- </div>
- </a-row>
- </a-form-model>
- </a-card>
- </a-spin>
- <div class="affix-cont">
- <a-button
- type="primary"
- class="button-primary"
- :disabled="spinning"
- id="productInfoEdit-submit-btn"
- size="large"
- @click="handleSave('all')"
- v-if="isShowNextStep"
- style="padding: 0 60px;">保存</a-button>
- <a-button
- type="primary"
- class="button-primary"
- style="padding: 0 30px;"
- size="large"
- v-if="!isShowNextStep"
- @click="handleSave('part')">保存后设置产品</a-button>
- </div>
- <!-- 添加产品 -->
- <chooseProduct
- ref="chooseProduct"
- :chooseType="chooseTypeList"
- :itemSn="$route.params.sn"
- :openModal="showProModal"
- @ok="addProductSuccess"
- @close="closeProductModal"></chooseProduct>
- <!-- 选择经销商 -->
- <chooseDealer :openModal="openDealerModal" @close="closeDealerModal" @ok="addDealerOk"></chooseDealer>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import moment from 'moment'
- // 组件
- import { VSelect, Upload } from '@/components'
- import Editor from '@/components/WEeditor'
- import chooseDealer from '@/views/easyPassManagement/homepageCarouselImg/chooseDealer'
- import productTable from './productTable'
- import chooseProduct from './chooseProductsModal.vue'
- // 接口
- import { saveChooseProduct, saveShopPromo, shopPromoDetail } from '@/api/shopPromo'
- export default {
- name: 'ProductBrandEditModal',
- mixins: [commonMixin],
- components: { VSelect, Upload, Editor, productTable, chooseDealer, chooseProduct },
- data () {
- return {
- spinning: false,
- // 表单 label 设置
- formItemLayout: {
- labelCol: { span: 2 },
- wrapperCol: { span: 20 }
- },
- productRangeList: [], // 产品范围列表
- dateFormat: 'YYYY-MM-DD', // 促销时间显示格式
- openDealerModal: false,
- pageType: undefined, // 促销类型
- // 链接配置内容
- form: {
- promoType: undefined, // 促销类型
- promoName: '', // '促销名称'
- time: [], // 促销时间
- promoStartDate: undefined, // 促销时间-开始
- promoEndDate: undefined, // 促销时间-结束
- sort: undefined, // 排序
- allDealerFlag: '1', // 全部经销商 1 部分经销商0'
- imageUrl: undefined, // 促销封面图
- description: '', // '促销描述'
- dealerEditFlag: '0', // 加盟商编辑 0否 1是
- dealerOpenFlag: '0', // 加盟商开关权限 0否 1是
- rangeList: [], // 选择产品列表
- discountType: 'STRAIGHT_DOWN', // 特价产品 - 优惠方式'
- validName: '', // 券名称
- validTitle: '', // 券副标题
- validBaseType: 'category', // 券生成方式
- validType: undefined, // 券有效期类型
- validStartDate: undefined, // 券生效时间
- validEndDate: undefined, // 券失效时间
- validDays: undefined, // 券有效期天数
- validScope: '1', // 券适用范围标记 1-全部 0-指定 死值 1
- validInfo: '', // 使用说明
- productNum: 0
- },
- conditionValue: undefined, // 买产品送产品 买
- resultValue: undefined, // 买产品送产品 赠 返券金额
- chooseDealerList: [], // 所选经销商数据
- timeLimit: [], // 有效期
- promotionName: '', // 促销名称
- showProModal: false, // 打开产品弹窗
- isShowNextStep: false, // 是否显示下一步 并提交一半配置产品
- isDisabled: false, // 控制页面是否能编辑
- chooseTypeList: [], // 已选中产品范围
- imageSet: [], // 回显显示图片数据
- productTypeList: [], // 产品范围 列表数据
- // 表单验证规则
- rules: {
- promoName: [{ required: true, message: '请输入促销名称', trigger: 'blur' }],
- time: [{ required: true, message: '请选择促销时间', trigger: 'change' }],
- sort: [{ required: true, message: '请输入排序数字', trigger: 'blur' }],
- allDealerFlag: [{ required: true, message: '请选择参与经销商', trigger: 'change' }],
- imageUrl: [{ required: true, message: '请选择要上传的封面图片', trigger: 'change' }],
- description: [{ required: true, message: '请输入促销描述内容', trigger: 'blur' }],
- dealerOpenFlag: [{ required: true, message: '请选择加盟商开关权限', trigger: 'change' }],
- rangeList: [{ required: true, message: '请选择促销产品', trigger: 'change' }],
- validName: [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
- validBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
- validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
- validScope: [{ required: true, message: '请选择券适用范围', trigger: 'blur' }],
- productNum: [{ required: true, message: '选择产品不能为空', trigger: 'blur' }]
- }
- }
- },
- methods: {
- changeDealerScope () {},
- addDealerOk () {},
- // 选择经销商
- handleDealerModal () {
- this.openDealerModal = true
- },
- // 关闭经销商弹窗
- closeDealerModal () {
- this.openDealerModal = false
- },
- // 禁用日期时间
- disabledDate (current) {
- return current && current < moment().startOf('day')
- },
- // 促销时间 change
- dateChange (date, dateStrings) {
- if (dateStrings && dateStrings[0]) {
- this.form.time = dateStrings
- this.form.promoStartDate = date.length ? dateStrings[0] + ' 00:00:00' : ''
- this.form.promoEndDate = date.length ? dateStrings[1] + ' 23:59:59' : ''
- } else {
- this.form.time = []
- }
- },
- // 有效期
- dateLimitChange (date, dateStrings) {
- if (dateStrings && dateStrings[0]) {
- this.timeLimit = dateStrings
- this.form.validStartDate = date.length ? dateStrings[0] + ' 00:00:00' : ''
- this.form.validEndDate = date.length ? dateStrings[1] + ' 23:59:59' : ''
- } else {
- this.timeLimit = []
- }
- },
- // 打开产品弹窗
- insterProduct (obj) {
- if (obj && Object.keys(obj).length > 0) {
- this.chooseTypeList = obj.typeArr
- }
- this.showProModal = true
- },
- handleDiscountType (val) {
- this.form.discountType = val
- this.resultValue = undefined
- },
- // 关闭产品弹窗
- closeProductModal () {
- this.showProModal = false
- },
- // 返回列表
- handleBack () {
- this.$router.push({ name: 'promotionalActivities', query: { closeLastOldTab: true } })
- },
- // 详情
- async getDetail (ajaxData) {
- const _this = this
- const res = await shopPromoDetail(ajaxData)
- if (res.status == 200) {
- if (res.data.promoStartDate && res.data.promoEndDate) {
- const startTime = res.data.promoStartDate.split(' ')[0]
- const endTime = res.data.promoEndDate.split(' ')[0]
- res.data.time = [startTime, endTime]
- }
- if (res.data.imageUrl) {
- _this.$refs.imageSet.setFileList(res.data.imageUrl)
- }
- _this.form = res.data
- _this.form.productNum = 0
- _this.isShowNextStep = true
- if (_this.$route.params.pageType === 'edit') {
- _this.pageType = res.data.promoType
- _this.promotionName = res.data.promoName
- }
- _this.$nextTick(() => {
- _this.$refs.chooseProductList.pageInit()
- })
- _this.form.productNum = _this.$refs.chooseProductList.getChooseProductNum()
- }
- },
- // 券有效期 change
- handleValidType (con) {
- this.form.validType = con
- if (con === 'FIXED') {
- this.form.validDays = undefined
- } else {
- this.timeLimit = []
- this.form.validStartDate = undefined
- this.form.validEndDate = undefined
- }
- },
- // 确定保存 验证必填
- handleSave (type) {
- const _this = this
- // 验证组件必填项
- console.log('_this.form.productNum ', _this.form.productNum)
- _this.$refs.ruleForm.validate(valid => {
- if (valid) {
- _this.savePartInfo(type)
- }
- })
- },
- // 保存
- savePartInfo (type) {
- const _this = this
- _this.form.promoType = _this.pageType
- var formData = JSON.parse(JSON.stringify(_this.form))
- if (type === 'all') {
- formData.productNum = _this.$refs.chooseProductList.getChooseProductNum()
- if (formData.productNum && formData.productNum == 0) {
- _this.$message.warning('请选择返券产品!')
- return
- }
- if (formData.promoType === 'BUY_PROD_GIVE_VALID') {
- if (formData.validType === 'FIXED') {
- if (!formData.validStartDate || !formData.validEndDate) {
- _this.$message.warning('请输入券有效期!')
- return false
- }
- } else {
- if (!formData.validDays) {
- _this.$message.warning('请输入券有效期!')
- return false
- }
- }
- }
- delete formData.productNum
- }
- delete formData.time
- _this.spinning = true
- saveShopPromo(formData).then(res => {
- if (res.status == 200) {
- _this.spinning = false
- if (res.data.errorMsg && res.data.errorMsg.length > 0) {
- this.$confirm({
- title: '提示',
- content: res.data.errorMsg.map((item, i) => { return <p>{i * 1 + 1}、{item}</p> }),
- centered: true,
- okText: '知道了',
- cancelText: '取消', // 将cancelText设置为空字符串或去掉该属性可以隐藏取消按钮
- cancelButtonProps: {
- style: {
- display: 'none' // 通过设置样式隐藏取消按钮
- }
- },
- onOk () {
- console.log('知道了')
- }
- })
- return
- }
- _this.$message.success(res.message)
- if (type === 'all') {
- _this.$nextTick(() => {
- _this.handleBack()
- _this.resetSearchForm()
- })
- } else {
- _this.isShowNextStep = true
- _this.getDetail({ sn: res.data.shopPromo.promoSn })
- }
- } else {
- _this.spinning = false
- }
- })
- },
- // 封面图片上传
- changeImage (file) {
- this.form.imageUrl = file
- },
- // 重置
- resetSearchForm () {
- if (this.pageType == 'add' || (this.pageType == 'edit' && !this.isDisabled)) {
- if (this.$refs.imageSet) {
- this.$refs.imageSet.setFileList('')
- }
- if (this.$refs.videoSet) {
- this.$refs.videoSet.setFileList('')
- }
- }
- if (this.$refs.editor) {
- this.$refs.editor.setHtml('')
- }
- this.form = {
- promoType: undefined, // 促销类型
- promoName: '', // '促销名称'
- time: [], // 促销时间
- promoStartDate: undefined, // 促销时间-开始
- promoEndDate: undefined, // 促销时间-结束
- sort: undefined, // 排序
- allDealerFlag: '1', // 全部经销商 1 部分经销商0'
- imageUrl: undefined, // 促销封面图
- description: '', // '促销描述'
- dealerEditFlag: '0', // 加盟商编辑 0否 1是
- dealerOpenFlag: '0', // 加盟商开关权限 0否 1是
- rangeList: [], // 选择产品列表
- discountType: 'STRAIGHT_DOWN', // 特价产品 - 优惠方式'
- validName: '', // 券名称
- validTitle: '', // 券副标题
- validBaseType: 'category', // 券生成方式
- validType: undefined, // 券有效期类型
- validStartDate: undefined, // 券生效时间
- validEndDate: undefined, // 券失效时间
- validDays: undefined, // 券有效期天数
- validScope: '1', // 券适用范围标记 1-全部 0-指定 死值 1
- validInfo: '', // 使用说明
- productNum: 0
- }
- this.isShowNextStep = false
- this.isDisabled = false
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields()
- }
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields()
- }
- },
- // 添加产品
- handleAddProduct () {
- this.chooseTypeList = this.productRangeList
- this.showProModal = true
- },
- // 批量设置
- handleBatchAdd () {
- if (!this.conditionValue && !this.resultValue) {
- this.$message.warning('请输入促销优惠规则!')
- return
- }
- this.$refs.chooseProductList.editMorePrice({ conditionValue: this.conditionValue, resultValue: this.resultValue })
- },
- // 添加产品成功
- addProductSuccess (list) {
- const productArr = list.map(item => {
- return {
- promoSn: this.form.promoSn,
- shopProductSn: item.shopProductSn,
- productSn: item.productSn,
- productCode: item.productCode
- }
- })
- saveChooseProduct(productArr).then(res => {
- if (res.status == 200) {
- this.showProModal = false
- // 获取产品列表 有分页
- this.$refs.chooseProductList.pageInit()
- }
- })
- },
- // 初始化
- pageInit () {
- if (this.$route.params.pageType === 'edit') {
- this.getDetail({ sn: this.$route.params.sn })
- } else {
- this.pageType = this.$route.params.pageType
- }
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- }
- // 仅刷新列表,不重置页面
- if (this.$store.state.app.updateList) {
- this.pageInit()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less" scoped>
- .promotionEdit-wrap{
- position: relative;
- height: 100%;
- box-sizing: border-box;
- padding-bottom:51px;
- .buyerBox{
- border:1px solid #d9d9d9;
- margin-top:10px;
- border-radius:4px;
- padding:4px 10px;
- background:#f2f2f2;
- max-height:130px;
- overflow-y:scroll;
- scrollbar-width: none;
- }
- >.ant-spin-nested-loading{
- overflow-y: scroll;
- height: 100%;
- }
- /deep/.ant-form-item{
- margin-bottom:8px;
- }
- // .ant-form-item-control
- .promotionEdit-cont{
- margin-bottom: 10px;
- }
- .upload{
- width: 100%!important;
- }
- // 文本编辑器 工具栏样式换行
- .promotionEdit-editor{
- .w-e-toolbar{
- flex-wrap: wrap;
- z-index: 0;
- }
- }
- // 商品图片描述
- .upload-desc{
- font-size: 12px;
- color: #808695;
- }
- #promotionEdit-attachList{
- height: auto;
- }
- .box{
- border:1px solid #d9d9d9;
- border-radius:4px;
- padding:4px 11px;
- color:rgba(0, 0, 0, 0.25);
- cursor: not-allowed;
- background:#fdfdfd;
- }
- .affix{
- .ant-affix{
- z-index: 101;
- display:inline-block
- }
- }
- /deep/.ant-radio-disabled + span{
- color:#000!important;
- }
- .tip{
- margin-left:10px;
- }
- .productInfo{
- display:flex;
- justify-content: space-between;
- }
- #setPromotion-productRange{
- /deep/.ant-select-dropdown{
- max-height:30vh !important;
- }
- }
- }
- </style>
|