|
|
@@ -32,6 +32,7 @@
|
|
|
>
|
|
|
<view class="card-top">
|
|
|
<text class="plan-title">{{ plan.goal || plan.memberName || '健康方案' }}</text>
|
|
|
+ <text class="plan-delete" @click.stop="onDeletePlan(plan)">删除</text>
|
|
|
<view class="plan-status" :class="'status-' + plan.status">
|
|
|
<text>{{ statusText(plan.status) }}</text>
|
|
|
</view>
|
|
|
@@ -47,7 +48,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getHealthPlanList } from '@/utils/api.js'
|
|
|
+import { getHealthPlanList, deleteHealthPlan } from '@/utils/api.js'
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
|
@@ -91,6 +92,30 @@ export default {
|
|
|
goCreatePlan() {
|
|
|
uni.navigateTo({ url: '/pages/health/health-plan-summary' })
|
|
|
},
|
|
|
+ onDeletePlan(plan) {
|
|
|
+ var self = this
|
|
|
+ uni.showModal({
|
|
|
+ title: '删除方案',
|
|
|
+ content: '删除后不可恢复:该方案及其已生成的所有任务(含每日生成的实例)将一并删除。确认删除?',
|
|
|
+ confirmText: '删除',
|
|
|
+ confirmColor: '#C62828',
|
|
|
+ success: function(res) {
|
|
|
+ if (!res.confirm) return
|
|
|
+ deleteHealthPlan({ planId: plan.id }).then(function(r) {
|
|
|
+ if (r && r.code === 200) {
|
|
|
+ var count = (r.data && r.data.taskCount) || 0
|
|
|
+ uni.showToast({ title: '已删除方案及 ' + count + ' 条任务', icon: 'none' })
|
|
|
+ self.loadPlans()
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: (r && r.message) || '删除失败', icon: 'none' })
|
|
|
+ }
|
|
|
+ }).catch(function(err) {
|
|
|
+ console.error('删除方案失败', err)
|
|
|
+ uni.showToast({ title: '删除失败', icon: 'none' })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
statusText(status) {
|
|
|
var map = {
|
|
|
'draft': '待确认',
|
|
|
@@ -209,6 +234,14 @@ export default {
|
|
|
flex: 1;
|
|
|
}
|
|
|
|
|
|
+.plan-delete {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #C62828;
|
|
|
+ padding: 8rpx 16rpx;
|
|
|
+ margin-right: 16rpx;
|
|
|
+ flex-shrink: 0;
|
|
|
+}
|
|
|
+
|
|
|
.plan-status {
|
|
|
font-size: 22rpx;
|
|
|
padding: 4rpx 16rpx;
|