部门管理新增添加公司功能
This commit is contained in:
parent
5b27e5202f
commit
b811e66339
|
|
@ -56,10 +56,15 @@ export function apiGetPartTree() {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/select/getPartTree',
|
url: '/system/select/getPartTree',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data:{}
|
data: {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增公司
|
||||||
|
export const addCompanyApi = (data) => {
|
||||||
|
return request.post('/system/dept/addCompany', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,336 +1,576 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
|
<el-form
|
||||||
<el-form-item label="部门名称" prop="deptName">
|
:model="queryParams"
|
||||||
<el-input
|
ref="queryForm"
|
||||||
v-model="queryParams.deptName"
|
size="small"
|
||||||
placeholder="请输入部门名称"
|
:inline="true"
|
||||||
clearable
|
v-show="showSearch"
|
||||||
@keyup.enter.native="handleQuery"
|
>
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="状态" prop="status">
|
|
||||||
<el-select v-model="queryParams.status" filterable placeholder="部门状态" clearable>
|
|
||||||
<el-option
|
|
||||||
v-for="dict in dict.type.sys_normal_disable"
|
|
||||||
:key="dict.value"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</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:dept:add']"
|
|
||||||
>新增</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="deptList"
|
|
||||||
row-key="deptId"
|
|
||||||
:default-expand-all="isExpandAll"
|
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
||||||
>
|
|
||||||
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
|
|
||||||
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
|
|
||||||
<el-table-column prop="status" label="状态" width="100">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
|
||||||
</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:dept:edit']"
|
|
||||||
>修改</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-plus"
|
|
||||||
@click="handleAdd(scope.row)"
|
|
||||||
v-hasPermi="['system:dept:add']"
|
|
||||||
>新增</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:dept:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<!-- 添加或修改部门对话框 -->
|
|
||||||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24" v-if="form.parentId !== 0">
|
|
||||||
<el-form-item label="上级部门" prop="parentId">
|
|
||||||
<treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果" placeholder="选择上级部门" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="部门名称" prop="deptName">
|
<el-form-item label="部门名称" prop="deptName">
|
||||||
<el-input v-model="form.deptName" placeholder="请输入部门名称" />
|
<el-input
|
||||||
|
v-model="queryParams.deptName"
|
||||||
|
placeholder="请输入部门名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
<el-form-item label="状态" prop="status">
|
||||||
<el-col :span="12">
|
<el-select
|
||||||
<el-form-item label="显示排序" prop="orderNum">
|
v-model="queryParams.status"
|
||||||
<el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
|
filterable
|
||||||
|
placeholder="部门状态"
|
||||||
|
clearable
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.sys_normal_disable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
<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="handleAddCompany"
|
||||||
|
v-if="userId == 1"
|
||||||
|
>新增公司</el-button
|
||||||
|
>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['system:dept:add']"
|
||||||
|
>新增部门</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-row>
|
||||||
<el-row>
|
|
||||||
<el-col :span="12">
|
<el-table
|
||||||
<el-form-item label="负责人" prop="leader">
|
v-if="refreshTable"
|
||||||
<el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" />
|
v-loading="loading"
|
||||||
</el-form-item>
|
:data="deptList"
|
||||||
</el-col>
|
row-key="deptId"
|
||||||
<el-col :span="12">
|
:default-expand-all="isExpandAll"
|
||||||
<el-form-item label="联系电话" prop="phone">
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||||
<el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" onkeyup="this.value = this.value.replace(/[^\d]/g,'');"/>
|
>
|
||||||
</el-form-item>
|
<el-table-column
|
||||||
</el-col>
|
prop="deptName"
|
||||||
</el-row>
|
label="部门名称"
|
||||||
<el-row>
|
width="260"
|
||||||
<el-col :span="12">
|
></el-table-column>
|
||||||
<el-form-item label="邮箱" prop="email">
|
<el-table-column
|
||||||
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
|
prop="orderNum"
|
||||||
</el-form-item>
|
label="排序"
|
||||||
</el-col>
|
width="200"
|
||||||
<el-col :span="12">
|
></el-table-column>
|
||||||
<el-form-item label="部门状态">
|
<el-table-column prop="status" label="状态" width="100">
|
||||||
<el-radio-group v-model="form.status">
|
<template slot-scope="scope">
|
||||||
<el-radio
|
<dict-tag
|
||||||
v-for="dict in dict.type.sys_normal_disable"
|
:options="dict.type.sys_normal_disable"
|
||||||
:key="dict.value"
|
:value="scope.row.status"
|
||||||
:label="dict.value"
|
/>
|
||||||
>{{dict.label}}</el-radio>
|
</template>
|
||||||
</el-radio-group>
|
</el-table-column>
|
||||||
</el-form-item>
|
<el-table-column
|
||||||
</el-col>
|
label="创建时间"
|
||||||
</el-row>
|
align="center"
|
||||||
</el-form>
|
prop="createTime"
|
||||||
<div slot="footer" class="dialog-footer">
|
width="200"
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
>
|
||||||
<el-button @click="cancel">取 消</el-button>
|
<template slot-scope="scope">
|
||||||
</div>
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
</el-dialog>
|
</template>
|
||||||
</div>
|
</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:dept:edit']"
|
||||||
|
>修改</el-button
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="handleAdd(scope.row)"
|
||||||
|
v-hasPermi="['system:dept:add']"
|
||||||
|
>新增</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:dept:remove']"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<!-- 添加或修改部门对话框 -->
|
||||||
|
<el-dialog
|
||||||
|
:title="title"
|
||||||
|
:visible.sync="open"
|
||||||
|
width="600px"
|
||||||
|
append-to-body
|
||||||
|
>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24" v-if="form.parentId !== 0">
|
||||||
|
<el-form-item label="上级部门" prop="parentId">
|
||||||
|
<treeselect
|
||||||
|
v-model="form.parentId"
|
||||||
|
:options="deptOptions"
|
||||||
|
:normalizer="normalizer"
|
||||||
|
noChildrenText="没有数据了"
|
||||||
|
noOptionsText="没有数据"
|
||||||
|
noResultsText="没有搜索结果"
|
||||||
|
placeholder="选择上级部门"
|
||||||
|
@select="treeChange"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="部门名称" prop="deptName">
|
||||||
|
<el-input
|
||||||
|
v-model="form.deptName"
|
||||||
|
placeholder="请输入部门名称"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="显示排序" prop="orderNum">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.orderNum"
|
||||||
|
controls-position="right"
|
||||||
|
:min="0"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="负责人" prop="leader">
|
||||||
|
<el-input
|
||||||
|
v-model="form.leader"
|
||||||
|
placeholder="请输入负责人"
|
||||||
|
maxlength="20"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="联系电话" prop="phone">
|
||||||
|
<el-input
|
||||||
|
v-model="form.phone"
|
||||||
|
placeholder="请输入联系电话"
|
||||||
|
maxlength="11"
|
||||||
|
onkeyup="this.value = this.value.replace(/[^\d]/g,'');"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="邮箱" prop="email">
|
||||||
|
<el-input
|
||||||
|
v-model="form.email"
|
||||||
|
placeholder="请输入邮箱"
|
||||||
|
maxlength="50"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="部门状态">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in dict.type.sys_normal_disable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value"
|
||||||
|
>{{ dict.label }}</el-radio
|
||||||
|
>
|
||||||
|
</el-radio-group>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<!-- 新增公司 -->
|
||||||
|
<el-dialog
|
||||||
|
title="添加公司"
|
||||||
|
:visible.sync="addCompanyVisible"
|
||||||
|
width="50%"
|
||||||
|
append-to-body
|
||||||
|
:before-close="closeAddCompanyDialog"
|
||||||
|
>
|
||||||
|
<el-table border :data="companyList">
|
||||||
|
<el-table-column
|
||||||
|
type="index"
|
||||||
|
label="序号"
|
||||||
|
width="80"
|
||||||
|
align="center"
|
||||||
|
/>
|
||||||
|
<el-table-column label="公司名称" align="center">
|
||||||
|
<template slot-scope="{ row }">
|
||||||
|
<el-input
|
||||||
|
placeholder="请输入公司名称"
|
||||||
|
clearable
|
||||||
|
v-model.trim="row.deptName"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
@click="addRows"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
v-if="scope.$index === 0"
|
||||||
|
>新增</el-button
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
@click="delRows(scope.$index)"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
style="color: #f56c6c"
|
||||||
|
v-if="scope.$index !== 0"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button size="mini" type="primary" @click="submitCompany"
|
||||||
|
>确 定</el-button
|
||||||
|
>
|
||||||
|
<el-button size="mini" @click="closeAddCompanyDialog"
|
||||||
|
>取 消</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept";
|
import {
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
listDept,
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
getDept,
|
||||||
|
delDept,
|
||||||
|
addDept,
|
||||||
|
updateDept,
|
||||||
|
listDeptExcludeChild,
|
||||||
|
addCompanyApi,
|
||||||
|
} from '@/api/system/dept'
|
||||||
|
import Treeselect from '@riophae/vue-treeselect'
|
||||||
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Dept",
|
name: 'Dept',
|
||||||
dicts: ['sys_normal_disable'],
|
dicts: ['sys_normal_disable'],
|
||||||
components: { Treeselect },
|
components: { Treeselect },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 表格树数据
|
// 表格树数据
|
||||||
deptList: [],
|
deptList: [],
|
||||||
// 部门树选项
|
// 部门树选项
|
||||||
deptOptions: [],
|
deptOptions: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: '',
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
// 是否展开,默认全部展开
|
// 是否展开,默认全部展开
|
||||||
isExpandAll: true,
|
isExpandAll: true,
|
||||||
// 重新渲染表格状态
|
// 重新渲染表格状态
|
||||||
refreshTable: true,
|
refreshTable: true,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
deptName: undefined,
|
deptName: undefined,
|
||||||
status: undefined
|
status: undefined,
|
||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
parentId: [
|
parentId: [
|
||||||
{ required: true, message: "上级部门不能为空", trigger: "blur" }
|
{
|
||||||
],
|
required: true,
|
||||||
deptName: [
|
message: '上级部门不能为空',
|
||||||
{ required: true, message: "部门名称不能为空", trigger: "blur" }
|
trigger: 'blur',
|
||||||
],
|
},
|
||||||
orderNum: [
|
],
|
||||||
{ required: true, message: "显示排序不能为空", trigger: "blur" }
|
deptName: [
|
||||||
],
|
{
|
||||||
email: [
|
required: true,
|
||||||
{
|
message: '部门名称不能为空',
|
||||||
type: "email",
|
trigger: 'blur',
|
||||||
message: "请输入正确的邮箱地址",
|
},
|
||||||
trigger: ["blur", "change"]
|
],
|
||||||
}
|
orderNum: [
|
||||||
],
|
{
|
||||||
phone: [
|
required: true,
|
||||||
{
|
message: '显示排序不能为空',
|
||||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
trigger: 'blur',
|
||||||
message: "请输入正确的手机号码",
|
},
|
||||||
trigger: "blur"
|
],
|
||||||
}
|
email: [
|
||||||
]
|
{
|
||||||
}
|
type: 'email',
|
||||||
};
|
message: '请输入正确的邮箱地址',
|
||||||
},
|
trigger: ['blur', 'change'],
|
||||||
created() {
|
},
|
||||||
this.getList();
|
],
|
||||||
},
|
phone: [
|
||||||
methods: {
|
{
|
||||||
/** 查询部门列表 */
|
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||||
getList() {
|
message: '请输入正确的手机号码',
|
||||||
this.loading = true;
|
trigger: 'blur',
|
||||||
listDept(this.queryParams).then(response => {
|
},
|
||||||
this.deptList = this.handleTree(response.data, "deptId");
|
],
|
||||||
this.loading = false;
|
},
|
||||||
});
|
// 新增公司弹框
|
||||||
},
|
addCompanyVisible: false,
|
||||||
/** 转换部门数据结构 */
|
// 新增公司数据源
|
||||||
normalizer(node) {
|
companyList: [{ deptName: '' }],
|
||||||
if (node.children && !node.children.length) {
|
userId: sessionStorage.getItem('userId'),
|
||||||
delete node.children;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
id: node.deptId,
|
|
||||||
label: node.deptName,
|
|
||||||
children: node.children
|
|
||||||
};
|
|
||||||
},
|
|
||||||
// 取消按钮
|
|
||||||
cancel() {
|
|
||||||
this.open = false;
|
|
||||||
this.reset();
|
|
||||||
},
|
|
||||||
// 表单重置
|
|
||||||
reset() {
|
|
||||||
this.form = {
|
|
||||||
deptId: undefined,
|
|
||||||
parentId: undefined,
|
|
||||||
deptName: undefined,
|
|
||||||
orderNum: undefined,
|
|
||||||
leader: undefined,
|
|
||||||
phone: undefined,
|
|
||||||
email: undefined,
|
|
||||||
status: "0"
|
|
||||||
};
|
|
||||||
this.resetForm("form");
|
|
||||||
},
|
|
||||||
/** 搜索按钮操作 */
|
|
||||||
handleQuery() {
|
|
||||||
this.getList();
|
|
||||||
},
|
|
||||||
/** 重置按钮操作 */
|
|
||||||
resetQuery() {
|
|
||||||
this.resetForm("queryForm");
|
|
||||||
this.handleQuery();
|
|
||||||
},
|
|
||||||
/** 新增按钮操作 */
|
|
||||||
handleAdd(row) {
|
|
||||||
this.reset();
|
|
||||||
if (row != undefined) {
|
|
||||||
this.form.parentId = row.deptId;
|
|
||||||
}
|
|
||||||
this.open = true;
|
|
||||||
this.title = "添加部门";
|
|
||||||
listDept().then(response => {
|
|
||||||
this.deptOptions = this.handleTree(response.data, "deptId");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 展开/折叠操作 */
|
|
||||||
toggleExpandAll() {
|
|
||||||
this.refreshTable = false;
|
|
||||||
this.isExpandAll = !this.isExpandAll;
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.refreshTable = true;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 修改按钮操作 */
|
|
||||||
handleUpdate(row) {
|
|
||||||
this.reset();
|
|
||||||
getDept(row.deptId).then(response => {
|
|
||||||
this.form = response.data;
|
|
||||||
this.open = true;
|
|
||||||
this.title = "修改部门";
|
|
||||||
});
|
|
||||||
listDeptExcludeChild(row.deptId).then(response => {
|
|
||||||
this.deptOptions = this.handleTree(response.data, "deptId");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 提交按钮 */
|
|
||||||
submitForm: function() {
|
|
||||||
this.$refs["form"].validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
if (this.form.deptId != undefined) {
|
|
||||||
updateDept(this.form).then(response => {
|
|
||||||
this.$modal.msgSuccess("修改成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
addDept(this.form).then(response => {
|
|
||||||
this.$modal.msgSuccess("新增成功");
|
|
||||||
this.open = false;
|
|
||||||
this.getList();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
created() {
|
||||||
handleDelete(row) {
|
this.getList()
|
||||||
this.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function() {
|
},
|
||||||
return delDept(row.deptId);
|
methods: {
|
||||||
}).then(() => {
|
/** 查询部门列表 */
|
||||||
this.getList();
|
getList() {
|
||||||
this.$modal.msgSuccess("删除成功");
|
this.loading = true
|
||||||
}).catch(() => {});
|
listDept(this.queryParams).then((response) => {
|
||||||
}
|
this.deptList = this.handleTree(response.data, 'deptId')
|
||||||
}
|
this.loading = false
|
||||||
};
|
console.log(this.deptList, '树节点数据---')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 转换部门数据结构 */
|
||||||
|
normalizer(node) {
|
||||||
|
if (node.children && !node.children.length) {
|
||||||
|
delete node.children
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: node.deptId,
|
||||||
|
label: node.deptName,
|
||||||
|
children: node.children,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false
|
||||||
|
this.reset()
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
deptId: undefined,
|
||||||
|
parentId: undefined,
|
||||||
|
deptName: undefined,
|
||||||
|
orderNum: undefined,
|
||||||
|
leader: undefined,
|
||||||
|
phone: undefined,
|
||||||
|
email: undefined,
|
||||||
|
status: '0',
|
||||||
|
}
|
||||||
|
this.resetForm('form')
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm('queryForm')
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd(row) {
|
||||||
|
this.reset()
|
||||||
|
if (row != undefined) {
|
||||||
|
this.form.parentId = row.deptId
|
||||||
|
this.form.companyId = row.companyId
|
||||||
|
}
|
||||||
|
this.open = true
|
||||||
|
this.title = '添加部门'
|
||||||
|
listDept().then((response) => {
|
||||||
|
this.deptOptions = this.handleTree(response.data, 'deptId')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 展开/折叠操作 */
|
||||||
|
toggleExpandAll() {
|
||||||
|
this.refreshTable = false
|
||||||
|
this.isExpandAll = !this.isExpandAll
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.refreshTable = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset()
|
||||||
|
getDept(row.deptId).then((response) => {
|
||||||
|
this.form = response.data
|
||||||
|
this.open = true
|
||||||
|
this.title = '修改部门'
|
||||||
|
})
|
||||||
|
listDeptExcludeChild(row.deptId).then((response) => {
|
||||||
|
this.deptOptions = this.handleTree(response.data, 'deptId')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm: function () {
|
||||||
|
this.$refs['form'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.deptId != undefined) {
|
||||||
|
updateDept(this.form).then((response) => {
|
||||||
|
this.$modal.msgSuccess('修改成功')
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
addDept(this.form).then((response) => {
|
||||||
|
this.$modal.msgSuccess('新增成功')
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
this.$modal
|
||||||
|
.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?')
|
||||||
|
.then(function () {
|
||||||
|
return delDept(row.deptId)
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.getList()
|
||||||
|
this.$modal.msgSuccess('删除成功')
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
},
|
||||||
|
/** 树节点选择事件 */
|
||||||
|
treeChange(val) {
|
||||||
|
this.form.companyId = val.companyId
|
||||||
|
},
|
||||||
|
/** 新增公司 */
|
||||||
|
handleAddCompany() {
|
||||||
|
console.log('新增公司!!')
|
||||||
|
this.addCompanyVisible = true
|
||||||
|
},
|
||||||
|
/** 新增行 */
|
||||||
|
addRows() {
|
||||||
|
const rows = {
|
||||||
|
deptName: '',
|
||||||
|
}
|
||||||
|
this.companyList.push(rows)
|
||||||
|
},
|
||||||
|
/** 删除行 */
|
||||||
|
delRows(index) {
|
||||||
|
this.companyLis = this.companyList.splice(index, 1)
|
||||||
|
},
|
||||||
|
/** 确定 */
|
||||||
|
async submitCompany() {
|
||||||
|
// 判断公司名称是否为空
|
||||||
|
let isNull = false
|
||||||
|
try {
|
||||||
|
this.companyList.map((e) => {
|
||||||
|
if (!e.deptName) {
|
||||||
|
this.$message.error('请输入公司名称!')
|
||||||
|
isNull = true
|
||||||
|
throw new Error()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (error) {}
|
||||||
|
if (isNull) return
|
||||||
|
// 判断已有的公司名称是否重复
|
||||||
|
const seen = {}
|
||||||
|
const uniqueCompanyList = this.companyList.reduce((acc, item) => {
|
||||||
|
const name = item.deptName
|
||||||
|
if (!seen[name]) {
|
||||||
|
seen[name] = true
|
||||||
|
acc.push(item)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
if (uniqueCompanyList.length < this.companyList.length) {
|
||||||
|
this.$message.error('公司名称不可重复添加!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let list = [...this.companyList]
|
||||||
|
const res = await addCompanyApi(list)
|
||||||
|
console.log(res, '新增结果--')
|
||||||
|
},
|
||||||
|
/** 关闭新增公司弹框 */
|
||||||
|
closeAddCompanyDialog() {
|
||||||
|
this.addCompanyVisible = false
|
||||||
|
this.companyList = [{ deptName: '' }]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<el-tree
|
<el-tree
|
||||||
:data="deptOptions"
|
:data="deptOptionsTree"
|
||||||
:props="defaultProps"
|
:props="defaultProps"
|
||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
:filter-node-method="filterNode"
|
:filter-node-method="filterNode"
|
||||||
|
|
@ -346,8 +346,10 @@
|
||||||
<treeselect
|
<treeselect
|
||||||
v-model="form.deptId"
|
v-model="form.deptId"
|
||||||
:options="deptOptions"
|
:options="deptOptions"
|
||||||
|
:normalizer="normalizer"
|
||||||
:show-count="true"
|
:show-count="true"
|
||||||
placeholder="请选择归属部门"
|
placeholder="请选择归属部门"
|
||||||
|
@select="deptIdChange"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
@ -548,6 +550,7 @@ import {
|
||||||
changeUserStatus,
|
changeUserStatus,
|
||||||
deptTreeSelect,
|
deptTreeSelect,
|
||||||
} from '@/api/system/user'
|
} from '@/api/system/user'
|
||||||
|
import { listDept } from '@/api/system/dept'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import Treeselect from '@riophae/vue-treeselect'
|
import Treeselect from '@riophae/vue-treeselect'
|
||||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
|
|
@ -577,6 +580,8 @@ export default {
|
||||||
title: '',
|
title: '',
|
||||||
// 部门树选项
|
// 部门树选项
|
||||||
deptOptions: undefined,
|
deptOptions: undefined,
|
||||||
|
// 部门树选项(左侧)
|
||||||
|
deptOptionsTree: undefined,
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
// 部门名称
|
// 部门名称
|
||||||
|
|
@ -720,7 +725,10 @@ export default {
|
||||||
/** 查询部门下拉树结构 */
|
/** 查询部门下拉树结构 */
|
||||||
getDeptTree() {
|
getDeptTree() {
|
||||||
deptTreeSelect().then((response) => {
|
deptTreeSelect().then((response) => {
|
||||||
this.deptOptions = response.data
|
this.deptOptionsTree = response.data
|
||||||
|
})
|
||||||
|
listDept().then((response) => {
|
||||||
|
this.deptOptions = this.handleTree(response.data, 'deptId')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 筛选节点
|
// 筛选节点
|
||||||
|
|
@ -768,6 +776,7 @@ export default {
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
postIds: [],
|
postIds: [],
|
||||||
roleIds: [],
|
roleIds: [],
|
||||||
|
companyId: undefined,
|
||||||
}
|
}
|
||||||
this.resetForm('form')
|
this.resetForm('form')
|
||||||
},
|
},
|
||||||
|
|
@ -946,6 +955,22 @@ export default {
|
||||||
submitFileForm() {
|
submitFileForm() {
|
||||||
this.$refs.upload.submit()
|
this.$refs.upload.submit()
|
||||||
},
|
},
|
||||||
|
// 归属部门选择变化时
|
||||||
|
deptIdChange(val) {
|
||||||
|
console.log(val, '部门变化时')
|
||||||
|
// console.log(this.form, '表单数据--')
|
||||||
|
},
|
||||||
|
/** 转换部门数据结构 */
|
||||||
|
normalizer(node) {
|
||||||
|
if (node.children && !node.children.length) {
|
||||||
|
delete node.children
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: node.deptId,
|
||||||
|
label: node.deptName,
|
||||||
|
children: node.children,
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue