90 lines
2.1 KiB
Vue
90 lines
2.1 KiB
Vue
<template>
|
||
<section class="contentAdd">
|
||
<u-form ref="ContentForm" label-position="top" :model="form">
|
||
<u-form-item label="标题" prop="title" required>
|
||
<u-input v-model="form.title" placeholder="请输入,最多30字" maxlength="30"/>
|
||
</u-form-item>
|
||
<u-form-item label="详情描述" prop="content">
|
||
<AiTextarea v-model="form.content" placeholder="请输入,最多500字" :maxlength="500"/>
|
||
</u-form-item>
|
||
<u-form-item label="图片(最多9张)" class="files">
|
||
<AiUploader multiple :limit="9" :def.sync="form.fileList" action="/admin/file/add2"/>
|
||
</u-form-item>
|
||
</u-form>
|
||
<div flex class="submitBtn" @tap="submitForm">提交</div>
|
||
</section>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
name: "contentAdd",
|
||
computed: {
|
||
isEdit() {
|
||
return !!this.$route.query?.id
|
||
},
|
||
},
|
||
data() {
|
||
return {
|
||
form: {
|
||
fileList: []
|
||
},
|
||
moduleId: ""
|
||
}
|
||
},
|
||
onLoad(params) {
|
||
this.moduleId = params.moduleId
|
||
this.getForm(params.id)
|
||
},
|
||
methods: {
|
||
getForm(id) {
|
||
id && this.$http.post(`/app/appcontentinfo/queryDetailById`, null, {
|
||
params: {id}
|
||
}).then(res => {
|
||
if (res?.data) {
|
||
this.form = {...res.data};
|
||
}
|
||
})
|
||
},
|
||
submitForm() {
|
||
if (!this.form.title) {
|
||
return this.$u.toast("标题请填写")
|
||
}
|
||
|
||
this.$refs.ContentForm?.validate(v => {
|
||
if (v) {
|
||
let {moduleId} = this
|
||
this.$http.post(`/app/appcontentinfo/addOrUpdate`, {moduleId, ...this.form}).then(res => {
|
||
if (res?.code == 0) {
|
||
this.$u.toast("提交成功!")
|
||
setTimeout(() => {
|
||
uni.navigateBack({})
|
||
}, 1000)
|
||
}
|
||
})
|
||
}
|
||
})
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.contentAdd {
|
||
.files {
|
||
margin-top: 24px;
|
||
}
|
||
|
||
.submitBtn {
|
||
position: fixed;
|
||
justify-content: center;
|
||
bottom: 0;
|
||
width: 100%;
|
||
height: 112px;
|
||
color: #fff;
|
||
background: $uni-color-primary;
|
||
font-size: 32px;
|
||
font-family: PingFangSC-Medium, PingFang SC;
|
||
}
|
||
}
|
||
</style>
|