|
@@ -9,8 +9,8 @@
|
|
@input="handleInputSearch"
|
|
@input="handleInputSearch"
|
|
@clear="clearContent"
|
|
@clear="clearContent"
|
|
/>
|
|
/>
|
|
- <el-button class="search" @click="searchServer(content)">搜索</el-button>
|
|
|
|
- <el-button type="primary" class="add" @click="dialogFormVisible =isAdd = true"> 新增职位 </el-button>
|
|
|
|
|
|
+ <el-button class="search" @click="search(content)">搜索</el-button>
|
|
|
|
+ <el-button type="primary" class="add" @click="dialogFormVisible = isAdd = true"> 新增职位</el-button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<!-- 表格数据展示区 -->
|
|
<!-- 表格数据展示区 -->
|
|
@@ -20,7 +20,6 @@
|
|
tooltip-effect="dark"
|
|
tooltip-effect="dark"
|
|
:header-cell-style="{background:'#fafafa',color:'#000', fontWeight: 700, borderTop: '1px solid #ebeef5'}"
|
|
:header-cell-style="{background:'#fafafa',color:'#000', fontWeight: 700, borderTop: '1px solid #ebeef5'}"
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
- @selection-change="handleSelectionChange"
|
|
|
|
>
|
|
>
|
|
<el-table-column
|
|
<el-table-column
|
|
type="selection"
|
|
type="selection"
|
|
@@ -49,7 +48,7 @@
|
|
align="center"
|
|
align="center"
|
|
>
|
|
>
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
- <el-button type="text" :style="{color: '#1990FF'}" @click="showUpdate(scope.row.id)">编辑</el-button>
|
|
|
|
|
|
+ <el-button type="text" :style="{color: '#1990FF'}" @click="showDialog(scope.row.id)">编辑</el-button>
|
|
<el-divider direction="vertical" /> <!-- 中间的小竖线 -->
|
|
<el-divider direction="vertical" /> <!-- 中间的小竖线 -->
|
|
<el-button type="text" :style="{color: '#E51C23'}" @click="del(scope.row.id)">删除</el-button>
|
|
<el-button type="text" :style="{color: '#E51C23'}" @click="del(scope.row.id)">删除</el-button>
|
|
</template>
|
|
</template>
|
|
@@ -66,10 +65,15 @@
|
|
/>
|
|
/>
|
|
|
|
|
|
<!-- 添加服务器信息dialog -->
|
|
<!-- 添加服务器信息dialog -->
|
|
- <el-dialog :visible.sync="dialogFormVisible" width="600px" :close-on-click-modal="false" @close="close('addServerForm')">
|
|
|
|
- <el-form ref="addServerForm" :model="serverFormData" label-width="140px" :rules="rules" label-position="right">
|
|
|
|
|
|
+ <el-dialog
|
|
|
|
+ :visible.sync="dialogFormVisible"
|
|
|
|
+ width="600px"
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
+ @close="cancelSubmitForm('formRef')"
|
|
|
|
+ >
|
|
|
|
+ <el-form ref="formRef" :model="formData" label-width="140px" :rules="rules" label-position="right">
|
|
<el-form-item label="职位名" prop="positionName">
|
|
<el-form-item label="职位名" prop="positionName">
|
|
- <el-input v-model="serverFormData.positionName" />
|
|
|
|
|
|
+ <el-input v-model="formData.positionName" />
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="菜单权限">
|
|
<el-form-item label="菜单权限">
|
|
<el-tree
|
|
<el-tree
|
|
@@ -83,11 +87,10 @@
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-form-item>
|
|
- <el-button @click="close('addServerForm')">取 消</el-button>
|
|
|
|
- <el-button type="primary" @click="submitForm('addServerForm')">确 认</el-button>
|
|
|
|
|
|
+ <el-button type="primary" @click="submitForm('formRef')">提交</el-button>
|
|
|
|
+ <el-button @click="cancelSubmitForm('formRef')">返回</el-button>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
- <el-button @click="$refs.tree.setCheckedKeys([9,10,11,12]);">通过 key 设置</el-button>
|
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -95,6 +98,7 @@
|
|
<script>
|
|
<script>
|
|
import { getJobList, addJob, delJob, updateJob, getMenuAuthorityList, getPositionPermissionsById } from '@/api/system'
|
|
import { getJobList, addJob, delJob, updateJob, getMenuAuthorityList, getPositionPermissionsById } from '@/api/system'
|
|
import Pagination from '@/components/Pagination/index'
|
|
import Pagination from '@/components/Pagination/index'
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
name: 'JobSettings',
|
|
name: 'JobSettings',
|
|
components: {
|
|
components: {
|
|
@@ -108,6 +112,7 @@ export default {
|
|
list: [],
|
|
list: [],
|
|
// 总条数
|
|
// 总条数
|
|
totalrecords: 0,
|
|
totalrecords: 0,
|
|
|
|
+ // 控制是添加还是修改
|
|
isAdd: true,
|
|
isAdd: true,
|
|
// 当前页
|
|
// 当前页
|
|
currentPage: 1,
|
|
currentPage: 1,
|
|
@@ -115,8 +120,8 @@ export default {
|
|
totalpages: 0,
|
|
totalpages: 0,
|
|
// 控制dialog显示和隐藏
|
|
// 控制dialog显示和隐藏
|
|
dialogFormVisible: false,
|
|
dialogFormVisible: false,
|
|
- // 服务器信息
|
|
|
|
- serverFormData: {
|
|
|
|
|
|
+ // 表单数据对象
|
|
|
|
+ formData: {
|
|
positionName: '',
|
|
positionName: '',
|
|
menuIds: [],
|
|
menuIds: [],
|
|
urlIds: []
|
|
urlIds: []
|
|
@@ -127,7 +132,7 @@ export default {
|
|
children: 'childrenMenu',
|
|
children: 'childrenMenu',
|
|
label: 'menuName'
|
|
label: 'menuName'
|
|
},
|
|
},
|
|
- // 服务器信息表单校验规则
|
|
|
|
|
|
+ // 表单校验规则
|
|
rules: {
|
|
rules: {
|
|
positionName: [
|
|
positionName: [
|
|
{
|
|
{
|
|
@@ -143,19 +148,20 @@ export default {
|
|
this.fetchMenuAuthorityList()
|
|
this.fetchMenuAuthorityList()
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- handleSelectionChange() {
|
|
|
|
- console.log('handleSelectionChange')
|
|
|
|
- },
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 每次点击树状控件进行菜单权限时触发的回调
|
|
|
|
+ * @param checkedNodes 被选中的节点的数据列表
|
|
|
|
+ */
|
|
nodeChecked(a, { checkedNodes }) {
|
|
nodeChecked(a, { checkedNodes }) {
|
|
- console.log(checkedNodes)
|
|
|
|
|
|
+ // console.log(checkedNodes)
|
|
const menuIds = []
|
|
const menuIds = []
|
|
const urlIds = []
|
|
const urlIds = []
|
|
/*
|
|
/*
|
|
* 遍历checkedNodes,有childrenMenu属性是菜单,把id加到菜单id,没有就是菜单urlId,把id加到菜单urlid
|
|
* 遍历checkedNodes,有childrenMenu属性是菜单,把id加到菜单id,没有就是菜单urlId,把id加到菜单urlid
|
|
- * */
|
|
|
|
|
|
+ */
|
|
checkedNodes.forEach(el => {
|
|
checkedNodes.forEach(el => {
|
|
if ('childrenMenu' in el) {
|
|
if ('childrenMenu' in el) {
|
|
- // 判断是否为空
|
|
|
|
|
|
+ // 判断是否已经存在
|
|
if (!menuIds.includes(el.id)) {
|
|
if (!menuIds.includes(el.id)) {
|
|
menuIds.push(el.id)
|
|
menuIds.push(el.id)
|
|
}
|
|
}
|
|
@@ -165,21 +171,28 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- this.$set(this.serverFormData, 'menuIds', menuIds)
|
|
|
|
- this.$set(this.serverFormData, 'urlIds', urlIds)
|
|
|
|
- console.log(this.serverFormData)
|
|
|
|
|
|
+ this.$set(this.formData, 'menuIds', menuIds)
|
|
|
|
+ this.$set(this.formData, 'urlIds', urlIds)
|
|
|
|
+ // console.log(this.formData)
|
|
},
|
|
},
|
|
- // 获取服务器列表数据
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取服务器列表
|
|
|
|
+ * @param params Object {page: '', content: ''}
|
|
|
|
+ * @returns {Promise<void>}
|
|
|
|
+ */
|
|
async fetchList(params) {
|
|
async fetchList(params) {
|
|
const res = await getJobList(params)
|
|
const res = await getJobList(params)
|
|
const { list, totalrecords, totalpages } = res
|
|
const { list, totalrecords, totalpages } = res
|
|
- // console.log(list)
|
|
|
|
- // console.log(res)
|
|
|
|
- this.list = list
|
|
|
|
- this.totalrecords = totalrecords
|
|
|
|
- this.totalpages = totalpages
|
|
|
|
|
|
+ this.list = list // 服务器列表
|
|
|
|
+ this.totalrecords = totalrecords // 总条数
|
|
|
|
+ this.totalpages = totalpages // 总页数
|
|
},
|
|
},
|
|
- // 获取菜单权限列表
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取菜单权限列表
|
|
|
|
+ * @returns {Promise<void>}
|
|
|
|
+ */
|
|
async fetchMenuAuthorityList() {
|
|
async fetchMenuAuthorityList() {
|
|
const { list } = await getMenuAuthorityList()
|
|
const { list } = await getMenuAuthorityList()
|
|
// 针对获取回来的数据处理,符合el-tree的数据格式
|
|
// 针对获取回来的数据处理,符合el-tree的数据格式
|
|
@@ -196,33 +209,48 @@ export default {
|
|
this.menuAuthorityList = list
|
|
this.menuAuthorityList = list
|
|
console.log(list)
|
|
console.log(list)
|
|
},
|
|
},
|
|
- // 处理分页模块
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 处理分页模块
|
|
|
|
+ * @param params Object { page: '', li
|
|
|
|
+ */
|
|
handlePaginate(params) {
|
|
handlePaginate(params) {
|
|
- // console.log(params)
|
|
|
|
|
|
+ // console.log(params) // { page: '', limit: '' }
|
|
params = Object.assign(params, { content: this.content })
|
|
params = Object.assign(params, { content: this.content })
|
|
this.fetchList(params)
|
|
this.fetchList(params)
|
|
},
|
|
},
|
|
- // 显示更新服务器dialog
|
|
|
|
- async showUpdate(id) {
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 显示更新dialog
|
|
|
|
+ * @param id 要更新的id
|
|
|
|
+ * @returns {Promise<void>}
|
|
|
|
+ */
|
|
|
|
+ async showDialog(id) {
|
|
// 修改添加状态为修改状态
|
|
// 修改添加状态为修改状态
|
|
this.isAdd = false
|
|
this.isAdd = false
|
|
- // console.log(item)
|
|
|
|
const { object } = await getPositionPermissionsById(id)
|
|
const { object } = await getPositionPermissionsById(id)
|
|
|
|
+ // console.log(object)
|
|
this.dialogFormVisible = true
|
|
this.dialogFormVisible = true
|
|
- console.log(object)
|
|
|
|
- this.serverFormData = {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 这里一定要等待dom更新完毕,然后再进行数据回显,
|
|
|
|
+ * 防止dialog中的el-form没有挂载完毕就对formData进行了赋值而导致el-form的resetFields方法不起效果
|
|
|
|
+ */
|
|
|
|
+ await this.$nextTick()
|
|
|
|
+ this.formData = Object.assign({}, {
|
|
positionName: object.positionName,
|
|
positionName: object.positionName,
|
|
menuIds: object.positionMenu && object.positionMenu.split(','),
|
|
menuIds: object.positionMenu && object.positionMenu.split(','),
|
|
urlIds: object.positionUrl && object.positionUrl.split(','),
|
|
urlIds: object.positionUrl && object.positionUrl.split(','),
|
|
id
|
|
id
|
|
- }
|
|
|
|
- await this.$nextTick()
|
|
|
|
- // console.log(this.$refs.tree)
|
|
|
|
|
|
+ })
|
|
if (object.positionUrl) {
|
|
if (object.positionUrl) {
|
|
this.$refs.tree.setCheckedKeys(object.positionUrl.split(',').map(el => parseInt(el)))
|
|
this.$refs.tree.setCheckedKeys(object.positionUrl.split(',').map(el => parseInt(el)))
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- // 根据id删除服务器数据
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id删除职位
|
|
|
|
+ * @param id
|
|
|
|
+ */
|
|
del(id) {
|
|
del(id) {
|
|
// 弹出提示框,询问是否确认删除
|
|
// 弹出提示框,询问是否确认删除
|
|
this.$confirm('你将要删除一条数据, 是否继续?', '温馨提示', {
|
|
this.$confirm('你将要删除一条数据, 是否继续?', '温馨提示', {
|
|
@@ -230,13 +258,12 @@ export default {
|
|
cancelButtonText: '取消',
|
|
cancelButtonText: '取消',
|
|
type: 'error'
|
|
type: 'error'
|
|
}).then(async() => {
|
|
}).then(async() => {
|
|
- // 发送删除服务器信息请求
|
|
|
|
|
|
+ // 发送删除请求
|
|
await delJob(id)
|
|
await delJob(id)
|
|
this.$message({
|
|
this.$message({
|
|
type: 'success',
|
|
type: 'success',
|
|
message: '删除成功!'
|
|
message: '删除成功!'
|
|
})
|
|
})
|
|
- await this.fetchList({ page: this.currentPage, content: this.content })
|
|
|
|
// 删除完后,如果当前页没有数据并且当前页不是第一页,那么就重新请求上一页的数据
|
|
// 删除完后,如果当前页没有数据并且当前页不是第一页,那么就重新请求上一页的数据
|
|
if (this.list.length === 0 && this.currentPage > 1) {
|
|
if (this.list.length === 0 && this.currentPage > 1) {
|
|
this.currentPage -= 1
|
|
this.currentPage -= 1
|
|
@@ -249,50 +276,64 @@ export default {
|
|
})
|
|
})
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- // 搜索服务器数据
|
|
|
|
- searchServer(content) {
|
|
|
|
- // console.log(content)
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据content查询服务器信息
|
|
|
|
+ * @param content
|
|
|
|
+ */
|
|
|
|
+ search(content) {
|
|
this.fetchList({ content })
|
|
this.fetchList({ content })
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 处理搜索框的输入
|
|
|
|
+ */
|
|
async handleInputSearch() {
|
|
async handleInputSearch() {
|
|
// 当用户清除了搜索框中的文字时或者搜索框内容为空时,重新发送请求获取服务器列表数据
|
|
// 当用户清除了搜索框中的文字时或者搜索框内容为空时,重新发送请求获取服务器列表数据
|
|
if (!this.content) {
|
|
if (!this.content) {
|
|
await this.fetchList()
|
|
await this.fetchList()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- // dialog关闭时要做的事
|
|
|
|
- close(formName) {
|
|
|
|
- // 隐藏dialog
|
|
|
|
- this.dialogFormVisible = false
|
|
|
|
- // 清空serverFormData
|
|
|
|
- this.serverFormData = {}
|
|
|
|
- // 清空树状控件数据
|
|
|
|
- this.$refs.tree.setCheckedKeys([])
|
|
|
|
- // 清除校验的效果
|
|
|
|
- this.$refs[formName].resetFields()
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 点击返回按钮, 取消提交表单
|
|
|
|
+ * @param formRef 表单ref
|
|
|
|
+ */
|
|
|
|
+ cancelSubmitForm(formRef) {
|
|
// 重新将添加的状态设置为true
|
|
// 重新将添加的状态设置为true
|
|
this.isAdd = true
|
|
this.isAdd = true
|
|
|
|
+ // 清空树状控件数据
|
|
|
|
+ this.$refs.tree.setCheckedKeys([])
|
|
|
|
+ // 重置表单
|
|
|
|
+ this.$refs[formRef].resetFields()
|
|
|
|
+ // 隐藏dialog
|
|
|
|
+ this.dialogFormVisible = false
|
|
},
|
|
},
|
|
- // 当搜索框点击清除按钮时
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 当搜索框点击清除按钮时
|
|
|
|
+ */
|
|
clearContent() {
|
|
clearContent() {
|
|
- // console.log(this.content)
|
|
|
|
// 让当前的页码为1
|
|
// 让当前的页码为1
|
|
this.currentPage = 1
|
|
this.currentPage = 1
|
|
this.fetchList({ content: this.content })
|
|
this.fetchList({ content: this.content })
|
|
},
|
|
},
|
|
- submitForm(formName) {
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 提交表单,添加或修改职位信息
|
|
|
|
+ * @param formRef 表单ref
|
|
|
|
+ */
|
|
|
|
+ submitForm(formRef) {
|
|
// 校验表单
|
|
// 校验表单
|
|
- this.$refs[formName].validate(async(valid) => {
|
|
|
|
|
|
+ this.$refs[formRef].validate(async(valid) => {
|
|
// 通过就发送请求
|
|
// 通过就发送请求
|
|
if (valid) {
|
|
if (valid) {
|
|
let res
|
|
let res
|
|
if (this.isAdd) {
|
|
if (this.isAdd) {
|
|
- res = await addJob(this.serverFormData)
|
|
|
|
|
|
+ res = await addJob(this.formData)
|
|
} else {
|
|
} else {
|
|
- res = await updateJob(this.serverFormData)
|
|
|
|
|
|
+ res = await updateJob(this.formData)
|
|
}
|
|
}
|
|
- // console.log(res)
|
|
|
|
-
|
|
|
|
// 提示添加成功
|
|
// 提示添加成功
|
|
this.$message.success(res.msg)
|
|
this.$message.success(res.msg)
|
|
// 重新获取服务器列表的数据
|
|
// 重新获取服务器列表的数据
|
|
@@ -313,26 +354,32 @@ export default {
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.job-settings-container {
|
|
.job-settings-container {
|
|
padding-left: 30px;
|
|
padding-left: 30px;
|
|
|
|
+
|
|
.header {
|
|
.header {
|
|
padding-top: 30px;
|
|
padding-top: 30px;
|
|
margin-bottom: 15px;
|
|
margin-bottom: 15px;
|
|
|
|
+
|
|
::v-deep .el-input {
|
|
::v-deep .el-input {
|
|
width: 300px;
|
|
width: 300px;
|
|
}
|
|
}
|
|
|
|
+
|
|
.search {
|
|
.search {
|
|
margin-left: 15px;
|
|
margin-left: 15px;
|
|
}
|
|
}
|
|
|
|
+
|
|
.add {
|
|
.add {
|
|
float: right;
|
|
float: right;
|
|
margin-right: 30px;
|
|
margin-right: 30px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
::v-deep .el-pagination {
|
|
::v-deep .el-pagination {
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
justify-content: flex-end;
|
|
}
|
|
}
|
|
|
|
+
|
|
::v-deep .el-dialog {
|
|
::v-deep .el-dialog {
|
|
- width: 80vw!important;
|
|
|
|
|
|
+ width: 80vw !important;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|