Pārlūkot izejas kodu

去掉管理员注册

reloaded 5 gadi atpakaļ
vecāks
revīzija
58c96b0ddf

+ 2 - 0
src/store/index.js

@@ -12,6 +12,7 @@ import user from './user';
 import news from './news';
 import demand from './demand';
 import comment from './comment';
+import links from './links';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -29,5 +30,6 @@ export default new Vuex.Store({
     news,
     demand,
     comment,
+    links,
   },
 });

+ 41 - 0
src/store/links.js

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

+ 16 - 4
src/views/pcenter/comment.vue

@@ -20,10 +20,18 @@
               <template slot-scope="scope">
                 <el-button size="mini" @click="view(scope.row.id)">查看</el-button>
                 <el-button type="danger" size="mini" @click="del(scope.row.id)">删除</el-button>
-                <el-button v-if="user.type === '0' || user.type === '1'" type="success" size="mini" @click="refer(scope.row.id, { status: '1' })"
+                <el-button
+                  v-if="user.type === '0' || user.type === '1' || user.type === '4'"
+                  type="success"
+                  size="mini"
+                  @click="refer(scope.row.id, { status: '1' })"
                   >审核通过</el-button
                 >
-                <el-button v-if="user.type === '0' || user.type === '1'" type="warning" size="mini" @click="refer(scope.row.id, { status: '2' })"
+                <el-button
+                  v-if="user.type === '0' || user.type === '1' || user.type === '4'"
+                  type="warning"
+                  size="mini"
+                  @click="refer(scope.row.id, { status: '2' })"
                   >审核拒绝</el-button
                 >
               </template>
@@ -45,8 +53,12 @@
                 <el-form-item label="评论内容:">
                   <span v-html="form.content"></span>
                 </el-form-item>
-                <el-button v-if="user.type === '0' || user.type === '1'" type="success" @click="refer(form.id, { status: '1' })">审核通过</el-button>
-                <el-button v-if="user.type === '0' || user.type === '1'" type="warning" @click="refer(form.id, { status: '2' })">审核拒绝</el-button>
+                <el-button v-if="user.type === '0' || user.type === '1' || user.type === '4'" type="success" @click="refer(form.id, { status: '1' })"
+                  >审核通过</el-button
+                >
+                <el-button v-if="user.type === '0' || user.type === '1' || user.type === '4'" type="warning" @click="refer(form.id, { status: '2' })"
+                  >审核拒绝</el-button
+                >
               </el-form-item>
             </el-form>
           </el-col>

+ 16 - 4
src/views/pcenter/demand.vue

@@ -30,10 +30,18 @@
                   <el-button v-if="user.type === '3' && scope.row.status == '0'" type="success" @click="refer(scope.row.id, { status: '1' })"
                     >提交审核</el-button
                   >
-                  <el-button v-if="user.type === '0' || user.type === '1'" type="success" size="mini" @click="refer(scope.row.id, { status: '2' })"
+                  <el-button
+                    v-if="user.type === '0' || user.type === '1' || user.type === '4'"
+                    type="success"
+                    size="mini"
+                    @click="refer(scope.row.id, { status: '2' })"
                     >审核通过</el-button
                   >
-                  <el-button v-if="user.type === '0' || user.type === '1'" type="warning" size="mini" @click="refer(scope.row.id, { status: '3' })"
+                  <el-button
+                    v-if="user.type === '0' || user.type === '1' || user.type === '4'"
+                    type="warning"
+                    size="mini"
+                    @click="refer(scope.row.id, { status: '3' })"
                     >审核拒绝</el-button
                   >
                 </template>
@@ -105,8 +113,12 @@
               </el-form-item>
               <el-form-item>
                 <el-button v-if="user.type === '3'" type="primary" @click="onSubmit()">提交</el-button>
-                <el-button v-if="user.type === '0' || user.type === '1'" type="success" @click="refer(form.id, { status: '2' })">审核通过</el-button>
-                <el-button v-if="user.type === '0' || user.type === '1'" type="warning" @click="refer(form.id, { status: '3' })">审核拒绝</el-button>
+                <el-button v-if="user.type === '0' || user.type === '1' || user.type === '4'" type="success" @click="refer(form.id, { status: '2' })"
+                  >审核通过</el-button
+                >
+                <el-button v-if="user.type === '0' || user.type === '1' || user.type === '4'" type="warning" @click="refer(form.id, { status: '3' })"
+                  >审核拒绝</el-button
+                >
               </el-form-item>
             </el-form>
           </el-col>

+ 14 - 1
src/views/pcenter/index.vue

@@ -24,7 +24,7 @@
                       <span>需求管理</span>
                     </template>
                   </el-menu-item>
-                  <el-menu-item index="3" v-if="user.type === '0' || user.type === '1'">
+                  <el-menu-item index="3" v-if="user.type === '0' || user.type === '1' || user.type === '2'">
                     <template slot="title">
                       <span>信息管理</span>
                     </template>
@@ -49,6 +49,11 @@
                       <span>职务管理</span>
                     </template>
                   </el-menu-item>
+                  <el-menu-item index="10">
+                    <template slot="title">
+                      <span>友情链接</span>
+                    </template>
+                  </el-menu-item>
                   <el-menu-item index="7">
                     <template slot="title">
                       <span>修改密码</span>
@@ -99,6 +104,10 @@
                 <el-col :span="24" class="infoTop"> <span>|</span><span>评论管理</span> </el-col>
                 <comment></comment>
               </span>
+              <span v-else-if="columnName == '友情链接'">
+                <el-col :span="24" class="infoTop"> <span>|</span><span>友情链接</span> </el-col>
+                <links></links>
+              </span>
             </el-col>
           </div>
         </el-col>
@@ -123,6 +132,7 @@ import uppasswd from '@/views/pcenter/uppasswd.vue';
 import department from '@/views/pcenter/department.vue';
 import level from '@/views/pcenter/level.vue';
 import comment from '@/views/pcenter/comment.vue';
+import links from '@/views/pcenter/links.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: login } = createNamespacedHelpers('login');
 export default {
@@ -139,6 +149,7 @@ export default {
     department,
     level,
     comment,
+    links,
   },
   data: function() {
     return {
@@ -171,6 +182,8 @@ export default {
         this.columnName = '退出登录';
       } else if (key == 9) {
         this.columnName = '评论管理';
+      } else if (key == 10) {
+        this.columnName = '友情链接';
       }
     },
     // 退出登录

+ 143 - 0
src/views/pcenter/links.vue

@@ -0,0 +1,143 @@
+<template>
+  <div id="links">
+    <el-row>
+      <el-col :span="24" class="style">
+        <el-col :span="24" class="list" v-if="display">
+          <el-col :span="24" class="top"><el-button type="primary" size="mini" @click="add">添加</el-button></el-col>
+          <el-table :data="tableData" border style="width: 100%">
+            <el-table-column prop="name" label="链接名称" align="center" :show-overflow-tooltip="true" width="180px"> </el-table-column>
+            <el-table-column prop="url" label="链接地址" align="center" :show-overflow-tooltip="true"> </el-table-column>
+            <el-table-column prop="img_url" label="链接图片" align="center" :show-overflow-tooltip="true" width="180px">
+              <template slot-scope="scope">
+                <el-image :src="scope.row.img_url"></el-image>
+              </template>
+            </el-table-column>
+            <el-table-column label="操作" align="center" width="230px">
+              <template slot-scope="scope">
+                <el-button size="mini" @click="view(scope.row.id)">查看</el-button>
+                <el-button type="danger" size="mini" @click="del(scope.row.id)">删除</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+          <page :total="total" position="right" @query="search"></page>
+        </el-col>
+        <el-col :span="24" class="detail" v-else>
+          <el-col class="top"><el-button type="primary" size="mini" @click="back">返回</el-button></el-col>
+          <el-col>
+            <el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
+              <el-form-item>
+                <el-form-item label="链接名称:">
+                  <el-input v-model="form.name" placeholder="请输入需求技术名称"></el-input>
+                </el-form-item>
+                <el-form-item label="链接地址:" prop="url">
+                  <el-input v-model="form.url" placeholder="请输入需求技术名称"></el-input>
+                </el-form-item>
+                <el-form-item label="链接图片:">
+                  <upload :limit="1" :data="form.img_url" type="img_url" :url="'/files/count/upload'" @upload="uploadSuccess"></upload>
+                </el-form-item>
+                <el-form-item>
+                  <el-button type="primary" @click="onSubmit()">提交</el-button>
+                </el-form-item>
+              </el-form-item>
+            </el-form>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import page from '@/components/pagination.vue';
+import upload from '@/components/uploadone.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: links } = createNamespacedHelpers('links');
+export default {
+  name: 'links',
+  props: {},
+  components: { page, upload },
+  data: () => ({
+    tableData: [],
+    display: true,
+    form: {},
+    total: 0,
+    rules: {
+      url: [{ required: true, message: '请输入链接地址', trigger: 'blur' }],
+    },
+  }),
+  created() {
+    this.search();
+  },
+  computed: {},
+  methods: {
+    ...links(['update', 'fetch', 'query', 'create', 'delete']),
+    // 查询信息列表
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let res = await this.query({ skip, limit, ...info });
+      this.$set(this, `tableData`, res.data);
+      this.$set(this, `total`, res.total);
+    },
+    async view(id) {
+      const res = await this.fetch(id);
+      this.$set(this, `form`, res.data);
+      this.display = false;
+    },
+    async del(id) {
+      const res = await this.delete(id);
+      if (res.errcode === 0) {
+        this.$message({
+          message: '信息删除成功',
+          type: 'success',
+        });
+        this.search();
+      } else {
+        this.$message.error('信息删除失败');
+      }
+    },
+    add() {
+      this.display = false;
+      this.form = {};
+    },
+    // 返回
+    back() {
+      this.display = true;
+    },
+    uploadSuccess({ type, data }) {
+      this.$set(this.form, `img_url`, data.uri);
+    },
+    async onSubmit() {
+      let res = {};
+      let data = JSON.parse(JSON.stringify(this.form));
+      console.log(data);
+
+      if (data.id) {
+        res = await this.update(data);
+      } else {
+        res = await this.create(data);
+      }
+      if (res.errcode === 0) {
+        this.$message({
+          message: '信息创建成功',
+          type: 'success',
+        });
+        this.display = true;
+        this.search();
+      } else {
+        this.$message.error('信息创建失败');
+      }
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.style {
+  width: 95%;
+  margin: 0 auto;
+  float: none;
+}
+.top {
+  text-align: right;
+  padding: 0 0 10px 0;
+}
+</style>

+ 2 - 2
src/views/register.vue

@@ -30,8 +30,8 @@
                   <el-form-item label="用户类别" prop="type">
                     <el-radio-group v-model="form.type">
                       <el-radio label="3">普通用户</el-radio>
-                      <el-radio label="0">超级管理员</el-radio>
-                      <el-radio label="1">管理员</el-radio>
+                      <!-- <el-radio label="0">超级管理员</el-radio>
+                      <el-radio label="1">管理员</el-radio> -->
                       <el-radio label="2">专家</el-radio>
                     </el-radio-group>
                   </el-form-item>