|
@@ -56,9 +56,10 @@
|
|
|
<span class="sort-header" @click.stop="onSortClick('createdAt', $event)">创建时间<span v-if="sortIndex('createdAt') !== null" class="sort-index" :class="sortClass('createdAt') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('createdAt') }}</span>{{ sortIcon('createdAt') }}</span>
|
|
<span class="sort-header" @click.stop="onSortClick('createdAt', $event)">创建时间<span v-if="sortIndex('createdAt') !== null" class="sort-index" :class="sortClass('createdAt') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('createdAt') }}</span>{{ sortIcon('createdAt') }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" width="100">
|
|
|
|
|
|
|
+ <el-table-column label="操作" width="140">
|
|
|
<template slot-scope="{ row }">
|
|
<template slot-scope="{ row }">
|
|
|
<el-button size="mini" type="primary" @click="showDetail(row)">详情</el-button>
|
|
<el-button size="mini" type="primary" @click="showDetail(row)">详情</el-button>
|
|
|
|
|
+ <el-button size="mini" type="danger" style="margin-left:6px" @click="onDeletePlan(row)">删除</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
@@ -128,7 +129,7 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import SortMixin from '@/mixins/SortMixin'
|
|
import SortMixin from '@/mixins/SortMixin'
|
|
|
-import { adminListHealthPlans, adminGetHealthPlanDetail } from '@/api/healthPlan'
|
|
|
|
|
|
|
+import { adminListHealthPlans, adminGetHealthPlanDetail, adminDeleteHealthPlan } from '@/api/healthPlan'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'HealthPlanManage',
|
|
name: 'HealthPlanManage',
|
|
@@ -184,6 +185,31 @@ export default {
|
|
|
this.pageNum = page
|
|
this.pageNum = page
|
|
|
this.loadPlans()
|
|
this.loadPlans()
|
|
|
},
|
|
},
|
|
|
|
|
+ async onDeletePlan(row) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ await this.$confirm(
|
|
|
|
|
+ '删除后不可恢复:该方案及其已生成的所有任务(含每日生成的实例)将一并删除。确认删除?',
|
|
|
|
|
+ '删除方案',
|
|
|
|
|
+ { type: 'warning', confirmButtonText: '删除', confirmButtonClass: 'el-button--danger' }
|
|
|
|
|
+ )
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ return // 用户取消
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await adminDeleteHealthPlan({ planId: row.id })
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ const count = (res.data && res.data.taskCount) || 0
|
|
|
|
|
+ this.$message.success('已删除方案及 ' + count + ' 条任务')
|
|
|
|
|
+ // 删除本页最后一条且不在第一页时回退一页,避免空页
|
|
|
|
|
+ if (this.plans.length === 1 && this.pageNum > 1) this.pageNum = this.pageNum - 1
|
|
|
|
|
+ this.loadPlans()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(res.message || '删除失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ this.$message.error('删除失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
async showDetail(row) {
|
|
async showDetail(row) {
|
|
|
this.detailVisible = true
|
|
this.detailVisible = true
|
|
|
this.detailLoading = true
|
|
this.detailLoading = true
|