1
This commit is contained in:
parent
0cea3df5d5
commit
743f714246
@ -548,4 +548,44 @@ export function uploadClientErrorLog(
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ index.getWarehousePanelData ============
|
||||
|
||||
/** index.getWarehousePanelData 入参 */
|
||||
export type GetWarehousePanelDataParams = {
|
||||
/** 最后一次更改的时间戳(Unix 秒);常规调用(force 非真)必填,小于服务端缓存时间戳时返回 is_change=true;force=true 时可选,缺省视为 0 */
|
||||
last_change_at?: number
|
||||
/** 是否强制输出数据(true/1/'true'):前端首次拉取时传 true,is_change 强制为 true,last_change_at 可不传 */
|
||||
force?: boolean | number | string
|
||||
}
|
||||
|
||||
/** index.getWarehousePanelData 响应 */
|
||||
export type GetWarehousePanelDataResponse = {
|
||||
/** 是否已改变:force 为真时恒为 true;否则传入时间戳小于最后缓存时间戳时为 true,反之为 false */
|
||||
is_change?: boolean
|
||||
/** 服务端最后更改时间戳(Unix 秒,缓存未命中为 0),前端保存后作为下次轮询的 last_change_at 入参回传 */
|
||||
last_change_at?: number
|
||||
/** 面板数据,当前为空对象,字段另行约定 */
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* 仓库面板数据接口:按仓库做增量变更检测,返回 is_change 与 last_change_at。
|
||||
* ⚠️ 常规调用(force 非真)必须传 `last_change_at`;首次拉取传 `force: true`。
|
||||
*/
|
||||
export function getWarehousePanelData(
|
||||
data?: GetWarehousePanelDataParams
|
||||
): Promise<GetWarehousePanelDataResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'index.getWarehousePanelData',
|
||||
v: '1.0',
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data ?? {},
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
@ -7,7 +7,8 @@ export const accountColumns = [
|
||||
{ label: '邮箱', prop: 'email', minWidth: 120 },
|
||||
{ label: '角色', prop: 'roles', minWidth: 140 },
|
||||
{ label: '状态', prop: 'status', width: 100 },
|
||||
{ label: '操作', prop: 'actions', width: 480, fixed: 'right' }
|
||||
// 操作列改为 link 按钮(对齐 views/mode 模板),宽度按最长 5 个按钮估算
|
||||
{ label: '操作', prop: 'actions', width: 300, fixed: 'right' }
|
||||
]
|
||||
|
||||
export const defaultTemp = {
|
||||
|
||||
@ -1,66 +1,104 @@
|
||||
<template>
|
||||
<div class="account-container app-container">
|
||||
<div class="filter-container">
|
||||
<el-form :inline="true" :model="listQuery" class="demo-form-inline">
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="listQuery.status" placeholder="状态" clearable style="width: 120px">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="停用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="包含已删除">
|
||||
<el-switch v-model="listQuery.includeDisabled" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleFilter">搜索</el-button>
|
||||
<el-button type="success" icon="Plus" @click="handleCreate">新增工号</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="page-wrapper" :style="{ height: containerHeight }">
|
||||
<div class="main-container">
|
||||
<div class="order-sub-container">
|
||||
<div class="main-content">
|
||||
<!-- 工具栏:左=操作按钮组,右=状态 / 包含已删除 -->
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<OrderToolbarButtonGroup
|
||||
:buttons="toolbarButtons"
|
||||
:resolve-disabled="resolveButtonDisabled"
|
||||
:resolve-loading="resolveButtonLoading"
|
||||
:resolve-label="resolveButtonLabel"
|
||||
:layout-key="toolbarLayoutKey"
|
||||
@action="handleToolbarButtonClick"
|
||||
/>
|
||||
</div>
|
||||
<div class="toolbar-right">
|
||||
<el-select
|
||||
v-model="listQuery.status"
|
||||
class="toolbar-right__status"
|
||||
size="small"
|
||||
clearable
|
||||
placeholder="全部状态"
|
||||
@change="handleFilter"
|
||||
>
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="停用" :value="0" />
|
||||
</el-select>
|
||||
<span class="toolbar-right__label">包含已删除</span>
|
||||
<el-switch
|
||||
v-model="listQuery.includeDisabled"
|
||||
size="small"
|
||||
@change="handleFilter"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表区:占满右侧全高 -->
|
||||
<div class="upper-wrapper">
|
||||
<UpperTable
|
||||
title="工号列表"
|
||||
default-align="center"
|
||||
:data="pagedList"
|
||||
:columns="columns"
|
||||
row-key="employee_id"
|
||||
table-size="small"
|
||||
:pagination="pagination"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:show-index="true"
|
||||
:show-selection="false"
|
||||
:loading="listLoading"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@refresh="getList"
|
||||
>
|
||||
<template #column-avatar_url="{ row }">
|
||||
<el-avatar :size="30" :src="row.avatar_url">
|
||||
<el-icon><User /></el-icon>
|
||||
</el-avatar>
|
||||
</template>
|
||||
<template #column-status="{ row }">
|
||||
<span :class="getStatusTextClass(row.status === 1 ? 'success' : 'danger')">
|
||||
{{ row.status === 1 ? '启用' : '停用' }}
|
||||
</span>
|
||||
</template>
|
||||
<template #column-roles="{ row }">
|
||||
<template v-if="row.roles && row.roles.length">
|
||||
<el-tag
|
||||
v-for="r in row.roles"
|
||||
:key="r.role_id"
|
||||
class="role-tag"
|
||||
size="small"
|
||||
:type="roleTagMap[r.role_name] || 'info'"
|
||||
>
|
||||
{{ r.role_name }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<span v-else class="cell-empty">未分配</span>
|
||||
</template>
|
||||
<template #column-actions="{ row }">
|
||||
<el-button link type="primary" size="small" @click.stop="handleUpdate(row)">编辑</el-button>
|
||||
<el-button link type="warning" size="small" @click.stop="handleAssignRole(row)">分配角色</el-button>
|
||||
<el-button link type="primary" size="small" @click.stop="handleResetPassword(row)">重置密码</el-button>
|
||||
<el-button v-if="row.status === 1" link type="danger" size="small" @click.stop="handleDelete(row)">停用</el-button>
|
||||
<el-button v-else link type="success" size="small" @click.stop="handleEnable(row)">启用</el-button>
|
||||
<el-button v-if="row.is_wechat_bound" link type="danger" size="small" @click.stop="handleUnbindWechat(row)">解除绑定</el-button>
|
||||
<el-button v-else link type="primary" size="small" @click.stop="handleBindWechat(row)">绑定微信</el-button>
|
||||
</template>
|
||||
|
||||
<template #empty>
|
||||
<div class="empty-tip">暂无工号数据</div>
|
||||
</template>
|
||||
</UpperTable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<upper-table
|
||||
v-loading="listLoading"
|
||||
:data="list"
|
||||
:columns="columns"
|
||||
row-key="employee_id"
|
||||
>
|
||||
<template #column-avatar_url="{ row }">
|
||||
<el-avatar :size="30" :src="row.avatar_url">
|
||||
<img src="https://cube.elemecdn.com/e/fd/0fc7693967a94116a3f11b0106734664jpg.png" />
|
||||
</el-avatar>
|
||||
</template>
|
||||
<template #column-status="{ row }">
|
||||
<el-tag :type="row.status === 1 ? 'success' : 'danger'">
|
||||
{{ row.status === 1 ? '启用' : '停用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #column-roles="{ row }">
|
||||
<template v-if="row.roles && row.roles.length">
|
||||
<el-tag
|
||||
v-for="r in row.roles"
|
||||
:key="r.role_id"
|
||||
size="small"
|
||||
style="margin:2px"
|
||||
:type="roleTagMap[r.role_name] || 'info'"
|
||||
>
|
||||
{{ r.role_name }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<el-text v-else type="info" size="small">未分配</el-text>
|
||||
</template>
|
||||
<template #column-actions="{ row }">
|
||||
<el-button type="primary" size="small" icon="Edit" @click="handleUpdate(row)">编辑</el-button>
|
||||
<el-button type="warning" size="small" icon="Lock" @click="handleAssignRole(row)">分配角色</el-button>
|
||||
<el-button size="small" icon="Key" @click="handleResetPassword(row)">重置密码</el-button>
|
||||
<el-button v-if="row.status === 1" type="danger" size="small" icon="CircleClose" @click="handleDelete(row)">停用</el-button>
|
||||
<el-button v-else type="success" size="small" icon="CircleCheck" @click="handleEnable(row)">启用</el-button>
|
||||
<el-button v-if="row.is_wechat_bound" type="danger" plain size="small" icon="CircleClose" @click="handleUnbindWechat(row)">解除绑定</el-button>
|
||||
<el-button v-else type="info" size="small" icon="Link" @click="handleBindWechat(row)">绑定微信</el-button>
|
||||
</template>
|
||||
</upper-table>
|
||||
|
||||
<!-- 新增/编辑弹窗 -->
|
||||
<el-dialog :title="textMap[dialogStatus]" v-model="dialogFormVisible" width="1000px" align-center custom-class="account-dialog" @close="handleDialogClose">
|
||||
<el-dialog :title="textMap[dialogStatus]" v-model="dialogFormVisible" width="1000px" align-center class="account-dialog" @close="handleDialogClose">
|
||||
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="top" class="custom-form">
|
||||
<el-tabs v-model="activeTab" class="form-tabs">
|
||||
<el-tab-pane label="基本信息" name="base">
|
||||
@ -266,9 +304,24 @@ import { roleList } from '@/api/setting.role/role'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import ImagesUpload from '@/components/ImagesUpload/index.vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { CircleCheckFilled, Loading, RefreshRight, User, Picture } from '@element-plus/icons-vue'
|
||||
import { CircleCheckFilled, Loading, RefreshRight, User } from '@element-plus/icons-vue'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||
import {
|
||||
getStatusTextClass,
|
||||
type ToolbarButtonConfig as OrderToolbarButtonConfig
|
||||
} from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { accountColumns, defaultTemp, accountRules, roleTagMap } from './account-config'
|
||||
|
||||
// ============================================================
|
||||
// 容器高度(对齐 views/mode 模板页面)
|
||||
// ============================================================
|
||||
const settingsStore = useSettingsStore()
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() =>
|
||||
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
|
||||
)
|
||||
|
||||
const list = ref([])
|
||||
const listLoading = ref(true)
|
||||
const listQuery = reactive({
|
||||
@ -276,6 +329,72 @@ const listQuery = reactive({
|
||||
includeDisabled: false
|
||||
})
|
||||
|
||||
// ============================================================
|
||||
// 工具栏按钮组(刷新 / 新增工号)
|
||||
// ============================================================
|
||||
const toolbarButtons: OrderToolbarButtonConfig[] = [
|
||||
{ key: 'refresh', label: '刷新', category: 'refresh', loadingKey: 'loading', action: 'loadData' },
|
||||
{ key: 'createAccount', label: '新增工号', category: 'action', action: 'createAccount' }
|
||||
]
|
||||
|
||||
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||
loading: listLoading.value
|
||||
}))
|
||||
|
||||
const toolbarLayoutKey = computed(() =>
|
||||
JSON.stringify({ loading: buttonLoadingMap.value })
|
||||
)
|
||||
|
||||
function resolveButtonLoading(loadingKey?: string) {
|
||||
if (!loadingKey) return false
|
||||
return Boolean(buttonLoadingMap.value[loadingKey])
|
||||
}
|
||||
|
||||
/** 本页无按选中状态禁用的按钮 */
|
||||
function resolveButtonDisabled() {
|
||||
return false
|
||||
}
|
||||
|
||||
/** 本页无动态文案按钮 */
|
||||
function resolveButtonLabel(defaultLabel: string) {
|
||||
return defaultLabel
|
||||
}
|
||||
|
||||
function handleToolbarButtonClick(action: string) {
|
||||
if (action === 'loadData') {
|
||||
void getList()
|
||||
return
|
||||
}
|
||||
if (action === 'createAccount') {
|
||||
handleCreate()
|
||||
return
|
||||
}
|
||||
console.warn('[account] 未处理的工具栏动作:', action)
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 前端分页(setting.account.list 一次性返回全部工号)
|
||||
// ============================================================
|
||||
const pagination = reactive({
|
||||
currentPage: 1,
|
||||
pageSize: 20,
|
||||
total: 0
|
||||
})
|
||||
|
||||
const pagedList = computed(() => {
|
||||
const start = (pagination.currentPage - 1) * pagination.pageSize
|
||||
return list.value.slice(start, start + pagination.pageSize)
|
||||
})
|
||||
|
||||
const handlePageChange = (page: number) => {
|
||||
pagination.currentPage = page
|
||||
}
|
||||
|
||||
const handlePageSizeChange = (size: number) => {
|
||||
pagination.pageSize = size
|
||||
pagination.currentPage = 1
|
||||
}
|
||||
|
||||
const imagesUploadRef = ref()
|
||||
const dataForm = ref()
|
||||
|
||||
@ -333,15 +452,24 @@ const getList = async () => {
|
||||
listLoading.value = true
|
||||
try {
|
||||
const response = await accountList(listQuery)
|
||||
list.value = response.data || []
|
||||
// 接口响应为 res.data 数组(兼容 data.list)
|
||||
list.value = Array.isArray(response?.data) ? response.data : (response?.data?.list ?? [])
|
||||
pagination.total = list.value.length
|
||||
// 页码夹取:删除/筛选后当前页可能超范围
|
||||
const maxPage = Math.max(1, Math.ceil(pagination.total / pagination.pageSize))
|
||||
if (pagination.currentPage > maxPage) pagination.currentPage = maxPage
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
list.value = []
|
||||
pagination.total = 0
|
||||
} finally {
|
||||
listLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 筛选条件变化:回到第一页重查 */
|
||||
const handleFilter = () => {
|
||||
pagination.currentPage = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
@ -473,11 +601,6 @@ const submitResetPassword = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleAvatarSuccess = (res: any) => {
|
||||
temp.file_id = res.file_id
|
||||
temp.avatar_url = res.url
|
||||
}
|
||||
|
||||
// ---------------- 角色分配相关 ----------------
|
||||
const roleDialogVisible = ref(false)
|
||||
const roleLoading = ref(false)
|
||||
@ -742,13 +865,56 @@ const handleUnbindWechat = (row: any) => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.account-container {
|
||||
height: calc(100vh - 130px);
|
||||
/* 布局样式对齐 order/orderManagement(order-sub.scss),同时提供 .ut-status-text 状态文字色 */
|
||||
@use "../../../order/orderManagement/styles/order-sub.scss";
|
||||
|
||||
.page-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 单页模式:一张卡片包住「工具栏 + 列表」 */
|
||||
.main-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #e8eef7;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 工具栏右侧:状态筛选 + 包含已删除 */
|
||||
.toolbar-right__status {
|
||||
width: 130px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.toolbar-right__label {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.role-tag {
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.cell-empty {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
margin-bottom: 20px;
|
||||
padding: 24px;
|
||||
@ -809,10 +975,9 @@ const handleUnbindWechat = (row: any) => {
|
||||
|
||||
:deep(.account-dialog) {
|
||||
.el-dialog__body {
|
||||
padding: 24px;
|
||||
max-height: 80vh;
|
||||
padding: 16px 20px 8px;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
background-color: #f8fafc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user