This commit is contained in:
zlwu committed 2026-05-17 08:36:37 +08:00
1 parent 246ad2228e
commit 8e2dd8b9f0
186 files changed
+38821 -2571

No files matched your search

+45 -19
View File
@@ -89,6 +89,7 @@
row-key="id"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
@selection-change="handleCategoryTableSelectionChange"
@row-dblclick="handleView"
>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column
@@ -136,7 +137,6 @@
<span>{{ formatPriceCoefficient(row.priceCoefficient) }}</span>
</template>
</el-table-column>
<el-table-column prop="sortOrder" label="排序" width="80" align="center" header-align="center" />
<el-table-column prop="isActive" label="状态" width="80" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="row.isActive ? 'success' : 'info'" size="small">
@@ -144,9 +144,10 @@
</el-tag>
</template>
</el-table-column>
<el-table-column prop="createAt" label="创建时间" width="160" align="center" header-align="center" />
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
<el-table-column prop="createAt" label="创建时间" width="180" align="center" header-align="center" />
<el-table-column label="操作" width="400" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)"><el-icon><View /></el-icon>查看</el-button>
<el-button class="btn-op-item primary" @click="handleAddChild(row)" v-if="!row.parentId">
新增子分类
</el-button>
@@ -193,12 +194,12 @@
<div class="form-row">
<el-form-item label="价格系数" prop="priceCoefficient" class="flex-1">
<div class="price-coefficient-field">
<el-input-number
<el-input
type="number"
step="any"
v-model="formData.priceCoefficient"
:min="0"
:max="100"
:precision="2"
:step="0.5"
controls-position="right"
class="price-coefficient-input"
/>
@@ -228,9 +229,6 @@
</el-upload>
</div>
</el-form-item>
<el-form-item label="排序" class="flex-1">
<el-input-number v-model="formData.sortOrder" :min="0" />
</el-form-item>
</div>
<div class="form-row">
<el-form-item label="状态" v-if="isEdit" class="flex-1">
@@ -425,6 +423,14 @@
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.name || '分类详情'"
:icon="Files"
:meta="`${viewRow?.isActive ? '启用' : '禁用'}${viewRow?.createAt ? ' · ' + viewRow.createAt : ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
@@ -434,9 +440,10 @@
import { ref, reactive, onMounted, nextTick, watch, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import { Plus, Search, Rank, Close, Check } from '@element-plus/icons-vue'
import { Plus, Search, Rank, Close, Check, View, Files } from '@element-plus/icons-vue'
import { VueDraggable as draggable } from 'vue-draggable-plus'
import type { UploadFile } from 'element-plus'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import {
fetchCategoryList,
fetchCreateCategory,
@@ -459,6 +466,31 @@
const categoryList = ref<any[]>([])
const parentCategoryList = ref<any[]>([])
// ---- 查看弹窗 ----
const viewVisible = ref(false)
const viewRow = ref<any>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
return [
{
title: '基本信息',
fields: [
{ label: '分类名称', value: row.name },
{ label: '上级分类', value: row.parentId ? parentCategoryList.value.find((c: any) => c.id === row.parentId)?.name || row.parentId : '无' },
{ label: '价格系数', value: formatPriceCoefficient(row.priceCoefficient) },
{ label: '状态', value: row.isActive ? '启用' : '禁用' },
{ label: '图片', value: row.imageUrl || '无' },
{ label: '创建时间', value: row.createAt }
]
}
]
})
function handleView(row: any) {
viewRow.value = row
viewVisible.value = true
}
const handleCategoryTableSelectionChange = (rows: any[]) => {
selectedRows.value = rows
}
@@ -1248,15 +1280,7 @@
border-top: none !important;
}
.category-dialog-form {
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
.category-image-row { display: flex; gap: 12px; align-items: center; }
.category-image-placeholder {
@@ -1289,7 +1313,9 @@
color: #303133;
margin-bottom: 16px;
padding-bottom: 12px;
padding-left: 10px;
border-bottom: 1px solid #ebeef5;
border-left: 3px solid #10b981;
}
.form-row {
+209 -57
View File
@@ -55,17 +55,15 @@
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
:default-expand-all="isExpandAll"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column
type="selection"
width="55"
align="center"
header-align="center"
/>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column
prop="deptName"
label="组织名称"
min-width="200"
min-width="140"
align="left"
header-align="left"
/>
<el-table-column
prop="deptCategoryCode"
@@ -94,32 +92,28 @@
<el-table-column
prop="leader"
label="负责人"
width="120"
width="160"
align="center"
header-align="center"
/>
<el-table-column
prop="leaderPhone"
label="联系电话"
width="140"
width="180"
align="center"
header-align="center"
/>
<el-table-column
prop="orderNum"
label="排序"
width="80"
align="center"
header-align="center"
/>
<el-table-column
label="操作"
width="320"
fixed="right"
label="操作"
width="400"
fixed="right"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button class="btn-op-item primary" @click="handleAddChild(row)">
新增子组织
</el-button>
@@ -154,11 +148,7 @@
<el-input v-model="formData.deptName" placeholder="请输入组织名称" />
</el-form-item>
<el-form-item label="组织类别">
<el-select
v-model="formData.deptCategoryCode"
placeholder="请选择组织类别"
clearable
>
<el-select v-model="formData.deptCategoryCode" placeholder="请选择组织类别" clearable>
<el-option
v-for="opt in deptCategoryOptions"
:key="opt.value"
@@ -178,26 +168,34 @@
</el-select>
</el-form-item>
<el-form-item label="负责人">
<el-input v-model="formData.leader" placeholder="可选" />
<el-select
v-model="leaderUserId"
class="w-full"
filterable
remote
clearable
reserve-keyword
:remote-method="remoteSearchLeaderUsers"
:loading="leaderUserLoading"
placeholder="输入关键词检索用户"
@change="onLeaderUserChange"
>
<el-option
v-for="u in leaderUserOptions"
:key="u.id"
:label="formatLeaderUserLabel(u)"
:value="u.id"
/>
</el-select>
</el-form-item>
<el-form-item label="联系电话">
<el-input v-model="formData.leaderPhone" placeholder="可选" />
</el-form-item>
<el-form-item label="排序">
<el-input-number
v-model="formData.orderNum"
:min="0"
:max="9999"
controls-position="right"
<el-input
v-model="formData.leaderPhone"
placeholder="可选,选择负责人后自动填入,可修改"
/>
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input
v-model="formData.remark"
type="textarea"
:rows="2"
placeholder="可选"
/>
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="可选" />
</el-form-item>
</div>
</el-form>
@@ -206,31 +204,36 @@
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button
class="btn-main"
type="primary"
@click="handleSubmit"
:loading="submitLoading"
>
<el-button class="btn-main" type="primary" @click="handleSubmit" :loading="submitLoading">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.deptName || '组织详情'"
:icon="OfficeBuilding"
:meta="`${viewRow?.leader ? '负责人:' + viewRow.leader : ''}${viewRow?.leader && viewRow?.createTime ? ' · ' : ''}${viewRow?.createTime || ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ref, reactive, computed, onMounted, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, View, OfficeBuilding } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import {
fetchDeptTree,
fetchCreateDept,
fetchUpdateDept,
fetchDeleteDept,
fetchDictDataOptions
fetchDictDataOptions,
fetchUserList
} from '@/api/admin'
defineOptions({ name: 'SystemDept' })
@@ -249,6 +252,9 @@
const formRef = ref()
const editingId = ref<string | null>(null)
const viewVisible = ref(false)
const viewRow = ref<Api.Dept.DeptItem | null>(null)
const formData = reactive({
parentId: '',
deptName: '',
@@ -267,6 +273,107 @@
const deptCategoryOptions = ref<Api.Dict.DictDataOption[]>([])
const statusOptions = ref<Api.Dict.DictDataOption[]>([])
/** 负责人:关联 sys_user,提交仍写 leader / leaderPhone 字符串 */
const leaderUserId = ref<string | null>(null)
const leaderUserOptions = ref<Api.User.UserItem[]>([])
const leaderSelectedSnapshot = ref<Api.User.UserItem | null>(null)
const leaderUserLoading = ref(false)
function formatLeaderUserLabel(u: Api.User.UserItem) {
const name = (u.nickName || '').trim() || '-'
const no = (u.userNo || '').trim()
const phone = (u.phoneNo || '').trim()
const parts = [name]
if (no) parts.push(no)
if (phone) parts.push(phone)
return parts.join(' · ')
}
async function remoteSearchLeaderUsers(query: string) {
leaderUserLoading.value = true
try {
const q = (query || '').trim()
const res = await fetchUserList({
page: 1,
pageSize: 50,
keyword: q || undefined,
status: '1'
})
let list = [...(res.list || [])]
const curId = leaderUserId.value
if (
curId &&
leaderSelectedSnapshot.value?.id === curId &&
!list.some((x) => x.id === curId)
) {
list = [leaderSelectedSnapshot.value, ...list]
}
leaderUserOptions.value = list
} catch (e) {
console.error('检索用户失败:', e)
leaderUserOptions.value = []
} finally {
leaderUserLoading.value = false
}
}
function onLeaderUserChange(val: string | null | undefined) {
if (!val) {
leaderUserId.value = null
leaderSelectedSnapshot.value = null
leaderUserOptions.value = []
formData.leader = ''
formData.leaderPhone = ''
return
}
const u =
leaderUserOptions.value.find((x) => x.id === val) ||
(leaderSelectedSnapshot.value?.id === val ? leaderSelectedSnapshot.value : undefined)
if (!u) return
leaderSelectedSnapshot.value = { ...u }
formData.leader = (u.nickName || '').trim()
formData.leaderPhone = (u.phoneNo || '').trim()
}
async function resolveLeaderUserForEdit() {
leaderUserId.value = null
leaderSelectedSnapshot.value = null
leaderUserOptions.value = []
const name = (formData.leader || '').trim()
const phone = (formData.leaderPhone || '').trim()
if (!name && !phone) return
leaderUserLoading.value = true
try {
const res = await fetchUserList({
page: 1,
pageSize: 50,
keyword: name || phone || undefined,
status: '1'
})
const list = res.list || []
const match =
list.find(
(u) =>
(u.nickName || '').trim() === name && (!phone || (u.phoneNo || '').trim() === phone)
) ||
(name ? list.find((u) => (u.nickName || '').trim() === name) : undefined) ||
(name ? list.find((u) => (u.userNo || '').trim() === name) : undefined)
if (match) {
leaderUserOptions.value = list
leaderUserId.value = match.id
leaderSelectedSnapshot.value = { ...match }
formData.leader = (match.nickName || '').trim()
if ((match.phoneNo || '').trim()) {
formData.leaderPhone = (match.phoneNo || '').trim()
}
}
} catch (e) {
console.error('匹配负责人用户失败:', e)
} finally {
leaderUserLoading.value = false
}
}
const loadDictOptions = async () => {
try {
const [zzlbbm, bmzt] = await Promise.all([
@@ -286,10 +393,53 @@
return opt ? opt.label : code
}
const viewSections = computed(() => [
{
title: '基本信息',
fields: [
{ label: '组织名称', value: viewRow.value?.deptName },
{ label: '组织类别', value: getDeptCategoryLabel(viewRow.value?.deptCategoryCode || '') },
{ label: '状态', value: viewRow.value?.status === '1' ? '正常' : '停用' },
{ label: '负责人', value: viewRow.value?.leader },
{ label: '联系电话', value: viewRow.value?.leaderPhone },
{ label: '备注', value: viewRow.value?.remark, span: true }
]
}
])
function handleView(row: Api.Dept.DeptItem) {
viewRow.value = { ...row }
viewVisible.value = true
}
const handleSelectionChange = (rows: Api.Dept.DeptItem[]) => {
selectedRows.value = rows
}
/** 树表格的 default-expand-all 只在初次挂载生效,展开态需用表格 API 同步 */
function applyTreeExpand(expand: boolean) {
const table = tableRef.value
if (!table?.toggleRowExpansion) return
const preorder = (items: Api.Dept.DeptItem[]) => {
for (const row of items) {
if (row.children?.length) {
table.toggleRowExpansion(row, expand)
preorder(row.children)
}
}
}
const postorder = (items: Api.Dept.DeptItem[]) => {
for (const row of items) {
if (row.children?.length) {
postorder(row.children)
table.toggleRowExpansion(row, expand)
}
}
}
if (expand) preorder(tableData.value)
else postorder(tableData.value)
}
async function loadData() {
loading.value = true
try {
@@ -297,6 +447,8 @@
keyword: searchForm.keyword || undefined
})
tableData.value = res || []
await nextTick()
applyTreeExpand(isExpandAll.value)
} catch (error) {
console.error('加载组织数据失败:', error)
} finally {
@@ -315,7 +467,9 @@
function toggleExpand() {
isExpandAll.value = !isExpandAll.value
tableData.value = [...tableData.value]
nextTick(() => {
applyTreeExpand(isExpandAll.value)
})
}
function resetForm() {
@@ -328,6 +482,9 @@
formData.orderNum = 0
formData.remark = ''
editingId.value = null
leaderUserId.value = null
leaderUserOptions.value = []
leaderSelectedSnapshot.value = null
}
function handleAdd() {
@@ -362,6 +519,9 @@
formData.remark = row.remark || ''
dialogVisible.value = true
formRef.value?.clearValidate?.()
nextTick(() => {
resolveLeaderUserForEdit()
})
}
async function handleSubmit() {
@@ -425,13 +585,5 @@
:deep(.el-form-item) {
margin-bottom: 0;
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
</style>
+70 -52
View File
@@ -62,6 +62,7 @@
stripe
row-key="id"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column
type="selection"
@@ -91,36 +92,31 @@
align="center"
header-align="center"
/>
<el-table-column
prop="orderNum"
label="排序"
width="80"
align="center"
header-align="center"
/>
<el-table-column
prop="remark"
label="备注"
min-width="150"
show-overflow-tooltip
align="center"
header-align="center"
/>
<el-table-column
prop="createTime"
label="创建时间"
min-width="160"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column
label="操作"
width="320"
width="400"
fixed="right"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button
class="btn-op-item primary"
@click="handleDictData(row)"
@@ -180,17 +176,6 @@
:disabled="isEdit"
/>
</el-form-item>
<el-form-item label="排序">
<div class="sort-field">
<el-input-number
v-model="formData.orderNum"
:min="0"
:max="9999"
controls-position="right"
/>
<span class="form-tip">数值越小越靠前</span>
</div>
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input
v-model="formData.remark"
@@ -217,6 +202,14 @@
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.dictName || '字典详情'"
:icon="Collection"
:meta="`字典类型编码:${viewRow?.dictType || ''}${viewRow?.createTime ? ' · ' + viewRow.createTime : ''}`"
:sections="viewSections"
/>
</section>
<el-dialog
@@ -256,13 +249,6 @@
align="center"
header-align="center"
/>
<el-table-column
prop="orderNum"
label="排序"
width="80"
align="center"
header-align="center"
/>
<el-table-column
prop="remark"
label="备注"
@@ -337,17 +323,6 @@
<el-form-item label="数据值" prop="dictValue">
<el-input v-model="dictDataFormData.dictValue" placeholder="数据值" />
</el-form-item>
<el-form-item label="排序">
<div class="sort-field">
<el-input-number
v-model="dictDataFormData.orderNum"
:min="0"
:max="9999"
controls-position="right"
/>
<span class="form-tip">数值越小越靠前</span>
</div>
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input
v-model="dictDataFormData.remark"
@@ -381,7 +356,9 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, View, Collection } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchDictTypeList,
fetchCreateDictType,
@@ -407,6 +384,10 @@
const formRef = ref()
const editingId = ref<string | null>(null)
const viewVisible = ref(false)
const viewRow = ref<Api.Dict.DictTypeItem | null>(null)
const viewDictDataList = ref<Api.Dict.DictDataItem[]>([])
const formData = reactive({
dictName: '',
dictType: '',
@@ -457,6 +438,47 @@
editingId.value = null
}
const viewSections = computed(() => {
const sections: any[] = [
{
title: '基本信息',
fields: [
{ label: '字典名称', value: viewRow.value?.dictName },
{ label: '字典类型编码', value: viewRow.value?.dictType },
{ label: '备注', value: viewRow.value?.remark, span: true },
{ label: '创建时间', value: viewRow.value?.createTime }
]
}
]
if (viewDictDataList.value.length > 0) {
sections.push({
title: '字典数据',
fields: viewDictDataList.value.map((item) => ({
label: item.dictLabel || '',
value: item.dictValue || '',
span: false
}))
})
}
return sections
})
async function handleView(row: Api.Dict.DictTypeItem) {
viewRow.value = { ...row }
viewDictDataList.value = []
viewVisible.value = true
try {
const res = await fetchDictDataList({
page: 1,
pageSize: 100,
dictType: row.dictType
})
viewDictDataList.value = res.list || []
} catch (e) {
console.error('加载字典数据失败:', e)
}
}
function handleAdd() {
isEdit.value = false
dialogTitle.value = '新增字典类型'
@@ -518,11 +540,14 @@
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个字典类型吗?`, '提示', {
type: 'warning'
})
for (const id of ids) {
await fetchDeleteDictType(id)
}
selectedRows.value = []
await loadData()
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeleteDictType(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
const dictDataDialogVisible = ref(false)
@@ -646,12 +671,5 @@
margin-bottom: 0;
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
</style>
+48 -28
View File
@@ -57,6 +57,7 @@
stripe
row-key="id"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column
@@ -69,10 +70,12 @@
/>
<el-table-column prop="expressCode" label="快递编码" min-width="120" align="center" header-align="center" />
<el-table-column prop="expressName" label="快递名称" min-width="140" align="center" header-align="center" />
<el-table-column prop="orderNum" label="排序" width="80" align="center" header-align="center" />
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center" header-align="center" />
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)"
><el-icon><View /></el-icon>查看</el-button
>
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
<el-button class="btn-op-item" @click="handleDelete(row)">删除</el-button>
</template>
@@ -116,17 +119,6 @@
<el-form-item label="快递名称" prop="expressName">
<el-input v-model="formData.expressName" placeholder="请输入快递名称" />
</el-form-item>
<el-form-item label="排序">
<div class="sort-field">
<el-input-number
v-model="formData.orderNum"
:min="0"
:max="9999"
controls-position="right"
/>
<span class="form-tip">数值越小越靠前</span>
</div>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="formData.remark" placeholder="可选" />
</el-form-item>
@@ -143,14 +135,24 @@
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.expressName || '快递公司详情'"
:icon="Van"
:meta="viewRow?.createTime || ''"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, View, Van } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchExpressCompanyList,
fetchCreateExpressCompany,
@@ -171,6 +173,8 @@
const submitLoading = ref(false)
const formRef = ref()
const editingId = ref<string | null>(null)
const viewVisible = ref(false)
const viewRow = ref<Api.ExpressCompany.ExpressCompanyItem | null>(null)
const formData = reactive({
expressCode: '',
@@ -188,6 +192,21 @@
selectedRows.value = rows
}
const viewSections = computed(() => {
if (!viewRow.value) return []
const row = viewRow.value
return [
{
title: '基本信息',
fields: [
{ label: '快递编码', value: row.expressCode },
{ label: '快递名称', value: row.expressName },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
async function loadData() {
loading.value = true
try {
@@ -267,6 +286,11 @@
}
}
function handleView(row: Api.ExpressCompany.ExpressCompanyItem) {
viewRow.value = row
viewVisible.value = true
}
async function handleDelete(row: Api.ExpressCompany.ExpressCompanyItem) {
await ElMessageBox.confirm(`确定删除快递公司「${row.expressName}」吗?`, '提示', { type: 'warning' })
await fetchDeleteExpressCompany(row.id)
@@ -278,11 +302,14 @@
const ids = selectedRows.value.map((r) => r.id)
if (!ids.length) return
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个快递公司吗?`, '提示', { type: 'warning' })
for (const id of ids) {
await fetchDeleteExpressCompany(id)
}
selectedRows.value = []
await loadData()
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeleteExpressCompany(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
@@ -296,12 +323,5 @@
margin-bottom: 0;
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
</style>
+331
View File
@@ -0,0 +1,331 @@
<!-- 请假申请 — 工作流测试页面 -->
<template>
<div class="page-container">
<header class="page-head">
<h1>请假申请</h1>
<p class="page-desc">测试工作流审批流程</p>
</header>
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">请假列表</h2>
</div>
<div class="filter-block">
<el-form :model="filterForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="关键词">
<el-input v-model="filterForm.keyword" placeholder="搜索原因/类型" clearable />
</el-form-item>
<el-form-item label="状态">
<el-select v-model="filterForm.status" placeholder="全部" clearable style="width: 120px">
<el-option label="草稿" value="draft" />
<el-option label="审批中" value="pending" />
<el-option label="已通过" value="approved" />
<el-option label="已驳回" value="rejected" />
</el-select>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">按原因、类型模糊查询。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" @click="handleReset">重置</el-button>
<el-button class="btn-main" type="primary" @click="handleSearch">搜索</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
</div>
<el-button class="btn-main" type="primary" @click="handleAdd">新增请假</el-button>
</div>
</div>
<div class="list-body list-wrap">
<el-table
class="list-table"
:data="tableData"
stripe
row-key="id"
v-loading="loading"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column prop="leaveTypeLabel" label="请假类型" width="100" align="center" header-align="center" />
<el-table-column prop="startDate" label="开始日期" width="120" align="center" header-align="center" />
<el-table-column prop="endDate" label="结束日期" width="120" align="center" header-align="center" />
<el-table-column prop="days" label="天数" width="80" align="center" header-align="center" />
<el-table-column prop="reason" label="请假原因" min-width="180" show-overflow-tooltip />
<el-table-column prop="status" label="状态" width="100" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="statusTagType(row.status)" size="small">{{ statusLabel(row.status) }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="180" align="center" header-align="center" />
<el-table-column label="操作" fixed="right" min-width="260" align="center" header-align="center">
<template #default="{ row }">
<template v-if="row.status === 'draft' || row.status === 'rejected'">
<el-button type="primary" link size="small" @click="handleEdit(row)">编辑</el-button>
<el-button type="success" link size="small" @click="handleSubmit(row.id)">提交审批</el-button>
<el-button type="danger" link size="small" @click="handleDelete(row.id)">删除</el-button>
</template>
<template v-else-if="row.status === 'pending'">
<el-tag type="warning" size="small">审批中</el-tag>
</template>
<template v-else>
<span style="color: #9ca3af; font-size: 12px">已结束</span>
</template>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
v-model:current-page="pagination.page"
v-model:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="loadData"
@current-change="loadData"
/>
</div>
</div>
</section>
<el-dialog
v-model="dialogVisible"
:title="isEdit ? '编辑请假' : '新增请假'"
width="600px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
:model="formData"
label-position="top"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="请假类型" required>
<el-select v-model="formData.leaveType" placeholder="请选择" style="width: 100%">
<el-option label="事假" value="personal" />
<el-option label="病假" value="sick" />
<el-option label="年假" value="annual" />
<el-option label="其他" value="other" />
</el-select>
</el-form-item>
<el-form-item label="请假天数" required>
<el-input
type="number"
step="any"
v-model="formData.days"
:min="0.5"
:max="30"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="开始日期" required>
<el-date-picker
v-model="formData.startDate"
type="date"
value-format="YYYY-MM-DD"
format="YYYY-MM-DD"
placeholder="选择开始日期"
clearable
style="width: 100%"
/>
</el-form-item>
<el-form-item label="结束日期" required>
<el-date-picker
v-model="formData.endDate"
type="date"
value-format="YYYY-MM-DD"
format="YYYY-MM-DD"
placeholder="选择结束日期"
clearable
style="width: 100%"
/>
</el-form-item>
<el-form-item label="请假原因" class="form-col-span-2">
<el-input v-model="formData.reason" type="textarea" :rows="3" placeholder="请输入请假原因" />
</el-form-item>
<el-form-item label="备注" class="form-col-span-2">
<el-input v-model="formData.remark" placeholder="选填" />
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="dialogVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" :loading="submitting" @click="handleSave">
<el-icon><Check /></el-icon>
保存
</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { Close, Check } from '@element-plus/icons-vue'
import {
fetchLeaveList,
fetchCreateLeave,
fetchUpdateLeave,
fetchDeleteLeave,
fetchSubmitLeave
} from '@/api/leave'
defineOptions({ name: 'LeaveRequest' })
const loading = ref(false)
const tableData = ref<Api.Leave.LeaveItem[]>([])
const selectedRows = ref<Api.Leave.LeaveItem[]>([])
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const filterForm = reactive({ keyword: '', status: '' })
const dialogVisible = ref(false)
const isEdit = ref(false)
const editingId = ref('')
const submitting = ref(false)
const formData = reactive({
leaveType: 'personal',
startDate: '',
endDate: '',
days: 1,
reason: '',
remark: ''
})
const statusMap: Record<string, { label: string; type: string }> = {
draft: { label: '草稿', type: 'info' },
pending: { label: '审批中', type: 'warning' },
approved: { label: '已通过', type: 'success' },
rejected: { label: '已驳回', type: 'danger' },
cancelled: { label: '已取消', type: 'info' }
}
function statusLabel(s: string) {
return statusMap[s]?.label || s
}
function statusTagType(s: string) {
return statusMap[s]?.type || 'info'
}
function resetForm() {
formData.leaveType = 'personal'
formData.startDate = ''
formData.endDate = ''
formData.days = 1
formData.reason = ''
formData.remark = ''
}
function handleSelectionChange(rows: Api.Leave.LeaveItem[]) {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchLeaveList({
page: pagination.page,
pageSize: pagination.pageSize,
keyword: filterForm.keyword || undefined,
status: filterForm.status || undefined
})
tableData.value = res.list || []
pagination.total = res.total || 0
} catch {
// error shown by http util
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
loadData()
}
function handleReset() {
filterForm.keyword = ''
filterForm.status = ''
pagination.page = 1
loadData()
}
function handleAdd() {
isEdit.value = false
editingId.value = ''
resetForm()
dialogVisible.value = true
}
function handleEdit(row: Api.Leave.LeaveItem) {
isEdit.value = true
editingId.value = row.id
formData.leaveType = row.leaveType
formData.startDate = row.startDate
formData.endDate = row.endDate
formData.days = row.days
formData.reason = row.reason
formData.remark = row.remark || ''
dialogVisible.value = true
}
async function handleSave() {
if (!formData.leaveType || !formData.startDate || !formData.endDate || !formData.days) {
ElMessage.warning('请填写必填项')
return
}
submitting.value = true
try {
if (isEdit.value) {
await fetchUpdateLeave(editingId.value, { ...formData })
} else {
await fetchCreateLeave({ ...formData })
}
dialogVisible.value = false
loadData()
} catch {
// error shown by http util
} finally {
submitting.value = false
}
}
async function handleSubmit(id: string) {
try {
await ElMessageBox.confirm('确定提交审批?提交后将进入审批流程。', '提示', { type: 'warning' })
await fetchSubmitLeave(id)
loadData()
} catch {
// cancelled or error
}
}
async function handleDelete(id: string) {
try {
await ElMessageBox.confirm('确定删除此请假申请?', '提示', { type: 'warning' })
await fetchDeleteLeave(id)
loadData()
} catch {
// cancelled or error
}
}
onMounted(() => loadData())
</script>
+78 -32
View File
@@ -54,6 +54,7 @@
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
:default-expand-all="isExpandAll"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column
type="selection"
@@ -65,6 +66,8 @@
prop="menuName"
label="菜单名称"
min-width="180"
align="left"
header-align="left"
/>
<el-table-column
prop="menuType"
@@ -141,21 +144,17 @@
</el-tag>
</template>
</el-table-column>
<el-table-column
prop="orderNum"
label="排序"
width="70"
align="center"
header-align="center"
/>
<el-table-column
label="操作"
width="320"
fixed="right"
align="center"
header-align="center"
>
<el-table-column
label="操作"
width="400"
fixed="right"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button class="btn-op-item primary" @click="handleAddChild(row)">
新增子菜单
</el-button>
@@ -230,14 +229,6 @@
<el-option label="停用" value="0" />
</el-select>
</el-form-item>
<el-form-item label="排序">
<el-input-number
v-model="formData.orderNum"
:min="0"
:max="9999"
controls-position="right"
/>
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input
v-model="formData.remark"
@@ -264,14 +255,23 @@
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.menuName || '菜单详情'"
:icon="MenuIcon"
:meta="`类型:${menuTypeTagMap[viewRow?.menuType || '']?.label || viewRow?.menuType || ''}${viewRow?.createTime ? ' · ' + viewRow.createTime : ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'
import { ref, reactive, computed, onMounted, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, View, Menu as MenuIcon } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import {
fetchMenuTree,
fetchCreateMenu,
@@ -301,6 +301,9 @@
const formRef = ref()
const editingId = ref<string | null>(null)
const viewVisible = ref(false)
const viewRow = ref<Api.Menu.MenuItem | null>(null)
const formData = reactive({
parentId: '0',
menuName: '',
@@ -335,10 +338,56 @@
return findName(tableData.value)
})
const viewSections = computed(() => [
{
title: '基本信息',
fields: [
{ label: '菜单名称', value: viewRow.value?.menuName },
{ label: '菜单类型', value: menuTypeTagMap[viewRow.value?.menuType || '']?.label || viewRow.value?.menuType },
{ label: '路由路径', value: viewRow.value?.path },
{ label: '组件路径', value: viewRow.value?.component },
{ label: '权限标识', value: viewRow.value?.perms },
{ label: '是否外链', value: viewRow.value?.isFrame === 1 ? '否' : '是' },
{ label: '显示状态', value: viewRow.value?.visible === '1' ? '显示' : '隐藏' },
{ label: '状态', value: viewRow.value?.status === '1' ? '正常' : '停用' },
{ label: '备注', value: viewRow.value?.remark, span: true }
]
}
])
function handleView(row: Api.Menu.MenuItem) {
viewRow.value = { ...row }
viewVisible.value = true
}
const handleSelectionChange = (rows: Api.Menu.MenuItem[]) => {
selectedRows.value = rows
}
/** 树表格的 default-expand-all 只在初次挂载生效,展开态需用表格 API 同步 */
function applyTreeExpand(expand: boolean) {
const table = tableRef.value
if (!table?.toggleRowExpansion) return
const preorder = (items: Api.Menu.MenuItem[]) => {
for (const row of items) {
if (row.children?.length) {
table.toggleRowExpansion(row, expand)
preorder(row.children)
}
}
}
const postorder = (items: Api.Menu.MenuItem[]) => {
for (const row of items) {
if (row.children?.length) {
postorder(row.children)
table.toggleRowExpansion(row, expand)
}
}
}
if (expand) preorder(tableData.value)
else postorder(tableData.value)
}
async function loadData() {
loading.value = true
try {
@@ -346,6 +395,8 @@
keyword: searchForm.keyword || undefined
})
tableData.value = Array.isArray(res) ? res : []
await nextTick()
applyTreeExpand(isExpandAll.value)
} catch (error) {
console.error('加载菜单数据失败:', error)
} finally {
@@ -364,7 +415,9 @@
function toggleExpand() {
isExpandAll.value = !isExpandAll.value
tableData.value = [...tableData.value]
nextTick(() => {
applyTreeExpand(isExpandAll.value)
})
}
function resetForm() {
@@ -483,12 +536,5 @@
margin-bottom: 0;
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
</style>
+10 -8
View File
@@ -182,7 +182,7 @@
</div>
</template>
</el-table-column>
<el-table-column prop="orderNo" label="订单编号" min-width="180">
<el-table-column prop="orderNo" label="订单编号" min-width="200">
<template #default="{ row }">
<el-button link type="primary" @click="toggleRowExpand(row)">{{ row.orderNo }}</el-button>
</template>
@@ -1221,8 +1221,8 @@
</el-form-item>
</el-form>
<template #footer>
<el-button @click="cancelVisible = false">取消</el-button>
<el-button type="primary" @click="confirmCancel" :loading="submitLoading">确定</el-button>
<el-button @click="cancelVisible = false"><el-icon><Close /></el-icon>取消</el-button>
<el-button type="primary" @click="confirmCancel" :loading="submitLoading"><el-icon><Check /></el-icon>确定</el-button>
</template>
</el-dialog>
@@ -1265,9 +1265,9 @@
</el-form-item>
</el-form>
<template #footer>
<el-button @click="cancelDialogVisible = false">取消</el-button>
<el-button @click="cancelDialogVisible = false"><el-icon><Close /></el-icon>取消</el-button>
<el-button type="danger" @click="confirmCancelOrder" :loading="cancelDialogLoading"
>确认取消</el-button
><el-icon><Check /></el-icon>确认取消</el-button
>
</template>
</el-dialog>
@@ -1329,7 +1329,9 @@
</el-table-column>
<el-table-column label="新数量" min-width="140" align="center">
<template #default="{ row }">
<el-input-number
<el-input
type="number"
step="any"
v-model="row.newQuantity"
:min="0"
:controls-position="'right'"
@@ -1363,8 +1365,8 @@
</el-form>
<template #footer>
<el-button @click="adjustDialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirmAdjustOrder" :loading="adjustDialogLoading">确认提交</el-button>
<el-button @click="adjustDialogVisible = false"><el-icon><Close /></el-icon>取消</el-button>
<el-button type="primary" @click="confirmAdjustOrder" :loading="adjustDialogLoading"><el-icon><Check /></el-icon>确认提交</el-button>
</template>
</el-dialog>
+487 -28
View File
@@ -57,6 +57,7 @@
stripe
row-key="id"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column
@@ -76,10 +77,14 @@
</el-tag>
</template>
</el-table-column>
<el-table-column prop="orderNum" label="排序" width="80" align="center" header-align="center" />
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center" header-align="center" />
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
<el-table-column label="操作" width="480" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)"><el-icon><View /></el-icon>查看</el-button>
<el-button class="btn-op-item primary" @click="handlePostBindUsers(row)">
<el-icon><User /></el-icon>
关联用户
</el-button>
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
<el-button class="btn-op-item" @click="handleDelete(row)">删除</el-button>
</template>
@@ -133,17 +138,6 @@
/>
</el-select>
</el-form-item>
<el-form-item label="排序">
<div class="sort-field">
<el-input-number
v-model="formData.orderNum"
:min="0"
:max="9999"
controls-position="right"
/>
<span class="form-tip">数值越小越靠前</span>
</div>
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="可选" />
</el-form-item>
@@ -160,20 +154,138 @@
</el-button>
</template>
</el-dialog>
<!-- 关联用户(布局对齐角色管理「数据权限」自定义范围) -->
<el-dialog
v-model="postBindDialogVisible"
title="关联用户"
width="1120px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<div v-loading="postBindLoading" class="post-bind-dialog-body">
<p v-if="postBindPostName" class="post-bind-subtitle">
职位:<strong>{{ postBindPostName }}</strong>
</p>
<el-form label-position="top" class="data-scope-form">
<el-form-item label="绑定用户" class="data-scope-custom-form-item">
<div class="data-scope-custom-grid">
<div class="data-scope-custom-col">
<div>
<div class="data-scope-col-title">选择部门</div>
<div class="data-scope-col-tip">点击部门名称可按该部门及子部门筛选右侧用户</div>
</div>
<div class="data-scope-tree-wrap">
<el-tree
ref="postBindDeptTreeRef"
:data="postBindDeptTreeData"
highlight-current
node-key="id"
:props="{ label: 'deptName', children: 'children' }"
default-expand-all
:expand-on-click-node="false"
@node-click="handlePostBindDeptNodeClick"
/>
</div>
</div>
<div class="data-scope-custom-col">
<div class="data-scope-col-head-row">
<span class="data-scope-col-title">选择用户</span>
<el-button
v-if="postBindUserFilterDeptId"
class="btn-ghost"
size="small"
@click="clearPostBindUserDeptFilter"
>
清除部门筛选
</el-button>
</div>
<el-input
v-model="postBindUserKeyword"
class="data-scope-user-filter"
clearable
placeholder="按姓名、账号过滤"
/>
<div class="data-scope-user-list-wrap">
<el-checkbox-group
v-if="postBindFilteredUsers.length > 0"
v-model="postBindUserCheckedKeys"
>
<div
v-for="u in postBindFilteredUsers"
:key="u.id"
class="data-scope-user-row"
>
<el-checkbox :value="u.id">{{ postBindUserOptionLabel(u) }}</el-checkbox>
</div>
</el-checkbox-group>
<el-empty v-else :description="postBindUserEmptyDesc" :image-size="40" />
</div>
</div>
</div>
<div class="data-scope-selection-summary">
<template v-if="postBindSelectedUserSummaries.length > 0">
<div class="data-scope-summary-block">
<div class="data-scope-summary-heading">已选用户</div>
<ul class="data-scope-summary-list">
<li v-for="row in postBindSelectedUserSummaries" :key="'u-' + row.id">
{{ row.label }}
</li>
</ul>
</div>
</template>
<p v-else class="data-scope-summary-empty">暂未勾选用户</p>
</div>
</el-form-item>
</el-form>
</div>
<template #footer>
<el-button class="btn-ghost" @click="postBindDialogVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button
class="btn-main"
type="primary"
@click="handlePostBindSubmit"
:loading="postBindSubmitLoading"
>
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.postName || '职位详情'"
:icon="Briefcase"
:meta="`职位编码:${viewRow?.postCode || ''}${viewRow?.createTime ? ' · ' + viewRow.createTime : ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ref, reactive, computed, onMounted, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, User, View, Briefcase } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { MAX_ADMIN_LIST_PAGE_SIZE } from '@/utils/fetch-paged-list'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchPostList,
fetchCreatePost,
fetchUpdatePost,
fetchDeletePost,
fetchDictDataOptions
fetchDictDataOptions,
fetchDeptTree,
fetchUserList,
fetchPostBoundUserIds,
fetchUpdatePostBoundUsers
} from '@/api/admin'
defineOptions({ name: 'SystemPost' })
@@ -205,6 +317,221 @@
const statusOptions = ref<Api.Dict.DictDataOption[]>([])
// ---- 查看弹窗 ----
const viewVisible = ref(false)
const viewRow = ref<Api.Post.PostItem | null>(null)
const viewBoundUserNames = ref<string[]>([])
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
const sections: any[] = [
{
title: '基本信息',
fields: [
{ label: '职位名称', value: row.postName },
{ label: '职位编码', value: row.postCode },
{ label: '状态', value: row.status === '1' ? '正常' : '停用' },
{ label: '创建时间', value: row.createTime },
{ label: '备注', value: row.remark, span: true }
]
}
]
if (viewBoundUserNames.value.length > 0) {
sections.push({
title: '关联用户',
fields: [
{ label: '已关联用户', value: viewBoundUserNames.value.join('、'), span: true }
]
})
}
return sections
})
async function handleView(row: Api.Post.PostItem) {
viewRow.value = row
viewBoundUserNames.value = []
viewVisible.value = true
try {
const [boundRes] = await Promise.all([
fetchPostBoundUserIds(row.id),
fetchDeptTree()
])
const boundIds = boundRes?.userIds || []
if (boundIds.length === 0) return
const users = await fetchAllUsersForPostBind()
const idToName = new Map(users.map((u) => [u.id, u.nickName || u.userNo || u.id]))
viewBoundUserNames.value = boundIds.map((id: string) => idToName.get(id) || id)
} catch (e) {
console.error('加载关联用户失败:', e)
}
}
// ---- 关联用户弹窗(布局对齐角色管理「数据权限」自定义范围)----
const postBindDialogVisible = ref(false)
const postBindLoading = ref(false)
const postBindSubmitLoading = ref(false)
const postBindPostId = ref('')
const postBindPostName = ref('')
const postBindDeptTreeRef = ref()
const postBindDeptTreeData = ref<Api.Dept.DeptItem[]>([])
const postBindAllUsers = ref<
Array<{ id: string; nickName: string; userNo: string; deptId: string; deptName?: string }>
>([])
const postBindUserCheckedKeys = ref<string[]>([])
const postBindUserFilterDeptId = ref<string | null>(null)
const postBindUserKeyword = ref('')
function findPostBindDeptNodeById(nodes: Api.Dept.DeptItem[], id: string): Api.Dept.DeptItem | null {
for (const n of nodes) {
if (n.id === id) return n
if (n.children?.length) {
const found = findPostBindDeptNodeById(n.children, id)
if (found) return found
}
}
return null
}
function collectPostBindDeptSubtreeIds(node: Api.Dept.DeptItem): string[] {
const ids = [node.id]
for (const c of node.children || []) ids.push(...collectPostBindDeptSubtreeIds(c))
return ids
}
function collectAllPostBindDeptIds(nodes: Api.Dept.DeptItem[]): string[] {
const ids: string[] = []
const walk = (list: Api.Dept.DeptItem[]) => {
for (const n of list) {
ids.push(n.id)
if (n.children?.length) walk(n.children)
}
}
walk(nodes)
return ids
}
async function expandPostBindDeptTree() {
await nextTick()
const tree = postBindDeptTreeRef.value
const keys = collectAllPostBindDeptIds(postBindDeptTreeData.value)
if (tree && keys.length && typeof tree.setExpandedKeys === 'function') {
tree.setExpandedKeys(keys)
}
}
const postBindDeptFilterIdSet = computed(() => {
const id = postBindUserFilterDeptId.value
if (!id) return null
const node = findPostBindDeptNodeById(postBindDeptTreeData.value, id)
if (!node) return new Set<string>([id])
return new Set(collectPostBindDeptSubtreeIds(node))
})
const postBindFilteredUsers = computed(() => {
const kw = postBindUserKeyword.value.trim().toLowerCase()
const deptSet = postBindDeptFilterIdSet.value
return postBindAllUsers.value.filter((u) => {
if (deptSet && !deptSet.has(u.deptId)) return false
if (!kw) return true
const name = (u.nickName || '').toLowerCase()
const no = (u.userNo || '').toLowerCase()
return name.includes(kw) || no.includes(kw)
})
})
const postBindUserEmptyDesc = computed(() => {
if (postBindAllUsers.value.length === 0) return '暂无用户数据'
const hasDept = Boolean(postBindUserFilterDeptId.value)
const kw = postBindUserKeyword.value.trim()
if (hasDept && kw) return '该部门下无匹配用户'
if (hasDept) return '该部门下暂无用户'
if (kw) return '无匹配用户'
return '无匹配用户'
})
const postBindSelectedUserSummaries = computed(() =>
postBindUserCheckedKeys.value.map((id) => {
const u = postBindAllUsers.value.find((x) => x.id === id)
return { id, label: u ? postBindUserOptionLabel(u) : id }
})
)
function postBindUserOptionLabel(u: {
id: string
nickName: string
userNo: string
deptName?: string
}) {
const base = u.nickName || u.userNo || u.id
if (u.deptName) return `${base}(${u.deptName})`
return base
}
function handlePostBindDeptNodeClick(data: Api.Dept.DeptItem) {
postBindUserFilterDeptId.value = data.id
postBindDeptTreeRef.value?.setCurrentKey?.(data.id)
}
function clearPostBindUserDeptFilter() {
postBindUserFilterDeptId.value = null
postBindDeptTreeRef.value?.setCurrentKey?.(null)
}
async function fetchAllUsersForPostBind(): Promise<
Array<{ id: string; nickName: string; userNo: string; deptId: string; deptName?: string }>
> {
const pageSize = MAX_ADMIN_LIST_PAGE_SIZE
const raw: any[] = []
let page = 1
for (;;) {
const res = await fetchUserList({ page, pageSize })
const list = res?.list || []
raw.push(...list)
if (list.length < pageSize) break
if (typeof res?.total === 'number' && raw.length >= res.total) break
page += 1
}
return raw.map((u: any) => ({
id: u.id,
deptId: u.deptId || '',
nickName: u.nickName || u.realName || '',
userNo: u.userNo || '',
deptName: u.deptName
}))
}
async function handlePostBindUsers(row: Api.Post.PostItem) {
postBindPostId.value = row.id
postBindPostName.value = row.postName || row.postCode || ''
postBindUserCheckedKeys.value = []
postBindUserFilterDeptId.value = null
postBindUserKeyword.value = ''
postBindDialogVisible.value = true
postBindLoading.value = true
try {
const [boundRes, deptTree, users] = await Promise.all([
fetchPostBoundUserIds(row.id),
fetchDeptTree(),
fetchAllUsersForPostBind()
])
postBindUserCheckedKeys.value = [...(boundRes?.userIds || [])]
postBindDeptTreeData.value = deptTree || []
postBindAllUsers.value = users
await expandPostBindDeptTree()
} finally {
postBindLoading.value = false
}
}
async function handlePostBindSubmit() {
postBindSubmitLoading.value = true
try {
await fetchUpdatePostBoundUsers(postBindPostId.value, [...postBindUserCheckedKeys.value])
postBindDialogVisible.value = false
} finally {
postBindSubmitLoading.value = false
}
}
const loadDictOptions = async () => {
try {
const bmzt = await fetchDictDataOptions('bmzt')
@@ -311,11 +638,14 @@
const ids = selectedRows.value.map((r) => r.id)
if (!ids.length) return
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个职位吗?`, '提示', { type: 'warning' })
for (const id of ids) {
await fetchDeletePost(id)
}
selectedRows.value = []
await loadData()
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeletePost(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
@@ -329,13 +659,142 @@
:deep(.el-form-item) {
margin-bottom: 0;
}
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
.post-bind-dialog-body {
min-height: 200px;
}
.post-bind-subtitle {
margin: 0 0 12px;
font-size: 13px;
line-height: 1.5;
color: var(--el-text-color-regular);
}
.data-scope-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
.data-scope-custom-form-item {
margin-top: 0;
:deep(.el-form-item__content) {
display: block;
}
}
.data-scope-custom-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
width: 100%;
}
.data-scope-custom-col {
display: flex;
flex-direction: column;
gap: 8px;
min-width: 0;
}
.data-scope-col-title {
padding-left: 10px;
font-size: 12px;
font-weight: 600;
color: var(--el-text-color-regular);
border-left: 3px solid #10b981;
}
.data-scope-col-tip {
margin-top: 4px;
font-size: 11px;
line-height: 1.45;
color: var(--mint-text-muted, var(--el-text-color-secondary));
}
.data-scope-col-head-row {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.data-scope-tree-wrap {
max-height: 280px;
padding: 8px;
overflow: auto;
border: 1px solid var(--el-border-color-lighter);
border-radius: 8px;
}
.data-scope-user-filter {
width: 100%;
}
.data-scope-user-list-wrap {
max-height: 236px;
padding: 8px;
overflow: auto;
border: 1px solid var(--el-border-color-lighter);
border-radius: 8px;
}
.data-scope-user-row {
padding: 4px 0;
}
.data-scope-selection-summary {
margin-top: 12px;
padding: 10px 12px;
border: 1px solid var(--el-border-color-lighter);
border-radius: 8px;
background: var(--el-fill-color-blank);
}
.data-scope-summary-block + .data-scope-summary-block {
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid var(--el-border-color-lighter);
}
.data-scope-summary-heading {
margin-bottom: 6px;
padding-left: 10px;
font-size: 12px;
font-weight: 600;
color: var(--el-text-color-regular);
border-left: 3px solid #10b981;
}
.data-scope-summary-list {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px 12px;
margin: 0;
padding: 0;
list-style: none;
font-size: 12px;
line-height: 1.45;
color: var(--el-text-color-primary);
}
.data-scope-summary-list li {
min-width: 0;
padding: 6px 8px;
overflow-wrap: anywhere;
word-break: break-word;
border-radius: 6px;
background: var(--el-fill-color-light);
}
.data-scope-summary-empty {
margin: 0;
font-size: 12px;
line-height: 1.5;
color: var(--mint-text-muted, var(--el-text-color-secondary));
}
</style>
+14 -17
View File
@@ -120,7 +120,7 @@
</template>
</el-table-column>
<el-table-column prop="skuCode" label="SKU编码" min-width="140" align="center" header-align="center" />
<el-table-column prop="categoryName" label="分类" min-width="120" align="center" header-align="center">
<el-table-column prop="categoryName" label="分类" min-width="180" align="center" header-align="center" show-overflow-tooltip>
<template #default="{ row }">
{{ categoryPathForProductRow(row) }}
</template>
@@ -131,14 +131,14 @@
</template>
</el-table-column>
<el-table-column prop="unitName" label="单位" min-width="80" align="center" header-align="center" />
<el-table-column prop="isActive" label="状态" min-width="70" align="center" header-align="center">
<el-table-column prop="isActive" label="状态" min-width="90" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="row.isActive ? 'success' : 'info'" size="small">
{{ row.isActive ? '启用' : '禁用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="createAt" label="创建时间" min-width="160" align="center" header-align="center" />
<el-table-column prop="createAt" label="创建时间" min-width="180" align="center" header-align="center" />
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="handleView(row)">查看</el-button>
@@ -231,11 +231,11 @@
<el-col :span="12">
<el-form-item label="计量/单位">
<div class="measure-unit-inline">
<el-input-number
<el-input
type="number"
step="any"
v-model="formData.measureValue"
:min="0"
:precision="3"
:step="1"
controls-position="right"
placeholder="如 500、1"
class="measure-number"
@@ -323,10 +323,10 @@
</el-col>
<el-col :span="12">
<el-form-item label="调价系数(%)" prop="priceCoefficient">
<el-input-number
<el-input
type="number"
step="any"
v-model="formData.priceCoefficient"
:precision="2"
:step="0.1"
controls-position="right"
style="width: 100%"
@change="handlePriceCoefficientChange"
@@ -2518,7 +2518,9 @@
color: var(--mint-text);
margin-bottom: 12px;
padding-bottom: 10px;
padding-left: 10px;
border-bottom: 1px solid var(--mint-border);
border-left: 3px solid #10b981;
.section-tip {
font-size: 12px;
@@ -2539,14 +2541,7 @@
margin-bottom: 12px;
}
:deep(.el-form-item__label) {
height: auto !important;
line-height: 1.25 !important;
padding: 0 0 6px !important;
font-size: 11px;
color: var(--mint-text-muted);
font-weight: 600;
}
}
.region-prices-empty {
@@ -2913,7 +2908,9 @@
color: #303133;
margin-bottom: 12px;
padding-bottom: 8px;
padding-left: 10px;
border-bottom: 1px solid #ebeef5;
border-left: 3px solid #10b981;
}
.view-banner-list {
+486 -64
View File
@@ -57,6 +57,7 @@
stripe
row-key="id"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column
@@ -67,25 +68,59 @@
header-align="center"
:index="(index: number) => (pagination.page - 1) * pagination.pageSize + index + 1"
/>
<el-table-column prop="roleName" label="角色名称" min-width="140" align="center" header-align="center" />
<el-table-column prop="dataScope" label="数据权限" min-width="120" align="center" header-align="center">
<el-table-column
prop="roleName"
label="角色名称"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="dataScope"
label="数据权限"
min-width="120"
align="center"
header-align="center"
>
<template #default="{ row }">
{{ dataScopeLabel(row.dataScope) }}
</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="100" align="center" header-align="center">
<el-table-column
prop="status"
label="状态"
width="100"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-tag :type="row.status === '1' ? 'success' : 'danger'" size="small">
{{ row.status === '1' ? '正常' : '停用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="orderNum" label="排序" width="80" align="center" header-align="center" />
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center" header-align="center" />
<el-table-column label="操作" width="400" fixed="right" align="center" header-align="center">
<el-table-column
prop="createTime"
label="创建时间"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column
label="操作"
width="480"
fixed="right"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="handleMenuConfig(row)">菜单配置</el-button>
<el-button class="btn-op-item primary" @click="handleDataScope(row)">数据权限</el-button>
<el-button class="btn-op-item" @click="handleView(row)"><el-icon><View /></el-icon>查看</el-button>
<el-button class="btn-op-item primary" @click="handleMenuConfig(row)"
>菜单配置</el-button
>
<el-button class="btn-op-item primary" @click="handleDataScope(row)"
><el-icon><DataAnalysis /></el-icon>数据权限</el-button
>
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
<el-button class="btn-op-item" @click="handleDelete(row)">删除</el-button>
</template>
@@ -98,7 +133,9 @@
:total="pagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="(val: number) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
@size-change="
(val: number) => ((pagination.page = 1), (pagination.pageSize = val), loadData())
"
@current-change="(val: number) => ((pagination.page = val), loadData())"
/>
</div>
@@ -133,12 +170,6 @@
<el-option label="停用" value="0" />
</el-select>
</el-form-item>
<el-form-item label="排序">
<div class="sort-field">
<el-input-number v-model="formData.orderNum" :min="0" :max="9999" controls-position="right" />
<span class="form-tip">数值越小越靠前</span>
</div>
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="可选" />
</el-form-item>
@@ -167,6 +198,7 @@
:close-on-click-modal="false"
>
<div v-loading="menuDialogLoading" style="min-height: 200px">
<!-- 父子关联勾选:选父级全选子级,选子级自动带上父级(与 check-strictly 互斥,故不加) -->
<el-tree
ref="menuTreeRef"
:data="menuTreeData"
@@ -174,7 +206,6 @@
node-key="id"
:props="{ label: 'menuName', children: 'children' }"
:default-checked-keys="menuCheckedKeys"
check-strictly
style="max-height: 500px; overflow-y: auto"
/>
</div>
@@ -183,7 +214,12 @@
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" @click="handleMenuSubmit" :loading="menuSubmitLoading">
<el-button
class="btn-main"
type="primary"
@click="handleMenuSubmit"
:loading="menuSubmitLoading"
>
<el-icon><Check /></el-icon>
确定
</el-button>
@@ -194,7 +230,7 @@
<el-dialog
v-model="dataScopeDialogVisible"
title="数据权限配置"
width="700px"
width="1120px"
class="dialog-form-layout"
align-center
destroy-on-close
@@ -212,26 +248,91 @@
</el-form-item>
<template v-if="dataScopeForm.dataScope === '5'">
<el-form-item label="选择部门">
<el-tree
ref="deptTreeRef"
:data="deptTreeData"
show-checkbox
node-key="id"
:props="{ label: 'deptName', children: 'children' }"
:default-checked-keys="scopeDeptCheckedKeys"
check-strictly
style="max-height: 260px; overflow-y: auto; border: 1px solid var(--el-border-color-lighter); border-radius: 4px; padding: 8px"
/>
</el-form-item>
<el-form-item label="选择用户">
<div style="border: 1px solid var(--el-border-color-lighter); border-radius: 4px; padding: 8px; max-height: 260px; overflow-y: auto; width: 100%">
<el-checkbox-group v-model="scopeUserCheckedKeys">
<div v-for="u in allUsers" :key="u.id" style="padding: 4px 0">
<el-checkbox :value="u.id">{{ u.nickName || u.userNo }}</el-checkbox>
<el-form-item label="自定义范围" class="data-scope-custom-form-item">
<div class="data-scope-custom-grid">
<div class="data-scope-custom-col">
<div>
<div class="data-scope-col-title">选择部门</div>
<div class="data-scope-col-tip">
仅通过复选框勾选授权范围;点击部门名称可筛选右侧用户
</div>
</div>
</el-checkbox-group>
<el-empty v-if="allUsers.length === 0" description="暂无用户数据" :image-size="40" />
<div class="data-scope-tree-wrap">
<el-tree
ref="deptTreeRef"
:data="deptTreeData"
show-checkbox
highlight-current
node-key="id"
:props="{ label: 'deptName', children: 'children' }"
:default-checked-keys="scopeDeptCheckedKeys"
default-expand-all
:check-on-click-node="false"
:check-on-click-leaf="false"
check-strictly
@check="syncDataScopeDeptCheckedFromTree"
@node-click="handleDataScopeDeptNodeClick"
/>
</div>
</div>
<div class="data-scope-custom-col">
<div class="data-scope-col-head-row">
<span class="data-scope-col-title">选择用户</span>
<el-button
v-if="dataScopeUserFilterDeptId"
class="btn-ghost"
size="small"
@click="clearDataScopeUserDeptFilter"
>
清除部门筛选
</el-button>
</div>
<el-input
v-model="dataScopeUserKeyword"
class="data-scope-user-filter"
clearable
placeholder="按姓名、账号过滤"
/>
<div class="data-scope-user-list-wrap">
<el-checkbox-group
v-if="dataScopeFilteredUsers.length > 0"
v-model="scopeUserCheckedKeys"
>
<div
v-for="u in dataScopeFilteredUsers"
:key="u.id"
class="data-scope-user-row"
>
<el-checkbox :value="u.id">{{ userOptionLabel(u) }}</el-checkbox>
</div>
</el-checkbox-group>
<el-empty v-else :description="dataScopeUserEmptyDesc" :image-size="40" />
</div>
</div>
</div>
<div class="data-scope-selection-summary">
<template v-if="dataScopeHasCustomSelectionSummary">
<div v-if="dataScopeSelectedDeptRows.length > 0" class="data-scope-summary-block">
<div class="data-scope-summary-heading">已选部门</div>
<ul class="data-scope-summary-list">
<li v-for="row in dataScopeSelectedDeptRows" :key="'d-' + row.id">
{{ row.label }}
</li>
</ul>
</div>
<div
v-if="dataScopeSelectedUserSummaries.length > 0"
class="data-scope-summary-block"
>
<div class="data-scope-summary-heading">已选用户</div>
<ul class="data-scope-summary-list">
<li v-for="row in dataScopeSelectedUserSummaries" :key="'u-' + row.id">
{{ row.label }}
</li>
</ul>
</div>
</template>
<p v-else class="data-scope-summary-empty">暂未勾选部门或用户</p>
</div>
</el-form-item>
</template>
@@ -241,20 +342,37 @@
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" @click="handleDataScopeSubmit" :loading="dataScopeSubmitLoading">
<el-button
class="btn-main"
type="primary"
@click="handleDataScopeSubmit"
:loading="dataScopeSubmitLoading"
>
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.roleName || '角色详情'"
:icon="Stamp"
:meta="`数据权限:${dataScopeLabel(viewRow?.dataScope || '')}${viewRow?.createTime ? ' · ' + viewRow.createTime : ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ref, reactive, computed, onMounted, nextTick, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, DataAnalysis, View, Stamp } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { MAX_ADMIN_LIST_PAGE_SIZE } from '@/utils/fetch-paged-list'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import { buildPathLabelMapFromTreeRoots } from '@/utils/tree-path'
import {
fetchRoleList,
fetchCreateRole,
@@ -323,13 +441,137 @@
const dataScopeEditingRoleId = ref<string>('')
const deptTreeRef = ref()
const deptTreeData = ref<Api.Dept.DeptItem[]>([])
const allUsers = ref<Array<{ id: string; nickName: string; userNo: string }>>([])
const allUsers = ref<
Array<{ id: string; nickName: string; userNo: string; deptId: string; deptName?: string }>
>([])
const scopeDeptCheckedKeys = ref<string[]>([])
const scopeUserCheckedKeys = ref<string[]>([])
/** 左侧部门树当前行(用于筛选右侧用户,不含子部门勾选逻辑) */
const dataScopeUserFilterDeptId = ref<string | null>(null)
const dataScopeUserKeyword = ref('')
const dataScopeForm = reactive({
dataScope: '1'
})
function findDeptNodeById(nodes: Api.Dept.DeptItem[], id: string): Api.Dept.DeptItem | null {
for (const n of nodes) {
if (n.id === id) return n
if (n.children?.length) {
const found = findDeptNodeById(n.children, id)
if (found) return found
}
}
return null
}
function collectDeptSubtreeIds(node: Api.Dept.DeptItem): string[] {
const ids = [node.id]
for (const c of node.children || []) ids.push(...collectDeptSubtreeIds(c))
return ids
}
/** 收集部门树全部节点 id(异步灌入数据后仍保持整树展开) */
function collectAllDeptIds(nodes: Api.Dept.DeptItem[]): string[] {
const ids: string[] = []
const walk = (list: Api.Dept.DeptItem[]) => {
for (const n of list) {
ids.push(n.id)
if (n.children?.length) walk(n.children)
}
}
walk(nodes)
return ids
}
async function expandDataScopeDeptTree() {
await nextTick()
const tree = deptTreeRef.value
const keys = collectAllDeptIds(deptTreeData.value)
if (tree && keys.length && typeof tree.setExpandedKeys === 'function') {
tree.setExpandedKeys(keys)
}
}
const dataScopeDeptFilterIdSet = computed(() => {
const id = dataScopeUserFilterDeptId.value
if (!id) return null
const node = findDeptNodeById(deptTreeData.value, id)
if (!node) return new Set<string>([id])
return new Set(collectDeptSubtreeIds(node))
})
const dataScopeFilteredUsers = computed(() => {
const kw = dataScopeUserKeyword.value.trim().toLowerCase()
const deptSet = dataScopeDeptFilterIdSet.value
return allUsers.value.filter((u) => {
if (deptSet && !deptSet.has(u.deptId)) return false
if (!kw) return true
const name = (u.nickName || '').toLowerCase()
const no = (u.userNo || '').toLowerCase()
return name.includes(kw) || no.includes(kw)
})
})
const dataScopeUserEmptyDesc = computed(() => {
if (allUsers.value.length === 0) return '暂无用户数据'
const hasDept = Boolean(dataScopeUserFilterDeptId.value)
const kw = dataScopeUserKeyword.value.trim()
if (hasDept && kw) return '该部门下无匹配用户'
if (hasDept) return '该部门下暂无用户'
if (kw) return '无匹配用户'
return '无匹配用户'
})
/** 与 el-tree 勾选状态同步,供已选摘要与提交一致 */
function syncDataScopeDeptCheckedFromTree() {
const keys = deptTreeRef.value?.getCheckedKeys?.() as string[] | undefined
scopeDeptCheckedKeys.value = Array.isArray(keys) ? [...keys] : []
}
const dataScopeDeptPathLabelMap = computed(() =>
buildPathLabelMapFromTreeRoots(deptTreeData.value, {
idKey: 'id',
nameKey: 'deptName',
childrenKey: 'children'
})
)
const dataScopeSelectedDeptRows = computed(() => {
const map = dataScopeDeptPathLabelMap.value
return scopeDeptCheckedKeys.value.map((id) => ({
id,
label: map.get(id) || findDeptNodeById(deptTreeData.value, id)?.deptName || id
}))
})
const dataScopeSelectedUserSummaries = computed(() =>
scopeUserCheckedKeys.value.map((id) => {
const u = allUsers.value.find((x) => x.id === id)
return { id, label: u ? userOptionLabel(u) : id }
})
)
const dataScopeHasCustomSelectionSummary = computed(
() =>
dataScopeSelectedDeptRows.value.length > 0 || dataScopeSelectedUserSummaries.value.length > 0
)
function userOptionLabel(u: { id: string; nickName: string; userNo: string; deptName?: string }) {
const base = u.nickName || u.userNo || u.id
if (u.deptName) return `${base}(${u.deptName})`
return base
}
function handleDataScopeDeptNodeClick(data: Api.Dept.DeptItem) {
dataScopeUserFilterDeptId.value = data.id
deptTreeRef.value?.setCurrentKey?.(data.id)
}
function clearDataScopeUserDeptFilter() {
dataScopeUserFilterDeptId.value = null
deptTreeRef.value?.setCurrentKey?.(null)
}
const handleSelectionChange = (rows: Api.Role.RoleItem[]) => {
selectedRows.value = rows
}
@@ -424,12 +666,17 @@
ElMessage.warning('请至少选择一项')
return
}
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个角色吗?`, '提示', { type: 'warning' })
for (const id of ids) {
await fetchDeleteRole(id)
}
selectedRows.value = []
await loadData()
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个角色吗?`, '提示', {
type: 'warning'
})
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeleteRole(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
// ---- 菜单配置 ----
@@ -446,29 +693,61 @@
}
}
/**
* 提交角色菜单:只持久化叶子菜单 ID(去重),避免树控件偶发重复 key。
* 父子关联下「半选」父节点在 getHalfCheckedKeys;若与 getCheckedKeys 一起入库,重开弹窗会把父节点当全选,误勾整棵子树。
* 侧栏按 menuCode 过滤时会保留有权限子项的父级,无需单独存父菜单行。
*/
async function handleMenuSubmit() {
menuSubmitLoading.value = true
try {
const tree = menuTreeRef.value
const checkedKeys: string[] = tree?.getCheckedKeys() || []
const halfCheckedKeys: string[] = tree?.getHalfCheckedKeys() || []
const allKeys = [...checkedKeys, ...halfCheckedKeys]
await fetchUpdateRoleMenus(menuEditingRoleId.value, allKeys)
const rawKeys: string[] = tree?.getCheckedKeys(true) || []
const leafKeys = [...new Set(rawKeys)]
await fetchUpdateRoleMenus(menuEditingRoleId.value, leafKeys)
menuDialogVisible.value = false
} finally {
menuSubmitLoading.value = false
}
}
/**
* 分页拉取租户用户列表供「数据权限」多选;单页 pageSize 超过 100 时接口会 422。
*/
async function fetchAllUsersForDataScope(): Promise<
Array<{ id: string; nickName: string; userNo: string; deptId: string; deptName?: string }>
> {
const pageSize = MAX_ADMIN_LIST_PAGE_SIZE
const raw: any[] = []
let page = 1
for (;;) {
const res = await fetchUserList({ page, pageSize })
const list = res?.list || []
raw.push(...list)
if (list.length < pageSize) break
if (typeof res?.total === 'number' && raw.length >= res.total) break
page += 1
}
return raw.map((u: any) => ({
id: u.id,
deptId: u.deptId || '',
nickName: u.nickName || u.realName || '',
userNo: u.userNo || '',
deptName: u.deptName
}))
}
// ---- 数据权限配置 ----
async function handleDataScope(row: Api.Role.RoleItem) {
dataScopeEditingRoleId.value = row.id
dataScopeForm.dataScope = row.dataScope || '1'
scopeDeptCheckedKeys.value = []
scopeUserCheckedKeys.value = []
dataScopeUserFilterDeptId.value = null
dataScopeUserKeyword.value = ''
dataScopeDialogVisible.value = true
const [, deptTree, userRes] = await Promise.all([
const [, deptTree, users] = await Promise.all([
fetchRoleDataScope(row.id).then((res) => {
if (res?.scopeDetails) {
scopeDeptCheckedKeys.value = res.scopeDetails
@@ -481,15 +760,12 @@
dataScopeForm.dataScope = res?.dataScope || row.dataScope || '1'
}),
fetchDeptTree(),
fetchUserList({ pageSize: 200 })
fetchAllUsersForDataScope()
])
deptTreeData.value = deptTree || []
allUsers.value = (userRes?.list || []).map((u: any) => ({
id: u.id,
nickName: u.nickName || u.realName || '',
userNo: u.userNo || ''
}))
allUsers.value = users
await expandDataScopeDeptTree()
}
async function handleDataScopeSubmit() {
@@ -516,6 +792,40 @@
}
}
watch(
() => dataScopeForm.dataScope,
async (v) => {
if (v !== '5' || !dataScopeDialogVisible.value) return
await expandDataScopeDeptTree()
}
)
// ---- 查看弹窗 ----
const viewVisible = ref(false)
const viewRow = ref<Api.Role.RoleItem | null>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
return [
{
title: '基本信息',
fields: [
{ label: '角色名称', value: row.roleName },
{ label: '数据权限', value: dataScopeLabel(row.dataScope) },
{ label: '状态', value: row.status === '1' ? '正常' : '停用' },
{ label: '创建时间', value: row.createTime },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function handleView(row: Api.Role.RoleItem) {
viewRow.value = row
viewVisible.value = true
}
onMounted(() => {
loadData()
})
@@ -527,13 +837,125 @@
:deep(.el-form-item) {
margin-bottom: 0;
}
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
.data-scope-custom-form-item {
margin-top: 12px;
:deep(.el-form-item__content) {
display: block;
}
}
.data-scope-custom-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
width: 100%;
}
.data-scope-custom-col {
display: flex;
flex-direction: column;
gap: 8px;
min-width: 0;
}
.data-scope-col-title {
padding-left: 10px;
font-size: 12px;
font-weight: 600;
color: var(--el-text-color-regular);
border-left: 3px solid #10b981;
}
.data-scope-col-tip {
margin-top: 4px;
font-size: 11px;
line-height: 1.45;
color: var(--mint-text-muted, var(--el-text-color-secondary));
}
.data-scope-col-head-row {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.data-scope-tree-wrap {
max-height: 280px;
padding: 8px;
overflow: auto;
border: 1px solid var(--el-border-color-lighter);
border-radius: 8px;
}
.data-scope-user-filter {
width: 100%;
}
.data-scope-user-list-wrap {
max-height: 236px;
padding: 8px;
overflow: auto;
border: 1px solid var(--el-border-color-lighter);
border-radius: 8px;
}
.data-scope-user-row {
padding: 4px 0;
}
.data-scope-selection-summary {
margin-top: 12px;
padding: 10px 12px;
border: 1px solid var(--el-border-color-lighter);
border-radius: 8px;
background: var(--el-fill-color-blank);
}
.data-scope-summary-block + .data-scope-summary-block {
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid var(--el-border-color-lighter);
}
.data-scope-summary-heading {
margin-bottom: 6px;
padding-left: 10px;
font-size: 12px;
font-weight: 600;
color: var(--el-text-color-regular);
border-left: 3px solid #10b981;
}
.data-scope-summary-list {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px 12px;
margin: 0;
padding: 0;
list-style: none;
font-size: 12px;
line-height: 1.45;
color: var(--el-text-color-primary);
}
.data-scope-summary-list li {
min-width: 0;
padding: 6px 8px;
overflow-wrap: anywhere;
word-break: break-word;
border-radius: 6px;
background: var(--el-fill-color-light);
}
.data-scope-summary-empty {
margin: 0;
font-size: 12px;
line-height: 1.5;
color: var(--mint-text-muted, var(--el-text-color-secondary));
}
</style>
+209 -32
View File
@@ -57,6 +57,7 @@
stripe
row-key="id"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column
@@ -83,11 +84,11 @@
</el-table-column>
<el-table-column prop="address" label="地址" min-width="160" align="center" header-align="center" show-overflow-tooltip />
<el-table-column prop="contactName" label="联系人" min-width="100" align="center" header-align="center" />
<el-table-column prop="contactPhone" label="联系电话" min-width="120" align="center" header-align="center" />
<el-table-column prop="orderNum" label="排序" width="80" align="center" header-align="center" />
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center" header-align="center" />
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
<el-table-column prop="contactPhone" label="联系电话" min-width="140" align="center" header-align="center" />
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)"><el-icon><View /></el-icon>查看</el-button>
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
<el-button class="btn-op-item" @click="handleDelete(row)">删除</el-button>
</template>
@@ -114,6 +115,7 @@
align-center
destroy-on-close
:close-on-click-modal="false"
@close="handleDialogClose"
>
<el-form
ref="formRef"
@@ -155,10 +157,31 @@
<el-input v-model="formData.address" placeholder="请输入地址" />
</el-form-item>
<el-form-item label="联系人">
<el-input v-model="formData.contactName" placeholder="可选" />
<el-select
v-model="contactUserId"
class="w-full"
filterable
remote
clearable
reserve-keyword
:remote-method="remoteSearchContactUsers"
:loading="contactUserLoading"
placeholder="输入关键词检索用户"
@change="onContactUserChange"
>
<el-option
v-for="u in contactUserOptions"
:key="u.id"
:label="formatContactUserLabel(u)"
:value="u.id"
/>
</el-select>
</el-form-item>
<el-form-item label="联系电话">
<el-input v-model="formData.contactPhone" placeholder="可选" />
<el-input
v-model="formData.contactPhone"
placeholder="可选,选择联系人后自动填入,可修改"
/>
</el-form-item>
<el-form-item label="经营范围" style="grid-column: 1 / -1">
<el-select
@@ -175,17 +198,6 @@
/>
</el-select>
</el-form-item>
<el-form-item label="排序">
<div class="sort-field">
<el-input-number
v-model="formData.orderNum"
:min="0"
:max="9999"
controls-position="right"
/>
<span class="form-tip">数值越小越靠前</span>
</div>
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="可选" />
</el-form-item>
@@ -202,24 +214,81 @@
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.siteName || '站点详情'"
:icon="Location"
:meta="`站点编码:${viewRow?.siteCode || ''}${viewRow?.createTime ? ' · ' + viewRow.createTime : ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ref, reactive, computed, onMounted, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, View, Location } from '@element-plus/icons-vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import {
fetchSiteList,
fetchCreateSite,
fetchUpdateSite,
fetchDeleteSite,
fetchDictDataOptions
fetchDictDataOptions,
fetchUserList
} from '@/api/admin'
defineOptions({ name: 'SystemSite' })
// ---- 查看弹窗 ----
const viewVisible = ref(false)
const viewRow = ref<Api.Site.SiteItem | null>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
return [
{
title: '基本信息',
fields: [
{ label: '站点名称', value: row.siteName },
{ label: '站点编码', value: row.siteCode },
{ label: '站点类型', value: getSiteTypeLabel(row.siteType) },
{ label: '状态', value: row.status === '1' ? '正常' : '停用' },
{ label: '地址', value: row.address, span: true }
]
},
{
title: '联系信息',
fields: [
{ label: '联系人', value: row.contactName },
{ label: '联系电话', value: row.contactPhone },
{
label: '经营范围',
value: row.businessScope
? row.businessScope
.split(',')
.map((code) => {
const opt = businessScopeOptions.value.find((o) => o.value === code)
return opt ? opt.label : code
})
.join('、')
: '无',
span: true,
},
{ label: '备注', value: row.remark, span: true },
{ label: '创建时间', value: row.createTime }
]
}
]
})
function handleView(row: Api.Site.SiteItem) {
viewRow.value = row
viewVisible.value = true
}
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.Site.SiteItem[]>([])
const selectedRows = ref<Api.Site.SiteItem[]>([])
@@ -254,6 +323,107 @@
const statusOptions = ref<Api.Dict.DictDataOption[]>([])
const businessScopeOptions = ref<Api.Dict.DictDataOption[]>([])
/** 联系人:关联 sys_user,提交仍写 contactName / contactPhone 字符串 */
const contactUserId = ref<string | null>(null)
const contactUserOptions = ref<Api.User.UserItem[]>([])
const contactSelectedSnapshot = ref<Api.User.UserItem | null>(null)
const contactUserLoading = ref(false)
function formatContactUserLabel(u: Api.User.UserItem) {
const name = (u.nickName || '').trim() || '-'
const no = (u.userNo || '').trim()
const phone = (u.phoneNo || '').trim()
const parts = [name]
if (no) parts.push(no)
if (phone) parts.push(phone)
return parts.join(' · ')
}
async function remoteSearchContactUsers(query: string) {
contactUserLoading.value = true
try {
const q = (query || '').trim()
const res = await fetchUserList({
page: 1,
pageSize: 50,
keyword: q || undefined,
status: '1'
})
let list = [...(res.list || [])]
const curId = contactUserId.value
if (
curId &&
contactSelectedSnapshot.value?.id === curId &&
!list.some((x) => x.id === curId)
) {
list = [contactSelectedSnapshot.value, ...list]
}
contactUserOptions.value = list
} catch (e) {
console.error('检索用户失败:', e)
contactUserOptions.value = []
} finally {
contactUserLoading.value = false
}
}
function onContactUserChange(val: string | null | undefined) {
if (!val) {
contactUserId.value = null
contactSelectedSnapshot.value = null
contactUserOptions.value = []
formData.contactName = ''
formData.contactPhone = ''
return
}
const u =
contactUserOptions.value.find((x) => x.id === val) ||
(contactSelectedSnapshot.value?.id === val ? contactSelectedSnapshot.value : undefined)
if (!u) return
contactSelectedSnapshot.value = { ...u }
formData.contactName = (u.nickName || '').trim()
formData.contactPhone = (u.phoneNo || '').trim()
}
async function resolveContactUserForEdit() {
contactUserId.value = null
contactSelectedSnapshot.value = null
contactUserOptions.value = []
const name = (formData.contactName || '').trim()
const phone = (formData.contactPhone || '').trim()
if (!name && !phone) return
contactUserLoading.value = true
try {
const res = await fetchUserList({
page: 1,
pageSize: 50,
keyword: name || phone || undefined,
status: '1'
})
const list = res.list || []
const match =
list.find(
(u) =>
(u.nickName || '').trim() === name && (!phone || (u.phoneNo || '').trim() === phone)
) ||
(name ? list.find((u) => (u.nickName || '').trim() === name) : undefined) ||
(name ? list.find((u) => (u.userNo || '').trim() === name) : undefined)
if (match) {
contactUserOptions.value = list
contactUserId.value = match.id
contactSelectedSnapshot.value = { ...match }
formData.contactName = (match.nickName || '').trim()
if ((match.phoneNo || '').trim()) {
formData.contactPhone = (match.phoneNo || '').trim()
}
}
} catch (e) {
console.error('匹配联系人用户失败:', e)
} finally {
contactUserLoading.value = false
}
}
const loadDictOptions = async () => {
try {
const [zdlx, bmzt, zdywfw] = await Promise.all([
@@ -317,6 +487,14 @@
formData.orderNum = 0
formData.remark = ''
editingId.value = null
contactUserId.value = null
contactUserOptions.value = []
contactSelectedSnapshot.value = null
}
function handleDialogClose() {
resetForm()
formRef.value?.clearValidate()
}
function handleAdd() {
@@ -343,6 +521,9 @@
formData.remark = row.remark || ''
dialogVisible.value = true
formRef.value?.clearValidate?.()
nextTick(() => {
resolveContactUserForEdit()
})
}
async function handleSubmit() {
@@ -387,11 +568,14 @@
const ids = selectedRows.value.map((r) => r.id)
if (!ids.length) return
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个站点吗?`, '提示', { type: 'warning' })
for (const id of ids) {
await fetchDeleteSite(id)
}
selectedRows.value = []
await loadData()
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeleteSite(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
@@ -406,12 +590,5 @@
margin-bottom: 0;
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
</style>
+50 -34
View File
@@ -61,6 +61,7 @@
stripe
row-key="id"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column
type="selection"
@@ -113,32 +114,28 @@
<el-table-column
prop="contactPhone"
label="联系电话"
min-width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="orderNum"
label="排序"
width="80"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="createTime"
label="创建时间"
min-width="160"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column
label="操作"
width="260"
width="320"
fixed="right"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)"
><el-icon><View /></el-icon>查看</el-button
>
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
<el-button
class="btn-op-item"
@@ -198,17 +195,6 @@
<el-form-item label="联系电话">
<el-input v-model="formData.contactPhone" placeholder="可选" />
</el-form-item>
<el-form-item label="排序">
<div class="sort-field">
<el-input-number
v-model="formData.orderNum"
:min="0"
:max="9999"
controls-position="right"
/>
<span class="form-tip">数值越小越靠前</span>
</div>
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="可选" />
</el-form-item>
@@ -225,6 +211,14 @@
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.tenantName || '租户详情'"
:icon="OfficeBuilding"
:meta="viewRow?.createTime || ''"
:sections="viewSections"
/>
</section>
</div>
</template>
@@ -232,7 +226,9 @@
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, View, OfficeBuilding } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchTenantList,
fetchCreateTenant,
@@ -256,6 +252,8 @@
const submitLoading = ref(false)
const formRef = ref()
const editingId = ref<string | null>(null)
const viewVisible = ref(false)
const viewRow = ref<Api.Tenant.TenantItem | null>(null)
const formData = reactive({
tenantNo: '',
@@ -275,6 +273,23 @@
selectedRows.value.filter((r) => !isDefaultTenantRow(r))
)
const viewSections = computed(() => {
if (!viewRow.value) return []
const row = viewRow.value
return [
{
title: '基本信息',
fields: [
{ label: '租户编号', value: row.tenantNo },
{ label: '租户名称', value: row.tenantName },
{ label: '联系人', value: row.contactName },
{ label: '联系电话', value: row.contactPhone },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function isDefaultTenantNo(no: string) {
return (no || '').trim() === DEFAULT_TENANT_NO
}
@@ -375,6 +390,11 @@
}
}
function handleView(row: Api.Tenant.TenantItem) {
viewRow.value = row
viewVisible.value = true
}
async function handleDelete(row: Api.Tenant.TenantItem) {
if (isDefaultTenantRow(row)) {
ElMessage.warning('默认租户不可删除')
@@ -394,11 +414,14 @@
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个租户吗?`, '提示', {
type: 'warning'
})
for (const id of ids) {
await fetchDeleteTenant(id)
}
selectedRows.value = []
await loadData()
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeleteTenant(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
@@ -412,12 +435,5 @@
margin-bottom: 0;
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
</style>
+48 -28
View File
@@ -57,6 +57,7 @@
stripe
row-key="id"
@selection-change="handleSelectionChange"
@row-dblclick="handleView"
>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column
@@ -69,10 +70,12 @@
/>
<el-table-column prop="unitName" label="单位名称" min-width="150" align="center" header-align="center" />
<el-table-column prop="unitCode" label="单位编码" min-width="120" align="center" header-align="center" />
<el-table-column prop="orderNum" label="排序" width="80" align="center" header-align="center" />
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center" header-align="center" />
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)"
><el-icon><View /></el-icon>查看</el-button
>
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
<el-button class="btn-op-item" @click="handleDelete(row)">删除</el-button>
</template>
@@ -116,17 +119,6 @@
<el-form-item label="单位编码" prop="unitCode">
<el-input v-model="formData.unitCode" placeholder="如:jin、kg、ge" />
</el-form-item>
<el-form-item label="排序">
<div class="sort-field">
<el-input-number
v-model="formData.orderNum"
:min="0"
:max="9999"
controls-position="right"
/>
<span class="form-tip">数值越小越靠前</span>
</div>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="formData.remark" placeholder="可选" />
</el-form-item>
@@ -143,14 +135,24 @@
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.unitName || '单位详情'"
:icon="ScaleToOriginal"
:meta="viewRow?.createTime || ''"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, View, ScaleToOriginal } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchItemUnitList,
fetchCreateItemUnit,
@@ -171,6 +173,8 @@
const submitLoading = ref(false)
const formRef = ref()
const editingId = ref<string | null>(null)
const viewVisible = ref(false)
const viewRow = ref<Api.ItemUnit.ItemUnitItem | null>(null)
const formData = reactive({
unitName: '',
@@ -188,6 +192,21 @@
selectedRows.value = rows
}
const viewSections = computed(() => {
if (!viewRow.value) return []
const row = viewRow.value
return [
{
title: '基本信息',
fields: [
{ label: '单位名称', value: row.unitName },
{ label: '单位编码', value: row.unitCode },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
async function loadData() {
loading.value = true
try {
@@ -267,6 +286,11 @@
}
}
function handleView(row: Api.ItemUnit.ItemUnitItem) {
viewRow.value = row
viewVisible.value = true
}
async function handleDelete(row: Api.ItemUnit.ItemUnitItem) {
await ElMessageBox.confirm('确定要删除该单位吗?', '提示', { type: 'warning' })
await fetchDeleteItemUnit(row.id)
@@ -278,11 +302,14 @@
const ids = selectedRows.value.map((r) => r.id)
if (!ids.length) return
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个单位吗?`, '提示', { type: 'warning' })
for (const id of ids) {
await fetchDeleteItemUnit(id)
}
selectedRows.value = []
await loadData()
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeleteItemUnit(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
@@ -296,12 +323,5 @@
margin-bottom: 0;
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
</style>
+6 -6
View File
@@ -211,8 +211,8 @@
</el-form-item>
</el-form>
<template #footer>
<el-button @click="editVisible = false">取消</el-button>
<el-button type="primary" @click="confirmEdit" :loading="submitLoading">确定</el-button>
<el-button @click="editVisible = false"><el-icon><Close /></el-icon>取消</el-button>
<el-button type="primary" @click="confirmEdit" :loading="submitLoading"><el-icon><Check /></el-icon>确定</el-button>
</template>
</el-dialog>
@@ -242,8 +242,8 @@
</el-form-item>
</el-form>
<template #footer>
<el-button @click="addressVisible = false">取消</el-button>
<el-button type="primary" @click="confirmAddress" :loading="submitLoading">确定</el-button>
<el-button @click="addressVisible = false"><el-icon><Close /></el-icon>取消</el-button>
<el-button type="primary" @click="confirmAddress" :loading="submitLoading"><el-icon><Check /></el-icon>确定</el-button>
</template>
</el-dialog>
</div>
@@ -254,7 +254,7 @@ import { ref, reactive, computed, onMounted, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import { ArrowLeft } from '@element-plus/icons-vue'
import { ArrowLeft, Close, Check } from '@element-plus/icons-vue'
import { fetchUserDetail, fetchUpdateUser, fetchActiveRegions } from '@/api/admin'
import { resolveUserAvatarUrl } from '@/utils/user-avatar'
import type { FormInstance, FormRules } from 'element-plus'
@@ -381,7 +381,7 @@ const formatAmount = (amount: number | string) => {
// 返回列表
const goBack = () => {
router.push('/demo/user')
router.push('/system/user')
}
// 加载数据
+67 -18
View File
@@ -11,12 +11,14 @@
<div class="flex gap-4">
<!-- 左侧:组织树 -->
<div class="w-[280px] shrink-0 border-r border-[var(--mint-border)] pr-4">
<div class="panel-top">
<!-- 标题与搜索同处 panel-top:避免标题栏底边与独立输入框之间出现不可控的视觉断层 -->
<div class="panel-top user-dept-aside__head">
<h2 class="title-bar-heading">组织</h2>
<el-input v-model="deptKeyword" placeholder="搜索组织" clearable />
</div>
<el-input v-model="deptKeyword" placeholder="搜索组织" clearable class="mb-3" />
<el-tree
ref="deptTreeRef"
class="user-dept-aside__tree"
:data="deptTree"
:props="{ label: 'deptName', children: 'children' }"
node-key="id"
@@ -74,6 +76,7 @@
v-loading="loading"
stripe
row-key="id"
@row-dblclick="handleView"
>
<el-table-column
type="index"
@@ -85,12 +88,12 @@
/>
<el-table-column prop="userNo" label="用户账号" min-width="120" align="center" header-align="center" />
<el-table-column prop="nickName" label="用户名" min-width="100" align="center" header-align="center" />
<el-table-column prop="deptName" label="所属组织" min-width="120" align="center" header-align="center">
<el-table-column prop="deptName" label="所属组织" min-width="160" align="center" header-align="center">
<template #default="{ row }">
{{ row.deptName || '-' }}
</template>
</el-table-column>
<el-table-column prop="phoneNo" label="手机号" min-width="120" align="center" header-align="center">
<el-table-column prop="phoneNo" label="手机号" min-width="140" align="center" header-align="center">
<template #default="{ row }">
{{ row.phoneNo || '-' }}
</template>
@@ -102,9 +105,10 @@
</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center" header-align="center" />
<el-table-column label="操作" width="320" fixed="right" align="center" header-align="center">
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
<el-table-column label="操作" width="400" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item" @click="handleView(row)"><el-icon><View /></el-icon>查看</el-button>
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
<el-button class="btn-op-item" @click="handleResetPwd(row)">重置密码</el-button>
<el-button class="btn-op-item" @click="handleDelete(row)">删除</el-button>
@@ -175,9 +179,6 @@
<el-option label="停用" value="0" />
</el-select>
</el-form-item>
<el-form-item label="排序">
<el-input-number v-model="formData.orderNum" :min="0" :max="9999" controls-position="right" />
</el-form-item>
<el-form-item label="备注" style="grid-column: 1 / -1">
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="可选" />
</el-form-item>
@@ -194,14 +195,23 @@
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.nickName || '用户详情'"
:icon="UserFilled"
:meta="`${viewRow?.deptName || ''}${viewRow?.deptName && viewRow?.createTime ? ' · ' : ''}${viewRow?.createTime || ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from 'vue'
import { ref, reactive, computed, onMounted, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check } from '@element-plus/icons-vue'
import { Plus, Close, Check, View, UserFilled } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import {
fetchUserList,
fetchCreateUser,
@@ -399,6 +409,39 @@
await fetchResetPassword(row.id)
}
// ---- 查看弹窗 ----
const viewVisible = ref(false)
const viewRow = ref<Api.User.UserItem | null>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
return [
{
title: '基本信息',
fields: [
{ label: '用户账号', value: row.userNo },
{ label: '用户名', value: row.nickName },
{ label: '所属组织', value: row.deptName },
{ label: '手机号', value: row.phoneNo },
{ label: '邮箱', value: row.email },
{
label: '性别',
value: ({ '0': '男', '1': '女', '2': '未知' } as Record<string, string>)[row.sex] || '未知'
},
{ label: '状态', value: row.status === '1' ? '正常' : '停用' },
{ label: '创建时间', value: row.createTime },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function handleView(row: Api.User.UserItem) {
viewRow.value = row
viewVisible.value = true
}
onMounted(() => {
loadDeptTree()
loadData()
@@ -406,17 +449,23 @@
</script>
<style scoped lang="scss">
/* 侧栏标题区纵向排布:与全局 panel-top 横排工具栏区分,收紧标题与搜索的间距节奏 */
.user-dept-aside__head {
flex-direction: column;
align-items: stretch;
justify-content: flex-start;
flex-wrap: nowrap;
gap: 8px;
}
.user-dept-aside__tree {
margin-top: 12px;
}
.user-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
:deep(.el-form-item__label) {
font-size: 11px;
font-weight: 500;
color: var(--mint-text-muted);
padding: 0 0 4px;
line-height: 1.2;
}
}
</style>
@@ -32,14 +32,15 @@
</ElForm>
<template #footer>
<div class="dialog-footer">
<ElButton class="btn-ghost" @click="dialogVisible = false">取消</ElButton>
<ElButton class="btn-main" type="primary" @click="handleSubmit">提交</ElButton>
<ElButton class="btn-ghost" @click="dialogVisible = false"><el-icon><Close /></el-icon>取消</ElButton>
<ElButton class="btn-main" type="primary" @click="handleSubmit"><el-icon><Check /></el-icon>提交</ElButton>
</div>
</template>
</ElDialog>
</template>
<script setup lang="ts">
import { Close, Check } from '@element-plus/icons-vue'
import { fetchGetRoleList } from '@/api/admin'
import type { FormInstance, FormRules } from 'element-plus'
@@ -0,0 +1,288 @@
<!-- 审批操作弹窗 -->
<template>
<el-dialog
v-model="visible"
width="640px"
destroy-on-close
class="workflow-module-dialog"
align-center
:close-on-click-modal="false"
:show-close="false"
style="backdrop-filter: none"
>
<div v-if="bizLoading" v-loading="true" class="dialog-scroll" style="min-height: 120px" />
<div v-else class="dialog-scroll">
<!-- Hero header -->
<div class="view-hero">
<div class="view-hero-icon">
<el-icon :size="28"><Checked /></el-icon>
</div>
<div class="view-hero-main">
<h2>{{ instanceData?.processName || '审批操作' }}</h2>
<div class="view-hero-tags">
<el-tag size="small" type="info">{{ instanceData?.businessTypeLabel || instanceData?.businessType || '--' }}</el-tag>
</div>
<p v-if="instanceData" class="view-hero-meta">
发起人:{{ instanceData.starterUserName || '--' }}
<span class="dot">·</span>
业务单号:{{ instanceData.businessId || '--' }}
<span class="dot">·</span>
{{ instanceData.createTime || '--' }}
</p>
</div>
</div>
<!-- 申请信息 -->
<div v-if="formFields.length" class="view-section">
<h3>申请信息</h3>
<dl class="view-kv-grid">
<div v-for="field in formFields" :key="field.label" class="view-kv">
<dt>{{ field.label }}</dt>
<dd>{{ field.value || '--' }}</dd>
</div>
</dl>
</div>
<!-- 审批操作 -->
<div class="view-section">
<h3>审批操作</h3>
<el-form :model="form" label-position="top">
<el-form-item label="审批结果">
<el-radio-group v-model="form.approved">
<el-radio :value="true">通过</el-radio>
<el-radio :value="false">驳回</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="审批意见">
<el-input
v-model="form.commentText"
type="textarea"
:rows="3"
placeholder="请输入审批意见"
/>
</el-form-item>
</el-form>
</div>
</div>
<template #footer>
<el-button class="btn-ghost" @click="visible = false"><el-icon><Close /></el-icon>取消</el-button>
<el-button type="primary" class="btn-main" :loading="submitting" @click="handleSubmit">
<el-icon><Check /></el-icon>
确认提交
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { fetchApproveTask, fetchRejectTask, fetchInstanceDetail } from '@/api/workflow'
import { Checked, Close, Check } from '@element-plus/icons-vue'
defineOptions({ name: 'ApprovalDialog' })
const props = defineProps<{
visible: boolean
taskId: string
instanceId?: string
}>()
const emit = defineEmits<{
(e: 'update:visible', val: boolean): void
(e: 'done'): void
}>()
const visible = computed({
get: () => props.visible,
set: (val) => emit('update:visible', val)
})
const submitting = ref(false)
const form = reactive({
approved: true,
commentText: ''
})
const bizLoading = ref(false)
const formFields = ref<Array<{ label: string; value: string }>>([])
const instanceData = ref<Record<string, any> | null>(null)
async function loadFormData() {
if (!props.instanceId) return
bizLoading.value = true
formFields.value = []
instanceData.value = null
try {
const data = await fetchInstanceDetail(props.instanceId)
instanceData.value = data
formFields.value = data.businessFormFields || []
} catch {
// 加载失败不影响审批操作
} finally {
bizLoading.value = false
}
}
watch(
() => props.visible,
(val) => {
if (val) {
form.approved = true
form.commentText = ''
loadFormData()
}
}
)
async function handleSubmit() {
submitting.value = true
try {
const data = { commentText: form.commentText?.trim() || undefined }
if (form.approved) {
await fetchApproveTask(props.taskId, data)
} else {
await fetchRejectTask(props.taskId, data)
}
visible.value = false
emit('done')
} catch {
// 错误已由全局处理
} finally {
submitting.value = false
}
}
</script>
<style scoped lang="scss">
.dialog-scroll {
overflow-y: auto;
max-height: calc(100vh - 120px);
}
.view-hero {
display: flex;
gap: 16px;
padding: 20px 22px;
background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 55%);
border-bottom: 1px solid #d9e8e2;
align-items: center;
}
.view-hero-icon {
width: 72px;
height: 72px;
border-radius: 12px;
border: 1px solid rgba(16, 185, 129, 0.2);
background: rgba(16, 185, 129, 0.08);
color: #059669;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.view-hero-main {
flex: 1;
min-width: 0;
h2 {
margin: 0 0 8px;
font-size: 18px;
font-weight: 700;
color: #1e293b;
letter-spacing: -0.02em;
}
}
.view-hero-tags {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
flex-wrap: wrap;
}
.view-hero-meta {
margin: 0;
font-size: 13px;
color: #64748b;
line-height: 1.5;
.dot {
margin: 0 6px;
opacity: 0.7;
}
}
.view-section {
padding: 18px 22px;
border-bottom: 1px solid #ebeef5;
&:last-child {
border-bottom: none;
}
h3 {
margin: 0 0 14px;
font-size: 13px;
font-weight: 700;
letter-spacing: 0.06em;
color: #64748b;
}
}
.view-kv-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px 28px;
}
.view-kv {
display: grid;
grid-template-columns: 96px 1fr;
gap: 8px 12px;
font-size: 13px;
align-items: start;
dt {
margin: 0;
color: #64748b;
font-weight: 500;
}
dd {
margin: 0;
color: #1e293b;
word-break: break-word;
}
}
@media (max-width: 640px) {
.view-kv-grid {
grid-template-columns: 1fr;
}
.view-kv {
grid-template-columns: 1fr;
gap: 4px;
}
}
</style>
<style lang="scss">
.workflow-module-dialog {
.el-dialog__header {
display: none;
}
.el-dialog__body {
padding: 0;
overflow: hidden;
}
.el-dialog__footer {
padding: 12px 22px;
border-top: 1px solid #d9e8e2;
background: #f8fafc;
}
}
</style>
@@ -0,0 +1,25 @@
<!-- 流程/任务状态标签 -->
<template>
<el-tag :type="tagType" size="small">{{ label }}</el-tag>
</template>
<script setup lang="ts">
defineOptions({ name: 'ProcessStatusTag' })
const props = defineProps<{
status: string
}>()
const statusMap: Record<string, { type: string; label: string }> = {
running: { type: 'warning', label: '进行中' },
completed: { type: 'success', label: '已完成' },
rejected: { type: 'danger', label: '已驳回' },
cancelled: { type: 'info', label: '已取消' },
pending: { type: 'warning', label: '待处理' },
approved: { type: 'success', label: '已通过' },
withdrawn: { type: 'info', label: '已撤回' }
}
const tagType = computed(() => statusMap[props.status]?.type ?? 'info')
const label = computed(() => statusMap[props.status]?.label ?? props.status)
</script>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,518 @@
<!-- 我的申请 -->
<template>
<div class="page-container">
<header class="page-head">
<h1>我的申请</h1>
<p class="page-desc">查看我发起的所有审批申请及进度。</p>
</header>
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">申请列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="关键词">
<el-input
v-model="searchForm.keyword"
placeholder="流程名称/业务单号"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="searchForm.status" placeholder="全部" clearable style="width: 140px">
<el-option label="进行中" value="running" />
<el-option label="已完成" value="completed" />
<el-option label="已驳回" value="rejected" />
</el-select>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">按流程名称、业务单号模糊查询。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" @click="handleReset"><el-icon><RefreshLeft /></el-icon>重置</el-button>
<el-button class="btn-main" type="primary" @click="handleSearch"><el-icon><Search /></el-icon>搜索</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-body list-wrap">
<el-table
class="list-table"
:data="tableData"
v-loading="loading"
stripe
row-key="id"
>
<el-table-column
type="index"
label="序号"
width="68"
align="center"
header-align="center"
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
/>
<el-table-column
prop="processName"
label="流程名称"
min-width="160"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
prop="businessTypeLabel"
label="业务类型"
width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="businessId"
label="业务单号"
min-width="200"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
prop="status"
label="状态"
width="100"
align="center"
header-align="center"
>
<template #default="{ row }">
<ProcessStatusTag :status="row.status || ''" />
</template>
</el-table-column>
<el-table-column
prop="createTime"
label="发起时间"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column label="操作" width="160" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="handleViewDetail(row)"><el-icon><View /></el-icon>查看详情</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
:current-page="pagination.page"
:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
@current-change="(val) => ((pagination.page = val), loadData())"
/>
</div>
</div>
<!-- 详情弹窗 -->
<el-dialog
v-model="detailVisible"
width="720px"
class="workflow-module-dialog"
align-center
destroy-on-close
:show-close="false"
style="backdrop-filter: none"
>
<div v-loading="detailLoading" class="dialog-scroll">
<template v-if="detailData">
<div class="view-hero">
<div class="view-hero-icon">
<el-icon :size="28"><Document /></el-icon>
</div>
<div class="view-hero-main">
<h2>{{ detailRow?.processName || '流程详情' }}</h2>
<div class="view-hero-tags">
<ProcessStatusTag :status="detailRow?.status || ''" />
<el-tag size="small" type="info">{{ detailRow?.businessTypeLabel || detailData.businessType || '--' }}</el-tag>
</div>
<p class="view-hero-meta">
业务单号:{{ detailData.businessId || '--' }}
<span class="dot">·</span>
{{ detailRow?.createTime || '--' }}
</p>
</div>
</div>
<div v-if="detailData.businessFormFields && detailData.businessFormFields.length" class="view-section">
<h3>申请信息</h3>
<dl class="view-kv-grid">
<div v-for="field in detailData.businessFormFields" :key="field.label" class="view-kv">
<dt>{{ field.label }}</dt>
<dd>{{ field.value || '--' }}</dd>
</div>
</dl>
</div>
<div v-if="detailData.tasks && detailData.tasks.length" class="view-section">
<h3>审批节点(含历史)</h3>
<div class="htl-scroll">
<div class="htl">
<div
v-for="(task, idx) in detailData.tasks"
:key="task.id"
class="htl-item"
:class="getTimelineStatusClass(task.status)"
>
<div class="htl-rail">
<span class="htl-node" />
<span v-if="idx < detailData.tasks.length - 1" class="htl-line" />
</div>
<div class="htl-body">
<div class="htl-name">{{ task.nodeName || '--' }}</div>
<div class="htl-user">{{ task.assigneeUserName || '--' }}</div>
<div class="htl-status">
<ProcessStatusTag :status="task.status || ''" />
</div>
<div v-if="task.updateTime" class="htl-time">{{ task.updateTime }}</div>
<div v-if="task.commentText" class="htl-comment">{{ task.commentText }}</div>
</div>
</div>
</div>
</div>
</div>
</template>
</div>
<template #footer>
<el-button class="btn-ghost" @click="detailVisible = false"><el-icon><Close /></el-icon>关闭</el-button>
</template>
</el-dialog>
</section>
</div>
</template>
<script setup lang="ts">
import { fetchMyInstances, fetchBusinessAllTasks } from '@/api/workflow'
import ProcessStatusTag from '../components/ProcessStatusTag.vue'
import { Document, View, Search, RefreshLeft, Close } from '@element-plus/icons-vue'
defineOptions({ name: 'WorkflowMyApplications' })
const searchForm = reactive<{ keyword: string; status: string }>({ keyword: '', status: '' })
const tableData = ref<Api.Workflow.MyInstanceItem[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const detailVisible = ref(false)
const detailLoading = ref(false)
const detailData = ref<Api.Workflow.BusinessAllTasks | null>(null)
const detailRow = ref<Api.Workflow.MyInstanceItem | null>(null)
async function loadData() {
loading.value = true
try {
const res = await fetchMyInstances({
page: pagination.page,
pageSize: pagination.pageSize,
keyword: searchForm.keyword || undefined,
status: searchForm.status || undefined,
})
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
loadData()
}
function handleReset() {
searchForm.keyword = ''
searchForm.status = ''
pagination.page = 1
loadData()
}
async function handleViewDetail(row: Api.Workflow.MyInstanceItem) {
detailVisible.value = true
detailLoading.value = true
detailData.value = null
detailRow.value = row
try {
const data = await fetchBusinessAllTasks(
row.businessType || '',
row.businessId || ''
)
detailData.value = data
} catch {
// error handled globally
} finally {
detailLoading.value = false
}
}
function getTimelineStatusClass(status: string) {
if (['approved', 'completed'].includes(status)) return 'htl-done'
if (['running', 'pending'].includes(status)) return 'htl-active'
if (status === 'rejected') return 'htl-reject'
return 'htl-muted'
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.dialog-scroll {
overflow-y: auto;
max-height: calc(100vh - 120px);
}
.view-hero {
display: flex;
gap: 16px;
padding: 20px 22px;
background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 55%);
border-bottom: 1px solid #d9e8e2;
align-items: center;
}
.view-hero-icon {
width: 72px;
height: 72px;
border-radius: 12px;
border: 1px solid rgba(16, 185, 129, 0.2);
background: rgba(16, 185, 129, 0.08);
color: #059669;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.view-hero-main {
flex: 1;
min-width: 0;
h2 {
margin: 0 0 8px;
font-size: 18px;
font-weight: 700;
color: #1e293b;
letter-spacing: -0.02em;
}
}
.view-hero-tags {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
flex-wrap: wrap;
}
.view-hero-meta {
margin: 0;
font-size: 13px;
color: #64748b;
line-height: 1.5;
.dot {
margin: 0 6px;
opacity: 0.7;
}
}
.view-section {
padding: 18px 22px;
border-bottom: 1px solid #ebeef5;
&:last-child {
border-bottom: none;
}
h3 {
margin: 0 0 14px;
font-size: 13px;
font-weight: 700;
letter-spacing: 0.06em;
color: #64748b;
}
}
.view-kv-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px 28px;
}
.view-kv {
display: grid;
grid-template-columns: 96px 1fr;
gap: 8px 12px;
font-size: 13px;
align-items: start;
dt {
margin: 0;
color: #64748b;
font-weight: 500;
}
dd {
margin: 0;
color: #1e293b;
word-break: break-word;
}
}
@media (max-width: 640px) {
.view-kv-grid {
grid-template-columns: 1fr;
}
.view-kv {
grid-template-columns: 1fr;
gap: 4px;
}
}
/* horizontal timeline */
.htl-scroll {
overflow-x: auto;
padding: 0 0 4px 12px;
&::-webkit-scrollbar {
height: 4px;
}
&::-webkit-scrollbar-thumb {
background: #d1d5db;
border-radius: 2px;
}
}
.htl {
display: inline-flex;
min-width: 100%;
}
.htl-item {
display: flex;
flex-direction: column;
min-width: 140px;
flex: 1 0 140px;
}
.htl-rail {
position: relative;
display: flex;
align-items: center;
height: 22px;
}
.htl-node {
position: relative;
z-index: 1;
width: 12px;
height: 12px;
border-radius: 50%;
flex-shrink: 0;
background: #10b981;
border: 2px solid #fff;
box-shadow: 0 0 0 1px #10b981;
}
.htl-line {
flex: 1;
height: 2px;
background: #d1d5db;
margin-left: 0;
}
.htl-body {
padding: 8px 4px 0 0;
font-size: 13px;
line-height: 1.45;
}
.htl-name {
font-weight: 600;
color: #1e293b;
margin-bottom: 2px;
}
.htl-user {
color: #64748b;
font-size: 12px;
margin-bottom: 4px;
}
.htl-status {
margin-bottom: 4px;
}
.htl-time {
font-size: 11px;
color: #94a3b8;
margin-bottom: 2px;
}
.htl-comment {
font-size: 12px;
color: #64748b;
word-break: break-word;
}
.htl-active .htl-node {
background: #fff;
border: 3px solid #10b981;
box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}
.htl-reject .htl-node {
background: #ef4444;
border-color: #fff;
box-shadow: 0 0 0 1px #ef4444;
}
.htl-muted .htl-node {
background: #d1d5db;
border-color: #fff;
box-shadow: none;
}
.htl-done + .htl-active .htl-line,
.htl-done + .htl-done .htl-line {
background: #10b981;
}
.htl-active + .htl-done .htl-line {
background: #10b981;
}
</style>
<style lang="scss">
.workflow-module-dialog {
.el-dialog__header {
display: none;
}
.el-dialog__body {
padding: 0;
overflow: hidden;
}
.el-dialog__footer {
padding: 12px 22px;
border-top: 1px solid #d9e8e2;
background: #f8fafc;
}
}
</style>
@@ -0,0 +1,352 @@
<!-- 流程定义管理 -->
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<div class="page-container">
<header class="page-head">
<h1>流程管理</h1>
<p class="page-desc">管理审批流程定义,支持图形化设计、版本发布与启停控制。</p>
</header>
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">流程列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="关键词">
<el-input
v-model="searchForm.keyword"
placeholder="流程名称/编码"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">按流程名称、编码模糊查询。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" @click="handleReset"><el-icon><RefreshLeft /></el-icon>重置</el-button>
<el-button class="btn-main" type="primary" @click="handleSearch"><el-icon><Search /></el-icon>搜索</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
</div>
<el-button class="btn-main" type="primary" @click="handleAdd">
<el-icon><Plus /></el-icon>
新增流程
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="selectedRows.length === 0"
@click="handleBatchDelete"
>
<el-icon><Delete /></el-icon>
批量删除
</el-button>
</div>
</div>
<div class="list-body list-wrap">
<el-table
class="list-table"
:data="tableData"
v-loading="loading"
stripe
row-key="id"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" header-align="center" />
<el-table-column
type="index"
label="序号"
width="68"
align="center"
header-align="center"
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
/>
<el-table-column
prop="processCode"
label="流程编码"
width="150"
align="center"
header-align="center"
/>
<el-table-column
prop="processName"
label="流程名称"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column label="状态" width="100" align="center" header-align="center">
<template #default="{ row }">
<el-switch
:model-value="row.status"
active-value="1"
inactive-value="0"
@change="(val) => handleStatusChange(row, val)"
/>
</template>
</el-table-column>
<el-table-column label="最新版本" width="100" align="center" header-align="center">
<template #default="{ row }">
{{ row.latestVersion != null ? `V${row.latestVersion}` : '--' }}
</template>
</el-table-column>
<el-table-column
prop="createTime"
label="创建时间"
width="160"
align="center"
header-align="center"
/>
<el-table-column label="操作" width="400" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="handleDesign(row)"><el-icon><SetUp /></el-icon>流程设计</el-button>
<el-button class="btn-op-item" @click="handleEdit(row)"><el-icon><Edit /></el-icon>编辑</el-button>
<el-button class="btn-op-item" @click="handleDelete(row)"><el-icon><Delete /></el-icon>删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
:current-page="pagination.page"
:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
@current-change="(val) => ((pagination.page = val), loadData())"
/>
</div>
</div>
<!-- 新增/编辑弹窗 -->
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
style="backdrop-filter: none"
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-position="top"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="流程编码" prop="processCode">
<el-input v-model="formData.processCode" placeholder="请输入流程编码" />
</el-form-item>
<el-form-item label="流程名称" prop="processName">
<el-input v-model="formData.processName" placeholder="请输入流程名称" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="formData.remark" placeholder="可选" />
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="dialogVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" :loading="submitLoading" @click="handleSubmit">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
</section>
<!-- 流程设计器 -->
<FlowDesigner
v-model:visible="designerVisible"
:process-def-id="designerDefId"
:process-name="designerDefName"
@saved="handleDesignerSaved"
/>
</div>
</template>
<script setup lang="ts">
import { Plus, Close, Check, Search, RefreshLeft, Delete, SetUp, Edit } from '@element-plus/icons-vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchProcessDefList,
fetchCreateProcessDef,
fetchUpdateProcessDef,
fetchDeleteProcessDef
} from '@/api/workflow'
import FlowDesigner from '../designer/FlowDesigner.vue'
defineOptions({ name: 'WorkflowProcess' })
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.Workflow.ProcessDefItem[]>([])
const selectedRows = ref<Api.Workflow.ProcessDefItem[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
// 新增/编辑
const dialogVisible = ref(false)
const dialogTitle = ref('新增流程')
const isEdit = ref(false)
const submitLoading = ref(false)
const formRef = ref()
const editingId = ref<string | null>(null)
const formData = reactive({
processCode: '',
processName: '',
orderNum: 0,
remark: ''
})
const formRules = {
processCode: [{ required: true, message: '请输入流程编码', trigger: 'blur' }],
processName: [{ required: true, message: '请输入流程名称', trigger: 'blur' }]
}
// 设计器
const designerVisible = ref(false)
const designerDefId = ref('')
const designerDefName = ref('')
const handleSelectionChange = (rows: Api.Workflow.ProcessDefItem[]) => {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchProcessDefList({
page: pagination.page,
pageSize: pagination.pageSize,
keyword: searchForm.keyword || undefined
})
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
loadData()
}
function handleReset() {
searchForm.keyword = ''
pagination.page = 1
loadData()
}
function resetForm() {
formData.processCode = ''
formData.processName = ''
formData.orderNum = 0
formData.remark = ''
editingId.value = null
}
function handleAdd() {
isEdit.value = false
dialogTitle.value = '新增流程'
resetForm()
dialogVisible.value = true
formRef.value?.clearValidate?.()
}
function handleEdit(row: Api.Workflow.ProcessDefItem) {
isEdit.value = true
dialogTitle.value = '编辑流程'
editingId.value = row.id
formData.processCode = row.processCode || ''
formData.processName = row.processName || ''
formData.orderNum = row.orderNum ?? 0
formData.remark = row.remark || ''
dialogVisible.value = true
formRef.value?.clearValidate?.()
}
async function handleSubmit() {
await formRef.value?.validate?.()
submitLoading.value = true
try {
const payload = {
processCode: formData.processCode.trim(),
processName: formData.processName.trim(),
orderNum: formData.orderNum,
remark: formData.remark?.trim() || undefined
}
if (isEdit.value && editingId.value) {
await fetchUpdateProcessDef(editingId.value, payload)
} else {
await fetchCreateProcessDef(payload)
}
dialogVisible.value = false
await loadData()
} catch {
// 校验或接口错误已由全局处理
} finally {
submitLoading.value = false
}
}
async function handleStatusChange(row: Api.Workflow.ProcessDefItem, val: string | number | boolean) {
const newStatus = String(val)
await fetchUpdateProcessDef(row.id, { status: newStatus })
await loadData()
}
async function handleDelete(row: Api.Workflow.ProcessDefItem) {
await ElMessageBox.confirm('确定要删除该流程吗?', '提示', { type: 'warning' })
await fetchDeleteProcessDef(row.id)
await loadData()
}
async function handleBatchDelete() {
const ids = selectedRows.value.map((r) => r.id)
if (!ids.length) return
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个流程吗?`, '提示', { type: 'warning' })
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeleteProcessDef(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
function handleDesign(row: Api.Workflow.ProcessDefItem) {
designerDefId.value = row.id
designerDefName.value = row.processName
designerVisible.value = true
}
function handleDesignerSaved() {
loadData()
}
onMounted(() => {
loadData()
})
</script>
@@ -0,0 +1,532 @@
<!-- 已办任务 -->
<template>
<div class="page-container">
<header class="page-head">
<h1>已办任务</h1>
<p class="page-desc">查看已处理的审批任务及审批结果。</p>
</header>
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">已办列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="关键词">
<el-input
v-model="searchForm.keyword"
placeholder="流程名称"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">按流程名称模糊查询。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" @click="handleReset"><el-icon><RefreshLeft /></el-icon>重置</el-button>
<el-button class="btn-main" type="primary" @click="handleSearch"><el-icon><Search /></el-icon>搜索</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-body list-wrap">
<el-table
class="list-table"
:data="tableData"
v-loading="loading"
stripe
row-key="id"
>
<el-table-column
type="index"
label="序号"
width="68"
align="center"
header-align="center"
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
/>
<el-table-column
prop="processName"
label="流程名称"
min-width="160"
align="center"
header-align="center"
/>
<el-table-column
prop="businessTypeLabel"
label="业务类型"
width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="businessId"
label="业务单号"
min-width="200"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
prop="starterUserName"
label="发起人"
width="100"
align="center"
header-align="center"
/>
<el-table-column label="审批结果" width="100" align="center" header-align="center">
<template #default="{ row }">
<ProcessStatusTag :status="row.status || ''" />
</template>
</el-table-column>
<el-table-column
prop="commentText"
label="审批意见"
min-width="150"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
prop="updateTime"
label="审批时间"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="handleViewDetail(row)"><el-icon><View /></el-icon>查看详情</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
:current-page="pagination.page"
:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
@current-change="(val) => ((pagination.page = val), loadData())"
/>
</div>
</div>
<!-- 详情弹窗 -->
<el-dialog
v-model="detailVisible"
width="720px"
class="workflow-module-dialog"
align-center
destroy-on-close
:show-close="false"
style="backdrop-filter: none"
>
<div v-loading="detailLoading" class="dialog-scroll">
<template v-if="detailData">
<div class="view-hero">
<div class="view-hero-icon">
<el-icon :size="28"><Document /></el-icon>
</div>
<div class="view-hero-main">
<h2>{{ detailData.processName || '流程详情' }}</h2>
<div class="view-hero-tags">
<ProcessStatusTag :status="detailData.status || ''" />
<el-tag size="small" type="info">{{ detailData.businessTypeLabel || detailData.businessType || '--' }}</el-tag>
</div>
<p class="view-hero-meta">
发起人:{{ detailData.starterUserName || '--' }}
<span class="dot">·</span>
业务单号:{{ detailData.businessId || '--' }}
<span class="dot">·</span>
{{ detailData.createTime || '--' }}
</p>
</div>
</div>
<div v-if="detailData.businessFormFields && detailData.businessFormFields.length" class="view-section">
<h3>申请信息</h3>
<dl class="view-kv-grid">
<div v-for="field in detailData.businessFormFields" :key="field.label" class="view-kv">
<dt>{{ field.label }}</dt>
<dd>{{ field.value || '--' }}</dd>
</div>
</dl>
</div>
<div v-if="detailData.tasks && detailData.tasks.length" class="view-section">
<h3>审批节点</h3>
<div class="htl-scroll">
<div class="htl">
<div
v-for="(task, idx) in detailData.tasks"
:key="idx"
class="htl-item"
:class="getTimelineStatusClass(task.status)"
>
<div class="htl-rail">
<span class="htl-node" />
<span v-if="idx < detailData.tasks.length - 1" class="htl-line" />
</div>
<div class="htl-body">
<div class="htl-name">{{ task.nodeName || '--' }}</div>
<div class="htl-user">{{ task.assigneeUserName || '--' }}</div>
<div class="htl-status">
<ProcessStatusTag :status="task.status || ''" />
</div>
<div v-if="task.updateTime" class="htl-time">{{ task.updateTime }}</div>
<div v-if="task.commentText" class="htl-comment">{{ task.commentText }}</div>
</div>
</div>
</div>
</div>
</div>
</template>
</div>
<template #footer>
<el-button class="btn-ghost" @click="detailVisible = false"><el-icon><Close /></el-icon>关闭</el-button>
</template>
</el-dialog>
</section>
</div>
</template>
<script setup lang="ts">
import { fetchCompletedTasks, fetchInstanceDetail } from '@/api/workflow'
import ProcessStatusTag from '../components/ProcessStatusTag.vue'
import { Document, View, Search, RefreshLeft, Close } from '@element-plus/icons-vue'
defineOptions({ name: 'WorkflowTaskCompleted' })
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.Workflow.TaskItem[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
// 详情
const detailVisible = ref(false)
const detailLoading = ref(false)
const detailData = ref<Api.Workflow.InstanceDetail | null>(null)
async function loadData() {
loading.value = true
try {
const res = await fetchCompletedTasks({
page: pagination.page,
pageSize: pagination.pageSize,
keyword: searchForm.keyword || undefined
})
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
loadData()
}
function handleReset() {
searchForm.keyword = ''
pagination.page = 1
loadData()
}
async function handleViewDetail(row: Api.Workflow.TaskItem) {
detailVisible.value = true
detailLoading.value = true
detailData.value = null
try {
const data = await fetchInstanceDetail(row.instanceId)
detailData.value = {
...data,
processName: row.processName,
businessType: row.businessType,
businessTypeLabel: row.businessTypeLabel,
businessId: row.businessId,
starterUserId: row.starterUserId,
starterUserName: row.starterUserName,
} as Api.Workflow.InstanceDetail & {
processName?: string
businessType?: string
businessTypeLabel?: string
businessId?: string
starterUserId?: string
starterUserName?: string
}
} catch {
// 错误已由全局处理
} finally {
detailLoading.value = false
}
}
function getTimelineStatusClass(status: string) {
if (['approved', 'completed'].includes(status)) return 'htl-done'
if (['running', 'pending'].includes(status)) return 'htl-active'
if (status === 'rejected') return 'htl-reject'
return 'htl-muted'
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.dialog-scroll {
overflow-y: auto;
max-height: calc(100vh - 120px);
}
.view-hero {
display: flex;
gap: 16px;
padding: 20px 22px;
background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 55%);
border-bottom: 1px solid #d9e8e2;
align-items: center;
}
.view-hero-icon {
width: 72px;
height: 72px;
border-radius: 12px;
border: 1px solid rgba(16, 185, 129, 0.2);
background: rgba(16, 185, 129, 0.08);
color: #059669;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.view-hero-main {
flex: 1;
min-width: 0;
h2 {
margin: 0 0 8px;
font-size: 18px;
font-weight: 700;
color: #1e293b;
letter-spacing: -0.02em;
}
}
.view-hero-tags {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
flex-wrap: wrap;
}
.view-hero-meta {
margin: 0;
font-size: 13px;
color: #64748b;
line-height: 1.5;
.dot {
margin: 0 6px;
opacity: 0.7;
}
}
.view-section {
padding: 18px 22px;
border-bottom: 1px solid #ebeef5;
&:last-child {
border-bottom: none;
}
h3 {
margin: 0 0 14px;
font-size: 13px;
font-weight: 700;
letter-spacing: 0.06em;
color: #64748b;
}
}
.view-kv-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px 28px;
}
.view-kv {
display: grid;
grid-template-columns: 96px 1fr;
gap: 8px 12px;
font-size: 13px;
align-items: start;
dt {
margin: 0;
color: #64748b;
font-weight: 500;
}
dd {
margin: 0;
color: #1e293b;
word-break: break-word;
}
}
@media (max-width: 640px) {
.view-kv-grid {
grid-template-columns: 1fr;
}
.view-kv {
grid-template-columns: 1fr;
gap: 4px;
}
}
/* ── horizontal timeline ── */
.htl-scroll {
overflow-x: auto;
padding: 0 0 4px 12px;
&::-webkit-scrollbar {
height: 4px;
}
&::-webkit-scrollbar-thumb {
background: #d1d5db;
border-radius: 2px;
}
}
.htl {
display: inline-flex;
min-width: 100%;
}
.htl-item {
display: flex;
flex-direction: column;
min-width: 140px;
flex: 1 0 140px;
}
/* rail: node circle + connecting line */
.htl-rail {
position: relative;
display: flex;
align-items: center;
height: 22px;
}
.htl-node {
position: relative;
z-index: 1;
width: 12px;
height: 12px;
border-radius: 50%;
flex-shrink: 0;
background: #10b981;
border: 2px solid #fff;
box-shadow: 0 0 0 1px #10b981;
}
.htl-line {
flex: 1;
height: 2px;
background: #d1d5db;
margin-left: 0;
}
.htl-body {
padding: 8px 4px 0 0;
font-size: 13px;
line-height: 1.45;
}
.htl-name {
font-weight: 600;
color: #1e293b;
margin-bottom: 2px;
}
.htl-user {
color: #64748b;
font-size: 12px;
margin-bottom: 4px;
}
.htl-status {
margin-bottom: 4px;
}
.htl-time {
font-size: 11px;
color: #94a3b8;
margin-bottom: 2px;
}
.htl-comment {
font-size: 12px;
color: #64748b;
word-break: break-word;
}
/* status variants */
.htl-active .htl-node {
background: #fff;
border: 3px solid #10b981;
box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}
.htl-reject .htl-node {
background: #ef4444;
border-color: #fff;
box-shadow: 0 0 0 1px #ef4444;
}
.htl-muted .htl-node {
background: #d1d5db;
border-color: #fff;
box-shadow: none;
}
.htl-done + .htl-active .htl-line,
.htl-done + .htl-done .htl-line {
background: #10b981;
}
.htl-active + .htl-done .htl-line {
background: #10b981;
}
</style>
<style lang="scss">
.workflow-module-dialog {
.el-dialog__header {
display: none;
}
.el-dialog__body {
padding: 0;
overflow: hidden;
}
.el-dialog__footer {
padding: 12px 22px;
border-top: 1px solid #d9e8e2;
background: #f8fafc;
}
}
</style>
@@ -0,0 +1,545 @@
<!-- 待办任务 -->
<template>
<div class="page-container">
<header class="page-head">
<h1>待办任务</h1>
<p class="page-desc">查看并处理待审批的工作流任务。</p>
</header>
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">待办列表</h2>
</div>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="关键词">
<el-input
v-model="searchForm.keyword"
placeholder="流程名称"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint">按流程名称模糊查询。</span>
<div class="filter-actions-end">
<el-button class="btn-ghost" @click="handleReset"><el-icon><RefreshLeft /></el-icon>重置</el-button>
<el-button class="btn-main" type="primary" @click="handleSearch"><el-icon><Search /></el-icon>搜索</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-body list-wrap">
<el-table
class="list-table"
:data="tableData"
v-loading="loading"
stripe
row-key="id"
>
<el-table-column
type="index"
label="序号"
width="68"
align="center"
header-align="center"
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
/>
<el-table-column
prop="processName"
label="流程名称"
width="160"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
prop="businessTypeLabel"
label="业务类型"
width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="businessId"
label="业务单号"
min-width="200"
align="center"
header-align="center"
show-overflow-tooltip
/>
<el-table-column
prop="starterUserName"
label="发起人"
width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="createTime"
label="到达时间"
width="180"
align="center"
header-align="center"
/>
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="handleApprove(row)"><el-icon><EditPen /></el-icon>审批</el-button>
<el-button class="btn-op-item" @click="handleViewDetail(row)"><el-icon><View /></el-icon>查看详情</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
:current-page="pagination.page"
:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
@current-change="(val) => ((pagination.page = val), loadData())"
/>
</div>
</div>
<!-- 审批弹窗 -->
<ApprovalDialog
v-model:visible="approvalVisible"
:task-id="approvalTaskId"
:instance-id="approvalInstanceId"
@done="handleApprovalDone"
/>
<!-- 详情弹窗 -->
<el-dialog
v-model="detailVisible"
width="720px"
class="workflow-module-dialog"
align-center
destroy-on-close
:show-close="false"
style="backdrop-filter: none"
>
<div v-loading="detailLoading" class="dialog-scroll">
<template v-if="detailData">
<div class="view-hero">
<div class="view-hero-icon">
<el-icon :size="28"><Document /></el-icon>
</div>
<div class="view-hero-main">
<h2>{{ detailData.processName || '流程详情' }}</h2>
<div class="view-hero-tags">
<ProcessStatusTag :status="detailData.status || ''" />
<el-tag size="small" type="info">{{ detailData.businessTypeLabel || detailData.businessType || '--' }}</el-tag>
</div>
<p class="view-hero-meta">
发起人:{{ detailData.starterUserName || '--' }}
<span class="dot">·</span>
业务单号:{{ detailData.businessId || '--' }}
<span class="dot">·</span>
{{ detailData.createTime || '--' }}
</p>
</div>
</div>
<div v-if="detailData.businessFormFields && detailData.businessFormFields.length" class="view-section">
<h3>申请信息</h3>
<dl class="view-kv-grid">
<div v-for="field in detailData.businessFormFields" :key="field.label" class="view-kv">
<dt>{{ field.label }}</dt>
<dd>{{ field.value || '--' }}</dd>
</div>
</dl>
</div>
<div v-if="detailData.tasks && detailData.tasks.length" class="view-section">
<h3>审批节点</h3>
<div class="htl-scroll">
<div class="htl">
<div
v-for="(task, idx) in detailData.tasks"
:key="idx"
class="htl-item"
:class="getTimelineStatusClass(task.status)"
>
<div class="htl-rail">
<span class="htl-node" />
<span v-if="idx < detailData.tasks.length - 1" class="htl-line" />
</div>
<div class="htl-body">
<div class="htl-name">{{ task.nodeName || '--' }}</div>
<div class="htl-user">{{ task.assigneeUserName || '--' }}</div>
<div class="htl-status">
<ProcessStatusTag :status="task.status || ''" />
</div>
<div v-if="task.updateTime" class="htl-time">{{ task.updateTime }}</div>
<div v-if="task.commentText" class="htl-comment">{{ task.commentText }}</div>
</div>
</div>
</div>
</div>
</div>
</template>
</div>
<template #footer>
<el-button class="btn-ghost" @click="detailVisible = false"><el-icon><Close /></el-icon>关闭</el-button>
</template>
</el-dialog>
</section>
</div>
</template>
<script setup lang="ts">
import { fetchPendingTasks, fetchInstanceDetail } from '@/api/workflow'
import ApprovalDialog from '../components/ApprovalDialog.vue'
import ProcessStatusTag from '../components/ProcessStatusTag.vue'
import { Document, EditPen, View, Search, RefreshLeft, Close } from '@element-plus/icons-vue'
defineOptions({ name: 'WorkflowTaskPending' })
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.Workflow.TaskItem[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
// 审批
const approvalVisible = ref(false)
const approvalTaskId = ref('')
const approvalInstanceId = ref('')
// 详情
const detailVisible = ref(false)
const detailLoading = ref(false)
const detailData = ref<Api.Workflow.InstanceDetail | null>(null)
async function loadData() {
loading.value = true
try {
const res = await fetchPendingTasks({
page: pagination.page,
pageSize: pagination.pageSize,
keyword: searchForm.keyword || undefined
})
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
loadData()
}
function handleReset() {
searchForm.keyword = ''
pagination.page = 1
loadData()
}
function handleApprove(row: Api.Workflow.TaskItem) {
approvalTaskId.value = row.id
approvalInstanceId.value = row.instanceId || ''
approvalVisible.value = true
}
function handleApprovalDone() {
loadData()
}
async function handleViewDetail(row: Api.Workflow.TaskItem) {
detailVisible.value = true
detailLoading.value = true
detailData.value = null
try {
const data = await fetchInstanceDetail(row.instanceId)
detailData.value = {
...data,
processName: row.processName,
businessType: row.businessType,
businessTypeLabel: row.businessTypeLabel,
businessId: row.businessId,
starterUserId: row.starterUserId,
starterUserName: row.starterUserName,
} as Api.Workflow.InstanceDetail & {
processName?: string
businessType?: string
businessTypeLabel?: string
businessId?: string
starterUserId?: string
starterUserName?: string
}
} catch {
// 错误已由全局处理
} finally {
detailLoading.value = false
}
}
function getTimelineStatusClass(status: string) {
if (['approved', 'completed'].includes(status)) return 'htl-done'
if (['running', 'pending'].includes(status)) return 'htl-active'
if (status === 'rejected') return 'htl-reject'
return 'htl-muted'
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.dialog-scroll {
overflow-y: auto;
max-height: calc(100vh - 120px);
}
.view-hero {
display: flex;
gap: 16px;
padding: 20px 22px;
background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 55%);
border-bottom: 1px solid #d9e8e2;
align-items: center;
}
.view-hero-icon {
width: 72px;
height: 72px;
border-radius: 12px;
border: 1px solid rgba(16, 185, 129, 0.2);
background: rgba(16, 185, 129, 0.08);
color: #059669;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.view-hero-main {
flex: 1;
min-width: 0;
h2 {
margin: 0 0 8px;
font-size: 18px;
font-weight: 700;
color: #1e293b;
letter-spacing: -0.02em;
}
}
.view-hero-tags {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
flex-wrap: wrap;
}
.view-hero-meta {
margin: 0;
font-size: 13px;
color: #64748b;
line-height: 1.5;
.dot {
margin: 0 6px;
opacity: 0.7;
}
}
.view-section {
padding: 18px 22px;
border-bottom: 1px solid #ebeef5;
&:last-child {
border-bottom: none;
}
h3 {
margin: 0 0 14px;
font-size: 13px;
font-weight: 700;
letter-spacing: 0.06em;
color: #64748b;
}
}
.view-kv-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px 28px;
}
.view-kv {
display: grid;
grid-template-columns: 96px 1fr;
gap: 8px 12px;
font-size: 13px;
align-items: start;
dt {
margin: 0;
color: #64748b;
font-weight: 500;
}
dd {
margin: 0;
color: #1e293b;
word-break: break-word;
}
}
@media (max-width: 640px) {
.view-kv-grid {
grid-template-columns: 1fr;
}
.view-kv {
grid-template-columns: 1fr;
gap: 4px;
}
}
/* ── horizontal timeline ── */
.htl-scroll {
overflow-x: auto;
padding: 0 0 4px 12px;
&::-webkit-scrollbar {
height: 4px;
}
&::-webkit-scrollbar-thumb {
background: #d1d5db;
border-radius: 2px;
}
}
.htl {
display: inline-flex;
min-width: 100%;
}
.htl-item {
display: flex;
flex-direction: column;
min-width: 140px;
flex: 1 0 140px;
}
/* rail: node circle + connecting line */
.htl-rail {
position: relative;
display: flex;
align-items: center;
height: 22px;
}
.htl-node {
position: relative;
z-index: 1;
width: 12px;
height: 12px;
border-radius: 50%;
flex-shrink: 0;
background: #10b981;
border: 2px solid #fff;
box-shadow: 0 0 0 1px #10b981;
}
.htl-line {
flex: 1;
height: 2px;
background: #d1d5db;
margin-left: 0;
}
.htl-body {
padding: 8px 4px 0 0;
font-size: 13px;
line-height: 1.45;
}
.htl-name {
font-weight: 600;
color: #1e293b;
margin-bottom: 2px;
}
.htl-user {
color: #64748b;
font-size: 12px;
margin-bottom: 4px;
}
.htl-status {
margin-bottom: 4px;
}
.htl-time {
font-size: 11px;
color: #94a3b8;
margin-bottom: 2px;
}
.htl-comment {
font-size: 12px;
color: #64748b;
word-break: break-word;
}
/* status variants */
.htl-active .htl-node {
background: #fff;
border: 3px solid #10b981;
box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}
.htl-reject .htl-node {
background: #ef4444;
border-color: #fff;
box-shadow: 0 0 0 1px #ef4444;
}
.htl-muted .htl-node {
background: #d1d5db;
border-color: #fff;
box-shadow: none;
}
.htl-done + .htl-active .htl-line,
.htl-done + .htl-done .htl-line {
background: #10b981;
}
.htl-active + .htl-done .htl-line {
background: #10b981;
}
</style>
<style lang="scss">
.workflow-module-dialog {
.el-dialog__header {
display: none;
}
.el-dialog__body {
padding: 0;
overflow: hidden;
}
.el-dialog__footer {
padding: 12px 22px;
border-top: 1px solid #d9e8e2;
background: #f8fafc;
}
}
</style>