|
@@ -2,24 +2,30 @@
|
|
|
<div class="my-layout">
|
|
|
<el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
|
|
|
<el-form :inline="true" @submit.stop.prevent>
|
|
|
+ <el-form-item>
|
|
|
+ <el-input type="text" v-model="state.filter.keyword" placeholder="请输入文章标题" clearable></el-input>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button v-auth="'api:admin:notice:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增
|
|
|
+ <el-button type="primary" @click="onQuery"> 搜索</el-button>
|
|
|
+ <el-button v-auth="'api:admin:article:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增
|
|
|
</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-card>
|
|
|
|
|
|
<el-card class="my-fill mt8" shadow="never">
|
|
|
- <el-table v-loading="state.loading" :data="state.tenantListData" row-key="id" height="'100%'"
|
|
|
+ <el-table v-loading="state.loading" :data="state.listData" row-key="id" height="'100%'"
|
|
|
style="width: 100%; height: 100%">
|
|
|
+ <el-table-column prop="id" label="文章ID" width="180" show-overflow-tooltip />
|
|
|
<el-table-column prop="title" label="标题" min-width="120" show-overflow-tooltip />
|
|
|
<el-table-column prop="createdTime" label="添加时间" width="180" show-overflow-tooltip />
|
|
|
<el-table-column prop="rank" label="排序" width="120" show-overflow-tooltip />
|
|
|
- <el-table-column label="操作" width="140" header-align="center" align="center" fixed="right">
|
|
|
+ <el-table-column label="操作" width="160" header-align="center" align="center" fixed="right">
|
|
|
<template #default="{ row }">
|
|
|
- <el-button v-auth="'api:admin:notice:update'" icon="ele-EditPen" size="small" text type="primary"
|
|
|
+ <el-button size="small" text type="primary" @click="onDetail(row)">查看</el-button>
|
|
|
+ <el-button v-auth="'api:admin:article:update'" icon="ele-EditPen" size="small" text type="primary"
|
|
|
@click="onEdit(row)">编辑</el-button>
|
|
|
- <el-button v-auth="'api:admin:notice:soft-delete'" icon="ele-Delete" size="small" text type="danger"
|
|
|
+ <el-button v-auth="'api:admin:article:soft-delete'" icon="ele-Delete" size="small" text type="danger"
|
|
|
@click="onDelete(row)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -32,78 +38,81 @@
|
|
|
</div>
|
|
|
</el-card>
|
|
|
|
|
|
- <notice-form ref="noticeFormRef" :title="state.noticeFormTitle"></notice-form>
|
|
|
+ <article-form ref="AriticelFormRef" :title="state.ArticleFormTitle"></article-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script lang="ts" setup name="admin/notice/index">
|
|
|
+<script lang="ts" setup name="admin/article/index">
|
|
|
import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
|
|
|
-import { NoticeGetPageOutput, PageInputNoticeGetPageDto } from '/@/api/admin/data-contracts'
|
|
|
-import { NoticeApi } from '/@/api/admin/Notice'
|
|
|
+import { AriticleListOutput, PageInputAriticleGetPageDto } from '/@/api/admin/data-contracts'
|
|
|
+import { AriticelApi } from '/@/api/admin/Article'
|
|
|
import eventBus from '/@/utils/mitt'
|
|
|
-import { auth } from '/@/utils/authFunction'
|
|
|
|
|
|
// 引入组件
|
|
|
-const NoticeForm = defineAsyncComponent(() => import('./components/notice-form.vue'))
|
|
|
-const MyDropdownMore = defineAsyncComponent(() => import('/@/components/my-dropdown-more/index.vue'))
|
|
|
+const ArticleForm = defineAsyncComponent(() => import('./components/article-form.vue'))
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as any
|
|
|
|
|
|
-const noticeFormRef = ref()
|
|
|
+const AriticelFormRef = ref()
|
|
|
|
|
|
const state = reactive({
|
|
|
loading: false,
|
|
|
- noticeFormTitle: '',
|
|
|
+ ArticleFormTitle: '',
|
|
|
total: 0,
|
|
|
filter: {
|
|
|
-
|
|
|
+ keyword:''
|
|
|
},
|
|
|
pageInput: {
|
|
|
currentPage: 1,
|
|
|
pageSize: 20,
|
|
|
- } as PageInputNoticeGetPageDto,
|
|
|
- tenantListData: [] as Array<NoticeGetPageOutput>,
|
|
|
+ } as PageInputAriticleGetPageDto,
|
|
|
+ listData: [] as Array<AriticleListOutput>,
|
|
|
})
|
|
|
|
|
|
onMounted(() => {
|
|
|
onQuery()
|
|
|
- eventBus.off('refreshNotice')
|
|
|
- eventBus.on('refreshNotice', async () => {
|
|
|
+ eventBus.off('refreshArticle')
|
|
|
+ eventBus.on('refreshArticle', async () => {
|
|
|
onQuery()
|
|
|
})
|
|
|
})
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
- eventBus.off('refreshNotice')
|
|
|
+ eventBus.off('refreshArticle')
|
|
|
})
|
|
|
|
|
|
const onQuery = async () => {
|
|
|
state.loading = true
|
|
|
state.pageInput.filter = state.filter
|
|
|
- const res = await new NoticeApi().getPage(state.pageInput).catch(() => {
|
|
|
+ const res = await new AriticelApi().getPage(state.pageInput).catch(() => {
|
|
|
state.loading = false
|
|
|
})
|
|
|
|
|
|
- state.tenantListData = res?.data?.list ?? []
|
|
|
+ state.listData = res?.data?.list ?? []
|
|
|
state.total = res?.data?.total ?? 0
|
|
|
state.loading = false
|
|
|
}
|
|
|
|
|
|
const onAdd = () => {
|
|
|
- state.noticeFormTitle = '新增公告'
|
|
|
- noticeFormRef.value.open()
|
|
|
+ state.ArticleFormTitle = '新增文章'
|
|
|
+ AriticelFormRef.value.open()
|
|
|
}
|
|
|
|
|
|
-const onEdit = (row: NoticeGetPageOutput) => {
|
|
|
- state.noticeFormTitle = '编辑公告'
|
|
|
- noticeFormRef.value.open(row)
|
|
|
+const onEdit = (row: AriticleListOutput) => {
|
|
|
+ state.ArticleFormTitle = '编辑文章'
|
|
|
+ AriticelFormRef.value.open(row)
|
|
|
+}
|
|
|
+const onDetail = (row: AriticleListOutput) => {
|
|
|
+ state.ArticleFormTitle = '查看详情'
|
|
|
+ AriticelFormRef.value.open(row,1)
|
|
|
}
|
|
|
|
|
|
-const onDelete = (row: NoticeGetPageOutput) => {
|
|
|
+
|
|
|
+const onDelete = (row: AriticleListOutput) => {
|
|
|
proxy.$modal
|
|
|
.confirmDelete(`确定要删除【${row.title}】?`)
|
|
|
.then(async () => {
|
|
|
- await new NoticeApi().softDelete({ id: row.id }, { loading: true, showSuccessMessage: true })
|
|
|
+ await new AriticelApi().softDelete({ id: row.id }, { loading: true, showSuccessMessage: true })
|
|
|
onQuery()
|
|
|
})
|
|
|
.catch(() => { })
|