You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 lines
9.5 KiB

3 years ago
<template>
<div v-if="detail">
<xy-dialog
3 years ago
ref="dialog"
3 years ago
:form="form"
3 years ago
:rules="rules"
3 years ago
:is-show.sync="isShow"
3 years ago
:width='84'
3 years ago
title="排班"
type="form"
3 years ago
@submit="submit"
@reset="pickType = 1,dateStartPick = '',dateEndPick = ''">
3 years ago
<template v-slot:extraFormTop>
<div :style="{
'display':'flex',
'align-items':'center',
'flex-wrap':'wrap',
'min-width':'380px'
}">
<el-form-item>
3 years ago
<div class="xy-table-item">
3 years ago
<div class="xy-table-item-label">
性别
</div>
<div class="xy-table-item-content">
3 years ago
<el-input v-model="detail.sex" readonly style="width: 300px;"></el-input>
3 years ago
</div>
</div>
</el-form-item>
<el-form-item>
<div class="xy-table-item">
<div class="xy-table-item-label">
年龄
</div>
<div class="xy-table-item-content">
3 years ago
<el-input :value="ageComputed" readonly style="width: 300px;"></el-input>
3 years ago
</div>
</div>
</el-form-item>
<el-form-item>
3 years ago
<div class="xy-table-item">
3 years ago
<div class="xy-table-item-label">
身份证号
</div>
<div class="xy-table-item-content">
3 years ago
<el-input :value="detail.idcard" readonly style="width: 300px;"></el-input>
3 years ago
</div>
</div>
</el-form-item>
<el-form-item>
3 years ago
<div class="xy-table-item">
3 years ago
<div class="xy-table-item-label">
失能等级
</div>
<div class="xy-table-item-content">
3 years ago
<el-select v-model="detail.level_id" disabled placeholder="请选择失能等级" style="width: 300px">
<el-option v-for="item in levels" :key="item.id" :label="item.value" :value="item.id"></el-option>
3 years ago
</el-select>
</div>
</div>
</el-form-item>
<el-form-item>
3 years ago
<div class="xy-table-item">
3 years ago
<div class="xy-table-item-label">
备注
</div>
<div class="xy-table-item-content">
3 years ago
<el-input v-model="detail.remark" :autosize="{minRows:2}" placeholder="请输入备注" readonly
style="width: 300px;"
type="textarea"></el-input>
3 years ago
</div>
</div>
</el-form-item>
</div>
</template>
<template v-slot:customer_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
客户
</div>
<div class="xy-table-item-content">
3 years ago
<el-select v-model="form.customer_id" disabled placeholder="请选择客户" style="width: 300px">
<el-option v-for="item in customers" :key="item.id" :label="item.name" :value="item.id"></el-option>
3 years ago
</el-select>
</div>
</div>
</template>
<template v-slot:product_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
产品
</div>
<div class="xy-table-item-content">
3 years ago
<el-select v-model="form.product_id" placeholder="请选择产品" style="width: 300px">
3 years ago
<el-option v-for="item in products" :key="item.id" :label="item.name" :value="item.id"></el-option>
3 years ago
</el-select>
</div>
</div>
</template>
3 years ago
<template v-slot:order_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
订单
</div>
<div class="xy-table-item-content">
<el-select v-model="form.order_id" placeholder="请选择订单" style="width: 300px">
<el-option v-for="item in orders" :key="item.id" :label="item.no" :value="item.id"></el-option>
</el-select>
</div>
</div>
</template>
3 years ago
<template v-slot:extraFormBottom>
<el-calendar>
3 years ago
<template v-slot:dateCell="{date, data}">
<el-popover
3 years ago
:ref="`popover-${data.day}`"
3 years ago
placement="top"
trigger="click"
3 years ago
width="280">
3 years ago
<div
slot="reference"
:style="
{
'padding':'8px',
}"
:class="{
'date-select':isInDate(data.day)
}"
style="width: 100%;height: 100%"
@click="datePicked(data,date)">
{{ data.day.split('-').slice(1).join('-') }} {{ isInDate(data.day) ? '✔️' : '' }}
</div>
<template>
3 years ago
<div style="display: flex;flex-direction: column;justify-content: center;align-items: center">
<template v-if="pickType === 1">
<el-time-select
style="width: 200px;margin-bottom: 10px"
v-model="form.start_time"
:picker-options="{
start: '00:00',
step: '00:5',
end: '23:59'
3 years ago
}"
3 years ago
placeholder="开始时间">
</el-time-select>
</template>
<template v-else>
<el-time-select
style="width: 200px;margin-bottom: 10px"
v-model="form.end_time"
:picker-options="{
start: '00:00',
step: '00:5',
end: '23:59',
3 years ago
minTime: form.start_time
}"
3 years ago
placeholder="结束时间">
</el-time-select>
</template>
<el-select placeholder="请选择护工" v-model="form.nurse_id" style="width: 200px;margin-bottom: 10px">
<el-option
v-for="item in nurses"
:key="item.id"
:value="item.id"
:label="item.name"></el-option>
</el-select>
<div style="width: 200px;display: flex;justify-content: space-between;">
<Button ghost type="primary" @click="$refs[`popover-${data.day}`].doClose()"></Button>
<Button type="primary" @click="dateConfirm(data)"></Button>
</div>
</div>
3 years ago
</template>
</el-popover>
</template>
3 years ago
</el-calendar>
</template>
</xy-dialog>
</div>
</template>
<script>
3 years ago
import {customerDetail,scheduleSave} from '@/api/schedule'
3 years ago
export default {
3 years ago
props: {
customers: {
type: Array,
default: () => []
3 years ago
},
3 years ago
products: {
type: Array,
default: () => []
3 years ago
},
3 years ago
nurses: {
type: Array,
default: () => []
3 years ago
},
3 years ago
levels: {
type: Array,
default: () => []
3 years ago
},
orders:{
type: Array,
default: () => []
3 years ago
}
},
data() {
return {
productId: '',
customerId: '',
isShow: false,
3 years ago
detail: {},
dateStartPick:'',
dateEndPick:'',
pickType:1,
3 years ago
form: {
3 years ago
customer_id: '',
product_id: '',
order_id: '',
start_time: '',
end_time: '',
nurse_id: '',
3 years ago
},
rules:{
product_id:[
{required:true,message:'请选择产品'}
],
order_id:[
{required:true,message:'请选择订单'}
3 years ago
],
start_time:[
{required:true,message:'请选择开始时间'}
],
end_time:[
{required:true,message:'请选择结束时间'}
3 years ago
]
3 years ago
}
}
},
methods: {
async getCustomer() {
const res = await customerDetail({
product_id: this.form.product_id,
3 years ago
id: this.form.customer_id,
3 years ago
})
console.log(res)
this.detail = res.detail
},
3 years ago
dateConfirm(data){
if(this.pickType === 1){
this.pickType = 2
return
}
this.$refs[`popover-${data.day}`].doClose()
3 years ago
},
datePicked(data,date){
if(this.pickType === 1){
this.dateStartPick = data.day
}
if(this.pickType === 2){
this.dateEndPick = data.day
}
},
3 years ago
submit() {
3 years ago
this.form.start_time = `${this.dateStartPick} ${this.form.start_time}`
3 years ago
this.form.end_time = `${this.dateEndPick || this.dateStartPick} ${this.form.end_time}`
3 years ago
3 years ago
scheduleSave(this.form).then(res => {
this.$successMessage('排班','')
this.isShow = false
})
3 years ago
}
},
3 years ago
computed: {
ageComputed() {
3 years ago
return new Date().getFullYear() - new Date(this.detail.birthday).getFullYear()
3 years ago
},
isInDate(){
return function (day){
let startTimer = new Date(this.dateStartPick).getTime()
let endTimer = new Date(this.dateEndPick).getTime()
let dayTimer = new Date(day).getTime()
return dayTimer >= startTimer && dayTimer <= endTimer
}
3 years ago
}
},
watch: {
isShow(val) {
if (val) {
3 years ago
//this.getCustomer()
3 years ago
} else {
3 years ago
this.pickType = 1
this.dateEndPick = ''
this.dateStartPick = ''
this.$refs['dialog'].reset()
3 years ago
}
}
}
}
</script>
<style lang="scss" scoped>
3 years ago
@import "../../../styles/index";
.date-select{
background: $primaryColor;
color: #fff;
}
::v-deep .el-calendar-day{
padding: 0 !important;
}
3 years ago
</style>