Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

index.vue 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  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" @click="DeleteStaffSchedule">清除</el-button>
  7. <el-button type="primary" @click="copyStaffSchedule">复制</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. @keyup.enter.native='toSearch'
  20. />
  21. <el-button
  22. size="small"
  23. class="filter-item"
  24. type="primary"
  25. icon="el-icon-search"
  26. @click="toSearch"
  27. >搜索</el-button
  28. >
  29. <el-select style="margin-left:10px;width:150px;" v-model="typeValue" placeholder="请选择" @change="changeOption">
  30. <el-option
  31. v-for="item in options"
  32. :key="item.value"
  33. :label="item.label"
  34. :value="item.value">
  35. </el-option>
  36. </el-select>
  37. <el-button @click="lastclick" type="text" style="margin:0 10px;">&lt;上一周({{ weekNum - 1 }})</el-button>
  38. <div class="dateBox">{{ weekDayArr[0] }}-{{ weekDayArr[6] }}({{ weekNum }})</div>
  39. <el-button @click="nextclick" type="text" style="margin:0 10px;">下一周({{ weekNum + 1 }})&gt;</el-button>
  40. </div>
  41. <div class="schedulingTable" style="display:flex;justify-content: space-between;">
  42. <div style="width: 70%">
  43. <el-table :data="tableData" border :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)', color: '#606266'}" :row-style="{ color: '#303133' }" @cell-click="clickThis">
  44. <el-table-column prop="name" label="医护姓名" style="width:16%" align="center">
  45. <template slot-scope="scope">
  46. {{scope.row.user_name}}
  47. </template>
  48. </el-table-column>
  49. <el-table-column :label="'周一\n(' + weekDayArr[0] + ')'" style="width:200px" align="center">
  50. <template slot-scope="scope">
  51. <div @click="hangdleClick(scope.row,scope.$index,0)">
  52. <el-dropdown trigger="click" @command="changeSchedule">
  53. <span class="el-dropdown-link">
  54. {{ getClass(scope.row.user_name,1) }}<i v-if="getTimestamp(weekDayArr[0])>=timeNow?true:false" class="el-icon-arrow-down el-icon--right"></i>
  55. </span>
  56. <el-dropdown-menu slot="dropdown" >
  57. <el-dropdown-item :command="item.id" icon="el-icon-plus" :disabled="getTimestamp(weekDayArr[0])<timeNow?true:false" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  58. </el-dropdown-menu>
  59. </el-dropdown>
  60. </div>
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="name" :label="'周二\n(' + weekDayArr[1] + ')'" style="width:14%" align="center">
  64. <template slot-scope="scope">
  65. <div @click="hangdleClick(scope.row,scope.$index,1)">
  66. <el-dropdown trigger="click" @command="changeSchedule">
  67. <span class="el-dropdown-link">
  68. {{ getClass(scope.row.user_name,2) }}<i v-if="getTimestamp(weekDayArr[1])>=timeNow?true:false" class="el-icon-arrow-down el-icon--right"></i>
  69. </span>
  70. <el-dropdown-menu slot="dropdown" >
  71. <el-dropdown-item :command="item.id" icon="el-icon-plus" :disabled="getTimestamp(weekDayArr[1])<timeNow?true:false" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  72. </el-dropdown-menu>
  73. </el-dropdown>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. <el-table-column prop="name" :label="'周三\n(' + weekDayArr[2] + ')'" style="width:14%" align="center">
  78. <template slot-scope="scope">
  79. <div @click="hangdleClick(scope.row,scope.$index,2)">
  80. <el-dropdown trigger="click" @command="changeSchedule">
  81. <span class="el-dropdown-link">
  82. {{ getClass(scope.row.user_name,3) }}<i v-if="getTimestamp(weekDayArr[2])>=timeNow?true:false" class="el-icon-arrow-down el-icon--right"></i>
  83. </span>
  84. <el-dropdown-menu slot="dropdown" >
  85. <el-dropdown-item :command="item.id" icon="el-icon-plus" :disabled="getTimestamp(weekDayArr[2])<timeNow?true:false" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  86. </el-dropdown-menu>
  87. </el-dropdown>
  88. </div>
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="name" :label="'周四\n(' + weekDayArr[3] + ')'" style="width:14%" align="center">
  92. <template slot-scope="scope">
  93. <div @click="hangdleClick(scope.row,scope.$index,3)">
  94. <el-dropdown trigger="click" @command="changeSchedule">
  95. <span class="el-dropdown-link">
  96. {{ getClass(scope.row.user_name,4) }}<i v-if="getTimestamp(weekDayArr[3])>=timeNow?true:false" class="el-icon-arrow-down el-icon--right"></i>
  97. </span>
  98. <el-dropdown-menu slot="dropdown" >
  99. <el-dropdown-item :command="item.id" icon="el-icon-plus" :disabled="getTimestamp(weekDayArr[3])<timeNow?true:false" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  100. </el-dropdown-menu>
  101. </el-dropdown>
  102. </div>
  103. </template>
  104. </el-table-column>
  105. <el-table-column prop="name" :label="'周五\n(' + weekDayArr[4] + ')'" style="width:14%" align="center">
  106. <template slot-scope="scope">
  107. <div @click="hangdleClick(scope.row,scope.$index,4)">
  108. <el-dropdown trigger="click" @command="changeSchedule">
  109. <span class="el-dropdown-link">
  110. {{ getClass(scope.row.user_name,5) }}<i v-if="getTimestamp(weekDayArr[4])>=timeNow?true:false" class="el-icon-arrow-down el-icon--right"></i>
  111. </span>
  112. <el-dropdown-menu slot="dropdown" >
  113. <el-dropdown-item :command="item.id" icon="el-icon-plus" :disabled="getTimestamp(weekDayArr[4])<timeNow?true:false" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  114. </el-dropdown-menu>
  115. </el-dropdown>
  116. </div>
  117. </template>
  118. </el-table-column>
  119. <el-table-column prop="name" :label="'周六\n(' + weekDayArr[5] + ')'" style="width:14%" align="center">
  120. <template slot-scope="scope">
  121. <div @click="hangdleClick(scope.row,scope.$index,5)">
  122. <el-dropdown trigger="click" @command="changeSchedule">
  123. <span class="el-dropdown-link">
  124. {{ getClass(scope.row.user_name,6) }}<i v-if="getTimestamp(weekDayArr[5])>=timeNow?true:false" class="el-icon-arrow-down el-icon--right"></i>
  125. </span>
  126. <el-dropdown-menu slot="dropdown" >
  127. <el-dropdown-item :command="item.id" icon="el-icon-plus" :disabled="getTimestamp(weekDayArr[5])<timeNow?true:false" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  128. </el-dropdown-menu>
  129. </el-dropdown>
  130. </div>
  131. </template>
  132. </el-table-column>
  133. <el-table-column prop="name" :label="'周日\n(' + weekDayArr[6] + ')'" style="width:14%" align="center">
  134. <template slot-scope="scope">
  135. <div @click="hangdleClick(scope.row,scope.$index,6)">
  136. <el-dropdown trigger="click" @command="changeSchedule">
  137. <span class="el-dropdown-link">
  138. {{ getClass(scope.row.user_name,0) }}<i v-if="getTimestamp(weekDayArr[6])>=timeNow?true:false" class="el-icon-arrow-down el-icon--right"></i>
  139. </span>
  140. <el-dropdown-menu slot="dropdown" >
  141. <el-dropdown-item :command="item.id" icon="el-icon-plus" :disabled="getTimestamp(weekDayArr[6])<timeNow?true:false" v-for="(item,index) in schedulelist" :key="index">{{item.class_name}}</el-dropdown-item>
  142. </el-dropdown-menu>
  143. </el-dropdown>
  144. </div>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. </div>
  149. <div class="classBox">
  150. <div class="classTitle">班种</div>
  151. <div class="classMain">
  152. <div class="classMainBox">
  153. <p v-for="(item,index) in schedulelist" :key="index">
  154. {{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> )
  155. </p>
  156. </div>
  157. <el-checkbox style="text-align:center;padding-bottom: 10px;" v-model="isChecked" @change="toContinuous">连续排班</el-checkbox>
  158. </div>
  159. </div>
  160. </div>
  161. <el-dialog
  162. title="复制排班"
  163. width="600px"
  164. :visible.sync="newVisible"
  165. >
  166. <el-form :model="form" ref="form" label-width="90px" :rules="rules">
  167. <el-form-item label="复制到 : " required prop="copyWeek">
  168. <el-select v-model="form.copyWeek" placeholder="请选择">
  169. <el-option
  170. v-for="item in typeOptions"
  171. :key="item.value"
  172. :label="item.label"
  173. :value="item.value">
  174. </el-option>
  175. </el-select>
  176. </el-form-item>
  177. </el-form>
  178. <div slot="footer" class="dialog-footer">
  179. <el-button @click="newVisible=false">取 消</el-button>
  180. <el-button type="primary" @click="submitAction('form')">保 存</el-button>
  181. </div>
  182. </el-dialog>
  183. </div>
  184. </div>
  185. </template>
  186. <script>
  187. const moment = require('moment')
  188. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  189. import { getDoctorList,getScheduleList,addSchedule,getStaffScheduleList,getNextWeekList,getScheduleByDoctorId,toSearchScheduleList,DeleteStaffSchedule,copyStaffSchedule,UpdateContinusSchedule } from '@/api/doctorSchedule'
  190. export default {
  191. components:{
  192. BreadCrumb
  193. },
  194. data(){
  195. return{
  196. crumbs: [
  197. { path: false, name: '医护排班' },
  198. { path: '/medicalScheduling/index', name: '医护排班' }
  199. ],
  200. keywords:'',
  201. options: [{
  202. value: '0',
  203. label: '全部'
  204. }, {
  205. value: '2',
  206. label: '医生'
  207. }, {
  208. value: '3',
  209. label: '护士'
  210. }],
  211. typeValue:'0',
  212. tableData: [],
  213. isChecked:true,
  214. schedulelist:[],
  215. weekNum:'',
  216. weekDayArr:[],
  217. todayDate:'',
  218. clen:7,
  219. nowYear: new Date().getFullYear(),
  220. schedule_week:0,
  221. docobj:{},
  222. class_name:"",
  223. doctorlist:[],
  224. schedule_date:"",
  225. newVisible:false,
  226. typeOptions:[],
  227. timeOptions:[],
  228. copyWeek:'',
  229. weekList: [],
  230. currentFirstDate1: '',
  231. form:{
  232. copyWeek:"",
  233. },
  234. rules: {
  235. copyWeek: [{ required: true, message: "请选择复制时间段", trigger: "blur" }],
  236. },
  237. timeNow:0,
  238. }
  239. },
  240. methods:{
  241. search(){},
  242. toPrint(){
  243. this.$router.push({
  244. path: '/medicalScheduling/schedule/print?starttime='+this.getTimestamp(this.weekDayArr[0])+"&endtime="+this.getTimestamp(this.weekDayArr[6])+"&weekArr="+ this.weekDayArr,
  245. // query: { date: date }
  246. })
  247. },
  248. getDoctorList(){
  249. getDoctorList().then(response=>{
  250. if(response.data.state == 1){
  251. var list = response.data.data.list
  252. // console.log("医护列表",list)
  253. this.tableData = list
  254. this.doctorlist = list
  255. //获取班种列表
  256. this.getStaffScheduleList()
  257. }
  258. })
  259. },
  260. getScheduleList(){
  261. getScheduleList().then(response=>{
  262. if(response.data.state == 1){
  263. var schedulelist = response.data.data.scheduleList
  264. // console.log("schedulelist",schedulelist)
  265. for(let i=0;i<schedulelist.length;i++){
  266. if(schedulelist[i].timeone_type == 1){
  267. schedulelist[i].timeone_type = "当日"
  268. }
  269. if(schedulelist[i].timeone_type == 2){
  270. schedulelist[i].timeone_type = "次日"
  271. }
  272. if(schedulelist[i].timetwo_type == 1){
  273. schedulelist[i].timetwo_type = "当日"
  274. }
  275. if(schedulelist[i].timetwo_type == 2){
  276. schedulelist[i].timetwo_type = "次日"
  277. }
  278. }
  279. this.schedulelist = schedulelist
  280. }
  281. })
  282. },
  283. hangdleClick(val,index,num){
  284. // console.log("val",val)
  285. this.docobj = val
  286. if(this.getTimestamp(this.weekDayArr[num]) < this.timeNow){
  287. this.$message.error("过去日期不可以编辑")
  288. return
  289. }
  290. },
  291. clickThis(row, column, cell, event){
  292. // console.log("row",row)
  293. // console.log("column",column)
  294. // console.log("日期",this.weekDayArr)
  295. var week = (column.label).split('');
  296. var weeks = week[0]+week[1]
  297. // console.log("weeks",weeks)
  298. if(weeks == "周日"){
  299. this.schedule_week = 0
  300. this.schedule_date = this.weekDayArr[6]
  301. }
  302. if(weeks == "周一"){
  303. this.schedule_week = 1
  304. this.schedule_date = this.weekDayArr[0]
  305. }
  306. if(weeks=="周二"){
  307. this.schedule_week = 2
  308. this.schedule_date = this.weekDayArr[1]
  309. }
  310. if(weeks=="周三"){
  311. this.schedule_week = 3
  312. this.schedule_date = this.weekDayArr[2]
  313. }
  314. if(weeks=="周四"){
  315. this.schedule_week = 4
  316. this.schedule_date = this.weekDayArr[3]
  317. }
  318. if(weeks == "周五"){
  319. this.schedule_week = 5
  320. this.schedule_date = this.weekDayArr[4]
  321. }
  322. if(weeks== "周六"){
  323. this.schedule_week = 6
  324. this.schedule_date = this.weekDayArr[5]
  325. }
  326. },
  327. changeSchedule(id){
  328. var class_name = ""
  329. for(let i=0;i<this.schedulelist.length;i++){
  330. if(id == this.schedulelist[i].id){
  331. class_name = this.schedulelist[i].class_name
  332. }
  333. }
  334. let arr = [...this.tableData]
  335. // console.log("arr===",arr)
  336. for(let i=0;i<arr.length;i++){
  337. if(this.docobj.id == arr[i].id){
  338. arr[i].class_name = class_name
  339. arr[i].class_index = this.schedule_week
  340. }
  341. }
  342. // console.log("arr",arr)
  343. this.tableData = arr
  344. const params = {
  345. doctor_id:this.docobj.admin_user_id,
  346. doctor_type:this.docobj.user_type,
  347. schedule_type:id,
  348. schedule_week:this.schedule_week,
  349. start_time:this.getTimestamp(this.weekDayArr[0]),
  350. end_time:this.getTimestamp(this.weekDayArr[6]),
  351. schedule_date:this.getTimestamp(this.schedule_date)
  352. }
  353. // console.log("params",params)
  354. addSchedule(params).then(response=>{
  355. if(response.data.state == 1){
  356. var schedule = response.data.data.schedule
  357. // console.log("schedule",schedule)
  358. this.$message.success("保存成功")
  359. this.getStaffScheduleList()
  360. }
  361. })
  362. },
  363. formatDate(date){
  364. var year = date.getFullYear()+'.'
  365. var month = (date.getMonth()+1)+'.';
  366. var day = date.getDate();
  367. return year+month+day
  368. },
  369. formatDateTwo(date){
  370. var year = date.getFullYear()+'.'
  371. var month = (date.getMonth()+1)+'.';
  372. var day = date.getDate();
  373. return year+month+day
  374. },
  375. addDate(date,n){
  376. date.setDate(date.getDate()+n);
  377. return date;
  378. },
  379. //
  380. setDate(date){
  381. var week = date.getDay()-1;
  382. date = this.addDate(date,week*-1);
  383. this.currentFirstDate = new Date(date);
  384. this.currentDate = new Date(date)
  385. for(var i = 0;i<this.clen; i++){
  386. this.weekDayArr.push(this.formatDate(i==0 ? date : this.addDate(date,1)))
  387. }
  388. },
  389. //上一周
  390. lastclick(){
  391. this.weekDayArr=[]
  392. this.setDate(this.addDate(this.currentFirstDate,-7));
  393. if (this.weekNum == 1) {
  394. let year = this.nowYear - 1
  395. let month = 12
  396. let date = 31
  397. this.weekNum = this.getYearWeek(year, month, date)
  398. this.nowYear = this.nowYear - 1
  399. }
  400. this.weekNum = this.weekNum - 1
  401. this.getNextWeekList()
  402. },
  403. //下一周
  404. nextclick(){
  405. this.weekDayArr=[]
  406. this.setDate(this.addDate(this.currentFirstDate,7));
  407. this.weekNum = this.weekNum + 1
  408. if (this.weekNum == 53) {
  409. let year = this.nowYear + 1
  410. let month = 1
  411. let date = 1
  412. this.weekNum = this.getYearWeek(year, month, date)
  413. this.nowYear = this.nowYear + 1
  414. }
  415. this.getNextWeekList()
  416. },
  417. getYearWeek(year,month,date){
  418. /*
  419. dateNow是当前日期
  420. dateFirst是当年第一天
  421. dataNumber是当前日期是今年第多少天
  422. 用dataNumber + 当前年的第一天的周差距的和在除以7就是本年第几周
  423. */
  424. let dateNow = new Date(year, parseInt(month) - 1, date);
  425. let dateFirst = new Date(year, 0, 1);
  426. let dataNumber = Math.round((dateNow.valueOf() - dateFirst.valueOf()) / 86400000);
  427. return Math.ceil((dataNumber + ((dateFirst.getDay() + 1) - 1)) / 7);
  428. },
  429. getTimestamp(time) { //把时间日期转成时间戳
  430. return (new Date(time)).getTime() / 1000
  431. },
  432. beforeHandleCommand(item,row){
  433. return {
  434. 'command': item,
  435. 'row': row
  436. }
  437. },
  438. //获取所有医护排班数据
  439. getStaffScheduleList(){
  440. const params = {
  441. start_time:this.getTimestamp(this.weekDayArr[0]),
  442. end_time:this.getTimestamp(this.weekDayArr[6])
  443. }
  444. getStaffScheduleList(params).then(response=>{
  445. if(response.data.state == 1){
  446. var staffList = response.data.data.staffList
  447. console.log("所有排班数据",staffList)
  448. for(let i=0;i<staffList.length;i++){
  449. if(staffList[i].schedule_week == 0){
  450. staffList[i].class_index = 0
  451. }
  452. if(staffList[i].schedule_week == 1){
  453. staffList[i].class_index = 1
  454. }
  455. if(staffList[i].schedule_week == 2){
  456. staffList[i].class_index = 2
  457. }
  458. if(staffList[i].schedule_week == 3){
  459. staffList[i].class_index = 3
  460. }
  461. if(staffList[i].schedule_week == 4){
  462. staffList[i].class_index = 4
  463. }
  464. if(staffList[i].schedule_week == 5){
  465. staffList[i].class_index = 5
  466. }
  467. if(staffList[i].schedule_week == 6){
  468. staffList[i].class_index = 6
  469. }
  470. }
  471. console.log("staffList--------",staffList)
  472. let tempArr = [], newArr = []
  473. for (let i = 0; i < staffList.length; i++) {
  474. if (tempArr.indexOf(staffList[i].user_name) === -1) {
  475. newArr.push({
  476. user_name: staffList[i].user_name,
  477. admin_user_id:staffList[i].admin_user_id,
  478. user_type:staffList[i].doctor_type,
  479. list: [{class_name:staffList[i].class_name,schedule_week:staffList[i].schedule_week}]
  480. })
  481. tempArr.push(staffList[i].user_name);
  482. } else {
  483. for (let j = 0; j < newArr.length; j++) {
  484. if (newArr[j].user_name == staffList[i].user_name) {
  485. newArr[j].list.push({class_name:staffList[i].class_name,admin_user_id:staffList[i].admin_user_id,schedule_week:staffList[i].schedule_week,user_type:staffList[i].doctor_type})
  486. }
  487. }
  488. }
  489. }
  490. let arr = [...newArr]
  491. arr.sort(this.compare('admin_user_id'))
  492. this.doctorlist.sort(this.compare('admin_user_id'))
  493. this.doctorlist.forEach((item, index) => {
  494.   if (arr[index] && item.admin_user_id == arr[index].admin_user_id) {
  495.   }else{
  496.     arr.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type})
  497.     // console.log("arr",arr)
  498.   }
  499. })
  500. console.log("arr=======",arr)
  501. arr.sort(this.compare('user_type'))
  502. this.tableData = arr
  503. }
  504. })
  505. },
  506. getClass(name,index){
  507. if(name != undefined){
  508. let newClass = '';
  509. this.tableData.map(item => {
  510. if(item.user_name == name){
  511. if(item.list){
  512. item.list.map(it => {
  513. if(it.schedule_week == index){
  514. newClass = it.class_name
  515. }
  516. })
  517. }
  518. }
  519. })
  520. return newClass
  521. }
  522. },
  523. unique(arr) {
  524. const res = new Map();
  525. return arr.filter((arr) => !res.has(arr.admin_user_id) && res.set(arr.admin_user_id, 1))
  526. },
  527. //获取上一周下一周的排班数据
  528. getNextWeekList(){
  529. const params = {
  530. start_time:this.getTimestamp(this.weekDayArr[0]),
  531. end_time:this.getTimestamp(this.weekDayArr[6])
  532. }
  533. getNextWeekList(params).then(response=>{
  534. if(response.data.state == 1){
  535. var staffList = response.data.data.staffList
  536. console.log("上下周数据",staffList)
  537. let tempArr = [], newArr = []
  538. for (let i = 0; i < staffList.length; i++) {
  539. if (tempArr.indexOf(staffList[i].user_name) === -1) {
  540. newArr.push({
  541. user_name: staffList[i].user_name,
  542. admin_user_id:staffList[i].admin_user_id,
  543. user_type:staffList[i].doctor_type,
  544. list: [{class_name:staffList[i].class_name,schedule_week:staffList[i].schedule_week}]
  545. })
  546. tempArr.push(staffList[i].user_name);
  547. } else {
  548. for (let j = 0; j < newArr.length; j++) {
  549. if (newArr[j].user_name == staffList[i].user_name) {
  550. newArr[j].list.push({class_name:staffList[i].class_name,admin_user_id:staffList[i].admin_user_id,schedule_week:staffList[i].schedule_week, user_type:staffList[i].doctor_type,})
  551. }
  552. }
  553. }
  554. }
  555. let arr = [...newArr]
  556. arr.sort(this.compare('admin_user_id'))
  557. this.doctorlist.sort(this.compare('admin_user_id'))
  558. this.doctorlist.forEach((item, index) => {
  559.   if (arr[index] && item.admin_user_id == arr[index].admin_user_id) {
  560.   }else{
  561.     arr.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type})
  562.     // console.log("arr",arr)
  563.   }
  564. })
  565. arr.sort(this.compare('user_type'))
  566. this.tableData = arr
  567. }
  568. })
  569. },
  570. changeOption(id){
  571. const params = {
  572. start_time:this.getTimestamp(this.weekDayArr[0]),
  573. end_time:this.getTimestamp(this.weekDayArr[6]),
  574. doctor_id:id
  575. }
  576. getScheduleByDoctorId(params).then(response=>{
  577. if(response.data.state == 1){
  578. var staffList = response.data.data.staffList
  579. console.log("staffList",staffList)
  580. let tempArr = [], newArr = []
  581. for (let i = 0; i < staffList.length; i++) {
  582. if (tempArr.indexOf(staffList[i].user_name) === -1) {
  583. newArr.push({
  584. user_type:staffList[i].doctor_type,
  585. user_name: staffList[i].user_name,
  586. admin_user_id:staffList[i].admin_user_id,
  587. list: [{class_name:staffList[i].class_name,schedule_week:staffList[i].schedule_week}]
  588. })
  589. tempArr.push(staffList[i].user_name);
  590. } else {
  591. for (let j = 0; j < newArr.length; j++) {
  592. if (newArr[j].user_name == staffList[i].user_name) {
  593. newArr[j].list.push({class_name:staffList[i].class_name,admin_user_id:staffList[i].admin_user_id,schedule_week:staffList[i].schedule_week, user_type:staffList[i].doctor_type})
  594. }
  595. }
  596. }
  597. }
  598. if(id == 0){
  599. let arr = [...newArr]
  600. arr.sort(this.compare('admin_user_id'))
  601. this.doctorlist.sort(this.compare('admin_user_id'))
  602. this.doctorlist.forEach((item, index) => {
  603.   if (arr[index] && item.admin_user_id == arr[index].admin_user_id) {
  604.   }else{
  605.     arr.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type})
  606.     // console.log("arr",arr)
  607.   }
  608. })
  609. console.log("全部=======",arr)
  610. arr.sort(this.compare('user_type'))
  611. this.tableData = arr
  612. }
  613. if(id == 2){
  614. let arr = [...newArr]
  615. arr.sort(this.compare('admin_user_id'))
  616. this.doctorlist.sort(this.compare('admin_user_id'))
  617. let newDoctor = []
  618. this.doctorlist.map(item => {
  619. if (item.user_type == 2) {
  620. newDoctor.push(item)
  621. }
  622. })
  623. newDoctor.map((item, index) => {
  624. if (arr[index] && item.admin_user_id == arr[index].admin_user_id) {
  625.   }else{
  626.     arr.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: []})
  627.     // console.log("arr",arr)
  628.   }
  629. })
  630. this.tableData = arr
  631. }
  632. if(id == 3){
  633. let arr = [...newArr]
  634. arr.sort(this.compare('admin_user_id'))
  635. this.doctorlist.sort(this.compare('admin_user_id'))
  636. let newDoctor = []
  637. this.doctorlist.map(item => {
  638. if (item.user_type == 3) {
  639. newDoctor.push(item)
  640. }
  641. })
  642. newDoctor.map((item, index) => {
  643. if (arr[index] && item.admin_user_id == arr[index].admin_user_id) {
  644.   }else{
  645.     arr.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: []})
  646.     // console.log("arr",arr)
  647.   }
  648. })
  649. this.tableData = arr
  650. }
  651. }
  652. })
  653. },
  654. toSearch(){
  655. console.log("医护人员姓名",this.keywords)
  656. const params = {
  657. user_name: this.keywords,
  658. start_time:this.getTimestamp(this.weekDayArr[0]),
  659. end_time:this.getTimestamp(this.weekDayArr[6])
  660. }
  661. toSearchScheduleList(params).then(response=>{
  662. if(response.data.state == 1){
  663. var staffList = response.data.data.staffList
  664. console.log("stafflist",staffList)
  665. let tempArr = [], newArr = []
  666. for (let i = 0; i < staffList.length; i++) {
  667. if (tempArr.indexOf(staffList[i].user_name) === -1) {
  668. newArr.push({
  669. user_name: staffList[i].user_name,
  670. admin_user_id:staffList[i].admin_user_id,
  671. list: [{class_name:staffList[i].class_name,schedule_week:staffList[i].schedule_week}]
  672. })
  673. tempArr.push(staffList[i].user_name);
  674. } else {
  675. for (let j = 0; j < newArr.length; j++) {
  676. if (newArr[j].user_name == staffList[i].user_name) {
  677. newArr[j].list.push({class_name:staffList[i].class_name,admin_user_id:staffList[i].admin_user_id,schedule_week:staffList[i].schedule_week})
  678. }
  679. }
  680. }
  681. }
  682. if(this.keywords != ''){
  683. this.tableData = newArr
  684. }else{
  685. let arr = [...newArr]
  686. arr.sort(this.compare('admin_user_id'))
  687. this.doctorlist.sort(this.compare('admin_user_id'))
  688. this.doctorlist.forEach((item, index) => {
  689.   if (arr[index] && item.admin_user_id == arr[index].admin_user_id) {
  690.   }else{
  691.     arr.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: []})
  692.     // console.log("arr",arr)
  693.   }
  694. })
  695. this.tableData = arr
  696. }
  697. }
  698. })
  699. },
  700. DeleteStaffSchedule(){
  701. const params = {
  702. start_time:this.getTimestamp(this.weekDayArr[0]),
  703. end_time:this.getTimestamp(this.weekDayArr[6])
  704. }
  705. console.log("params",params)
  706. this.$confirm(
  707. '是否要清除当周排班? <br>清除后,信息将无法恢复',
  708. '删除提示',
  709. {
  710. dangerouslyUseHTMLString: true,
  711. confirmButtonText: '确定',
  712. cancelButtonText: '取消',
  713. type: 'warning'
  714. }
  715. ).then(()=>{
  716. DeleteStaffSchedule(params).then(response=>{
  717. if(response.data.state == 1){
  718. var msg = response.data.data.msg
  719. this.$message.success("清除成功")
  720. this.getStaffScheduleList()
  721. }
  722. })
  723. })
  724. },
  725. copyStaffSchedule(){
  726. this.newVisible = true
  727. // const params = {
  728. // start_time:this.getTimestamp(this.weekDayArr[0]),
  729. // end_time:this.getTimestamp(this.weekDayArr[6])
  730. // }
  731. // copyStaffSchedule(params).then(response=>{
  732. // if(response.data.state == 1){
  733. // var msg = response.data.data.msg
  734. // console.log("msg",msg)
  735. // this.$message.success("复制成功")
  736. // }else{
  737. // this.$message.error("排班已存在")
  738. // }
  739. // })
  740. },
  741. toContinuous(){
  742. var is_status = 0
  743. if(this.isChecked == false){
  744. is_status = 0
  745. }
  746. if(this.isChecked == true){
  747. is_status = 1
  748. }
  749. const params = {
  750. is_status:is_status
  751. }
  752. UpdateContinusSchedule(params).then(response=>{
  753. if(response.data.state == 1){
  754. var schedule = response.data.data.schedule
  755. console.log("schedule",schedule)
  756. this.$message.success("保存成功")
  757. }
  758. })
  759. },
  760. setDate1 (date) {
  761. var week = date.getDay() - 1
  762. date = this.addDate(date, week * -1)
  763. this.currentDate = new Date(date)
  764. let arr1 = []
  765. for (var i = 0; i < this.clen; i++) {
  766. arr1.push(this.formatDate(i == 0 ? date : this.addDate(date, 1)))
  767. }
  768. this.weekList.push(arr1)
  769. let num = this.weekNum
  770. this.currentFirstDate1 = num + 1
  771. },
  772. submitAction(formName){
  773. console.log("数据",this.typeOptions)
  774. console.log("2222",this.timeOptions)
  775. var label = ""
  776. for(let i=0;i<this.timeOptions.length;i++){
  777. if(this.form.copyWeek == this.timeOptions[i].value){
  778. label = this.timeOptions[i].label
  779. }
  780. }
  781. var start = label.split('~')
  782. var copy_startime = this.getTimestamp(start[0])
  783. console.log("copy_startime",copy_startime)
  784. var copy_endtime = this.getTimestamp(start[1])
  785. console.log("copy_endtime",copy_endtime)
  786. const params = {
  787. start_time:this.getTimestamp(this.weekDayArr[0]),
  788. end_time:this.getTimestamp(this.weekDayArr[6]),
  789. copy_startime:copy_startime,
  790. copy_endtime:copy_endtime,
  791. }
  792. console.log("params",params)
  793. this.$refs[formName].validate(valid=>{
  794. if(valid){
  795. copyStaffSchedule(params).then(response=>{
  796. if(response.data.state == 1){
  797. var msg = response.data.data.msg
  798. console.log("msg",msg)
  799. this.$message.success("复制成功")
  800. this.newVisible = false
  801. }else{
  802. this.$message.error("排班已存在")
  803. }
  804. })
  805. }
  806. })
  807. },
  808. compare(property){
  809. return function(a,b){
  810. var value1 = a[property];
  811. var value2 = b[property];
  812. return value2 - value1;
  813. }
  814. },
  815. },
  816. created(){
  817. //获取医护人员
  818. this.getDoctorList()
  819. //获取班种
  820. this.getScheduleList()
  821. let year = new Date().getFullYear()
  822. let month = new Date().getMonth() + 1
  823. let date = new Date().getDate()
  824. this.weekNum = this.getYearWeek(year,month,date)
  825. this.todayDate=this.formatDate(new Date())
  826. this.setDate(new Date())
  827. for (var i = 0; i <= 9; i++) {
  828. this.setDate1(this.addDate(this.currentDate, 7))
  829. }
  830. let newNum = 0
  831. for(let i = 0; i < this.weekList.length; i++){
  832. if(this.weekNum + i + 1 <= 53){
  833. let num = this.weekNum + i + 1
  834. let str = this.weekList[i][0] + '~' + this.weekList[i][6] + '(' + num + ')'
  835. this.typeOptions.push({value:i,label:str})
  836. let stt = this.weekList[i][0] +"~"+this.weekList[i][6]
  837. this.timeOptions.push({value:i,label:stt})
  838. }else{
  839. newNum++
  840. let str = this.weekList[i][0] + '~' + this.weekList[i][6] + '(' + newNum + ')'
  841. this.typeOptions.push({value:i,label:str})
  842. let stt = this.weekList[i][0] +"~"+this.weekList[i][6]
  843. this.timeOptions.push({value:i,label:stt})
  844. }
  845. }
  846. var now = moment().locale('zh-cn').format('YYYY-MM-DD 00:00:00')
  847. console.log('now',now)
  848. this.timeNow = this.getTimestamp(now)
  849. console.log("timenow",this.timeNow)
  850. }
  851. }
  852. </script>
  853. <style lang="scss" scoped>
  854. .dateBox{
  855. border: 1px solid #DCDFE6;
  856. height: 36px;
  857. line-height: 36px;
  858. text-align: center;
  859. padding: 0 10px;
  860. border-radius: 4px;
  861. }
  862. .classBox{
  863. width:28%;
  864. height: 100%;
  865. border: 1px solid #d0d3da;
  866. .classTitle{
  867. height: 42px;
  868. text-align: center;
  869. line-height: 42px;
  870. background-color: rgb(245, 247, 250);
  871. color: rgb(96, 98, 102);
  872. font-weight:bold;
  873. }
  874. .classMain{
  875. height: 400px;
  876. padding: 0 0 0 20px;
  877. display: flex;
  878. justify-content: space-between;
  879. flex-direction: column;
  880. >div>p{
  881. line-height: 30px;
  882. color: rgb(48, 49, 51);
  883. }
  884. .classMainBox{
  885. height: 350px;
  886. overflow-y: auto;
  887. }
  888. }
  889. }
  890. </style>
  891. <style lang="scss">
  892. .schedulingTable{
  893. .el-table th .cell {
  894. white-space: pre-line;/*保留换行符*/
  895. }
  896. }
  897. </style>