|
@@ -17,8 +17,17 @@
|
|
|
<n-button round @click="showLogin = true" type="primary" size="small">登录</n-button>
|
|
<n-button round @click="showLogin = true" type="primary" size="small">登录</n-button>
|
|
|
</template>
|
|
</template>
|
|
|
</NLayoutHeader>
|
|
</NLayoutHeader>
|
|
|
- <NLayoutContent position="absolute" style="top: 64px; bottom: 0" class="px-8 py-4">
|
|
|
|
|
- <NSpace class="pb-8">
|
|
|
|
|
|
|
+ <NLayoutContent
|
|
|
|
|
+ position="absolute"
|
|
|
|
|
+ style="top: 64px; bottom: 0"
|
|
|
|
|
+ class="px-8 py-4"
|
|
|
|
|
+ content-style="display:flex !important;flex-direction:column"
|
|
|
|
|
+ >
|
|
|
|
|
+ <NSpace class="pb-4">
|
|
|
|
|
+ <n-input-group @keyup.enter="getData">
|
|
|
|
|
+ <n-input clearable v-model:value="search"/>
|
|
|
|
|
+ <n-button type="primary" ghost @click="getData(true)"> 搜索 </n-button>
|
|
|
|
|
+ </n-input-group>
|
|
|
<NButton type="primary" @click="onCreate">创建</NButton>
|
|
<NButton type="primary" @click="onCreate">创建</NButton>
|
|
|
</NSpace>
|
|
</NSpace>
|
|
|
<n-data-table
|
|
<n-data-table
|
|
@@ -27,7 +36,10 @@
|
|
|
:data="tableData"
|
|
:data="tableData"
|
|
|
:pagination="paginationReactive"
|
|
:pagination="paginationReactive"
|
|
|
:bordered="false"
|
|
:bordered="false"
|
|
|
- @update:page="getData"
|
|
|
|
|
|
|
+ @update:page="getData(false)"
|
|
|
|
|
+ @update:page-size="getData(true)"
|
|
|
|
|
+ v-bind:flex-height="true"
|
|
|
|
|
+ class="flex-1"
|
|
|
/>
|
|
/>
|
|
|
</NLayoutContent>
|
|
</NLayoutContent>
|
|
|
</NLayout>
|
|
</NLayout>
|
|
@@ -40,6 +52,7 @@
|
|
|
:pagination="resultsPagination"
|
|
:pagination="resultsPagination"
|
|
|
:bordered="false"
|
|
:bordered="false"
|
|
|
@update:page="getResults"
|
|
@update:page="getResults"
|
|
|
|
|
+ @update:page-size="getResults"
|
|
|
/>
|
|
/>
|
|
|
</n-card>
|
|
</n-card>
|
|
|
</n-modal>
|
|
</n-modal>
|
|
@@ -135,7 +148,8 @@ import {
|
|
|
NPopover,
|
|
NPopover,
|
|
|
NDropdown,
|
|
NDropdown,
|
|
|
NDrawer,
|
|
NDrawer,
|
|
|
- NDrawerContent
|
|
|
|
|
|
|
+ NDrawerContent,
|
|
|
|
|
+ NInputGroup
|
|
|
} from 'naive-ui'
|
|
} from 'naive-ui'
|
|
|
import {
|
|
import {
|
|
|
fetchPaperOrders,
|
|
fetchPaperOrders,
|
|
@@ -158,7 +172,9 @@ import { t } from '@/locales'
|
|
|
import Vditor from 'vditor'
|
|
import Vditor from 'vditor'
|
|
|
import 'vditor/src/assets/less/index.less'
|
|
import 'vditor/src/assets/less/index.less'
|
|
|
import OutlineEditor from '@/components/common/OutlineEditor.vue'
|
|
import OutlineEditor from '@/components/common/OutlineEditor.vue'
|
|
|
|
|
+import { useRouter } from 'vue-router'
|
|
|
|
|
|
|
|
|
|
+const router = useRouter()
|
|
|
const message = useMessage()
|
|
const message = useMessage()
|
|
|
const showLogin = ref(false)
|
|
const showLogin = ref(false)
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
@@ -167,6 +183,9 @@ const dialog = useDialog()
|
|
|
const isLogin = computed(() => {
|
|
const isLogin = computed(() => {
|
|
|
return !!userInfo.value.id
|
|
return !!userInfo.value.id
|
|
|
})
|
|
})
|
|
|
|
|
+const roles = computed(() => {
|
|
|
|
|
+ return userInfo.value?.roles || []
|
|
|
|
|
+})
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
getData()
|
|
getData()
|
|
|
if (!isLogin.value) {
|
|
if (!isLogin.value) {
|
|
@@ -200,12 +219,13 @@ const columns: DataTableColumn[] = [
|
|
|
{
|
|
{
|
|
|
title: '#',
|
|
title: '#',
|
|
|
key: 'id',
|
|
key: 'id',
|
|
|
- width: 150
|
|
|
|
|
|
|
+ width: 100
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: '创建时间',
|
|
title: '创建时间',
|
|
|
key: 'createdAt',
|
|
key: 'createdAt',
|
|
|
- render: timeFormatter
|
|
|
|
|
|
|
+ render: timeFormatter,
|
|
|
|
|
+ width: 180
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
title: '标题',
|
|
title: '标题',
|
|
@@ -246,15 +266,17 @@ const columns: DataTableColumn[] = [
|
|
|
width: '250px',
|
|
width: '250px',
|
|
|
render(row: any) {
|
|
render(row: any) {
|
|
|
return h(NSpace, { justify: 'center' }, () => [
|
|
return h(NSpace, { justify: 'center' }, () => [
|
|
|
- h(
|
|
|
|
|
- NButton,
|
|
|
|
|
- {
|
|
|
|
|
- type: 'primary',
|
|
|
|
|
- size: 'small',
|
|
|
|
|
- onClick: () => gen(row)
|
|
|
|
|
- },
|
|
|
|
|
- () => '生成'
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ roles.value.includes('paperGen')
|
|
|
|
|
+ ? h(
|
|
|
|
|
+ NButton,
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'primary',
|
|
|
|
|
+ size: 'small',
|
|
|
|
|
+ onClick: () => gen(row)
|
|
|
|
|
+ },
|
|
|
|
|
+ () => '生成'
|
|
|
|
|
+ )
|
|
|
|
|
+ : null,
|
|
|
h(
|
|
h(
|
|
|
NButton,
|
|
NButton,
|
|
|
{
|
|
{
|
|
@@ -264,16 +286,18 @@ const columns: DataTableColumn[] = [
|
|
|
},
|
|
},
|
|
|
{ default: () => '查看' }
|
|
{ default: () => '查看' }
|
|
|
),
|
|
),
|
|
|
- h(
|
|
|
|
|
- NButton,
|
|
|
|
|
- {
|
|
|
|
|
- strong: true,
|
|
|
|
|
- tertiary: true,
|
|
|
|
|
- size: 'small',
|
|
|
|
|
- onClick: () => editRow(row)
|
|
|
|
|
- },
|
|
|
|
|
- { default: () => '编辑' }
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ roles.value.includes('paperGen')
|
|
|
|
|
+ ? h(
|
|
|
|
|
+ NButton,
|
|
|
|
|
+ {
|
|
|
|
|
+ strong: true,
|
|
|
|
|
+ tertiary: true,
|
|
|
|
|
+ size: 'small',
|
|
|
|
|
+ onClick: () => editRow(row)
|
|
|
|
|
+ },
|
|
|
|
|
+ { default: () => '编辑' }
|
|
|
|
|
+ )
|
|
|
|
|
+ : null
|
|
|
])
|
|
])
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -281,9 +305,9 @@ const columns: DataTableColumn[] = [
|
|
|
|
|
|
|
|
const paginationReactive = reactive({
|
|
const paginationReactive = reactive({
|
|
|
page: 1,
|
|
page: 1,
|
|
|
- pageSize: 10,
|
|
|
|
|
- showSizePicker: false,
|
|
|
|
|
- pageSizes: [10],
|
|
|
|
|
|
|
+ pageSize: 20,
|
|
|
|
|
+ showSizePicker: true,
|
|
|
|
|
+ pageSizes: [10, 20, 50, 100],
|
|
|
pageCount: 1,
|
|
pageCount: 1,
|
|
|
onChange: (page: number) => {
|
|
onChange: (page: number) => {
|
|
|
paginationReactive.page = page
|
|
paginationReactive.page = page
|
|
@@ -293,21 +317,32 @@ const paginationReactive = reactive({
|
|
|
paginationReactive.page = 1
|
|
paginationReactive.page = 1
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
-async function getData() {
|
|
|
|
|
- const res: any = await fetchPaperOrders({
|
|
|
|
|
- page: {
|
|
|
|
|
- page: paginationReactive.page,
|
|
|
|
|
- limit: paginationReactive.pageSize
|
|
|
|
|
- },
|
|
|
|
|
- search: {
|
|
|
|
|
- order: {
|
|
|
|
|
- createdAt: 'desc'
|
|
|
|
|
|
|
+const search = ref('')
|
|
|
|
|
+async function getData(reset = false) {
|
|
|
|
|
+ if (reset) {
|
|
|
|
|
+ paginationReactive.page = 1
|
|
|
|
|
+ }
|
|
|
|
|
+ if (roles.value.includes('paperGen') || roles.value.includes('paperOrder')) {
|
|
|
|
|
+ const res: any = await fetchPaperOrders({
|
|
|
|
|
+ page: {
|
|
|
|
|
+ page: paginationReactive.page,
|
|
|
|
|
+ limit: paginationReactive.pageSize
|
|
|
|
|
+ },
|
|
|
|
|
+ search: {
|
|
|
|
|
+ where: {
|
|
|
|
|
+ title: search.value || undefined
|
|
|
|
|
+ },
|
|
|
|
|
+ order: {
|
|
|
|
|
+ createdAt: 'desc'
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- tableData.value = res.items
|
|
|
|
|
- paginationReactive.pageCount = res.meta.totalPages
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ tableData.value = res.items
|
|
|
|
|
+ paginationReactive.pageCount = res.meta.totalPages
|
|
|
|
|
+ } else {
|
|
|
|
|
+ tableData.value = []
|
|
|
|
|
+ paginationReactive.pageCount = 1
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function gen(row: any) {
|
|
async function gen(row: any) {
|
|
@@ -458,16 +493,28 @@ const rules = {
|
|
|
}
|
|
}
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
function onCreate() {
|
|
function onCreate() {
|
|
|
- orderId.value = null
|
|
|
|
|
- model.value = {
|
|
|
|
|
- major: '',
|
|
|
|
|
- title: '',
|
|
|
|
|
- description: '',
|
|
|
|
|
- remark: '',
|
|
|
|
|
- chapters: []
|
|
|
|
|
|
|
+ if (roles.value.includes('paperGen') || roles.value.includes('paperOrder')) {
|
|
|
|
|
+ orderId.value = null
|
|
|
|
|
+ model.value = {
|
|
|
|
|
+ major: '',
|
|
|
|
|
+ title: '',
|
|
|
|
|
+ description: '',
|
|
|
|
|
+ remark: '',
|
|
|
|
|
+ chapters: []
|
|
|
|
|
+ }
|
|
|
|
|
+ form.value?.restoreValidation()
|
|
|
|
|
+ showForm.value = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dialog.error({
|
|
|
|
|
+ title: '无权限',
|
|
|
|
|
+ positiveText: '返回首页',
|
|
|
|
|
+ closable: false,
|
|
|
|
|
+ maskClosable: false,
|
|
|
|
|
+ onPositiveClick: () => {
|
|
|
|
|
+ router.replace('/home')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- form.value?.restoreValidation()
|
|
|
|
|
- showForm.value = true
|
|
|
|
|
}
|
|
}
|
|
|
async function submit() {
|
|
async function submit() {
|
|
|
try {
|
|
try {
|