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.

279 lines
7.8 KiB

3 years ago
<template>
<div v-if="detail">
<xy-dialog
:form="form"
:is-show.sync="isShow"
3 years ago
:width='84'
3 years ago
title="排班"
type="form"
@submit="submit">
<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" disabled placeholder="请选择产品" style="width: 300px">
<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>
<template v-slot:extraFormBottom>
<el-calendar>
3 years ago
<template v-slot:dateCell="{date, data}">
<el-popover
ref="popover"
placement="top"
trigger="click"
width="300">
<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>
<template v-if="pickType === 1">
<el-time-select
v-model="form.start_time"
:picker-options="{
start: '08:30',
step: '00:15',
end: '18:30'
}"
placeholder="开始时间">
</el-time-select>
</template>
<template v-else>
<el-time-select
v-model="form.end_time"
:picker-options="{
start: '08:30',
step: '00:15',
end: '18:30',
minTime: form.start_time
}"
placeholder="结束时间">
</el-time-select>
</template>
<el-select v-model="form.nurse_id">
<el-option
v-for="item in nurses"
:key="item.id"
:value="item.id"
:label="item.name"></el-option>
</el-select>
<Button type="primary" @click="dateConfirm"></Button>
</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
}
},
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
}
}
},
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(){
this.pickType = 2
this.$refs['popover'].doClose()
console.log(this.$refs['popover'].showPopper)
},
datePicked(data,date){
console.log(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}`
this.form.end_time = `${this.dateEndPick} ${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) {
this.getCustomer()
} else {
}
}
}
}
</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>