guhongwei před 4 roky
rodič
revize
18ca3c9674

+ 3 - 0
src/store/index.js

@@ -31,6 +31,8 @@ import channel from './live/channel';
 import channelVideo from './live/channelVideo';
 import flower from './live/flower';
 import imgtxtdock from './live/imgtxtdock';
+// 培训问诊
+import trainlive from './live/trainlive';
 // 专家
 import expertsuser from './market/exportuser';
 // 产品
@@ -91,6 +93,7 @@ export default new Vuex.Store({
     channelVideo,
     flower,
     imgtxtdock,
+    trainlive,
     // 专家
     expertsuser,
     // 产品

+ 41 - 0
src/store/live/trainlive.js

@@ -0,0 +1,41 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  trainliveInfo: `/api/live/trainlive`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = undefined, ...info } = {}) {
+    const res = await this.$axios.$get(api.trainliveInfo, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.trainliveInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.trainliveInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.trainliveInfo}/update/${id}`, {
+      ...info,
+    });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.trainliveInfo}/${payload}`);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 11 - 11
src/views/superAdminCenter/channel/index.vue

@@ -97,6 +97,11 @@ export default {
       this.$set(this, `list`, res.data);
       this.$set(this, `total`, res.total);
     },
+    // 修改
+    toEdit({ data }) {
+      this.$set(this, `form`, data);
+      this.display = 'detail';
+    },
     // 提交
     async toSave({ data }) {
       if (data.id) {
@@ -122,17 +127,6 @@ export default {
         }
       }
     },
-    // 修改
-    toEdit({ data }) {
-      this.$set(this, `form`, data);
-      this.display = 'detail';
-    },
-    // 返回
-    back() {
-      this.form = {};
-      this.display = 'list';
-      this.search();
-    },
     // 删除
     toDelete({ data }) {
       this.$confirm('您确定要删除此信息吗?', '提示', {
@@ -152,6 +146,12 @@ export default {
         })
         .catch(() => {});
     },
+    // 返回
+    back() {
+      this.form = {};
+      this.display = 'list';
+      this.search();
+    },
     // 查询字典表
     async searchtype() {
       // 类型

+ 4 - 2
src/views/superAdminCenter/index.vue

@@ -55,6 +55,7 @@ import heads from '@/layout/userCenter/heads.vue';
 import foot from '@/layout/live/foot.vue';
 import scienceNews from './scienceNews/index.vue';
 import patent from './patent/index.vue';
+import trainlive from './trainlive/index.vue';
 
 import { mapState, createNamespacedHelpers } from 'vuex';
 export default {
@@ -88,6 +89,7 @@ export default {
     monitor,
     scienceNews,
     patent,
+    trainlive,
   },
   data: function() {
     return {
@@ -99,8 +101,8 @@ export default {
   methods: {
     setRight(menu) {
       let { name, cpt } = menu;
-      this.$set(this, `topTitle`, name);
-      this.$set(this, `cpt`, cpt);
+      this.$set(this, `topTitle`, '培训问诊管理');
+      this.$set(this, `cpt`, 'trainlive');
     },
   },
   computed: {

+ 209 - 0
src/views/superAdminCenter/trainlive/index.vue

@@ -0,0 +1,209 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main">
+        <span v-if="display == 'list'">
+          <el-col :span="24" class="top">
+            <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>
+        </span>
+        <span v-else>
+          <el-col :span="24" class="top">
+            <el-button type="primary" size="mini" @click="back">返回</el-button>
+          </el-col>
+          <el-col :span="24" class="detail">
+            <data-form :data="form" :fields="formFields" @save="toSave" :rules="rules">
+              <template #custom="{ item, form }">
+                <template v-if="item.model == 'create_date'">
+                  <el-date-picker
+                    v-model="form.create_date"
+                    type="datetime"
+                    placeholder="请选择"
+                    format="yyyy-MM-dd HH:mm:ss"
+                    value-format="yyyy-MM-dd HH:mm:ss"
+                  >
+                  </el-date-picker>
+                </template>
+                <template v-else-if="item.model == 'province'">
+                  <el-select v-model="form.province" placeholder="请选择" filterable clearable @change="changePro">
+                    <el-option v-for="(i, index) in provinceList" :key="index" :label="i.name" :value="i.code"></el-option>
+                  </el-select>
+                </template>
+                <template v-else-if="item.model == 'place'">
+                  <el-select v-model="form.place" placeholder="请选择" filterable clearable>
+                    <el-option v-for="(i, index) in placeList" :key="index" :label="i.name" :value="i.code"></el-option>
+                  </el-select>
+                </template>
+              </template>
+            </data-form>
+          </el-col>
+        </span>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import dataForm from '@/components/form.vue';
+import dataTable from '@/components/data-table.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: place } = createNamespacedHelpers('place');
+const { mapActions: trainlive } = createNamespacedHelpers('trainlive');
+export default {
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  name: 'index',
+  props: {},
+  components: {
+    dataTable,
+    dataForm,
+  },
+  data: function() {
+    return {
+      display: 'list',
+      opera: [
+        {
+          label: '编辑',
+          method: 'edit',
+        },
+        {
+          label: '删除',
+          method: 'delete',
+        },
+      ],
+      fields: [
+        { label: '房间号', prop: 'room_id' },
+        { label: '标题', prop: 'title' },
+        { label: '开始时间', prop: 'create_date' },
+        { label: '负责人', prop: 'user' },
+        { label: '联系电话', prop: 'phone' },
+      ],
+      list: [],
+      total: 0,
+      // 添加
+      formFields: [
+        { label: '标题', model: 'title' },
+        { label: '开始时间', model: 'create_date', custom: true },
+        { label: '省份', model: 'province', custom: true },
+        { label: '市区', model: 'place', custom: true },
+        { label: '主办方', model: 'sponsor' },
+        { label: '负责人', model: 'user' },
+        { label: '联系电话', model: 'phone' },
+        { label: '信息简介', model: 'brief', type: 'textarea' },
+      ],
+      form: {},
+      rules: {},
+      // 省份
+      provinceList: [],
+      // 市区
+      placeList: [],
+    };
+  },
+  async created() {
+    await this.search();
+    await this.searchType();
+  },
+  methods: {
+    ...place({ palcequery: 'query', palcefetch: 'fetch' }),
+    ...trainlive(['query', 'fetch', 'create', 'update', '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);
+      }
+    },
+    // 添加
+    add() {
+      this.display = true;
+    },
+    // 提交
+    async toSave({ data }) {
+      if (data.id) {
+        let res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '修改信息成功',
+            type: 'success',
+          });
+          this.back();
+        }
+      } else {
+        let res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$checkRes(res, '创建成功', '创建失败');
+          this.$alert(`房间号:${res.data.room_id}` + `密码:${res.data.password};`, '成功', {
+            dangerouslyUseHTMLString: true,
+            confirmButtonText: '确定',
+            type: 'success',
+            center: true,
+            callback: action => {
+              this.back();
+            },
+          });
+        }
+      }
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$set(this, `form`, data);
+      this.display = 'detail';
+    },
+    // 删除
+    async toDelete({ data }) {
+      this.$confirm('您确定要删除此信息吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      })
+        .then(async () => {
+          let res = await this.delete(data.id);
+          if (this.$checkRes(res)) {
+            this.$message({
+              message: '删除信息成功',
+              type: 'success',
+            });
+            this.search();
+          }
+        })
+        .catch(() => {});
+    },
+    // 返回
+    back() {
+      this.form = {};
+      this.display = 'list';
+      this.search();
+    },
+    // 查询省市
+    async searchType() {
+      let res = await this.palcequery({ level: 1 });
+      this.$set(this, `provinceList`, res.data);
+    },
+    // 选择市
+    async changePro(value) {
+      let parent = value;
+      let res = await this.palcequery({ level: 2, parent });
+      this.$set(this, `placeList`, res.data);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  watch: {},
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  padding: 0 16px 0 0;
+  .top {
+    text-align: right;
+    padding: 0 0 10px 0;
+  }
+}
+</style>