111 lines
3.3 KiB
Vue
111 lines
3.3 KiB
Vue
<template>
|
|
<ai-detail>
|
|
<template slot="title">
|
|
<ai-title :title="params.id ? '编辑小程序公告' : '添加小程序公告'" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
|
|
</ai-title>
|
|
</template>
|
|
<template slot="content">
|
|
<ai-card title="基本信息">
|
|
<template #content>
|
|
<el-form ref="form" class="ai-form" :model="form" label-width="110px" label-position="right">
|
|
<el-form-item label="标题" style="width: 100%;" prop="codeName" :rules="[{ required: true, message: '请输入标题', trigger: 'blur' }]">
|
|
<el-input size="small" placeholder="请输入标题" :maxlength="30" v-model="form.codeName"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="发布单位" style="width: 100%;" prop="codeName" :rules="[{ required: true, message: '请输入发布单位', trigger: 'blur' }]">
|
|
<el-input size="small" placeholder="请输入发布单位" :maxlength="30" v-model="form.codeName"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="正文" style="width: 100%;" prop="codeName" :rules="[{ required: true, message: '请输入正文', trigger: 'blur' }]">
|
|
<el-input size="small" placeholder="请输入正文" :rows="6" :maxlength="1000" type="textarea" v-model="form.codeName"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="图片" style="width: 100%;" prop="codeName">
|
|
<ai-uploader v-model="form.pictureUrl" :instance="instance" :limit="9"></ai-uploader>
|
|
</el-form-item>
|
|
</el-form>
|
|
</template>
|
|
</ai-card>
|
|
</template>
|
|
<template #footer>
|
|
<el-button @click="cancel">取消</el-button>
|
|
<el-button type="primary" @click="confirm">提交</el-button>
|
|
</template>
|
|
</ai-detail>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'Add',
|
|
|
|
props: {
|
|
instance: Function,
|
|
dict: Object,
|
|
params: Object
|
|
},
|
|
|
|
data () {
|
|
return {
|
|
info: {},
|
|
form: {
|
|
codeName: '',
|
|
code: '',
|
|
pictureUrl: [],
|
|
codeUrl: [],
|
|
type: '',
|
|
},
|
|
id: ''
|
|
}
|
|
},
|
|
|
|
created () {
|
|
if (this.params && this.params.id) {
|
|
this.id = this.params.id
|
|
this.getInfo(this.params.id)
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
getInfo (id) {
|
|
this.instance.post(`/app/appeveryvillagecode/queryDetailById?id=${id}`).then(res => {
|
|
if (res.code === 0) {
|
|
this.form = res.data
|
|
this.form.codeUrl = [{
|
|
url: res.data.codeUrl
|
|
}]
|
|
}
|
|
})
|
|
},
|
|
|
|
onClose () {
|
|
this.form.explain = ''
|
|
},
|
|
|
|
confirm () {
|
|
this.$refs.form.validate((valid) => {
|
|
if (valid) {
|
|
this.instance.post(`/app/appeveryvillagecode/addOrUpdate`, {
|
|
...this.form,
|
|
codeUrl: this.form.codeUrl[0].url
|
|
}).then(res => {
|
|
if (res.code == 0) {
|
|
this.$message.success('提交成功')
|
|
setTimeout(() => {
|
|
this.cancel(true)
|
|
}, 600)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
cancel (isRefresh) {
|
|
this.$emit('change', {
|
|
type: 'list',
|
|
isRefresh: !!isRefresh
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
</style>
|