From 13a31edf7f569cdcf15d3c43a476a2c947f47fbf Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 09 十一月 2025 22:33:24 +0800
Subject: [PATCH] feat: 增加hospdata表,同步sqlserver过来
---
app/pages/task/detail.vue | 314 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 304 insertions(+), 10 deletions(-)
diff --git a/app/pages/task/detail.vue b/app/pages/task/detail.vue
index e4cdcbc..fa10be3 100644
--- a/app/pages/task/detail.vue
+++ b/app/pages/task/detail.vue
@@ -109,13 +109,17 @@
<!-- 杞繍浠诲姟鐗规湁淇℃伅 -->
<view class="detail-section" v-if="taskDetail.taskType === 'EMERGENCY_TRANSFER' && taskDetail.emergencyInfo">
<view class="section-title">鎮h�呬俊鎭�</view>
- <view class="info-item" v-if="taskDetail.emergencyInfo.patientName">
- <view class="label">鎮h�呭鍚�</view>
- <view class="value">{{ taskDetail.emergencyInfo.patientName }}</view>
+ <view class="info-item">
+ <view class="label">鑱旂郴浜�</view>
+ <view class="value">{{ taskDetail.emergencyInfo.patientContact || '鏈缃�' }}</view>
</view>
- <view class="info-item" v-if="taskDetail.emergencyInfo.patientPhone">
+ <view class="info-item">
+ <view class="label">鎮h�呭鍚�</view>
+ <view class="value">{{ taskDetail.emergencyInfo.patientName || '鏈缃�' }}</view>
+ </view>
+ <view class="info-item">
<view class="label">鑱旂郴鐢佃瘽</view>
- <view class="value">{{ taskDetail.emergencyInfo.patientPhone }}</view>
+ <view class="value">{{ taskDetail.emergencyInfo.patientPhone || '鏈缃�' }}</view>
</view>
<view class="info-item" v-if="taskDetail.emergencyInfo.patientGender">
<view class="label">鎬у埆</view>
@@ -189,6 +193,15 @@
<view class="value">锟{ taskDetail.emergencyInfo.transferPrice }}</view>
</view>
</view>
+
+ <!-- 闄勪欢淇℃伅 -->
+ <AttachmentUpload
+ :taskId="taskId"
+ title="浠诲姟闄勪欢"
+ :readonly="isTaskFinished"
+ @uploaded="onAttachmentUploaded"
+ @deleted="onAttachmentDeleted"
+ />
<!-- 绂忕杞︿换鍔$壒鏈変俊鎭� -->
<view class="detail-section" v-if="taskDetail.taskType === 'WELFARE' && taskDetail.welfareInfo">
@@ -316,8 +329,12 @@
<script>
import { getTask, changeTaskStatus } from '@/api/task'
import { formatDateTime } from '@/utils/common'
+ import AttachmentUpload from '@/components/AttachmentUpload.vue'
export default {
+ components: {
+ AttachmentUpload
+ },
data() {
return {
taskDetail: null,
@@ -325,6 +342,13 @@
}
},
computed: {
+ // 鍒ゆ柇浠诲姟鏄惁宸茬粨鏉燂紙宸插畬鎴愭垨宸插彇娑堬級
+ isTaskFinished() {
+ if (!this.taskDetail || !this.taskDetail.taskStatus) {
+ return false
+ }
+ return ['COMPLETED', 'CANCELLED'].includes(this.taskDetail.taskStatus)
+ },
// 鏄剧ず浠诲姟绫诲瀷
displayTaskType() {
if (!this.taskDetail || !this.taskDetail.taskType) {
@@ -395,11 +419,11 @@
getTask(this.taskId).then(response => {
this.taskDetail = response.data || response
// 璋冭瘯锛氭墦鍗拌繑鍥炵殑鏁版嵁
- console.log('浠诲姟璇︽儏瀹屾暣鏁版嵁:', JSON.stringify(this.taskDetail, null, 2))
- console.log('浠诲姟绫诲瀷瀛楁鍊�:', this.taskDetail.taskType)
- console.log('浠诲姟鐘舵�佸瓧娈靛��:', this.taskDetail.taskStatus)
- console.log('鍑哄彂鍦板潃:', this.taskDetail.departureAddress)
- console.log('鐩殑鍦板潃:', this.taskDetail.destinationAddress)
+ // console.log('浠诲姟璇︽儏瀹屾暣鏁版嵁:', JSON.stringify(this.taskDetail, null, 2))
+ // console.log('浠诲姟绫诲瀷瀛楁鍊�:', this.taskDetail.taskType)
+ // console.log('浠诲姟鐘舵�佸瓧娈靛��:', this.taskDetail.taskStatus)
+ // console.log('鍑哄彂鍦板潃:', this.taskDetail.departureAddress)
+ // console.log('鐩殑鍦板潃:', this.taskDetail.destinationAddress)
}).catch(error => {
console.error('鍔犺浇浠诲姟璇︽儏澶辫触:', error)
this.$modal.showToast('鍔犺浇浠诲姟璇︽儏澶辫触')
@@ -588,6 +612,264 @@
})
}
})
+ },
+
+ // 鍔犺浇闄勪欢鍒楄〃
+ loadAttachmentList() {
+ if (!this.taskId) {
+ return
+ }
+
+ getAttachmentList(this.taskId).then(response => {
+ this.attachmentList = response.data || response || []
+ }).catch(error => {
+ console.error('鍔犺浇闄勪欢鍒楄〃澶辫触:', error)
+ })
+ },
+
+ // 鏄剧ず涓婁紶瀵硅瘽妗�
+ showUploadDialog() {
+ this.selectedCategoryIndex = 0
+ this.tempImagePath = null
+ this.$refs.uploadPopup.open()
+ },
+
+ // 鍏抽棴涓婁紶瀵硅瘽妗�
+ closeUploadDialog() {
+ this.$refs.uploadPopup.close()
+ },
+
+ // 鍒嗙被閫夋嫨鍙樺寲
+ onCategoryChange(e) {
+ this.selectedCategoryIndex = e.detail.value
+ },
+
+ // 閫夋嫨鍥剧墖
+ chooseImage() {
+ const that = this
+ uni.chooseImage({
+ count: 1,
+ sizeType: ['compressed'],
+ sourceType: ['album', 'camera'],
+ success: function(res) {
+ that.tempImagePath = res.tempFilePaths[0]
+ },
+ fail: function(err) {
+ console.error('閫夋嫨鍥剧墖澶辫触:', err)
+ that.$modal.showToast('閫夋嫨鍥剧墖澶辫触')
+ }
+ })
+ },
+
+ // 纭涓婁紶
+ confirmUpload() {
+ if (!this.tempImagePath) {
+ this.$modal.showToast('璇峰厛閫夋嫨鍥剧墖')
+ return
+ }
+
+ const that = this
+ const category = this.categoryList[this.selectedCategoryIndex].value
+
+ // 寰俊灏忕▼搴忕幆澧冿細鍏堣幏鍙朅ccessToken锛屽啀涓婁紶鍒板井淇℃湇鍔″櫒锛屾渶鍚庢彁浜ediaId鍒板悗绔�
+ // #ifdef MP-WEIXIN
+ if (this.isWechatMiniProgram) {
+ uni.showLoading({
+ title: '涓婁紶涓�...'
+ })
+
+ // 绗竴姝ワ細浠庡悗绔幏鍙朅ccessToken
+ getWechatAccessToken().then(tokenResponse => {
+ // 鎺ュ彛杩斿洖鏍煎紡锛歿"msg":"token鍊�","code":200}
+ console.log('鑾峰彇AccessToken鎴愬姛:', tokenResponse)
+ const accessToken = tokenResponse.msg || tokenResponse.data || tokenResponse
+ if (!accessToken) {
+ uni.hideLoading()
+ that.$modal.showToast('鑾峰彇AccessToken澶辫触')
+ console.error('鑾峰彇AccessToken澶辫触锛屽搷搴旀暟鎹�:', tokenResponse)
+ return
+ }
+
+ console.log('鑾峰彇鍒癆ccessToken:', accessToken)
+
+ // 绗簩姝ワ細涓婁紶鍒板井淇℃湇鍔″櫒
+ const uploadUrl = `https://api.weixin.qq.com/cgi-bin/media/upload?access_token=${accessToken}&type=image`
+
+ uni.uploadFile({
+ url: uploadUrl,
+ filePath: that.tempImagePath,
+ name: 'media',
+ success: function(res) {
+ console.log('寰俊涓婁紶鍝嶅簲:', res)
+ try {
+ const data = JSON.parse(res.data)
+ if (data.media_id) {
+ // 绗笁姝ワ細鎻愪氦mediaId鍒板悗绔�
+ uploadAttachmentFromWechat(that.taskId, data.media_id, category).then(response => {
+ uni.hideLoading()
+ that.$modal.showToast('涓婁紶鎴愬姛')
+ that.closeUploadDialog()
+ that.loadAttachmentList()
+ }).catch(error => {
+ uni.hideLoading()
+ console.error('鎻愪氦mediaId澶辫触:', error)
+ that.$modal.showToast('涓婁紶澶辫触锛�' + (error.msg || '璇烽噸璇�'))
+ })
+ } else {
+ uni.hideLoading()
+ const errMsg = data.errmsg || '鏈煡閿欒'
+ console.error('寰俊杩斿洖閿欒:', data)
+ that.$modal.showToast('寰俊涓婁紶澶辫触锛�' + errMsg)
+ }
+ } catch (e) {
+ uni.hideLoading()
+ console.error('瑙f瀽寰俊鍝嶅簲澶辫触:', e, res.data)
+ that.$modal.showToast('涓婁紶澶辫触锛氬搷搴旇В鏋愰敊璇�')
+ }
+ },
+ fail: function(err) {
+ uni.hideLoading()
+ console.error('涓婁紶鍒板井淇″け璐�:', err)
+ that.$modal.showToast('涓婁紶澶辫触锛�' + (err.errMsg || '璇锋鏌ョ綉缁�'))
+ }
+ })
+ }).catch(error => {
+ uni.hideLoading()
+ console.error('鑾峰彇AccessToken澶辫触:', error)
+ that.$modal.showToast('鑾峰彇AccessToken澶辫触')
+ })
+ return
+ }
+ // #endif
+
+ // 闈炲井淇″皬绋嬪簭鐜锛氱洿鎺ヤ笂浼犲埌鍚庣鏈嶅姟鍣�
+ uni.showLoading({
+ title: '涓婁紶涓�...'
+ })
+
+ uni.uploadFile({
+ url: that.$baseUrl + '/task/attachment/upload/' + that.taskId,
+ filePath: that.tempImagePath,
+ name: 'file',
+ formData: {
+ 'category': category
+ },
+ header: {
+ 'Authorization': 'Bearer ' + uni.getStorageSync('token')
+ },
+ success: function(uploadRes) {
+ uni.hideLoading()
+
+ if (uploadRes.statusCode === 200) {
+ const result = JSON.parse(uploadRes.data)
+ if (result.code === 200) {
+ that.$modal.showToast('涓婁紶鎴愬姛')
+ that.closeUploadDialog()
+ that.loadAttachmentList()
+ } else {
+ that.$modal.showToast(result.msg || '涓婁紶澶辫触')
+ }
+ } else {
+ that.$modal.showToast('涓婁紶澶辫触')
+ }
+ },
+ fail: function(err) {
+ uni.hideLoading()
+ console.error('涓婁紶澶辫触:', err)
+ that.$modal.showToast('涓婁紶澶辫触')
+ }
+ })
+ },
+
+ // 鏌ョ湅闄勪欢
+ viewAttachment(item) {
+ // 濡傛灉鏄浘鐗囷紝浣跨敤鍥剧墖棰勮
+ const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
+ const fileExt = item.fileName.split('.').pop().toLowerCase()
+
+ if (imageTypes.includes(fileExt)) {
+ // 鏋勫缓鍥剧墖璁块棶鍦板潃
+ // 濡傛灉鏄痜ilePath鏄畬鏁磋矾寰勶紝闇�瑕侀�氳繃涓嬭浇鎺ュ彛璁块棶
+ const imageUrl = this.$baseUrl + '/task/attachment/download/' + item.attachmentId
+
+ // 寰俊灏忕▼搴忎腑棰勮鍥剧墖
+ // #ifdef MP-WEIXIN
+ // 寰俊灏忕▼搴忛渶瑕佸厛涓嬭浇鍒版湰鍦板啀棰勮
+ uni.showLoading({ title: '鍔犺浇涓�...' })
+ uni.downloadFile({
+ url: imageUrl,
+ success: function(res) {
+ uni.hideLoading()
+ if (res.statusCode === 200) {
+ uni.previewImage({
+ urls: [res.tempFilePath],
+ current: res.tempFilePath
+ })
+ } else {
+ uni.showToast({ title: '鍔犺浇鍥剧墖澶辫触', icon: 'none' })
+ }
+ },
+ fail: function() {
+ uni.hideLoading()
+ uni.showToast({ title: '涓嬭浇澶辫触', icon: 'none' })
+ }
+ })
+ // #endif
+
+ // 闈炲井淇″皬绋嬪簭鐜锛岀洿鎺ラ瑙�
+ // #ifndef MP-WEIXIN
+ uni.previewImage({
+ urls: [imageUrl],
+ current: imageUrl
+ })
+ // #endif
+ } else {
+ this.$modal.showToast('浠呮敮鎸侀瑙堝浘鐗�')
+ }
+ },
+
+ // 鍒犻櫎闄勪欢
+ deleteAttachment(attachmentId, index) {
+ const that = this
+ this.$modal.confirm('纭畾瑕佸垹闄よ闄勪欢鍚楋紵').then(() => {
+ deleteAttachment(attachmentId).then(response => {
+ that.$modal.showToast('鍒犻櫎鎴愬姛')
+ that.attachmentList.splice(index, 1)
+ }).catch(error => {
+ console.error('鍒犻櫎闄勪欢澶辫触:', error)
+ that.$modal.showToast('鍒犻櫎澶辫触')
+ })
+ }).catch(() => {})
+ },
+
+ // 鑾峰彇鍒嗙被鍚嶇О
+ getCategoryName(category) {
+ const item = this.categoryList.find(c => c.value === category)
+ return item ? item.label : '鏈垎绫�'
+ },
+
+ // 鏍煎紡鍖栨椂闂�
+ formatTime(time) {
+ if (!time) return ''
+ return formatDateTime(time, 'YYYY-MM-DD HH:mm')
+ },
+
+ // 鏍煎紡鍖栨枃浠跺ぇ灏�
+ formatFileSize(size) {
+ if (!size) return '0B'
+ if (size < 1024) return size + 'B'
+ if (size < 1024 * 1024) return (size / 1024).toFixed(2) + 'KB'
+ return (size / 1024 / 1024).toFixed(2) + 'MB'
+ },
+
+ // 闄勪欢涓婁紶鎴愬姛鍥炶皟
+ onAttachmentUploaded(response) {
+ console.log('闄勪欢涓婁紶鎴愬姛:', response)
+ },
+
+ // 闄勪欢鍒犻櫎鎴愬姛鍥炶皟
+ onAttachmentDeleted(attachmentId) {
+ console.log('闄勪欢鍒犻櫎鎴愬姛:', attachmentId)
}
}
}
@@ -643,6 +925,18 @@
color: #333;
border-bottom: 1rpx solid #f0f0f0;
padding-bottom: 10rpx;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .upload-btn {
+ font-size: 24rpx;
+ padding: 8rpx 20rpx;
+ background-color: #007AFF;
+ color: white;
+ border-radius: 8rpx;
+ border: none;
+ }
}
.info-item {
--
Gitblit v1.9.1