This commit is contained in:
花有清香月有阴
2022-01-07 08:50:23 +08:00
parent 7e6f22ee19
commit a3b7536fba
2 changed files with 83 additions and 91 deletions

View File

@@ -3,22 +3,19 @@
<div class="header-description"> <div class="header-description">
<u-form :model="form" ref="uForm" label-width="auto"> <u-form :model="form" ref="uForm" label-width="auto">
<u-form-item label="主题" prop="content" required label-position="top"> <u-form-item label="主题" prop="content" required label-position="top">
<u-input v-model="form.content" placeholder="请输入标题(1000字以内)" type="textarea" auto-height height="280" <u-input v-model="form.content" placeholder="请输入标题(1000字以内)" type="textarea" auto-height height="280" maxlength="1000" />
maxlength="1000"/>
</u-form-item> </u-form-item>
<u-form-item label="图片(最多9张)" prop="images" class="avatars" label-position="top"> <u-form-item label="图片(最多9张)" prop="images" class="avatars" label-position="top">
<AiUploader :def.sync="form.images" multiple placeholder="上传图片" :limit="9" <AiUploader :def.sync="form.images" multiple placeholder="上传图片" :limit="9" action="/admin/file/add2"></AiUploader>
action="/admin/file/add2"></AiUploader>
</u-form-item> </u-form-item>
<u-form-item label="议事截止时间" prop="discussDeadline" required> <u-form-item label="议事截止时间" prop="discussDeadline" required>
<AiDateTime v-model="form.discussDeadline"/> <AiDateTime v-model="form.discussDeadline" />
</u-form-item> </u-form-item>
<u-form-item label="公示截止时间" prop="publicityDeadline"> <u-form-item label="公示截止时间" prop="publicityDeadline">
<AiDateTime v-model="form.publicityDeadline"/> <AiDateTime v-model="form.publicityDeadline" />
</u-form-item> </u-form-item>
<u-form-item label="议事类型" prop="type" required label-position="top"> <u-form-item label="议事类型" prop="type" required label-position="top">
<div v-for="op in $dict.getDict('discussType')" :key="op.dictValue" class="discussType" <div v-for="op in $dict.getDict('discussType')" :key="op.dictValue" class="discussType" @click="form.type = op.dictValue" :class="{ current: form.type == op.dictValue }">
@click="form.type=op.dictValue" :class="{current:form.type==op.dictValue}">
{{ op.dictName }} {{ op.dictName }}
</div> </div>
</u-form-item> </u-form-item>
@@ -30,7 +27,7 @@
</template> </template>
<script> <script>
import {mapState} from 'vuex' import { mapState } from 'vuex'
export default { export default {
name: 'Add', name: 'Add',
@@ -38,26 +35,26 @@ export default {
data() { data() {
return { return {
id: '', id: '',
form: {type: 0}, form: { type: 0 },
flag: false, flag: false,
} }
}, },
computed: {...mapState(['user'])}, computed: { ...mapState(['user']) },
onLoad(o) { onLoad(o) {
if (o.id) { if (o.id) {
this.id = o.id this.id = o.id
this.getDetail() this.getDetail()
} }
this.$dict.load("discussType") this.$dict.load('discussType')
}, },
onShow() { onShow() {
document.title = "新增议事" document.title = '新增议事'
}, },
methods: { methods: {
getDetail() { getDetail() {
this.$http.post(`/app/appvillagediscuss/queryDetailById?id=${this.id}`).then((res) => { this.$http.post(`/app/appvillagediscuss/queryDetailById?id=${this.id}`).then((res) => {
if (res?.data) { if (res?.data) {
this.form = {...res.data} this.form = { ...res.data }
if (res.data.images) { if (res.data.images) {
this.form.images = JSON.parse(res.data.images || '[]') this.form.images = JSON.parse(res.data.images || '[]')
} }
@@ -72,20 +69,22 @@ export default {
if (!this.form.discussDeadline) { if (!this.form.discussDeadline) {
return this.$u.toast('请选择 议事截止时间') return this.$u.toast('请选择 议事截止时间')
} }
this.$http.post(`/app/appvillagediscuss/addOrUpdate`, { this.$http
...this.form, .post(`/app/appvillagediscuss/addOrUpdate`, {
images: JSON.stringify(this.form.images), ...this.form,
id: this.id, images: JSON.stringify(this.form.images),
}).then((res) => { id: this.id,
if (res?.code == 0) { })
uni.$emit('update') .then((res) => {
this.$u.toast('发布成功') if (res?.code == 0) {
this.flag = true uni.$emit('update')
setTimeout(() => { this.$u.toast('发布成功')
uni.navigateBack({}) this.flag = true
}, 600) setTimeout(() => {
} uni.navigateBack({})
}) }, 600)
}
})
}, },
}, },
} }
@@ -153,7 +152,7 @@ export default {
.discussType { .discussType {
width: 320px; width: 320px;
height: 112px; height: 112px;
background: #F5F5F5; background: #f5f5f5;
border-radius: 4px; border-radius: 4px;
font-size: 30px; font-size: 30px;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
@@ -168,17 +167,17 @@ export default {
} }
&.current { &.current {
color: #1174FE; color: #1174fe;
background: #E7F1FE; background: #e7f1fe;
position: relative; position: relative;
&:before { &:before {
position: absolute; position: absolute;
display: block; display: block;
content: " "; content: ' ';
bottom: 0; bottom: 0;
right: 0; right: 0;
border: 24px solid #1576FE; border: 24px solid #1576fe;
border-top-color: transparent; border-top-color: transparent;
border-left-color: transparent; border-left-color: transparent;
border-radius: inherit; border-radius: inherit;
@@ -188,7 +187,7 @@ export default {
&:after { &:after {
position: absolute; position: absolute;
display: block; display: block;
content: "✓"; content: '✓';
bottom: 0; bottom: 0;
right: 0; right: 0;
color: #fff; color: #fff;

View File

@@ -1,55 +1,50 @@
<template> <template>
<div class="AppVillageDiscuss"> <div class="AppVillageDiscuss">
<AiTopFixed v-if="tabs.length>0"> <AiTopFixed v-if="tabs.length > 0">
<div class="tab-select"> <div class="tab-select">
<div class="item" :class="{active:type == item.dictValue}" v-for="(item) in tabs" :key="item.dictValue" <div class="item" :class="{ active: type == item.dictValue }" v-for="item in tabs" :key="item.dictValue" @click="tabClick(item.dictValue)">{{ item.dictName }}<span /></div>
@click="tabClick(item.dictValue)">{{ item.dictName }}<span/>
</div>
</div> </div>
</AiTopFixed> </AiTopFixed>
<template v-if="datas.length > 0"> <template v-if="datas.length > 0">
<AiCard v-for="(item, i) in datas" :ref="item.id" :key="i" @click.native="toAdd(item, 1)"> <AiCard v-for="(item, i) in datas" :ref="item.id" :key="i" @click.native="toAdd(item, 1)">
<template #custom> <template #custom>
<div flex class="w-100"> <div flex class="w-100">
<div class="avatar" v-text="item.avatar"/> <div class="avatar" v-text="item.avatar" />
<div flex class="column start fill"> <div flex class="column start fill">
<b class="color-333" v-text="item.createUserName"/> <b class="color-333" v-text="item.createUserName" />
<span class="color-999" v-text="item.createTime"/> <span class="color-999" v-text="item.createTime" />
</div> </div>
<div class="statusTag" :class="{over:item.status>0}" <div class="statusTag" :class="{ over: item.status > 0 }" v-text="item.status == 0 ? (item.type == 0 ? '征集中' : '投票中') : $dict.getLabel('discussStatus', item.status)" />
v-text="item.status==0? item.type==0?'征集中':'投票中':$dict.getLabel('discussStatus',item.status)"/>
</div> </div>
<p class="item-content"> <p class="item-content">
<u-parse :html="item.content"></u-parse> <u-parse :html="item.content"></u-parse>
</p> </p>
<div v-if="item.images&&item.images.length"> <div v-if="item.images && item.images.length">
<div class="img-list" v-if="item.contentType != 1"> <div class="img-list" v-if="item.contentType != 1">
<img :src="items.accessUrl" alt="" v-for="(items, index) in item.images" :key="index" v-if="index < 3" <img :src="items.accessUrl" alt="" v-for="(items, index) in item.images" :key="index" v-if="index < 3" @click.stop="previewImage(item.images, items.accessUrl)" />
@click.stop="previewImage(item.images, items.accessUrl)"/>
</div> </div>
<div class="img-list" v-else> <div class="img-list" v-else>
<video class="video" :src="item.images[0].url"/> <video class="video" :src="item.images[0].url" />
</div> </div>
</div> </div>
</template> </template>
</AiCard> </AiCard>
<u-loadmore :status="loadmore" color="#999" font-size="24" margin-top="32" margin-bottom="80"/> <u-loadmore :status="loadmore" color="#999" font-size="24" margin-top="32" margin-bottom="80" />
</template> </template>
<AiEmpty description="暂无数据" v-else></AiEmpty> <AiEmpty description="暂无数据" v-else></AiEmpty>
<AiFixedBtn> <AiFixedBtn>
<div class="addBtn iconfont iconfont-iconfangda" @tap.stop="toAdd()"/> <div class="addBtn iconfont iconfont-iconfangda" @tap.stop="toAdd()" />
<div class="addBtn iconfont iconfont-iconDouble_Up" @tap.stop="backTop" v-if="showBackTop"/> <div class="addBtn iconfont iconfont-iconDouble_Up" @tap.stop="backTop" v-if="showBackTop" />
</AiFixedBtn> </AiFixedBtn>
<u-modal v-model="deletShow" content="您确认要删除该条信息吗?" :show-cancel-button="true" :mask-close-able="true" <u-modal v-model="deletShow" content="您确认要删除该条信息吗?" :show-cancel-button="true" :mask-close-able="true" :show-title="false" @confirm="delet"></u-modal>
:show-title="false" @confirm="delet"></u-modal>
</div> </div>
</template> </template>
<script> <script>
import {mapState} from 'vuex' import { mapState } from 'vuex'
export default { export default {
name: 'AppVillageDiscuss', name: 'AppVillageDiscuss',
@@ -67,7 +62,7 @@ export default {
type: '0', type: '0',
listName: '', listName: '',
tabIndex: 0, tabIndex: 0,
showBackTop: false showBackTop: false,
} }
}, },
computed: { computed: {
@@ -76,8 +71,8 @@ export default {
return this.pages <= this.current ? 'loading ' : 'nomore' return this.pages <= this.current ? 'loading ' : 'nomore'
}, },
tabs() { tabs() {
return this.$dict.getDict("discussStatus") return this.$dict.getDict('discussStatus')
} },
}, },
onLoad(o) { onLoad(o) {
this.moduleId = o.moduleId this.moduleId = o.moduleId
@@ -86,10 +81,10 @@ export default {
uni.$on('update', () => { uni.$on('update', () => {
this.getList() this.getList()
}) })
this.$dict.load("discussStatus") this.$dict.load('discussStatus')
}, },
onShow() { onShow() {
document.title = "居民议事" document.title = '居民议事'
}, },
onPageScroll(obj) { onPageScroll(obj) {
this.showBackTop = obj.scrollTop > 0 this.showBackTop = obj.scrollTop > 0
@@ -97,8 +92,8 @@ export default {
methods: { methods: {
previewImage(images, img) { previewImage(images, img) {
uni.previewImage({ uni.previewImage({
urls: images.map(v => v.url), urls: images.map((v) => v.url),
current: img current: img,
}) })
}, },
tabClick(type) { tabClick(type) {
@@ -111,22 +106,23 @@ export default {
this.getList() this.getList()
}, },
getList() { getList() {
let {current, type} = this let { current, type } = this
this.$http.post('/app/appvillagediscuss/list', null, { this.$http
params: {size: 20, current, type}, .post('/app/appvillagediscuss/list', null, {
}) params: { size: 20, current, type },
.then((res) => { })
if (res?.data) { .then((res) => {
res.data.records.forEach(e => { if (res?.data) {
e.avatar = e.createUserName?.substring(0, 2) || "游客" res.data.records.forEach((e) => {
if (e.images) { e.avatar = e.createUserName?.substring(0, 2) || '游客'
e.images = JSON.parse(e.images) if (e.images) {
} e.images = JSON.parse(e.images)
}) }
this.datas = this.current > 1 ? [...this.datas, ...res.data.records] : res.data.records })
this.pages = res.data.pages this.datas = this.current > 1 ? [...this.datas, ...res.data.records] : res.data.records
} this.pages = res.data.pages
}) }
})
}, },
toAdd(item, type) { toAdd(item, type) {
@@ -134,13 +130,13 @@ export default {
this.$refs?.[item.id]?.[0]?.handleClose() this.$refs?.[item.id]?.[0]?.handleClose()
} }
if (type == '1') { if (type == '1') {
uni.navigateTo({url: `./Detail?id=${item.id}`}) uni.navigateTo({ url: `./Detail?id=${item.id}` })
} }
if (type == '2') { if (type == '2') {
uni.navigateTo({url: `./Add?id=${item.id}`}) uni.navigateTo({ url: `./Add?id=${item.id}` })
} }
if (type == null) { if (type == null) {
uni.navigateTo({url: `./Add`}) uni.navigateTo({ url: `./Add` })
} }
}, },
@@ -161,9 +157,9 @@ export default {
}, },
backTop() { backTop() {
uni.pageScrollTo({ uni.pageScrollTo({
scrollTop: 0 scrollTop: 0,
}); })
} },
}, },
onReachBottom() { onReachBottom() {
this.current++ this.current++
@@ -203,8 +199,8 @@ export default {
.statusTag { .statusTag {
padding: 0 12px; padding: 0 12px;
line-height: 30px; line-height: 30px;
border: 1px solid #2573FF; border: 1px solid #2573ff;
color: #2573FF; color: #2573ff;
font-size: 22px; font-size: 22px;
&.over { &.over {
@@ -223,7 +219,7 @@ export default {
width: 100%; width: 100%;
height: 96px; height: 96px;
line-height: 96px; line-height: 96px;
background: #3975C6; background: #3975c6;
display: flex; display: flex;
.item { .item {
@@ -231,7 +227,7 @@ export default {
text-align: center; text-align: center;
font-size: 28px; font-size: 28px;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
color: #CDDCF0; color: #cddcf0;
} }
.active { .active {
@@ -243,7 +239,7 @@ export default {
span { span {
width: 48px; width: 48px;
height: 4px; height: 4px;
background: #FFF; background: #fff;
position: absolute; position: absolute;
bottom: 14px; bottom: 14px;
left: 50%; left: 50%;
@@ -252,7 +248,6 @@ export default {
} }
} }
::v-deep .AiCard { ::v-deep .AiCard {
background: #f3f6f9; background: #f3f6f9;
position: relative; position: relative;
@@ -322,7 +317,7 @@ export default {
display: inline-block; display: inline-block;
padding: 0 16px; padding: 0 16px;
line-height: 48px; line-height: 48px;
background: #EEE; background: #eee;
border-radius: 24px; border-radius: 24px;
font-size: 24px; font-size: 24px;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
@@ -348,9 +343,7 @@ export default {
} }
} }
} }
} }
} }
.AiFixedBtn { .AiFixedBtn {