Files
peko-admin-web/src/views/luckGift/luckGiftSet.vue

980 lines
30 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="box">
<div class="condition">
<div class="inquire">
<span>后台关注用户</span>
<!-- @input="handleInput" -->
<el-input v-model="inquire.adminFollowErbanNoList"
placeholder=""
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 16;
editDialogTitle = '后台关注用户';
value = inquire.adminFollowErbanNoList;
">
编辑</el-button>
</div>
<div class="inquire">
<span>用户上线列表</span>
<!-- @input="handleInput" -->
<el-input v-model="inquire.followErbanNoList"
placeholder=""
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 11;
editDialogTitle = '用户上线列表';
value = inquire.followErbanNoList;
">
编辑</el-button>
</div>
<div class="inquire">
<span>用户W级列表</span>
<!-- @input="handleInput" -->
<!-- <el-input
v-model="inquire.whiteErbanNoProductionRatioMap"
placeholder=""
class="input"
disabled
></el-input> -->
<el-button class="primary"
type="primary"
@click="detailsClick">
查看详情</el-button>
</div>
<div class="inquire">
<span>用户B级列表</span>
<!-- @input="handleInput" -->
<el-input v-model="inquire.blackErbanNoList"
placeholder=""
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 13;
editDialogTitle = '用户B级列表';
value = inquire.blackErbanNoList;
">
编辑</el-button>
</div>
<!-- 分区 -->
<div class="inquire">
<span>分区</span>
<el-select v-model="inquire.value"
placeholder="请选择"
@change="handleChange">
<el-option v-for="item in inquire.options"
:key="item.id"
:label="item.desc"
:value="item.id">
</el-option>
</el-select>
</div>
<div class="inquire">
<span>对比值N</span>
<!-- @input="handleInput" -->
<el-input v-model="inquire.comparisonValue"
placeholder=""
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 1;
editDialogTitle = '对比值N';
value = inquire.comparisonValue;
">
编辑</el-button>
</div>
<div class="inquire">
<span>幸运24金币库存</span>
<el-input v-model="inquire.goldInventory"
placeholder=""
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 2;
editDialogTitle = '幸运24金币库存';
value = inquire.goldInventory;
">编辑</el-button>
</div>
<!-- <div class="inquire">
<span>幸运礼物ID</span>
<el-input
v-model="inquire.x"
placeholder=""
class="input"
disabled
></el-input>
<el-button
class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 8;
editDialogTitle = '幸运礼物ID';
value = inquire.x;
"
>
编辑</el-button
>
</div> -->
<div class="inquire">
<span>平台抽成</span>
<el-input v-model="inquire.platformCommission"
placeholder=""
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 3;
editDialogTitle = '平台抽成';
value = inquire.platformCommission;
">编辑</el-button>
</div>
<div class="inquire">
<span>用户收益比例</span>
<el-input v-model="inquire.userRevenueRatio"
placeholder=""
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 4;
editDialogTitle = '用户收益比例';
value = inquire.userRevenueRatio;
">编辑</el-button>
</div>
<div class="inquire">
<span>通知制定金额</span>
<!-- @input="handleInput" -->
<el-input v-model="inquire.warnMulti"
placeholder=""
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 9;
editDialogTitle = '通知制定金额';
value = inquire.warnMulti;
">
编辑</el-button>
</div>
<!-- <div class="inquire">
<span>库存告急通知</span>
<el-input
v-model="inquire.x"
placeholder=""
class="input"
disabled
></el-input>
<el-button
class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 10;
editDialogTitle = '库存告急通知';
value = inquire.x;
"
>
编辑</el-button
>
</div> -->
<div class="inquire">
<span>赠送1000倍奖励</span>
<el-button class="primary"
type="primary"
:disabled="butClick"
@click="
editDialog = true;
type = 12;
editDialogTitle = '赠送1000倍奖励';
value = inquire.x;
">
赠送</el-button>
</div>
<el-divider content-position="left">个人库存</el-divider>
<div class="inquire">
<span>H</span>
<el-input v-model="inquire.preJudgeValue_H"
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 5;
editDialogTitle = 'H';
value = inquire.preJudgeValue_H;
">
编辑</el-button>
</div>
<div class="inquire">
<span>J</span>
<el-input v-model="inquire.totalInput_J"
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 6;
editDialogTitle = 'J';
value = inquire.totalInput_J;
">
编辑</el-button>
</div>
<div class="inquire">
<span>K1</span>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K1.S"
class="input"
disabled>
<template #prepend>S</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K1.A"
class="input"
disabled>
<template #prepend>A</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K1.B"
class="input"
disabled>
<template #prepend>B</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K1.C"
class="input"
disabled>
<template #prepend>C</template>
</el-input>
</div>
<div class="inquire">
<span></span>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K1.D"
class="input"
disabled>
<template #prepend>D</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K1.E"
class="input"
disabled>
<template #prepend>E</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K1.F"
class="input"
disabled>
<template #prepend>F</template>
</el-input>
<el-button class="primary"
type="primary"
@click="
multiEditDialog = true;
butClick = false;
multiEditDialogTitle = 'K1';
multiEditObj = inquire.userRechargeLevel_totalInputOffset_K1;
">
编辑</el-button>
</div>
<el-divider />
<div class="inquire">
<span>K2</span>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K2.S"
class="input"
disabled>
<template #prepend>S</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K2.A"
class="input"
disabled>
<template #prepend>A</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K2.B"
class="input"
disabled>
<template #prepend>B</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K2.C"
class="input"
disabled>
<template #prepend>C</template>
</el-input>
</div>
<div class="inquire">
<span></span>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K2.D"
class="input"
disabled>
<template #prepend>D</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K2.E"
class="input"
disabled>
<template #prepend>E</template>
</el-input>
<el-input v-model="inquire.userRechargeLevel_totalInputOffset_K2.F"
class="input"
disabled>
<template #prepend>F</template>
</el-input>
<el-button class="primary"
type="primary"
@click="
multiEditDialog = true;
butClick = false;
multiEditDialogTitle = 'K2';
multiEditObj = inquire.userRechargeLevel_totalInputOffset_K2;
">
编辑</el-button>
</div>
<el-divider content-position="left">额外数组</el-divider>
<div class="inquire">
<span>额外库存</span>
<el-input v-model="inquire.extraStock"
class="input"
disabled></el-input>
<el-button class="primary"
type="primary"
@click="
editDialog = true;
butClick = false;
type = 15;
editDialogTitle = '额外库存';
value = inquire.extraStock;
">编辑</el-button>
</div>
<div class="inquire">
<span>开关</span>
<el-switch v-model="inquire.extraPoolConfig.isOpen"
size="large"
active-text=""
inactive-text=""
disabled />
</div>
<div class="inquire">
<span>库存蓄水比例</span>
<el-input v-model="inquire.extraPoolConfig.storeRatio"
class="input"
disabled></el-input>
</div>
<div class="inquire">
<span>开始活跃小时当地时区</span>
<el-input v-model="inquire.extraPoolConfig.startHour"
class="input"
disabled></el-input>
</div>
<div class="inquire">
<span>结束活跃小时当地时区</span>
<el-input v-model="inquire.extraPoolConfig.endHour"
class="input"
disabled></el-input>
</div>
<div class="inquire">
<span>单次投入金币门槛</span>
<el-input v-model="inquire.extraPoolConfig.inputThreshold"
class="input"
disabled></el-input>
</div>
<div class="inquire">
<span>用户充值等级</span>
<el-input v-model="inquire.extraPoolConfig.userRechargeLevels"
class="input"
disabled></el-input>
</div>
<div class="inquire">
<span>当天退出率</span>
<el-input v-model="inquire.extraPoolConfig.todayProductionRatio"
class="input"
disabled></el-input>
</div>
<div class="inquire">
<span>当天差额</span>
<el-input v-model="inquire.extraPoolConfig.todayDiff"
class="input"
disabled></el-input>
</div>
<div class="inquire">
<span>近两天获得次数限制</span>
<el-input v-model="inquire.extraPoolConfig.twoDayCountLimit"
class="input"
disabled></el-input>
</div>
<el-button class="primary"
type="primary"
@click="
extraPoolDialog = true;
">
编辑</el-button>
</div>
<!-- 编辑弹窗 -->
<el-dialog v-model="editDialog"
:title="editDialogTitle"
width="36%"
center>
<div style="margin-bottom: 25px; margin-top: 10px">
<span style="display: inline-block; margin-right: 20px"
class="col-sm-2 control-label">{{ editDialogTitle }}</span>
<el-input v-model="value"
style="width: 75%"
class="input"
placeholder="请输入"></el-input>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="
editDialog = false;
butClick = false;
">取消</el-button>
<el-button type="primary"
:disabled="butClick"
@click="editDialogClick()">
保存
</el-button>
</span>
</template>
</el-dialog>
<!-- 编辑弹窗 -->
<el-dialog v-model="multiEditDialog"
:title="multiEditDialogTitle"
width="24%"
center>
<div style="margin-bottom: 25px; margin-top: 10px"
v-for="(val, key) in multiEditObj"
:key="key">
<span style="display: inline-block; margin-right: 20px"
class="col-sm-2 control-label">{{ key }}</span>
<el-input v-model="multiEditObj[key]"
style="width: 75%"
class="input"
placeholder="请输入" />
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="
multiEditDialog = false;
butClick = false;
">取消</el-button>
<el-button type="primary"
:disabled="butClick"
@click="multiEditDialogClick()">
保存
</el-button>
</span>
</template>
</el-dialog>
<!-- 详情弹窗 -->
<el-dialog v-model="detailsDialog"
title="用户W级列表"
width="36%"
center>
<el-button class="primary"
type="primary"
@click="addDetail">
新增</el-button>
<el-table :data="detailsTable"
style="width: 100%">
<el-table-column label="用户ID">
<template v-slot="scope">
<el-input v-model="scope.row.userId"
type="number"
@blur="handleEdit(scope.$index, scope.row)"></el-input>
</template>
</el-table-column>
<el-table-column label="值">
<template v-slot="scope">
<el-input v-model="scope.row.val"
type="number"
@blur="handleEdit(scope.$index, scope.row)"></el-input>
</template>
</el-table-column>
<el-table-column label="操作">
<template v-slot="scope">
<el-button class="danger"
type="danger"
@click="delDetail(scope.$index, scope.row)">
删除</el-button>
</template>
</el-table-column>
<!-- 其他列 -->
</el-table>
<template #footer>
<span class="dialog-footer">
<el-button @click="detailsDialog = false">取消</el-button>
<el-button type="primary"
:disabled="butClick"
@click="sevaDetail()">
保存
</el-button>
</span>
</template>
</el-dialog>
<!-- 详情弹窗 -->
<el-dialog v-model="extraPoolDialog"
title="额外数组配置"
width="36%"
center>
<el-form :model="inquire.extraPoolConfig"
label-width="auto"
style="max-width: 600px">
<el-form-item label="开关">
<el-switch v-model="inquire.extraPoolConfig.isOpen"
size="large"
active-text=""
inactive-text="" />
</el-form-item>
<el-form-item label="库存蓄水比例">
<el-input v-model="inquire.extraPoolConfig.storeRatio"
class="input"></el-input>
</el-form-item>
<el-form-item label="活跃小时">
<el-col :span="10">
<el-input type="number"
v-model="inquire.extraPoolConfig.startHour"
class="input"></el-input>
</el-col>
<el-col :span="2"
class="text-center">
<span class="text-gray-500">-</span>
</el-col>
<el-col :span="11">
<el-input type="number"
v-model="inquire.extraPoolConfig.endHour"
class="input" />
</el-col>
</el-form-item>
<el-form-item label="单次投入金币门槛">
<el-input v-model="inquire.extraPoolConfig.inputThreshold" />
</el-form-item>
<el-form-item label="用户充值等级">
<el-input v-model="inquire.extraPoolConfig.userRechargeLevels" />
</el-form-item>
<el-form-item label="当天退出率">
<el-input v-model="inquire.extraPoolConfig.todayProductionRatio"
class="input"></el-input>
</el-form-item>
<el-form-item label="当天差额">
<el-input v-model="inquire.extraPoolConfig.todayDiff"
class="input"></el-input>
</el-form-item>
<el-form-item label="近两天获得次数限制">
<el-input v-model="inquire.extraPoolConfig.twoDayCountLimit"
class="input"></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="extraPoolDialog = false">取消</el-button>
<el-button type="primary"
:disabled="!extraDialogButClick"
@click="saveExtraPoolConfig()">
保存
</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script>
import { getConfig, updateSet, updateUserMulti } from "@/api/luckGift/luckGift";
import { listAll } from "@/api/partition/partitionInfo";
// @ts-ignore
import { ElMessage } from "element-plus";
export default {
name: "luckGiftSet",
data () {
return {
loading: false,
butClick: false,
butClickTime: null,
//查询所需条件对象
inquire: {
value: 2,
options: [
// {
// name: "阿拉伯区",
// type: 2,
// },
// {
// name: "英语区",
// type: 1,
// },
// {
// name: "华语区",
// type: 4,
// },
// {
// name: "土耳其区",
// type: 8,
// },
],
comparisonValue: "",
goldInventory: 0,
giftId: "",
platformCommission: "",
userRevenueRatio: "",
warnMulti: "",
followErbanNoList: "",
adminFollowErbanNoList: "",
whiteErbanNoProductionRatioMap: "",
blackErbanNoList: "",
preJudgeValue_H: undefined,
totalInput_J: undefined,
userRechargeLevel_totalInputOffset_K1: {},
userRechargeLevel_totalInputOffset_K2: {},
extraStock: 0,
extraPoolConfig: {}
},
editDialog: false,
editDialogTitle: "",
multiEditDialog: false,
multiEditDialogTitle: "",
detailsDialog: false,
extraPoolDialog: false,
extraDialogButClick: true,
value: "",
type: null,
// 详情
detailsTable: [],
whiteErbanNoProductionRatioMap: null,
};
},
created () {
this.getData();
listAll().then((res) => {
this.inquire.options = res.data;
});
},
methods: {
// 查询接口
getData () {
getConfig({ partitionId: this.inquire.value }).then((res) => {
this.inquire.comparisonValue = res.data.productionRatio;
this.inquire.goldInventory = res.data.stock;
this.inquire.platformCommission = res.data.platformRatio;
this.inquire.userRevenueRatio = res.data.receiverRatio;
this.inquire.warnMulti = res.data.warnMulti;
this.inquire.followErbanNoList = res.data.followErbanNoList.join();
this.inquire.adminFollowErbanNoList = res.data.adminFollowErbanNoList.join();
// this.inquire.whiteErbanNoProductionRatioMap = res.data.whiteErbanNoProductionRatioMap.join();
this.inquire.blackErbanNoList = res.data.blackErbanNoList.join();
var newArr = [];
var obj = res.data.whiteErbanNoProductionRatioMap;
var arr = Object.keys(obj).map((key) => ({
userId: key,
val: obj[key],
}));
arr.forEach((res, i) => {
newArr[i] = res;
});
this.detailsTable = newArr;
this.inquire.preJudgeValue_H = res.data.preJudgeValue_H;
this.inquire.totalInput_J = res.data.totalInput_J;
this.inquire.userRechargeLevel_totalInputOffset_K1 = this.sortK12(res.data.userRechargeLevel_totalInputOffset_K1);
this.inquire.userRechargeLevel_totalInputOffset_K2 = this.sortK12(res.data.userRechargeLevel_totalInputOffset_K2);
this.inquire.extraStock = res.data.extraStock;
this.inquire.extraPoolConfig = res.data.extraPoolConfig;
this.inquire.extraPoolConfig.userRechargeLevels = res.data.extraPoolConfig.userRechargeLevels.join(',');
});
},
// 排序
sortK12 (kObj) {
// 创建一个新对象以保持排序后的键值对
const sortedKObj = {};
// 提取所有键并进行排序
const keys = Object.keys(kObj);
// 将 "S" 键单独提取出来
const sKey = keys.find(key => key === 'S');
// 过滤掉 "S" 键,剩下的键按字母顺序排序
const otherKeys = keys.filter(key => key !== 'S').sort();
// 如果存在 "S" 键,则将其放在第一位
if (sKey) {
sortedKObj[sKey] = kObj[sKey];
}
// 按照排序后的其他键填充对象
otherKeys.forEach(key => {
sortedKObj[key] = kObj[key];
});
return sortedKObj;
},
// 查看详情按钮
detailsClick () {
this.getData();
this.detailsDialog = true;
this.type = 14;
// this.value = inquire.whiteErbanNoProductionRatioMap;
},
// 详情新增按钮
addDetail () {
this.detailsTable.unshift([]);
},
// 详情删除按钮
delDetail (index, val) {
this.detailsTable.splice(index, 1);
},
// 详情确认保存按钮
sevaDetail () {
var map = {};
var lock = true;
this.detailsTable.forEach((res) => {
if (res.userId == (undefined || "") || res.val == undefined || "") {
lock = false;
}
map[res.userId] = res.val;
});
console.log(map);
this.whiteErbanNoProductionRatioMap = map;
if (lock) {
this.editDialogClick();
} else {
ElMessage({
showClose: true,
message: "用户ID和值不能为空",
type: "error",
});
}
},
// 详情编辑监听
handleEdit (index, row) {
// 这里可以添加保存逻辑例如调用API更新服务器数据等。
console.log(index, "保存行数据", row);
// 示例:更新本地数据或其他操作...
},
// 确认保存
editDialogClick () {
var obj = {};
obj.partitionId = this.inquire.value;
if (this.type == 12) {
this.butClick = true;
updateUserMulti({ erbanNo: this.value }).then((res) => {
if (res.code == 200) {
ElMessage({
showClose: true,
message: "赠送成功",
type: "success",
});
setTimeout(() => {
this.butClick = false;
}, 3000);
this.editDialog = false;
this.getData();
} else {
this.butClick = false;
ElMessage({
showClose: true,
message: res.message,
type: "error",
});
}
});
} else {
if (this.type == 1) {
obj.productionRatio = this.value;
} else if (this.type == 2) {
obj.stock = this.value;
} else if (this.type == 3) {
obj.platformRatio = this.value;
} else if (this.type == 4) {
obj.receiverRatio = this.value;
} else if (this.type == 5) {
obj.preJudgeValue_H = this.value;
} else if (this.type == 6) {
obj.totalInput_J = this.value;
} else if (this.type == 9) {
obj.warnMulti = this.value;
} else if (this.type == 11) {
obj.followErbanNoList = this.value.split(",");
} else if (this.type == 16) {
obj.adminFollowErbanNoList = this.value.split(",");
} else if (this.type == 14) {
obj.whiteErbanNoProductionRatioMap =
this.whiteErbanNoProductionRatioMap;
} else if (this.type == 13) {
obj.blackErbanNoList = this.value.split(",");
} else if (this.type == 15) {
obj.extraStock = this.value;
}
updateSet(obj).then((res) => {
if (res.code == 200) {
ElMessage({
showClose: true,
message: "保存成功",
type: "success",
});
this.editDialog = false;
// this.detailsDialog = false;
this.getData();
} else {
ElMessage({
showClose: true,
message: res.message,
type: "error",
});
}
});
}
},
// 确认保存
multiEditDialogClick () {
var obj = {};
obj.partitionId = this.inquire.value;
if (this.multiEditDialogTitle == "K1") {
obj.userRechargeLevel_totalInputOffset_K1 = this.multiEditObj;
} else if (this.multiEditDialogTitle == "K2") {
obj.userRechargeLevel_totalInputOffset_K2 = this.multiEditObj;
}
updateSet(obj).then((res) => {
if (res.code == 200) {
ElMessage({
showClose: true,
message: "保存成功",
type: "success",
});
this.multiEditDialog = false;
// this.detailsDialog = false;
this.getData();
} else {
ElMessage({
showClose: true,
message: res.message,
type: "error",
});
}
});
},
// 监听类型
handleChange (value) {
this.inquire.value = value;
this.getData();
},
// 确认保存
saveExtraPoolConfig () {
this.extraDialogButClick = false;
var obj = {};
obj.partitionId = this.inquire.value;
obj.extraPoolConfig = this.inquire.extraPoolConfig;
console.info(this.inquire.extraPoolConfig.userRechargeLevels)
obj.extraPoolConfig.userRechargeLevels = this.inquire.extraPoolConfig.userRechargeLevels.split(",");
updateSet(obj).then((res) => {
if (res.code == 200) {
ElMessage({
showClose: true,
message: "保存成功",
type: "success",
});
this.extraPoolDialog = false;
this.getData();
} else {
ElMessage({
showClose: true,
message: res.message,
type: "error",
});
}
}).finally(() => {
this.extraDialogButClick = true;
});
}
},
};
</script>
<style lang="less" scoped>
.box {
padding-top: 20px;
background: #ecf0f5;
.condition {
margin-bottom: 20px;
.inquire {
margin-right: 20px;
margin-bottom: 20px;
span {
display: inline-block;
width: 110px;
margin-right: 10px;
// text-align: right;
}
.input {
width: 180px;
margin-right: 10px;
}
}
}
.but {
margin-bottom: 20px;
}
}
</style>