jhprjv2/ruoyi-ui/src/views/project/unitpay/index.vue

159 lines
5.2 KiB
Vue
Raw Normal View History

2024-11-10 23:48:52 +08:00
<template>
<div class="app-container">
2024-11-14 00:25:32 +08:00
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="项目名称" prop="projectId">
<el-select v-model="queryParams.projectId" filterable placeholder="请选择项目" @change="doQuerySub">
<el-option v-for="(item, index) in projectOptions" :key="index" :label="item.projectName" :value="item.id">
</el-option>
</el-select>
2024-11-10 23:48:52 +08:00
</el-form-item>
2024-11-14 00:25:32 +08:00
<el-form-item label="总包单位" prop="subDeptId">
<el-select v-model="queryParams.subDeptId" filterable placeholder="请选择总包单位" clearable>
<el-option v-for="(item, index) in depts" :key="index" :label="item.deptName" :value="item.deptId">
</el-option>
</el-select>
2024-11-10 23:48:52 +08:00
</el-form-item>
2024-11-14 00:25:32 +08:00
<el-form-item label="日期" prop="subDeptId" v-if="activeName == 'day'">
<el-date-picker v-model="queryParams.attendanceDay" style="margin:0px 10px;" type="date" placeholder="选择日期"
@change="handleQuery">
</el-date-picker>
2024-11-10 23:48:52 +08:00
</el-form-item>
2024-11-14 00:25:32 +08:00
<el-form-item label="月份" prop="subDeptId" v-if="activeName == 'month'">
<el-date-picker v-model="queryParams.attendanceMonth" style="margin:0px 10px;" type="month" placeholder="请选择月份"
@change="handleQuery">
</el-date-picker>
2024-11-10 23:48:52 +08:00
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
2024-11-14 00:25:32 +08:00
<el-button type="success" v-if="total>0" @click="doExport"></el-button>
2024-11-10 23:48:52 +08:00
</el-form-item>
</el-form>
2024-11-14 00:25:32 +08:00
<el-tabs type="card" v-model="activeName" @tab-click="doTabClick">
<el-tab-pane label="日工资列表" name="day">
<DayPay ref="day" @update="dataChange" :getPrjInfo="getPrjInfo" type="index" v-if="activeName == 'day'"></DayPay>
</el-tab-pane>
<el-tab-pane label="月工资列表" name="month">
<MonthPay ref="month" @update="dataChange" :getPrjInfo="getPrjInfo" type="index" v-if="activeName == 'month'"></MonthPay>
</el-tab-pane>
</el-tabs>
2024-11-10 23:48:52 +08:00
</div>
</template>
<script>
2024-11-14 00:25:32 +08:00
import DayPay from './dayPay.vue'
import MonthPay from './monthPay.vue'
2024-11-10 23:48:52 +08:00
export default {
2024-11-14 00:25:32 +08:00
components:{
DayPay,MonthPay
},
2024-11-10 23:48:52 +08:00
name: "Unitpay",
data() {
return {
// 遮罩层
loading: true,
2024-11-14 00:25:32 +08:00
activeName: 'day',
2024-11-10 23:48:52 +08:00
// 查询参数
queryParams: {
2024-11-14 00:25:32 +08:00
projectId: null,
subDeptId: null,
attendanceDay:new Date(),
attendanceMonth:new Date(),
2024-11-10 23:48:52 +08:00
},
// 表单校验
2024-11-14 00:25:32 +08:00
projectOptions: [],
depts: [],
total:0,
2024-11-10 23:48:52 +08:00
};
},
created() {
2024-11-14 00:25:32 +08:00
this.init();
2024-11-10 23:48:52 +08:00
},
methods: {
2024-11-14 00:25:32 +08:00
dataChange(total){
this.total=total;
2024-11-10 23:48:52 +08:00
},
2024-11-14 00:25:32 +08:00
getPrjInfo(){
return {
projectId:this.queryParams.projectId,
deptId:this.queryParams.subDeptId,
attendanceTime:this.activeName=="day"?this.queryParams.attendanceDay:this.queryParams.attendanceMonth
}
2024-11-10 23:48:52 +08:00
},
2024-11-14 00:25:32 +08:00
doQuerySub() {
let prjId = this.queryParams.projectId;
let tmps = this.prjDept2 && this.prjDept2[prjId] ? this.prjDept2[prjId] || [] : [];
if (tmps.length > 0 || !prjId) {
this.depts = tmps;
if (tmps.length == 1) {
this.queryParams.subDeptId = tmps[0].deptId;
} else {
this.queryParams.subDeptId = '';
}
return;
}
this.$api.publics.queryUnitList({
projectId: prjId,
unitTypes: "2".split(","),
}).then((d) => {
let objs = d.rows || [];
if (!this.prjDept2) {
this.prjDept2 = {};
}
this.prjDept2[prjId] = objs;
this.depts = objs;
if (objs.length == 1) {
this.queryParams.subDeptId = objs[0].deptId;
} else {
this.queryParams.subDeptId = '';
}
2024-11-10 23:48:52 +08:00
});
},
2024-11-14 00:25:32 +08:00
init() {
if (this.projectOptions && this.projectOptions.length > 0) {
return;
}
this.$api.publics.getMyProjectList({}).then((response) => {
this.projectOptions = response.rows || [];
if (this.projectOptions.length > 0) {
this.queryParams.projectId = this.projectOptions[0].id;
this.doQuerySub();
2024-11-10 23:48:52 +08:00
}
});
},
2024-11-14 00:25:32 +08:00
handleQuery() {
if(this.activeName=='day'){
this.$refs.day.doQuery();
}else{
this.$refs.month.doQuery();
}
},
doTabClick(){
setTimeout(this.handleQuery,1000);
2024-11-10 23:48:52 +08:00
},
2024-11-14 00:25:32 +08:00
doExport(){
let postData=this.getPrjInfo();
let tmps=this.projectOptions.filter(d=>d.id==this.queryParams.projectId);
let name=tmps.length>0?tmps[0].projectName:"";
if(this.queryParams.subDeptId){
tmps=this.depts.filter(d=>d.deptId==this.queryParams.subDeptId);
if(tmps.length>0){
name+="_"+tmps[0].deptName;
}
}
name+="_"+this.$dt(postData.attendanceTime).format(this.activeName=="day"?"YYYY年MM月DD日":"YYYY年MM月");
name+=`_[${new Date().getTime()}].xlsx`
postData.attendanceTime=this.$dt(postData.attendanceTime).format("YYYY-MM-DD");
let url=this.activeName=="day"?"project/unitpay/exportDay":"project/unitpay/exportMonth";
this.download(
url,
{
...postData,
},
name
);
2024-11-10 23:48:52 +08:00
}
}
};
</script>