From a9ed11754ccca39e924c6cca7dedb87c98d019dc Mon Sep 17 00:00:00 2001 From: aaron <> Date: Wed, 12 Mar 2025 12:41:02 +0800 Subject: [PATCH] update --- src/views/community/CommunityList.vue | 282 +++++++++++++++++++++++++- src/views/system/TaskManager.vue | 40 +++- 2 files changed, 320 insertions(+), 2 deletions(-) diff --git a/src/views/community/CommunityList.vue b/src/views/community/CommunityList.vue index 8a1b1f9..0ce99d2 100644 --- a/src/views/community/CommunityList.vue +++ b/src/views/community/CommunityList.vue @@ -64,6 +64,17 @@ 未设置 + @@ -316,6 +329,69 @@ (总比例必须等于100%) + + + +
+ + + + + + +
+ +
+
+ 用户ID: + {{ adminSearchResult.userid }} +
+
+ 姓名: + {{ adminSearchResult.nickname }} +
+
+ 手机号: + {{ adminSearchResult.phone }} +
+
+
+
+ +
+
当前服务商信息
+
+
+ 用户ID: + {{ currentCommunity.admin_id }} +
+
+ 姓名: + {{ currentCommunity.admin_name }} +
+
+ 手机号: + {{ currentCommunity.admin_phone }} +
+
+
+ +
+
+
+
@@ -416,6 +492,11 @@ export default defineComponent({ key: 'profit_sharing', width: 220, }, + { + title: '服务商', + key: 'admin', + width: 150, + }, { title: '位置', key: 'location', @@ -972,6 +1053,104 @@ export default defineComponent({ currentCommunityName.value = '' } + // 添加服务商相关的状态 + const adminModalVisible = ref(false) + const adminSaving = ref(false) + const adminSearching = ref(false) + const adminSearchPhone = ref('') + const adminSearchResult = ref(null) + const currentCommunity = ref(null) + + // 显示设置服务商模态框 + const handleSetAdmin = (record) => { + currentCommunity.value = { ...record } + adminSearchPhone.value = '' + adminSearchResult.value = null + adminModalVisible.value = true + } + + // 搜索用户 + const handleSearchAdmin = async () => { + if (!adminSearchPhone.value || adminSearchPhone.value.length < 5) { + message.warning('请输入有效的手机号') + return + } + + try { + adminSearching.value = true + const res = await request.get(`/api/user/search_by_phone/${adminSearchPhone.value}`) + if (res.code === 200) { + if (res.data) { + adminSearchResult.value = { + ...res.data, + selected: false + } + } else { + adminSearchResult.value = null + message.warning('未找到该用户') + } + } else { + message.error(res.message || '搜索失败') + } + } catch (error) { + console.error('搜索用户失败:', error) + message.error('搜索失败') + } finally { + adminSearching.value = false + } + } + + // 选择搜索结果 + const selectSearchResult = (result) => { + if (adminSearchResult.value) { + adminSearchResult.value.selected = !adminSearchResult.value.selected + } + } + + // 保存服务商设置 + const handleAdminSave = async () => { + if (!adminSearchResult.value) { + message.warning('请先搜索并选择服务商') + return + } + + if (!adminSearchResult.value.selected) { + message.warning('请先选择搜索结果中的用户作为服务商') + return + } + + try { + adminSaving.value = true + const params = { + admin_id: adminSearchResult.value.userid + } + + const res = await request.put(`/api/community/${currentCommunity.value.id}`, params) + if (res.code === 200) { + message.success('服务商设置成功') + adminModalVisible.value = false + + // 刷新列表数据 + fetchData() + } else { + message.error(res.message || '设置失败') + } + } catch (error) { + console.error('设置服务商失败:', error) + message.error('设置失败') + } finally { + adminSaving.value = false + } + } + + // 取消服务商设置 + const handleAdminCancel = () => { + adminModalVisible.value = false + adminSearchPhone.value = '' + adminSearchResult.value = null + currentCommunity.value = null + } + onMounted(() => { fetchData() }) @@ -1023,7 +1202,18 @@ export default defineComponent({ handleProfitSharingCancel, getTotalRate, validateTotalRate, - calculatePlatformRate + calculatePlatformRate, + adminModalVisible, + adminSaving, + adminSearching, + adminSearchPhone, + adminSearchResult, + currentCommunity, + handleSetAdmin, + handleSearchAdmin, + handleAdminSave, + handleAdminCancel, + selectSearchResult } } }) @@ -1436,6 +1626,7 @@ export default defineComponent({ .action-buttons a { white-space: nowrap; + padding: 0 4px; } :deep(.ant-divider-vertical) { @@ -1484,4 +1675,93 @@ export default defineComponent({ color: rgba(0, 0, 0, 0.45); line-height: 1.2; } + +/* 服务商设置相关样式 */ +.admin-search-form { + margin-bottom: 16px; +} + +.admin-search-result { + margin-top: 16px; + margin-bottom: 16px; +} + +.admin-card-selected { + border: 2px solid #1890ff; + cursor: pointer; +} + +.admin-search-result :deep(.ant-card) { + cursor: pointer; + transition: all 0.3s; +} + +.admin-search-result :deep(.ant-card:hover) { + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); +} + +.current-admin-info { + margin-top: 24px; + border-top: 1px dashed #e8e8e8; + padding-top: 16px; +} + +.current-admin-title { + font-size: 14px; + font-weight: 500; + color: rgba(0, 0, 0, 0.85); + margin-bottom: 12px; +} + +.admin-info { + background-color: #f9f9f9; + padding: 12px; + border-radius: 4px; +} + +.admin-info-item { + margin-bottom: 8px; + display: flex; +} + +.admin-info-item:last-child { + margin-bottom: 0; +} + +.admin-info-label { + width: 70px; + color: rgba(0, 0, 0, 0.65); +} + +.admin-info-value { + flex: 1; + color: rgba(0, 0, 0, 0.85); + font-weight: 500; +} + +.no-admin-info { + padding: 16px 0; +} + +/* 表格中服务商信息显示样式 */ +.admin-info-table { + display: flex; + flex-direction: column; + gap: 4px; + font-size: 12px; + padding: 4px 0; +} + +.admin-info-row { + line-height: 1.5; +} + +.admin-name { + font-weight: 500; + color: rgba(0, 0, 0, 0.85); +} + +.admin-phone { + color: rgba(0, 0, 0, 0.65); +} \ No newline at end of file diff --git a/src/views/system/TaskManager.vue b/src/views/system/TaskManager.vue index 6021b6f..8aead1e 100644 --- a/src/views/system/TaskManager.vue +++ b/src/views/system/TaskManager.vue @@ -67,6 +67,15 @@ > 恢复 + + 执行 + @@ -178,7 +187,8 @@ export default defineComponent({ // 为每个任务添加loading状态 tableData.value = (res.data || []).map(item => ({ ...item, - loading: false + loading: false, + runLoading: false })) pagination.value.total = tableData.value.length } else { @@ -271,6 +281,33 @@ export default defineComponent({ } } + // 手动执行任务 + const runJob = async (record) => { + try { + // 设置当前任务的runLoading状态 + const index = tableData.value.findIndex(item => item.id === record.id) + if (index !== -1) { + tableData.value[index].runLoading = true + } + + const res = await request.post(`/api/scheduler/jobs/${record.id}/run`) + if (res.code === 200) { + message.success('任务已触发执行') + } else { + message.error(res.message || '操作失败') + } + } catch (error) { + console.error('执行任务失败:', error) + message.error('操作失败') + } finally { + // 清除runLoading状态 + const index = tableData.value.findIndex(item => item.id === record.id) + if (index !== -1) { + tableData.value[index].runLoading = false + } + } + } + onMounted(() => { refreshData() }) @@ -285,6 +322,7 @@ export default defineComponent({ handleTableChange, pauseJob, resumeJob, + runJob, refreshData } }