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,538 @@
<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 label="部门负责人" prop="leader">
<el-input
v-model="queryParams.leader"
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:sysBranch: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:sysBranch: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:sysBranch:remove']"
>删除</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:sysBranch:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<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="部门负责人" min-width="20%" align="center" prop="leader" />
<el-table-column label="联系电话" min-width="20%" align="center" prop="phone" />
<el-table-column label="所属规则" width="300" align="center" prop="ruleId" :formatter="ruleName" :show-overflow-tooltip="true" />
<el-table-column label="操作" width="250" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-add"
@click="handleAdd(scope.row)"
v-hasPermi="['system:sysBranch:add']"
>新增</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:sysBranch:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleDown(scope.row)"
v-hasPermi="['system:sysBranch:down']"
>下发</el-button>
<el-button
v-if="scope.row.parentId != 0"
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:sysBranch:remove']"
>删除</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-col>
</el-row>
<!-- 添加或修改部门管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="24" >
<el-form-item label="上级部门" prop="parentId">
<treeselect v-model="form.parentId" :options="branchOptions" :normalizer="normalizer" placeholder="选择上级部门" />
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="部门名称" prop="name">
<el-input v-model="form.name" placeholder="请输入部门名称"/>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="负责人" prop="leader">
<el-input v-model="form.leader" placeholder="请输入负责人"/>
</el-form-item>
</el-col>
<el-col :span="12" >
<el-form-item label="联系电话" prop="phone">
<el-input v-model="form.phone" placeholder="请输入联系电话"/>
</el-form-item>
</el-col>
<el-col :span="24" >
<el-form-item label="所属规则" prop="ruleId">
<treeselect v-model="form.ruleId" :options="ruleOptions" :normalizer="normalizer" placeholder="请选择" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="归属部门" prop="deptId">
<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
</el-form-item>
</el-col>
</el-row>
</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 {listSysBranch,getSysBranch, delSysBranch,addSysBranch,updateSysBranch,listBranchExcludeChild, branchTreeSelect,downSysBranch} 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;
});
},
/** 查询部门管理列表 */
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;
});
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset();
if (row != undefined) {
this.form.parentId = row.id;
}
this.open = true;
this.title = "添加部门管理";
listSysBranch().then(response => {
this.branchOptions = this.handleTree(response.data, "id");
});
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getSysBranch(id).then(res => {
this.form = res.data;
if(res.data.ruleId == null){
this.form.ruleId = undefined
}
if(res.data.ladderRuleId == null){
this.form.ladderRuleId = undefined
}
if(res.data.deptId == null){
this.form.deptId = undefined
}
this.open = true;
this.title = "修改部门管理";
});
listBranchExcludeChild(row.id).then(response => {
let temp = [];
this.branchOptions = []
temp = this.handleTree(response.data, "id");
this.branchOptions.push({
id:'0',
parentId:'-1',
children:temp,
name:'锦江集团',
disabled:true
})
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
let obj = JSON.parse(JSON.stringify(this.form));
if(this.form.ruleId == undefined){
obj.ruleId = null
}
if(this.form.ladderRuleId == undefined){
obj.ladderRuleId = null
}
if(this.form.deptId == undefined){
obj.deptId = null
}
updateSysBranch(obj).then(res => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addSysBranch(this.form).then(res => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除部门管理编号为"' + ids + '"的数据项?').then(function() {
return delSysBranch(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/sysBranch/export', {
...this.queryParams
}, `sysBranch_${new Date().getTime()}.xlsx`)
},
/** 删除按钮操作 */
handleDown(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认下发部门编号为"' + ids + '"的人员数据项?').then(function() {
return downSysBranch(ids);
}).then(() => {
this.$modal.msgSuccess("下发成功");
}).catch(() => {});
},
ruleName(row){
if(row.ruleId){
for (let i = 0; i < this.ruleOptions.length; i++) {
if (this.ruleOptions[i].id == row.ruleId) {
return this.ruleOptions[i].name;
}
}
}else {
return '尚未填写'
}
}
}
};
</script>
<style scoped>
.el-tree{
overflow: auto;
height:720px;
}
.custom-tree-node{
font-size:14px;
}
</style>