addEditPatient.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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="imgPath+'/app/commonCourse/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="imgPath+'/app/commonCourse/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. computed: {
  271. imgPath() {
  272. return this.$store.state.imgpath
  273. },
  274. },
  275. onLoad(option) {
  276. this.type=option.type;
  277. if(this.type=='edit'){
  278. this.patientId=option.patientId;
  279. this.getPatientById();
  280. uni.setNavigationBarTitle({
  281. title: '编辑就诊人'
  282. });
  283. }
  284. else{
  285. uni.setNavigationBarTitle({
  286. title: '新增就诊人'
  287. });
  288. }
  289. },
  290. methods:{
  291. liverUnusualChange(item){
  292. console.log(item)
  293. this.form.liverUnusual=item.detail.value;
  294. },
  295. renalUnusualChange(item){
  296. console.log(item)
  297. this.form.renalUnusual=item.detail.value;
  298. },
  299. historyAllergicOptionChange(item){
  300. item.checked=item.checked==1?0:1
  301. },
  302. selfMedHistoryOptionChange(item){
  303. item.checked=item.checked==1?0:1
  304. },
  305. familyMedHistoryOptionChange(item){
  306. item.checked=item.checked==1?0:1
  307. },
  308. historyAllergicChange(item){
  309. console.log(item)
  310. this.form.historyAllergic=item.detail.value;
  311. },
  312. selfMedHistoryChange(item){
  313. console.log(item)
  314. this.form.selfMedHistory=item.detail.value;
  315. },
  316. familyMedHistoryChange(item){
  317. console.log(item)
  318. this.form.familyMedHistory=item.detail.value;
  319. },
  320. relationSelect(e){
  321. this.form.relation = e.name
  322. },
  323. idcardChange(){
  324. if(this.form.idCard.length==18){
  325. var json=this.$parseIDCardInfo(this.form.idCard)
  326. this.form.birthday=json.birthday
  327. console.log(json)
  328. }
  329. },
  330. genderChange(type){
  331. this.form.sex=type
  332. },
  333. getPatientById(){
  334. var data={patientId:this.patientId};
  335. getPatientById(data).then(
  336. res => {
  337. if(res.code==200){
  338. this.form=res.data;
  339. this.date=this.form.birthday;
  340. if(this.form.historyAllergic!=null&&this.form.historyAllergic!="无"){
  341. var options=this.form.historyAllergic.split(',');
  342. this.historyAllergics.forEach(item =>{
  343. for(var i=0;i<options.length;i++){
  344. if(item.name==options[i]){
  345. item.checked=1;
  346. }
  347. }
  348. })
  349. this.form.historyAllergic="有";
  350. }
  351. if(this.form.selfMedHistory!=null&&this.form.selfMedHistory!="无"){
  352. var options=this.form.selfMedHistory.split(',');
  353. this.selfMedHistorys.forEach(item =>{
  354. for(var i=0;i<options.length;i++){
  355. if(item.name==options[i]){
  356. item.checked=1;
  357. }
  358. }
  359. })
  360. this.form.selfMedHistory="有";
  361. }
  362. if(this.form.familyMedHistory!=null&&this.form.familyMedHistory!="无"){
  363. var options=this.form.familyMedHistory.split(',');
  364. this.familyMedHistorys.forEach(item =>{
  365. for(var i=0;i<options.length;i++){
  366. if(item.name==options[i]){
  367. item.checked=1;
  368. }
  369. }
  370. })
  371. this.form.familyMedHistory="有";
  372. }
  373. }else{
  374. uni.showToast({
  375. title: res.msg,
  376. });
  377. }
  378. },
  379. rej => {}
  380. );
  381. },
  382. submit(){
  383. if(this.type=="add"){
  384. this.addPatient()
  385. }
  386. else if(this.type=="edit"){
  387. this.editPatient()
  388. }
  389. },
  390. editPatient(){
  391. var data={
  392. patientId:this.patientId,
  393. patientName:this.form.patientName,
  394. mobile:this.form.mobile,
  395. sex: this.form.sex,
  396. birthday: this.form.birthday,
  397. idCard:this.form.idCard,
  398. relation:this.form.relation, // 与本人关系
  399. liverUnusual:this.form.liverUnusual, // 肝功能是否异常
  400. renalUnusual:this.form.renalUnusual, // 肾功能是否异常
  401. }
  402. if(this.form.historyAllergic=="有"){
  403. var options=[];
  404. this.historyAllergics.forEach(item =>{
  405. if(item.checked==1){
  406. options.push(item.name);
  407. }
  408. })
  409. data.historyAllergic=options.toString();
  410. }
  411. else{
  412. data.historyAllergic=this.form.historyAllergic;
  413. }
  414. if(this.form.selfMedHistory=="有"){
  415. var options=[];
  416. this.selfMedHistorys.forEach(item =>{
  417. if(item.checked==1){
  418. options.push(item.name);
  419. }
  420. })
  421. data.selfMedHistory=options.toString();
  422. }
  423. else{
  424. data.selfMedHistory=this.form.selfMedHistory;
  425. }
  426. if(this.form.familyMedHistory=="有"){
  427. var options=[];
  428. this.familyMedHistorys.forEach(item =>{
  429. if(item.checked==1){
  430. options.push(item.name);
  431. }
  432. })
  433. data.familyMedHistory=options.toString();
  434. }
  435. else{
  436. data.familyMedHistory=this.form.familyMedHistory;
  437. }
  438. editPatient(data).then(
  439. res => {
  440. if(res.code==200){
  441. uni.showToast({
  442. icon:'success',
  443. title: "操作成功",
  444. });
  445. setTimeout(function() {
  446. uni.$emit('refreshPatient');
  447. uni.navigateBack({
  448. delta: 1
  449. })
  450. }, 500);
  451. }else{
  452. uni.showToast({
  453. icon:'none',
  454. title: res.msg,
  455. });
  456. }
  457. },
  458. rej => {}
  459. );
  460. },
  461. addPatient(){
  462. var data={
  463. patientName:this.form.patientName,
  464. mobile:this.form.mobile,
  465. sex: this.form.sex,
  466. birthday: this.form.birthday,
  467. idCard:this.form.idCard,
  468. relation:this.form.relation, // 与本人关系
  469. liverUnusual:this.form.liverUnusual, // 肝功能是否异常
  470. renalUnusual:this.form.renalUnusual, // 肾功能是否异常
  471. }
  472. if(this.form.historyAllergic=="有"){
  473. var options=[];
  474. this.historyAllergics.forEach(item =>{
  475. if(item.checked==1){
  476. options.push(item.name);
  477. }
  478. })
  479. data.historyAllergic=options.toString();
  480. }
  481. else{
  482. data.historyAllergic=this.form.historyAllergic;
  483. }
  484. if(this.form.selfMedHistory=="有"){
  485. var options=[];
  486. this.selfMedHistorys.forEach(item =>{
  487. if(item.checked==1){
  488. options.push(item.name);
  489. }
  490. })
  491. data.selfMedHistory=options.toString();
  492. }
  493. else{
  494. data.selfMedHistory=this.form.selfMedHistory;
  495. }
  496. if(this.form.familyMedHistory=="有"){
  497. var options=[];
  498. this.familyMedHistorys.forEach(item =>{
  499. if(item.checked==1){
  500. options.push(item.name);
  501. }
  502. })
  503. data.familyMedHistory=options.toString();
  504. }
  505. else{
  506. data.familyMedHistory=this.form.familyMedHistory;
  507. }
  508. addPatient(data).then(
  509. res => {
  510. if(res.code==200){
  511. uni.showToast({
  512. icon:'none',
  513. title: res.alert || res.msg,
  514. });
  515. const time = res.alert&&res.alert.includes('芳华币') ? 1000 : 500
  516. setTimeout(function() {
  517. uni.$emit('refreshPatient');
  518. uni.navigateBack({
  519. delta: 1
  520. })
  521. }, time);
  522. }else{
  523. uni.showToast({
  524. icon:'none',
  525. title: res.msg,
  526. });
  527. }
  528. },
  529. rej => {}
  530. );
  531. },
  532. // 出生日期选择
  533. birthdayChange: function(e) {
  534. this.form.birthday = e.target.value
  535. },
  536. }
  537. }
  538. </script>
  539. <style lang="scss">
  540. page{
  541. height: 100%;
  542. }
  543. .content{
  544. height: 100%;
  545. .inner{
  546. padding: 20upx 20rpx 200rpx;
  547. .form-box{
  548. margin-bottom: 15rpx;
  549. padding: 0upx 30upx;
  550. background: #FFFFFF;
  551. border-radius: 16upx;
  552. .form-item{
  553. min-height: 103upx;
  554. display: flex;
  555. align-items: center;
  556. justify-content: space-between;
  557. border-bottom: 1px solid #F1F1F1;
  558. &:last-child{
  559. border-bottom: none;
  560. }
  561. .label{
  562. min-width: 200upx;
  563. font-size: 30upx;
  564. font-family: PingFang SC;
  565. font-weight: 500;
  566. color: #222222;
  567. }
  568. .option-box{
  569. display: flex;
  570. flex-wrap: wrap;
  571. align-items: flex-start;
  572. justify-content: flex-start;
  573. .option{
  574. margin: 5rpx;
  575. }
  576. }
  577. .input-width{
  578. width: calc(100% - 200upx);
  579. text-align: right;
  580. }
  581. .form-input{
  582. font-size: 30upx;
  583. font-family: PingFang SC;
  584. font-weight: 500;
  585. color: #999999;
  586. text-align: right;
  587. }
  588. .option-text{
  589. font-size: 30upx;
  590. font-family: PingFang SC;
  591. font-weight: 500;
  592. color: #111111;
  593. line-height: 30upx;
  594. }
  595. .right-box{
  596. display: flex;
  597. align-items: center;
  598. .input-box{
  599. width: 400upx;
  600. display: flex;
  601. align-items: center;
  602. justify-content: flex-end;
  603. input{
  604. text-align: right;
  605. }
  606. }
  607. .arrow{
  608. width: 13upx;
  609. height: 23upx;
  610. margin-left: 20upx;
  611. }
  612. }
  613. .birth-picker {
  614. display: flex;
  615. align-items: center;
  616. .right-box{
  617. display: flex;
  618. align-items: center;
  619. .input-box{
  620. width: 400upx;
  621. display: flex;
  622. align-items: center;
  623. justify-content: flex-end;
  624. input{
  625. text-align: right;
  626. }
  627. }
  628. .arrow{
  629. width: 13upx;
  630. height: 23upx;
  631. margin-left: 20upx;
  632. }
  633. }
  634. }
  635. }
  636. }
  637. }
  638. .btn-box{
  639. position: fixed;
  640. bottom: 0rpx;
  641. left:0rpx;
  642. width: 100%;
  643. height: 120upx;
  644. padding: 0 30upx;
  645. display: flex;
  646. align-items: center;
  647. justify-content: center;
  648. background: #FFFFFF;
  649. .sub-btn{
  650. width: 100%;
  651. height: 88upx;
  652. line-height: 88upx;
  653. text-align: center;
  654. font-size: 30upx;
  655. font-family: PingFang SC;
  656. font-weight: bold;
  657. color: #FFFFFF;
  658. background: #C39A58;
  659. border-radius: 44upx;
  660. }
  661. }
  662. }
  663. </style>