sql数据流,amdin业务逻辑接入
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<view class="filter-row">
|
||||
<view class="filter-item">
|
||||
<text class="label">代理商查询:</text>
|
||||
<input class="filter-input" placeholder="请输入姓名、手机号或UID" />
|
||||
<input class="filter-input" placeholder="请输入姓名、手机号或UID" v-model="searchQuery" @confirm="onSearch" />
|
||||
</view>
|
||||
<view class="filter-btns">
|
||||
<button class="btn primary" @click="onSearch">查询</button>
|
||||
@@ -16,51 +16,119 @@
|
||||
<button class="btn primary small" @click="onAdd">添加代理商</button>
|
||||
</view>
|
||||
<view class="table-container">
|
||||
<!-- Loading 遮罩 -->
|
||||
<view v-if="isLoading" class="loading-mask">
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
|
||||
<view class="table-header">
|
||||
<view class="col col-uid"><text>用户UID</text></view>
|
||||
<view class="col col-avatar"><text>头像</text></view>
|
||||
<view class="col col-name"><text>名称</text></view>
|
||||
<view class="col col-ratio"><text>分佣比例</text></view>
|
||||
<view class="col col-count"><text>员工数量</text></view>
|
||||
<view class="col col-time"><text>过期时间</text></view>
|
||||
<view class="col col-ratio"><text>所属事业部</text></view>
|
||||
<view class="col col-time"><text>加入时间</text></view>
|
||||
<view class="col col-status"><text>状态</text></view>
|
||||
<view class="col col-ops"><text>操作</text></view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view v-if="agentList.length === 0 && !isLoading" class="empty-row">
|
||||
<text>暂无代理商数据</text>
|
||||
</view>
|
||||
<view v-for="item in agentList" :key="item.uid" class="table-row">
|
||||
<view class="col col-uid"><text>{{ item.uid }}</text></view>
|
||||
<view class="col col-uid"><text class="td-txt-small">{{ item.uid }}</text></view>
|
||||
<view class="col col-avatar">
|
||||
<image class="avatar-img" src="/static/logo.png" mode="aspectFill" />
|
||||
<image class="avatar-img" :src="item.avatar_url || '/static/logo.png'" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="col col-name"><text>{{ item.name }}</text></view>
|
||||
<view class="col col-ratio"><text>{{ item.ratio }}%</text></view>
|
||||
<view class="col col-count"><text>{{ item.staffCount }}</text></view>
|
||||
<view class="col col-time"><text>{{ item.endTime }}</text></view>
|
||||
<view class="col col-name"><text>{{ item.name || item.nickname }}</text></view>
|
||||
<view class="col col-ratio"><text>{{ item.division_name || '-' }}</text></view>
|
||||
<view class="col col-time"><text>{{ formatDateTime(item.created_at) }}</text></view>
|
||||
<view class="col col-status">
|
||||
<switch :checked="item.status" color="#1890ff" scale="0.8" />
|
||||
<switch :checked="item.status" color="#1890ff" scale="0.8" @change="toggleStatus(item)" />
|
||||
</view>
|
||||
<view class="col col-ops">
|
||||
<text class="op-link">编辑</text>
|
||||
<text class="op-link">详情</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">查看</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">员工</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">删除</text>
|
||||
<text class="op-link danger" @click="onDelete(item.id)">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="pagination">
|
||||
<view class="pager-btns">
|
||||
<button class="btn small" :disabled="page <= 1" @click="onPrevPage">上一页</button>
|
||||
<text class="page-num">第 {{ page }} 页</text>
|
||||
<button class="btn small" :disabled="agentList.length < pageSize" @click="onNextPage">下一页</button>
|
||||
</view>
|
||||
<text class="page-info">共 {{ total }} 条记录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
const agentList = ref([
|
||||
{ uid: '60569', name: 'cs2020', ratio: 50, staffCount: 1, endTime: '2026-01-01', status: true },
|
||||
])
|
||||
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
|
||||
function onAdd() { uni.showToast({ title: '添加中...', icon: 'none' }) }
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { fetchAgents, saveAgent, DistributionAgent } from '@/services/admin/distributionService.uts'
|
||||
|
||||
const agentList = ref<DistributionAgent[]>([])
|
||||
const isLoading = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = 20
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await fetchAgents({
|
||||
search: searchQuery.value,
|
||||
page: page.value,
|
||||
pageSize: pageSize
|
||||
})
|
||||
agentList.value = res.items
|
||||
total.value = res.total
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
page.value = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
uni.showToast({ title: '添加代理商功能开发中', icon: 'none' })
|
||||
}
|
||||
|
||||
async function toggleStatus(item : DistributionAgent) {
|
||||
if (item.id == null) return
|
||||
const nextStatus = !item.status
|
||||
const success = await saveAgent({ ...item, status: nextStatus } as DistributionAgent)
|
||||
if (success) {
|
||||
item.status = nextStatus
|
||||
uni.showToast({ title: '状态修改成功', icon: 'success' })
|
||||
}
|
||||
}
|
||||
|
||||
function onPrevPage() {
|
||||
if (page.value > 1) {
|
||||
page.value--
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function onNextPage() {
|
||||
if (agentList.value.length >= pageSize) {
|
||||
page.value++
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.admin-page { padding: 0; }
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="table-container">
|
||||
<!-- Loading 遮罩 -->
|
||||
<view v-if="isLoading" class="loading-mask">
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
|
||||
<view class="table-header">
|
||||
<view class="col col-uid"><text>用户UID</text></view>
|
||||
<view class="col col-name"><text>代理商名称</text></view>
|
||||
@@ -30,40 +35,152 @@
|
||||
<view class="col col-ops"><text>操作</text></view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view v-for="item in applyList" :key="item.uid" class="table-row">
|
||||
<view class="col col-uid"><text>{{ item.uid }}</text></view>
|
||||
<view v-if="applyList.length === 0 && !isLoading" class="empty-row">
|
||||
<text>暂无申请记录</text>
|
||||
</view>
|
||||
<view v-for="item in applyList" :key="item.id" class="table-row">
|
||||
<view class="col col-uid"><text class="td-txt-small">{{ item.uid }}</text></view>
|
||||
<view class="col col-name"><text>{{ item.name }}</text></view>
|
||||
<view class="col col-phone"><text>{{ item.phone }}</text></view>
|
||||
<view class="col col-dept"><text>{{ item.deptName }}</text></view>
|
||||
<view class="col col-dept"><text>{{ item.division_name || '-' }}</text></view>
|
||||
<view class="col col-img">
|
||||
<image class="table-img" src="/static/logo.png" mode="aspectFill" />
|
||||
<image class="table-img" :src="item.images[0] || '/static/logo.png'" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="col col-time"><text>{{ item.time }}</text></view>
|
||||
<view class="col col-time"><text class="td-txt-small">{{ formatTime(item.created_at) }}</text></view>
|
||||
<view class="col col-status">
|
||||
<view class="status-tag"><text>{{ item.statusText }}</text></view>
|
||||
<view class="status-tag"><text>{{ getStatusLabel(item.status) }}</text></view>
|
||||
</view>
|
||||
<view class="col col-code"><view class="code-box"><text>{{ item.code }}</text></view></view>
|
||||
<view class="col col-code"><view class="code-box"><text>{{ item.invite_code || '-' }}</text></view></view>
|
||||
<view class="col col-ops">
|
||||
<text class="op-link">同意</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">拒绝</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">删除</text>
|
||||
<template v-if="item.status === 1">
|
||||
<text class="op-link" @click="handleAudit(item, 2)">同意</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link" @click="handleAudit(item, 3)">拒绝</text>
|
||||
<text class="op-divider">|</text>
|
||||
</template>
|
||||
<text class="op-link danger" @click="onDelete(item.id)">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="pagination" style="padding: 16px 24px;">
|
||||
<view class="pager-btns">
|
||||
<button class="btn small" :disabled="page <= 1" @click="onPrevPage">上一页</button>
|
||||
<text class="page-num">第 {{ page }} 页</text>
|
||||
<button class="btn small" :disabled="applyList.length < pageSize" @click="onNextPage">下一页</button>
|
||||
</view>
|
||||
<text class="page-info">共 {{ total }} 条记录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { fetchApplications, auditApplication, DistributionApplication } from '@/services/admin/distributionService.uts'
|
||||
|
||||
const activeTab = ref(0)
|
||||
const tabs = ['全部', '申请中', '已同意', '已拒绝']
|
||||
const applyList = ref([
|
||||
{ uid: '81806', name: '测试测试', phone: '19910205954', deptName: '26991', time: '2026-01-08 15:30:39', statusText: '申请中', code: '70623142' },
|
||||
])
|
||||
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
|
||||
const statusMap = [0, 1, 2, 3] // 映射到接口状态: 0:全部, 1:待审核, 2:已同意, 3:已拒绝
|
||||
|
||||
const applyList = ref<DistributionApplication[]>([])
|
||||
const isLoading = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = 20
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
watch(activeTab, () => {
|
||||
page.value = 1
|
||||
loadData()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await fetchApplications({
|
||||
search: searchQuery.value,
|
||||
status: statusMap[activeTab.value],
|
||||
page: page.value,
|
||||
pageSize: pageSize
|
||||
})
|
||||
applyList.value = res.items
|
||||
total.value = res.total
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
page.value = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
async function handleAudit(item : DistributionApplication, status : number) {
|
||||
if (item.id == null) return
|
||||
const actionText = status === 2 ? '同意' : '拒绝'
|
||||
uni.showModal({
|
||||
title: '确认操作',
|
||||
content: `确定要${actionText}该申请吗?`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
const success = await auditApplication(item.id!, status)
|
||||
if (success) {
|
||||
uni.showToast({ title: '操作成功', icon: 'success' })
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function onDelete(id : string | undefined) {
|
||||
if (id == null) return
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定要删除该申请记录吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
// 暂用审核接口或补充删除接口,此处示例为提示
|
||||
uni.showToast({ title: '删除功能开发中', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onPrevPage() {
|
||||
if (page.value > 1) {
|
||||
page.value--
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function onNextPage() {
|
||||
if (applyList.value.length >= pageSize) {
|
||||
page.value++
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(iso : string | null | undefined) : string {
|
||||
if (iso == null) return '-'
|
||||
return iso.substring(0, 16).replace('T', ' ')
|
||||
}
|
||||
|
||||
function getStatusLabel(status : number) : string {
|
||||
switch (status) {
|
||||
case 1: return '申请中'
|
||||
case 2: return '已同意'
|
||||
case 3: return '已拒绝'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.admin-page { padding: 0; }
|
||||
@@ -86,4 +203,5 @@ function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
|
||||
.code-box { border: 1px solid #d9d9d9; padding: 2px 8px; border-radius: 4px; font-size: 12px; background: #fafafa; }
|
||||
.op-link { color: #1890ff; cursor: pointer; }
|
||||
.op-divider { color: #e8e8e8; margin: 0 8px; }
|
||||
</style>
|
||||
</style>
|
||||
@@ -4,7 +4,7 @@
|
||||
<view class="filter-row">
|
||||
<view class="filter-item">
|
||||
<text class="label">搜索:</text>
|
||||
<input class="filter-input" placeholder="请输入姓名、UID" />
|
||||
<input class="filter-input" placeholder="请输入姓名、UID" v-model="searchQuery" @confirm="onSearch" />
|
||||
</view>
|
||||
<view class="filter-btns">
|
||||
<button class="btn primary" @click="onSearch">查询</button>
|
||||
@@ -16,6 +16,11 @@
|
||||
<button class="btn primary small" @click="onAdd">添加事业部</button>
|
||||
</view>
|
||||
<view class="table-container">
|
||||
<!-- Loading 遮罩 -->
|
||||
<view v-if="isLoading" class="loading-mask">
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
|
||||
<view class="table-header">
|
||||
<view class="col col-uid"><text>用户UID</text></view>
|
||||
<view class="col col-avatar"><text>头像</text></view>
|
||||
@@ -28,39 +33,128 @@
|
||||
<view class="col col-ops"><text>操作</text></view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view v-if="divisionList.length === 0 && !isLoading" class="empty-row">
|
||||
<text>暂无事业部数据</text>
|
||||
</view>
|
||||
<view v-for="item in divisionList" :key="item.uid" class="table-row">
|
||||
<view class="col col-uid"><text>{{ item.uid }}</text></view>
|
||||
<view class="col col-uid"><text class="td-txt-small">{{ item.uid }}</text></view>
|
||||
<view class="col col-avatar">
|
||||
<image class="avatar-img" src="/static/logo.png" mode="aspectFill" />
|
||||
<image class="avatar-img" :src="item.avatar_url || '/static/logo.png'" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="col col-name"><text>{{ item.name }}</text></view>
|
||||
<view class="col col-code"><text>{{ item.code }}</text></view>
|
||||
<view class="col col-name"><text>{{ item.name || item.nickname }}</text></view>
|
||||
<view class="col col-code"><text>{{ item.invite_code }}</text></view>
|
||||
<view class="col col-ratio"><text>{{ item.ratio }}%</text></view>
|
||||
<view class="col col-count"><text>{{ item.agentCount }}</text></view>
|
||||
<view class="col col-time"><text>{{ item.endTime }}</text></view>
|
||||
<view class="col col-count"><text>{{ item.agent_count }}</text></view>
|
||||
<view class="col col-time"><text>{{ formatTime(item.end_time) }}</text></view>
|
||||
<view class="col col-status">
|
||||
<switch :checked="item.status" color="#1890ff" scale="0.8" />
|
||||
<switch :checked="item.status" color="#1890ff" scale="0.8" @change="toggleStatus(item)" />
|
||||
</view>
|
||||
<view class="col col-ops">
|
||||
<text class="op-link">查看代理商</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">编辑</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">删除</text>
|
||||
<text class="op-link" @click="onDelete(item.id)">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="pagination">
|
||||
<view class="pager-btns">
|
||||
<button class="btn small" :disabled="page <= 1" @click="onPrevPage">上一页</button>
|
||||
<text class="page-num">第 {{ page }} 页</text>
|
||||
<button class="btn small" :disabled="divisionList.length < pageSize" @click="onNextPage">下一页</button>
|
||||
</view>
|
||||
<text class="page-info">共 {{ total }} 条记录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
const divisionList = ref([
|
||||
{ uid: '26991', name: '26991', code: '70623142', ratio: 40, agentCount: 1, endTime: '2026-12-31', status: true },
|
||||
])
|
||||
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
|
||||
function onAdd() { uni.showToast({ title: '添加中...', icon: 'none' }) }
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { fetchDivisions, saveDivision, deleteDivision, DistributionDivision } from '@/services/admin/distributionService.uts'
|
||||
|
||||
const divisionList = ref<DistributionDivision[]>([])
|
||||
const isLoading = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = 20
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res = await fetchDivisions({
|
||||
search: searchQuery.value,
|
||||
page: page.value,
|
||||
pageSize: pageSize
|
||||
})
|
||||
divisionList.value = res.items
|
||||
total.value = res.total
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
page.value = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
uni.showToast({ title: '添加事业部功能开发中', icon: 'none' })
|
||||
}
|
||||
|
||||
async function toggleStatus(item : DistributionDivision) {
|
||||
if (item.id == null) return
|
||||
const nextStatus = !item.status
|
||||
const success = await saveDivision({ ...item, status: nextStatus } as DistributionDivision)
|
||||
if (success) {
|
||||
item.status = nextStatus
|
||||
uni.showToast({ title: '状态修改成功', icon: 'success' })
|
||||
}
|
||||
}
|
||||
|
||||
async function onDelete(id : string | undefined) {
|
||||
if (id == null) return
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定要删除该事业部吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
const success = await deleteDivision(id!)
|
||||
if (success) {
|
||||
uni.showToast({ title: '删除成功' })
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onPrevPage() {
|
||||
if (page.value > 1) {
|
||||
page.value--
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function onNextPage() {
|
||||
if (divisionList.value.length >= pageSize) {
|
||||
page.value++
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(iso : string | null) : string {
|
||||
if (!iso) return '-'
|
||||
return iso.substring(0, 10)
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.admin-page { padding: 0; }
|
||||
|
||||
Reference in New Issue
Block a user