Files
dvcp_v2_webapp/project/lulong/AppSubjectSet/components/Add.vue
2023-10-17 13:57:46 +08:00

129 lines
4.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<ai-detail class="content-add">
<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 class="ai-form" :model="form" label-width="120px" ref="form">
<el-form-item prop="title" style="width: 100%;" label="话题名称" :rules="[{required: true, message: '请输入话题名称', trigger: 'change'}]">
<el-input size="small" placeholder='如“社会保障”仅限4个字' v-model="form.title" maxlength="4" :show-word-limit="true"></el-input>
</el-form-item>
<el-form-item prop="showIndex" style="width: 100%;" label="排序" :rules="[{required: true, message: '请输入排序', trigger: 'change'}]">
<el-input-number v-model="form.showIndex" :min="1" :max="100" size="small"></el-input-number>
<span class="tips">请输入数字数字越小排序越前</span>
</el-form-item>
<el-form-item label="话题描述" prop="description" style="width: 100%;" :rules="[{required: true, message: '请输入发布内容', trigger: 'change'}]">
<el-input type="textarea" placeholder="限500字" v-model="form.description" rows="8" maxlength="500" :show-word-limit="true"></el-input>
</el-form-item>
<el-form-item label="话题图标" prop="files" style="width: 100%;" :rules="[{required: true, message: '请上传话题图标', trigger: 'change'}]">
<ai-uploader
:instance="instance"
v-model="form.files"
isShowTip
:limit="1">
</ai-uploader>
</el-form-item>
<el-form-item prop="status" style="width: 100%;" label="是否启用" :rules="[{required: true}]">
<el-radio-group v-model="form.status">
<el-radio label="1"></el-radio>
<el-radio label="0"></el-radio>
</el-radio-group>
</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>
import { mapState } from 'vuex'
export default {
name: 'Add',
props: {
instance: Function,
dict: Object,
params: Object
},
data () {
return {
form: {
title: '',
showIndex: '',
description: '',
files: [],
picUrl: '',
status: '1',
},
isFlag: false
}
},
computed: {
...mapState(['user'])
},
created () {
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
},
methods: {
getInfo (id) {
this.instance.post(`/app/appneighborhoodassistancetheme/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.form = res.data
this.form.files = [{url: res.data.picUrl}]
}
})
},
confirm () {
if(this.isFlag) return
this.$refs.form.validate((valid) => {
if (valid) {
this.isFlag = true
this.instance.post(`/app/appneighborhoodassistancetheme/addOrUpdate`, {
...this.form,
picUrl: this.form.files[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">
.tips {
display: inline-block;
margin-left: 8px;
color: #999;
font-size: 12px;
}
</style>