|
@@ -1,408 +1,469 @@
|
|
<template>
|
|
<template>
|
|
- <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>
|
|
|
|
|
|
+ <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>
|
|
|
|
|
|
- <!--列表-->
|
|
|
|
- <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="danger"
|
|
|
|
- v-if="scope.row.role == 0"
|
|
|
|
- @click="deleteUser(scope.$index)"
|
|
|
|
- >删除</el-button>
|
|
|
|
- </template>
|
|
|
|
- </el-table-column>
|
|
|
|
- </el-table>
|
|
|
|
|
|
+ <!--列表-->
|
|
|
|
+ <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="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 :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>
|
|
|
|
|
|
- <!-- 新增单个人员的Dialog -->
|
|
|
|
- <el-dialog title="新增人员" :visible.sync="dialogVisible" width="400px">
|
|
|
|
- <el-form ref="form1" :model="insertForm" :rules="rules" label-width="60px">
|
|
|
|
- <el-form-item label="名字" prop="name">
|
|
|
|
- <el-input v-model="insertForm.name" placeholder="请输入姓名" clearable></el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="电话" prop="phone">
|
|
|
|
- <el-input v-model="insertForm.phone" placeholder="请输入电话号码" clearable></el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="成本" prop="cost">
|
|
|
|
- <!-- 这里目前只能输入整数 但实际上数据库里是可以存的 需要调整校验方式 -->
|
|
|
|
- <el-input v-model.number="insertForm.cost" placeholder="请输入成本 单位:元/小时" clearable></el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="角色" prop="role">
|
|
|
|
- <el-select v-model="insertForm.role" placeholder="请选择角色" style="width: 100%">
|
|
|
|
- <el-option label="普通员工" :value="0"></el-option>
|
|
|
|
- <el-option label="管理员" :value="2"></el-option>
|
|
|
|
- </el-select>
|
|
|
|
- </el-form-item>
|
|
|
|
- </el-form>
|
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
|
- <el-button @click="dialogVisible=false">取消</el-button>
|
|
|
|
- <el-button type="primary" @click="submitInsert">提交</el-button>
|
|
|
|
- </span>
|
|
|
|
- </el-dialog>
|
|
|
|
- </section>
|
|
|
|
|
|
+ <!-- 新增单个人员的Dialog -->
|
|
|
|
+ <el-dialog :title="title" :visible.sync="dialogVisible" width="400px">
|
|
|
|
+ <el-form ref="form1" :model="insertForm" :rules="rules" label-width="60px">
|
|
|
|
+ <el-form-item label="名字" prop="name">
|
|
|
|
+ <el-input v-model="insertForm.name" placeholder="请输入姓名" clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="电话" prop="phone">
|
|
|
|
+ <el-input v-model="insertForm.phone" placeholder="请输入电话号码" clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="成本" prop="costNum">
|
|
|
|
+ <!-- 这里目前只能输入整数 但实际上数据库里是可以存的 需要调整校验方式 -->
|
|
|
|
+ <el-input v-model.number="insertForm.cost" placeholder="请输入成本 单位:元/小时" clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="角色" prop="role">
|
|
|
|
+ <el-select v-model="insertForm.role" placeholder="请选择角色" style="width: 100%">
|
|
|
|
+ <el-option label="普通员工" :value="0"></el-option>
|
|
|
|
+ <el-option label="管理员" :value="2"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="dialogVisible=false">取消</el-button>
|
|
|
|
+ <el-button type="primary" @click="submitInsert">提交</el-button>
|
|
|
|
+ </span>
|
|
|
|
+ </el-dialog>
|
|
|
|
+
|
|
|
|
+ <el-dialog title="修改成本" :visible.sync="dialogVisible1" width="400px">
|
|
|
|
+ <el-form ref="form1" :model="insertForm" :rules="rules" label-width="60px">
|
|
|
|
+ <el-form-item label="成本" prop="cost">
|
|
|
|
+ <el-input v-model.number="insertForm.cost" placeholder="请输入成本 单位:元/小时" clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="dialogVisible1=false">取消</el-button>
|
|
|
|
+ <el-button type="primary" @click="submitInsert1">提交</el-button>
|
|
|
|
+ </span>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </section>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-export default {
|
|
|
|
- data() {
|
|
|
|
- return {
|
|
|
|
- user: JSON.parse(sessionStorage.getItem("user")),
|
|
|
|
|
|
+ export default {
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ user: JSON.parse(sessionStorage.getItem("user")),
|
|
|
|
|
|
- tableHeight: 0,
|
|
|
|
- listLoading: false,
|
|
|
|
- total: 0,
|
|
|
|
- page: 1,
|
|
|
|
- size: 20,
|
|
|
|
- list: [],
|
|
|
|
- dialogVisible: false,
|
|
|
|
- insertForm: {
|
|
|
|
- id: null,
|
|
|
|
- name: null,
|
|
|
|
- phone: null,
|
|
|
|
- role: null,
|
|
|
|
- cost: null
|
|
|
|
- },
|
|
|
|
- rules: {
|
|
|
|
- name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
|
|
|
|
- phone: [{ required: true, message: "请输入电话", trigger: "blur" }],
|
|
|
|
- role: [{ required: true, message: "请选择角色", trigger: "blur" }],
|
|
|
|
- cost: [{ required: false, message: "请输入成本", trigger: "blur" }]
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- methods: {
|
|
|
|
- //分页
|
|
|
|
- handleCurrentChange(val) {
|
|
|
|
- this.page = val;
|
|
|
|
- this.getUser();
|
|
|
|
- },
|
|
|
|
|
|
+ tableHeight: 0,
|
|
|
|
+ listLoading: false,
|
|
|
|
+ total: 0,
|
|
|
|
+ page: 1,
|
|
|
|
+ size: 20,
|
|
|
|
+ list: [],
|
|
|
|
+
|
|
|
|
+ dialogVisible: false,
|
|
|
|
+ title: "",
|
|
|
|
+ insertForm: {
|
|
|
|
+ id: null,
|
|
|
|
+ name: null,
|
|
|
|
+ phone: null,
|
|
|
|
+ role: null,
|
|
|
|
+ cost: null
|
|
|
|
+ },
|
|
|
|
+ rules: {
|
|
|
|
+ name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
|
|
|
|
+ phone: [{ required: true, message: "请输入电话", trigger: "blur" }],
|
|
|
|
+ role: [{ required: true, message: "请选择角色", trigger: "blur" }],
|
|
|
|
+ cost: [{ required: true, message: "请输入成本", trigger: "blur" }]
|
|
|
|
+ },
|
|
|
|
|
|
- handleSizeChange(val) {
|
|
|
|
- this.size = val;
|
|
|
|
- this.getUser();
|
|
|
|
- },
|
|
|
|
|
|
+ dialogVisible1: false,
|
|
|
|
|
|
- //获取所有员工的列表
|
|
|
|
- getUser() {
|
|
|
|
- this.listLoading = true;
|
|
|
|
- this.http.post(
|
|
|
|
- this.port.manage.list,
|
|
|
|
- {},
|
|
|
|
- res => {
|
|
|
|
- this.listLoading = false;
|
|
|
|
- if (res.code == "ok") {
|
|
|
|
- this.list = res.data;
|
|
|
|
- } else {
|
|
|
|
- this.$message({
|
|
|
|
- message: res.msg,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ };
|
|
},
|
|
},
|
|
- error => {
|
|
|
|
- this.listLoading = false;
|
|
|
|
- this.$message({
|
|
|
|
- message: error,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
|
|
+ methods: {
|
|
|
|
+ //分页
|
|
|
|
+ handleCurrentChange(val) {
|
|
|
|
+ this.page = val;
|
|
|
|
+ this.getUser();
|
|
|
|
+ },
|
|
|
|
|
|
- //新增员工
|
|
|
|
- submitInsert() {
|
|
|
|
- this.$refs.form1.validate(valid => {
|
|
|
|
- if (valid) {
|
|
|
|
- this.listLoading = true;
|
|
|
|
- var form = {
|
|
|
|
- name: this.insertForm.name,
|
|
|
|
- phone: this.insertForm.phone,
|
|
|
|
- role: this.insertForm.role,
|
|
|
|
- cost: this.insertForm.cost
|
|
|
|
- };
|
|
|
|
- if (this.insertForm.id != null) {
|
|
|
|
- form.id = this.insertForm.id;
|
|
|
|
- }
|
|
|
|
- this.http.post(
|
|
|
|
- this.port.manage.insert,
|
|
|
|
- form,
|
|
|
|
- res => {
|
|
|
|
- this.listLoading = false;
|
|
|
|
- if (res.code == "ok") {
|
|
|
|
- this.$message({
|
|
|
|
- message:
|
|
|
|
- this.insertForm.id != null ? "修改" : "创建" + "成功",
|
|
|
|
- type: "success"
|
|
|
|
- });
|
|
|
|
- this.dialogVisible = false;
|
|
|
|
- //重新读取列表
|
|
|
|
|
|
+ handleSizeChange(val) {
|
|
|
|
+ this.size = val;
|
|
this.getUser();
|
|
this.getUser();
|
|
- } else {
|
|
|
|
- this.$message({
|
|
|
|
- message: res.msg,
|
|
|
|
- type: "error"
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ //获取所有员工的列表
|
|
|
|
+ getUser() {
|
|
|
|
+ this.listLoading = true;
|
|
|
|
+ this.http.post( this.port.manage.list, {
|
|
|
|
+ pageIndex: this.page,
|
|
|
|
+ pageSize: this.size
|
|
|
|
+ },
|
|
|
|
+ res => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ if (res.code == "ok") {
|
|
|
|
+ this.list = res.data.records;
|
|
|
|
+ this.total = res.data.total;
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: res.msg,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ error => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ this.$message({
|
|
|
|
+ message: error,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
});
|
|
});
|
|
- }
|
|
|
|
},
|
|
},
|
|
- error => {
|
|
|
|
- this.listLoading = false;
|
|
|
|
- this.$message({
|
|
|
|
- message: error,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
|
|
|
|
- //获取所有员工的列表
|
|
|
|
- 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"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ //新增员工
|
|
|
|
+ submitInsert() {
|
|
|
|
+ this.$refs.form1.validate(valid => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ this.listLoading = true;
|
|
|
|
+ var form = {
|
|
|
|
+ name: this.insertForm.name,
|
|
|
|
+ phone: this.insertForm.phone,
|
|
|
|
+ role: this.insertForm.role,
|
|
|
|
+ cost: this.insertForm.cost
|
|
|
|
+ };
|
|
|
|
+ if (this.insertForm.id != null) {
|
|
|
|
+ form.id = this.insertForm.id;
|
|
|
|
+ }
|
|
|
|
+ this.http.post( this.port.manage.insert, form,
|
|
|
|
+ res => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ if (res.code == "ok") {
|
|
|
|
+ this.$message({
|
|
|
|
+ message:
|
|
|
|
+ this.insertForm.id != null ? "修改" : "创建" + "成功",
|
|
|
|
+ type: "success"
|
|
|
|
+ });
|
|
|
|
+ this.dialogVisible = false;
|
|
|
|
+ //重新读取列表
|
|
|
|
+ this.getUser();
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: res.msg,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ error => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ this.$message({
|
|
|
|
+ message: error,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
|
|
- //切换角色 0/2
|
|
|
|
- switchRole(index) {
|
|
|
|
- this.listLoading = true;
|
|
|
|
- this.http.post(
|
|
|
|
- this.port.manage.permission,
|
|
|
|
- { id: this.list[index].id },
|
|
|
|
- res => {
|
|
|
|
- this.listLoading = false;
|
|
|
|
- if (res.code == "ok") {
|
|
|
|
- this.$message({
|
|
|
|
- message: "切换角色成功",
|
|
|
|
- type: "success"
|
|
|
|
- });
|
|
|
|
- //重新读取列表
|
|
|
|
- this.getUser();
|
|
|
|
- } else {
|
|
|
|
- this.$message({
|
|
|
|
- message: res.msg,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- error => {
|
|
|
|
- this.listLoading = false;
|
|
|
|
- this.$message({
|
|
|
|
- message: error,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
|
|
+ //获取所有员工的列表
|
|
|
|
+ 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"
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
|
|
- //三天之内删了你 数据库都给你清了
|
|
|
|
- deleteUser(index) {
|
|
|
|
- this.$confirm(
|
|
|
|
- "确定要删除用户" + this.list[index].name + "吗?",
|
|
|
|
- "删除用户",
|
|
|
|
- {
|
|
|
|
- confirmButtonText: "确定",
|
|
|
|
- cancelButtonText: "取消",
|
|
|
|
- type: "warning"
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
- .then(() => {
|
|
|
|
- this.listLoading = true;
|
|
|
|
- this.http.post(
|
|
|
|
- this.port.manage.delete,
|
|
|
|
- { userId: this.list[index].id },
|
|
|
|
- res => {
|
|
|
|
- this.listLoading = false;
|
|
|
|
- if (res.code == "ok") {
|
|
|
|
- this.$message({
|
|
|
|
- message: "删除成功",
|
|
|
|
- type: "success"
|
|
|
|
|
|
+ //切换角色 0/2
|
|
|
|
+ switchRole(index) {
|
|
|
|
+ this.listLoading = true;
|
|
|
|
+ this.http.post( this.port.manage.permission, { id: this.list[index].id },
|
|
|
|
+ res => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ if (res.code == "ok") {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: "切换角色成功",
|
|
|
|
+ type: "success"
|
|
|
|
+ });
|
|
|
|
+ //重新读取列表
|
|
|
|
+ this.getUser();
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: res.msg,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ error => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ this.$message({
|
|
|
|
+ message: error,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
});
|
|
});
|
|
- //重新读取列表
|
|
|
|
- this.getUser();
|
|
|
|
- } else {
|
|
|
|
- this.$message({
|
|
|
|
- message: res.msg,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
- error => {
|
|
|
|
- this.listLoading = false;
|
|
|
|
- this.$message({
|
|
|
|
- message: error,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- })
|
|
|
|
- .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
|
|
|
|
- };
|
|
|
|
- } else {
|
|
|
|
- this.insertForm = {
|
|
|
|
- id: null,
|
|
|
|
- name: null,
|
|
|
|
- phone: null,
|
|
|
|
- role: null,
|
|
|
|
- cost: null
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
- this.dialogVisible = true;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ //三天之内删了你 数据库都给你清了
|
|
|
|
+ deleteUser(index) {
|
|
|
|
+ this.$confirm( "确定要删除用户" + this.list[index].name + "吗?", "删除用户", {
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
+ type: "warning"
|
|
|
|
+ })
|
|
|
|
+ .then(() => {
|
|
|
|
+ this.listLoading = true;
|
|
|
|
+ this.http.post( this.port.manage.delete, { userId: this.list[index].id },
|
|
|
|
+ res => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ if (res.code == "ok") {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: "删除成功",
|
|
|
|
+ type: "success"
|
|
|
|
+ });
|
|
|
|
+ //重新读取列表
|
|
|
|
+ this.getUser();
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: res.msg,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ error => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ this.$message({
|
|
|
|
+ message: error,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ .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) {
|
|
|
|
+ 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.dialogVisible1 = true;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ submitInsert1() {
|
|
|
|
+ this.$refs.form1.validate(valid => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ this.listLoading = true;
|
|
|
|
+ var form = {
|
|
|
|
+ id: this.insertForm.id,
|
|
|
|
+ name: this.insertForm.name,
|
|
|
|
+ phone: this.insertForm.phone,
|
|
|
|
+ role: this.insertForm.role,
|
|
|
|
+ cost: this.insertForm.cost
|
|
|
|
+ };
|
|
|
|
+ this.http.post( this.port.manage.insert, form,
|
|
|
|
+ res => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ if (res.code == "ok") {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: "修改成功",
|
|
|
|
+ type: "success"
|
|
|
|
+ });
|
|
|
|
+ this.dialogVisible1 = false;
|
|
|
|
+ //重新读取列表
|
|
|
|
+ this.getUser();
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: res.msg,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ error => {
|
|
|
|
+ this.listLoading = false;
|
|
|
|
+ this.$message({
|
|
|
|
+ message: error,
|
|
|
|
+ type: "error"
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
|
|
- created() {
|
|
|
|
- let height = window.innerHeight;
|
|
|
|
- this.tableHeight = height - 195;
|
|
|
|
- const that = this;
|
|
|
|
- window.onresize = function temp() {
|
|
|
|
- that.tableHeight = window.innerHeight - 195;
|
|
|
|
|
|
+ created() {
|
|
|
|
+ let height = window.innerHeight;
|
|
|
|
+ this.tableHeight = height - 195;
|
|
|
|
+ const that = this;
|
|
|
|
+ window.onresize = function temp() {
|
|
|
|
+ that.tableHeight = window.innerHeight - 195;
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.getUser();
|
|
|
|
+ }
|
|
};
|
|
};
|
|
- },
|
|
|
|
- mounted() {
|
|
|
|
- this.getUser();
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
-.nowTime {
|
|
|
|
- height: 40px;
|
|
|
|
- line-height: 40px;
|
|
|
|
- font-size: 16px;
|
|
|
|
- color: #20a0ff;
|
|
|
|
- margin-left: 10px;
|
|
|
|
- i {
|
|
|
|
- margin-right: 10px;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+ .nowTime {
|
|
|
|
+ height: 40px;
|
|
|
|
+ line-height: 40px;
|
|
|
|
+ font-size: 16px;
|
|
|
|
+ color: #20a0ff;
|
|
|
|
+ margin-left: 10px;
|
|
|
|
+ i {
|
|
|
|
+ margin-right: 10px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|