20200722-zlp-1

幼儿考勤管理
This commit is contained in:
paidaxing444 2020-07-22 15:30:11 +08:00
parent f978966259
commit bc17996e3f
2 changed files with 189 additions and 70 deletions

View File

@ -2,13 +2,14 @@
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px"> <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
<el-form-item label="班级编码" prop="classid"> <el-form-item label="班级编码" prop="classid">
<el-input <el-select v-model="queryParams.classid" placeholder="请选择班级">
v-model="queryParams.classid" <el-option
placeholder="请输入班级编码" v-for="dict in classOptions"
clearable :key="dict.bjbh"
size="small" :label="dict.bjmc"
@keyup.enter.native="handleQuery" :value="dict.bjbh"
/> ></el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="幼儿姓名" prop="childname"> <el-form-item label="幼儿姓名" prop="childname">
<el-input <el-input
@ -21,7 +22,12 @@
</el-form-item> </el-form-item>
<el-form-item label="出勤类型" prop="type"> <el-form-item label="出勤类型" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择出勤类型" clearable size="small"> <el-select v-model="queryParams.type" placeholder="请选择出勤类型" clearable size="small">
<el-option label="请选择字典生成" value /> <el-option
v-for="dict in checkinOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -74,12 +80,17 @@
<el-table v-loading="loading" :data="detailList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="detailList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" /> <el-table-column label="编号" align="center" prop="id" />
<el-table-column label="学校编码" align="center" prop="schoolid" /> <!-- <el-table-column label="学校编码" align="center" prop="schoolid" /> -->
<el-table-column label="班级编码" align="center" prop="classid" /> <el-table-column label="班级编码" align="center" prop="classid" :formatter="classFormat" />
<el-table-column label="幼儿编码" align="center" prop="childid" /> <!-- <el-table-column label="幼儿编码" align="center" prop="childid" /> -->
<el-table-column label="幼儿姓名" align="center" prop="childname" /> <el-table-column label="幼儿姓名" align="center" prop="childname" />
<el-table-column label="出勤类型" align="center" prop="type" /> <el-table-column label="出勤类型" align="center" prop="type" :formatter="typeFormat" />
<el-table-column label="创建人" align="center" prop="createuserid" /> <el-table-column label="考勤时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="创建人" align="center" prop="createuserid" /> -->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -111,26 +122,28 @@
<!-- 添加或修改幼儿考勤对话框 --> <!-- 添加或修改幼儿考勤对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="学校编码" prop="schoolid"> <el-form-item label="选择幼儿" prop="childname">
<el-input v-model="form.schoolid" placeholder="请输入学校编码" /> <el-checkbox
:indeterminate="isIndeterminate"
v-model="checkAll"
@change="handleCheckAllChange"
>全选</el-checkbox>
<div style="margin: 15px 0;"></div>
<el-checkbox-group v-model="checkedChilds" @change="handlecheckedChildsChange">
<el-checkbox v-for="child in childs" :label="child.id" :key="child.id">{{child.name}}</el-checkbox>
</el-checkbox-group>
<el-input v-model="form.childname" v-if="false" />
</el-form-item> </el-form-item>
<el-form-item label="班级编码" prop="classid"> <el-form-item label="出勤类型" prop="type">
<el-input v-model="form.classid" placeholder="请输入班级编码" />
</el-form-item>
<el-form-item label="幼儿编码" prop="childid">
<el-input v-model="form.childid" placeholder="请输入幼儿编码" />
</el-form-item>
<el-form-item label="幼儿姓名" prop="childname">
<el-input v-model="form.childname" placeholder="请输入幼儿姓名" />
</el-form-item>
<el-form-item label="出勤类型">
<el-select v-model="form.type" placeholder="请选择出勤类型"> <el-select v-model="form.type" placeholder="请选择出勤类型">
<el-option label="请选择字典生成" value /> <el-option
v-for="dict in checkinOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="创建人" prop="createuserid">
<el-input v-model="form.createuserid" placeholder="请输入创建人" />
</el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
@ -150,10 +163,18 @@ import {
exportDetail exportDetail
} from "@/api/benyi/checkindetail"; } from "@/api/benyi/checkindetail";
import { listChild } from "@/api/benyi/child";
import { listClass } from "@/api/system/class";
export default { export default {
name: "Detail", name: "Detail",
data() { data() {
return { return {
checkAll: false,
checkedChilds: [],
childs: [],
isIndeterminate: false,
// //
loading: true, loading: true,
// //
@ -166,6 +187,10 @@ export default {
total: 0, total: 0,
// //
detailList: [], detailList: [],
//
checkinOptions: [],
//
classOptions: [],
// //
title: "", title: "",
// //
@ -184,18 +209,55 @@ export default {
// //
form: {}, form: {},
// //
rules: {} rules: {
childname: [
{
required: true,
message: "请至少选择一个幼儿",
trigger: "blur"
}
],
type: [{ required: true, message: "出勤类型不能为空", trigger: "blur" }]
}
}; };
}, },
created() { created() {
this.getList(); this.getList();
this.getClassList();
this.getDicts("sys_dm_cqzt").then(response => {
this.checkinOptions = response.data;
});
}, },
methods: { methods: {
//
getClassList() {
listClass(null).then(response => {
this.classOptions = response.rows;
});
},
//
typeFormat(row, column) {
return this.selectDictLabel(this.checkinOptions, row.type);
},
//
classFormat(row, column) {
// return this.selectDictLabel(this.classOptions, row.classid);
var actions = [];
var datas = this.classOptions;
Object.keys(datas).map(key => {
if (datas[key].bjbh == "" + row.classid) {
actions.push(datas[key].bjmc);
return false;
}
});
return actions.join("");
},
/** 查询幼儿考勤列表 */ /** 查询幼儿考勤列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listDetail(this.queryParams).then(response => { listDetail(this.queryParams).then(response => {
this.detailList = response.rows; this.detailList = response.rows;
// console.log(response.rows);
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
}); });
@ -237,9 +299,11 @@ export default {
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset();
this.open = true; this.open = true;
this.title = "添加幼儿考勤"; this.title = "幼儿考勤";
listChild(null).then(response => {
this.childs = response.rows;
});
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
@ -255,23 +319,18 @@ export default {
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.id != undefined) { if (this.form.childname == "") {
updateDetail(this.form).then(response => { this.msgError("请至少选择一个幼儿");
if (response.code === 200) { return;
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addDetail(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
} }
//
addDetail(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("添加考勤成功");
this.open = false;
this.getList();
}
});
} }
}); });
}, },
@ -311,6 +370,41 @@ export default {
this.download(response.msg); this.download(response.msg);
}) })
.catch(function() {}); .catch(function() {});
},
handleCheckAllChange(val) {
// this.checkedChilds = val ? this.childs : [];
// this.isIndeterminate = false;
this.checkedChilds = [];
this.childs.forEach(item => {
//
this.checkedChilds.push(item.id);
});
this.checkedChilds = val ? this.checkedChilds : []; //valtruefalse
this.isIndeterminate = false; //
//console.log(this.checkedChilds);
var cids = "";
this.checkedChilds.forEach(item => {
//
cids = cids + item + ",";
});
console.log(cids);
this.form.childname = cids;
},
handlecheckedChildsChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.childs.length;
this.isIndeterminate =
checkedCount > 0 && checkedCount < this.childs.length;
//console.log(this.checkedChilds);
var cids = "";
this.checkedChilds.forEach(item => {
//
cids = cids + item + ",";
});
console.log(cids);
this.form.childname = cids;
} }
} }
}; };

View File

@ -1,6 +1,11 @@
package com.ruoyi.project.benyi.controller; package com.ruoyi.project.benyi.controller;
import java.util.List; import java.util.List;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.project.benyi.domain.ByChild;
import com.ruoyi.project.benyi.service.IByChildService;
import com.ruoyi.project.common.SchoolCommon;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -28,18 +33,20 @@ import com.ruoyi.framework.web.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/benyi/checkindetail") @RequestMapping("/benyi/checkindetail")
public class ByChildCheckinDetailController extends BaseController public class ByChildCheckinDetailController extends BaseController {
{
@Autowired @Autowired
private IByChildCheckinDetailService byChildCheckinDetailService; private IByChildCheckinDetailService byChildCheckinDetailService;
@Autowired
private SchoolCommon schoolCommon;
@Autowired
private IByChildService byChildService;
/** /**
* 查询幼儿考勤列表 * 查询幼儿考勤列表
*/ */
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:list')") @PreAuthorize("@ss.hasPermi('benyi:checkindetail:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(ByChildCheckinDetail byChildCheckinDetail) public TableDataInfo list(ByChildCheckinDetail byChildCheckinDetail) {
{
startPage(); startPage();
List<ByChildCheckinDetail> list = byChildCheckinDetailService.selectByChildCheckinDetailList(byChildCheckinDetail); List<ByChildCheckinDetail> list = byChildCheckinDetailService.selectByChildCheckinDetailList(byChildCheckinDetail);
return getDataTable(list); return getDataTable(list);
@ -51,8 +58,7 @@ public class ByChildCheckinDetailController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:export')") @PreAuthorize("@ss.hasPermi('benyi:checkindetail:export')")
@Log(title = "幼儿考勤", businessType = BusinessType.EXPORT) @Log(title = "幼儿考勤", businessType = BusinessType.EXPORT)
@GetMapping("/export") @GetMapping("/export")
public AjaxResult export(ByChildCheckinDetail byChildCheckinDetail) public AjaxResult export(ByChildCheckinDetail byChildCheckinDetail) {
{
List<ByChildCheckinDetail> list = byChildCheckinDetailService.selectByChildCheckinDetailList(byChildCheckinDetail); List<ByChildCheckinDetail> list = byChildCheckinDetailService.selectByChildCheckinDetailList(byChildCheckinDetail);
ExcelUtil<ByChildCheckinDetail> util = new ExcelUtil<ByChildCheckinDetail>(ByChildCheckinDetail.class); ExcelUtil<ByChildCheckinDetail> util = new ExcelUtil<ByChildCheckinDetail>(ByChildCheckinDetail.class);
return util.exportExcel(list, "detail"); return util.exportExcel(list, "detail");
@ -63,8 +69,7 @@ public class ByChildCheckinDetailController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:query')") @PreAuthorize("@ss.hasPermi('benyi:checkindetail:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id) {
{
return AjaxResult.success(byChildCheckinDetailService.selectByChildCheckinDetailById(id)); return AjaxResult.success(byChildCheckinDetailService.selectByChildCheckinDetailById(id));
} }
@ -74,9 +79,31 @@ public class ByChildCheckinDetailController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:add')") @PreAuthorize("@ss.hasPermi('benyi:checkindetail:add')")
@Log(title = "幼儿考勤", businessType = BusinessType.INSERT) @Log(title = "幼儿考勤", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody ByChildCheckinDetail byChildCheckinDetail) public AjaxResult add(@RequestBody ByChildCheckinDetail byChildCheckinDetail) {
{ //首先判断当前账户是否为幼儿园账号
return toAjax(byChildCheckinDetailService.insertByChildCheckinDetail(byChildCheckinDetail)); if (schoolCommon.isSchool()) {
int iCount = 0;
//getChildname 暂用作幼儿id集合
if (!schoolCommon.isStringEmpty(byChildCheckinDetail.getChildname())) {
String[] strArr = byChildCheckinDetail.getChildname().split(",");
for (int i = 0; i < strArr.length; i++) {
Long cid = Long.parseLong(strArr[i]);
byChildCheckinDetail.setChildid(cid);
ByChild byChild=byChildService.selectByChildById(cid);
byChildCheckinDetail.setChildname(byChild.getName());
byChildCheckinDetail.setClassid(byChild.getClassid());
byChildCheckinDetail.setSchoolid(SecurityUtils.getLoginUser().getUser().getDept().getDeptId());
iCount = iCount + byChildCheckinDetailService.insertByChildCheckinDetail(byChildCheckinDetail);
}
return toAjax(iCount);
}
return toAjax(iCount);
} else {
return AjaxResult.error("当前用户非幼儿园,无法添加幼儿");
}
} }
/** /**
@ -85,8 +112,7 @@ public class ByChildCheckinDetailController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:edit')") @PreAuthorize("@ss.hasPermi('benyi:checkindetail:edit')")
@Log(title = "幼儿考勤", businessType = BusinessType.UPDATE) @Log(title = "幼儿考勤", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody ByChildCheckinDetail byChildCheckinDetail) public AjaxResult edit(@RequestBody ByChildCheckinDetail byChildCheckinDetail) {
{
return toAjax(byChildCheckinDetailService.updateByChildCheckinDetail(byChildCheckinDetail)); return toAjax(byChildCheckinDetailService.updateByChildCheckinDetail(byChildCheckinDetail));
} }
@ -96,8 +122,7 @@ public class ByChildCheckinDetailController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:remove')") @PreAuthorize("@ss.hasPermi('benyi:checkindetail:remove')")
@Log(title = "幼儿考勤", businessType = BusinessType.DELETE) @Log(title = "幼儿考勤", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids) {
{
return toAjax(byChildCheckinDetailService.deleteByChildCheckinDetailByIds(ids)); return toAjax(byChildCheckinDetailService.deleteByChildCheckinDetailByIds(ids));
} }
} }