This commit is contained in:
yanran200730
2022-01-07 16:29:40 +08:00
4 changed files with 106 additions and 79 deletions

View File

@@ -3,7 +3,7 @@
<div class="header-description">
<u-form :model="form" ref="uForm" label-width="auto">
<u-form-item label="主题" prop="content" required label-position="top" class="contents">
<u-input v-model="form.content" placeholder="请输入题(1000字以内)" type="textarea" auto-height height="280" maxlength="1000" />
<u-input v-model="form.content" placeholder="请输入题(500字以内)" type="textarea" auto-height height="280" maxlength="500" />
</u-form-item>
<u-form-item label="图片(最多9张)" prop="images" class="avatars" label-position="top">
@@ -11,7 +11,7 @@
</u-form-item>
<u-form-item label="发布地区" prop="areaId" required :border-bottom="false" right-icon="arrow-right" class="addresss">
<AiAreaPicker v-model="form.areaId" :areaId="user.areaId" @select="areaSelect" style="color: #666"></AiAreaPicker>
<AiAreaPicker v-model="form.areaId" :areaId="user.areaId" :name.sync="form.areaName" @select="areaSelect" style="color: #666"></AiAreaPicker>
</u-form-item>
<u-form-item label="议事截止时间" prop="discussDeadline" required :border-bottom="false" right-icon="arrow-right">
@@ -39,7 +39,7 @@
<img src="./img/22.png" alt="" />
<div class="rightopts">
<u-input v-model="content" placeholder="选项" maxlength="20" :clearable="false" />
<u-input v-model="contents" placeholder="选项" maxlength="200" :clearable="false" />
</div>
</div>
</div>
@@ -53,7 +53,7 @@
<img src="./img/22.png" alt="" />
<div class="rightopts">
<u-input v-model="content" placeholder="选项" :clearable="false" maxlength="20" />
<u-input v-model="contents" placeholder="选项" :clearable="false" maxlength="200" />
</div>
</div>
@@ -94,7 +94,11 @@ export default {
data() {
return {
id: '',
form: { type: 0 },
form: {
type: 0,
areaId: '',
areaName: '',
},
flag: false,
showStartTime: false,
showEndTime: false,
@@ -108,9 +112,10 @@ export default {
timestamp: true,
},
opts: 0,
checked: true,
checked: false,
list: [],
content: '',
contents: '',
keys: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
}
},
computed: { ...mapState(['user']) },
@@ -119,7 +124,7 @@ export default {
this.id = o.id
this.getDetail()
}
this.form.areaId = this.user.areaId
this.$dict.load('discussType').then(() => {
// this.areaId = this.user.areaId
})
@@ -142,27 +147,65 @@ export default {
submit() {
if (this.flag) return
if (!this.form.content) {
return this.$u.toast('请输入 主题')
return this.$u.toast('请输入主题')
}
if (!this.form.discussDeadline) {
return this.$u.toast('请选择 议事截止时间')
if (!this.form.areaId) {
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)
// if (!this.form.discussDeadline) {
// return this.$u.toast('请选择议事截止时间')
// }
// if (!this.form.publicityDeadline) {
// return this.$u.toast('请选择公示截止时间')
// }
if (this.form.type == 1) {
if (this.opts == 0) {
if (!this.form.contents) {
return this.$u.toast('请输入单选选项')
}
}
if (this.opts == 1) {
if (!this.list.length > 0) {
return this.$u.toast('请输入多选选项')
}
}
}
if (this.opts == 1) {
var lists = []
this.list.map((item, index) => {
item.contents == item, item.item == this.keys[index]
lists.push({
content: item,
item: this.keys[index],
})
})
console.log(lists)
}
var params = {
...this.form,
// voteItems: this.list,
areaId: this.form.areaId,
areaName: this.form.areaName,
voteItems: lists,
anonymous: this.checked == true ? 1 : 0,
createUserId: this.user.id,
createUserName: this.user.name,
images: JSON.stringify(this.form.images),
voteType: this.opts,
}
this.$http.post(`/app/appvillagediscuss/addOrUpdate`, params).then((res) => {
if (res.code == 0) {
uni.$emit('update')
this.$u.toast('发布成功')
this.flag = true
setTimeout(() => {
uni.navigateBack({})
}, 600)
}
})
},
addOpts() {