|
@@ -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>
|