addDoc.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="form-box">
  5. <text class="form-title">身体信息</text>
  6. <view class="form-item">
  7. <text class="label">身高<text class="color-price">*</text></text>
  8. <input maxlength="10" class="input-width" type="digit" v-model="form.height" placeholder="请输入身高"
  9. placeholder-class="form-input" />
  10. <text class="unit">cm</text>
  11. </view>
  12. <view class="form-item">
  13. <text class="label">体重<text class="color-price">*</text></text>
  14. <input maxlength="10" class="input-width" type="digit" v-model="form.weight" placeholder="请输入体重"
  15. placeholder-class="form-input" />
  16. <text class="unit">kg</text>
  17. </view>
  18. <view class="form-item">
  19. <text class="label">腰围<text class="color-price">*</text></text>
  20. <input maxlength="10" class="input-width" type="digit" v-model="form.waistCircumference"
  21. placeholder="请输入腰围" placeholder-class="form-input" />
  22. <text class="unit">cm</text>
  23. </view>
  24. <view class="form-item">
  25. <text class="label">臀围<text class="color-price">*</text></text>
  26. <input maxlength="10" class="input-width" type="digit" v-model="form.hipCircumference"
  27. placeholder="请输入臀围" placeholder-class="form-input" />
  28. <text class="unit">cm</text>
  29. </view>
  30. </view>
  31. <view class="form-box">
  32. <text class="form-title">疾病史</text>
  33. <view class="form-item">
  34. <text class="label">高血糖</text>
  35. <radio-group style="display: flex;align-items: center;">
  36. <label style="margin-right: 50upx;">
  37. <radio @click="hyperglycemiaChange(0)" value="0" :checked="form.hyperglycemia==0"
  38. style="margin-right: 16upx;" />
  39. <text class="sex-text">无</text>
  40. </label>
  41. <label style="margin-right: 50upx;">
  42. <radio @click="hyperglycemiaChange(1)" value="1" :checked="form.hyperglycemia==1"
  43. style="margin-right: 16upx;" />
  44. <text class="sex-text">轻微</text>
  45. </label>
  46. <label>
  47. <radio @click="hyperglycemiaChange(2)" value="2" :checked="form.hyperglycemia==2"
  48. style="margin-right: 16upx;" />
  49. <text class="sex-text">严重</text>
  50. </label>
  51. </radio-group>
  52. </view>
  53. <view class="form-item">
  54. <text class="label">测量值</text>
  55. <input maxlength="10" class="input-width" type="digit" v-model="form.hyperglycemiaValue"
  56. placeholder="请输入测量值" placeholder-class="form-input" />
  57. <text class="unit">mmol/L</text>
  58. </view>
  59. <view class="form-item">
  60. <text class="label">高血压</text>
  61. <radio-group style="display: flex;align-items: center;">
  62. <label style="margin-right: 50upx;">
  63. <radio @click="hypertensionChange(0)" value="0" :checked="form.hypertension==0"
  64. style="margin-right: 16upx;" />
  65. <text class="sex-text">无</text>
  66. </label>
  67. <label style="margin-right: 50upx;">
  68. <radio @click="hypertensionChange(1)" value="1" :checked="form.hypertension==1"
  69. style="margin-right: 16upx;" />
  70. <text class="sex-text">轻微</text>
  71. </label>
  72. <label>
  73. <radio @click="hypertensionChange(2)" value="2" :checked="form.hypertension==2"
  74. style="margin-right: 16upx;" />
  75. <text class="sex-text">严重</text>
  76. </label>
  77. </radio-group>
  78. </view>
  79. <view class="form-item">
  80. <text class="label">收缩压</text>
  81. <input maxlength="10" class="input-width" type="digit" v-model="form.systolicPressure"
  82. placeholder="请输入测量值" placeholder-class="form-input" />
  83. <text class="unit">mmHg</text>
  84. </view>
  85. <view class="form-item">
  86. <text class="label">舒张压</text>
  87. <input maxlength="10" class="input-width" type="digit" v-model="form.diastolicPressure"
  88. placeholder="请输入测量值" placeholder-class="form-input" />
  89. <text class="unit">mmHg</text>
  90. </view>
  91. <view class="form-item">
  92. <text class="label">高血脂</text>
  93. <radio-group style="display: flex;align-items: center;">
  94. <label style="margin-right: 50upx;">
  95. <radio @click="hyperlipidemiaChange(0)" value="0" :checked="form.hyperlipidemia==0"
  96. style="margin-right: 16upx;" />
  97. <text class="sex-text">无</text>
  98. </label>
  99. <label style="margin-right: 50upx;">
  100. <radio @click="hyperlipidemiaChange(1)" value="1" :checked="form.hyperlipidemia==1"
  101. style="margin-right: 16upx;" />
  102. <text class="sex-text">轻微</text>
  103. </label>
  104. <label>
  105. <radio @click="hyperlipidemiaChange(2)" value="2" :checked="form.hyperlipidemia==2"
  106. style="margin-right: 16upx;" />
  107. <text class="sex-text">严重</text>
  108. </label>
  109. </radio-group>
  110. </view>
  111. <view class="form-item">
  112. <text class="label">高尿酸</text>
  113. <radio-group style="display: flex;align-items: center;">
  114. <label style="margin-right: 50upx;">
  115. <radio @click="hyperuricemiaChange(0)" value="0" :checked="form.hyperuricemia==0"
  116. style="margin-right: 16upx;" />
  117. <text class="sex-text">无</text>
  118. </label>
  119. <label style="margin-right: 50upx;">
  120. <radio @click="hyperuricemiaChange(1)" value="1" :checked="form.hyperuricemia==1"
  121. style="margin-right: 16upx;" />
  122. <text class="sex-text">轻微</text>
  123. </label>
  124. <label>
  125. <radio @click="hyperuricemiaChange(2)" value="2" :checked="form.hyperuricemia==2"
  126. style="margin-right: 16upx;" />
  127. <text class="sex-text">严重</text>
  128. </label>
  129. </radio-group>
  130. </view>
  131. <view class="form-item">
  132. <text class="label">测量值</text>
  133. <input maxlength="10" class="input-width" type="digit" v-model="form.hyperuricemiaValue"
  134. placeholder="请输入测量值" placeholder-class="form-input" />
  135. <text class="unit">μmol/L</text>
  136. </view>
  137. <view class="form-item">
  138. <text class="label">高体重</text>
  139. <radio-group style="display: flex;align-items: center;">
  140. <label style="margin-right: 50upx;">
  141. <radio @click="bodyWeightStatusChange(0)" value="0" :checked="form.bodyWeightStatus==0"
  142. style="margin-right: 16upx;" />
  143. <text class="sex-text">正常</text>
  144. </label>
  145. <label style="margin-right: 50upx;">
  146. <radio @click="bodyWeightStatusChange(1)" value="1" :checked="form.bodyWeightStatus==1"
  147. style="margin-right: 16upx;" />
  148. <text class="sex-text">偏瘦</text>
  149. </label>
  150. <label>
  151. <radio @click="bodyWeightStatusChange(2)" value="2" :checked="form.bodyWeightStatus==2"
  152. style="margin-right: 16upx;" />
  153. <text class="sex-text">偏重</text>
  154. </label>
  155. </radio-group>
  156. </view>
  157. </view>
  158. <view class="form-box">
  159. <text class="form-title">其他病史</text>
  160. <view class="form-item wrap">
  161. <view class="form-item-tag mb16" v-for="(item, index) in tags" :key="index"
  162. @click="tagsClick(item)">
  163. <view :class="checkedItems.includes(item.dictValue)?'tag active':'tag'">
  164. {{item.dictLabel}}
  165. </view>
  166. </view>
  167. <!-- 其他选项 -->
  168. <view class="form-item-tag" @click="toggleOther">
  169. <view :class="otherSelected ? 'tag active' : 'tag'">
  170. + 其他
  171. </view>
  172. </view>
  173. </view>
  174. <view class="form-item" v-if="otherSelected">
  175. <text class="label">其他病史</text>
  176. <input class="input-width" type="text" v-model="symptom" placeholder="请输入病史"
  177. placeholder-class="form-input" />
  178. </view>
  179. </view>
  180. <view class="form-box">
  181. <text class="form-title">症状史</text>
  182. <view class="form-item wrap">
  183. <view class="form-item-tag mb16" v-for="(item, index) in cates" :key="index"
  184. @click="catesClick(item)">
  185. <view :class="checkedItems2.includes(item.dictValue)?'tag active':'tag'">
  186. {{item.dictLabel}}
  187. </view>
  188. </view>
  189. <!-- 其他选项 -->
  190. <view class="form-item-tag" @click="toggleOther2">
  191. <view :class="otherSelected2 ? 'tag active' : 'tag'">
  192. + 其他
  193. </view>
  194. </view>
  195. </view>
  196. <!-- 其他症状输入框(选中"其他"时显示) -->
  197. <view class="form-item" v-if="otherSelected2">
  198. <text class="label">其他症状</text>
  199. <input class="input-width" type="text" v-model="symptom2" placeholder="请输入症状"
  200. placeholder-class="form-input" />
  201. </view>
  202. </view>
  203. </view>
  204. <view class="btn-box">
  205. <view class="sub-btn" @click="submit()">保存</view>
  206. </view>
  207. </view>
  208. </template>
  209. <script>
  210. import {
  211. getDoc,
  212. addDoc,
  213. updateDoc
  214. } from '@/api/healthUser.js'
  215. import {
  216. getDictByKey
  217. } from '@/api/common.js'
  218. export default {
  219. data() {
  220. return {
  221. type: null,
  222. patientId: null,
  223. symptom: null,
  224. symptom2: null,
  225. famaleurl: "/static/images/health/female_profile.png",
  226. maleurl: "/static/images/health/my_heads.png",
  227. // 存储所有选中的症状值
  228. checkedItems: [],
  229. checkedItems2: [],
  230. text: [],
  231. text2: [],
  232. // 其他选项是否选中
  233. otherSelected: false,
  234. otherSelected2: false,
  235. // 其他症状输入内容
  236. tags: [
  237. // {
  238. // name: '心脏病',
  239. // checked:true,
  240. // id: 1
  241. // },
  242. // {
  243. // name: '脑梗死',
  244. // checked:false,
  245. // id: 2
  246. // },{
  247. // name: '肾病',
  248. // checked:false,
  249. // id: 3
  250. // },{
  251. // name: '脂肪肝',
  252. // checked:false,
  253. // id: 4
  254. // },
  255. ],
  256. cates: [],
  257. form: {
  258. "height": null,
  259. "weight": null,
  260. "waistCircumference": null,
  261. "hipCircumference": null,
  262. "hyperglycemia": 0,
  263. "hyperglycemiaValue": null,
  264. "hypertension": 0,
  265. "systolicPressure": null,
  266. "diastolicPressure": null,
  267. "hyperlipidemia": 0,
  268. "hyperuricemia": 0,
  269. "hyperuricemiaValue": null,
  270. "bodyWeightStatus": 0,
  271. "otherMedicalHistory": null,
  272. "symptomHistory": null,
  273. }
  274. };
  275. },
  276. onLoad(options) {
  277. this.companyUserId = options.companyUserId;
  278. this.form.userId =options.userId;
  279. this.form.companyUserId = options.companyUserId;
  280. // console.log(this.type)
  281. // if (this.type == 'edit') {
  282. // }
  283. this.getDoc();
  284. this.getDictByKey('other_medical_history')
  285. this.getDictByKey('medical_history')
  286. },
  287. methods: {
  288. sexChange(type) {
  289. this.form.sex = type
  290. },
  291. //血糖
  292. hyperglycemiaChange(e) {
  293. this.form.hyperglycemia = e
  294. },
  295. //血压
  296. hypertensionChange(e) {
  297. this.form.hypertension = e
  298. },
  299. //血脂
  300. hyperlipidemiaChange(e) {
  301. this.form.hyperlipidemia = e
  302. },
  303. //尿酸
  304. hyperuricemiaChange(e) {
  305. this.form.hyperuricemia = e
  306. },
  307. bodyWeightStatusChange(e) {
  308. this.form.bodyWeightStatus = e
  309. },
  310. tagsClick(item) {
  311. const index = this.checkedItems.indexOf(item.dictValue);
  312. if (index > -1) {
  313. // 如果已选中则移除
  314. this.checkedItems.splice(index, 1);
  315. } else {
  316. // 如果未选中则添加
  317. this.checkedItems.push(item.dictValue);
  318. this.text.push(item.dictLabel)
  319. }
  320. },
  321. catesClick(item) {
  322. const index = this.checkedItems2.indexOf(item.dictValue);
  323. if (index > -1) {
  324. // 如果已选中则移除
  325. this.checkedItems2.splice(index, 1);
  326. } else {
  327. // 如果未选中则添加
  328. this.checkedItems2.push(item.dictValue);
  329. this.text2.push(item.dictLabel)
  330. }
  331. },
  332. // 切换其他选项
  333. toggleOther() {
  334. this.otherSelected = !this.otherSelected;
  335. // 清空其他症状输入
  336. if (!this.otherSelected) {
  337. this.symptom = null;
  338. }
  339. },
  340. toggleOther2() {
  341. this.otherSelected2 = !this.otherSelected2;
  342. // 清空其他症状输入
  343. if (!this.otherSelected2) {
  344. this.symptom2 = null;
  345. }
  346. },
  347. getDictByKey(key) {
  348. var data = {
  349. key: key
  350. }
  351. getDictByKey(data).then(
  352. res => {
  353. if (res.code == 200) {
  354. if (key == "other_medical_history") {
  355. this.tags = res.data;
  356. }
  357. if (key == "medical_history") {
  358. this.cates = res.data;
  359. }
  360. }
  361. },
  362. err => {}
  363. );
  364. },
  365. getDoc() {
  366. var data = {
  367. userId: this.form.userId
  368. };
  369. getDoc(data).then(
  370. res => {
  371. if (res.code == 200) {
  372. if(res.data==null){
  373. this.type='add'
  374. }else{
  375. this.type='edit'
  376. this.form = res.data;
  377. }
  378. } else {
  379. uni.showToast({
  380. title: res.msg,
  381. });
  382. }
  383. },
  384. rej => {}
  385. );
  386. },
  387. submit() {
  388. if (this.form.height == null) {
  389. uni.showToast({
  390. icon: 'none',
  391. title: "身高不能为空",
  392. });
  393. return;
  394. }
  395. if (this.form.weight == null) {
  396. uni.showToast({
  397. icon: 'none',
  398. title: "体重不能为空",
  399. });
  400. return;
  401. }
  402. if (this.form.waistCircumference == null) {
  403. uni.showToast({
  404. icon: 'none',
  405. title: "腰围不能为空",
  406. });
  407. return;
  408. }
  409. if (this.form.hipCircumference == null) {
  410. uni.showToast({
  411. icon: 'none',
  412. title: "臀围不能为空",
  413. });
  414. return;
  415. }
  416. // console.log(this.text,'---')
  417. this.form.otherMedicalHistory = this.utils.joinWithSymptom(this.text, this.symptom)
  418. this.form.symptomHistory = this.utils.joinWithSymptom(this.text2, this.symptom2)
  419. if (this.type == "add") {
  420. this.addDoc()
  421. } else if (this.type == "edit") {
  422. this.editDoc()
  423. }
  424. },
  425. editDoc() {
  426. updateDoc(this.form).then(
  427. res => {
  428. if (res.code == 200) {
  429. uni.showToast({
  430. icon: 'success',
  431. title: "操作成功",
  432. });
  433. setTimeout(function() {
  434. uni.$emit('refreshHealthFiles');
  435. uni.navigateBack({
  436. delta: 1
  437. })
  438. }, 500);
  439. } else {
  440. uni.showToast({
  441. icon: 'none',
  442. title: res.msg,
  443. });
  444. }
  445. },
  446. rej => {}
  447. );
  448. },
  449. addDoc() {
  450. addDoc(this.form).then(
  451. res => {
  452. if (res.code == 200) {
  453. uni.showToast({
  454. icon: 'success',
  455. title: "操作成功",
  456. });
  457. setTimeout(function() {
  458. uni.$emit('refreshHealthFiles');
  459. uni.navigateBack({
  460. delta: 1
  461. })
  462. }, 500);
  463. } else {
  464. uni.showToast({
  465. icon: 'none',
  466. title: res.msg,
  467. });
  468. }
  469. },
  470. rej => {}
  471. );
  472. },
  473. // 出生日期选择
  474. bindDateChange: function(e) {
  475. this.form.birthdate = e.target.value
  476. },
  477. }
  478. }
  479. </script>
  480. <style lang="scss">
  481. page {
  482. height: 100%;
  483. }
  484. .content {
  485. height: 100%;
  486. display: flex;
  487. flex-direction: column;
  488. justify-content: space-between;
  489. .inner {
  490. // height: calc(100% - 120upx);
  491. padding: 20upx;
  492. .form-box {
  493. padding: 0 30upx;
  494. background: #FFFFFF;
  495. border-radius: 16upx;
  496. margin-bottom: 20upx;
  497. .form-title {
  498. font-family: PingFang SC;
  499. font-weight: 600;
  500. font-size: 40rpx;
  501. color: #222426;
  502. text-align: left;
  503. padding: 30rpx 0;
  504. display: block;
  505. }
  506. .form-item {
  507. padding: 30upx 0;
  508. display: flex;
  509. align-items: flex-start;
  510. border-bottom: 1px solid #F1F1F1;
  511. &:last-child {
  512. border-bottom: none;
  513. }
  514. .label {
  515. width: 150upx;
  516. text-align: left;
  517. font-size: 32upx;
  518. line-height: 44upx;
  519. font-family: PingFang SC;
  520. font-weight: 500;
  521. color: #222222;
  522. flex-shrink: 0;
  523. }
  524. input {
  525. text-align: left;
  526. }
  527. .unit {
  528. width: 150upx;
  529. text-align: right;
  530. font-size: 32upx;
  531. line-height: 44upx;
  532. font-family: PingFang SC;
  533. font-weight: 500;
  534. color: #222222;
  535. flex-shrink: 0;
  536. }
  537. .form-input {
  538. font-size: 30upx;
  539. font-family: PingFang SC;
  540. font-weight: 500;
  541. color: #999999;
  542. text-align: left;
  543. }
  544. .form-item-tag {
  545. margin-right: 16rpx;
  546. .tag {
  547. border-radius: 8rpx 8rpx 8rpx 8rpx;
  548. border: 2rpx solid #ECECEC;
  549. display: flex;
  550. align-items: center;
  551. padding: 24rpx;
  552. font-family: PingFang SC;
  553. font-weight: 400;
  554. font-size: 24rpx;
  555. &.active {
  556. background: #F0FAFF;
  557. border: 2rpx solid #008FD3;
  558. color: #008FD3;
  559. }
  560. }
  561. }
  562. }
  563. }
  564. }
  565. .btn-box {
  566. height: 120upx;
  567. padding: 0 30upx;
  568. display: flex;
  569. align-items: center;
  570. justify-content: center;
  571. // position: fixed;
  572. // width: 90%;
  573. // bottom: 0;
  574. // left: 50%;
  575. // transform: translate(-50%,-50%);
  576. // background: #FFFFFF;
  577. .sub-btn {
  578. width: 100%;
  579. height: 88upx;
  580. line-height: 88upx;
  581. text-align: center;
  582. font-size: 32upx;
  583. font-family: PingFang SC;
  584. font-weight: bold;
  585. color: #FFFFFF;
  586. background: #008FD3;
  587. border-radius: 44upx;
  588. margin-bottom: 40upx;
  589. }
  590. }
  591. }
  592. </style>