gz-att-web/src/views/process/restApply/index.vue

610 lines
23 KiB
Vue
Raw Normal View History

2024-10-16 15:09:57 +08:00
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="申请时间" prop="leaveDate">
2024-11-12 18:05:51 +08:00
<el-date-picker
2024-10-16 15:09:57 +08:00
v-model="queryParams.leaveDate" :clearable="false"
type="date" value-format="yyyy-MM-dd" style="width: 95%"
placeholder="选择申请时间">
</el-date-picker>
</el-form-item>
<el-form-item label="审批状态" prop="examineStatus">
<el-select
v-model="queryParams.examineStatus"
placeholder="审批状态" style="width: 95%">
<el-option
v-for="dict in dict.type.apply_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
2024-11-12 18:05:51 +08:00
2024-10-16 15:09:57 +08:00
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
2024-11-12 18:05:51 +08:00
@click="handleAdd"
2024-10-18 10:41:05 +08:00
v-hasPermi="['flow:holiday:add']"
2024-10-16 15:09:57 +08:00
>新增</el-button>
</el-col>
2024-11-12 18:05:51 +08:00
2024-10-16 15:09:57 +08:00
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
2024-11-12 18:05:51 +08:00
2024-10-16 15:09:57 +08:00
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
2024-11-12 18:05:51 +08:00
2024-10-16 15:09:57 +08:00
<el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column label="序号" align="center" width="80" type="index">
<template slot-scope="scope">
<span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="姓名" align="center" prop="userName" width="100"/>
<el-table-column label="所属部门" align="center" prop="orgName" :show-overflow-tooltip="true" width="240">
</el-table-column>
<el-table-column label="申请时间" align="center" prop="createTime" :show-overflow-tooltip="true" width="180"/>
<el-table-column label="轮休开始时间" align="center" prop="leaveStartDate" :show-overflow-tooltip="true" width="180">
<template slot-scope="scope">
<div>{{ scope.row.leaveStartDate }}
<span v-show="scope.row.leaveStartInterval=='1'">上午</span>
<span v-show="scope.row.leaveStartInterval=='2'">下午</span>
</div>
</template>
</el-table-column>
<el-table-column label="轮休结束时间" align="center" prop="leaveEndDate" :show-overflow-tooltip="true" width="180">
<template slot-scope="scope">
<div>{{ scope.row.leaveEndDate }}
<span v-show="scope.row.leaveEndInterval=='1'">上午</span>
<span v-show="scope.row.leaveEndInterval=='2'">下午</span>
</div>
</template>
</el-table-column>
<el-table-column label="轮休时长(天)" align="center" prop="leaveDuration" :show-overflow-tooltip="true" width="180"/>
<el-table-column label="审批状态" align="center" prop="examineStatus" :show-overflow-tooltip="true" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.apply_status" :value="scope.row.examineStatus"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button
size="mini"
type="primary"
v-if="scope.row.examineStatus==3"
@click="handleUpdate(scope.row)"
2024-10-18 10:41:05 +08:00
v-hasPermi="['flow:holiday:edit']"
2024-10-16 15:09:57 +08:00
>编辑</el-button>
<el-button
size="mini"
2024-10-18 10:41:05 +08:00
v-hasPermi="['flow:holiday:query']"
2024-10-16 15:09:57 +08:00
@click="handleView(scope.row)"
>详情</el-button>
<el-button
size="mini"
type="primary"
2024-10-18 10:41:05 +08:00
v-hasPermi="['flow:holiday:edit']"
2024-10-16 15:09:57 +08:00
v-if="scope.row.examineStatus==0"
@click="handleBack(scope.row)"
>撤回</el-button>
<el-button
size="mini"
type="danger"
2024-10-18 10:41:05 +08:00
v-hasPermi="['flow:holiday:remove']"
2024-10-16 15:09:57 +08:00
v-if="scope.row.examineStatus==2||scope.row.examineStatus==3"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
2024-11-12 18:05:51 +08:00
2024-10-16 15:09:57 +08:00
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
2024-11-12 18:05:51 +08:00
2024-10-16 15:09:57 +08:00
<!-- 添加或修改参数配置对话框 -->
2024-11-12 18:05:51 +08:00
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="170px">
2024-10-16 15:09:57 +08:00
<el-row>
<el-col :span="12">
2024-11-12 18:05:51 +08:00
<el-form-item label="申请人:" prop="userName">
2024-10-16 15:09:57 +08:00
<el-input v-model="form.userName" :readonly="true" />
</el-form-item>
</el-col>
2024-11-12 18:05:51 +08:00
<el-col :span="12">
<el-form-item label="职务:" prop="postName">
<el-input v-model="form.postName" :readonly="true" />
</el-form-item>
</el-col>
</el-row>
<el-row>
2024-10-16 15:09:57 +08:00
<el-col :span="12">
<el-form-item label="所属部门:" prop="orgId" >
2024-12-19 16:52:39 +08:00
<el-select v-model="form.orgId" @change="changDept" :disabled="isView" style="width: 100%;">
2024-10-16 15:09:57 +08:00
<el-option
v-for="item in orgList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
2024-11-12 18:05:51 +08:00
<el-col :span="12">
<el-form-item label="轮休开始时间:" prop="leaveStartDate">
<el-date-picker
2024-10-28 11:05:42 +08:00
v-model="form.leaveStartDate" :clearable="false" :disabled="isView"
type="date" value-format="yyyy-MM-dd" style="width: 100%;" @change="handleDateChange"
2024-11-12 18:05:51 +08:00
placeholder="轮休开始时间" :pickerOptions="startPickerOptions">
2024-10-16 15:09:57 +08:00
</el-date-picker>
2024-10-28 11:05:42 +08:00
</el-form-item>
</el-col>
2024-11-12 18:05:51 +08:00
<!-- <el-col :span="4">-->
<!-- <el-form-item prop="leaveStartInterval" label-width="0px">-->
<!-- <el-select v-model="form.leaveStartInterval" style="width: 80%;margin-left: 10px;" :disabled="isView" @change="handleDateChange">-->
<!-- <el-option-->
<!-- v-for="item in timeStatusList"-->
<!-- :key="item.id"-->
<!-- :label="item.name"-->
<!-- :value="item.id"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="轮休结束时间:" prop="leaveEndDate">
<el-date-picker
v-model="form.leaveEndDate" :clearable="false" :disabled="isView"
type="date" value-format="yyyy-MM-dd" style="width: 100%;" @change="handleDateChange"
placeholder="轮休结束时间" :pickerOptions="endPickerOptions">
2024-10-16 15:09:57 +08:00
</el-date-picker>
2024-10-28 11:05:42 +08:00
</el-form-item>
</el-col>
2024-11-12 18:05:51 +08:00
<!-- <el-col :span="4">-->
<!-- <el-form-item prop="leaveEndInterval" label-width="0px">-->
<!-- <el-select v-model="form.leaveEndInterval" style="width: 80%;margin-left: 10px;" :disabled="isView" @change="handleDateChange">-->
<!-- <el-option-->
<!-- v-for="item in timeStatusList"-->
<!-- :key="item.id"-->
<!-- :label="item.name"-->
<!-- :value="item.id"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="12">
<el-form-item label="轮休时长(天)" prop="leaveDuration">
<el-input v-model="form.leaveDuration" :readonly="true" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="地点:">
<el-input v-model="form.location" style="width: 100%;" placeholder="请输入地点">
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否请示领导同意:" prop="isAgree">
<el-radio-group v-model="form.isAgree">
<el-radio
v-for="item in isAgreeList"
2024-10-16 15:09:57 +08:00
:key="item.id"
2024-11-12 18:05:51 +08:00
:label="item.id"
>{{item.name}}</el-radio>
</el-radio-group>
</el-form-item>
2024-10-16 15:09:57 +08:00
</el-col>
</el-row>
<el-row>
2024-11-12 18:05:51 +08:00
<el-col :span="12">
<el-form-item label="代理主持工作人员:" prop="hostUserId">
2024-12-19 16:52:39 +08:00
<el-select v-model="form.hostUserId" multiple placeholder="请选择" filterable clearable style="width: 100%;">
2024-11-12 18:05:51 +08:00
<el-option
v-for="item in userList"
:key="item.userId"
:label="item.userName"
:value="item.userId"
/>
</el-select>
2024-10-16 15:09:57 +08:00
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
2024-11-12 18:05:51 +08:00
<el-form-item label="备注:">
<el-input type="textarea" placeholder="输入内容" v-model="form.remark" maxlength="100" :readonly="isView"></el-input>
2024-10-16 15:09:57 +08:00
</el-form-item>
</el-col>
2024-11-12 18:05:51 +08:00
</el-row>
2024-10-16 15:09:57 +08:00
<el-row v-if="form.examineOpinion">
<el-col :span="24">
<el-form-item label="审批意见:" prop="examineOpinion">
<el-input type="textarea" v-model="form.examineOpinion" maxlength="100" :readonly="isView"></el-input>
</el-form-item>
</el-col>
2024-11-12 18:05:51 +08:00
</el-row>
2024-10-16 15:09:57 +08:00
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" v-if="!isView"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
2024-11-12 18:05:51 +08:00
2024-10-16 15:09:57 +08:00
<script>
2024-11-12 18:05:51 +08:00
import { listHoliday,getHoliday,delHoliday,addHoliday,updateHoliday,changeHolidayStatus,exportHoliday,getPostName,
getUserList, } from "@/api/process/rest";
2024-10-16 15:09:57 +08:00
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "rules",
dicts: ['apply_status'],
components: { Treeselect },
data() {
return {
userInfo:this.$store.state.user,
orgList:this.$store.state.user.orgList,
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 表格数据
tableList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
isEdit: false,
isView: false,
2024-11-12 18:05:51 +08:00
userList:[],
isAgreeList:[{id:'0',name:'否'},{id:'1',name:'是'}],
2024-10-16 15:09:57 +08:00
timeStatusList:[{id:'1',name:"上午"},{id:'2',name:"下午"}],
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
leaveType:"轮休",
leaveDate: undefined,
examineStatus: undefined
},
personOptions:[],
typeList:[{value:'1',label:'固定班制'},{value:'2',label:'自由工时'}],
attDayList:[{id:0,label:'周一'},{id:1,label:'周二'},{id:2,label:'周三'},{id:3,label:'周四'},{id:4,label:'周五'},{id:5,label:'周六'},{id:6,label:'周日'}],
// 表单参数
form: {},
// 表单校验
rules: {
2024-11-12 18:05:51 +08:00
userName:[
{required: true, message: "申请人不能为空", trigger: "blur" }
],
postName:[
{required: true, message: "职务不能为空", trigger: "blur" }
],
2024-10-16 15:09:57 +08:00
orgId: [
{ required: true, message: "所属部门不能为空", trigger: "blur" }
],
leaveStartDate: [
{ required: true, message: "轮休开始时间不能为空", trigger: "blur" }
],
2024-10-28 11:05:42 +08:00
leaveStartInterval: [
{ required: true, message: "不能为空", trigger: "change" }
],
2024-10-16 15:09:57 +08:00
leaveEndDate: [
{ required: true, message: "轮休结束时间不能为空", trigger: "blur" }
],
2024-10-28 11:05:42 +08:00
leaveEndInterval: [
{ required: true, message: "不能为空", trigger: "change" }
],
2024-10-16 15:09:57 +08:00
leaveDuration: [
{ required: true, message: "轮休时长不能为空", trigger: "blur" }
],
2024-11-12 18:05:51 +08:00
isAgree:[
{ required: true, message: "是否请示领导不能为空", trigger: "blur" }
],
hostUserId:[
{ required: true, message: "代理主持工作人员不能为空", trigger: "blur" }
2024-10-16 15:09:57 +08:00
]
2024-11-12 18:05:51 +08:00
// ,
// leaveReason: [
// { required: true, message: "轮休事由不能为空", trigger: "blur" }
// ]
2024-10-16 15:09:57 +08:00
},
// 开始日期选择限制
startPickerOptions: {
disabledDate: (v) => {
if(this.form.leaveEndDate) {
2024-11-12 18:05:51 +08:00
return v.getTime() > new Date(this.form.leaveEndDate).getTime()
2024-10-16 15:09:57 +08:00
}
},
},
// 结束日期选择限制
endPickerOptions: {
disabledDate: (v) => {
if(this.form.leaveStartDate) {
return v.getTime() < new Date(this.form.leaveStartDate).getTime() - 86400000; // - 86400000是否包括当天
}
},
},
};
},
created() {
this.getList();
2024-11-12 18:05:51 +08:00
this.getUserLists();
2024-10-16 15:09:57 +08:00
},
methods: {
handleDateChange(){
if(this.form.leaveStartDate&&this.form.leaveEndDate){
let daysNumber = this.daysBetween(this.form.leaveStartDate,this.form.leaveEndDate)
console.log(daysNumber)
2024-11-12 18:05:51 +08:00
this.form.leaveDuration=daysNumber+1
2024-11-14 20:16:51 +08:00
//添加默认值
this.form.leaveStartInterval = 1
this.form.leaveEndInterval = 2
2024-11-12 18:05:51 +08:00
// if(this.form.leaveStartInterval==1&&this.form.leaveEndInterval==1){
// this.form.leaveDuration=daysNumber+0.5
// }else if(this.form.leaveStartInterval==1&&this.form.leaveEndInterval==2){
// this.form.leaveDuration=daysNumber+1
// }else if(this.form.leaveStartInterval==2&&this.form.leaveEndInterval==2){
// this.form.leaveDuration=daysNumber+0.5
// }else if(this.form.leaveStartInterval==2&&this.form.leaveEndInterval==1){
// this.form.leaveDuration=daysNumber
// }
2024-10-16 15:09:57 +08:00
}
},
daysBetween(date1, date2){
const oneDay = 24 * 60 * 60 * 1000;
const date1Ms = new Date(date1).getTime()
const date2Ms = new Date(date2).getTime()
const diff = Math.abs(date1Ms - date2Ms); // 计算两日期的差值
return diff / oneDay; // 返回天数
},
/** 查询列表 */
2024-11-12 18:05:51 +08:00
getList() {
2024-10-16 15:09:57 +08:00
this.loading = true;
listHoliday(this.queryParams).then(response => {
this.tableList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},
2024-11-12 18:05:51 +08:00
getUserLists(){
const Id = this.$store.state.user.id;
getUserList(Id).then(response => {
this.userList = response.data.data;
console.log("userList",this.userList)
});
},
2024-10-16 15:09:57 +08:00
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
userId:this.userInfo.id,
userName:this.userInfo.name,
orgId: undefined,
leaveStartDate: undefined,
2024-10-28 11:05:42 +08:00
leaveStartInterval:undefined,
2024-10-16 15:09:57 +08:00
leaveEndDate: undefined,
2024-10-28 11:05:42 +08:00
leaveEndInterval:undefined,
leaveDuration:undefined,
2024-10-16 15:09:57 +08:00
leaveType:"轮休",
examineStatus:"0",
2024-11-12 18:05:51 +08:00
isAgree: "0",
hostUserId:[],
2024-10-16 15:09:57 +08:00
leaveReason:undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
console.log(this.userInfo)
console.log(this.orgList)
this.reset();
2024-11-12 18:05:51 +08:00
const Id = this.$store.state.user.id;
getPostName(Id).then(response => {
this.form.postName = response.data.postName;
this.open = true;
this.isView = false;
this.title = "新增";
});
2024-10-16 15:09:57 +08:00
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.Id)
this.single = selection.length!=1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const Id = row.id
2024-11-12 18:05:51 +08:00
const userId = this.$store.state.user.id;
let postName;
getPostName(userId).then(response => {
postName = response.data.postName;
return getHoliday(Id);
}).then(holidayResponse => {
// 更新表单的 holiday 信息
this.form = holidayResponse.data;
console.log(this.form);
// 转换 hostUserId 字段为整数数组
2024-11-14 20:15:11 +08:00
if(this.form.hostUserId ==null){
this.$set(this.form, "hostUserId", 0);
}else{
let numArr = this.form.hostUserId.split(",");
let num = numArr.map(item => parseInt(item)); // 使用 map 简化代码
this.$set(this.form, "hostUserId", num);
}
2024-11-12 18:05:51 +08:00
this.$set(this.form,"postName",postName)
// 更新视图状态
2024-10-16 15:09:57 +08:00
this.open = true;
this.isView = false;
this.title = "编辑";
});
},
handleView(row) {
this.reset();
const Id = row.id
2024-11-12 18:05:51 +08:00
const userId = this.$store.state.user.id;
let postName;
getPostName(userId).then(response => {
postName = response.data.postName;
return getHoliday(Id);
}).then(holidayResponse => {
// 更新表单的 holiday 信息
this.form = holidayResponse.data;
console.log(this.form);
// 转换 hostUserId 字段为整数数组
2024-11-14 20:15:11 +08:00
if(this.form.hostUserId ==null){
this.$set(this.form, "hostUserId", 0);
}else{
let numArr = this.form.hostUserId.split(",");
let num = numArr.map(item => parseInt(item)); // 使用 map 简化代码
this.$set(this.form, "hostUserId", num);
}
2024-11-12 18:05:51 +08:00
this.$set(this.form,"postName",postName)
// 更新视图状态
2024-10-16 15:09:57 +08:00
this.open = true;
this.isView = true;
this.title = "查看";
});
},
//选择部门
changDept(e){
console.log(e)
this.orgList.forEach(item=>{
if(item.id==e){
this.form.orgName = item.name
}
})
},
/** 提交按钮 */
submitForm: function() {
console.log(this.form)
this.$refs["form"].validate(valid => {
if (valid) {
console.log(this.form)
2024-11-12 18:05:51 +08:00
var list = this.form.hostUserId.join(",");
2024-11-14 20:15:11 +08:00
// 将字符串分割成数组
const userIdArray = list.split(',');
// 检查数组中是否同时存在0和其他非0的值
const containsZero = userIdArray.includes('0');
const containsOtherValues = userIdArray.some(id => id !== '0');
if (containsZero && containsOtherValues) {
this.$modal.msgError("选择’/‘后不能在选择其他人员");
return ;
}
2024-11-12 18:05:51 +08:00
this.form.hostUserId = list;
2024-10-16 15:09:57 +08:00
if (this.form.id != undefined) {
this.form.examineStatus=0
updateHoliday(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addHoliday(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
handleBack(row) {
2024-11-14 20:15:11 +08:00
var that = this;
2024-10-16 15:09:57 +08:00
this.$modal.confirm('是否确认撤回该申请?').then(function() {
let param = {
id:row.id,
examineStatus:'3',
}
changeHolidayStatus(param).then(response => {
2024-11-14 20:15:11 +08:00
that.getList();
2024-10-16 15:09:57 +08:00
this.$modal.msgSuccess("撤回成功");
});
})
},
/** 删除按钮操作 */
handleDelete(row) {
const Ids = row.id;
2024-10-22 15:34:01 +08:00
this.$modal.confirm('是否确认删除该申请?').then(function() {
2024-10-16 15:09:57 +08:00
return delHoliday(Ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
2024-10-16 18:54:28 +08:00
this.queryParams.exportType="查询";
exportHoliday(this.queryParams).then(res => {
2024-10-17 11:15:22 +08:00
this.downloadFile({ fileName: `轮休_${new Date().getTime()}.xlsx`, fileData: res, fileType: 'application/vnd.ms-excel;charset=utf-8' })
2024-10-16 18:54:28 +08:00
})
2024-10-16 15:09:57 +08:00
},
2024-11-12 18:05:51 +08:00
2024-10-16 15:09:57 +08:00
}
};
2024-11-12 18:05:51 +08:00
</script>