lrf402788946 4 gadi atpakaļ
vecāks
revīzija
cba5448dad

+ 18 - 0
src/router/index.js

@@ -165,6 +165,24 @@ const web = [
         meta: { title: '机构管理' },
         component: () => import('../views/adminCenter/mechanism/detail.vue'),
       },
+      {
+        path: '/adminCenter/online',
+        name: 'admin_online',
+        meta: { title: '线上管理' },
+        component: () => import('../views/adminCenter/online/index.vue'),
+      },
+      {
+        path: '/adminCenter/online/detail',
+        name: 'admin_online_detail',
+        meta: { title: '线上管理' },
+        component: () => import('../views/adminCenter/online/detail.vue'),
+      },
+      {
+        path: '/adminCenter/online/file',
+        name: 'admin_online_file',
+        meta: { title: '线上管理' },
+        component: () => import('../views/adminCenter/online/file.vue'),
+      },
     ],
   },
 ];

+ 4 - 0
src/store/index.js

@@ -10,6 +10,8 @@ import roadShow from '@common/src/store/roadShow';
 import expert from '@common/src/store/expert';
 import organization from '@common/src/store/organization';
 import mechanism from '@common/src/store/mechanism';
+import code from '@common/src/store/code';
+import online from '@common/src/store/online';
 
 Vue.use(Vuex);
 
@@ -26,5 +28,7 @@ export default new Vuex.Store({
     expert,
     organization,
     mechanism,
+    online,
+    code,
   },
 });

+ 123 - 0
src/views/adminCenter/online/detail.vue

@@ -0,0 +1,123 @@
+<template>
+  <div id="detail">
+    <data-form :fields="fields" :data="data" @save="toSave" returns="/adminCenter/online" @filterReturn="filterReturn">
+      <template #options="{ item }">
+        <template v-if="item.model === 'column_name'">
+          <el-option v-for="(i, index) in columnList" :key="`columns-name-${index}`" :label="i" :value="i"></el-option>
+        </template>
+        <template v-if="item.model === 'province'">
+          <el-option v-for="(i, index) in provinceList" :key="`province-${index}`" :label="i.name" :value="i.code"></el-option>
+        </template>
+        <template v-if="item.model === 'city'">
+          <el-option v-for="(i, index) in cityList" :key="`city-${index}`" :label="i.name" :value="i.code"></el-option>
+        </template>
+      </template>
+      <template #radios="{ item }">
+        <template v-if="item.model === 'status'">
+          <el-radio v-for="(i, index) in statusList" :key="`status-${index}`" :label="i.value">{{ i.label }}</el-radio>
+        </template>
+      </template>
+      <template #custom="{ item }">
+        <template v-if="item.model === 'image'">
+          <e-upload url="/files/cysci/online_image/upload" v-model="data[item.model]"></e-upload>
+        </template>
+      </template>
+    </data-form>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+const { onlineType, progressType } = require('@common/dict/index');
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: online } = createNamespacedHelpers('online');
+const { mapActions: code } = createNamespacedHelpers('code');
+export default {
+  name: 'onlineDetail',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      columnList: onlineType,
+      statusList: progressType,
+      data: {
+        image: [],
+        status: '0',
+      },
+      fields: [
+        { label: '栏目名称', model: 'column_name', type: 'select' },
+        { label: '标题', model: 'title' },
+        { label: '封面', model: 'image', custom: true },
+        { label: '举办方', model: 'organizers' },
+        { label: '联系人', model: 'contacts' },
+        { label: '联系电话', model: 'phone' },
+        { label: '省', model: 'province', type: 'select', filterReturn: true },
+        { label: '市', model: 'city', type: 'select' },
+        { label: '举办开始时间', model: 'start_time', type: 'datetime' },
+        { label: '举办结束时间', model: 'end_time', type: 'datetime' },
+        { label: '信息简介', model: 'brief' },
+        { label: '进行状态', model: 'status', type: 'radio' },
+      ],
+      xzqhList: [],
+      provinceList: [],
+      cityList: [],
+    };
+  },
+  created() {
+    this.getXzqh();
+    if (this.id) this.search();
+  },
+  methods: {
+    ...online(['fetch', 'create', 'update']),
+    ...code(['xzqh']),
+    async search() {
+      const res = await this.fetch(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `data`, res.data);
+      }
+    },
+    async toSave({ data }) {
+      let dup = _.cloneDeep(data);
+      let res;
+      if (_.get(dup, 'id')) {
+        res = await this.update(dup);
+      } else {
+        res = await this.create(dup);
+      }
+      if (this.$checkRes(res, '保存成功', '保存失败')) {
+        if (!this.$dev_mode) this.$router.push('/adminCenter/news');
+      }
+    },
+    async getXzqh(code) {
+      if (!code) {
+        const res = await this.xzqh();
+        if (this.$checkRes(res)) {
+          this.$set(this, `provinceList`, res.data);
+        }
+      } else {
+        const res = await this.xzqh({ code });
+        if (this.$checkRes(res)) {
+          this.$set(this, `cityList`, res.data);
+        }
+      }
+    },
+    filterReturn({ data, model }) {
+      if (model === 'province') this.getXzqh(data);
+    },
+  },
+  computed: {
+    ...mapState(['user', 'menuParams']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 73 - 0
src/views/adminCenter/online/file.vue

@@ -0,0 +1,73 @@
+<template>
+  <div id="file">
+    <el-row type="flex">
+      <el-col :span="21">{{ data.title }}----视频列表</el-col>
+      <el-col :span="2">
+        <el-button type="primary" @click="$router.push('/adminCenter/online')" size="mini">返回</el-button>
+      </el-col>
+    </el-row>
+    <el-row>
+      <el-col :span="24">
+        <e-upload url="/files/cysci/online_video/upload" v-model="data.video" type="text"></e-upload>
+      </el-col>
+      <el-col :span="24" style="text-align: center">
+        <el-button type="primary" @click="toSave">保存</el-button>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: online } = createNamespacedHelpers('online');
+export default {
+  name: 'onlineFile',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      data: {
+        video: [],
+      },
+    };
+  },
+  created() {
+    if (this.id) this.search();
+  },
+  methods: {
+    ...online(['fetch', 'create', 'update']),
+    async search() {
+      const res = await this.fetch(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `data`, res.data);
+      }
+    },
+    async toSave() {
+      let dup = _.cloneDeep(this.data);
+      let res;
+      if (_.get(dup, 'id')) {
+        res = await this.update(dup);
+      } else {
+        res = await this.create(dup);
+      }
+      if (this.$checkRes(res, '保存成功', '保存失败')) {
+        if (!this.$dev_mode) this.$router.push('/adminCenter/news');
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user', 'menuParams']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 104 - 0
src/views/adminCenter/online/index.vue

@@ -0,0 +1,104 @@
+<template>
+  <div id="index">
+    <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @file="toFile" @edit="toEdit" @delete="toDelete">
+      <template #selfbtn>
+        <el-button type="primary" size="mini" @click="toAdd">添加</el-button>
+      </template>
+      <template #options="{ item }">
+        <template v-if="item.prop === 'column_name'">
+          <el-option v-for="(i, index) in typeList" :key="`columns-name-${index}`" :label="i" :value="i"></el-option>
+        </template>
+      </template>
+    </data-table>
+  </div>
+</template>
+
+<script>
+const { onlineType, progressType } = require('@common/dict/index');
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: online } = createNamespacedHelpers('online');
+export default {
+  name: 'onlineIndex',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      list: [],
+      total: 0,
+      opera: [
+        {
+          label: '修改',
+          method: 'edit',
+        },
+        {
+          label: '查看播放视频',
+          method: 'file',
+        },
+        {
+          label: '删除',
+          method: 'delete',
+          type: 'danger',
+        },
+      ],
+      fields: [
+        { label: '栏目名称', prop: 'column_name', filter: 'select' },
+        { label: '标题', prop: 'title', filter: true },
+        { label: '举办方', prop: 'organizers' },
+        { label: '联系人', prop: 'contacts' },
+        { label: '联系电话', prop: 'phone' },
+        { label: '举办开始时间', prop: 'start_time' },
+        { label: '举办结束时间', prop: 'end_time' },
+        {
+          label: '进行状态',
+          prop: 'status',
+          format: (i) => {
+            const r = progressType.find((f) => f.value === i);
+            if (r) return r.label;
+            return '未知状态';
+          },
+        },
+      ],
+      typeList: onlineType,
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...online(['query', 'delete']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    toAdd() {
+      this.$router.push('/adminCenter/online/detail');
+    },
+    toEdit({ data }) {
+      this.$router.push({ path: '/adminCenter/online/detail', query: { id: data._id } });
+    },
+    toFile({ data }) {
+      this.$router.push({ path: '/adminCenter/online/file', query: { id: data._id } });
+    },
+    async toDelete({ data }) {
+      const res = await this.delete(data._id);
+      if (this.$checkRes(res, '删除成功', '删除失败')) {
+        this.search();
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user', 'menuParams']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 0 - 8
src/views/adminCenter/patent/detail.vue

@@ -54,14 +54,6 @@ export default {
     async search() {
       const res = await this.fetch(this.id);
       if (this.$checkRes(res)) {
-        const { img_url } = res.data;
-        if (_.isArray(img_url) && img_url.length > 0) {
-          const arr = [];
-          for (let i = 0; i < img_url.length; i++) {
-            if (_.isString(img_url[i])) arr.push({ name: `img${i + 1}`, url: img_url[i] });
-          }
-          res.data.img_url = arr;
-        }
         this.$set(this, `data`, res.data);
       }
     },

+ 0 - 15
src/views/adminCenter/road_show/detail.vue

@@ -46,21 +46,6 @@ export default {
     async search() {
       const res = await this.fetch(this.id);
       if (this.$checkRes(res)) {
-        const { picture, filepath } = res.data;
-        if (_.isArray(picture) && picture.length > 0) {
-          const arr = [];
-          for (let i = 0; i < picture.length; i++) {
-            if (_.isString(picture[i])) arr.push({ name: `img${i + 1}`, url: picture[i] });
-          }
-          res.data.picture = arr;
-        }
-        if (_.isArray(filepath) && filepath.length > 0) {
-          const arr = [];
-          for (let i = 0; i < filepath.length; i++) {
-            if (_.isString(filepath[i])) arr.push({ name: `file${i + 1}`, url: filepath[i] });
-          }
-          res.data.filepath = arr;
-        }
         this.$set(this, `data`, res.data);
       }
     },