guhongwei il y a 2 ans
Parent
commit
cd7261ff9f
5 fichiers modifiés avec 222 ajouts et 1 suppressions
  1. 10 0
      src/router/module/app.js
  2. 3 0
      src/store/index.js
  3. 101 0
      src/views/app/users/add.vue
  4. 107 0
      src/views/app/users/index.vue
  5. 1 1
      vue.config.js

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

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

+ 3 - 0
src/store/index.js

@@ -4,6 +4,8 @@ import * as ustate from '@common/src/store/user/state';
 import * as umutations from '@common/src/store/user/mutations';
 // 管理员
 import admin from '@common/src/store/admin';
+import users from '@common/src/store/user';
+
 import program from '@common/src/store/program';
 
 // 系统设置
@@ -34,6 +36,7 @@ export default new Vuex.Store({
   actions: {},
   modules: {
     admin,
+    users,
     program,
     dicttype,
     dictdata,

+ 101 - 0
src/views/app/users/add.vue

@@ -0,0 +1,101 @@
+<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="24">
+            <template #gender>
+              <el-option v-for="i in genderList" :key="i._id" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #logo_url="{ item }">
+              <c-upload v-model="form[item.model]" url="/files/projectadmin/imgurl/upload" :limit="1"></c-upload>
+            </template>
+          </data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('users');
+const { mapActions: dictdata } = createNamespacedHelpers('dictdata');
+export default {
+  name: 'add',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      fields: [
+        { label: '账号', model: 'account', options: { readonly: true } },
+        { label: '昵称', model: 'nick_name' },
+        { label: '联系电话', model: 'phone' },
+        { label: '性别', model: 'gender', type: 'select' },
+        { label: '头像', model: 'logo_url', custom: true },
+      ],
+      form: {},
+      // 字典
+      // 性别
+      genderList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...mapActions(['fetch', 'create', 'update']),
+    ...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: 'gender' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `genderList`, res.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>

+ 107 - 0
src/views/app/users/index.vue

@@ -0,0 +1,107 @@
+<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"> </c-search>
+        </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('users');
+const { mapActions: dictdata } = createNamespacedHelpers('dictdata');
+
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      // 查询
+      searchInfo: {},
+      fields: [
+        { label: '序号', options: { type: 'index' } },
+        { label: '账号', model: 'account', isSearch: true },
+        { label: '昵称', model: 'nick_name', isSearch: true },
+        { label: '联系电话', model: 'phone', isSearch: true },
+        {
+          label: '性别',
+          model: 'gender',
+          format: (i) => {
+            let data = this.genderList.find((r) => r.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      list: [],
+      total: 0,
+      // 字典
+      // 性别
+      genderList: [],
+    };
+  },
+  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();
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$router.push({ path: '/app/users/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: 'gender' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `genderList`, 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>

+ 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://127.0.0.1:10102  http://www.freeskyghw.cn  http://47.93.34.200
+        target: 'http://broadcast.waityou24.cn', //http://127.0.0.1:10102  http://www.freeskyghw.cn  http://47.93.34.200
         changeOrigin: true,
         ws: false,
       },