个人的排班日历查询功能

This commit is contained in:
JinLu.Yin 2022-06-11 23:10:43 +08:00
parent 8f8455eca7
commit b52d7118d2
3 changed files with 479 additions and 5 deletions

View File

@ -0,0 +1,258 @@
<template>
<el-dialog title="人员选择"
v-if="showFlag"
:visible.sync="showFlag"
:modal= false
width="80%"
center
>
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-input
v-model="deptName"
placeholder="请输入部门名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container">
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
default-expand-all
@node-click="handleNodeClick"
/>
</div>
</el-col>
<!--用户数据-->
<el-col :span="20" :xs="24">
<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"
placeholder="请输入用户名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="手机号码" prop="phonenumber">
<el-input
v-model="queryParams.phonenumber"
placeholder="请输入手机号码"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</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-table v-loading="loading" :data="userList" @current-change="handleCurrent" @row-dblclick="handleRowDbClick">
<el-table-column width="55" align="center" >
<template v-slot="scope">
<el-radio v-model="selectedId" :label="scope.row.userId" @change="handleRowChange(scope.row)">{{""}}</el-radio>
</template>
</el-table-column>
<el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
<el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
<el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />
<el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible" width="120" />
<el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[6].visible" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmSelect"> </el-button>
<el-button @click="showFlag=false"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus } from "@/api/system/user";
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "UserSingleSelect",
dicts: ['sys_normal_disable', 'sys_user_sex'],
components: { Treeselect },
data() {
return {
showFlag:false,
//
loading: true,
//
selectedId: null,
selectedRow: null,
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
userList: null,
//
title: "",
//
deptOptions: undefined,
//
open: false,
//
deptName: undefined,
//
dateRange: [],
//
postOptions: [],
//
roleOptions: [],
//
form: {},
defaultProps: {
children: "children",
label: "label"
},
//
queryParams: {
pageNum: 1,
pageSize: 10,
userName: undefined,
phonenumber: undefined,
status: undefined,
deptId: undefined
},
//
columns: [
{ key: 0, label: `用户编号`, visible: true },
{ key: 1, label: `用户名称`, visible: true },
{ key: 2, label: `用户昵称`, visible: true },
{ key: 3, label: `部门`, visible: true },
{ key: 4, label: `手机号码`, visible: true },
{ key: 5, label: `状态`, visible: true },
{ key: 6, label: `创建时间`, visible: true }
],
};
},
watch: {
//
deptName(val) {
this.$refs.tree.filter(val);
}
},
created() {
this.getList();
this.getTreeselect();
},
methods: {
/** 查询用户列表 */
getList() {
this.loading = true;
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.userList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then(response => {
debugger;
this.deptOptions = response.data;
});
},
//
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
//
handleNodeClick(data) {
this.queryParams.deptId = data.id;
this.handleQuery();
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
handleCurrent(row){
if(row){
this.selectedRow = row;
}
},
//
handleRowDbClick(row){
if(row){
this.selectedRow = row;
this.$emit('onSelected',this.selectedRow);
this.showFlag = false;
}
},
//
handleRowChange(row) {
debugger;
if(row){
this.selectedRow = row;
}
},
//
confirmSelect(){
if(this.selectedId == null || this.selectedId == 0){
this.$notify({
title:'提示',
type:'warning',
message: '请至少选择一条数据!'
});
return;
}
this.$emit('onSelected',this.selectedRow);
this.showFlag = false;
}
}
};
</script>

View File

@ -7,7 +7,9 @@
<el-tab-pane label="班组">
<TeamView></TeamView>
</el-tab-pane>
<el-tab-pane label="个人"></el-tab-pane>
<el-tab-pane label="个人">
<UserView></UserView>
</el-tab-pane>
</el-tabs>
</div>
</template>
@ -15,8 +17,9 @@
<script>
import CalendarTypeView from "./calendarType.vue"
import TeamView from "./team.vue"
import UserView from "./person.vue"
export default {
components:{CalendarTypeView,TeamView},
components:{CalendarTypeView,TeamView,UserView},
data(){
return {

View File

@ -1,15 +1,228 @@
<template>
<div class="app-container">
<el-container>
<el-header height="20px">
<el-form :model="form" size="small" :inline="true" label-width="100px">
<el-form-item label="人员" prop="nickName">
<el-input
v-model="form.nickName"
placeholder="请选择查询的人员"
clearable
readonly="readonly"
>
<el-button slot="append" @click="handleQuery" icon="el-icon-search"></el-button>
</el-input>
<UserSingleSelect ref="userSelect" @onSelected="onUserSelected"></UserSingleSelect>
</el-form-item>
</el-form>
</el-header>
<el-main>
<el-calendar v-loading="loading" v-model="date">
<template slot="dateCell" slot-scope="{date, data }">
<div>
<el-row>
<el-col :span="6">
<div class="solar">
{{ data.day.split('-')[2] }}
</div>
</el-col>
<el-col :span="12">
<div class="lunar" :class="{ festival : isFestival(date, data) }">{{ solarDate2lunar(data.day) }}</div>
</el-col>
<el-col :span="6">
<el-tag v-if="holidayList.indexOf(data.day) ==-1" effect="dark"></el-tag>
<el-tag v-else effect="dark" type="success"></el-tag>
</el-col>
</el-row>
<el-row v-for="calendarDay in calendarDayList " :key="calendarDay.theDay">
<el-col :span="24" v-if="calendarDay.theDay == data.day && holidayList.indexOf(data.day) ==-1">
<div v-for="teamShift in calendarDay.teamShifts" :key="teamShift.orderNum" class="grid-content">
<el-button v-if="teamShift.orderNum == 1" type="success" icon="el-icon-sunrise">{{ teamShift.teamName }}</el-button>
<el-button v-if="teamShift.orderNum ==2 && calendarDay.shiftType=='SHIFT_THREE'" type="warning" icon="el-icon-sunny">{{ teamShift.teamName }}</el-button>
<el-button v-if="teamShift.orderNum ==2 && calendarDay.shiftType=='SHIFT_TWO'" type="info" icon="el-icon-moon">{{ teamShift.teamName }}</el-button>
<el-button v-if="teamShift.orderNum ==3 && calendarDay.shiftType=='SHIFT_THREE'" type="info" icon="el-icon-moon">{{ teamShift.teamName }}</el-button>
</div>
</el-col>
</el-row>
</div>
</template>
</el-calendar>
</el-main>
</el-container>
</div>
</template>
<script>
import { listCalholiday } from "@/api/mes/cal/calholiday";
import { listCalendars } from "@/api/mes/cal/calendar";
import UserSingleSelect from "@/components/userSelect/single.vue"
import calendar from '@/utils/calendar';
export default {
name: 'UserView',
dicts:['mes_calendar_type'],
components :{UserSingleSelect},
data(){
return {
//
loading: true,
date: new Date(),
holidayList:[],//
workdayList:[],//
selectedType:null,
form:{},
calendarDayList:[
{
theDay:'2022-06-04',
shiftType: 'SHIFT_TWO',
teamShifts:[{teamName: '注塑1组',shiftName:'白班',orderNum: 1},{teamName: '注塑2组',shiftName:'中班',orderNum: 2},{teamName: '注塑3组',shiftName:'晚班',orderNum: 3}]
},
{
theDay:'2022-06-13',
shiftType: 'SHIFT_TWO',
teamShifts:[{teamName: '注塑1组',shiftName:'白班',orderNum: 1},{teamName: '注塑2组',shiftName:'中班',orderNum: 2},{teamName: '注塑3组',shiftName:'晚班',orderNum: 3}]
},
{
theDay:'2022-06-14',
shiftType: 'SHIFT_THREE',
teamShifts:[{teamName: '注塑1组',shiftName:'白班',orderNum: 1},{teamName: '注塑2组',shiftName:'中班',orderNum: 2},{teamName: '注塑3组',shiftName:'晚班',orderNum: 3}]
}
],
queryParams: {
theDay: null,
holidayType: null,
startTime: null,
endTime: null,
},
}
},
watch:{
date:{
handler(newVal,oldVal){
console.log(newVal.getFullYear()+'-'+(newVal.getMonth()+1)+'-'+newVal.getDate());
}
}
},
created() {
this.getList();
},
methods:{
/** 查询节假日设置列表 */
getList() {
this.loading = true;
this.holidayList =[];
this.workdayList =[];
let that = this;
listCalholiday(this.queryParams).then(response => {
if(response.data !=null){
response.data.forEach(theDay => {
if(theDay.holidayType =='HOLIDAY'){
that.holidayList.push(theDay.theDay);
}else{
that.workdayList.push(theDay.theDay);
}
});
this.loading = false;
}
});
},
//
handleQuery(){
this.$refs.userSelect.showFlag = true;
},
//
onUserSelected(row){
this.form.nickName = row.nickName;
this.loading = true;
var param = {
queryType: 'USER',
userId: row.userId
}
listCalendars(param).then(response =>{
this.calendarDayList = response.data;
this.loading = false;
});
},
isFestival(slotDate, slotData) {
let solarDayArr = slotData.day.split('-');
let lunarDay = calendar.solar2lunar(solarDayArr[0], solarDayArr[1], solarDayArr[2])
// \\
let festAndTerm = [];
festAndTerm.push(lunarDay.festival == null ? '' : ' ' + lunarDay.festival)
festAndTerm.push(lunarDay.lunarFestival == null ? '' : '' + lunarDay.lunarFestival)
festAndTerm.push(lunarDay.Term == null ? '' : '' + lunarDay.Term)
festAndTerm = festAndTerm.join('')
return festAndTerm != ''
},
solarDate2lunar(solarDate) {
var solar = solarDate.split('-')
var lunar = calendar.solar2lunar(solar[0], solar[1], solar[2])
let lunarMD = lunar.IMonthCn + lunar.IDayCn;
// \\
let festAndTerm = [];
festAndTerm.push(lunar.festival == null ? '' : ' ' + lunar.festival)
festAndTerm.push(lunar.lunarFestival == null ? '' : '' + lunar.lunarFestival)
festAndTerm.push(lunar.Term == null ? '' : '' + lunar.Term)
festAndTerm = festAndTerm.join('')
return festAndTerm == '' ? lunarMD : festAndTerm
}
}
}
</script>
<style>
.grid-content{
padding: 5px 0;
}
.el-group-list.el-radio-group{
display: flex;
flex-direction: column;
align-items:stretch;
}
.el-group-list.el-radio-group .el-radio-button:first-child .el-radio-button__inner,
.el-group-list.el-radio-group .el-radio-button:last-child .el-radio-button__inner,
.el-group-list.el-radio-group .el-radio-button:first-child .el-radio-button__inner,
.el-group-list.el-radio-group .el-radio-button__inner
{
border-radius: 0px !important;
border: none !important;
}
.el-group-list.el-radio-group .el-radio-button{
border-bottom: 1px solid #F7F7F7 !important;
}
.el-group-list.el-radio-group{
border: 1px solid #dcdfe6;
}
.el-group-list.el-radio-group > label > span{
width: 100%;
text-align: left;
padding-left: 20px;
}
/**本月周末设置为红色*/
.el-calendar-table .current:nth-last-child(-n+2) .solar {
color: red;
font-size: small;
}
/**本月农历设置为灰色*/
.el-calendar-table .current .lunar {
color: #606266;
font-size: small;
}
/**本月农历节日设置为红色*/
.el-calendar-table .current .lunar.festival {
color: green;
font-size: small;
}
/**节假日背景设置为绿色 */
.el-calendar-table .holiday {
background-color: #88E325;
}
</style>