Commit 9fae0f1e by zhangquan

模板配置开发

1 parent 5f24d8bf
<template>
<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>
</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">
<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>
</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">
<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 }}
</div>
<div slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
</div>
<select-coupon-dialog @confirmDialog="confirmDialog" @closeDialog="closeDialog" :selectedGoodsList="couponFormObj.selectedGoodsList" v-if="isVisible" :isVisible="isVisible"></select-coupon-dialog>
</div>
</template>
<script>
import selectCouponDialog from './components/selectCouponDialog.vue'
export default {
name: 'index',
components: {
selectCouponDialog
},
data() {
return {
curConfigId: 1,
showInput: false,
isVisible: false,
configName: '',
curIdx: -1,
couponFormObj: {
selectedGoodsList: []
},
editForm: {
merchantId: ''
},
templateList: [
{
name:'定保',
id: 1
},
{
name:'续保模板',
id: 2
},
{
name:'节假日模板',
id: 3
}
],
rowList: [],
colList: [],
getListApi: this.$apis.goodsCouponApi.getCouponsList,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
searchForm: {
brandName: '',
goodsName: '',
appearance: '',
status: ''
},
buttonList: [
{
type: 'el-button',
name: '删除',
attrs: {
type: 'text',
fn: '删除'
},
listeners: {
click: row => this.del(row.scope)
}
}
],
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '品牌',
prop: 'brandName'
},
{
label: '商品名称',
minWidth: 220,
addHtml: 'goodName'
},
{
label: '数量',
prop: 'couponAmount'
},
{
label: '券面额',
width: 110,
prop: 'denomination'
},
{
label: '有效期',
width: 110,
prop: 'validityPeriod'
}
]
},
}
},
created() {
},
mounted(){
this.getTemplateList()
},
methods: {
getTemplateList(){
this.calcWidth()
},
addTemplate(){
this.showInput = true
this.$nextTick(()=>{
this.$refs.addInput.focus()
})
},
checkedTemp(item){
this.curConfigId = item.id
},
addCoupon(){
this.isVisible = true
},
calcWidth(){
let calculated = false
let mainW = this.$refs.main.offsetWidth
this.$nextTick(()=>{
this.rowList.reduce((pre, cur,index) => {
let curW = this.$refs?.['tempRef'+index]?.[0]?.offsetWidth
if((pre + curW) > mainW-500 && !calculated) {
this.curIdx = index
calculated = true
}
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.configName = ''
}
this.calcWidth()
},
closeDialog() {
this.isVisible = false
},
confirmDialog(e) {
this.couponFormObj.selectedGoodsList = e || []
},
}
}
</script>
<style lang="scss" scoped>
.container {
.nav{
.inputArea{
display: inline-block;
height: 40px;
line-height: 40px;
border-radius: 4px 4px 0 0;
margin-right: 1px;
.input{
width: 245px;
/deep/ .el-input__inner{
vertical-align: baseline;
box-sizing: border-box;
border: none;
}
}
}
.configItem{
display: inline-block;
padding: 0 20px;
height: 40px;
line-height: 40px;
background-color: #F8F8F8;
border-radius: 4px 4px 0 0;
margin-right: 1px;
color: #666666;
letter-spacing: 0;
text-align: center;
cursor: pointer;
}
.curConfigItem{
background-color: #fff;
color: #5850FF;
font-weight: 500;
}
.addBtn, .pullBtn{
width: 50px;
box-sizing: border-box;
padding: 0;
position: relative;
i{
border: 1px dashed #999;
color: #999;
}
}
.pullBtn{
&:hover{
.pullDownArea{
display: block;
}
}
.pullDownArea{
display: none;
position: absolute;
width: 200px;
max-height: 200px;
overflow-y: auto;
right: 0;
background-color: #fff;
z-index: 2;
box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px 0 #00000014, 0 9px 28px 8px #0000000d;
border-radius: 4px;
.pullDownItem{
height: 36px;
line-height: 36px;
font-weight: 400;
padding: 0 15px;
font-size: 14px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: #666666;
background-color: #F8F8F8;
&:hover{
background-color: #f5f7fa;
}
}
.curConfigItem{
background-color: #fff;
color: #5850FF;
font-weight: 500;
}
}
}
}
.main{
background-color: #fff;
padding: 16px 20px;
.good_name {
img {
width: 40px;
height: 20px;
vertical-align: text-bottom;
}
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!