123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608 |
- <template>
- <div class="main-contain">
- <div class="position">
- <bread-crumb :crumbs="crumbs"></bread-crumb>
- <div style="display:flex;align-items:center">
- <el-button type="primary" @click="DeleteStaffSchedule">清除</el-button>
- <el-button type="primary" @click="copyStaffSchedule">复制</el-button>
- <el-button type="primary" icon="el-icon-printer" @click="toPrint">打印</el-button>
- </div>
- </div>
- <div class="app-container">
- <div class="cell clearfix">
- <el-input
- size="small"
- style="width: 150px;"
- class="filter-item"
- v-model.trim="keywords"
- placeholder="请输入医护人员姓名"
- />
- <el-button
- size="small"
- class="filter-item"
- type="primary"
- icon="el-icon-search"
- @click="toSearch"
- >搜索</el-button
- >
- <el-select style="margin-left:10px;width:150px;" v-model="typeValue" placeholder="请选择" @change="changeOption">
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- <el-button @click="lastclick" type="text" style="margin:0 10px;"><上一周({{ weekNum - 1 }})</el-button>
- <div class="dateBox">{{ weekDayArr[0] }}-{{ weekDayArr[6] }}({{ weekNum }})</div>
- <el-button @click="nextclick" type="text" style="margin:0 10px;">下一周({{ weekNum + 1 }})></el-button>
- </div>
- <div style="display:flex;justify-content: space-between;">
- <div style="width: 70%">
- <el-table :data="tableData" border :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)', color: '#606266'}" :row-style="{ color: '#303133' }" @cell-click="clickThis">
- <el-table-column prop="name" label="医护姓名" style="width:16%" align="center">
- <template slot-scope="scope">
- {{scope.row.user_name}}
- </template>
- </el-table-column>
- <el-table-column :label="'周一 (' + weekDayArr[0] + ')'" style="width:200px" align="center">
- <template slot-scope="scope">
- <div @click="hangdleClick(scope.row,scope.$index)">
- <el-dropdown trigger="click" @command="changeSchedule">
- <span class="el-dropdown-link">
- <span v-if="scope.row.class_index == 1">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown" >
- <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" :label="'周二 (' + weekDayArr[1] + ')'" style="width:14%" align="center">
- <template slot-scope="scope">
- <div @click="hangdleClick(scope.row,scope.$index)">
- <el-dropdown trigger="click" @command="changeSchedule">
- <span class="el-dropdown-link">
- <span v-if="scope.row.class_index == 2">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown" >
- <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" :label="'周三 (' + weekDayArr[2] + ')'" style="width:14%" align="center">
- <template slot-scope="scope">
- <div @click="hangdleClick(scope.row,scope.$index)">
- <el-dropdown trigger="click" @command="changeSchedule">
- <span class="el-dropdown-link">
- <span v-if="scope.row.class_index == 3">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown" >
- <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" :label="'周四 (' + weekDayArr[3] + ')'" style="width:14%" align="center">
- <template slot-scope="scope">
- <div @click="hangdleClick(scope.row,scope.$index)">
- <el-dropdown trigger="click" @command="changeSchedule">
- <span class="el-dropdown-link">
- <span v-if="scope.row.class_index ==4">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown" >
- <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" :label="'周五 (' + weekDayArr[4] + ')'" style="width:14%" align="center">
- <template slot-scope="scope">
- <div @click="hangdleClick(scope.row,scope.$index)">
- <el-dropdown trigger="click" @command="changeSchedule">
- <span class="el-dropdown-link">
- <span v-if="scope.row.class_index == 5">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown" >
- <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" :label="'周六 (' + weekDayArr[5] + ')'" style="width:14%" align="center">
- <template slot-scope="scope">
- <div @click="hangdleClick(scope.row,scope.$index)">
- <el-dropdown trigger="click" @command="changeSchedule">
- <span class="el-dropdown-link">
- <span v-if="scope.row.class_index==6">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown" >
- <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" :label="'周日 (' + weekDayArr[6] + ')'" style="width:14%" align="center">
- <template slot-scope="scope">
- <div @click="hangdleClick(scope.row,scope.$index)">
- <el-dropdown trigger="click" @command="changeSchedule">
- <span class="el-dropdown-link">
- <span v-if="scope.row.class_index == 0">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown" >
- <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div class="classBox">
- <div class="classTitle">班种</div>
- <div class="classMain">
- <div v-for="(item,index) in schedulelist" :key="index">
- <p>
- {{item.class_name}} ({{item.timeone_start}}~{{item.timeone_type}}{{item.timeone_end}} <span v-if="item.timetwo_start!=''">{{item.timetwo_start}}~{{item.timetwo_type}}{{item.timetwo_end}}</span> )
- </p>
- </div>
- <el-checkbox style="text-align:center" v-model="isChecked" @change="toContinuous">连续排班</el-checkbox>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
-
-
- <script>
- import BreadCrumb from '@/xt_pages/components/bread-crumb'
- import { getDoctorList,getScheduleList,addSchedule,getStaffScheduleList,getNextWeekList,getScheduleByDoctorId,toSearchScheduleList,DeleteStaffSchedule,copyStaffSchedule,UpdateContinusSchedule } from '@/api/doctorSchedule'
- export default {
- components:{
- BreadCrumb
- },
- data(){
- return{
- crumbs: [
- { path: false, name: '医护排班' },
- { path: '/medicalScheduling/index', name: '医护排班' }
- ],
- keywords:'',
- options: [{
- value: '1',
- label: '全部'
- }, {
- value: '2',
- label: '医生'
- }, {
- value: '3',
- label: '护士'
- }],
- typeValue:'1',
- tableData: [],
- isChecked:true,
- schedulelist:[],
- weekNum:'',
- weekDayArr:[],
- todayDate:'',
- clen:7,
-
-
-
-
-
- nowYear: new Date().getFullYear(),
- schedule_week:0,
- docobj:{},
- class_name:"",
- doctorlist:[],
- schedule_date:"",
- }
- },
- methods:{
- search(){},
- toPrint(){
- this.$router.push({
- path: '/medicalScheduling/schedule/print?starttime='+this.getTimestamp(this.weekDayArr[0])+"&endtime="+this.getTimestamp(this.weekDayArr[6]),
- // query: { date: date }
- })
- },
- getDoctorList(){
- getDoctorList().then(response=>{
- if(response.data.state == 1){
- var list = response.data.data.list
- console.log("医护列表",list)
- this.tableData = list
- this.doctorlist = list
- //获取班种列表
- this.getStaffScheduleList()
- }
- })
- },
- getScheduleList(){
- getScheduleList().then(response=>{
- if(response.data.state == 1){
- var schedulelist = response.data.data.scheduleList
- console.log("schedulelist",schedulelist)
- for(let i=0;i<schedulelist.length;i++){
- if(schedulelist[i].timeone_type == 1){
- schedulelist[i].timeone_type = "当日"
- }
- if(schedulelist[i].timeone_type == 2){
- schedulelist[i].timeone_type = "次日"
- }
- if(schedulelist[i].timetwo_type == 1){
- schedulelist[i].timetwo_type = "当日"
- }
- if(schedulelist[i].timetwo_type == 2){
- schedulelist[i].timetwo_type = "次日"
- }
- }
- this.schedulelist = schedulelist
- }
- })
- },
- hangdleClick(val,index){
- this.docobj = val
- },
- clickThis(row, column, cell, event){
- // console.log("row",row)
- // console.log("column",column)
- // console.log("日期",this.weekDayArr)
- var week = (column.label).split('');
- var weeks = week[0]+week[1]
- console.log("weeks",weeks)
- if(weeks == "周日"){
- this.schedule_week = 0
- this.schedule_date = this.weekDayArr[6]
- }
- if(weeks == "周一"){
- this.schedule_week = 1
- this.schedule_date = this.weekDayArr[0]
- }
- if(weeks=="周二"){
- this.schedule_week = 2
- this.schedule_date = this.weekDayArr[1]
- }
- if(weeks=="周三"){
- this.schedule_week = 3
- this.schedule_date = this.weekDayArr[2]
- }
- if(weeks=="周四"){
- this.schedule_week = 4
- this.schedule_date = this.weekDayArr[3]
- }
- if(weeks == "周五"){
- this.schedule_week = 5
- this.schedule_date = this.weekDayArr[4]
- }
- if(weeks== "周六"){
- this.schedule_week = 6
- this.schedule_date = this.weekDayArr[5]
- }
- },
- changeSchedule(id){
- var class_name = ""
- for(let i=0;i<this.schedulelist.length;i++){
- if(id == this.schedulelist[i].id){
- class_name = this.schedulelist[i].class_name
- }
- }
- let arr = [...this.tableData]
- for(let i=0;i<arr.length;i++){
- if(this.docobj.id == arr[i].id){
- arr[i].class_name = class_name
- arr[i].class_index = this.schedule_week
- }
- }
- console.log("arr",arr)
- this.tableData = arr
- const params = {
- doctor_id:this.docobj.admin_user_id,
- doctor_type:this.docobj.user_type,
- schedule_type:id,
- schedule_week:this.schedule_week,
- start_time:this.getTimestamp(this.weekDayArr[0]),
- end_time:this.getTimestamp(this.weekDayArr[6]),
- schedule_date:this.getTimestamp(this.schedule_date)
- }
- console.log("params",params)
- addSchedule(params).then(response=>{
- if(response.data.state == 1){
- var schedule = response.data.data.schedule
- console.log("schedule",schedule)
- this.$message.success("保存成功")
- this.getStaffScheduleList()
- }
- })
- },
- formatDate(date){
- var year = date.getFullYear()+'.'
- var month = (date.getMonth()+1)+'.';
- var day = date.getDate();
- return year+month+day
- },
- formatDateTwo(date){
- var year = date.getFullYear()+'.'
- var month = (date.getMonth()+1)+'.';
- var day = date.getDate();
- return year+month+day
- },
- addDate(date,n){
- date.setDate(date.getDate()+n);
- return date;
- },
- //
- setDate(date){
- var week = date.getDay()-1;
- date = this.addDate(date,week*-1);
- this.currentFirstDate = new Date(date);
- for(var i = 0;i<this.clen; i++){
- this.weekDayArr.push(this.formatDate(i==0 ? date : this.addDate(date,1)))
-
- }
- },
- //上一周
- lastclick(){
- this.weekDayArr=[]
- this.setDate(this.addDate(this.currentFirstDate,-7));
- this.weekNum = this.weekNum - 1
- if(this.weekNum - 1 == 0){
- let year = this.nowYear - 1
- let month = 12
- let date = 31
- this.weekNum = this.getYearWeek(year,month,date)
- this.nowYear = this.nowYear - 1
- }
- this.getNextWeekList()
- },
- //下一周
- nextclick(){
- this.weekDayArr=[]
- this.setDate(this.addDate(this.currentFirstDate,7));
- this.weekNum = this.weekNum + 1
- if(this.weekNum + 1 == 54){
- let year = this.nowYear + 1
- let month = 1
- let date = 1
- this.weekNum = this.getYearWeek(year,month,date)
- this.nowYear = this.nowYear + 1
- }
- this.getNextWeekList()
- },
-
- getYearWeek(year,month,date){
- /*
- dateNow是当前日期
- dateFirst是当年第一天
- dataNumber是当前日期是今年第多少天
- 用dataNumber + 当前年的第一天的周差距的和在除以7就是本年第几周
- */
- let dateNow = new Date(year, parseInt(month) - 1, date);
- let dateFirst = new Date(year, 0, 1);
- let dataNumber = Math.round((dateNow.valueOf() - dateFirst.valueOf()) / 86400000);
- return Math.ceil((dataNumber + ((dateFirst.getDay() + 1) - 1)) / 7);
- },
- getTimestamp(time) { //把时间日期转成时间戳
- return (new Date(time)).getTime() / 1000
- },
- beforeHandleCommand(item,row){
- return {
- 'command': item,
- 'row': row
- }
- },
-
- //获取所有医护排班数据
- getStaffScheduleList(){
- const params = {
- start_time:this.getTimestamp(this.weekDayArr[0]),
- end_time:this.getTimestamp(this.weekDayArr[6])
- }
- getStaffScheduleList(params).then(response=>{
- if(response.data.state == 1){
- var staffList = response.data.data.staffList
- for(let i=0;i<staffList.length;i++){
- if(staffList[i].schedule_week == 0){
- staffList[i].class_index = 0
- }
- if(staffList[i].schedule_week == 1){
- staffList[i].class_index = 1
- }
- if(staffList[i].schedule_week == 2){
- staffList[i].class_index = 2
- }
- if(staffList[i].schedule_week == 3){
- staffList[i].class_index = 3
- }
- if(staffList[i].schedule_week == 4){
- staffList[i].class_index = 4
- }
- if(staffList[i].schedule_week == 5){
- staffList[i].class_index = 5
- }
- if(staffList[i].schedule_week == 6){
- staffList[i].class_index = 6
- }
- }
- // console.log("staffList--------",staffList)
- // if(staffList.length == 0){
- // this.tableData = this.doctorlist
- // }else{
- // this.tableData = []
- // this.tableData = staffList
- // }
-
- }
- })
- },
-
- //获取上一周下一周的排班数据
- getNextWeekList(){
- const params = {
- start_time:this.getTimestamp(this.weekDayArr[0]),
- end_time:this.getTimestamp(this.weekDayArr[6])
- }
- getNextWeekList(params).then(response=>{
- if(response.data.state == 1){
- var staffList = response.data.data.staffList
- console.log("上下周数据",staffList)
- }
- })
- },
-
- changeOption(id){
- const params = {
- start_time:this.getTimestamp(this.weekDayArr[0]),
- end_time:this.getTimestamp(this.weekDayArr[6]),
- doctor_id:id
- }
- getScheduleByDoctorId(params).then(response=>{
- if(response.data.state == 1){
- var staffList = response.data.data.staffList
- console.log("staffList",staffList)
-
- }
- })
- },
- toSearch(){
- console.log("医护人员姓名",this.keywords)
- var id = 0
- for(let i = 0 ;i<this.doctorlist.length;i++){
- if(this.keywords == this.doctorlist[i].user_name){
- id = this.doctorlist[i].admin_user_id
- }
- }
- const params = {
- doctor_id:id,
- start_time:this.getTimestamp(this.weekDayArr[0]),
- end_time:this.getTimestamp(this.weekDayArr[6])
- }
- toSearchScheduleList(params).then(response=>{
- if(response.data.state == 1){
- var staffList = response.data.data.staffList
- console.log("stafflist",staffList)
- }
- })
- },
-
- DeleteStaffSchedule(){
- const params = {
- start_time:this.getTimestamp(this.weekDayArr[0]),
- end_time:this.getTimestamp(this.weekDayArr[6])
- }
- console.log("params",params)
- this.$confirm(
- '是否要清除当周排班? <br>清除后,信息将无法恢复',
- '删除提示',
- {
- dangerouslyUseHTMLString: true,
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }
- ).then(()=>{
- DeleteStaffSchedule(params).then(response=>{
- if(response.data.state == 1){
- var msg = response.data.data.msg
- this.$message.success("清除成功")
- this.getStaffScheduleList()
- }
- })
- })
- },
-
- copyStaffSchedule(){
- const params = {
- start_time:this.getTimestamp(this.weekDayArr[0]),
- end_time:this.getTimestamp(this.weekDayArr[6])
- }
- copyStaffSchedule(params).then(response=>{
- if(response.data.state == 1){
- var msg = response.data.data.msg
- console.log("msg",msg)
- this.$message.success("复制成功")
- }else{
- this.$message.error("排班已存在")
- }
- })
- },
- toContinuous(){
- var is_status = 0
- if(this.isChecked == false){
- is_status = 0
- }
- if(this.isChecked == true){
- is_status = 1
- }
- const params = {
- is_status:is_status
- }
- UpdateContinusSchedule(params).then(response=>{
- if(response.data.state == 1){
- var schedule = response.data.data.schedule
- console.log("schedule",schedule)
- this.$message.success("保存成功")
- }
- })
- }
- },
- created(){
- //获取医护人员
- this.getDoctorList()
- //获取班种
- this.getScheduleList()
-
- let year = new Date().getFullYear()
- let month = new Date().getMonth() + 1
- let date = new Date().getDate()
- this.weekNum = this.getYearWeek(year,month,date)
- this.todayDate=this.formatDate(new Date())
- this.setDate(new Date())
- }
- }
- </script>
-
- <style lang="scss" scoped>
- .dateBox{
- border: 1px solid #DCDFE6;
- height: 36px;
- line-height: 36px;
- text-align: center;
- padding: 0 10px;
- border-radius: 4px;
- }
- .classBox{
- width:25%;
- height: 100%;
- border: 1px solid #EBEEF5;
- .classTitle{
- height: 42px;
- text-align: center;
- line-height: 42px;
- background-color: rgb(245, 247, 250);
- color: rgb(96, 98, 102);
- font-weight:bold;
-
- }
- .classMain{
- height: 400px;
- padding: 0 20px;
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- >div>p{
- line-height: 30px;
- }
- }
- }
- </style>
|