Commit f5540c35 by zhangquan

模板联调

1 parent 9fae0f1e
......@@ -95,6 +95,60 @@ const effectiveCouponApi = params => {
})
}
// 获取模板配置
const getTemplateList = params => {
params.method = `${defaultPath}template.page`
return other_http({
url,
method: 'POST',
data: params,
sign: true
})
}
// 获取模板配置
const saveTemplate = params => {
params.method = `${defaultPath}template.save`
return other_http({
url,
method: 'POST',
data: params,
sign: true
})
}
// 保存模板下的优惠券
const saveCouponInfo = params => {
params.method = `${defaultPath}template.details.save`
return other_http({
url,
method: 'POST',
data: params,
sign: true
})
}
// 获取模板下的优惠券列表
const getCouponById = params => {
params.method = `${defaultPath}template.details.page`
return other_http({
url,
method: 'POST',
data: params,
sign: true
})
}
const delCouponById = params => {
params.method = `${defaultPath}template.details.delete`
return other_http({
url,
method: 'POST',
data: params,
sign: true
})
}
export default {
getCouponsList,
createCoupons,
......@@ -104,5 +158,10 @@ export default {
deleteCouponApi,
couponUserCancelApi,
detailExportApi,
effectiveCouponApi
effectiveCouponApi,
getTemplateList,
saveTemplate,
saveCouponInfo,
getCouponById,
delCouponById
}
......@@ -29,7 +29,7 @@
<div>
<div class="title">
<i class="el-icon-warning icon"></i>
<div class="tip">以下品牌商品优惠券面额已存在,请修改面额或删除</div>
<div class="tip">以下面额的品牌商品优惠券,已存在相同有效期,请修改有效期或删除</div>
</div>
<div class="error_coupon">
<div class="coupon_item" v-for="(item, index) in errorCouponList" :key="index">
......
......@@ -8,8 +8,8 @@
<div class="good_name" slot="goodName" slot-scope="scope">
<img v-if="scope.scope.appearance == 1" src="@/assets/coupon.png" alt="" />
<img v-else src="@/assets/directCharge.png" alt="" />
<!-- {{ scope.scope.appearance == 2 ? scope.scope.productName + (scope.scope.denomination || '') : scope.scope.productName }} -->
{{ scope.scope.productName }}
<!-- {{ scope.scope.appearance == 2 ? scope.scope.goodsName + (scope.scope.denomination || '') : scope.scope.goodsName }} -->
{{ scope.scope.goodsName }}
</div>
</GLTable>
</div>
......@@ -25,9 +25,9 @@
<div class="gift_item" v-for="(item, index) in val" :key="index">
<img class="muti_icon" src="@/assets/muti-selected.png" @click="handleGiftDelete(key, item, index)" />
<!-- <img class="muti_icon" src="@/assets/muti-no-select.png" @click="handleGiftDelete(item, index)" /> -->
<el-tooltip effect="dark" placement="top" :disabled="item.productName.length <= 8">
<p :class="['gift_coupon_name', 'ellipsis-1', item.status == '3' ? 'txt-grey' : '']">{{ item.productName.length > 8 ? item.productName.slice(0, 8) + '...' : item.productName }}</p>
<div slot="content">{{ item.productName }}</div>
<el-tooltip effect="dark" placement="top" :disabled="item.goodsName.length <= 8">
<p :class="['gift_coupon_name', 'ellipsis-1', item.status == '3' ? 'txt-grey' : '']">{{ item.goodsName.length > 8 ? item.goodsName.slice(0, 8) + '...' : item.goodsName }}</p>
<div slot="content">{{ item.goodsName }}</div>
</el-tooltip>
<div class="gift_sum">
<el-input-number :disabled="item.status == '3'" class="sum_input" v-model="item.couponAmount" :min="1" :max="9999" size="mini" label="描述文字"></el-input-number>
......@@ -61,8 +61,7 @@ export default {
pageSizes: [10, 20, 30, 40, 50],
dialogSearchForm: {
brandName: '',
productName: '',
status: 1
goodsName: ''
},
dialogFormData: [
{
......@@ -76,12 +75,12 @@ export default {
},
{
label: '商品名称',
name: 'productName',
name: 'goodsName',
type: 'input',
isClear: true
}
],
getListApi: this.$apis.orderApi.getGoodsList,
getListApi: this.$apis.goodsCouponApi.getCouponsList,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
tableParams: {
listName: 'list',
......@@ -99,14 +98,16 @@ export default {
addHtml: 'goodName'
},
{
label: '券面额',
label: '券面额/元',
width: 110,
prop: 'denomination'
formatter: cell => {
return cell.denomination ? Number((Number(cell.denomination) / 100).toFixed(2)) : 0
}
},
{
label: '有效期',
label: '有效期/天',
width: 110,
prop: 'validityPeriod'
prop: 'effectiveDays'
}
]
}
......@@ -136,8 +137,7 @@ export default {
handleRest() {
this.dialogSearchForm = {
brandName: '',
productName: '',
status: 1
goodsName: ''
}
this.handleOk()
},
......
......@@ -2,25 +2,28 @@
<div class="container">
<div class="nav">
<div style="display: inline-block;">
<div v-if="curIdx>index || curIdx==-1" class="configItem" :ref="'tempRef'+index" @click="checkedTemp(item)" :class="{curConfigItem:curConfigId==item.id}" v-for="item,index in rowList" :key="item.id">{{ item.name }}</div>
<!-- v-if="curIdx>index || curIdx==-1" -->
<template v-for="item,index in rowList">
<div v-if="curIdx>index || curIdx==-1" class="configItem" :ref="'tempRef'+index" @click="selectedTemp(item)" :class="{curConfigItem:curConfigId==item.id}" :key="item.id">{{ item.name }}</div>
</template>
</div>
<div v-if="showInput" class="inputArea"><el-input maxLength="15" ref="addInput" @blur="inputBlur" v-model="configName" class="input"></el-input></div>
<div v-else class="configItem addBtn" style="cursor: pointer;" @click="addTemplate"><i class="el-icon-plus"></i></div>
<div v-if="curIdx > -1" class="configItem pullBtn" style="cursor: pointer;" @click="slideDown">
<div v-if="curIdx > -1" class="configItem pullBtn" style="cursor: pointer;">
<i class="el-icon-arrow-down"></i>
<div class="pullDownArea">
<div class="pullDownItem" @click="checkedTemp(item)" :class="{curConfigItem:curConfigId==item.id}" v-for="item,index in colList" :key="item.id">{{ item.name }}</div>
<div class="pullDownItem" @click="selectedTemp(item, 'sort')" :class="{curConfigItem:curConfigId==item.id}" v-for="item,index in colList" :key="item.id">{{ item.name }}</div>
</div>
</div>
</div>
<div ref="main" class="main">
<el-button type="primary" style="margin-bottom: 16px;" size="small" @click="addCoupon" class="el-icon-plus">添加优惠券</el-button>
<GLTable ref="tableRef" :pageConf="pageConf" :searchForm="searchForm" :tableParams="tableParams" :tableData="couponFormObj.selectedGoodsList">
<GLTable ref="tableRef" :pageConf="pageConf" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :beforeSearchFn="beforeSearchFn">
<div class="good_name" slot="goodName" slot-scope="scope">
<img v-if="scope.scope.appearance == 1" src="@/assets/coupon.png" alt="" />
<img v-else src="@/assets/directCharge.png" alt="" />
<!-- {{ scope.scope.appearance == 2 ? scope.scope.productName + (scope.scope.denomination || '') : scope.scope.productName }} -->
{{ scope.scope.productName }}
{{ scope.scope.goodsName }}
</div>
<div slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
......@@ -40,7 +43,7 @@ import selectCouponDialog from './components/selectCouponDialog.vue'
},
data() {
return {
curConfigId: 1,
curConfigId: '',
showInput: false,
isVisible: false,
configName: '',
......@@ -48,32 +51,14 @@ import selectCouponDialog from './components/selectCouponDialog.vue'
couponFormObj: {
selectedGoodsList: []
},
editForm: {
merchantId: ''
},
templateList: [
{
name:'定保',
id: 1
},
{
name:'续保模板',
id: 2
},
{
name:'节假日模板',
id: 3
}
],
rowList: [],
colList: [],
getListApi: this.$apis.goodsCouponApi.getCouponsList,
getListApi: this.$apis.goodsCouponApi.getCouponById,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
searchForm: {
brandName: '',
goodsName: '',
appearance: '',
status: ''
templateId: ''
},
buttonList: [
{
......@@ -84,7 +69,7 @@ import selectCouponDialog from './components/selectCouponDialog.vue'
fn: '删除'
},
listeners: {
click: row => this.del(row.scope)
click: row => this.delCoupon(row.scope)
}
}
],
......@@ -106,14 +91,16 @@ import selectCouponDialog from './components/selectCouponDialog.vue'
prop: 'couponAmount'
},
{
label: '券面额',
label: '券面额/元',
width: 110,
prop: 'denomination'
formatter: cell => {
return cell.denomination ? Number((Number(cell.denomination) / 100).toFixed(2)) : 0
}
},
{
label: '有效期',
label: '有效期/天',
width: 110,
prop: 'validityPeriod'
prop: 'effectiveDays'
}
]
},
......@@ -126,8 +113,36 @@ import selectCouponDialog from './components/selectCouponDialog.vue'
this.getTemplateList()
},
methods: {
delCoupon(row){
console.log(row)
this.$confirm('确认删除吗?', '提示', {
type: 'warning',
callback: action => {
if(action=='confirm'){
let params = {
templateId: this.curConfigId,
couponId: row.couponId
}
this.$apis.goodsCouponApi.delCouponById(params).then(res => {
if(res){
this.$message.success('删除成功')
this.handleOk()
}
})
}
}
})
},
getTemplateList(){
this.calcWidth()
this.$apis.goodsCouponApi.getTemplateList({pageSize: 10000, pageNum: 1}).then(res => {
if(res?.list?.length){
this.curConfigId = res.list[0]?.id
this.handleOk()
this.templateList = res.list
this.rowList = res.list
this.calcWidth()
}
})
},
addTemplate(){
this.showInput = true
......@@ -135,10 +150,29 @@ import selectCouponDialog from './components/selectCouponDialog.vue'
this.$refs.addInput.focus()
})
},
checkedTemp(item){
beforeSearchFn(){
return new Promise((resolve, reject) => {
this.searchForm.templateId = this.curConfigId
if(!this.curConfigId) return reject();
resolve()
})
},
handleOk() {
this.$refs.tableRef.refreshTable()
},
selectedTemp(item, isSort){
this.curConfigId = item.id
if(isSort){
let idx = this.templateList.findIndex(row => row.id == item.id)
console.log(idx, item.id, this.templateList)
let arr = this.templateList.splice(idx, 1)
this.templateList.unshift(arr[0])
this.calcWidth()
}
this.handleOk()
},
addCoupon(){
if(!this.curConfigId) return this.$message.error('请先选择模板');
this.isVisible = true
},
calcWidth(){
......@@ -153,30 +187,40 @@ import selectCouponDialog from './components/selectCouponDialog.vue'
}
return pre + curW
},0);
console.log( this.curIdx)
this.colList = this.curIdx >-1 ? this.templateList.slice(this.curIdx) : []
this.rowList = this.curIdx >-1 ? this.templateList.slice(0, this.curIdx) : this.templateList
})
},
slideDown(){
},
inputBlur(e){
this.showInput = false
if(this.configName) {
this.templateList.push({
name: this.configName,
id: parseInt(Math.random(1)*10000)
this.$apis.goodsCouponApi.saveTemplate({name: this.configName}).then(res =>{
if(res){
this.configName = ''
this.$message.success('添加成功')
this.getTemplateList()
}
})
this.configName = ''
}
this.calcWidth()
},
closeDialog() {
this.isVisible = false
},
confirmDialog(e) {
this.couponFormObj.selectedGoodsList = e || []
// this.couponFormObj.selectedGoodsList = e || []
if(e?.length){
let params = {
templateId: this.curConfigId,
coupons: e.map(item => {return {couponId: item.id, couponAmount: item.couponAmount}})
}
this.$apis.goodsCouponApi.saveCouponInfo(params).then(res => {
console.log(res)
if(res){
this.$message.success('添加成功')
this.handleOk()
}
})
}
},
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!