2026-02-05 18:59:48 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="appManagement-container">
|
|
|
|
|
<vab-query-form>
|
|
|
|
|
<vab-query-form-left-panel :span="12">
|
|
|
|
|
<el-button icon="el-icon-plus" type="primary" @click="handleEdit">添加</el-button>
|
|
|
|
|
<!-- <el-button icon="el-icon-delete" type="danger" @click="handleDelete">批量删除</el-button> -->
|
|
|
|
|
</vab-query-form-left-panel>
|
|
|
|
|
<vab-query-form-right-panel :span="12">
|
|
|
|
|
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
|
2026-03-13 04:07:07 +08:00
|
|
|
<el-form-item>
|
|
|
|
|
<el-select v-model="queryForm.scene" clearable placeholder="请选择场景" @change="queryData">
|
|
|
|
|
<el-option v-for="item in sceneList" :key="item.scene" :label="item.sceneName" :value="item.scene" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
2026-02-05 18:59:48 +08:00
|
|
|
<el-form-item>
|
|
|
|
|
<el-input v-model.trim="queryForm.keyword" clearable placeholder="请输入查询条件" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</vab-query-form-right-panel>
|
|
|
|
|
</vab-query-form>
|
|
|
|
|
|
|
|
|
|
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
|
|
|
|
<!-- <el-table-column show-overflow-tooltip type="selection" /> -->
|
|
|
|
|
<el-table-column align="center" label="排序" prop="sort" show-overflow-tooltip />
|
|
|
|
|
|
|
|
|
|
<el-table-column align="center" label="模版" width="100">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-tooltip class="item" :content="scope.row.id" effect="dark" placement="top">
|
|
|
|
|
<el-image
|
|
|
|
|
fit="cover"
|
|
|
|
|
:preview-src-list="[scope.row.imageUrl]"
|
|
|
|
|
:src="getThumbUrl(scope.row.imageUrl)"
|
|
|
|
|
style="width: 50px; height: 50px"
|
|
|
|
|
/>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column align="center" label="标题" prop="name" show-overflow-tooltip />
|
2026-03-13 04:07:07 +08:00
|
|
|
<el-table-column align="center" label="场景" show-overflow-tooltip>
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
{{ getSceneName(row.scene) }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2026-02-05 18:59:48 +08:00
|
|
|
<el-table-column align="center" label="使用次数" prop="useCount" show-overflow-tooltip />
|
|
|
|
|
<el-table-column align="center" label="是否启用" show-overflow-tooltip>
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-switch active-color="#13ce66" inactive-color="#ff4949" :value="row.isEnabled" @change="handleToggleEnable(row, $event)" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column align="center" label="操作">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
|
|
|
|
|
<el-button :disabled="!scope.row.isEnabled || isFirstEnabled(scope.row)" type="text" @click="handleMoveUp(scope.row)">
|
|
|
|
|
上移
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button :disabled="!scope.row.isEnabled || isLastEnabled(scope.row)" type="text" @click="handleMoveDown(scope.row)">
|
|
|
|
|
下移
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<el-pagination
|
|
|
|
|
background
|
|
|
|
|
:current-page="queryForm.pageNo"
|
|
|
|
|
:layout="layout"
|
|
|
|
|
:page-size="queryForm.pageSize"
|
|
|
|
|
:total="total"
|
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
|
/>
|
|
|
|
|
<edit ref="edit" @fetch-data="fetchData" />
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { doDelete, getList, toggleEnable, doMoveUp, doMoveDown } from '@/api/spring/blessing/titleTemplate/index'
|
2026-03-13 04:07:07 +08:00
|
|
|
import { getAll as getAllScenes } from '@/api/spring/blessing/scene'
|
2026-02-05 18:59:48 +08:00
|
|
|
import { formatTime } from '@/utils'
|
|
|
|
|
import { getThumbUrl } from '@/utils/blessing'
|
|
|
|
|
import Edit from './components/AppManagementEdit'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'TitleTemplateManagement',
|
|
|
|
|
components: { Edit },
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
list: null,
|
|
|
|
|
listLoading: true,
|
|
|
|
|
layout: 'total, sizes, prev, pager, next, jumper',
|
|
|
|
|
total: 0,
|
|
|
|
|
selectRows: '',
|
|
|
|
|
elementLoadingText: '正在加载...',
|
|
|
|
|
queryForm: {
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
keyword: '',
|
2026-03-13 04:07:07 +08:00
|
|
|
scene: '',
|
2026-02-05 18:59:48 +08:00
|
|
|
},
|
|
|
|
|
timeOutID: null,
|
2026-03-13 04:07:07 +08:00
|
|
|
sceneList: [],
|
2026-02-05 18:59:48 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
const { templateId } = this.$route.query || {}
|
|
|
|
|
if (templateId) {
|
|
|
|
|
this.queryForm.keyword = templateId
|
|
|
|
|
this.queryForm.pageNo = 1
|
|
|
|
|
}
|
2026-03-13 04:07:07 +08:00
|
|
|
this.fetchSceneList()
|
2026-02-05 18:59:48 +08:00
|
|
|
this.fetchData()
|
|
|
|
|
},
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
clearTimeout(this.timeOutID)
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
setSelectRows(val) {
|
|
|
|
|
this.selectRows = val
|
|
|
|
|
},
|
|
|
|
|
handleEdit(row) {
|
2026-03-13 04:07:07 +08:00
|
|
|
this.$refs['edit'].showEdit(row)
|
2026-02-05 18:59:48 +08:00
|
|
|
},
|
|
|
|
|
handleDelete(row) {
|
|
|
|
|
if (row.id) {
|
|
|
|
|
this.$baseConfirm('你确定要删除当前项吗', null, async () => {
|
2026-03-13 04:07:07 +08:00
|
|
|
const { msg } = await doDelete(row.id)
|
2026-02-05 18:59:48 +08:00
|
|
|
this.$baseMessage(msg, 'success')
|
|
|
|
|
this.fetchData()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleSizeChange(val) {
|
|
|
|
|
this.queryForm.pageSize = val
|
|
|
|
|
this.fetchData()
|
|
|
|
|
},
|
|
|
|
|
handleCurrentChange(val) {
|
|
|
|
|
this.queryForm.pageNo = val
|
|
|
|
|
this.fetchData()
|
|
|
|
|
},
|
|
|
|
|
queryData() {
|
|
|
|
|
this.queryForm.pageNo = 1
|
|
|
|
|
this.fetchData()
|
|
|
|
|
},
|
|
|
|
|
async fetchData() {
|
|
|
|
|
this.listLoading = true
|
|
|
|
|
const { data } = await getList(this.queryForm)
|
|
|
|
|
this.list = data.list
|
|
|
|
|
this.total = data.totalCount
|
|
|
|
|
this.timeOutID = setTimeout(() => {
|
|
|
|
|
this.listLoading = false
|
2026-03-13 04:07:07 +08:00
|
|
|
}, 500)
|
2026-02-05 18:59:48 +08:00
|
|
|
},
|
2026-03-13 04:07:07 +08:00
|
|
|
async handleToggleEnable(row, value) {
|
|
|
|
|
this.$baseConfirm(`你确定要${value ? '启用' : '禁用'}当前项吗`, null, async () => {
|
|
|
|
|
const { msg } = await toggleEnable(row.id, value)
|
|
|
|
|
this.$baseMessage(msg, 'success')
|
2026-02-05 18:59:48 +08:00
|
|
|
this.fetchData()
|
2026-03-13 04:07:07 +08:00
|
|
|
})
|
2026-02-05 18:59:48 +08:00
|
|
|
},
|
|
|
|
|
async handleMoveUp(row) {
|
2026-03-13 04:07:07 +08:00
|
|
|
const { msg } = await doMoveUp(row.id)
|
|
|
|
|
this.$baseMessage(msg, 'success')
|
|
|
|
|
this.fetchData()
|
2026-02-05 18:59:48 +08:00
|
|
|
},
|
|
|
|
|
async handleMoveDown(row) {
|
2026-03-13 04:07:07 +08:00
|
|
|
const { msg } = await doMoveDown(row.id)
|
|
|
|
|
this.$baseMessage(msg, 'success')
|
|
|
|
|
this.fetchData()
|
2026-02-05 18:59:48 +08:00
|
|
|
},
|
|
|
|
|
isFirstEnabled(row) {
|
2026-03-13 04:07:07 +08:00
|
|
|
const enabledList = this.list.filter((item) => item.isEnabled)
|
|
|
|
|
return enabledList.length > 0 && enabledList[0].id === row.id
|
2026-02-05 18:59:48 +08:00
|
|
|
},
|
|
|
|
|
isLastEnabled(row) {
|
2026-03-13 04:07:07 +08:00
|
|
|
const enabledList = this.list.filter((item) => item.isEnabled)
|
|
|
|
|
return enabledList.length > 0 && enabledList[enabledList.length - 1].id === row.id
|
|
|
|
|
},
|
|
|
|
|
getThumbUrl,
|
|
|
|
|
async fetchSceneList() {
|
|
|
|
|
const { data } = await getAllScenes()
|
|
|
|
|
this.sceneList = data || []
|
|
|
|
|
},
|
|
|
|
|
getSceneName(scene) {
|
|
|
|
|
const found = this.sceneList.find((item) => item.scene === scene)
|
|
|
|
|
return found ? found.sceneName : scene
|
2026-02-05 18:59:48 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
</script>
|