Commit 10291701 by caoyanzhi

update: 品牌会员等级列表修改

parent 56641367
......@@ -18,8 +18,8 @@
<label class="input-label">{{ inputNumObj.gradeCode }}/6</label>
</el-form-item>
<el-form-item label="等级类型" prop="gradeType">
<el-radio v-model="ruleForm.gradeType" label="1">常规卡</el-radio>
<el-radio v-model="ruleForm.gradeType" label="2">特殊卡</el-radio>
<el-radio :value="ruleForm.gradeType" :disabled="ruleForm.gradeType == 2" label="1">常规卡</el-radio>
<el-radio :value="ruleForm.gradeType" :disabled="ruleForm.gradeType == 1" label="2">特殊卡</el-radio>
</el-form-item>
<!-- 自动升级 -->
<!-- 自动升级 -->
......@@ -481,6 +481,7 @@ export default {
that.navpath[3].path = '/memberGrade?enterpriseId=' + that.cliqueId + '&name=' + that.cliqueName;
that.navpath[4].name = '新增【' + that.cliqueName + '】等级';
that.enterpId = sessionStorage.getItem('enterpriseId');
this.ruleForm.gradeType = this.$route.query.type + '';
}
};
</script>
......
......@@ -94,6 +94,11 @@ export default {
typeL: String,
default: '1' // type 1 常规卡 2 特殊卡 3 付费卡
},
// 企业id,不传时查集团数据,否则查该id的商户数据
enterpriseId: {
type: String,
default: ''
}
},
watch: {
tableData: {
......@@ -139,13 +144,7 @@ export default {
methods: {
// 编辑集团
editCliqueLevel(index, row, obj) {
this.$router.push({
path: '/editGroupGrade',
query: {
gradeId: row.gradeId
}
});
this.$emit('edit', row);
},
// 删除
delCliqueLevel(index, row, obj) {
......@@ -169,12 +168,7 @@ export default {
},
addCard(type) {
if (this.tableData.length===10) return this.$message.warning('每个卡类型最多可创建10张会员卡')
this.$router.push({
path: '/addGroupGrade',
query: {
type
}
});
this.$emit('add', type);
},
editSort() {
if (!this.list.length) return this.$message.warning(`暂无${this.$options.filters.typeFilter(this.type)}!`);
......@@ -194,6 +188,9 @@ export default {
gradeIds: this.list.map(el => (el.gradeId)),
gradeType: this.type
};
if (this.enterpriseId) {
data.enterpriseId = this.enterpriseId;
}
postJson('/api-admin/sort-member-grade', data)
.then((res) => {
let resData = res.data;
......@@ -220,10 +217,6 @@ export default {
}
});
},
// 取消删除
cancelPop(index, row, obj) {
row.popVisible = false;
},
}
}
</script>
......@@ -264,11 +257,11 @@ export default {
}
}
.card-cell {
display: flex;
display: inline-flex;
align-items: center;
width: 120px;
padding: 0 15px;
max-width: 150px;
height: 40px;
padding-left: 10px;
border-radius: 4px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
......
......@@ -18,8 +18,8 @@
<label class="input-label">{{ inputNumObj.gradeCode }}/6</label>
</el-form-item>
<el-form-item label="等级类型" prop="gradeType">
<el-radio v-model="ruleForm.gradeType" label="1">常规卡</el-radio>
<el-radio v-model="ruleForm.gradeType" label="2">特殊卡</el-radio>
<el-radio :value="ruleForm.gradeType" :disabled="ruleForm.gradeType == 2" label="1">常规卡</el-radio>
<el-radio :value="ruleForm.gradeType" :disabled="ruleForm.gradeType == 1" label="2">特殊卡</el-radio>
</el-form-item>
<!-- 自动升级 -->
<!-- 自动升级 -->
......
......@@ -276,8 +276,8 @@
</el-form-item>
</el-form>
<!-- type 1 常规卡 2 特殊卡 3 付费卡(集团不展示) -->
<member-card-table :tableData="generalCardList" type="1" :logoImg="logoImg"/>
<member-card-table :tableData="specialCardList" type="2" :logoImg="logoImg"/>
<member-card-table :tableData="generalCardList" type="1" :logoImg="logoImg" @add="onAdd" @edit="onEdit"/>
<member-card-table :tableData="specialCardList" type="2" :logoImg="logoImg" @add="onAdd" @edit="onEdit"/>
</div>
</div>
<!-- end -->
......@@ -506,10 +506,23 @@ export default {
that.changeRoute('/memberGrade');
},
// 新增
onAdd(type) {
this.$router.push({
path: '/addGroupGrade',
query: {
type
}
});
},
// 编辑集团
editCliqueLevel(index, row, obj) {
let that = this;
that.changeRoute('/editGroupGrade');
onEdit(row) {
this.$router.push({
path: '/editGroupGrade',
query: {
gradeId: row.gradeId
}
});
},
// 取消删除
......
......@@ -4,59 +4,33 @@
<div class="right-content">
<div class="right-box">
<div class="attention-wrap">
<div class="title">
<div>会员等级根据从低到高的顺序,自上而下进行排序</div>
<div class="add-btn"><el-button type="primary" @click="addGrade">新增等级</el-button></div>
<!-- 常规卡 -->
<member-card-table
:tableData="generalCardList"
:logoImg="logoImg"
:enterpriseId="cliqueId"
type="1"
@add="addGrade"
@edit="editGrade"></member-card-table>
<!-- 特殊卡 -->
<member-card-table
:tableData="specialCardList"
:logoImg="logoImg"
:enterpriseId="cliqueId"
type="2"
@add="addGrade"
@edit="editGrade"></member-card-table>
</div>
<div class="table-wrap">
<el-table :data="memberTableData" style="width: 100%">
<el-table-column prop="gradeName" label="会员等级名称"> </el-table-column>
<el-table-column prop="gradeCode" label="等级编码"> </el-table-column>
<el-table-column prop="" label="等级类型">
<template slot-scope="scope">
{{ scope.row.gradeType == 1 ? '常规卡' : '特殊卡' }}
</template>
</el-table-column>
<el-table-column prop="" label="移动">
<template slot-scope="scope">
<i :class="['icon-color', 'el-icon-upload2', scope.$index == 0 ? 'disable' : '']" @click="toUp(scope.$index, scope.row, memberTableData)"></i>
<i :class="['icon-color', 'el-icon-back', 'icon-to-pre', scope.$index == 0 ? 'disable' : '']" @click="toPre(scope.$index, scope.row, memberTableData)"></i>
<i :class="['icon-color', 'el-icon-back', 'icon-to-next', scope.$index == memberTableData.length - 1 ? 'disable' : '']" @click="toNext(scope.$index, scope.row, memberTableData)"></i>
<i :class="['icon-color', 'el-icon-download', scope.$index == memberTableData.length - 1 ? 'disable' : '']" @click="toBottom(scope.$index, scope.row, memberTableData)"></i>
</template>
</el-table-column>
<el-table-column prop="" label="操作">
<template slot-scope="scope">
<el-button @click="editGrade(scope.$index, scope.row, memberTableData)" type="text" size="small">
编辑
</el-button>
<el-popover placement="top" width="160" v-model="scope.row.popVisible">
<p style="line-height: 1.5; padding: 10px 10px 20px;">确认删除吗?</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="cancelPop(scope.$index, scope.row, memberTableData)">取消</el-button>
<el-button type="primary" size="mini" @click="delGrade(scope.$index, scope.row, memberTableData)">确定</el-button>
</div>
<el-button slot="reference" class="m-l-10" type="text">
删除
</el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
</div>
</div>
</div>
</div>
<!-- <vue-gic-footer></vue-gic-footer> -->
</div>
</template>
<script>
import topNavNew from 'components/nav/navNew';
import MemberCardTable from './components/MemberCardTable.vue';
import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
import { getRequest, postRequest } from '@/api/api';
import { log } from '@/utils/index.js';
import { getRequest } from '@/api/api';
export default {
name: 'memberGrade',
......@@ -80,140 +54,40 @@ export default {
path: ''
}
],
// 商户id
cliqueId: '',
generalCardList: [], // 常规卡列表数据
specialCardList: [], // 特殊卡列表数据
logoImg: '', // 商户logo
cliqueId: '', // 商户id
cliqueName: '', //商户 name
memberTableData: []
};
},
mounted() {
let that = this;
that.cliqueId = that.$route.query.enterpriseId;
that.cliqueName = that.$route.query.name;
that.navpath[3].name = '编辑【' + that.cliqueName + '】会员等级';
that.getList();
const { enterpriseId, name } = this.$route.query;
this.cliqueId = enterpriseId;
this.cliqueName = name;
this.navpath[3].name = '编辑【' + name + '】会员等级';
sessionStorage.removeItem('enterpriseId');
this.getList();
},
methods: {
//获取列表
getList() {
let that = this;
let para = {
enterpriseId: that.cliqueId
};
postRequest('/api-admin/get-enterprise-member-grade-list', para)
.then(res => {
let resData = res.data;
if (resData.errorCode == 0) {
if (!!resData.result.List && !!resData.result.List.length) {
resData.result.List.forEach(function(ele, index) {
ele.popVisible = false;
});
that.memberTableData = resData.result.List;
}
const para = { enterpriseId: this.cliqueId };
getRequest('/api-admin/get-enterprise-grade-info', para).then(res => {
const { errorCode, message, result } = res.data || {};
if (errorCode != 0) {
errMsg.errorMsg(message);
return;
}
errMsg.errorMsg(resData);
this.logoImg = result.logoImg;
// 常规卡
this.generalCardList = result.generalCardList || [];
// 特殊卡
this.specialCardList = result.specialCardList || [];
})
.catch(function(error) {});
},
// 置顶 先删除后追加首部
toUp(index, row, obj) {
let that = this;
if (index == 0) {
return;
}
log(index, row, obj);
let newTable = JSON.parse(JSON.stringify(that.memberTableData));
newTable.splice(index, 1);
newTable.unshift(row);
log(newTable);
// 保存设置
that.setSort(row.gradeId, 10, that.cliqueId);
that.memberTableData = newTable;
},
// 向上
toPre(index, row, obj) {
let that = this;
if (index == 0) {
return;
}
log(index, row, obj);
let newTable = JSON.parse(JSON.stringify(that.memberTableData));
let temp = {};
temp = newTable[index - 1];
newTable[index - 1] = row;
newTable[index] = temp;
// 保存设置
that.setSort(row.gradeId, 20, that.cliqueId);
that.memberTableData = newTable;
},
// 向下
toNext(index, row, obj) {
let that = this;
if (index == obj.length - 1) {
return;
}
log(index, row, obj);
let newTable = JSON.parse(JSON.stringify(that.memberTableData));
let temp = {};
temp = newTable[index + 1];
newTable[index + 1] = row;
newTable[index] = temp;
// 保存设置
that.setSort(row.gradeId, 30, that.cliqueId);
that.memberTableData = newTable;
},
//置底 先删除后追加尾部
toBottom(index, row, obj) {
let that = this;
if (index == obj.length - 1) {
return;
}
log(index, row, obj);
let newTable = JSON.parse(JSON.stringify(that.memberTableData));
newTable.splice(index, 1);
newTable.push(row);
// 保存设置
that.setSort(row.gradeId, 40, that.cliqueId);
that.memberTableData = newTable;
},
// 等级排序
setSort(gradeId, type, enterpriseId) {
let that = this;
let para = {
gradeId: gradeId,
sortType: type,
enterpriseId: enterpriseId
};
postRequest('/api-admin/sort-member-grade', para)
.then(res => {
let resData = res.data;
if (resData.errorCode == 0) {
showMsg.showmsg('设置成功', 'success');
return;
}
errMsg.errorMsg(resData);
})
.catch(function(error) {
log(error);
that.$message.error({
duration: 1000,
message: error.message
});
});
},
// 编辑
editGrade(index, row, obj) {
editGrade(row) {
this.$router.push({
path: '/editMemberGrade',
query: {
......@@ -223,55 +97,22 @@ export default {
}
});
},
// 新增等级
addGrade() {
addGrade(type) {
this.$router.push({
path: '/addMemberGrade',
query: {
enterpriseId: this.cliqueId,
name: this.cliqueName
name: this.cliqueName,
type
}
});
},
// 取消删除
cancelPop(index, row, obj) {
row.popVisible = false;
},
// 删除
delGrade(index, row, obj) {
let para = {
gradeId: row.gradeId,
enterpriseId: ''
};
getRequest('/api-admin/delete-member-grade', para)
.then(res => {
let resData = res.data;
if (resData.errorCode == 0) {
showMsg.showmsg('删除成功', 'success');
obj.splice(index, 1);
return;
}
errMsg.errorMsg(resData);
})
.catch(function(error) {});
},
// 路由跳转
changeRoute(route) {
this.$router.push(route);
}
},
components: {
topNavNew
},
components: { topNavNew, MemberCardTable },
beforeRouteLeave(to, from, next) {
let that = this;
let d = to;
if (d.path == '/editMemberGrade' || d.path == '/addMemberGrade') {
sessionStorage.setItem('enterpriseId', that.cliqueId);
if (to.path == '/editMemberGrade' || to.path == '/addMemberGrade') {
sessionStorage.setItem('enterpriseId', this.cliqueId);
}
next();
}
......@@ -284,51 +125,5 @@ export default {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
.item-label {
font-size: 14px;
color: #606266;
margin-bottom: 30px;
span {
display: inline-block;
width: 80px;
}
}
.title {
padding: 0 0 22px 0;
display: -webkit-flex;
display: flex;
align-items: center;
color: #828282;
.add-btn {
text-align: right;
}
div {
-webkit-flex: 1;
-moz-flex: 1;
-ms-flex: 1;
-o-flex: 1;
flex: 1;
font-size: 13px;
}
}
.el-icon-upload2 {
font-size: 22px;
cursor: pointer;
}
.el-icon-download {
font-size: 22px;
cursor: pointer;
}
i.icon-color {
color: #606266;
}
i.disable {
color: #e6e6e6;
cursor: not-allowed;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment