first commit
This commit is contained in:
103
src/views/system/ladderRule/RoleAuthModal.vue
Normal file
103
src/views/system/ladderRule/RoleAuthModal.vue
Normal file
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-checkbox v-model="menuExpand" @change="handleTreeExpand">展开/折叠</el-checkbox>
|
||||
<el-checkbox v-model="menuNodeAll" @change="handleTreeNodeAll">全选/全不选</el-checkbox>
|
||||
<el-tree
|
||||
class="tree-border"
|
||||
:data="menuOptions"
|
||||
show-checkbox
|
||||
ref="authRef"
|
||||
:default-checked-keys="pointIds"
|
||||
node-key="id"
|
||||
empty-text="加载中,请稍候"
|
||||
:style="{height:isExpanded ? '420px' : 'auto',overflow:isExpanded ? 'auto' : ''}"
|
||||
:props="defaultProps"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'RoleAuthModal',
|
||||
props: {
|
||||
// 源策略选项
|
||||
menuOptions: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
defaultProps:{
|
||||
type:Object,
|
||||
default:{
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
menuExpand: false,
|
||||
menuNodeAll: false,
|
||||
isExpanded: false,
|
||||
pointIds: [],
|
||||
/* defaultProps: {
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
} */
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 获取树权限 */
|
||||
getAuthScope(id) {
|
||||
this.pointIds = id.split(",")
|
||||
/* this.$nextTick(() => {
|
||||
pointIds.forEach((v) => {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.authRef.setChecked(v, true, false)
|
||||
})
|
||||
})
|
||||
}) */
|
||||
},
|
||||
/** 树权限(展开/折叠) */
|
||||
handleTreeExpand(value) {
|
||||
const treeNode = this.$refs.authRef.store.nodesMap;
|
||||
for (let key in treeNode) {
|
||||
treeNode[key].expanded = !this.isExpanded;
|
||||
}
|
||||
this.isExpanded = !this.isExpanded;
|
||||
},
|
||||
/** 树权限(全选/全不选) */
|
||||
handleTreeNodeAll(value) {
|
||||
this.$refs.authRef.setCheckedNodes(value ? this.menuOptions : [])
|
||||
},
|
||||
/** 所有权限节点数据 */
|
||||
getAllCheckedKeys() {
|
||||
// 目前被选中的节点
|
||||
let checkedKey = this.$refs.authRef.getCheckedNodes();
|
||||
let checkedKeys =[];
|
||||
if(checkedKey.length>0){
|
||||
for(let i=0;i<checkedKey.length;i++){
|
||||
if(checkedKey[i].children){
|
||||
checkedKeys.push(checkedKey[i].id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 半选中的节点
|
||||
let halfCheckedKeys = this.$refs.authRef.getHalfCheckedKeys()
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
|
||||
return checkedKeys
|
||||
},
|
||||
getCheckAllNode(){
|
||||
let checkedNode = this.$refs.authRef.getCheckedNodes();
|
||||
return checkedNode;
|
||||
},
|
||||
closeTree(){
|
||||
this.isExpanded = false
|
||||
this.menuExpand = false
|
||||
this.menuNodeAll = false
|
||||
this.$refs.authRef.setCheckedKeys([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
||||
406
src/views/system/ladderRule/index.vue
Normal file
406
src/views/system/ladderRule/index.vue
Normal file
@@ -0,0 +1,406 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="规则名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入规则名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['system:ladderRule:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['system:ladderRule:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['system:ladderRule:del']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['system:ladderRule:export']"
|
||||
>导出</el-button>
|
||||
</el-col> -->
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="ladderList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="规则名称" align="center" prop="name" />
|
||||
<el-table-column label="有效期" align="center" prop="startTime" width="250">
|
||||
<template slot-scope="scope">
|
||||
<template v-if="scope.row.startTime">{{ parseTime(scope.row.startTime, '{y}年{m}月{d}日') }}-{{ parseTime(scope.row.endTime, '{y}年{m}月{d}日') }}</template>
|
||||
<template v-else>尚未填写</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<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-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:ladderRule:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:ladderRule:del']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改梯控规则对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @close="cancel">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="规则名称:" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入规则名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="有效期:" prop="startTime">
|
||||
<el-date-picker
|
||||
v-model="form.value1"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="yyyy-MM-dd"
|
||||
@input="input1()"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="准入时间:" prop="admittanceStart">
|
||||
<el-time-picker
|
||||
is-range
|
||||
v-model="form.value2"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
placeholder="选择时间范围"
|
||||
value-format="HH:mm:ss"
|
||||
@input="input2()"
|
||||
>
|
||||
</el-time-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备位置:" prop="pointIds">
|
||||
<RoleAuthModal ref="authRef" :menuOptions="menuOptions" :defaultProps="defaultProps" />
|
||||
</el-form-item>
|
||||
<el-form-item label="人员权限:" prop="permission">
|
||||
<el-checkbox-group v-model="form.permission">
|
||||
<el-checkbox label="QRCodePermission" name="permission">二维码权限</el-checkbox>
|
||||
<el-checkbox label="idCardPermission" name="permission">刷卡权限</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
import { listLadder, getLadder, delLadder, addLadder, updateLadder,queryDevicePositionTree } from "@/api/system/ladderRule";
|
||||
import RoleAuthModal from './RoleAuthModal'
|
||||
import { formatDate } from '@/utils'
|
||||
export default {
|
||||
name: "Ladder",
|
||||
components: {RoleAuthModal},
|
||||
data() {
|
||||
return {
|
||||
menuOptions:[],
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 梯控规则表格数据
|
||||
ladderList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
permission:[]
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name:{ required: true, message: "规则名称不能为空", trigger: "blur" }
|
||||
},
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name'
|
||||
},
|
||||
childNode:[],
|
||||
currentNode:[]
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getOptions();
|
||||
},
|
||||
methods: {
|
||||
getOptions() {
|
||||
this.menuOptions = []
|
||||
/* ruleAuthApi().then(response => {
|
||||
this.menuOptions = response.depts
|
||||
}) */
|
||||
},
|
||||
/** 查询梯控规则列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listLadder(this.queryParams).then(response => {
|
||||
this.ladderList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
name:'',
|
||||
value1:[],
|
||||
pointIds:[],
|
||||
permission:[]
|
||||
};
|
||||
this.$refs.form.resetFields();
|
||||
this.$refs.authRef.closeTree();
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.queryParams = {
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
}
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
isLeafNode(array){
|
||||
//递归
|
||||
array.map((ele) => {
|
||||
if(ele.children){
|
||||
this.isLeafNode(ele.children)
|
||||
}else{
|
||||
if(ele.name == '18'){
|
||||
ele.name = '19'
|
||||
}
|
||||
else if(ele.name == '19'){
|
||||
ele.name = '19A'
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
deviceTree(){
|
||||
// 设备位置树形
|
||||
queryDevicePositionTree().then(res => {
|
||||
this.isLeafNode(res.data);
|
||||
this.menuOptions = res.data;
|
||||
})
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.deviceTree();
|
||||
this.open = true;
|
||||
this.title = "添加";
|
||||
},
|
||||
input1() {
|
||||
this.$forceUpdate();
|
||||
},
|
||||
input2() {
|
||||
this.$forceUpdate();
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.deviceTree();
|
||||
const id = row.id || this.ids
|
||||
getLadder(id).then(res => {
|
||||
this.form = res.data;
|
||||
this.form.permission = res.data.permission.split(',')
|
||||
let value1 = []
|
||||
let value2 = []
|
||||
value1[0] = res.data.startTime
|
||||
value1[1] = res.data.endTime
|
||||
value2[0] = res.data.admittanceStart
|
||||
value2[1] = res.data.admittanceEnd
|
||||
this.form.value1 = res.data.startTime ? value1 :''
|
||||
this.form.value2 = res.data.admittanceStart ? value2 : ''
|
||||
this.$nextTick(() => {
|
||||
this.$refs.authRef.handleTreeNodeAll()
|
||||
this.$refs.authRef.getAuthScope(res.data.pointId)
|
||||
})
|
||||
this.open = true;
|
||||
this.title = "修改";
|
||||
});
|
||||
},
|
||||
getChildrenId(arr){
|
||||
let leafNodes = [];
|
||||
arr.forEach(ele => {
|
||||
if(ele.children == null){
|
||||
leafNodes.push(ele.id);
|
||||
}
|
||||
})
|
||||
return leafNodes;
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
console.log("时间", this.form.value1)
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
let flag = true
|
||||
let pointId = [];
|
||||
let pointName = [];
|
||||
let treeArr = [];
|
||||
treeArr = this.$refs.authRef.getCheckAllNode();
|
||||
treeArr.forEach(ele => {
|
||||
pointId.push(ele.id);
|
||||
pointName.push(ele.name);
|
||||
})
|
||||
this.form.pointIds = this.$refs.authRef.getAllCheckedKeys();
|
||||
this.form.pointId = pointId.toString();
|
||||
this.form.pointName = pointName.toString();
|
||||
this.form.storeyId = this.getChildrenId(treeArr).toString();
|
||||
if(this.form.storeyId){
|
||||
flag = true
|
||||
}else{
|
||||
flag = false
|
||||
this.$message({
|
||||
message: '设备位置不能为空',
|
||||
type: 'warning'
|
||||
});
|
||||
return
|
||||
}
|
||||
if(flag){
|
||||
if(this.form.value1){
|
||||
this.form.startTime = moment(this.form.value1[0]).format('yyyy-MM-DD') + ' 00:00:00';
|
||||
this.form.endTime = moment(this.form.value1[1]).format('yyyy-MM-DD') + ' 23:59:59';
|
||||
}else{
|
||||
this.form.startTime = ''
|
||||
this.form.endTime = ''
|
||||
}
|
||||
if(this.form.value2){
|
||||
this.form.admittanceStart = this.form.value2[0]
|
||||
this.form.admittanceEnd = this.form.value2[1]
|
||||
}else{
|
||||
this.form.admittanceStart = ''
|
||||
this.form.admittanceEnd = ''
|
||||
}
|
||||
if(this.form.permission.length > 0){
|
||||
this.form.permission = this.form.permission.toString()
|
||||
}else{
|
||||
this.form.permission = ''
|
||||
}
|
||||
delete this.form.value1
|
||||
delete this.form.value2
|
||||
if (this.form.id != null) {
|
||||
updateLadder(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.cancel();
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addLadder(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.cancel();
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('确实要删除吗?').then(function() {
|
||||
return delLadder(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('system/ladderRule/export', {
|
||||
...this.queryParams
|
||||
}, `ladder_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user