政策解读的完成。资讯快报页面初始化
This commit is contained in:
83
src/views/front/expressNews/add.vue
Normal file
83
src/views/front/expressNews/add.vue
Normal file
@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div>添加资讯</div>
|
||||
<el-form
|
||||
style="width:50%;margin:15px 0 0 15px"
|
||||
label-position="left"
|
||||
:model="ruleForm"
|
||||
:rules="rules"
|
||||
ref="ruleForm"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="资讯标题" prop="title">
|
||||
<el-input placeholder="请输入" v-model="ruleForm.title"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="正文" prop="text">
|
||||
<editor v-model="ruleForm.text" :min-height="192" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('ruleForm')"
|
||||
>确定</el-button
|
||||
>
|
||||
<!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Editor from '@/components/Editor';
|
||||
import { read, getPolicyReadInfo } from '@/api/front/unscramble';
|
||||
export default {
|
||||
components: {
|
||||
Editor
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editPage: false,
|
||||
ruleForm: {
|
||||
title: '',
|
||||
text: ''
|
||||
},
|
||||
rules: {
|
||||
title: [{ required: true, message: '请输入资讯标题', trigger: 'blur' }],
|
||||
text: [{ required: true, message: '请填写富文本内容', trigger: 'blur' }]
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submitForm(formName) {
|
||||
this.$refs[formName].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.editPage) {
|
||||
// 修改
|
||||
read(this.ruleForm).then(({ message }) => {
|
||||
this.msgSuccess(message);
|
||||
});
|
||||
} else {
|
||||
// 添加
|
||||
read(this.ruleForm).then(({ message }) => {
|
||||
this.msgSuccess(message);
|
||||
});
|
||||
}
|
||||
this.$router.go(-1);
|
||||
} else {
|
||||
console.log('error submit!!');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
// resetForm(formName) {
|
||||
// this.$refs[formName].resetFields();
|
||||
// }
|
||||
},
|
||||
created() {
|
||||
let { id } = this.$route.query;
|
||||
if (id) {
|
||||
this.editPage = true;
|
||||
getPolicyReadInfo({ readId: id }).then(({ data }) => {
|
||||
this.ruleForm = data;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Reference in New Issue
Block a user