feat:新增发布和取消发布接口
This commit is contained in:
parent
763173de44
commit
deeb3a472c
@ -20,6 +20,17 @@ export const post = (url: string, data?: object, headersType?: string) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const put = (url: string, data?: object, headersType?: string) => {
|
||||||
|
return axiosInstance({
|
||||||
|
url: url,
|
||||||
|
method: RequestHttpEnum.PUT,
|
||||||
|
data: data,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': headersType || ContentTypeEnum.JSON
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const del = (url: string, params?: object) => {
|
export const del = (url: string, params?: object) => {
|
||||||
return axiosInstance({
|
return axiosInstance({
|
||||||
url: url,
|
url: url,
|
||||||
@ -30,11 +41,20 @@ export const del = (url: string, params?: object) => {
|
|||||||
|
|
||||||
// 获取请求函数,默认get
|
// 获取请求函数,默认get
|
||||||
export const http = (type?: RequestHttpEnum) => {
|
export const http = (type?: RequestHttpEnum) => {
|
||||||
return type === RequestHttpEnum.GET
|
switch (type) {
|
||||||
? get
|
case RequestHttpEnum.GET:
|
||||||
: type === RequestHttpEnum.POST
|
return get
|
||||||
? post
|
|
||||||
: type === RequestHttpEnum.DELETE
|
case RequestHttpEnum.POST:
|
||||||
? del
|
return post
|
||||||
: get
|
|
||||||
|
case RequestHttpEnum.PUT:
|
||||||
|
return put
|
||||||
|
|
||||||
|
case RequestHttpEnum.DELETE:
|
||||||
|
return del
|
||||||
|
|
||||||
|
default:
|
||||||
|
return get
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,14 @@ export const deleteProjectApi = async (data: object) => {
|
|||||||
} catch {
|
} catch {
|
||||||
httpErrorHandle();
|
httpErrorHandle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// * 修改发布状态 [-1未发布,1发布]
|
||||||
|
export const changeProjectReleaseApi = async (data: object) => {
|
||||||
|
try {
|
||||||
|
const res = await http(RequestHttpEnum.PUT)(`${ModuleTypeEnum.PROJECT}/publish`, data);
|
||||||
|
return res;
|
||||||
|
} catch {
|
||||||
|
httpErrorHandle();
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,11 +20,16 @@ const global = {
|
|||||||
r_edit: '编辑',
|
r_edit: '编辑',
|
||||||
r_preview: '预览',
|
r_preview: '预览',
|
||||||
r_copy: '克隆',
|
r_copy: '克隆',
|
||||||
|
r_copy_success: '克隆成功!',
|
||||||
r_rename: '重命名',
|
r_rename: '重命名',
|
||||||
|
r_rename_success: '重命名成功!',
|
||||||
r_publish: '发布',
|
r_publish: '发布',
|
||||||
|
r_publish_success: '成功发布!',
|
||||||
r_unpublish: '取消发布',
|
r_unpublish: '取消发布',
|
||||||
|
r_unpublish_success: '取消成功!',
|
||||||
r_download: '下载',
|
r_download: '下载',
|
||||||
r_delete: '删除',
|
r_delete: '删除',
|
||||||
|
r_delete_success: '删除成功!',
|
||||||
r_more: '更多',
|
r_more: '更多',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,10 @@ import { SketchRule } from 'vue3-sketch-ruler'
|
|||||||
* @param app
|
* @param app
|
||||||
*/
|
*/
|
||||||
export function setupCustomComponents(app: App) {
|
export function setupCustomComponents(app: App) {
|
||||||
|
// 骨架屏
|
||||||
app.component('GoSkeleton', GoSkeleton)
|
app.component('GoSkeleton', GoSkeleton)
|
||||||
|
// 加载
|
||||||
app.component('GoLoading', GoLoading)
|
app.component('GoLoading', GoLoading)
|
||||||
|
// 标尺
|
||||||
app.component('SketchRule', SketchRule)
|
app.component('SketchRule', SketchRule)
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ const {
|
|||||||
SendIcon
|
SendIcon
|
||||||
} = icon.ionicons5
|
} = icon.ionicons5
|
||||||
|
|
||||||
const emit = defineEmits(['delete', 'resize', 'edit'])
|
const emit = defineEmits(['delete', 'resize', 'edit', 'release'])
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
cardData: Object as PropType<Chartype>
|
cardData: Object as PropType<Chartype>
|
||||||
@ -146,7 +146,7 @@ const selectOptions = ref([
|
|||||||
label: props.cardData?.release
|
label: props.cardData?.release
|
||||||
? renderLang('global.r_unpublish')
|
? renderLang('global.r_unpublish')
|
||||||
: renderLang('global.r_publish'),
|
: renderLang('global.r_publish'),
|
||||||
key: 'send',
|
key: 'release',
|
||||||
icon: renderIcon(SendIcon)
|
icon: renderIcon(SendIcon)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -170,6 +170,9 @@ const handleSelect = (key: string) => {
|
|||||||
case 'delete':
|
case 'delete':
|
||||||
deleteHanlde()
|
deleteHanlde()
|
||||||
break
|
break
|
||||||
|
case 'release':
|
||||||
|
releaseHandle()
|
||||||
|
break
|
||||||
case 'edit':
|
case 'edit':
|
||||||
editHandle()
|
editHandle()
|
||||||
break
|
break
|
||||||
@ -186,6 +189,11 @@ const editHandle = () => {
|
|||||||
emit('edit', props.cardData)
|
emit('edit', props.cardData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 编辑处理
|
||||||
|
const releaseHandle = () => {
|
||||||
|
emit('release', props.cardData)
|
||||||
|
}
|
||||||
|
|
||||||
// 放大处理
|
// 放大处理
|
||||||
const resizeHandle = () => {
|
const resizeHandle = () => {
|
||||||
emit('resize', props.cardData)
|
emit('resize', props.cardData)
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive } from 'vue';
|
||||||
import { goDialog, httpErrorHandle } from '@/utils'
|
import { goDialog, httpErrorHandle } from '@/utils'
|
||||||
import { DialogEnum } from '@/enums/pluginEnum'
|
import { DialogEnum } from '@/enums/pluginEnum'
|
||||||
import { projectListApi, deleteProjectApi } from '@/api/path/project'
|
import { projectListApi, deleteProjectApi, changeProjectReleaseApi } from '@/api/path/project'
|
||||||
import { Chartype, ChartList } from '../../../index.d'
|
import { Chartype, ChartList } from '../../../index.d'
|
||||||
import { ResultEnum } from '@/enums/httpEnum'
|
import { ResultEnum } from '@/enums/httpEnum'
|
||||||
|
|
||||||
// 数据初始化
|
// 数据初始化
|
||||||
export const useDataListInit = () => {
|
export const useDataListInit = () => {
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
|
||||||
const paginat = reactive({
|
const paginat = reactive({
|
||||||
// 当前页数
|
// 当前页数
|
||||||
page: 1,
|
page: 1,
|
||||||
// 每页值
|
// 每页值
|
||||||
limit: 12,
|
limit: 12,
|
||||||
@ -21,6 +23,7 @@ export const useDataListInit = () => {
|
|||||||
|
|
||||||
// 数据请求
|
// 数据请求
|
||||||
const fetchList = async () => {
|
const fetchList = async () => {
|
||||||
|
loading.value = true
|
||||||
const res: any = await projectListApi({
|
const res: any = await projectListApi({
|
||||||
page: paginat.page,
|
page: paginat.page,
|
||||||
limit: paginat.limit
|
limit: paginat.limit
|
||||||
@ -38,7 +41,12 @@ export const useDataListInit = () => {
|
|||||||
release: state !== -1
|
release: state !== -1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
loading.value = false
|
||||||
|
}, 500)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
httpErrorHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改页数
|
// 修改页数
|
||||||
@ -53,8 +61,8 @@ export const useDataListInit = () => {
|
|||||||
fetchList()
|
fetchList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除处理
|
||||||
const deleteHandle = (cardData: Chartype, index: number) => {
|
const deleteHandle = (cardData: Chartype) => {
|
||||||
goDialog({
|
goDialog({
|
||||||
type: DialogEnum.DELETE,
|
type: DialogEnum.DELETE,
|
||||||
promise: true,
|
promise: true,
|
||||||
@ -65,7 +73,7 @@ export const useDataListInit = () => {
|
|||||||
}),
|
}),
|
||||||
promiseResCallback: (res: any) => {
|
promiseResCallback: (res: any) => {
|
||||||
if (res.code === ResultEnum.SUCCESS) {
|
if (res.code === ResultEnum.SUCCESS) {
|
||||||
window['$message'].success('删除成功')
|
window['$message'].success(window['$t']('global.r_delete_success'))
|
||||||
fetchList()
|
fetchList()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -74,13 +82,40 @@ export const useDataListInit = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发布处理
|
||||||
|
const releaseHandle = async (cardData: Chartype, index: number) => {
|
||||||
|
const { id, release } = cardData
|
||||||
|
const res: any = await changeProjectReleaseApi({
|
||||||
|
id: id,
|
||||||
|
// [-1未发布, 1发布]
|
||||||
|
state: !release ? 1 : -1
|
||||||
|
})
|
||||||
|
if (res.code === ResultEnum.SUCCESS) {
|
||||||
|
list.value = []
|
||||||
|
fetchList()
|
||||||
|
// 发布 -> 未发布
|
||||||
|
if (release) {
|
||||||
|
window['$message'].success(window['$t']('global.r_unpublish_success'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 未发布 -> 发布
|
||||||
|
window['$message'].success(window['$t']('global.r_publish_success'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
httpErrorHandle()
|
||||||
|
}
|
||||||
|
|
||||||
// 立即请求
|
// 立即请求
|
||||||
fetchList()
|
fetchList()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
loading,
|
||||||
paginat,
|
paginat,
|
||||||
list,
|
list,
|
||||||
fetchList, changeSize, changePage,
|
fetchList,
|
||||||
|
releaseHandle,
|
||||||
|
changeSize,
|
||||||
|
changePage,
|
||||||
deleteHandle
|
deleteHandle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ref, Ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { ChartEnum } from '@/enums/pageEnum'
|
import { ChartEnum } from '@/enums/pageEnum'
|
||||||
import { fetchPathByName, routerTurnByPath } from '@/utils'
|
import { fetchPathByName, routerTurnByPath } from '@/utils'
|
||||||
import { Chartype } from '../../../index.d'
|
import { Chartype } from '../../../index.d'
|
||||||
|
@ -1,20 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="go-items-list">
|
<div class="go-items-list">
|
||||||
<n-grid
|
<!-- 加载 -->
|
||||||
:x-gap="20"
|
<div v-show="loading">
|
||||||
:y-gap="20"
|
<go-loading></go-loading>
|
||||||
cols="2 s:2 m:3 l:4 xl:4 xxl:4"
|
</div>
|
||||||
responsive="screen"
|
<!-- 列表 -->
|
||||||
>
|
<div v-show="!loading">
|
||||||
<n-grid-item v-for="(item, index) in list" :key="item.id">
|
<n-grid
|
||||||
<project-items-card
|
:x-gap="20"
|
||||||
:cardData="item"
|
:y-gap="20"
|
||||||
@resize="resizeHandle"
|
cols="2 s:2 m:3 l:4 xl:4 xxl:4"
|
||||||
@delete="deleteHandle(item, index)"
|
responsive="screen"
|
||||||
@edit="editHandle"
|
>
|
||||||
></project-items-card>
|
<n-grid-item v-for="(item, index) in list" :key="item.id">
|
||||||
</n-grid-item>
|
<project-items-card
|
||||||
</n-grid>
|
:cardData="item"
|
||||||
|
@resize="resizeHandle"
|
||||||
|
@delete="deleteHandle(item)"
|
||||||
|
@release="releaseHandle(item, index)"
|
||||||
|
@edit="editHandle"
|
||||||
|
></project-items-card>
|
||||||
|
</n-grid-item>
|
||||||
|
</n-grid>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 分页 -->
|
||||||
<div class="list-pagination">
|
<div class="list-pagination">
|
||||||
<n-pagination
|
<n-pagination
|
||||||
:page="paginat.page"
|
:page="paginat.page"
|
||||||
@ -27,6 +37,8 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- model -->
|
||||||
<project-items-modal-card
|
<project-items-modal-card
|
||||||
v-if="modalData"
|
v-if="modalData"
|
||||||
v-model:modalShow="modalShow"
|
v-model:modalShow="modalShow"
|
||||||
@ -44,8 +56,17 @@ import { useModalDataInit } from './hooks/useModal.hook'
|
|||||||
import { useDataListInit } from './hooks/useData.hook'
|
import { useDataListInit } from './hooks/useData.hook'
|
||||||
|
|
||||||
const { CopyIcon, EllipsisHorizontalCircleSharpIcon } = icon.ionicons5
|
const { CopyIcon, EllipsisHorizontalCircleSharpIcon } = icon.ionicons5
|
||||||
const { modalData, modalShow, closeModal, resizeHandle, editHandle } = useModalDataInit()
|
const { modalData, modalShow, closeModal, resizeHandle, editHandle } =
|
||||||
const { paginat, list, changeSize,changePage, deleteHandle } = useDataListInit()
|
useModalDataInit()
|
||||||
|
const {
|
||||||
|
loading,
|
||||||
|
paginat,
|
||||||
|
list,
|
||||||
|
changeSize,
|
||||||
|
changePage,
|
||||||
|
releaseHandle,
|
||||||
|
deleteHandle,
|
||||||
|
} = useDataListInit()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@ -54,7 +75,7 @@ $contentHeight: 250px;
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
min-height: calc(100vh - #{$--header-height} * 2 - 2px);
|
min-height: calc(100vh - #{$--header-height} - 40px - 2px);
|
||||||
.list-content {
|
.list-content {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: $contentHeight;
|
height: $contentHeight;
|
||||||
|
@ -10,6 +10,6 @@ import { ProjectItemsList } from './components/ProjectItemsList'
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@include go(project-items) {
|
@include go(project-items) {
|
||||||
padding: 30px 20px;
|
padding: 20px 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user