部门管理
This commit is contained in:
@@ -21,9 +21,9 @@
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="顶级部门" prop="isTop">
|
||||
<el-radio-group v-model="dataForm.isTop" style="width: 140px">
|
||||
<el-radio label="1">是</el-radio>
|
||||
<el-radio label="0">否</el-radio>
|
||||
<el-radio-group v-model="dataForm.isTop" style="width: 140px" @change="handleChange">
|
||||
<el-radio :label="'1'">是</el-radio>
|
||||
<el-radio :label="'0'">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -68,10 +68,8 @@
|
||||
name: null,
|
||||
deptSort: 999,
|
||||
isTop: '1',
|
||||
isUsed: true
|
||||
// ext_id: null,
|
||||
// sub_count: 0,
|
||||
// pid: null
|
||||
isUsed: true,
|
||||
pid: null
|
||||
},
|
||||
depts: [],
|
||||
dataRule: {
|
||||
@@ -88,20 +86,20 @@
|
||||
Treeselect
|
||||
},
|
||||
methods: {
|
||||
handleChange () {
|
||||
this.$forceUpdate()
|
||||
},
|
||||
init (row) {
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (row) {
|
||||
this.dataForm = {...row}
|
||||
// if (this.dataForm.pid !== null) {
|
||||
// this.dataForm.isTop = '0'
|
||||
// } else {
|
||||
// this.dataForm.isTop = '1'
|
||||
// }
|
||||
if (this.dataForm.pid != null) {
|
||||
if (this.dataForm.pid !== null) {
|
||||
this.dataForm.isTop = '0'
|
||||
this.getSupDepts(this.dataForm.pid)
|
||||
} else {
|
||||
this.dataForm.isTop = '1'
|
||||
this.getDepts()
|
||||
}
|
||||
}
|
||||
@@ -124,7 +122,7 @@
|
||||
if (data.children) {
|
||||
this.buildDepts(data.children)
|
||||
}
|
||||
if (data.has_children && !data.children) {
|
||||
if (data.hasChildren && !data.children) {
|
||||
data.children = null
|
||||
}
|
||||
})
|
||||
@@ -133,25 +131,33 @@
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/api/dept/vo'),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams({is_used: true})
|
||||
params: this.$http.adornParams({isUsed: true})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 200) {
|
||||
this.depts = data.content.map(function(obj) {
|
||||
if (obj.has_children) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
}
|
||||
return obj
|
||||
})
|
||||
console.log(this.depts)
|
||||
}
|
||||
})
|
||||
},
|
||||
normalizer(node) {
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.name,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/api/dept/vo'),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams({is_used: true, pid: parentNode.dept_id})
|
||||
params: this.$http.adornParams({isUsed: true, pid: parentNode.deptId})
|
||||
}).then(({res}) => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
obj.children = null
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList()">查询</el-button>
|
||||
<el-button v-if="isAuth('sys:dept:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="isAuth('sys:dept:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
|
||||
<el-button v-if="isAuth('sys:dept:delete')" type="danger" @click="deleteHandle(1)" :disabled="dataListSelections.length <= 0">批量删除</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table
|
||||
@@ -80,7 +80,7 @@
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="isAuth('sys:dept:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row)">修改</el-button>
|
||||
<el-button v-if="isAuth('sys:dept:delete')" type="text" size="small" @click="deleteHandle(scope.row.deptId)">删除</el-button>
|
||||
<el-button v-if="isAuth('sys:dept:delete')" type="text" size="small" @click="deleteHandle(2, scope.row.deptId)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -104,8 +104,8 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
dataForm: {
|
||||
name: '',
|
||||
isUsed: ''
|
||||
name: null,
|
||||
isUsed: null
|
||||
},
|
||||
enabledTypeOptions: [
|
||||
{ key: true, displayName: '启用' },
|
||||
@@ -136,7 +136,7 @@ export default {
|
||||
params: this.$http.adornParams({
|
||||
'page': this.pageIndex,
|
||||
'size': this.pageSize,
|
||||
'sort': 'id,desc',
|
||||
'sort': 'create_time',
|
||||
'name': this.dataForm.name,
|
||||
'isUsed': this.dataForm.isUsed
|
||||
})
|
||||
@@ -174,11 +174,11 @@ export default {
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
deleteHandle (id) {
|
||||
deleteHandle (type, id) {
|
||||
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||
return item.deptId
|
||||
})
|
||||
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
|
||||
this.$confirm(type === 1 ? `确认删除选中的${this.dataListSelections.length}条数据?` : '确定删除吗,如果存在下级节点则一并删除,此操作不能撤销!', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
@@ -186,7 +186,7 @@ export default {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/api/dept'),
|
||||
method: 'DELETE',
|
||||
data: this.$http.adornData(ids)
|
||||
data: ids
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 200) {
|
||||
this.$message({
|
||||
|
||||
Reference in New Issue
Block a user