From d9a7f824f4831eb1cdd943a76daf16d25f81b3b1 Mon Sep 17 00:00:00 2001
From: lbw_9527443 <780139497@qq.com>
Date: Wed, 18 Mar 2026 20:02:02 +0800
Subject: [PATCH] =?UTF-8?q?refactor(AdminIndex):=20=E7=BB=9F=E4=B8=80?=
=?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=91=BD=E5=90=8D=E5=B9=B6=E4=BC=98=E5=8C=96?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=98=A0=E5=B0=84=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
重构表单字段命名以保持前后端一致性,优化数据映射逻辑确保正确回显。
移除未使用的导入并简化状态管理,提升代码可维护性。
---
src/views/AdminIndex.vue | 184 ++++++++++++++++++++-------------------
1 file changed, 95 insertions(+), 89 deletions(-)
diff --git a/src/views/AdminIndex.vue b/src/views/AdminIndex.vue
index 93d7fe6..94e2e1c 100644
--- a/src/views/AdminIndex.vue
+++ b/src/views/AdminIndex.vue
@@ -74,7 +74,7 @@
数据列表
共找到 {{ pagination.itemCount
- }}
+ }}
条记录
@@ -104,10 +104,10 @@
执行分配
-
+
-
+
@@ -119,23 +119,24 @@
客户及成交信息
- {{ editingRow.analystSupervisor
- }}
- {{ editingRow.analystDepartment
- }}
- {{ editingRow.analystName
- }}
- {{ editingRow.parentName }}
- {{ editingRow.parentPhone }}
- {{ editingRow.parentIdCard
- }}
- {{ editingRow.transactionDate
+ {{ editingRow.analyst_supervisor
+ }}
+ {{ editingRow.analyst_department
+ }}
+ {{ editingRow.analyst_name
+ }}
+ {{ editingRow.parent_name }}
+ {{ editingRow.parent_phone
}}
+ {{ editingRow.parent_id_card
+ }}
+ {{ editingRow.transaction_date
+ }}
¥{{
- editingRow.transactionAmount
+ editingRow.transaction_amount
}}
- {{ editingRow.guidancePeriod
- }}
+ {{ editingRow.guidance_period
+ }}
@@ -143,7 +144,7 @@
附件文档
-
+
下载附件文档
@@ -155,7 +156,7 @@
付款截图
-
@@ -166,7 +167,8 @@
电子签名
-
+
暂无签名数据
@@ -196,7 +198,7 @@ import {
import {
SearchOutline, LogOutOutline, DownloadOutline, PersonOutline, FileTrayOutline,
- ImagesOutline, BrushOutline, ReaderOutline, EyeOutline, CheckmarkCircleOutline
+ ImagesOutline, BrushOutline, ReaderOutline, EyeOutline
} from '@vicons/ionicons5'
const router = useRouter()
@@ -204,7 +206,6 @@ const message = useMessage()
const loading = ref(false)
const submitLoading = ref(false)
-// 搜索参数
const searchParams = reactive({
wecom_id: '',
parentInfo: '',
@@ -219,7 +220,6 @@ const statusOptions = [
const displayData = ref([])
-// 分页配置
const pagination = reactive({
page: 1,
pageSize: 10,
@@ -237,7 +237,7 @@ const pagination = reactive({
}
})
-// 1. 获取列表数据
+// 1. 获取列表数据并映射回显
const fetchData = async () => {
loading.value = true
try {
@@ -256,24 +256,35 @@ const fetchData = async () => {
if (res.success) {
displayData.value = res.data.map(item => ({
- id: item.wecom_id,
- analystSupervisor: item.analyst_supervisor,
- analystDepartment: item.analyst_department,
- analystName: item.analyst_name,
- parentName: item.parent_name,
- parentPhone: item.parent_phone,
- parentIdCard: item.parent_id_card,
- transactionDate: item.transaction_date,
- transactionAmount: item.transaction_amount || '0',
- guidancePeriod: item.guidance_period,
- submissionTime: item.submission_time,
+ // 基础信息
+ wecom_id: item.wecom_id,
+ analyst_supervisor: item.analyst_supervisor,
+ analyst_department: item.analyst_department,
+ analyst_name: item.analyst_name,
+ parent_name: item.parent_name,
+ parent_phone: item.parent_phone,
+ parent_id_card: item.parent_id_card || '',
+ transaction_date: item.transaction_date,
+ transaction_amount: item.transaction_amount || '0',
+ guidance_period: item.guidance_period || '',
+ submission_time: item.submission_time,
status: item.status,
- paymentImages: item.payment_image_url ? [item.payment_image_url] : [],
- signature: item.signature_image_url,
- files: item.attachment_file_url ? [item.attachment_file_url] : [],
- // 交互字段
- guideName: '',
- guidePhone: '',
+
+ // --- 修复关键:直接映射分配人信息以实现回显 ---
+ assignee_name: item.assignee_name || '',
+ assignee_phone: item.assignee_phone || '',
+
+ // 存储原始 Object Names (用于提交接口)
+ payment_object_names: Array.isArray(item.payment_object_names) ? item.payment_object_names : [],
+ signature_object_name: item.signature_object_name || '',
+ attachment_object_name: item.attachment_object_name || '',
+
+ // 带有签名的展示 URL
+ payment_image_urls: item.payment_image_url || [],
+ signature_image_url: item.signature_image_url,
+ attachment_file_url: item.attachment_file_url,
+
+ // 交互状态
isSubmitting: false
}))
pagination.itemCount = res.pagination.total
@@ -287,36 +298,32 @@ const fetchData = async () => {
}
}
-// 2. 提交分配请求函数
+// 2. 提交分配请求
const submitAssignment = async (row) => {
- if (!row.guideName || !row.guidePhone) {
- message.warning('请填写完整的指导师信息')
- return
+ if (!row.assignee_name || !row.assignee_phone) {
+ message.warning('请填写指导师姓名和电话')
+ return false
}
row.isSubmitting = true
try {
- // --- 修改开始 ---
- // 构建与 curl 命令匹配的 payload
const payload = {
- wecom_id: row.id,
- // payment_object_names 需要是一个数组
- payment_object_names: row.paymentImages || [],
- signature_object_name: row.signature || "",
- attachment_object_name: row.files?.[0] || "",
- analyst_supervisor: row.analystSupervisor,
- analyst_department: row.analystDepartment,
- analyst_name: row.analystName,
- parent_name: row.parentName,
- parent_phone: row.parentPhone,
- parent_id_card: row.parentIdCard,
- transaction_date: row.transactionDate,
- transaction_amount: String(row.transactionAmount),
- guidance_period: row.guidancePeriod,
- assignee_name: row.guideName,
- assignee_phone: row.guidePhone
+ wecom_id: String(row.wecom_id),
+ payment_object_names: row.payment_object_names,
+ signature_object_name: row.signature_object_name,
+ attachment_object_name: row.attachment_object_name,
+ analyst_supervisor: row.analyst_supervisor,
+ analyst_department: row.analyst_department,
+ analyst_name: row.analyst_name,
+ parent_name: row.parent_name,
+ parent_phone: row.parent_phone,
+ parent_id_card: row.parent_id_card,
+ transaction_date: row.transaction_date,
+ transaction_amount: String(row.transaction_amount),
+ guidance_period: row.guidance_period,
+ assignee_name: row.assignee_name,
+ assignee_phone: row.assignee_phone
}
- // --- 修改结束 ---
const response = await fetch('http://192.168.15.115:5636/api/v1/material/submit', {
method: 'POST',
@@ -328,27 +335,35 @@ const submitAssignment = async (row) => {
})
const res = await response.json()
- if (res.success || res.code === 200) {
- message.success('分配成功')
- row.status = 'processed' // 本地更新状态
+
+ if (response.ok && (res.success || res.code === 200)) {
+ message.success('分配并提报成功')
+ row.status = 'processed'
return true
} else {
message.error(res.message || '提交失败')
return false
}
} catch (error) {
- message.error('提交请求失败,请检查网络')
+ message.error('网络请求异常')
return false
} finally {
row.isSubmitting = false
}
}
+const handleDrawerSubmit = async () => {
+ submitLoading.value = true
+ const success = await submitAssignment(editingRow.value)
+ submitLoading.value = false
+ if (success) showDrawer.value = false
+}
+
// 表格列定义
const columns = [
- { title: '分析师', key: 'analystName', width: 90, fixed: 'left' },
- { title: '家长姓名', key: 'parentName', width: 90 },
- { title: '家长电话', key: 'parentPhone', width: 120 },
+ { title: '分析师', key: 'analyst_name', width: 90, fixed: 'left' },
+ { title: '家长姓名', key: 'parent_name', width: 90 },
+ { title: '家长电话', key: 'parent_phone', width: 120 },
{
title: '状态',
key: 'status',
@@ -358,27 +373,27 @@ const columns = [
round: true, size: 'small'
}, { default: () => row.status === 'pending' ? '待处理' : '已处理' })
},
- { title: '成交金额', key: 'transactionAmount', width: 100, render: (row) => h('span', { class: 'price-text' }, `¥${row.transactionAmount}`) },
+ { title: '成交金额', key: 'transaction_amount', width: 100, render: (row) => h('span', { class: 'price-text' }, `¥${row.transaction_amount}`) },
{
title: '分配指导师姓名',
- key: 'guideName',
+ key: 'assignee_name',
width: 130,
render: (row) => h(NInput, {
- value: row.guideName,
+ value: row.assignee_name,
size: 'small',
placeholder: '输入姓名',
- onUpdateValue: (v) => { row.guideName = v }
+ onUpdateValue: (v) => { row.assignee_name = v }
})
},
{
title: '指导师电话',
- key: 'guidePhone',
+ key: 'assignee_phone',
width: 160,
render: (row) => h(NInput, {
- value: row.guidePhone,
+ value: row.assignee_phone,
size: 'small',
placeholder: '输入手机号',
- onUpdateValue: (v) => { row.guidePhone = v }
+ onUpdateValue: (v) => { row.assignee_phone = v }
})
},
{
@@ -405,22 +420,13 @@ const columns = [
}
]
-// 抽屉逻辑
const showDrawer = ref(false)
const editingRow = ref({})
const openDetails = (row) => {
- editingRow.value = row // 这里使用引用,方便同步修改
+ editingRow.value = row
showDrawer.value = true
}
-const handleDrawerSubmit = async () => {
- submitLoading.value = true
- const success = await submitAssignment(editingRow.value)
- submitLoading.value = false
- if (success) showDrawer.value = false
-}
-
-// 搜索逻辑
const handleSearch = () => { pagination.page = 1; fetchData() }
const resetSearch = () => {
Object.assign(searchParams, { wecom_id: '', parentInfo: '', dateRange: null, status: null })
@@ -431,7 +437,7 @@ const resetSearch = () => {
onMounted(() => fetchData())
const logout = () => { localStorage.clear(); router.push('/login') }
-const downloadFile = () => { if (editingRow.value.files?.[0]) window.open(editingRow.value.files[0]) }
+const downloadFile = () => { if (editingRow.value.attachment_file_url) window.open(editingRow.value.attachment_file_url) }