Browse Source

工时管家——人员管理页面修改

ZhouRuiTing 5 years ago
parent
commit
4be3f74325

+ 28 - 21
fhKeeper/formulahousekeeper/timesheet/src/port.js

@@ -1,41 +1,48 @@
 export default {
 export default {
     manage: {
     manage: {
-        login: '/user/loginAdmin', // 登录
-        register: '/user/insertCompany', //注册
-        list: '/user/getEmployeeList', //获取员工列表
-        delete: '/user/deleteUser', //删除用户
-        insert: '/user/insertUser', //单独新增用户
-        import: '/user/importUser', //批量导入用户
-        permission: '/user/switchPermission', //切换权限
+        login: '/user/loginAdmin',                              // 登录
+        register: '/user/insertCompany',                        // 注册
+        editPassword: '/user/editPassword',                     // 修改密码
+        
+        depList: '/department/list',                            // 部门列表
+        add: '/department/add',                                 // 添加部门
+        edit: '/department/edit',                               // 编辑部门
+        del: '/department/delete',                              // 删除部门
+
+        list: '/user/getEmployeeList',                          // 获取员工列表
+        delete: '/user/deleteUser',                             // 删除用户
+        insert: '/user/insertUser',                             // 单独新增用户
+        import: '/user/importUser',                             // 批量导入用户
+        permission: '/user/switchPermission',                   // 切换权限
     },
     },
 
 
     //时间
     //时间
     time: {
     time: {
-        getToday: '/time-calculation/getTodayWorkingTime', //获取某人今日时间信息
-        listDeviance: '/time-calculation/getDevianceList', //获取异常行为列表
-        listStatistics: '/time-calculation/getTimeStatistics', //获取当天的统计
+        getToday: '/time-calculation/getTodayWorkingTime',      // 获取某人今日时间信息
+        listDeviance: '/time-calculation/getDevianceList',      // 获取异常行为列表
+        listStatistics: '/time-calculation/getTimeStatistics',  // 获取当天的统计
     },
     },
 
 
     //截图
     //截图
     desktop: {
     desktop: {
-        list: '/screenshot/getLatestScreenshotList', //获取当前每个人最新的桌面截图
-        listToday: '/screenshot/getTodayScreenshotList', //获取今日截图
-        getScreenshotDate: '/screenshot/getScreenshotDate',
+        list: '/screenshot/getLatestScreenshotList',            // 获取当前每个人最新的桌面截图
+        listToday: '/screenshot/getTodayScreenshotList',        // 获取今日截图
+        getScreenshotDate: '/screenshot/getScreenshotDate',     // 获取最近有截图的日期
     },
     },
 
 
     //项目
     //项目
     project: {
     project: {
-        list: '/project/getProjectList', //获取项目列表
-        listPage: '/project/getProjectPage',//获取项目列表分页
-        delete: '/project/deleteProject', //删除项目
-        add: '/project/editProject', //新增项目
-        listCost: '/project/getTimeCost', //获取所有项目花费的工时
-        projectCost: '/project/getProjectCost', //获取某个项目每个人分别花费的工时
+        list: '/project/getProjectList',                        // 获取项目列表
+        listPage: '/project/getProjectPage',                    // 获取项目列表分页
+        delete: '/project/deleteProject',                       // 删除项目
+        add: '/project/editProject',                            // 新增项目
+        listCost: '/project/getTimeCost',                       // 获取所有项目花费的工时
+        projectCost: '/project/getProjectCost',                 // 获取某个项目每个人分别花费的工时
     },
     },
 
 
     //日报
     //日报
     report: {
     report: {
-        list: '/report/getReportList', //获取报告列表
-        export: '/report/exportReport', //导出报告
+        list: '/report/getReportList',                          // 获取报告列表
+        export: '/report/exportReport',                         // 导出报告
     }
     }
 }
 }

+ 2 - 2
fhKeeper/formulahousekeeper/timesheet/src/routes.js

@@ -72,7 +72,7 @@ let routes = [
             { path: '/cost/:id/:name', component: proDetail, name: '项目详情', hidden: true },
             { path: '/cost/:id/:name', component: proDetail, name: '项目详情', hidden: true },
         ]
         ]
     },
     },
-    //团队管理
+    //组织架构
     {
     {
         path: '/',
         path: '/',
         component: Home,
         component: Home,
@@ -80,7 +80,7 @@ let routes = [
         iconCls: 'fa fa-users',
         iconCls: 'fa fa-users',
         leaf: true,//只有一个节点
         leaf: true,//只有一个节点
         children: [
         children: [
-            { path: '/team', component: team, name: '团队管理' },
+            { path: '/team', component: team, name: '组织架构' },
         ]
         ]
     },
     },
     //系统管理
     //系统管理

+ 35 - 31
fhKeeper/formulahousekeeper/timesheet/src/views/Home.vue

@@ -83,8 +83,11 @@
                 <!--修改密码-->
                 <!--修改密码-->
                 <el-dialog title="修改密码" width='450px' v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass="customWidth">
                 <el-dialog title="修改密码" width='450px' v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass="customWidth">
                     <el-form :model="addForm" label-width="80px" :rules="passRule" ref="addForm">
                     <el-form :model="addForm" label-width="80px" :rules="passRule" ref="addForm">
-                        <el-form-item label="新密码" prop="password">
-                            <el-input v-model="addForm.password" autocomplete="off" placeholder="请输入新密码" show-password></el-input>
+                        <el-form-item label="原密码" prop="originPassword">
+                            <el-input v-model="addForm.originPassword" autocomplete="off" placeholder="请输入原密码" show-password></el-input>
+                        </el-form-item>
+                        <el-form-item label="新密码" prop="newPassword">
+                            <el-input v-model="addForm.newPassword" autocomplete="off" placeholder="请输入新密码" show-password></el-input>
                         </el-form-item>
                         </el-form-item>
                     </el-form>
                     </el-form>
                     <div slot="footer" class="dialog-footer">
                     <div slot="footer" class="dialog-footer">
@@ -123,7 +126,7 @@
                 user: sessionStorage.getItem("user"),
                 user: sessionStorage.getItem("user"),
 
 
                 sysName: "工时管家",
                 sysName: "工时管家",
-                collapsed: false,
+                collapsed: sessionStorage.collapsed!=null?(sessionStorage.collapsed=='true'?true:false):false,
                 sysUserName: "",
                 sysUserName: "",
 
 
                 editInformation: false,
                 editInformation: false,
@@ -132,7 +135,8 @@
                 editLoading2: false,
                 editLoading2: false,
                 addForm: {
                 addForm: {
                     id: "",
                     id: "",
-                    password: ""
+                    originPassword: "",
+                    newPassword: ""
                 },
                 },
                 editInfoForm: {
                 editInfoForm: {
                     id: "",
                     id: "",
@@ -141,7 +145,8 @@
                     companyName: ""
                     companyName: ""
                 },
                 },
                 passRule: {
                 passRule: {
-                    password: [{ required: true, message: "请输入新密码", trigger: "blur" }],
+                    originPassword: [{ required: true, message: "请输入原密码", trigger: "blur" }],
+                    newPassword: [{ required: true, message: "请输入新密码", trigger: "blur" }],
                     username: [{ required: true, message: "请输入姓名", trigger: "blur" }]
                     username: [{ required: true, message: "请输入姓名", trigger: "blur" }]
                 },
                 },
 
 
@@ -167,6 +172,7 @@
             //折叠导航栏
             //折叠导航栏
             collapse: function() {
             collapse: function() {
                 this.collapsed = !this.collapsed;
                 this.collapsed = !this.collapsed;
+                sessionStorage.collapsed = this.collapsed;
             },
             },
 
 
             showMenu(i, status) {
             showMenu(i, status) {
@@ -240,35 +246,32 @@
             resetPwd() {
             resetPwd() {
                 this.$refs.addForm.validate(valid => {
                 this.$refs.addForm.validate(valid => {
                     if (valid) {
                     if (valid) {
-                    this.editLoading = true;
-                    this.http.post(
-                        this.port.pwd.resetPwd,
-                        this.addForm,
-                        res => {
-                        this.editLoading = false;
-                        this.editPassWord = false;
-                        if (res.code == "ok") {
+                        this.editLoading = true;
+                        this.http.post( this.port.manage.editPassword, this.addForm,
+                            res => {
+                            this.editLoading = false;
+                            this.editPassWord = false;
+                            if (res.code == "ok") {
+                                this.$message({
+                                message: "修改成功,请重新登录",
+                                type: "success"
+                                });
+                                this.$router.push("/login");
+                            } else {
+                                this.$message({
+                                message: res.msg,
+                                type: "error"
+                                });
+                            }
+                            },
+                            error => {
+                            this.editLoading = false;
+                            this.editPassWord = false;
                             this.$message({
                             this.$message({
-                            message: "修改成功,请重新登录",
-                            type: "success"
+                                message: error,
+                                type: "error"
                             });
                             });
-                            this.$router.push("/login");
-                        } else {
-                            this.$message({
-                            message: res.msg,
-                            type: "error"
-                            });
-                        }
-                        },
-                        error => {
-                        this.editLoading = false;
-                        this.editPassWord = false;
-                        this.$message({
-                            message: error,
-                            type: "error"
                         });
                         });
-                        }
-                    );
                     }
                     }
                 });
                 });
             },
             },
@@ -420,6 +423,7 @@
                         z-index: 99999;
                         z-index: 99999;
                         height: auto;
                         height: auto;
                         display: none;
                         display: none;
+                        box-shadow: 5px 5px 10px #ddd;
                     }
                     }
                 }
                 }
             }
             }

+ 428 - 173
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -1,104 +1,106 @@
 <template>
 <template>
     <section>
     <section>
-        <!--工具条-->
-        <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
-            <el-form :inline="true">
-                <el-form-item>
-                    <div class="nowTime">
-                        <i class="el-icon-s-home"></i>
-                        {{user.companyName}}
-                    </div>
-                </el-form-item>
-                <el-form-item style="float:right;">
-                    <el-link type="primary" :underline="false" @click="openInsertDialog(null)">添加人员</el-link>
-                </el-form-item>
-                <el-form-item style="float:right;">
-                    <el-upload
-                        ref="upload"
-                        action="#"
-                        :limit="1"
-                        :http-request="importUser"
-                        :show-file-list="false"
-                    >
-                        <el-link type="primary" :underline="false">批量导入</el-link>
-                    </el-upload>
-                </el-form-item>
-                <el-form-item style="float:right;">
-                    <el-link
-                        type="primary"
-                        :underline="false"
-                        href="./upload/人员导入模板.xlsx"
-                        download="人员导入模板.xlsx"
-                    >模板下载</el-link>
-                </el-form-item>
-            </el-form>
+        <el-col :span="4" class="left" :style="'height:'+ (tableHeight + 113) + 'px'">
+            <div class="department">
+                <span>部门</span>
+                <div v-on:click="createDepartment(-1)">
+                    <i class="fa fa-plus-circle"></i>
+                    创建部门
+                </div>
+            </div>
+            <div class="tree" :style="'height:'+ (tableHeight + 83) + 'px'">
+                <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" accordion></el-tree>
+            </div>
         </el-col>
         </el-col>
 
 
-        <!--列表-->
-        <el-table
-            :data="list"
-            highlight-current-row
-            v-loading="listLoading"
-            :height="tableHeight"
-            style="width: 100%;"
-        >
-            <el-table-column type="index" width="60"></el-table-column>
-            <el-table-column prop="name" label="姓名" sortable></el-table-column>
-            <el-table-column prop="phone" label="手机"></el-table-column>
-            <el-table-column label="角色">
-                <template slot-scope="scope">
-                {{scope.row.role == 0 ? "普通员工" :
-                scope.row.role == 1 ? "负责人" : "管理员"}}
-                </template>
-            </el-table-column>
-            <el-table-column prop="cost" label="成本"></el-table-column>
-            <el-table-column label="操作" width="280">
-                <template slot-scope="scope">
-                <el-button
-                    size="small"
-                    v-if="scope.row.role == 0 && user.role == 1"
-                    @click="switchRole(scope.$index)"
-                >切换为管理员</el-button>
-                <el-button
-                    size="small"
-                    v-if="scope.row.role == 2 && user.role == 1"
-                    @click="switchRole(scope.$index)"
-                >切换为员工</el-button>
-                <el-button
-                    size="small"
-                    type="primary"
-                    v-if="scope.row.role != 1"
-                    @click="openInsertDialog(scope.$index)"
-                >编辑</el-button>
-                <el-button
-                    size="small"
-                    type="primary"
-                    v-if="scope.row.role == 1"
-                    @click="openInsertDialog1(scope.$index)"
-                >编辑</el-button>
-                <el-button
-                    size="small"
-                    type="danger"
-                    v-if="scope.row.role == 0"
-                    @click="deleteUser(scope.$index)"
-                >删除</el-button>
-                </template>
-            </el-table-column>
-        </el-table>
+        <el-col :span="20" class="right">
+            <!--工具条-->
+            <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
+                <el-form :inline="true">
+                    <el-form-item>
+                        <div v-if="depData == null || depData.id == -1" class="nowTime" style="cursor:unset">
+                            <i class="fa fa-home"></i>全部人员
+                        </div>
+                        <div v-else-if="depData.id == 0" class="nowTime" style="cursor:unset">
+                            <i class="fa fa-home"></i>未分配
+                        </div>
+                        <div v-else-if="depData != null && depData.id != -1 && depData.id != 0" class="nowTime" @click="createDepartment(0)">
+                            <i class="fa fa-pencil-square-o"></i>
+                            {{depData!=null?depData.label:''}}
+                        </div>
+                    </el-form-item>
+                    <el-form-item style="float:right;">
+                        <el-link type="primary" :underline="false" @click="openInsertDialog(null)">添加人员</el-link>
+                    </el-form-item>
+                    <el-form-item style="float:right;" v-if="depData != null && depData.id != -1 && depData.id != 0">
+                        <el-upload ref="upload" action="#" :limit="1" :http-request="importUser" :show-file-list="false">
+                            <el-link type="primary" :underline="false">批量导入</el-link>
+                        </el-upload>
+                    </el-form-item>
+                    <el-form-item style="float:right;">
+                        <el-link type="primary" :underline="false" href="./upload/人员导入模板.xlsx" download="人员导入模板.xlsx">模板下载</el-link>
+                    </el-form-item>
+                    <el-form-item  v-if="depData != null && depData.id != -1 && depData.id != 0" style="float:right;border: 0.5px solid #20a0ff;height: 27px;margin-top: 6px;">
+                    </el-form-item>
+                    <el-form-item style="float:right;">
+                        <el-link type="danger" v-if="depData != null && depData.id != -1 && depData.id != 0" :underline="false" @click="deleteDep(null)">删除部门</el-link>
+                    </el-form-item>
+                    <el-form-item style="float:right;">
+                        <el-link type="primary" v-if="depData != null && depData.id != -1 && depData.id != 0" :underline="false" @click="createDepartment(-1)">新增子部门</el-link>
+                    </el-form-item>
+                </el-form>
+            </el-col>
+
+            <!--列表-->
+            <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
+                <el-table-column type="index" width="40"></el-table-column>
+                <el-table-column prop="name" label="姓名" sortable></el-table-column>
+                <el-table-column prop="phone" label="手机" width="120"></el-table-column>
+                <el-table-column prop="departmentName" label="部门" sortable></el-table-column>
+                <el-table-column label="角色" width="100">
+                    <template slot-scope="scope">{{scope.row.role == 0 ? "普通员工" : scope.row.role == 1 ? "负责人" : "管理员"}}</template>
+                </el-table-column>
+                <el-table-column prop="cost" label="成本" sortable>
+                    <template slot-scope="scope">{{scope.row.cost==null?0:scope.row.cost}} 元 / 小时</template>
+                </el-table-column>
+                <el-table-column label="操作" width="280">
+                    <template slot-scope="scope">
+                        <el-button size="small" v-if="scope.row.role == 0 && user.role == 1" @click="switchRole(scope.$index)">切换为管理员</el-button>
+                        <el-button size="small" v-if="scope.row.role == 2 && user.role == 1" @click="switchRole(scope.$index)">切换为员工</el-button>
+                        <el-button size="small" type="primary" v-if="scope.row.role != 1" @click="openInsertDialog(scope.$index)">编辑</el-button>
+                        <el-button size="small" type="primary" v-if="scope.row.role == 1" @click="openInsertDialog1(scope.$index)">编辑</el-button>
+                        <el-button size="small" type="danger" v-if="scope.row.role == 0" @click="deleteUser(scope.$index)">删除</el-button>
+                    </template>
+                </el-table-column>
+            </el-table>
 
 
-        <!--工具条-->
-        <el-col :span="24" class="toolbar">
-            <el-pagination
-                @size-change="handleSizeChange"
-                @current-change="handleCurrentChange"
-                :page-sizes="[20 , 50 , 80 , 100]"
-                :page-size="20"
-                layout="total, sizes, prev, pager, next"
-                :total="total"
-                style="float:right;"
-            ></el-pagination>
+            <!--工具条-->
+            <el-col :span="24" class="toolbar">
+                <el-pagination
+                    @size-change="handleSizeChange"
+                    @current-change="handleCurrentChange"
+                    :page-sizes="[20 , 50 , 80 , 100]"
+                    :page-size="20"
+                    layout="total, sizes, prev, pager, next"
+                    :total="total"
+                    style="float:right;"
+                ></el-pagination>
+            </el-col>
         </el-col>
         </el-col>
 
 
+        <!-- 新增部门 -->
+        <el-dialog :title="depTitle" :visible.sync="departmentVisible" width="400px">
+            <el-form ref="depForm" :model="depForm" :rules="depRules" label-width="80px">
+                <el-form-item label="部门名称" prop="name">
+                    <el-input v-model="depForm.name" placeholder="请输入部门名称" clearable></el-input>
+                </el-form-item>
+            </el-form>
+            <span slot="footer" class="dialog-footer">
+                <el-button @click="departmentVisible = false">取消</el-button>
+                <el-button type="primary" @click="submitDepartment">提交</el-button>
+            </span>
+        </el-dialog>
+
         <!-- 新增单个人员的Dialog -->
         <!-- 新增单个人员的Dialog -->
         <el-dialog :title="title" :visible.sync="dialogVisible" width="400px">
         <el-dialog :title="title" :visible.sync="dialogVisible" width="400px">
             <el-form ref="form1" :model="insertForm" :rules="rules" label-width="60px">
             <el-form ref="form1" :model="insertForm" :rules="rules" label-width="60px">
@@ -108,10 +110,13 @@
                 <el-form-item label="电话" prop="phone">
                 <el-form-item label="电话" prop="phone">
                     <el-input v-model="insertForm.phone" placeholder="请输入电话号码" clearable></el-input>
                     <el-input v-model="insertForm.phone" placeholder="请输入电话号码" clearable></el-input>
                 </el-form-item>
                 </el-form-item>
-                <el-form-item label="成本" prop="costNum">
-                    <!-- 这里目前只能输入整数 但实际上数据库里是可以存的 需要调整校验方式 -->
+                <el-form-item label="成本" prop="cost">
                     <el-input v-model.number="insertForm.cost" placeholder="请输入成本 单位:元/小时" clearable></el-input>
                     <el-input v-model.number="insertForm.cost" placeholder="请输入成本 单位:元/小时" clearable></el-input>
                 </el-form-item>
                 </el-form-item>
+                <el-form-item label="部门" prop="departmentId">
+                    <el-cascader v-model="insertForm.departmentId" placeholder="请选择部门" style="width: 100%" @change="handleChange"
+                    :options="option" :props="{ checkStrictly: true }" :show-all-levels="false" clearable></el-cascader>
+                </el-form-item>
                 <el-form-item label="角色" prop="role">
                 <el-form-item label="角色" prop="role">
                     <el-select v-model="insertForm.role" placeholder="请选择角色" style="width: 100%">
                     <el-select v-model="insertForm.role" placeholder="请选择角色" style="width: 100%">
                         <el-option label="普通员工" :value="0"></el-option>
                         <el-option label="普通员工" :value="0"></el-option>
@@ -151,6 +156,26 @@
                 page: 1,
                 page: 1,
                 size: 20,
                 size: 20,
                 list: [],
                 list: [],
+
+                data: [
+                    {
+                        id: -1,
+                        label: '全部人员',
+                    },
+                    {
+                        id: 0,
+                        label: '未分配',
+                    }
+                ],
+                option: [],
+                depData: {
+                    id: -1,
+                    label: '全部人员',
+                },
+                defaultProps: {
+                    children: 'children',
+                    label: 'label'
+                },
                 
                 
                 dialogVisible: false,
                 dialogVisible: false,
                 title: "",
                 title: "",
@@ -159,7 +184,8 @@
                     name: null,
                     name: null,
                     phone: null,
                     phone: null,
                     role: null,
                     role: null,
-                    cost: null
+                    cost: null,
+                    departmentId: null,
                 },
                 },
                 rules: {
                 rules: {
                     name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
                     name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
@@ -170,9 +196,64 @@
 
 
                 dialogVisible1: false,
                 dialogVisible1: false,
 
 
+                departmentVisible: false,
+                depTitle: '',
+                depForm: {
+                    id: null,
+                    name: null,
+                    parentId: null,
+                },
+                depRules: {
+                    name: [{ required: true, message: "请输入部门名称", trigger: "blur" }],
+                },
+
             };
             };
         },
         },
         methods: {
         methods: {
+            // 批量导入人员
+            importUser(item) {
+                //首先判断文件类型
+                let str = item.file.name.split(".");
+                let format = str[str.length - 1];
+                if (format != "xls" && format != "xlsx") {
+                    this.$message({
+                        message: "请选择.xls或.xlsx文件",
+                        type: "error"
+                    });
+                } else {
+                    this.listLoading = true;
+                    let formData = new FormData();
+                    formData.append("file", item.file);
+                    formData.append("departmentId", this.depData.id);
+                    this.http.uploadFile( this.port.manage.import, formData,
+                    res => {
+                        this.$refs.upload.clearFiles();
+                        this.listLoading = false;
+                        if (res.code == "ok") {
+                            this.$message({
+                                message: "导入成功",
+                                type: "success"
+                            });
+                            //重新读取列表
+                            this.getUser();
+                        } else {
+                            this.$message({
+                                message: res.msg,
+                                type: "error"
+                            });
+                        }
+                    },
+                    error => {
+                        this.$refs.upload.clearFiles();
+                        this.listLoading = false;
+                        this.$message({
+                            message: error,
+                            type: "error"
+                        });
+                    });
+                }
+            },
+
             //分页
             //分页
             handleCurrentChange(val) {
             handleCurrentChange(val) {
                 this.page = val;
                 this.page = val;
@@ -188,6 +269,7 @@
             getUser() {
             getUser() {
                 this.listLoading = true;
                 this.listLoading = true;
                 this.http.post( this.port.manage.list, {
                 this.http.post( this.port.manage.list, {
+                    departmentId: this.depData.id,
                     pageIndex: this.page,
                     pageIndex: this.page,
                     pageSize: this.size
                     pageSize: this.size
                 },
                 },
@@ -212,7 +294,45 @@
                 });
                 });
             },
             },
 
 
-            //新增员工
+            // 新增、编辑人员
+            openInsertDialog(i) {
+                if (i != null) {
+                    var list = JSON.parse(JSON.stringify(this.list[i])) , arr = [] , array = [];
+                    if(list.departmentCascade!='0' && list.departmentCascade!=null) {
+                        if(list.departmentCascade.indexOf(",")>-1) {
+                            arr = list.departmentCascade.split(",");
+                        } else {
+                            arr = [].concat(list.departmentCascade)
+                        }
+                    }
+                        
+                    for(var i in arr) {
+                        array.push(parseInt(arr[i]))
+                    }
+                    
+                    this.insertForm = {
+                        id: list.id,
+                        name: list.name,
+                        phone: list.phone,
+                        role: list.role,
+                        cost: list.cost,
+                        departmentId: array,
+                    };
+                    this.title = "编辑人员"
+                } else {
+                    this.insertForm = {
+                        id: null,
+                        name: null,
+                        phone: null,
+                        role: null,
+                        cost: null,
+                        departmentId: null,
+                    };
+                    this.title = "新增人员"
+                }
+                this.dialogVisible = true;
+            },
+
             submitInsert() {
             submitInsert() {
                 this.$refs.form1.validate(valid => {
                 this.$refs.form1.validate(valid => {
                     if (valid) {
                     if (valid) {
@@ -226,22 +346,24 @@
                         if (this.insertForm.id != null) {
                         if (this.insertForm.id != null) {
                             form.id = this.insertForm.id;
                             form.id = this.insertForm.id;
                         }
                         }
+                        if (this.insertForm.departmentId != null) {
+                            form.departmentId = this.insertForm.departmentId[this.insertForm.departmentId.length-1];
+                            // form.departmentCascade = this.insertForm.departmentId.join(",")
+                        }
                         this.http.post( this.port.manage.insert, form,
                         this.http.post( this.port.manage.insert, form,
                         res => {
                         res => {
                             this.listLoading = false;
                             this.listLoading = false;
                             if (res.code == "ok") {
                             if (res.code == "ok") {
                                 this.$message({
                                 this.$message({
-                                message:
-                                    this.insertForm.id != null ? "修改" : "创建" + "成功",
-                                type: "success"
+                                    message: this.insertForm.id != null ? "修改" : "创建" + "成功",
+                                    type: "success"
                                 });
                                 });
                                 this.dialogVisible = false;
                                 this.dialogVisible = false;
-                                //重新读取列表
                                 this.getUser();
                                 this.getUser();
                             } else {
                             } else {
                                 this.$message({
                                 this.$message({
-                                message: res.msg,
-                                type: "error"
+                                    message: res.msg,
+                                    type: "error"
                                 });
                                 });
                             }
                             }
                         },
                         },
@@ -256,50 +378,7 @@
                 });
                 });
             },
             },
 
 
-            //获取所有员工的列表
-            importUser(item) {
-                //首先判断文件类型
-                let str = item.file.name.split(".");
-                let format = str[str.length - 1];
-                if (format != "xls" && format != "xlsx") {
-                    this.$message({
-                    message: "请选择.xls或.xlsx文件",
-                    type: "error"
-                    });
-                } else {
-                    this.listLoading = true;
-                    let formData = new FormData();
-                    formData.append("file", item.file);
-                    this.http.uploadFile( this.port.manage.import, formData,
-                    res => {
-                        this.$refs.upload.clearFiles();
-                        this.listLoading = false;
-                        if (res.code == "ok") {
-                            this.$message({
-                                message: "导入成功",
-                                type: "success"
-                            });
-                            //重新读取列表
-                            this.getUser();
-                        } else {
-                            this.$message({
-                                message: res.msg,
-                                type: "error"
-                            });
-                        }
-                    },
-                    error => {
-                        this.$refs.upload.clearFiles();
-                        this.listLoading = false;
-                        this.$message({
-                            message: error,
-                            type: "error"
-                        });
-                    });
-                }
-            },
-
-            //切换角色 0/2
+            // 切换角色
             switchRole(index) {
             switchRole(index) {
                 this.listLoading = true;
                 this.listLoading = true;
                 this.http.post( this.port.manage.permission, { id: this.list[index].id },
                 this.http.post( this.port.manage.permission, { id: this.list[index].id },
@@ -328,7 +407,7 @@
                 });
                 });
             },
             },
 
 
-            //三天之内删了你 数据库都给你清了
+            // 删除用户
             deleteUser(index) {
             deleteUser(index) {
                 this.$confirm( "确定要删除用户" + this.list[index].name + "吗?", "删除用户", {
                 this.$confirm( "确定要删除用户" + this.list[index].name + "吗?", "删除用户", {
                     confirmButtonText: "确定",
                     confirmButtonText: "确定",
@@ -365,30 +444,7 @@
                 .catch(() => {});
                 .catch(() => {});
             },
             },
 
 
-            //打开单独新增的Dialog
-            openInsertDialog(i) {
-                if (i != null) {
-                    this.insertForm = {
-                        id: this.list[i].id,
-                        name: this.list[i].name,
-                        phone: this.list[i].phone,
-                        role: this.list[i].role,
-                        cost: this.list[i].cost
-                    };
-                    this.title = "编辑人员"
-                } else {
-                    this.insertForm = {
-                        id: null,
-                        name: null,
-                        phone: null,
-                        role: null,
-                        cost: null
-                    };
-                    this.title = "新增人员"
-                }
-                this.dialogVisible = true;
-            },
-
+            // 修改老板的成本
             openInsertDialog1(i) {
             openInsertDialog1(i) {
                 this.insertForm = {
                 this.insertForm = {
                     id: this.list[i].id,
                     id: this.list[i].id,
@@ -439,6 +495,172 @@
                     }
                     }
                 });
                 });
             },
             },
+
+            // 获取部门列表
+            getDepartment() {
+                this.http.post( this.port.manage.depList, {},
+                res => {
+                    if (res.code == "ok") {
+                        var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
+                        list.splice(0,0,{
+                            id: -1,
+                            label: '全部人员',
+                        })
+                        list.push({
+                            id: 0,
+                            label: '未分配',
+                        })
+                        this.data = list;
+                        this.option = this.changeArr(list1);
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+            },
+
+            // 修改数组
+            changeArr(arr) {
+                for (var i = 0; i < arr.length; i++) {
+                    if(arr[i].id != -1 && arr[i].id != 0) {
+                        if (arr[i].children != null && arr[i].children.length>0) {
+                            arr[i].children = this.changeArr(arr[i].children);
+                        }
+                        arr[i].id && (arr[i].value = arr[i].id);
+                        delete arr[i].id;
+                    }
+                }
+                for(var i in arr) {
+                    if(arr[i].id == -1 || arr[i].id == 0) {
+                        arr.splice(i,1)
+                    }    
+                }
+                return arr;
+            },
+
+            // 部门列表点击
+            handleNodeClick(data) {
+                if(this.depData == null || data.id != this.depData.id) {
+                    this.depData = data;
+                    this.getUser();
+                }
+            },
+
+            // 新增、修改部门
+            createDepartment(i) {
+                if(i == -1) {
+                    this.depForm = {
+                        id: null,
+                        name: null,
+                        parentId: null,
+                    }
+                    if(this.depData.id != -1 && this.depData.id != 0) {
+                        this.depForm.parentId = this.depData.id;
+                    }
+                    this.depTitle = "新增部门";
+                } else {
+                    this.depForm = {
+                        id: this.depData.id,
+                        name: this.depData.label,
+                        parentId: this.depData.parentId,
+                    }
+                    this.depTitle = "编辑部门";
+                }
+                this.departmentVisible = true;
+            },
+            
+            submitDepartment() {
+                this.$refs.depForm.validate(valid => {
+                    if (valid) {
+                        var form = {
+                            name: this.depForm.name,
+                        };
+                        if(this.depForm.id != null) {
+                            form.id = this.depForm.id
+                        }
+                        if(this.depForm.parentId != null) {
+                            form.parentId = this.depForm.parentId
+                        }
+                        this.http.post( this.depForm.id==null?this.port.manage.add:this.port.manage.edit, form,
+                        res => {
+                            if (res.code == "ok") {
+                                this.$message({
+                                    message: this.depForm.id==null?"新增成功":"修改成功",
+                                    type: "success"
+                                });
+                                this.departmentVisible = false;
+                                this.depData.label = form.name;
+                                this.getDepartment();
+                            } else {
+                                this.$message({
+                                    message: res.msg,
+                                    type: "error"
+                                });
+                            }
+                        },
+                        error => {
+                            this.listLoading = false;
+                            this.$message({
+                                message: error,
+                                type: "error"
+                            });
+                        });
+                    }
+                });
+            },
+
+            // 删除部门
+            deleteDep() {
+                this.$confirm( "确定要删除部门" + this.depData.label + "吗?", "删除部门", {
+                    confirmButtonText: "确定",
+                    cancelButtonText: "取消",
+                    type: "warning"
+                })
+                .then(() => {
+                    this.listLoading = true;
+                    this.http.post( this.port.manage.del, { id: this.depData.id },
+                    res => {
+                        this.listLoading = false;
+                        if (res.code == "ok") {
+                            this.$message({
+                                message: "删除成功",
+                                type: "success"
+                            });
+                            this.depData = {
+                                id: -1,
+                                label: '全部人员',
+                            }
+                            this.getDepartment();
+                            this.getUser();
+                        } else {
+                            this.$message({
+                                message: res.msg,
+                                type: "error"
+                            });
+                        }
+                    },
+                    error => {
+                        this.listLoading = false;
+                        this.$message({
+                            message: error,
+                            type: "error"
+                        });
+                    });
+                })
+                .catch(() => {});
+            },
+
+            handleChange(value) {
+                // console.log(value);
+            }
         },
         },
 
 
         created() {
         created() {
@@ -450,20 +672,53 @@
             };
             };
         },
         },
         mounted() {
         mounted() {
+            this.getDepartment();
             this.getUser();
             this.getUser();
         }
         }
     };
     };
 </script>
 </script>
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>
+    .left {
+        border: 1px solid #f2f2f2;
+        overflow: hidden;
+        .department {
+            color: #8f8f8f;
+            margin: 15px 0 10px;
+            line-height: 30px;
+            padding: 0 10px;
+            font-size: 16px;
+            div {
+                float: right;
+                color: #20a0ff;
+                font-size: 14px;
+                cursor: pointer;
+            }
+        }
+        .tree {
+            overflow: auto;
+        }
+    }
+
     .nowTime {
     .nowTime {
         height: 40px;
         height: 40px;
         line-height: 40px;
         line-height: 40px;
         font-size: 16px;
         font-size: 16px;
         color: #20a0ff;
         color: #20a0ff;
         margin-left: 10px;
         margin-left: 10px;
+        cursor: pointer;
         i {
         i {
             margin-right: 10px;
             margin-right: 10px;
         }
         }
     }
     }
 </style>
 </style>
+
+<style lang="scss">
+    .tree {
+        .el-tree-node__label {
+            overflow-x: hidden;
+            white-space: nowrap;
+            text-overflow: ellipsis;
+        }
+    }
+</style>