前端类型切换

This commit is contained in:
xh
2025-12-18 22:10:17 +08:00
parent acfb2356ce
commit 9178fa4b56
12 changed files with 28 additions and 555 deletions

View File

@@ -6,8 +6,8 @@ import queryString from 'query-string'
import { getToken } from '@/utils/auth'
type album_cate = {
id?: number
pid?: number
id?: string
pid?: string
// type?: number
name?: string
isDelete?: number
@@ -17,7 +17,7 @@ type album_cate = {
}
// 查询
type album_cate_query = {
pid?: number
pid?: string
// type?: number
name?: string
createTimeStart?: string
@@ -27,8 +27,8 @@ type album_cate_query = {
}
// 添加编辑
type album_cate_edit = {
id?: number
pid?: number
id?: string
pid?: string
// type?: number
name?: string
}

View File

@@ -2,8 +2,8 @@ import request from '@/utils/request'
import type { Pages } from '@/utils/request'
export type type_flow_apply = {
id?: number
templateId?: number
id?: string
templateId?: string
applyUserId?: number
applyUserNickname?: string
flowName?: string
@@ -21,7 +21,7 @@ export type type_flow_apply = {
}
// 查询
export type type_flow_apply_query = {
templateId?: number
templateId?: string
applyUserId?: number
applyUserNickname?: string
flowName?: string
@@ -39,8 +39,8 @@ export type type_flow_apply_query = {
}
// 添加编辑
export type type_flow_apply_edit = {
id?: number
templateId?: number
id?: string
templateId?: string
applyUserId?: number
applyUserNickname?: string
flowName?: string

View File

@@ -2,9 +2,9 @@ import request from '@/utils/request/index'
import type { Pages } from '@/utils/request'
export type type_flow_history = {
id?: number
applyId?: number
templateId?: number
id?: string
applyId?: string
templateId?: string
applyUserId?: number
applyUserNickname?: string
approverId?: number
@@ -21,8 +21,8 @@ export type type_flow_history = {
}
// 查询
export type type_flow_history_query = {
applyId?: number
templateId?: number
applyId?: string
templateId?: string
applyUserId?: number
applyUserNickname?: string
approverId?: number
@@ -40,9 +40,9 @@ export type type_flow_history_query = {
}
// 添加编辑
export type type_flow_history_edit = {
id?: number
applyId?: number
templateId?: number
id?: string
applyId?: string
templateId?: string
applyUserId?: number
applyUserNickname?: string
approverId?: number

View File

@@ -2,7 +2,7 @@ import request from '@/utils/request'
import type { Pages } from '@/utils/request'
export type type_flow_template = {
id?: number
id?: string
flowName?: string
flowGroup?: number
flowRemark?: string
@@ -29,7 +29,7 @@ export type type_flow_template_query = {
}
// 添加编辑
export type type_flow_template_edit = {
id?: number
id?: string
flowName?: string
flowGroup?: number
flowRemark?: string

View File

@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
import { clearEmpty } from '@/utils/util'
export type type_monitor_client = {
Id?: number
Id?: string
ProjectKey?: string
ClientId?: string
UserId?: string
@@ -41,7 +41,7 @@ export type type_monitor_client_query = {
}
// 添加编辑
export type type_monitor_client_edit = {
Id?: number
Id?: string
ProjectKey?: string
ClientId?: string
UserId?: string

View File

@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
import { clearEmpty } from '@/utils/util'
export type type_monitor_error = {
Id?: number
Id?: string
ProjectKey?: string
EventType?: string
Path?: string
@@ -29,7 +29,7 @@ export type type_monitor_error_query = {
}
// 添加编辑
export type type_monitor_error_edit = {
Id?: number
Id?: string
ProjectKey?: string
EventType?: string
Path?: string

View File

@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
import { clearEmpty } from '@/utils/util'
export type type_monitor_project = {
Id?: number
Id?: string
ProjectKey?: string
ProjectName?: string
ProjectType?: string
@@ -30,7 +30,7 @@ export type type_monitor_project_query = {
}
// 添加编辑
export type type_monitor_project_edit = {
Id?: number
Id?: string
ProjectKey?: string
ProjectName?: string
ProjectType?: string

View File

@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
import { clearEmpty } from '@/utils/util'
export type type_user_protocol = {
Id?: number
Id?: string
Tag?: string
Version?: number
Title?: string
@@ -31,7 +31,7 @@ export type type_user_protocol_query = {
}
// 添加编辑
export type type_user_protocol_edit = {
Id?: number
Id?: string
Tag?: string
Version?: number
Title?: string

View File

@@ -1,96 +0,0 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
<el-form-item label="栏目名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入栏目名称" clearable />
</el-form-item>
<el-form-item label="排序" prop="sort">
<div>
<el-input-number v-model="formData.sort" :min="0" :max="9999" />
<div class="form-tips">默认为0 数值越大越排前</div>
</div>
</el-form-item>
<el-form-item label="状态" prop="isShow">
<el-switch v-model="formData.isShow" :active-value="1" :inactive-value="0" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup>
import { ref, computed, useTemplateRef, reactive } from 'vue'
import type { FormInstance } from 'element-plus'
import { articleCateEdit, articleCateAdd, articleCateDetail } from '@/api/article'
import Popup from '@/components/popup/index.vue'
import feedback from '@/utils/feedback'
const emit = defineEmits(['success', 'close'])
const formRef = useTemplateRef<FormInstance>('formRef')
const popupRef = useTemplateRef<InstanceType<typeof Popup>>('popupRef')
const mode = ref('add')
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑栏目' : '新增栏目'
})
const formData = reactive({
id: '',
name: '',
sort: 0,
isShow: 1
})
const formRules = {
name: [
{
required: true,
message: '请输入栏目名称',
trigger: ['blur']
}
]
}
const handleSubmit = async () => {
await formRef.value?.validate()
mode.value == 'edit' ? await articleCateEdit(formData) : await articleCateAdd(formData)
feedback.msgSuccess('操作成功')
popupRef.value?.close()
emit('success')
}
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
const setFormData = (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await articleCateDetail({
id: row.id
})
setFormData(data)
}
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@@ -1,115 +0,0 @@
<template>
<div>
<el-card class="!border-none" shadow="never">
<el-alert
type="warning"
title="温馨提示:用于管理网站的分类,只可添加到一级"
:closable="false"
show-icon
/>
</el-card>
<el-card class="!border-none mt-4" shadow="never" v-loading="pager.loading">
<div>
<el-button
class="mb-4"
v-perms="['admin:article:cate:add']"
type="primary"
@click="handleAdd()"
>
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
</div>
<el-table size="large" :data="pager.lists">
<el-table-column label="栏目名称" prop="name" min-width="120" />
<el-table-column label="文章数" prop="number" min-width="120" />
<el-table-column label="状态" min-width="120">
<template #default="{ row }">
<el-switch
v-perms="['admin:article:cate:change']"
v-model="row.isShow"
:active-value="1"
:inactive-value="0"
@change="changeStatus(row.id)"
/>
</template>
</el-table-column>
<el-table-column label="排序" prop="sort" min-width="120" />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['admin:article:cate:edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['admin:article:cate:del']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<div class="flex justify-end mt-4">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
</div>
</template>
<script lang="ts" setup>
import { ref, useTemplateRef, nextTick } from 'vue'
import { articleCateDelete, articleCateLists, articleCateStatus } from '@/api/article'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
defineOptions({
name: 'articleColumn'
})
const editRef = useTemplateRef<InstanceType<typeof EditPopup>>('editRef')
const showEdit = ref(false)
const { pager, getLists } = usePaging({
fetchFun: articleCateLists
})
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
const handleEdit = async (data: any) => {
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.getDetail(data)
}
const handleDelete = async (id: number) => {
await feedback.confirm('确定要删除?')
await articleCateDelete({ id })
feedback.msgSuccess('删除成功')
getLists()
}
const changeStatus = async (id: number) => {
try {
await articleCateStatus({ id })
feedback.msgSuccess('修改成功')
getLists()
} catch (error) {
getLists()
}
}
getLists()
</script>

View File

@@ -1,179 +0,0 @@
<template>
<div class="article-edit">
<el-card class="!border-none" shadow="never">
<el-page-header content="文章编辑" @back="$router.back()" />
</el-card>
<el-card class="mt-4 !border-none" shadow="never">
<el-form
ref="formRef"
class="ls-form"
:model="formData"
label-width="85px"
:rules="rules"
>
<div class="xl:flex">
<div>
<el-form-item label="文章标题" prop="title">
<div class="w-80">
<el-input
v-model="formData.title"
placeholder="请输入文章标题"
type="textarea"
:autosize="{ minRows: 3, maxRows: 3 }"
maxlength="64"
show-word-limit
clearable
/>
</div>
</el-form-item>
<el-form-item label="文章栏目" prop="cid">
<el-select
class="w-80"
v-model="formData.cid"
placeholder="请选择文章栏目"
clearable
>
<el-option
v-for="item in optionsData.articleCate"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="文章简介" prop="intro">
<div class="w-80">
<el-input
v-model="formData.intro"
placeholder="请输入文章简介"
type="textarea"
:autosize="{ minRows: 3, maxRows: 6 }"
:maxlength="200"
show-word-limit
clearable
/>
</div>
</el-form-item>
<el-form-item label="摘要" prop="summary">
<div class="w-80">
<el-input
type="textarea"
:autosize="{ minRows: 6, maxRows: 6 }"
v-model="formData.summary"
maxlength="200"
show-word-limit
clearable
/>
</div>
</el-form-item>
<el-form-item label="文章封面" prop="image">
<div>
<div>
<material-picker v-model="formData.image" :limit="1" />
</div>
<div class="form-tips">建议尺寸240*180px</div>
</div>
</el-form-item>
<el-form-item label="作者" prop="author">
<div class="w-80">
<el-input v-model="formData.author" placeholder="请输入作者名称" />
</div>
</el-form-item>
<el-form-item label="排序" prop="sort">
<div>
<el-input-number v-model="formData.sort" :min="0" :max="9999" />
<div class="form-tips">默认为0 数值越大越排前</div>
</div>
</el-form-item>
<el-form-item label="初始浏览量" prop="visit">
<div>
<el-input-number v-model="formData.visit" />
</div>
</el-form-item>
<el-form-item label="文章状态" required prop="isShow">
<el-radio-group v-model="formData.isShow">
<el-radio :value="1">显示</el-radio>
<el-radio :value="0">隐藏</el-radio>
</el-radio-group>
</el-form-item>
</div>
<div class="xl:ml-20">
<el-form-item label="文章内容" required prop="content">
<editor v-model="formData.content" :height="667" :width="375" />
</el-form-item>
</div>
</div>
</el-form>
</el-card>
<footer-btns>
<el-button type="primary" @click="handleSave">保存</el-button>
</footer-btns>
</div>
</template>
<script lang="ts" setup>
import { reactive, useTemplateRef } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import type { FormInstance } from 'element-plus'
import feedback from '@/utils/feedback'
import { useDictOptions } from '@/hooks/useDictOptions'
import { articleCateAll, articleDetail, articleEdit, articleAdd } from '@/api/article'
import useMultipleTabs from '@/hooks/useMultipleTabs'
defineOptions({
name: 'articleListsEdit'
})
const route = useRoute()
const router = useRouter()
const formData = reactive({
id: '',
title: '',
image: '',
cid: '',
intro: '',
author: '',
content: '',
visit: 0,
sort: 0,
isShow: 1,
summary: ''
})
const { removeTab } = useMultipleTabs()
const formRef = useTemplateRef<FormInstance>('formRef')
const rules = reactive({
title: [{ required: true, message: '请输入文章标题', trigger: 'blur' }],
cid: [{ required: true, message: '请选择文章栏目', trigger: 'blur' }]
})
const getDetails = async () => {
const data = await articleDetail({
id: route.query.id
})
Object.keys(formData).forEach((key) => {
//@ts-ignore
formData[key] = data[key]
})
}
const { optionsData } = useDictOptions<{
articleCate: any[]
}>({
articleCate: {
api: articleCateAll
}
})
const handleSave = async () => {
await formRef.value?.validate()
if (route.query.id) {
await articleEdit(formData)
} else {
await articleAdd(formData)
}
feedback.msgSuccess('操作成功')
removeTab()
router.back()
}
route.query.id && getDetails()
</script>

View File

@@ -1,137 +0,0 @@
<template>
<div class="article-lists">
<el-card class="!border-none" shadow="never">
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
<el-form-item label="文章标题" class="w-[280px]">
<el-input v-model="queryParams.title" clearable @keyup.enter="resetPage" />
</el-form-item>
<el-form-item label="栏目名称" class="w-[280px]">
<el-select v-model="queryParams.cid" :empty-values="[null, undefined]">
<el-option label="全部" value />
<el-option
v-for="item in optionsData.articleCate"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="文章状态" class="w-[280px]">
<el-select v-model="queryParams.isShow" :empty-values="[null, undefined]">
<el-option label="全部" value />
<el-option label="显示" :value="1" />
<el-option label="隐藏" :value="0" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="!border-none mt-4" shadow="never">
<el-table size="large" v-loading="pager.loading" :data="pager.lists">
<el-table-column label="ID" prop="id" min-width="80" />
<el-table-column label="封面" min-width="100">
<template #default="{ row }">
<image-contain
v-if="row.image"
:src="row.image"
:width="60"
:height="45"
:preview-src-list="[row.image]"
preview-teleported
fit="contain"
/>
</template>
</el-table-column>
<el-table-column
label="标题"
prop="title"
min-width="160"
show-tooltip-when-overflow
/>
<el-table-column label="栏目" prop="category" min-width="100" />
<el-table-column label="作者" prop="author" min-width="120" />
<el-table-column label="浏览量" prop="visit" min-width="100" />
<el-table-column label="状态" min-width="100">
<template #default="{ row }">
<el-switch
v-perms="['admin:article:cate:change']"
v-model="row.isShow"
:active-value="1"
:inactive-value="0"
@change="changeStatus(row.id)"
/>
</template>
</el-table-column>
<el-table-column label="排序" prop="sort" min-width="100" />
<el-table-column label="发布时间" prop="createTime" min-width="120" />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['admin:article:del']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<div class="flex justify-end mt-4">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
</div>
</template>
<script lang="ts" setup name="articleLists">
import { reactive, onActivated } from 'vue'
import { articleLists, articleDelete, articleStatus, articleCateAll } from '@/api/article'
import { useDictOptions } from '@/hooks/useDictOptions'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
const queryParams = reactive({
title: '',
cid: '',
isShow: ''
})
const { pager, getLists, resetPage, resetParams } = usePaging({
fetchFun: articleLists,
params: queryParams
})
const { optionsData } = useDictOptions<{
articleCate: any[]
}>({
articleCate: {
api: articleCateAll
}
})
const changeStatus = async (id: number) => {
try {
await articleStatus({ id })
feedback.msgSuccess('修改成功')
getLists()
} catch (error) {
getLists()
}
}
const handleDelete = async (id: number) => {
await feedback.confirm('确定要删除?')
await articleDelete({ id })
feedback.msgSuccess('删除成功')
getLists()
}
onActivated(() => {
getLists()
})
getLists()
</script>