questionnaireForm.vue 11 KB

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