|
@@ -2,7 +2,7 @@
|
|
|
<CommonPage>
|
|
|
<template #action>
|
|
|
<NButton type="primary" @click="router.push('article/add')">
|
|
|
- <i class="i-material-symbols:add mr-4 text-18"/>
|
|
|
+ <i class="i-material-symbols:add mr-4 text-18" />
|
|
|
新增文章
|
|
|
</NButton>
|
|
|
</template>
|
|
@@ -10,7 +10,7 @@
|
|
|
<MeCrud ref="$table" v-model:query-items="queryItems" :scroll-x="1200" :columns="columns" :get-data="api.read">
|
|
|
<MeQueryItem label="标题" :label-width="50">
|
|
|
<n-input v-model:value="queryItems.title" type="text" placeholder="请输入标题名" clearable>
|
|
|
- <template #password-visible-icon/>
|
|
|
+ <template #password-visible-icon />
|
|
|
</n-input>
|
|
|
</MeQueryItem>
|
|
|
<MeQueryItem label="状态" :label-width="50">
|
|
@@ -26,13 +26,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import {MeCrud, MeQueryItem} from '@/components'
|
|
|
-import {useCrud} from '@/composables'
|
|
|
-import {formatDateTime} from '@/utils'
|
|
|
-import {NButton, NSwitch} from 'naive-ui'
|
|
|
+import { MeCrud, MeQueryItem } from '@/components'
|
|
|
+import { useCrud } from '@/composables'
|
|
|
+import { formatDateTime } from '@/utils'
|
|
|
+import { NButton, NSwitch } from 'naive-ui'
|
|
|
import api from './api'
|
|
|
|
|
|
-defineOptions({name: 'RoleMgt'})
|
|
|
+defineOptions({ name: 'RoleMgt' })
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
@@ -44,19 +44,19 @@ onMounted(() => {
|
|
|
$table.value?.handleSearch()
|
|
|
})
|
|
|
|
|
|
-const {handleDelete}
|
|
|
+const { handleDelete }
|
|
|
= useCrud({
|
|
|
- name: '文章',
|
|
|
- doCreate: api.create,
|
|
|
- doDelete: api.delete,
|
|
|
- doUpdate: api.update,
|
|
|
- initForm: {enable: true},
|
|
|
- refresh: (_, keepCurrentPage) => $table.value?.handleSearch(keepCurrentPage),
|
|
|
-})
|
|
|
+ name: '文章',
|
|
|
+ doCreate: api.create,
|
|
|
+ doDelete: api.delete,
|
|
|
+ doUpdate: api.update,
|
|
|
+ initForm: { enable: true },
|
|
|
+ refresh: (_, keepCurrentPage) => $table.value?.handleSearch(keepCurrentPage),
|
|
|
+ })
|
|
|
|
|
|
const columns = [
|
|
|
- {title: '标题名', key: 'title', width: '200'},
|
|
|
- {title: '分类', key: 'category.title'},
|
|
|
+ { title: '标题名', key: 'title', width: '200' },
|
|
|
+ { title: '分类', key: 'category.title' },
|
|
|
{
|
|
|
title: '内容',
|
|
|
key: 'content',
|
|
@@ -107,7 +107,7 @@ const columns = [
|
|
|
},
|
|
|
{
|
|
|
default: () => '编辑',
|
|
|
- icon: () => h('i', {class: 'i-material-symbols:edit-outline text-14'}),
|
|
|
+ icon: () => h('i', { class: 'i-material-symbols:edit-outline text-14' }),
|
|
|
},
|
|
|
),
|
|
|
|
|
@@ -122,7 +122,7 @@ const columns = [
|
|
|
},
|
|
|
{
|
|
|
default: () => '删除',
|
|
|
- icon: () => h('i', {class: 'i-material-symbols:delete-outline text-14'}),
|
|
|
+ icon: () => h('i', { class: 'i-material-symbols:delete-outline text-14' }),
|
|
|
},
|
|
|
),
|
|
|
]
|
|
@@ -133,11 +133,12 @@ const columns = [
|
|
|
async function handleEnable(row) {
|
|
|
row.enableLoading = true
|
|
|
try {
|
|
|
- await api.update({id: row.id, enable: !row.enable})
|
|
|
+ await api.update({ id: row.id, enable: !row.enable })
|
|
|
row.enableLoading = false
|
|
|
$message.success('操作成功')
|
|
|
$table.value?.handleSearch()
|
|
|
- } catch (error) {
|
|
|
+ }
|
|
|
+ catch (error) {
|
|
|
console.error(error)
|
|
|
row.enableLoading = false
|
|
|
}
|