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

@ -1,14 +1,15 @@
<template>
<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-input
v-model="queryParams.classid"
placeholder="请输入班级编码"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
<el-select v-model="queryParams.classid" placeholder="请选择班级">
<el-option
v-for="dict in classOptions"
:key="dict.bjbh"
:label="dict.bjmc"
:value="dict.bjbh"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="幼儿姓名" prop="childname">
<el-input
@ -21,7 +22,12 @@
</el-form-item>
<el-form-item label="出勤类型" prop="type">
<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-form-item>
<el-form-item>
@ -74,12 +80,17 @@
<el-table v-loading="loading" :data="detailList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="学校编码" align="center" prop="schoolid" />
<el-table-column label="班级编码" align="center" prop="classid" />
<el-table-column label="幼儿编码" align="center" prop="childid" />
<!-- <el-table-column label="学校编码" align="center" prop="schoolid" /> -->
<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="childname" />
<el-table-column label="出勤类型" align="center" prop="type" />
<el-table-column label="创建人" align="center" prop="createuserid" />
<el-table-column label="出勤类型" align="center" prop="type" :formatter="typeFormat" />
<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">
<template slot-scope="scope">
<el-button
@ -111,26 +122,28 @@
<!-- 添加或修改幼儿考勤对话框 -->
<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-item label="学校编码" prop="schoolid">
<el-input v-model="form.schoolid" placeholder="请输入学校编码" />
<el-form-item label="选择幼儿" prop="childname">
<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 label="班级编码" prop="classid">
<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-form-item label="出勤类型" prop="type">
<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-form-item>
<el-form-item label="创建人" prop="createuserid">
<el-input v-model="form.createuserid" placeholder="请输入创建人" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -150,10 +163,18 @@ import {
exportDetail
} from "@/api/benyi/checkindetail";
import { listChild } from "@/api/benyi/child";
import { listClass } from "@/api/system/class";
export default {
name: "Detail",
data() {
return {
checkAll: false,
checkedChilds: [],
childs: [],
isIndeterminate: false,
//
loading: true,
//
@ -166,6 +187,10 @@ export default {
total: 0,
//
detailList: [],
//
checkinOptions: [],
//
classOptions: [],
//
title: "",
//
@ -184,18 +209,55 @@ export default {
//
form: {},
//
rules: {}
rules: {
childname: [
{
required: true,
message: "请至少选择一个幼儿",
trigger: "blur"
}
],
type: [{ required: true, message: "出勤类型不能为空", trigger: "blur" }]
}
};
},
created() {
this.getList();
this.getClassList();
this.getDicts("sys_dm_cqzt").then(response => {
this.checkinOptions = response.data;
});
},
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() {
this.loading = true;
listDetail(this.queryParams).then(response => {
this.detailList = response.rows;
// console.log(response.rows);
this.total = response.total;
this.loading = false;
});
@ -237,9 +299,11 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加幼儿考勤";
this.title = "幼儿考勤";
listChild(null).then(response => {
this.childs = response.rows;
});
},
/** 修改按钮操作 */
handleUpdate(row) {
@ -255,23 +319,18 @@ export default {
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != undefined) {
updateDetail(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addDetail(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
if (this.form.childname == "") {
this.msgError("请至少选择一个幼儿");
return;
}
//
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);
})
.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;
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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -28,31 +33,32 @@ import com.ruoyi.framework.web.page.TableDataInfo;
*/
@RestController
@RequestMapping("/benyi/checkindetail")
public class ByChildCheckinDetailController extends BaseController
{
public class ByChildCheckinDetailController extends BaseController {
@Autowired
private IByChildCheckinDetailService byChildCheckinDetailService;
@Autowired
private SchoolCommon schoolCommon;
@Autowired
private IByChildService byChildService;
/**
* 查询幼儿考勤列表
*/
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:list')")
@GetMapping("/list")
public TableDataInfo list(ByChildCheckinDetail byChildCheckinDetail)
{
/**
* 查询幼儿考勤列表
*/
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:list')")
@GetMapping("/list")
public TableDataInfo list(ByChildCheckinDetail byChildCheckinDetail) {
startPage();
List<ByChildCheckinDetail> list = byChildCheckinDetailService.selectByChildCheckinDetailList(byChildCheckinDetail);
return getDataTable(list);
}
/**
* 导出幼儿考勤列表
*/
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:export')")
@Log(title = "幼儿考勤", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(ByChildCheckinDetail byChildCheckinDetail)
{
public AjaxResult export(ByChildCheckinDetail byChildCheckinDetail) {
List<ByChildCheckinDetail> list = byChildCheckinDetailService.selectByChildCheckinDetailList(byChildCheckinDetail);
ExcelUtil<ByChildCheckinDetail> util = new ExcelUtil<ByChildCheckinDetail>(ByChildCheckinDetail.class);
return util.exportExcel(list, "detail");
@ -63,8 +69,7 @@ public class ByChildCheckinDetailController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(byChildCheckinDetailService.selectByChildCheckinDetailById(id));
}
@ -74,9 +79,31 @@ public class ByChildCheckinDetailController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:add')")
@Log(title = "幼儿考勤", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ByChildCheckinDetail byChildCheckinDetail)
{
return toAjax(byChildCheckinDetailService.insertByChildCheckinDetail(byChildCheckinDetail));
public AjaxResult add(@RequestBody ByChildCheckinDetail 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')")
@Log(title = "幼儿考勤", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ByChildCheckinDetail byChildCheckinDetail)
{
public AjaxResult edit(@RequestBody ByChildCheckinDetail byChildCheckinDetail) {
return toAjax(byChildCheckinDetailService.updateByChildCheckinDetail(byChildCheckinDetail));
}
@ -96,8 +122,7 @@ public class ByChildCheckinDetailController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:checkindetail:remove')")
@Log(title = "幼儿考勤", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(byChildCheckinDetailService.deleteByChildCheckinDetailByIds(ids));
}
}