村民议事

This commit is contained in:
yanran200730
2022-01-04 18:02:08 +08:00
parent 56e73bf7ad
commit 945a087f1b
3 changed files with 168 additions and 151 deletions

View File

@@ -1,7 +1,7 @@
<template>
<ai-detail>
<template slot="title">
<ai-title :title="params.id ? '编辑本村简介' : '添加本村简介'" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
<ai-title :title="params.id ? '编辑村民议事' : '添加村民议事'" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
</ai-title>
</template>
<template slot="content">
@@ -9,62 +9,63 @@
<template #content>
<el-form class="ai-form" :model="form" label-width="120px" ref="form">
<el-form-item label="主题" style="width: 100%;" prop="title" :rules="[{required: true, message: '请输入主题', trigger: 'blur'}]">
<el-input type="textarea" :rows="5" v-model="form.title" clearable placeholder="请输入主题..." maxlength="30" show-word-limit></el-input>
<el-input type="textarea" :rows="5" v-model="form.title" clearable placeholder="请输入主题..." :maxlength="500" show-word-limit></el-input>
</el-form-item>
<el-form-item prop="areaId" style="width: 100%;" label="发布地区" :rules="[{required: true, message: '请选择地区', trigger: 'change'}]">
<ai-area-select clearable always-show :instance="instance" v-model="form.areaId" :disabled-level="disabledLevel"></ai-area-select>
<el-form-item prop="areaId" style="width: 100%;" label="发布地区" :rules="[{required: true, pattern: /([^0]\d{2}|0[^0]\d|0\d[^0])$/, message: '请选择到村', trigger: 'change'}]">
<ai-area-select @fullname="form.areaName" clearable always-show :instance="instance" v-model="form.areaId" :disabled-level="disabledLevel"></ai-area-select>
</el-form-item>
<el-form-item label="议事截止时间" prop="date" :rules="[{required: true, message: '请选择议事截止时间', trigger: 'change'}]">
<el-form-item label="议事截止时间" prop="discussDeadline" :rules="[{required: true, message: '请选择议事截止时间', trigger: 'change'}]">
<el-date-picker
v-model="form.date"
v-model="form.discussDeadline"
type="datetime"
style="width: 100%;"
size="small"
value-format="yyyy-MM-dd hh:mm:ss"
placeholder="选择议事截止时间">
</el-date-picker>
</el-form-item>
<el-form-item label="公示截止时间" prop="time" :rules="[{required: true, message: '请选择公示截止时间', trigger: 'change'}]">
<el-form-item label="公示截止时间" prop="publicityDeadline" :rules="[{required: true, message: '请选择公示截止时间', trigger: 'change'}]">
<el-date-picker
v-model="form.time"
v-model="form.publicityDeadline"
size="small"
style="width: 100%;"
type="datetime"
value-format="yyyy-MM-dd hh:mm:ss"
placeholder="选择公示截止时间">
</el-date-picker>
</el-form-item>
<el-form-item label="议事类型" prop="type" :rules="[{required: true, message: '请选择议事类型', trigger: 'change'}]">
<el-radio-group v-model="form.type">
<el-radio label="0">意见征集</el-radio>
<el-radio label="1">投票表决</el-radio>
<el-radio :label="item.dictValue" v-for="(item, index) in dict.getDict('discussType')" :key="index">{{ item.dictName }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item class="vite-form__item" style="width: 100%;" label="投票选项" prop="type" :rules="[{required: true, message: '请添加投票选项', trigger: 'change'}]">
<el-form-item label-width="80px" :label="'选项' + index" v-for="(item, index) in form.voteList" :key="index + item.name">
<el-form-item v-if="form.type === '1'" class="vite-form__item" style="width: 100%;" label="投票选项" prop="voteItems" :rules="[{required: true, message: '请添加投票选项', trigger: 'change'}]">
<el-form-item label-width="80px" :label="'选项' + (index + 1)" v-for="(item, index) in form.voteItems" :key="'选项' + (index + 1)">
<div class="form-flex">
<el-input v-model="item.name" size="small" clearable placeholder="请输入选项"></el-input>
<el-input v-model="item.content" size="small" clearable placeholder="请输入选项"></el-input>
<el-button type="danger" size="small" @click="removeVote(index)">删除</el-button>
</div>
</el-form-item>
<el-button type="primary" size="small" @click="addVote">添加选项</el-button>
</el-form-item>
<el-form-item label="是否匿名投票" prop="anonymity" :rules="[{required: true, message: '请选择是否匿名投票', trigger: 'change'}]">
<el-form-item v-if="form.type === '1'" label="是否匿名投票" prop="anonymous" :rules="[{required: true, message: '请选择是否匿名投票', trigger: 'change'}]">
<el-switch
v-model="form.anonymity"
v-model="form.anonymous"
active-value="1"
inactive-value="0">
</el-switch>
</el-switch>
</el-form-item>
<el-form-item label="投票方式" prop="type" :rules="[{required: true, message: '请选择投票方式', trigger: 'change'}]">
<el-radio-group v-model="form.type">
<el-form-item v-if="form.type === '1'" label="投票方式" prop="voteType" :rules="[{required: true, message: '请选择投票方式', trigger: 'change'}]">
<el-radio-group v-model="form.voteType">
<el-radio label="0">单选</el-radio>
<el-radio label="1">多选</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="图片" style="width: 100%;" prop="thumbUrl">
<el-form-item label="图片" style="width: 100%;" prop="images">
<ai-uploader
:instance="instance"
isShowTip
v-model="form.thumbUrl"
v-model="form.images"
:limit="9">
</ai-uploader>
</el-form-item>
@@ -95,18 +96,18 @@
info: {},
form: {
title: '',
content: '',
areaId: '',
date: '',
type: '',
voteList: [],
time: '',
areaName: '',
anonymous: '0',
discussDeadline: '',
publicityDeadline: '',
type: '0',
voteType: '0',
voteItems: [],
anonymity: '1',
createUnitName: '',
createUserName: '',
status: '',
thumbUrl: []
images: []
},
keys: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
id: ''
}
},
@@ -117,6 +118,7 @@
created () {
this.form.areaId = this.user.info.areaId
this.form.areaName = this.user.info.areaName
this.disabledLevel = this.user.info.areaList.length
if (this.params && this.params.id) {
this.id = this.params.id
@@ -126,34 +128,49 @@
methods: {
getInfo (id) {
this.instance.post(`/app/appcountrysidetourism/queryDetailById?id=${id}`).then(res => {
this.instance.post(`/app/appvillagediscuss/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.form = res.data
this.form.thumbUrl = res.data.thumbUrl ? JSON.parse(res.data.thumbUrl) : []
this.form.images = res.data.images ? JSON.parse(res.data.images) : []
}
})
},
addVote () {
this.form.voteList.push({
name: ''
if (this.form.voteItems > 7) {
return this.$message.error('选项不能大于7个')
}
this.form.voteItems.push({
content: ''
})
},
removeVote (index) {
this.form.voteList.splice(index, 1)
this.form.voteItems.splice(index, 1)
},
confirm () {
this.$refs.form.validate((valid) => {
if (valid) {
this.instance.post(`/app/appcountrysidetourism/addOrUpdate`, {
if (this.form.type === '1' && this.form.voteItems.length < 2) {
return this.$message.error('投票选项不能少于2')
}
if (this.form.type === '1') {
this.form.voteItems = this.form.voteItems.map((v, index) => {
return {
content: v.content,
item: this.keys[index]
}
})
}
this.instance.post(`/app/appvillagediscuss/addOrUpdate`, {
...this.form,
type: 0,
createUserId: this.user.info.id,
createUserName: this.user.info.name,
thumbUrl: this.form.thumbUrl.length ? JSON.stringify([{
url: this.form.thumbUrl[0].url
}]) : ''
images: this.form.images.length ? JSON.stringify(this.form.images) : '',
}).then(res => {
if (res.code == 0) {
this.$message.success('提交成功')

View File

@@ -5,15 +5,29 @@
</ai-title>
</template>
<template slot="content">
<AiSidebar :tabTitle="tabList" v-model="currIndex"></AiSidebar>
<AiSidebar :tabTitle="tabList" v-model="currIndex" @change="onChange"></AiSidebar>
<ai-card title="议题信息" v-show="currIndex === 0">
<template #content>
<ai-wrapper>
<ai-info-item label="主题" value="主题"></ai-info-item>
<ai-info-item label="主题" :value="info.title" isLine></ai-info-item>
<ai-info-item label="发布地区" :value="info.areaName" isLine></ai-info-item>
<ai-info-item label="议事截止时间" :value="info.discussDeadline"></ai-info-item>
<ai-info-item label="公示截止时间" :value="info.publicityDeadline"></ai-info-item>
<ai-info-item label="议事类型" :value="dict.getLabel('discussType', info.type)" isLine></ai-info-item>
<ai-info-item label="是否匿名投票" v-if="info.type === '1'" :value="info.anonymous === '1' ? '是' : '否'"></ai-info-item>
<ai-info-item label="投票方式" v-if="info.type === '1'" :value="info.voteType === '0' ? '单选' : '多选'"></ai-info-item>
<ai-info-item label="图片">
<ai-uploader
:instance="instance"
disabled
v-model="info.images"
:limit="9">
</ai-uploader>
</ai-info-item>
</ai-wrapper>
</template>
</ai-card>
<ai-card title="意见征集" v-if="false" v-show="currIndex === 1">
<ai-card title="意见征集" v-if="info.type === '0'" v-show="currIndex === 1">
<template #right>
<el-button type="primary" size="small" @click="isShowAdd = true">发表意见</el-button>
</template>
@@ -31,14 +45,14 @@
</ai-table>
</template>
</ai-card>
<ai-card title="投票统计" v-show="currIndex === 1">
<ai-card title="投票统计" v-show="currIndex === 1 && info.type === '1'">
<template #content>
<div id="chart"></div>
<div class="chart" style="wdith: 800px; height: 240px; margin: 0 auto;"></div>
<ai-table
class="detail-table__table"
:border="true"
:tableData="tableData"
:col-configs="colConfigs"
:col-configs="voteColConfigs"
:total="total"
:current.sync="search.current"
:size.sync="search.size"
@@ -65,6 +79,7 @@
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'Detail',
@@ -90,111 +105,92 @@
currIndex: 0,
tableData: [],
colConfigs: [
{slot: 'userinfo'},
{prop: 'addWay', label: '客户来源', align: 'center', formart: v => this.dict.getLabel('wxCustomerAddWay', v)},
{prop: 'createTime', label: '添加时间', align: 'center'}
{prop: 'content', label: '发言内容', align: 'center'},
{prop: 'suport', label: '获赞次数', align: 'center'},
{prop: 'createTime', label: '发言时间', align: 'center'},
{prop: 'createUserName', label: '发言人', align: 'center'},
{prop: 'createUserId', label: '发言身份', align: 'center', formart: v => v === this.info.createUserId ? '话事人' : '村民'}
],
voteColConfigs: [
{prop: 'createTime', label: '投票时间', align: 'center'},
{prop: 'userName', label: '投票人', align: 'center'},
{prop: 'item', label: '投票选项', align: 'center'}
],
statistic: {},
tabList: ['议题信息', '意见征集']
}
},
created () {
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
this.getInfo(this.params.id)
},
methods: {
onChange (e) {
if (e === 1 && this.info.type === '1') {
this.$nextTick(() => {
this.initChart(this.statistic)
})
}
},
getInfo (id) {
this.instance.post(`/app/appeveryvillagecode/queryDetailById?id=${id}`).then(res => {
this.instance.post(`/app/appvillagediscuss/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
// this.form = res.data
this.info = res.data
this.info.images = res.data.images ? JSON.parse(res.data.images) : []
this.getList(this.params.id, res.data.type)
if (res.data.type === '1') {
this.statistic = res.data.statistic
this.tabList = ['议题信息', '投票表决']
}
}
})
},
getList(id, type) {
this.instance.post(`${type === '0' ? '/app/appvillagediscussmessage/list' : '/app/appvillagediscussvote/list'}`, null, {
params: {
discussId: id,
...this.search
}
}).then(res => {
if (res.code == 0) {
this.tableData = res.data.records
this.total = res.data.total
}
})
},
initChart(data) {
const y = data.map(v => this.$dict.getLabel('fpRiskType', v.risk_type) || '其他')
const v = data.map(v => v.c)
this.chart = echarts.init(document.querySelector('.chart'))
const option = {
tooltip: {},
color: ['#2896FF', '#09DBFE', '#61FDB9', '#FFBB69', '#8429FF', '#ea7ccc'],
grid: {
top: '4%',
left: '4%',
right: '6%',
bottom: '0%',
containLabel: true
},
xAxis: {
type: 'value',
splitLine: {
show: true,
lineStyle: {
width: 1,
type: 'solid',
color: '#f5f5f5'
}
},
axisTick: {
length: 1,
show: true
},
axisLabel: {
align: 'center',
padding: [2, 0, 0, 0],
interval: 0,
fontSize: 14,
color: '#999'
},
boundaryGap: true,
axisLine: {
show: true,
lineStyle: {
width: 1,
type: 'solid',
color: '#aaa'
}
},
},
yAxis: {
type: 'category',
data: y,
boundaryGap: true,
axisTick: {
length: 0,
show: false
},
splitLine: {
show: true,
lineStyle: {
color: ['#e9e9e9'],
width: 1,
type: 'solid'
}
},
nameTextStyle: {
color: '#999',
align: 'left'
},
axisLine: {
show: true,
lineStyle: {
width: 1,
type: 'solid',
color: '#aaa'
}
},
axisLabel: {
color: '#999'
}
legend: {
right: '5%',
top: 'center',
orient: 'vertical'
},
series: [
{
name: '2011',
type: 'bar',
data: v
type: 'pie',
radius: '50%',
data: Object.keys(data).map(v => {
return {
value: data[v],
name: v
}
}),
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
}
@@ -219,10 +215,6 @@
})
},
getList () {
},
onClose () {
},

View File

@@ -6,6 +6,8 @@
<template slot="content">
<ai-search-bar class="search-bar">
<template #left>
<ai-select v-model="search.type" clearable @change="search.current = 1, getList()" :selectList="dict.getDict('discussType')"></ai-select>
<ai-select v-model="search.status" clearable @change="search.current = 1, getList()" :selectList="dict.getDict('discussStatus')"></ai-select>
<el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')">发布议事</el-button>
</template>
<template #right>
@@ -36,12 +38,12 @@
</div>
</template>
</el-table-column>
<el-table-column slot="options" width="240px" fixed="right" label="操作" align="center">
<el-table-column slot="options" width="160px" fixed="right" label="操作" align="center">
<template slot-scope="{ row }">
<div class="table-options">
<el-button type="text" title="详情" @click="toDetail(row.id)">详情</el-button>
<el-button type="text" :title="row.status == 1 ? '取消发布' : '发布'" @click="changeStatus(row)">{{ row.status == 1 ? '取消发布' : '发布' }}</el-button>
<el-button type="text" @click="toAdd(row.id)">编辑</el-button>
<el-button type="text" title="取消公示" @click="changeStatus(row)" :disabled="row.status !== '1'">取消公示</el-button>
<!-- <el-button type="text" @click="toAdd(row.id)">编辑</el-button> -->
<el-button type="text" @click="remove(row.id)">删除</el-button>
</div>
</template>
@@ -66,19 +68,22 @@
search: {
current: 1,
size: 10,
title: ''
status: '',
type: '',
title: '',
areaId: ''
},
currIndex: -1,
areaList: [],
total: 10,
colConfigs: [
{ prop: 'title', label: '议事主题', align: 'left', width: '200px' },
{ prop: 'areaName', label: '议事类型', align: 'center' },
{ prop: 'createUnitName', label: '话事人', align: 'center' },
{ prop: 'createUserName', label: '观点数量', align: 'center' },
{ prop: 'createUserName', label: '投票数量', align: 'center' },
{ prop: 'status', label: '发布状态', align: 'center', formart: v => v === '1' ? '已发布' : '未发布' },
{ prop: 'createDate', label: '发布时间', align: 'center' },
{ prop: 'type', label: '议事类型', align: 'center', formart: v => this.dict.getLabel('discussType', v) },
{ prop: 'createUserName', label: '话事人', align: 'center' },
{ prop: 'msgCount', label: '观点数量', align: 'center' },
{ prop: 'voteCount', label: '投票数量', align: 'center' },
{ prop: 'status', label: '发布状态', align: 'center', formart: v => this.dict.getLabel('discussStatus', v) },
{ prop: 'createTime', label: '发布时间', align: 'center' },
{ slot: 'options', label: '操作', align: 'center' }
],
areaName: '',
@@ -91,14 +96,16 @@
...mapState(['user'])
},
mounted() {
created () {
this.search.areaId = this.user.info.areaId
this.getList()
this.dict.load(['discussType', 'discussStatus']).then(() => {
this.getList()
})
},
methods: {
getList() {
this.instance.post(`/app/appcountrysidetourism/list`, null, {
this.instance.post(`/app/appvillagediscuss/list`, null, {
params: {
type: 0,
...this.search
@@ -112,12 +119,13 @@
},
changeStatus (item) {
let title = item.status == '1' ? '是否要取消发布?' : '是否要发布?';
this.$confirm(title, {type: 'warning'}).then(() => {
item.status = item.status == '1' ? '0' : '1'
this.instance.post('/app/appcountrysidetourism/addOrUpdate', item).then(res => {
this.$confirm('是否要结束公示', {type: 'warning'}).then(() => {
this.instance.post('/app/appvillagediscuss/finishPublic', {
stauts: '2',
id: item.id
}).then(res => {
if (res && res.code == 0) {
title == '是否要发布?' ? this.$message.success('发布成功') : this.$message.success('取消发布成功')
this.$message.success('结束公示')
this.getList()
}
})
@@ -126,7 +134,7 @@
remove(id) {
this.$confirm('确定删除该数据?').then(() => {
this.instance.post(`/app/appcountrysidetourism/delete?ids=${id}`).then(res => {
this.instance.post(`/app/appvillagediscuss/delete?ids=${id}`).then(res => {
if (res.code == 0) {
this.$message.success('删除成功!')
this.getList()