week_Scheduling.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <view style="width: 100%;height: 100%;">
  3. <!--医院列表 -->
  4. <u-select v-model="hospitalListShow" :list="hospitalList" @confirm="setSelectHospital" :default-value="defaultList"></u-select>
  5. <!-- 顶部标题和按钮 -->
  6. <view class="flex justify-between align-center" style="margin: 40rpx 28rpx;">
  7. <view style="font-size: 50rpx;flex-grow: 2;">排班医院:</view>
  8. <view class="flex justify-around align-center" style="flex-grow: 3;">
  9. <view class="drop-down" @click="hospitalListShow=!hospitalListShow">
  10. <text>{{hospital}}</text>
  11. <u-icon name="arrow-down-fill" size="32" color="#848484" v-show="!hospitalListShow"></u-icon>
  12. <u-icon name="arrow-up-fill" size="32" color="#848484" v-show="hospitalListShow"></u-icon>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 温馨提示 -->
  17. <view style="margin: 10rpx 28rpx;">温馨提示:排班默认按周循环,特殊安排请在月视图调整</view>
  18. <!-- 周 -->
  19. <view class="flex justify-center align-center" style="height: 500rpx;width: 100%;" v-show="loading">
  20. <u-loading mode="circle" size="50"></u-loading>
  21. </view>
  22. <view v-for="item,index in weekList" class="week" :key="index" v-show="!loading">
  23. <view style="flex-grow: 1;text-align: center;border-right: 2rpx solid #808080;font-size: 36rpx;margin-right: 30rpx;">{{weekTitlelist[index].text}}</view>
  24. <view style="flex-grow: 2;">
  25. <view :class="item.mon == hospitalID ? 'monStyle' : item.mon == 0 ? 'nullStyle' :'otherStyle'" @click="modify(1,index)">上午</view>
  26. </view>
  27. <view style="flex-grow: 2;">
  28. <view :class="item.aft == hospitalID ? 'aftStyle' : item.aft == 0 ? 'nullStyle' :'otherStyle'" @click="modify(2,index)">下午</view>
  29. </view>
  30. <view style="flex-grow: 2;">
  31. <view :class="item.nig == hospitalID ? 'nigStyle' : item.nig == 0 ? 'nullStyle' :'otherStyle'" @click="modify(3,index)">晚上</view>
  32. </view>
  33. </view>
  34. <!-- 提交 -->
  35. <view class="flex justify-center" style="margin-top: 40rpx;" v-show="!loading">
  36. <u-button size="medium" shape="circle" @click="submit">确认提交</u-button>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. onLoad() {
  43. this.$nextTick(function() {
  44. this.getHostail()
  45. this.getWeek();
  46. })
  47. },
  48. data() {
  49. return {
  50. hospital: "", //现在选中的医院
  51. hospitalID: "1", //选中的医院ID
  52. hospitalListShow: false, //控制医院选择器
  53. // 医院列表
  54. hospitalList: [],
  55. weekTitlelist: [{
  56. text: '周一'
  57. }, {
  58. text: '周二'
  59. }, {
  60. text: '周三'
  61. }, {
  62. text: '周四'
  63. }, {
  64. text: '周五'
  65. }, {
  66. text: '周六'
  67. }, {
  68. text: '周日'
  69. }, ],
  70. weekList: [{
  71. mon: 0,
  72. aft: 0,
  73. nig: 0
  74. },
  75. {
  76. mon: 0,
  77. aft: 0,
  78. nig: 0
  79. },
  80. {
  81. mon: 0,
  82. aft: 0,
  83. nig: 0
  84. },
  85. {
  86. mon: 0,
  87. aft: 0,
  88. nig: 0
  89. },
  90. {
  91. mon: 0,
  92. aft: 0,
  93. nig: 0
  94. },
  95. {
  96. mon: 0,
  97. aft: 0,
  98. nig: 0
  99. },
  100. {
  101. mon: 0,
  102. aft: 0,
  103. nig: 0
  104. },
  105. ],
  106. //loading
  107. loading:false,
  108. defaultList:[0]
  109. }
  110. },
  111. methods: {
  112. getHostail: async function() {
  113. let res = await this.$request.post("doctor/organizationList");
  114. if (res.status == 0) {
  115. let data = res.data;
  116. let newList = [];
  117. if (data.length == 0) {
  118. uni.showModal({
  119. title: '请先认证医院'
  120. })
  121. } else {
  122. for (let i = 0; i < data.length; i++) {
  123. newList.push({
  124. value: data[i].value,
  125. label: data[i].label,
  126. extra:i
  127. })
  128. }
  129. }
  130. this.hospitalList = newList;
  131. this.hospital = this.hospitalList[0].label
  132. this.hospitalID = this.hospitalList[0].value + ""
  133. }
  134. },
  135. getWeek: async function() {
  136. let res = await this.$request.post("doctor/getLinsDetailnew");
  137. console.log('res', res);
  138. let weekList = this.weekTitlelist;
  139. if (res.status == 0) {
  140. let newList = [];
  141. let data = res.data.list;
  142. if (data.length == 0) {
  143. for (let y = 0; y < 7; y++) {
  144. newList.push({
  145. mon: 0,
  146. aft: 0,
  147. nig: 0
  148. })
  149. }
  150. } else {
  151. for (let y = 0; y < 7; y++) {
  152. for (let i = 0; i < data.length; i++) {
  153. if (weekList[y].text == data[i].week) {
  154. this.weekList[y].mon = data[i].ident.zao_id
  155. this.weekList[y].aft = data[i].ident.xia_id
  156. this.weekList[y].nig = data[i].ident.wan_id
  157. // mon:data[i].ident.zao_id,
  158. // aft:data[i].ident.xia_id,
  159. // nig:data[i].ident.wan_id,
  160. }
  161. }
  162. }
  163. }
  164. // this.weekList = newList;
  165. }
  166. },
  167. /**
  168. * 切换医院
  169. * */
  170. setSelectHospital(e) {
  171. let t = this
  172. t.hospitalID = e[0].value + ""
  173. this.loading = true
  174. setTimeout(function() {
  175. t.defaultList[0] = e[0].extra
  176. t.hospital = e[0].label
  177. t.loading = false
  178. }, 1000)
  179. console.log(e)
  180. },
  181. /**
  182. * 点击排班
  183. * */
  184. modifys(id, index) {
  185. switch (id) {
  186. case 1:
  187. if (this.weekList[index].mon == this.hospitalID) {
  188. this.weekList[index].mon = 0;
  189. } else if (this.weekList[index].mon == 0) {
  190. this.weekList[index].mon = this.hospitalID
  191. }
  192. break;
  193. case 2:
  194. if (this.weekList[index].aft == this.hospitalID) {
  195. this.weekList[index].aft = 0;
  196. } else if (this.weekList[index].aft == 0) {
  197. this.weekList[index].aft = this.hospitalID
  198. }
  199. break;
  200. case 3:
  201. if (this.weekList[index].nig == this.hospitalID) {
  202. this.weekList[index].nig = 0;
  203. } else if (this.weekList[index].nig == 0) {
  204. this.weekList[index].nig = this.hospitalID
  205. }
  206. break;
  207. }
  208. },
  209. modify(id, index) {
  210. this.$nextTick(function() {
  211. this.modifys(id, index)
  212. })
  213. this.$forceUpdate();
  214. // switch (id) {
  215. // case 1:
  216. // if (this.weekList[index].mon == this.hospitalID) {
  217. // this.weekList[index].mon = 0;
  218. // } else if (this.weekList[index].mon == 0) {
  219. // this.weekList[index].mon = this.hospitalID
  220. // }
  221. // break;
  222. // case 2:
  223. // if (this.weekList[index].aft == this.hospitalID) {
  224. // this.weekList[index].aft = 0;
  225. // } else if (this.weekList[index].aft == 0) {
  226. // this.weekList[index].aft = this.hospitalID
  227. // }
  228. // break;
  229. // case 3:
  230. // if (this.weekList[index].nig == this.hospitalID) {
  231. // this.weekList[index].nig = 0;
  232. // } else if (this.weekList[index].nig == 0) {
  233. // this.weekList[index].nig = this.hospitalID
  234. // }
  235. // break;
  236. // }
  237. },
  238. submit: async function() {
  239. let newData = [];
  240. let list = this.weekList;
  241. for (let i = 0; i < list.length; i++) {
  242. newData.push({
  243. week: i + 1,
  244. identifi: {
  245. zao: list[i].mon,
  246. zhong: list[i].aft,
  247. wan: list[i].nig,
  248. }
  249. })
  250. }
  251. console.log("newData", newData)
  252. if (typeof newData == 'object') {
  253. newData = JSON.stringify(newData);
  254. }
  255. let res = await this.$request.post("doctor/week_scheduling", {
  256. 'data': newData
  257. });
  258. console.log("res", res)
  259. if (res.status == 0) {
  260. uni.showToast({
  261. duration: 2000,
  262. title: '排班成功',
  263. success() {
  264. let pages = getCurrentPages();
  265. let prevPage = pages[pages.length - 2];
  266. prevPage.$vm.refresh = true;
  267. uni.navigateBack({
  268. delta: 1
  269. })
  270. }
  271. })
  272. } else {
  273. console.log(res.message)
  274. uni.showModal({
  275. duration: 2000,
  276. title: res.message,
  277. })
  278. }
  279. }
  280. }
  281. }
  282. </script>
  283. <style>
  284. /* 下拉按钮 */
  285. .drop-down {
  286. border: 1rpx solid #AAAAAA;
  287. font-size: 32rpx;
  288. flex-grow: 1;
  289. margin-right: 30rpx;
  290. border-radius: 15rpx;
  291. display: flex;
  292. justify-content: space-between;
  293. align-items: center;
  294. padding: 10rpx 15rpx;
  295. }
  296. /* 周 */
  297. .week {
  298. margin: 30rpx 28rpx;
  299. border-radius: 20rpx;
  300. box-shadow: 12rpx 12rpx 8rpx #c8c8c8;
  301. padding: 20rpx;
  302. background-color: #FFF;
  303. display: flex;
  304. align-items: center;
  305. }
  306. /* //空按钮样式 */
  307. .nullStyle {
  308. text-align: center;
  309. padding: 10rpx 0;
  310. border: 0.3rpx solid #909399;
  311. background-color: #FFF;
  312. border-radius: 30rpx;
  313. color: #000;
  314. font-weight: bold;
  315. margin: 20rpx 0 10rpx 0;
  316. width: 80%;
  317. }
  318. ,
  319. /* //上午按钮样式 */
  320. .monStyle {
  321. text-align: center;
  322. padding: 10rpx 0;
  323. background-color: #5667c8;
  324. border-radius: 30rpx;
  325. color: #fff;
  326. fontWeight: bold;
  327. margin: 20rpx 0 10rpx 0;
  328. width: 80%;
  329. }
  330. ,
  331. /* //下午按钮样式 */
  332. .aftStyle {
  333. text-align: center;
  334. padding: 10rpx 0;
  335. color: #FFF;
  336. border-radius: 30rpx;
  337. background-color: #ec9d75;
  338. color: #fff;
  339. font-weight: bold;
  340. margin: 20rpx 0 10rpx 0;
  341. width: 80%
  342. }
  343. ,
  344. /* //晚上按钮样式 */
  345. .nigStyle {
  346. text-align: center;
  347. padding: 10rpx 0;
  348. border: 0.3rpx solid #909399;
  349. background-color: #55aa7f;
  350. color: #fff;
  351. border-radius: 30rpx;
  352. font-weight: bold;
  353. margin: 20rpx 0 10rpx 0;
  354. width: 80%;
  355. }
  356. ,
  357. /* //其他医院按钮样式 */
  358. .otherStyle {
  359. text-align: center;
  360. padding: 10rpx 0;
  361. background-color: #989898;
  362. border-radius: 30rpx;
  363. color: #fff;
  364. font-weight: bold;
  365. margin: 20rpx 0 10rpx 0;
  366. width: 80%;
  367. }
  368. </style>