|
@@ -0,0 +1,159 @@
|
|
|
+<template>
|
|
|
+ <div id="index">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-col :span="24" class="add" style="text-align:right;padding: 10px 20px;">
|
|
|
+ <el-button size="mini" type="primary" @click="toAdd" icon="el-icon-plus">添加{{ theme }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="main">
|
|
|
+ <data-table :fields="fields" :opera="opera" @edit="toEdit" :data="list" :total="total" @delete="toDelete" @query="search"></data-table>
|
|
|
+ </el-col>
|
|
|
+ <el-dialog :title="theme" width="60%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
|
|
|
+ <el-form ref="form" :rules="rules" :model="form" label-width="80px">
|
|
|
+ <el-form-item label="信息标题" prop="title">
|
|
|
+ <el-input v-model="form.title" placeholder="请输入信息标题"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="来源">
|
|
|
+ <el-input v-model="form.orgin" placeholder="请输入信息来源"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="标题简介">
|
|
|
+ <el-input type="textarea" v-model="form.titlejj" placeholder="请输入标题简介"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="信息图片" prop="picture">
|
|
|
+ <upload :limit="1" :data="form.picture" type="picture" :url="'/files/imgpath/upload'" @upload="uploadSuccess"></upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="视频" prop="filepath">
|
|
|
+ <upload :limit="1" :data="form.filepath" type="filepath" listType="" :url="'/files/imgpath/upload'" @upload="uploadSuccess"></upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="信息内容">
|
|
|
+ <wang-editor v-model="form.content" placeholder="请输入信息内容"></wang-editor>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="发布时间">
|
|
|
+ <el-col :span="11">
|
|
|
+ <el-date-picker type="date" placeholder="发布时间" value-format="yyyy-MM-dd" v-model="form.publish_time" style="width: 100%;"></el-date-picker>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="onSubmit()">提交</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import WangEditor from '@/components/wang-editor.vue';
|
|
|
+import upload from '@/components/upload.vue';
|
|
|
+import dataTable from '@/components/data-table.vue';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: newsguidance } = createNamespacedHelpers('newsguidance');
|
|
|
+export default {
|
|
|
+ name: 'index',
|
|
|
+ props: {},
|
|
|
+ components: {
|
|
|
+ dataTable,
|
|
|
+ WangEditor,
|
|
|
+ upload,
|
|
|
+ },
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ theme: '嘉宾访谈',
|
|
|
+ opera: [
|
|
|
+ {
|
|
|
+ label: '修改',
|
|
|
+ icon: 'el-icon-edit',
|
|
|
+ method: 'edit',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '删除',
|
|
|
+ icon: 'el-icon-delete',
|
|
|
+ method: 'delete',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ fields: [
|
|
|
+ { label: '信息标题', prop: 'title', filter: 'input' },
|
|
|
+ { label: '来源', prop: 'orgin' },
|
|
|
+ { label: '标题简介', prop: 'titlejj' },
|
|
|
+ { label: '发布时间', prop: 'publish_time' },
|
|
|
+ ],
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ dialog: false,
|
|
|
+ // 添加信息
|
|
|
+ form: {},
|
|
|
+ rules: {},
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...newsguidance(['query', 'create', 'update', 'delete']),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ let arr = await this.query({ skip, limit, ...info });
|
|
|
+ this.$set(this, `list`, arr.data);
|
|
|
+ this.$set(this, `total`, arr.total);
|
|
|
+ },
|
|
|
+ toEdit({ data }) {
|
|
|
+ this.dialog = true;
|
|
|
+ this.$set(this, `form`, data);
|
|
|
+ },
|
|
|
+ async toDelete({ data }) {
|
|
|
+ let res = await this.delete(data.id);
|
|
|
+ this.$message({
|
|
|
+ message: '刪除信息成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ // 添加
|
|
|
+ toAdd() {
|
|
|
+ this.dialog = true;
|
|
|
+ this.form = {};
|
|
|
+ },
|
|
|
+ // 提交
|
|
|
+ async onSubmit() {
|
|
|
+ if (this.form.id) {
|
|
|
+ let res = await this.update(this.form);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({
|
|
|
+ message: '修改信息成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.handleClose();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let res = await this.create(this.form);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({
|
|
|
+ message: '添加信息成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.handleClose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 取消
|
|
|
+ handleClose() {
|
|
|
+ this.form = {};
|
|
|
+ this.dialog = false;
|
|
|
+ },
|
|
|
+ uploadSuccess({ type, data }) {
|
|
|
+ this.$set(this.form, `${type}`, data.uri);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ pageTitle() {
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|