导出页部门筛选更改

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

View File

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