addEditPatient.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <u-alert title="国家卫健委要求,就医行为必须实名登记" type = "info" ></u-alert>
  5. <view class="form-box">
  6. <view class="form-item">
  7. <text class="label">姓名</text>
  8. <input class="input-width" type="text" v-model="form.patientName" placeholder="请输入真实姓名" placeholder-class="form-input" />
  9. </view>
  10. <view class="form-item">
  11. <text class="label">性别</text>
  12. <radio-group style="display: flex;align-items: center;">
  13. <label style="margin-right:30rpx;">
  14. <radio @click="genderChange(1)" color="#C39A58" value="1" :checked="form.sex===1" style="margin-right: 16upx;" />
  15. <text class="option-text">男</text>
  16. </label>
  17. <label>
  18. <radio @click="genderChange(2)" color="#C39A58" value="2" :checked="form.sex===2" style="margin-right: 16upx;" />
  19. <text class="option-text">女</text>
  20. </label>
  21. </radio-group>
  22. </view>
  23. <view class="form-item">
  24. <text class="label">联系方式</text>
  25. <input class="input-width" type="phone" v-model="form.mobile" placeholder="请输入联系方式" placeholder-class="form-input" />
  26. </view>
  27. <view class="form-item">
  28. <text class="label">身份证号</text>
  29. <input class="input-width" type="idcard" @blur="idcardChange()" v-model="form.idCard" placeholder="请输入身份证号" placeholder-class="form-input" />
  30. </view>
  31. <view class="form-item">
  32. <text class="label">出生年月</text>
  33. <picker :value="form.birthday" start="1900-01-01" class="birth-picker" mode="date" @change="birthdayChange">
  34. <view class="right-box">
  35. <view class="input-box">
  36. <input type="text" :value="form.birthday" placeholder="请选择出生年月" placeholder-class="form-input" disabled="disabled" />
  37. </view>
  38. <image class="arrow" src="../../static/images/arrow_gray.png" mode=""></image>
  39. </view>
  40. </picker>
  41. </view>
  42. </view>
  43. <view class="form-box">
  44. <view class="form-item" @click="relationShow=true">
  45. <text class="label">与本人关系</text>
  46. <view class="right-box">
  47. <view class="input-box">
  48. <input type="text" :value="form.relation" placeholder="请选择" placeholder-class="form-input" disabled="disabled" />
  49. </view>
  50. <image class="arrow" src="../../static/images/arrow_gray.png" mode=""></image>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="form-box">
  55. <view class="form-item">
  56. <text class="label">肝功能</text>
  57. <radio-group @change="liverUnusualChange" style="display: flex;align-items: center;">
  58. <label style="margin-right:30rpx;">
  59. <radio color="#C39A58" value="正常" :checked="form.liverUnusual==='正常'" style="margin-right: 16upx;" />
  60. <text class="option-text">正常</text>
  61. </label>
  62. <label>
  63. <radio color="#C39A58" value="异常" :checked="form.liverUnusual==='异常'" style="margin-right: 16upx;" />
  64. <text class="option-text">异常</text>
  65. </label>
  66. </radio-group>
  67. </view>
  68. <view class="form-item">
  69. <text class="label">肾功能</text>
  70. <radio-group @change="renalUnusualChange" style="display: flex;align-items: center;">
  71. <label style="margin-right:30rpx;">
  72. <radio color="#C39A58" value="正常" :checked="form.renalUnusual==='正常'" style="margin-right: 16upx;" />
  73. <text class="option-text">正常</text>
  74. </label>
  75. <label>
  76. <radio color="#C39A58" value="异常" :checked="form.renalUnusual==='异常'" style="margin-right: 16upx;" />
  77. <text class="option-text">异常</text>
  78. </label>
  79. </radio-group>
  80. </view>
  81. <view class="form-item">
  82. <text class="label">过敏史</text>
  83. <radio-group @change="historyAllergicChange" style="display: flex;align-items: center;justify-content: flex-end;margin: 5rpx 0rpx;">
  84. <label style="margin-right:30rpx;">
  85. <radio color="#C39A58" value="无" :checked="form.historyAllergic==='无'" style="margin-right: 16upx;" />
  86. <text class="option-text">无</text>
  87. </label>
  88. <label>
  89. <radio color="#C39A58" value="有" :checked="form.historyAllergic==='有'" style="margin-right: 16upx;" />
  90. <text class="option-text">有</text>
  91. </label>
  92. </radio-group>
  93. </view>
  94. <view class="form-item" v-if="form.historyAllergic=='有'" >
  95. <view class="option-box" style="margin: 5rpx 0rpx;" >
  96. <view class="option" v-for="(item,index) in historyAllergics" >
  97. <u-tag @click="historyAllergicOptionChange(item)" :borderColor="item.checked==1?'#ffffff':'#C39A58'" :bgColor="item.checked==1?'#C39A58':'#ffffff'" :color="item.checked==1?'#ffffff':'#C39A58'" shape="circle" :text="item.name"></u-tag>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="form-item">
  102. <text class="label">个人病史</text>
  103. <radio-group @change="selfMedHistoryChange" style="display: flex;align-items: center;">
  104. <label style="margin-right:30rpx;">
  105. <radio color="#C39A58" value="无" :checked="form.selfMedHistory==='无'" style="margin-right: 16upx;" />
  106. <text class="option-text">无</text>
  107. </label>
  108. <label>
  109. <radio color="#C39A58" value="有" :checked="form.selfMedHistory==='有'" style="margin-right: 16upx;" />
  110. <text class="option-text">有</text>
  111. </label>
  112. </radio-group>
  113. </view>
  114. <view class="form-item" v-if="form.selfMedHistory=='有'" >
  115. <view class="option-box" style="margin: 5rpx 0rpx;" >
  116. <view class="option" v-for="(item,index) in selfMedHistorys" >
  117. <u-tag @click="selfMedHistoryOptionChange(item)" :borderColor="item.checked==1?'#ffffff':'#C39A58'" :bgColor="item.checked==1?'#C39A58':'#ffffff'" :color="item.checked==1?'#ffffff':'#C39A58'" shape="circle" :text="item.name"></u-tag>
  118. </view>
  119. </view>
  120. </view>
  121. <view class="form-item">
  122. <text class="label">家庭病史</text>
  123. <radio-group @change="familyMedHistoryChange" style="display: flex;align-items: center;">
  124. <label style="margin-right:30rpx;">
  125. <radio color="#C39A58" value="无" :checked="form.familyMedHistory==='无'" style="margin-right: 16upx;" />
  126. <text class="option-text">无</text>
  127. </label>
  128. <label>
  129. <radio color="#C39A58" value="有" :checked="form.familyMedHistory==='有'" style="margin-right: 16upx;" />
  130. <text class="option-text">有</text>
  131. </label>
  132. </radio-group>
  133. </view>
  134. <view class="form-item" v-if="form.familyMedHistory=='有'" >
  135. <view class="option-box" style="margin: 5rpx 0rpx;" >
  136. <view class="option" v-for="(item,index) in familyMedHistorys" >
  137. <u-tag @click="familyMedHistoryOptionChange(item)" :borderColor="item.checked==1?'#ffffff':'#C39A58'" :bgColor="item.checked==1?'#C39A58':'#ffffff'" :color="item.checked==1?'#ffffff':'#C39A58'" shape="circle" :text="item.name"></u-tag>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. <view class="btn-box">
  144. <view class="sub-btn" @click="submit()">保存就诊人</view>
  145. </view>
  146. <u-action-sheet
  147. :show="relationShow"
  148. :actions="relations"
  149. title="请选择"
  150. @close="relationShow = false"
  151. @select="relationSelect"
  152. >
  153. </u-action-sheet>
  154. </view>
  155. </template>
  156. <script>
  157. import {getPatientById,addPatient,editPatient} from '@/api/patient'
  158. export default {
  159. data() {
  160. return {
  161. relationShow:false,
  162. relations: [
  163. {
  164. name: '本人',
  165. },
  166. {
  167. name: '配偶',
  168. },
  169. {
  170. name: '父母',
  171. },
  172. {
  173. name: '子女',
  174. },
  175. {
  176. name: '朋友',
  177. },
  178. {
  179. name: '亲戚',
  180. },
  181. {
  182. name: '其他',
  183. },
  184. ],
  185. historyAllergics: [
  186. {
  187. name: '阿司匹林',
  188. checked: 0,
  189. },
  190. {
  191. name: '磺胺类',
  192. checked: 0,
  193. },
  194. {
  195. name: '头孢类',
  196. checked: 0,
  197. },
  198. {
  199. name: '青毒素类',
  200. checked: 0,
  201. },
  202. {
  203. name: '奶制品',
  204. checked: 0,
  205. },
  206. {
  207. name: '其他',
  208. checked: 0,
  209. },
  210. ],
  211. selfMedHistorys: [
  212. {
  213. name: '糖尿病',
  214. checked: 0,
  215. },
  216. {
  217. name: '哮喘',
  218. checked: 0,
  219. },
  220. {
  221. name: '恶性肿瘤',
  222. checked: 0,
  223. },
  224. {
  225. name: '高血压',
  226. checked: 0,
  227. },
  228. {
  229. name: '其他',
  230. checked: 0,
  231. },
  232. ],
  233. familyMedHistorys: [
  234. {
  235. name: '糖尿病',
  236. checked: 0,
  237. },
  238. {
  239. name: '哮喘',
  240. checked: 0,
  241. },
  242. {
  243. name: '恶性肿瘤',
  244. checked: 0,
  245. },
  246. {
  247. name: '高血压',
  248. checked: 0,
  249. },
  250. {
  251. name: '其他',
  252. checked: 0,
  253. },
  254. ],
  255. type:null,
  256. patientId:null,
  257. form: {
  258. sex: 1,
  259. birthday: '',
  260. idCard:"",
  261. relation:"", // 与本人关系
  262. liverUnusual:"正常", // 肝功能是否异常
  263. renalUnusual:"正常", // 肾功能是否异常
  264. historyAllergic:"无", // 过敏史
  265. familyMedHistory:"无", // 家族病史
  266. selfMedHistory:"无", // 个人病史
  267. }
  268. };
  269. },
  270. onLoad(option) {
  271. this.type=option.type;
  272. if(this.type=='edit'){
  273. this.patientId=option.patientId;
  274. this.getPatientById();
  275. uni.setNavigationBarTitle({
  276. title: '编辑就诊人'
  277. });
  278. }
  279. else{
  280. uni.setNavigationBarTitle({
  281. title: '新增就诊人'
  282. });
  283. }
  284. },
  285. methods:{
  286. liverUnusualChange(item){
  287. console.log(item)
  288. this.form.liverUnusual=item.detail.value;
  289. },
  290. renalUnusualChange(item){
  291. console.log(item)
  292. this.form.renalUnusual=item.detail.value;
  293. },
  294. historyAllergicOptionChange(item){
  295. item.checked=item.checked==1?0:1
  296. },
  297. selfMedHistoryOptionChange(item){
  298. item.checked=item.checked==1?0:1
  299. },
  300. familyMedHistoryOptionChange(item){
  301. item.checked=item.checked==1?0:1
  302. },
  303. historyAllergicChange(item){
  304. console.log(item)
  305. this.form.historyAllergic=item.detail.value;
  306. },
  307. selfMedHistoryChange(item){
  308. console.log(item)
  309. this.form.selfMedHistory=item.detail.value;
  310. },
  311. familyMedHistoryChange(item){
  312. console.log(item)
  313. this.form.familyMedHistory=item.detail.value;
  314. },
  315. relationSelect(e){
  316. this.form.relation = e.name
  317. },
  318. idcardChange(){
  319. if(this.form.idCard.length==18){
  320. var json=this.$parseIDCardInfo(this.form.idCard)
  321. this.form.birthday=json.birthday
  322. console.log(json)
  323. }
  324. },
  325. genderChange(type){
  326. this.form.sex=type
  327. },
  328. getPatientById(){
  329. var data={patientId:this.patientId};
  330. getPatientById(data).then(
  331. res => {
  332. if(res.code==200){
  333. this.form=res.data;
  334. this.date=this.form.birthday;
  335. if(this.form.historyAllergic!=null&&this.form.historyAllergic!="无"){
  336. var options=this.form.historyAllergic.split(',');
  337. this.historyAllergics.forEach(item =>{
  338. for(var i=0;i<options.length;i++){
  339. if(item.name==options[i]){
  340. item.checked=1;
  341. }
  342. }
  343. })
  344. this.form.historyAllergic="有";
  345. }
  346. if(this.form.selfMedHistory!=null&&this.form.selfMedHistory!="无"){
  347. var options=this.form.selfMedHistory.split(',');
  348. this.selfMedHistorys.forEach(item =>{
  349. for(var i=0;i<options.length;i++){
  350. if(item.name==options[i]){
  351. item.checked=1;
  352. }
  353. }
  354. })
  355. this.form.selfMedHistory="有";
  356. }
  357. if(this.form.familyMedHistory!=null&&this.form.familyMedHistory!="无"){
  358. var options=this.form.familyMedHistory.split(',');
  359. this.familyMedHistorys.forEach(item =>{
  360. for(var i=0;i<options.length;i++){
  361. if(item.name==options[i]){
  362. item.checked=1;
  363. }
  364. }
  365. })
  366. this.form.familyMedHistory="有";
  367. }
  368. }else{
  369. uni.showToast({
  370. title: res.msg,
  371. });
  372. }
  373. },
  374. rej => {}
  375. );
  376. },
  377. submit(){
  378. if(this.type=="add"){
  379. this.addPatient()
  380. }
  381. else if(this.type=="edit"){
  382. this.editPatient()
  383. }
  384. },
  385. editPatient(){
  386. var data={
  387. patientId:this.patientId,
  388. patientName:this.form.patientName,
  389. mobile:this.form.mobile,
  390. sex: this.form.sex,
  391. birthday: this.form.birthday,
  392. idCard:this.form.idCard,
  393. relation:this.form.relation, // 与本人关系
  394. liverUnusual:this.form.liverUnusual, // 肝功能是否异常
  395. renalUnusual:this.form.renalUnusual, // 肾功能是否异常
  396. }
  397. if(this.form.historyAllergic=="有"){
  398. var options=[];
  399. this.historyAllergics.forEach(item =>{
  400. if(item.checked==1){
  401. options.push(item.name);
  402. }
  403. })
  404. data.historyAllergic=options.toString();
  405. }
  406. else{
  407. data.historyAllergic=this.form.historyAllergic;
  408. }
  409. if(this.form.selfMedHistory=="有"){
  410. var options=[];
  411. this.selfMedHistorys.forEach(item =>{
  412. if(item.checked==1){
  413. options.push(item.name);
  414. }
  415. })
  416. data.selfMedHistory=options.toString();
  417. }
  418. else{
  419. data.selfMedHistory=this.form.selfMedHistory;
  420. }
  421. if(this.form.familyMedHistory=="有"){
  422. var options=[];
  423. this.familyMedHistorys.forEach(item =>{
  424. if(item.checked==1){
  425. options.push(item.name);
  426. }
  427. })
  428. data.familyMedHistory=options.toString();
  429. }
  430. else{
  431. data.familyMedHistory=this.form.familyMedHistory;
  432. }
  433. editPatient(data).then(
  434. res => {
  435. if(res.code==200){
  436. uni.showToast({
  437. icon:'success',
  438. title: "操作成功",
  439. });
  440. setTimeout(function() {
  441. uni.$emit('refreshPatient');
  442. uni.navigateBack({
  443. delta: 1
  444. })
  445. }, 500);
  446. }else{
  447. uni.showToast({
  448. icon:'none',
  449. title: res.msg,
  450. });
  451. }
  452. },
  453. rej => {}
  454. );
  455. },
  456. addPatient(){
  457. var data={
  458. patientName:this.form.patientName,
  459. mobile:this.form.mobile,
  460. sex: this.form.sex,
  461. birthday: this.form.birthday,
  462. idCard:this.form.idCard,
  463. relation:this.form.relation, // 与本人关系
  464. liverUnusual:this.form.liverUnusual, // 肝功能是否异常
  465. renalUnusual:this.form.renalUnusual, // 肾功能是否异常
  466. }
  467. if(this.form.historyAllergic=="有"){
  468. var options=[];
  469. this.historyAllergics.forEach(item =>{
  470. if(item.checked==1){
  471. options.push(item.name);
  472. }
  473. })
  474. data.historyAllergic=options.toString();
  475. }
  476. else{
  477. data.historyAllergic=this.form.historyAllergic;
  478. }
  479. if(this.form.selfMedHistory=="有"){
  480. var options=[];
  481. this.selfMedHistorys.forEach(item =>{
  482. if(item.checked==1){
  483. options.push(item.name);
  484. }
  485. })
  486. data.selfMedHistory=options.toString();
  487. }
  488. else{
  489. data.selfMedHistory=this.form.selfMedHistory;
  490. }
  491. if(this.form.familyMedHistory=="有"){
  492. var options=[];
  493. this.familyMedHistorys.forEach(item =>{
  494. if(item.checked==1){
  495. options.push(item.name);
  496. }
  497. })
  498. data.familyMedHistory=options.toString();
  499. }
  500. else{
  501. data.familyMedHistory=this.form.familyMedHistory;
  502. }
  503. addPatient(data).then(
  504. res => {
  505. if(res.code==200){
  506. uni.showToast({
  507. icon:'success',
  508. title: "操作成功",
  509. });
  510. setTimeout(function() {
  511. uni.$emit('refreshPatient');
  512. uni.navigateBack({
  513. delta: 1
  514. })
  515. }, 500);
  516. }else{
  517. uni.showToast({
  518. icon:'none',
  519. title: res.msg,
  520. });
  521. }
  522. },
  523. rej => {}
  524. );
  525. },
  526. // 出生日期选择
  527. birthdayChange: function(e) {
  528. this.form.birthday = e.target.value
  529. },
  530. }
  531. }
  532. </script>
  533. <style lang="scss">
  534. page{
  535. height: 100%;
  536. }
  537. .content{
  538. height: 100%;
  539. .inner{
  540. padding: 20upx 20rpx 200rpx;
  541. .form-box{
  542. margin-bottom: 15rpx;
  543. padding: 0upx 30upx;
  544. background: #FFFFFF;
  545. border-radius: 16upx;
  546. .form-item{
  547. min-height: 103upx;
  548. display: flex;
  549. align-items: center;
  550. justify-content: space-between;
  551. border-bottom: 1px solid #F1F1F1;
  552. &:last-child{
  553. border-bottom: none;
  554. }
  555. .label{
  556. min-width: 200upx;
  557. font-size: 30upx;
  558. font-family: PingFang SC;
  559. font-weight: 500;
  560. color: #222222;
  561. }
  562. .option-box{
  563. display: flex;
  564. flex-wrap: wrap;
  565. align-items: flex-start;
  566. justify-content: flex-start;
  567. .option{
  568. margin: 5rpx;
  569. }
  570. }
  571. .input-width{
  572. width: calc(100% - 200upx);
  573. text-align: right;
  574. }
  575. .form-input{
  576. font-size: 30upx;
  577. font-family: PingFang SC;
  578. font-weight: 500;
  579. color: #999999;
  580. text-align: right;
  581. }
  582. .option-text{
  583. font-size: 30upx;
  584. font-family: PingFang SC;
  585. font-weight: 500;
  586. color: #111111;
  587. line-height: 30upx;
  588. }
  589. .right-box{
  590. display: flex;
  591. align-items: center;
  592. .input-box{
  593. width: 400upx;
  594. display: flex;
  595. align-items: center;
  596. justify-content: flex-end;
  597. input{
  598. text-align: right;
  599. }
  600. }
  601. .arrow{
  602. width: 13upx;
  603. height: 23upx;
  604. margin-left: 20upx;
  605. }
  606. }
  607. .birth-picker {
  608. display: flex;
  609. align-items: center;
  610. .right-box{
  611. display: flex;
  612. align-items: center;
  613. .input-box{
  614. width: 400upx;
  615. display: flex;
  616. align-items: center;
  617. justify-content: flex-end;
  618. input{
  619. text-align: right;
  620. }
  621. }
  622. .arrow{
  623. width: 13upx;
  624. height: 23upx;
  625. margin-left: 20upx;
  626. }
  627. }
  628. }
  629. }
  630. }
  631. }
  632. .btn-box{
  633. position: fixed;
  634. bottom: 0rpx;
  635. left:0rpx;
  636. width: 100%;
  637. height: 120upx;
  638. padding: 0 30upx;
  639. display: flex;
  640. align-items: center;
  641. justify-content: center;
  642. background: #FFFFFF;
  643. .sub-btn{
  644. width: 100%;
  645. height: 88upx;
  646. line-height: 88upx;
  647. text-align: center;
  648. font-size: 30upx;
  649. font-family: PingFang SC;
  650. font-weight: bold;
  651. color: #FFFFFF;
  652. background: #C39A58;
  653. border-radius: 44upx;
  654. }
  655. }
  656. }
  657. </style>