123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <template>
- <div class="cmain">
- <el-form ref="form" :model="form" :rules="rules" label-width="100px">
- <el-form-item label="新闻标题" prop="title">
- <el-input v-model="form.title" placeholder="请输入标题"></el-input>
- </el-form-item>
- <el-row>
- <el-col :span="12">
- <el-form-item label="新闻类型" prop="type">
- <el-select v-model="form.type" placeholder="请选择" style="width: 100%">
- <el-option v-for="item in typeList" :key="item.value + 'typeList'" :label="item.label" :value="item.value"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="新闻来源">
- <el-input v-model="form.source" placeholder="请输入来源"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item label="新闻封面">
- <cropper v-model="form.picture" :fixed_number="[4, 2]"></cropper>
- </el-form-item>
- <el-form-item label="新闻内容" prop="content">
- <editor v-model="form.content" />
- </el-form-item>
- </el-form>
- <div class="mfooter">
- <el-button type="primary" @click="submitForm">确 定</el-button>
- <el-button @click="$layer.close(layerid)">取 消</el-button>
- </div>
- </div>
- </template>
- <script>
- import { listNEWS, getNEWS, delNEWS, addNEWS, updateNEWS, upload, setTop, newCommit, updateAndex, downloadpic } from '@/api/portal/news/NEWS.js';
- export default {
- data() {
- return {
- typeList: [
- { label: '要闻动态', value: 1 },
- { label: '政策法规', value: 2 },
- { label: '通知公告', value: 3 },
- { label: '政策解读', value: 4 },
- { label: '投资导航', value: 5 }
- ],
- form: {type:2},
- rules: {
- title: [{ required: true, message: '标题不能为空', trigger: 'blur' }],
- content: [{ required: true, message: '内容不能为空', trigger: 'blur' }],
- fileUrl: [{ required: true, message: '附件不能为空', trigger: 'blur' }],
- type: [{ required: true, message: '类型不能为空', trigger: 'change' }],
- typeName: [{ required: true, message: '字典类型名称不能为空', trigger: 'blur' }],
- picture: [{ required: true, message: '图片不能为空', trigger: 'blur' }],
- status: [{ required: true, message: '状态(0.草稿,1.下架,2.审核中,3.审核驳回,4.已发布,5.已上报)不能为空', trigger: 'blur' }]
- }
- };
- },
- props: {
- param: {
- type: Object,
- default: () => {
- return {};
- }
- },
- layerid: {
- type: String
- }
- },
- mounted() {
- console.log('asd:' + this.param.type);
- if (this.param.type) {
- this.form.type =parseInt(this.param.type);
- }
- if (this.param.id) {
- getNEWS(this.param.id).then(response => {
- this.form = response.data;
- this.form.type=parseInt(this.form.type);
- this.form.content = response.data.content.replace(new RegExp('/profile/upload/', 'g'), this.baseUrl + '/profile/upload/');
- });
- }
- },
- methods: {
- /** 提交按钮 */
- submitForm() {
- this.$refs['form'].validate(valid => {
- if (valid) {
- if (this.form.id != null) {
- updateAndex(this.form).then(response => {
- this.$modal.msgSuccess('修改成功');
- this.$layer.close(this.layerid);
- this.$parent.getList();
- });
- } else {
- this.form.status = '1';
- addNEWS(this.form).then(response => {
- this.$modal.msgSuccess('新增成功');
- this.$layer.close(this.layerid);
- this.$parent.getList();
- });
- }
- }
- });
- }
- }
- };
- </script>
|