caseCollection.vue 9.3 KB

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