<!--访客管理--> <template> <div class="app-container"> <!--筛选条件--> <div class="search-div"> <el-form ref="selectForm" :inline="true" :model="listQuery" size="small" class="form-container"> <el-row> <el-form-item class="selectForm-container-item" > <!--<dept-select v-model="listQuery.deptid" :need-top="false" placeholder="部门"/>--> <el-select :disabled="deptDisabled" v-model="listQuery.deptid" placeholder="部门" clearable value=""> <el-option v-for="item in deptList" :key="item.id" :label="item.simplename" :value="item.id"/> </el-select> </el-form-item> <el-form-item class="selectForm-container-item"> <el-input v-model.trim="listQuery.name" placeholder="姓名" clearable/> </el-form-item> <el-form-item class="selectForm-container-item" prop="month"> <el-date-picker v-model="listQuery.month" type="month" value-format="yyyy-MM" style="width: 160px" placeholder="考勤月"/> </el-form-item> <el-form-item class="selectForm-container-item" prop="date"> <el-date-picker v-model="listQuery.date" type="date" value-format="yyyy-MM-dd" style="width: 160px" placeholder="日期"/> </el-form-item> <el-form-item class="selectForm-container-item" prop="isMark"> <el-checkbox v-model="listQuery.isMark" style="width: 160px; height: 30px" border>仅显示无备注</el-checkbox> </el-form-item> <el-form-item class="selectForm-container-item" prop="isAbnormal"> <el-checkbox v-model="listQuery.isAbnormal" style="width: 160px; height: 30px" border checked>仅显示异常</el-checkbox> </el-form-item> <!--<el-form-item class="selectForm-container-item" />--> <el-button class="filter-item" type="primary" size="small" icon="el-icon-search" @click="search">搜索</el-button> <el-button class="filter-item" type="primary" size="small" @click="syn">重新获取识别记录</el-button> </el-row> </el-form> </div> <!--查询结果Table显示--> <div> <el-row class="table-title"> <el-col :span="6"><div class="title-header"><i class="el-icon-menu"/>数据列表</div></el-col> <el-col :span="12" :offset="6" class="edit_btns"> <el-button :disabled="total===0" class="edit_btn" size="small" @click="batchExport">导出记录</el-button> </el-col> </el-row> <el-table v-loading="listLoading" ref="table" :data="list" class="table" border> <el-table-column :index="indexMethod" align="center" type="index" /> <el-table-column v-for="column in columns" :key="column.value" :label="column.text" :width="column.width" :align="column.align" show-overflow-tooltip> <template slot-scope="scope"> <span>{{ scope.row[column.value] }}</span> <span v-if="column.ext">{{ scope.row.ext[column.value] }}</span> </template> </el-table-column> <el-table-column label="备注操作" align="center" width="80"> <template slot-scope="scope"> <el-button :disabled="scope.row.canEdit === '0'" type="text" @click="edit(scope.row)">编辑</el-button> </template> </el-table-column> </el-table> </div> <!--分页--> <div class="pagination-container"> <el-pagination v-show="total>listQuery.limit" :current-page="listQuery.offset" :page-sizes="[20,30,50]" :page-size="listQuery.limit" :total="total" align="center" layout="total, sizes, prev, pager, next" @size-change="handleSizeChange" @current-change="handleCurrentChange"/> </div> <edit-remarks ref="editRemarks" @watchChild="fetchData"/> <sync-and-generate ref="syncAndGenerate" @watchChild="fetchData"/> </div> </template> <script> import EditRemarks from './editRemarks' import SyncAndGenerate from './syncAndGenerate' import { getDeptList, getReportList, batchExportReport } from '@/api/attendance' import { downloadFile } from '@/utils/downloadUtils' export default { name: 'ListReport', components: { EditRemarks, SyncAndGenerate }, data() { return { listQuery: { deptid: '', // 部门 name: '', // 姓名 month: '', // 考勤月 date: '', // 日期 isMark: '', // 是否有备注 isAbnormal: '', // 是否异常 offset: 1, limit: 20, sort: '', order: '' }, // 筛选条件 columns: [ { text: '部门', value: 'deptName', align: 'center' }, { text: '姓名', value: 'name', align: 'center' }, { text: '日期', value: 'date', align: 'center' }, { text: '识别记录', value: 'time', width: 180, align: 'center' }, { text: '迟到(m)', value: 'late', width: 80, align: 'center' }, { text: '早退(m)', value: 'early', width: 80, align: 'center' }, { text: '上午旷工(h)', value: 'absentAm', width: 100, align: 'center' }, { text: '下午旷工(h)', value: 'absentPm', width: 100, align: 'center' }, { text: '旷工一天', value: 'absentOneDay', width: 90, align: 'center' }, { text: '备注信息', value: 'remarks', width: 220, align: 'center' } ], // 显示列 multipleSelection: [], // 多选选中项 list: [], // 列表数据 total: 0, // 数据总数 listLoading: false, // 加载动画 fullscreenLoading: false, // 全屏加载动画 dialogFormVisible: '', deptList: [], deptDisabled: false } }, watch: {}, mounted() { this.getDeptSource() }, activated() { }, methods: { // 检查选择情况 checkSelection() { if (this.multipleSelection.length === 0) { return false } else { return true } }, // 编辑备注 edit(row) { this.dialogFormVisible = true this.editShow = true this.$refs.editRemarks.initDialog(null, this.dialogFormVisible, row) }, syn() { this.dialogFormVisible = true this.$refs.syncAndGenerate.initDialog(this.dialogFormVisible) }, // 批量导出 batchExport() { // 全屏加载动画 const loading = this.$loading({ lock: true, text: '数据处理中,请稍后...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) batchExportReport(this.listQuery).then(res => { loading.close() // 关闭加载动画 downloadFile(res.data, '考勤报表数据') }).catch((res) => { loading.close() }) }, // 查询数据 search() { this.fetchData(false) }, // 获取数据 fetchData(isNowPage = true) { this.listLoading = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 this.listQuery.offset = 1 } console.log(this.listQuery.date) getReportList(this.listQuery).then(response => { this.list = response.data.rows this.total = parseInt(response.data.total) this.listLoading = false }) }, indexMethod(index) { return this.listQuery.limit * (this.listQuery.offset - 1) + index + 1 }, // 改变页容量 handleSizeChange(val) { this.listQuery.limit = val this.fetchData() }, // 改变当前页 handleCurrentChange(val) { this.listQuery.offset = val this.fetchData() }, // 获取部门列表 getDeptSource() { getDeptList().then(response => { this.deptList = response.data if (this.deptList.length === 1) { this.deptDisabled = true this.listQuery.deptid = this.deptList[0].id } this.fetchData(false)// 获取数据 }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> $tableTitleHeight:46px; .app-container{ margin-bottom:20px } .table{ margin-bottom: 20px; } .pagination-container{ margin-bottom: 50px; } .table-title{ background-color:rgba(243, 243, 243, 1); height: $tableTitleHeight; .title-header{ line-height:$tableTitleHeight; color: #606266; font-size: 15px; i{ margin-left: 5px; margin-right: 5px; } } } .edit_btns{ .edit_btn{ float:right; margin:7px 3px;//为了需要居中显示margin-top和bottom要用$tableTitleHeight减去按钮原高度除以2 } } .selectForm-container-item{ width: 160px; } body .el-table th.gutter{ display: table-cell!important; } /*.filter-item{*/ /*height: 30px;*/ /*}*/ </style>