瀏覽代碼

导出报告和导入用户以及前端优化

Reiskuchen 5 年之前
父節點
當前提交
c7bc0ad109
共有 15 個文件被更改,包括 316 次插入48 次删除
  1. 7 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java
  2. 5 4
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserController.java
  3. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java
  4. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java
  5. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/UserService.java
  6. 2 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  7. 89 4
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java
  8. 5 5
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java
  9. 8 4
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TimeCalculationServiceImpl.java
  10. 77 5
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java
  11. 15 1
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml
  12. 2 5
      fhKeeper/formulahousekeeper/timesheet/src/port.js
  13. 10 10
      fhKeeper/formulahousekeeper/timesheet/src/routes.js
  14. 89 5
      fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue
  15. 2 2
      fhKeeper/formulahousekeeper/timesheet/src/views/workReport/statistics.vue

+ 7 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -41,6 +41,12 @@ public class ReportController {
         return reportService.getReportList(date, request);
     }
 
+    @RequestMapping("/exportReport")
+    public HttpRespMsg exportReport(@RequestParam String date) {
+        return reportService.exportReport(date, request);
+    }
+
+
     /**
      * 根据时间 获取本人报告信息 以及工时
      * date 日期 格式yyyy-mm-dd
@@ -79,7 +85,7 @@ public class ReportController {
             }
         } catch (NullPointerException e) {
             HttpRespMsg httpRespMsg = new HttpRespMsg();
-            httpRespMsg.setError("缺少数据");
+            httpRespMsg.setError("验证失败");
             return httpRespMsg;
         }
         return reportService.editReport(reportList);

+ 5 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserController.java

@@ -80,7 +80,7 @@ public class UserController {
      * newPassword 新密码
      */
     @RequestMapping("/editPassword")
-    HttpRespMsg editPassword(@RequestParam String originPassword, @RequestParam String newPassword) {
+    public HttpRespMsg editPassword(@RequestParam String originPassword, @RequestParam String newPassword) {
         return userService.editPassword(originPassword, newPassword, request);
     }
 
@@ -91,7 +91,8 @@ public class UserController {
      * phone 电话号码
      */
     @RequestMapping("/insertCompany")
-    HttpRespMsg insertCompany(@RequestParam String companyName, @RequestParam String name, @RequestParam String phone) {
+    public HttpRespMsg insertCompany(
+            @RequestParam String companyName, @RequestParam String name, @RequestParam String phone) {
         return userService.insertCompany(companyName, name, phone);
     }
 
@@ -102,7 +103,7 @@ public class UserController {
      * role 角色 0-普通员工 2-管理员
      */
     @RequestMapping("/insertUser")
-    HttpRespMsg insertUser(@RequestParam String name, @RequestParam String phone, @RequestParam Integer role) {
+    public HttpRespMsg insertUser(@RequestParam String name, @RequestParam String phone, @RequestParam Integer role) {
         return userService.insertUser(name, phone, role, request);
     }
 
@@ -111,7 +112,7 @@ public class UserController {
      * file Excel文件
      */
     @RequestMapping("/importUser")
-    HttpRespMsg importUser(@RequestParam MultipartFile file) {
+    public HttpRespMsg importUser(@RequestParam MultipartFile file) {
         return userService.importUser(file, request);
     }
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -17,6 +17,8 @@ import java.util.Map;
  * @since 2019-12-31
  */
 public interface ReportMapper extends BaseMapper<Report> {
+    List<Map<String, Object>> getAllReportByDate(@Param("date") String date);
+
     List<Map<String, Object>> getReportByDate(@Param("date") String date, @Param("id") String id);
 
     List<Map<String, Object>> getReportNameByDate(@Param("date") String date, @Param("companyId") Integer companyId);

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -18,6 +18,8 @@ import java.util.List;
 public interface ReportService extends IService<Report> {
     HttpRespMsg getReportList(String date, HttpServletRequest request);
 
+    HttpRespMsg exportReport(String date, HttpServletRequest request);
+
     HttpRespMsg getReport(String date, HttpServletRequest request);
 
     HttpRespMsg editReport(List<Report> reportList);

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/UserService.java

@@ -32,5 +32,5 @@ public interface UserService extends IService<User> {
 
     HttpRespMsg insertUser(String name, String phone, Integer role, HttpServletRequest request);
 
-    HttpRespMsg importUser(MultipartFile file, HttpServletRequest request);
+    HttpRespMsg importUser(MultipartFile multipartFile, HttpServletRequest request);
 }

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -41,6 +41,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             httpRespMsg.data = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
@@ -68,8 +69,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             }
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
-
         return httpRespMsg;
     }
 

+ 89 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -12,17 +12,18 @@ import com.management.platform.mapper.UserMapper;
 import com.management.platform.service.ReportService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.util.HttpRespMsg;
+import org.apache.poi.hssf.usermodel.*;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -47,6 +48,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     @Resource
     private ProjectMapper projectMapper;
 
+    @Value(value = "${upload.path}")
+    private String path;
+
     //获取报告列表
     @Override
     public HttpRespMsg getReportList(String date, HttpServletRequest request) {
@@ -62,6 +66,85 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             httpRespMsg.data = nameList;
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
+        }
+        return httpRespMsg;
+    }
+
+    @Override
+    public HttpRespMsg exportReport(String date, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        try {
+            //准备导出
+            HSSFWorkbook workbook = new HSSFWorkbook();
+            HSSFSheet sheet = workbook.createSheet(date + "日报");
+            //创建表头
+            HSSFRow headRow = sheet.createRow(0);
+            //设置列宽 setColumnWidth的第二个参数要乘以256,这个参数的单位是1/256个字符宽度
+            sheet.setColumnWidth(0, 5 * 256);
+            sheet.setColumnWidth(1, 18 * 256);
+            sheet.setColumnWidth(2, 18 * 256);
+            sheet.setColumnWidth(3, 18 * 256);
+            sheet.setColumnWidth(4, 30 * 256);
+            sheet.setColumnWidth(5, 18 * 256);
+            //设置为居中加粗
+            HSSFCellStyle headStyle = workbook.createCellStyle();
+            HSSFFont font = workbook.createFont();
+            font.setBold(true);
+            headStyle.setFont(font);
+
+            HSSFCell headCell;
+            headCell = headRow.createCell(0);
+            headCell.setCellValue("序号");
+            headCell.setCellStyle(headStyle);
+            headCell = headRow.createCell(1);
+            headCell.setCellValue("上传者");
+            headCell.setCellStyle(headStyle);
+            headCell = headRow.createCell(2);
+            headCell.setCellValue("项目名称");
+            headCell.setCellStyle(headStyle);
+            headCell = headRow.createCell(3);
+            headCell.setCellValue("工作时间");
+            headCell.setCellStyle(headStyle);
+            headCell = headRow.createCell(4);
+            headCell.setCellValue("工作内容");
+            headCell.setCellStyle(headStyle);
+            headCell = headRow.createCell(5);
+            headCell.setCellValue("提交时间");
+            headCell.setCellStyle(headStyle);
+
+            //设置日期格式
+            HSSFCellStyle style = workbook.createCellStyle();
+            style.setDataFormat(HSSFDataFormat.getBuiltinFormat("yy/mm/dd hh:mm"));
+            //新增数据行,并且设置单元格数据
+            int rowNum = 1;
+            for (Map<String, Object> map : reportMapper.getAllReportByDate(date)) {
+                HSSFRow row = sheet.createRow(rowNum);
+                row.createCell(0).setCellValue(rowNum);
+                row.createCell(1).setCellValue((String) map.get("name"));
+                row.createCell(2).setCellValue((String) map.get("project"));
+                row.createCell(3).setCellValue((String) map.get("duration"));
+                row.createCell(4).setCellValue((String) map.get("content"));
+                HSSFCell cell = row.createCell(5);
+                cell.setCellValue((String) map.get("time"));
+                cell.setCellStyle(style);
+                rowNum++;
+            }
+
+            //生成Excel文件
+            String fileUrlSuffix = date + "日报" + new SimpleDateFormat("hh-mm-ss").format(new Date()) + ".xls";
+            try {
+                FileOutputStream fos = new FileOutputStream(path + fileUrlSuffix);
+                workbook.write(fos);
+                fos.flush();
+                fos.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            httpRespMsg.data = "/upload/" + fileUrlSuffix;
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
@@ -92,8 +175,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             httpRespMsg.data = resultMap;
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         } catch (DateTimeParseException e) {
             httpRespMsg.setError("日期格式有误");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }

+ 5 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -203,7 +203,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             try {
                 String browserName = isBrowser(new File(filePath));
                 System.out.println(
-                        "找到浏览器=="+browserName
+                        "找到浏览器==" + browserName
                 );
                 if (browserName != null) {
                     screenshot.setPicType(1);
@@ -300,7 +300,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
         try {
             browserName = isBrowser(new File("C://Users/seya/Desktop/360.jpg"));
             System.out.println(
-                    "找到浏览器=="+browserName
+                    "找到浏览器==" + browserName
             );
         } catch (Exception e) {
             e.printStackTrace();
@@ -489,7 +489,7 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
             /*之后可能还需要处理跨越一天的情况*/
         } catch (NullPointerException e) {
             //凡是有空指针说明缺少用户id或者时间数据
-            log.info("=====工作时长统计失败 缺少用户或时间数据=====");
+            log.info("工作时长统计失败 缺少用户或时间数据");
         }
     }
 
@@ -508,13 +508,13 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
                 File[] targetFile = subFolder.listFiles();
                 int matchCnt = 0;
                 for (File targetPic : targetFile) {
-                    System.out.println("targetPic=="+targetPic.getAbsolutePath());
+                    System.out.println("targetPic==" + targetPic.getAbsolutePath());
                     boolean matchPic = ImageReconizeUtil.isTemplateMatch(pic.getAbsolutePath(), targetPic.getAbsolutePath());
                     if (matchPic) {
                         matchCnt++;
                     }
                 }
-                if (matchCnt >=4) {
+                if (matchCnt >= 4) {
                     browserName = subFolder.getName();
                     break;
                 }

+ 8 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TimeCalculationServiceImpl.java

@@ -74,6 +74,7 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
             httpRespMsg.data = resultMap;
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
@@ -113,6 +114,7 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
             httpRespMsg.data = resultList;
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
@@ -161,16 +163,18 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
                 resultList.add(dataMap);
             }
             httpRespMsg.data = resultList;
-        } catch (NullPointerException e) {
-            httpRespMsg.setError("验证失败");
         } catch (DateTimeParseException e) {
             httpRespMsg.setError("日期格式有误");
+            return httpRespMsg;
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("验证失败");
+            return httpRespMsg;
         }
         return httpRespMsg;
     }
 
     //秒数转化为时间字符串
-    private String convertSecond(Integer time) {
+    private static String convertSecond(Integer time) {
         Integer hour = 0, minute = 0, second = 0;
         hour = time / 3600;
         time = time % 3600;
@@ -179,7 +183,7 @@ public class TimeCalculationServiceImpl extends ServiceImpl<TimeCalculationMappe
         return hour + "小时" + minute + "分" + second + "秒";
     }
 
-    private String convertSecond(Long time) {
+    private static String convertSecond(Long time) {
         Long hour = 0L, minute = 0L, second = 0L;
         hour = time / 3600;
         time = time % 3600;

+ 77 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -11,15 +11,22 @@ import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MD5Util;
 import com.management.platform.util.SnowFlake;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.io.FileInputStream;
-import java.io.IOException;
+import java.io.*;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -119,7 +126,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             if (target == null) {
                 httpRespMsg.setError("未找到用户");
             } else {
-                if (!requester.getCompanyId().equals(target.getRole())) {
+                if (!requester.getCompanyId().equals(target.getCompanyId())) {
                     httpRespMsg.setError("只能删除同一公司人员的账号");
                 } else if (target.getRole() == 2) {
                     httpRespMsg.setError("负责人账号不可删除");
@@ -220,9 +227,74 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 
     //导入用户
     @Override
-    public HttpRespMsg importUser(MultipartFile file, HttpServletRequest request) {
+    public HttpRespMsg importUser(MultipartFile multipartFile, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
-        httpRespMsg.setError("现在不能导入");
+        try {
+            //首先先搞到公司id
+            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
+            //然后处理文件
+            String fileName = multipartFile.getOriginalFilename();
+            File file = new File(fileName == null ? "file" : fileName);
+            InputStream inputStream = multipartFile.getInputStream();
+            OutputStream outputStream = new FileOutputStream(file);
+            byte[] buffer = new byte[4096];
+            int temp = 0;
+            while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
+                outputStream.write(buffer, 0, temp);
+            }
+            inputStream.close();
+            outputStream.close();
+            //然后解析表格
+            XSSFWorkbook workbook = new XSSFWorkbook(file);
+            //我们只需要第一个sheet
+            XSSFSheet sheet = workbook.getSheetAt(0);
+            //查重检验的手机号列表
+            List<String> phoneList = new ArrayList<>();
+            //要插入的账号列表
+            List<User> userList = new ArrayList<>();
+            for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
+                XSSFRow row = sheet.getRow(rowIndex);
+                if (row == null) {
+                    continue;
+                }
+                //此处新建账号 默认密码为000000 默认 姓名第一列 手机号第二列
+                Long id = SnowFlake.nextId();
+                String name = row.getCell(0).getStringCellValue();
+                String phone = row.getCell(1).getStringCellValue();
+                phoneList.add(phone);
+                userList.add(new User()
+                        .setId(id.toString())
+                        .setName(name)
+                        .setPassword(MD5Util.getPassword("000000"))
+                        .setPhone(phone)
+                        .setRole(0)
+                        .setCompanyId(companyId));
+            }
+            //最后删掉这个文件
+            if (!file.delete()) {
+                System.out.println("临时文件" + file.getName() + "删除失败");
+            }
+            //校验是否有重复账号
+            if (userMapper.selectCount(new QueryWrapper<User>().in("phone", phoneList)) == 0) {
+                for (User user : userList) {
+                    userMapper.insert(user);
+                }
+            } else {
+                httpRespMsg.setError("手机号有重复 批量新建账号失败");
+                /*这里以后可能需要返回重复的手机号的具体信息*/
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            httpRespMsg.setError("文件处理出错");
+            return httpRespMsg;
+        } catch (NullPointerException e) {
+            httpRespMsg.setError("数据格式有误或存在空数据 导出失败");
+            return httpRespMsg;
+        } catch (Exception e) {
+            e.printStackTrace();
+            httpRespMsg.setError("发生其他错误");
+            return httpRespMsg;
+        }
         return httpRespMsg;
     }
 }

+ 15 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -18,6 +18,20 @@
         id, creator_id, project_id, create_date, working_time, content, create_time
     </sql>
 
+    <!--根据日期获取全部报告信息-->
+    <select id="getAllReportByDate" resultType="java.util.Map">
+        SELECT c.name, b.project_name AS project, a.working_time AS duration, a.content, a.create_time AS time
+        FROM report AS a
+        JOIN project AS b ON a.project_id=b.id
+        LEFT JOIN user AS c ON a.creator_id=c.id
+        WHERE 1=1
+        <if test="date != null and date != ''">
+            AND a.create_date=#{date}
+        </if>
+        AND a.creator_id=#{id}
+        ORDER BY a.creator_id ASC
+    </select>
+
     <!--根据日期获取报告信息-->
     <select id="getReportByDate" resultType="java.util.Map">
         SELECT b.project_name AS project, a.working_time AS time, a.content
@@ -28,7 +42,7 @@
             AND a.create_date=#{date}
         </if>
         AND a.creator_id=#{id}
-        ORDER BY a.project_id ASC
+        ORDER BY a.creator_id ASC
     </select>
 
     <!--根据日期获取报告上传人-->

+ 2 - 5
fhKeeper/formulahousekeeper/timesheet/src/port.js

@@ -1,13 +1,10 @@
 export default {
-    test:{
-      test1:'/time-calculation/getDuration'
-    },
-
-
     manage: {
         login: '/user/loginAdmin', // 登录
         list: '/user/getEmployeeList', //获取员工列表
         delete: '/user/deleteUser', //删除用户
+        insert: '/user/insertUser', //单独新增用户
+        import: '/user/importUser', //批量导入用户
     },
 
     //时间

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

@@ -60,16 +60,16 @@ let routes = [
         ]
     },
     //系统管理
-    {
-        path: '/',
-        component: Home,
-        name: '',
-        iconCls: 'fa fa-cog',
-        leaf: true,//只有一个节点
-        children: [
-            { path: '/system', component: system, name: '系统管理' },
-        ]
-    },
+    // {
+    //     path: '/',
+    //     component: Home,
+    //     name: '',
+    //     iconCls: 'fa fa-cog',
+    //     leaf: true,//只有一个节点
+    //     children: [
+    //         { path: '/system', component: system, name: '系统管理' },
+    //     ]
+    // },
     {
         path: '/404',
         component: NotFound,

+ 89 - 5
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -4,10 +4,10 @@
     <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
       <el-form :inline="true">
         <el-form-item style="float:right;">
-          <el-link type="primary" :underline="false">添加人员</el-link>
+          <el-link type="primary" :underline="false" @click="openInsertDialog">添加人员</el-link>
         </el-form-item>
         <el-form-item style="float:right;">
-          <el-link type="primary" :underline="false">批量导入</el-link>
+          <el-link type="primary" :underline="false">批量导入N/A</el-link>
         </el-form-item>
       </el-form>
     </el-col>
@@ -23,6 +23,12 @@
       <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 label="操作">
         <template slot-scope="scope">
           <el-button size="small" type="danger" @click="deleteUser(scope.$index)">删除</el-button>
@@ -31,7 +37,7 @@
     </el-table>
 
     <!--工具条-->
-    <el-col :span="24" class="toolbar">
+    <!-- <el-col :span="24" class="toolbar">
       <el-pagination
         @size-change="handleSizeChange"
         @current-change="handleCurrentChange"
@@ -41,7 +47,29 @@
         :total="total"
         style="float:right;"
       ></el-pagination>
-    </el-col>
+    </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="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>
 </template>
 
@@ -56,7 +84,18 @@ export default {
       total: 0,
       page: 1,
       size: 20,
-      list: []
+      list: [],
+      dialogVisible: false,
+      insertForm: {
+        name: null,
+        phone: null,
+        role: null
+      },
+      rules: {
+        name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
+        phone: [{ required: true, message: "请输入电话", trigger: "blur" }],
+        role: [{ required: true, message: "请选择角色", trigger: "blur" }]
+      }
     };
   },
   methods: {
@@ -98,6 +137,43 @@ export default {
       );
     },
 
+    //新增员工
+    submitInsert() {
+      this.$refs.form1.validate(valid => {
+        if (valid) {
+          this.listLoading = true;
+          this.http.post(
+            this.port.manage.insert,
+            {
+              name: this.insertForm.name,
+              phone: this.insertForm.phone,
+              role: this.insertForm.role
+            },
+            res => {
+              this.listLoading = false;
+              if (res.code == "ok") {
+                this.dialogVisible = false;
+                //重新读取列表
+                this.getUser();
+              } else {
+                this.$message({
+                  message: res.msg,
+                  type: "error"
+                });
+              }
+            },
+            error => {
+              this.listLoading = false;
+              this.$message({
+                message: error,
+                type: "error"
+              });
+            }
+          );
+        }
+      });
+    },
+
     //三天之内删了你 数据库都给你清了
     deleteUser(index) {
       this.$confirm(
@@ -140,6 +216,14 @@ export default {
           );
         })
         .catch(() => {});
+    },
+
+    //打开单独新增的Dialog
+    openInsertDialog() {
+      this.insertForm.name = null;
+      this.insertForm.phone = null;
+      this.insertForm.role = null;
+      this.dialogVisible = true;
     }
   },
 

+ 2 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/statistics.vue

@@ -15,9 +15,9 @@
             placeholder="选择日期"
           ></el-date-picker>
         </el-form-item>
-        <el-form-item style="float:right;">
+        <!-- <el-form-item style="float:right;">
           <el-link type="primary" :underline="false" @click="handleAdd">异常申请</el-link>
-        </el-form-item>
+        </el-form-item> -->
       </el-form>
     </el-col>