导出页部门筛选更改

This commit is contained in:
shijing 2023-03-08 12:17:48 +08:00
parent cb4854d0f5
commit f674e8e3e8
2 changed files with 213 additions and 152 deletions

View File

@ -6,10 +6,10 @@
v-model="query.employee__belong_dept" v-model="query.employee__belong_dept"
ref="belongDept" ref="belongDept"
:options="deptData" clearable :options="deptData" clearable
placeholder="部门/单位" placeholder="相关方"
@change="handleQuery" @change="handleQuery"
:show-all-levels="false" :show-all-levels="false"
:props="{emitPath:false,checkStrictly: true}" :props="{emitPath:false}"
/> />
<el-date-picker <el-date-picker
v-model="monthV" v-model="monthV"
@ -32,12 +32,18 @@
icon="el-icon-search" icon="el-icon-search"
@click="handleQuery" @click="handleQuery"
></el-button> ></el-button>
<el-button
type="primary"
:loading = 'cLoading'
icon="el-icon-download"
@click="exportExcel"
>下载记录</el-button>
<el-button <el-button
type="primary" type="primary"
:loading = 'dLoading' :loading = 'dLoading'
icon="el-icon-download" icon="el-icon-download"
@click="exportList" @click="exportList"
></el-button> >下载统计</el-button>
</div> </div>
</div> </div>
</el-header> </el-header>
@ -87,11 +93,11 @@
</el-main> </el-main>
</el-container> </el-container>
</template> </template>
<script> <script>
import config from "@/config"
import * as XLSX2 from "xlsx"; import * as XLSX2 from "xlsx";
import { genTree } from "@/utils/verificate"; import { fill } from "lodash";
import { fill } from "lodash"; export default {
export default {
name: "clock_record", name: "clock_record",
components: {}, components: {},
data() { data() {
@ -119,15 +125,19 @@ export default {
weekList : ['姓名','星期'], weekList : ['姓名','星期'],
daysList:['姓名','日期'], daysList:['姓名','日期'],
dLoading: false, dLoading: false,
cLoading:false,
ElLoading:null,
deptSearch:{},
}; };
}, },
mounted() { mounted() {
this.getDept(); this.getDept();
that.ElLoading =null;
}, },
methods: { methods: {
async getDept() { async getDept() {
let res = await this.$API.system.dept.list.req({ page: 0, type__in: 'dept,rparty' }); let res = await this.$API.system.dept.list.req({ page: 0, type__in: 'dept,rparty' });
this.deptData = genTree(res); this.deptData = this.genTree(res);
}, },
handleQuery(){ handleQuery(){
if(this.monthV){ if(this.monthV){
@ -144,20 +154,39 @@ export default {
this.$refs.table.queryData(this.query) this.$refs.table.queryData(this.query)
}, },
exportExcel(){ exportExcel(){
if(this.monthV){ let that = this;
this.query.year = this.monthV.getFullYear(); if(that.query.employee__belong_dept!=undefined &&that.query.employee__belong_dept!=null &&
this.query.month = this.monthV.getMonth() + 1; that.query.year!=undefined &&that.query.year!=null && that.query.month!=undefined&& that.query.month!=null){
}else{ }else{
this.query.year = null; that.$message.warning("请选择部门和月份后导出")
this.query.month = null; that.cLoading = false;
return;
} }
this.dLoading = true; if(that.monthV){
this.$API.hrm.clock_record.export_excel that.query.year = that.monthV.getFullYear();
.req(this.query) that.query.month = that.monthV.getMonth() + 1;
}else{
that.query.year = null;
that.query.month = null;
}
that.cLoading = true;
that.ElLoading = this.$loading({
lock: true,
text: '数据请求中,请稍后...',
background: 'rgba(0, 0, 0, 0)',
})
that.$API.hrm.clock_record.export_excel.req(that.query)
.then(res=>{ .then(res=>{
window.open(res.path, "_blank"); that.cLoading = false;
this.dLoading = false; that.ElLoading.close();
}).catch(e=>{this.dLoading = false;}) let urls = config.API_URL.slice(0,-4)+res.path;
console.log(urls)
window.open(urls, "_blank");
}).catch(e=>{
that.cLoading = false;
that.ElLoading.close();
})
}, },
// //
getOneData(id){ getOneData(id){
@ -185,7 +214,7 @@ export default {
for(var i = 1;i<= days;i++){ for(var i = 1;i<= days;i++){
let weekNum = new Date(this.query.year+'-'+this.query.month+'-'+i).getDay(); let weekNum = new Date(this.query.year+'-'+this.query.month+'-'+i).getDay();
// debugger; // debugger;
console.log(weekNum) // console.log(weekNum)
let week=that.getDayWeek(weekNum) let week=that.getDayWeek(weekNum)
daysList.push(i); daysList.push(i);
weekList.push(week); weekList.push(week);
@ -196,6 +225,11 @@ export default {
tableData.push(titleData) tableData.push(titleData)
tableData.push(weekList) tableData.push(weekList)
tableData.push(daysList) tableData.push(daysList)
that.ElLoading = this.$loading({
lock: true,
text: '数据请求中,请稍后...',
background: 'rgba(0, 0, 0, 0)',
})
that.$API.hrm.employee.list.req({page:1,page_size:999,belong_dept:that.query.employee__belong_dept}) that.$API.hrm.employee.list.req({page:1,page_size:999,belong_dept:that.query.employee__belong_dept})
.then(res=>{ .then(res=>{
let promiseList = []; let promiseList = [];
@ -205,28 +239,28 @@ export default {
promiseList.push(that.getOneData(item.id)) promiseList.push(that.getOneData(item.id))
}) })
Promise.all(promiseList).then(res=> { Promise.all(promiseList).then(res=> {
that.userList.forEach ((item,index)=> { for(let i=0;i<this.userList.length;i++){
let recordList = res[index]; let recordList = res[i];
rowData1 = [ rowData1 = [
item.name, this.userList[i].name,
'上班打卡', '上班打卡',
] ]
rowData2 = [ rowData2 = [
item.name, this.userList[i].name,
'下班打卡', '下班打卡',
] ]
recordList.forEach(recordItem=>{ for(let j=0;j<recordList.length;j++){
let dateInd = new Date(recordItem.create_time).getDate(); let dateInd = new Date(recordList[j].create_time).getDate();
let dateIndex = parseInt(dateInd); let dateIndex = parseInt(dateInd);
if(recordItem.type==10){ if(recordList[j].type==10){
rowData1[dateIndex+1] = '√'; rowData1[dateIndex+1] = '√';
}else{ }else{
rowData2[dateIndex+1] = '√'; rowData2[dateIndex+1] = '√';
} }
}) }
tableData.push(rowData1); tableData.push(rowData1);
tableData.push(rowData2); tableData.push(rowData2);
}) }
let ws = XLSX2.utils.aoa_to_sheet(tableData); let ws = XLSX2.utils.aoa_to_sheet(tableData);
let wb = XLSX2.utils.book_new(); let wb = XLSX2.utils.book_new();
// //
@ -260,7 +294,11 @@ export default {
XLSX2.utils.book_append_sheet(wb, ws, chartName); // 簿 XLSX2.utils.book_append_sheet(wb, ws, chartName); // 簿
XLSX2.writeFile(wb, chartName+'.xlsx'); // XLSX2.writeFile(wb, chartName+'.xlsx'); //
that.dLoading = false; that.dLoading = false;
that.ElLoading.close();
}); });
}).catch(e=>{
that.dLoading = false;
that.ElLoading.close();
}) })
}, },
getDayWeek(day){ getDayWeek(day){
@ -281,6 +319,28 @@ export default {
return '六'; return '六';
} }
}, },
genTree(data) {
const result = [
{id:'bumen',label:'部门',value:'bumen',children:[]},
{id:'xiangguanfang',label:'相关方',value:'xiangguanfang',children:[]}
]
if (!Array.isArray(data)) {
return result
}
data.forEach(item => {
item.label = item.name
if(item.fullname){
item.label = item.fullname
}
item.value = item.id
if(item.type==='dept'){
result[0].children.push(item)
}else{
result[1].children.push(item)
}
})
return result
}
}, },
}; };
</script> </script>

View File

@ -28,6 +28,7 @@
clearable clearable
show-password show-password
:placeholder="$t('login.PWPlaceholder')" :placeholder="$t('login.PWPlaceholder')"
@keyup.enter="login"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item style="margin-bottom: 10px"> <el-form-item style="margin-bottom: 10px">