feat(F006): 资讯列表状态列 + 弹窗1200px + 暂存/发布双按钮

This commit is contained in:
zou 2026-08-28 17:51:13 +08:00
parent 00650f487a
commit 34b9a31e0f

View File

@ -24,6 +24,7 @@ interface Info {
content: string content: string
images: string images: string
createTime: string createTime: string
status?: number
} }
const list = ref<Info[]>([]) const list = ref<Info[]>([])
@ -54,6 +55,7 @@ const columns = [
{ prop: 'id', label: 'ID', width: 90 }, { prop: 'id', label: 'ID', width: 90 },
{ prop: 'title', label: '资讯标题', minWidth: 260 }, { prop: 'title', label: '资讯标题', minWidth: 260 },
{ prop: 'categoryName', label: '分类', width: 120, formatter: (r: Info) => r.categoryName || '--' }, { prop: 'categoryName', label: '分类', width: 120, formatter: (r: Info) => r.categoryName || '--' },
{ prop: 'status', label: '状态', width: 90, formatter: (r: Info) => r.status === 0 ? '草稿' : '已发布' },
{ prop: 'createTime', label: '发布时间', width: 170 }, { prop: 'createTime', label: '发布时间', width: 170 },
] ]
@ -67,7 +69,7 @@ const imgStyle = computed(() => ({
async function load() { async function load() {
loading.value = true loading.value = true
try { try {
const params: any = { page: query.page, limit: query.limit } const params: any = { page: query.page, limit: query.limit, status: 'all' }
if (search.title.trim()) params.title = search.title.trim() if (search.title.trim()) params.title = search.title.trim()
const resp: any = await httpGet('/other/information/page', params) const resp: any = await httpGet('/other/information/page', params)
list.value = resp?.list || [] list.value = resp?.list || []
@ -113,7 +115,7 @@ function onCategoryChange(id: string) {
const c = categories.value.find(x => x.id === id) const c = categories.value.find(x => x.id === id)
editForm.categoryName = c?.name || '' editForm.categoryName = c?.name || ''
} }
async function submit() { async function submit(status: number) {
if (!editForm.title.trim()) { ElMessage.warning('请填写标题'); return } if (!editForm.title.trim()) { ElMessage.warning('请填写标题'); return }
if (!editForm.categoryId) { ElMessage.warning('请选择分类'); return } if (!editForm.categoryId) { ElMessage.warning('请选择分类'); return }
saving.value = true saving.value = true
@ -124,6 +126,7 @@ async function submit() {
categoryName: editForm.categoryName, categoryName: editForm.categoryName,
content: richEditorRef.value?.getContent?.() ?? editForm.content, content: richEditorRef.value?.getContent?.() ?? editForm.content,
images: editForm.images, images: editForm.images,
status,
} }
if (editMode.value === 'create') { if (editMode.value === 'create') {
await httpPost('/other/information/save', payload) await httpPost('/other/information/save', payload)
@ -217,7 +220,7 @@ async function customUpload(opt: any) {
</div> </div>
<!-- 新增/编辑弹窗 --> <!-- 新增/编辑弹窗 -->
<el-dialog v-model="dialogVisible" :title="editMode === 'create' ? '新增资讯' : '编辑资讯'" width="640px" destroy-on-close> <el-dialog v-model="dialogVisible" :title="editMode === 'create' ? '新增资讯' : '编辑资讯'" width="1200px" destroy-on-close>
<el-form label-width="90px" label-position="right"> <el-form label-width="90px" label-position="right">
<el-form-item label="标题" required> <el-form-item label="标题" required>
<el-input v-model="editForm.title" placeholder="资讯标题" maxlength="50" show-word-limit /> <el-input v-model="editForm.title" placeholder="资讯标题" maxlength="50" show-word-limit />
@ -246,7 +249,8 @@ async function customUpload(opt: any) {
</el-form> </el-form>
<template #footer> <template #footer>
<el-button @click="dialogVisible = false">取消</el-button> <el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="submit">保存</el-button> <el-button :loading="saving" @click="submit(0)">暂存</el-button>
<el-button type="primary" :loading="saving" @click="submit(1)">发布</el-button>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>