值班计划

This commit is contained in:
cool 2024-03-23 14:29:13 +08:00
parent 2619c97307
commit e9a4dd4f3f
1 changed files with 149 additions and 56 deletions

View File

@ -1,15 +1,15 @@
<template>
<div class="app-container">
<div class="filter-container">
<div class="filter-container clearfix">
<el-button
style="margin-left: 40px"
class="filter-item"
class="filter-item fr"
type="primary"
@click="handleExport"
>
导出
</el-button>
<el-button class="filter-item" style="margin-left: 10px" type="primary" @click="handleEdit">
<el-button class="filter-item fr" style="margin-left: 10px" type="primary" @click="handleEdit">
编辑
</el-button>
</div>
@ -27,6 +27,72 @@
</div>
<div class="content">
<h4 class="text-center">排班计划</h4>
<table v-if="currentTime" class="custom-table">
<thead>
<tr>
<th />
<th>周一</th>
<th>周二</th>
<th>周三</th>
<th>周四</th>
<th>周五</th>
<th>周六</th>
<th>周日</th>
</tr>
</thead>
<tbody v-if="planEditMode">
<tr>
<td>上午</td>
<td><el-input v-model="temp.mon" /></td>
<td><el-input v-model="temp.tue" /></td>
<td><el-input v-model="temp.wed" /></td>
<td><el-input v-model="temp.thu" /></td>
<td><el-input v-model="temp.fri" /></td>
<td><el-input v-model="temp.sat" /></td>
<td><el-input v-model="temp.sun" /></td>
</tr>
<tr>
<td>下午</td>
<td><el-input v-model="temp.mon1" /></td>
<td><el-input v-model="temp.tue1" /></td>
<td><el-input v-model="temp.wed1" /></td>
<td><el-input v-model="temp.thu1" /></td>
<td><el-input v-model="temp.fri1" /></td>
<td><el-input v-model="temp.sat1" /></td>
<td><el-input v-model="temp.sun1" /></td>
</tr>
</tbody>
<tbody v-else>
<tr>
<td>上午</td>
<td>{{ temp.mon }}</td>
<td>{{ temp.tue }}</td>
<td>{{ temp.wed }}</td>
<td>{{ temp.thu }}</td>
<td>{{ temp.fri }}</td>
<td>{{ temp.sat }}</td>
<td>{{ temp.sun }}</td>
</tr>
<tr>
<td>下午</td>
<td>{{ temp.mon1 }}</td>
<td>{{ temp.tue1 }}</td>
<td>{{ temp.wed1 }}</td>
<td>{{ temp.thu1 }}</td>
<td>{{ temp.fri1 }}</td>
<td>{{ temp.sat1 }}</td>
<td>{{ temp.sun1 }}</td>
</tr>
</tbody>
</table>
<div v-show="planEditMode" class="clearfix" style="margin-top: 20px">
<el-button class="filter-item fr" style="margin-left: 40px" type="primary" @click="handleExit">
取消
</el-button>
<el-button class="filter-item fr" style="margin-left: 10px" type="primary" @click="handleSave">
保存
</el-button>
</div>
</div>
</div>
</div>
@ -45,14 +111,20 @@ import { downloadFile } from '@/utils/download'
import { exportDutyPlan, getDutyPlan, getTimeList, updateDutyPlan } from '@/api/risk/dutyPlan'
const defaultTmp = {
teamId: '',
teamName: '',
teamLeader: '',
teamLeaderPhone: '',
evalTime: '',
evaluator: '',
score: 0,
content: ''
mon: '',
mon1: '',
tue: '',
tue1: '',
wed: '',
wed1: '',
thu: '',
thu1: '',
fri: '',
fri1: '',
sat: '',
sat1: '',
sun: '',
sun1: ''
}
export default {
components: { Pagination },
@ -65,25 +137,13 @@ export default {
currentTime: '',
total: 0,
listLoading: false,
tableHeight: 650,
showReviewer: false,
temp: _.cloneDeep(defaultTmp),
dialogFormVisible: false,
dialogStatus: '',
downloadLoading: false,
planEditMode: false,
textMap: {
update: '编辑',
create: '新增'
},
dialogPvVisible: false,
rules: {
teamId: [{ required: true, message: '不能为空', trigger: 'change' }],
teamName: [{ required: true, message: '不能为空', trigger: 'blur' }],
teamLeader: [{ required: true, message: '不能为空', trigger: 'blur' }],
teamLeaderPhone: [{ required: true, message: '不能为空', trigger: 'blur' }],
score: [{ required: true, message: '不能为空', trigger: 'change' }],
content: [{ required: true, message: '不能为空', trigger: 'blur' }]
}
dialogPvVisible: false
}
},
created() {
@ -95,15 +155,39 @@ export default {
this.currentTime = index
this.getDutyPlan()
},
//
handleSave() {
if (this.currentTime) {
this.temp.createDay = this.currentTime
updateDutyPlan(this.temp).then((response) => {
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 2000
})
this.getDutyPlan()
this.planEditMode = false
}).finally(() => {
// this.dialogFormVisible = false
})
}
},
handleExit() {
this.planEditMode = false
this.temp = _.cloneDeep(defaultTmp)
},
//
handleExport() {
exportDutyPlan().then(res => {
downloadFile({ fileName: '值班计划详情.xlsx', fileData: res, fileType: 'application/vnd.ms-excel;charset=utf-8' })
})
if (this.currentTime) {
exportDutyPlan({ createDay: this.currentTime }).then(res => {
downloadFile({ fileName: '值班计划详情.xlsx', fileData: res, fileType: 'application/vnd.ms-excel;charset=utf-8' })
})
}
},
//
handleEdit(val) {
this.planEditMode = true
},
//
getList() {
@ -124,11 +208,30 @@ export default {
//
getDutyPlan() {
this.listLoading = true
getDutyPlan({ createDay: this.currentTime }).then((response) => {
this.list = response.data.map(item => {
return item
getDutyPlan({ createDay: this.currentTime }).then((res) => {
const { data } = res
const tmp = {}
data.forEach(item => {
const { type } = item
if (type === '1') {
tmp.mon = item.mon
tmp.tue = item.tue
tmp.wed = item.wed
tmp.thu = item.thu
tmp.fri = item.fri
tmp.sat = item.sat
tmp.sun = item.sun
} else if (type === '2') {
tmp.mon1 = item.mon
tmp.tue1 = item.tue
tmp.wed1 = item.wed
tmp.thu1 = item.thu
tmp.fri1 = item.fri
tmp.sat1 = item.sat
tmp.sun1 = item.sun
}
})
this.total = response.total
this.temp = Object.assign({}, tmp)
}).finally(() => {
this.listLoading = false
})
@ -138,28 +241,6 @@ export default {
this.listQuery.pageNum = 1
this.getList()
},
//
handleCreate() {
this.dialogStatus = 'create'
this.dialogFormVisible = true
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
addQualityItem(this.temp).then((response) => {
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 2000
})
this.getList()
}).finally(() => {
this.dialogFormVisible = false
})
}
})
},
//
handleUpdate(row) {
this.dialogStatus = 'update'
@ -175,7 +256,7 @@ export default {
type: 'success',
duration: 2000
})
this.getList()
this.getDutyPlan()
}).finally(() => {
this.dialogFormVisible = false
})
@ -221,6 +302,18 @@ export default {
}
.content {
flex: 1;
padding-left: 15px;
}
}
.custom-table {
border-collapse: collapse;
width: 100%;
th, td {
width: 12.5%;
border: 1px solid #e6e6e6;
padding: 8px;
text-align: left;
}
}
</style>