addDoc.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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/health.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.type = options.type;
  278. this.companyUserId = options.companyUserId;
  279. this.form.userId =options.userId;
  280. this.form.companyUserId = options.companyUserId;
  281. console.log(this.type)
  282. // if (this.type == 'edit') {
  283. this.getDoc();
  284. // }
  285. this.getDictByKey('other_medical_history')
  286. this.getDictByKey('medical_history')
  287. },
  288. methods: {
  289. sexChange(type) {
  290. this.form.sex = type
  291. },
  292. //血糖
  293. hyperglycemiaChange(e) {
  294. this.form.hyperglycemia = e
  295. },
  296. //血压
  297. hypertensionChange(e) {
  298. this.form.hypertension = e
  299. },
  300. //血脂
  301. hyperlipidemiaChange(e) {
  302. this.form.hyperlipidemia = e
  303. },
  304. //尿酸
  305. hyperuricemiaChange(e) {
  306. this.form.hyperuricemia = e
  307. },
  308. bodyWeightStatusChange(e) {
  309. this.form.bodyWeightStatus = e
  310. },
  311. tagsClick(item) {
  312. const index = this.checkedItems.indexOf(item.dictValue);
  313. if (index > -1) {
  314. // 如果已选中则移除
  315. this.checkedItems.splice(index, 1);
  316. } else {
  317. // 如果未选中则添加
  318. this.checkedItems.push(item.dictValue);
  319. this.text.push(item.dictLabel)
  320. }
  321. },
  322. catesClick(item) {
  323. const index = this.checkedItems2.indexOf(item.dictValue);
  324. if (index > -1) {
  325. // 如果已选中则移除
  326. this.checkedItems2.splice(index, 1);
  327. } else {
  328. // 如果未选中则添加
  329. this.checkedItems2.push(item.dictValue);
  330. this.text2.push(item.dictLabel)
  331. }
  332. },
  333. // 切换其他选项
  334. toggleOther() {
  335. this.otherSelected = !this.otherSelected;
  336. // 清空其他症状输入
  337. if (!this.otherSelected) {
  338. this.symptom = null;
  339. }
  340. },
  341. toggleOther2() {
  342. this.otherSelected2 = !this.otherSelected2;
  343. // 清空其他症状输入
  344. if (!this.otherSelected2) {
  345. this.symptom2 = null;
  346. }
  347. },
  348. getDictByKey(key) {
  349. var data = {
  350. key: key
  351. }
  352. getDictByKey(data).then(
  353. res => {
  354. if (res.code == 200) {
  355. if (key == "other_medical_history") {
  356. this.tags = res.data;
  357. }
  358. if (key == "medical_history") {
  359. this.cates = res.data;
  360. }
  361. }
  362. },
  363. err => {}
  364. );
  365. },
  366. getDoc() {
  367. var data = {
  368. userId: this.form.userId
  369. };
  370. getDoc(data).then(
  371. res => {
  372. if (res.code == 200) {
  373. if(res.data==null){
  374. this.type='add'
  375. }else{
  376. this.type='edit'
  377. this.form = res.data;
  378. }
  379. } else {
  380. uni.showToast({
  381. title: res.msg,
  382. });
  383. }
  384. },
  385. rej => {}
  386. );
  387. },
  388. submit() {
  389. if (this.form.height == null) {
  390. uni.showToast({
  391. icon: 'none',
  392. title: "身高不能为空",
  393. });
  394. return;
  395. }
  396. if (this.form.weight == null) {
  397. uni.showToast({
  398. icon: 'none',
  399. title: "体重不能为空",
  400. });
  401. return;
  402. }
  403. if (this.form.waistCircumference == null) {
  404. uni.showToast({
  405. icon: 'none',
  406. title: "腰围不能为空",
  407. });
  408. return;
  409. }
  410. if (this.form.hipCircumference == null) {
  411. uni.showToast({
  412. icon: 'none',
  413. title: "臀围不能为空",
  414. });
  415. return;
  416. }
  417. // console.log(this.text,'---')
  418. this.form.otherMedicalHistory = this.utils.joinWithSymptom(this.text, this.symptom)
  419. this.form.symptomHistory = this.utils.joinWithSymptom(this.text2, this.symptom2)
  420. if (this.type == "add") {
  421. this.addDoc()
  422. } else if (this.type == "edit") {
  423. this.editDoc()
  424. }
  425. },
  426. editDoc() {
  427. updateDoc(this.form).then(
  428. res => {
  429. if (res.code == 200) {
  430. uni.showToast({
  431. icon: 'success',
  432. title: "操作成功",
  433. });
  434. setTimeout(function() {
  435. uni.$emit('refreshHealthFiles');
  436. uni.navigateBack({
  437. delta: 1
  438. })
  439. }, 500);
  440. } else {
  441. uni.showToast({
  442. icon: 'none',
  443. title: res.msg,
  444. });
  445. }
  446. },
  447. rej => {}
  448. );
  449. },
  450. addDoc() {
  451. addDoc(this.form).then(
  452. res => {
  453. if (res.code == 200) {
  454. uni.showToast({
  455. icon: 'success',
  456. title: "操作成功",
  457. });
  458. setTimeout(function() {
  459. uni.$emit('refreshHealthFiles');
  460. uni.navigateBack({
  461. delta: 1
  462. })
  463. }, 500);
  464. } else {
  465. uni.showToast({
  466. icon: 'none',
  467. title: res.msg,
  468. });
  469. }
  470. },
  471. rej => {}
  472. );
  473. },
  474. // 出生日期选择
  475. bindDateChange: function(e) {
  476. this.form.birthdate = e.target.value
  477. },
  478. }
  479. }
  480. </script>
  481. <style lang="scss">
  482. page {
  483. height: 100%;
  484. }
  485. .content {
  486. height: 100%;
  487. display: flex;
  488. flex-direction: column;
  489. justify-content: space-between;
  490. .inner {
  491. // height: calc(100% - 120upx);
  492. padding: 20upx;
  493. .form-box {
  494. padding: 0 30upx;
  495. background: #FFFFFF;
  496. border-radius: 16upx;
  497. margin-bottom: 20upx;
  498. .form-title {
  499. font-family: PingFang SC;
  500. font-weight: 600;
  501. font-size: 40rpx;
  502. color: #222426;
  503. text-align: left;
  504. padding: 30rpx 0;
  505. display: block;
  506. }
  507. .form-item {
  508. padding: 30upx 0;
  509. display: flex;
  510. align-items: flex-start;
  511. border-bottom: 1px solid #F1F1F1;
  512. &:last-child {
  513. border-bottom: none;
  514. }
  515. .label {
  516. width: 150upx;
  517. text-align: left;
  518. font-size: 32upx;
  519. line-height: 44upx;
  520. font-family: PingFang SC;
  521. font-weight: 500;
  522. color: #222222;
  523. flex-shrink: 0;
  524. }
  525. input {
  526. text-align: left;
  527. }
  528. .unit {
  529. width: 150upx;
  530. text-align: right;
  531. font-size: 32upx;
  532. line-height: 44upx;
  533. font-family: PingFang SC;
  534. font-weight: 500;
  535. color: #222222;
  536. flex-shrink: 0;
  537. }
  538. .form-input {
  539. font-size: 30upx;
  540. font-family: PingFang SC;
  541. font-weight: 500;
  542. color: #999999;
  543. text-align: left;
  544. }
  545. .form-item-tag {
  546. margin-right: 16rpx;
  547. .tag {
  548. border-radius: 8rpx 8rpx 8rpx 8rpx;
  549. border: 2rpx solid #ECECEC;
  550. display: flex;
  551. align-items: center;
  552. padding: 24rpx;
  553. font-family: PingFang SC;
  554. font-weight: 400;
  555. font-size: 24rpx;
  556. &.active {
  557. background: #F0FAFF;
  558. border: 2rpx solid #008FD3;
  559. color: #008FD3;
  560. }
  561. }
  562. }
  563. }
  564. }
  565. }
  566. .btn-box {
  567. height: 120upx;
  568. padding: 0 30upx;
  569. display: flex;
  570. align-items: center;
  571. justify-content: center;
  572. // position: fixed;
  573. // width: 90%;
  574. // bottom: 0;
  575. // left: 50%;
  576. // transform: translate(-50%,-50%);
  577. // background: #FFFFFF;
  578. .sub-btn {
  579. width: 100%;
  580. height: 88upx;
  581. line-height: 88upx;
  582. text-align: center;
  583. font-size: 32upx;
  584. font-family: PingFang SC;
  585. font-weight: bold;
  586. color: #FFFFFF;
  587. background: #008FD3;
  588. border-radius: 44upx;
  589. margin-bottom: 40upx;
  590. }
  591. }
  592. }
  593. </style>