index.vue 107KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309
  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="setting">设置</el-button>
  7. <el-button type="primary" @click="DeleteStaffSchedule">清除</el-button>
  8. <el-button type="primary" @click="copyStaffSchedule">复制</el-button>
  9. <el-button type="primary" icon="el-icon-printer" @click="toPrint">打印</el-button>
  10. <el-button type="primary" icon="el-icon-printer" @click="exportList">导出</el-button>
  11. </div>
  12. </div>
  13. <div class="app-container">
  14. <div class="cell clearfix">
  15. <el-input
  16. size="small"
  17. style="width: 150px;"
  18. class="filter-item"
  19. v-model.trim="keywords"
  20. placeholder="请输入医护人员姓名"
  21. @keyup.enter.native='toSearch'
  22. />
  23. <el-button
  24. size="small"
  25. class="filter-item"
  26. type="primary"
  27. icon="el-icon-search"
  28. @click="toSearch"
  29. >搜索</el-button
  30. >
  31. <el-select style="margin-left:10px;width:150px;" v-model="typeValue" placeholder="请选择" @change="changeOption">
  32. <el-option
  33. v-for="item in options"
  34. :key="item.value"
  35. :label="item.label"
  36. :value="item.value">
  37. </el-option>
  38. </el-select>
  39. <el-button @click="lastclick" type="text" style="margin:0 10px;">&lt;上一周({{ weekNum - 1 }})</el-button>
  40. <div class="dateBox">{{ weekDayArr[0] }}-{{ weekDayArr[6] }}({{ weekNum }})</div>
  41. <el-button @click="nextclick" type="text" style="margin:0 10px;">下一周({{ weekNum + 1 }})&gt;</el-button>
  42. </div>
  43. <div class="schedulingTable" style="display:flex;justify-content: space-between;">
  44. <div style="width: 70%">
  45. <el-table :data="tableData" border
  46. :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)', color: '#606266'}"
  47. :row-style="{ color: '#303133' }" @cell-click="clickThis" :cell-style="tableCellStyle"
  48. @cell-mouse-enter="hoverMouse" @cell-mouse-leave="leavemouse">
  49. <!-- @cell-mouse-enter="hoverMouse" @cell-mouse-leave="leavemouse" -->
  50. <el-table-column prop="name" label="医护姓名" style="width:16%" align="center">
  51. <template slot-scope="scope">
  52. <span>{{scope.row.user_name}}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column :label="'周一\n(' + weekDayArr[0] + ')'" style="width:200px" align="center">
  56. <template slot-scope="scope">
  57. <div v-if="name==scope.row.user_name&&column_lie =='周一' ? true:false">
  58. <div class="del_table_btns" v-show="scope.row.user_name=='合计'? false : true" >
  59. <el-button type="danger" size="mini" icon="el-icon-close"
  60. circle @click.stop="toClick(getClassId(scope.row.user_name,1))"
  61. ></el-button>
  62. </div>
  63. </div>
  64. <div @click="hangdleClick(scope.row,scope.$index,0)">
  65. <el-dropdown trigger="click" @command="changeSchedule" >
  66. <span class="el-dropdown-link" v-if='getClassAttributes(scope.row.user_name,1) == 2' style="color:red">
  67. <span>{{ getClass(scope.row.user_name,1) }}</span><i v-if="getTimestamp(weekDayArr[0])>=timeNow && scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  68. </span>
  69. <span class="el-dropdown-link" v-else>
  70. <span>{{ getClass(scope.row.user_name,1) }}</span><i v-if="getTimestamp(weekDayArr[0])>=timeNow && scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  71. </span>
  72. <el-dropdown-menu slot="dropdown" >
  73. <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>
  74. </el-dropdown-menu>
  75. </el-dropdown>
  76. </div>
  77. </template>
  78. </el-table-column>
  79. <el-table-column prop="name" :label="'周二\n(' + weekDayArr[1] + ')'" style="width:14%" align="center">
  80. <template slot-scope="scope">
  81. <div v-if="name==scope.row.user_name&&column_lie =='周二' ? true:false">
  82. <div class="del_table_btns" v-show="scope.row.user_name=='合计'? false : true">
  83. <el-button type="danger" size="mini" icon="el-icon-close"
  84. circle @click.stop="toClick(getClassId(scope.row.user_name,2))"
  85. ></el-button>
  86. </div>
  87. </div>
  88. <div @click="hangdleClick(scope.row,scope.$index,1)">
  89. <el-dropdown trigger="click" @command="changeSchedule">
  90. <span class="el-dropdown-link" v-if='getClassAttributes(scope.row.user_name,2) == 2' style="color:red">
  91. <span>{{ getClass(scope.row.user_name,2) }}</span><i v-if="getTimestamp(weekDayArr[1])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  92. </span>
  93. <span class="el-dropdown-link" v-else>
  94. <span>{{ getClass(scope.row.user_name,2) }}</span><i v-if="getTimestamp(weekDayArr[1])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  95. </span>
  96. <el-dropdown-menu slot="dropdown" >
  97. <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>
  98. </el-dropdown-menu>
  99. </el-dropdown>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column prop="name" :label="'周三\n(' + weekDayArr[2] + ')'" style="width:14%" align="center">
  104. <template slot-scope="scope">
  105. <div v-if="name==scope.row.user_name&&column_lie =='周三' ? true:false">
  106. <div class="del_table_btns" v-show="scope.row.user_name=='合计'? false : true">
  107. <el-button type="danger" size="mini" icon="el-icon-close"
  108. circle @click.stop="toClick(getClassId(scope.row.user_name,3))"
  109. ></el-button>
  110. </div>
  111. </div>
  112. <div @click="hangdleClick(scope.row,scope.$index,2)">
  113. <el-dropdown trigger="click" @command="changeSchedule">
  114. <span class="el-dropdown-link" v-if='getClassAttributes(scope.row.user_name,3) == 2' style="color:red">
  115. <span>{{ getClass(scope.row.user_name,3) }}</span><i v-if="getTimestamp(weekDayArr[2])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  116. </span>
  117. <span class="el-dropdown-link" v-else>
  118. <span>{{ getClass(scope.row.user_name,3) }}</span><i v-if="getTimestamp(weekDayArr[2])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  119. </span>
  120. <el-dropdown-menu slot="dropdown" >
  121. <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>
  122. </el-dropdown-menu>
  123. </el-dropdown>
  124. </div>
  125. </template>
  126. </el-table-column>
  127. <el-table-column prop="name" :label="'周四\n(' + weekDayArr[3] + ')'" style="width:14%" align="center">
  128. <template slot-scope="scope">
  129. <div v-if="name==scope.row.user_name&&column_lie =='周四' ? true:false">
  130. <div class="del_table_btns" v-show="scope.row.user_name=='合计'? false : true">
  131. <el-button type="danger" size="mini" icon="el-icon-close"
  132. circle @click.stop="toClick(getClassId(scope.row.user_name,4))"
  133. ></el-button>
  134. </div>
  135. </div>
  136. <div @click="hangdleClick(scope.row,scope.$index,3)">
  137. <el-dropdown trigger="click" @command="changeSchedule">
  138. <span class="el-dropdown-link" v-if='getClassAttributes(scope.row.user_name,4) == 2' style="color:red">
  139. <span>{{ getClass(scope.row.user_name,4) }}</span><i v-if="getTimestamp(weekDayArr[3])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  140. </span>
  141. <span class="el-dropdown-link" v-else>
  142. <span>{{ getClass(scope.row.user_name,4) }}</span><i v-if="getTimestamp(weekDayArr[3])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  143. </span>
  144. <el-dropdown-menu slot="dropdown" >
  145. <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>
  146. </el-dropdown-menu>
  147. </el-dropdown>
  148. </div>
  149. </template>
  150. </el-table-column>
  151. <el-table-column prop="name" :label="'周五\n(' + weekDayArr[4] + ')'" style="width:14%" align="center">
  152. <template slot-scope="scope">
  153. <div v-if="name==scope.row.user_name&&column_lie =='周五' ? true:false">
  154. <div class="del_table_btns" v-show="scope.row.user_name=='合计'? false : true">
  155. <el-button type="danger" size="mini" icon="el-icon-close"
  156. circle @click.stop="toClick(getClassId(scope.row.user_name,5))"
  157. ></el-button>
  158. </div>
  159. </div>
  160. <div @click="hangdleClick(scope.row,scope.$index,4)">
  161. <el-dropdown trigger="click" @command="changeSchedule">
  162. <span class="el-dropdown-link" v-if='getClassAttributes(scope.row.user_name,5) == 2' style="color:red">
  163. <span>{{ getClass(scope.row.user_name,5) }}</span><i v-if="getTimestamp(weekDayArr[4])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  164. </span>
  165. <span class="el-dropdown-link" v-else>
  166. <span>{{ getClass(scope.row.user_name,5) }}</span><i v-if="getTimestamp(weekDayArr[4])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  167. </span>
  168. <el-dropdown-menu slot="dropdown" >
  169. <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>
  170. </el-dropdown-menu>
  171. </el-dropdown>
  172. </div>
  173. </template>
  174. </el-table-column>
  175. <el-table-column prop="name" :label="'周六\n(' + weekDayArr[5] + ')'" style="width:14%" align="center">
  176. <template slot-scope="scope">
  177. <div v-if="name==scope.row.user_name&&column_lie =='周六' ? true:false">
  178. <div class="del_table_btns" v-show="scope.row.user_name=='合计'? false : true">
  179. <el-button type="danger" size="mini" icon="el-icon-close"
  180. circle @click.stop="toClick(getClassId(scope.row.user_name,6))"
  181. ></el-button>
  182. </div>
  183. </div>
  184. <div @click="hangdleClick(scope.row,scope.$index,5)">
  185. <el-dropdown trigger="click" @command="changeSchedule">
  186. <span class="el-dropdown-link" v-if='getClassAttributes(scope.row.user_name,6) == 2' style="color:red">
  187. <span>{{ getClass(scope.row.user_name,6) }}</span><i v-if="getTimestamp(weekDayArr[5])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  188. </span>
  189. <span class="el-dropdown-link" v-else>
  190. <span>{{ getClass(scope.row.user_name,6) }}</span><i v-if="getTimestamp(weekDayArr[5])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  191. </span>
  192. <el-dropdown-menu slot="dropdown" >
  193. <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>
  194. </el-dropdown-menu>
  195. </el-dropdown>
  196. </div>
  197. </template>
  198. </el-table-column>
  199. <el-table-column prop="name" :label="'周日\n(' + weekDayArr[6] + ')'" style="width:14%" align="center">
  200. <template slot-scope="scope">
  201. <div v-if="name==scope.row.user_name&&column_lie =='周日' ? true:false">
  202. <div class="del_table_btns" v-show="scope.row.user_name=='合计'? false : true">
  203. <el-button type="danger" size="mini" icon="el-icon-close"
  204. circle @click.stop="toClick(getClassId(scope.row.user_name,0))"
  205. ></el-button>
  206. </div>
  207. </div>
  208. <div @click="hangdleClick(scope.row,scope.$index,6)">
  209. <el-dropdown trigger="click" @command="changeSchedule">
  210. <span class="el-dropdown-link" v-if='getClassAttributes(scope.row.user_name,0) == 2' style="color:red">
  211. <span>{{ getClass(scope.row.user_name,0) }}</span><i v-if="getTimestamp(weekDayArr[6])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  212. </span>
  213. <span class="el-dropdown-link" v-else>
  214. <span>{{ getClass(scope.row.user_name,0) }}</span><i v-if="getTimestamp(weekDayArr[6])>=timeNow&&scope.row.admin_user_id!=1000000?true:false" class="el-icon-arrow-down el-icon--right"></i>
  215. </span>
  216. <el-dropdown-menu slot="dropdown" >
  217. <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>
  218. </el-dropdown-menu>
  219. </el-dropdown>
  220. </div>
  221. </template>
  222. </el-table-column>
  223. <el-table-column prop="name" :label="'备注'" style="width:14%" align="center">
  224. <template slot-scope="scope">
  225. <div @click="toDialog(scope.row)">
  226. <el-input placeholder="请输入内容" v-model="scope.row.remark"></el-input>
  227. </div>
  228. </template>
  229. </el-table-column>
  230. </el-table>
  231. <div> 备注: <el-input type="textarea" placeholder="请输入内容"v-model="remark" style="min-height:200px" @input="changeStaffRmark"></el-input></div>
  232. </div>
  233. <div class="classBox">
  234. <div class="classTitle">班种</div>
  235. <div class="classMain">
  236. <div class="classMainBox">
  237. <p v-for="(item,index) in schedulelist" :key="index">
  238. {{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> )
  239. </p>
  240. </div>
  241. <el-checkbox style="text-align:center;padding-bottom: 10px;" v-model="isChecked" @change="toContinuous">连续排班</el-checkbox>
  242. </div>
  243. </div>
  244. </div>
  245. <el-dialog
  246. title="复制排班"
  247. width="600px"
  248. :visible.sync="newVisible"
  249. >
  250. <el-form :model="form" ref="form" label-width="90px" :rules="rules">
  251. <el-form-item label="复制到 : " required prop="copyWeek">
  252. <el-select v-model="form.copyWeek" placeholder="请选择">
  253. <el-option
  254. v-for="item in typeOptions"
  255. :key="item.value"
  256. :label="item.label"
  257. :value="item.value">
  258. </el-option>
  259. </el-select>
  260. </el-form-item>
  261. </el-form>
  262. <div slot="footer" class="dialog-footer">
  263. <el-button @click="newVisible=false">取 消</el-button>
  264. <el-button v-loading="copySchLoading" type="primary" @click="submitAction('form')">保 存</el-button>
  265. </div>
  266. </el-dialog>
  267. <el-dialog
  268. title="设置"
  269. width="800px"
  270. :visible.sync="nurseVisible"
  271. :before-close="_close"
  272. >
  273. <div>
  274. <el-tabs v-model="activeName">
  275. <el-tab-pane label="护士" name="nurse">
  276. <el-table
  277. :data="nurseTableData"
  278. border
  279. height="250"
  280. style="width: 100%">
  281. <el-table-column align="center" prop="name" label="姓名" width="180">
  282. <template slot-scope="scope">
  283. {{scope.row.user_name}}
  284. </template>
  285. </el-table-column>
  286. <el-table-column align="center" prop="date" label="职称" width="180">
  287. <template slot-scope="scope">
  288. <span v-if="scope.row.user_title == 1">医士</span>
  289. <span v-if="scope.row.user_title == 2">医师</span>
  290. <span v-if="scope.row.user_title == 3">住院医师</span>
  291. <span v-if="scope.row.user_title == 4">主治医师</span>
  292. <span v-if="scope.row.user_title == 5">副主任医师</span>
  293. <span v-if="scope.row.user_title == 6">主任医师</span>
  294. <span v-if="scope.row.user_title == 7">护士</span>
  295. <span v-if="scope.row.user_title == 8">护师</span>
  296. <span v-if="scope.row.user_title == 9">主管护师</span>
  297. <span v-if="scope.row.user_title == 10">副主任护师</span>
  298. <span v-if="scope.row.user_title == 11">主任护师</span>
  299. <span v-if="scope.row.user_title == 12">运营专员</span>
  300. <span v-if="scope.row.user_title == 13">运营主管</span>
  301. </template>
  302. </el-table-column>
  303. <el-table-column
  304. align="center"
  305. label="排序">
  306. <template slot-scope="scope">
  307. <el-input v-model="scope.row.sort" @change="changeSort(scope.row)" placeholder="请输入内容"></el-input>
  308. </template>
  309. </el-table-column>
  310. <el-table-column
  311. align="center"
  312. label="是否排班">
  313. <template slot-scope="scope">
  314. <el-radio-group v-model="scope.row.is_sort" @change="changeRadio(scope.row)">
  315. <el-radio :label="1">是</el-radio>
  316. <el-radio :label="0">否</el-radio>
  317. </el-radio-group>
  318. </template>
  319. </el-table-column>
  320. </el-table>
  321. </el-tab-pane>
  322. <el-tab-pane label="医生" name="doctor">
  323. <el-table
  324. :data="doctorTableData"
  325. border
  326. height="250"
  327. style="width: 100%">
  328. <el-table-column
  329. align="center"
  330. prop="name"
  331. label="姓名"
  332. width="180">
  333. <template slot-scope="scope">
  334. {{scope.row.user_name}}
  335. </template>
  336. </el-table-column>
  337. <el-table-column align="center" prop="date" label="职称" width="180">
  338. <template slot-scope="scope">
  339. <span v-if="scope.row.user_title == 1">医士</span>
  340. <span v-if="scope.row.user_title == 2">医师</span>
  341. <span v-if="scope.row.user_title == 3">住院医师</span>
  342. <span v-if="scope.row.user_title == 4">主治医师</span>
  343. <span v-if="scope.row.user_title == 5">副主任医师</span>
  344. <span v-if="scope.row.user_title == 6">主任医师</span>
  345. <span v-if="scope.row.user_title == 7">护士</span>
  346. <span v-if="scope.row.user_title == 8">护师</span>
  347. <span v-if="scope.row.user_title == 9">主管护师</span>
  348. <span v-if="scope.row.user_title == 10">副主任护师</span>
  349. <span v-if="scope.row.user_title == 11">主任护师</span>
  350. <span v-if="scope.row.user_title == 12">运营专员</span>
  351. <span v-if="scope.row.user_title == 13">运营主管</span>
  352. </template>
  353. </el-table-column>
  354. <el-table-column
  355. align="center"
  356. label="排序">
  357. <template slot-scope="scope">
  358. <el-input v-model="scope.row.sort" placeholder="请输入内容" @change="changeSort(scope.row)"></el-input>
  359. </template>
  360. </el-table-column>
  361. <el-table-column
  362. align="center"
  363. label="是否排班">
  364. <template slot-scope="scope">
  365. <el-radio-group v-model="scope.row.is_sort" @change="changeRadio(scope.row)">
  366. <el-radio :label="1">是</el-radio>
  367. <el-radio :label="0">否</el-radio>
  368. </el-radio-group>
  369. </template>
  370. </el-table-column>
  371. </el-table>
  372. </el-tab-pane>
  373. </el-tabs>
  374. </div>
  375. </el-dialog>
  376. </div>
  377. <!-- <el-dialog
  378. title="导出排班"
  379. :visible.sync="exportDialogVisible"
  380. width="30%">
  381. <span>
  382. <div class="block">
  383. <span class="demonstration">月份:</span>
  384. <el-date-picker
  385. v-model="value1"
  386. type="week"
  387. format="yyyy 第 WW 周"
  388. placeholder="选择周">
  389. </el-date-picker>
  390. </div>
  391. </span>
  392. <span slot="footer" class="dialog-footer">
  393. <el-button @click="dialogVisible = false">取 消</el-button>
  394. <el-button type="primary" @click="exportList">确 定</el-button>
  395. </span>
  396. </el-dialog> -->
  397. <el-dialog
  398. title="设置备注"
  399. :visible.sync="dialogVisible"
  400. width="40%">
  401. <span>
  402. <el-input v-model="content" type="textarea"></el-input>
  403. </span>
  404. <span slot="footer" class="dialog-footer">
  405. <el-button @click="dialogVisible = false">取 消</el-button>
  406. <el-button type="primary" @click="saveDialog">确 定</el-button>
  407. </span>
  408. </el-dialog>
  409. </div>
  410. </template>
  411. <script>
  412. const moment = require('moment')
  413. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  414. import { getDoctorList,getScheduleList,addSchedule,getStaffScheduleList,getNextWeekList,getScheduleByDoctorId,toSearchScheduleList,DeleteStaffSchedule,copyStaffSchedule,UpdateContinusSchedule,SaveNurseSort,SaveIsSchedule,DeleteStaffScheduleById,saveStafScheduleRemark,getStaffScheduleRemarkList,changeStaffRmark } from '@/api/doctorSchedule'
  415. import { constants } from 'crypto'
  416. export default {
  417. components:{
  418. BreadCrumb
  419. },
  420. data(){
  421. return{
  422. copySchLoading:false,
  423. crumbs: [
  424. { path: false, name: '医护排班' },
  425. { path: '/medicalScheduling/index', name: '医护排班' }
  426. ],
  427. keywords:'',
  428. options: [{
  429. value: '0',
  430. label: '全部'
  431. }, {
  432. value: '2',
  433. label: '医生'
  434. }, {
  435. value: '3',
  436. label: '护士'
  437. }],
  438. typeValue:'0',
  439. tableData: [],
  440. isChecked:true,
  441. schedulelist:[],
  442. weekNum:'',
  443. weekDayArr:[],
  444. todayDate:'',
  445. clen:7,
  446. nowYear: new Date().getFullYear(),
  447. schedule_week:0,
  448. docobj:{},
  449. class_name:"",
  450. doctorlist:[],
  451. schedule_date:"",
  452. newVisible:false,
  453. typeOptions:[],
  454. timeOptions:[],
  455. copyWeek:'',
  456. weekList: [],
  457. currentFirstDate1: '',
  458. form:{
  459. copyWeek:"",
  460. },
  461. rules: {
  462. copyWeek: [{ required: true, message: "请选择复制时间段", trigger: "blur" }],
  463. },
  464. timeNow:0,
  465. arrZero:[],
  466. arrOne:[],
  467. arrTwo:[],
  468. arrThree:[],
  469. arrFour:[],
  470. arrFive:[],
  471. arrSix:[],
  472. arrSeven:[],
  473. nurseVisible:false,
  474. activeName:'nurse',
  475. radio:'1',
  476. nurseTableData:[],
  477. doctorTableData:[],
  478. exportDialogVisible:false,
  479. month_time:"",
  480. name:'',
  481. column_lie:'',
  482. remark:"",
  483. dialogVisible:false,
  484. content:"",
  485. staffObj:{}
  486. }
  487. },
  488. methods:{
  489. search(){},
  490. // toPrint(){
  491. // this.exportDialogVisible = true
  492. // },
  493. toPrint(){
  494. this.$router.push({
  495. path: '/medicalScheduling/schedule/print?starttime='+this.getTimestamp(this.weekDayArr[0])+"&endtime="+this.getTimestamp(this.weekDayArr[6])+"&weekArr="+ this.weekDayArr+"&typeValue="+this.typeValue,
  496. // query: { date: date }
  497. })
  498. },
  499. getDoctorList(){
  500. getDoctorList().then(response=>{
  501. if(response.data.state == 1){
  502. var list = response.data.data.list
  503. // console.log("医护列表",list)
  504. // this.tableData = list
  505. // let arr = []
  506. // list.map(item => {
  507. // if(item.is_sort == 1){
  508. // arr.push(item)
  509. // }
  510. // })
  511. // this.doctorlist = arr
  512. //获取班种列表
  513. this.getStaffScheduleList()
  514. var doctorlist = response.data.data.doctorlist
  515. for(let i=0;i<doctorlist.length;i++){
  516. if(doctorlist[i].sort == 0){
  517. doctorlist[i].sort = ""
  518. }
  519. }
  520. console.log('doctorlist',doctorlist)
  521. this.doctorTableData = doctorlist
  522. var nurselist = response.data.data.nurselist
  523. for(let i=0;i<nurselist.length;i++){
  524. if(nurselist[i].sort == 0){
  525. nurselist[i].sort = ""
  526. }
  527. }
  528. this.nurseTableData = nurselist
  529. }
  530. })
  531. },
  532. getScheduleList(){
  533. getScheduleList().then(response=>{
  534. if(response.data.state == 1){
  535. var schedulelist = response.data.data.scheduleList
  536. // console.log("schedulelist",schedulelist)
  537. for(let i=0;i<schedulelist.length;i++){
  538. if(schedulelist[i].timeone_type == 1){
  539. schedulelist[i].timeone_type = "当日"
  540. }
  541. if(schedulelist[i].timeone_type == 2){
  542. schedulelist[i].timeone_type = "次日"
  543. }
  544. if(schedulelist[i].timetwo_type == 1){
  545. schedulelist[i].timetwo_type = "当日"
  546. }
  547. if(schedulelist[i].timetwo_type == 2){
  548. schedulelist[i].timetwo_type = "次日"
  549. }
  550. }
  551. this.schedulelist = schedulelist
  552. }
  553. })
  554. },
  555. hangdleClick(val,index,num){
  556. console.log("val",val)
  557. this.docobj = val
  558. if(this.getTimestamp(this.weekDayArr[num]) < this.timeNow){
  559. this.$message.error("过去日期不可以编辑")
  560. return
  561. }
  562. },
  563. clickThis(row, column, cell, event){
  564. var week = (column.label).split('');
  565. var weeks = week[0]+week[1]
  566. if(weeks == "周日"){
  567. this.schedule_week = 0
  568. this.schedule_date = this.weekDayArr[6]
  569. }
  570. if(weeks == "周一"){
  571. this.schedule_week = 1
  572. this.schedule_date = this.weekDayArr[0]
  573. }
  574. if(weeks=="周二"){
  575. this.schedule_week = 2
  576. this.schedule_date = this.weekDayArr[1]
  577. }
  578. if(weeks=="周三"){
  579. this.schedule_week = 3
  580. this.schedule_date = this.weekDayArr[2]
  581. }
  582. if(weeks=="周四"){
  583. this.schedule_week = 4
  584. this.schedule_date = this.weekDayArr[3]
  585. }
  586. if(weeks == "周五"){
  587. this.schedule_week = 5
  588. this.schedule_date = this.weekDayArr[4]
  589. }
  590. if(weeks== "周六"){
  591. this.schedule_week = 6
  592. this.schedule_date = this.weekDayArr[5]
  593. }
  594. },
  595. changeSchedule(id){
  596. var class_name = ""
  597. for(let i=0;i<this.schedulelist.length;i++){
  598. if(id == this.schedulelist[i].id){
  599. class_name = this.schedulelist[i].class_name
  600. }
  601. }
  602. let arr = [...this.tableData]
  603. // console.log("arr===",arr)
  604. for(let i=0;i<arr.length;i++){
  605. if(this.docobj.id == arr[i].id){
  606. arr[i].class_name = class_name
  607. arr[i].class_index = this.schedule_week
  608. }
  609. }
  610. // console.log("arr",arr)
  611. this.tableData = arr
  612. const params = {
  613. doctor_id:this.docobj.admin_user_id,
  614. doctor_type:this.docobj.user_type,
  615. schedule_type:id,
  616. schedule_week:this.schedule_week,
  617. start_time:this.getTimestamp(this.weekDayArr[0]),
  618. end_time:this.getTimestamp(this.weekDayArr[6]),
  619. schedule_date:this.getTimestamp(this.schedule_date)
  620. }
  621. // console.log("params",params)
  622. addSchedule(params).then(response=>{
  623. if(response.data.state == 1){
  624. var schedule = response.data.data.schedule
  625. // console.log("schedule",schedule)
  626. this.$message.success("保存成功")
  627. this.getStaffScheduleList()
  628. }
  629. })
  630. },
  631. formatDate(date){
  632. var year = date.getFullYear()+'.'
  633. var month = (date.getMonth()+1)+'.';
  634. var day = date.getDate();
  635. return year+month+day
  636. },
  637. formatDateTwo(date){
  638. var year = date.getFullYear()+'.'
  639. var month = (date.getMonth()+1)+'.';
  640. var day = date.getDate();
  641. return year+month+day
  642. },
  643. addDate(date,n){
  644. date.setDate(date.getDate()+n);
  645. return date;
  646. },
  647. //
  648. setDate(date){
  649. var week = date.getDay()-1;
  650. date = this.addDate(date,week*-1);
  651. this.currentFirstDate = new Date(date);
  652. this.currentDate = new Date(date)
  653. for(var i = 0;i<this.clen; i++){
  654. this.weekDayArr.push(this.formatDate(i==0 ? date : this.addDate(date,1)))
  655. }
  656. },
  657. //上一周
  658. lastclick(){
  659. this.weekDayArr=[]
  660. this.setDate(this.addDate(this.currentFirstDate,-7));
  661. if (this.weekNum == 1) {
  662. let year = this.nowYear - 1
  663. let month = 12
  664. let date = 31
  665. this.weekNum = this.getYearWeek(year, month, date)
  666. this.nowYear = this.nowYear - 1
  667. }
  668. this.weekNum = this.weekNum - 1
  669. this.getNextWeekList()
  670. this.getStaffScheduleRemarkList()
  671. },
  672. //下一周
  673. nextclick(){
  674. this.weekDayArr=[]
  675. this.setDate(this.addDate(this.currentFirstDate,7));
  676. this.weekNum = this.weekNum + 1
  677. if (this.weekNum == 53) {
  678. let year = this.nowYear + 1
  679. let month = 1
  680. let date = 1
  681. this.weekNum = this.getYearWeek(year, month, date)
  682. this.nowYear = this.nowYear + 1
  683. }
  684. this.getNextWeekList()
  685. this.getStaffScheduleRemarkList()
  686. },
  687. getYearWeek(year,month,date){
  688. /*
  689. dateNow是当前日期
  690. dateFirst是当年第一天
  691. dataNumber是当前日期是今年第多少天
  692. 用dataNumber + 当前年的第一天的周差距的和在除以7就是本年第几周
  693. */
  694. let dateNow = new Date(year, parseInt(month) - 1, date);
  695. let dateFirst = new Date(year, 0, 1);
  696. let dataNumber = Math.round((dateNow.valueOf() - dateFirst.valueOf()) / 86400000);
  697. return Math.ceil((dataNumber + ((dateFirst.getDay() + 1) - 1)) / 7);
  698. },
  699. getTimestamp(time) { //把时间日期转成时间戳
  700. return (new Date(time)).getTime() / 1000
  701. },
  702. beforeHandleCommand(item,row){
  703. return {
  704. 'command': item,
  705. 'row': row
  706. }
  707. },
  708. //获取所有医护排班数据
  709. getStaffScheduleList(){
  710. const params = {
  711. start_time:this.getTimestamp(this.weekDayArr[0]),
  712. end_time:this.getTimestamp(this.weekDayArr[6])
  713. }
  714. getStaffScheduleList(params).then(response=>{
  715. if(response.data.state == 1){
  716. var staffList = response.data.data.staffList
  717. // console.log("获取所有排班",staffList)
  718. var sevenStr = ""
  719. var oneStr = ""
  720. var twoStr = ""
  721. var threeStr = ""
  722. var fourStr = ""
  723. var fiveStr = ""
  724. var sixStr = ""
  725. this.arrZero = []
  726. this.arrOne = []
  727. this.arrTwo = []
  728. this.arrThree = []
  729. this.arrFour = []
  730. this.arrFive = []
  731. this.arrSix = []
  732. for(let i=0;i<staffList.length;i++){
  733. if(staffList[i].schedule_week == 0){
  734. staffList[i].class_index = 0
  735. var arr = []
  736. this.arrZero.push(staffList[i].class_name)
  737. for(let i=0;i<this.arrZero.length;i++){
  738. if(this.arrZero[i]!=''){
  739. arr.push(this.arrZero[i])
  740. }
  741. }
  742. var countedNames = arr.reduce(function (allNames, name) {
  743. if (name in allNames) {
  744. allNames[name]++;
  745. }
  746. else {
  747. allNames[name] = 1;
  748. }
  749. return allNames;
  750. }, {});
  751. let objKey = Object.keys(countedNames)
  752. let objVal = Object.values(countedNames)
  753. var zeroStr = ''
  754. objKey.map((item,index) => {
  755. let objVal = Object.values(countedNames)
  756. zeroStr += item + objVal[index] + '\n'
  757. })
  758. sevenStr = zeroStr
  759. }
  760. if(staffList[i].schedule_week == 1){
  761. staffList[i].class_index = 1
  762. var arr = []
  763. this.arrOne.push(staffList[i].class_name)
  764. for(let i=0;i<this.arrOne.length;i++){
  765. if(this.arrOne[i]!=''){
  766. arr.push(this.arrOne[i])
  767. }
  768. }
  769. var countedNames = arr.reduce(function (allNames, name) {
  770. if (name in allNames) {
  771. allNames[name]++;
  772. }
  773. else {
  774. allNames[name] = 1;
  775. }
  776. return allNames;
  777. }, {});
  778. let objKey = Object.keys(countedNames)
  779. let objVal = Object.values(countedNames)
  780. let strOne = ''
  781. objKey.map((item,index) => {
  782. let objVal = Object.values(countedNames)
  783. strOne += item + objVal[index] + '\n'
  784. })
  785. oneStr = strOne
  786. }
  787. if(staffList[i].schedule_week == 2){
  788. staffList[i].class_index = 2
  789. var arr = []
  790. this.arrTwo.push(staffList[i].class_name)
  791. for(let i=0;i<this.arrTwo.length;i++){
  792. if(this.arrTwo[i]!=''){
  793. arr.push(this.arrTwo[i])
  794. }
  795. }
  796. var countedNames = arr.reduce(function (allNames, name) {
  797. if (name in allNames) {
  798. allNames[name]++;
  799. }
  800. else {
  801. allNames[name] = 1;
  802. }
  803. return allNames;
  804. }, {});
  805. let objKey = Object.keys(countedNames)
  806. let objVal = Object.values(countedNames)
  807. let strTwo = ''
  808. objKey.map((item,index) => {
  809. let objVal = Object.values(countedNames)
  810. strTwo += item + objVal[index] + '\n'
  811. })
  812. twoStr = strTwo
  813. }
  814. if(staffList[i].schedule_week == 3){
  815. staffList[i].class_index = 3
  816. var arr = []
  817. this.arrThree.push(staffList[i].class_name)
  818. for(let i=0;i<this.arrThree.length;i++){
  819. if(this.arrThree[i]!=''){
  820. arr.push(this.arrThree[i])
  821. }
  822. }
  823. var countedNames = arr.reduce(function (allNames, name) {
  824. if (name in allNames) {
  825. allNames[name]++;
  826. }
  827. else {
  828. allNames[name] = 1;
  829. }
  830. return allNames;
  831. }, {});
  832. let objKey = Object.keys(countedNames)
  833. let objVal = Object.values(countedNames)
  834. let strThree = ''
  835. objKey.map((item,index) => {
  836. let objVal = Object.values(countedNames)
  837. strThree += item + objVal[index] + '\n'
  838. })
  839. threeStr = strThree
  840. }
  841. if(staffList[i].schedule_week == 4){
  842. staffList[i].class_index = 4
  843. var arr = []
  844. this.arrFour.push(staffList[i].class_name)
  845. for(let i=0;i<this.arrFour.length;i++){
  846. if(this.arrFour[i]!=''){
  847. arr.push(this.arrFour[i])
  848. }
  849. }
  850. var countedNames = arr.reduce(function (allNames, name) {
  851. if (name in allNames) {
  852. allNames[name]++;
  853. }
  854. else {
  855. allNames[name] = 1;
  856. }
  857. return allNames;
  858. }, {});
  859. let objKey = Object.keys(countedNames)
  860. let objVal = Object.values(countedNames)
  861. let strFour = ''
  862. objKey.map((item,index) => {
  863. let objVal = Object.values(countedNames)
  864. strFour += item + objVal[index] + '\n'
  865. })
  866. fourStr = strFour
  867. }
  868. if(staffList[i].schedule_week == 5){
  869. staffList[i].class_index = 5
  870. var arr = []
  871. this.arrFive.push(staffList[i].class_name)
  872. for(let i=0;i<this.arrFive.length;i++){
  873. if(this.arrFive[i]!=''){
  874. arr.push(this.arrFive[i])
  875. }
  876. }
  877. var countedNames = arr.reduce(function (allNames, name) {
  878. if (name in allNames) {
  879. allNames[name]++;
  880. }
  881. else {
  882. allNames[name] = 1;
  883. }
  884. return allNames;
  885. }, {});
  886. let objKey = Object.keys(countedNames)
  887. let objVal = Object.values(countedNames)
  888. let strFive = ''
  889. objKey.map((item,index) => {
  890. let objVal = Object.values(countedNames)
  891. strFive += item + objVal[index] + '\n'
  892. })
  893. fiveStr = strFive
  894. }
  895. if(staffList[i].schedule_week == 6){
  896. staffList[i].class_index = 6
  897. var arr = []
  898. this.arrSix.push(staffList[i].class_name)
  899. for(let i=0;i<this.arrSix.length;i++){
  900. if(this.arrSix[i]!=''){
  901. arr.push(this.arrSix[i])
  902. }
  903. }
  904. var countedNames = arr.reduce(function (allNames, name) {
  905. if (name in allNames) {
  906. allNames[name]++;
  907. }
  908. else {
  909. allNames[name] = 1;
  910. }
  911. return allNames;
  912. }, {});
  913. let objKey = Object.keys(countedNames)
  914. let objVal = Object.values(countedNames)
  915. let strSix = ''
  916. objKey.map((item,index) => {
  917. let objVal = Object.values(countedNames)
  918. strSix += item + objVal[index] + '\n'
  919. })
  920. sixStr = strSix
  921. }
  922. }
  923. console.log("staffList",staffList)
  924. let tempArr = [], newArr = []
  925. for (let i = 0; i < staffList.length; i++) {
  926. if (tempArr.indexOf(staffList[i].user_name) == -1) {
  927. newArr.push({
  928. id:staffList[i].id,
  929. user_name: staffList[i].user_name,
  930. admin_user_id:staffList[i].admin_user_id,
  931. user_type:staffList[i].doctor_type,
  932. is_sort:staffList[i].is_sort,
  933. sort:staffList[i].sort,
  934. list: [{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,class_attributes:staffList[i].class_attributesk,id:staffList[i].id}],
  935. remark:staffList[i].remark
  936. })
  937. tempArr.push(staffList[i].user_name);
  938. } else {
  939. console.log("staffList",staffList[i].user_name)
  940. for (let j = 0; j < newArr.length; j++) {
  941. if (newArr[j].admin_user_id == staffList[i].admin_user_id) {
  942. 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,class_attributes:staffList[i].class_attributes,id:staffList[i].id})
  943. }
  944. }
  945. }
  946. }
  947. let arrTen = [...newArr]
  948. console.log("newArr22o2o2o2o2wo",arrTen)
  949. let newNurse = []
  950. let newDoctor = []
  951. arrTen.map(item => {
  952. if(item.user_type == 2){
  953. newDoctor.push(item)
  954. }
  955. if(item.user_type == 3){
  956. newNurse.push(item)
  957. }
  958. })
  959. //护士
  960. console.log("newNurse",newNurse)
  961. newNurse.sort(this.compare('admin_user_id'))
  962. let newNurseTableData = []
  963. this.nurseTableData.map(item => {
  964. if(item.is_sort == 1){
  965. newNurseTableData.push(item)
  966. }
  967. })
  968. newNurseTableData.sort(this.compare('admin_user_id'))
  969. console.log("newNurseTableData",newNurseTableData)
  970. newNurseTableData.map((item,index) => {
  971. if (newNurse[index] && item.admin_user_id == newNurse[index].admin_user_id) {
  972. }else{
  973. newNurse.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  974. }
  975. })
  976. newNurse.sort(this.compare('sort'))
  977. // //医生
  978. newDoctor.sort(this.compare('admin_user_id'))
  979. let newDoctorTableData = []
  980. this.doctorTableData.map(item => {
  981. if(item.is_sort == 1){
  982. newDoctorTableData.push(item)
  983. }
  984. })
  985. newDoctorTableData.sort(this.compare('admin_user_id'))
  986. newDoctorTableData.map((item,index) => {
  987. if (newDoctor[index] && item.admin_user_id == newDoctor[index].admin_user_id) {
  988. }else{
  989. newDoctor.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  990. }
  991. })
  992. newDoctor.sort(this.compare('sort'))
  993. let arr2 = []
  994. arr2.push({class_name:oneStr,schedule_week:1})
  995. arr2.push({class_name:twoStr,schedule_week:2})
  996. arr2.push({class_name:threeStr,schedule_week:3})
  997. arr2.push({class_name:fourStr,schedule_week:4})
  998. arr2.push({class_name:fiveStr,schedule_week:5})
  999. arr2.push({class_name:sixStr,schedule_week:6})
  1000. arr2.push({class_name:sevenStr,schedule_week:0})
  1001. var obj = {}
  1002. obj.admin_user_id = "1000000"
  1003. obj.user_name = "合计"
  1004. obj.user_type = 10
  1005. obj.list = arr2
  1006. arr2.push(obj)
  1007. let data = []
  1008. data.push(...newNurse)
  1009. data.push(...newDoctor)
  1010. data.push(obj)
  1011. console.log("data2o2oo2o2o2o22o",data)
  1012. // this.tableData = this.distinct(data)
  1013. this.tableData = data
  1014. }
  1015. })
  1016. },
  1017. distinct(tempArr) {
  1018. for (let i = 0; i < tempArr.length; i++) {
  1019. for (let j = i + 1; j < tempArr.length; j++) {
  1020. if (tempArr[i].admin_user_id == tempArr[j].admin_user_id) {
  1021. tempArr.splice(j, 1);
  1022. j--;
  1023. };
  1024. };
  1025. };
  1026. return tempArr;
  1027. },
  1028. getClass(name,index){
  1029. if(name != undefined){
  1030. let newClass = '';
  1031. this.tableData.map(item => {
  1032. if(item.user_name == name){
  1033. if(item.list){
  1034. item.list.map(it => {
  1035. if(it.schedule_week == index){
  1036. newClass = it.class_name
  1037. }
  1038. })
  1039. }
  1040. }
  1041. })
  1042. return newClass
  1043. }
  1044. },
  1045. getClassId(name,index){
  1046. if(name != undefined){
  1047. let id = '';
  1048. this.tableData.map(item => {
  1049. if(item.user_name == name){
  1050. if(item.list){
  1051. item.list.map(it => {
  1052. if(it.schedule_week == index){
  1053. id = it.id
  1054. }
  1055. })
  1056. }
  1057. }
  1058. })
  1059. return id
  1060. }
  1061. },
  1062. getClassAttributes(name,index){
  1063. if(name != undefined){
  1064. let newClass = '';
  1065. this.tableData.map(item => {
  1066. if(item.user_name == name){
  1067. if(item.list){
  1068. item.list.map(it => {
  1069. if(it.schedule_week == index){
  1070. newClass = it.class_attributes
  1071. }
  1072. })
  1073. }
  1074. }
  1075. })
  1076. return newClass
  1077. }
  1078. },
  1079. unique(arr) {
  1080. const res = new Map();
  1081. return arr.filter((arr) => !res.has(arr.admin_user_id) && res.set(arr.admin_user_id, 1))
  1082. },
  1083. //获取上一周下一周的排班数据
  1084. getNextWeekList(){
  1085. const params = {
  1086. start_time:this.getTimestamp(this.weekDayArr[0]),
  1087. end_time:this.getTimestamp(this.weekDayArr[6]),
  1088. doctor_id:parseInt(this.typeValue),
  1089. }
  1090. console.log("params232323",params)
  1091. getNextWeekList(params).then(response=>{
  1092. if(response.data.state == 1){
  1093. var staffList = response.data.data.staffList
  1094. // console.log("上下周数据",staffList)
  1095. var sevenStr = ""
  1096. var oneStr = ""
  1097. var twoStr = ""
  1098. var threeStr = ""
  1099. var fourStr = ""
  1100. var fiveStr = ""
  1101. var sixStr = ""
  1102. this.arrZero = []
  1103. this.arrOne = []
  1104. this.arrTwo = []
  1105. this.arrThree = []
  1106. this.arrFour = []
  1107. this.arrFive = []
  1108. this.arrSix = []
  1109. for(let i=0;i<staffList.length;i++){
  1110. if(staffList[i].schedule_week == 0){
  1111. staffList[i].class_index = 0
  1112. var arr = []
  1113. this.arrZero.push(staffList[i].class_name)
  1114. for(let i=0;i<this.arrZero.length;i++){
  1115. if(this.arrZero[i]!=''){
  1116. arr.push(this.arrZero[i])
  1117. }
  1118. }
  1119. var countedNames = arr.reduce(function (allNames, name) {
  1120. if (name in allNames) {
  1121. allNames[name]++;
  1122. }
  1123. else {
  1124. allNames[name] = 1;
  1125. }
  1126. return allNames;
  1127. }, {});
  1128. let objKey = Object.keys(countedNames)
  1129. let objVal = Object.values(countedNames)
  1130. var zeroStr = ''
  1131. objKey.map((item,index) => {
  1132. let objVal = Object.values(countedNames)
  1133. zeroStr += item + objVal[index] + '\n'
  1134. })
  1135. sevenStr = zeroStr
  1136. }
  1137. if(staffList[i].schedule_week == 1){
  1138. staffList[i].class_index = 1
  1139. var arr = []
  1140. this.arrOne.push(staffList[i].class_name)
  1141. for(let i=0;i<this.arrOne.length;i++){
  1142. if(this.arrOne[i]!=''){
  1143. arr.push(this.arrOne[i])
  1144. }
  1145. }
  1146. var countedNames = arr.reduce(function (allNames, name) {
  1147. if (name in allNames) {
  1148. allNames[name]++;
  1149. }
  1150. else {
  1151. allNames[name] = 1;
  1152. }
  1153. return allNames;
  1154. }, {});
  1155. let objKey = Object.keys(countedNames)
  1156. let objVal = Object.values(countedNames)
  1157. let strOne = ''
  1158. objKey.map((item,index) => {
  1159. let objVal = Object.values(countedNames)
  1160. strOne += item + objVal[index] + '\n'
  1161. })
  1162. oneStr = strOne
  1163. }
  1164. if(staffList[i].schedule_week == 2){
  1165. staffList[i].class_index = 2
  1166. var arr = []
  1167. this.arrTwo.push(staffList[i].class_name)
  1168. for(let i=0;i<this.arrTwo.length;i++){
  1169. if(this.arrTwo[i]!=''){
  1170. arr.push(this.arrTwo[i])
  1171. }
  1172. }
  1173. var countedNames = arr.reduce(function (allNames, name) {
  1174. if (name in allNames) {
  1175. allNames[name]++;
  1176. }
  1177. else {
  1178. allNames[name] = 1;
  1179. }
  1180. return allNames;
  1181. }, {});
  1182. let objKey = Object.keys(countedNames)
  1183. let objVal = Object.values(countedNames)
  1184. let strTwo = ''
  1185. objKey.map((item,index) => {
  1186. let objVal = Object.values(countedNames)
  1187. strTwo += item + objVal[index] + '\n'
  1188. })
  1189. twoStr = strTwo
  1190. }
  1191. if(staffList[i].schedule_week == 3){
  1192. staffList[i].class_index = 3
  1193. var arr = []
  1194. this.arrThree.push(staffList[i].class_name)
  1195. for(let i=0;i<this.arrThree.length;i++){
  1196. if(this.arrThree[i]!=''){
  1197. arr.push(this.arrThree[i])
  1198. }
  1199. }
  1200. var countedNames = arr.reduce(function (allNames, name) {
  1201. if (name in allNames) {
  1202. allNames[name]++;
  1203. }
  1204. else {
  1205. allNames[name] = 1;
  1206. }
  1207. return allNames;
  1208. }, {});
  1209. let objKey = Object.keys(countedNames)
  1210. let objVal = Object.values(countedNames)
  1211. let strThree = ''
  1212. objKey.map((item,index) => {
  1213. let objVal = Object.values(countedNames)
  1214. strThree += item + objVal[index] + '\n'
  1215. })
  1216. threeStr = strThree
  1217. }
  1218. if(staffList[i].schedule_week == 4){
  1219. staffList[i].class_index = 4
  1220. var arr = []
  1221. this.arrFour.push(staffList[i].class_name)
  1222. for(let i=0;i<this.arrFour.length;i++){
  1223. if(this.arrFour[i]!=''){
  1224. arr.push(this.arrFour[i])
  1225. }
  1226. }
  1227. var countedNames = arr.reduce(function (allNames, name) {
  1228. if (name in allNames) {
  1229. allNames[name]++;
  1230. }
  1231. else {
  1232. allNames[name] = 1;
  1233. }
  1234. return allNames;
  1235. }, {});
  1236. let objKey = Object.keys(countedNames)
  1237. let objVal = Object.values(countedNames)
  1238. let strFour = ''
  1239. objKey.map((item,index) => {
  1240. let objVal = Object.values(countedNames)
  1241. strFour += item + objVal[index] + '\n'
  1242. })
  1243. fourStr = strFour
  1244. }
  1245. if(staffList[i].schedule_week == 5){
  1246. staffList[i].class_index = 5
  1247. var arr = []
  1248. this.arrFive.push(staffList[i].class_name)
  1249. for(let i=0;i<this.arrFive.length;i++){
  1250. if(this.arrFive[i]!=''){
  1251. arr.push(this.arrFive[i])
  1252. }
  1253. }
  1254. var countedNames = arr.reduce(function (allNames, name) {
  1255. if (name in allNames) {
  1256. allNames[name]++;
  1257. }
  1258. else {
  1259. allNames[name] = 1;
  1260. }
  1261. return allNames;
  1262. }, {});
  1263. let objKey = Object.keys(countedNames)
  1264. let objVal = Object.values(countedNames)
  1265. let strFive = ''
  1266. objKey.map((item,index) => {
  1267. let objVal = Object.values(countedNames)
  1268. strFive += item + objVal[index] + '\n'
  1269. })
  1270. fiveStr = strFive
  1271. }
  1272. if(staffList[i].schedule_week == 6){
  1273. staffList[i].class_index = 6
  1274. var arr = []
  1275. this.arrSix.push(staffList[i].class_name)
  1276. for(let i=0;i<this.arrSix.length;i++){
  1277. if(this.arrSix[i]!=''){
  1278. arr.push(this.arrSix[i])
  1279. }
  1280. }
  1281. var countedNames = arr.reduce(function (allNames, name) {
  1282. if (name in allNames) {
  1283. allNames[name]++;
  1284. }
  1285. else {
  1286. allNames[name] = 1;
  1287. }
  1288. return allNames;
  1289. }, {});
  1290. let objKey = Object.keys(countedNames)
  1291. let objVal = Object.values(countedNames)
  1292. let strSix = ''
  1293. objKey.map((item,index) => {
  1294. let objVal = Object.values(countedNames)
  1295. strSix += item + objVal[index] + '\n'
  1296. })
  1297. sixStr = strSix
  1298. }
  1299. }
  1300. let tempArr = [], newArr = []
  1301. for (let i = 0; i < staffList.length; i++) {
  1302. if (tempArr.indexOf(staffList[i].user_name) === -1) {
  1303. newArr.push({
  1304. user_name: staffList[i].user_name,
  1305. admin_user_id:staffList[i].admin_user_id,
  1306. user_type:staffList[i].doctor_type,
  1307. is_sort:staffList[i].is_sort,
  1308. sort:staffList[i].sort,
  1309. list: [{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,class_attributes:staffList[i].class_attributes}],
  1310. remark:staffList[i].remark
  1311. })
  1312. tempArr.push(staffList[i].user_name);
  1313. } else {
  1314. for (let j = 0; j < newArr.length; j++) {
  1315. if (newArr[j].user_name == staffList[i].user_name) {
  1316. 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,class_attributes:staffList[i].class_attributes})
  1317. }
  1318. }
  1319. }
  1320. }
  1321. let arr = [...newArr]
  1322. let newNurse = []
  1323. let newDoctor = []
  1324. arr.map(item => {
  1325. if(item.user_type == 2){
  1326. newDoctor.push(item)
  1327. }
  1328. if(item.user_type == 3){
  1329. newNurse.push(item)
  1330. }
  1331. })
  1332. //护士
  1333. newNurse.sort(this.compare('admin_user_id'))
  1334. let newNurseTableData = []
  1335. this.nurseTableData.map(item => {
  1336. if(item.is_sort == 1){
  1337. newNurseTableData.push(item)
  1338. }
  1339. })
  1340. newNurseTableData.sort(this.compare('admin_user_id'))
  1341. newNurseTableData.map((item,index) => {
  1342. if (newNurse[index] && item.admin_user_id == newNurse[index].admin_user_id) {
  1343. }else{
  1344. newNurse.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  1345. }
  1346. })
  1347. newNurse.sort(this.compare('sort'))
  1348. //医生
  1349. newDoctor.sort(this.compare('admin_user_id'))
  1350. let newDoctorTableData = []
  1351. this.doctorTableData.map(item => {
  1352. if(item.is_sort == 1){
  1353. newDoctorTableData.push(item)
  1354. }
  1355. })
  1356. newDoctorTableData.sort(this.compare('admin_user_id'))
  1357. newDoctorTableData.map((item,index) => {
  1358. if (newDoctor[index] && item.admin_user_id == newDoctor[index].admin_user_id) {
  1359. }else{
  1360. newDoctor.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  1361. }
  1362. })
  1363. newDoctor.sort(this.compare('sort'))
  1364. // arr.sort(this.compare('admin_user_id'))
  1365. // this.doctorlist.sort(this.compare('admin_user_id'))
  1366. // this.doctorlist.forEach((item, index) => {
  1367. //   if (arr[index] && item.admin_user_id == arr[index].admin_user_id) {
  1368. //   }else{
  1369. //     arr.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type})
  1370. //   }
  1371. // })
  1372. // arr.sort(this.compare('user_type'))
  1373. let arr2 = []
  1374. arr2.push({class_name:oneStr,schedule_week:1})
  1375. arr2.push({class_name:twoStr,schedule_week:2})
  1376. arr2.push({class_name:threeStr,schedule_week:3})
  1377. arr2.push({class_name:fourStr,schedule_week:4})
  1378. arr2.push({class_name:fiveStr,schedule_week:5})
  1379. arr2.push({class_name:sixStr,schedule_week:6})
  1380. arr2.push({class_name:sevenStr,schedule_week:0})
  1381. var obj = {}
  1382. obj.admin_user_id = "1000000"
  1383. obj.user_name = "合计"
  1384. obj.user_type = 10
  1385. obj.list = arr2
  1386. arr.push(obj)
  1387. if(parseInt(this.typeValue) == 2){
  1388. newNurse = []
  1389. }
  1390. if(parseInt(this.typeValue) == 3){
  1391. newDoctor = []
  1392. }
  1393. let data = []
  1394. data.push(...newNurse)
  1395. data.push(...newDoctor)
  1396. data.push(obj)
  1397. this.tableData = data
  1398. }
  1399. })
  1400. },
  1401. changeOption(id){
  1402. const params = {
  1403. start_time:this.getTimestamp(this.weekDayArr[0]),
  1404. end_time:this.getTimestamp(this.weekDayArr[6]),
  1405. doctor_id:id
  1406. }
  1407. getScheduleByDoctorId(params).then(response=>{
  1408. if(response.data.state == 1){
  1409. var staffList = response.data.data.staffList
  1410. // console.log("staffList",staffList)
  1411. var sevenStr = ""
  1412. var oneStr = ""
  1413. var twoStr = ""
  1414. var threeStr = ""
  1415. var fourStr = ""
  1416. var fiveStr = ""
  1417. var sixStr = ""
  1418. this.arrZero = []
  1419. this.arrOne = []
  1420. this.arrTwo = []
  1421. this.arrThree = []
  1422. this.arrFour = []
  1423. this.arrFive = []
  1424. this.arrSix = []
  1425. for(let i=0;i<staffList.length;i++){
  1426. if(staffList[i].schedule_week == 0){
  1427. staffList[i].class_index = 0
  1428. var arr = []
  1429. this.arrZero.push(staffList[i].class_name)
  1430. for(let i=0;i<this.arrZero.length;i++){
  1431. if(this.arrZero[i]!=''){
  1432. arr.push(this.arrZero[i])
  1433. }
  1434. }
  1435. var countedNames = arr.reduce(function (allNames, name) {
  1436. if (name in allNames) {
  1437. allNames[name]++;
  1438. }
  1439. else {
  1440. allNames[name] = 1;
  1441. }
  1442. return allNames;
  1443. }, {});
  1444. let objKey = Object.keys(countedNames)
  1445. let objVal = Object.values(countedNames)
  1446. var zeroStr = ''
  1447. objKey.map((item,index) => {
  1448. let objVal = Object.values(countedNames)
  1449. zeroStr += item + objVal[index] + '\n'
  1450. })
  1451. sevenStr = zeroStr
  1452. }
  1453. if(staffList[i].schedule_week == 1){
  1454. staffList[i].class_index = 1
  1455. var arr = []
  1456. this.arrOne.push(staffList[i].class_name)
  1457. for(let i=0;i<this.arrOne.length;i++){
  1458. if(this.arrOne[i]!=''){
  1459. arr.push(this.arrOne[i])
  1460. }
  1461. }
  1462. var countedNames = arr.reduce(function (allNames, name) {
  1463. if (name in allNames) {
  1464. allNames[name]++;
  1465. }
  1466. else {
  1467. allNames[name] = 1;
  1468. }
  1469. return allNames;
  1470. }, {});
  1471. let objKey = Object.keys(countedNames)
  1472. let objVal = Object.values(countedNames)
  1473. let strOne = ''
  1474. objKey.map((item,index) => {
  1475. let objVal = Object.values(countedNames)
  1476. strOne += item + objVal[index] + '\n'
  1477. })
  1478. oneStr = strOne
  1479. }
  1480. if(staffList[i].schedule_week == 2){
  1481. staffList[i].class_index = 2
  1482. var arr = []
  1483. this.arrTwo.push(staffList[i].class_name)
  1484. for(let i=0;i<this.arrTwo.length;i++){
  1485. if(this.arrTwo[i]!=''){
  1486. arr.push(this.arrTwo[i])
  1487. }
  1488. }
  1489. var countedNames = arr.reduce(function (allNames, name) {
  1490. if (name in allNames) {
  1491. allNames[name]++;
  1492. }
  1493. else {
  1494. allNames[name] = 1;
  1495. }
  1496. return allNames;
  1497. }, {});
  1498. let objKey = Object.keys(countedNames)
  1499. let objVal = Object.values(countedNames)
  1500. let strTwo = ''
  1501. objKey.map((item,index) => {
  1502. let objVal = Object.values(countedNames)
  1503. strTwo += item + objVal[index] + '\n'
  1504. })
  1505. twoStr = strTwo
  1506. }
  1507. if(staffList[i].schedule_week == 3){
  1508. staffList[i].class_index = 3
  1509. var arr = []
  1510. this.arrThree.push(staffList[i].class_name)
  1511. for(let i=0;i<this.arrThree.length;i++){
  1512. if(this.arrThree[i]!=''){
  1513. arr.push(this.arrThree[i])
  1514. }
  1515. }
  1516. var countedNames = arr.reduce(function (allNames, name) {
  1517. if (name in allNames) {
  1518. allNames[name]++;
  1519. }
  1520. else {
  1521. allNames[name] = 1;
  1522. }
  1523. return allNames;
  1524. }, {});
  1525. let objKey = Object.keys(countedNames)
  1526. let objVal = Object.values(countedNames)
  1527. let strThree = ''
  1528. objKey.map((item,index) => {
  1529. let objVal = Object.values(countedNames)
  1530. strThree += item + objVal[index] + '\n'
  1531. })
  1532. threeStr = strThree
  1533. }
  1534. if(staffList[i].schedule_week == 4){
  1535. staffList[i].class_index = 4
  1536. var arr = []
  1537. this.arrFour.push(staffList[i].class_name)
  1538. for(let i=0;i<this.arrFour.length;i++){
  1539. if(this.arrFour[i]!=''){
  1540. arr.push(this.arrFour[i])
  1541. }
  1542. }
  1543. var countedNames = arr.reduce(function (allNames, name) {
  1544. if (name in allNames) {
  1545. allNames[name]++;
  1546. }
  1547. else {
  1548. allNames[name] = 1;
  1549. }
  1550. return allNames;
  1551. }, {});
  1552. let objKey = Object.keys(countedNames)
  1553. let objVal = Object.values(countedNames)
  1554. let strFour = ''
  1555. objKey.map((item,index) => {
  1556. let objVal = Object.values(countedNames)
  1557. strFour += item + objVal[index] + '\n'
  1558. })
  1559. fourStr = strFour
  1560. }
  1561. if(staffList[i].schedule_week == 5){
  1562. staffList[i].class_index = 5
  1563. var arr = []
  1564. this.arrFive.push(staffList[i].class_name)
  1565. for(let i=0;i<this.arrFive.length;i++){
  1566. if(this.arrFive[i]!=''){
  1567. arr.push(this.arrFive[i])
  1568. }
  1569. }
  1570. var countedNames = arr.reduce(function (allNames, name) {
  1571. if (name in allNames) {
  1572. allNames[name]++;
  1573. }
  1574. else {
  1575. allNames[name] = 1;
  1576. }
  1577. return allNames;
  1578. }, {});
  1579. let objKey = Object.keys(countedNames)
  1580. let objVal = Object.values(countedNames)
  1581. let strFive = ''
  1582. objKey.map((item,index) => {
  1583. let objVal = Object.values(countedNames)
  1584. strFive += item + objVal[index] + '\n'
  1585. })
  1586. fiveStr = strFive
  1587. }
  1588. if(staffList[i].schedule_week == 6){
  1589. staffList[i].class_index = 6
  1590. var arr = []
  1591. this.arrSix.push(staffList[i].class_name)
  1592. for(let i=0;i<this.arrSix.length;i++){
  1593. if(this.arrSix[i]!=''){
  1594. arr.push(this.arrSix[i])
  1595. }
  1596. }
  1597. var countedNames = arr.reduce(function (allNames, name) {
  1598. if (name in allNames) {
  1599. allNames[name]++;
  1600. }
  1601. else {
  1602. allNames[name] = 1;
  1603. }
  1604. return allNames;
  1605. }, {});
  1606. let objKey = Object.keys(countedNames)
  1607. let objVal = Object.values(countedNames)
  1608. let strSix = ''
  1609. objKey.map((item,index) => {
  1610. let objVal = Object.values(countedNames)
  1611. strSix += item + objVal[index] + '\n'
  1612. })
  1613. sixStr = strSix
  1614. }
  1615. }
  1616. let tempArr = [], newArr = []
  1617. for (let i = 0; i < staffList.length; i++) {
  1618. if (tempArr.indexOf(staffList[i].user_name) === -1) {
  1619. newArr.push({
  1620. user_name: staffList[i].user_name,
  1621. admin_user_id:staffList[i].admin_user_id,
  1622. user_type:staffList[i].doctor_type,
  1623. is_sort:staffList[i].is_sort,
  1624. sort:staffList[i].sort,
  1625. list: [{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,class_attributes:staffList[i].class_attributes}]
  1626. })
  1627. tempArr.push(staffList[i].user_name);
  1628. } else {
  1629. for (let j = 0; j < newArr.length; j++) {
  1630. if (newArr[j].user_name == staffList[i].user_name) {
  1631. 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,class_attributes:staffList[i].class_attributes})
  1632. }
  1633. }
  1634. }
  1635. }
  1636. let arr = [...newArr]
  1637. let newNurse = []
  1638. let newDoctor = []
  1639. arr.map(item => {
  1640. if(item.user_type == 2){
  1641. newDoctor.push(item)
  1642. }
  1643. if(item.user_type == 3){
  1644. newNurse.push(item)
  1645. }
  1646. })
  1647. if(id == 0){
  1648. //护士
  1649. newNurse.sort(this.compare('admin_user_id'))
  1650. let newNurseTableData = []
  1651. this.nurseTableData.map(item => {
  1652. if(item.is_sort == 1){
  1653. newNurseTableData.push(item)
  1654. }
  1655. })
  1656. newNurseTableData.sort(this.compare('admin_user_id'))
  1657. newNurseTableData.map((item,index) => {
  1658. if (newNurse[index] && item.admin_user_id == newNurse[index].admin_user_id) {
  1659. }else{
  1660. newNurse.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  1661. }
  1662. })
  1663. newNurse.sort(this.compare('sort'))
  1664. //医生
  1665. newDoctor.sort(this.compare('admin_user_id'))
  1666. let newDoctorTableData = []
  1667. this.doctorTableData.map(item => {
  1668. if(item.is_sort == 1){
  1669. newDoctorTableData.push(item)
  1670. }
  1671. })
  1672. newDoctorTableData.sort(this.compare('admin_user_id'))
  1673. newDoctorTableData.map((item,index) => {
  1674. if (newDoctor[index] && item.admin_user_id == newDoctor[index].admin_user_id) {
  1675. }else{
  1676. newDoctor.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  1677. }
  1678. })
  1679. newDoctor.sort(this.compare('sort'))
  1680. // let data = []
  1681. // data.push(...newNurse)
  1682. // data.push(...newDoctor)
  1683. // this.tableData = data
  1684. let arr2 = []
  1685. arr2.push({class_name:oneStr,schedule_week:1})
  1686. arr2.push({class_name:twoStr,schedule_week:2})
  1687. arr2.push({class_name:threeStr,schedule_week:3})
  1688. arr2.push({class_name:fourStr,schedule_week:4})
  1689. arr2.push({class_name:fiveStr,schedule_week:5})
  1690. arr2.push({class_name:sixStr,schedule_week:6})
  1691. arr2.push({class_name:sevenStr,schedule_week:0})
  1692. var obj = {}
  1693. obj.admin_user_id = "1000000"
  1694. obj.user_name = "合计"
  1695. obj.user_type = 10
  1696. obj.list = arr2
  1697. arr.push(obj)
  1698. let data = []
  1699. data.push(...newNurse)
  1700. data.push(...newDoctor)
  1701. data.push(obj)
  1702. this.tableData = data
  1703. }
  1704. if(id == 2){
  1705. newDoctor.sort(this.compare('admin_user_id'))
  1706. let newDoctorTableData = []
  1707. this.doctorTableData.map(item => {
  1708. if(item.is_sort == 1){
  1709. newDoctorTableData.push(item)
  1710. }
  1711. })
  1712. newDoctorTableData.sort(this.compare('admin_user_id'))
  1713. newDoctorTableData.map((item,index) => {
  1714. if (newDoctor[index] && item.admin_user_id == newDoctor[index].admin_user_id) {
  1715. }else{
  1716. newDoctor.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  1717. }
  1718. })
  1719. newDoctor.sort(this.compare('sort'))
  1720. // this.tableData = newDoctor
  1721. let arr2 = []
  1722. arr2.push({class_name:oneStr,schedule_week:1})
  1723. arr2.push({class_name:twoStr,schedule_week:2})
  1724. arr2.push({class_name:threeStr,schedule_week:3})
  1725. arr2.push({class_name:fourStr,schedule_week:4})
  1726. arr2.push({class_name:fiveStr,schedule_week:5})
  1727. arr2.push({class_name:sixStr,schedule_week:6})
  1728. arr2.push({class_name:sevenStr,schedule_week:0})
  1729. var obj = {}
  1730. obj.admin_user_id = "1000000"
  1731. obj.user_name = "合计"
  1732. obj.user_type = 10
  1733. obj.list = arr2
  1734. arr.push(obj)
  1735. let data = []
  1736. data.push(...newDoctor)
  1737. data.push(obj)
  1738. this.tableData = data
  1739. }
  1740. if(id == 3){
  1741. newNurse.sort(this.compare('admin_user_id'))
  1742. let newNurseTableData = []
  1743. this.nurseTableData.map(item => {
  1744. if(item.is_sort == 1){
  1745. newNurseTableData.push(item)
  1746. }
  1747. })
  1748. newNurseTableData.sort(this.compare('admin_user_id'))
  1749. newNurseTableData.map((item,index) => {
  1750. if (newNurse[index] && item.admin_user_id == newNurse[index].admin_user_id) {
  1751. }else{
  1752. newNurse.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: [],user_type:item.user_type,is_sort:item.is_sort,sort:item.sort})
  1753. }
  1754. })
  1755. newNurse.sort(this.compare('sort'))
  1756. // this.tableData = newNurse
  1757. let arr2 = []
  1758. arr2.push({class_name:oneStr,schedule_week:1})
  1759. arr2.push({class_name:twoStr,schedule_week:2})
  1760. arr2.push({class_name:threeStr,schedule_week:3})
  1761. arr2.push({class_name:fourStr,schedule_week:4})
  1762. arr2.push({class_name:fiveStr,schedule_week:5})
  1763. arr2.push({class_name:sixStr,schedule_week:6})
  1764. arr2.push({class_name:sevenStr,schedule_week:0})
  1765. var obj = {}
  1766. obj.admin_user_id = "1000000"
  1767. obj.user_name = "合计"
  1768. obj.user_type = 10
  1769. obj.list = arr2
  1770. arr.push(obj)
  1771. let data = []
  1772. data.push(...newNurse)
  1773. data.push(obj)
  1774. this.tableData = data
  1775. console.log('cccccc',this.tableData);
  1776. }
  1777. }
  1778. })
  1779. },
  1780. toSearch(){
  1781. const params = {
  1782. user_name: this.keywords,
  1783. start_time:this.getTimestamp(this.weekDayArr[0]),
  1784. end_time:this.getTimestamp(this.weekDayArr[6])
  1785. }
  1786. toSearchScheduleList(params).then(response=>{
  1787. if(response.data.state == 1){
  1788. var staffList = response.data.data.staffList
  1789. // console.log("搜索",staffList)
  1790. let tempArr = [], newArr = []
  1791. for (let i = 0; i < staffList.length; i++) {
  1792. if (tempArr.indexOf(staffList[i].user_name) === -1) {
  1793. newArr.push({
  1794. user_name: staffList[i].user_name,
  1795. admin_user_id:staffList[i].admin_user_id,
  1796. list: [{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,class_attributes:staffList[i].class_attributes}]
  1797. })
  1798. tempArr.push(staffList[i].user_name);
  1799. } else {
  1800. for (let j = 0; j < newArr.length; j++) {
  1801. if (newArr[j].user_name == staffList[i].user_name) {
  1802. 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,class_attributes:staffList[i].class_attributes})
  1803. }
  1804. }
  1805. }
  1806. }
  1807. if(this.keywords != ''){
  1808. this.tableData = newArr
  1809. }else{
  1810. let arr = [...newArr]
  1811. arr.sort(this.compare('admin_user_id'))
  1812. this.doctorlist.sort(this.compare('admin_user_id'))
  1813. this.doctorlist.forEach((item, index) => {
  1814.   if (arr[index] && item.admin_user_id == arr[index].admin_user_id) {
  1815.   }else{
  1816.     arr.splice(index, 0, {user_name: item.user_name, admin_user_id: item.admin_user_id, list: []})
  1817.     // console.log("arr",arr)
  1818.   }
  1819. })
  1820. this.tableData = arr
  1821. }
  1822. }
  1823. })
  1824. },
  1825. DeleteStaffSchedule(){
  1826. const params = {
  1827. start_time:this.getTimestamp(this.weekDayArr[0]),
  1828. end_time:this.getTimestamp(this.weekDayArr[6])
  1829. }
  1830. this.$confirm(
  1831. '是否要清除当周排班? <br>清除后,信息将无法恢复',
  1832. '删除提示',
  1833. {
  1834. dangerouslyUseHTMLString: true,
  1835. confirmButtonText: '确定',
  1836. cancelButtonText: '取消',
  1837. type: 'warning'
  1838. }
  1839. ).then(()=>{
  1840. DeleteStaffSchedule(params).then(response=>{
  1841. if(response.data.state == 1){
  1842. var msg = response.data.data.msg
  1843. this.$message.success("清除成功")
  1844. this.getStaffScheduleList()
  1845. }
  1846. })
  1847. })
  1848. },
  1849. copyStaffSchedule(){
  1850. this.newVisible = true
  1851. // const params = {
  1852. // start_time:this.getTimestamp(this.weekDayArr[0]),
  1853. // end_time:this.getTimestamp(this.weekDayArr[6]),
  1854. // }
  1855. // copyStaffSchedule(params).then(response=>{
  1856. // if(response.data.state == 1){
  1857. // var msg = response.data.data.msg
  1858. // console.log("msg",msg)
  1859. // this.$message.success("复制成功")
  1860. // }else{
  1861. // this.$message.error("排班已存在")
  1862. // }
  1863. // })
  1864. },
  1865. toContinuous(){
  1866. var is_status = 0
  1867. if(this.isChecked == false){
  1868. is_status = 0
  1869. }
  1870. if(this.isChecked == true){
  1871. is_status = 1
  1872. }
  1873. const params = {
  1874. is_status:is_status
  1875. }
  1876. UpdateContinusSchedule(params).then(response=>{
  1877. if(response.data.state == 1){
  1878. var schedule = response.data.data.schedule
  1879. this.$message.success("保存成功")
  1880. }
  1881. })
  1882. },
  1883. setDate1 (date) {
  1884. var week = date.getDay() - 1
  1885. date = this.addDate(date, week * -1)
  1886. this.currentDate = new Date(date)
  1887. let arr1 = []
  1888. for (var i = 0; i < this.clen; i++) {
  1889. arr1.push(this.formatDate(i == 0 ? date : this.addDate(date, 1)))
  1890. }
  1891. this.weekList.push(arr1)
  1892. let num = this.weekNum
  1893. this.currentFirstDate1 = num + 1
  1894. },
  1895. submitAction(formName){
  1896. var label = ""
  1897. for(let i=0;i<this.timeOptions.length;i++){
  1898. if(this.form.copyWeek == this.timeOptions[i].value){
  1899. label = this.timeOptions[i].label
  1900. }
  1901. }
  1902. var start = label.split('~')
  1903. var copy_startime = this.getTimestamp(start[0])
  1904. var copy_endtime = this.getTimestamp(start[1])
  1905. const params = {
  1906. start_time:this.getTimestamp(this.weekDayArr[0]),
  1907. end_time:this.getTimestamp(this.weekDayArr[6]),
  1908. copy_startime:copy_startime,
  1909. copy_endtime:copy_endtime,
  1910. remark:this.remark,
  1911. }
  1912. this.$refs[formName].validate(valid=>{
  1913. if(valid){
  1914. if(!this.copySchLoading){
  1915. this.copySchLoading = true
  1916. copyStaffSchedule(params).then(response=>{
  1917. if(response.data.state == 1){
  1918. var msg = response.data.data.msg
  1919. this.copySchLoading = false
  1920. this.$message.success("复制成功")
  1921. this.newVisible = false
  1922. }else{
  1923. this.copySchLoading = false
  1924. this.$message.error("排班已存在")
  1925. }
  1926. })
  1927. }
  1928. }
  1929. })
  1930. },
  1931. compare(property){
  1932. return function(a,b){
  1933. var value1 = a[property];
  1934. var value2 = b[property];
  1935. return value2 - value1;
  1936. }
  1937. },
  1938. tableCellStyle (row, rowIndex, column) {
  1939. var week = (row.column.label).split('');
  1940. var weeks = 0
  1941. if (week.length == 13) {
  1942. weeks = week[4]+week[5]+week[6]+week[7]+week[8]+week[9]+week[10]+week[11]
  1943. }
  1944. if (week.length == 14) {
  1945. weeks = week[4]+week[5]+week[6]+week[7]+week[8]+week[9]+week[10]+week[11]+week[12]
  1946. }
  1947. var weekdate = this.getTimestamp(weeks)
  1948. if(weekdate < this.timeNow){
  1949. return 'background-color:#e5e5e5;'
  1950. }
  1951. },
  1952. setting(){
  1953. this.nurseVisible = true
  1954. },
  1955. _close: function(done) {
  1956. done();
  1957. },
  1958. changeSort(val){
  1959. console.log('val',val)
  1960. const params = {
  1961. sort:parseInt(val.sort),
  1962. id:val.id,
  1963. }
  1964. console.log("params",params)
  1965. SaveNurseSort(params).then(response=>{
  1966. if(response.data.state == 1){
  1967. var role = response.data.data.role
  1968. this.$message.success("保存成功")
  1969. this.getDoctorList()
  1970. }
  1971. })
  1972. },
  1973. changeRadio(val){
  1974. console.log("val",val)
  1975. const params = {
  1976. id:val.id,
  1977. is_sort:val.is_sort,
  1978. }
  1979. SaveIsSchedule(params).then(response=>{
  1980. if(response.data.state == 1){
  1981. var role = response.data.data.role
  1982. this.$message.success("保存成功")
  1983. this.getDoctorList()
  1984. }
  1985. })
  1986. },
  1987. toExport(){
  1988. this.exportDialogVisible = true
  1989. },
  1990. getTimestamp(time) { //把时间日期转成时间戳
  1991. return (new Date(time)).getTime() / 1000
  1992. },
  1993. exportList(){
  1994. import('@/vendor/Export2Excel').then(excel => {
  1995. for(let i=0;i<this.tableData.length;i++){
  1996. this.tableData[i].monday = this.getClass(this.tableData[i].user_name,1)
  1997. this.tableData[i].tuesday = this.getClass(this.tableData[i].user_name,2)
  1998. this.tableData[i].wednesday = this.getClass(this.tableData[i].user_name,3)
  1999. this.tableData[i].thursday = this.getClass(this.tableData[i].user_name,4)
  2000. this.tableData[i].friday = this.getClass(this.tableData[i].user_name,5)
  2001. this.tableData[i].saturday = this.getClass(this.tableData[i].user_name,6)
  2002. this.tableData[i].weekday = this.getClass(this.tableData[i].user_name,0)
  2003. }
  2004. console.log("this.table",this.tableData)
  2005. const tHeader = ['医护姓名', '周一'+"("+this.weekDayArr[0]+")" , '周二'+"("+this.weekDayArr[1]+")", '周三'+"("+this.weekDayArr[2]+")" , '周四'+"("+this.weekDayArr[3]+")" , '周五'+"("+this.weekDayArr[4]+")" , '周六'+"("+this.weekDayArr[5]+")",'周日'+"("+this.weekDayArr[6]+")"]
  2006. const filterVal = ['user_name', 'monday', 'tuesday','wednesday','thursday','friday','saturday','weekday']
  2007. const data = this.formatJson(filterVal,this.tableData)
  2008. console.log("data",data)
  2009. excel.export_json_to_excel({
  2010. header: tHeader,
  2011. data,
  2012. filename: '医护排班'
  2013. })
  2014. this.downloadLoading = false
  2015. })
  2016. },
  2017. formatJson(filterVal, jsonData) {
  2018. return jsonData.map(v => filterVal.map(j => v[j]))
  2019. },
  2020. toClick(id,index){
  2021. this.$confirm(
  2022. '是否要清除当前排班? <br>清除后,信息将无法恢复',
  2023. '删除提示',
  2024. {
  2025. dangerouslyUseHTMLString: true,
  2026. confirmButtonText: '确定',
  2027. cancelButtonText: '取消',
  2028. type: 'warning'
  2029. }
  2030. ).then(()=>{
  2031. console.log("rowwoowowow",id)
  2032. DeleteStaffScheduleById(id).then(response=>{
  2033. if(response.data.state == 1){
  2034. var msg = response.data.data.msg
  2035. this.$message.success("清除成功")
  2036. this.getStaffScheduleList()
  2037. }
  2038. })
  2039. })
  2040. },
  2041. hoverMouse(row,column, cell, event){
  2042. this.name=row.user_name
  2043. this.column_lie= column.label.split('\n')[0]
  2044. },
  2045. leavemouse(row, column, cell, event){
  2046. this.name=''
  2047. },
  2048. toDialog(row){
  2049. this.dialogVisible = true
  2050. this.staffObj = row
  2051. this.content = ""
  2052. this.content = row.remark
  2053. },
  2054. saveDialog(){
  2055. var data = {
  2056. admin_user_id:this.staffObj.admin_user_id,
  2057. start_time:this.getTimestamp(this.weekDayArr[0]),
  2058. end_time:this.getTimestamp(this.weekDayArr[6]),
  2059. content:this.content,
  2060. }
  2061. console.log("params",data)
  2062. saveStafScheduleRemark(data).then(response=>{
  2063. if(response.data.state == 1){
  2064. var msg = response.data.data.msg
  2065. this.getStaffScheduleList()
  2066. this.dialogVisible = false
  2067. }
  2068. })
  2069. },
  2070. changeStaffRmark(){
  2071. console.log("val000000000000000000",this.remark)
  2072. var params = {
  2073. content:this.remark,
  2074. start_time:this.getTimestamp(this.weekDayArr[0]),
  2075. end_time:this.getTimestamp(this.weekDayArr[6])
  2076. }
  2077. changeStaffRmark(params).then(response=>{
  2078. if(response.data.state == 1){
  2079. var msg = response.data.data.msg
  2080. this.getStaffScheduleRemarkList()
  2081. }
  2082. })
  2083. },
  2084. getStaffScheduleRemarkList(){
  2085. var params = {
  2086. start_time:this.getTimestamp(this.weekDayArr[0]),
  2087. end_time:this.getTimestamp(this.weekDayArr[6])
  2088. }
  2089. console.log("params=====",params)
  2090. getStaffScheduleRemarkList(params).then(response=>{
  2091. if(response.data.state==1){
  2092. var scheduleRemark = response.data.data.scheduleRemark
  2093. console.log("scheduleRemark",scheduleRemark)
  2094. this.remark = scheduleRemark.remark
  2095. console.log("haaaaaaaaaaaaaaaaaaa",this.remark)
  2096. }
  2097. })
  2098. }
  2099. },
  2100. created(){
  2101. //获取医护人员
  2102. this.getDoctorList()
  2103. //获取班种班种
  2104. this.getScheduleList()
  2105. let year = new Date().getFullYear()
  2106. let month = new Date().getMonth() + 1
  2107. let date = new Date().getDate()
  2108. this.weekNum = this.getYearWeek(year,month,date)
  2109. this.todayDate=this.formatDate(new Date())
  2110. this.setDate(new Date())
  2111. for (var i = 0; i <= 9; i++) {
  2112. this.setDate1(this.addDate(this.currentDate, 7))
  2113. }
  2114. let newNum = 0
  2115. for(let i = 0; i < this.weekList.length; i++){
  2116. if(this.weekNum + i + 1 <= 53){
  2117. let num = this.weekNum + i + 1
  2118. let str = this.weekList[i][0] + '~' + this.weekList[i][6] + '(' + num + ')'
  2119. this.typeOptions.push({value:i,label:str})
  2120. let stt = this.weekList[i][0] +"~"+this.weekList[i][6]
  2121. this.timeOptions.push({value:i,label:stt})
  2122. }else{
  2123. newNum++
  2124. let str = this.weekList[i][0] + '~' + this.weekList[i][6] + '(' + newNum + ')'
  2125. this.typeOptions.push({value:i,label:str})
  2126. let stt = this.weekList[i][0] +"~"+this.weekList[i][6]
  2127. this.timeOptions.push({value:i,label:stt})
  2128. }
  2129. }
  2130. // var now = moment().locale('zh-cn').format('YYYY-MM-DD 00:00:00')
  2131. var now = moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00')
  2132. console.log("日期==========---------------",now)
  2133. this.timeNow = this.getTimestamp(now)
  2134. console.log("haaaaaaaaaaaaaaaaaaa",this.timeNow)
  2135. this.getStaffScheduleRemarkList()
  2136. }
  2137. }
  2138. </script>
  2139. <style lang="scss" scoped>
  2140. .dateBox{
  2141. border: 1px solid #DCDFE6;
  2142. height: 36px;
  2143. line-height: 36px;
  2144. text-align: center;
  2145. padding: 0 10px;
  2146. border-radius: 4px;
  2147. }
  2148. .classBox{
  2149. width:28%;
  2150. height: 100%;
  2151. border: 1px solid #d0d3da;
  2152. .classTitle{
  2153. height: 42px;
  2154. text-align: center;
  2155. line-height: 42px;
  2156. background-color: rgb(245, 247, 250);
  2157. color: rgb(96, 98, 102);
  2158. font-weight:bold;
  2159. }
  2160. .classMain{
  2161. height: 400px;
  2162. padding: 0 0 0 20px;
  2163. display: flex;
  2164. justify-content: space-between;
  2165. flex-direction: column;
  2166. >div>p{
  2167. line-height: 30px;
  2168. color: rgb(48, 49, 51);
  2169. }
  2170. .classMainBox{
  2171. height: 350px;
  2172. overflow-y: auto;
  2173. }
  2174. }
  2175. }
  2176. </style>
  2177. <style lang="scss">
  2178. .schedulingTable{
  2179. .el-table .cell {
  2180. white-space: pre-line;/*保留换行符*/
  2181. }
  2182. }
  2183. .el-dropdown-menu{
  2184. max-height:96%;
  2185. overflow-y: auto;
  2186. }
  2187. .del_table_btns {
  2188. position: absolute;
  2189. right: 0px;
  2190. top: -3px;
  2191. // visibility: hidden;
  2192. .el-button {
  2193. width: 15px;
  2194. height: 15px;
  2195. padding: 0px;
  2196. }
  2197. }
  2198. </style>