first commit

This commit is contained in:
zc
2025-06-05 09:55:41 +08:00
commit 935360c185
459 changed files with 61034 additions and 0 deletions

View File

@@ -0,0 +1,329 @@
<template>
<div class="app-container">
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-input
v-model="branchName"
placeholder="请输入部门名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container">
<el-tree
:data="treeOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="treeRef"
node-key="id"
highlight-current
@node-click="handleNodeClick"
:default-expanded-keys="nodeKey">
<!-- <span slot-scope="{ node, data }">
<el-tooltip class="item" effect="dark" :content="node.label" placement="right">
<span class="custom-tree-node">{{ node.label }}</span>
</el-tooltip>
</span> -->
</el-tree>
</div>
</el-col>
<el-col :span="20" :xs="24">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<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-table v-if="refreshTable" v-loading="loading" :data="sysBranchList" :indent="30" row-key="id" :default-expand-all="isExpandAll" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="部门名称" align="left" prop="name" :show-overflow-tooltip="true" />
<el-table-column label="是否审核" align="center" prop="isExamine">
<template slot-scope="scope">
<template v-if="scope.row.examine"></template>
<template v-else></template>
</template>
</el-table-column>
<el-table-column label="操作" width="250" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-switch v-model="scope.row.examine" @change="changeExamine(scope.row,$event)"></el-switch>
</template>
</el-table-column>
</el-table>
<!-- <pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>-->
</el-col>
</el-row>
</div>
</template>
<script>
import {listSysBranch,branchTreeSelect,updateSysBranch } from "@/api/system/sysBranch";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { listRules} from "@/api/system/rule";
import {deptTreeSelect} from "@/api/system/user";
export default {
name: "SysBranch",
components: { Treeselect },
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 选中数组名称
idNames: [],
// 部门树选项
branchOptions: [],
treeOptions: [],
// 空间树选项
spaceOptions: [],
ruleOptions: [],
nodeKey: [],
ladderRule: [],
// 部门名称
branchId: undefined,
branchName: undefined,
deptOptions: undefined,
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 部门管理表格数据
sysBranchList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 是否展开,默认全部展开
isExpandAll: true,
// 重新渲染表格状态
refreshTable: true,
defaultProps: {
children: 'children',
label: 'label'
},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
id: null,
name: null,
leader: null,
phone: null,
parentId: null,
level: null,
ancestors: null,
spaceId: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
name: [
{ required: true, message: "部门名称不能为空", trigger: "blur" }
],
parentId: [
{ required: true, message: "上级部门不能为空", trigger: "change" }
],
phone:[
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
]
}
};
},
watch: {
// 根据名称筛选部门树
branchName(val) {
this.$refs.treeRef.filter(val)
}
},
created() {
this.getOptions()
this.getList();
this.getDeptTree();
},
methods: {
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then(response => {
this.deptOptions = response.data;
});
},
changeExamine(row,e){
console.log(e);
let obj = {
id:row.id,
isExamine:e ? '1' : '0'
};
let flag = row.examine //保存点击之后v-modeld的值(truefalse)
row.examine = !row.examine //保持switch点击前的状态
let that = this;
if(e){
this.$modal.confirm('确定要审核?').then(function() {
flag ? row.examine = true : row.showState = false // 这一步很重要row.showState会根据flag的值开启或关闭开关
updateSysBranch(obj).then(res => {
that.$modal.msgSuccess("审核成功");
that.getList();
});
})
}else{
this.$modal.confirm('确定取消审核?').then(function() {
flag ? row.examine = true : row.examine = false // 这一步很重要row.showState会根据flag的值开启或关闭开关
updateSysBranch(obj).then(res => {
that.$modal.msgSuccess("取消成功");
that.getList();
});
})
}
},
/** 查询部门管理列表 */
getList() {
this.loading = true;
listSysBranch(this.queryParams).then(response => {
this.sysBranchList = this.handleTree(response.data, "id");
this.loading = false;
});
},
/** 查询选项列表 */
getOptions() {
this.treeOptions = []
branchTreeSelect().then(response => {
this.treeOptions = response.data
this.nodeKey.push(this.treeOptions[0].id)
}),
/* this.spaceOptions = []
spaceTreeSelect().then(response => {
this.spaceOptions = response.data
}) */
this.ruleOptions = []
listRules().then(response => {
this.ruleOptions = response.data
})
},
/** 转换树数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.name,
isDisabled: false,
children: node.children
};
},
/** 转换树数据结构 */
normalizer1(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.label,
isDisabled: false,
children: node.children
};
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
name: null,
leader: null,
phone: null,
parentId: null,
level: null,
ancestors: null,
spaceId: null,
remark: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 多选框选中数据 */
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.idNames = selection.map(item => item.name)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 筛选节点 */
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
/** 节点单击事件 */
handleNodeClick(data) {
this.queryParams.id = data.id
this.handleQuery()
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
this.$nextTick(() => {
this.refreshTable = true;
});
}
}
};
</script>
<style lang="scss" scoped>
.el-tree{
overflow: auto;
height:720px;
}
.custom-tree-node{
font-size:14px;
}
</style>