guhongwei 2 years ago
parent
commit
96ddef8b82

+ 14 - 1
src/plugins/components.js

@@ -1,5 +1,18 @@
 import Vue from 'vue';
+import dataTable from '@common/src/components/frame/c-table.vue';
+import dataForm from '@common/src/components/frame/c-form.vue';
+import cDialog from '@common/src/components/frame/c-dialog.vue';
+import cUpload from '@common/src/components/frame/c-upload.vue';
+import cSearch from '@common/src/components/frame/c-search.vue';
+import cButton from '@common/src/components/frame/c-button.vue';
 
-const Plugin = (vue) => {};
+const Plugin = (vue) => {
+  vue.component('data-table', dataTable);
+  vue.component('data-form', dataForm);
+  vue.component('cDialog', cDialog);
+  vue.component('cUpload', cUpload);
+  vue.component('cSearch', cSearch);
+  vue.component('cButton', cButton);
+};
 
 Vue.use(Plugin);

+ 6 - 6
src/router/module/common.js

@@ -24,14 +24,14 @@ export default [
         component: () => import('@/views/home/index.vue'),
       },
       {
-        path: '/test/test1',
-        meta: { title: '二级菜单', is_filter: true },
-        component: () => import('@/views/test/test1/index.vue'),
+        path: '/tvadmin',
+        meta: { title: '电视节目管理', is_filter: true },
+        component: () => import('@/views/tvadmin/index.vue'),
       },
       {
-        path: '/test/test2/test1',
-        meta: { title: '三级菜单', is_filter: true },
-        component: () => import('@/views/test/test2/test1/index.vue'),
+        path: '/tvadmin/add',
+        meta: { title: '信息管理', is_filter: true },
+        component: () => import('@/views/tvadmin/add.vue'),
       },
     ],
   },

+ 2 - 11
src/views/home/index.vue

@@ -8,7 +8,6 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('test');
 export default {
   name: 'index',
   props: {},
@@ -16,16 +15,8 @@ export default {
   data: function () {
     return {};
   },
-  created() {
-    this.search();
-  },
-  methods: {
-    ...mapActions(['query']),
-    async search() {
-      let res = await this.query();
-      console.log(res);
-    },
-  },
+  created() {},
+  methods: {},
   computed: {
     ...mapState(['user']),
   },

+ 0 - 36
src/views/test/test1/index.vue

@@ -1,36 +0,0 @@
-<template>
-  <div id="index">
-    <el-row>
-      <el-col :span="24" class="main animate__animated animate__backInRight"> 二级菜单 </el-col>
-    </el-row>
-  </div>
-</template>
-
-<script>
-import { mapState, createNamespacedHelpers } from 'vuex';
-export default {
-  name: 'index',
-  props: {},
-  components: {},
-  data: function () {
-    return {};
-  },
-  created() {},
-  methods: {},
-  computed: {
-    ...mapState(['user']),
-  },
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
-  watch: {
-    test: {
-      deep: true,
-      immediate: true,
-      handler(val) {},
-    },
-  },
-};
-</script>
-
-<style lang="less" scoped></style>

+ 0 - 36
src/views/test/test2/test1/index.vue

@@ -1,36 +0,0 @@
-<template>
-  <div id="index">
-    <el-row>
-      <el-col :span="24" class="main animate__animated animate__backInRight"> 三级第一个 </el-col>
-    </el-row>
-  </div>
-</template>
-
-<script>
-import { mapState, createNamespacedHelpers } from 'vuex';
-export default {
-  name: 'index',
-  props: {},
-  components: {},
-  data: function () {
-    return {};
-  },
-  created() {},
-  methods: {},
-  computed: {
-    ...mapState(['user']),
-  },
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
-  watch: {
-    test: {
-      deep: true,
-      immediate: true,
-      handler(val) {},
-    },
-  },
-};
-</script>
-
-<style lang="less" scoped></style>

+ 88 - 0
src/views/tvadmin/add.vue

@@ -0,0 +1,88 @@
+<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">
+            <template #is_use>
+              <el-option v-for="i in is_useList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
+            </template>
+          </data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { is_use } from '@common/src/layout/site';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('test');
+export default {
+  name: 'add',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      fields: [
+        { label: '名称', model: 'name' },
+        { label: '简介', model: 'brief', type: 'textarea' },
+        { label: '视频流', model: 'path' },
+        { label: '排序', model: 'sort', type: 'number' },
+
+        { label: '是否启用', model: 'is_use', type: 'select' },
+      ],
+      form: {},
+      is_useList: is_use,
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...mapActions(['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 }) {
+      let res;
+      if (data.id) res = await this.update(data);
+      else res = await this.create(data);
+      if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
+    },
+
+    // 返回
+    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>

+ 108 - 0
src/views/tvadmin/index.vue

@@ -0,0 +1,108 @@
+<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 is_useList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_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 { is_use } from '@common/src/layout/site';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('test');
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      // 查询
+      searchInfo: {},
+      list: [],
+      total: 0,
+      fields: [
+        { label: '序号', options: { type: 'index' } },
+        { label: '名称', model: 'name', isSearch: true },
+        { label: '视频流', model: 'path', isSearch: true },
+        { label: '排序', model: 'sort', isSearch: true },
+
+        {
+          label: '是否启用',
+          model: 'is_use',
+          type: 'select',
+          format: (i) => {
+            let data = this.is_useList.find((r) => r.dict_value == i);
+            if (data) return data.dict_label;
+            else return '暂无';
+          },
+          isSearch: true,
+        },
+      ],
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      is_useList: is_use,
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...mapActions(['query', 'update', 'delete']),
+    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: '/tvadmin/add' });
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$router.push({ path: '/tvadmin/add', query: { id: data._id } });
+    },
+    // 删除信息
+    async toDel({ data }) {
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res, `刪除信息成功`, `${res.errmsg}`)) this.search();
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 1 - 1
vue.config.js

@@ -23,7 +23,7 @@ module.exports = {
         target: 'http://broadcast.waityou24.cn',
       },
       '/projectadmin/api': {
-        target: 'http://127.0.0.1:10102', //http://192.168.1.144:16001
+        target: 'http://broadcast.waityou24.cn', //http://192.168.1.144:16001
         changeOrigin: true,
         ws: false,
       },