patient.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view class="container">
  3. <view class="address-list">
  4. <view class="address-item" v-for="item,index in patientList" :key="index" @click="selectAddress(item)">
  5. <span class="name">{{item.name}},{{item.mobile}}</span>
  6. <view class="func-box">
  7. <span class="default" v-if="item.defaulted">默认</span>
  8. <u-radio-group v-else @change="changeDefault(item)">
  9. <u-radio :name="item.defaulted" shape="circle" label="设置默认" iconSize="14"
  10. labelSize="12"></u-radio>
  11. </u-radio-group>
  12. <view class="btn-box">
  13. <span class="btn-s" @click.stop="editAddress(item)"><u-icon name="edit-pen" size="22" color="#4B91D1"></u-icon></span>
  14. <span class="btn-s" @click.stop="delAddress(item)"><u-icon name="trash" size="22" color="#FF0000"></u-icon></span>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="empty-box" v-if="!patientList.length">
  20. <u-image src="/static/none.png" mode="aspectFill" width="582rpx" height="582rpx"></u-image>
  21. <span class="empty-txt">暂无数据!</span>
  22. </view>
  23. <!-- 底部按钮 -->
  24. <view class="footer-box">
  25. <view class="btn-box">
  26. <view class="submit-btn" @click="addAddress()">添加就诊人</view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. getPatientList,
  34. delPatient,
  35. setDefaultPatient
  36. } from "@/api/user.js"
  37. export default {
  38. data() {
  39. return {
  40. patientList: [],
  41. type: '',
  42. }
  43. },
  44. onLoad(option) {
  45. if (option.type) {
  46. this.type = option.type
  47. }
  48. },
  49. onShow() {
  50. this.getList()
  51. },
  52. methods: {
  53. changeDefault(row) {
  54. console.log('row', row);
  55. let that = this;
  56. uni.showLoading({
  57. title: '切换中',
  58. mask: true,
  59. });
  60. setDefaultPatient(row.id).then(res => {
  61. if (res.code == 200) {
  62. uni.$u.toast('切换成功');
  63. this.patientList = []
  64. this.getList()
  65. }
  66. })
  67. .catch((err) => {
  68. console.log(err);
  69. this.patientList = []
  70. this.getList()
  71. })
  72. .finally(() => {
  73. uni.hideLoading();
  74. });
  75. },
  76. getList() {
  77. let that = this;
  78. uni.showLoading({
  79. title: '加载中',
  80. mask: true,
  81. });
  82. getPatientList().then(res => {
  83. let data = res.data;
  84. if (data) {
  85. this.patientList = data;
  86. }
  87. })
  88. .catch((err) => {
  89. console.log(err);
  90. })
  91. .finally(() => {
  92. uni.hideLoading();
  93. });
  94. },
  95. selectAddress(item) {
  96. let type = uni.getStorageSync('patientType')
  97. if (type && type == 'order') {
  98. uni.$emit('returnPatient', item);
  99. uni.navigateBack({
  100. delta: 1,
  101. });
  102. }
  103. },
  104. editAddress(item) {
  105. uni.navigateTo({
  106. url: `/pages/mine/patient/form?id=${item.id}&type=edit`
  107. })
  108. },
  109. delAddress(item) {
  110. uni.showModal({
  111. title: '提示',
  112. content: '是否删除该信息',
  113. success: (res) => {
  114. let that = this;
  115. if (res.confirm) {
  116. delPatient(item.id).then(res => {
  117. if (res.code == 200) {
  118. uni.$u.toast('删除成功');
  119. this.getList()
  120. }
  121. })
  122. .catch((err) => {
  123. console.log(err);
  124. })
  125. } else if (res.cancel) {
  126. console.log('用户点击取消');
  127. }
  128. },
  129. });
  130. },
  131. addAddress() {
  132. uni.navigateTo({
  133. url: `/pages/mine/patient/form?type=add`
  134. })
  135. },
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .container {
  141. padding: 20rpx 20rpx 200rpx;
  142. .address-list {
  143. display: flex;
  144. flex-direction: column;
  145. .address-item {
  146. display: flex;
  147. flex-direction: column;
  148. background-color: #fff;
  149. padding: 30rpx;
  150. margin-bottom: 20rpx;
  151. border-radius: 15rpx;
  152. .name {
  153. font-size: 32rpx;
  154. font-weight: 700;
  155. color: #1A1A1A;
  156. margin-bottom: 20rpx;
  157. }
  158. .address {
  159. font-size: 24rpx;
  160. }
  161. .func-box {
  162. display: flex;
  163. align-items: center;
  164. justify-content: space-between;
  165. .default {
  166. padding: 10rpx 30rpx;
  167. background-color: #F0F1F5;
  168. border-radius: 15rpx;
  169. font-size: 28rpx;
  170. color: #302F33;
  171. }
  172. .btn-box {
  173. display: flex;
  174. align-items: center;
  175. .btn-s {
  176. padding: 20rpx 10rpx;
  177. }
  178. }
  179. // ::v-deep .u-icon {
  180. // font-size: 34rpx;
  181. // margin-left: 20rpx;
  182. // }
  183. }
  184. }
  185. }
  186. .footer-box {
  187. position: fixed;
  188. bottom: 0;
  189. left: 0;
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. width: 100%;
  194. padding: 50rpx 30rpx 50rpx;
  195. box-sizing: border-box;
  196. font-size: 28rpx;
  197. background-color: #fff;
  198. box-shadow: 0 -2rpx 30rpx #c5c5c53a;
  199. .btn-box {
  200. width: 100%;
  201. .submit-btn {
  202. display: block;
  203. width: 100%;
  204. height: 80rpx;
  205. line-height: 80rpx;
  206. text-align: center;
  207. color: #fff;
  208. background-color: #026EB7;
  209. border-radius: 50rpx;
  210. }
  211. }
  212. }
  213. }
  214. </style>