|
@@ -0,0 +1,131 @@
|
|
|
+<template>
|
|
|
+ <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-button v-auth="'api:admin:notice: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%'" style="width: 100%; height: 100%">
|
|
|
+ <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">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-button v-auth="'api:admin:notice:update'" icon="ele-EditPen" size="small" text type="primary" @click="onEdit(row)">编辑</el-button>
|
|
|
+ <my-dropdown-more v-auths="['api:admin:notice:delete']">
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu>
|
|
|
+ <el-dropdown-item v-if="auth('api:admin:notice:delete')" @click="onDelete(row)">删除租户</el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </my-dropdown-more>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <div class="my-flex my-flex-end" style="margin-top: 20px">
|
|
|
+ <el-pagination
|
|
|
+ v-model:currentPage="state.pageInput.currentPage"
|
|
|
+ v-model:page-size="state.pageInput.pageSize"
|
|
|
+ :total="state.total"
|
|
|
+ :page-sizes="[10, 20, 50, 100]"
|
|
|
+ small
|
|
|
+ background
|
|
|
+ @size-change="onSizeChange"
|
|
|
+ @current-change="onCurrentChange"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+
|
|
|
+ <notice-form ref="noticeFormRef" :title="state.noticeFormTitle"></notice-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup name="admin/notice">
|
|
|
+import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
|
|
|
+import { NoticeGetPageOutput, PageInputNoticeGetPageDto } from '/@/api/admin/data-contracts'
|
|
|
+import { NoticeApi } from '/@/api/admin/Notice'
|
|
|
+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 { proxy } = getCurrentInstance() as any
|
|
|
+
|
|
|
+const noticeFormRef = ref()
|
|
|
+
|
|
|
+const state = reactive({
|
|
|
+ loading: false,
|
|
|
+ noticeFormTitle: '',
|
|
|
+ total: 0,
|
|
|
+ filter: {
|
|
|
+
|
|
|
+ },
|
|
|
+ pageInput: {
|
|
|
+ currentPage: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ } as PageInputNoticeGetPageDto,
|
|
|
+ tenantListData: [] as Array<NoticeGetPageOutput>,
|
|
|
+})
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ onQuery()
|
|
|
+ eventBus.off('refreshNotice')
|
|
|
+ eventBus.on('refreshNotice', async () => {
|
|
|
+ onQuery()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+onBeforeMount(() => {
|
|
|
+ eventBus.off('refreshNotice')
|
|
|
+})
|
|
|
+
|
|
|
+const onQuery = async () => {
|
|
|
+ state.loading = true
|
|
|
+ state.pageInput.filter = state.filter
|
|
|
+ const res = await new NoticeApi().getPage(state.pageInput).catch(() => {
|
|
|
+ state.loading = false
|
|
|
+ })
|
|
|
+
|
|
|
+ state.tenantListData = res?.data?.list ?? []
|
|
|
+ state.total = res?.data?.total ?? 0
|
|
|
+ state.loading = false
|
|
|
+}
|
|
|
+
|
|
|
+const onAdd = () => {
|
|
|
+ state.noticeFormTitle = '新增公告'
|
|
|
+ noticeFormRef.value.open()
|
|
|
+}
|
|
|
+
|
|
|
+const onEdit = (row: NoticeGetPageOutput) => {
|
|
|
+ state.noticeFormTitle = '编辑公告'
|
|
|
+ noticeFormRef.value.open(row)
|
|
|
+}
|
|
|
+
|
|
|
+const onDelete = (row: NoticeGetPageOutput) => {
|
|
|
+ proxy.$modal
|
|
|
+ .confirmDelete(`确定要删除【${row.title}】?`)
|
|
|
+ .then(async () => {
|
|
|
+ await new NoticeApi().softDelete({ id: row.id }, { loading: true, showSuccessMessage: true })
|
|
|
+ onQuery()
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+}
|
|
|
+
|
|
|
+const onSizeChange = (val: number) => {
|
|
|
+ state.pageInput.pageSize = val
|
|
|
+ onQuery()
|
|
|
+}
|
|
|
+
|
|
|
+const onCurrentChange = (val: number) => {
|
|
|
+ state.pageInput.currentPage = val
|
|
|
+ onQuery()
|
|
|
+}
|
|
|
+</script>
|