Ver Fonte

站点角色

rkljw há 10 meses atrás
pai
commit
e582f32018

+ 2 - 4
src/api/pub.js

@@ -3,8 +3,6 @@ import {request} from '@/axios/request'
 export default {
     getMenuList(){
         return request.get("/authority/getRecursionMenu")
-    },
-    getCommonRegion(data){
-        return request.get("/seller/common/getCommonRegion",data)
-    },
+    }
+    
 }

+ 12 - 0
src/api/website.js

@@ -39,4 +39,16 @@ export default {
         return request.post("/website/updateWebsiteColumn",parames)
     },
 
+     //站点角色列表
+     getAdminWebsiteRoleList (parames){
+        return request.get("/website/getAdminWebsiteRoleList",parames)
+    },
+    //创建站点角色
+    createAdminWebsiteRoleUser(parames){
+        return request.post("/website/createAdminWebsiteRoleUser",parames)
+    },
+    //删除站点角色
+    delAdminWebsiteRoleUser(parames){
+        return request.post("/website/delAdminWebsiteRoleUser",parames)
+    },
 }

+ 14 - 4
src/router/index.js

@@ -39,13 +39,23 @@ const routes = [{
             },
             {
                 meta: {
-                    action: "websiteList",
+                    action: "websiteRole",
                     title: '站点角色'
                 },
-                path: 'websiteList/nice',
-                name: 'nice',
+                path: 'websiteRole/:Id',
+                name: 'websiteRole',
                 component: () =>
-                    import ('@views/website/index.vue')
+                    import ('@views/websiteRole/index.vue')
+            },
+            {
+                meta: {
+                    action: "websiteRoleUser",
+                    title: '站点角色'
+                },
+                path: 'websiteRoleUser/:Id',
+                name: 'websiteRoleUser',
+                component: () =>
+                    import ('@views/websiteRoleUser/index.vue')
             },
             {
                 meta: {

+ 4 - 0
src/views/website/index.vue

@@ -57,6 +57,7 @@
                     <div style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
                       <span class="btn"  @click="updateClick(scope.row, scope.$index)">编辑</span>
                       <span class="btn"  @click="deleteAuthority(scope.row,scope.$index)">删除</span>
+                      <span class="btn"  @click="websiteRoleClick(scope.row)">站点角色</span>
                     </div>
                   </template>
                 </el-table-column>
@@ -250,6 +251,9 @@
         this.currentPage = 1
         this.pageSize = 10
         this.getList()
+      },
+      websiteRoleClick(row){
+        this.$router.push('websiteRole/'+row.id);
       }
 
     },

+ 113 - 0
src/views/websiteRole/components/edit.vue

@@ -0,0 +1,113 @@
+<template>
+  <div>
+    <el-form ref="form" :rules="rules"  :model="form" label-width="120px">
+      <el-form-item
+          label="角色名称:"
+          prop="role_id"
+      >
+      <el-select
+          v-model="form.role_id"
+          :multiple = "false"
+          filterable
+          remote
+          reserve-keyword
+          placeholder="请输入关键词"
+          :remote-method="remoteMethod"
+          :loading="loading">
+          <el-option
+            v-for="item in options"
+            :key="item.id"
+            :label="item.role_name"
+            :value="item.id">
+          </el-option>
+        </el-select>
+      </el-form-item>
+    
+      <el-form-item>
+        <div style="text-align: center">
+          <el-button type="primary" @click="onSubmit" :disabled="Isdisabled" :loading="isloading">保存</el-button>
+          <el-button style="color: #5075FC " @click="closeDlg">取消</el-button>
+        </div>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+<script>
+export default {
+  props: {
+    roleDataForm: {
+      type: Object,
+      default: () => {}
+    },
+    isloading:{
+      type:Boolean,
+      default: true
+    },
+    closeDlg:{
+      type:Function
+    }
+  },
+  data() {
+    return {
+      options: [],
+      loading: false,
+      form: {
+        role_id: ''
+      },
+      Isdisabled: false,
+      rules: {
+        role_id: [
+          { required: true, message: '角色名称必填' },
+        ]
+      }
+    }
+  },
+  mounted() {
+    if(this.roleDataForm) {
+      this.form = Object.assign({} , this.roleDataForm)
+    }
+  },
+  methods: {
+    closeDlg() {
+      this.$emit('closeDlg',1)
+    },
+    remoteMethod(query) {  
+      let _t = this;
+        if (query !== '') {
+          _t.loading = true;
+        let parames = {
+            'keyword':query
+        }
+        this.$api.user.roleList(parames).then(res=>{
+                _t.loading = false;
+                if(res.code==200){
+                  if(res.data.rows.length==0){
+                    this.$message.error("没找到该角色!!!")
+                    return
+                  }
+                  this.options = res.data.rows
+                }else{
+                    this.$message.error("查询失败")
+                }
+            })
+        } else {
+          this.options = [];
+        }
+    },
+    onSubmit() {
+      let that = this
+      that.$refs['form'].validate((valid) => {
+        if (valid) {
+          console.log("提交数据:",this.form)
+          this.$emit('roleSubmitClick', this.form)
+        }
+      })
+    },
+  }
+}
+</script>
+<style>
+.el-cascader-node>.el-radio{
+  margin-top:25px;
+}
+</style>

+ 260 - 0
src/views/websiteRole/index.vue

@@ -0,0 +1,260 @@
+<template>
+    <div class="main-content__div">
+      <div class="table-box__div" v-cloak v-loading="loadingFlag">
+        <el-form  class="demo-form-inline">
+          <el-form-item label="角色名称">
+            <el-input
+              placeholder="角色名称"
+              v-model="keyword"
+              style="width:150px;"
+              size="small"
+              >
+            </el-input>
+          </el-form-item>
+          
+          <!-- 搜索按钮 -->
+          <el-form-item>
+            <el-button type="primary" size="small" @click="searchFrom()">搜索</el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+      <!-- 列表 -->
+      <div class="table-box__div" v-cloak v-loading="loadingFlag">
+        <!-- 查询表单 -->
+        <el-form :inline="true" class="demo-form-inline">
+          <el-form-item>
+            <el-button type="primary" size="small" @click="addClick">添加站点角色</el-button>
+          </el-form-item>
+        
+        </el-form>
+        <el-table
+          size="mini"
+          :data="tableData"
+          :empty-text="tableDataLoadingText"
+          style="width: 100%;font-size: 15px;"
+          :header-cell-style="{background:'#FAFAFA'}"
+        >
+          <el-table-column label="编号" width="250" prop="id"></el-table-column>
+          <el-table-column label="角色名称" prop="role_name" width="350"></el-table-column>
+          <el-table-column label="角色备注" prop="remark" width="300"></el-table-column>
+          <el-table-column label="操作时间" prop="updated_at" width="300"></el-table-column>
+          <el-table-column label="排序" prop="sort" width="300"></el-table-column>
+          <el-table-column   prop="" label="操作" align="center">
+                  <template v-slot="scope">
+                    <div style="display: flex;flex-direction: column;justify-content: center;align-items: center;" >
+                      <span class="btn"  @click="assignPermissions(scope.row, scope.$index)">添加用户</span>
+                      <span class="btn"  @click="deleteAuthority(scope.row,scope.$index)">删除</span>
+                    </div>
+                  </template>
+                </el-table-column>
+        </el-table>
+        <!-- 分页 -->
+        <div class="block" v-show="pagination" style="margin-top: 10px;float: right;">
+          <el-pagination
+            background
+            @current-change="handleCurrentChange"
+            :current-page="currentPage"
+            :page-size="pageSize"
+            layout="total, prev, pager, next, jumper"
+            :total="parseInt(tableCount)">
+          </el-pagination>
+        </div>
+      </div>
+    </div>
+  <Dialog title="温馨提示" content="您确认要删除该角色吗?"
+          @close="DialogShow = false"
+          @submitSureClick="submitSureClickDel"
+          @DialogFalse="DialogShow = false"
+          :innerVisible="DialogShow">
+  </Dialog>
+  <DialogSlot
+      title="添加"
+      @close="roleDialogShow = false"
+      @DialogClose="roleDialogShow = false"
+      :innerVisible="roleDialogShow"
+      @colesClick="roleDialogShow  = false"
+  >
+    <editFrom
+        @colesClick="roleDialogShow = false"
+        :roleDataForm="roleDataForm"
+         :isloading="isloading"
+        @roleSubmitClick="roleSubmitClick"
+        @closeDlg="closeDlg"
+        >
+    </editFrom>
+  </DialogSlot>
+
+
+  </template>
+  <script>
+  import Dialog from "../../components/dialog";
+  import editFrom from "./components/edit";
+  import DialogSlot from "../../components/DialogSlot";
+  export default {
+    components: {
+      Dialog,
+      editFrom,
+      DialogSlot
+    },
+    data() {
+      return {
+        value:"1",
+        //  菜单列表数据
+        tableData: [],
+        //  加载中数据提示
+        tableDataLoadingText:"拼命加载中······",
+        //  是否显示分页
+        pagination:false,
+        //  每页显示的条数
+        pageSize:10,
+        //  当前页
+        currentPage:1,
+        //  菜单列表数据总条数
+        tableCount:0,
+  
+        loadingFlag: false,
+        isShowSource: false, // 是否显示来源列
+        id:0,
+        DialogShow: false, //控制删除弹窗
+        websiteRoleId:'',
+        roleRowIndex:'',
+        roleDataForm: {},
+        roleTableData: [],
+        isloading:false, //提交按钮状态
+        roleDialogShow: false, // 控制保存弹窗
+
+
+        authorityDialogShow:false,
+        authorityDataForm: {},
+        keyword:'',
+        websiteId:''
+      }
+    },
+    mounted() {},
+    methods: {
+      // 获取菜单信息列表
+      getList:function(){
+        let _t = this;
+        _t.loadingFlag = true;
+        let parames = {
+            'page':this.currentPage,
+            'pageSize':this.pageSize,
+            'keyword':this.keyword,
+            'id':this.websiteId
+        }
+        this.$api.website.getAdminWebsiteRoleList(parames).then(res=>{
+                _t.loadingFlag = false;
+                if(res.code==200){
+                  if(res.data.rows.length==0){
+                    this.$message.error("没找到该角色!!!")
+                    return
+                  }
+                    _t.tableData = res.data.rows;
+                    _t.tableCount = res.data.count;
+                     //  总条数大于每页显示的条数时显示分页
+                    if( _t.tableCount > _t.pageSize ){
+                     _t.pagination = true;
+                    }
+                    if( _t.tableData.length==0 ){
+                     _t.tableDataLoadingText = "暂无数据";
+                    }
+                }else{
+                    this.$message.error("查询失败")
+                }
+            })
+      },
+      // 点击翻页
+      handleCurrentChange(val) {
+        this.currentPage = val;
+        this.getList();
+      },
+      // 查看下一级
+      nextClick( id ){
+        let _t = this;
+        _t.id = id
+        _t.currentPage = 1
+        _t.pageSize = 10
+       this.getList()
+      },
+      addClick(){
+        this.roleDataForm = {}
+        this.roleDialogShow = true
+      },
+      closeDlg(val){
+          this.roleDialogShow = false
+          this.isloading = false
+          this.authorityDialogShow = false
+      },
+      roleSubmitClick(data){
+        let _t = this
+        console.log("提交数据",data)
+        let parames = {
+          type_id:data.role_id,
+          type:'1',
+          website_id:this.websiteId
+        }
+        _t.isloading = true
+        this.$api.website.createAdminWebsiteRoleUser(parames).then(res=>{
+              _t.loadingFlag = false;
+              if(res.code==200){
+                    console.log("创建成功")
+                    this.getList()
+              }else{
+                  this.$message.error(res.message)
+              }
+              this.roleDialogShow = false
+              this.isloading = false
+          })
+      },
+   
+      //删除站点角色
+      deleteAuthority(row, index) {
+        this.websiteRoleId = row.website_role_user_id
+        this.roleRowIndex = index
+        this.DialogShow = true
+      },
+      submitSureClickDel(row,index){
+        let parames = {
+          'id':this.websiteRoleId
+        }
+        this.$api.website.delAdminWebsiteRoleUser(parames).then(res=>{
+          if(res.code==200){
+            this.DialogShow = false
+            this.getList()
+          }else{
+            this.$message.error("删除失败")
+          }
+        })
+      },
+      searchFrom(){
+        this.currentPage = 1
+        this.pageSize = 10
+        this.getList()
+      },
+      assignPermissions(row,index){
+        console.log(row)
+        this.authorityDataForm = row
+        this.rowIndex = index
+        this.authorityDialogShow = true
+      }
+
+    },
+    created() {
+        //赋值站点id
+        this.websiteId = this.$route.params.Id;
+        console.log("接收参数:",this.$route.params.Id);
+        this.getList();
+  
+    }
+  }
+  </script>
+
+  
+<style >
+.demo-form-inline{
+   display: flex;
+}
+.demo-form-inline .el-form-item{
+ margin: 0 20px;
+}
+</style>

+ 113 - 0
src/views/websiteRoleUser/components/edit.vue

@@ -0,0 +1,113 @@
+<template>
+  <div>
+    <el-form ref="form" :rules="rules"  :model="form" label-width="120px">
+      <el-form-item
+          label="角色名称:"
+          prop="role_id"
+      >
+      <el-select
+          v-model="form.role_id"
+          :multiple = "false"
+          filterable
+          remote
+          reserve-keyword
+          placeholder="请输入关键词"
+          :remote-method="remoteMethod"
+          :loading="loading">
+          <el-option
+            v-for="item in options"
+            :key="item.id"
+            :label="item.role_name"
+            :value="item.id">
+          </el-option>
+        </el-select>
+      </el-form-item>
+    
+      <el-form-item>
+        <div style="text-align: center">
+          <el-button type="primary" @click="onSubmit" :disabled="Isdisabled" :loading="isloading">保存</el-button>
+          <el-button style="color: #5075FC " @click="closeDlg">取消</el-button>
+        </div>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+<script>
+export default {
+  props: {
+    roleDataForm: {
+      type: Object,
+      default: () => {}
+    },
+    isloading:{
+      type:Boolean,
+      default: true
+    },
+    closeDlg:{
+      type:Function
+    }
+  },
+  data() {
+    return {
+      options: [],
+      loading: false,
+      form: {
+        role_id: ''
+      },
+      Isdisabled: false,
+      rules: {
+        role_id: [
+          { required: true, message: '角色名称必填' },
+        ]
+      }
+    }
+  },
+  mounted() {
+    if(this.roleDataForm) {
+      this.form = Object.assign({} , this.roleDataForm)
+    }
+  },
+  methods: {
+    closeDlg() {
+      this.$emit('closeDlg',1)
+    },
+    remoteMethod(query) {  
+      let _t = this;
+        if (query !== '') {
+          _t.loading = true;
+        let parames = {
+            'keyword':query
+        }
+        this.$api.user.roleList(parames).then(res=>{
+                _t.loading = false;
+                if(res.code==200){
+                  if(res.data.rows.length==0){
+                    this.$message.error("没找到该角色!!!")
+                    return
+                  }
+                  this.options = res.data.rows
+                }else{
+                    this.$message.error("查询失败")
+                }
+            })
+        } else {
+          this.options = [];
+        }
+    },
+    onSubmit() {
+      let that = this
+      that.$refs['form'].validate((valid) => {
+        if (valid) {
+          console.log("提交数据:",this.form)
+          this.$emit('roleSubmitClick', this.form)
+        }
+      })
+    },
+  }
+}
+</script>
+<style>
+.el-cascader-node>.el-radio{
+  margin-top:25px;
+}
+</style>

+ 259 - 0
src/views/websiteRoleUser/index.vue

@@ -0,0 +1,259 @@
+<template>
+    <div class="main-content__div">
+      <div class="table-box__div" v-cloak v-loading="loadingFlag">
+        <el-form  class="demo-form-inline">
+          <el-form-item label="用户名称">
+            <el-input
+              placeholder="用户名称"
+              v-model="keyword"
+              style="width:150px;"
+              size="small"
+              >
+            </el-input>
+          </el-form-item>
+          
+          <!-- 搜索按钮 -->
+          <el-form-item>
+            <el-button type="primary" size="small" @click="searchFrom()">搜索</el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+      <!-- 列表 -->
+      <div class="table-box__div" v-cloak v-loading="loadingFlag">
+        <!-- 查询表单 -->
+        <el-form :inline="true" class="demo-form-inline">
+          <el-form-item>
+            <el-button type="primary" size="small" @click="addClick">添加站点角色用户</el-button>
+          </el-form-item>
+        
+        </el-form>
+        <el-table
+          size="mini"
+          :data="tableData"
+          :empty-text="tableDataLoadingText"
+          style="width: 100%;font-size: 15px;"
+          :header-cell-style="{background:'#FAFAFA'}"
+        >
+          <el-table-column label="编号" width="250" prop="id"></el-table-column>
+          <el-table-column label="角色名称" prop="role_name" width="350"></el-table-column>
+          <el-table-column label="角色备注" prop="remark" width="300"></el-table-column>
+          <el-table-column label="操作时间" prop="updated_at" width="300"></el-table-column>
+          <el-table-column label="排序" prop="sort" width="300"></el-table-column>
+          <el-table-column   prop="" label="操作" align="center">
+                  <template v-slot="scope">
+                    <div style="display: flex;flex-direction: column;justify-content: center;align-items: center;" >
+                      <span class="btn"  @click="deleteAuthority(scope.row,scope.$index)">删除</span>
+                    </div>
+                  </template>
+                </el-table-column>
+        </el-table>
+        <!-- 分页 -->
+        <div class="block" v-show="pagination" style="margin-top: 10px;float: right;">
+          <el-pagination
+            background
+            @current-change="handleCurrentChange"
+            :current-page="currentPage"
+            :page-size="pageSize"
+            layout="total, prev, pager, next, jumper"
+            :total="parseInt(tableCount)">
+          </el-pagination>
+        </div>
+      </div>
+    </div>
+  <Dialog title="温馨提示" content="您确认要删除该角色吗?"
+          @close="DialogShow = false"
+          @submitSureClick="submitSureClickDel"
+          @DialogFalse="DialogShow = false"
+          :innerVisible="DialogShow">
+  </Dialog>
+  <DialogSlot
+      title="添加"
+      @close="roleDialogShow = false"
+      @DialogClose="roleDialogShow = false"
+      :innerVisible="roleDialogShow"
+      @colesClick="roleDialogShow  = false"
+  >
+    <editFrom
+        @colesClick="roleDialogShow = false"
+        :roleDataForm="roleDataForm"
+         :isloading="isloading"
+        @roleSubmitClick="roleSubmitClick"
+        @closeDlg="closeDlg"
+        >
+    </editFrom>
+  </DialogSlot>
+
+
+  </template>
+  <script>
+  import Dialog from "../../components/dialog";
+  import editFrom from "./components/edit";
+  import DialogSlot from "../../components/DialogSlot";
+  export default {
+    components: {
+      Dialog,
+      editFrom,
+      DialogSlot
+    },
+    data() {
+      return {
+        value:"1",
+        //  菜单列表数据
+        tableData: [],
+        //  加载中数据提示
+        tableDataLoadingText:"拼命加载中······",
+        //  是否显示分页
+        pagination:false,
+        //  每页显示的条数
+        pageSize:10,
+        //  当前页
+        currentPage:1,
+        //  菜单列表数据总条数
+        tableCount:0,
+  
+        loadingFlag: false,
+        isShowSource: false, // 是否显示来源列
+        id:0,
+        DialogShow: false, //控制删除弹窗
+        websiteRoleId:'',
+        roleRowIndex:'',
+        roleDataForm: {},
+        roleTableData: [],
+        isloading:false, //提交按钮状态
+        roleDialogShow: false, // 控制保存弹窗
+
+
+        authorityDialogShow:false,
+        authorityDataForm: {},
+        keyword:'',
+        websiteId:''
+      }
+    },
+    mounted() {},
+    methods: {
+      // 获取菜单信息列表
+      getList:function(){
+        let _t = this;
+        _t.loadingFlag = true;
+        let parames = {
+            'page':this.currentPage,
+            'pageSize':this.pageSize,
+            'keyword':this.keyword,
+            'id':this.websiteId
+        }
+        this.$api.website.getAdminWebsiteRoleList(parames).then(res=>{
+                _t.loadingFlag = false;
+                if(res.code==200){
+                  if(res.data.rows.length==0){
+                    this.$message.error("没找到该角色!!!")
+                    return
+                  }
+                    _t.tableData = res.data.rows;
+                    _t.tableCount = res.data.count;
+                     //  总条数大于每页显示的条数时显示分页
+                    if( _t.tableCount > _t.pageSize ){
+                     _t.pagination = true;
+                    }
+                    if( _t.tableData.length==0 ){
+                     _t.tableDataLoadingText = "暂无数据";
+                    }
+                }else{
+                    this.$message.error("查询失败")
+                }
+            })
+      },
+      // 点击翻页
+      handleCurrentChange(val) {
+        this.currentPage = val;
+        this.getList();
+      },
+      // 查看下一级
+      nextClick( id ){
+        let _t = this;
+        _t.id = id
+        _t.currentPage = 1
+        _t.pageSize = 10
+       this.getList()
+      },
+      addClick(){
+        this.roleDataForm = {}
+        this.roleDialogShow = true
+      },
+      closeDlg(val){
+          this.roleDialogShow = false
+          this.isloading = false
+          this.authorityDialogShow = false
+      },
+      roleSubmitClick(data){
+        let _t = this
+        console.log("提交数据",data)
+        let parames = {
+          type_id:data.role_id,
+          type:'1',
+          website_id:this.websiteId
+        }
+        _t.isloading = true
+        this.$api.website.createAdminWebsiteRoleUser(parames).then(res=>{
+              _t.loadingFlag = false;
+              if(res.code==200){
+                    console.log("创建成功")
+                    this.getList()
+              }else{
+                  this.$message.error(res.message)
+              }
+              this.roleDialogShow = false
+              this.isloading = false
+          })
+      },
+   
+      //删除站点角色
+      deleteAuthority(row, index) {
+        this.websiteRoleId = row.website_role_user_id
+        this.roleRowIndex = index
+        this.DialogShow = true
+      },
+      submitSureClickDel(row,index){
+        let parames = {
+          'id':this.websiteRoleId
+        }
+        this.$api.website.delAdminWebsiteRoleUser(parames).then(res=>{
+          if(res.code==200){
+            this.DialogShow = false
+            this.getList()
+          }else{
+            this.$message.error("删除失败")
+          }
+        })
+      },
+      searchFrom(){
+        this.currentPage = 1
+        this.pageSize = 10
+        this.getList()
+      },
+      assignPermissions(row,index){
+        console.log(row)
+        this.authorityDataForm = row
+        this.rowIndex = index
+        this.authorityDialogShow = true
+      }
+
+    },
+    created() {
+        //赋值站点id
+        this.websiteId = this.$route.params.Id;
+        console.log("接收参数:",this.$route.params.Id);
+        this.getList();
+  
+    }
+  }
+  </script>
+
+  
+<style >
+.demo-form-inline{
+   display: flex;
+}
+.demo-form-inline .el-form-item{
+ margin: 0 20px;
+}
+</style>