2021-12-16 16:04:21 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="add">
|
|
|
|
|
<div class="header-description">
|
|
|
|
|
<u-form :model="forms" ref="uForm" label-width="auto">
|
|
|
|
|
<u-form-item label="标题" prop="title" required label-position="top">
|
|
|
|
|
<u-input v-model="forms.title" placeholder="请输入标题(30字以内)" type="textarea" auto-height height="60" maxlength="30" />
|
|
|
|
|
</u-form-item>
|
|
|
|
|
|
2021-12-23 16:12:29 +08:00
|
|
|
<u-form-item label="类别" prop="status" required v-if="selectList.length">
|
2021-12-23 15:09:25 +08:00
|
|
|
<div class="right" @click="showStstus=true">
|
2021-12-23 15:49:49 +08:00
|
|
|
<span v-if="forms.selectIndex === ''" class="color-999">请选择类别</span>
|
|
|
|
|
<span v-else>{{selectList[forms.selectIndex].categoryName}}</span>
|
2021-12-23 15:09:25 +08:00
|
|
|
<u-icon name="arrow-right" color="#CCCCCC" class="right-icon"></u-icon>
|
|
|
|
|
</div>
|
2021-12-23 15:49:49 +08:00
|
|
|
<u-select v-model="showStstus" :list="selectList" value-name="selectIndex" label-name="categoryName" @confirm="selectStatus"></u-select>
|
2021-12-16 16:04:21 +08:00
|
|
|
</u-form-item>
|
|
|
|
|
|
2021-12-23 15:09:25 +08:00
|
|
|
<u-form-item label="发布地区" prop="areaId" required >
|
|
|
|
|
<div class="right">
|
|
|
|
|
<AiAreaPicker v-model="forms.areaId" :areaId="user.areaId" @select="areaSelect"></AiAreaPicker>
|
|
|
|
|
<u-icon name="arrow-right" color="#CCCCCC" class="right-icon area-right-icon"></u-icon>
|
|
|
|
|
</div>
|
2021-12-16 16:04:21 +08:00
|
|
|
</u-form-item>
|
|
|
|
|
|
|
|
|
|
<u-form-item label="正文" prop="content" required label-position="top">
|
|
|
|
|
<u-input v-model="forms.content" placeholder="请输入活动详情(30字以内)" type="textarea" auto-height height="60" maxlength="500" />
|
|
|
|
|
</u-form-item>
|
|
|
|
|
|
|
|
|
|
<u-form-item label="图片(最多9张)" prop="fileIds" class="avatars" label-position="top">
|
|
|
|
|
<AiUploader :def.sync="forms.fileIds" multiple placeholder="上传图片" :limit="9"></AiUploader>
|
|
|
|
|
</u-form-item>
|
|
|
|
|
</u-form>
|
|
|
|
|
</div>
|
2021-12-23 15:49:49 +08:00
|
|
|
<div class="pad-b112"></div>
|
2021-12-16 16:04:21 +08:00
|
|
|
|
|
|
|
|
<div class="btn" @click="submit">保存</div>
|
|
|
|
|
|
|
|
|
|
<AiBack></AiBack>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { mapState } from 'vuex'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'Add',
|
|
|
|
|
components: {},
|
|
|
|
|
props: {},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2021-12-16 17:13:18 +08:00
|
|
|
id: '',
|
2021-12-16 16:04:21 +08:00
|
|
|
forms: {
|
|
|
|
|
title: '',
|
|
|
|
|
content: '',
|
|
|
|
|
fileIds: [],
|
|
|
|
|
areaId: '',
|
2021-12-23 15:49:49 +08:00
|
|
|
selectIndex: '',
|
2021-12-16 16:04:21 +08:00
|
|
|
},
|
|
|
|
|
showStstus: false,
|
|
|
|
|
flag: false,
|
|
|
|
|
areaIdProps: '',
|
2021-12-23 15:09:25 +08:00
|
|
|
moduleId: '',
|
|
|
|
|
listName: '',
|
|
|
|
|
selectList: []
|
2021-12-16 16:04:21 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: { ...mapState(['user']) },
|
2021-12-16 17:13:18 +08:00
|
|
|
onLoad(o) {
|
|
|
|
|
console.log(o)
|
|
|
|
|
this.id = o.id
|
2021-12-23 11:03:06 +08:00
|
|
|
this.moduleId = o.moduleId
|
2021-12-23 15:09:25 +08:00
|
|
|
this.forms.areaId = this.user.areaId
|
|
|
|
|
this.listName = o.listName
|
|
|
|
|
this.getType()
|
2021-12-23 16:56:41 +08:00
|
|
|
uni.setNavigationBarTitle({title: this.listName})
|
2021-12-16 16:04:21 +08:00
|
|
|
},
|
2021-12-16 17:13:18 +08:00
|
|
|
|
2021-12-16 16:04:21 +08:00
|
|
|
mounted() {},
|
|
|
|
|
methods: {
|
2021-12-23 15:09:25 +08:00
|
|
|
getDetail() {
|
|
|
|
|
this.$http.post(`/app/appcontentinfo/queryDetailById?id=${this.id}`).then((res) => {
|
|
|
|
|
if (res?.data) {
|
|
|
|
|
this.forms = {...res.data}
|
|
|
|
|
if(this.selectList.length) {
|
|
|
|
|
this.selectList.map((item, index) => {
|
|
|
|
|
if(item.id == res.data.categoryId) {
|
2021-12-23 15:49:49 +08:00
|
|
|
this.forms.selectIndex = index
|
2021-12-23 15:09:25 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (res.data.images) {
|
|
|
|
|
this.forms.images = JSON.parse(res.data.images || '[]')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getType() {
|
|
|
|
|
this.$http.post(`/app/appcontentmoduleinfo/listByName?names=${this.listName}`).then((res) => {
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
if(res.data && res.data[0].categoryList.length) {
|
|
|
|
|
this.selectList = res.data[0].categoryList
|
2021-12-23 15:49:49 +08:00
|
|
|
this.selectList.map((item, index) => {
|
|
|
|
|
item.selectIndex = index
|
|
|
|
|
})
|
2021-12-23 15:09:25 +08:00
|
|
|
if(this.id) {
|
|
|
|
|
this.getDetail()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-12-16 16:04:21 +08:00
|
|
|
submit() {
|
|
|
|
|
if (this.flag) return
|
|
|
|
|
|
|
|
|
|
this.$refs.uForm.validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
if (!this.forms.title) {
|
2021-12-16 17:13:18 +08:00
|
|
|
return this.$u.toast('请输入标题')
|
|
|
|
|
}
|
|
|
|
|
if (!this.forms.content) {
|
|
|
|
|
return this.$u.toast('请输入正文')
|
2021-12-16 16:04:21 +08:00
|
|
|
}
|
|
|
|
|
|
2021-12-23 15:49:49 +08:00
|
|
|
if(this.selectList.length && this.forms.selectIndex === '') {
|
2021-12-23 15:09:25 +08:00
|
|
|
return this.$u.toast('请选择类别')
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 16:04:21 +08:00
|
|
|
const imgs = []
|
2021-12-16 17:13:18 +08:00
|
|
|
if (this.forms.fileIds) {
|
|
|
|
|
this.forms.fileIds.map((e) => {
|
2021-12-16 16:04:21 +08:00
|
|
|
imgs.push({ url: e.url, id: e.id })
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.flag = true
|
2021-12-23 15:09:25 +08:00
|
|
|
this.$http.post(`/app/appcontentinfo/addOrUpdate`, {
|
2021-12-16 16:04:21 +08:00
|
|
|
title: this.forms.title,
|
2021-12-16 17:13:18 +08:00
|
|
|
areaId: this.forms.areaId,
|
|
|
|
|
content: this.forms.content,
|
2021-12-23 15:09:25 +08:00
|
|
|
files: imgs || [],
|
2021-12-16 16:04:21 +08:00
|
|
|
id: this.id,
|
2021-12-23 15:09:25 +08:00
|
|
|
moduleId: this.moduleId,
|
2021-12-23 15:49:49 +08:00
|
|
|
categoryId: this.selectList[this.forms.selectIndex].id,
|
|
|
|
|
categoryName: this.selectList[this.forms.selectIndex].categoryName,
|
2021-12-16 16:04:21 +08:00
|
|
|
})
|
|
|
|
|
.then((res) => {
|
|
|
|
|
if (res.code == 0) {
|
2021-12-23 15:49:49 +08:00
|
|
|
uni.$emit('update')
|
2021-12-16 16:04:21 +08:00
|
|
|
this.$u.toast('发布成功')
|
|
|
|
|
this.flag = false
|
2021-12-23 15:49:49 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.navigateBack()
|
|
|
|
|
}, 600)
|
2021-12-16 16:04:21 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
this.$u.toast('失败')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
areaSelect(e) {
|
2021-12-16 17:13:18 +08:00
|
|
|
this.forms.areaId = e.id
|
2021-12-16 16:04:21 +08:00
|
|
|
},
|
|
|
|
|
|
2021-12-16 17:13:18 +08:00
|
|
|
selectStatus(e) {
|
2021-12-23 15:49:49 +08:00
|
|
|
this.forms.selectIndex = e[0].value
|
2021-12-16 16:04:21 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.add {
|
|
|
|
|
height: 100%;
|
|
|
|
|
.header-description {
|
|
|
|
|
::v-deep .u-form {
|
|
|
|
|
.u-form-item {
|
|
|
|
|
.u-form-item__body {
|
|
|
|
|
.u-form-item--right__content__slot {
|
|
|
|
|
padding-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.u-form-item:last-child {
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
padding-bottom: 20px !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.avatars {
|
|
|
|
|
.u-form-item__body {
|
|
|
|
|
.default {
|
|
|
|
|
width: 160px;
|
|
|
|
|
height: 160px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-23 15:49:49 +08:00
|
|
|
.pad-b112{
|
|
|
|
|
padding-bottom: 224px;
|
|
|
|
|
}
|
2021-12-16 16:04:21 +08:00
|
|
|
|
|
|
|
|
.btn {
|
|
|
|
|
position: fixed;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 112px;
|
|
|
|
|
line-height: 112px;
|
|
|
|
|
background: #1365dd;
|
|
|
|
|
text-align: center;
|
|
|
|
|
font-size: 32px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
color: #ffffff;
|
2021-12-23 15:49:49 +08:00
|
|
|
z-index: 999;
|
2021-12-16 16:04:21 +08:00
|
|
|
}
|
2021-12-23 15:09:25 +08:00
|
|
|
|
|
|
|
|
.right{
|
|
|
|
|
width: 100%;
|
|
|
|
|
text-align: right;
|
|
|
|
|
.right-icon{
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
}
|
|
|
|
|
.area-right-icon{
|
|
|
|
|
margin: -40px 0 0 8px;
|
|
|
|
|
}
|
|
|
|
|
::v-deep .AiAreaPicker{
|
|
|
|
|
display: inline-block;
|
|
|
|
|
width: calc(100% - 50px);
|
|
|
|
|
.areaSelector{
|
|
|
|
|
div{
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding-top: 30px;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
text-align: right;
|
|
|
|
|
}
|
|
|
|
|
.fixedTop{
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.color-999{
|
|
|
|
|
color: #999;
|
|
|
|
|
}
|
2021-12-16 16:04:21 +08:00
|
|
|
}
|
|
|
|
|
</style>
|