From 4bcf13ba1f393244be6a08af47103d53aab91a89 Mon Sep 17 00:00:00 2001 From: zou Date: Sat, 8 Aug 2026 08:49:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(F006):=20=E8=AF=A2=E4=BB=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8/=E8=AF=A6=E6=83=85=E6=94=B9=E8=B0=83=E7=9C=9F=20API?= =?UTF-8?q?=20/supplier/inquiry/page=20+=20getById=20(=E5=81=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E2=86=92=E7=9C=9F=E6=95=B0=E6=8D=AE=20204=E6=9D=A1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/inquiry/InquiryDetailView.vue | 29 ++++++++++++++++++++--- src/modules/inquiry/InquiryListView.vue | 6 ++--- src/stores/inquiry.ts | 9 +++---- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/modules/inquiry/InquiryDetailView.vue b/src/modules/inquiry/InquiryDetailView.vue index 15805bd..0a62b1b 100644 --- a/src/modules/inquiry/InquiryDetailView.vue +++ b/src/modules/inquiry/InquiryDetailView.vue @@ -96,11 +96,34 @@ const inquiryId = computed(() => String(route.params.id || '')) async function load() { loading.value = true try { - await new Promise(r => setTimeout(r, 200)) - detail.value = { ...FALLBACK, id: inquiryId.value } + const resp: any = await httpGet('/supplier/inquiry/getById', { id: inquiryId.value }) + if (resp && resp.id) { + detail.value = { + ...FALLBACK, + ...resp, + id: String(resp.id || inquiryId.value), + title: resp.title || FALLBACK.title, + productName: resp.productName || resp.product || FALLBACK.productName, + productBrand: resp.brand || resp.productBrand || FALLBACK.productBrand, + specification: resp.specification || resp.spec || FALLBACK.specification, + unit: resp.unit || FALLBACK.unit, + quantity: resp.purchaseQuantity || resp.quantity || FALLBACK.quantity, + shippingAddress: resp.shippingAddress || resp.address || FALLBACK.shippingAddress, + deliveryDate: resp.deliveryDate || FALLBACK.deliveryDate, + priceValidDate: resp.priceValidDate || FALLBACK.priceValidDate, + enterpriseName: resp.inquiryEnterpriseName || resp.enterpriseName || FALLBACK.enterpriseName, + fileList: resp.fileList || FALLBACK.fileList, + quotationList: resp.quotationList || FALLBACK.quotationList, + raw: resp, + } + } else { + detail.value = { ...FALLBACK, id: inquiryId.value } + } } catch { detail.value = { ...FALLBACK, id: inquiryId.value } - } finally { loading.value = false } + } finally { + loading.value = false + } } function fmtDate(s: any): string { diff --git a/src/modules/inquiry/InquiryListView.vue b/src/modules/inquiry/InquiryListView.vue index 6311147..f23d5d3 100644 --- a/src/modules/inquiry/InquiryListView.vue +++ b/src/modules/inquiry/InquiryListView.vue @@ -74,12 +74,13 @@ async function load() { loading.value = true error.value = null try { - const data = await httpGet('/sys/openapi/inquiry/list', { + const resp = await httpGet('/supplier/inquiry/page', { page: page.value, limit: limit.value, ...(filters.value.status ? { status: filters.value.status } : {}) }) - const arr = Array.isArray(data) ? data : [] + const arr = Array.isArray(resp) ? resp : (resp?.list || []) + total.value = Number(resp?.total || (arr.length + (page.value - 1) * limit.value)) list.value = arr.map((it: any) => ({ id: String(it.id ?? ''), customer: it.inquiryEnterpriseName || it.customer || it.customerName || '--', @@ -89,7 +90,6 @@ async function load() { time: it.publishDate || it.createDate || it.time, raw: it })) - total.value = arr.length + (page.value - 1) * limit.value // 各状态计数 (基于当前页结果) stats.all = list.value.length list.value.forEach(r => { stats[r.status] = (stats[r.status] || 0) + 1 }) diff --git a/src/stores/inquiry.ts b/src/stores/inquiry.ts index 171b2af..0e6a588 100644 --- a/src/stores/inquiry.ts +++ b/src/stores/inquiry.ts @@ -100,13 +100,14 @@ export const useInquiryStore = defineStore('inquiry', () => { loading.value = true error.value = null try { - const data = await httpGet('/sys/openapi/inquiry/list', { + const resp = await httpGet('/supplier/inquiry/page', { page: page.value, limit: limit.value, ...(statusFilter.value ? { status: statusFilter.value } : {}) }) - list.value = (Array.isArray(data) ? data : []).map(normalizeInquiry) - total.value = list.value.length + (page.value - 1) * limit.value // 简化 total(后端不返) + const arr = Array.isArray(resp) ? resp : (resp?.list || []) + list.value = arr.map(normalizeInquiry) + total.value = Number(resp?.total || (arr.length + (page.value - 1) * limit.value)) isLive.value = true lastFetchedAt.value = Date.now() } catch (e: any) { @@ -123,7 +124,7 @@ export const useInquiryStore = defineStore('inquiry', () => { */ async function fetchOne(id: string): Promise { try { - const data = await httpGet(`/sys/openapi/inquiry/${id}`) + const data = await httpGet('/supplier/inquiry/getById', { id }) return data ? normalizeInquiry(data) : null } catch { return null From f7bb10f744fae71423ce07944d31ea556c9f3859 Mon Sep 17 00:00:00 2001 From: zou Date: Sat, 8 Aug 2026 08:55:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(F006):=20DashboardView+AppLayout=20?= =?UTF-8?q?=E6=94=B9=E8=B0=83=E7=9C=9F=20API=20/supplier/inquiry/page=20(?= =?UTF-8?q?=E5=81=87=E6=95=B0=E6=8D=AE=E2=86=92=E7=9C=9F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AppLayout/AppLayout.vue | 4 ++-- src/modules/dashboard/DashboardView.vue | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/AppLayout/AppLayout.vue b/src/components/AppLayout/AppLayout.vue index 7a2cea3..02dd25b 100644 --- a/src/components/AppLayout/AppLayout.vue +++ b/src/components/AppLayout/AppLayout.vue @@ -273,12 +273,12 @@ const badges = ref>({}) async function loadBadges() { try { - const data = await fetch('/sys/openapi/inquiry/list?page=1&limit=1', { + const data = await fetch('/supplier/inquiry/page?page=1&limit=1', { headers: { Authorization: `Bearer ${userStore.token}` }, credentials: 'omit' }).then(r => r.json()).catch(() => null) if (data?.code === 0) { - const total = data.total ?? data.data?.length ?? 0 + const total = data.data?.total ?? data.total ?? 0 badges.value['询价管理'] = String(total) } } catch {} diff --git a/src/modules/dashboard/DashboardView.vue b/src/modules/dashboard/DashboardView.vue index eb9bbfa..fb76e83 100644 --- a/src/modules/dashboard/DashboardView.vue +++ b/src/modules/dashboard/DashboardView.vue @@ -89,8 +89,9 @@ const FALLBACK_STATUS = [ */ async function loadRecentInquiries(): Promise { try { - const data = await httpGet('/sys/openapi/inquiry/list', { page: 1, limit: 5 }) - if (!Array.isArray(data)) throw new Error('inquiry list not array') + const resp = await httpGet('/supplier/inquiry/page', { page: 1, limit: 5 }) + const data = Array.isArray(resp) ? resp : (resp?.list || []) + if (!data.length) throw new Error('inquiry list empty') return data.slice(0, 5).map((it: any) => { const s = it.apprStatus === 0 ? 'pending' : it.apprStatus === 1 ? 'quoting' @@ -127,13 +128,14 @@ async function loadRecentInquiries(): Promise { */ async function loadStats(): Promise { try { - const data = await httpGet('/sys/openapi/inquiry/list', { page: 1, limit: 500 }) - if (!Array.isArray(data)) throw new Error('inquiry list not array') + const resp = await httpGet('/supplier/inquiry/page', { page: 1, limit: 500 }) + const data = Array.isArray(resp) ? resp : (resp?.list || []) + if (!data.length) throw new Error('inquiry list empty') - const total = data.length - const pending = data.filter((it: any) => it.apprStatus === 0).length - const quoting = data.filter((it: any) => it.apprStatus === 1).length - const done = data.filter((it: any) => it.apprStatus === 2).length + const total = Number(resp?.total || data.length) + const pending = data.filter((it: any) => it.apprStatus === 0 || it.status === 0).length + const quoting = data.filter((it: any) => it.apprStatus === 1 || it.status === 1).length + const done = data.filter((it: any) => it.apprStatus === 2 || it.status === 2).length return [ { label: '询价总数', value: String(total), delta: '', trend: 'up', icon: 'ChatDotRound' }, @@ -221,8 +223,8 @@ onMounted(async () => { // 拉一次全量算图表 + 较昨日 let allInquiries: any[] = [] try { - allInquiries = await httpGet('/sys/openapi/inquiry/list', { page: 1, limit: 500 }) - if (!Array.isArray(allInquiries)) allInquiries = [] + const resp = await httpGet('/supplier/inquiry/page', { page: 1, limit: 500 }) + allInquiries = Array.isArray(resp) ? resp : (resp?.list || []) } catch { allInquiries = [] } const isLive = allInquiries.length > 0 From d0790126b04554b304b8dbc001a43d398cf92b87 Mon Sep 17 00:00:00 2001 From: zou Date: Sat, 8 Aug 2026 09:06:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(F006-P1):=207=E4=B8=AAB=E7=BA=A7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=20CRUD=20mock=E2=86=92=E7=9C=9F=20API=20-=20?= =?UTF-8?q?groupbuy/seckill/coupon/textconfig/feedback/lunbo/help=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4/=E5=90=AF=E7=94=A8/=E5=81=9C=E7=94=A8/?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4/=E6=96=B0=E5=A2=9E/?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E5=85=A8=E9=83=A8=E6=8E=A5=E7=9C=9F?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=20(Playwright=207/7=20PASS)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/api/feedback/FeedbackListView.vue | 8 ++++---- src/modules/api/help/HelpListView.vue | 17 +++++++++------- src/modules/api/lunbo/LunboListView.vue | 17 +++++++++------- .../other/groupbuy/GroupbuyListView.vue | 20 +++++++++---------- src/modules/other/seckill/SeckillListView.vue | 20 +++++++++---------- .../other/textconfig/TextconfigListView.vue | 16 +++++++++------ .../supplier/coupon/CouponListView.vue | 20 +++++++++---------- 7 files changed, 64 insertions(+), 54 deletions(-) diff --git a/src/modules/api/feedback/FeedbackListView.vue b/src/modules/api/feedback/FeedbackListView.vue index a0b61b0..7f967ae 100644 --- a/src/modules/api/feedback/FeedbackListView.vue +++ b/src/modules/api/feedback/FeedbackListView.vue @@ -13,7 +13,7 @@ */ import { ref, onMounted, reactive } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' -import { httpGet } from '@/utils/request' +import { httpGet, httpPost } from '@/utils/request' import DataTable from '@/components/DataTable/DataTable.vue' import PageHeader from '@/components/PageHeader/PageHeader.vue' import SearchBar from '@/components/SearchBar/SearchBar.vue' @@ -76,9 +76,9 @@ function onPageChange(p: number) { page.value = p; load() } function onLimitChange(l: number) { limit.value = l; load() } function onPreview(row: Feedback) { previewData.value = row; previewVisible.value = true } function onDelete(row: Feedback) { - ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/feedback/delete', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) } diff --git a/src/modules/api/help/HelpListView.vue b/src/modules/api/help/HelpListView.vue index 06e55ec..49fbbd6 100644 --- a/src/modules/api/help/HelpListView.vue +++ b/src/modules/api/help/HelpListView.vue @@ -12,7 +12,7 @@ */ import { ref, onMounted, reactive } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' -import { httpGet } from '@/utils/request' +import { httpGet, httpPost } from '@/utils/request' import DataTable from '@/components/DataTable/DataTable.vue' import PageHeader from '@/components/PageHeader/PageHeader.vue' import SearchBar from '@/components/SearchBar/SearchBar.vue' @@ -72,14 +72,17 @@ function onAdd() { editMode.value = 'add'; editForm.id = ''; editForm.title = '' function onEdit(row: Help) { editMode.value = 'edit'; Object.assign(editForm, JSON.parse(JSON.stringify(row))); editVisible.value = true } function onSubmitEdit() { if (!editForm.title.trim()) { ElMessage.warning('请填写标题'); return } - ElMessage.success(editMode.value === 'add' ? '新增成功 (mock)' : '修改成功 (mock)') - editVisible.value = false - load() + const ep = editMode.value === 'add' ? '/other/help/save' : '/other/help/update' + httpPost(ep, { ...editForm }).then(() => { + ElMessage.success(editMode.value === 'add' ? '新增成功' : '修改成功') + editVisible.value = false + load() + }).catch((e: any) => { ElMessage.error(e?.msg || '操作失败') }) } function onDelete(row: Help) { - ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/help/delete', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) } diff --git a/src/modules/api/lunbo/LunboListView.vue b/src/modules/api/lunbo/LunboListView.vue index 45c4425..2407b81 100644 --- a/src/modules/api/lunbo/LunboListView.vue +++ b/src/modules/api/lunbo/LunboListView.vue @@ -12,7 +12,7 @@ */ import { ref, onMounted, reactive } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' -import { httpGet } from '@/utils/request' +import { httpGet, httpPost } from '@/utils/request' import DataTable from '@/components/DataTable/DataTable.vue' import PageHeader from '@/components/PageHeader/PageHeader.vue' import SearchBar from '@/components/SearchBar/SearchBar.vue' @@ -85,14 +85,17 @@ function onEdit(row: Lunbo) { editMode.value = 'edit'; Object.assign(editForm, J function onSubmitEdit() { if (!editForm.title.trim()) { ElMessage.warning('请填写标题'); return } if (!editForm.image.trim()) { ElMessage.warning('请填写图片URL'); return } - ElMessage.success(editMode.value === 'add' ? '新增成功 (mock)' : '修改成功 (mock)') - editVisible.value = false - load() + const ep = editMode.value === 'add' ? '/other/lunbo/save' : '/other/lunbo/update' + httpPost(ep, { ...editForm }).then(() => { + ElMessage.success(editMode.value === 'add' ? '新增成功' : '修改成功') + editVisible.value = false + load() + }).catch((e: any) => { ElMessage.error(e?.msg || '操作失败') }) } function onDelete(row: Lunbo) { - ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/lunbo/delete', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) } diff --git a/src/modules/other/groupbuy/GroupbuyListView.vue b/src/modules/other/groupbuy/GroupbuyListView.vue index f5e4321..d802a5f 100644 --- a/src/modules/other/groupbuy/GroupbuyListView.vue +++ b/src/modules/other/groupbuy/GroupbuyListView.vue @@ -13,7 +13,7 @@ */ import { ref, onMounted, reactive } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' -import { httpGet } from '@/utils/request' +import { httpGet, httpPost } from '@/utils/request' import PageHeader from '@/components/PageHeader/PageHeader.vue' import SearchBar from '@/components/SearchBar/SearchBar.vue' @@ -78,22 +78,22 @@ function onSelectionChange(rows: Groupbuy[]) { selection.value = rows } function onView(row: Groupbuy) { viewData.value = row; viewVisible.value = true } function onToggleStatus(row: Groupbuy) { const newStatus = row.status === 1 ? 2 : 1 - ElMessageBox.confirm(`确认${newStatus === 1 ? '启用' : '停用'}「${row.name}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success(`${newStatus === 1 ? '启用' : '停用'}成功 (mock)`) - load() + ElMessageBox.confirm(`确认${newStatus === 1 ? '启用' : '停用'}「${row.name}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/groupbuy/update', { id: row.id, status: newStatus }); ElMessage.success(`${newStatus === 1 ? '启用' : '停用'}成功`); load() } + catch (e: any) { ElMessage.error(e?.msg || '操作失败') } }).catch(() => {}) } function onDelete(row: Groupbuy) { - ElMessageBox.confirm(`确认删除「${row.name}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.name}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/groupbuy/delete', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) } function onBatchDelete() { if (selection.value.length === 0) { ElMessage.warning('请先选择要删除的活动'); return } - ElMessageBox.confirm(`确认批量删除选中的 ${selection.value.length} 个活动?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已批量删除 (mock)') - load() + ElMessageBox.confirm(`确认批量删除选中的 ${selection.value.length} 个活动?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/groupbuy/delete', selection.value.map(s => s.id)); ElMessage.success(`已批量删除 ${selection.value.length} 个`); load() } + catch (e: any) { ElMessage.error(e?.msg || '批量删除失败') } }).catch(() => {}) } diff --git a/src/modules/other/seckill/SeckillListView.vue b/src/modules/other/seckill/SeckillListView.vue index ca8217f..8ef5a80 100644 --- a/src/modules/other/seckill/SeckillListView.vue +++ b/src/modules/other/seckill/SeckillListView.vue @@ -13,7 +13,7 @@ */ import { ref, onMounted, reactive } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' -import { httpGet } from '@/utils/request' +import { httpGet, httpPost } from '@/utils/request' import PageHeader from '@/components/PageHeader/PageHeader.vue' import SearchBar from '@/components/SearchBar/SearchBar.vue' @@ -79,22 +79,22 @@ function onSelectionChange(rows: Seckill[]) { selection.value = rows } function onView(row: Seckill) { viewData.value = row; viewVisible.value = true } function onToggleStatus(row: Seckill) { const newStatus = row.status === 0 ? 1 : 0 - ElMessageBox.confirm(`确认${newStatus === 0 ? '启用' : '停用'}「${row.name}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success(`${newStatus === 0 ? '启用' : '停用'}成功 (mock)`) - load() + ElMessageBox.confirm(`确认${newStatus === 0 ? '启用' : '停用'}「${row.name}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/seckill/updateSeckill', { id: row.id, status: newStatus }); ElMessage.success(`${newStatus === 0 ? '启用' : '停用'}成功`); load() } + catch (e: any) { ElMessage.error(e?.msg || '操作失败') } }).catch(() => {}) } function onDelete(row: Seckill) { - ElMessageBox.confirm(`确认删除「${row.name}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.name}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/seckill/delete', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) } function onBatchDelete() { if (selection.value.length === 0) { ElMessage.warning('请先选择要删除的活动'); return } - ElMessageBox.confirm(`确认批量删除选中的 ${selection.value.length} 个活动?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已批量删除 (mock)') - load() + ElMessageBox.confirm(`确认批量删除选中的 ${selection.value.length} 个活动?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/seckill/delete', selection.value.map(s => s.id)); ElMessage.success(`已批量删除 ${selection.value.length} 个`); load() } + catch (e: any) { ElMessage.error(e?.msg || '批量删除失败') } }).catch(() => {}) } diff --git a/src/modules/other/textconfig/TextconfigListView.vue b/src/modules/other/textconfig/TextconfigListView.vue index 6a0cf57..0008a8a 100644 --- a/src/modules/other/textconfig/TextconfigListView.vue +++ b/src/modules/other/textconfig/TextconfigListView.vue @@ -15,6 +15,7 @@ */ import { ref, onMounted, reactive } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' +import { httpPost } from '@/utils/request' import DataTable from '@/components/DataTable/DataTable.vue' import PageHeader from '@/components/PageHeader/PageHeader.vue' import SearchBar from '@/components/SearchBar/SearchBar.vue' @@ -84,15 +85,18 @@ function onAdd() { editMode.value = 'add'; Object.assign(editForm, { id: '', cod function onEdit(row: TextConfig) { editMode.value = 'edit'; Object.assign(editForm, JSON.parse(JSON.stringify(row))); editVisible.value = true } function onSubmitEdit() { if (!editForm.code.trim() || !editForm.descr.trim()) { ElMessage.warning('请填写编码和描述'); return } - ElMessage.success(editMode.value === 'add' ? '新增成功 (mock)' : '修改成功 (mock)') - editVisible.value = false - load() + const ep = editMode.value === 'add' ? '/other/textconfig/save' : '/other/textconfig/update' + httpPost(ep, { ...editForm }).then(() => { + ElMessage.success(editMode.value === 'add' ? '新增成功' : '修改成功') + editVisible.value = false + load() + }).catch((e: any) => { ElMessage.error(e?.msg || '操作失败') }) } function onShowRichText(content: string) { richTextContent.value = content; richTextVisible.value = true } function onDelete(row: TextConfig) { - ElMessageBox.confirm(`确认删除「${row.code}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.code}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/textconfig/delete', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) } diff --git a/src/modules/supplier/coupon/CouponListView.vue b/src/modules/supplier/coupon/CouponListView.vue index 5c2199d..27d2db8 100644 --- a/src/modules/supplier/coupon/CouponListView.vue +++ b/src/modules/supplier/coupon/CouponListView.vue @@ -12,7 +12,7 @@ */ import { ref, onMounted, reactive } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' -import { httpGet } from '@/utils/request' +import { httpGet, httpPost } from '@/utils/request' import PageHeader from '@/components/PageHeader/PageHeader.vue' import SearchBar from '@/components/SearchBar/SearchBar.vue' import TableActions from '@/components/TableActions/TableActions.vue' @@ -87,22 +87,22 @@ function onEdit(row: Coupon) { } function onToggleStatus(row: Coupon) { const next = row.onShelf === 1 ? 0 : 1 - ElMessageBox.confirm(`确认${next === 1 ? '启用' : '停用'}「${row.name}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success(`${next === 1 ? '启用' : '停用'}成功 (mock)`) - load() + ElMessageBox.confirm(`确认${next === 1 ? '启用' : '停用'}「${row.name}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/supplier/coupon/updateCoupon', { id: row.id, onShelf: next }); ElMessage.success(`${next === 1 ? '启用' : '停用'}成功`); load() } + catch (e: any) { ElMessage.error(e?.msg || '操作失败') } }).catch(() => {}) } function onDelete(row: Coupon) { - ElMessageBox.confirm(`确认删除「${row.name}」?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.name}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/supplier/coupon/delete', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) } function onBatchDelete() { if (selection.value.length === 0) { ElMessage.warning('请先选择要删除的券'); return } - ElMessageBox.confirm(`确认批量删除选中的 ${selection.value.length} 张券?`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已批量删除 (mock)') - load() + ElMessageBox.confirm(`确认批量删除选中的 ${selection.value.length} 张券?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/supplier/coupon/delete', selection.value.map(s => s.id)); ElMessage.success(`已批量删除 ${selection.value.length} 张`); load() } + catch (e: any) { ElMessage.error(e?.msg || '批量删除失败') } }).catch(() => {}) } function onShowRecords(row: Coupon) {