Commit 377b7b15 by 胡悦

完成删除选中

2 parents 8c46f021 4f5c5db0
import {
roleTest,
deleteRoleById,
deleteUserRoleById,
getRoleDetail,
getRoleList,
isRoleNameExit,
addRole,
// isRoleNameExit,
saveRoleList,
selectMenuTreeRoleId,
selectUserRoleByRoleId,
updateRole
} from './roleApi'
import {
getUser,
batcheDelUser,
findUserList,
getUserInfo,
findAll,
getUser,
getWithRoles,
operatUser,
updateUser
......@@ -41,21 +39,19 @@ import {
export {
// role接口
roleTest,
deleteRoleById,
deleteUserRoleById,
getRoleDetail,
getRoleList,
isRoleNameExit,
addRole,
// isRoleNameExit,
saveRoleList,
selectMenuTreeRoleId,
selectUserRoleByRoleId,
updateRole,
// user接口
getUser,
batcheDelUser,
findUserList,
getUserInfo,
findAll,
getUser,
getWithRoles,
operatUser,
updateUser,
......
......@@ -2,22 +2,16 @@ import {
GlAxios
} from 'glsx-vue-common'
const path = 'role'
const __sTest = `${path}/roleList`
const __sDeleteRole = `${path}/deleteRoleById`
const __sDeleteUserRole = `${path}/deleteUserRoleById`
const __sGetRoleDetail = `${path}/getRoleDetail`
const __sGetRoleList = `${path}/getRoleList`
const __sIsRoleNameExit = `${path}/isRoleNameExit`
const __sAddRole = `${path}/saveRoleList`
// const __sIsRoleNameExit = `${path}/isRoleNameExit`
const __sSaveRoleList = `${path}/saveRoleList`
const __sSelectMenuTreeRoleId = `${path}/selectMenuTreeRoleId`
const __sSelectUserRole = `${path}/selectUserRoleByRoleId`
const __sUpdateRole = `${path}/updateRole`
const roleTest = {
p: [__sTest],
req: params => GlAxios.post(__sTest, params)
}
const deleteRoleById = {
p: [__sDeleteRole],
req: params => GlAxios.post(__sDeleteRole, params)
......@@ -38,15 +32,16 @@ const getRoleList = {
req: params => GlAxios.get(__sGetRoleList, { params })
}
const isRoleNameExit = {
p: [__sIsRoleNameExit],
req: params => GlAxios.get(__sIsRoleNameExit, { params })
}
// const isRoleNameExit = {
// p: [__sIsRoleNameExit],
// req: params => GlAxios.get(__sIsRoleNameExit, { params })
// }
const addRole = {
p: [__sAddRole],
req: params => GlAxios.post(__sAddRole, params)
const saveRoleList = {
p: [__sSaveRoleList],
req: params => GlAxios.post(__sSaveRoleList, params)
}
const selectMenuTreeRoleId = {
p: [__sSelectMenuTreeRoleId],
req: params => GlAxios.get(__sSelectMenuTreeRoleId, { params })
......@@ -63,13 +58,12 @@ const updateRole = {
}
export {
roleTest,
deleteRoleById,
deleteUserRoleById,
getRoleDetail,
getRoleList,
isRoleNameExit,
addRole,
// isRoleNameExit,
saveRoleList,
selectMenuTreeRoleId,
selectUserRoleByRoleId,
updateRole
......
......@@ -2,7 +2,6 @@ import {
GlAxios
} from 'glsx-vue-common'
const path = 'user'
const __sUserTest = `role/userList`
const __sBatcheDel = `${path}/batcheDel`
const __sFindAll = `${path}/findAll`
const __sGet = `${path}/get`
......@@ -10,22 +9,17 @@ const __sGetWithRoles = `${path}/getWithRoles`
const __sOperatUser = `${path}/operatUser`
const __sUpdateUser = `${path}/updateUser`
const getUser = {
p: [__sUserTest],
req: params => GlAxios.post(__sUserTest, params)
}
const batcheDelUser = {
p: [__sBatcheDel],
req: params => GlAxios.post(__sBatcheDel, params)
}
const findUserList = {
const findAll = {
p: [__sFindAll],
req: params => GlAxios.get(__sFindAll, { params })
}
const getUserInfo = {
const getUser = {
p: [__sGet],
req: params => GlAxios.get(__sGet, { params })
}
......@@ -46,10 +40,9 @@ const updateUser = {
}
export {
getUser,
batcheDelUser,
findUserList,
getUserInfo,
findAll,
getUser,
getWithRoles,
operatUser,
updateUser
......
......@@ -7,7 +7,6 @@ import GlsxVueCommon from 'glsx-vue-common'
import { common } from '@/config'
import './styles/role-user-common.scss'
import './styles/index.scss'
import './time.js'
// import _ from 'lodash'
import { Tree } from '@/components'
Vue.use(GlsxVueComponents)
......
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from './roleCommon'
import { userDetailColumn } from './userCommon'
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from './roleConst'
import { userDetailColumn } from './userConst'
export {
roleCreateStructure,
......
const roleCreateStructure = {
id: '',
// id: Number,
roleName: '',
description: '',
departName: '',
right: [],
state: '启动',
right: Array,
state: 1,
createTime: ''
}
......
......@@ -27,7 +27,8 @@
</template>
<script>
import { roleCreateStructure } from '@/common/roleCommon'
import { roleCreateStructure } from '@/common/commonConst'
import { saveRoleList } from '@/api/api'
export default {
name: 'RoleCreate',
props: {
......@@ -63,17 +64,28 @@ export default {
}
},
methods: {
// isRoleNameExit
addRole(editData) {
saveRoleList.req(editData).then((data) => {
console.log(data)
}).catch(err => {
console.log(err)
})
},
handleCreateSubmit(formName) {
const editData = this.$deep_clone(this.createRuleForm)
// eidt:true;create:false
const flagEOrC = editData.id
this.$refs[formName].validate((valid) => {
if (valid) {
this.$emit('createClose', flagEOrC, editData)
} else {
return false
}
})
// const flagEOrC = role.id === Number
// flagEOrC &&
// const editData = { roleName: 'fhkdsajfakjfa' }
this.addRole(editData)
// this.$refs[formName].validate((valid) => {
// if (valid) {
// this.$emit('createClose', flagEOrC, editData)
// } else {
// return false
// }
// })
},
handleCreateCancel() {
this.$emit('createClose')
......
export default {
axios: {
// baseURL: 'http://cas.dev.glsx.net/cas/',
baseURL: 'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem',
whiteList: ['/role/deleteRoleById', '/role/deleteUserRoleById', '/role/getRoleDetail', '/role/getRoleDetail', '/role/getRoleList', '/role/isRoleNameExit', '/role/saveRoleList', '/role/selectMenuTreeRoleId', '/role/selectUserRoleByRoleId', '/role/updateRole', 'role/userList', 'role/roleList'],
baseURL: 'http://cas.dev.glsx.net/admin-operating-auth/',
// baseURL: 'http://192.168.3.171:7300/mock/5b91805391b67469b43e2921/subsystem/',
whiteList: ['role/deleteRoleById', 'role/deleteUserRoleById', 'role/getRoleDetail', 'role/getRoleDetail', 'role/getRoleList', 'role/isRoleNameExit', 'role/saveRoleList', 'role/selectMenuTreeRoleId', 'role/selectUserRoleByRoleId', 'role/updateRole', 'user/batcheDel', 'user/findAll', 'user/get', 'user/getWithRoles', 'user/operatUser', 'user/updateUser'],
timeout: 15000,
result: {
data_key: 'data', // 返回值数据实体存放对象
......
function format(formatStr) {
const date = this
var zeroize = function(value, length) {
if (!length) {
length = 2
}
for (var i = 0, zeros = ''; i < (length - value.length); i++) {
zeros += '0'
}
return zeros + value
}
return formatStr.replace(/"[^"]*"|'[^']*'|\b(?:d{1,4}|M{1,4}|yy(?:yy)?|([hHmstT])\1?|[lLZ])\b/g, function($0) {
switch ($0) {
case 'd': return date.getDate()
case 'dd': return zeroize(date.getDate())
case 'ddd': return ['Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat'][date.getDay()]
case 'dddd': return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][date.getDay()]
case 'M': return date.getMonth() + 1
case 'MM': return zeroize(date.getMonth() + 1)
case 'MMM': return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][date.getMonth()]
case 'MMMM': return ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][date.getMonth()]
case 'yy': return date.getFullYear().substr(2)
case 'yyyy': return date.getFullYear()
case 'h': return date.getHours() % 12 || 12
case 'hh': return zeroize(date.getHours() % 12 || 12)
case 'H': return date.getHours()
case 'HH': return zeroize(date.getHours())
case 'm': return date.getMinutes()
case 'mm': return zeroize(date.getMinutes())
case 's': return date.getSeconds()
case 'ss': return zeroize(date.getSeconds())
case 'l': return date.getMilliseconds()
case 'll': return zeroize(date.getMilliseconds())
case 'tt': return date.getHours() < 12 ? 'am' : 'pm'
case 'TT': return date.getHours() < 12 ? 'AM' : 'PM'
}
})
}
const time = Date
time.prototype.format = format
......@@ -10,16 +10,10 @@
<gl-button class="control-tabledata-button" size="small" @click="handleCreateOrEdit(roleParam, '新增角色')">创建</gl-button>
<role-create :createVisible="createVisible" :roleParam="roleParam" :createOrEditTitle="createOrEditTitle" @createClose="handleCreateClose"></role-create>
<div class="m-b8">
<gl-table :table="roleData"></gl-table>
<gl-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pagination.pageNum"
:page-sizes="[10,20,30,40]"
:page-size="pagination.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
<transition>
<gl-table :table="roleData"></gl-table>
</transition>
<gl-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNum" :page-sizes="[10,20,30,40]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
</gl-pagination>
<role-detail :detailVisible="detailVisible" :roleParam="roleParam" @detailClose="handleDetailClose"></role-detail>
<user-detail :userDetailVisible="userDetailVisible" :userDetailTitle="userDetailTitle" @userDetailClose="handleUserDetailClose" :dataParam="[]" :columnParam="columnParam" :consoleParam="consoleParam"></user-detail>
......@@ -30,11 +24,9 @@
<script>
import { RoleCreate, RoleDetail, UserDetail } from '@/components/index'
// easy mock接口
import { roleTest } from '@/api/api'
// 后台接口
// import { getRoleList } from '@/api/api'
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from '@/common/common'
// 接口
import { getRoleList } from '@/api/api'
import { roleCreateStructure, userRoleDetailColumn, userRoleDetailConsole } from '@/common/commonConst'
export default {
name: 'role',
components: {
......@@ -54,11 +46,9 @@ export default {
createOrEditTitle: '新增角色',
userDetailTitle: '用户列表',
// 分页所需参数-start
total: 100,
pagination: {
pageNum: 1,
pageSize: 10
},
total: 10,
pageNum: 1,
pageSize: 10,
// 分页所需参数-end
roleData: {
border: true,
......@@ -113,18 +103,14 @@ export default {
}
},
mounted() {
roleTest.req().then(res => {
this.roleData.data = res.roleData
})
// 请求表格数据
// getRoleList.req(this.pagination).then(res => {
// console.log(res)
// this.total = res.total
// this.roleData.data = res.condition
// }).catch(err => {
// console.log(err)
// })
this.getList()
},
// search--------------------
// watch: {
// roleName(val) {
// !val
// }
// },
methods: {
message(message, type) {
type && this.$message({
......@@ -143,13 +129,34 @@ export default {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.roleData.data.splice(index, 1)
rows.splice(index, 1)
this.message('删除成功', 'success')
}).catch(() => {
this.message('取消删除')
})
},
// 获取页面参数
getParams() {
return {
// pageSize: this.pageSize,
// pageNum: this.pageNum,
roleName: this.roleName
}
},
// 接口请求-start---------------------------------------
// 获取展示数据,请求表格数据
getList() {
// 接口
const params = this.getParams()
getRoleList.req(params).then(res => {
console.log(res)
this.total = res.total
this.roleData.data = res.list
}).catch(err => {
console.log(err)
})
},
// 接口请求-end---------------------------------------
// 新增用户到页面
aaaddRole(data) {
// 后台获取----------------------
......@@ -171,13 +178,16 @@ export default {
},
// 调取接口相关函数
handleSizeChange(val) {
this.pagination.pageSize = val
this.pageSize = val
this.getList()
},
handleCurrentChange(val) {
this.pagination.pageNum = val
this.pageNum = val
this.getList()
},
handleSearchRoleName() {
this.roleName = ''
this.getList()
// this.roleName = ''
},
handleGetRoleDetail(params) {
this.roleParam = params
......
......@@ -9,11 +9,13 @@
<div class="default p-t15">
<div class="control-tabledata-button">
<gl-button size="small" @click="createUser(editUser={})">新增用户</gl-button>
<gl-button size="small" @click="toggleSelection(this.toggle)">删除选中</gl-button>
<gl-button size="small" @click="toggleRowSelection">删除选中</gl-button>
<user-create :dialogFormVisible="dialogFormVisible" :editUser="editUser" @userFormData="handleUserFormData"></user-create>
</div>
<div class="m-b8">
<gl-table :table="userData" ref="multipleTable" :pagination="pagination"></gl-table>
<gl-table :table="userData" ref="multipleTable"></gl-table>
<gl-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNum" :page-sizes="[10,20,30,40]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
</gl-pagination>
<user-detail :userDetailVisible="userDetailVisible" :userDetailTitle="userDetailTitle" @userDetailClose="handleUserDetailClose" :dataParam="[]" :columnParam="columnParam" :consoleParam="consoleParam"></user-detail>
</div>
</div>
......@@ -22,8 +24,9 @@
<script>
import { UserCreate, UserDetail } from '@/components/index'
import { getUser } from '@/api/userApi'
import { userDetailColumn } from '@/common/common'
// 接口
import { findAll } from '@/api/api'
import { userDetailColumn } from '@/common/commonConst'
export default {
name: 'user',
components: {
......@@ -33,11 +36,16 @@ export default {
data() {
return {
userName: '',
toggle: {},
toggle: [],
dialogFormVisible: false,
editUser: {},
userDetailVisible: false,
userDetailTitle: '用户详情',
// 分页所需参数-start
total: 10,
pageNum: 1,
pageSize: 10,
// 分页所需参数-end
columnParam: [],
consoleParam: [],
userData: {
......@@ -107,23 +115,32 @@ export default {
},
selection: {},
multipleSelection: []
},
pagination: {
show: true,
layout: 'total, sizes, prev, pager, next, jumper',
style: {
marginTop: '20px'
}
}
}
},
mounted() {
getUser.req().then(res => {
this.userData.data = res.userData
console.log(res.userData)
})
this.findUserList()
},
methods: {
// 获取所需字段
getParams() {
return {
pageSize: this.pageSize,
pageNum: this.pageNum,
username: this.userName
}
},
// 接口请求-start
findUserList() {
const params = this.getParams()
findAll.req(params).then(res => {
this.total = res.total
this.userData.data = res.list
}).catch(err => {
console.log(err)
})
},
// 接口请求-end
message(message, type) {
type && this.$message({
showClose: true,
......@@ -178,22 +195,34 @@ export default {
console.log(createTime)
return createTime
},
handleSelectionChange(val) {
handleSelectionChange(val, row) {
// this.multipleSelection = val
alert(val)
this.toggle = val
console.log(this.toggle)
},
toggleSelection(rows) {
if (rows) {
rows.forEach(row => {
this.$refs.multipleTable.toggleRowSelection(row)
toggleRowSelection() {
console.log(this.$refs.multipleTable, this.toggle)
if (this.toggle) {
this.toggle.forEach(row => {
this.userData.data.splice(this.toggle, 1)
// this.$refs.multipleTable.$refs.table.toggleRowSelection(row)
})
} else {
this.$refs.multipleTable.clearSelection()
// this.$refs.multipleTable.clearSelection()
}
},
finduserName() {
this.userName = ''
// this.userName = ''
this.findUserList()
},
// 调取接口相关函数
handleSizeChange(val) {
this.pageSize = val
this.findUserList()
},
handleCurrentChange(val) {
this.pageNum = val
this.findUserList()
},
delteSelected(val) {
console.log(val)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!