patient.vue 4.6 KB

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