优化
This commit is contained in:
@ -82,11 +82,18 @@
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="formalitiesAreConsolidatedList" @selection-change="handleSelectionChange" row-key="id" default-expand-all>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:table-layout="'auto'"
|
||||
:data="formalitiesAreConsolidatedList"
|
||||
@selection-change="handleSelectionChange"
|
||||
row-key="id"
|
||||
default-expand-all
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="手续办理清单" align="left" prop="formalitiesName">
|
||||
<template #default="scope">
|
||||
<div>{{ scope.row.formalitiesName }}</div>
|
||||
{{ scope.row.formalitiesName }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计划开始时间" align="center" prop="planTheStartTime" width="180">
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
<el-button icon="Download" type="warning" @click="onExport">导出</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
@ -234,6 +235,17 @@ const dialog = reactive<DialogOption>({
|
||||
details: false,
|
||||
title: ''
|
||||
});
|
||||
const now = new Date();
|
||||
|
||||
// 获取年份(4位数字)
|
||||
const year = now.getFullYear();
|
||||
|
||||
// 获取月份(注意:getMonth() 返回 0-11,需要 +1 转换为 1-12)
|
||||
const month = now.getMonth() + 1;
|
||||
|
||||
// 格式化月份为两位数(不足两位补0),拼接成年月字符串
|
||||
const currentYearMonth = `${year}-${month.toString().padStart(2, '0')}`;
|
||||
|
||||
const echartsOption = ref<any>({});
|
||||
const initFormData: AttendanceForm = {
|
||||
id: undefined,
|
||||
@ -260,7 +272,7 @@ const data = reactive<PageData<AttendanceForm, AttendanceQuery>>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
userName: undefined,
|
||||
clockDate: undefined,
|
||||
clockDate: currentYearMonth,
|
||||
clockStatus: undefined,
|
||||
commuter: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
@ -454,7 +466,19 @@ const init = () => {
|
||||
handleQuery();
|
||||
});
|
||||
};
|
||||
|
||||
const onExport = () => {
|
||||
try {
|
||||
console.log(queryParams.value.clockDate);
|
||||
proxy?.download(
|
||||
'project/attendance/exportList',
|
||||
{ projectId: currentProject.value?.id, clockDate: queryParams.value.clockDate },
|
||||
`考勤列表_${queryParams.value.clockDate}.xlsx`
|
||||
);
|
||||
} catch (error) {
|
||||
ElMessage.error('导出失败,请重试');
|
||||
console.error('文件导出错误:', error);
|
||||
}
|
||||
};
|
||||
//监听项目id刷新数据
|
||||
const listeningProject = watch(
|
||||
() => currentProject.value?.id,
|
||||
|
||||
102
src/views/project/busSalaryDetails/component/detail.vue
Normal file
102
src/views/project/busSalaryDetails/component/detail.vue
Normal file
@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<!-- 员工工资考核记录详情抽屉 -->
|
||||
<div class="system-busSalaryDetails-detail">
|
||||
<el-drawer v-model="isShowDialog" size="40%" direction="ltr">
|
||||
<template #header>
|
||||
<h4>员工工资考核记录详情</h4>
|
||||
</template>
|
||||
<el-table v-loading="loading" :data="tableData">
|
||||
<el-table-column label="序号" align="center" type="index" width="60" />
|
||||
<el-table-column label="工作日期" align="center" min-width="100px">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.dateOfIssue + '-' + scope.row.working_date }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="工作时长" align="center" prop="duration" min-width="100px" />
|
||||
<el-table-column label="发放年月" align="center" prop="dateOfIssue" min-width="100px" />
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { reactive, toRefs, defineComponent, ref, getCurrentInstance } from 'vue';
|
||||
// import { getByIdDetail } from '@/api/project/busSalaryDetails';
|
||||
import { BusSalaryDetailsEditState } from './model';
|
||||
export default defineComponent({
|
||||
name: 'index',
|
||||
setup(props, { emit }) {
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const formRef = ref<HTMLElement | null>(null);
|
||||
const menuRef = ref();
|
||||
const state = reactive<BusSalaryDetailsEditState>({
|
||||
loading: false,
|
||||
isShowDialog: false,
|
||||
formData: {
|
||||
sfzNumber: undefined,
|
||||
pageNum: 1,
|
||||
pageSize: 50
|
||||
},
|
||||
tableData: [], //考勤数据
|
||||
total: 0 //列表数量
|
||||
});
|
||||
// 打开弹窗
|
||||
const openDialog = (row) => {
|
||||
state.formData.pageNum = 1; //重置
|
||||
state.formData.sfzNumber = row.sfzNumber; //重置
|
||||
state.isShowDialog = true;
|
||||
getList();
|
||||
};
|
||||
// 获取列表
|
||||
const getList = () => {
|
||||
state.loading = true;
|
||||
// getByIdDetail(state.formData).then((res: any) => {
|
||||
// state.loading = false;
|
||||
// if (res.code == 0 && res.data.list) {
|
||||
// state.tableData = res.data.list.reverse();
|
||||
// state.total = res.data.total;
|
||||
// }
|
||||
// });
|
||||
};
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
state.isShowDialog = false;
|
||||
};
|
||||
// 取消
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
return {
|
||||
proxy,
|
||||
openDialog,
|
||||
closeDialog,
|
||||
onCancel,
|
||||
menuRef,
|
||||
getList,
|
||||
formRef,
|
||||
...toRefs(state)
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
.system-busSalaryDetails-detail :deep(.el-form-item--large .el-form-item__label) {
|
||||
font-weight: bolder;
|
||||
}
|
||||
.pic-block {
|
||||
margin-right: 8px;
|
||||
}
|
||||
.file-block {
|
||||
width: 100%;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
transition: var(--el-transition-duration-fast);
|
||||
margin-bottom: 5px;
|
||||
padding: 3px 6px;
|
||||
}
|
||||
.ml-2 {
|
||||
margin-right: 5px;
|
||||
}
|
||||
</style>
|
||||
146
src/views/project/busSalaryDetails/component/edit.vue
Normal file
146
src/views/project/busSalaryDetails/component/edit.vue
Normal file
@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<div class="system-busSalaryDetails-edit">
|
||||
<!-- 添加或修改员工工资考核记录对话框 -->
|
||||
<el-dialog v-model="isShowDialog" width="769px" :close-on-click-modal="false" :destroy-on-close="true">
|
||||
<template #header>
|
||||
<div v-drag="['.system-busSalaryDetails-edit .el-dialog', '.system-busSalaryDetails-edit .el-dialog__header']">
|
||||
{{ (!formData.id || formData.id == 0 ? '添加' : '修改') + '员工工资考核记录' }}
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="90px"> </el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="onSubmit">确 定</el-button>
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { reactive, toRefs, defineComponent, ref, unref, getCurrentInstance } from 'vue';
|
||||
import { ElMessageBox, ElMessage, FormInstance, UploadProps } from 'element-plus';
|
||||
import {
|
||||
listBusSalaryDetails,
|
||||
getBusSalaryDetails,
|
||||
delBusSalaryDetails,
|
||||
addBusSalaryDetails,
|
||||
updateBusSalaryDetails
|
||||
} from '@/api/project/busSalaryDetails';
|
||||
import { BusSalaryDetailsTableColumns, BusSalaryDetailsInfoData, BusSalaryDetailsTableDataState, BusSalaryDetailsEditState } from './model';
|
||||
export default defineComponent({
|
||||
name: 'apiV1SystemBusSalaryDetailsEdit',
|
||||
components: {},
|
||||
props: {},
|
||||
setup(props, { emit }) {
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const formRef = ref<HTMLElement | null>(null);
|
||||
const menuRef = ref();
|
||||
const state = reactive<BusSalaryDetailsEditState>({
|
||||
loading: false,
|
||||
isShowDialog: false,
|
||||
formData: {
|
||||
id: undefined,
|
||||
sfzNumber: undefined,
|
||||
name: undefined,
|
||||
account: undefined,
|
||||
sumDuration: undefined,
|
||||
salary: undefined,
|
||||
projectId: undefined,
|
||||
teamId: undefined,
|
||||
projectName: undefined,
|
||||
teamName: undefined,
|
||||
dateOfIssue: undefined,
|
||||
lister: undefined,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined,
|
||||
deletedAt: undefined
|
||||
},
|
||||
// 表单校验
|
||||
rules: {}
|
||||
});
|
||||
// 打开弹窗
|
||||
const openDialog = (row?: BusSalaryDetailsInfoData) => {
|
||||
resetForm();
|
||||
if (row) {
|
||||
getBusSalaryDetails(row.id!).then((res: any) => {
|
||||
const data = res.data;
|
||||
state.formData = data;
|
||||
});
|
||||
}
|
||||
state.isShowDialog = true;
|
||||
};
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
state.isShowDialog = false;
|
||||
};
|
||||
// 取消
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
const formWrap = unref(formRef) as any;
|
||||
if (!formWrap) return;
|
||||
formWrap.validate((valid: boolean) => {
|
||||
if (valid) {
|
||||
state.loading = true;
|
||||
if (!state.formData.id || state.formData.id === 0) {
|
||||
//添加
|
||||
addBusSalaryDetails(state.formData)
|
||||
.then(() => {
|
||||
ElMessage.success('添加成功');
|
||||
closeDialog(); // 关闭弹窗
|
||||
emit('busSalaryDetailsList');
|
||||
})
|
||||
.finally(() => {
|
||||
state.loading = false;
|
||||
});
|
||||
} else {
|
||||
//修改
|
||||
updateBusSalaryDetails(state.formData)
|
||||
.then(() => {
|
||||
ElMessage.success('修改成功');
|
||||
closeDialog(); // 关闭弹窗
|
||||
emit('busSalaryDetailsList');
|
||||
})
|
||||
.finally(() => {
|
||||
state.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const resetForm = () => {
|
||||
state.formData = {
|
||||
id: undefined,
|
||||
sfzNumber: undefined,
|
||||
name: undefined,
|
||||
account: undefined,
|
||||
sumDuration: undefined,
|
||||
salary: undefined,
|
||||
projectId: undefined,
|
||||
teamId: undefined,
|
||||
projectName: undefined,
|
||||
teamName: undefined,
|
||||
dateOfIssue: undefined,
|
||||
lister: undefined,
|
||||
createdAt: undefined,
|
||||
updatedAt: undefined,
|
||||
deletedAt: undefined
|
||||
};
|
||||
};
|
||||
return {
|
||||
proxy,
|
||||
openDialog,
|
||||
closeDialog,
|
||||
onCancel,
|
||||
onSubmit,
|
||||
menuRef,
|
||||
formRef,
|
||||
...toRefs(state)
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style scoped></style>
|
||||
57
src/views/project/busSalaryDetails/component/model.ts
Normal file
57
src/views/project/busSalaryDetails/component/model.ts
Normal file
@ -0,0 +1,57 @@
|
||||
export interface BusSalaryDetailsTableColumns {
|
||||
id:number
|
||||
sfzNumber:string; // 身份证
|
||||
name:string; // 户名
|
||||
account:string; // 账户
|
||||
sumDuration:number; // 当月总时长
|
||||
salary:number; // 薪水(天)
|
||||
dateOfIssue:string; // 发放年月
|
||||
lister:string; // 制表人
|
||||
createdAt:string; // 创建时间
|
||||
}
|
||||
|
||||
|
||||
export interface BusSalaryDetailsInfoData {
|
||||
id:number|undefined; // 主键ID
|
||||
sfzNumber:string|undefined; // 身份证
|
||||
name:string|undefined; // 户名
|
||||
account:string|undefined; // 账户
|
||||
sumDuration:number|undefined; // 当月总时长
|
||||
salary:number|undefined; // 薪水(天)
|
||||
projectId:number|undefined; // 项目id
|
||||
teamId:number|undefined; // 班组id
|
||||
projectName:string|undefined; // 项目名称
|
||||
teamName:string|undefined; // 班组名称
|
||||
dateOfIssue:string|undefined; // 发放年月
|
||||
lister:string|undefined; // 制表人
|
||||
createdAt:string|undefined; // 创建时间
|
||||
updatedAt:string|undefined; // 更新时间
|
||||
deletedAt:string|undefined; // 删除时间
|
||||
}
|
||||
|
||||
|
||||
export interface BusSalaryDetailsTableDataState {
|
||||
ids:any[];
|
||||
tableData: {
|
||||
data: Array<BusSalaryDetailsTableColumns>;
|
||||
total: number;
|
||||
loading: boolean;
|
||||
param: {
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
id: number|undefined;
|
||||
sfzNumber: string|undefined;
|
||||
projectId: number|undefined;
|
||||
teamId: number|undefined;
|
||||
dateRange: string[];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export interface BusSalaryDetailsEditState{
|
||||
loading:boolean;
|
||||
isShowDialog: boolean;
|
||||
formData:BusSalaryDetailsInfoData;
|
||||
rules: object;
|
||||
}
|
||||
563
src/views/project/busSalaryDetails/index.vue
Normal file
563
src/views/project/busSalaryDetails/index.vue
Normal file
@ -0,0 +1,563 @@
|
||||
<template>
|
||||
<div class="system-busSalaryDetails-container">
|
||||
<el-card shadow="hover">
|
||||
<div class="system-busSalaryDetails-search mb15">
|
||||
<el-form :model="tableData.param" ref="queryRef" :inline="true" label-width="100px">
|
||||
<el-form-item label="身份证" prop="sfzNumber">
|
||||
<el-input v-model="tableData.param.sfzNumber" placeholder="请输入身份证" clearable @keyup.enter.native="busSalaryDetailsList" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目选择" prop="projectId">
|
||||
<el-select v-model="tableData.param.projectId" placeholder="请选择项目" @change="onChangeProject">
|
||||
<el-option v-for="(item, i) of projectList" :key="i" :label="item.shortName" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="班组选择" prop="teamId">
|
||||
<el-select v-model="tableData.param.teamId" @change="onChangeTeam" :disabled="!tableData.param.projectId" placeholder="请选择班组">
|
||||
<el-option v-for="(item, i) of TeamList" :key="i" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发放年月" prop="dateOfIssue">
|
||||
<el-date-picker
|
||||
v-model="tableData.param.dateOfIssue"
|
||||
@change="onChangeOfIssue"
|
||||
value-format="YYYY-MM"
|
||||
type="month"
|
||||
placeholder="选择月份"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="busSalaryDetailsList"
|
||||
><el-icon><Search /></el-icon>搜索</el-button
|
||||
>
|
||||
<el-button @click="resetQuery(queryRef)"
|
||||
><el-icon><Refresh /></el-icon>重置</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
<el-button type="danger" :disabled="multiple" @click="handleDelete(null)" v-auth="'api/v1/system/busSalaryDetails/delete'"
|
||||
><el-icon><Delete /></el-icon>批量删除</el-button
|
||||
>
|
||||
<!-- <el-col :span="2">
|
||||
<span>
|
||||
<label for="file" class="input-button" title="选择您的excel表格进行上传">导入考勤表格</label>
|
||||
<input type="file" id="file" placeholder="选择文件2" />
|
||||
</span>
|
||||
</el-col> -->
|
||||
<el-button type="success" @click="exportSalary(null)"
|
||||
><el-icon><Download /></el-icon>导出员工工资表</el-button
|
||||
>
|
||||
</el-form>
|
||||
</div>
|
||||
<el-table v-loading="loading" border height="72vh" :data="tableData.data" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" min-width="50px" />
|
||||
<el-table-column label="身份证" align="center" prop="sfzNumber" min-width="120px" />
|
||||
<el-table-column label="户名" align="center" prop="name" min-width="100px" />
|
||||
<el-table-column label="账户" align="center" prop="account" min-width="100px" />
|
||||
<el-table-column label="当月总天数" align="center" prop="sumDuration" min-width="100px" />
|
||||
<el-table-column label="薪水(天)" align="center" prop="salary" min-width="100px" />
|
||||
<el-table-column label="发放年月" align="center" prop="dateOfIssue" min-width="100px" />
|
||||
<el-table-column label="总额(元)" align="center" prop="" min-width="100px">
|
||||
<template #default="scope">
|
||||
<span>{{ (Number(scope.row.sumDuration) * Number(scope.row.salary)).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="上传时间" align="center" prop="createdAt" min-width="100px">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.createdAt }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding" min-width="200px" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" link @click="handleView(scope.row)" v-auth="'api/v1/system/busSalaryDetails/view'"
|
||||
><el-icon><View /></el-icon>详情</el-button
|
||||
>
|
||||
<el-button type="success" link @click="exportSalary(scope.row)"
|
||||
><el-icon><Download /></el-icon>导出工资表</el-button
|
||||
>
|
||||
<el-button type="danger" link @click="handleDelete(scope.row)" v-auth="'api/v1/system/busSalaryDetails/delete'"
|
||||
><el-icon><DeleteFilled /></el-icon>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="tableData.total > 0"
|
||||
:total="tableData.total"
|
||||
v-model:page="tableData.param.pageNum"
|
||||
v-model:limit="tableData.param.pageSize"
|
||||
@pagination="busSalaryDetailsList"
|
||||
/>
|
||||
</el-card>
|
||||
<apiV1SystemBusSalaryDetailsDetail ref="detailRef" @busSalaryDetailsList="busSalaryDetailsList"></apiV1SystemBusSalaryDetailsDetail>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { toRefs, reactive, onMounted, ref, defineComponent, computed, getCurrentInstance, toRaw } from 'vue';
|
||||
import { ElMessageBox, ElMessage, FormInstance, ElLoading } from 'element-plus';
|
||||
// import { listBusSalaryDetails, delBusSalaryDetails, addBusSalaryDetails, salarySheet } from '@/api/project/busSalaryDetails';
|
||||
import { BusSalaryDetailsTableColumns, BusSalaryDetailsTableDataState } from './component/model';
|
||||
import apiV1SystemBusSalaryDetailsDetail from './component/detail.vue';
|
||||
import * as xlsx from 'xlsx';
|
||||
|
||||
// import { exportDataToExcel } from '@/utils/exportDataToExcel.js';
|
||||
import { useUserStoreHook } from '@/store/modules/user';
|
||||
import { listProjectTeam } from '@/api/project/projectTeam';
|
||||
// import { listProject, listProjectGo } from '@/api/project/project';
|
||||
export default defineComponent({
|
||||
name: 'index',
|
||||
components: {
|
||||
apiV1SystemBusSalaryDetailsDetail
|
||||
},
|
||||
setup() {
|
||||
const stores = useUserStoreHook();
|
||||
const { proxy } = <any>getCurrentInstance();
|
||||
const loading = ref(false);
|
||||
const queryRef = ref();
|
||||
const detailRef = ref();
|
||||
// 是否显示所有搜索选项
|
||||
const showAll = ref(false);
|
||||
// 非单个禁用
|
||||
const single = ref(true);
|
||||
// 非多个禁用
|
||||
const multiple = ref(true);
|
||||
const word = computed(() => {
|
||||
if (showAll.value === false) {
|
||||
//对文字进行处理
|
||||
return '展开搜索';
|
||||
} else {
|
||||
return '收起搜索';
|
||||
}
|
||||
});
|
||||
// 字典选项数据
|
||||
const {} = proxy.useDict();
|
||||
const state = reactive<BusSalaryDetailsTableDataState>({
|
||||
ids: [],
|
||||
projectList: [], //项目列表
|
||||
projectListMap: new Map(),
|
||||
TeamList: [], //班组列表
|
||||
TeamListMap: new Map(), //班组列表
|
||||
tableData: {
|
||||
data: [],
|
||||
total: 0,
|
||||
loading: false,
|
||||
param: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
sfzNumber: undefined,
|
||||
projectId: stores.selectedProject.goId,
|
||||
teamId: undefined,
|
||||
dateRange: [],
|
||||
dateOfIssue: proxy.parseTime(new Date(), '{y}-{m}') //默认当前工作年月
|
||||
}
|
||||
}
|
||||
});
|
||||
// 页面加载时
|
||||
onMounted(() => {
|
||||
initTableData();
|
||||
sysProjectList();
|
||||
document.querySelector('#file').addEventListener('change', function () {
|
||||
//获取到选中的文件
|
||||
var file = document.querySelector('#file').files[0];
|
||||
onChange(file);
|
||||
});
|
||||
sysListSysProjectTeam(state.tableData.param.projectId); //默认项目
|
||||
});
|
||||
const onChangeProject = (val) => {
|
||||
sysListSysProjectTeam(val);
|
||||
// 切换项目后 班组默认未空
|
||||
state.tableData.param.teamId = '';
|
||||
// 获取数据
|
||||
busSalaryDetailsList();
|
||||
};
|
||||
// 班组切换
|
||||
const onChangeTeam = (val) => {
|
||||
busSalaryDetailsList();
|
||||
};
|
||||
const onChangeOfIssue = () => {
|
||||
busSalaryDetailsList();
|
||||
};
|
||||
// 获取项目列表数据
|
||||
const sysProjectList = () => {
|
||||
// listProjectGo({ pageNum: 1, pageSize: 1000 }).then((res: any) => {
|
||||
// let list = res.data.list ?? [];
|
||||
// if (list.length) {
|
||||
// state.projectList = list;
|
||||
// list.forEach((item) => {
|
||||
// state.projectListMap.set(item.id, item.shortName);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
};
|
||||
// 获取班组列表
|
||||
const sysListSysProjectTeam = (projectId) => {
|
||||
// listProjectTeam({ pageNum: 1, pageSize: 1000, projectId }).then((res: any) => {
|
||||
// let list = res.data.list ?? [];
|
||||
// if (list.length) {
|
||||
// state.TeamList = list;
|
||||
// list.forEach((item) => {
|
||||
// state.TeamListMap.set(item.id, item.name);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
};
|
||||
const onChange = async (file) => {
|
||||
/**
|
||||
* 1. 使用原生api去读取好的文件
|
||||
* */
|
||||
// console.log("原始上传的文件", file);
|
||||
// 读取文件不是立马能够读取到的,所以是异步的,使用Promise
|
||||
let dataBinary = await new Promise((resolve) => {
|
||||
// Web API构造函数FileReader,可实例化对象,去调用其身上方法,去读取解析文件信息
|
||||
let reader = new FileReader(); // https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader
|
||||
// console.log("实例化对象有各种方法", reader);
|
||||
reader.readAsBinaryString(file); // 读取raw的File文件
|
||||
reader.onload = (ev) => {
|
||||
// console.log("文件解析流程进度事件", ev);
|
||||
resolve(ev.target.result); // 将解析好的结果扔出去,以供使用
|
||||
};
|
||||
});
|
||||
// console.log("读取出的流文件", dataBinary);
|
||||
/**
|
||||
* 2. 使用xlsx插件去解析已经读取好的二进制excel流文件
|
||||
* */
|
||||
let workBook = xlsx.read(dataBinary, { type: 'binary', cellDates: true });
|
||||
// excel中有很多的sheet,这里取了第一个sheet:workBook.SheetNames[0]
|
||||
let arr = [];
|
||||
workBook.SheetNames.forEach((item) => {
|
||||
let firstWorkSheet = workBook.Sheets[item];
|
||||
const data = xlsx.utils.sheet_to_json(firstWorkSheet);
|
||||
arr.push(data);
|
||||
});
|
||||
let dataList = []; //需提交数据
|
||||
arr.forEach((item, i) => {
|
||||
//截取数据
|
||||
// 获取制表人
|
||||
let detailObj = {};
|
||||
let lister = ''; //制表人 单独读取
|
||||
let listerObj = item[item.length - 3];
|
||||
let year = 0; //年
|
||||
let month = 0; //月
|
||||
for (let key in listerObj) {
|
||||
if (key.indexOf('建筑施工') != -1) {
|
||||
//是否包含
|
||||
lister = listerObj[key].substring(4).trim();
|
||||
// 获取年月
|
||||
let index = key.indexOf('年');
|
||||
let index1 = key.indexOf('(');
|
||||
month = parseInt(key.substring(index + 1, index + 10));
|
||||
year = parseInt(key.substring(index1 + 1, index));
|
||||
}
|
||||
}
|
||||
// 获取人员信息
|
||||
let arr1 = item.slice(2, -3);
|
||||
month = month < 10 ? '0' + month : month;
|
||||
if (arr1.length) {
|
||||
arr1.forEach((item) => {
|
||||
let dates = []; //用户信息
|
||||
let name = item.__EMPTY; //用户名
|
||||
let sfzNumber = item.__EMPTY_1; //身份证
|
||||
let sumDuration = 0; //工作总时长
|
||||
let dateOfIssue = year + '-' + month; //发放年月
|
||||
let days = new Date(year, month, 0).getDate();
|
||||
for (let key in item) {
|
||||
let ind = key.split('_')[3];
|
||||
if (ind > 1 && ind <= days + 1) {
|
||||
//后面数据
|
||||
let working_date = ind - 1 < 10 ? '0' + (ind - 1) : ind - 1;
|
||||
let obj = { working_date: working_date.toString(), duration: item[key] };
|
||||
dates.push(obj);
|
||||
sumDuration += item[key];
|
||||
}
|
||||
}
|
||||
detailObj = {
|
||||
//用户
|
||||
lister,
|
||||
dates,
|
||||
name,
|
||||
sfzNumber,
|
||||
dateOfIssue,
|
||||
sumDuration
|
||||
};
|
||||
dataList.push(detailObj);
|
||||
});
|
||||
}
|
||||
});
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '正在上传中……',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
if (dataList.length) {
|
||||
// addBusSalaryDetails({ dataList }).then((res: any) => {
|
||||
// loading.close();
|
||||
// if (res.code == 0) {
|
||||
// ElMessage.success('上传成功');
|
||||
// busSalaryDetailsList();
|
||||
// } else {
|
||||
// ElMessage.error(res.message);
|
||||
// }
|
||||
// });
|
||||
} else {
|
||||
ElMessage.warning('表格数据为空');
|
||||
}
|
||||
event.target.value = '';
|
||||
};
|
||||
// 初始化表格数据
|
||||
const initTableData = () => {
|
||||
busSalaryDetailsList();
|
||||
};
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
busSalaryDetailsList();
|
||||
};
|
||||
// 获取列表数据
|
||||
const busSalaryDetailsList = () => {
|
||||
loading.value = true;
|
||||
// listBusSalaryDetails(state.tableData.param).then((res: any) => {
|
||||
// let list = res.data.list ?? [];
|
||||
// state.tableData.data = list;
|
||||
// state.tableData.total = res.data.total;
|
||||
// loading.value = false;
|
||||
// });
|
||||
};
|
||||
const toggleSearch = () => {
|
||||
showAll.value = !showAll.value;
|
||||
};
|
||||
const handleDelete = (row: BusSalaryDetailsTableColumns) => {
|
||||
let msg = '你确定要删除所选数据?';
|
||||
let id: number[] = [];
|
||||
if (row) {
|
||||
msg = `此操作将永久删除数据,是否继续?`;
|
||||
id = [row.id];
|
||||
} else {
|
||||
id = state.ids;
|
||||
}
|
||||
if (id.length === 0) {
|
||||
ElMessage.error('请选择要删除的数据。');
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm(msg, '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
// delBusSalaryDetails(id).then(() => {
|
||||
// ElMessage.success('删除成功');
|
||||
// busSalaryDetailsList();
|
||||
// });
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
const handleView = (row: BusSalaryDetailsTableColumns) => {
|
||||
detailRef.value.openDialog(toRaw(row));
|
||||
};
|
||||
const exportSalary = (row) => {
|
||||
// 导出工资表
|
||||
let obj = {};
|
||||
let fileName = '';
|
||||
let year = '';
|
||||
let month = '';
|
||||
let porjectName = '';
|
||||
if (row) {
|
||||
//个人
|
||||
obj = {
|
||||
project: state.tableData.param.projectId, //项目id
|
||||
dateOfIssue: row.dateOfIssue, //工作年月
|
||||
team: '', //班组id
|
||||
sfzNumber: row.sfzNumber //施工人员身份证
|
||||
};
|
||||
year = obj.dateOfIssue.split('-')[0];
|
||||
month = obj.dateOfIssue.split('-')[1];
|
||||
fileName = row.name + '-' + year + '年' + month + '月工资表.xlsx';
|
||||
} else {
|
||||
// 导出工资表
|
||||
obj = {
|
||||
project: state.tableData.param.projectId,
|
||||
dateOfIssue: state.tableData.param.dateOfIssue,
|
||||
team: state.tableData.param.teamId,
|
||||
sfzNumber: '' //施工人员身份证
|
||||
};
|
||||
porjectName = state.projectListMap.get(state.tableData.param.projectId);
|
||||
year = obj.dateOfIssue.split('-')[0];
|
||||
month = obj.dateOfIssue.split('-')[1];
|
||||
if (state.tableData.param.teamId) {
|
||||
let TeamName = state.TeamListMap.get(state.tableData.param.teamId);
|
||||
fileName = porjectName + '-' + TeamName + '-' + year + '年' + month + '月员工工资表.xlsx';
|
||||
} else {
|
||||
fileName = porjectName + '-' + year + '年' + month + '月员工工资表.xlsx';
|
||||
}
|
||||
}
|
||||
let time = year + '年' + month + '月';
|
||||
getSalarySheet(obj, fileName, time);
|
||||
};
|
||||
const getSalarySheet = (obj, fileName, time) => {
|
||||
salarySheet(obj).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
// 先根据
|
||||
let array = setTeamList(res.data.list);
|
||||
// 设置项目名称及班组
|
||||
let excelList = [];
|
||||
array.forEach((item) => {
|
||||
let obj = item[0];
|
||||
let excelName = obj.teamName; //班组
|
||||
if (!obj.teamName) {
|
||||
excelName = '暂未分组人员';
|
||||
}
|
||||
let config = exportConfig(item, excelName, time);
|
||||
excelList.push(config);
|
||||
});
|
||||
exportDataToExcel(excelList, fileName);
|
||||
}
|
||||
});
|
||||
};
|
||||
// 把施工人员分组
|
||||
const setTeamList = (list) => {
|
||||
let team = new Map();
|
||||
list.forEach((item) => {
|
||||
// 判断班组id是否存在
|
||||
if (!item.teamName) {
|
||||
item.teamName = '暂无班组';
|
||||
}
|
||||
if (team.has(item.teamName)) {
|
||||
let arr = team.get(item.teamName);
|
||||
arr.push(item);
|
||||
team.set(item.teamName, arr);
|
||||
} else {
|
||||
team.set(item.teamName, [item]);
|
||||
}
|
||||
});
|
||||
return Array.from(team.values());
|
||||
};
|
||||
// excel表格样式设置
|
||||
const exportConfig = (arr, sheetName, time) => {
|
||||
let header = ['建筑施工企业现场人员工资表(' + time + ')'];
|
||||
const header1 = [];
|
||||
let obj = arr[0];
|
||||
let projectName = '项目部名称:' + obj.projectName;
|
||||
let teamName = '班组类别:' + obj.teamName;
|
||||
const header2 = [projectName + ' ' + teamName];
|
||||
const header3 = ['序号', '账号', '户名', '金额', '开户行', '签字'];
|
||||
let columnsWidth = [8, 24, 12, 10, 35, 10]; //表格宽度
|
||||
let fields = ['index', 'yhkNumber', 'userName', 'money', 'bankingHouse', ''];
|
||||
arr.map((item, index) => {
|
||||
item.index = index + 1;
|
||||
return;
|
||||
});
|
||||
// 单元格合并
|
||||
const merges = [
|
||||
{ row: 0, col: 0, rowspan: 1, colspan: 6 },
|
||||
{ row: 2, col: 0, rowspan: 1, colspan: 6 },
|
||||
{ row: arr.length + 5, col: 0, rowspan: 1, colspan: 3 },
|
||||
{ row: arr.length + 5, col: 3, rowspan: 1, colspan: 3 }
|
||||
];
|
||||
arr.push({});
|
||||
arr.push({
|
||||
index: '班组长:',
|
||||
money: '劳资员:'
|
||||
});
|
||||
const config = {
|
||||
data: arr,
|
||||
fields,
|
||||
headers: [header, header1, header2, header3],
|
||||
merges,
|
||||
attrs: [],
|
||||
view: [],
|
||||
columnsWidth,
|
||||
sheetName
|
||||
};
|
||||
// 设置表头字体加粗
|
||||
config.attrs.push({
|
||||
rowStart: 0,
|
||||
rowEnd: 0,
|
||||
colStart: 0,
|
||||
colEnd: config.fields.length - 1,
|
||||
attr: {
|
||||
alignment: { vertical: 'middle', horizontal: 'center' },
|
||||
font: {
|
||||
bold: true,
|
||||
size: '16'
|
||||
}
|
||||
}
|
||||
});
|
||||
config.attrs.push({
|
||||
rowStart: 2,
|
||||
rowEnd: 2,
|
||||
colStart: 0,
|
||||
colEnd: config.fields.length - 1,
|
||||
attr: {
|
||||
alignment: { vertical: 'middle', horizontal: 'center' }
|
||||
}
|
||||
});
|
||||
// 设置全表单元格边框,居中布局
|
||||
config.attrs.push({
|
||||
rowStart: 3,
|
||||
rowEnd: config.data.length + 1,
|
||||
colStart: 0,
|
||||
colEnd: config.fields.length - 1,
|
||||
attr: {
|
||||
alignment: { vertical: 'middle', horizontal: 'center' },
|
||||
border: {
|
||||
top: { style: 'thin' },
|
||||
left: { style: 'thin' },
|
||||
bottom: { style: 'thin' },
|
||||
right: { style: 'thin' }
|
||||
}
|
||||
}
|
||||
});
|
||||
return config;
|
||||
};
|
||||
// 多选框选中数据
|
||||
const handleSelectionChange = (selection) => {
|
||||
state.ids = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
return {
|
||||
proxy,
|
||||
detailRef,
|
||||
showAll,
|
||||
loading,
|
||||
single,
|
||||
onChangeProject,
|
||||
onChangeTeam,
|
||||
multiple,
|
||||
handleSelectionChange,
|
||||
word,
|
||||
onChangeOfIssue,
|
||||
queryRef,
|
||||
resetQuery,
|
||||
busSalaryDetailsList,
|
||||
exportSalary,
|
||||
toggleSearch,
|
||||
handleDelete,
|
||||
handleView,
|
||||
...toRefs(state)
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.colBlock {
|
||||
display: block;
|
||||
}
|
||||
.colNone {
|
||||
display: none;
|
||||
}
|
||||
.system-busSalaryDetails-container {
|
||||
input[type='file'] {
|
||||
display: none;
|
||||
}
|
||||
label {
|
||||
display: inline-block;
|
||||
background-color: #007bff; /*设置背景色*/
|
||||
color: #fff; /*设置字体颜色*/
|
||||
padding: 3px 10px; /*设置内边距*/
|
||||
border-radius: 5px; /*设置圆角*/
|
||||
cursor: pointer; /*将鼠标光标设置为手型*/
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user