<template>
|
<div class="work-time-management">
|
<div class="search">
|
<div class="search_thing" style="width: 200px">
|
<div class="search_label">星期:</div>
|
<el-select
|
v-model="entity.weekDay"
|
placeholder="全部"
|
size="small"
|
@change="refreshTable()"
|
clearable
|
>
|
<el-option
|
v-for="item in weekList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="search_thing" style="width: 390px">
|
<div class="search_label" style="width: 90px">时间范围:</div>
|
<div class="search_input">
|
<el-date-picker
|
style="width: 100%"
|
v-model="entity.dateTime"
|
size="small"
|
type="daterange"
|
range-separator="至"
|
format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
@change="refreshTable()"
|
clearable
|
>
|
</el-date-picker>
|
</div>
|
</div>
|
<!-- 以下这两个为组长角色特有的 -->
|
<div class="search_thing" style="width: 200px">
|
<div class="search_label">名字:</div>
|
<el-input
|
size="small"
|
placeholder="请输入"
|
clearable
|
v-model="entity.name"
|
@keyup.enter.native="refreshTable()"
|
></el-input>
|
</div>
|
<div
|
class="search_thing"
|
style="width: 200px"
|
v-if="currentTable == 'ValueTable0'"
|
>
|
<div class="search_label">状态:</div>
|
<el-select
|
v-model="entity.state"
|
placeholder="全部"
|
size="small"
|
@change="refreshTable()"
|
>
|
<el-option
|
v-for="item in stateList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="search_thing" style="padding-left: 30px; width: 100px">
|
<el-button size="small" @click="refresh()">重 置</el-button>
|
<el-button size="small" type="primary" @click="refreshTable()"
|
>查 询</el-button
|
>
|
</div>
|
</div>
|
<div
|
style="
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-top: 10px;
|
"
|
>
|
<el-radio-group v-model="currentTable" size="small" :key="'111'">
|
<el-radio-button label="ValueTable0"> 辅助工时 </el-radio-button>
|
<el-radio-button label="ValueTable1"> 产量工时 </el-radio-button>
|
</el-radio-group>
|
<div style="display: flex; align-items: center">
|
<p style="font-size: 14px; margin-right: 30px">
|
总工时汇总:<span
|
style="font-size: 16px; color: #3a7bfa"
|
v-if="totalInfo"
|
>{{
|
totalInfo["产量工时汇总"] + totalInfo["辅助工时汇总"]
|
? Number(
|
totalInfo["产量工时汇总"] + totalInfo["辅助工时汇总"]
|
).tofixed(4)
|
: 0
|
}}</span
|
> 产量工时汇总:<span
|
style="font-size: 16px; color: #3a7bfa"
|
v-if="totalInfo"
|
>{{
|
totalInfo["产量工时汇总"]
|
? Number(totalInfo["产量工时汇总"]).tofixed(4)
|
: 0
|
}}</span
|
> 辅助工时汇总:<span
|
style="font-size: 16px; color: #3a7bfa"
|
v-if="totalInfo"
|
>{{
|
totalInfo["辅助工时汇总"]
|
? Number(totalInfo["辅助工时汇总"]).tofixed(4)
|
: 0
|
}}</span
|
>
|
</p>
|
<el-button
|
size="small"
|
type="primary"
|
@click="openAdd"
|
v-show="currentTable == 'ValueTable0'"
|
v-hasPermi="['performance:manHour:workTimeManagement:enterData']"
|
>录入数据</el-button
|
>
|
<el-button
|
size="small"
|
type="primary"
|
@click="handleOut"
|
:loading="outLoading"
|
v-hasPermi="['performance:manHour:workTimeManagement:export']"
|
>导 出</el-button
|
>
|
<el-button
|
size="small"
|
type="primary"
|
v-show="currentTable == 'ValueTable0'"
|
@click="openBatchCheck(0)"
|
v-hasPermi="['performance:manHour:workTimeManagement:batchExamine']"
|
>批量审核</el-button
|
>
|
<el-button
|
size="small"
|
type="primary"
|
v-show="currentTable == 'ValueTable0'"
|
@click="openBatchCheck(1)"
|
v-hasPermi="['performance:manHour:workTimeManagement:batchApprove']"
|
>批量批准</el-button
|
>
|
</div>
|
</div>
|
<div class="table">
|
<lims-table
|
v-if="currentTable == 'ValueTable0'"
|
:tableData="tableData"
|
isSelection
|
:handleSelectionChange="handleSelectionChange"
|
:column="column"
|
:key="upIndex"
|
:tableLoading="tableLoading"
|
:height="tableHeight+''"
|
:page="page"
|
@pagination="pagination"
|
></lims-table>
|
|
<lims-table
|
v-if="currentTable == 'ValueTable1'"
|
:tableData="tableData1"
|
:column="column1"
|
:key="upIndex1"
|
:tableLoading="tableLoading1"
|
:height="tableHeight+''"
|
:page="page1"
|
@pagination="pagination1"
|
></lims-table>
|
</div>
|
|
<el-dialog
|
:title="formData.id ? '编辑' : '录入数据'"
|
:visible.sync="addVisible"
|
width="600px"
|
:before-close="handleClose"
|
>
|
<el-row style="display: flex; justify-content: space-around">
|
<el-col :span="12">
|
<el-form :model="formData" label-width="90px">
|
<el-form-item label="录入时间:">
|
<el-radio-group v-model="formData.dateTime" size="small">
|
<el-radio :label="getYearAndMonthAndDays() + ' 00:00:00'"
|
>今天</el-radio
|
>
|
<el-radio
|
:label="
|
getYearAndMonthAndDays(
|
new Date(new Date().getTime() - 24 * 60 * 60 * 1000)
|
) + ' 00:00:00'
|
"
|
>昨天</el-radio
|
>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item label="年份:">
|
<el-input
|
v-model="formData.year"
|
disabled
|
size="small"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="周次:">
|
<el-input
|
v-model="formData.week"
|
size="small"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="星期:">
|
<el-select
|
v-model="formData.weekDay"
|
placeholder="请选择"
|
size="small"
|
disabled
|
>
|
<el-option
|
v-for="item in weekList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="班次:">
|
<el-select
|
v-model="formData.shift"
|
placeholder="请选择"
|
size="small"
|
disabled
|
>
|
<el-option
|
v-for="item in classType"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
</el-col>
|
<el-col :span="12">
|
<el-form :model="formData" label-width="90px">
|
<el-form-item label="编号:" required>
|
<el-input
|
v-model="formData.number"
|
size="small"
|
@blur="getInfoByCode"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="数量:" required>
|
<el-input v-model="formData.amount" size="small"></el-input>
|
</el-form-item>
|
<el-form-item label="核准工时:">
|
<el-input
|
v-model="formData.approvedWorkingHour"
|
size="small"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="辅助工时:">
|
<el-input
|
v-model="formData.nonproductiveTime"
|
size="small"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="辅助项目:">
|
<el-input
|
v-model="formData.auxiliaryProject"
|
size="small"
|
disabled
|
></el-input>
|
</el-form-item>
|
</el-form>
|
</el-col>
|
</el-row>
|
<el-form :model="formData" label-width="90px">
|
<el-form-item label="辅助说明:">
|
<el-input
|
v-model="formData.remarks"
|
type="textarea"
|
:rows="3"
|
size="small"
|
></el-input>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-row>
|
<el-button @click="handleClose">取 消</el-button>
|
<el-button type="primary" @click="submitAdd" :loading="addLoad"
|
>确 定</el-button
|
>
|
</el-row>
|
</span>
|
</el-dialog>
|
<el-dialog :title="title" :visible.sync="checkVisible" width="600px">
|
<el-row style="display: flex; justify-content: space-around">
|
<el-col :span="12">
|
<el-form :model="formData0" label-width="90px">
|
<el-form-item label="年份:">
|
<el-input
|
v-model="formData0.year"
|
size="small"
|
:disabled="title == '批准'"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="周次:">
|
<el-input
|
v-model="formData0.week"
|
size="small"
|
:disabled="title == '批准'"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="星期:">
|
<el-select
|
v-model="formData0.weekDay"
|
placeholder="请选择"
|
size="small"
|
:disabled="title == '批准'"
|
>
|
<el-option
|
v-for="item in weekList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="姓名:">
|
<el-input
|
v-model="formData0.name"
|
size="small"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="班次:">
|
<el-select
|
v-model="formData0.shift"
|
placeholder="请选择"
|
size="small"
|
:disabled="title == '批准'"
|
>
|
<el-option
|
v-for="item in classType"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="复核说明:">
|
<el-input
|
v-model="formData0.reviewerRemark"
|
type="textarea"
|
:rows="3"
|
size="small"
|
:disabled="title == '批准'"
|
></el-input>
|
</el-form-item>
|
</el-form>
|
</el-col>
|
<el-col :span="12">
|
<el-form :model="formData0" label-width="90px">
|
<el-form-item label="编号:" required>
|
<el-input
|
v-model="formData0.number"
|
size="small"
|
:disabled="title == '批准'"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="数量:" required>
|
<el-input
|
v-model="formData0.amount"
|
size="small"
|
:disabled="title == '批准'"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="复核数量:" required>
|
<el-input
|
v-model="formData0.reviewerNumber"
|
size="small"
|
:disabled="title == '批准'"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="核准工时:">
|
<el-input
|
v-model="formData0.approvedWorkingHour"
|
size="small"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="复核工时:">
|
<el-input
|
v-model="formData0.reviewerNonproductiveTime"
|
size="small"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="辅助项目:">
|
<el-input
|
v-model="formData0.auxiliaryProject"
|
size="small"
|
disabled
|
></el-input>
|
</el-form-item>
|
</el-form>
|
</el-col>
|
</el-row>
|
<span slot="footer" class="dialog-footer">
|
<el-row>
|
<el-button
|
@click="submitCheck(0)"
|
type="danger"
|
:loading="checkLoadN"
|
>{{ title == "审核" ? "不通过" : "不批准" }}</el-button
|
>
|
<el-button
|
style="margin-left: 20px"
|
type="primary"
|
@click="submitCheck(1)"
|
:loading="checkLoadY"
|
>{{ title == "审核" ? "通 过" : "批 准" }}</el-button
|
>
|
</el-row>
|
</span>
|
</el-dialog>
|
<el-dialog
|
:title="batchCheckTitle"
|
:visible.sync="batchCheckDialog"
|
width="30%"
|
:before-close="closeBatchCheckDialog"
|
>
|
<span>{{ batchCheckDialogMessage }}</span>
|
<span slot="footer" class="dialog-footer">
|
<el-button type="danger" @click="batchCheckDialog = false">{{
|
batchCheckTitle == "批量审核" ? "不通过" : "不批准"
|
}}</el-button>
|
<el-button
|
style="margin-left: 20px"
|
type="primary"
|
@click="batchCheck"
|
>{{ batchCheckTitle == "批量审核" ? "通 过" : "批 准" }}</el-button
|
>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import limsTable from "@/components/Table/lims-table.vue";
|
import {
|
obtainItemParameterList,
|
selectAuxiliaryCorrectionHours,
|
selectAuxiliaryOriginalHours,
|
selectAuxiliaryWorkingHoursDay,
|
selectAuxiliaryOutputWorkingHours,
|
insertAuxiliaryWorkingHoursDay,
|
updateAuxiliaryWorkingHoursDay,
|
check,
|
approve,
|
collectWorkingHours,
|
selectshiftByUser,
|
selectAuxiliaryWorkingHoursByNumber,
|
exportWorkingHours,
|
deleteAuxiliaryWorkingHoursDay
|
} from "../../../api/business/manHour";
|
import { getYearAndMonthAndDays } from "../../../utils/date";
|
|
import auth from "@/plugins/auth.js";
|
|
import { getDicts } from "@/api/system/dict/data";
|
import Big from "big.js";
|
export default {
|
components: {
|
limsTable,
|
},
|
data() {
|
return {
|
tableHeight: "",
|
shiftList:[],
|
tableData: [],
|
column: [
|
{
|
label: '姓名',
|
prop: 'name',
|
},
|
{
|
label: '编号',
|
prop: 'number',
|
},
|
{
|
label: '辅助项目名称',
|
prop: 'auxiliaryProject'
|
},
|
{
|
label: '状态',
|
prop: 'state',
|
},
|
{
|
label: '核准工时',
|
prop: 'approvedWorkingHour'
|
},
|
{
|
label: '数量',
|
prop: 'amount'
|
},
|
{
|
label: '辅助工时',
|
prop: 'nonproductiveTime'
|
},
|
{
|
label: '辅助说明',
|
prop: 'remarks'
|
},
|
{
|
label: '班次',
|
prop: 'shift',
|
dataType: 'tag',
|
formatData: (params) => {
|
let farmat = '';
|
let list = this.shiftList.filter(item => item.dictValue == params)
|
if(list.length > 0){
|
farmat = list[0].dictLabel
|
}
|
return farmat;
|
},
|
formatType: () => {
|
return "primary";
|
},
|
},
|
{
|
label: '周次',
|
prop: 'week',
|
|
},
|
{
|
label: '星期',
|
prop: 'weekDay',
|
dataType: 'tag',
|
|
formatData: (params) => {
|
let farmat = '';
|
let list = this.weekList.filter(item => item.value == params)
|
if(list.length > 0){
|
farmat = list[0].label
|
}
|
return farmat;
|
},
|
formatType: () => {
|
return "success";
|
},
|
},
|
{
|
label: '复核人',
|
prop: 'reviewer'
|
},
|
{
|
label: '复核数量',
|
prop: 'reviewerNumber'
|
},
|
{
|
label: '复核工时',
|
prop: 'reviewerNonproductiveTime'
|
},
|
{
|
label: '复核说明',
|
prop: 'reviewerRemark'
|
},
|
{
|
label: '年',
|
prop: 'year'
|
},
|
{
|
label: '创建时间',
|
prop: 'createTime'
|
},
|
{
|
label: '日期',
|
prop: 'dateTime'
|
},
|
{
|
dataType: "action",
|
fixed: "right",
|
label: "操作",
|
operation: [
|
{
|
name: "删除",
|
type: "text",
|
clickFun: (row) => {
|
this.del(row);
|
},
|
showHide: () => {
|
return auth.hasPermi('performance:manHour:workTimeManagement:del');
|
}
|
},
|
{
|
name: "编辑",
|
type: "text",
|
clickFun: (row) => {
|
this.handleEdit(row);
|
},
|
showHide: () => {
|
return auth.hasPermi('performance:manHour:workTimeManagement:edit');
|
}
|
},
|
{
|
name: "审核",
|
type: "text",
|
clickFun: (row) => {
|
this.handleCheck(row);
|
},
|
showHide: () => {
|
return auth.hasPermi('performance:manHour:workTimeManagement:examine');
|
}
|
},
|
{
|
name: "批准",
|
type: "text",
|
clickFun: (row) => {
|
this.handleRatify(row);
|
},
|
showHide: () => {
|
return auth.hasPermi('performance:manHour:workTimeManagement:approve');
|
}
|
},
|
],
|
},
|
],
|
tableLoading: false,
|
page: {
|
current: 1,
|
size: 20,
|
total: 0,
|
},
|
entity: {
|
week: null,
|
weekDay: null,
|
dateTime: [],
|
name: null,
|
state: null,
|
},
|
tableData1: [],
|
column1: [
|
{
|
label: '检测父项',
|
prop: 'inspectionItem'
|
},
|
{
|
label: '检测子项',
|
prop: 'inspectionItemSubclass'
|
},
|
{
|
label: '样品编号',
|
prop: 'sample'
|
},
|
{
|
label: '加班委托单号',
|
prop: 'overtimeOrderNo'
|
},
|
{
|
label: '加班工时',
|
prop: 'overtimeWorkTime'
|
},
|
{
|
label: '加班数量',
|
prop: 'overtimeAmount'
|
},
|
{
|
label: '非加班委托单号',
|
prop: 'orderNo'
|
},
|
{
|
label: '非加班工时',
|
prop: 'workTime'
|
},
|
{
|
label: '非加班数量',
|
prop: 'amount'
|
},
|
{
|
label: '产量工时',
|
prop: 'outputWorkTime'
|
},
|
{
|
label: '日期',
|
prop: 'dateTime'
|
},
|
{
|
label: '周次',
|
prop: 'week'
|
},
|
{
|
label: '星期',
|
prop: 'weekDay'
|
},
|
{
|
label: '检测人',
|
prop: 'name'
|
}
|
],
|
tableLoading1: false,
|
page1: {
|
current: 1,
|
size: 20,
|
total: 0,
|
},
|
entityCopy: {},
|
upIndex: 0,
|
addFileVisible: false,
|
entityCopy1: {},
|
upIndex1: 100,
|
weekList: [
|
{ label: "周一", value: "1", type: "primary" },
|
{ label: "周二", value: "2", type: "primary" },
|
{ label: "周三", value: "3", type: "primary" },
|
{ label: "周四", value: "4", type: "primary" },
|
{ label: "周五", value: "5", type: "primary" },
|
{ label: "周六", value: "6", type: "primary" },
|
{ label: "周日", value: "0", type: "primary" },
|
],
|
currentTable: "ValueTable0",
|
addVisible: false,
|
addLoad: false,
|
formData: {
|
dateTime: getYearAndMonthAndDays() + " 00:00:00",
|
year: new Date().getFullYear(),
|
week: this.getCurrentWeekNumber(),
|
weekDay: this.getWeek(),
|
shift: "",
|
number: "",
|
amount: "",
|
approvedWorkingHour: "",
|
nonproductiveTime: "",
|
auxiliaryProject: "",
|
remarks: "",
|
},
|
formData0: {
|
dateTime: 0,
|
year: new Date().getFullYear(),
|
week: this.getCurrentWeekNumber(),
|
weekDay: this.getWeek(),
|
createUser: "",
|
shift: "",
|
number: "",
|
reviewerNumber: "",
|
approvedWorkingHour: "",
|
reviewerNonproductiveTime: "",
|
auxiliaryProject: "",
|
reviewerRemark: "",
|
nameUser: "",
|
name: "",
|
},
|
checkVisible: false,
|
checkLoadN: false,
|
checkLoadY: false,
|
title: "审核",
|
classType: [],
|
stateList: [
|
{
|
value: "已提交",
|
label: "已提交",
|
},
|
{
|
value: "已审核",
|
label: "已审核",
|
},
|
{
|
value: "已批准",
|
label: "已批准",
|
},
|
],
|
totalInfo: null,
|
auxiliaryWorking: null,
|
outLoading: false,
|
batchCheckTitle: "批量审核",
|
batchCheckDialog: false,
|
ValueTable0Selected: [],
|
batchCheckDialogMessage: "",
|
};
|
},
|
watch: {
|
currentTable() {
|
this.refreshTable();
|
},
|
"formData.dateTime"(val) {
|
if (val == getYearAndMonthAndDays() + " 00:00:00") {
|
this.formData.year = new Date().getFullYear();
|
this.formData.week = this.getCurrentWeekNumber();
|
this.formData.weekDay = this.getWeek();
|
} else {
|
var today = new Date(); // 获取当前日期
|
var yesterday = new Date(today); // 复制当前日期
|
yesterday.setDate(today.getDate() - 1); // 设置为前一天
|
var timestamp = new Date(yesterday.getTime());
|
this.formData.year = timestamp.getFullYear();
|
this.formData.week = this.getCurrentWeekNumber(timestamp);
|
this.formData.weekDay = this.getWeek(timestamp);
|
}
|
},
|
"formData.amount"(val) {
|
if (val) {
|
if (!isNaN(val)) {
|
if (this.formData.approvedWorkingHour) {
|
let workHour = new Big(this.formData.approvedWorkingHour);
|
this.formData.nonproductiveTime = workHour.times(val).toNumber();
|
}
|
} else {
|
this.$message.error("请输入数字");
|
this.formData.amount = "";
|
}
|
}
|
},
|
"formData.approvedWorkingHour"(val) {
|
if (val && this.formData.amount) {
|
let amount = new Big(this.formData.amount);
|
this.formData.nonproductiveTime = amount.times(val).toNumber();
|
}
|
},
|
"formData0.reviewerNumber"(val) {
|
if (val) {
|
if (!isNaN(val)) {
|
if (this.formData0.approvedWorkingHour) {
|
let approvedWorkingHour = new Big(
|
this.formData0.approvedWorkingHour
|
);
|
this.formData0.reviewerNonproductiveTime = approvedWorkingHour
|
.times(val)
|
.toNumber();
|
}
|
} else {
|
this.$message.error("请输入数字");
|
this.formData0.reviewerNumber = "";
|
}
|
}
|
},
|
"formData0.approvedWorkingHour"(val) {
|
if (val && this.formData0.reviewerNumber) {
|
let num = new Big(reviewerNumber);
|
this.formData0.reviewerNonproductiveTime = num.times(val).toNumber();
|
}
|
},
|
},
|
created() {
|
//当只有产量工时tab页时,当前页改为产量工时页
|
this.selectEnumByCategory();
|
this.setDate();
|
this.getTableHeight();
|
},
|
mounted() {
|
console.log(11);
|
this.getCurrentWeekNumber();
|
this.selectshiftByUser();
|
this.entityCopy = this.HaveJson(this.entity);
|
this.entityCopy1 = this.HaveJson(this.entity);
|
},
|
methods: {
|
getTableHeight() {
|
this.tableHeight = window.innerHeight -50 -46 - 63 - 80 - 41 -30 -30 -32;
|
},
|
del(row) {
|
console.log(row);
|
this.$confirm("此操作将永久删除, 是否继续?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
}).then(() => {
|
deleteAuxiliaryWorkingHoursDay({id:row.id}).then((res) => {
|
this.$message({
|
type: "success",
|
message: "删除成功!",
|
});
|
this.refreshTable();
|
});
|
});
|
},
|
getData() {
|
if (this.currentTable == "ValueTable0") {
|
console.log('辅助工时');
|
this.tableLoading = true;
|
let params = {
|
current: this.page.current,
|
size: this.page.size,
|
dateTime1: this.entity.dateTime[0],
|
dateTime2: this.entity.dateTime[1],
|
week: this.entity.week,
|
weekDay: this.entity.weekDay,
|
name: this.entity.name,
|
state: this.entity.state,
|
};
|
selectAuxiliaryWorkingHoursDay(params)
|
.then((res) => {
|
this.tableLoading = false;
|
this.tableData = res.data.records;
|
this.page.total = res.data.total;
|
});
|
} else {
|
console.log('产量工时');
|
this.tableLoading1 = true;
|
let params = {
|
current: this.page1.current,
|
size: this.page1.size,
|
dateTime1: this.entity.dateTime[0],
|
dateTime2: this.entity.dateTime[1],
|
week: this.entity.week,
|
weekDay: this.entity.weekDay,
|
name: this.entity.name,
|
state: this.entity.state,
|
};
|
selectAuxiliaryOutputWorkingHours(params)
|
.then((res) => {
|
this.tableLoading1 = false;
|
this.tableData1 = res.data.records;
|
this.page1.total = res.data.total;
|
});
|
}
|
},
|
pagination({ page, limit }) {
|
this.page.current = page;
|
this.page.size = limit;
|
this.getData();
|
},
|
pagination1({ page, limit }) {
|
this.page1.current = page;
|
this.page1.size = limit;
|
this.getData();
|
},
|
/** 将时间选择器默认选为当天的日期 */
|
setDate() {
|
let currentDate = new Date();
|
let year = currentDate.getFullYear();
|
let month = String(currentDate.getMonth() + 1).padStart(2, "0");
|
let day = String(currentDate.getDate()).padStart(2, "0");
|
let formattedDate1 = `${year}-${month}-${day}`;
|
let formattedDate2 = `${year}-${month}-${day}`;
|
this.entity.dateTime.push(formattedDate1);
|
this.entity.dateTime.push(formattedDate2);
|
this.refreshTable();
|
},
|
getYearAndMonthAndDays(date) {
|
return getYearAndMonthAndDays(date);
|
},
|
refreshTable(e) {
|
let entity = {};
|
if (this.entity.week1 && this.entity.week2) {
|
entity.week = JSON.stringify([this.entity.week1, this.entity.week2]);
|
} else {
|
entity.week = "";
|
}
|
if (!this.entity.dateTime) {
|
entity.dateTime = "";
|
|
}
|
entity.weekDay = this.entity.weekDay;
|
entity.name = this.entity.name;
|
if (this.currentTable == "ValueTable0") {
|
entity.state = this.entity.state;
|
this.entity = { ...this.entity, ...entity };
|
this.$nextTick(() => {
|
this.getData();
|
});
|
} else {
|
this.entity = {
|
...this.entity,
|
...entity,
|
};
|
this.getData();
|
}
|
|
this.collectWorkingHours();
|
},
|
refresh() {
|
this.entity = {};
|
this.refreshTable();
|
},
|
openAdd() {
|
this.formData = {
|
dateTime: getYearAndMonthAndDays() + " 00:00:00",
|
year: new Date().getFullYear(),
|
week: this.getCurrentWeekNumber(),
|
weekDay: this.getWeek(),
|
shift: "",
|
number: "",
|
amount: "",
|
approvedWorkingHour: "",
|
nonproductiveTime: "",
|
auxiliaryProject: "",
|
remarks: "",
|
};
|
this.addVisible = true;
|
},
|
handleSelectionChange(val) {
|
this.ValueTable0Selected = val;
|
},
|
handleEdit(row) {
|
this.formData = JSON.parse(JSON.stringify(row));
|
this.addVisible = true;
|
},
|
handleDelete() {
|
this.collectWorkingHours();
|
},
|
handleClose() {
|
this.addVisible = false;
|
},
|
submitAdd() {
|
if (!this.formData.number) {
|
this.$message.error("请输入编号");
|
return;
|
}
|
if (!this.formData.amount) {
|
this.$message.error("请输入数量");
|
return;
|
}
|
this.addLoad = true;
|
if (!this.formData.id) {
|
insertAuxiliaryWorkingHoursDay({...this.formData})
|
.then((res) => {
|
this.addLoad = false;
|
if (res.code == 201) return;
|
this.$message.success("已提交");
|
this.formData.number = "";
|
this.formData.amount = "";
|
this.formData.remarks = "";
|
this.formData.approvedWorkingHour = "";
|
this.formData.nonproductiveTime = "";
|
this.formData.auxiliaryProject = "";
|
// this.addVisible = false
|
this.refreshTable("page");
|
});
|
} else {
|
updateAuxiliaryWorkingHoursDay({...this.formData})
|
.then((res) => {
|
this.addLoad = false;
|
if (res.code == 201) return;
|
this.$message.success("操作成功");
|
this.formData.number = "";
|
this.formData.amount = "";
|
this.formData.remarks = "";
|
this.formData.approvedWorkingHour = "";
|
this.formData.nonproductiveTime = "";
|
this.formData.auxiliaryProject = "";
|
// this.addVisible = false
|
this.refreshTable("page");
|
});
|
}
|
},
|
handleCheck(row) {
|
this.title = "审核";
|
this.formData0 = row;
|
this.checkVisible = true;
|
this.formData0.reviewerNumber = this.formData0.amount;
|
},
|
handleRatify(row) {
|
this.title = "批准";
|
this.formData0 = row;
|
this.checkVisible = true;
|
this.formData0.reviewerNumber = this.formData0.amount;
|
},
|
handleChangeTask(row) {
|
this.ValueTable0Selected = JSON.parse(JSON.stringify(row));
|
},
|
openBatchCheck(e) {
|
if (this.ValueTable0Selected.length > 0) {
|
const isChecked = this.ValueTable0Selected.every(
|
(item) => item.state === "已提交"
|
);
|
const isApprove = this.ValueTable0Selected.every(
|
(item) => item.state !== "已批准"
|
);
|
console.log("this.isApprove---", isApprove);
|
this.batchCheckTitle = e === 0 ? "批量审核" : "批量批准";
|
this.batchCheckDialogMessage =
|
e === 0 ? "是否全部通过审核?" : "是否全部通过批准?";
|
if (this.batchCheckTitle === "批量审核") {
|
if (isChecked) {
|
this.batchCheckDialog = true;
|
} else {
|
this.$message.error("请选择未审核或未批准的数据");
|
}
|
} else {
|
if (isApprove) {
|
this.batchCheckDialog = true;
|
} else {
|
this.$message.error("请选择未批准的数据");
|
}
|
}
|
} else {
|
this.$message.error("请选择至少一条数据");
|
}
|
},
|
batchCheck() {
|
const e = this.batchCheckTitle === "批量审核" ? 0 : 1;
|
this.batchCheck1(e);
|
},
|
batchCheck1(e) {
|
if (this.ValueTable0Selected && this.ValueTable0Selected.length > 0) {
|
const list = JSON.parse(JSON.stringify(this.ValueTable0Selected));
|
const state = e === 0 ? "已审核" : "已批准";
|
let auxiliaryWorkingHoursDays = [];
|
list.forEach((item) => {
|
delete item.orderBy;
|
item.state = state;
|
auxiliaryWorkingHoursDays.push(item);
|
});
|
if(e == 0) {
|
check({auxiliaryWorkingHoursDays: auxiliaryWorkingHoursDays}).then((res) => {
|
if (res.code == 201) return;
|
this.$message.success("操作成功");
|
this.batchCheckDialog = false;
|
this.refreshTable("page");
|
});
|
}else {
|
approve({auxiliaryWorkingHoursDays: auxiliaryWorkingHoursDays}).then((res) => {
|
if (res.code == 201) return;
|
this.$message.success("操作成功");
|
this.batchCheckDialog = false;
|
this.refreshTable("page");
|
});
|
}
|
} else {
|
this.$message.error("请选择至少一条数据");
|
}
|
},
|
closeBatchCheckDialog() {
|
this.batchCheckDialog = false;
|
},
|
submitBatchCheckDialog() {
|
this.batchCheckDialog = false;
|
this.refreshTable("page");
|
this.collectWorkingHours();
|
},
|
submitCheck(e) {
|
if (!this.formData0.number) {
|
this.$message.error("请输入编号");
|
return;
|
}
|
if (!this.formData0.amount) {
|
this.$message.error("请输入数量");
|
return;
|
}
|
|
if (this.title == "审核") {
|
if (e == 0) {
|
// 审核不通过
|
this.checkLoadN = true;
|
} else {
|
// 审核通过
|
this.checkLoadY = true;
|
}
|
this.formData0.state = e == 0 ? this.formData0.state : "已审核";
|
check({auxiliaryWorkingHoursDays: [this.formData0]}).then((res) => {
|
if (e == 0) {
|
// 审核不通过
|
this.checkLoadN = false;
|
} else {
|
// 审核通过
|
this.checkLoadY = false;
|
}
|
if (res.code == 201) return;
|
this.$message.success("操作成功");
|
this.checkVisible = false;
|
this.refreshTable("page");
|
});
|
} else {
|
if (e == 0) {
|
this.checkLoadN = true;
|
} else {
|
this.checkLoadY = true;
|
}
|
this.formData0.state = e == 0 ? "已提交" : "已批准";
|
approve({auxiliaryWorkingHoursDays: [this.formData0]}).then((res) => {
|
if (e == 0) {
|
this.checkLoadN = false;
|
} else {
|
this.checkLoadY = false;
|
}
|
if (res.code == 201) return;
|
this.$message.success("操作成功");
|
this.checkVisible = false;
|
this.refreshTable("page");
|
});
|
}
|
},
|
selectEnumByCategory() {
|
getDicts('sys_class_type').then((res) => {
|
this.classType = res.data;
|
this.classType = res.data;
|
this.shiftList = res.data
|
console.log('shif',this.shiftList);
|
});
|
},
|
getCurrentWeekNumber(now = new Date()) {
|
const startOfWeek = new Date(
|
now.getFullYear(),
|
now.getMonth(),
|
now.getDate() - now.getDay()
|
); // 周天
|
const firstWeekOfYear = new Date(startOfWeek.getFullYear(), 0, 0); // 当年的第一个周天
|
const firstWeekOfNextYear = new Date(
|
firstWeekOfYear.getFullYear() + 1,
|
0,
|
0
|
); // 下一年的第一个周天
|
const daysSinceNewYear =
|
(startOfWeek - firstWeekOfYear) / (24 * 60 * 60 * 1000); // 计算自新年以来的天数
|
const weeksSinceNewYear = Math.floor(daysSinceNewYear / 7); // 天数除以7得到周数
|
|
if (startOfWeek > now) {
|
// 如果当前周的周天还没到,则返回上年的最后一周
|
return weeksSinceNewYear;
|
} else if (firstWeekOfNextYear <= now) {
|
// 如果当前周的周天已经过了,则返回当年的周数
|
return weeksSinceNewYear + 1;
|
} else {
|
// 否则返回当年的最后一周
|
return weeksSinceNewYear + 2;
|
}
|
},
|
getWeek(e = new Date()) {
|
// let str = '日一二三四五六'
|
let d = e.getDay();
|
// let c = str.charAt(d)
|
// return `周${c}`
|
return String(d);
|
},
|
collectWorkingHours() {
|
let entity = {};
|
if (this.entity.week1 && this.entity.week2) {
|
entity.week = JSON.stringify([this.entity.week1, this.entity.week2]);
|
} else {
|
entity.week = "";
|
}
|
if (this.entity.dateTime) {
|
entity.dateTime = JSON.stringify(this.entity.dateTime);
|
} else {
|
entity.dateTime = "";
|
}
|
entity.weekDay = this.entity.weekDay;
|
entity.name = this.entity.name;
|
entity.state = this.entity.state;
|
collectWorkingHours(entity).then((res) => {
|
this.totalInfo = res.data;
|
});
|
},
|
selectshiftByUser() {
|
selectshiftByUser().then((res) => {
|
this.formData.shift = res.data;
|
});
|
},
|
getInfoByCode() {
|
if (this.formData.number) {
|
selectAuxiliaryWorkingHoursByNumber({number:this.formData.number}).then((res) => {
|
this.auxiliaryWorking = res.data;
|
if (this.addVisible) {
|
this.formData.approvedWorkingHour =
|
this.auxiliaryWorking.approvedWorkingHour;
|
this.formData.auxiliaryProject =
|
this.auxiliaryWorking.auxiliaryProject;
|
} else if (this.title == "审核" && this.checkVisible) {
|
this.formData0.approvedWorkingHour =
|
this.auxiliaryWorking.approvedWorkingHour;
|
this.formData0.auxiliaryProject =
|
this.auxiliaryWorking.auxiliaryProject;
|
}
|
});
|
}
|
},
|
handleOut() {
|
this.outLoading = true;
|
exportWorkingHours().then((res) => {
|
this.outLoading = false;
|
this.$message.success("导出成功");
|
const blob = new Blob([res]);
|
console.log(blob);
|
const url = URL.createObjectURL(blob);
|
const link = document.createElement("a");
|
link.href = url;
|
link.download = "日工时汇总表.xlsx";
|
link.click();
|
});
|
},
|
},
|
};
|
</script>
|
|
<style scoped>
|
.work-time-management {
|
height: 100%;
|
overflow-y: scroll;
|
/* scrollbar-width: none; */
|
}
|
/* .work-time-management::-webkit-scrollbar {
|
display: none;
|
} */
|
.search {
|
background-color: #fff;
|
height: 80px;
|
display: flex;
|
align-items: center;
|
}
|
|
.search_thing {
|
width: 300px;
|
display: flex;
|
align-items: center;
|
}
|
|
.search_label {
|
width: 70px;
|
font-size: 14px;
|
text-align: right;
|
}
|
|
.search_input {
|
width: calc(100% - 70px);
|
}
|
.table {
|
margin-top: 10px;
|
background-color: #fff;
|
width: calc(100% - 40px);
|
height: calc(100% - 60px - 80px - 10px - 40px - 25px);
|
padding: 20px;
|
}
|
</style>
|
|