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

View File

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