gz-att-web-new/src/views/process/restExam/index.vue

554 lines
18 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container" id="restExam">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="姓名" prop="userName">
<el-input v-model="queryParams.userName" />
</el-form-item>
<el-form-item label="部门名称" prop="orgName">
<el-input v-model="queryParams.orgName" />
</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>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
<el-button
type="warning"
plain
icon="el-icon-user-solid"
size="mini"
@click="handleClick"
>一键审批</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange" row-key="id" ref="multipleTable">
<el-table-column type="selection" width="55" align="center" :reserve-selection="true" :selectable="selectableRow" />
<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" />
<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" />
<el-table-column label="轮休开始时间" align="center" prop="leaveStartDate" :show-overflow-tooltip="true" >
<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" >
<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
type="primary" size="mini"
v-if="scope.row.examineStatus==0"
v-hasPermi="['flow:restExam:edit']"
@click="handleUpdate(scope.row)"
>审批</el-button>
<el-button
size="mini"
v-hasPermi="['flow:restExam:query']"
@click="handleView(scope.row)"
>详情</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="170px">
<el-row>
<el-col :span="12">
<el-form-item label="申请人:" prop="userName">
<el-input v-model="form.userName" :readonly="true" />
</el-form-item>
</el-col>
<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>
<el-col :span="12">
<el-form-item label="所属部门:" prop="orgId">
<el-select v-model="form.orgId" disabled>
<el-option
v-for="item in orgList"
: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="createTime">
<el-input v-model="form.createTime" :readonly="true" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="轮休开始时间:" prop="leaveStartDate">
<el-input v-model="form.leaveStartDate" :readonly="true" style="width: 70%;"/>
<!-- <el-select v-model="form.leaveStartInterval" style="width: 25%;margin-left: 10px;" disabled>-->
<!-- <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="leaveEndDate">
<el-input v-model="form.leaveEndDate" :readonly="true" style="width: 70%;"/>
<!-- <el-select v-model="form.leaveEndInterval" style="width: 25%;margin-left: 10px;" disabled>-->
<!-- <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="leaveDuration">
<el-input v-model="form.leaveDuration" :readonly="true" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="地点:">
<el-input
v-model="form.location" :clearable="false" style="width: 100%;"
placeholder="请输入地点">
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="是否请示领导同意:" prop="isAgree">
<el-radio-group v-model="form.isAgree">
<el-radio
v-for="item in isAgreeList"
:key="item.id"
:label="item.id"
>{{item.name}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="代理主持工作人员:" prop="hostUserId">
<el-select v-model="form.hostUserId" multiple placeholder="请选择" filterable clearable>
<el-option
v-for="item in userList"
:key="item.userId"
:label="item.userName"
:value="item.userId"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="备注:" prop="remark">
<el-input type="textarea" v-model="form.remark" maxlength="100" :readonly="true"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24" v-if="form.examineOpinion">
<el-form-item label="审批意见:" prop="examineOpinion">
<el-input type="textarea" v-model="form.examineOpinion" maxlength="100" :readonly="true"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="pass" v-if="!isView"> </el-button>
<el-button type="danger" @click="reject" v-if="!isView">不同意</el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="openClick" width="1000px" append-to-body>
<el-form ref="form" :model="formDate" :rules="rules" label-width="170px" style="font-size: 22px;text-align: center;">
<span >确认一键审批</span>
<span style="color: red">{{formDate.number}}</span>
<span>条数据</span>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="passClick" v-if="!isView"> </el-button>
<el-button type="danger" @click="rejectClick" v-if="!isView">不同意</el-button>
<el-button @click="cancelClick"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { checkListHoliday,getHoliday,changeHolidayStatus,exportHoliday,getPostName,getUserList,batchLxCheckStatus } from "@/api/process/rest";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "RestExam",
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: [
{
userName:"张三",
orgName:"公司机关/分公司机关/×××项目部",
createTime:"2024-08-28 1728",
leaveStartDate:"2024-08-29",
leaveStartInterval:"1",
leaveEndDate:"2024-08-29",
leaveEndInterval:"2",
leaveDuration:"1",
examineStatus:"0",
}
],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
openClick: false,
isView: false,
userList:[],
isAgreeList:[{id:'0',name:'否'},{id:'1',name:'是'}],
timeStatusList:[{id:'1',name:"上午"},{id:'2',name:"下午"}],
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
leaveType:"轮休",
userName: undefined,
orgName: 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: {},
formDate: {},
// 表单校验
rules: {
// examineOpinion: [
// { required: true, message: "审批意见不能为空", trigger: "blur" }
// ],
}
};
},
created() {
if(this.$route.query.param){
console.log(this.$route.query.param)
this.queryParams.userName=this.$route.query.param
}
this.getList();
this.getUserLists();
},
methods: {
/** 查询列表 */
getList() {
this.loading = true;
checkListHoliday(this.queryParams).then(response => {
this.tableList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},
getUserLists(){
const Id = this.$store.state.user.id;
console.log(Id)
getUserList(Id).then(response => {
this.userList = response.data.data;
console.log("userList",this.userList)
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
userId:this.userInfo.id,
userName:this.userInfo.name,
orgId: undefined,
leaveStartDate: undefined,
leaveStartInterval:'1',
leaveEndDate: undefined,
leaveEndInterval:'1',
leaveDuration:undefined,
leaveReason:undefined,
isAgree: "0",
hostUserId:[],
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "新增";
},
// 多选框选中数据
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
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;
// 转换 hostUserId 字段为整数数组
let numArr = this.form.hostUserId.split(",");
let num = numArr.map(item => parseInt(item)); // 使用 map 简化代码
this.$set(this.form, "hostUserId", num);
this.$set(this.form,"postName",postName)
this.open = true;
this.isView = false;
this.title = "轮休申请";
});
},
handleView(row) {
this.reset();
const Id = row.id
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 字段为整数数组
let numArr = this.form.hostUserId.split(",");
let num = numArr.map(item => parseInt(item)); // 使用 map 简化代码
this.$set(this.form, "hostUserId", num);
this.$set(this.form,"postName",postName)
this.open = true;
this.isView = true;
this.title = "轮休申请";
});
},
pass(){
this.$refs["form"].validate(valid => {
var name = "";
const selectedOrg = this.orgList.find(org => org.id == this.form.orgId);
if (selectedOrg) {
name = selectedOrg.name;
} else {
name = '';
}
if (valid) {
let param = {
id:this.form.id,
examineStatus:'1',
leaveType:"轮休",
examineOpinion:this.form.examineOpinion,
orgName:name
}
this.changExamStatus(param)
}
});
},
reject(){
this.$refs["form"].validate(valid => {
var name = "";
const selectedOrg = this.orgList.find(org => org.id == this.form.orgId);
if (selectedOrg) {
name = selectedOrg.name;
} else {
name = '';
}
if (valid) {
let param = {
id:this.form.id,
examineStatus:'2',
leaveType:"轮休",
examineOpinion:this.form.examineOpinion,
orgName:name
}
this.changExamStatus(param)
}
});
},
/** 提交 */
changExamStatus(param) {
console.log(param)
changeHolidayStatus(param).then(response => {
this.$modal.msgSuccess("操作成功");
this.open = false;
this.getList();
});
},
/** 导出按钮操作 */
handleExport() {
this.queryParams.exportType="审批";
exportHoliday(this.queryParams).then(res => {
this.downloadFile({ fileName: `轮休_${new Date().getTime()}.xlsx`, fileData: res, fileType: 'application/vnd.ms-excel;charset=utf-8' })
})
},
handleClick() {
if(this.ids.length>0){
this.openClick=true;
this.title = "一键审批";
this.formDate.number = this.ids.length;
}else{
this.$message({ message: '请先勾选数据!', type: 'warning' })
}
},
passClick(){
let param = {
ids:this.ids,
examineStatus:'1',
}
this.batchLxCheckStatus(param)
},
rejectClick(){
let param = {
ids:this.ids,
examineStatus:'2',
}
this.batchLxCheckStatus(param)
},
cancelClick(){
this.openClick = false;
this.resetClick();
},
resetClick() {
this.formDate = {
number: 0,
};
this.resetForm("formDate");
},
selectableRow(row,index){
if(row.examineStatus==0){
return true
}else {
return false
}
},
/** 一键审批 */
batchLxCheckStatus(param) {
console.log(param)
batchLxCheckStatus(param).then(response => {
this.$modal.msgSuccess("操作成功");
this.openClick = false;
this.ids = [];
// 清空选择
this.$refs.multipleTable.clearSelection();
this.getList();
});
},
}
};
</script>