guhongwei 4 gadi atpakaļ
vecāks
revīzija
c22fbe3734
4 mainītis faili ar 234 papildinājumiem un 0 dzēšanām
  1. 11 0
      src/router/index.js
  2. 3 0
      src/store/index.js
  3. 122 0
      src/views/channel/detail.vue
  4. 98 0
      src/views/channel/index.vue

+ 11 - 0
src/router/index.js

@@ -181,6 +181,17 @@ export default new Router({
           component: () => import('../views/train/detail.vue'),
           meta: { title: '培训问诊信息管理' },
         },
+        // 科技频道
+        {
+          path: '/channel',
+          component: () => import('../views/channel/index.vue'),
+          meta: { title: '科技频道' },
+        },
+        {
+          path: '/channel/detail',
+          component: () => import('../views/channel/detail.vue'),
+          meta: { title: '科技频道信息管理' },
+        },
       ],
     },
     {

+ 3 - 0
src/store/index.js

@@ -20,6 +20,8 @@ import product from '@common/src/store/product';
 import dock from '@common/src/store/dock';
 // 培训问诊
 import trainLive from '@common/src/store/trainLive';
+// 科技频道
+import channel from '@common/src/store/channel';
 // 技术新闻
 import column from '@common/src/store/column';
 import news from '@common/src/store/news';
@@ -53,6 +55,7 @@ export default new Vuex.Store({
     product,
     dock,
     trainLive,
+    channel,
     column,
     news,
     roadShow,

+ 122 - 0
src/views/channel/detail.vue

@@ -0,0 +1,122 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="back">
+          <el-button type="primary" size="mini" @click="back">返回</el-button>
+        </el-col>
+        <el-col :span="24" class="detail">
+          <data-form :data="form" :fields="formFields" :rules="rules" @save="toSave">
+            <template #options="{item}">
+              <template v-if="item.model === 'type'">
+                <el-option v-for="(i, index) in typelist" :key="index" :label="i.name" :value="i.id"></el-option>
+              </template>
+            </template>
+          </data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import dataForm from '@common/src/components/frame/form.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: channel } = createNamespacedHelpers('channel');
+const { mapActions: code } = createNamespacedHelpers('code');
+export default {
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  name: 'detail',
+  props: {},
+  components: {
+    dataForm,
+  },
+  data: function() {
+    return {
+      formFields: [
+        { label: '信息类型', model: 'type', type: 'select' },
+        { label: '标题', model: 'title' },
+        { label: '来源', model: 'origin' },
+        { label: '简介', model: 'desc', type: 'textarea' },
+      ],
+      form: {},
+      rules: {},
+      // 类型
+      typelist: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...code({ codeQuery: 'query' }),
+    ...channel(['query', 'fetch', 'create', 'update']),
+    async search() {
+      if (this.id) {
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
+      }
+    },
+    // 提交
+    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.uid;
+        let res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$checkRes(res, '创建成功', '创建失败');
+          this.$alert(`房间号:${res.data.room_id}` + `密码:${res.data.passwd.secret};`, '成功', {
+            dangerouslyUseHTMLString: true,
+            confirmButtonText: '确定',
+            type: 'success',
+            center: true,
+            callback: action => {
+              this.back();
+            },
+          });
+        }
+      }
+    },
+    // 返回
+    back() {
+      this.$router.push({ path: '/channel' });
+    },
+    // 查询类型
+    async searchOther() {
+      let res = await this.codeQuery({ category: '04' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `typelist`, res.data);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  watch: {},
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .back {
+    text-align: right;
+    margin: 0 0 10px 0;
+  }
+}
+</style>

+ 98 - 0
src/views/channel/index.vue

@@ -0,0 +1,98 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="add">
+          <el-button type="primary" size="mini" @click="add">添加</el-button>
+        </el-col>
+        <el-col :span="24" class="list">
+          <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: channel } = createNamespacedHelpers('channel');
+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: 'room_id' },
+        { label: '标题', prop: 'title' },
+        { label: '来源', prop: 'origin' },
+        { label: '发布时间', prop: 'create_time' },
+      ],
+      list: [],
+      total: 0,
+    };
+  },
+  async created() {
+    await this.search();
+  },
+  methods: {
+    ...channel(['query', 'delete']),
+    // 查询列表
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      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: '/channel/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: '/channel/detail' });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  watch: {},
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .add {
+    text-align: right;
+    margin: 0 0 10px 0;
+  }
+}
+</style>