0109出勤导出
This commit is contained in:
parent
9c3ceb1ca9
commit
fbfc4e7522
|
@ -7,9 +7,9 @@ VUE_APP_TITLE = '曲阳金隅安全智能管控平台'
|
|||
# 接口地址
|
||||
#VUE_APP_API_BASEURL = http://1.203.161.103:2800/api
|
||||
#VUE_APP_WS_API = 'ws://localhost:8000'
|
||||
#VUE_APP_API_BASEURL = http://222.222.144.147:6013/api
|
||||
VUE_APP_API_BASEURL = http://222.222.144.147:6013/api
|
||||
#VUE_APP_API_BASEURL = http://10.99.5.79:20309/api
|
||||
VUE_APP_API_BASEURL = http://127.0.0.1:8001/api
|
||||
#VUE_APP_API_BASEURL = http://127.0.0.1:8001/api
|
||||
#VUE_APP_BASEURL = http://127.0.0.1:8000
|
||||
|
||||
|
||||
|
|
|
@ -16,21 +16,22 @@
|
|||
"cropperjs": "1.5.12",
|
||||
"crypto-js": "4.1.1",
|
||||
"d3": "^7.6.1",
|
||||
"dagre-d3": "^0.6.4",
|
||||
"dagre-d3": "^0.4.18",
|
||||
"echarts": "5.3.2",
|
||||
"element-plus": "2.2.3",
|
||||
"json-editor-vue3": "^1.0.6",
|
||||
"nprogress": "0.2.0",
|
||||
"qrcodejs2": "0.0.2",
|
||||
"sortablejs": "1.15.0",
|
||||
"tinymce": "6.0.3",
|
||||
"tinymce": "^6.3.1",
|
||||
"vue": "3.2.36",
|
||||
"vue-i18n": "9.1.10",
|
||||
"vue-router": "4.0.15",
|
||||
"vuedraggable": "4.0.3",
|
||||
"vuex": "4.0.2",
|
||||
"xgplayer": "2.31.6",
|
||||
"xgplayer-hls": "2.5.2"
|
||||
"xgplayer-hls": "2.5.2",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.18.2",
|
||||
|
|
|
@ -2,8 +2,16 @@
|
|||
<el-container>
|
||||
<el-header>
|
||||
<div class="left-panel">
|
||||
<el-cascader v-model="query.employee__belong_dept" :options="deptData" clearable placeholder="部门/单位" @change="handleQuery" :show-all-levels="false" :props="{emitPath:false,checkStrictly: true}"/>
|
||||
<el-date-picker
|
||||
<el-cascader
|
||||
v-model="query.employee__belong_dept"
|
||||
ref="belongDept"
|
||||
:options="deptData" clearable
|
||||
placeholder="部门/单位"
|
||||
@change="handleQuery"
|
||||
:show-all-levels="false"
|
||||
:props="{emitPath:false,checkStrictly: true}"
|
||||
/>
|
||||
<el-date-picker
|
||||
v-model="monthV"
|
||||
type="month"
|
||||
style="margin-left:4px"
|
||||
|
@ -28,7 +36,7 @@
|
|||
type="primary"
|
||||
:loading = 'dLoading'
|
||||
icon="el-icon-download"
|
||||
@click="exportExcel"
|
||||
@click="exportList"
|
||||
></el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -38,9 +46,7 @@
|
|||
ref="table"
|
||||
:apiObj="apiObj"
|
||||
row-key="id"
|
||||
|
||||
stripe
|
||||
|
||||
>
|
||||
<el-table-column label="人员类型" prop="employee">
|
||||
<template #default="scope">
|
||||
|
@ -82,7 +88,9 @@
|
|||
</el-container>
|
||||
</template>
|
||||
<script>
|
||||
import * as XLSX2 from "xlsx";
|
||||
import { genTree } from "@/utils/verificate";
|
||||
import { fill } from "lodash";
|
||||
export default {
|
||||
name: "clock_record",
|
||||
components: {},
|
||||
|
@ -90,8 +98,10 @@ export default {
|
|||
return {
|
||||
apiObj: this.$API.hrm.clock_record.list,
|
||||
deptData: [],
|
||||
tableData:[],
|
||||
monthV: null,
|
||||
query: {},
|
||||
userList:[],
|
||||
selection: [],
|
||||
type_:{
|
||||
10: {"label": "上班打卡", "color": ""},
|
||||
|
@ -105,6 +115,9 @@ export default {
|
|||
"door": "门禁",
|
||||
"location": "定位"
|
||||
},
|
||||
excelName:'',
|
||||
weekList : ['姓名','星期'],
|
||||
daysList:['姓名','日期'],
|
||||
dLoading: false,
|
||||
};
|
||||
},
|
||||
|
@ -124,6 +137,10 @@ export default {
|
|||
this.query.year = null;
|
||||
this.query.month = null;
|
||||
}
|
||||
if(this.query.employee__belong_dept){
|
||||
let getCheckedNodes = this.$refs['belongDept'].getCheckedNodes()[0].data;
|
||||
this.excelName = getCheckedNodes.name;
|
||||
}
|
||||
this.$refs.table.queryData(this.query)
|
||||
},
|
||||
exportExcel(){
|
||||
|
@ -141,7 +158,119 @@ export default {
|
|||
window.open(res.path, "_blank");
|
||||
this.dLoading = false;
|
||||
}).catch(e=>{this.dLoading = false;})
|
||||
}
|
||||
},
|
||||
//循环调用的接口
|
||||
getOneData(id){
|
||||
let that = this;
|
||||
return new Promise((resolve,reject)=>{
|
||||
that.$API.hrm.clock_record.list.req({page:1,page_size:400,year:that.query.year,month:that.query.month,employee:id})
|
||||
.then(res=>{
|
||||
resolve(res.results)
|
||||
})
|
||||
})
|
||||
},
|
||||
exportList(){
|
||||
let that = this;
|
||||
let days = new Date(this.query.year, this.query.month , 0).getDate();
|
||||
let weekList = ['姓名','星期'],daysList=['姓名','日期'],titleData = [];
|
||||
for(var i = 1;i<= days;i++){
|
||||
let weekNum = new Date(this.query.year,this.query.month,i).getDay();
|
||||
let week=that.getDayWeek(weekNum)
|
||||
daysList.push(i);
|
||||
weekList.push(week);
|
||||
}
|
||||
let chartName = this.excelName+that.query.year+'年'+that.query.month+'月考勤统计表';
|
||||
titleData.push(chartName)
|
||||
let tableData = [];
|
||||
tableData.push(titleData)
|
||||
tableData.push(weekList)
|
||||
tableData.push(daysList)
|
||||
that.$API.hrm.employee.list.req({page:1,page_size:999,belong_dept:that.query.employee__belong_dept})
|
||||
.then(res=>{
|
||||
let promiseList = [];
|
||||
let rowData1 = [],rowData2=[];
|
||||
that.userList=res.results;
|
||||
that.userList.forEach ((item)=> {
|
||||
promiseList.push(that.getOneData(item.id))
|
||||
})
|
||||
Promise.all(promiseList).then(res=> {
|
||||
debugger;
|
||||
console.log(res)
|
||||
that.userList.forEach ((item,index)=> {
|
||||
let recordList = res[index];
|
||||
rowData1 = [
|
||||
item.name,
|
||||
'上班打卡',
|
||||
]
|
||||
rowData2 = [
|
||||
item.name,
|
||||
'下班打卡',
|
||||
]
|
||||
recordList.forEach(recordItem=>{
|
||||
let dateInd = new Date(recordItem.update_time).getDate();
|
||||
let dateIndex = parseInt(dateInd);
|
||||
if(recordItem.type==10){
|
||||
rowData1[dateIndex+1] = '√';
|
||||
}else{
|
||||
rowData2[dateIndex+1] = '√';
|
||||
}
|
||||
})
|
||||
tableData.push(rowData1);
|
||||
tableData.push(rowData2);
|
||||
})
|
||||
let ws = XLSX2.utils.aoa_to_sheet(tableData);
|
||||
let wb = XLSX2.utils.book_new();
|
||||
//字体样式
|
||||
const font = {
|
||||
name: '宋体',
|
||||
sz: 12,
|
||||
bold: true,
|
||||
color: { rgb: '00000000' },
|
||||
}
|
||||
//设置文字居中
|
||||
const alignment = {
|
||||
horizontal: 'center',
|
||||
vertical: 'center',
|
||||
}
|
||||
// ws['A0'].s = {
|
||||
// font,
|
||||
// alignment,
|
||||
// }
|
||||
// s 意为 start ,即开始的单元格//r 是 row ,表示行号,从 0 计起//c 是 col ,表示列号,从 0 计起
|
||||
let cNumber = daysList.length-1;
|
||||
let merge = [{ s: { r: 0, c: 0 }, e: { r: 0, c:cNumber } }];//{ s: { r: 0, c: 0 }, e: { r: 1, c: 0 } },
|
||||
for(let i = 1;i<tableData.length;i++){
|
||||
merge.push({ s: { r: i, c: 0 }, e: { r: i+1, c: 0 } })
|
||||
i++
|
||||
}
|
||||
ws['!merges'] = merge;
|
||||
let closList = new Array(31).fill({wch: 2 });
|
||||
closList.unshift({wch:8})
|
||||
closList.unshift({wch:15})
|
||||
ws['!cols'] = closList;
|
||||
XLSX2.utils.book_append_sheet(wb, ws, chartName); // 工作簿名称
|
||||
XLSX2.writeFile(wb, chartName+'.xlsx'); // 保存的文件名
|
||||
});
|
||||
})
|
||||
},
|
||||
getDayWeek(day){
|
||||
switch(day){
|
||||
case 0:
|
||||
return '日';
|
||||
case 1:
|
||||
return '一';
|
||||
case 2:
|
||||
return '二';
|
||||
case 3:
|
||||
return '三';
|
||||
case 4:
|
||||
return '四';
|
||||
case 5:
|
||||
return '五';
|
||||
case 6:
|
||||
return '六';
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue