耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

499 lines
15 KiB

  1. <template>
  2. <view class="health-info">
  3. <!-- <view class="health-info-header font-30 text-black font-weight-bold m-b-40">健康信息</view> -->
  4. <view class="health-info-form">
  5. <view class="health-info-form-item" v-for="(item, index) in healthInfo" :key="index">
  6. <view class="flex align-center justify-between">
  7. <text class="font-32">{{ item.name }}</text>
  8. <u-radio-group v-model="item.value">
  9. <u-radio
  10. @change="radioChange(radioItem, item, index)"
  11. active-color="#01aeea"
  12. v-for="(radioItem, radioIndex) in item.radios" :key="radioIndex"
  13. :name="radioItem.name"
  14. :disabled="radioItem.disabled"
  15. >
  16. {{radioItem.name}}
  17. </u-radio>
  18. </u-radio-group>
  19. </view>
  20. <view v-if="item.isChild && item.showChild">
  21. <view class="flex align-center flex-wrap m-b-20">
  22. <view
  23. v-for="(subItem, subIndex) in item.child.otherList"
  24. @click="otherChange(item, subItem, subIndex)"
  25. :key="subIndex"
  26. :class="{'health-info-form-item-tag--active': subItem.checked}"
  27. class="font-30 health-info-form-item-tag flex align-center justify-center font-24 m-r-16 m-t-26"
  28. >
  29. {{ subItem.name }}
  30. </view>
  31. </view>
  32. <view>
  33. <text class="font-30 text-black">其他</text>
  34. <view class="health-info-form-item-textarea position-relative m-t-6 p-16">
  35. <u-input
  36. v-model="item.child.otherVal"
  37. type="textarea"
  38. placeholder="请补充您的过敏药物"
  39. :height="120"
  40. auto-height
  41. maxlength="200"
  42. />
  43. <view class="position-absolute health-info-form-item-textarea-num">
  44. {{ `${item.child.otherVal.length?item.child.otherVal.length:0}/${textareaMaxlen}`}}
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="health-info-footer position-fixed flex align-center justify-center">
  52. <u-button class="font-32" type="primary" shape="circle" @click="confirm">确定</u-button>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data () {
  59. return {
  60. textareaMaxlen: 200,
  61. healthInfo: [
  62. {
  63. name: '过往病史',
  64. value: '',
  65. isChild: true,
  66. showChild: false,
  67. radios: [
  68. {name: '有', disabled: false, value: '1'},
  69. {name: '无', disabled: false, value: '2'},
  70. ],
  71. child: {
  72. otherVal: '',
  73. select: [],
  74. otherList: []
  75. }
  76. },
  77. {
  78. name: '药物过敏史',
  79. value: '',
  80. isChild: true,
  81. showChild: false,
  82. radios: [
  83. {name: '有', disabled: false, value: '1'},
  84. {name: '无', disabled: false, value: '2'},
  85. ],
  86. child: {
  87. otherVal: '',
  88. select: [],
  89. otherList: []
  90. }
  91. },
  92. {
  93. name: '食物/接触过敏史',
  94. value: '',
  95. isChild: true,
  96. showChild: false,
  97. radios: [
  98. {name: '有', disabled: false, value: '1'},
  99. {name: '无', disabled: false, value: '2'},
  100. ],
  101. child: {
  102. otherVal: '',
  103. select: [],
  104. otherList: []
  105. }
  106. },
  107. {
  108. name: '家族遗传病史',
  109. value: '',
  110. isChild: true,
  111. showChild: false,
  112. radios: [
  113. {name: '有', disabled: false, value: '1'},
  114. {name: '无', disabled: false, value: '2'},
  115. ],
  116. child: {
  117. otherVal: '',
  118. select: [],
  119. otherList: []
  120. }
  121. },
  122. {
  123. name: '抽烟',
  124. value: '',
  125. isChild: false,
  126. showChild: false,
  127. radios: [
  128. {name: '有', disabled: false, value: '1'},
  129. {name: '无', disabled: false, value: '2'},
  130. ],
  131. child: {
  132. otherVal: '',
  133. select: [],
  134. otherList: []
  135. }
  136. },
  137. {
  138. name: '饮酒',
  139. value: '',
  140. isChild: false,
  141. showChild: false,
  142. radios: [
  143. {name: '有', disabled: false, value: '1'},
  144. {name: '无', disabled: false, value: '2'},
  145. ],
  146. child: {
  147. otherVal: '',
  148. select: [],
  149. otherList: []
  150. }
  151. },
  152. {
  153. name: '妊娠哺乳',
  154. value: '',
  155. isChild: false,
  156. showChild: false,
  157. radios: [
  158. {name: '有', disabled: false, value: '1'},
  159. {name: '无', disabled: false, value: '2'},
  160. ],
  161. child: {
  162. otherVal: '',
  163. select: [],
  164. otherList: []
  165. }
  166. },
  167. ],
  168. form: {}
  169. }
  170. },
  171. onLoad(options) {
  172. if(options.form){
  173. this.form = JSON.parse(options.form);
  174. console.log(this.form,"接受参数2")
  175. if(this.form.Id !== '') {
  176. this.editInfo(this.form);
  177. }
  178. }
  179. this.getAllergyList();
  180. },
  181. methods: {
  182. // 获取药品过敏信息列表
  183. getAllergyList(){
  184. this.$api('getAllergyList').then(res => {
  185. let {code, result, message} = res;
  186. if(code == 200) {
  187. console.log(result)
  188. result.forEach(item => {
  189. this.healthInfo.forEach(item2 =>{
  190. if(item2.name == item.name) {
  191. item.list.forEach(item3 => {
  192. item2.child.otherList.push({ name: item3.name, checked: false})
  193. })
  194. }
  195. })
  196. });
  197. if(this.form.Id !== '') {
  198. // 设置选中的标签
  199. this.selectOtherList(this.form);
  200. }
  201. }else{
  202. this.$Toast(message);
  203. }
  204. }).catch(err => {
  205. this.$Toast(err.message)
  206. })
  207. },
  208. radioChange(radioItem, item, index) {
  209. item.showChild = radioItem.value == 1 ? true : false
  210. // if()
  211. },
  212. otherChange(item, subItem, idx) {
  213. console.log(item, subItem, idx,111111111)
  214. item.child.otherList.forEach((obj, index) => {
  215. if(index === idx){
  216. console.log(obj.checked)
  217. obj.checked = !obj.checked
  218. if(obj.checked) {
  219. item.child.select.push(obj.name);
  220. }else{
  221. const newOtherVal = [...new Set(item.child.select)].filter(item => item !== obj.name)
  222. item.child.select = newOtherVal
  223. }
  224. }
  225. // obj[idx].checked = !obj[idx].checked;
  226. // if(obj[idx].checked){
  227. // // 添加
  228. // item.select.push(obj[idx].name);
  229. // }else {
  230. // // 删除
  231. // const newOtherVal = [...new Set(select)].filter(item => item !==obj[idx].name)
  232. // item.select = newOtherVal;
  233. // }
  234. // console.log(item);
  235. // obj.checked = index === idx ? true : false
  236. })
  237. // item.child.otherList.splict(idx, 1, { ...subItem, checked: true})
  238. console.log(subItem, idx)
  239. },
  240. // 修改信息
  241. editInfo(data) {
  242. // 过往病史是否有1有
  243. this.healthInfo[0].showChild = data.pastMedicalHistoryIs == 0? false: true;
  244. this.healthInfo[0].value= this.healthInfo[0].showChild? '有': '无'
  245. this.healthInfo[1].showChild = data.drugAllergyIs ==0? false: true;
  246. this.healthInfo[1].value= this.healthInfo[1].showChild? '有': '无'
  247. this.healthInfo[2].showChild = data.contactAllergy == 0? false: true;
  248. this.healthInfo[2].value= this.healthInfo[2].showChild? '有': '无'
  249. this.healthInfo[3].showChild = data.hereditaryDisease == 0? false: true;
  250. this.healthInfo[3].value= this.healthInfo[3].showChild? '有': '无'
  251. this.healthInfo[4].showChild = data.smoke == 0? false: true;
  252. this.healthInfo[4].value= this.healthInfo[4].showChild? '有': '无'
  253. // 过往病史其他
  254. this.healthInfo[0].child.otherVal = data.pastMedicalHistoryOther ;
  255. // 1药物过敏史
  256. // 药物过敏史其他
  257. this.healthInfo[1].child.otherVal = data.other;
  258. // 食物接触过敏史1有
  259. // 食物接触过敏史其他
  260. this.healthInfo[2].child.otherVal = data.contactAllergyOther;
  261. // 家族遗传病史1有
  262. // 家族遗传病其他
  263. this.healthInfo[3].child.otherVal = data.hereditaryDiseaseOther ;
  264. // 吸烟
  265. // 过往病史标签 药物过敏史标签 食物接触过敏史标签 家族遗传病标签
  266. this.healthInfo[0].child.select = (data.pastMedicalHistoryLabel && data.pastMedicalHistoryLabel !== '')?data.pastMedicalHistoryLabel.split(',') : [];
  267. this.healthInfo[1].child.select= (data.drugAllergyLabel && data.drugAllergyLabel !== '')? data.drugAllergyLabel.split(',') : [];
  268. this.healthInfo[2].child.select = (data.contactAllergyLabel && data.contactAllergyLabel !== '')? data.contactAllergyLabel.split(',') : [];
  269. this.healthInfo[3].child.select= (data.hereditaryDiseaseLabel && data.hereditaryDiseaseLabel !== '')? data.hereditaryDiseaseLabel.split(',') : [];
  270. },
  271. // 修改信息 选中的标签
  272. selectOtherList(data){
  273. // 过往病史标签 药物过敏史标签 食物接触过敏史标签 家族遗传病标签
  274. // debugger
  275. for(let i= 0; i<= this.healthInfo.length-1; i++){
  276. this.healthInfo[i].child.otherList.forEach(item => {
  277. this.healthInfo[i].child.select.forEach(item2 =>{
  278. if(item.name == item2) {
  279. item.checked = true;
  280. }
  281. })
  282. })
  283. }
  284. },
  285. // 处理选中的信息
  286. getUserSelectInfo () {
  287. // 过往病史是否有1有
  288. let pastMedicalHistoryIs,pastMedicalHistoryLabel,pastMedicalHistoryOther;
  289. this.healthInfo[0].showChild ? pastMedicalHistoryIs = 1: pastMedicalHistoryIs = 0
  290. // 过往病史标签
  291. pastMedicalHistoryLabel = this.healthInfo[0].child.select.toString();
  292. // 过往病史其他
  293. pastMedicalHistoryOther = this.healthInfo[0].child.otherVal;
  294. pastMedicalHistoryLabel = pastMedicalHistoryLabel + pastMedicalHistoryOther
  295. // 1药物过敏史
  296. let drugAllergyIs,drugAllergyLabel,other;
  297. this.healthInfo[1].showChild ? drugAllergyIs = 1: drugAllergyIs = 0
  298. // 药物过敏史标签
  299. drugAllergyLabel = this.healthInfo[1].child.select.toString();
  300. // 药物过敏史其他
  301. other = this.healthInfo[1].child.otherVal;
  302. drugAllergyLabel = drugAllergyLabel + other
  303. // 食物接触过敏史1有
  304. let contactAllergy,contactAllergyLabel,contactAllergyOther;
  305. this.healthInfo[2].showChild ? contactAllergy = 1: contactAllergy = 0
  306. // 食物接触过敏史标签
  307. contactAllergyLabel = this.healthInfo[2].child.select.toString();
  308. // 食物接触过敏史其他
  309. contactAllergyOther = this.healthInfo[2].child.otherVal;
  310. contactAllergyLabel = contactAllergyLabel + contactAllergyOther
  311. // 家族遗传病史1有
  312. let hereditaryDisease,hereditaryDiseaseLabel,hereditaryDiseaseOther;
  313. this.healthInfo[3].showChild ? hereditaryDisease = 1: hereditaryDisease = 0
  314. // 家族遗传病标签
  315. hereditaryDiseaseLabel = this.healthInfo[3].child.select.toString();
  316. // 家族遗传病其他
  317. hereditaryDiseaseOther = this.healthInfo[3].child.otherVal;
  318. hereditaryDiseaseLabel = hereditaryDiseaseLabel + hereditaryDiseaseOther
  319. let smoke;
  320. this.healthInfo[4].showChild ? smoke = 1: smoke = 0
  321. return {
  322. pastMedicalHistoryIs,pastMedicalHistoryLabel,
  323. drugAllergyIs,drugAllergyLabel,
  324. contactAllergy,contactAllergyLabel,
  325. hereditaryDisease,hereditaryDiseaseLabel,
  326. smoke
  327. }
  328. },
  329. isRules(item) {
  330. if(this.healthInfo[0].showChild && item.pastMedicalHistoryLabel=='') {
  331. return '请补充过往病史信息或选择往病史信息标签'
  332. }
  333. if(this.healthInfo[1].showChild && item.drugAllergyLabel=='') {
  334. return '请补充药物过敏史信息或选择药物过敏史标签'
  335. }
  336. if(this.healthInfo[2].showChild && item.contactAllergyLabel=='') {
  337. return '请补充食物接触过敏史信息或选择食物接触过敏史标签'
  338. }
  339. if(this.healthInfo[3].showChild && item.hereditaryDiseaseLabel=='') {
  340. return '请补充家族遗传病信息或选择家族遗传病标签'
  341. }
  342. return false
  343. },
  344. confirm () {
  345. console.log(this.healthInfo)
  346. // 处理选中的信息
  347. const userSelectInfo = this.getUserSelectInfo();
  348. if(this.isRules(userSelectInfo)) {
  349. this.$Toast(this.isRules(userSelectInfo));
  350. return
  351. }
  352. const params = {
  353. ...userSelectInfo,
  354. birthday: this.form.time,
  355. cardId: this.form.idCard,
  356. cardName: this.form.type,
  357. cardType: this.form.cardType,
  358. cardPhoto: this.form.idPhoto,
  359. cardPic: this.form.idPhotoImage,
  360. labelValue: this.form.relationship,
  361. name: this.form.name,
  362. phone: this.form.phone,
  363. sex: this.form.sex == '男'?1: 2,
  364. height: this.form.height,
  365. weight: this.form.weight,
  366. defaultIs: 0
  367. };
  368. if(this.form.Id !== '') {
  369. params.id = this.form.Id
  370. }
  371. // 将空的删除掉
  372. params.pastMedicalHistoryIs == '0'? delete params.pastMedicalHistoryLabel:''
  373. params.drugAllergyIs == '0'? delete params.drugAllergyLabel:''
  374. params.contactAllergy == '0'? delete params.contactAllergyLabel:''
  375. params.hereditaryDisease == '0'? delete params.hereditaryDiseaseLabel:''
  376. // 添加用药人
  377. this.$api('addDrugUser',params).then(res => {
  378. let {code, result, message} = res;
  379. if(code == 200) {
  380. if(this.form.typeName == 'noPrescription') {
  381. // 从无处方 -> 预约流程
  382. const medicineMan = JSON.stringify(result)
  383. setTimeout(()=> {
  384. this.$tools.navigateTo({
  385. url: `/pagesC/subscribe/confirmSubscribe?addressId=${params.Id}&medicineMan=${medicineMan}&goodsId=${params.goodsId}&num=${params.num}&price=${params.price}&goodSkuParam=${params.goodSkuParam}&prescriptionId=${params.prescriptionId}`
  386. })
  387. },1500)
  388. }else {
  389. // 修改 添加
  390. console.log(result);
  391. if(this.form.Id !== ''){
  392. this.$Toast('修改成功');
  393. setTimeout(()=> {
  394. // 修改 和 新增
  395. uni.navigateBack({
  396. delta: 3
  397. })
  398. },1500)
  399. }else{
  400. this.$Toast(result);
  401. setTimeout(()=> {
  402. // 修改 和 新增
  403. uni.navigateBack({
  404. delta: 3
  405. })
  406. },1500)
  407. }
  408. }
  409. }else {
  410. this.$Toast(message);
  411. }
  412. }).catch(err => {
  413. this.$Toast(err.message);
  414. })
  415. }
  416. }
  417. }
  418. </script>
  419. <style lang="scss" scoped>
  420. /deep/ .u-input__textarea{
  421. background-color: rgba(245,245,245,1) !important;
  422. }
  423. .health-info-form-item-textarea{
  424. background-color: rgba(245,245,245,1) !important;
  425. }
  426. /deep/ .u-input__input{
  427. font-size: 30rpx !important;
  428. }
  429. .health-info {
  430. padding: 20rpx 40rpx 160rpx;
  431. &-form {
  432. &-item {
  433. padding: 20rpx 0;
  434. border-bottom: 2rpx solid #d2d2d2;
  435. &-tag {
  436. padding: 0 15rpx;
  437. height: 50rpx;
  438. background: #E2E2E2;
  439. color: #1d1d1d;
  440. border-radius: 24rpx;
  441. &--active {
  442. background: #baebfc;
  443. color: #01aeea;
  444. }
  445. }
  446. &-textarea {
  447. background-color: #E2E2E2;
  448. border-radius: 10rpx;
  449. &-num {
  450. right: 26rpx;
  451. bottom: 4rpx;
  452. font-size: 24rpx;
  453. color: #b8b8b8;
  454. }
  455. }
  456. }
  457. }
  458. &-footer {
  459. z-index: 1;
  460. height: 120rpx;
  461. bottom: 0;
  462. left: 0;
  463. width: 100%;
  464. background: #fff;
  465. /deep/.u-btn {
  466. width: 660rpx;
  467. height: 80rpx;
  468. }
  469. }
  470. }
  471. </style>