Bed.vue 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div class="Bed">
  3. <van-list
  4. v-model="loading"
  5. @load="onLoad"
  6. :finished="finished"
  7. finished-text="没有更多了"
  8. :immediate-check='show'
  9. >
  10. <div class="BedOne" v-for="(item,index) in BedNumber" :key="index">
  11. <div class="BedLeft">
  12. <p>床位号:{{item.number}}</p>
  13. <p>分区类型:{{getZone(item.zone_id)}}</p>
  14. <p>所属分组:{{getGroup(item.group_id)}}</p>
  15. </div>
  16. <van-icon class="ellipsis" name="ellipsis" @click="Delete(item.id,index)" />
  17. </div>
  18. </van-list>
  19. <div class="add">
  20. <div style="display: flex;align-items: center;">
  21. <van-icon class="addIcon" name="add" @click="addBed" />新增
  22. </div>
  23. </div>
  24. <van-action-sheet
  25. v-model="newShow"
  26. :actions="actions"
  27. cancel-text="取消"
  28. @cancel="onCancel"
  29. @select="toDeleteBed"
  30. />
  31. </div>
  32. </template>
  33. <script>
  34. import { GetAllNumber, DeleteBed } from "@/api/patient/patient";
  35. import { Dialog } from "vant";
  36. export default {
  37. props: {
  38. active: Number
  39. },
  40. data() {
  41. return {
  42. loading: false,
  43. finished: false,
  44. newShow: false,
  45. show: false,
  46. actions: [{ name: "编辑" }, { name: "删除" }],
  47. page: 1,
  48. limit: 10,
  49. total: 0,
  50. BedNumber: [],
  51. Zone: [],
  52. Group: [],
  53. id: 0,
  54. index: 0
  55. };
  56. },
  57. methods: {
  58. onCancel() {},
  59. addBed() {
  60. this.$router.push("/addbed?active=" + this.active);
  61. },
  62. GetAllNumber() {
  63. GetAllNumber(this.page, this.limit).then(response => {
  64. if (response.data.state === 1) {
  65. var number = response.data.data.number;
  66. console.log("number", number);
  67. let arr = this.BedNumber;
  68. arr.push(...number);
  69. this.BedNumber = arr;
  70. var total = response.data.data.total;
  71. console.log("total", total);
  72. this.total = total;
  73. var zone = response.data.data.zone;
  74. this.Zone = zone;
  75. var group = response.data.data.group;
  76. this.Group = group;
  77. this.loading = false;
  78. }
  79. });
  80. },
  81. onLoad() {
  82. setTimeout(() => {
  83. this.page++;
  84. if (this.page <= Math.ceil(this.total / 10)) {
  85. this.GetAllNumber(this.page, this.limit);
  86. } else {
  87. this.loading = false;
  88. this.finished = true;
  89. }
  90. }, 1000);
  91. },
  92. getZone(id) {
  93. for (let i = 0; i < this.Zone.length; i++) {
  94. if (id === this.Zone[i].id) {
  95. return this.Zone[i].name;
  96. }
  97. }
  98. },
  99. getGroup(id) {
  100. for (let i = 0; i < this.Group.length; i++) {
  101. if (id === this.Group[i].id) {
  102. return this.Group[i].name;
  103. }
  104. }
  105. },
  106. Delete(id, index) {
  107. this.newShow = true;
  108. this.id = id;
  109. this.index = index;
  110. },
  111. toDeleteBed(val) {
  112. if (val.name === "删除") {
  113. this.DeleteBed(this.id, this.index);
  114. }
  115. if (val.name === "编辑") {
  116. this.$router.push("/editbed?id=" + this.id + "&active=" + this.active);
  117. }
  118. },
  119. onCancel() {
  120. this.newShow = false;
  121. },
  122. DeleteBed(id, index) {
  123. Dialog.confirm({
  124. title: "删除提示!",
  125. message: "确认删除该条信息吗?,删除后将无法恢复!"
  126. }).then(() => {
  127. DeleteBed(id).then(response => {
  128. if (response.data.state === 1) {
  129. var msg = response.data.data.msg;
  130. console.log("msg", msg);
  131. this.BedNumber.splice(index, 1);
  132. this.newShow = false;
  133. } else {
  134. this.$toast("该床位尚有排班安排,不能删除");
  135. this.newShow = false;
  136. }
  137. });
  138. });
  139. }
  140. },
  141. created() {
  142. console.log("active", this.active);
  143. this.GetAllNumber();
  144. }
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .Bed {
  149. margin-bottom: 3.125rem;
  150. .BedOne {
  151. padding: 1.375rem 1.125rem 0 1.5rem;
  152. display: flex;
  153. justify-content: space-between;
  154. box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
  155. p {
  156. font-size: 0.9375rem;
  157. margin-bottom: 1.125rem;
  158. }
  159. .ellipsis {
  160. font-size: 1.5rem;
  161. color: #cccccc;
  162. }
  163. }
  164. .add {
  165. position: fixed;
  166. bottom: 0;
  167. left: 0;
  168. width: 100%;
  169. height: 2.75rem;
  170. background: rgba(255, 255, 255, 1);
  171. box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.1);
  172. display: flex;
  173. align-items: center;
  174. justify-content: space-around;
  175. font-size: 0.9375rem;
  176. color: #979798;
  177. .addIcon {
  178. color: #5b98ff;
  179. font-size: 1.25rem;
  180. margin-right: 0.25rem;
  181. }
  182. }
  183. }
  184. </style>