<template>
<app-container>
<search-area :need-clear="true" :need-search-more="false" type="seperate" size="small" search-more-type="default" @search="fetchData(false)" @clear="clearInput">
<!--一般查询条件-->
<search-item>
<el-input v-model.trim="listQuery.keywords" size="small" placeholder="员工号/员工姓名" @change="fetchData(false)" />
</search-item>
<search-item>
<el-select v-model="listQuery.staffType" size="small" placeholder="员工类型" clearable @change="fetchData(false)">
<el-option
v-for="item in typeList"
:key="item.value"
:label="item.name"
:value="item.value"
/>
</el-select>
</search-item>
<search-item>
<el-date-picker
v-model="timeRange"
type="daterange"
range-separator="至"
value-format="yyyy-MM-dd"
start-placeholder="起始日期"
end-placeholder="终止日期"
size="small"
@change="fetchData(false)"
/>
</search-item>
</search-area>
<normal-table :data="list" :head="tableOption.head" :query="listQuery" :total="total" :columns="columns" :list-loading="listLoading" :options="tableOption.options" :tools-option="tableOption.toolsOption" size="small" @change="changePage" />
</app-container>
</template>
<script>
import NormalTable from '@/components/NormalTable'
import AppContainer from '@/components/layout/AppContainer'
import SearchArea from '@/components/SearchArea/SearchArea'
import SearchItem from '@/components/SearchArea/SearchItem'
import { getAttendanceListPage } from '@/api/person'
import { getDictByCode } from '@/api/system/dict'
export default {
name: 'AttendanceList',
components: { SearchItem, SearchArea, AppContainer, NormalTable },
data() {
return {
listQuery: {
keywords: '',
staffType: '',
startDate: '',
endDate: '',
offset: 1,
limit: 20
}, // 筛选条件
columns: [
{
text: '员工号',
value: 'staffCode',
align: 'center'
},
{
text: '姓名',
value: 'staffName',
align: 'center'
},
{
text: '员工类型',
value: 'staffTypeName',
align: 'center'
},
{
text: '日期',
value: 'atteDate',
align: 'center'
},
{
text: '上班时间',
value: 'atteStartTime',
align: 'center'
},
{
text: '上班时间获取设备',
value: 'atteStartDev',
align: 'center'
},
{
text: '下班时间',
value: 'atteEndTime',
align: 'center'
},
{
text: '下班时间获取设备',
value: 'atteEndDev',
align: 'center'
}
], // 显示列
dialogFormVisible: false, // 是否显示编辑框
timeRange: [], // 时间范围
multipleSelection: [], // 多选选中项
list: [], // 列表数据
typeList: [],
total: 0, // 数据总数
listLoading: true, // 列表加载动画
tableOption: {
head: {
show: true, // 是否需要标题栏,
text: '数据列表' // 标题名称
},
options: {
needIndex: true // 是否需要序号列
},
toolsOption: {
selectColumns: false, // 是否需要筛选列
refresh: false, // 是否需要刷新按钮
needCheckBox: false
}
} // 表格属性
}
},
watch: {
timeRange(val) {
if (val && val.length > 0) {
this.listQuery.startDate = val[0]
this.listQuery.endDate = val[1]
} else {
this.listQuery.startDate = ''
this.listQuery.endDate = ''
}
}
},
created() {
this.fetchOptions()
this.fetchData()
},
methods: {
fetchOptions() {
getDictByCode('staffType').then(response => {
if (response.code === 200) {
this.typeList = response.data.filter(item => {
if (item.name !== '正式员工') {
return item
}
})
}
})
},
fetchData(isNowPage = true) {
this.listLoading = true
if (!isNowPage) { // 是否显示当前页,否则跳转第一页
this.listQuery.offset = 1
}
getAttendanceListPage(this.listQuery).then(response => {
if (response.code === 200) {
this.list = response.data.rows.map(item => {
if (item.atteDate.length !== 0) {
item.atteDate = item.atteDate.substring(0, 10)
}
return item
})
this.total = parseInt(response.data.total)
this.listLoading = false
}
})
// const that = this
// setTimeout(function() {
// that.list = [
// { id: '', staffCode: '0098701', staffName: '张三', staffType: '0', staffTypeName: '物业人员', date: '2022-05-06', onTime: '08:00:04', onDevCode: '0012301', offTime: '19:12:00', offDevCode: '0012301' },
// { id: '', staffCode: '0098701', staffName: '张三', staffType: '0', staffTypeName: '物业人员', date: '2022-05-06', onTime: '08:00:04', onDevCode: '0012301', offTime: '19:12:00', offDevCode: '0012301' },
// { id: '', staffCode: '0098701', staffName: '张三', staffType: '0', staffTypeName: '物业人员', date: '2022-05-06', onTime: '08:00:04', onDevCode: '0012301', offTime: '19:12:00', offDevCode: '0012301' },
// { id: '', staffCode: '0098701', staffName: '张三', staffType: '0', staffTypeName: '物业人员', date: '2022-05-06', onTime: '08:00:04', onDevCode: '0012301', offTime: '19:12:00', offDevCode: '0012301' },
// { id: '', staffCode: '0098701', staffName: '张三', staffType: '0', staffTypeName: '物业人员', date: '2022-05-06', onTime: '08:00:04', onDevCode: '0012301', offTime: '19:12:00', offDevCode: '0012301' }
// ]
// that.total = 200
// that.listLoading = false
// }, 100)
},
// 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写
changePage(val) {
if (val && val.size) {
this.listQuery.limit = val.size
}
if (val && val.page) {
this.listQuery.offset = val.page
}
this.fetchData()
},
clearInput() {
this.listQuery = {
keywords: '',
staffType: '',
startDate: '',
endDate: '',
offset: 1,
limit: 20
}
this.timeRange = []
this.fetchData()
}
}
}
</script>
<style scoped>
</style>