bug
This commit is contained in:
@@ -1,159 +1,425 @@
|
|||||||
<template>
|
<template>
|
||||||
<ai-list class="notice">
|
<ai-list class="gridScoreRules">
|
||||||
<template slot="title">
|
<ai-title
|
||||||
<ai-title title="积分规则" isShowBottomBorder isShowArea :hideLevel="hideLevel-1" v-model="search.areaId" @change="changeArea">
|
slot="title"
|
||||||
|
title="积分规则"
|
||||||
|
isShowBottomBorder>
|
||||||
</ai-title>
|
</ai-title>
|
||||||
</template>
|
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<ai-search-bar class="search-bar">
|
<ai-search-bar>
|
||||||
<template #left>
|
<template #left>
|
||||||
<el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')">我要发帖</el-button>
|
<el-button type="primary" icon="iconfont iconAdd" @click="dialog = true"> 添加</el-button>
|
||||||
<el-date-picker
|
<el-cascader size="small" v-model="systemRuleIdList" :options="rulesOps" placeholder="请选择事件/类型" clearable :props="rulesProps"
|
||||||
v-model="dateList"
|
@change="handleTypeSearch" ref="eventTypeSearch"/>
|
||||||
@change="search.current = 1,getList()"
|
<ai-select v-model="search.status" @change="(page.current = 1), getList()" placeholder="请选择状态" :selectList="$dict.getDict('integralRuleStatus')">
|
||||||
type="daterange"
|
</ai-select>
|
||||||
size="small"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
range-separator="至"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期">
|
|
||||||
</el-date-picker>
|
|
||||||
</template>
|
|
||||||
<template #right>
|
|
||||||
<el-input
|
|
||||||
v-model="search.createUserName"
|
|
||||||
class="search-input"
|
|
||||||
size="small"
|
|
||||||
v-throttle="() => {search.current = 1, getList()}"
|
|
||||||
placeholder="请输入发帖人"
|
|
||||||
clearable
|
|
||||||
@clear="search.current = 1, search.createUserName = '', getList()"
|
|
||||||
suffix-icon="iconfont iconSearch">
|
|
||||||
</el-input>
|
|
||||||
</template>
|
</template>
|
||||||
</ai-search-bar>
|
</ai-search-bar>
|
||||||
<ai-table
|
<ai-table
|
||||||
:tableData="tableData"
|
:tableData="tableData"
|
||||||
:col-configs="colConfigs"
|
:col-configs="colConfigs"
|
||||||
:total="total"
|
:total="page.total"
|
||||||
style="margin-top: 6px;"
|
:dict="dict"
|
||||||
:current.sync="search.current"
|
:current.sync="page.current"
|
||||||
:size.sync="search.size"
|
:size.sync="page.size"
|
||||||
@getList="getList">
|
@getList="getList()">
|
||||||
<el-table-column slot="options" width="180px" fixed="right" label="操作" align="center">
|
<el-table-column slot="integral" label="分值" align="center">
|
||||||
|
<template slot-scope="{ row }">
|
||||||
|
<span>{{ row.integral > 0 ? "+" : "" }}{{ row.integral }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column slot="options" label="操作" align="center" fixed="right" width="160">
|
||||||
<template slot-scope="{ row }">
|
<template slot-scope="{ row }">
|
||||||
<div class="table-options">
|
<div class="table-options">
|
||||||
<el-button type="text" @click="toDetail(row.id)">详情</el-button>
|
<el-button type="text" @click="changeStatus(row.id, 0)" v-if="row.status == 1">停用</el-button>
|
||||||
|
<el-button type="text" @click="changeStatus(row.id, 1)" v-else>启用</el-button>
|
||||||
|
<el-button type="text" @click="toEdit(row)">编辑</el-button>
|
||||||
<el-button type="text" @click="remove(row.id)">删除</el-button>
|
<el-button type="text" @click="remove(row.id)">删除</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</ai-table>
|
</ai-table>
|
||||||
|
<ai-dialog :title="dialogTitle" :visible.sync="dialog" @onConfirm="onConfirm" @close="closed" width="900px">
|
||||||
|
<div class="form_div" v-if="dialog">
|
||||||
|
<el-form ref="DialogForm" :model="form" :rules="formRules" size="small" label-suffix=":" label-width="150px">
|
||||||
|
<el-form-item label="事件类型" prop="systemRuleId">
|
||||||
|
<el-cascader v-model="form.systemRuleId" ref="cascaderArr" :props="etOps" clearable placeholder="请选择" @change="handleTypeForm" :options="rulesOps"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="自定义事件" prop="ruleName">
|
||||||
|
<ai-select v-model="form.ruleName" placeholder="请选择自定义事件" :selectList="$dict.getDict('appIntegralApplyEventType')">
|
||||||
|
</ai-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="规则">
|
||||||
|
<div>常规</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="周期范围" prop="scoringCycle">
|
||||||
|
<ai-select v-model="form.scoringCycle" :selectList="$dict.getDict('integralRuleScoringCycle')" :disabled="isOneAndTen"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="奖励次数">
|
||||||
|
<el-input type="number" placeholder="请输入,周期范围内,不填写表示不限制" v-model.number="form.numberLimit" clearable :disabled="isOneAndTen"/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="积分分值" prop="integral">
|
||||||
|
<el-input placeholder="请输入" v-model="form.integral" clearable/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="有效地区" prop="areaId" required>
|
||||||
|
<ai-area-select
|
||||||
|
clearable
|
||||||
|
@fullname="v => form.areaName = v"
|
||||||
|
:disabled-level="$store.state.user.info.areaList.length - 1"
|
||||||
|
always-show
|
||||||
|
:instance="instance"
|
||||||
|
v-model="form.areaId">
|
||||||
|
</ai-area-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</ai-dialog>
|
||||||
</template>
|
</template>
|
||||||
</ai-list>
|
</ai-list>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
|
||||||
export default {
|
export default {
|
||||||
name: 'List',
|
name: "gridScoreRules",
|
||||||
|
label: "积分规则",
|
||||||
props: {
|
props: {
|
||||||
instance: Function,
|
instance: Function,
|
||||||
dict: Object
|
dict: Object,
|
||||||
|
permissions: Function,
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
data () {
|
var validcode = (rule, value, callback) => {
|
||||||
|
if (value) {
|
||||||
|
if (value != 0) {
|
||||||
|
if (!/^([+-]?([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/.test(value)) {
|
||||||
|
callback(new Error('请输入积分分值,可输入正数、负数、最多保留两位小数'))
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callback(new Error('请输入有效的积分分值'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callback(new Error('请输入积分分值'));
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
search: {
|
search: {
|
||||||
current: 1,
|
status: "",
|
||||||
size: 10,
|
systemRuleId: "",
|
||||||
createUserName: '',
|
ruleName: ""
|
||||||
areaId: ''
|
|
||||||
},
|
},
|
||||||
total: 10,
|
systemRuleIdList: [],
|
||||||
|
page: {current: 1, size: 10, total: 0},
|
||||||
colConfigs: [
|
colConfigs: [
|
||||||
{ prop: 'content', label: '内容', align: 'left', 'show-overflow-tooltip': true },
|
{
|
||||||
{ prop: 'commentCount', label: '评论数', align: 'center', width: '120' },
|
prop: "parentRuleName",
|
||||||
{ prop: 'appreciateCount', label: '点赞数', align: 'center', width: '120' },
|
label: "类型",
|
||||||
{ prop: 'sharedCount', label: '分享数', align: 'center', width: '120' },
|
dict: "integralRuleEventType",
|
||||||
{ prop: 'createUserName', label: '发帖人', align: 'center', width: '120' },
|
},
|
||||||
{ prop: 'createUserAreaName', label: '所在地区', align: 'center', width: '120' },
|
{prop: "ruleName", label: "事件", dict: "integralRuleEvent", align: "center"},
|
||||||
{ prop: 'createTime', label: '创建时间', align: 'center', width: '180' },
|
{prop: "ruleType", label: "规则", dict: "integralRuleRuleType", align: "center"},
|
||||||
{ slot: 'options'},
|
{
|
||||||
|
prop: "scoringCycle",
|
||||||
|
label: "周期范围",
|
||||||
|
align: "center",
|
||||||
|
dict: "integralRuleScoringCycle",
|
||||||
|
render: (h, {row}) => {
|
||||||
|
return h(
|
||||||
|
"span",
|
||||||
|
{},
|
||||||
|
row.numberLimit.length
|
||||||
|
? $dict.getLabel("integralRuleScoringCycle", row.scoringCycle)
|
||||||
|
: $dict.getLabel("integralRuleScoringCycle", row.scoringCycle) +
|
||||||
|
row.numberLimit +
|
||||||
|
"次"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{slot: "integral", label: "积分分值", align: "center"},
|
||||||
|
{
|
||||||
|
prop: "validRangeData",
|
||||||
|
label: "有效地区",
|
||||||
|
align: "center",
|
||||||
|
format: v => JSON.parse(v).areaName
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: "status",
|
||||||
|
label: "状态",
|
||||||
|
align: "center",
|
||||||
|
dict: "integralRuleStatus",
|
||||||
|
},
|
||||||
|
{slot: "options", label: "操作", align: "center"},
|
||||||
],
|
],
|
||||||
tableData: [],
|
tableData: [],
|
||||||
dateList: [],
|
dialog: false,
|
||||||
|
form: {
|
||||||
|
ruleType: "0",
|
||||||
|
systemRuleId: "",
|
||||||
|
ruleName: "",
|
||||||
|
scoringCycle: "",
|
||||||
|
numberLimit: "",
|
||||||
|
integral: "",
|
||||||
|
validRangeType: "2",
|
||||||
|
validRangeData: "",
|
||||||
|
areaName: '',
|
||||||
|
areaId: ''
|
||||||
|
},
|
||||||
|
formRules: {
|
||||||
|
systemRuleId: [
|
||||||
|
{required: true, message: "请选择事件/类型", trigger: "change"},
|
||||||
|
],
|
||||||
|
ruleName: [
|
||||||
|
{required: true, message: "请输入自定义事件", trigger: "change"},
|
||||||
|
],
|
||||||
|
scoringCycle: [
|
||||||
|
{required: true, message: "请选择周期范围", trigger: "change"},
|
||||||
|
],
|
||||||
|
integral: [{required: true, validator: validcode, trigger: "blur"},],
|
||||||
|
areaId: [
|
||||||
|
{required: true, message: "请选择地区", trigger: "change"},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
rulesOps: [],
|
||||||
|
rulesProps: {
|
||||||
|
label: "ruleName",
|
||||||
|
value: "id",
|
||||||
|
checkStrictly: true,
|
||||||
|
},
|
||||||
|
radio: 0,
|
||||||
|
treeObj: {
|
||||||
|
treeList: [],
|
||||||
|
defaultProps: {
|
||||||
|
label: "girdName",
|
||||||
|
value: "id",
|
||||||
|
children: 'children',
|
||||||
|
isLeaf: 'leaf'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
treeSelected: {},
|
||||||
|
girdInfoList: [],
|
||||||
|
rulueType: "0",
|
||||||
|
girdNameList: [],
|
||||||
|
list: [],
|
||||||
|
isOneAndTen: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.form.areaId = this.$store.state.user.info.areaId
|
||||||
|
this.$dict.load("integralRuleStatus", "integralRuleRuleType", "integralRuleScoringCycle",
|
||||||
|
"integralRuleEvent", "integralRuleEventType", 'appIntegralApplyEventType').then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.getRulesList();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getList() {
|
||||||
|
this.instance
|
||||||
|
.post(`/app/appintegralrule/listByAppletFD`, null, {
|
||||||
|
params: {
|
||||||
|
...this.search,
|
||||||
|
...this.page,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (res?.data) {
|
||||||
|
this.tableData = res.data.records;
|
||||||
|
this.page.total = res.data.total;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
closed () {
|
||||||
|
this.form.ruleType = '0'
|
||||||
|
this.form.systemRuleId = ''
|
||||||
|
this.form.ruleName = ''
|
||||||
|
this.form.scoringCycle = ''
|
||||||
|
this.form.numberLimit = ''
|
||||||
|
this.form.integral = ''
|
||||||
|
this.form.validRangeType = '2'
|
||||||
|
this.form.validRangeData = ''
|
||||||
|
this.form.areaName = this.$store.state.user.info.areaName
|
||||||
|
this.form.areaId = this.$store.state.user.info.areaId
|
||||||
|
},
|
||||||
|
toEdit(row) {
|
||||||
|
this.form = {...row}
|
||||||
|
if (this.form?.validRangeData) {
|
||||||
|
this.form.areaName = JSON.parse(this.form.validRangeData).areaName
|
||||||
|
this.form.areaId = JSON.parse(this.form.validRangeData).areaId
|
||||||
|
}
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.dialog = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
remove(id) {
|
||||||
|
this.$confirm("删除后不可恢复,是否要删除该规则?", {
|
||||||
|
type: "error",
|
||||||
|
}).then(() => {
|
||||||
|
this.instance
|
||||||
|
.post(`/app/appintegralrule/delete?ids=${id}`)
|
||||||
|
.then((res) => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.$message.success("删除成功!");
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
changeStatus(id, status) {
|
||||||
|
let text = status == 1 ? "启用" : "停用";
|
||||||
|
this.$confirm(`确定${text}该条规则?`).then(() => {
|
||||||
|
this.instance
|
||||||
|
.post(`/app/appintegralrule/enableStatus?id=${id}`)
|
||||||
|
.then((res) => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.$message.success(`${text}成功!`);
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onConfirm() {
|
||||||
|
this.$refs.DialogForm.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
let formData = this.$copy(this.form);
|
||||||
|
// formData.ladderRule = JSON.stringify(formData.ladderRule)
|
||||||
|
formData.integral = formData.integral || 0;
|
||||||
|
this.instance
|
||||||
|
.post(`/app/appintegralrule/addOrUpdate`, {
|
||||||
|
...formData,
|
||||||
|
appCodeType: '2',
|
||||||
|
validRangeData: JSON.stringify({
|
||||||
|
areaName: this.form.areaName,
|
||||||
|
areaId: this.form.areaId
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.$message.success(
|
||||||
|
`${this.isEdit ? "编辑成功" : "添加成功"}`
|
||||||
|
);
|
||||||
|
this.dialog = false;
|
||||||
|
this.getList();
|
||||||
|
this.closed();
|
||||||
|
this.girdInfoList = []
|
||||||
|
this.girdNameList = []
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleTypeSearch(v) {
|
||||||
|
this.systemRuleIdList = v
|
||||||
|
this.search.systemRuleId = v?.[v.length - 1];
|
||||||
|
this.search.ruleName = this.$refs.eventTypeSearch.getCheckedNodes()[0]?.label
|
||||||
|
this.page.current = 1;
|
||||||
|
this.$refs.eventTypeSearch.dropDownVisible = false;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
handleTypeForm(v) {
|
||||||
|
if (this.dialog) {
|
||||||
|
if(v[0] == '1' || v[0]== '10') {
|
||||||
|
this.form.scoringCycle = '0'
|
||||||
|
this.form.numberLimit = '1'
|
||||||
|
this.isOneAndTen = true
|
||||||
|
} else {
|
||||||
|
this.form.scoringCycle = ''
|
||||||
|
this.form.numberLimit = ''
|
||||||
|
this.isOneAndTen = false
|
||||||
|
}
|
||||||
|
this.form.systemRuleId = v?.[v.length - 1];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleDelete(i) {
|
||||||
|
this.$confirm("是否要删除该规则?")
|
||||||
|
.then(() => {
|
||||||
|
this.form.ladderRule.splice(i, 1);
|
||||||
|
})
|
||||||
|
.catch(() => 0);
|
||||||
|
},
|
||||||
|
checkIntegral(v) {
|
||||||
|
return /\.\d{2,}$/.test(v) ? Math.abs(v).toFixed(1) : Math.abs(v);
|
||||||
|
},
|
||||||
|
getRulesList() {
|
||||||
|
this.instance
|
||||||
|
.post(`/app/appintegralsystemrule/listByAppletFD?current=1&size=3000`)
|
||||||
|
.then((res) => {
|
||||||
|
if (res?.data) {
|
||||||
|
this.rulesOps = this.toTree(res.data.records)
|
||||||
|
this.rulesOps.push({
|
||||||
|
ruleName: "积分申请",
|
||||||
|
id: "积分申请",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 转树形结构
|
||||||
|
toTree(data) {
|
||||||
|
let result = [];
|
||||||
|
if (!Array.isArray(data)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
let map = {};
|
||||||
|
data.forEach((item) => {
|
||||||
|
map[item.id] = item;
|
||||||
|
});
|
||||||
|
data.forEach((item) => {
|
||||||
|
let parent = map[item.parentRuleId];
|
||||||
|
if (parent) {
|
||||||
|
(parent.children || (parent.children = [])).push(item);
|
||||||
|
} else {
|
||||||
|
result.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['user']),
|
isEdit() {
|
||||||
hideLevel() {
|
return !!this.form.id;
|
||||||
return this.user.info.areaList?.length || 0
|
},
|
||||||
|
dialogTitle() {
|
||||||
|
return this.isEdit ? "编辑积分规则" : "添加积分规则";
|
||||||
|
},
|
||||||
|
etOps() {
|
||||||
|
return {
|
||||||
|
value: "id",
|
||||||
|
label: "ruleName",
|
||||||
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
|
||||||
this.search.areaId = this.user.info.areaId
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
getList() {
|
|
||||||
this.instance.post(`/app/appneighborhoodassistance/list`, null, {
|
|
||||||
params: {
|
|
||||||
...this.search,
|
|
||||||
createUserAreaId: this.search.areaId,
|
|
||||||
beginDate: this.dateList[0] || '',
|
|
||||||
endDate: this.dateList[1] || '',
|
|
||||||
}
|
|
||||||
}).then(res => {
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.tableData = res.data.records
|
|
||||||
this.total = res.data.total
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
changeArea () {
|
|
||||||
this.search.current = 1
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.getList()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
remove (id) {
|
|
||||||
this.$confirm('确定删除该帖子?').then(() => {
|
|
||||||
this.instance.post(`/app/appneighborhoodassistance/delete?id=${id}`).then(res => {
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.$message.success('删除成功!')
|
|
||||||
this.getList()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
toDetail (id) {
|
|
||||||
this.$emit('change', {
|
|
||||||
type: 'Detail',
|
|
||||||
params: {
|
|
||||||
id: id || ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
toAdd(id) {
|
|
||||||
this.$emit('change', {
|
|
||||||
type: 'Add',
|
|
||||||
params: {
|
|
||||||
id: id || ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.gridScoreRules {
|
||||||
|
height: 100%;
|
||||||
|
background: #f3f6f9;
|
||||||
|
|
||||||
|
:deep( .ai-list__content--right ){
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
// :deep( .searchRightZone ){
|
||||||
|
// display: flex;
|
||||||
|
// }
|
||||||
|
|
||||||
|
:deep( .ai-dialog ){
|
||||||
|
.el-cascader {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tableInput {
|
||||||
|
& > input {
|
||||||
|
text-align: center;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user