guhongwei 2 年之前
父節點
當前提交
e234351f55
共有 5 個文件被更改,包括 320 次插入0 次删除
  1. 1 0
      .gitignore
  2. 10 0
      src/router/module/app.js
  3. 2 0
      src/store/index.js
  4. 165 0
      src/views/app/videos/add.vue
  5. 142 0
      src/views/app/videos/index.vue

+ 1 - 0
.gitignore

@@ -22,3 +22,4 @@ pnpm-debug.log*
 *.njsproj
 *.sln
 *.sw?
+*.history

+ 10 - 0
src/router/module/app.js

@@ -49,4 +49,14 @@ export default [
     meta: { title: '信息管理', is_filter: false },
     component: () => import('@/views/app/scene/data/add.vue'),
   },
+  {
+    path: '/app/videos',
+    meta: { title: '视频信息', is_filter: false },
+    component: () => import('@/views/app/videos/index.vue'),
+  },
+  {
+    path: '/app/videos/add',
+    meta: { title: '信息管理', is_filter: false },
+    component: () => import('@/views/app/videos/add.vue'),
+  },
 ];

+ 2 - 0
src/store/index.js

@@ -23,6 +23,7 @@ import hotlink from '@common/src/store/app/hotlink';
 import appapk from '@common/src/store/app/appapk';
 import scenetype from '@common/src/store/app/scenetype';
 import scenedata from '@common/src/store/app/scenedata';
+import videos from '@common/src/store/app/videos';
 
 Vue.use(Vuex);
 
@@ -49,5 +50,6 @@ export default new Vuex.Store({
     appapk,
     scenetype,
     scenedata,
+    videos,
   },
 });

+ 165 - 0
src/views/app/videos/add.vue

@@ -0,0 +1,165 @@
+<template>
+  <div id="add">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col :span="24" class="one">
+          <c-search :is_title="true" :is_back="true" @toBack="toBack"></c-search>
+        </el-col>
+        <el-col :span="24" class="two">
+          <data-form :fields="fields" :form="form" :rules="{}" @save="toSave" :span="12">
+            <template #firm_id>
+              <el-option v-for="i in firmList" :key="i._id" :label="i.title" :value="i._id"></el-option>
+            </template>
+            <template #type_id>
+              <el-option v-for="i in typeList" :key="i._id" :label="i.title" :value="i._id"></el-option>
+            </template>
+            <template #place_id>
+              <el-option v-for="i in placeList" :key="i._id" :label="i.title" :value="i._id"></el-option>
+            </template>
+            <template #year>
+              <el-option v-for="i in yearList" :key="i._id" :label="i.title" :value="i._id"></el-option>
+            </template>
+            <template #head_actor>
+              <el-option v-for="i in actorList" :key="i._id" :label="i.title" :value="i._id"></el-option>
+            </template>
+            <template #img_url="{ item }">
+              <c-upload v-model="form[item.model]" url="/files/projectadmin/imgurl/upload" accept="" listType="text" :limit="1"></c-upload>
+            </template>
+            <template #video_url="{ item }">
+              <c-upload v-model="form[item.model]" url="/files/projectadmin/imgurl/upload" accept="" listType="text" :limit="1"></c-upload>
+            </template>
+            <template #is_use>
+              <el-option v-for="i in isuseList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #is_hot>
+              <el-option v-for="i in isnoList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('videos');
+const { mapActions: scenetype } = createNamespacedHelpers('scenetype');
+const { mapActions: scenedata } = createNamespacedHelpers('scenedata');
+const { mapActions: dictdata } = createNamespacedHelpers('dictdata');
+export default {
+  name: 'add',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      fields: [
+        { label: '名称', model: 'title' },
+        { label: '简介', model: 'brief', type: 'textarea' },
+        { label: '时长', model: 'time_num' },
+        { label: '来源', model: 'origin' },
+        { label: '厂商', model: 'firm_id', type: 'select' },
+        { label: '类型', model: 'type_id', type: 'select' },
+        { label: '产地', model: 'place_id', type: 'select' },
+        { label: '年份', model: 'year', type: 'select' },
+        { label: '领衔演员', model: 'head_actor', type: 'select' },
+        { label: '演员', model: 'actor' },
+        { label: '封面', model: 'img_url', custom: true },
+        { label: '视频路径', model: 'video_url', custom: true },
+        // { label: '观看次数', model: 'view_num', type: 'number' },
+        { label: '是否启用', model: 'is_use', type: 'select' },
+        { label: '是否热推', model: 'is_hot', type: 'select' },
+      ],
+      form: {},
+      // 是否启用
+      isuseList: [],
+      // 是否
+      isnoList: [],
+      // 厂商
+      firmList: [],
+      typeList: [],
+      placeList: [],
+      yearList: [],
+      actorList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...mapActions(['fetch', 'create', 'update']),
+    ...scenetype({ scQuery: 'query' }),
+    ...scenedata({ scdQuery: 'query' }),
+    ...dictdata({ dQuery: 'query' }),
+    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 }) {
+      let res;
+      if (data.id) res = await this.update(data);
+      else res = await this.create(data);
+      if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
+    },
+    // 字典
+    async searchOther() {
+      let res;
+      // 是否启用
+      res = await this.dQuery({ type: 'is_use' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `isuseList`, res.data);
+      }
+      // 是否
+      res = await this.dQuery({ type: 'is_no' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `isnoList`, res.data);
+      }
+      // 厂商,类型,产地,年份,演员
+      res = await this.scQuery({ is_use: '0' });
+      if (this.$checkRes(res)) {
+        for (const val of res.data) {
+          let arr;
+          let type = '';
+          if (val.title == '厂商') type = 'firm';
+          else if (val.title == '类型') type = 'type';
+          else if (val.title == '产地') type = 'place';
+          else if (val.title == '年份') type = 'year';
+          else if (val.title == '演员') type = 'actor';
+          arr = await this.scdQuery({ is_use: '0', type_id: val._id });
+          if (this.$checkRes(arr)) {
+            this.$set(this, `${type}List`, arr.data);
+          }
+        }
+      }
+    },
+    // 返回
+    toBack() {
+      window.history.go('-1');
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 142 - 0
src/views/app/videos/index.vue

@@ -0,0 +1,142 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col :span="24" class="one">
+          <c-search :is_search="true" :fields="fields" @search="btSearch">
+            <template #is_use>
+              <el-option v-for="i in isuseList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #is_hot>
+              <el-option v-for="i in isnoList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </c-search>
+        </el-col>
+        <el-col :span="24" class="two">
+          <c-button @toAdd="toAdd"></c-button>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @edit="toEdit" @del="toDel"> </data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('videos');
+const { mapActions: dictdata } = createNamespacedHelpers('dictdata');
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      // 查询
+      searchInfo: {},
+      fields: [
+        { label: '序号', options: { type: 'index' } },
+        { label: '名称', model: 'title', isSearch: true },
+        { label: '演员', model: 'actor' },
+        { label: '来源', model: 'origin' },
+        { label: '时长', model: 'time_num' },
+        {
+          label: '是否启用',
+          model: 'is_use',
+          type: 'select',
+          format: (i) => {
+            let data = this.isuseList.find((r) => r.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+          isSearch: true,
+        },
+        {
+          label: '是否热推',
+          model: 'is_hot',
+          type: 'select',
+          format: (i) => {
+            let data = this.isnoList.find((r) => r.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+          isSearch: true,
+        },
+        { label: '观看次数', model: 'view_num' },
+      ],
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      list: [],
+      total: 0,
+      // 字典
+      // 是否启用
+      isuseList: [],
+      // 是否
+      isnoList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...mapActions(['query', 'delete']),
+    ...dictdata({ dQuery: 'query' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    btSearch(query) {
+      this.$set(this, `searchInfo`, query);
+      this.search();
+    },
+    // 新增
+    toAdd() {
+      this.$router.push({ path: '/app/videos/add' });
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$router.push({ path: '/app/videos/add', query: { id: data._id } });
+    },
+    async toDel({ data }) {
+      let res = await this.delete(data._id);
+      if (this.$checkRes(res, '删除信息成功', res.errmsg)) this.search();
+    },
+    // 字典表
+    async searchOther() {
+      let res;
+      // 是否启用
+      res = await this.dQuery({ type: 'is_use' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `isuseList`, res.data);
+      }
+      // 是否
+      res = await this.dQuery({ type: 'is_no' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `isnoList`, res.data);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>