| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- <template>
- <view class="container">
- <scroll-view class="content" scroll-y>
- <!-- 表单标题 -->
- <view class="form-header">
- <view class="form-title">{{ formData.title }}</view>
- <view class="form-tips">
- <view class="tip-item">请您根据患者真实情况选择并填写</view>
- <view class="tip-item">我们承诺对您及患者所提供的所有信息严格保密</view>
- </view>
- </view>
-
- <!-- 表单内容 -->
- <view class="form-section">
- <!-- 患者姓名 -->
- <view class="form-item">
- <view class="form-label">
- <text class="required">*</text>
- <text>1、患者姓名</text>
- </view>
- <input
- class="form-input"
- v-model="formData.patientName"
- placeholder="请输入患者姓名"
- />
- </view>
-
- <!-- 患者性别 -->
- <view class="form-item">
- <view class="form-label">
- <text class="required">*</text>
- <text>2、患者性别</text>
- </view>
- <radio-group @change="onGenderChange" class="radio-group">
- <label class="radio-item">
- <radio value="male" :checked="formData.patientGender === 'male'" color="#388BFF" />
- <text>男</text>
- </label>
- <label class="radio-item">
- <radio value="female" :checked="formData.patientGender === 'female'" color="#388BFF" />
- <text>女</text>
- </label>
- </radio-group>
- </view>
-
- <!-- 患者年龄 -->
- <view class="form-item">
- <view class="form-label">
- <text class="required">*</text>
- <text>3、患者年龄</text>
- </view>
- <input
- class="form-input"
- v-model="formData.patientAge"
- type="number"
- placeholder="请输入患者年龄 (岁)"
- />
- </view>
-
- <!-- 处方日期 -->
- <view class="form-item">
- <view class="form-label">
- <text class="required">*</text>
- <text>4、处方日期</text>
- </view>
- <picker mode="date" :value="formData.prescriptionDate" @change="onDateChange">
- <view class="form-input picker-input" :class="{ placeholder: !formData.prescriptionDate }">
- {{ formData.prescriptionDate || '请选择处方日期' }}
- <text class="calendar-icon">📅</text>
- </view>
- </picker>
- </view>
-
- <!-- 心脏病类型 -->
- <view class="form-item">
- <view class="form-label">
- <text class="required">*</text>
- <text>5、您被诊断的心脏病类型 (多选)</text>
- </view>
- <checkbox-group @change="onDiseaseTypeChange" class="checkbox-group">
- <label class="checkbox-item">
- <checkbox value="coronary" :checked="formData.diseaseTypes.includes('coronary')" color="#388BFF" />
- <text>冠心病</text>
- </label>
- <label class="checkbox-item">
- <checkbox value="heartFailure" :checked="formData.diseaseTypes.includes('heartFailure')" color="#388BFF" />
- <text>心力衰竭</text>
- </label>
- <label class="checkbox-item">
- <checkbox value="arrhythmia" :checked="formData.diseaseTypes.includes('arrhythmia')" color="#388BFF" />
- <text>心律失常</text>
- </label>
- </checkbox-group>
- </view>
-
- <!-- 图片上传 -->
- <view class="form-item">
- <view class="form-label">
- <text class="required">*</text>
- <text>6、图片上传</text>
- </view>
- <view class="upload-section">
- <view class="upload-item" v-for="(image, index) in formData.images" :key="index">
- <image class="uploaded-image" :src="image" mode="aspectFill"></image>
- <view class="delete-btn" @click="removeImage(index)">×</view>
- </view>
- <view class="upload-item upload-placeholder" @click="chooseImage" v-if="formData.images.length < 2">
- <text class="camera-icon">📷</text>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
-
- <!-- 提交按钮 -->
- <view class="submit-btn" @click="handleSubmit">提交</view>
- </view>
- </template>
- <script>
- import { submitCaseCollection } from '@/api-js/medicationSurvey'
- export default {
- data() {
- return {
- statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
- activityId: '',
- formData: {
- title: '心脏相关疾病病例征集表',
- patientName: '',
- patientGender: 'male',
- patientAge: '',
- prescriptionDate: '',
- diseaseTypes: ['coronary', 'heartFailure'],
- images: []
- }
- }
- },
- onLoad(options) {
- if (options.activityId) {
- this.activityId = options.activityId
- }
- },
- methods: {
- goBack() {
- uni.navigateBack()
- },
- onDateChange(e) {
- this.formData.prescriptionDate = e.detail.value
- },
- onGenderChange(e) {
- this.formData.patientGender = e.detail.value
- },
- onDiseaseTypeChange(e) {
- this.formData.diseaseTypes = e.detail.value
- },
- chooseImage() {
- uni.chooseImage({
- count: 2 - this.formData.images.length,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: (res) => {
- this.formData.images = [...this.formData.images, ...res.tempFilePaths]
- }
- })
- },
- removeImage(index) {
- this.formData.images.splice(index, 1)
- },
- async handleSubmit() {
- // 表单验证
- if (!this.formData.patientName) {
- uni.showToast({
- icon: 'none',
- title: '请输入患者姓名'
- })
- return
- }
- if (!this.formData.patientAge) {
- uni.showToast({
- icon: 'none',
- title: '请输入患者年龄'
- })
- return
- }
- if (!this.formData.prescriptionDate) {
- uni.showToast({
- icon: 'none',
- title: '请选择处方日期'
- })
- return
- }
- if (this.formData.diseaseTypes.length === 0) {
- uni.showToast({
- icon: 'none',
- title: '请至少选择一种心脏病类型'
- })
- return
- }
- if (this.formData.images.length === 0) {
- uni.showToast({
- icon: 'none',
- title: '请至少上传一张图片'
- })
- return
- }
-
- try {
- uni.showLoading({ title: '提交中...' })
- const res = await submitCaseCollection({
- activityId: this.activityId,
- ...this.formData
- })
- uni.hideLoading()
- if (res.code === 200) {
- uni.showToast({
- icon: 'success',
- title: '提交成功'
- })
- setTimeout(() => {
- uni.navigateBack()
- }, 1500)
- } else {
- uni.showToast({
- icon: 'none',
- title: res.msg || '提交失败'
- })
- }
- } catch (e) {
- uni.hideLoading()
- uni.showToast({
- icon: 'none',
- title: '提交失败'
- })
- }
- }
- }
- }
- </script>
- <style lang="stylus">
- checkbox .wx-checkbox-input{
- border-radius:0 !important;
- }
- checkbox .wx-checkbox-input.wx-checkbox-input-checked {
- border-radius:0 !important;
- }
- </style>
- <style lang="scss" scoped>
- .container {
- min-height: 100vh;
- background: linear-gradient(180deg, #E6F3FF 0%, #FFFFFF 100%);
- display: flex;
- flex-direction: column;
- }
- .status-bar {
- width: 100%;
- background: transparent;
- }
- .header {
- position: relative;
- height: 88rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background: transparent;
-
- .back-btn {
- position: absolute;
- left: 24rpx;
- width: 40rpx;
- height: 40rpx;
-
- image {
- width: 100%;
- height: 100%;
- }
- }
-
- .title {
- font-size: 36rpx;
- font-weight: bold;
- color: #333;
- }
-
- .header-right {
- position: absolute;
- right: 24rpx;
- display: flex;
- align-items: center;
- gap: 16rpx;
-
- .more-icon {
- font-size: 32rpx;
- color: #333;
- }
- }
- }
- .content {
- flex: 1;
- padding: 24rpx;
- }
- .form-header {
- margin-bottom: 32rpx;
-
- .form-title {
- font-size: 36rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 16rpx;
- }
-
- .form-tips {
- .tip-item {
- font-size: 24rpx;
- color: #666;
- margin-bottom: 8rpx;
- }
- }
- }
- .form-section {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- }
- .form-item {
- margin-bottom: 32rpx;
-
- &:last-child {
- margin-bottom: 0;
- }
-
- .form-label {
- display: flex;
- align-items: center;
- font-size: 28rpx;
- color: #333;
- margin-bottom: 16rpx;
-
- .required {
- color: #FF5030;
- margin-right: 4rpx;
- }
- }
-
- .form-input {
- width: 100%;
- height: 80rpx;
- padding: 0 24rpx;
- background: #f5f5f5;
- border-radius: 8rpx;
- font-size: 28rpx;
- color: #333;
-
- &.placeholder {
- color: #999;
- }
-
- &.picker-input {
- display: flex;
- align-items: center;
- justify-content: space-between;
-
- .calendar-icon {
- font-size: 32rpx;
- }
- }
- }
-
- .radio-group,
- .checkbox-group {
- display: flex;
- gap: 48rpx;
-
- .radio-item,
- .checkbox-item {
- display: flex;
- align-items: center;
- gap: 16rpx;
- font-size: 28rpx;
- color: #333;
- }
- }
-
- .upload-section {
- display: flex;
- gap: 16rpx;
- flex-wrap: wrap;
-
- .upload-item {
- width: 200rpx;
- height: 200rpx;
- border-radius: 8rpx;
- overflow: hidden;
- position: relative;
-
- .uploaded-image {
- width: 100%;
- height: 100%;
- }
-
- .delete-btn {
- position: absolute;
- top: 8rpx;
- right: 8rpx;
- width: 40rpx;
- height: 40rpx;
- background: rgba(0, 0, 0, 0.5);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- color: #fff;
- }
-
- &.upload-placeholder {
- background: #f5f5f5;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .camera-icon {
- font-size: 60rpx;
- }
- }
- }
- }
- }
- .submit-btn {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- height: 88rpx;
- background: #388BFF;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- color: #fff;
- font-weight: 500;
- z-index: 100;
- }
- </style>
|