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