Commit e35f2e19 authored by 刘宇扬's avatar 刘宇扬

设备申请/领用2

parent 525201ff
...@@ -134,49 +134,16 @@ ...@@ -134,49 +134,16 @@
<!-- 批准或驳回设备配置对话框 --> <!-- 批准或驳回设备配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> <el-form ref="form" :model="form" size="small" label-width="80px">
<el-form-item label="名称" prop="roleName"> <el-form-item label="备注">
<el-input v-model.trim="form.roleName" show-word-limit :maxlength="30" placeholder="请输入设备名称" /> <el-input v-model.trim="form.remark" maxlength="200" show-word-limit type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
<!-- <el-form-item label="权限字符" prop="roleKey"> </el-form>
<el-input v-model.trim="form.roleKey" show-word-limit :maxlength="30" placeholder="请输入权限字符" /> <div slot="footer" class="dialog-footer">
</el-form-item> --> <el-button @click="cancel">取 消</el-button>
<!-- <el-form-item label="排序" prop="roleSort"> <el-button type="primary" @click="submitForm">确 定</el-button>
<el-input-number v-model="form.roleSort" style="width: 100%" controls-position="right" :min="0" /> </div>
</el-form-item> --> </el-dialog>
<el-form-item label="状态">
<!-- <el-radio-group v-model="form.flag">-->
<!-- <el-radio :label="1">启用</el-radio>-->
<!-- <el-radio :label="0">停用</el-radio>-->
<!-- </el-radio-group>-->
<el-radio v-model="form.flag" label="1">启用</el-radio>
<el-radio v-model="form.flag" label="0">停用</el-radio>
</el-form-item>
<!-- <el-form-item label="菜单权限"> -->
<!-- <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>-->
<!-- <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>-->
<!-- <el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox>-->
<!-- <el-tree
ref="menu"
class="tree-border"
:data="menuOptions"
show-checkbox
node-key="id"
check-strictly
empty-text="加载中,请稍后"
:props="defaultProps"
@check-change="handleMenuCheckChange"
/> -->
<!-- </el-form-item> -->
<el-form-item label="备注">
<el-input v-model.trim="form.remark" maxlength="200" show-word-limit type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="submitForm">确 定</el-button>
</div>
</el-dialog>
<!-- 分配设备数据权限对话框 --> <!-- 分配设备数据权限对话框 -->
<el-dialog class="roleDialog" title="数据权限信息" :visible.sync="openDataScope" width="900px" append-to-body> <el-dialog class="roleDialog" title="数据权限信息" :visible.sync="openDataScope" width="900px" append-to-body>
...@@ -369,17 +336,17 @@ ...@@ -369,17 +336,17 @@
label: 'label' label: 'label'
}, },
// 表单校验 // 表单校验
rules: { // rules: {
roleName: [ // roleName: [
{ required: true, message: '请输入设备名称', trigger: 'blur' } // { required: true, message: '请输入设备名称', trigger: 'blur' }
], // ],
roleKey: [ // roleKey: [
{ required: true, message: '请输入权限字符', trigger: 'blur' } // { required: true, message: '请输入权限字符', trigger: 'blur' }
], // ],
roleSort: [ // roleSort: [
{ required: true, message: '请输入设备排序', trigger: 'blur' } // { required: true, message: '请输入设备排序', trigger: 'blur' }
] // ]
}, // },
deptOptions: [] deptOptions: []
} }
}, },
......
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form ref="queryForm" style="padding: 0 0 0 10px" :model="queryParams" :inline="true"> <el-form v-show="showSearch" ref="queryForm" style="padding: 0 0 0 10px" :model="queryParams" :inline="true" label-width="68px">
<el-form-item label="设备名称" prop="roleName"> <!-- <el-form-item label="登录地址" prop="ipaddr">-->
<el-input <!-- <el-input-->
v-model="queryParams.roleName" <!-- v-model="queryParams.ipaddr"-->
placeholder="请输入设备名称" <!-- placeholder="请输入登录地址"-->
clearable <!-- clearable-->
:maxlength="30" <!-- :maxlength="30"-->
<!-- size="small"-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="设备名称" prop="userName">
<el-input
v-model="queryParams.username"
placeholder="请输入设备名称"
clearable
:maxlength="30"
style="width: 240px;"
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="登录状态" prop="status">-->
<!-- <el-select-->
<!-- v-model="queryParams.status"-->
<!-- placeholder="请选择登录状态"-->
<!-- clearable-->
<!-- size="small"-->
<!-- style="width: 240px"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="dict in statusOptions"-->
<!-- :key="dict.dictValue"-->
<!-- :label="dict.dictLabel"-->
<!-- :value="dict.dictValue"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="登录时间">
<el-date-picker
v-model="queryParams.loginTime"
type="month"
size="small"
style="width: 170px"
value-format="yyyy-MM"
placeholder="请选择月份"
/>
</el-form-item> -->
<el-form-item>
<el-button type="primary" size="small" icon="el-icon-search" @click="handleQuery">查询</el-button>
</el-form-item>
<div style="float: right">
<el-form-item>
<!-- v-hasPermi="['zt:loginlog:delete']"-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- size="small"-->
<!-- :disabled="multiple"-->
<!-- @click="handleDelete"-->
<!-- >删除</el-button>-->
<!-- <coolbutton :type="deletetypePrimary" :name="deleteName" :size="deleteSize" :disabled="multiple" @btn-click="handleDelete" />-->
<!-- v-hasPermi="['zt:loginlog:clear']"-->
<!-- <el-button
type="danger"
size="small" size="small"
style="width: 150px" :icon="delIcon"
@keyup.enter.native="handleQuery" @click="handleClean"
/> >清空</el-button> -->
<!-- <coolbutton :type="cleantypePrimary" :name="cleanName" :haspermi="clearHaspermi" :icon="delIcon" :size="cleanSize" @btn-click="handleClean" />-->
<!-- v-hasPermi="['zt:loginlog:export']"-->
<el-button
type="success"
size="small"
icon="el-icon-download"
@click="handleExport"
>导出</el-button>
<!-- <coolbutton :type="exporttypePrimary" :name="exportName" :icon="exportIcon" :size="exportSize" @btn-click="handleExport" />-->
<!-- <el-button size="mini" @click="resetQuery">重置</el-button>-->
</el-form-item> </el-form-item>
<!-- <el-form-item label="权限字符" prop="roleKey"> </div>
<el-input </el-form>
v-model="queryParams.roleKey"
placeholder="请输入权限字符" <div class="placeholder" />
clearable <div style="padding:10px">
<div class="mb12 font-small-bold">设备可领用列表</div>
<template>
<div>
<el-table v-loading="loading" border :data="list" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column type="index" width="55" label="序号" align="center" />
<el-table-column label="设备名称" align="center" prop="username" />
<el-table-column label="XXXX" align="center" prop="ipaddr" width="130" :show-overflow-tooltip="true" />
<el-table-column label="XXXX" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
<el-table-column label="XXXX" align="center" prop="status">
<template slot-scope="scope">
<span v-if="scope.row.status === '0'">失败</span>
<span v-if="scope.row.status === '1'">成功</span>
</template>
</el-table-column>
<el-table-column label="提示信息" align="center">
<template slot-scope="scope">
{{ scope.row.msg || '-' }}
</template>
</el-table-column>
<el-table-column label="时间" align="center" prop="loginTime" width="180" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.loginTime) | transformDateByFormat('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click="handleDelete(scope.row.businessId)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<el-button
type="primary"
size="small" size="small"
style="width: 150px" :disabled="selection.length === 0"
@keyup.enter.native="handleQuery" @click="handleSubmit"
>提交</el-button>
</div>
</template>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.rows"
@pagination="getList"
/>
<!-- 清空弹窗-->
<el-dialog
title="选择清空月份"
:visible.sync="clearVisible"
width="30%"
:before-close="handleClose"
>
<el-form ref="clear" :model="clearFrom" :rules="clearRule">
<el-form-item label="月份" prop="month">
<el-date-picker
v-model="clearFrom.month"
type="monthrange"
range-separator="至"
start-placeholder="开始月份"
end-placeholder="结束月份"
value-format="yyyy_MM"
:picker-options="endDatePicker"
@change="timechange"
/> />
</el-form-item> -->
<el-form-item label="设备状态" prop="flag">
<el-select
v-model="queryParams.flag"
placeholder="请选择设备状态"
clearable
size="small"
style="width: 150px"
>
<el-option
v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item style="float: right;margin-top: 20px">
<el-button type="primary" size="small" icon="el-icon-search" @click="handleQuery">查询</el-button> <el-button @click="clearVisible = false">取 消</el-button>
<el-button type="primary" @click="clear">确 定</el-button>
</el-form-item> </el-form-item>
<div style="float: right"> </el-form>
<el-form-item> </el-dialog>
<!-- <el-button--> <!-- 导出弹窗-->
<!-- v-hasPermi="['sys:role:add']"--> <el-dialog
<!-- type="primary"--> title="选择导出月份"
<!-- size="small"--> :visible.sync="exportVisible"
<!-- @click="handleAdd"--> width="30%"
<!-- >新增</el-button>--> :before-close="handleClose"
<!-- <coolbutton style="padding: 8px 7px;" :type="typePrimary" :name="addName" :size="smallSize" :icon="addIcon" :haspermi="addHaspermi" @btn-click="handleAdd" /> --> >
<!-- <el-button--> <el-form ref="export" :model="exportFrom" :rules="exportRule">
<!-- v-hasPermi="['sys:role:export']"--> <el-form-item label="月份" prop="month">
<!-- style="padding: 8px 7px;"--> <el-date-picker
<!-- type="success"--> v-model="exportFrom.month"
<!-- size="small"--> type="monthrange"
<!-- icon="el-icon-download"--> range-separator="至"
<!-- @click="handleExport"--> start-placeholder="开始月份"
<!-- >导出</el-button>--> end-placeholder="结束月份"
<!-- <coolbutton style="padding: 8px 7px;" :type="typeSuccess" :name="exportName" :size="smallSize" :icon="exportIcon" :haspermi="exportHaspermi" @btn-click="handleExport" /> --> value-format="yyyy_MM"
:picker-options="endDatePicker"
@change="timechange"
/>
</el-form-item>
<el-form-item style="float: right;margin-top: 20px">
<el-button @click="exportVisible = false">取 消</el-button>
<el-button type="primary" @click="exportSubmit">确 定</el-button>
</el-form-item> </el-form-item>
</div>
</el-form> </el-form>
<div class="placeholder" /> </el-dialog>
<div style="padding:5px 10px"> </div>
<div class="mb12 font-small-bold">设备管理列表</div> </template>
<el-table v-loading="loading" border :data="roleList" @selection-change="handleSelectionChange">
<el-table-column type="index" label="序号" width="50" /> <script>
<el-table-column label="名称" prop="roleName" :show-overflow-tooltip="true"> import { list, delLogininfo, cleanLogininfo, exportLogininfo } from '@/api/monitor/loginInfo'
<template slot-scope="scope"> import dictCons from '@/utils/dictCons'
{{ scope.row.roleName || '-' }} import Template from '@/views/instance/Template'
</template> import Coolbutton from '@/components/coolbutton'
</el-table-column> export default {
<!-- <el-table-column label="权限字符" prop="roleKey"> name: 'LoginInfo',
<template slot-scope="scope"> components: { Template, Coolbutton },
{{ scope.row.roleKey || '-' }} data() {
</template> return {
</el-table-column> --> loading: false,
<el-table-column label="显示顺序" prop="roleSort"> list: [],
<template slot-scope="scope"> selection: [],
{{ scope.row.roleSort || '-' }} endDatePicker: this.handelFixDate(),
</template> // 自定义按钮
</el-table-column> deletetypePrimary: 'danger',
<el-table-column label="状态" align="center" width="100"> textPrimary: 'text',
<template slot-scope="scope"> deleteName: '删除',
<el-switch deleteSize: 'mini',
v-model="scope.row.flag" deleteDisabled: 'multiple',
active-value="1" cleantypePrimary: 'danger',
inactive-value="0" cleanName: '清空',
@change="handleStatusChange(scope.row)" cleanSize: 'small',
/> exporttypePrimary: 'success',
</template> exportName: '导出',
</el-table-column> exportSize: 'small',
<el-table-column label="创建时间" :show-overflow-tooltip="true" align="center" prop="createTime"> delIcon: 'el-icon-delete',
<template slot-scope="scope"> exportIcon: 'el-icon-download',
<span>{{ scope.row.createDate | transformDateByFormat('YYYY-MM-DD HH:mm') }}</span> clearVisible: false,
</template> exportVisible: false,
</el-table-column> exportFrom: {},
<el-table-column label="操作" class-name="small-padding fixed-width" width="240px"> exportRule: {
<template slot-scope="scope"> month: [
<!-- <el-button--> { required: true, message: '请选择月份', trigger: 'change' }
<!-- v-hasPermi="['sys:role:update']"--> ]
<!-- size="mini"--> },
<!-- type="text"--> // 遮罩层
<!-- style="color: #49cec9"--> loading: true,
<!-- @click="handleUpdate(scope.row)"--> // 选中数组
<!-- >修改</el-button>--> ids: [],
<coolbutton style="color: #49cec9" :type="typeParent" :name="updataName" :size="size" :haspermi="updateHaspermi" @btn-click="handleUpdate(scope.row)" /> // 非多个禁用
<!-- <el-button--> multiple: true,
<!-- v-hasPermi="['sys:role:update']"--> // 显示搜索条件
<!-- size="mini"--> showSearch: true,
<!-- type="text"--> // 总条数
<!-- icon="el-icon-circle-check"--> total: 0,
<!-- @click="handleMenu(scope.row)"--> clearFrom: {},
<!-- >数据权限</el-button>--> clearRule: {
<el-button month: [
size="mini" { required: true, message: '请选择月份', trigger: 'change' }
type="text" ]
@click="handleDelete(scope.row)" },
>删除</el-button> // 表格数据
</template> list: [],
</el-table-column> // 状态数据字典
</el-table> statusOptions: [
</div> {
<pagination dictLabel: '启用',
v-show="total>0" dictValue: '1'
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改设备配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="名称" prop="roleName">
<el-input v-model.trim="form.roleName" show-word-limit :maxlength="30" placeholder="请输入设备名称" />
</el-form-item>
<!-- <el-form-item label="权限字符" prop="roleKey">
<el-input v-model.trim="form.roleKey" show-word-limit :maxlength="30" placeholder="请输入权限字符" />
</el-form-item> -->
<el-form-item label="排序" prop="roleSort">
<el-input-number v-model="form.roleSort" style="width: 100%" controls-position="right" :min="0" />
</el-form-item>
<el-form-item label="状态">
<!-- <el-radio-group v-model="form.flag">-->
<!-- <el-radio :label="1">启用</el-radio>-->
<!-- <el-radio :label="0">停用</el-radio>-->
<!-- </el-radio-group>-->
<el-radio v-model="form.flag" label="1">启用</el-radio>
<el-radio v-model="form.flag" label="0">停用</el-radio>
</el-form-item>
<el-form-item label="菜单权限">
<!-- <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>-->
<!-- <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>-->
<!-- <el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox>-->
<el-tree
ref="menu"
class="tree-border"
:data="menuOptions"
show-checkbox
node-key="id"
check-strictly
empty-text="加载中,请稍后"
:props="defaultProps"
@check-change="handleMenuCheckChange"
/>
</el-form-item>
<el-form-item label="备注">
<el-input v-model.trim="form.remark" maxlength="200" show-word-limit type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="submitForm">确 定</el-button>
</div>
</el-dialog>
<!-- 分配设备数据权限对话框 -->
<el-dialog class="roleDialog" title="数据权限信息" :visible.sync="openDataScope" width="900px" append-to-body>
<el-row>
<el-col style="width: 49%">
<el-form ref="form" :model="form" :rules="rules" label-width="70px">
<el-form-item label="设备名称">
<el-input v-model.trim="form.roleName" placeholder="请输入设备名称" show-word-limit :maxlength="30" :disabled="true" />
</el-form-item>
<el-table
v-loading="loading"
:data="menuList"
row-key="businessId"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
max-height="400px"
>
<!-- <el-form-item label="权限字符">-->
<!-- <el-input v-model.trim="form.roleKey" placeholder="请输入设备名称" show-word-limit :maxlength="30" :disabled="true" />-->
<!-- </el-form-item>-->
<el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-circle-check"
@click="handleDataScope(scope.row)"
>修改</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</el-col>
<el-col style="width: 1%">
<div class="dividerStyle">
<el-divider direction="vertical" />
</div>
</el-col>
<el-col style="width: 49%">
<el-form :model="form" label-width="80px">
<el-form-item label="菜单名称" prop="roleName">
<el-input v-model="form.menuName" placeholder="未选择菜单名称" disabled />
</el-form-item>
<el-form-item label="权限范围">
<el-select v-model="form.dataScope">
<el-option
v-for="item in dataScopeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item v-show="form.dataScope === 2" label="数据权限">
<!-- <el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox>-->
<!-- <el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选</el-checkbox>-->
<!-- <el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动</el-checkbox>-->
<el-tree
ref="dept"
class="tree-border"
:data="deptOptions"
show-checkbox
default-expand-all
node-key="id"
:check-strictly="!form.deptCheckStrictly"
empty-text="加载中,请稍后"
:props="defaultProps"
/>
</el-form-item>
</el-form>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelDataScope">取 消</el-button>
<el-button type="primary" @click="submitDataScope">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from '@/api/system/role'
import { roleMenuTreeselectMC, treeselect as menuTreeselect, roleMenuTreeselect } from '@/api/system/menu'
import { treeselect as deptTreeselect, roleDeptTreeselect } from '@/api/system/dept'
// import { getRolesByInsId } from '../../../api/businessManage/template'
import Coolbutton from '@/components/coolbutton'
export default {
name: 'Role',
components: { Coolbutton },
data() {
return {
typeParent: 'text',
typePrimary: 'primary',
typeSuccess: 'success',
nameParent: '删除',
resetName: '重置',
addName: '申请',
exportName: '导出',
updataName: '修改',
size: 'mini',
smallSize: 'small',
delicon: 'el-icon-delete',
addIcon: 'el-icon-plus',
exportIcon: 'el-icon-download',
resetIcon: '',
haspermi: ['sys:user:delete'],
resetHaspermi: ['sys:user:resetPwd'],
updateHaspermi: ['sys:role:update'],
addHaspermi: ['sys:role:add'],
exportHaspermi: ['sys:role:export'],
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 总条数
total: 0,
// 设备表格数据
roleList: [],
// 弹出层标题
title: '',
// 是否显示弹出层
open: false,
// 是否显示弹出层(数据权限)
openDataScope: false,
// 日期范围
// dateRange: [],
// 菜单表格数据
menuList: [],
menuExpand: false,
menuNodeAll: false,
deptExpand: true,
deptNodeAll: false,
// 状态数据字典
statusOptions: [
{
dictLabel: '启用',
dictValue: '1'
},
{
dictLabel: '停用',
dictValue: '0'
}
],
// 数据范围选项
dataScopeOptions: [
{
value: '1',
label: '全部数据权限'
},
{
value: '2',
label: '自定数据权限'
},
{
value: '3',
label: '本部门数据权限'
},
{
value: '4',
label: '本部门及以下数据权限'
},
{
value: '5',
label: '仅本人数据权限'
}
],
// 菜单列表
menuOptions: [],
// 部门列表
tOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
roleName: undefined,
roleKey: undefined,
flag: undefined
}, },
// 表单参数 {
form: { dictLabel: '停用',
dictValue: '0'
}
],
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
page: 1,
rows: 10,
ipaddr: undefined,
username: undefined,
status: undefined,
loginTime: ''
}
}
},
}, // 多选提交操作
defaultProps: { methods: {
children: 'children', handleSelectionChange(selection) {
label: 'label' this.selectedRows = selection;
}, },
// 表单校验 submitSelectedRows() {
rules: { if (this.selectedRows.length === 0) {
roleName: [ return; // 如果没有选中行,不进行提交操作
{ required: true, message: '请输入设备名称', trigger: 'blur' }
],
roleKey: [
{ required: true, message: '请输入权限字符', trigger: 'blur' }
],
roleSort: [
{ required: true, message: '请输入设备排序', trigger: 'blur' }
]
},
deptOptions: []
} }
axios
.post('/api/submit', this.selectedRows) // 将选中的行数据提交到服务器的接口地址
.then(response => {
// 提交成功处理
console.log(response.data);
// 清空选中的行
this.selectedRows = [];
})
.catch(error => {
// 提交失败处理
console.error(error);
});
}, },
/** 路由离开前存储筛选条件*/ },
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', { /** 路由离开前存储筛选条件*/
path: this.$route.path, beforeRouteLeave(to, from, next) {
param: { this.$store.dispatch('searchSave/searchParamsSet', {
...this.queryParams path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters; const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
// this.queryParams.loginTime = this.$parseDate(new Date(), 'YYYY-MM-DD HH:mm:ss')
this.getList()
// this.getDicts(dictCons['COMMON_STATUS']).then(response => {
// this.statusOptions = response.data
// })
},
methods: {
// 清空和导出弹出框的日期选择器禁用当前月份之后的月份
handelFixDate() {
return {
disabledDate(time) {
// 如果想蕴含本月本月 - 8.64e7 * t 就不须要了,
// 如果想之前的不能抉择把 > 换成 <
return time.getTime() > Date.now()
} }
}
},
/** 查询登录日志列表 */
getList() {
this.loading = true
// const query = Object.assign({}, this.queryParams)
// query.loginTime = query.loginTime ? this.$parseDate(new Date(query.loginTime), 'YYYY-MM-DD HH:mm:ss') : ''
list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.list = response.rows
this.total = response.total
this.loading = false
}) })
next()
}, },
created() { handleClose() {
if (this.$store.getters.searchParams[this.$route.path]) { this.clearVisible = false
const { searchParams } = this.$store.getters; const { path } = this.$route this.exportVisible = false
const param = JSON.parse(searchParams[path]) // 保留着的查询条件 },
this.queryParams = { ...param } timechange(e) {
}
},
// 登录状态字典翻译
// statusFormat(row, column) {
// return this.selectDictLabel(this.statusOptions, row.status)
// },
/** 查询按钮操作 */
handleQuery() {
this.queryParams.page = 1
this.getList() this.getList()
// this.getDicts(dictCons['NORMAL_DISABLE']).then(response => {
// this.statusOptions = response.data;
// });
}, },
methods: { /** 重置按钮操作 */
/** 查询设备列表 */ resetQuery() {
getList() { this.dateRange = ''
this.loading = true this.resetForm('queryForm')
listRole(this.queryParams).then( this.handleQuery()
response => { },
this.roleList = response.rows // 多选框选中数据
this.total = response.total handleSelectionChange(selection) {
this.loading = false this.ids = selection.map(item => item.businessId)
} this.multiple = !selection.length
) },
}, /** 删除按钮操作 */
/** 查询菜单树结构 */ handleDelete(data) {
getMenuTreeselect() { this.$confirm('是否确认操作?', '提示', {
menuTreeselect().then(response => { confirmButtonText: '确定',
this.menuOptions = response.data cancelButtonText: '取消',
}) type: 'warning'
}, }).then(() => {
/** 查询菜单列表 */ // const id = this.ids.join(',')
getMenuList(roleId) { const id = data
roleMenuTreeselectMC(roleId).then(response => { const query = {
this.menuList = this.handleTree(response.data.menus, 'businessId') deleteIds: id
this.loading = false
})
},
/** 查询部门树结构 */
getDeptTreeselect() {
deptTreeselect().then(response => {
this.deptOptions = response.data
})
},
// 树状图节点点击选中事件
handleMenuCheckChange(data, check, subCheck) { // data为选中节点信息,check选中状态
if (data.children !== undefined && data.children !== null) { // 是否包含子节点
this.checkNode(data.children, check) // 调用checkNode方法
}
// // 获取所有被选中的节点信息
// const nodes = this.$refs.menu.getCheckedNodes(false, false)
// // 将获取到的信息赋值(根据自己的需求)
// this.custGroupDesc = nodes.map(item => item.CN_NAME)
// this.searchForm.custGroup = nodes.map(item => item.code)
},
// 选中所有下级节点
checkNode(data, check) {
// 遍历所有下级节点信息
data.forEach(item => {
// 通过节点信息设置选中状态
this.$refs.menu.setChecked(item, check, false)
// 是否包含下级节点,包含下级节点则选中所有下级节点
if (item.children !== undefined) {
this.checkNode(item.children, check)
}
})
},
// 所有菜单节点数据
getMenuAllCheckedKeys() {
// 目前被选中的菜单节点
const checkedKeys = this.$refs.menu.getHalfCheckedKeys()
// 半选中的菜单节点
const halfCheckedKeys = this.$refs.menu.getCheckedKeys()
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
return checkedKeys
},
// 所有部门节点数据
getDeptAllCheckedKeys() {
// 目前被选中的部门节点
const checkedKeys = this.$refs.dept.getHalfCheckedKeys()
// // 半选中的部门节点
const halfCheckedKeys = this.$refs.dept.getCheckedKeys()
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
return this.$refs.dept.getCheckedKeys()
},
/** 根据设备ID查询菜单树结构 */
getRoleMenuTreeselect(roleId) {
return roleMenuTreeselect(roleId).then(response => {
this.menuOptions = response.data.menus
return response
})
},
/** 根据设备ID和菜单ID查询部门树结构 */
getRoleDeptTreeselect(roleId, menuId) {
return roleDeptTreeselect(roleId, menuId).then(response => {
this.form.deptCheckStrictly = response.data.deptCheckStrictly
this.deptOptions = response.data.depts
this.form.dataScope = this.dataScopeOptions[response.data.dataScope - 1].value
return response
})
},
// 设备状态修改
handleStatusChange(row) {
const text = row.flag === '1' ? '启用' : '停用'
this.$confirm('是否确认操作?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return changeRoleStatus(row.businessId, row.flag)
}).then(() => {
this.$message({
message: text + '成功',
type: 'success'
})
}).catch(function() {
row.flag = row.flag === '0' ? '1' : '0'
})
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 取消按钮(数据权限)
cancelDataScope() {
this.openDataScope = false
this.reset()
},
// 表单重置
reset() {
if (this.$refs.menu !== undefined) {
this.$refs.menu.setCheckedKeys([])
}
this.menuExpand = false
this.menuNodeAll = false
this.deptExpand = true
this.deptNodeAll = false
this.form = {
roleId: undefined,
businessId: undefined,
roleName: undefined,
roleKey: undefined,
roleSort: 0,
flag: '1',
menuIds: [],
menuName: undefined,
deptIds: [],
menuCheckStrictly: false,
deptCheckStrictly: false,
remark: undefined
} }
this.resetForm('form') return delLogininfo(query)
}, }).then(() => {
/** 查询按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList() this.getList()
}, this.$message.success('删除成功')
/** 重置按钮操作 */ this.ids = []
resetQuery() { this.multiple = true
// this.dateRange = [] }).catch(function() {})
this.resetForm('queryForm') },
this.handleQuery() clear() {
}, this.$refs['clear'].validate((valid) => {
// 多选框选中数据 if (valid) {
handleSelectionChange(selection) { const that = this
this.ids = selection.map(item => item.roleId) const query = {
this.single = selection.length !== 1 beginTime: that.clearFrom.month[0],
this.multiple = !selection.length endTime: that.clearFrom.month[1]
},
// // 树权限(父子联动)
// handleCheckedTreeConnect(value, type) {
// if (type === 'menu') {
// this.form.menuCheckStrictly = !!value
// } else if (type === 'dept') {
// this.form.deptCheckStrictly = !!value
// }
// },
// 树权限(全选/全不选)
handleCheckedTreeNodeAll(value, type) {
if (type === 'menu') {
this.$refs.menu.setCheckedNodes(value ? this.menuOptions : [])
} else if (type === 'dept') {
this.$refs.dept.setCheckedNodes(value ? this.deptOptions : [])
}
},
// 树权限(展开/折叠)
handleCheckedTreeExpand(value, type) {
if (type === 'menu') {
const treeList = this.menuOptions
for (let i = 0; i < treeList.length; i++) {
this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value
}
} else if (type === 'dept') {
const treeList = this.deptOptions
for (let i = 0; i < treeList.length; i++) {
this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value
} }
} cleanLogininfo(query).then(res => {
}, if (res.code === 200) {
/** 新增按钮操作 */ that.getList()
handleAdd() { that.$message.success('清空成功')
this.reset() this.clearVisible = false
this.getMenuTreeselect()
this.open = true
this.title = '添加设备'
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const roleId = row.businessId || this.ids
const roleMenu = this.getRoleMenuTreeselect(roleId)
getRole(roleId).then(response => {
this.form = response.data
this.open = true
this.getMenuTreeselect(roleId)
this.$nextTick(() => {
roleMenu.then(res => {
this.$refs.menu.setCheckedKeys(res.data.checkedKeys)
})
})
this.title = '修改设备'
})
},
/** 分配数据权限操作 选择菜单 */
handleMenu(row) {
this.reset()
const roleId = row.businessId || this.ids
this.getMenuList(roleId) // 查询菜单列表树形显示
getRole(roleId).then(response => {
this.form = response.data
this.openDataScope = true
this.title = '分配数据权限'
})
},
/** 分配数据权限操作 */
handleDataScope(row) {
this.deptOptions = []
this.form.dataScope = undefined
const roleId = this.form.businessId
this.form.menuId = row.businessId
this.form.menuName = row.menuName
const roleDeptTreeselect = this.getRoleDeptTreeselect(roleId, this.form.menuId)
this.$nextTick(() => {
roleDeptTreeselect.then(res => {
this.$refs.dept.setCheckedKeys(res.data.checkedKeys)
})
})
this.title = '分配数据权限'
},
/** 提交按钮 */
submitForm: function() {
this.$refs['form'].validate(valid => {
if (valid) {
this.form.menuCheckStrictly = false
if (this.form.businessId !== undefined) {
this.form.menuIds = this.getMenuAllCheckedKeys()
updateRole(this.form).then(response => {
this.msgSuccess('修改成功')
this.open = false
this.getList()
})
} else { } else {
this.form.menuIds = this.getMenuAllCheckedKeys() that.$message.error(res.message)
addRole(this.form).then(response => {
this.msgSuccess('新增成功')
this.open = false
this.getList()
})
} }
}
})
},
/** 提交按钮(数据权限) */
submitDataScope: function() {
if (this.form.businessId !== undefined && this.form.menuId !== undefined) {
this.form.deptIds = this.getDeptAllCheckedKeys()
dataScope(this.form).then(response => {
this.msgSuccess('修改成功')
this.openDataScope = false
this.getList()
}) })
} }
}, })
/** 删除按钮操作 */ },
handleDelete(row) { /** 清空按钮操作 */
const roleIds = row.businessId || this.ids handleClean() {
this.$confirm('是否确认操作?', '提示', { this.clearVisible = true
confirmButtonText: '确定', this.clearFrom = {}
cancelButtonText: '取消', },
type: 'warning' exportSubmit() {
}).then(function() { this.$refs['export'].validate((valid) => {
return delRole(roleIds) if (valid) {
}).then(() => { const that = this
this.getList() const query = {
this.$message({ beginTime: that.exportFrom.month[0],
message: '删除成功', endTime: that.exportFrom.month[1]
type: 'success' }
return exportLogininfo(query).then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '登录日志' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
this.exportVisible = false
// this.download(response.msg)
}) })
}).catch(function() { }
}) })
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
// handleExport() { handleExport() {
// const queryParams = this.queryParams this.exportVisible = true
// this.$confirm('是否确认操作?', '警告', { this.exportFrom = {}
// confirmButtonText: '确定', // const queryParams = Object.assign({}, this.queryParams)
// cancelButtonText: '取消', // // queryParams.loginTime = queryParams.loginTime ? this.$parseDate(new Date(queryParams.loginTime), 'YYYY-MM-DD HH:mm:ss') : ''
// type: 'warning' // delete queryParams.page
// }).then(function() { // delete queryParams.rows
// return exportRole(queryParams).then(response => { // queryParams.ids = this.ids.join(',') || null
// const blob = new Blob([response]) // exportLogininfo(queryParams).then(response => {
// const downloadElement = document.createElement('a') // this.download(response.msg)
// const href = window.URL.createObjectURL(blob)// 创建下载的链接 // }).catch(function() {})
// downloadElement.href = href
// downloadElement.download = '设备信息' + '.xls' // 下载后文件名
// document.body.appendChild(downloadElement)
// downloadElement.click()// 点击下载
// document.body.removeChild(downloadElement)// 下载完成移除元素
// window.URL.revokeObjectURL(href)// 释放掉blob对象
// // this.download(response.msg);
// })
// })
// }
}
}
</script>
<style lang="scss" scoped>
.app-container {
font-size: 18px;
padding: 0;
.placeholder {
height: 1.3vh;
background-color: #F4F4F4;
margin-bottom: 10px
}
.table-drop {
vertical-align: 2px;
line-height: 20px;
margin-left: 15px
}
.el-switch {
margin-left: 15px;
} }
} }
.el-divider--vertical{ }
height: 12em; </script>
width: 4px; <style lang="scss" scoped>
.app-container {
padding: 0;
font-size: 18px;
.placeholder{
height:14px;
background-color: #F4F4F4;
margin-bottom:10px
} }
</style> }
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment