patient-filing.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <CustomNav title="患者建档信息" leftType="home" />
  3. <view class="complete-container">
  4. <view class="form-section">
  5. <text class="section-title">患者建档信息</text>
  6. <!-- 吸烟饮酒史 -->
  7. <view class="form-item">
  8. <text class="label">吸烟史</text>
  9. <picker mode="selector" :range="smokingOptions" :value="smokingIndex" range-key="label" @change="onSmokingChange">
  10. <view class="picker">{{ smokingSelected ? smokingOptions[smokingIndex]?.label : '请点击选择' }}</view>
  11. </picker>
  12. </view>
  13. <view class="form-item">
  14. <text class="label">饮酒史</text>
  15. <picker mode="selector" :range="drinkingOptions" :value="drinkingIndex" range-key="label" @change="onDrinkingChange">
  16. <view class="picker">{{ drinkingSelected ? drinkingOptions[drinkingIndex]?.label : '请点击选择' }}</view>
  17. </picker>
  18. </view>
  19. <!-- 疾病诊断 -->
  20. <view class="form-item">
  21. <text class="label">疾病诊断</text>
  22. <view class="disease-list">
  23. <view class="disease-item" v-for="disease in diseases" :key="disease.key">
  24. <text class="disease-label">{{ disease.label }}</text>
  25. <switch :checked="diseaseHistory[disease.key]" @change="(e: any) => toggleDisease(disease.key, e.detail.value)" />
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 用药情况 -->
  30. <view class="form-item">
  31. <text class="label">用药情况</text>
  32. <textarea
  33. v-model="medicationHistory"
  34. placeholder="请输入用药情况"
  35. class="input"
  36. />
  37. </view>
  38. <!-- 过敏史 -->
  39. <view class="form-item">
  40. <view class="switch-row">
  41. <text class="label">过敏史</text>
  42. <switch :checked="hasAllergy" @change="(e: any) => hasAllergy = e.detail.value" />
  43. </view>
  44. <view v-if="hasAllergy" class="input-container">
  45. <textarea
  46. v-model="allergyHistory"
  47. placeholder="请输入过敏史"
  48. class="input"
  49. />
  50. </view>
  51. </view>
  52. <!-- 家族史 -->
  53. <view class="form-item">
  54. <view class="switch-row">
  55. <text class="label">家族史</text>
  56. <switch :checked="hasFamilyHistory" @change="(e: any) => hasFamilyHistory = e.detail.value" />
  57. </view>
  58. <view v-if="hasFamilyHistory" class="input-container">
  59. <textarea
  60. v-model="familyHistory"
  61. placeholder="请输入家族史"
  62. class="input"
  63. />
  64. </view>
  65. </view>
  66. <!-- 提交按钮 -->
  67. <view class="submit-section">
  68. <button class="submit-btn" @click="submitForm">提交</button>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script setup lang="ts">
  74. import { ref } from 'vue'
  75. import CustomNav from '@/components/custom-nav.vue'
  76. // 吸烟选项
  77. const smokingOptions = [
  78. { label: '否', value: 'no' },
  79. { label: '偶尔(吸烟<1包/周)', value: 'occasional' },
  80. { label: '经常', value: 'frequent' }
  81. ]
  82. // 饮酒选项
  83. const drinkingOptions = [
  84. { label: '否', value: 'no' },
  85. { label: '偶尔(饮酒<1次/周)', value: 'occasional' },
  86. { label: '经常', value: 'frequent' }
  87. ]
  88. // 疾病列表
  89. const diseases = [
  90. { key: 'diabetes', label: '糖尿病' },
  91. { key: 'hypertension', label: '高血压' },
  92. { key: 'dyslipidemia', label: '血脂异常' },
  93. { key: 'coronaryHeartDisease', label: '冠心病' },
  94. { key: 'cerebralInfarction', label: '脑梗塞' }
  95. ]
  96. // 响应式数据
  97. const smokingHistory = ref('')
  98. const drinkingHistory = ref('')
  99. const smokingIndex = ref(0)
  100. const drinkingIndex = ref(0)
  101. const smokingSelected = ref(false)
  102. const drinkingSelected = ref(false)
  103. const diseaseHistory = ref<Record<string, boolean>>({
  104. diabetes: false,
  105. hypertension: false,
  106. dyslipidemia: false,
  107. coronaryHeartDisease: false,
  108. cerebralInfarction: false
  109. })
  110. const medicationHistory = ref('')
  111. const allergyHistory = ref('')
  112. const familyHistory = ref('')
  113. const hasAllergy = ref(false)
  114. const hasFamilyHistory = ref(false)
  115. // 切换疾病状态
  116. const toggleDisease = (key: string, value: boolean) => {
  117. diseaseHistory.value[key] = value
  118. }
  119. // picker change事件处理
  120. const onSmokingChange = (e: any) => {
  121. smokingIndex.value = e.detail.value
  122. smokingHistory.value = smokingOptions[smokingIndex.value].value
  123. smokingSelected.value = true
  124. }
  125. const onDrinkingChange = (e: any) => {
  126. drinkingIndex.value = e.detail.value
  127. drinkingHistory.value = drinkingOptions[drinkingIndex.value].value
  128. drinkingSelected.value = true
  129. }
  130. // 提交表单
  131. const submitForm = () => {
  132. const formData = {
  133. smokingHistory: smokingHistory.value,
  134. drinkingHistory: drinkingHistory.value,
  135. diseaseHistory: diseaseHistory.value,
  136. medicationHistory: medicationHistory.value,
  137. allergyHistory: hasAllergy.value ? allergyHistory.value : '',
  138. familyHistory: hasFamilyHistory.value ? familyHistory.value : ''
  139. }
  140. console.log('提交的表单数据:', formData)
  141. // 这里可以添加提交逻辑,比如调用API
  142. uni.showToast({
  143. title: '提交成功',
  144. icon: 'success'
  145. })
  146. }
  147. </script>
  148. <style>
  149. .complete-container {
  150. min-height: 100vh;
  151. /* 为固定在顶部的 CustomNav 留出空间(状态栏 + 导航栏 44px) */
  152. padding-top: calc(var(--status-bar-height) + 44px + 40rpx);
  153. /* 保留侧边与内部间距,使用 border-box 避免计算误差 */
  154. padding-right: 40rpx;
  155. padding-left: 40rpx;
  156. /* 底部安全区:使用项目中声明的 --window-bottom 或 fallback */
  157. padding-bottom: calc(var(--window-bottom, 0px) + 40rpx);
  158. box-sizing: border-box;
  159. background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  160. display: flex;
  161. flex-direction: column;
  162. align-items: center;
  163. justify-content: center;
  164. }
  165. .form-section {
  166. background-color: #fff;
  167. border-radius: 20rpx;
  168. padding: 40rpx;
  169. width: 100%;
  170. max-width: 600rpx;
  171. box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
  172. }
  173. .section-title {
  174. font-size: 36rpx;
  175. font-weight: bold;
  176. color: #333;
  177. margin-bottom: 40rpx;
  178. display: block;
  179. text-align: center;
  180. }
  181. .form-item {
  182. margin-bottom: 30rpx;
  183. }
  184. .label {
  185. display: block;
  186. font-size: 32rpx;
  187. color: #333;
  188. margin-bottom: 10rpx;
  189. }
  190. .radio-group {
  191. display: flex;
  192. flex-wrap: wrap;
  193. gap: 40rpx;
  194. margin-bottom: 20rpx;
  195. }
  196. .radio-item {
  197. display: flex;
  198. align-items: center;
  199. font-size: 32rpx;
  200. color: #333;
  201. }
  202. .disease-list {
  203. display: flex;
  204. flex-direction: column;
  205. gap: 20rpx;
  206. }
  207. .disease-item {
  208. display: flex;
  209. justify-content: space-between;
  210. align-items: center;
  211. padding: 20rpx;
  212. background-color: #f9f9f9;
  213. border-radius: 8rpx;
  214. }
  215. .disease-label {
  216. font-size: 32rpx;
  217. color: #333;
  218. }
  219. .input {
  220. width: 100%;
  221. height: 120rpx;
  222. border: 1rpx solid #ddd;
  223. border-radius: 8rpx;
  224. padding: 20rpx;
  225. font-size: 32rpx;
  226. box-sizing: border-box;
  227. max-width: 100%;
  228. }
  229. .picker {
  230. width: 100%;
  231. height: 80rpx;
  232. border: 1rpx solid #ddd;
  233. border-radius: 8rpx;
  234. padding: 0 20rpx;
  235. display: flex;
  236. align-items: center;
  237. font-size: 32rpx;
  238. color: #333;
  239. box-sizing: border-box;
  240. max-width: 100%;
  241. }
  242. .switch-row {
  243. display: flex;
  244. justify-content: space-between;
  245. align-items: center;
  246. margin-bottom: 10rpx;
  247. }
  248. .input-container {
  249. margin-top: 10rpx;
  250. }
  251. .submit-btn {
  252. width: 100%;
  253. background: linear-gradient(135deg, #07C160 0%, #00A854 100%);
  254. color: #fff;
  255. border-radius: 12rpx;
  256. font-size: 32rpx;
  257. line-height: 80rpx;
  258. border: none;
  259. }
  260. </style>