<template>
|
<div class="integral-control-form" id="integral-control-form">
|
<list-condition-template ref="table" :isExistBtn="true" :tableData="tableData" @page-info-change="handlePageInfoChange">
|
<template slot="otherElement">
|
<el-form size="mini" :model="listData" class="control-form" :rules="formRules" ref="form">
|
<el-row>
|
<el-col class="integral-control-area" :span="12">
|
<h6>用户积分控制</h6>
|
<hr/>
|
<el-form-item label="用户名称:">
|
<el-input v-show="!isIntegralAdjust" style="width:256px" v-model.trim="listData.memberPhone" placeholder="请输入手机号进行查询">
|
<el-button slot="append" @click="query">查询</el-button>
|
</el-input>
|
<span v-show="isIntegralAdjust">
|
{{listData.memberPhone}},当前剩余积分{{listData.memberIntegral}}
|
<el-button @click="query">取消</el-button>
|
</span>
|
</el-form-item>
|
<el-form-item label="积分调整:" prop="modifyTurn" v-show="isIntegralAdjust">
|
<el-row>
|
<el-col :span="7" style="width:200px">
|
<el-select v-model="listData.modifyTurn">
|
<el-option label="扣除" key="2" value="2"></el-option>
|
</el-select>
|
</el-col>
|
<el-col :span="6" style="width:150px" >
|
<el-input-number :min="1" v-model="listData.modifyValue"></el-input-number>
|
</el-col>
|
<el-col :span="2">
|
<el-button type="primary" @click="openIntegralAdjust">确定</el-button>
|
</el-col>
|
</el-row>
|
</el-form-item>
|
<div>
|
<el-form-item label="积分调整:" v-show="!isIntegralAdjust">请先输入用户名称后点击“查询”</el-form-item>
|
</div>
|
<el-form-item label="操作提示:">输入用户名称>查询>修改积分>输入理由>确定</el-form-item>
|
</el-col>
|
<el-col class="integral-control-area" :span="12">
|
<h6>积分当前执行标准</h6>
|
<hr/>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="积分规则:">消费送积分</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="执行期限:">长期</el-form-item>
|
</el-col>
|
</el-row>
|
<el-form-item label="获取比例:">用户确认收货时,每实际消费200元,获得1积分</el-form-item>
|
<el-form-item label="特殊备注:">消费不满200元不计分,后续累计满足时仍可发放</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</template>
|
<template slot="columns">
|
<el-table-column label="用户名称" align="center" prop="useId"></el-table-column>
|
<el-table-column label="修改前积分" align="center" prop="modifyBeforeIntegral"></el-table-column>
|
<el-table-column label="修改值" align="center" prop="modifyValue">
|
<template slot-scope="scope">
|
{{scope.row.modifyTurn === '2'?'-':'+'}} {{scope.row.modifyValue}}
|
</template>
|
</el-table-column>
|
<el-table-column label="修改后积分" align="center" prop="modifyAfterIntegral"></el-table-column>
|
<el-table-column label="操作人" align="center" prop="operatorId"></el-table-column>
|
<el-table-column label="操作时间" align="center" prop="operatorTime"></el-table-column>
|
<el-table-column label="更改理由" prop="modifyReason" show-overflow-tooltip>
|
<template slot-scope="scope">
|
{{scope.row.modifyReason ? scope.row.modifyReason : '-'}}
|
</template>
|
</el-table-column>
|
</template>
|
</list-condition-template>
|
<el-dialog
|
:visible.sync="dialogVisible"
|
title="调整理由"
|
:close-on-click-modal="false"
|
:modal-append-to-body="false"
|
width="564px"
|
>
|
<integral-adjust-reason :form="listData" :memberPhone="memberPhone"></integral-adjust-reason>
|
<div slot="footer" class="dialog-footer buttonPosition">
|
<el-button size="mini" @click="submit" type="primary" :loading="loading">确定</el-button>
|
<el-button size="mini" @click="dialogVisible = false">取消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import integralAdjustReason from '@/views/integralControl/components/integralAdjustReason.vue'
|
import integralControlApi from '@/api/member/integralControl'
|
|
export default {
|
components: { integralAdjustReason },
|
data() {
|
const validateIntegral = (rule, value, callback) => {
|
const reg = /^[0-9]*$/ // 只能输入正整数
|
if (!value) {
|
callback(new Error('请选择积分扣减方式'))
|
} else if (!this.listData.modifyValue || !reg.test(this.listData.modifyValue)) {
|
callback(new Error('积分修改值应为大于0的整数'))
|
} else if (value === '2' && this.listData.modifyValue > this.listData.memberIntegral) {
|
callback(new Error('积分扣减数不能大于剩余积分数'))
|
} else {
|
callback()
|
}
|
}
|
return {
|
listData: {
|
modifyTurn: null,
|
modifyValue: null,
|
memberPhone: null
|
},
|
form: {},
|
isIntegralAdjust: false, // 是否积分调整
|
dialogVisible: false,
|
loading: false,
|
tableData: [],
|
formRules: {
|
modifyTurn: [
|
{ validator: validateIntegral, trigger: 'change' }
|
]
|
},
|
memberPhone: null
|
}
|
},
|
/*
|
* 数据变化后刷新列表
|
*/
|
activated() {
|
this.queryList(this.$refs.table.getPageInfo())
|
},
|
methods: {
|
// 查询用户
|
async query() {
|
if (!this.listData.memberPhone) {
|
this.$message({
|
type: 'warning',
|
message: '请输入手机号'
|
})
|
return
|
} else {
|
const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
|
if (!reg.test(this.listData.memberPhone)) {
|
this.$message({
|
type: 'warning',
|
message: '请输入正确的手机号码'
|
})
|
return
|
}
|
}
|
if (!this.isIntegralAdjust) {
|
try {
|
const res = await integralControlApi.queryUserInfo({ memberPhone: this.listData.memberPhone })
|
if (res.code === '0' && res.data) {
|
this.isIntegralAdjust = !this.isIntegralAdjust
|
this.listData = res.data
|
this.memberPhone = this.listData.memberPhone
|
}
|
} catch (error) {
|
}
|
} else {
|
this.isIntegralAdjust = !this.isIntegralAdjust
|
this.listData.memberPhone = null
|
}
|
},
|
// 保存调整理由
|
async submit() {
|
const param = {
|
modifyAfterIntegral: this.listData.memberIntegral - this.listData.modifyValue,
|
modifyBeforeIntegral: this.listData.memberIntegral,
|
modifyReason: this.listData.modifyReason,
|
modifyTurn: this.listData.modifyTurn,
|
modifyValue: this.listData.modifyValue,
|
memberId: this.listData.memberId,
|
useId: this.memberPhone
|
}
|
try {
|
this.loading = true
|
const res = await integralControlApi.adjustIntegral(param)
|
if (res.code === '0' && res.data) {
|
this.loading = false
|
this.dialogVisible = false
|
this.memberPhone = null
|
} else {
|
this.loading = false
|
}
|
} catch (error) {
|
this.loading = false
|
}
|
if (!this.dialogVisible) {
|
await this.$refs.table.changeCondition()
|
}
|
},
|
// 打开积分调整弹窗
|
openIntegralAdjust() {
|
this.$refs.form.validate().then((res) => {
|
this.isIntegralAdjust = false
|
this.dialogVisible = true
|
this.listData.memberPhone = null
|
})
|
},
|
/**
|
* '分页信息改变时查询列表
|
*/
|
handlePageInfoChange(pageInfo) {
|
this.queryList(pageInfo)
|
},
|
|
/**
|
* 重置
|
*/
|
resetQuery() {
|
this.$refs.table.reloadCurrent()
|
},
|
/**
|
* 点击查询按钮
|
*/
|
queryData() {
|
this.$refs.table.changeCondition()
|
},
|
/**
|
* 查询列表
|
*/
|
async queryList(pageInfo = { pageNum: 1, pageSize: 10 }) {
|
try {
|
const res = await integralControlApi.queryUserIntegralList(pageInfo)
|
if (res.code === '0') {
|
this.tableData = res.data.list
|
this.total = res.data.total
|
}
|
} catch (error) {
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
.integral-control-form{
|
.el-row{
|
display: block;
|
}
|
hr{
|
height:1px;
|
border:none;
|
background-color: #ccc;
|
}
|
.control-form{
|
// width: 1500px;
|
.integral-control-area{
|
// width: 750px;
|
padding: 0 20px;
|
}
|
}
|
}
|
</style>
|