feat(徽章配置管理): 配置新增徽章选项

This commit is contained in:
hzj 2025-11-19 18:47:41 +08:00
parent 22232def5d
commit 8c98f90fb9

View File

@ -91,7 +91,8 @@
)
"
@click.native="handleUpdate(item)"
>编辑规则</el-dropdown-item>
>编辑规则</el-dropdown-item
>
<el-dropdown-item
v-if="
buttonPermissions.includes(
@ -99,13 +100,15 @@
)
"
@click.native="clickEditSource(item)"
>编辑资源</el-dropdown-item>
>编辑资源</el-dropdown-item
>
<el-dropdown-item
v-if="
buttonPermissions.includes('content:manager:badge:del')
"
@click.native="handlDel(item.id)"
>删除</el-dropdown-item>
>删除</el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown>
</div>
@ -228,22 +231,22 @@
</template>
<script>
import { badgeTable, updateBadge, deleteBadge, addBadge } from '@/api/badge'
import Pagination from '@/components/Pagination'
import SourceEdit from './source-edit'
import { mapGetters } from 'vuex'
import { badgeTable, updateBadge, deleteBadge, addBadge } from "@/api/badge";
import Pagination from "@/components/Pagination";
import SourceEdit from "./source-edit";
import { mapGetters } from "vuex";
function getFormData() {
return {
id: '',
badgeName: '',
type: '',
badgeKey: '',
badgeLevel: '',
milestone: ''
}
id: "",
badgeName: "",
type: "",
badgeKey: "",
badgeLevel: "",
milestone: ""
};
}
export default {
name: 'BadgeRule',
name: "BadgeRule",
components: { Pagination, SourceEdit },
data() {
return {
@ -251,18 +254,25 @@ export default {
sourceEditRow: null,
badgeGroups: [
{
label: '用户',
label: "用户",
options: [
{ label: '成就', value: 'ACHIEVEMENT' },
{ label: '管理员', value: 'ADMINISTRATOR' },
{ label: '活动', value: 'ACTIVITY' }
{ label: "成就", value: "ACHIEVEMENT" },
{ label: "管理员", value: "ADMINISTRATOR" },
{ label: "活动", value: "ACTIVITY" }
]
},
{
label: '房间',
options: [{ label: '成就', value: 'ROOM_ACHIEVEMENT' }]
},
{ label: '家族', options: [{ label: '等级', value: 'FAMILY' }] }
label: "荣誉",
options: [
{ label: "成就", value: "HONOR_ACHIEVEMENT" },
{ label: "活动", value: "HONOR_ACTIVITY" }
]
}
// {
// label: '',
// options: [{ label: '', value: 'ROOM_ACHIEVEMENT' }]
// },
// { label: '', options: [{ label: '', value: 'FAMILY' }] }
],
pushTextHistoryLoading: false,
pushTextHistoryVisible: false,
@ -273,157 +283,157 @@ export default {
listQuery: {
cursor: 1,
limit: 20,
badgeName: '',
badgeKey: '',
type: 'ACHIEVEMENT'
badgeName: "",
badgeKey: "",
type: "ACHIEVEMENT"
},
formVisible: false,
textOptTitle: '',
textOptTitle: "",
form: getFormData(),
submitLoading: false,
rules: {
type: [{ required: true, message: '请选择类型', trigger: 'blur' }],
type: [{ required: true, message: "请选择类型", trigger: "blur" }],
badgeName: [
{ required: true, message: '请填写徽章名称', trigger: 'blur' }
{ required: true, message: "请填写徽章名称", trigger: "blur" }
],
badgeKey: [
{ required: true, message: '请填写徽章key', trigger: 'blur' }
{ required: true, message: "请填写徽章key", trigger: "blur" }
],
badgeLevel: [
{ required: true, message: '请填写等级', trigger: 'blur' }
{ required: true, message: "请填写等级", trigger: "blur" }
],
milestone: [
{ required: true, message: '请填写可领取里程碑', trigger: 'blur' }
{ required: true, message: "请填写可领取里程碑", trigger: "blur" }
]
},
listLoading: true
}
};
},
computed: {
...mapGetters(['buttonPermissions']),
...mapGetters(["buttonPermissions"]),
isShowOperationBut() {
return (
this.buttonPermissions.includes('content:manager:badge:edit:rule') ||
this.buttonPermissions.includes('content:manager:badge:edit:source') ||
this.buttonPermissions.includes('content:manager:badge:del')
)
this.buttonPermissions.includes("content:manager:badge:edit:rule") ||
this.buttonPermissions.includes("content:manager:badge:edit:source") ||
this.buttonPermissions.includes("content:manager:badge:del")
);
}
},
created() {
this.renderData()
this.renderData();
},
methods: {
renderData(isClean) {
const that = this
const that = this;
if (isClean === true) {
that.listQuery.cursor = 1
that.listQuery.cursor = 1;
}
that.listLoading = true
that.listLoading = true;
badgeTable(that.listQuery).then(res => {
const { body } = res
that.total = body.total || 0
that.list = body.records
that.listLoading = false
})
const { body } = res;
that.total = body.total || 0;
that.list = body.records;
that.listLoading = false;
});
},
handleSearch() {
this.renderData()
this.renderData();
},
renderDataSuccess() {
this.$message({
message: 'Successful',
type: 'success'
})
this.renderData()
message: "Successful",
type: "success"
});
this.renderData();
},
queryUserDetails(row) {
this.userDeatilsDrawer = true
this.thatSelectedUserId = row.id
this.userDeatilsDrawer = true;
this.thatSelectedUserId = row.id;
},
submitForm() {
const that = this
const that = this;
that.$refs.form.validate(valid => {
if (valid) {
that.submitLoading = true
that.submitLoading = true;
if (that.form.id) {
updateBadge(that.form)
.then(res => {
that.submitLoading = false
that.formVisible = false
that.form = getFormData()
that.fileList = []
that.renderData()
that.submitLoading = false;
that.formVisible = false;
that.form = getFormData();
that.fileList = [];
that.renderData();
})
.catch(er => {
that.submitLoading = false
that.$emit('fial', er)
})
return
that.submitLoading = false;
that.$emit("fial", er);
});
return;
}
addBadge(that.form)
.then(res => {
that.submitLoading = false
that.formVisible = false
that.form = getFormData()
that.fileList = []
that.renderData()
that.submitLoading = false;
that.formVisible = false;
that.form = getFormData();
that.fileList = [];
that.renderData();
})
.catch(er => {
that.submitLoading = false
console.error(er)
that.$emit('fial', er)
})
that.submitLoading = false;
console.error(er);
that.$emit("fial", er);
});
} else {
console.error('error submit!!')
return false
console.error("error submit!!");
return false;
}
})
});
},
//
handlDel(id) {
this.$confirm('确认删除吗?', '提示', {
type: 'warning'
this.$confirm("确认删除吗?", "提示", {
type: "warning"
})
.then(() => {
this.listLoading = true
this.listLoading = true;
deleteBadge(id).then(res => {
this.listLoading = false
this.listLoading = false;
this.$message({
message: '删除成功',
type: 'success'
})
this.renderData()
})
message: "删除成功",
type: "success"
});
this.renderData();
});
})
.catch(() => {})
.catch(() => {});
},
handleClose() {
//
this.$refs.form.clearValidate()
this.fileList = []
this.formVisible = false
this.$refs.form.clearValidate();
this.fileList = [];
this.formVisible = false;
},
handleCreate() {
this.formVisible = true
this.textOptTitle = '添加'
this.form = getFormData()
this.formVisible = true;
this.textOptTitle = "添加";
this.form = getFormData();
},
handleUpdate(row) {
this.textOptTitle = '修改'
this.formVisible = true
this.form = Object.assign(this.form, row)
this.textOptTitle = "修改";
this.formVisible = true;
this.form = Object.assign(this.form, row);
},
clickEditSource(row) {
this.sourceEditVisible = true
this.sourceEditRow = row
this.sourceEditVisible = true;
this.sourceEditRow = row;
},
editSourceClose() {
this.sourceEditVisible = false
this.sourceEditRow = null
this.renderData()
this.sourceEditVisible = false;
this.sourceEditRow = null;
this.renderData();
}
}
}
};
</script>
<style scoped lang="scss">
.box-card {