|
@@ -0,0 +1,283 @@
|
|
|
+<template>
|
|
|
+ <section>
|
|
|
+ <!--工具条-->
|
|
|
+ <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
|
|
|
+ <el-form :inline="true" :model="filters">
|
|
|
+ <el-form-item>
|
|
|
+ <el-input v-model="filters.keyName" placeholder="请输入公司名称进行搜索" clearable></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click.native="getRoles">查询</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item style="float:right;">
|
|
|
+ <el-button type="primary" @click.native="handleAdd">新增</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!--列表-->
|
|
|
+ <el-table :data="list" highlight-current-row :height="tableHeight" v-loading="listLoading" style="width: 100%;">
|
|
|
+ <el-table-column prop="roleName" label="公司名称" sortable></el-table-column>
|
|
|
+ <el-table-column label="操作" width="150">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button size="small" @click.native="handleEdit(scope.$index, scope.row)">编辑</el-button>
|
|
|
+ <el-button type="danger" size="small" @click.native.native="handleDel(scope.$index, scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!--工具条-->
|
|
|
+ <el-col :span="24" class="toolbar">
|
|
|
+ <el-pagination
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :page-sizes="[20 , 50 , 80 , 100 , 200]"
|
|
|
+ :page-size="20"
|
|
|
+ layout="total, sizes, prev, pager, next"
|
|
|
+ :total="total"
|
|
|
+ style="float:right;">
|
|
|
+ </el-pagination>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!--新增界面-->
|
|
|
+ <el-dialog title="新增角色" :inline="true" :visible.sync="addFormVisible" :close-on-click-modal="false">
|
|
|
+ <el-form :model="addForm" label-width="80px" :rules="formRules" ref="addForm">
|
|
|
+ <el-form-item label="角色名称" prop="roleName">
|
|
|
+ <el-input v-model="addForm.roleName" auto-complete="off"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="角色名称" prop="roleName">
|
|
|
+ <el-input v-model="addForm.roleName" auto-complete="off"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click.native="addFormVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!--编辑界面-->
|
|
|
+ <el-dialog title="编辑人员" :inline="true" :visible.sync="editFormVisible" :close-on-click-modal="false">
|
|
|
+ <el-form :model="editForm" label-width="80px" :rules="formRules" ref="editForm">
|
|
|
+ <el-form-item label="角色名称" prop="roleName">
|
|
|
+ <el-input v-model="editForm.roleName" auto-complete="off"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="角色名称" prop="roleName">
|
|
|
+ <el-input v-model="addForm.roleName" auto-complete="off"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click.native="editFormVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click.native="editSubmit" :loading="editLoading">提交</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </section>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import util from '../../common/js/util'
|
|
|
+
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ filters: {
|
|
|
+ keyName: ''
|
|
|
+ },
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ page: 1,
|
|
|
+ size: 20,
|
|
|
+ listLoading: false,
|
|
|
+ tableHeight: 0,
|
|
|
+
|
|
|
+ formRules: {
|
|
|
+ roleName: [
|
|
|
+ { required: true, message: '请输入公司名称', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+
|
|
|
+ // 新增界面
|
|
|
+ addFormVisible: false,
|
|
|
+ addLoading: false,
|
|
|
+ addForm: {
|
|
|
+ roleName: ''
|
|
|
+ },
|
|
|
+
|
|
|
+ // 编辑界面
|
|
|
+ editFormVisible: false,
|
|
|
+ editLoading: false,
|
|
|
+ editForm: {
|
|
|
+ id: 0,
|
|
|
+ roleName: ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 分页
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.page = val;
|
|
|
+ this.getRoles();
|
|
|
+ },
|
|
|
+
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.size = val;
|
|
|
+ this.getRoles();
|
|
|
+ },
|
|
|
+
|
|
|
+ //获取用户列表
|
|
|
+ getRoles() {
|
|
|
+ this.listLoading = true;
|
|
|
+ this.http.post(this.port.base.companyList, {
|
|
|
+ keyName: this.filters.keyName
|
|
|
+ }, res => {
|
|
|
+ this.listLoading = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.list = res.data;
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, error => {
|
|
|
+ this.listLoading = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ //显示新增界面
|
|
|
+ handleAdd: function () {
|
|
|
+ this.addFormVisible = true;
|
|
|
+ this.addForm = {
|
|
|
+ roleName: ''
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ //新增
|
|
|
+ addSubmit: function () {
|
|
|
+ this.$refs.addForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.addLoading = true;
|
|
|
+ this.http.post(this.port.base.addCompany, {
|
|
|
+ roleName: this.addForm.roleName,
|
|
|
+ flag: 0
|
|
|
+ }, res => {
|
|
|
+ this.addLoading = false;
|
|
|
+ this.addFormVisible = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.$message({
|
|
|
+ message: '创建成功',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ this.getRoles();
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, error => {
|
|
|
+ this.addLoading = false;
|
|
|
+ this.addFormVisible = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ //删除
|
|
|
+ handleDel: function (index, row) {
|
|
|
+ this.$confirm('确认删除该公司吗?', '提示', {
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ var _this = this;
|
|
|
+ this.addLoading = true;
|
|
|
+ this.http.post(this.port.base.delCompany, {
|
|
|
+ id: row.id
|
|
|
+ }, res => {
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.$message({
|
|
|
+ message: '删除成功',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ this.getRoles();
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, error => {
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ //显示编辑界面
|
|
|
+ handleEdit: function (index, row) {
|
|
|
+ this.editFormVisible = true;
|
|
|
+ this.editForm = {
|
|
|
+ id: row.id,
|
|
|
+ roleName: row.roleName
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ //编辑
|
|
|
+ editSubmit: function () {
|
|
|
+ this.$refs.editForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.editLoading = true;
|
|
|
+ this.http.post(this.port.base.addCompany, {
|
|
|
+ id: this.editForm.id,
|
|
|
+ roleName: this.editForm.roleName,
|
|
|
+ flag: 1
|
|
|
+ }, res => {
|
|
|
+ this.editLoading = false;
|
|
|
+ this.editFormVisible = false;
|
|
|
+ if (res.code == "ok") {
|
|
|
+ this.$message({
|
|
|
+ message: '修改成功',
|
|
|
+ type: 'success'
|
|
|
+ });
|
|
|
+ this.getRoles();
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, error => {
|
|
|
+ this.editLoading = false;
|
|
|
+ this.editFormVisible = false;
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ created() {
|
|
|
+ let height = window.innerHeight;
|
|
|
+ this.tableHeight = height - 240;
|
|
|
+ },
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ this.getRoles();
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|