Commit 036cecd4 authored by yuwenwen's avatar yuwenwen

修改积分管理模块

parent a659c077
<template> <template>
<div>
<el-dialog :visible.sync="visible" v-if="visible" title="批量兑换" :close-on-click-modal="false" width="36%" <el-dialog :visible.sync="visible" v-if="visible" title="批量兑换" :close-on-click-modal="false" width="36%"
class="dialog" @close="handleClose"> class="dialog" @close="handleClose">
<el-form :model="form" ref="formRef" label-position="top" :rules="rules"> <el-form :model="form" ref="formRef" label-position="top" :rules="rules">
...@@ -15,12 +16,15 @@ ...@@ -15,12 +16,15 @@
<el-button type="primary" @click="handleConfirm">确定</el-button> <el-button type="primary" @click="handleConfirm">确定</el-button>
</template> </template>
</el-dialog> </el-dialog>
<!-- 操作失败结果 -->
<error-dialog ref="errorDialogRef"></error-dialog>
</div>
</template> </template>
<script> <script>
// import { pointsExchange, exchange } from '@/api/pointsExchange'
import { batchExchange } from '@/api/pointsExchange'; import { batchExchange } from '@/api/pointsExchange';
import UserSelectInput from '@/components/UserSelect/input' import UserSelectInput from '@/components/UserSelect/input'
import GoodsSelectInput from '@/components/GoodsSelect/input' import GoodsSelectInput from '@/components/GoodsSelect/input'
import ErrorDialog from '../pointsManage/ErrorDialog.vue';
export default { export default {
data() { data() {
return { return {
...@@ -37,20 +41,9 @@ export default { ...@@ -37,20 +41,9 @@ export default {
}, },
components: { components: {
UserSelectInput, UserSelectInput,
GoodsSelectInput GoodsSelectInput,
ErrorDialog
}, },
// watch: {
// "form.userName": {
// handler: function (val, oVal) {
// console.log(val, oVal)
// if (val) {
// this.formatData(val)
// }
// }
// },
// deep: true,
// immediate: true
// },
methods: { methods: {
// 打开兑换窗口 // 打开兑换窗口
openModal(row) { openModal(row) {
...@@ -64,7 +57,7 @@ export default { ...@@ -64,7 +57,7 @@ export default {
let userNames = val.split(',') let userNames = val.split(',')
let nickNames = name.split(',') let nickNames = name.split(',')
userNames.forEach((item, index) => { userNames.forEach((item, index) => {
users.push({ nickName: nickNames[index], userName: item }) users.push({ nickName: nickNames[index], userName: item})
}) })
if (users.length > 0) { if (users.length > 0) {
this.form.users = users; this.form.users = users;
...@@ -83,11 +76,7 @@ export default { ...@@ -83,11 +76,7 @@ export default {
if (res.data.length == 0) { if (res.data.length == 0) {
this.$modal.msgSuccess('批量兑换商品成功') this.$modal.msgSuccess('批量兑换商品成功')
} else { } else {
let userName = res.data.map((item)=>{ this.$refs.errorDialogRef.openModal(res.data)
return item.userName;
}).join(',')
let msg = `失败:${res.data.length}条,失败用户:${userName}`
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + msg + "</div>", "结果", { dangerouslyUseHTMLString: true });
} }
this.handleClose() this.handleClose()
this.$emit('handleOk'); this.$emit('handleOk');
......
<template> <template>
<el-dialog :visible.sync="visible" v-if="visible" title="批量增加积分" :close-on-click-modal="false" width="36%" <div>
class="dialog" @close="handleClose"> <el-dialog :visible.sync="visible" v-if="visible" title="批量增加积分" append-to-body :close-on-click-modal="false"
width="36%" class="dialog" @close="handleClose">
<el-form :model="form" ref="formRef" label-position="top" :rules="rules"> <el-form :model="form" ref="formRef" label-position="top" :rules="rules">
<el-form-item label="用户名" prop="userName"> <el-form-item label="用户名" prop="userName">
<UserSelectInput v-model="form.userName" :value.sync="form.userName" :multiple="true" <UserSelectInput v-model="form.userName" :value.sync="form.userName" :multiple="true"
@getValue="getNickName" placeholder="请选择用户"></UserSelectInput> @getValue="getNickName" placeholder="请选择用户"></UserSelectInput>
</el-form-item> </el-form-item>
<el-form-item label="积分" prop="points"> <el-form-item label="积分" prop="points">
<el-input v-model="form.points" placeholder="请输入"></el-input> <el-input-number v-model="form.points" placeholder="请输入" :min="0" :step="1"
style="width: 100%;"></el-input-number>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="handleClose">取消</el-button> <el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="handleConfirm">确定</el-button> <el-button type="primary" @click="handleConfirm">确定</el-button>
</template> </template>
</el-dialog> </el-dialog>
<!-- 操作失败结果 -->
<error-dialog ref="errorDialogRef"></error-dialog>
</div>
</template> </template>
<script> <script>
// import { pointsExchange, exchange } from '@/api/pointsExchange'
import { batchAddPoints } from '@/api/pointsManage'; import { batchAddPoints } from '@/api/pointsManage';
import UserSelectInput from '@/components/UserSelect/input' import UserSelectInput from '@/components/UserSelect/input'
import ErrorDialog from './ErrorDialog.vue';
export default { export default {
data() { data() {
return { return {
...@@ -36,19 +45,8 @@ export default { ...@@ -36,19 +45,8 @@ export default {
}, },
components: { components: {
UserSelectInput, UserSelectInput,
ErrorDialog
}, },
// watch: {
// "form.userName": {
// handler: function (val, oVal) {
// console.log(val, oVal)
// if (val) {
// this.formatData(val)
// }
// }
// },
// deep: true,
// immediate: true
// },
methods: { methods: {
// 打开兑换窗口 // 打开兑换窗口
openModal(row) { openModal(row) {
...@@ -77,15 +75,12 @@ export default { ...@@ -77,15 +75,12 @@ export default {
this.$refs.formRef.validate((valid) => { this.$refs.formRef.validate((valid) => {
if (valid) { if (valid) {
batchAddPoints(data).then(res => { batchAddPoints(data).then(res => {
console.log(res)
if (res.code == 200) { if (res.code == 200) {
if (res.data.length == 0) { if (res.data.length == 0) {
this.$modal.msgSuccess('批量添加积分成功') this.$modal.msgSuccess('批量添加积分成功')
} else { } else {
let userName = res.data.map((item)=>{ this.$refs.errorDialogRef.openModal(res.data)
return item.userName;
}).join(',')
let msg = `失败:${res.data.length}条,失败用户:${userName}`
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + msg + "</div>", "结果", { dangerouslyUseHTMLString: true });
} }
this.handleClose() this.handleClose()
this.$emit('handleOk'); this.$emit('handleOk');
......
<template>
<el-dialog :visible.sync="visible" v-if="visible" title="操作失败结果" append-to-body :close-on-click-modal="false" width="40%"
class="dialog" @close="handleClose">
<el-table :data="tableList">
<el-table-column type="index" width="55" align="center"></el-table-column>
<el-table-column label="用户" prop="userName" align="center"></el-table-column>
<el-table-column label="失败原因" prop="errorMessage" align="center"></el-table-column>
</el-table>
<template #footer>
<el-button @click="handleClose">关闭</el-button>
</template>
</el-dialog>
</template>
<script>
export default {
data() {
return {
visible: false,
tableList: []
}
},
methods: {
// 打开兑换窗口
openModal(tableList) {
this.visible = true;
this.tableList = tableList
},
handleClose() {
this.visible = false
}
}
}
</script>
<style lang="scss">
.dialog {
.el-dialog__body {
padding: 0 20px !important;
}
}
</style>
...@@ -11,10 +11,8 @@ ...@@ -11,10 +11,8 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row class="mb10"> <el-row class="mb10">
<el-col :span="2"> <el-col :span="24">
<el-button type="primary" @click="handleAdd">积分规则设置</el-button> <el-button type="primary" @click="handleAdd">积分规则设置</el-button>
</el-col>
<el-col :span="2">
<el-button type="primary" @click="handleBatchAddPonits" plain>批量增加积分</el-button> <el-button type="primary" @click="handleBatchAddPonits" plain>批量增加积分</el-button>
</el-col> </el-col>
</el-row> </el-row>
......
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