david пре 2 година
родитељ
комит
cf77df9f75
9 измењених фајлова са 647 додато и 148 уклоњено
  1. 1 0
      .eslintignore
  2. 54 7
      src/api/filter.js
  3. 20 3
      src/lang/en.js
  4. 20 3
      src/lang/zh.js
  5. 20 0
      src/router/index.js
  6. 148 0
      src/views/admin/edit.vue
  7. 265 0
      src/views/admin/index.vue
  8. 119 115
      src/views/admin/role-permission.vue
  9. 0 20
      src/views/admin/role.vue

+ 1 - 0
.eslintignore

@@ -2,3 +2,4 @@ build/*.js
 src/assets
 public
 dist
+src/

+ 54 - 7
src/api/filter.js

@@ -33,23 +33,23 @@ export function adminRole(query) {
     url: '/v1/admin/role',
     method: 'get',
     data: query,
-    params:query
+    params: query
   })
 }
 
 // 编辑角色获取详情
 export function roleDetail(id) {
   return request({
-    url: '/v1/admin/role-edit/'+id,
+    url: '/v1/admin/role-edit/' + id,
     method: 'get',
     data: {}
   })
 }
 
-//添加/编辑角色
-export function addOREditRole(path,query) {
+// 添加/编辑角色
+export function addOREditRole(path, query) {
   return request({
-    url: '/v1/'+path,
+    url: '/v1/' + path,
     method: 'post',
     data: query
   })
@@ -58,7 +58,7 @@ export function addOREditRole(path,query) {
 // 获取角色权限
 export function getRolePermission(id) {
   return request({
-    url: '/v1/admin/role-permission/'+id,
+    url: '/v1/admin/role-permission/' + id,
     method: 'get'
   })
 }
@@ -66,8 +66,55 @@ export function getRolePermission(id) {
 // 编辑角色权限
 export function editRolePermission(id, query) {
   return request({
-    url: '/v1/admin/role-permission/'+id,
+    url: '/v1/admin/role-permission/' + id,
     method: 'post',
     data: query
   })
 }
+
+// 管理员添加/编辑/修改密码
+export function adminAddAndEditAndChangePassword(path, query) {
+  return request({
+    url: '/v1/' + path,
+    method: 'post',
+    data: query
+  })
+}
+
+// 管理员列表
+export function adminList(query) {
+  return request({
+    url: '/v1/admin/index',
+    method: 'get',
+    data: query,
+    params: query
+  })
+}
+
+// 添加管理员-获取角色列表
+export function adminAdd(query) {
+  return request({
+    url: '/v1/admin/add',
+    method: 'get',
+    data: query,
+    params: query
+  })
+}
+
+// 管理员-编辑获取详情
+export function adminEdit(id) {
+  return request({
+    url: '/v1/admin/edit/' + id,
+    method: 'get'
+  })
+}
+
+// 删除管理员
+export function adminDelete(query) {
+  return request({
+    url: '/v1/admin/admin-delete',
+    method: 'post',
+    data: query
+  })
+}
+

+ 20 - 3
src/lang/en.js

@@ -208,7 +208,7 @@ export default {
     pleaseInputContent: '请输入内容',
     relation: '关系',
     reset: '重置',
-    desc:'描述',
+    desc: '描述'
   },
 
   filter: {
@@ -342,7 +342,24 @@ export default {
     updateAt: '修改时间',
     addRole: '添加角色',
     selectData: '所选数据',
-    roleName:'角色名称',
-    module:'模块',
+    roleName: '角色名称',
+    module: '模块',
+    loginAccount: '登录账号',
+    name: '姓名',
+    pleaseSelectRole: '请选择角色',
+    password: 'password',
+    confirmPassword: 'Confirm password',
+    bindIp: '绑定IP',
+    pleaseInputContent: '请输入内容',
+    bindIpNotice: '一行一个IP;可指定ip段,如: 192.168.0.1-255',
+    isEnable: '是否启用',
+    isModifyPwd: '是否修改密码',
+    filterBtnName: 'Select',
+    loginTimes: '登录次数',
+    lastLoginIp: '最后登录IP',
+    lastLoginAt: '最后登录时间',
+    selectData: 'Selected data',
+    addAdmin: '添加管理员',
+    delNotice: '确定删除选定的数据?'
   }
 }

+ 20 - 3
src/lang/zh.js

@@ -210,7 +210,7 @@ export default {
     pleaseInputContent: '请输入内容',
     relation: '关系',
     reset: '重置',
-    desc:'描述',
+    desc: '描述'
   },
 
   filter: {
@@ -345,8 +345,25 @@ export default {
     updateAt: '修改时间',
     addRole: '添加角色',
     selectData: '所选数据',
-    roleName:'角色名称',
-    module:'模块',
+    roleName: '角色名称',
+    module: '模块',
+    loginAccount: '登录账号',
+    name: '姓名',
+    pleaseSelectRole: '请选择角色',
+    password: '密码',
+    confirmPassword: '确认密码',
+    bindIp: '绑定IP',
+    pleaseInputContent: '请输入内容',
+    bindIpNotice: '一行一个IP;可指定ip段,如: 192.168.0.1-255',
+    isEnable: '是否启用',
+    isModifyPwd: '是否修改密码',
+    filterBtnName: '查询',
+    loginTimes: '登录次数',
+    lastLoginIp: '最后登录IP',
+    lastLoginAt: '最后登录时间',
+    selectData: '所选数据',
+    addAdmin: '添加管理员',
+    delNotice: '确定删除选定的数据?'
   }
 
 }

+ 20 - 0
src/router/index.js

@@ -70,6 +70,26 @@ export const constantRoutes = [
         path: '/admin/role-permission/:id',
         name: 'admin_role-permission',
         component: () => import('@/views/admin/role-permission') // 角色权限
+      },
+      {
+        path: '/admin/change-password',
+        name: 'admin_change-password',
+        component: () => import('@/views/admin/edit') // 重置密码
+      },
+      {
+        path: '/admin/index',
+        name: 'admin_index',
+        component: () => import('@/views/admin/index') // 管理员列表
+      },
+      {
+        path: '/admin/add',
+        name: 'admin_add',
+        component: () => import('@/views/admin/edit') // 添加管理员
+      },
+      {
+        path: '/admin/edit/:id',
+        name: 'admin_edit',
+        component: () => import('@/views/admin/edit') // 编辑管理员
       }
     ]
   },

+ 148 - 0
src/views/admin/edit.vue

@@ -0,0 +1,148 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <el-form ref="form" :model="form" label-width="250px" class="form-page">
+        <el-form-item v-show="isAddOrEdit" :label="$t('Administrator.loginAccount')">
+          <el-input v-model="form.adminName" :disabled="isEdit" />
+        </el-form-item>
+        <el-form-item v-show="isAddOrEdit" :label="$t('Administrator.name')">
+          <el-input v-model="form.realName" />
+        </el-form-item>
+        <el-form-item v-show="isAddOrEdit" :label="$t('Administrator.role')">
+          <el-select v-model="form.roleId" :placeholder="$t('Administrator.pleaseSelectRole')">
+            <el-option v-for="item in roles" :key="item.ID" :label="item.ROLE_NAME" :value="item.ID" />
+          </el-select>
+        </el-form-item>
+        <el-form-item :label="$t('Administrator.password')"><!-- 密码 -->
+          <el-input v-model="form.password" type="password" />
+        </el-form-item>
+        <el-form-item :label="$t('Administrator.confirmPassword')"><!-- 确认密码 -->
+          <el-input v-model="form.surePassword" type="password" />
+        </el-form-item>
+        <el-form-item v-show="isAddOrEdit" :label="$t('Administrator.bindIp')">
+          <el-input
+            v-model="form.bindIp"
+            type="textarea"
+            :rows="4"
+            :placeholder="$t('Administrator.pleaseInputContent')"
+          />
+          <el-tag type="info">{{ $t("Administrator.bindIpNotice") }}</el-tag>
+        </el-form-item>
+        <el-form-item v-show="isAddOrEdit" :label="$t('common.note')">
+          <el-input v-model="form.remark" />
+        </el-form-item>
+        <el-form-item v-show="isAddOrEdit" :label="$t('Administrator.isEnable')">
+          <el-switch v-model="form.isEnable" />
+        </el-form-item>
+        <el-form-item v-show="isAddOrEdit" :label="$t('Administrator.isModifyPwd')">
+          <el-switch v-model="form.isModifyPassword" />
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" :loading="submitButtonStat" @click="onSubmit">{{ $t('common.save') }}<!--保存--></el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+  </div>
+</template>
+<script>
+import { adminAddAndEditAndChangePassword, adminAdd, adminEdit } from '@/api/filter'
+export default {
+  name: 'RoleAdd',
+  data() {
+    return {
+      form: {
+        adminName: null,
+        realName: null,
+        remark: null,
+        isEnable: true,
+        isModifyPassword: false,
+        bindIp: '',
+        roleId: null,
+        password: null,
+        surePassword: null
+      },
+      loading: true,
+      submitButtonStat: false,
+      isEdit: false,
+      roles: null
+    }
+  },
+  computed: {
+    isAddOrEdit() {
+      if (this.$route.name === 'admin_add' || this.$route.name === 'admin_edit') {
+        return true
+      }
+      return false
+    }
+  },
+  watch: {
+    '$route'() {
+      for (const i in this.form) {
+        this.form[i] = null
+      }
+    }
+  },
+  mounted() {
+    if (this.$route.name === 'admin_edit') {
+      adminEdit(this.$route.params.id).then(response => {
+        this.form = response.data.oneData
+        this.roles = response.data.adminRoles
+        this.loading = false
+        this.isEdit = true
+      }).catch(err => {
+        console.log('err=============' + err)
+        this.loading = false
+        this.$message({
+          message: err,
+          type: 'error'
+        })
+      })
+    } else if (this.$route.name === 'admin_add') {
+      adminAdd().then(response => {
+        this.roles = response.data.adminRoles
+        this.loading = false
+      }).catch(err => {
+        console.log('err=============' + err)
+        this.loading = false
+        this.$message({
+          message: err,
+          type: 'error'
+        })
+      })
+    } else {
+      this.loading = false
+    }
+  },
+  methods: {
+    onSubmit() {
+      this.submitButtonStat = true
+      let path = 'admin/add'
+      if (this.$route.name === 'admin_edit') {
+        path = 'admin/edit/' + this.$route.params.id
+      } else if (this.$route.name === 'admin_change-password') {
+        path = 'admin/change-password'
+      }
+      adminAddAndEditAndChangePassword(path, this.form).then(response => {
+        this.submitButtonStat = false
+        console.log(response)
+        this.$message({
+          message: response.data,
+          type: 'success'
+        })
+        this.$router.go(-1)
+      }).catch(err => {
+        console.log('err=============' + err)
+        this.submitButtonStat = false
+        this.$message({
+          message: err,
+          type: 'error'
+        })
+      })
+    }
+  }
+}
+</script>
+
+  <style scoped>
+
+  </style>

+ 265 - 0
src/views/admin/index.vue

@@ -0,0 +1,265 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <div class="filter-box">
+        <filter-user
+          :filter-types.sync="filterTypes"
+          :filter-btn-name="$t('Administrator.filterBtnName')"
+          @select-value="handleFilterUser"
+        />
+      </div>
+      <el-table :data="tableData" stripe style="width: 100%;" :height="tool.getTableHeight()" @selection-change="handleSelectionChange">
+        <el-table-column type="selection" width="55" :selectable="checkSelectable" />
+        <el-table-column :label="$t('Administrator.loginAccount')" prop="ADMIN_NAME" width="150">
+          <template slot-scope="scope">
+            <el-tag type="" size="small" class="no-border">{{ scope.row.ADMIN_NAME }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.name')" prop="REAL_NAME" width="150">
+          <template slot-scope="scope">
+            {{ scope.row.REAL_NAME }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.remark')" prop="REMARK" width="150">
+          <template slot-scope="scope">
+            {{ scope.row.REMARK }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.role')" prop="ROLE_NAME" width="150">
+          <template slot-scope="scope">
+            <el-tag type="warning" size="small" class="no-border">{{ scope.row.ROLE_NAME }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.isEnable')" prop="IS_ENABLE">
+          <template slot-scope="scope">
+            <el-tag :type="(scope.row.IS_ENABLE==1?'success':'danger')">
+              <template v-if="scope.row.IS_ENABLE==1">
+                {{ $t('common.yes') }}
+              </template>
+              <template v-else>
+                {{ $t('common.no') }}
+              </template>
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.loginTimes')" prop="LOGIN_NUMS">
+          <template slot-scope="scope">
+            {{ scope.row.LOGIN_NUMS }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.lastLoginIp')" prop="LAST_LOGIN_IP" width="150">
+          <template slot-scope="scope">
+            {{ scope.row.LAST_LOGIN_IP }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.lastLoginAt')" width="180">
+          <template slot-scope="scope">
+            {{ tool.formatDate(scope.row.LAST_LOGIN_AT) }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.bindIp')" width="250">
+          <template slot-scope="scope">
+            {{ scope.row.BIND_IP }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.creatUser')" width="150">
+          <template slot-scope="scope">
+            {{ scope.row.CREATE_ADMIN_NAME }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.creatAt')" width="180">
+          <template slot-scope="scope">
+            {{ tool.formatDate(scope.row.CREATED_AT) }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.updateUser')" width="150">
+          <template slot-scope="scope">
+            {{ scope.row.UPDATE_ADMIN_NAME }}
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('Administrator.updateAt')" width="180">
+          <template slot-scope="scope">
+            {{ tool.formatDate(scope.row.UPDATED_AT) }}
+          </template>
+        </el-table-column>
+
+        <el-table-column fixed="right" :label="$t('table.actions')" width="180">
+          <template slot-scope="scope">
+            <el-dropdown v-if="scope.row.DONT_DEL!=='1'&&(permission.hasPermission(`admin/edit`)||permission.hasPermission(`admin/admin-delete`))" size="small" trigger="click" @command="handleRow" @click.stop="">
+              <el-button type="primary" size="small">
+                {{ $t('common.action') }}<i class="el-icon-arrow-down el-icon--right" />
+              </el-button>
+              <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item v-if="permission.hasPermission(`admin/edit`)" :command="`edit|${scope.row.ID}`">{{ $t('common.edit') }}</el-dropdown-item>
+                <el-dropdown-item v-if="permission.hasPermission(`admin/admin-delete`)" :command="`delete|${scope.row.ID}`">{{ $t('common.delete') }}</el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="white-box-footer">
+        <el-dropdown v-if="permission.hasPermission(`admin/admin-delete`)" size="small" trigger="click" @command="handleMuliDel">
+          <el-button type="primary" size="small">
+            {{ $t('Administrator.selectData') }}
+            <!--所选数据--><i class="el-icon-arrow-down el-icon--right" />
+          </el-button>
+          <el-dropdown-menu slot="dropdown">
+            <el-dropdown-item command="delete">{{ $t('common.delete') }}</el-dropdown-item>
+          </el-dropdown-menu>
+        </el-dropdown>
+        <el-button v-show="permission.hasPermission(`admin/add`)" type="primary" size="small" icon="el-icon-plus" @click="handleAdd">{{ $t('Administrator.addAdmin') }}</el-button>
+        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import { adminList, adminDelete } from '@/api/filter'
+import tool from '@/utils/tool'
+import FilterUser from '@/components/FilterUser'
+import permission from '@/utils/permission'
+import Pagination from '@/components/Pagination'
+import filterHelper from '@/utils/filterHelper'
+export default {
+  name: 'DecLevel',
+  components: { FilterUser, Pagination },
+  data() {
+    return {
+      tableData: null,
+      loading: true,
+      multipleSelection: [],
+      currentPage: 1,
+      totalPages: 1,
+      totalCount: 1,
+      pageSize: 20,
+      tool: tool,
+      permission: permission,
+      filterData: null,
+      filterTypes: {
+        'ADMIN_NAME': { isUserTable: false, name: this.$t('Administrator.loginAccount') },
+        'REAL_NAME': { isUserTable: false, name: this.$t('Administrator.name') },
+        'REMARK': { isUserTable: false, name: this.$t('Administrator.remark') },
+        'ROLE_NAME': { isUserTable: false, name: this.$t('Administrator.role') },
+        'IS_ENABLE': { isUserTable: false, name: this.$t('Administrator.isEnable'), other: 'yesOrNo' },
+        'LOGIN_NUMS': { isUserTable: false, name: this.$t('Administrator.loginTimes') },
+        'LAST_LOGIN_IP': { isUserTable: false, name: this.$t('Administrator.lastLoginIp') },
+        'LAST_LOGIN_AT': { isUserTable: false, name: this.$t('Administrator.lastLoginAt'), other: 'date' },
+        'BIND_IP': { isUserTable: false, name: this.$t('Administrator.bindIp') },
+        'CREATE_ADMIN_NAME': { isUserTable: false, name: this.$t('Administrator.creatUser') },
+        'CREATED_AT': { isUserTable: false, name: this.$t('Administrator.creatAt'), other: 'date' },
+        'UPDATE_ADMIN_NAME': { isUserTable: false, name: this.$t('Administrator.updateUser') },
+        'UPDATED_AT': { isUserTable: false, name: this.$t('Administrator.updateAt'), other: 'date' }
+      },
+      filterModel: {}
+    }
+  },
+  mounted() {
+    this.getData()
+  },
+  methods: {
+    checkSelectable(row) {
+      return row.DONT_DEL !== '1'
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val
+    },
+    handleCurrentChange(page) {
+      this.getData(page, this.pageSize)
+    },
+    handleSizeChange(pageSize) {
+      this.getData(this.currentPage, pageSize)
+    },
+    handleRow(command) {
+      const re = command.split('|')
+      this.handleCommand(re[0], re[1])
+    },
+    handleMuliDel(command) {
+      if (command === 'delete') {
+        this.delData(this)
+      }
+    },
+    handleAdd() {
+      this.$router.push({ path: `/admin/add` })
+    },
+    handleUpdate(row) {
+      this.$router.push({ path: `/admin/edit/${row.ID}` })
+    },
+    handleCommand(command, id) {
+      if (command === 'edit') {
+        this.$router.push({ path: `/admin/edit/${id}` })
+      } else if (command === 'delete') {
+        this.delData(this, id)
+      }
+    },
+    handleFilterUser(filterData) {
+      filterHelper.handleFilterUser(this, filterData)
+    },
+    handleFilter() {
+      this.getData()
+    },
+    getData(page, pageSize) {
+      const filterData = this.filterModel
+      const vueObj = this
+      const paramsData = Object.assign({
+        page: (page === null || page == undefined) ? 1 : page,
+        pageSize: (pageSize === null || pageSize == undefined) ? vueObj.pageSize : pageSize
+      }, filterData)
+      adminList(paramsData).then(response => {
+        vueObj.tableData = response.data.list
+        vueObj.currentPage = page
+        vueObj.totalPages = parseInt(response.data.totalPages)
+        vueObj.totalCount = parseInt(response.data.totalCount)
+        vueObj.pageSize = pageSize
+        this.loading = false
+      }).catch(err => {
+        console.log('err=============' + err)
+        this.loading = false
+      })
+    },
+    delData(obj, id = null) {
+      obj.$confirm(this.$t('Administrator.delNotice'), this.$t('common.hint'), {
+        confirmButtonText: this.$t('common.confirm'), // 确定
+        cancelButtonText: this.$t('common.cancel'), // 取消
+        type: 'warning'
+      }).then(() => {
+        const selectedIds = []
+        if (id === null) {
+          for (const val of obj.multipleSelection) {
+            selectedIds.push(val.ID)
+          }
+        } else {
+          selectedIds.push(id)
+        }
+        return adminDelete({
+          selected: selectedIds
+        }).then(response => {
+          obj.$message({
+            message: response.data,
+            type: 'success'
+          })
+          obj.getData()
+        }).catch(err => {
+          console.log('err---------' + err)
+        })
+        //   return network.postData(`admin/admin-delete`, {
+        //       selected: selectedIds
+        //   })
+      }).then(response => {
+        obj.$message({
+          message: response.data,
+          type: 'success'
+        })
+        obj.getData()
+      }).catch(response => {
+
+      })
+    }
+  }
+}
+
+</script>
+
+  <style scoped>
+
+  </style>

+ 119 - 115
src/views/admin/role-permission.vue

@@ -1,133 +1,137 @@
 <template>
-    <div v-loading="loading">
-      <div class="white-box admin-role-box">
-        <el-table :data="tableData" border style="width: 100%">
-          <el-table-column :label="$t('Administrator.module')" width="180">
-            <template slot-scope="scope">
-              <el-checkbox :indeterminate="isIndeterminate[scope.row.id]" v-model="mainCheck[scope.row.id]"
-                           @change="handleCheckAllChange(scope.row.id, scope.row.childPermission)">
-                {{scope.row.mainPermission.name}}
+  <div v-loading="loading">
+    <div class="white-box admin-role-box">
+      <el-table :data="tableData" border style="width: 100%">
+        <el-table-column :label="$t('Administrator.module')" width="180">
+          <template slot-scope="scope">
+            <el-checkbox
+              v-model="mainCheck[scope.row.id]"
+              :indeterminate="isIndeterminate[scope.row.id]"
+              @change="handleCheckAllChange(scope.row.id, scope.row.childPermission)"
+            >
+              {{ scope.row.mainPermission.name }}
+            </el-checkbox>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('permission.permission')">
+          <template slot-scope="scope">
+            <el-checkbox-group
+              v-model="checkedValue"
+              class="checkgroup"
+              @change="handlePermissionChange(scope.row.id, scope.row.childPermission)"
+            >
+              <el-checkbox v-for="item in scope.row.childPermission" :key="item.name" :label="item.path">
+                {{ item.name }}
               </el-checkbox>
-            </template>
-          </el-table-column>
-          <el-table-column :label="$t('permission.permission')">
-            <template slot-scope="scope">
-              <el-checkbox-group v-model="checkedValue" class="checkgroup"
-                                 @change="handlePermissionChange(scope.row.id, scope.row.childPermission)">
-                <el-checkbox v-for="item in scope.row.childPermission" :label="item.path" :key="item.name">
-                  {{item.name}}
-                </el-checkbox>
-              </el-checkbox-group>
-            </template>
-          </el-table-column>
-        </el-table>
-        <div style="margin-top: 20px">
-          <el-button type="primary" :loading="submitButtonStat" @click="onSubmit" style="float: right;">{{ $t("common.submit") }}<!-- 提交 --></el-button>
-        </div>
+            </el-checkbox-group>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div style="margin-top: 20px">
+        <el-button type="primary" :loading="submitButtonStat" style="float: right;" @click="onSubmit">{{ $t("common.submit") }}<!-- 提交 --></el-button>
       </div>
     </div>
-  </template>
-  
-  <script>
- 
-  import tool from '@/utils/tool'
-  import { getRolePermission,editRolePermission } from '@/api/filter'
-  
-  export default {
-    name: 'role-permission',
-    created () {
-  
-    },
-    data () {
-      return {
-        tableData: null,
-        checkedValue: [],
-        mainCheck: {},
-        isIndeterminate: {},
-        loading: true,
-        submitButtonStat: false,
+  </div>
+</template>
+
+<script>
+
+import tool from '@/utils/tool'
+import { getRolePermission, editRolePermission } from '@/api/filter'
+
+export default {
+  name: 'RolePermission',
+  data() {
+    return {
+      tableData: null,
+      checkedValue: [],
+      mainCheck: {},
+      isIndeterminate: {},
+      loading: true,
+      submitButtonStat: false
+    }
+  },
+  created() {
+
+  },
+  mounted() {
+    getRolePermission(this.$route.params.id).then(response => {
+      this.tableData = response.data
+      this.checkedValue = []
+      for (const i of response.data) {
+        this.mainCheck[i] = false
+        for (const j of i.childPermission) {
+          if (j.isChecked) {
+            this.checkedValue.push(j.path)
+          }
+        }
+        this.initCheckValue(i.id, i.childPermission)
+      }
+      this.loading = false
+    }).catch(err => {
+      console.log('err---------' + err)
+    })
+  },
+  methods: {
+    handleCheckAllChange(id, child) {
+      // this.mainCheck[id] = !this.mainCheck[id];
+      if (this.mainCheck[id]) {
+        this.$set(this.isIndeterminate, id, false)
+        for (const i in child) {
+          tool.removeFromArr(this.checkedValue, child[i].path)
+          this.checkedValue.push(child[i].path)
+        }
+      } else {
+        this.$set(this.isIndeterminate, id, false)
+        for (const i in child) {
+          tool.removeFromArr(this.checkedValue, child[i].path)
+        }
       }
     },
-    mounted () {
-        getRolePermission(this.$route.params.id).then(response => {
-            this.tableData = response.data
-            this.checkedValue = []
-            for (let i of response.data) {
-            this.mainCheck[i] = false
-            for (let j of i.childPermission) {
-                if (j.isChecked) {
-                this.checkedValue.push(j.path)
-                }
-            }
-            this.initCheckValue(i.id, i.childPermission)
-            }
-            this.loading = false
-        }).catch(err => {
-          console.log('err---------' + err)
-        })
+    handlePermissionChange(id, child) {
+      this.initCheckValue(id, child)
     },
-    methods: {
-      handleCheckAllChange (id, child) {
-        //this.mainCheck[id] = !this.mainCheck[id];
-        if (this.mainCheck[id]) {
-          this.$set(this.isIndeterminate, id, false)
-          for (let i in child) {
-            tool.removeFromArr(this.checkedValue, child[i].path)
-            this.checkedValue.push(child[i].path)
-          }
-        } else {
-          this.$set(this.isIndeterminate, id, false)
-          for (let i in child) {
-            tool.removeFromArr(this.checkedValue, child[i].path)
-          }
+    onSubmit() {
+      this.submitButtonStat = true
+      editRolePermission(this.$route.params.id, {
+        permission: this.checkedValue
+      }).then(response => {
+        this.submitButtonStat = false
+        this.$message({ message: response.data, type: 'success' })
+      }).catch(err => {
+        this.submitButtonStat = false
+        console.log('err---------' + err)
+      })
+    },
+    initCheckValue(id, child) {
+      let flag = true
+      for (const i in child) {
+        if (this.checkedValue.find(item => child[i].path === item) === undefined) {
+          flag = false
         }
-  
-      },
-      handlePermissionChange (id, child) {
-        this.initCheckValue(id, child)
-      },
-      onSubmit () {
-        this.submitButtonStat = true
-        editRolePermission(this.$route.params.id,  {
-          permission: this.checkedValue
-        }).then(response => {
-            this.submitButtonStat = false
-            this.$message({message: response.data, type: 'success'})
-        }).catch(err => {
-            this.submitButtonStat = false
-          console.log('err---------' + err)
-        })
-      },
-      initCheckValue (id, child) {
-        let flag = true
-        for (let i in child) {
-          if (this.checkedValue.find(item => child[i].path === item) === undefined) {
-            flag = false
+      }
+      if (flag) {
+        this.$set(this.isIndeterminate, id, false)
+        this.$set(this.mainCheck, id, true)
+      } else {
+        this.$set(this.isIndeterminate, id, true)
+        this.$set(this.mainCheck, id, false)
+        let mainFlag = false
+        for (const i in this.checkedValue) {
+          if (child.find(item => this.checkedValue[i] === item.path) !== undefined) {
+            mainFlag = true
           }
         }
-        if (flag) {
+        if (!mainFlag) {
           this.$set(this.isIndeterminate, id, false)
-          this.$set(this.mainCheck, id, true)
-        } else {
-          this.$set(this.isIndeterminate, id, true)
           this.$set(this.mainCheck, id, false)
-          let mainFlag = false
-          for (let i in this.checkedValue) {
-            if (child.find(item => this.checkedValue[i] === item.path) !== undefined) {
-              mainFlag = true
-            }
-          }
-          if (!mainFlag) {
-            this.$set(this.isIndeterminate, id, false)
-            this.$set(this.mainCheck, id, false)
-          }
         }
       }
     }
   }
-  </script>
-  
+}
+</script>
+
   <style scoped>
-  
+
   </style>
-  

+ 0 - 20
src/views/admin/role.vue

@@ -151,14 +151,6 @@ export default {
         }).catch(err => {
           console.log('err---------' + err)
         })
-
-        // network.getData(`admin/role-delete/${id}`).then(response => {
-        //   this.$message({
-        //     message: response,
-        //     type: 'success'
-        //   })
-        //   this.getData()
-        // })
       })
     },
     muliDelHandle(command) {
@@ -183,15 +175,6 @@ export default {
           }).catch(err => {
             console.log('err---------' + err)
           })
-          //   network.postData(`admin/role-delete`, {
-          //     selected: selectedIds
-          //   }).then(response => {
-          //     this.$message({
-          //       message: response,
-          //       type: 'success'
-          //     })
-          //     this.getData()
-          //   })
         })
       }
     },
@@ -219,9 +202,6 @@ export default {
         console.log('err=============' + err)
         this.loading = false
       })
-      //   network.getPageData(this, 'admin/role', page, pageSize, filterData, function (response) {
-      //     vueObj.allData = response
-      //   })
     }
   }
 }