|
|
@@ -6,12 +6,14 @@
|
|
|
<view class="nav-back" @click="goBack">
|
|
|
<image src="/static/public/back.png" mode="aspectFill" class="back-icon"></image>
|
|
|
</view>
|
|
|
- <text class="nav-title">穴位定位</text>
|
|
|
+ <text class="nav-title">{{pageMode === 'edit' ? '编辑方案' : '新增方案'}}</text>
|
|
|
<view class="nav-right">
|
|
|
- <text class="nav-count">{{acupointList.length}}穴位</text>
|
|
|
+ <text class="nav-save-btn" @click="savePlan">保存</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
+
|
|
|
+
|
|
|
<!-- 人体模型 + 穴位标注 -->
|
|
|
<scroll-view class="body-scroll" :scroll-y="!isLandscape" :show-scrollbar="false" :scroll-top="scrollTop" @scroll="onScroll" scroll-with-animation>
|
|
|
<view class="body-content">
|
|
|
@@ -33,7 +35,8 @@
|
|
|
:key="point.id"
|
|
|
class="acupoint-dot"
|
|
|
:class="{
|
|
|
- 'acupoint-active': selectedIndex === index
|
|
|
+ 'acupoint-active': selectedIndex === index,
|
|
|
+ 'acupoint-edited': selectedIndex !== index && (point.customSide || point._inPlan)
|
|
|
}"
|
|
|
:style="{
|
|
|
left: point.screenX + 'px',
|
|
|
@@ -60,11 +63,12 @@
|
|
|
class="list-item"
|
|
|
:class="{
|
|
|
'list-item-active': selectedIndex === index,
|
|
|
+ 'list-item-edited': selectedIndex !== index && (point.customSide || point._inPlan),
|
|
|
'list-item-full': point.isSingle
|
|
|
}"
|
|
|
@click="onListItemTap(index)"
|
|
|
>
|
|
|
- <view class="item-index" :class="{'item-index-active': selectedIndex === index}">
|
|
|
+ <view class="item-index" :class="{'item-index-active': selectedIndex === index || point.customSide || point._inPlan}">
|
|
|
<text class="index-text">{{index + 1}}</text>
|
|
|
</view>
|
|
|
<text class="item-name">{{point.acupointName}}</text>
|
|
|
@@ -150,13 +154,37 @@
|
|
|
<text class="loading-text">加载中...</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
+
|
|
|
+ <!-- 新增方案名称弹窗 -->
|
|
|
+ <view class="popup-mask" v-if="showNamePopup" @click="showNamePopup = false">
|
|
|
+ <view class="popup-content" @click.stop>
|
|
|
+ <view class="popup-header">
|
|
|
+ <text class="popup-title">保存方案</text>
|
|
|
+ </view>
|
|
|
+ <view class="popup-body">
|
|
|
+ <view class="form-group">
|
|
|
+ <text class="form-label">方案名称</text>
|
|
|
+ <input class="name-popup-input" v-model="planName" placeholder="请输入方案名称" maxlength="100" focus />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="popup-footer">
|
|
|
+ <view class="btn btn-cancel" @click="showNamePopup = false">取消</view>
|
|
|
+ <view class="btn btn-confirm" @click="confirmSavePlan">确认保存</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <ay-toast ref="ayToast" />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { getBackAcupoints } from '@/utils/api/acupoint.js'
|
|
|
+import { createCustomPlan, updateCustomPlan, getCustomPlanDetail } from '@/utils/api/care.js'
|
|
|
+import ayToast from '@/components/ay-toast/ay-toast.nvue'
|
|
|
|
|
|
export default {
|
|
|
+ components: { ayToast },
|
|
|
data() {
|
|
|
return {
|
|
|
isLandscape: false,
|
|
|
@@ -168,7 +196,7 @@ export default {
|
|
|
// SVG viewBox: 0 0 300 400, 一体式实心剪影
|
|
|
containerWidth: 345,
|
|
|
containerHeight: 460,
|
|
|
- // 大椎穴(0,0)在容器中的位置
|
|
|
+ // 大椚穴(0,0)在容器中的位置
|
|
|
// 颈根/斜方肌起点(C7)在SVG中 y=78 -> 按比例放大1.15倍
|
|
|
originX: 172.5,
|
|
|
originY: 89.7,
|
|
|
@@ -188,7 +216,15 @@ export default {
|
|
|
methodOptions: ['温和灸', '雀啄灸', '回旋灸'],
|
|
|
|
|
|
scrollTop: 0,
|
|
|
- oldScrollTop: 0
|
|
|
+ oldScrollTop: 0,
|
|
|
+
|
|
|
+ // 方案相关
|
|
|
+ pageMode: 'create', // 'create' | 'edit'
|
|
|
+ planId: null,
|
|
|
+ planName: '',
|
|
|
+ planData: null, // 编辑模式下的原始方案数据
|
|
|
+ saving: false,
|
|
|
+ showNamePopup: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -220,6 +256,8 @@ export default {
|
|
|
const sysInfo = uni.getSystemInfoSync()
|
|
|
this.statusBarHeight = sysInfo.statusBarHeight || 44
|
|
|
this.profileId = decodeURIComponent(options.profileId || '')
|
|
|
+ this.pageMode = options.mode || 'create'
|
|
|
+ this.planId = options.planId || null
|
|
|
this.checkOrientation(sysInfo)
|
|
|
this.loadAcupoints()
|
|
|
},
|
|
|
@@ -292,7 +330,7 @@ export default {
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.error('加载穴位数据失败:', e)
|
|
|
- uni.showToast({ title: '穴位数据加载失败', icon: 'none' })
|
|
|
+ this.$refs.ayToast.error('穴位数据加载失败')
|
|
|
this.acupointList = []
|
|
|
} finally {
|
|
|
this.loading = false
|
|
|
@@ -303,6 +341,10 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+ // 穴位数据加载完成后,编辑模式下加载方案详情并回填
|
|
|
+ if (this.pageMode === 'edit' && this.planId && this.acupointList.length > 0) {
|
|
|
+ this.loadPlanDetail()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/** 点击穴位点 */
|
|
|
@@ -368,7 +410,7 @@ export default {
|
|
|
saveEdit() {
|
|
|
if (this.selectedIndex >= 0) {
|
|
|
const point = this.acupointList[this.selectedIndex]
|
|
|
- // 更新穴位列表中的对应数据(使用Vue的响应式需要特殊处理,但这里我们直接改属性,若无法触发视图更新可用$set或splice,但简单修改通常有效)
|
|
|
+ // 更新穴位列表中的对应数据
|
|
|
point.customSide = this.editForm.side
|
|
|
point.method = this.editForm.method
|
|
|
point.temperature = this.editForm.temperature
|
|
|
@@ -377,6 +419,117 @@ export default {
|
|
|
this.closePopup()
|
|
|
},
|
|
|
|
|
|
+ /** 加载方案详情(编辑模式) */
|
|
|
+ async loadPlanDetail() {
|
|
|
+ try {
|
|
|
+ const res = await getCustomPlanDetail(this.planId)
|
|
|
+ if (res) {
|
|
|
+ this.planData = res
|
|
|
+ this.planName = res.name || ''
|
|
|
+ // 穴位列表已加载完成,直接回填方案步骤参数
|
|
|
+ if (res.steps && res.steps.length > 0) {
|
|
|
+ this.applyStepsToAcupoints(res.steps)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('加载方案详情失败:', e)
|
|
|
+ this.$refs.ayToast.error('加载方案失败')
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 将方案步骤参数回填到穴位列表 */
|
|
|
+ applyStepsToAcupoints(steps) {
|
|
|
+ const sideMap = { 1: '中心', 2: '左侧', 3: '右侧', 4: '双侧' }
|
|
|
+ const techniqueMap = { '2': '温和灸', '4': '回旋灸', '3': '雀啄灸' }
|
|
|
+ steps.forEach(step => {
|
|
|
+ const point = this.acupointList.find(p => p.acupointId === step.acupointId)
|
|
|
+ if (point) {
|
|
|
+ point.customSide = sideMap[step.side] || '中心'
|
|
|
+ point.method = techniqueMap[step.techniqueId] || '温和灸'
|
|
|
+ point.temperature = step.temperature || 45
|
|
|
+ point.duration = step.duration || 15
|
|
|
+ point._inPlan = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 点击保存按钮 */
|
|
|
+ savePlan() {
|
|
|
+ if (this.saving) return
|
|
|
+ const steps = this.buildSteps()
|
|
|
+ if (steps.length === 0) {
|
|
|
+ this.$refs.ayToast.show('请至少编辑一个穴位参数')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.pageMode === 'edit') {
|
|
|
+ // 编辑模式直接保存
|
|
|
+ this.doSavePlan()
|
|
|
+ } else {
|
|
|
+ // 新增模式弹出名称输入框
|
|
|
+ this.showNamePopup = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 弹窗确认保存(新增模式) */
|
|
|
+ confirmSavePlan() {
|
|
|
+ if (!this.planName.trim()) {
|
|
|
+ this.$refs.ayToast.show('请输入方案名称')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.showNamePopup = false
|
|
|
+ this.doSavePlan()
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 执行保存方案 */
|
|
|
+ async doSavePlan() {
|
|
|
+ if (this.saving) return
|
|
|
+ if (!this.planName.trim()) {
|
|
|
+ this.$refs.ayToast.show('请输入方案名称')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.saving = true
|
|
|
+ try {
|
|
|
+ const sideMap = { '中心': 1, '左侧': 2, '右侧': 3, '双侧': 4 }
|
|
|
+ const techniqueMap = { '温和灸': '2', '回旋灸': '4', '雀啄灸': '3' }
|
|
|
+ const steps = this.buildSteps()
|
|
|
+
|
|
|
+ const planData = {
|
|
|
+ name: this.planName.trim(),
|
|
|
+ status: 1,
|
|
|
+ steps: steps.map(point => ({
|
|
|
+ acupointId: point.acupointId,
|
|
|
+ side: sideMap[point.customSide] || 1,
|
|
|
+ temperature: Number(point.temperature) || 45,
|
|
|
+ duration: Number(point.duration) || 15,
|
|
|
+ techniqueId: techniqueMap[point.method] || '2'
|
|
|
+ }))
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.pageMode === 'edit' && this.planId) {
|
|
|
+ planData.id = this.planId
|
|
|
+ await updateCustomPlan(planData)
|
|
|
+ this.$refs.ayToast.success('修改成功')
|
|
|
+ } else {
|
|
|
+ await createCustomPlan(planData)
|
|
|
+ this.$refs.ayToast.success('新增成功')
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.navigateBack()
|
|
|
+ }, 1000)
|
|
|
+ } catch (e) {
|
|
|
+ console.error('保存方案失败:', e)
|
|
|
+ this.$refs.ayToast.error(e.message || '保存失败')
|
|
|
+ } finally {
|
|
|
+ this.saving = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 构建方案步骤(筛选已编辑的穴位) */
|
|
|
+ buildSteps() {
|
|
|
+ return this.acupointList.filter(point => point.customSide || point._inPlan)
|
|
|
+ },
|
|
|
+
|
|
|
/** 侧别标签 */
|
|
|
sideLabel(side) {
|
|
|
const map = { left: '左侧', right: '右侧', center: '中心' }
|
|
|
@@ -447,6 +600,50 @@ export default {
|
|
|
font-size: 12px;
|
|
|
color: rgba(255,255,255,0.8);
|
|
|
}
|
|
|
+.nav-save-btn {
|
|
|
+ font-size: 14px;
|
|
|
+ color: #FFFFFF;
|
|
|
+ background: rgba(255,255,255,0.2);
|
|
|
+ padding: 5px 14px;
|
|
|
+ border-radius: 14px;
|
|
|
+ font-weight: 500;
|
|
|
+}
|
|
|
+
|
|
|
+/* 方案名称输入 */
|
|
|
+.plan-name-section {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+ margin: 0 15px 10px;
|
|
|
+ background: rgba(255,255,255,0.9);
|
|
|
+ border-radius: 12px;
|
|
|
+ padding: 10px 14px;
|
|
|
+}
|
|
|
+.plan-name-label {
|
|
|
+ font-size: 13px;
|
|
|
+ color: #545F71;
|
|
|
+ font-weight: 500;
|
|
|
+ margin-right: 10px;
|
|
|
+ flex-shrink: 0;
|
|
|
+}
|
|
|
+.plan-name-input {
|
|
|
+ flex: 1;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #333333;
|
|
|
+ height: 32px;
|
|
|
+}
|
|
|
+
|
|
|
+/* 名称弹窗输入框 */
|
|
|
+.name-popup-input {
|
|
|
+ width: 100%;
|
|
|
+ height: 40px;
|
|
|
+ border: 1px solid #E8ECF0;
|
|
|
+ border-radius: 8px;
|
|
|
+ padding: 0 12px;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #333333;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
|
|
|
/* 人体模型容器 */
|
|
|
.body-scroll {
|
|
|
@@ -525,6 +722,14 @@ export default {
|
|
|
box-shadow: 0 4px 12px rgba(246, 82, 82, 0.4);
|
|
|
transform: scale(1.1);
|
|
|
}
|
|
|
+/* 已编辑态 */
|
|
|
+.acupoint-edited .dot-inner {
|
|
|
+ width: 11px;
|
|
|
+ height: 11px;
|
|
|
+ background: #F65252;
|
|
|
+ border: 1.5px solid #FFFFFF;
|
|
|
+ box-shadow: 0 2px 8px rgba(246, 82, 82, 0.3);
|
|
|
+}
|
|
|
|
|
|
/* 穴位列表 */
|
|
|
.list-section {
|
|
|
@@ -578,6 +783,10 @@ export default {
|
|
|
box-shadow: 0 4px 12px rgba(56, 149, 136, 0.1);
|
|
|
transform: scale(1);
|
|
|
}
|
|
|
+.list-item-edited {
|
|
|
+ background: rgba(246, 82, 82, 0.05);
|
|
|
+ border-color: rgba(246, 82, 82, 0.2);
|
|
|
+}
|
|
|
.list-item-full {
|
|
|
margin-right: 50%;
|
|
|
}
|