Merge branch 'feature/31-carousal' into feature/code-review-sprint1
This commit is contained in:
commit
f8fc42dfec
6 files changed
+35
-31
No files matched your search
@@ -1,3 +1,3 @@
|
|||||||
VITE_ENABLE_MOCK=false
|
VITE_ENABLE_MOCK=false
|
||||||
VITE_API_PREFIX=/api
|
VITE_API_PREFIX=/api
|
||||||
VITE_PROXY_ENDPOINT=http://localhost:8000
|
VITE_PROXY_ENDPOINT=https://bright.yilibili.com/api
|
||||||
+1
-4
@@ -1,4 +1 @@
|
|||||||
VITE_ENABLE_MOCK=false
|
VITE_ENABLE_MOCK=true
|
||||||
VITE_API_PREFIX=/api
|
|
||||||
VITE_PROXY_ENDPOINT=https://bright.yilibili.com
|
|
||||||
|
|
||||||
+8
-7
@@ -1,19 +1,20 @@
|
|||||||
import httpClient from './httpClient'
|
import httpClient from './httpClient'
|
||||||
import type { CreateCarousalsRequest, GetCarousalsRequest } from '@/model/carousals'
|
import type { CarousalResult, CreateCarousalsRequest, GetCarousalsRequest } from '@/model/carousals'
|
||||||
|
import type { PageResult } from '@/model/base'
|
||||||
|
|
||||||
export const createCarousal = (createCarousalsRequest: CreateCarousalsRequest) => {
|
export const createCarousal = (createCarousalsRequest: CreateCarousalsRequest) => {
|
||||||
return httpClient.post('/carousals', createCarousalsRequest)
|
return httpClient.post<PageResult<CarousalResult>>('/carousals', createCarousalsRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCarousalList = (getCarousalsRequest:GetCarousalsRequest) => {
|
export const getCarousalList = (getCarousalsRequest:GetCarousalsRequest) => {
|
||||||
return httpClient.get('/carousals',getCarousalsRequest)
|
return httpClient.get<PageResult<CarousalResult>>('/carousals',getCarousalsRequest)
|
||||||
}
|
}
|
||||||
export const getCarousalItem = (id:string) => {
|
export const getCarousalItem = (id:string) => {
|
||||||
return httpClient.get(`/carousals/${id}`)
|
return httpClient.get<CarousalResult>(`/carousals/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateCarousalItem = (id:number,updateCarousalsRequest: CreateCarousalsRequest) => {
|
export const updateCarousalItem = (id:number,updateCarousalsRequest: CreateCarousalsRequest) => {
|
||||||
return httpClient.put(`/carousals/${id}`,updateCarousalsRequest)
|
return httpClient.put<CarousalResult>(`/carousals/${id}`,updateCarousalsRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteCarousal = (id:string | number) => {
|
export const deleteCarousal = (id:string | number) => {
|
||||||
@@ -21,9 +22,9 @@ export const deleteCarousal = (id:string | number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const activeCarousal = (id: string | number) => {
|
export const activeCarousal = (id: string | number) => {
|
||||||
return httpClient.put(`/carousals/${id}/active`)
|
return httpClient.put<CarousalResult>(`/carousals/${id}/active`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inactiveCarousal = (id: string | number ) => {
|
export const inactiveCarousal = (id: string | number ) => {
|
||||||
return httpClient.put(`/carousals/${id}/inactive`)
|
return httpClient.put<CarousalResult>(`/carousals/${id}/inactive`)
|
||||||
}
|
}
|
||||||
@@ -10,10 +10,10 @@ const sizeLimit = ref<UploadProps['sizeLimit']>({
|
|||||||
unit: 'MB',
|
unit: 'MB',
|
||||||
});
|
});
|
||||||
const file1 = ref<UploadProps['value']>([]);
|
const file1 = ref<UploadProps['value']>([]);
|
||||||
const disabled = ref(false);
|
const disabled = ref<boolean>(false);
|
||||||
const autoUpload = ref(true);
|
const autoUpload = ref<boolean>(true);
|
||||||
const showImageFileName = ref(true);
|
const showImageFileName = ref<boolean>(true);
|
||||||
const uploadAllFilesInOneRequest = ref(false);
|
const uploadAllFilesInOneRequest = ref<boolean>(false);
|
||||||
const handleFail: UploadProps['onFail'] = ({ file }) => {
|
const handleFail: UploadProps['onFail'] = ({ file }) => {
|
||||||
MessagePlugin.error(`文件 ${file.name} 上传失败`);
|
MessagePlugin.error(`文件 ${file.name} 上传失败`);
|
||||||
};
|
};
|
||||||
@@ -36,6 +36,7 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emits = defineEmits(['on-success'])
|
const emits = defineEmits(['on-success'])
|
||||||
watch(() => props.imageUrl,(newVal) => {
|
watch(() => props.imageUrl,(newVal) => {
|
||||||
if(newVal){
|
if(newVal){
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import type { BaseModel } from '@/model/base'
|
||||||
|
|
||||||
export interface CreateCarousalsRequest {
|
export interface CreateCarousalsRequest {
|
||||||
imageUrl:string,
|
imageUrl:string,
|
||||||
targetType:string,
|
targetType:string,
|
||||||
@@ -10,3 +12,6 @@ export interface GetCarousalsRequest {
|
|||||||
order?:[string]
|
order?:[string]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CarousalResult extends BaseModel,CreateCarousalsRequest{
|
||||||
|
status:string
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import type { BaseTableColumns } from 'tdesign-vue-next'
|
|||||||
import CarousalDialog from '@/pages/carousal/components/CarousalDialog.vue'
|
import CarousalDialog from '@/pages/carousal/components/CarousalDialog.vue'
|
||||||
import { activeCarousal, deleteCarousal, getCarousalList, inactiveCarousal } from '@/api/carousal'
|
import { activeCarousal, deleteCarousal, getCarousalList, inactiveCarousal } from '@/api/carousal'
|
||||||
import { BrowseIcon } from 'tdesign-icons-vue-next'
|
import { BrowseIcon } from 'tdesign-icons-vue-next'
|
||||||
|
import type { CarousalResult } from '@/model/carousals'
|
||||||
|
|
||||||
const columns: BaseTableColumns = [
|
const columns: BaseTableColumns = [
|
||||||
{
|
{
|
||||||
@@ -28,21 +29,21 @@ const columns: BaseTableColumns = [
|
|||||||
width: 100,
|
width: 100,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const loading = ref(false)
|
const loading = ref<boolean>(false)
|
||||||
const data = ref([])
|
const data = ref<CarousalResult[]>([])
|
||||||
const pagination = reactive({
|
const pagination = reactive<{page:number,size:number,total:number}>({
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
total:0
|
total:0
|
||||||
})
|
})
|
||||||
const query = reactive({
|
const query = reactive<{page:number,size:number}>({
|
||||||
page:1,
|
page:1,
|
||||||
size:10,
|
size:10,
|
||||||
})
|
})
|
||||||
const carousalDialogVisible = ref(false)
|
const carousalDialogVisible = ref<boolean>(false)
|
||||||
const isEdit = ref(false)
|
const isEdit = ref<boolean>(false)
|
||||||
const currentTableData = ref<{}>({})
|
const currentTableData = ref<CarousalResult | {}>({})
|
||||||
const fetchSaveCarousalData = async () => {
|
const fetchSaveCarousalData = async () :Promise<void> => {
|
||||||
/* TODO: 获取轮播图表格数据 */
|
/* TODO: 获取轮播图表格数据 */
|
||||||
query.page = pagination.page
|
query.page = pagination.page
|
||||||
query.size = pagination.size
|
query.size = pagination.size
|
||||||
@@ -51,12 +52,12 @@ const fetchSaveCarousalData = async () => {
|
|||||||
pagination.total = getCarousalListApi.pagination.total
|
pagination.total = getCarousalListApi.pagination.total
|
||||||
}
|
}
|
||||||
onMounted(fetchSaveCarousalData)
|
onMounted(fetchSaveCarousalData)
|
||||||
const editClick = (row:object) => {
|
const editClick = (row:object):void => {
|
||||||
isEdit.value = true
|
isEdit.value = true
|
||||||
currentTableData.value = Object.assign({}, row)
|
currentTableData.value = Object.assign({}, row)
|
||||||
carousalDialogVisible.value = true
|
carousalDialogVisible.value = true
|
||||||
}
|
}
|
||||||
const showClick = async (res:object) => {
|
const showClick = async (res:CarousalResult):Promise<void> => {
|
||||||
if (res.status === 'active'){
|
if (res.status === 'active'){
|
||||||
await inactiveCarousal(res.id)
|
await inactiveCarousal(res.id)
|
||||||
} else {
|
} else {
|
||||||
@@ -64,20 +65,19 @@ const showClick = async (res:object) => {
|
|||||||
}
|
}
|
||||||
await fetchSaveCarousalData()
|
await fetchSaveCarousalData()
|
||||||
}
|
}
|
||||||
const delClick = async (row:object) => {
|
const delClick = async (row:CarousalResult) :Promise<void>=> {
|
||||||
console.log(row,'删除')
|
|
||||||
await deleteCarousal(row.id)
|
await deleteCarousal(row.id)
|
||||||
await fetchSaveCarousalData()
|
await fetchSaveCarousalData()
|
||||||
}
|
}
|
||||||
const handleCreateCarousal = () => {
|
const handleCreateCarousal = () :void => {
|
||||||
isEdit.value = false
|
isEdit.value = false
|
||||||
carousalDialogVisible.value = true
|
carousalDialogVisible.value = true
|
||||||
currentTableData.value = {}
|
currentTableData.value = {}
|
||||||
}
|
}
|
||||||
const onPageChange = () => {
|
const onPageChange = ():void => {
|
||||||
/* TODO: 分页切换 */
|
/* TODO: 分页切换 */
|
||||||
}
|
}
|
||||||
const handleSuccessDialog = async () => {
|
const handleSuccessDialog = async () :Promise<void> => {
|
||||||
await fetchSaveCarousalData()
|
await fetchSaveCarousalData()
|
||||||
carousalDialogVisible.value = false
|
carousalDialogVisible.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user