feature:咨询管理页面开发及接口对接 #6
No files matched your search
Vendored
+2
-2
@@ -16,7 +16,6 @@ declare module 'vue' {
|
|||||||
TAvatar: typeof import('tdesign-vue-next')['Avatar']
|
TAvatar: typeof import('tdesign-vue-next')['Avatar']
|
||||||
TButton: typeof import('tdesign-vue-next')['Button']
|
TButton: typeof import('tdesign-vue-next')['Button']
|
||||||
TCard: typeof import('tdesign-vue-next')['Card']
|
TCard: typeof import('tdesign-vue-next')['Card']
|
||||||
TCheckbox: typeof import('tdesign-vue-next')['Checkbox']
|
|
||||||
TDialog: typeof import('tdesign-vue-next')['Dialog']
|
TDialog: typeof import('tdesign-vue-next')['Dialog']
|
||||||
TDropdown: typeof import('tdesign-vue-next')['Dropdown']
|
TDropdown: typeof import('tdesign-vue-next')['Dropdown']
|
||||||
TForm: typeof import('tdesign-vue-next')['Form']
|
TForm: typeof import('tdesign-vue-next')['Form']
|
||||||
@@ -25,10 +24,11 @@ declare module 'vue' {
|
|||||||
TIcon: typeof import('tdesign-vue-next')['Icon']
|
TIcon: typeof import('tdesign-vue-next')['Icon']
|
||||||
TImageViewer: typeof import('tdesign-vue-next')['ImageViewer']
|
TImageViewer: typeof import('tdesign-vue-next')['ImageViewer']
|
||||||
TInput: typeof import('tdesign-vue-next')['Input']
|
TInput: typeof import('tdesign-vue-next')['Input']
|
||||||
|
TInputNumber: typeof import('tdesign-vue-next')['InputNumber']
|
||||||
TLayout: typeof import('tdesign-vue-next')['Layout']
|
TLayout: typeof import('tdesign-vue-next')['Layout']
|
||||||
TLink: typeof import('tdesign-vue-next')['Link']
|
|
||||||
TMenu: typeof import('tdesign-vue-next')['Menu']
|
TMenu: typeof import('tdesign-vue-next')['Menu']
|
||||||
TMenuItem: typeof import('tdesign-vue-next')['MenuItem']
|
TMenuItem: typeof import('tdesign-vue-next')['MenuItem']
|
||||||
|
TPopconfirm: typeof import('tdesign-vue-next')['Popconfirm']
|
||||||
TRadioButton: typeof import('tdesign-vue-next')['RadioButton']
|
TRadioButton: typeof import('tdesign-vue-next')['RadioButton']
|
||||||
TRadioGroup: typeof import('tdesign-vue-next')['RadioGroup']
|
TRadioGroup: typeof import('tdesign-vue-next')['RadioGroup']
|
||||||
TSpace: typeof import('tdesign-vue-next')['Space']
|
TSpace: typeof import('tdesign-vue-next')['Space']
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<t-dialog
|
<t-dialog
|
||||||
width="70%"
|
width="70%"
|
||||||
v-model:visible="visible"
|
|
||||||
:header="header"
|
:header="header"
|
||||||
:confirmBtn="confirmBtn"
|
:confirmBtn="confirmBtn"
|
||||||
:closeOnOverlayClick="false"
|
:closeOnOverlayClick="false"
|
||||||
@close="handleCloseDialog"
|
@close="handleCloseDialog"
|
||||||
@confirm="fetchSaveClassifyData"
|
@confirm="fetchSaveCarousalData"
|
||||||
>
|
>
|
||||||
<t-space direction="vertical" style="width: 100%">
|
<t-space direction="vertical" style="width: 100%">
|
||||||
<TForm ref="form" :data="carousalData" :rules="rules" resetType="initial" label-width="100">
|
<TForm ref="form" :data="carousalData" :rules="rules" resetType="initial" label-width="100">
|
||||||
@@ -29,7 +28,6 @@
|
|||||||
</t-dialog>
|
</t-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Classify } from '@/model/classify'
|
|
||||||
import { computed, ref, reactive, watch } from 'vue'
|
import { computed, ref, reactive, watch } from 'vue'
|
||||||
import type { FormInstanceFunctions, FormProps } from 'tdesign-vue-next'
|
import type { FormInstanceFunctions, FormProps } from 'tdesign-vue-next'
|
||||||
import ImageUpload from '@/components/ImageUpload.vue'
|
import ImageUpload from '@/components/ImageUpload.vue'
|
||||||
@@ -37,7 +35,7 @@ import { createCarousal, updateCarousalItem } from '@/api/carousal'
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
isEdit?: Boolean | null
|
isEdit?: Boolean | null
|
||||||
headerTitle?: String | null
|
headerTitle?: String | null
|
||||||
classify: Classify | {} | number
|
carousal: {} | number
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits(['success'])
|
const emit = defineEmits(['success'])
|
||||||
const form = ref<FormInstanceFunctions | null>(null)
|
const form = ref<FormInstanceFunctions | null>(null)
|
||||||
@@ -46,7 +44,6 @@ const formType = computed(() => `${props.isEdit ? 'update' : 'add'}`)
|
|||||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||||
const carousalData: FormProps['data'] = ref({})
|
const carousalData: FormProps['data'] = ref({})
|
||||||
const imgUrl = ref({})
|
const imgUrl = ref({})
|
||||||
const visible = ref(false)
|
|
||||||
const rules = computed(() => {
|
const rules = computed(() => {
|
||||||
const commonRules = {
|
const commonRules = {
|
||||||
imageUrl: [
|
imageUrl: [
|
||||||
@@ -93,7 +90,7 @@ const handleFormTypeData = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.classify,
|
() => props.carousal,
|
||||||
(newClassify) => {
|
(newClassify) => {
|
||||||
carousalData.value = Object.assign({}, newClassify)
|
carousalData.value = Object.assign({}, newClassify)
|
||||||
const carousalObj = Object.assign({},newClassify)
|
const carousalObj = Object.assign({},newClassify)
|
||||||
@@ -105,7 +102,7 @@ watch(
|
|||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
const fetchSaveClassifyData = async () => {
|
const fetchSaveCarousalData = async () => {
|
||||||
/* TODO: 保存分类数据 */
|
/* TODO: 保存分类数据 */
|
||||||
if (form.value) {
|
if (form.value) {
|
||||||
const valid = await form.value.validate()
|
const valid = await form.value.validate()
|
||||||
@@ -118,7 +115,7 @@ const fetchSaveClassifyData = async () => {
|
|||||||
switch (formType.value){
|
switch (formType.value){
|
||||||
case 'create':
|
case 'create':
|
||||||
res = await createCarousal(carousalData.value)
|
res = await createCarousal(carousalData.value)
|
||||||
emit('success', true)
|
emit('success')
|
||||||
break;
|
break;
|
||||||
case 'update':
|
case 'update':
|
||||||
const fieldsToKeep = ["imageUrl", "targetType", "targetUrl", "targetId"];
|
const fieldsToKeep = ["imageUrl", "targetType", "targetUrl", "targetId"];
|
||||||
@@ -131,10 +128,11 @@ const fetchSaveClassifyData = async () => {
|
|||||||
}
|
}
|
||||||
handleFormTypeData()
|
handleFormTypeData()
|
||||||
res = await updateCarousalItem(carousalData.value.id,requestObj)
|
res = await updateCarousalItem(carousalData.value.id,requestObj)
|
||||||
emit('success', res)
|
emit('success')
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = await createCarousal(carousalData.value)
|
res = await createCarousal(carousalData.value)
|
||||||
|
emit('success')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// const createCarousalApi = createCarousal(carousalData.value)
|
// const createCarousalApi = createCarousal(carousalData.value)
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
import RegularPage from '@/components/RegularPage.vue'
|
import RegularPage from '@/components/RegularPage.vue'
|
||||||
import { onMounted, ref, reactive } from 'vue'
|
import { onMounted, ref, reactive } from 'vue'
|
||||||
import type { BaseTableColumns } from 'tdesign-vue-next'
|
import type { BaseTableColumns } from 'tdesign-vue-next'
|
||||||
import type { Classify } from '@/model/classify'
|
import CarousalDialog from '@/pages/carousal/components/CarousalDialog.vue'
|
||||||
import ClassifyDialog 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 { aS } from 'vitest/dist/reporters-yx5ZTtEV'
|
|
||||||
|
|
||||||
const columns: BaseTableColumns = [
|
const columns: BaseTableColumns = [
|
||||||
{
|
{
|
||||||
@@ -44,7 +42,7 @@ const query = reactive({
|
|||||||
const carousalDialogVisible = ref(false)
|
const carousalDialogVisible = ref(false)
|
||||||
const isEdit = ref(false)
|
const isEdit = ref(false)
|
||||||
const currentTableData = ref<{}>({})
|
const currentTableData = ref<{}>({})
|
||||||
const fetchClassifyTableData = async () => {
|
const fetchSaveCarousalData = async () => {
|
||||||
/* TODO: 获取轮播图表格数据 */
|
/* TODO: 获取轮播图表格数据 */
|
||||||
query.page = pagination.page
|
query.page = pagination.page
|
||||||
query.size = pagination.size
|
query.size = pagination.size
|
||||||
@@ -52,7 +50,7 @@ const fetchClassifyTableData = async () => {
|
|||||||
data.value = getCarousalListApi.data
|
data.value = getCarousalListApi.data
|
||||||
pagination.total = getCarousalListApi.pagination.total
|
pagination.total = getCarousalListApi.pagination.total
|
||||||
}
|
}
|
||||||
onMounted(fetchClassifyTableData)
|
onMounted(fetchSaveCarousalData)
|
||||||
const editClick = (row:object) => {
|
const editClick = (row:object) => {
|
||||||
isEdit.value = true
|
isEdit.value = true
|
||||||
currentTableData.value = Object.assign({}, row)
|
currentTableData.value = Object.assign({}, row)
|
||||||
@@ -64,12 +62,12 @@ const showClick = async (res:object) => {
|
|||||||
} else {
|
} else {
|
||||||
await activeCarousal(res.id)
|
await activeCarousal(res.id)
|
||||||
}
|
}
|
||||||
await fetchClassifyTableData()
|
await fetchSaveCarousalData()
|
||||||
}
|
}
|
||||||
const delClick = async (row:object) => {
|
const delClick = async (row:object) => {
|
||||||
console.log(row,'删除')
|
console.log(row,'删除')
|
||||||
await deleteCarousal(row.id)
|
await deleteCarousal(row.id)
|
||||||
await fetchClassifyTableData()
|
await fetchSaveCarousalData()
|
||||||
}
|
}
|
||||||
const handleCreateCarousal = () => {
|
const handleCreateCarousal = () => {
|
||||||
isEdit.value = false
|
isEdit.value = false
|
||||||
@@ -79,12 +77,9 @@ const handleCreateCarousal = () => {
|
|||||||
const onPageChange = () => {
|
const onPageChange = () => {
|
||||||
/* TODO: 分页切换 */
|
/* TODO: 分页切换 */
|
||||||
}
|
}
|
||||||
const handleSuccessDialog = async (res) => {
|
const handleSuccessDialog = async () => {
|
||||||
console.log(res,'res')
|
await fetchSaveCarousalData()
|
||||||
if (res){
|
carousalDialogVisible.value = false
|
||||||
console.log(123)
|
|
||||||
await fetchClassifyTableData()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -142,13 +137,13 @@ const handleSuccessDialog = async (res) => {
|
|||||||
<TButton variant="text" size="small" theme="danger" @click="delClick(row)">删除</TButton>
|
<TButton variant="text" size="small" theme="danger" @click="delClick(row)">删除</TButton>
|
||||||
</template>
|
</template>
|
||||||
</TTable>
|
</TTable>
|
||||||
<ClassifyDialog
|
<CarousalDialog
|
||||||
:classify="currentTableData"
|
:carousal="currentTableData"
|
||||||
v-model:visible="carousalDialogVisible"
|
v-model:visible="carousalDialogVisible"
|
||||||
:isEdit="isEdit"
|
:isEdit="isEdit"
|
||||||
@success="handleSuccessDialog"
|
@success="handleSuccessDialog"
|
||||||
headerTitle="轮播图"
|
headerTitle="轮播图"
|
||||||
></ClassifyDialog>
|
></CarousalDialog>
|
||||||
</RegularPage>
|
</RegularPage>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user