guhongwei 3 سال پیش
والد
کامیت
ce8e937373
4فایلهای تغییر یافته به همراه260 افزوده شده و 0 حذف شده
  1. 11 0
      src/router/index.js
  2. 2 0
      src/store/index.js
  3. 152 0
      src/views/viewPoint/detail.vue
  4. 95 0
      src/views/viewPoint/index.vue

+ 11 - 0
src/router/index.js

@@ -126,6 +126,17 @@ export default new Router({
           component: () => import('../views/universal/detail.vue'),
           meta: { title: '信息管理' },
         },
+        // 智库视点
+        {
+          path: '/viewPoint',
+          component: () => import('../views/viewPoint/index.vue'),
+          meta: { title: '智库视点管理' },
+        },
+        {
+          path: '/viewPoint/detail',
+          component: () => import('../views/viewPoint/detail.vue'),
+          meta: { title: '信息管理' },
+        },
         // 项目路演
         {
           path: '/roadshow',

+ 2 - 0
src/store/index.js

@@ -28,6 +28,7 @@ import channel from '@common/src/store/channel';
 import column from '@common/src/store/column';
 import news from '@common/src/store/news';
 import universal from '@common/src/store/universal';
+import viewPoint from '@common/src/store/viewPoint';
 // 项目路演
 import roadShow from '@common/src/store/roadShow';
 // 嘉宾访谈
@@ -67,6 +68,7 @@ export default new Vuex.Store({
     column,
     news,
     universal,
+    viewPoint,
     roadShow,
     interview,
     dockTranscation,

+ 152 - 0
src/views/viewPoint/detail.vue

@@ -0,0 +1,152 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="top">
+          <el-button type="primary" size="mini" @click="back">返回</el-button>
+        </el-col>
+        <el-col :span="24" class="down" v-loading="loading">
+          <data-form :data="form" :fields="fields" :rules="{}" @save="toSave">
+            <template #custom="{item,form}">
+              <template v-if="item.model == 'picture'">
+                <upload :limit="1" :data="form.picture" type="picture" :url="'/files/picture/upload'" @upload="uploadSuccess" @delete="uploadDelete"></upload>
+              </template>
+              <template v-else-if="item.model == 'video'">
+                <upload
+                  :limit="1"
+                  :data="form.video"
+                  listType=""
+                  type="video"
+                  :url="'/files/video/upload'"
+                  @upload="uploadSuccess"
+                  @delete="uploadDelete"
+                ></upload>
+              </template>
+              <template v-else-if="item.model == 'filepath'">
+                <upload
+                  :limit="1"
+                  :data="form.filepath"
+                  listType=""
+                  type="filepath"
+                  :url="'/files/filepath/upload'"
+                  @upload="uploadSuccess"
+                  @delete="uploadDelete"
+                ></upload>
+              </template>
+              <template v-else-if="item.model == 'is_money'">
+                <el-switch v-model="form.is_money" active-color="#13ce66" inactive-color="#ff4949"> </el-switch>
+              </template>
+              <template v-else-if="item.model == 'money'">
+                <el-input v-model="form.money" placeholder="请输入金额" :disabled="form.is_money == true ? false : true" @keyup.native="number"></el-input>
+              </template>
+            </template>
+          </data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import dataForm from '@common/src/components/frame/form.vue';
+import upload from '@common/src/components/frame/upload.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: mapViewPoint } = createNamespacedHelpers('viewPoint');
+export default {
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  name: 'detail',
+  props: {},
+  components: { dataForm, upload },
+  data: function() {
+    return {
+      fields: [
+        { label: '信息标题', model: 'title' },
+        { label: '发布时间', model: 'publish_time', type: 'date' },
+        { label: '信息来源', model: 'origin' },
+        { label: '信息简介', model: 'brief', type: 'textarea' },
+        { label: '是否收费', model: 'is_money', custom: true },
+        { label: '输入金额(元)', model: 'money', custom: true },
+        { label: '图片文件', model: 'picture', custom: true },
+        { label: '视频文件', model: 'video', custom: true },
+        { label: '附件文件', model: 'filepath', custom: true },
+        { label: '内容', model: 'content', type: 'editor' },
+      ],
+      form: {},
+      loading: false,
+    };
+  },
+  async created() {
+    if (this.id) {
+      await this.search();
+    }
+  },
+  methods: {
+    ...mapViewPoint(['fetch', 'update', 'create']),
+    async search() {
+      this.loading = true;
+      let res = await this.fetch(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `form`, res.data);
+        this.loading = false;
+      }
+    },
+    async toSave({ data }) {
+      if (data.id) {
+        let res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '信息修改成功',
+            type: 'success',
+          });
+          this.back();
+        }
+      } else {
+        data.user_id = this.user.id;
+        let res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '信息创建成功',
+            type: 'success',
+          });
+          this.back();
+        }
+      }
+    },
+
+    // 返回列表
+    back() {
+      this.$router.push({ path: '/viewPoint' });
+    },
+    // 图片上传
+    uploadSuccess({ type, data }) {
+      this.$set(this.form, `${type}`, data.uri);
+    },
+    // 删除图片
+    uploadDelete(data) {
+      this.$set(this.form, `${data.type}`, null);
+    },
+    number() {
+      this.form.money = this.form.money.replace(/[^\.\d]/g, '');
+      this.form.money = this.form.money.replace('.', '');
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  watch: {},
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .top {
+    text-align: right;
+    margin: 0 0 10px 0;
+  }
+}
+</style>

+ 95 - 0
src/views/viewPoint/index.vue

@@ -0,0 +1,95 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="top">
+          <el-button type="primary" size="mini" @click="add">添加</el-button>
+        </el-col>
+        <el-col :span="24" class="down">
+          <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @edit="toEdit" @delete="toDelete"></data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import dataTable from '@common/src/components/frame/filter-page-table.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: mapViewPoint } = createNamespacedHelpers('viewPoint');
+export default {
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  name: 'index',
+  props: {},
+  components: { dataTable },
+  data: function() {
+    return {
+      opera: [
+        {
+          label: '编辑',
+          method: 'edit',
+        },
+        {
+          label: '删除',
+          method: 'delete',
+        },
+      ],
+      fields: [
+        { label: '信息标题', prop: 'title' },
+        { label: '信息来源', prop: 'origin' },
+        { label: '发布时间', prop: 'publish_time' },
+      ],
+      list: [],
+      total: 0,
+    };
+  },
+  async created() {
+    await this.search();
+  },
+  methods: {
+    ...mapViewPoint(['query', 'fetch', 'create', 'update', 'delete']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      info.user_id = this.user.id;
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$router.push({ path: '/viewPoint/detail', query: { id: data.id } });
+    },
+    // 删除
+    async toDelete({ data }) {
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '信息删除成功',
+          type: 'success',
+        });
+        this.search();
+      }
+    },
+    // 添加数据
+    add() {
+      this.$router.push({ path: '/viewPoint/detail' });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  watch: {},
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .top {
+    text-align: right;
+    margin: 0 0 10px 0;
+  }
+}
+</style>