info.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="content">
  3. <view class="self-inf">
  4. <view class="img-title-box">
  5. <view class="title">我的资料</view>
  6. </view>
  7. </view>
  8. <view class="example">
  9. <!-- 基础表单校验 -->
  10. <uni-forms ref="valiForm" :rules="rules" :modelValue="baseFormData">
  11. <uni-forms-item label="姓名" name="name" box-width="175rpx">
  12. <uni-easyinput :value="baseFormData.name" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled />
  13. </uni-forms-item>
  14. <uni-forms-item label="电话" name="phone" box-width="175rpx">
  15. <uni-easyinput type="number" :value="baseFormData.phone" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled/>
  16. </uni-forms-item>
  17. <uni-forms-item label="性别" box-width="175rpx">
  18. <uni-data-checkbox v-model="baseFormData.sex" :localdata="selectData.sex" :wrap="true" disabled/>
  19. </uni-forms-item>
  20. <uni-forms-item label="年龄" name="age" box-width="175rpx">
  21. <uni-easyinput type="number" :value="baseFormData.age" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled />
  22. </uni-forms-item>
  23. <uni-forms-item label="身高(cm)" name="height" box-width="175rpx">
  24. <uni-easyinput type="number" :value="baseFormData.height" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled />
  25. </uni-forms-item>
  26. <uni-forms-item label="体重(kg)" name="weight" box-width="175rpx">
  27. <uni-easyinput type="number" :value="baseFormData.weight" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled />
  28. </uni-forms-item>
  29. <uni-forms-item label="婚姻" name="marriage" box-width="175rpx">
  30. <uni-data-select v-model="baseFormData.marriage" disabled :localdata="selectData.marriage"></uni-data-select>
  31. </uni-forms-item>
  32. <uni-forms-item label="有无孩子" name="has_children" box-width="175rpx">
  33. <uni-data-checkbox v-model="baseFormData.has_children" :localdata="yesNoOptions" :wrap="true" disabled/>
  34. </uni-forms-item>
  35. <uni-forms-item label="孩子年龄" name="children_age" box-width="175rpx" v-if="baseFormData.has_children === 1">
  36. <uni-easyinput type="number" :value="baseFormData.children_age" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled />
  37. </uni-forms-item>
  38. <uni-forms-item label="职业" name="profession" box-width="175rpx">
  39. <uni-data-select v-model="baseFormData.profession" disabled :localdata="selectData.profession"></uni-data-select>
  40. </uni-forms-item>
  41. <uni-forms-item label="工作地点" name="work_address" box-width="175rpx" v-if="isTeacher">
  42. <uni-data-checkbox v-model="baseFormData.work_address" :localdata="workplaceOptions" :wrap="true" disabled/>
  43. </uni-forms-item>
  44. <uni-forms-item label="目前最主要的症状" name="main_symptom" box-width="175rpx">
  45. <uni-easyinput :value="baseFormData.main_symptom" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled />
  46. </uni-forms-item>
  47. <uni-forms-item label="持续时间(月)" name="symptom_duration" box-width="175rpx">
  48. <uni-easyinput type="number" :value="baseFormData.symptom_duration" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled />
  49. </uni-forms-item>
  50. <uni-forms-item label="就诊类型" name="type" box-width="175rpx">
  51. <uni-data-select v-model="baseFormData.type" disabled :localdata="selectData.type"></uni-data-select>
  52. </uni-forms-item>
  53. <uni-forms-item label="就诊医院" name="hospital_id" box-width="175rpx">
  54. <uni-data-select v-model="baseFormData.hospital_id" disabled :localdata="selectData.hospital"></uni-data-select>
  55. </uni-forms-item>
  56. <uni-forms-item label="就诊医生" name="doctor_id" box-width="175rpx">
  57. <uni-data-select v-model="baseFormData.doctor_id" disabled :localdata="doctorRange"></uni-data-select>
  58. </uni-forms-item>
  59. <uni-forms-item label="ID号" name="code" box-width="175rpx">
  60. <uni-easyinput :value="baseFormData.code" :styles="{fontSize:'14px',disableColor: '#f5f7fa', borderColor:'#e5e5e5'}" disabled />
  61. </uni-forms-item>
  62. </uni-forms>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import { request, currentOpenId } from '@/utils/request.js'
  68. // 和 history.vue 保持一致:这几组选项后台 get_case_select 目前没有提供,先在前端写死
  69. const YES_NO_OPTIONS = [{ value: 1, text: '有' }, { value: 0, text: '无' }]
  70. const WORKPLACE_OPTIONS = [
  71. { value: 1, text: '幼儿园' }, { value: 2, text: '小学' }, { value: 3, text: '初中' },
  72. { value: 4, text: '高中' }, { value: 5, text: '大学' },
  73. ]
  74. export default {
  75. data() {
  76. return {
  77. isAuth: true,
  78. isWith:0,
  79. // 基础表单数据
  80. baseFormData: {
  81. name: "",
  82. phone: "",
  83. sex: 1,
  84. age: "",
  85. height: "",
  86. weight: "",
  87. marriage: 1,
  88. has_children: 0,
  89. children_age: "",
  90. profession: 1,
  91. work_address: "",
  92. main_symptom: "",
  93. symptom_duration: "",
  94. type: 1,
  95. hospital_id: 1,
  96. hospital_name: "",
  97. doctor_id: 1,
  98. doctor_name: "",
  99. code: "",
  100. },
  101. selectData:{
  102. sex: [],
  103. profession: [],
  104. marriage: [],
  105. type: [],
  106. hospital: [],
  107. },
  108. doctorRange: [],
  109. yesNoOptions: YES_NO_OPTIONS,
  110. workplaceOptions: WORKPLACE_OPTIONS,
  111. };
  112. },
  113. computed: {
  114. isTeacher() {
  115. const item = this.selectData.profession.find(item => item.value === this.baseFormData.profession)
  116. return !!(item && item.text.includes('教师'))
  117. }
  118. },
  119. onLoad() {
  120. this.getUserHis();
  121. },
  122. methods: {
  123. async getUserHis() {
  124. const res = await request('user', 'get_case_info', { openId: currentOpenId() })
  125. if (res.code === 200) {
  126. // 用合并而不是整体替换,后台还没实现的新字段会保留 data() 里的默认值,不会变成 undefined(跟 history.vue 一致)
  127. this.baseFormData = Object.assign({}, this.baseFormData, res.data);
  128. // 后台没填过的选择类字段存的是字符串 "0"(或者字段压根不存在),选项列表都是从 value:1 开始编号,
  129. // 统一兜底成 1,否则这几个只读下拉会显示空白
  130. ['sex','profession','marriage','type','hospital_id','doctor_id'].forEach((key)=>{
  131. if (!this.baseFormData[key] || this.baseFormData[key] == '0') this.baseFormData[key] = 1
  132. this.baseFormData[key] = Number(this.baseFormData[key])
  133. })
  134. if (this.baseFormData.work_address == null || this.baseFormData.work_address == undefined) this.baseFormData.work_address = ''
  135. this.getUserSelect();
  136. }
  137. },
  138. async getUserSelect() {
  139. const res = await request('user', 'get_case_select', { openId: currentOpenId() })
  140. if (res.code === 200) {
  141. this.selectData = Object.assign({}, this.selectData, res.data);
  142. this.getDoctor(this.baseFormData.hospital_id)
  143. }
  144. },
  145. async getDoctor(hosId) {
  146. const res = await request('user', 'get_doctor_select', { hospital_id: hosId })
  147. if (res.code === 200) {
  148. this.doctorRange = this.objToArr(res.data);
  149. }
  150. },
  151. objToArr(data){
  152. let obj = data;
  153. let arr = [];
  154. for(let key in obj) {
  155. let child = {
  156. text : obj[key],
  157. value: Number(key)
  158. }
  159. arr.push(child)
  160. }
  161. return arr;
  162. },
  163. },
  164. };
  165. </script>
  166. <style lang="scss" scoped>
  167. .content {
  168. display: flex;
  169. flex-direction: column;
  170. .self-inf {
  171. height: 400rpx;
  172. width: 100%;
  173. background-image: url('/static/common-header-bg.jpg');
  174. background-size: contain;
  175. background-repeat: no-repeat;
  176. .img-title-box {
  177. display: flex;
  178. flex-direction: column;
  179. padding: 50rpx;
  180. .title {
  181. font-size: 32rpx;
  182. font-weight: bold;
  183. color: #000;
  184. }
  185. }
  186. }
  187. }
  188. .fontGrey {
  189. color: $uni-text-color-grey;
  190. }
  191. .example {
  192. padding: 15px;
  193. background-color: #fff;
  194. }
  195. </style>