index.vue 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <div style="display:flex;align-items:center">
  6. <el-button type="primary">清除</el-button>
  7. <el-button type="primary">复制</el-button>
  8. <el-button type="primary" icon="el-icon-printer" @click="toPrint">打印</el-button>
  9. </div>
  10. </div>
  11. <div class="app-container">
  12. <div class="cell clearfix">
  13. <el-input
  14. size="small"
  15. style="width: 150px;"
  16. class="filter-item"
  17. v-model.trim="keywords"
  18. placeholder="请输入医护人员姓名"
  19. />
  20. <el-button
  21. size="small"
  22. class="filter-item"
  23. type="primary"
  24. icon="el-icon-search"
  25. @click="toSearch"
  26. >搜索</el-button
  27. >
  28. <el-select style="margin-left:10px;width:150px;" v-model="typeValue" placeholder="请选择" @change="changeOption">
  29. <el-option
  30. v-for="item in options"
  31. :key="item.value"
  32. :label="item.label"
  33. :value="item.value">
  34. </el-option>
  35. </el-select>
  36. <el-button @click="lastclick" type="text" style="margin:0 10px;">&lt;上一周({{ weekNum - 1 }})</el-button>
  37. <div class="dateBox">{{ weekDayArr[0] }}-{{ weekDayArr[6] }}({{ weekNum }})</div>
  38. <el-button @click="nextclick" type="text" style="margin:0 10px;">下一周({{ weekNum + 1 }})&gt;</el-button>
  39. </div>
  40. <div style="display:flex;justify-content: space-between;">
  41. <div style="width: 70%">
  42. <el-table :data="tableData" border :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)', color: '#606266'}" :row-style="{ color: '#303133' }" @cell-click="clickThis">
  43. <el-table-column prop="name" label="医护姓名" style="width:16%" align="center">
  44. <template slot-scope="scope">
  45. {{scope.row.user_name}}
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="周一" style="width:14%" align="center">
  49. <template slot-scope="scope">
  50. <div @click="hangdleClick(scope.row,scope.$index)">
  51. <el-dropdown trigger="click" @command="changeSchedule">
  52. <span class="el-dropdown-link">
  53. <span v-if="scope.row.class_index == 1">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
  54. </span>
  55. <el-dropdown-menu slot="dropdown" >
  56. <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  57. </el-dropdown-menu>
  58. </el-dropdown>
  59. </div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="name" label="周二" style="width:14%" align="center">
  63. <template slot-scope="scope">
  64. <div @click="hangdleClick(scope.row,scope.$index)">
  65. <el-dropdown trigger="click" @command="changeSchedule">
  66. <span class="el-dropdown-link">
  67. <span v-if="scope.row.class_index == 2">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
  68. </span>
  69. <el-dropdown-menu slot="dropdown" >
  70. <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  71. </el-dropdown-menu>
  72. </el-dropdown>
  73. </div>
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop="name" label="周三" style="width:14%" align="center">
  77. <template slot-scope="scope">
  78. <div @click="hangdleClick(scope.row,scope.$index)">
  79. <el-dropdown trigger="click" @command="changeSchedule">
  80. <span class="el-dropdown-link">
  81. <span v-if="scope.row.class_index == 3">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
  82. </span>
  83. <el-dropdown-menu slot="dropdown" >
  84. <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  85. </el-dropdown-menu>
  86. </el-dropdown>
  87. </div>
  88. </template>
  89. </el-table-column>
  90. <el-table-column prop="name" label="周四" style="width:14%" align="center">
  91. <template slot-scope="scope">
  92. <div @click="hangdleClick(scope.row,scope.$index)">
  93. <el-dropdown trigger="click" @command="changeSchedule">
  94. <span class="el-dropdown-link">
  95. <span v-if="scope.row.class_index ==4">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
  96. </span>
  97. <el-dropdown-menu slot="dropdown" >
  98. <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  99. </el-dropdown-menu>
  100. </el-dropdown>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column prop="name" label="周五" style="width:14%" align="center">
  105. <template slot-scope="scope">
  106. <div @click="hangdleClick(scope.row,scope.$index)">
  107. <el-dropdown trigger="click" @command="changeSchedule">
  108. <span class="el-dropdown-link">
  109. <span v-if="scope.row.class_index == 5">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
  110. </span>
  111. <el-dropdown-menu slot="dropdown" >
  112. <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  113. </el-dropdown-menu>
  114. </el-dropdown>
  115. </div>
  116. </template>
  117. </el-table-column>
  118. <el-table-column prop="name" label="周六" style="width:14%" align="center">
  119. <template slot-scope="scope">
  120. <div @click="hangdleClick(scope.row,scope.$index)">
  121. <el-dropdown trigger="click" @command="changeSchedule">
  122. <span class="el-dropdown-link">
  123. <span v-if="scope.row.class_index==6">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
  124. </span>
  125. <el-dropdown-menu slot="dropdown" >
  126. <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  127. </el-dropdown-menu>
  128. </el-dropdown>
  129. </div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column prop="name" label="周日" style="width:14%" align="center">
  133. <template slot-scope="scope">
  134. <div @click="hangdleClick(scope.row,scope.$index)">
  135. <el-dropdown trigger="click" @command="changeSchedule">
  136. <span class="el-dropdown-link">
  137. <span v-if="scope.row.class_index == 0">{{scope.row.class_name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
  138. </span>
  139. <el-dropdown-menu slot="dropdown" >
  140. <el-dropdown-item :command="item.id" icon="el-icon-plus" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  141. </el-dropdown-menu>
  142. </el-dropdown>
  143. </div>
  144. </template>
  145. </el-table-column>
  146. </el-table>
  147. </div>
  148. <div class="classBox">
  149. <div class="classTitle">班种</div>
  150. <div class="classMain">
  151. <div v-for="(item,index) in schedulelist" :key="index">
  152. <p>
  153. {{item.class_name}}&nbsp;({{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> )
  154. </p>
  155. </div>
  156. <el-checkbox style="text-align:center" v-model="isChecked">连续排班</el-checkbox>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. </template>
  163. <script>
  164. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  165. import { getDoctorList,getScheduleList,addSchedule,getStaffScheduleList,getNextWeekList,getScheduleByDoctorId,toSearchScheduleList } from '@/api/doctorSchedule'
  166. export default {
  167. components:{
  168. BreadCrumb
  169. },
  170. data(){
  171. return{
  172. crumbs: [
  173. { path: false, name: '医护排班' },
  174. { path: '/medicalScheduling/index', name: '医护排班' }
  175. ],
  176. keywords:'',
  177. options: [{
  178. value: '1',
  179. label: '全部'
  180. }, {
  181. value: '2',
  182. label: '医生'
  183. }, {
  184. value: '3',
  185. label: '护士'
  186. }],
  187. typeValue:'1',
  188. tableData: [],
  189. isChecked:true,
  190. schedulelist:[],
  191. weekNum:'',
  192. weekDayArr:[],
  193. todayDate:'',
  194. clen:7,
  195. nowYear: new Date().getFullYear(),
  196. schedule_week:0,
  197. docobj:{},
  198. class_name:"",
  199. doctorlist:[],
  200. }
  201. },
  202. methods:{
  203. search(){},
  204. toPrint(){
  205. this.$router.push({
  206. path: '/medicalScheduling/schedule/print',
  207. // query: { date: date }
  208. })
  209. },
  210. getDoctorList(){
  211. getDoctorList().then(response=>{
  212. if(response.data.state == 1){
  213. var list = response.data.data.list
  214. console.log("医护列表",list)
  215. this.tableData = list
  216. this.doctorlist = list
  217. //获取班种列表
  218. this.getStaffScheduleList()
  219. }
  220. })
  221. },
  222. getScheduleList(){
  223. getScheduleList().then(response=>{
  224. if(response.data.state == 1){
  225. var schedulelist = response.data.data.scheduleList
  226. console.log("schedulelist",schedulelist)
  227. for(let i=0;i<schedulelist.length;i++){
  228. if(schedulelist[i].timeone_type == 1){
  229. schedulelist[i].timeone_type = "当日"
  230. }
  231. if(schedulelist[i].timeone_type == 2){
  232. schedulelist[i].timeone_type = "次日"
  233. }
  234. if(schedulelist[i].timetwo_type == 1){
  235. schedulelist[i].timetwo_type = "当日"
  236. }
  237. if(schedulelist[i].timetwo_type == 2){
  238. schedulelist[i].timetwo_type = "次日"
  239. }
  240. }
  241. this.schedulelist = schedulelist
  242. }
  243. })
  244. },
  245. hangdleClick(val,index){
  246. console.log("val=====",val)
  247. this.docobj = val
  248. },
  249. clickThis(row, column, cell, event){
  250. if(column.label == "周日"){
  251. this.schedule_week = 0
  252. }
  253. if(column.label == "周一"){
  254. this.schedule_week = 1
  255. }
  256. if(column.label=="周二"){
  257. this.schedule_week = 2
  258. }
  259. if(column.label=="周三"){
  260. this.schedule_week = 3
  261. }
  262. if(column.label=="周四"){
  263. this.schedule_week = 4
  264. }
  265. if(column.label == "周五"){
  266. this.schedule_week = 5
  267. }
  268. if(column.label == "周六"){
  269. this.schedule_week = 6
  270. }
  271. },
  272. changeSchedule(id){
  273. var class_name = ""
  274. for(let i=0;i<this.schedulelist.length;i++){
  275. if(id == this.schedulelist[i].id){
  276. class_name = this.schedulelist[i].class_name
  277. }
  278. }
  279. let arr = [...this.tableData]
  280. for(let i=0;i<arr.length;i++){
  281. if(this.docobj.id == arr[i].id){
  282. arr[i].class_name = class_name
  283. arr[i].class_index = this.schedule_week
  284. }
  285. }
  286. console.log("arr",arr)
  287. this.tableData = arr
  288. const params = {
  289. doctor_id:this.docobj.admin_user_id,
  290. doctor_type:this.docobj.user_type,
  291. schedule_type:id,
  292. schedule_week:this.schedule_week,
  293. start_time:this.getTimestamp(this.weekDayArr[0]),
  294. end_time:this.getTimestamp(this.weekDayArr[6])
  295. }
  296. console.log("params",params)
  297. // return false
  298. addSchedule(params).then(response=>{
  299. if(response.data.state == 1){
  300. var schedule = response.data.data.schedule
  301. console.log("schedule",schedule)
  302. this.getStaffScheduleList()
  303. }
  304. })
  305. },
  306. formatDate(date){
  307. var year = date.getFullYear()+'.'
  308. var month = (date.getMonth()+1)+'.';
  309. var day = date.getDate();
  310. return year+month+day
  311. },
  312. formatDateTwo(date){
  313. var year = date.getFullYear()+'.'
  314. var month = (date.getMonth()+1)+'.';
  315. var day = date.getDate();
  316. return year+month+day
  317. },
  318. addDate(date,n){
  319. date.setDate(date.getDate()+n);
  320. return date;
  321. },
  322. //
  323. setDate(date){
  324. var week = date.getDay()-1;
  325. date = this.addDate(date,week*-1);
  326. this.currentFirstDate = new Date(date);
  327. for(var i = 0;i<this.clen; i++){
  328. this.weekDayArr.push(this.formatDate(i==0 ? date : this.addDate(date,1)))
  329. }
  330. },
  331. //上一周
  332. lastclick(){
  333. this.weekDayArr=[]
  334. this.setDate(this.addDate(this.currentFirstDate,-7));
  335. this.weekNum = this.weekNum - 1
  336. if(this.weekNum - 1 == 0){
  337. let year = this.nowYear - 1
  338. let month = 12
  339. let date = 31
  340. this.weekNum = this.getYearWeek(year,month,date)
  341. this.nowYear = this.nowYear - 1
  342. }
  343. this.getNextWeekList()
  344. },
  345. //下一周
  346. nextclick(){
  347. this.weekDayArr=[]
  348. this.setDate(this.addDate(this.currentFirstDate,7));
  349. this.weekNum = this.weekNum + 1
  350. if(this.weekNum + 1 == 54){
  351. let year = this.nowYear + 1
  352. let month = 1
  353. let date = 1
  354. this.weekNum = this.getYearWeek(year,month,date)
  355. this.nowYear = this.nowYear + 1
  356. }
  357. this.getNextWeekList()
  358. },
  359. getYearWeek(year,month,date){
  360. /*
  361. dateNow是当前日期
  362. dateFirst是当年第一天
  363. dataNumber是当前日期是今年第多少天
  364. 用dataNumber + 当前年的第一天的周差距的和在除以7就是本年第几周
  365. */
  366. let dateNow = new Date(year, parseInt(month) - 1, date);
  367. let dateFirst = new Date(year, 0, 1);
  368. let dataNumber = Math.round((dateNow.valueOf() - dateFirst.valueOf()) / 86400000);
  369. return Math.ceil((dataNumber + ((dateFirst.getDay() + 1) - 1)) / 7);
  370. },
  371. getTimestamp(time) { //把时间日期转成时间戳
  372. return (new Date(time)).getTime() / 1000
  373. },
  374. beforeHandleCommand(item,row){
  375. return {
  376. 'command': item,
  377. 'row': row
  378. }
  379. },
  380. //获取所有排班数据
  381. getStaffScheduleList(){
  382. const params = {
  383. start_time:this.getTimestamp(this.weekDayArr[0]),
  384. end_time:this.getTimestamp(this.weekDayArr[6])
  385. }
  386. getStaffScheduleList(params).then(response=>{
  387. if(response.data.state == 1){
  388. var staffList = response.data.data.staffList
  389. for(let i=0;i<staffList.length;i++){
  390. if(staffList[i].schedule_week == 0){
  391. staffList[i].class_index = 0
  392. }
  393. if(staffList[i].schedule_week == 1){
  394. staffList[i].class_index = 1
  395. }
  396. if(staffList[i].schedule_week == 2){
  397. staffList[i].class_index = 2
  398. }
  399. if(staffList[i].schedule_week == 3){
  400. staffList[i].class_index = 3
  401. }
  402. if(staffList[i].schedule_week == 4){
  403. staffList[i].class_index = 4
  404. }
  405. if(staffList[i].schedule_week == 5){
  406. staffList[i].class_index = 5
  407. }
  408. if(staffList[i].schedule_week == 6){
  409. staffList[i].class_index = 6
  410. }
  411. }
  412. console.log("staffList--------",staffList)
  413. if(staffList.length == 0){
  414. this.tableData = this.doctorlist
  415. }else{
  416. this.tableData = []
  417. this.tableData = staffList
  418. }
  419. }
  420. })
  421. },
  422. //获取上一周下一周的排班数据
  423. getNextWeekList(){
  424. const params = {
  425. start_time:this.getTimestamp(this.weekDayArr[0]),
  426. end_time:this.getTimestamp(this.weekDayArr[6])
  427. }
  428. getNextWeekList(params).then(response=>{
  429. if(response.data.state == 1){
  430. var staffList = response.data.data.staffList
  431. console.log("上下周数据",staffList)
  432. }
  433. })
  434. },
  435. changeOption(id){
  436. const params = {
  437. start_time:this.getTimestamp(this.weekDayArr[0]),
  438. end_time:this.getTimestamp(this.weekDayArr[6]),
  439. doctor_id:id
  440. }
  441. getScheduleByDoctorId(params).then(response=>{
  442. if(response.data.state == 1){
  443. var staffList = response.data.data.staffList
  444. console.log("staffList",staffList)
  445. }
  446. })
  447. },
  448. toSearch(){
  449. console.log("医护人员姓名",this.keywords)
  450. var id = 0
  451. for(let i = 0 ;i<this.doctorlist.length;i++){
  452. if(this.keywords == this.doctorlist[i].user_name){
  453. id = this.doctorlist[i].admin_user_id
  454. }
  455. }
  456. const params = {
  457. doctor_id:id,
  458. start_time:this.getTimestamp(this.weekDayArr[0]),
  459. end_time:this.getTimestamp(this.weekDayArr[6])
  460. }
  461. toSearchScheduleList(params).then(response=>{
  462. if(response.data.state == 1){
  463. var staffList = response.data.data.staffList
  464. console.log("stafflist",staffList)
  465. }
  466. })
  467. }
  468. },
  469. created(){
  470. //获取医护人员
  471. this.getDoctorList()
  472. //获取班种
  473. this.getScheduleList()
  474. let year = new Date().getFullYear()
  475. let month = new Date().getMonth() + 1
  476. let date = new Date().getDate()
  477. this.weekNum = this.getYearWeek(year,month,date)
  478. this.todayDate=this.formatDate(new Date())
  479. this.setDate(new Date())
  480. }
  481. }
  482. </script>
  483. <style lang="scss" scoped>
  484. .dateBox{
  485. border: 1px solid #DCDFE6;
  486. height: 36px;
  487. line-height: 36px;
  488. text-align: center;
  489. padding: 0 10px;
  490. border-radius: 4px;
  491. }
  492. .classBox{
  493. width:25%;
  494. height: 100%;
  495. border: 1px solid #EBEEF5;
  496. .classTitle{
  497. height: 42px;
  498. text-align: center;
  499. line-height: 42px;
  500. background-color: rgb(245, 247, 250);
  501. color: rgb(96, 98, 102);
  502. font-weight:bold;
  503. }
  504. .classMain{
  505. height: 400px;
  506. padding: 0 20px;
  507. display: flex;
  508. justify-content: space-between;
  509. flex-direction: column;
  510. >div>p{
  511. line-height: 30px;
  512. }
  513. }
  514. }
  515. </style>