caseCollection.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view class="container">
  3. <!-- 状态栏占位 -->
  4. <view class="status-bar" :style="{height: statusBarHeight}"></view>
  5. <!-- 顶部导航栏 -->
  6. <view class="header">
  7. <view class="back-btn" @click="goBack">
  8. <image src="@/static/image/back.png" mode="aspectFill"></image>
  9. </view>
  10. <view class="title">病例征集</view>
  11. <view class="header-right">
  12. <text class="more-icon">⋯</text>
  13. <text class="more-icon">○</text>
  14. </view>
  15. </view>
  16. <scroll-view class="content" scroll-y>
  17. <!-- 表单标题 -->
  18. <view class="form-header">
  19. <view class="form-title">{{ formData.title }}</view>
  20. <view class="form-tips">
  21. <view class="tip-item">请您根据患者真实情况选择并填写</view>
  22. <view class="tip-item">我们承诺对您及患者所提供的所有信息严格保密</view>
  23. </view>
  24. </view>
  25. <!-- 表单内容 -->
  26. <view class="form-section">
  27. <!-- 患者姓名 -->
  28. <view class="form-item">
  29. <view class="form-label">
  30. <text class="required">*</text>
  31. <text>1、患者姓名</text>
  32. </view>
  33. <input
  34. class="form-input"
  35. v-model="formData.patientName"
  36. placeholder="请输入患者姓名"
  37. />
  38. </view>
  39. <!-- 患者性别 -->
  40. <view class="form-item">
  41. <view class="form-label">
  42. <text class="required">*</text>
  43. <text>2、患者性别</text>
  44. </view>
  45. <view class="radio-group">
  46. <view
  47. class="radio-item"
  48. :class="{ active: formData.patientGender === 'male' }"
  49. @click="formData.patientGender = 'male'">
  50. <view class="radio-icon">
  51. <text v-if="formData.patientGender === 'male'">✓</text>
  52. </view>
  53. <text>男</text>
  54. </view>
  55. <view
  56. class="radio-item"
  57. :class="{ active: formData.patientGender === 'female' }"
  58. @click="formData.patientGender = 'female'">
  59. <view class="radio-icon">
  60. <text v-if="formData.patientGender === 'female'">✓</text>
  61. </view>
  62. <text>女</text>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 患者年龄 -->
  67. <view class="form-item">
  68. <view class="form-label">
  69. <text class="required">*</text>
  70. <text>3、患者年龄</text>
  71. </view>
  72. <input
  73. class="form-input"
  74. v-model="formData.patientAge"
  75. type="number"
  76. placeholder="请输入患者年龄 (岁)"
  77. />
  78. </view>
  79. <!-- 处方日期 -->
  80. <view class="form-item">
  81. <view class="form-label">
  82. <text class="required">*</text>
  83. <text>4、处方日期</text>
  84. </view>
  85. <picker mode="date" :value="formData.prescriptionDate" @change="onDateChange">
  86. <view class="form-input picker-input" :class="{ placeholder: !formData.prescriptionDate }">
  87. {{ formData.prescriptionDate || '请选择处方日期' }}
  88. <text class="calendar-icon">📅</text>
  89. </view>
  90. </picker>
  91. </view>
  92. <!-- 心脏病类型 -->
  93. <view class="form-item">
  94. <view class="form-label">
  95. <text class="required">*</text>
  96. <text>5、您被诊断的心脏病类型 (多选)</text>
  97. </view>
  98. <view class="checkbox-group">
  99. <view
  100. class="checkbox-item"
  101. :class="{ active: formData.diseaseTypes.includes('coronary') }"
  102. @click="toggleDiseaseType('coronary')">
  103. <view class="checkbox-icon">
  104. <text v-if="formData.diseaseTypes.includes('coronary')">✓</text>
  105. </view>
  106. <text>冠心病</text>
  107. </view>
  108. <view
  109. class="checkbox-item"
  110. :class="{ active: formData.diseaseTypes.includes('heartFailure') }"
  111. @click="toggleDiseaseType('heartFailure')">
  112. <view class="checkbox-icon">
  113. <text v-if="formData.diseaseTypes.includes('heartFailure')">✓</text>
  114. </view>
  115. <text>心力衰竭</text>
  116. </view>
  117. <view
  118. class="checkbox-item"
  119. :class="{ active: formData.diseaseTypes.includes('arrhythmia') }"
  120. @click="toggleDiseaseType('arrhythmia')">
  121. <view class="checkbox-icon">
  122. <text v-if="formData.diseaseTypes.includes('arrhythmia')">✓</text>
  123. </view>
  124. <text>心律失常</text>
  125. </view>
  126. </view>
  127. </view>
  128. <!-- 图片上传 -->
  129. <view class="form-item">
  130. <view class="form-label">
  131. <text class="required">*</text>
  132. <text>6、图片上传</text>
  133. </view>
  134. <view class="upload-section">
  135. <view class="upload-item" v-for="(image, index) in formData.images" :key="index">
  136. <image class="uploaded-image" :src="image" mode="aspectFill"></image>
  137. <view class="delete-btn" @click="removeImage(index)">×</view>
  138. </view>
  139. <view class="upload-item upload-placeholder" @click="chooseImage" v-if="formData.images.length < 2">
  140. <text class="camera-icon">📷</text>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </scroll-view>
  146. <!-- 提交按钮 -->
  147. <view class="submit-btn" @click="handleSubmit">提交</view>
  148. </view>
  149. </template>
  150. <script>
  151. import { submitCaseCollection } from '@/api-js/medicationSurvey'
  152. export default {
  153. data() {
  154. return {
  155. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  156. activityId: '',
  157. formData: {
  158. title: '心脏相关疾病病例征集表',
  159. patientName: '',
  160. patientGender: 'male',
  161. patientAge: '',
  162. prescriptionDate: '',
  163. diseaseTypes: ['coronary', 'heartFailure'],
  164. images: []
  165. }
  166. }
  167. },
  168. onLoad(options) {
  169. if (options.activityId) {
  170. this.activityId = options.activityId
  171. }
  172. },
  173. methods: {
  174. goBack() {
  175. uni.navigateBack()
  176. },
  177. onDateChange(e) {
  178. this.formData.prescriptionDate = e.detail.value
  179. },
  180. toggleDiseaseType(type) {
  181. const index = this.formData.diseaseTypes.indexOf(type)
  182. if (index > -1) {
  183. this.formData.diseaseTypes.splice(index, 1)
  184. } else {
  185. this.formData.diseaseTypes.push(type)
  186. }
  187. },
  188. chooseImage() {
  189. uni.chooseImage({
  190. count: 2 - this.formData.images.length,
  191. sizeType: ['compressed'],
  192. sourceType: ['album', 'camera'],
  193. success: (res) => {
  194. this.formData.images = [...this.formData.images, ...res.tempFilePaths]
  195. }
  196. })
  197. },
  198. removeImage(index) {
  199. this.formData.images.splice(index, 1)
  200. },
  201. async handleSubmit() {
  202. // 表单验证
  203. if (!this.formData.patientName) {
  204. uni.showToast({
  205. icon: 'none',
  206. title: '请输入患者姓名'
  207. })
  208. return
  209. }
  210. if (!this.formData.patientAge) {
  211. uni.showToast({
  212. icon: 'none',
  213. title: '请输入患者年龄'
  214. })
  215. return
  216. }
  217. if (!this.formData.prescriptionDate) {
  218. uni.showToast({
  219. icon: 'none',
  220. title: '请选择处方日期'
  221. })
  222. return
  223. }
  224. if (this.formData.diseaseTypes.length === 0) {
  225. uni.showToast({
  226. icon: 'none',
  227. title: '请至少选择一种心脏病类型'
  228. })
  229. return
  230. }
  231. if (this.formData.images.length === 0) {
  232. uni.showToast({
  233. icon: 'none',
  234. title: '请至少上传一张图片'
  235. })
  236. return
  237. }
  238. try {
  239. uni.showLoading({ title: '提交中...' })
  240. const res = await submitCaseCollection({
  241. activityId: this.activityId,
  242. ...this.formData
  243. })
  244. uni.hideLoading()
  245. if (res.code === 200) {
  246. uni.showToast({
  247. icon: 'success',
  248. title: '提交成功'
  249. })
  250. setTimeout(() => {
  251. uni.navigateBack()
  252. }, 1500)
  253. } else {
  254. uni.showToast({
  255. icon: 'none',
  256. title: res.msg || '提交失败'
  257. })
  258. }
  259. } catch (e) {
  260. uni.hideLoading()
  261. uni.showToast({
  262. icon: 'none',
  263. title: '提交失败'
  264. })
  265. }
  266. }
  267. }
  268. }
  269. </script>
  270. <style lang="scss" scoped>
  271. .container {
  272. min-height: 100vh;
  273. background: linear-gradient(180deg, #E6F3FF 0%, #FFFFFF 100%);
  274. display: flex;
  275. flex-direction: column;
  276. }
  277. .status-bar {
  278. width: 100%;
  279. background: transparent;
  280. }
  281. .header {
  282. position: relative;
  283. height: 88rpx;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. background: transparent;
  288. .back-btn {
  289. position: absolute;
  290. left: 24rpx;
  291. width: 40rpx;
  292. height: 40rpx;
  293. image {
  294. width: 100%;
  295. height: 100%;
  296. }
  297. }
  298. .title {
  299. font-size: 36rpx;
  300. font-weight: bold;
  301. color: #333;
  302. }
  303. .header-right {
  304. position: absolute;
  305. right: 24rpx;
  306. display: flex;
  307. align-items: center;
  308. gap: 16rpx;
  309. .more-icon {
  310. font-size: 32rpx;
  311. color: #333;
  312. }
  313. }
  314. }
  315. .content {
  316. flex: 1;
  317. padding: 24rpx;
  318. }
  319. .form-header {
  320. margin-bottom: 32rpx;
  321. .form-title {
  322. font-size: 36rpx;
  323. font-weight: bold;
  324. color: #333;
  325. margin-bottom: 16rpx;
  326. }
  327. .form-tips {
  328. .tip-item {
  329. font-size: 24rpx;
  330. color: #666;
  331. margin-bottom: 8rpx;
  332. }
  333. }
  334. }
  335. .form-section {
  336. background: #fff;
  337. border-radius: 16rpx;
  338. padding: 24rpx;
  339. }
  340. .form-item {
  341. margin-bottom: 32rpx;
  342. &:last-child {
  343. margin-bottom: 0;
  344. }
  345. .form-label {
  346. display: flex;
  347. align-items: center;
  348. font-size: 28rpx;
  349. color: #333;
  350. margin-bottom: 16rpx;
  351. .required {
  352. color: #FF5030;
  353. margin-right: 4rpx;
  354. }
  355. }
  356. .form-input {
  357. width: 100%;
  358. height: 80rpx;
  359. padding: 0 24rpx;
  360. background: #f5f5f5;
  361. border-radius: 8rpx;
  362. font-size: 28rpx;
  363. color: #333;
  364. &.placeholder {
  365. color: #999;
  366. }
  367. &.picker-input {
  368. display: flex;
  369. align-items: center;
  370. justify-content: space-between;
  371. .calendar-icon {
  372. font-size: 32rpx;
  373. }
  374. }
  375. }
  376. .radio-group,
  377. .checkbox-group {
  378. display: flex;
  379. gap: 24rpx;
  380. .radio-item,
  381. .checkbox-item {
  382. display: flex;
  383. align-items: center;
  384. gap: 8rpx;
  385. font-size: 28rpx;
  386. color: #333;
  387. .radio-icon,
  388. .checkbox-icon {
  389. width: 40rpx;
  390. height: 40rpx;
  391. border: 2rpx solid #ddd;
  392. border-radius: 50%;
  393. display: flex;
  394. align-items: center;
  395. justify-content: center;
  396. font-size: 24rpx;
  397. color: #388BFF;
  398. }
  399. .checkbox-icon {
  400. border-radius: 4rpx;
  401. }
  402. &.active {
  403. .radio-icon,
  404. .checkbox-icon {
  405. border-color: #388BFF;
  406. background: #E6F7FF;
  407. }
  408. }
  409. }
  410. }
  411. .upload-section {
  412. display: flex;
  413. gap: 16rpx;
  414. flex-wrap: wrap;
  415. .upload-item {
  416. width: 200rpx;
  417. height: 200rpx;
  418. border-radius: 8rpx;
  419. overflow: hidden;
  420. position: relative;
  421. .uploaded-image {
  422. width: 100%;
  423. height: 100%;
  424. }
  425. .delete-btn {
  426. position: absolute;
  427. top: 8rpx;
  428. right: 8rpx;
  429. width: 40rpx;
  430. height: 40rpx;
  431. background: rgba(0, 0, 0, 0.5);
  432. border-radius: 50%;
  433. display: flex;
  434. align-items: center;
  435. justify-content: center;
  436. font-size: 32rpx;
  437. color: #fff;
  438. }
  439. &.upload-placeholder {
  440. background: #f5f5f5;
  441. display: flex;
  442. align-items: center;
  443. justify-content: center;
  444. .camera-icon {
  445. font-size: 60rpx;
  446. }
  447. }
  448. }
  449. }
  450. }
  451. .submit-btn {
  452. position: fixed;
  453. bottom: 0;
  454. left: 0;
  455. right: 0;
  456. height: 88rpx;
  457. background: #388BFF;
  458. display: flex;
  459. align-items: center;
  460. justify-content: center;
  461. font-size: 32rpx;
  462. color: #fff;
  463. font-weight: 500;
  464. z-index: 100;
  465. }
  466. </style>