抽奖转盘增加类型,修复转盘抽奖上传图片回显问题

This commit is contained in:
YeMingfei666 2024-12-21 10:21:57 +08:00
parent 4b55f7f344
commit 1173900fb6
4 changed files with 95 additions and 27 deletions

View File

@ -8,7 +8,7 @@ function add(data) {
}
function del(data) {
return $http({
url: 'discSpinning/deleteDiscSpinning',
url: 'discSpinning/deleteDiscSpinning?id='+data.id,
method: 'post',
data: data
})

View File

@ -55,6 +55,12 @@
import { $redPackApi } from "@/api/red-pack.js";
import { isNull } from "@/utils/validate.js";
export default {
props: {
source:{
type:[String,Number],
default:1
}
},
data() {
return {
dialogVisible: false,
@ -106,13 +112,14 @@ export default {
if (this.form.random > 1 || this.form.random < 0) {
return this.$message.error("概率为0-1");
}
console.log(id);
const res = id
? await $redPackApi.update({ ...this.form, num: this.form.num || "" })
: await $redPackApi.add(this.form);
? await $redPackApi.update({ ...this.form, num: this.form.num || "" ,discType:this.source})
: await $redPackApi.add({...this.form,discType:this.source});
console.log(res);
const { data, msg } = res;
if (data && data.code == 0) {
this.$message.success("修改成功");
this.$message.success(id?"修改成功":"添加成功");
this.$emit("refresh");
this.diaClose();
} else {

View File

@ -27,7 +27,7 @@
<el-upload
class="avatar-uploader"
v-model="form.url"
:action="$http.adornUrl('alioss/upload')"
:action="$http.adornUrlUp('alioss/upload')"
:show-file-list="false"
:on-success="uploadSuccess"
>
@ -50,6 +50,12 @@
import $disc from "@/api/disc-spinning.js";
export default {
props: {
source:{
type:[String,Number],
default:1
}
},
data() {
return {
dialogVisible: false,
@ -65,14 +71,14 @@ export default {
methods: {
uploadSuccess(file) {
this.form.url = file.data;
console.log(file.data);
console.log(this.form.url);
},
open(item) {
console.log(item);
this.dialogVisible = true;
this.item = item;
this.form = {
...item,
};
Object.assign(this.form, item);
},
diaClose() {
this.dialogVisible = false;
@ -91,9 +97,10 @@ export default {
return this.$message.error("中奖概率不能为空!");
}
const { name, url, type, odds, id } = this.form;
const { data } = await $disc.update({ name, url, type, odds, id });
const submitForm={ name, url, type, odds, discType:this.source };
const { data } =id? await $disc.update({...submitForm,id }) : await $disc.add({ ...submitForm});
if (data.code == 0) {
this.$message.success("修改成功");
this.$message.success(id?"修改成功":'添加成功');
this.$emit("refresh");
this.diaClose();
}else{

View File

@ -788,7 +788,21 @@
<el-tab-pane label="抽奖转盘" name="sexth">
<div class="">
<!-- <el-button type="primary" @click="refAddZhuanpanOpen">添加抽奖项</el-button> -->
<div style="margin-bottom: 20px">
<el-select @change="zhuanPanTypeChange" v-model="zhuanPanType" placeholder="请选择">
<el-option
v-for="item in zhuanPanTypes"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</div>
<div style="margin-bottom: 20px;">
<el-button type="primary" @click="refAddZhuanpanOpen" v-if="zhuanPanType > 1">添加抽奖项</el-button>
</div>
<el-table :border="true" :data="zhuanpanData">
<el-table-column label="名称" prop="name"></el-table-column>
<el-table-column label="图片">
@ -828,6 +842,12 @@
@click="refAddZhuanpanOpen(scope.row)"
>编辑</el-button
>
<el-button
type="text"
size="mini"
@click="depPopZhuanpanPack(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
@ -853,12 +873,12 @@
</el-table-column>
<el-table-column label="是否启用">
<template slot-scope="scope">
<el-switch
@change="redPackChangeStatus($event, scope.row)"
v-model="scope.row.status"
:inactive-value="0"
:active-value="1"
></el-switch>
<el-switch
@change="redPackChangeStatus($event, scope.row)"
v-model="scope.row.status"
:inactive-value="0"
:active-value="1"
></el-switch>
</template>
</el-table-column>
<el-table-column label="编辑">
@ -869,7 +889,10 @@
@click="openPop('refAddRedPack', scope.row)"
>编辑</el-button
>
<el-button type="text" size="mini" @click="depPopRedPack(scope.row)"
<el-button
type="text"
size="mini"
@click="depPopRedPack(scope.row)"
>删除</el-button
>
</template>
@ -882,6 +905,7 @@
<pop-add-zhuanpan
ref="refAddZhuanpan"
@refresh="zhuanPanRefresh"
:source="zhuanPanType"
></pop-add-zhuanpan>
<pop-add-red-pack
ref="refAddRedPack"
@ -899,6 +923,12 @@ export default {
components: { popAddZhuanpan, popAddRedPack },
data() {
return {
zhuanPanType:1,
zhuanPanTypes:[
{value:1,label:'普通转盘'},
{value:2,label:'周任务转盘'},
{value:3,label:'月任务转盘'},
],
redPackData: [],
//
zhuanpanData: [],
@ -1026,7 +1056,29 @@ export default {
};
},
methods: {
depPopRedPack(item){
zhuanPanTypeChange(){
this.zhuanPanInit();
},
depPopZhuanpanPack(item){
this.$confirm("是否删除该转盘配置?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
$disc.del(item).then((res) => {
const data = res.data;
if (data.code == 0) {
this.$message.success("删除成功");
this.zhuanPanInit();
} else {
this.$message.error(data.msg || "删除失败");
}
});
})
.catch(() => {});
},
depPopRedPack(item) {
this.$confirm("是否删除该红包抽奖配置?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
@ -1045,14 +1097,14 @@ export default {
})
.catch(() => {});
},
async redPackChangeStatus(e,item){
console.log(e)
const res=await $redPackApi.update({...item,status:e})
if(res.data.code==0){
this.$message.success('修改成功')
this.redPackInit()
}else{
this.$message.error(res.data.msg || '修改失败')
async redPackChangeStatus(e, item) {
console.log(e);
const res = await $redPackApi.update({ ...item, status: e ,source:this.zhuanPanType });
if (res.data.code == 0) {
this.$message.success("修改成功");
this.redPackInit();
} else {
this.$message.error(res.data.msg || "修改失败");
}
},
redpackRefresh() {
@ -1388,6 +1440,7 @@ export default {
const { data } = await $disc.getList({
page: this.page,
limit: this.limit,
source:this.zhuanPanType
});
this.zhuanpanData = data.data.records;
},
@ -1396,6 +1449,7 @@ export default {
const { data } = await $redPackApi.getList({
page: this.page,
limit: this.limit,
source:this.zhuanPanType
});
this.redPackData = data.data.records;
},