diff --git a/src/modules/other/categoryGood/CategoryGoodListView.vue b/src/modules/other/categoryGood/CategoryGoodListView.vue index 4b0acb2..7dfb6ab 100644 --- a/src/modules/other/categoryGood/CategoryGoodListView.vue +++ b/src/modules/other/categoryGood/CategoryGoodListView.vue @@ -14,7 +14,7 @@ */ import { ref, onMounted, reactive, computed } 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' @@ -129,26 +129,33 @@ function onEdit(row: Category) { } function onSubmitEdit() { if (!editForm.name.trim()) { ElMessage.warning('请填写分类名'); return } - ElMessage.success(editMode.value === 'add' ? '新增成功 (mock)' : '修改成功 (mock)') - editVisible.value = false - load() + const ep = editMode.value === 'add' ? '/other/category/save' : '/other/category/update' + httpPost(ep, { ...editForm, type: 2 }).then(() => { + ElMessage.success(editMode.value === 'add' ? '新增成功' : '修改成功') + editVisible.value = false + load() + }).catch((e: any) => { ElMessage.error(e?.msg || '操作失败') }) } function onDelete(row: Category) { - ElMessageBox.confirm(`确认删除「${row.name}」? ${row.children?.length ? '该分类下有子分类, 将一起删除!' : ''}`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.name}」? ${row.children?.length ? '该分类下有子分类, 将一起删除!' : ''}`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/other/category/delete', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) } function onMove(row: Category, dir: 1 | 2) { - ElMessage.success(`${dir === 1 ? '上移' : '下移'}成功 (mock)`) - load() + httpPost('/other/category/moveCategory', { id: row.id, moveType: dir }).then(() => { + ElMessage.success(`${dir === 1 ? '上移' : '下移'}成功`) + load() + }).catch((e: any) => { ElMessage.error(e?.msg || '操作失败') }) } function onSelectionChange(rows: Category[]) { selection.value = rows } 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 { + for (const s of selection.value) { await httpPost('/other/category/delete', { id: s.id }) } + ElMessage.success(`已批量删除 ${selection.value.length} 个`); load() + } catch (e: any) { ElMessage.error(e?.msg || '批量删除失败'); load() } }).catch(() => {}) } diff --git a/src/modules/supplier/good/GoodListView.vue b/src/modules/supplier/good/GoodListView.vue index ae1e206..7533ddf 100644 --- a/src/modules/supplier/good/GoodListView.vue +++ b/src/modules/supplier/good/GoodListView.vue @@ -294,23 +294,23 @@ async function onDelete(row: Good) { function onBatchCheck() { if (selection.value.length === 0) { ElMessage.warning('请先选择商品'); return } - ElMessageBox.confirm(`确认批量通过 ${selection.value.length} 个商品?`, '提示', { type: 'success' }).then(() => { - ElMessage.success('批量审核通过 (mock)') - load() + ElMessageBox.confirm(`确认批量通过 ${selection.value.length} 个商品?`, '提示', { type: 'success' }).then(async () => { + try { for (const s of selection.value) { await httpPost('/supplier/good/checkGood', { id: s.id, checkStatus: 2, checkOpinion: '批量审核通过' }) } ElMessage.success(`批量审核通过 ${selection.value.length} 个`); load() } + catch (e: any) { ElMessage.error(e?.msg || '批量审核失败'); load() } }).catch(() => {}) } function onBatchReject() { if (selection.value.length === 0) { ElMessage.warning('请先选择商品'); return } batchRejectDialogVisible.value = true } function onSubmitBatchReject() { if (!batchRejectForm.reason.trim()) { ElMessage.warning('请填写驳回原因'); return } - ElMessage.success(`已驳回 ${selection.value.length} 个商品 (mock)`) - batchRejectDialogVisible.value = false - load() + Promise.all(selection.value.map(s => httpPost('/supplier/good/checkGood', { id: s.id, checkStatus: 3, checkOpinion: batchRejectForm.reason }))).then(() => { + ElMessage.success(`已驳回 ${selection.value.length} 个商品`); batchRejectDialogVisible.value = false; load() + }).catch((e: any) => ElMessage.error(e?.msg || '批量驳回失败')) } function onBatchOnShelf() { 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 { for (const s of selection.value) { await httpPost('/supplier/good/goodOnShelf', { id: s.id, onShelf: 0 }) } ElMessage.success(`批量下架 ${selection.value.length} 个`); load() } + catch (e: any) { ElMessage.error(e?.msg || '批量下架失败'); load() } }).catch(() => {}) } function onShowBatchCategoryDialog() { @@ -318,19 +318,19 @@ function onShowBatchCategoryDialog() { batchCategoryDialogVisible.value = true } function onSubmitBatchCategory() { - ElMessage.success(`已修改 ${selection.value.length} 个商品分类 (mock)`) - batchCategoryDialogVisible.value = false - load() + Promise.all(selection.value.map(s => httpPost('/supplier/good/updateSupplierGood', { id: s.id, firstCategoryId: categoryForm.firstCategoryId }))).then(() => { + ElMessage.success(`已修改 ${selection.value.length} 个商品分类`); batchCategoryDialogVisible.value = false; load() + }).catch((e: any) => ElMessage.error(e?.msg || '批量改分类失败')) } function onDeleteBatch() { 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 { for (const s of selection.value) { await httpPost('/supplier/good/deleteSupplierGood', { id: s.id }) } ElMessage.success('批量删除成功'); load() } + catch (e: any) { ElMessage.error(e?.msg || '批量删除失败'); load() } }).catch(() => {}) } -function onExport() { ElMessage.success('导出商品 (mock)') } -function onAdd() { ElMessage.info('新增商品 (mock)') } +function onExport() { ElMessage.info('导出功能开发中') } +function onAdd() { ElMessage.info('新增商品请前往供应商端') } onMounted(() => Promise.all([load(), loadStats(), loadCounts()])) diff --git a/src/modules/supplier/servicegood/ServiceGoodListView.vue b/src/modules/supplier/servicegood/ServiceGoodListView.vue index 289cab3..a1153b6 100644 --- a/src/modules/supplier/servicegood/ServiceGoodListView.vue +++ b/src/modules/supplier/servicegood/ServiceGoodListView.vue @@ -12,7 +12,7 @@ */ import { ref, onMounted, reactive, computed } 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 ListTabs from '@/components/ListTabs/ListTabs.vue' @@ -191,21 +191,64 @@ function onStatusTab(v: string) { filters.checkStatus = v; load() } function onShowDetail(row: ServiceGood) { detailData.value = row; detailVisible.value = true } function onShowCheck(row: ServiceGood) { checkData.value = row; checkDialogVisible.value = true } -function onSubmitCheck() { if (!checkForm.checkOpinion.trim()) { ElMessage.warning('请填写审核意见'); return } ElMessage.success('审核成功 (mock)'); checkDialogVisible.value = false; load() } -function onOnShelf(row: ServiceGood) { ElMessageBox.confirm(`确认${row.onShelf === 1 ? '下架' : '上架'}?`, '提示', { type: 'warning' }).then(() => { ElMessage.success('操作成功 (mock)'); load() }).catch(() => {}) } +function onSubmitCheck() { + if (!checkForm.checkOpinion.trim()) { ElMessage.warning('请填写审核意见'); return } + httpPost('/supplier/good/checkGood', { id: checkData.value?.id, checkStatus: checkForm.checkStatus, checkOpinion: checkForm.checkOpinion }).then(() => { + ElMessage.success('审核成功'); checkDialogVisible.value = false; load() + }).catch((e: any) => ElMessage.error(e?.msg || '审核失败')) +} +function onOnShelf(row: ServiceGood) { + ElMessageBox.confirm(`确认${row.onShelf === 1 ? '下架' : '上架'}?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/supplier/good/goodOnShelf', { id: row.id, onShelf: row.onShelf === 1 ? 0 : 1 }); ElMessage.success('操作成功'); load() } + catch (e: any) { ElMessage.error(e?.msg || '操作失败') } + }).catch(() => {}) +} function onShowCategory(row: ServiceGood) { categoryData.value = row; categoryDialogVisible.value = true } -function onSubmitCategory() { ElMessage.success('分类已修改 (mock)'); categoryDialogVisible.value = false; load() } -function onDelete(row: ServiceGood) { ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }).then(() => { ElMessage.success('已删除 (mock)'); load() }).catch(() => {}) } +function onSubmitCategory() { + httpPost('/supplier/good/updateSupplierGood', { id: categoryData.value?.id }).then(() => { + ElMessage.success('分类已修改'); categoryDialogVisible.value = false; load() + }).catch((e: any) => ElMessage.error(e?.msg || '操作失败')) +} +function onDelete(row: ServiceGood) { + ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/supplier/good/deleteSupplierGood', { id: row.id }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } + }).catch(() => {}) +} -function onBatchCheck() { if (!selection.value.length) return ElMessage.warning('请先选择'); ElMessage.success(`批量审核通过 ${selection.value.length} 个 (mock)`); load() } +function onBatchCheck() { + if (!selection.value.length) return ElMessage.warning('请先选择') + Promise.all(selection.value.map(s => httpPost('/supplier/good/checkGood', { id: s.id, checkStatus: 2, checkOpinion: '批量审核通过' }))).then(() => { + ElMessage.success(`批量审核通过 ${selection.value.length} 个`); load() + }).catch((e: any) => ElMessage.error(e?.msg || '批量审核失败')) +} function onBatchReject() { if (!selection.value.length) return ElMessage.warning('请先选择'); batchRejectDialogVisible.value = true } -function onSubmitBatchReject() { ElMessage.success(`批量驳回 ${selection.value.length} 个 (mock)`); batchRejectDialogVisible.value = false; load() } -function onBatchOnShelf() { if (!selection.value.length) return ElMessage.warning('请先选择'); ElMessage.success(`批量上下架 ${selection.value.length} 个 (mock)`); load() } +function onSubmitBatchReject() { + Promise.all(selection.value.map(s => httpPost('/supplier/good/checkGood', { id: s.id, checkStatus: 3, checkOpinion: batchRejectForm.reason }))).then(() => { + ElMessage.success(`批量驳回 ${selection.value.length} 个`); batchRejectDialogVisible.value = false; load() + }).catch((e: any) => ElMessage.error(e?.msg || '批量驳回失败')) +} +function onBatchOnShelf() { + if (!selection.value.length) return ElMessage.warning('请先选择') + httpPost('/supplier/good/goodOnShelfBatch', selection.value.map(s => ({ id: s.id, onShelf: s.onShelf === 1 ? 0 : 1 }))).then(() => { + ElMessage.success(`批量操作 ${selection.value.length} 个`); load() + }).catch((e: any) => ElMessage.error(e?.msg || '批量操作失败')) +} function onShowBatchCategory() { if (!selection.value.length) return ElMessage.warning('请先选择'); batchCategoryDialogVisible.value = true } -function onSubmitBatchCategory() { ElMessage.success(`批量改分类 ${selection.value.length} 个 (mock)`); batchCategoryDialogVisible.value = false; load() } -function onDeleteBatch() { if (!selection.value.length) return ElMessage.warning('请先选择'); ElMessageBox.confirm(`确认批量删除 ${selection.value.length} 个?`, '提示', { type: 'warning' }).then(() => { ElMessage.success('批量删除成功 (mock)'); load() }).catch(() => {}) } -function onExport() { ElMessage.success('导出服务商品 (mock)') } -function onAdd() { ElMessage.info('新增服务商品 (mock)') } +function onSubmitBatchCategory() { + Promise.all(selection.value.map(s => httpPost('/supplier/good/updateSupplierGood', { id: s.id }))).then(() => { + ElMessage.success(`批量改分类 ${selection.value.length} 个`); batchCategoryDialogVisible.value = false; load() + }).catch((e: any) => ElMessage.error(e?.msg || '批量改分类失败')) +} +function onDeleteBatch() { + if (!selection.value.length) return ElMessage.warning('请先选择') + ElMessageBox.confirm(`确认批量删除 ${selection.value.length} 个?`, '提示', { type: 'warning' }).then(async () => { + try { for (const s of selection.value) { await httpPost('/supplier/good/deleteSupplierGood', { id: s.id }) } ElMessage.success('批量删除成功'); load() } + catch (e: any) { ElMessage.error(e?.msg || '批量删除失败'); load() } + }).catch(() => {}) +} +function onExport() { ElMessage.info('导出功能开发中') } +function onAdd() { ElMessage.info('新增服务商品请前往供应商端') } onMounted(() => Promise.all([load(), loadStats(), loadCounts()])) diff --git a/src/modules/sys/region/RegionListView.vue b/src/modules/sys/region/RegionListView.vue index 6f448e7..9868bc1 100644 --- a/src/modules/sys/region/RegionListView.vue +++ b/src/modules/sys/region/RegionListView.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 TableActions from '@/components/TableActions/TableActions.vue' @@ -97,14 +97,17 @@ function onEdit(row: Region) { } function onSubmitEdit() { if (!editForm.name.trim()) { ElMessage.warning('请填写名称'); return } - ElMessage.success(editMode.value === 'add' ? '新增成功 (mock)' : '修改成功 (mock)') - editVisible.value = false - load() + const ep = editMode.value === 'add' ? '/sys/region' : '/sys/region' + const method = editMode.value === 'add' ? 'POST' : 'PUT' + httpPost(ep, { ...editForm, _method: method }).then(() => { + ElMessage.success(editMode.value === 'add' ? '新增成功' : '修改成功') + editVisible.value = false; load() + }).catch((e: any) => ElMessage.error(e?.msg || '操作失败')) } function onDelete(row: Region) { - ElMessageBox.confirm(`确认删除「${row.name}」? ${row.children?.length ? '该节点下有子节点, 将一起删除!' : ''}`, '提示', { type: 'warning' }).then(() => { - ElMessage.success('已删除 (mock)') - load() + ElMessageBox.confirm(`确认删除「${row.name}」? ${row.children?.length ? '该节点下有子节点, 将一起删除!' : ''}`, '提示', { type: 'warning' }).then(async () => { + try { await httpPost('/sys/region/' + row.id, { _method: 'DELETE' }); ElMessage.success('已删除'); load() } + catch (e: any) { ElMessage.error(e?.msg || '删除失败') } }).catch(() => {}) }