patient.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view v-for="(item,index) in patient" :key="index" class="peop-item">
  5. <view class="info">
  6. <view class="name">{{item.patientName}}</view>
  7. <view class="detail">
  8. <text class="text" v-if="item.gender==1">男</text>
  9. <text class="text" v-if="item.gender==2">女</text>
  10. <text class="text">{{utils.getAge(item.birthday)}}岁</text>
  11. <text class="text">{{utils.parseIdCard(item.idCard)}}</text>
  12. </view>
  13. </view>
  14. <view class="operat-box">
  15. <image src="../../static/images/del1.png" mode="" @click="delPatient(item)" ></image>
  16. <image src="../../static/images/edit.png" mode="" @click="editPatient(item)"></image>
  17. </view>
  18. </view>
  19. <view v-if="patient.length == 0" class="no-data-box" @click="getPatientList()">
  20. <image src="../../static/images/no_data.png" mode="aspectFit"></image>
  21. <view class="empty-title">暂无数据</view>
  22. </view>
  23. </view>
  24. <view class="btn-box">
  25. <view class="sub-btn" @click="addPatient">创建用药人</view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import {getPatientList,delPatient} from '@/api/patient'
  31. export default {
  32. data() {
  33. return {
  34. patient:[],
  35. }
  36. },
  37. onLoad() {
  38. this.getPatientList()
  39. uni.$on('refreshPatient', () => {
  40. this.getPatientList()
  41. })
  42. },
  43. methods: {
  44. editPatient(item){
  45. uni.navigateTo({
  46. url: './addPatient?type=edit&patientId='+item.patientId
  47. })
  48. },
  49. delPatient(item){
  50. uni.showModal({
  51. title:"提示",
  52. content:"确认删除吗?",
  53. showCancel:true,
  54. cancelText:'取消',
  55. confirmText:'确定',
  56. success:res=>{
  57. if(res.confirm){
  58. // 用户点击确定
  59. var data={patientId:item.patientId}
  60. delPatient(data).then(
  61. res => {
  62. if(res.code==200){
  63. uni.showToast({
  64. icon:'success',
  65. title: "操作成功",
  66. });
  67. this.getPatientList()
  68. }else{
  69. uni.showToast({
  70. icon:'none',
  71. title: "请求失败",
  72. });
  73. }
  74. },
  75. rej => {}
  76. );
  77. }else{
  78. // 否则点击了取消
  79. }
  80. }
  81. })
  82. },
  83. getPatientList(){
  84. uni.showLoading({
  85. title:"正在加载中"
  86. })
  87. getPatientList().then(
  88. res => {
  89. uni.hideLoading()
  90. if(res.code==200){
  91. this.patient=res.data;
  92. }else{
  93. uni.showToast({
  94. icon:'none',
  95. title: "请求失败",
  96. });
  97. }
  98. },
  99. rej => {}
  100. );
  101. },
  102. addPatient() {
  103. uni.navigateTo({
  104. url: './addPatient?type=add'
  105. })
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. page{
  112. height: 100%;
  113. }
  114. .content{
  115. height: 100%;
  116. display: flex;
  117. flex-direction: column;
  118. justify-content: space-between;
  119. .inner{
  120. flex: 1;
  121. padding: 20upx 20upx 160upx;
  122. .peop-item{
  123. box-sizing: border-box;
  124. height: 184upx;
  125. background: #FFFFFF;
  126. border-radius: 16upx;
  127. padding: 50upx 40upx 50upx 30upx;
  128. display: flex;
  129. align-items: center;
  130. justify-content: space-between;
  131. margin-bottom: 20upx;
  132. .info{
  133. .name{
  134. font-size: 30upx;
  135. font-family: PingFang SC;
  136. font-weight: bold;
  137. color: #111111;
  138. line-height: 1;
  139. }
  140. .detail{
  141. display: flex;
  142. align-items: center;
  143. margin-top: 30upx;
  144. .text{
  145. font-size: 26upx;
  146. font-family: PingFang SC;
  147. font-weight: 500;
  148. color: #999999;
  149. line-height: 1;
  150. margin-right: 30upx;
  151. &:last-child{
  152. margin-right: 0;
  153. }
  154. }
  155. }
  156. }
  157. .operat-box{
  158. display: flex;
  159. align-items: center;
  160. image{
  161. width: 30upx;
  162. height: 30upx;
  163. margin-left: 38upx;
  164. &:first-child{
  165. margin-left: 0;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. .btn-box{
  172. z-index: 9999;
  173. width: 100%;
  174. padding: 30upx;
  175. position: fixed;
  176. bottom: 0;
  177. left: 0;
  178. box-sizing: border-box;
  179. background: #FFFFFF;
  180. .sub-btn{
  181. width: 100%;
  182. height: 88upx;
  183. line-height: 88upx;
  184. text-align: center;
  185. font-size: 30upx;
  186. font-family: PingFang SC;
  187. font-weight: bold;
  188. color: #FFFFFF;
  189. background: #2BC7B9;
  190. border-radius: 44upx;
  191. }
  192. }
  193. }
  194. </style>