Browse Source

新闻中心发布管理

wuhongyuq 5 năm trước cách đây
mục cha
commit
06339e9e79

+ 2 - 0
src/layout/layout-part/menus.vue

@@ -46,6 +46,8 @@
           <el-menu-item index="/otheruser/index">其他用户</el-menu-item>
         </el-menu-item-group>
       </el-submenu>
+
+      <el-menu-item index="/news/index"> <i class="el-icon-s-grid"></i>新闻中心内容管理</el-menu-item>
       <el-menu-item index="/companyup/index"> <i class="el-icon-s-grid"></i>企业信息管理</el-menu-item>
       <el-menu-item index="/companyidentify/index"> <i class="el-icon-s-grid"></i>企业认证管理</el-menu-item>
       <el-menu-item index="/character/index"> <i class="el-icon-s-grid"></i>角色管理</el-menu-item>

+ 91 - 0
src/layout/news/newsForm.vue

@@ -0,0 +1,91 @@
+<template>
+  <div id="otheruserForm">
+    <el-row>
+      <el-col :span="24" class="form">
+        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+          <el-form-item label="标题" prop="name">
+            <el-input v-model="ruleForm.title" placeholder="请输入标题"></el-input>
+          </el-form-item>
+          <el-form-item label="图片" prop="image">
+            <upload :limit="1" :data="ruleForm.image" type="image" :url="`/files/teacher/upload`" @upload="uploadSuccess"></upload>
+          </el-form-item>
+          <el-form-item label="来源" prop="source">
+            <el-input v-model="ruleForm.source" placeholder="请输入来源"></el-input>
+          </el-form-item>
+          <el-form-item label="发布日期" prop="publish_time">
+            <el-input v-model="ruleForm.publish_time" placeholder="请输入发布日期"></el-input>
+          </el-form-item>
+          <el-form-item label="发布状态" prop="type">
+            <el-select v-model="ruleForm.type" placeholder="请选择发布状态">
+              <el-option label="未发布" value="0"></el-option>
+              <el-option label="发布" value="1"></el-option>
+              <el-option label="下架" value="2"></el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item label="简介">
+            <!-- <span v-if="toDisplay()"> -->
+            <wang-editor v-model="ruleForm.description" placeholder="请输入简介"></wang-editor>
+            <!-- </span> -->
+          </el-form-item>
+          <el-form-item>
+            <el-button size="small" @click="resetForm('ruleForm')">取消</el-button>
+            <el-button type="primary" size="small" @click="submitForm('ruleForm')">提交</el-button>
+          </el-form-item>
+        </el-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import WangEditor from '@/components/wang-editor.vue';
+import upload from '@/components/upload.vue';
+export default {
+  name: 'otheruserForm',
+  props: {
+    ruleForm: null,
+  },
+  components: {
+    WangEditor, //富文本
+    upload, //图片
+  },
+  data: () => ({
+    rules: {
+      title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
+      source: [{ required: true, message: '请输入来源', trigger: 'blur' }],
+      publish_time: [{ required: true, message: '请输入发布日期', trigger: 'blur' }],
+      description: [{ required: true, message: '请输入简介', trigger: 'blur' }],
+      type: [{ required: true, message: '请选择发布状态', trigger: 'change' }],
+    },
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    submitForm() {
+      this.$emit('submitForm', { data: this.ruleForm });
+    },
+    resetForm() {
+      this.$emit('resetForm');
+    },
+    uploadSuccess({ type, data }) {
+      if (type !== 'logo') {
+        let arr = _.get(this.ruleForm, type);
+        if (arr !== undefined) {
+          this.ruleForm[type].push({ name: data.name, uri: data.uri });
+        } else {
+          let newArr = [{ name: data.name, uri: data.uri }];
+          this.$set(this.ruleForm, `${type}`, newArr);
+        }
+      } else {
+        this.$set(this.ruleForm, `${type}`, data.uri);
+      }
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.form {
+  padding: 0 200px 0 0;
+}
+</style>

+ 82 - 0
src/layout/news/newsList.vue

@@ -0,0 +1,82 @@
+<template>
+  <div id="otheruserList">
+    <el-row>
+      <el-col :span="24">
+        <el-table ref="debtTable" :data="debtTable" style="width: 100%" border>
+          <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
+          <el-table-column property="title" label="标题" align="center"> </el-table-column>
+          <el-table-column label="图片" align="center">
+            <template slot-scope="scope">
+              <span style="margin-left: 10px"> <el-image :src="scope.row.image"></el-image></span>
+            </template>
+          </el-table-column>
+          <el-table-column property="source" label="来源" align="center"> </el-table-column>
+          <el-table-column property="publish_time" label="发布日期" align="center"> </el-table-column>
+          <el-table-column property="" label="发布状态" align="center"> </el-table-column>
+
+          <el-table-column label="状态" align="center">
+            <template slot-scope="scope">
+              <span style="margin-left: 10px">{{ scope.row.publish_state === '0' ? '未发布' : scope.row.publish_state === '1' ? '已发布' : '停用' }}</span>
+            </template>
+          </el-table-column>
+
+          <el-table-column property="description" label="内容" align="center"> </el-table-column>
+
+          <el-table-column fixed="right" label="操作" align="center">
+            <template slot-scope="scope">
+              <el-button @click="$router.push({ path: '/news/detail', query: { id: scope.row.id } })" type="text"><i class="el-icon-edit"></i></el-button>
+              <el-button @click.prevent="deleteRow(scope.row.id)" type="text"><i class="el-icon-delete"></i></el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <el-row class="page">
+          <el-pagination
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+            :current-page="currentPage"
+            layout="total, prev, pager, next, jumper"
+            :total="total"
+          >
+          </el-pagination>
+        </el-row>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'otheruserList',
+  props: {
+    debtTable: null,
+    total: null,
+  },
+  components: {},
+  data: () => ({
+    currentPage: 1,
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    deleteRow(id) {
+      this.$emit('deleteRow', id);
+    },
+    clickRest(id) {
+      this.$emit('clickRest', id);
+    },
+    handleSizeChange(val) {
+      console.log(`每页 ${val} 条`);
+    },
+    handleCurrentChange(val) {
+      console.log(`当前页: ${val}`);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.page {
+  text-align: center;
+  padding: 15px 0;
+}
+</style>

+ 10 - 0
src/router/index.js

@@ -27,6 +27,16 @@ const routes = [
     path: '/finance/index',
     component: () => import('../views/finance/index.vue'),
   },
+  //新闻中心
+  {
+    path: '/news/index',
+    component: () => import('../views/news/index.vue'),
+  },
+  //新闻中心详情
+  {
+    path: '/news/detail',
+    component: () => import('../views/news/detail.vue'),
+  },
 
   // 金融数字超市 - 股权产品
   {

+ 108 - 0
src/views/news/detail.vue

@@ -0,0 +1,108 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="debt">
+        <el-col :span="24" class="top">
+          <topInfo :topTitle="topTitle" :display="display"></topInfo>
+        </el-col>
+        <el-col :span="24" class="main">
+          <el-col :span="24" class="back">
+            <detailTop @goBack="goBack"></detailTop>
+          </el-col>
+          <el-col :span="24" class="info">
+            <newsForm :ruleForm="ruleForm" @submitForm="submitForm" @resetForm="resetForm"></newsForm>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/common/topInfo.vue';
+import detailTop from '@/layout/common/detailTop.vue';
+import newsForm from '@/layout/news/newsForm.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+
+export default {
+  name: 'detail',
+  props: {},
+  components: {
+    topInfo, //头部导航
+    detailTop, //头部返回
+    newsForm, //添加其他用户
+  },
+  data: () => ({
+    display: 'none',
+    topTitle: '新闻中心内容管理',
+    ruleForm: {},
+  }),
+  created() {
+    this.searchInfo();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  methods: {
+    // ...otheruser(['query', 'fetch', 'update', 'create']),
+    // ...character({ charquery: 'query', charFetch: 'fetch' }),
+    async searchInfo() {
+      // if (this.id) {
+      //   const res = await this.fetch(this.id);
+      //   this.$set(this, `ruleForm`, res.data);
+      // }
+    },
+
+    // 提交
+    async submitForm({ data }) {
+      // let res;
+      // if (this.id) {
+      //   res = await this.update(data);
+      //   if (res.errcode === 0) {
+      //     this.$message({
+      //       message: '信息修改成功',
+      //       type: 'success',
+      //     });
+      //   }
+      // } else {
+      //   res = await this.create(data);
+      //   if (res.errcode === 0) {
+      //     this.$message({
+      //       message: '信息创建成功',
+      //       type: 'success',
+      //     });
+      //   }
+      // }
+      // if (this.$checkRes(res)) this.resetForm();
+      // console.log(res.data);
+    },
+    // 取消
+    resetForm() {
+      this.$router.push({ path: '/news/index' });
+    },
+    // 返回
+    goBack() {
+      this.$router.go(-1);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.debt {
+  padding: 20px;
+}
+.top {
+  border-bottom: 1px solid #ccc;
+}
+.main {
+  border-radius: 10px;
+  margin: 20px 0 0 0;
+  box-shadow: 0 0 3px #666;
+}
+.main .back {
+  padding: 10px 0 10px 15px;
+}
+</style>

+ 80 - 0
src/views/news/index.vue

@@ -0,0 +1,80 @@
+<template>
+  <div id="index">
+    <el-col :span="24" class="debt">
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle" :display="display" @clickBtn="clickBtn"></topInfo>
+      </el-col>
+      <el-col :span="24" class="search">
+        <searchInfo></searchInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <newsList :debtTable="debtTable" :total="total" @deleteRow="deleteRow" @clickRest="clickRest"></newsList>
+      </el-col>
+    </el-col>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/common/topInfo.vue';
+import searchInfo from '@/layout/common/searchInfo.vue';
+import newsList from '@/layout/news/newsList.vue';
+// import { createNamespacedHelpers, mapGetters } from 'vuex';
+
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    topInfo, //头部导航
+    searchInfo, //搜素
+    newsList, //其他用户列表
+  },
+  data: () => ({
+    topTitle: '新闻中心内容管理',
+    display: 'block',
+    debtTable: [
+      {
+        image: require('@/assets/logo.png'),
+        title: 'title',
+        issuing_organ: '科技厅',
+        score: '1',
+        subject_classification: '123',
+        issued_number: '131',
+        publish_time: '21:12',
+        publish_state: '1',
+      },
+    ],
+    total: 1,
+  }),
+  created() {
+    // this.searchInfo();
+  },
+  computed: {},
+  methods: {
+    // ...otheruser(['query', 'delete', 'update']),
+    // async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
+    //   const res = await this.query({ skip, limit, ...info });
+    //   this.$set(this, `debtTable`, res.data);
+    //   this.$set(this, `total`, res.total);
+    // },
+    // 添加
+    clickBtn() {
+      this.$router.push({ path: '/news/detail' });
+    },
+    async clickRest() {},
+    async deleteRow(id) {
+      // const res = await this.delete(id);
+      // this.$checkRes(res, '删除成功', '删除失败');
+      // this.searchInfo();
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.debt {
+  padding: 20px;
+}
+.top {
+  border-bottom: 1px solid #ccc;
+}
+</style>