addPatient.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="form-box">
  5. <view class="form-item">
  6. <text class="label">姓名</text>
  7. <input class="input-width" type="text" v-model="form.patientName" placeholder="请如实填写您的真实姓名" placeholder-class="form-input" />
  8. </view>
  9. <view class="form-item">
  10. <text class="label">性别</text>
  11. <radio-group style="display: flex;align-items: center;">
  12. <label style="margin-right: 50upx;">
  13. <radio @click="genderChange(1)" value="1" :checked="form.gender===1" style="margin-right: 16upx;" />
  14. <text class="sex-text">男</text>
  15. </label>
  16. <label>
  17. <radio @click="genderChange(2)" value="2" :checked="form.gender===2" style="margin-right: 16upx;" />
  18. <text class="sex-text">女</text>
  19. </label>
  20. </radio-group>
  21. </view>
  22. <view class="form-item">
  23. <text class="label">身份证号</text>
  24. <input class="input-width" type="idcard" v-model="form.idCard" placeholder="请如实填写身份证号" placeholder-class="form-input" />
  25. </view>
  26. <view class="form-item">
  27. <text class="label">出生年月</text>
  28. <picker class="birth-picker" mode="date" @change="bindDateChange">
  29. <view class="right-box">
  30. <view class="input-box">
  31. <input type="text" :value="form.birthday" placeholder="请选择出生年月" placeholder-class="form-input" disabled="disabled" />
  32. </view>
  33. <image class="arrow" src="../../static/images/arrow_gray.png" mode=""></image>
  34. </view>
  35. </picker>
  36. </view>
  37. <!-- <view class="form-item">
  38. <text class="label">联系电话</text>
  39. <input type="number" value="" placeholder="请输入联系电话" placeholder-class="form-input" />
  40. </view> -->
  41. </view>
  42. </view>
  43. <view class="btn-box">
  44. <view class="sub-btn" @click="submit()">保存就诊人</view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {getPatientById,addPatient,editPatient} from '@/api/patient'
  50. export default {
  51. data() {
  52. return {
  53. type:null,
  54. patientId:null,
  55. form: {
  56. gender: 1,
  57. birthday: ''
  58. }
  59. };
  60. },
  61. onLoad(option) {
  62. this.type=option.type;
  63. console.log(this.type)
  64. if(this.type=='edit'){
  65. this.patientId=option.patientId;
  66. this.getPatientById();
  67. }
  68. },
  69. methods:{
  70. genderChange(type){
  71. this.form.gender=type
  72. },
  73. getPatientById(){
  74. var data={patientId:this.patientId};
  75. getPatientById(data).then(
  76. res => {
  77. if(res.code==200){
  78. this.form=res.data;
  79. }else{
  80. uni.showToast({
  81. title: res.msg,
  82. });
  83. }
  84. },
  85. rej => {}
  86. );
  87. },
  88. submit(){
  89. if(this.type=="add"){
  90. this.addPatient()
  91. }
  92. else if(this.type=="edit"){
  93. this.editPatient()
  94. }
  95. },
  96. editPatient(){
  97. editPatient(this.form).then(
  98. res => {
  99. if(res.code==200){
  100. uni.showToast({
  101. icon:'success',
  102. title: "操作成功",
  103. });
  104. setTimeout(function() {
  105. uni.$emit('refreshPatient');
  106. uni.navigateBack({
  107. delta: 1
  108. })
  109. }, 500);
  110. }else{
  111. uni.showToast({
  112. title: res.msg,
  113. });
  114. }
  115. },
  116. rej => {}
  117. );
  118. },
  119. addPatient(){
  120. addPatient(this.form).then(
  121. res => {
  122. if(res.code==200){
  123. uni.showToast({
  124. icon:'success',
  125. title: "操作成功",
  126. });
  127. setTimeout(function() {
  128. uni.$emit('refreshPatient');
  129. uni.navigateBack({
  130. delta: 1
  131. })
  132. }, 500);
  133. }else{
  134. uni.showToast({
  135. title: res.msg,
  136. });
  137. }
  138. },
  139. rej => {}
  140. );
  141. },
  142. // 出生日期选择
  143. bindDateChange: function(e) {
  144. this.form.birthday = e.target.value
  145. },
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. page{
  151. height: 100%;
  152. }
  153. .content{
  154. height: 100%;
  155. display: flex;
  156. flex-direction: column;
  157. justify-content: space-between;
  158. .inner{
  159. height: calc(100% - 120upx);
  160. padding: 20upx;
  161. .form-box{
  162. padding: 20upx 30upx;
  163. background: #FFFFFF;
  164. border-radius: 16upx;
  165. .form-item{
  166. height: 103upx;
  167. display: flex;
  168. align-items: center;
  169. justify-content: space-between;
  170. border-bottom: 1px solid #F1F1F1;
  171. &:last-child{
  172. border-bottom: none;
  173. }
  174. .label{
  175. font-size: 30upx;
  176. font-family: PingFang SC;
  177. font-weight: 500;
  178. color: #222222;
  179. }
  180. .input-width{
  181. width: calc(100% - 150upx);
  182. text-align: right;
  183. }
  184. .form-input{
  185. font-size: 30upx;
  186. font-family: PingFang SC;
  187. font-weight: 500;
  188. color: #999999;
  189. text-align: right;
  190. }
  191. .sex-text{
  192. font-size: 30upx;
  193. font-family: PingFang SC;
  194. font-weight: 500;
  195. color: #111111;
  196. line-height: 30upx;
  197. }
  198. .birth-picker {
  199. display: flex;
  200. align-items: center;
  201. .right-box{
  202. display: flex;
  203. align-items: center;
  204. .input-box{
  205. width: 400upx;
  206. display: flex;
  207. align-items: center;
  208. justify-content: flex-end;
  209. input{
  210. text-align: right;
  211. }
  212. }
  213. .arrow{
  214. width: 13upx;
  215. height: 23upx;
  216. margin-left: 20upx;
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223. .btn-box{
  224. height: 120upx;
  225. padding: 0 30upx;
  226. display: flex;
  227. align-items: center;
  228. justify-content: center;
  229. background: #FFFFFF;
  230. .sub-btn{
  231. width: 100%;
  232. height: 88upx;
  233. line-height: 88upx;
  234. text-align: center;
  235. font-size: 30upx;
  236. font-family: PingFang SC;
  237. font-weight: bold;
  238. color: #FFFFFF;
  239. background: #2BC7B9;
  240. border-radius: 44upx;
  241. }
  242. }
  243. }
  244. </style>