Files
dvcp_v2_webapp/project/fengdu/AppOutSource/AppRateManage/components/RuleManage.vue

332 lines
9.2 KiB
Vue
Raw Normal View History

2024-06-24 14:27:26 +08:00
<template>
<div>
<ai-list>
<template #content>
<div class="card_list">
2024-07-19 09:44:34 +08:00
<div class="card" v-for="(label,key) in cardSta" :key="key">
<h2>{{ label }}</h2>
<p class="color1">{{ cardData[key] || 0 }}</p>
2024-06-24 14:27:26 +08:00
</div>
</div>
<ai-title title="评分列表"></ai-title>
<ai-search-bar>
<template #left>
<el-button type="primary" icon="iconfont iconAdd" @click="handleAdd">添加</el-button>
2024-07-19 09:44:34 +08:00
<!-- <ai-select-->
<!-- v-model="search.type"-->
<!-- @change="onChange"-->
<!-- placeholder="请选择事件类型"-->
<!-- :selectList="$dict.getDict('shopScoreType')">-->
<!-- </ai-select>-->
2024-06-24 14:27:26 +08:00
<ai-select
2024-06-29 14:27:03 +08:00
v-model="search.listType"
2024-06-24 14:27:26 +08:00
@change="(search.current = 1), getList()"
placeholder="请选择自定义事件"
:selectList="dictList">
</ai-select>
<ai-select
2024-06-26 15:32:10 +08:00
v-model="search.status"
2024-06-24 14:27:26 +08:00
@change="(search.current = 1), getList()"
placeholder="请选择状态"
2024-06-26 15:32:10 +08:00
:selectList="$dict.getDict('shopScoreEvent')">
2024-06-24 14:27:26 +08:00
</ai-select>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
style="margin-top: 6px;"
:current.sync="search.current"
:size.sync="search.size"
@getList="getList">
2024-06-26 15:32:10 +08:00
<el-table-column
label="分值"
slot="score">
<template v-slot="{ row }">
2024-07-19 09:44:34 +08:00
<span>{{ row.score === 0 ? 0 : row.score > 0 ? `+${row.score}` : row.score }}</span>
2024-06-26 15:32:10 +08:00
</template>
</el-table-column>
2024-06-24 14:27:26 +08:00
<el-table-column
label="状态"
2024-06-26 15:32:10 +08:00
slot="status">
2024-06-24 14:27:26 +08:00
<template v-slot="{ row }">
2024-06-26 15:32:10 +08:00
<span class="start" v-if="row.status==='1'">启用</span>
<span class="stop" v-else>停用</span>
2024-06-24 14:27:26 +08:00
</template>
</el-table-column>
<el-table-column slot="options" width="180px" fixed="right" label="操作" align="center">
<template slot-scope="{ row }">
<div class="table-options">
2024-07-19 09:44:34 +08:00
<el-button type="text" @click="changeState(row)">{{ row.status === '1' ? '停用' : '启用' }}</el-button>
2024-06-26 15:32:10 +08:00
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
2024-06-24 14:27:26 +08:00
</div>
</template>
</el-table-column>
</ai-table>
</template>
</ai-list>
2024-06-26 15:35:16 +08:00
<ai-dialog title="评分规则" :visible.sync="dialog" width="800px" @closed="onClosed" @onConfirm="onConfirm">
2024-07-19 09:44:34 +08:00
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px" size="small">
<!-- <el-form-item label="事件类型:" prop="type">-->
<!-- <ai-select v-model="form.type" placeholder="请选择事件类型" dict="shopScoreType"/>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="自定义事件:" prop="listType">-->
<!-- <el-input v-model="form.listType" :disabled="form.type === '' || form.type === null || form.type === undefined" placeholder="请输入自定义事件" size="small"></el-input>-->
<!-- </el-form-item>-->
<el-form-item label="事件名称:" prop="listType">
<el-input v-model="form.listType" placeholder="请输入事件名称" clearable/>
2024-06-24 14:27:26 +08:00
</el-form-item>
<el-form-item label="规则:">常规</el-form-item>
2024-06-26 15:32:10 +08:00
<el-form-item label="分值:" prop="score">
2024-07-19 09:44:34 +08:00
<el-input-number v-model="form.score" :precision="2" size="small" placeholder="请输入分值" :min="0"/>
2024-06-24 14:27:26 +08:00
</el-form-item>
</el-form>
</ai-dialog>
</div>
</template>
<script>
export default {
name: "RuleManage",
2024-06-26 15:32:10 +08:00
props: {
instance: Function,
dict: Object,
permissions: Function
},
2024-06-24 14:27:26 +08:00
data() {
return {
2024-07-19 09:44:34 +08:00
search: {
genre: '',
type: '',
status: '',
2024-06-26 15:58:23 +08:00
current: 1,
size: 10,
2024-06-26 15:32:10 +08:00
},
2024-07-19 09:44:34 +08:00
dictList: [],
cardSta: {
rulesCount: "规则总数量",
positiveCount: "启动规则项",
negativeCount: "停用规则项",
positiveScore: "规则总分数",
// negativeScore: "负向事件总分数",
},
cardData: {},
2024-06-24 14:27:26 +08:00
total: 10,
colConfigs: [
{type: "selection"},
2024-07-19 09:44:34 +08:00
// { prop: 'type', label: '类型', align: 'center' ,render:(h,{row})=>{
// return h('span',null,this.dict.getLabel('shopScoreType',row.type))
// }},
{prop: 'listType', label: '事件', align: 'center'},
{prop: 'rule', label: '规则', align: 'center'},
{slot: 'score'},
{slot: 'status'},
2024-06-24 14:27:26 +08:00
],
tableData: [],
2024-07-19 09:44:34 +08:00
dialog: false,
form: {
id: null,
listType: '',
type: '',
score: '',
rule: '常规'
2024-06-26 15:32:10 +08:00
},
2024-07-19 09:44:34 +08:00
rules: {
type: [{required: true, message: '请选择事件类型', trigger: 'change'},],
listType: [{required: true, message: '请输入自定义事件', trigger: 'blur'},],
score: [{required: true, message: '请输入分值', trigger: 'change'},],
2024-06-26 15:32:10 +08:00
}
2024-06-24 14:27:26 +08:00
}
},
2024-06-26 15:32:10 +08:00
2024-07-19 09:44:34 +08:00
created() {
this.queryListTypeByType()
this.$dict.load('shopScoreType', 'shopScoreEvent').then(() => {
2024-06-26 15:32:10 +08:00
this.getStatic()
this.getList()
})
},
2024-06-24 14:27:26 +08:00
methods: {
2024-07-19 09:44:34 +08:00
onChange(e) {
if (e) {
2024-06-27 09:38:47 +08:00
this.queryListTypeByType(e)
2024-07-19 09:44:34 +08:00
} else {
2024-06-29 14:27:03 +08:00
this.search.listType = ''
2024-07-19 09:44:34 +08:00
this.dictList = []
this.search.current = 1
this.getList()
2024-06-27 09:38:47 +08:00
}
},
2024-07-19 09:44:34 +08:00
async queryListTypeByType(type) {
2024-06-27 09:38:47 +08:00
try {
2024-07-19 09:44:34 +08:00
const {code, data} = await this.instance.post('/app/appscorerules/queryListTypeByType', null, {
params: {type}
2024-06-27 09:38:47 +08:00
})
2024-07-19 09:44:34 +08:00
if (code === 0) {
this.dictList = [...new Set(data?.map(e => e.listType) || [])].map(item => {
return {dictName: item, dictValue: item}
2024-06-27 09:38:47 +08:00
})
}
2024-07-19 09:44:34 +08:00
} catch (e) {
2024-06-27 09:38:47 +08:00
console.log(e)
}
},
2024-07-19 09:44:34 +08:00
onConfirm() {
this.$refs['formRef'].validate(async valid => {
if (valid) {
2024-06-26 15:35:16 +08:00
try {
2024-07-19 09:44:34 +08:00
const {code} = await this.instance.post('/app/appscorerules/addOrUpdate', {...this.form})
if (code === 0) {
2024-06-26 15:35:16 +08:00
this.$message.success('保存成功')
2024-06-27 09:38:47 +08:00
this.dialog = false
2024-06-26 15:35:16 +08:00
this.getList()
this.getStatic()
}
2024-07-19 09:44:34 +08:00
} catch (e) {
2024-06-26 15:35:16 +08:00
console.error(e)
}
}
})
},
2024-07-19 09:44:34 +08:00
onClosed() {
2024-06-26 15:32:10 +08:00
this.form = {
2024-07-19 09:44:34 +08:00
type: '',
score: ''
2024-06-26 15:32:10 +08:00
}
this.$refs['formRef'].resetFields()
},
2024-07-19 09:44:34 +08:00
async changeState({id, status}) {
2024-06-26 15:32:10 +08:00
try {
2024-07-19 09:44:34 +08:00
const {code} = await this.instance.post('/app/appscorerules/isOrNotEnableById', null, {
params: {id}
2024-06-26 15:32:10 +08:00
})
2024-07-19 09:44:34 +08:00
if (code === 0) {
this.$message.success(status === '1' ? '停用成功' : '启用成功')
2024-06-26 15:32:10 +08:00
this.getStatic()
this.getList()
}
2024-07-19 09:44:34 +08:00
} catch (e) {
2024-06-26 15:32:10 +08:00
console.error(e)
}
},
2024-07-19 09:44:34 +08:00
handleEdit(row) {
2024-06-26 15:32:10 +08:00
this.form = {...row}
this.dialog = true
},
2024-07-19 09:44:34 +08:00
handleDelete({id}) {
2024-06-26 15:32:10 +08:00
this.$confirm("是否要删除此数据?").then(
2024-07-19 09:44:34 +08:00
async () => {
try {
const {code} = await this.instance.post('/app/appscorerules/delete', null, {
params: {ids: id}
})
if (code === 0) {
this.$message.success('删除成功')
this.getStatic()
this.getList()
}
} catch (e) {
console.error(e)
2024-06-26 15:32:10 +08:00
}
}
)
},
2024-07-19 09:44:34 +08:00
handleAdd() {
2024-06-24 14:27:26 +08:00
this.dialog = true
},
2024-06-26 15:32:10 +08:00
async getStatic() {
try {
2024-07-19 09:44:34 +08:00
const {code, data} = await this.instance.post('/app/appscorerules/queryAppScoreRulesCount')
if (code === 0) {
this.cardData = data
2024-06-26 15:32:10 +08:00
}
2024-07-19 09:44:34 +08:00
} catch (e) {
2024-06-26 15:32:10 +08:00
console.error(e)
}
},
2024-07-19 09:44:34 +08:00
async getList() {
2024-06-26 15:32:10 +08:00
try {
2024-07-19 09:44:34 +08:00
const {code, data} = await this.instance.post('/app/appscorerules/list', null, {
params: {
2024-06-27 09:38:47 +08:00
...this.search
}
})
2024-07-19 09:44:34 +08:00
if (code === 0) {
2024-06-26 15:32:10 +08:00
this.tableData = data.records
this.total = data.total
}
2024-07-19 09:44:34 +08:00
} catch (e) {
2024-06-26 15:32:10 +08:00
console.error(e)
}
2024-06-24 14:27:26 +08:00
}
},
}
</script>
<style lang="scss" scoped>
.card_list {
display: flex;
.card {
flex: 1;
height: 96px;
background: #F9F9F9;
border-radius: 2px;
margin-right: 20px;
padding: 16px 24px;
box-sizing: border-box;
h2 {
color: #888888;
font-weight: 600;
font-size: 16px;
}
p {
margin-top: 8px;
font-size: 24px;
font-weight: 600;
}
.color1 {
color: #2891FF;
}
.color2 {
color: #22AA99;
}
.color3 {
color: #F8B425;
}
}
.card:last-child {
margin-right: 0;
}
}
2024-06-26 15:32:10 +08:00
2024-07-19 09:44:34 +08:00
:deep(.start) {
2024-06-26 15:32:10 +08:00
font-size: 14px;
color: #2EA222;
}
2024-07-19 09:44:34 +08:00
:deep(.stop) {
2024-06-26 15:32:10 +08:00
font-size: 14px;
color: #FF4466;
}
2024-06-24 14:27:26 +08:00
</style>