guhongwei 5 lat temu
rodzic
commit
a0df8b83a1

+ 3 - 2
src/components/upload.vue

@@ -4,14 +4,14 @@
       v-if="url"
       ref="upload"
       :action="url"
-      list-type="picture-card"
+      :list-type="listType"
       :file-list="fileList"
       :limit="limit"
       :on-exceed="outLimit"
       :on-preview="handlePictureCardPreview"
       :before-remove="handleRemove"
       :on-success="onSuccess"
-      accept=".jpg,.jpeg,.png,.bmp,.gif,.svg"
+      accept=".jpg,.jpeg,.png,.bmp,.gif,.svg,.mp4"
     >
       <template>
         <i class="el-icon-plus"></i>
@@ -31,6 +31,7 @@ export default {
     limit: { type: Number },
     data: { type: null },
     type: { type: String },
+    listType: { type: String, default: 'picture-card' },
   },
   components: {},
   data: () => ({

+ 75 - 0
src/layout/technical/column.vue

@@ -0,0 +1,75 @@
+<template>
+  <div id="column">
+    <el-row>
+      <el-col :span="24" class="info">
+        <el-col :span="24" class="top">
+          <el-col :span="12" class="topTitle">
+            <span>栏目列表</span>
+          </el-col>
+          <el-col :span="12" class="topAdd">
+            <el-button type="primary" size="mini" @click="addData()"><i class="el-icon-plus"></i></el-button>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="list">
+          <template>
+            <el-table :data="columnInfo" style="width: 100%">
+              <el-table-column label="栏目名称" align="center">
+                <template slot-scope="scoped">
+                  <el-tooltip effect="dark" content="点击查询栏目" placement="left">
+                    <el-col :span="24" @click.native="handleClick(scoped.row)">{{ scoped.row.name }}</el-col>
+                  </el-tooltip>
+                </template>
+              </el-table-column>
+              <el-table-column label="操作" align="center">
+                <template slot-scope="scoped">
+                  <el-button type="text" size="small" @click="$router.push({ path: '/technical/columnDetail', query: { id: scoped.row.id } })"
+                    ><i class="el-icon-edit"></i
+                  ></el-button>
+                  <el-button type="text" size="small" @click="handleDelete(scoped.row)"><i class="el-icon-delete"></i></el-button>
+                </template>
+              </el-table-column>
+            </el-table>
+          </template>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'column',
+  props: {
+    columnInfo: null,
+  },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    addData() {
+      this.$router.push({ path: '/technical/columnDetail' });
+    },
+    handleDelete(item) {
+      this.$emit('delete', item);
+    },
+    handleClick(row) {
+      this.$emit('list', { data: row });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  padding: 15px 0;
+  border-bottom: 1px solid #cccc;
+}
+.top .topTitle {
+  padding: 0 10px;
+}
+.top .topAdd {
+  padding: 0 10px 0 0;
+  text-align: right;
+}
+</style>

+ 68 - 0
src/layout/technical/columnDetail.vue

@@ -0,0 +1,68 @@
+<template>
+  <div id="columnDetail">
+    <el-row>
+      <el-col :span="24">
+        <el-col :span="24" class="top">
+          <el-col :span="12" class="topTitle">
+            添加栏目
+          </el-col>
+          <el-col :span="12" class="topBtn">
+            <el-button type="primary" size="mini" @click="returnBtn()">返回</el-button>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="messgae">
+          <el-form ref="form" :model="form" label-width="80px">
+            <el-form-item label="栏目名称">
+              <el-input v-model="form.name"></el-input>
+            </el-form-item>
+            <el-form-item label="所在位置">
+              <el-select v-model="form.site" placeholder="请选择所在位置">
+                <el-option label="专题研讨" value="ztyt"></el-option>
+                <el-option label="专家问诊" value="zjwz"></el-option>
+                <el-option label="行业研究" value="hyyj"></el-option>
+                <el-option label="教育培训" value="jypx"></el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" @click="onSubmit()">提交</el-button>
+            </el-form-item>
+          </el-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'columnDetail',
+  props: {
+    form: null,
+  },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    onSubmit() {
+      this.$emit('submitDate', { data: this.form, id: this.form.id });
+    },
+    returnBtn() {
+      this.$router.push({ path: '/technical/index' });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  padding: 15px 0;
+}
+.top .topTitle {
+  text-align: left;
+}
+.top .topBtn {
+  text-align: right;
+  padding: 0 5px;
+}
+</style>

+ 87 - 0
src/layout/technical/messageDetail.vue

@@ -0,0 +1,87 @@
+<template>
+  <div id="messageDetail">
+    <el-row v-if="loading">
+      <el-col :span="24">
+        <el-col :span="24" class="topBtn">
+          <el-button type="primary" size="mini" @click="returnBtn()">返回</el-button>
+        </el-col>
+      </el-col>
+      <el-col>
+        <el-col :span="24" class="messgae">
+          <el-form ref="form" :model="form" label-width="80px">
+            <el-form-item label="信息标题">
+              <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="所属栏目" placeholder="请选择所属栏目">
+              <el-select v-model="form.column_id" filterable @change="selectChild">
+                <el-option v-for="(item, index) in columnList" :key="index" :value="item.id" :label="item.name"></el-option>
+              </el-select>
+            </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>
+              <el-button type="primary" @click="onSubmit()">提交</el-button>
+            </el-form-item>
+          </el-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import WangEditor from '@/components/wang-editor.vue';
+import upload from '@/components/upload.vue';
+export default {
+  name: 'messageDetail',
+  props: {
+    form: null,
+    columnList: null,
+    loading: null,
+  },
+  components: {
+    WangEditor,
+    upload,
+  },
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    returnBtn() {
+      this.$router.push({ path: '/technical/index' });
+    },
+    onSubmit() {
+      this.$emit('submitDate', { data: this.form, id: this.form.id });
+    },
+    selectChild(column_id) {
+      let res = this.columnList.filter(fil => fil.id === column_id);
+      if (res.length > 0) {
+        this.$set(this.form, `column_name`, res[0].name);
+      }
+      this.$forceUpdate();
+    },
+    uploadSuccess({ type, data }) {
+      console.log(type, data);
+
+      this.$set(this.form, `${type}`, data.uri);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.topBtn {
+  text-align: right;
+  padding: 15px 5px;
+}
+</style>

+ 90 - 0
src/layout/technical/messageInfo.vue

@@ -0,0 +1,90 @@
+<template>
+  <div id="messageInfo">
+    <el-row>
+      <el-col :span="24" class="info">
+        <el-col :span="24" class="top">
+          <el-col :span="12" class="topTitle">
+            <span>信息列表</span>
+          </el-col>
+          <el-col :span="12" class="topAdd">
+            <el-button type="primary" size="mini" @click="addData()"><i class="el-icon-plus"></i></el-button>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="list">
+          <template>
+            <el-table :data="message" style="width: 100%">
+              <el-table-column prop="title" label="标题" align="center"> </el-table-column>
+              <el-table-column prop="column_name" label="所属栏目" align="center"> </el-table-column>
+              <el-table-column label="操作" align="center">
+                <template slot-scope="scope">
+                  <el-button type="text" size="small" @click="$router.push({ path: '/technical/messageInfoDetail', query: { id: scope.row.id } })"
+                    ><i class="el-icon-edit"></i
+                  ></el-button>
+                  <el-button type="text" size="small" @click="handleDelete(scope.row)"><i class="el-icon-delete"></i></el-button>
+                </template>
+              </el-table-column>
+            </el-table>
+            <el-col :span="24" class="page">
+              <el-pagination
+                @size-change="handleSizeChange"
+                @current-change="handleCurrentChange"
+                :current-page="currentPage"
+                layout="total, prev, pager, next, jumper"
+                :total="total"
+              >
+              </el-pagination>
+            </el-col>
+          </template>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'messageInfo',
+  props: {
+    message: null,
+    total: null,
+  },
+  components: {},
+  data: () => ({
+    currentPage: 1,
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    handleSizeChange(val) {
+      console.log(`每页 ${val} 条`);
+    },
+    handleCurrentChange(val) {
+      console.log(`当前页: ${val}`);
+    },
+    addData() {
+      this.$router.push({ path: '/technical/messageInfoDetail' });
+    },
+    handleDelete(item) {
+      this.$emit('delete', item);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  padding: 15px 0;
+  border-bottom: 1px solid #cccc;
+}
+.top .topTitle {
+  padding: 0 10px;
+}
+.top .topAdd {
+  padding: 0 10px 0 0;
+  text-align: right;
+}
+.page {
+  padding: 20px 0;
+  text-align: center;
+}
+</style>

+ 10 - 0
src/router/index.js

@@ -262,6 +262,16 @@ const routes = [
     path: '/technical/index',
     component: () => import('../views/technical/index.vue'),
   },
+  // 技术培训-栏目列表
+  {
+    path: '/technical/columnDetail',
+    component: () => import('../views/technical/columnDetail.vue'),
+  },
+  // 技术培训-信息列表
+  {
+    path: '/technical/messageInfoDetail',
+    component: () => import('../views/technical/messageInfoDetail.vue'),
+  },
 ];
 
 const router = new VueRouter({

+ 4 - 1
src/store/index.js

@@ -10,7 +10,8 @@ import recordColumn from './recordColumn';
 import recordNews from './recordNews';
 import serveColumn from './serveColumn';
 import serveNews from './serveNews';
-
+import liveTechnicalColumn from './liveTechnicalColumn';
+import liveTechnicalNews from './liveTechnicalNews';
 import talentColumn from './talentColumn';
 import talentExperts from './talentExperts';
 import talentInformation from './talentInformation';
@@ -52,6 +53,8 @@ export default new Vuex.Store({
     recordNews,
     serveColumn,
     serveNews,
+    liveTechnicalColumn,
+    liveTechnicalNews,
     talentColumn,
     talentExperts,
     talentInformation,

+ 42 - 0
src/store/liveTechnicalColumn.js

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

+ 43 - 0
src/store/liveTechnicalNews.js

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

+ 76 - 0
src/views/technical/columnDetail.vue

@@ -0,0 +1,76 @@
+<template>
+  <div id="columnDetail">
+    <el-row>
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle"></topInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <column :form="form" @submitDate="onSubmit"></column>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import column from '@/layout/technical/columnDetail.vue';
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('liveTechnicalColumn');
+export default {
+  name: 'columnDetail',
+  props: {},
+  components: {
+    column,
+    topInfo,
+  },
+  data: () => ({
+    topTitle: '添加栏目',
+    form: {},
+  }),
+  created() {
+    this.search();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  methods: {
+    ...mapActions(['fetch', 'create', 'update']),
+    async search() {
+      if (this.$route.query.id) {
+        const res = await this.fetch(this.id);
+        this.$set(this, `form`, res.data);
+      }
+    },
+    async onSubmit(form) {
+      let data = this.form;
+      console.log(data);
+      let res;
+      let msg;
+      if (data.id) {
+        res = await this.update(data);
+        msg = `${this.keyWord}修改成功`;
+      } else {
+        res = await this.create(data);
+        msg = `${this.keyWord}添加成功`;
+      }
+      if (this.$checkRes(res, msg)) this.$router.push({ path: '/technical/index' });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  padding: 20px;
+  margin: 10px 20px;
+  border: 1px solid #ccc;
+  width: 96%;
+}
+</style>

+ 71 - 4
src/views/technical/index.vue

@@ -5,7 +5,12 @@
         <topInfo :topTitle="topTitle"></topInfo>
       </el-col>
       <el-col :span="24" class="main">
-        主体
+        <el-col :span="7" class="column">
+          <column :columnInfo="columnInfo" @delete="deleteData" @list="handleList"></column>
+        </el-col>
+        <el-col :span="17" class="message">
+          <messageInfo :message="message" :total="total" @delete="deleteMess"></messageInfo>
+        </el-col>
       </el-col>
     </el-row>
   </div>
@@ -13,19 +18,81 @@
 
 <script>
 import topInfo from '@/layout/public/top.vue';
+import column from '@/layout/technical/column.vue';
+import messageInfo from '@/layout/technical/messageInfo.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: liveTechnicalColumn } = createNamespacedHelpers('liveTechnicalColumn');
+const { mapActions: liveTechnicalNews } = createNamespacedHelpers('liveTechnicalNews');
 export default {
   name: 'index',
   props: {},
   components: {
     topInfo, //头部信息
+    column, //栏目列表
+    messageInfo, //信息列表
   },
   data: () => ({
     topTitle: '技术培训',
+    columnInfo: [],
+    message: [],
+    total: 0,
+    leftId: null,
   }),
-  created() {},
+  created() {
+    this.search();
+  },
   computed: {},
-  methods: {},
+  methods: {
+    ...liveTechnicalColumn(['query', 'delete', 'fetch']),
+    ...liveTechnicalNews({ queryList: 'query', deleteList: 'delete' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `columnInfo`, res.data);
+      }
+    },
+    async deleteData(item) {
+      const res = await this.delete(item.id);
+      this.$checkRes(res, '删除成功', '删除失败');
+      this.search();
+    },
+    handleList({ data }) {
+      this.$set(this, `leftId`, data.id);
+      this.searchRight();
+    },
+    async searchRight({ skip = 0, limit = 10, column_id } = {}) {
+      const res = await this.queryList({ skip, limit, column_id: this.leftId });
+      for (const val of res.data) {
+        const result = await this.fetch(val.column_id);
+        val.column_name = result.data.name;
+      }
+      this.$set(this, `message`, res.data);
+      this.$set(this, `total`, res.total);
+    },
+    async deleteMess(item) {
+      const res = await this.deleteList(item.id);
+      this.$checkRes(res, '删除成功', '删除失败');
+      this.search();
+    },
+  },
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.main {
+  padding: 20px;
+  margin: 10px 20px;
+  border: 1px solid #ccc;
+  width: 96%;
+}
+.column {
+  width: 27%;
+  min-height: 500px;
+  border: 1px solid #ccc;
+  margin: 0 20px 0 0;
+}
+.message {
+  border: 1px solid #ccc;
+  min-height: 500px;
+}
+</style>

+ 92 - 0
src/views/technical/messageInfoDetail.vue

@@ -0,0 +1,92 @@
+<template>
+  <div id="messageInfoDetail">
+    <el-row>
+      <el-col :span="24" class="top">
+        <topInfo :topTitle="topTitle"></topInfo>
+      </el-col>
+      <el-col :span="24" class="main">
+        <message :form="form" :columnList="columnList" @submitDate="onSubmit" :loading="loading"></message>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import topInfo from '@/layout/public/top.vue';
+import message from '@/layout/technical/messageDetail.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: liveTechnicalColumn } = createNamespacedHelpers('liveTechnicalColumn');
+const { mapActions: liveTechnicalNews } = createNamespacedHelpers('liveTechnicalNews');
+export default {
+  name: 'messageInfoDetail',
+  props: {},
+  components: {
+    message,
+    topInfo,
+  },
+  data: () => ({
+    topTitle: '添加信息',
+    form: {},
+    columnList: [],
+    loading: true,
+  }),
+  created() {
+    this.search();
+    this.searchColumn();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  methods: {
+    ...liveTechnicalNews(['fetch', 'create', 'update']),
+    ...liveTechnicalColumn({ queryList: 'query' }),
+    async search() {
+      this.loading = false;
+      if (this.$route.query.id) {
+        const res = await this.fetch(this.id);
+        this.$set(this, `form`, res.data);
+      }
+      this.loading = true;
+    },
+    async onSubmit(form) {
+      let data = this.form;
+      console.log(data);
+      let res;
+      let msg;
+      if (data.id) {
+        res = await this.update(data);
+        msg = `${this.keyWord}修改成功`;
+      } else {
+        res = await this.create(data);
+        msg = `${this.keyWord}添加成功`;
+      }
+      if (this.$checkRes(res, msg)) this.$router.push({ path: '/technical/index' });
+    },
+    async searchColumn({ ...info } = {}) {
+      const res = await this.queryList({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `columnList`, res.data);
+      }
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  padding: 0 0 10px 0;
+}
+.main {
+  padding: 20px;
+  margin: 10px 20px;
+  border: 1px solid #ccc;
+  width: 96%;
+}
+</style>