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

+1 -1
View File
@@ -78,7 +78,7 @@
const panelTitleClassList = panelTitleIconByText.map(([, cls]) => cls)
const panelTitleBarClass = 'title-bar-heading'
const panelTitleBarTextRules: RegExp[] = [
/(数据概览|快捷菜单|分类列表|单位列表|商品列表|参数列表|用户列表|租户列表|区域列表|区域与询报价概览|报价管理|订单列表|最新订单|待结算订单|结算单记录|配送任务列表|预警列表|订单设置|客服设置|请求列表|近30日趋势|今日各区域|组织|组织管理|角色列表|菜单列表|字典类型|字典数据|站点列表|职位列表|快递公司列表)/
/(数据概览|快捷菜单|分类列表|单位列表|商品列表|参数列表|用户列表|租户列表|区域列表|区域与询报价概览|报价管理|订单列表|最新订单|待结算订单|结算单记录|配送任务列表|预警列表|订单设置|客服设置|请求列表|近30日趋势|今日各区域|组织|组织管理|角色列表|菜单列表|字典类型|字典数据|站点列表|职位列表|快递公司列表|流程配置|流程列表|待办列表|已办列表|申请列表|客户列表|细胞样本类型列表|采集地区列表|采集协议号列表|样本编码列表|医院列表|协议单列表|审核记录列表|收款确认列表|退费确认列表|分期预警列表|请假列表|洁净室列表|库位树|预约列表)/
]
const refreshPanelTitleIcons = () => {
+555 -31
View File
@@ -1,5 +1,6 @@
import request from '@/utils/http'
import type { AppRouteRecord } from '@/types/router'
import { MAX_ADMIN_LIST_PAGE_SIZE } from '@/utils/fetch-paged-list'
// ---------------------------------------------------------------------------
// 后端菜单 / 角色(与 router 后端模式、用户弹窗对齐)
@@ -21,6 +22,20 @@ export function fetchGetRoleList() {
})
}
/** 流程设计器:用户下拉选项(label=昵称,value=用户ID) */
export function fetchUserOptions() {
return request.get<Array<{ label: string; value: string }>>({
url: '/web/admin/users/options'
})
}
/** 流程设计器:角色下拉选项(label=角色名,value=角色ID UUID) */
export function fetchRoleOptions() {
return request.get<Array<{ label: string; value: string }>>({
url: '/web/admin/roles/options'
})
}
// ---------------------------------------------------------------------------
// 租户(系统管理)
// ---------------------------------------------------------------------------
@@ -219,7 +234,7 @@ export async function fetchNotDeletedRegions() {
const cache = anyFn.__cache as undefined | { ts: number; data: Api.Region.RegionItem[] }
if (cache && now - cache.ts < 5 * 60 * 1000) return cache.data
const pageSize = 100
const pageSize = MAX_ADMIN_LIST_PAGE_SIZE
const all: Api.Region.RegionItem[] = []
let page = 1
@@ -450,14 +465,20 @@ export function fetchProductBannerList(productId: string) {
})
}
export function fetchCreateProductBanners(productId: string, items: Api.Product.ProductBannerCreate[]) {
export function fetchCreateProductBanners(
productId: string,
items: Api.Product.ProductBannerCreate[]
) {
return request.post({
url: `/web/admin/product-banners/product/${productId}`,
params: items
})
}
export function fetchUpdateProductBannerSort(productId: string, items: { id: string; sortOrder: number }[]) {
export function fetchUpdateProductBannerSort(
productId: string,
items: { id: string; sortOrder: number }[]
) {
return request.put({
url: `/web/admin/product-banners/product/${productId}/sort`,
params: { items }
@@ -491,7 +512,10 @@ export function fetchCreateProductDetailMedia(
})
}
export function fetchUpdateProductDetailMediaSort(productId: string, items: { id: string; sortOrder: number }[]) {
export function fetchUpdateProductDetailMediaSort(
productId: string,
items: { id: string; sortOrder: number }[]
) {
return request.put({
url: `/web/admin/product-detail-media/product/${productId}/sort`,
params: { items }
@@ -526,7 +550,10 @@ export function fetchCategoryParameters(categoryId: string) {
})
}
export function fetchUpdateCategoryParameters(categoryId: string, items: Api.Product.CategoryParameterCreate[]) {
export function fetchUpdateCategoryParameters(
categoryId: string,
items: Api.Product.CategoryParameterCreate[]
) {
return request.put({
url: `/web/admin/categories/${categoryId}/parameters`,
params: { items }
@@ -558,11 +585,7 @@ export function fetchSaveProductParameterValues(
// 字典类型
// ---------------------------------------------------------------------------
export function fetchDictTypeList(params?: {
page?: number
pageSize?: number
keyword?: string
}) {
export function fetchDictTypeList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get<{
list: Api.Dict.DictTypeItem[]
total: number
@@ -703,12 +726,43 @@ export function fetchDeleteDept(id: string) {
// ---------------------------------------------------------------------------
export function fetchSiteList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get<{ list: Api.Site.SiteItem[]; total: number; page: number; pageSize: number; totalPages: number }>({ url: '/web/admin/sites', params })
return request.get<{
list: Api.Site.SiteItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({ url: '/web/admin/sites', params })
}
export function fetchCreateSite(data: { siteName: string; siteCode: string; siteType?: string; status?: string; address?: string; contactName?: string; contactPhone?: string; businessScope?: string; orderNum?: number; remark?: string }) {
export function fetchCreateSite(data: {
siteName: string
siteCode: string
siteType?: string
status?: string
address?: string
contactName?: string
contactPhone?: string
businessScope?: string
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/sites', params: data })
}
export function fetchUpdateSite(id: string, data: Partial<{ siteName: string; siteCode: string; siteType: string; status: string; address: string; contactName: string; contactPhone: string; businessScope: string; orderNum: number; remark: string }>) {
export function fetchUpdateSite(
id: string,
data: Partial<{
siteName: string
siteCode: string
siteType: string
status: string
address: string
contactName: string
contactPhone: string
businessScope: string
orderNum: number
remark: string
}>
) {
return request.put({ url: `/web/admin/sites/${id}`, params: data })
}
export function fetchDeleteSite(id: string) {
@@ -720,46 +774,381 @@ export function fetchDeleteSite(id: string) {
// ---------------------------------------------------------------------------
export function fetchPostList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get<{ list: Api.Post.PostItem[]; total: number; page: number; pageSize: number; totalPages: number }>({ url: '/web/admin/posts', params })
return request.get<{
list: Api.Post.PostItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({ url: '/web/admin/posts', params })
}
export function fetchCreatePost(data: { postName: string; postCode: string; status?: string; orderNum?: number; remark?: string }) {
export function fetchCreatePost(data: {
postName: string
postCode: string
status?: string
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/posts', params: data })
}
export function fetchUpdatePost(id: string, data: Partial<{ postName: string; postCode: string; status: string; orderNum: number; remark: string }>) {
export function fetchUpdatePost(
id: string,
data: Partial<{
postName: string
postCode: string
status: string
orderNum: number
remark: string
}>
) {
return request.put({ url: `/web/admin/posts/${id}`, params: data })
}
export function fetchDeletePost(id: string) {
return request.del({ url: `/web/admin/posts/${id}` })
}
export function fetchPostBoundUserIds(postId: string) {
return request.get<{ userIds: string[] }>({ url: `/web/admin/posts/${postId}/users` })
}
export function fetchUpdatePostBoundUsers(postId: string, userIds: string[]) {
return request.put({
url: `/web/admin/posts/${postId}/users`,
params: { userIds },
showSuccessMessage: true
})
}
// ---------------------------------------------------------------------------
// 物品单位管理
// ---------------------------------------------------------------------------
export function fetchItemUnitList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get<{ list: Api.ItemUnit.ItemUnitItem[]; total: number; page: number; pageSize: number; totalPages: number }>({ url: '/web/admin/item-units', params })
return request.get<{
list: Api.ItemUnit.ItemUnitItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({ url: '/web/admin/item-units', params })
}
export function fetchCreateItemUnit(data: { unitCode: string; unitName: string; orderNum?: number; remark?: string }) {
export function fetchCreateItemUnit(data: {
unitCode: string
unitName: string
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/item-units', params: data })
}
export function fetchUpdateItemUnit(id: string, data: Partial<{ unitCode: string; unitName: string; orderNum: number; remark: string }>) {
export function fetchUpdateItemUnit(
id: string,
data: Partial<{ unitCode: string; unitName: string; orderNum: number; remark: string }>
) {
return request.put({ url: `/web/admin/item-units/${id}`, params: data })
}
export function fetchDeleteItemUnit(id: string) {
return request.del({ url: `/web/admin/item-units/${id}` })
}
// ---------------------------------------------------------------------------
// 基础信息管理
// ---------------------------------------------------------------------------
type PageResult<T> = {
list: T[]
total: number
page: number
pageSize: number
totalPages: number
}
export function fetchCustomerList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get<PageResult<Api.BizCustomer.CustomerItem>>({
url: '/web/admin/customers',
params
})
}
export function fetchCreateCustomer(data: {
customerName: string
sex?: string
idCardNo?: string
age?: number | null
phoneNo?: string
customerTags?: string
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/customers', params: data })
}
export function fetchUpdateCustomer(
id: string,
data: Partial<{
customerName: string
sex: string
idCardNo: string
age: number | null
phoneNo: string
customerTags: string
orderNum: number
remark: string
}>
) {
return request.put({ url: `/web/admin/customers/${id}`, params: data })
}
export function fetchDeleteCustomer(id: string) {
return request.del({ url: `/web/admin/customers/${id}` })
}
export function fetchCellSampleTypeList(params?: {
page?: number
pageSize?: number
keyword?: string
}) {
return request.get<PageResult<Api.BizCellSampleType.CellSampleTypeItem>>({
url: '/web/admin/cell-sample-types',
params
})
}
export function fetchCreateCellSampleType(data: {
typeCode: string
typeName: string
storageYears?: number | null
storagePrice?: number | null
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/cell-sample-types', params: data })
}
export function fetchUpdateCellSampleType(
id: string,
data: Partial<{
typeCode: string
typeName: string
storageYears: number | null
storagePrice: number | null
orderNum: number
remark: string
}>
) {
return request.put({ url: `/web/admin/cell-sample-types/${id}`, params: data })
}
export function fetchDeleteCellSampleType(id: string) {
return request.del({ url: `/web/admin/cell-sample-types/${id}` })
}
export function fetchCollectionRegionList(params?: {
page?: number
pageSize?: number
keyword?: string
}) {
return request.get<PageResult<Api.BizCollectionRegion.RegionItem>>({
url: '/web/admin/collection-regions',
params
})
}
export function fetchCreateCollectionRegion(data: {
regionName: string
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/collection-regions', params: data })
}
export function fetchUpdateCollectionRegion(
id: string,
data: Partial<{ regionName: string; orderNum: number; remark: string }>
) {
return request.put({ url: `/web/admin/collection-regions/${id}`, params: data })
}
export function fetchDeleteCollectionRegion(id: string) {
return request.del({ url: `/web/admin/collection-regions/${id}` })
}
export function fetchHospitalList(
regionId: string,
params?: { page?: number; pageSize?: number; keyword?: string }
) {
return request.get<PageResult<Api.BizCollectionHospital.HospitalItem>>({
url: `/web/admin/collection-regions/${regionId}/hospitals`,
params
})
}
export function fetchCreateHospital(
regionId: string,
data: { hospitalName: string; orderNum?: number; remark?: string }
) {
return request.post({ url: `/web/admin/collection-regions/${regionId}/hospitals`, params: data })
}
export function fetchUpdateHospital(
regionId: string,
hospitalId: string,
data: Partial<{ hospitalName: string; orderNum: number; remark: string }>
) {
return request.put({
url: `/web/admin/collection-regions/${regionId}/hospitals/${hospitalId}`,
params: data
})
}
export function fetchDeleteHospital(regionId: string, hospitalId: string) {
return request.del({ url: `/web/admin/collection-regions/${regionId}/hospitals/${hospitalId}` })
}
export function fetchCollectionProtocolNoList(params?: {
page?: number
pageSize?: number
keyword?: string
}) {
return request.get<PageResult<Api.BizCollectionProtocolNo.ProtocolNoItem>>({
url: '/web/admin/collection-protocol-nos',
params
})
}
export function fetchCreateCollectionProtocolNo(data: {
protocolNo: string
issued?: number
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/collection-protocol-nos', params: data })
}
export function fetchUpdateCollectionProtocolNo(
id: string,
data: Partial<{ protocolNo: string; issued: number; orderNum: number; remark: string }>
) {
return request.put({ url: `/web/admin/collection-protocol-nos/${id}`, params: data })
}
export function fetchDeleteCollectionProtocolNo(id: string) {
return request.del({ url: `/web/admin/collection-protocol-nos/${id}` })
}
export function fetchBatchGenerateProtocolNos(data: {
prefix: string
middle: string
seqStart: number
seqEnd: number
digitCount?: number
}) {
return request.post({
url: '/web/admin/collection-protocol-nos/batch-generate',
params: data,
showSuccessMessage: true,
timeout: 120_000
})
}
export function fetchBatchIssueProtocolNos(data: {
ids: string[]
issuedUserId: string
issuedUserName?: string
}) {
return request.post({
url: '/web/admin/collection-protocol-nos/batch-issue',
params: data,
showSuccessMessage: true,
timeout: 120_000
})
}
export function fetchBatchRevokeProtocolNos(ids: string[]) {
return request.post({
url: '/web/admin/collection-protocol-nos/batch-revoke',
params: { ids },
showSuccessMessage: true,
timeout: 120_000
})
}
export function fetchSampleCodeList(params?: {
page?: number
pageSize?: number
keyword?: string
}) {
return request.get<PageResult<Api.BizSampleCode.SampleCodeItem>>({
url: '/web/admin/sample-codes',
params
})
}
export function fetchCreateSampleCode(data: {
sampleCode: string
issued?: number
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/sample-codes', params: data })
}
export function fetchUpdateSampleCode(
id: string,
data: Partial<{ sampleCode: string; issued: number; orderNum: number; remark: string }>
) {
return request.put({ url: `/web/admin/sample-codes/${id}`, params: data })
}
export function fetchDeleteSampleCode(id: string) {
return request.del({ url: `/web/admin/sample-codes/${id}` })
}
export function fetchBatchGenerateSampleCodes(data: {
sampleCodeType: string
middle: string
seqStart: number
seqEnd: number
digitCount?: number
}) {
return request.post({
url: '/web/admin/sample-codes/batch-generate',
params: data,
showSuccessMessage: true,
timeout: 120_000
})
}
export function fetchBatchIssueSampleCodes(data: {
ids: string[]
issuedUserId: string
issuedUserName?: string
}) {
return request.post({
url: '/web/admin/sample-codes/batch-issue',
params: data,
showSuccessMessage: true,
timeout: 120_000
})
}
export function fetchBatchRevokeSampleCodes(ids: string[]) {
return request.post({
url: '/web/admin/sample-codes/batch-revoke',
params: { ids },
showSuccessMessage: true,
timeout: 120_000
})
}
// ---------------------------------------------------------------------------
// 快递公司管理
// ---------------------------------------------------------------------------
export function fetchExpressCompanyList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get<{ list: Api.ExpressCompany.ExpressCompanyItem[]; total: number; page: number; pageSize: number; totalPages: number }>({ url: '/web/admin/express-companies', params })
export function fetchExpressCompanyList(params?: {
page?: number
pageSize?: number
keyword?: string
}) {
return request.get<{
list: Api.ExpressCompany.ExpressCompanyItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({ url: '/web/admin/express-companies', params })
}
export function fetchCreateExpressCompany(data: { expressCode: string; expressName: string; orderNum?: number; remark?: string }) {
export function fetchCreateExpressCompany(data: {
expressCode: string
expressName: string
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/express-companies', params: data })
}
export function fetchUpdateExpressCompany(id: string, data: Partial<{ expressCode: string; expressName: string; orderNum: number; remark: string }>) {
export function fetchUpdateExpressCompany(
id: string,
data: Partial<{ expressCode: string; expressName: string; orderNum: number; remark: string }>
) {
return request.put({ url: `/web/admin/express-companies/${id}`, params: data })
}
export function fetchDeleteExpressCompany(id: string) {
@@ -821,13 +1210,38 @@ export function fetchDeleteMenu(id: string) {
// ---------------------------------------------------------------------------
export function fetchRoleList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get<{ list: Api.Role.RoleItem[]; total: number; page: number; pageSize: number; totalPages: number }>({ url: '/web/admin/role-management', params })
return request.get<{
list: Api.Role.RoleItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({ url: '/web/admin/role-management', params })
}
export function fetchCreateRole(data: { roleName: string; dataScope?: string; status?: string; orderNum?: number; remark?: string }) {
export function fetchCreateRole(data: {
roleName: string
dataScope?: string
status?: string
orderNum?: number
remark?: string
}) {
return request.post({ url: '/web/admin/role-management', params: data, showSuccessMessage: true })
}
export function fetchUpdateRole(id: string, data: Partial<{ roleName: string; dataScope: string; status: string; orderNum: number; remark: string }>) {
return request.put({ url: `/web/admin/role-management/${id}`, params: data, showSuccessMessage: true })
export function fetchUpdateRole(
id: string,
data: Partial<{
roleName: string
dataScope: string
status: string
orderNum: number
remark: string
}>
) {
return request.put({
url: `/web/admin/role-management/${id}`,
params: data,
showSuccessMessage: true
})
}
export function fetchDeleteRole(id: string) {
return request.del({ url: `/web/admin/role-management/${id}`, showSuccessMessage: true })
@@ -836,11 +1250,121 @@ export function fetchRoleMenuIds(roleId: string) {
return request.get<{ menuIds: string[] }>({ url: `/web/admin/role-management/${roleId}/menus` })
}
export function fetchUpdateRoleMenus(roleId: string, menuIds: string[]) {
return request.put({ url: `/web/admin/role-management/${roleId}/menus`, params: { menuIds }, showSuccessMessage: true })
return request.put({
url: `/web/admin/role-management/${roleId}/menus`,
params: { menuIds },
showSuccessMessage: true
})
}
export function fetchRoleDataScope(roleId: string) {
return request.get<{ dataScope: string; scopeDetails: Array<{ scopeType: string; scopeValue: string }> }>({ url: `/web/admin/role-management/${roleId}/data-scope` })
return request.get<{
dataScope: string
scopeDetails: Array<{ scopeType: string; scopeValue: string }>
}>({ url: `/web/admin/role-management/${roleId}/data-scope` })
}
export function fetchUpdateRoleDataScope(roleId: string, data: { dataScope: string; scopeDetails?: Array<{ scopeType: string; scopeValue: string }> }) {
return request.put({ url: `/web/admin/role-management/${roleId}/data-scope`, params: data, showSuccessMessage: true })
export function fetchUpdateRoleDataScope(
roleId: string,
data: { dataScope: string; scopeDetails?: Array<{ scopeType: string; scopeValue: string }> }
) {
return request.put({
url: `/web/admin/role-management/${roleId}/data-scope`,
params: data,
showSuccessMessage: true
})
}
// ---------------------------------------------------------------------------
// 洁净室管理
// ---------------------------------------------------------------------------
export function fetchCleanRoomList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get({ url: '/web/admin/clean-rooms', params })
}
export function fetchCreateCleanRoom(data: Record<string, any>) {
return request.post({ url: '/web/admin/clean-rooms', params: data })
}
export function fetchUpdateCleanRoom(id: string, data: Record<string, any>) {
return request.put({ url: `/web/admin/clean-rooms/${id}`, params: data })
}
export function fetchDeleteCleanRoom(id: string) {
return request.del({ url: `/web/admin/clean-rooms/${id}` })
}
export function fetchAccessLogList(params?: { page?: number; pageSize?: number; cleanRoomId?: string; keyword?: string }) {
return request.get({ url: '/web/admin/clean-room-access-logs', params })
}
export function fetchCreateAccessLog(data: Record<string, any>) {
return request.post({ url: '/web/admin/clean-room-access-logs', params: data })
}
export function fetchUpdateAccessLog(id: string, data: Record<string, any>) {
return request.put({ url: `/web/admin/clean-room-access-logs/${id}`, params: data })
}
export function fetchDeleteAccessLog(id: string) {
return request.del({ url: `/web/admin/clean-room-access-logs/${id}` })
}
// ---------------------------------------------------------------------------
// 库位管理
// ---------------------------------------------------------------------------
export function fetchStorageFacilityList(params?: { keyword?: string }) {
return request.get({ url: '/web/admin/storage-facilities', params })
}
export function fetchCreateStorageFacility(data: Record<string, any>) {
return request.post({ url: '/web/admin/storage-facilities', params: data })
}
export function fetchUpdateStorageFacility(id: string, data: Record<string, any>) {
return request.put({ url: `/web/admin/storage-facilities/${id}`, params: data })
}
export function fetchDeleteStorageFacility(id: string) {
return request.del({ url: `/web/admin/storage-facilities/${id}` })
}
export function fetchStorageSlotList(params?: { facilityNodeId?: string }) {
return request.get({ url: '/web/admin/storage-facility-slots', params })
}
export function fetchCreateStorageSlot(data: Record<string, any>) {
return request.post({ url: '/web/admin/storage-facility-slots', params: data })
}
export function fetchBatchCreateSlots(data: { facilityNodeId: string; rows: number; cols: number; codePrefix?: string }) {
return request.post({ url: '/web/admin/storage-facility-slots/batch', params: data })
}
export function fetchUpdateStorageSlot(id: string, data: Record<string, any>) {
return request.put({ url: `/web/admin/storage-facility-slots/${id}`, params: data })
}
export function fetchDeleteStorageSlot(id: string) {
return request.del({ url: `/web/admin/storage-facility-slots/${id}` })
}
// ---------------------------------------------------------------------------
// 展馆预约
// ---------------------------------------------------------------------------
export function fetchExhibitionAppointmentList(params?: { page?: number; pageSize?: number; keyword?: string }) {
return request.get({ url: '/web/admin/exhibition-appointments', params })
}
export function fetchCreateExhibitionAppointment(data: Record<string, any>) {
return request.post({ url: '/web/admin/exhibition-appointments', params: data })
}
export function fetchUpdateExhibitionAppointment(id: string, data: Record<string, any>) {
return request.put({ url: `/web/admin/exhibition-appointments/${id}`, params: data })
}
export function fetchDeleteExhibitionAppointment(id: string) {
return request.del({ url: `/web/admin/exhibition-appointments/${id}` })
}
+134
View File
@@ -0,0 +1,134 @@
import request from '@/utils/http'
type PageList<T> = {
list: T[]
total: number
page: number
pageSize: number
totalPages: number
}
/** 采集协议单列表项(camelCase,与后端一致) */
export type CollectionProtocolRow = Record<string, unknown>
export function fetchCollectionProtocolList(params?: {
page?: number
pageSize?: number
keyword?: string
protocolStatus?: string
}) {
return request.get<PageList<CollectionProtocolRow>>({
url: '/web/admin/collection-protocols',
params
})
}
export function fetchCollectionProtocolDetail(id: string) {
return request.get<{
protocol: Record<string, unknown>
partyCustomer: Record<string, unknown> | null
collectionInfo: Record<string, unknown> | null
samples: Array<Record<string, unknown>> | null
payment: Record<string, unknown> | null
paymentDetails: Array<Record<string, unknown>> | null
attachments?: Array<Record<string, unknown>>
}>({
url: `/web/admin/collection-protocols/${id}`
})
}
export function fetchCollectionProtocolAuditList(params?: {
page?: number
pageSize?: number
keyword?: string
auditStatus?: string
}) {
return request.get<PageList<Record<string, unknown>>>({
url: '/web/admin/collection-protocol-audits',
params
})
}
export function fetchSubmitProtocolAudit(
protocolId: string,
data: { auditStatus: string; auditRemark?: string }
) {
return request.post({
url: `/web/admin/collection-protocols/${protocolId}/audit`,
data,
showSuccessMessage: true
})
}
export function fetchReceiptConfirmList(params?: { page?: number; pageSize?: number }) {
return request.get<PageList<Record<string, unknown>>>({
url: '/web/admin/protocol-payment-details/receipt-confirm',
params
})
}
export function fetchReceiptConfirmSubmit(
detailId: string,
data?: { financeConfirmAttachments?: string }
) {
return request.post({
url: `/web/admin/protocol-payment-details/${detailId}/receipt-confirm`,
data: data || {},
showSuccessMessage: true
})
}
export function fetchRefundConfirmList(params?: { page?: number; pageSize?: number }) {
return request.get<PageList<Record<string, unknown>>>({
url: '/web/admin/protocol-payment-details/refund-confirm',
params
})
}
export function fetchRefundConfirmSubmit(
detailId: string,
data?: { financeConfirmAttachments?: string }
) {
return request.post({
url: `/web/admin/protocol-payment-details/${detailId}/refund-confirm`,
data: data || {},
showSuccessMessage: true
})
}
export function fetchInstallmentWarningList(params?: {
page?: number
pageSize?: number
warningType?: string
}) {
return request.get<PageList<Record<string, unknown>>>({
url: '/web/admin/protocol-payment-details/installment-warning',
params
})
}
export function fetchCreateCollectionProtocol(data: Record<string, unknown>) {
return request.post({
url: '/web/admin/collection-protocols',
data,
showSuccessMessage: true
})
}
export function fetchUpdateCollectionProtocol(
id: string,
data: Record<string, unknown>
) {
return request.put({
url: `/web/admin/collection-protocols/${id}`,
data,
showSuccessMessage: true
})
}
export function fetchDeleteCollectionProtocol(id: string) {
return request.del({
url: `/web/admin/collection-protocols/${id}`,
showSuccessMessage: true
})
}
+15
View File
@@ -0,0 +1,15 @@
import request from '@/utils/http'
export type EthnicOption = {
id: string
ethnicName: string
ethnicCode: string
orderNum?: number | null
}
export function fetchEthnicList(params?: { keyword?: string; limit?: number }) {
return request.get<{ list: EthnicOption[] }>({
url: '/web/admin/ethnics',
params
})
}
+78
View File
@@ -0,0 +1,78 @@
import request from '@/utils/http'
/** 请假申请列表 */
export function fetchLeaveList(params?: {
page?: number
pageSize?: number
keyword?: string
status?: string
}) {
return request.get<{
list: Api.Leave.LeaveItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({
url: '/web/admin/leave',
params
})
}
/** 创建请假申请 */
export function fetchCreateLeave(data: {
leaveType: string
startDate: string
endDate: string
days: number
reason?: string
remark?: string
}) {
return request.post<Api.Leave.LeaveItem>({
url: '/web/admin/leave',
data,
showSuccessMessage: true
})
}
/** 编辑请假申请 */
export function fetchUpdateLeave(
id: string,
data: Partial<{
leaveType: string
startDate: string
endDate: string
days: number
reason: string
remark: string
}>
) {
return request.put<Api.Leave.LeaveItem>({
url: `/web/admin/leave/${id}`,
data,
showSuccessMessage: true
})
}
/** 删除请假申请 */
export function fetchDeleteLeave(id: string) {
return request.del({
url: `/web/admin/leave/${id}`,
showSuccessMessage: true
})
}
/** 提交请假申请并发起审批 */
export function fetchSubmitLeave(id: string) {
return request.post<{ instanceId: string; status: string }>({
url: `/web/admin/leave/${id}/submit`,
showSuccessMessage: true
})
}
/** 请假详情 */
export function fetchLeaveDetail(id: string) {
return request.get<Api.Leave.LeaveItem>({
url: `/web/admin/leave/${id}`
})
}
+206
View File
@@ -0,0 +1,206 @@
import request from '@/utils/http'
// ---------------------------------------------------------------------------
// 流程定义
// ---------------------------------------------------------------------------
export function fetchProcessDefList(params?: {
page?: number
pageSize?: number
keyword?: string
status?: string
}) {
return request.get<{
list: Api.Workflow.ProcessDefItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({
url: '/web/admin/workflow/defs',
params
})
}
export function fetchCreateProcessDef(data: {
processCode: string
processName: string
status?: string
orderNum?: number
remark?: string
}) {
return request.post<Api.Workflow.ProcessDefItem>({
url: '/web/admin/workflow/defs',
data,
showSuccessMessage: true
})
}
export function fetchUpdateProcessDef(
id: string,
data: Partial<{
processCode: string
processName: string
status: string
orderNum: number
remark: string
}>
) {
return request.put<Api.Workflow.ProcessDefItem>({
url: `/web/admin/workflow/defs/${id}`,
data,
showSuccessMessage: true
})
}
export function fetchDeleteProcessDef(id: string) {
return request.del({
url: `/web/admin/workflow/defs/${id}`,
showSuccessMessage: true
})
}
// ---------------------------------------------------------------------------
// 发布版本
// ---------------------------------------------------------------------------
export function fetchPublishVersion(
defId: string,
data: {
graphJson: string
nodes: Array<{
nodeKey: string
nodeType: string
nodeName?: string | null
configJson?: string | null
}>
transitions: Array<{
fromNodeKey: string
toNodeKey: string
conditionExpr?: string | null
}>
remark?: string
}
) {
return request.post({
url: `/web/admin/workflow/defs/${defId}/publish`,
data,
})
}
export function fetchVersionList(defId: string) {
return request.get<Api.Workflow.VersionItem[]>({
url: `/web/admin/workflow/defs/${defId}/versions`
})
}
// ---------------------------------------------------------------------------
// 设计器数据
// ---------------------------------------------------------------------------
export function fetchDesignerData(defId: string) {
return request.get<Api.Workflow.DesignerData>({
url: `/web/admin/workflow/defs/${defId}/designer`
})
}
// ---------------------------------------------------------------------------
// 流程实例
// ---------------------------------------------------------------------------
export function fetchStartInstance(data: {
processCode: string
businessType?: string
businessId?: string
variables?: Record<string, any>
callbackUrl?: string
}) {
return request.post<{ instanceId: string }>({
url: '/web/admin/workflow/instances',
data
})
}
export function fetchInstanceDetail(instanceId: string) {
return request.get<Api.Workflow.InstanceDetail>({
url: `/web/admin/workflow/instances/${instanceId}`
})
}
// ---------------------------------------------------------------------------
// 任务办理
// ---------------------------------------------------------------------------
export function fetchPendingTasks(params?: {
page?: number
pageSize?: number
keyword?: string
}) {
return request.get<{
list: Api.Workflow.TaskItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({
url: '/web/admin/workflow/tasks/pending',
params
})
}
export function fetchCompletedTasks(params?: {
page?: number
pageSize?: number
keyword?: string
}) {
return request.get<{
list: Api.Workflow.TaskItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({
url: '/web/admin/workflow/tasks/completed',
params
})
}
export function fetchApproveTask(taskId: string, data?: { commentText?: string }) {
return request.post({
url: `/web/admin/workflow/tasks/${taskId}/approve`,
data,
showSuccessMessage: true
})
}
export function fetchRejectTask(taskId: string, data?: { commentText?: string }) {
return request.post({
url: `/web/admin/workflow/tasks/${taskId}/reject`,
data,
showSuccessMessage: true
})
}
export function fetchMyInstances(params?: {
page?: number
pageSize?: number
keyword?: string
status?: string
}) {
return request.get<{
list: Api.Workflow.MyInstanceItem[]
total: number
page: number
pageSize: number
totalPages: number
}>({
url: '/web/admin/workflow/instances/my',
params
})
}
export function fetchBusinessAllTasks(businessType: string, businessId: string) {
return request.get<Api.Workflow.BusinessAllTasks>({
url: `/web/admin/workflow/instances/by-business/${businessType}/${businessId}`
})
}
+10 -1
View File
@@ -548,6 +548,7 @@ body {
padding: 10px 16px 12px;
border-top: 1px solid var(--mint-border);
background: var(--mint-surface);
border-radius: 0 0 var(--mint-radius) var(--mint-radius);
}
.pagination {
@@ -657,6 +658,13 @@ body {
font-size: 12px;
}
.form-label-tip {
margin-left: 4px;
color: var(--mint-text-muted);
font-size: 12px;
font-weight: 400;
}
@media (max-width: 900px) {
.form-grid-3 {
grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -714,7 +722,8 @@ body {
gap: 10px !important;
}
#app-header .flex-b.w-full {
#app-header .flex-b.w-full,
#app-header .worktab-strip.w-full {
margin-bottom: 0 !important;
padding: 0 24px 10px !important;
}
@@ -1,12 +1,13 @@
// https://github.com/element-plus/element-plus/blob/dev/packages/theme-chalk/src/common/var.scss
// 自定义Element 亮色主题
// success 与 Fresh Mint 主色一致(见 fresh-mint-tokens.scss --mint-primary),便于 Message/Tag/Button 等语义统一
@forward 'element-plus/theme-chalk/src/common/var.scss' with (
$colors: (
'white': #ffffff,
'black': #000000,
'success': (
'base': #13deb9
'base': #10b981
),
'warning': (
'base': #ffae1f
@@ -50,6 +50,14 @@
line-height: var(--el-component-custom-height) !important;
}
// label-top 弹窗表单:13px 深色标签
.el-form--label-top .el-form-item__label {
font-size: 13px !important;
font-weight: 500 !important;
color: var(--mint-text) !important;
padding: 0 0 4px !important;
}
// 日期选择器
.el-date-range-picker {
--el-datepicker-inrange-bg-color: var(--art-gray-200) !important;
@@ -636,16 +644,37 @@ body .el-table thead {
}
// 全局:列表表格内容居中展示(表头 + 单元格)
// 列上设置 align / header-align 时,Element Plus 会加 is-left、is-right,须高于默认居中
.el-table {
th.el-table__cell,
td.el-table__cell {
text-align: center;
}
th.el-table__cell.is-left,
td.el-table__cell.is-left {
text-align: left;
}
th.el-table__cell.is-right,
td.el-table__cell.is-right {
text-align: right;
}
th.el-table__cell > .cell,
td.el-table__cell > .cell {
justify-content: center;
}
th.el-table__cell.is-left > .cell,
td.el-table__cell.is-left > .cell {
justify-content: flex-start;
}
th.el-table__cell.is-right > .cell,
td.el-table__cell.is-right > .cell {
justify-content: flex-end;
}
}
// -------------------------------- el-table 全局样式 end --------------------------------
@@ -800,6 +829,31 @@ body .el-table thead {
.el-cascader__suggestion-panel,
.el-tree-select__popper {
--el-text-color-placeholder: #9ca3af !important;
--el-select-multiple-input-color: #9ca3af !important;
}
/* 已选中值(placeholder 无 is-transparent):保持正文深色 */
.page-container .el-select__placeholder:not(.is-transparent),
.console-container .el-select__placeholder:not(.is-transparent),
.el-select__placeholder:not(.is-transparent) {
color: var(--mint-text) !important;
-webkit-text-fill-color: var(--mint-text) !important;
}
/* 已选值:必须保持正文深色,确保在 page-container / console-container 作用域下也正确 */
.page-container .el-select .el-select__selected-item,
.console-container .el-select .el-select__selected-item,
.el-select .el-select__selected-item {
color: var(--mint-text) !important;
-webkit-text-fill-color: var(--mint-text) !important;
}
/* 未选中时 placeholder(is-transparent)应为灰色,区别于已选值 */
.page-container .el-select__placeholder.is-transparent,
.console-container .el-select__placeholder.is-transparent,
.el-select__placeholder.is-transparent {
color: #9ca3af !important;
-webkit-text-fill-color: #9ca3af !important;
}
// 兜底:页面内原生 input/textarea placeholder(避免自绘控件不走 Element)
@@ -0,0 +1,211 @@
<!-- 通用查看弹窗 —— 样式对齐待办中心「查看详情」 -->
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<el-dialog
v-model="innerVisible"
width="720px"
class="system-view-dialog"
align-center
destroy-on-close
:show-close="false"
style="backdrop-filter: none"
>
<div class="dialog-scroll">
<!-- hero -->
<div class="view-hero">
<div class="view-hero-icon">
<el-icon :size="28"><component :is="iconComponent" /></el-icon>
</div>
<div class="view-hero-main">
<h2>{{ title }}</h2>
<p v-if="meta" class="view-hero-meta">{{ meta }}</p>
</div>
</div>
<!-- sections -->
<div v-for="section in sections" :key="section.title" class="view-section">
<h3>{{ section.title }}</h3>
<dl class="view-kv-grid">
<div
v-for="field in section.fields"
:key="field.label"
class="view-kv"
:class="{ 'view-kv-span-2': field.span }"
>
<dt>{{ field.label }}</dt>
<dd>{{ field.value ?? '—' }}</dd>
</div>
</dl>
</div>
</div>
<template #footer>
<el-button class="btn-ghost" @click="innerVisible = false">
<el-icon><Close /></el-icon>关闭
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { computed, type Component } from 'vue'
import { Close } from '@element-plus/icons-vue'
export interface ViewField {
label: string
value: string | number | boolean | null | undefined
span?: boolean
}
export interface ViewSection {
title: string
fields: ViewField[]
}
const props = defineProps<{
visible: boolean
title: string
icon?: Component
meta?: string
sections: ViewSection[]
}>()
const emit = defineEmits<{
(e: 'update:visible', val: boolean): void
}>()
const innerVisible = computed({
get: () => props.visible,
set: (val) => emit('update:visible', val)
})
const iconComponent = computed(() => props.icon || (() => null))
</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-meta {
margin: 0;
font-size: 13px;
color: #64748b;
line-height: 1.5;
}
.view-section {
padding: 18px 22px;
border-bottom: 1px solid #ebeef5;
&:last-child {
border-bottom: none;
}
h3 {
margin: 0 0 14px;
padding-left: 10px;
font-size: 14px;
font-weight: 600;
color: #1e293b;
border-left: 3px solid #10b981;
line-height: 1;
}
}
.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;
}
}
.view-kv-span-2 {
grid-column: 1 / -1;
}
@media (max-width: 640px) {
.view-kv-grid {
grid-template-columns: 1fr;
}
.view-kv {
grid-template-columns: 1fr;
gap: 4px;
}
}
</style>
<style lang="scss">
.system-view-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>
@@ -107,7 +107,6 @@
ElDatePicker,
ElInput,
ElInputTag,
ElInputNumber,
ElRadioGroup,
ElRate,
ElSelect,
@@ -125,7 +124,7 @@
const componentMap = {
input: ElInput, // 输入框
inputtag: ElInputTag, // 标签输入框
number: ElInputNumber, // 数字输入框
number: ElInput, // 数字输入框
select: ElSelect, // 选择器
switch: ElSwitch, // 开关
checkbox: ElCheckbox, // 复选框
@@ -414,9 +413,22 @@
}
const getProps = (item: FormItem) => {
if (item.props) return item.props
if (item.props) {
// number 类型使用 ElInput 渲染时需要注入 type="number"
if (item.type === 'number') {
return { type: 'number', step: 'any', ...item.props }
}
return item.props
}
const props = { ...item }
rootProps.forEach((key) => delete (props as Record<string, any>)[key])
// number 类型使用 ElInput 渲染时需要注入 type="number"
if (item.type === 'number') {
;(props as Record<string, any>).type = 'number'
if (!(props as Record<string, any>).step) {
;(props as Record<string, any>).step = 'any'
}
}
return props
}
@@ -114,7 +114,6 @@
ElDatePicker,
ElInput,
ElInputTag,
ElInputNumber,
ElRadioGroup,
ElRate,
ElSelect,
@@ -132,7 +131,7 @@
const componentMap = {
input: ElInput, // 输入框
inputTag: ElInputTag, // 标签输入框
number: ElInputNumber, // 数字输入框
number: ElInput, // 数字输入框
select: ElSelect, // 选择器
switch: ElSwitch, // 开关
checkbox: ElCheckbox, // 复选框
@@ -297,9 +296,22 @@
}))
const getProps = (item: SearchFormItem) => {
if (item.props) return item.props
if (item.props) {
// number 类型使用 ElInput 渲染时需要注入 type="number"
if (item.type === 'number') {
return { type: 'number', step: 'any', ...item.props }
}
return item.props
}
const props = { ...item }
rootProps.forEach((key) => delete (props as Record<string, any>)[key])
// number 类型使用 ElInput 渲染时需要注入 type="number"
if (item.type === 'number') {
;(props as Record<string, any>).type = 'number'
if (!(props as Record<string, any>).step) {
;(props as Record<string, any>).step = 'any'
}
}
return props
}
@@ -36,12 +36,20 @@
}"
>
<ArtSvgIcon
v-if="menu.meta.icon"
class="menu-icon text-g-700 dark:text-g-800"
:icon="menu.meta.icon"
:style="{
marginBottom: dualMenuShowText ? '5px' : '0'
}"
/>
<div
v-else
class="dual-menu-icon-placeholder"
:style="{
marginBottom: dualMenuShowText ? '5px' : '0'
}"
/>
<span v-if="dualMenuShowText" class="text-md text-g-700">
{{ $t(menu.meta.title) }}
</span>
@@ -55,6 +55,14 @@
font-size: 20px;
}
.dual-menu-icon-placeholder {
display: block;
flex-shrink: 0;
width: 20px;
height: 20px;
margin: 0 auto;
}
span {
display: -webkit-box;
width: 100%;
@@ -112,12 +112,25 @@ $popup-menu-radius: 6px;
}
}
// 菜单图标
// 菜单图标(固定槽宽,无 icon 的一级项用空槽与文字对齐)
.menu-icon {
box-sizing: border-box;
flex-shrink: 0;
width: $menu-icon-size;
min-width: $menu-icon-size;
height: $menu-icon-size;
margin-right: 8px;
font-size: $menu-icon-size;
}
.menu-icon__virtual {
display: block;
flex: 0 0 0;
width: 0;
height: 0;
overflow: hidden;
}
// 菜单高度
.el-sub-menu__title,
.el-menu-item {
@@ -2,12 +2,17 @@
<template v-for="(item, index) in filteredMenuItems" :key="getUniqueKey(item, index)">
<ElSubMenu v-if="hasChildren(item)" :index="item.path || item.meta.title" :level="level">
<template #title>
<div v-if="level === 0" class="menu-icon flex-cc">
<div
v-if="level === 0 && (item.meta.icon || item.meta.virtualMenuIcon)"
class="menu-icon flex-cc"
>
<ArtSvgIcon
v-if="item.meta.icon"
:icon="item.meta.icon"
:color="theme?.iconColor"
:style="{ color: theme.iconColor }"
/>
<span v-else class="menu-icon__virtual" aria-hidden="true" />
</div>
<span class="menu-name">
{{ formatMenuTitle(item.meta.title) }}
@@ -30,12 +35,17 @@
:level-item="level + 1"
@click="goPage(item)"
>
<div v-if="level === 0" class="menu-icon flex-cc">
<div
v-if="level === 0 && (item.meta.icon || item.meta.virtualMenuIcon)"
class="menu-icon flex-cc"
>
<ArtSvgIcon
v-if="item.meta.icon"
:icon="item.meta.icon"
:color="theme?.iconColor"
:style="{ color: theme.iconColor }"
/>
<span v-else class="menu-icon__virtual" aria-hidden="true" />
</div>
<div
v-show="item.meta.showBadge && level === 0 && !menuOpen"
@@ -6,15 +6,15 @@
<ElSwitch v-if="config.type === 'switch'" :model-value="modelValue" @change="handleChange" />
<!-- 数字输入类型 -->
<ElInputNumber
<ElInput
type="number"
step="any"
v-else-if="config.type === 'input-number'"
:model-value="modelValue"
:min="config.min"
:max="config.max"
:step="config.step"
:style="config.style"
:controls-position="config.controlsPosition"
@change="handleChange"
@input="handleChange"
/>
<!-- 选择器类型 -->
@@ -2,9 +2,9 @@
<template>
<div
v-if="showWorkTab"
class="worktab-strip box-border flex-b w-full px-5 mb-3 select-none max-sm:px-[15px]"
class="worktab-strip box-border flex w-full items-center px-5 mb-3 select-none max-sm:px-[15px]"
>
<div class="worktab-scroll-wrap w-full" ref="scrollRef">
<div class="worktab-scroll-wrap min-w-0 flex-1" ref="scrollRef">
<ul
class="float-left whitespace-nowrap !bg-transparent flex"
:class="[tabStyle === 'tab-google' ? 'pl-1' : '']"
@@ -24,12 +24,6 @@
@click="clickTab(item)"
@contextmenu.prevent="(e) => showMenu(e, item.path)"
>
<ArtSvgIcon
v-show="item.icon"
:icon="item.icon"
class="text-base mr-1 group-hover:text-theme"
:class="item.path === activeTab ? 'text-theme' : 'text-inherit'"
/>
{{ item.customTitle || formatMenuTitle(item.title) }}
<span
v-if="list.length > 1 && !item.fixedTab"
@@ -42,7 +36,7 @@
</ul>
</div>
<div class="flex">
<div class="flex shrink-0">
<div
class="worktab-menu-btn flex-cc relative top-0 size-8 leading-8 text-center c-p tad-200"
@click="(e) => showMenu(e, activeTab)"
+1 -1
View File
@@ -20,4 +20,4 @@ export function initRouter(app: App<Element>): void {
}
// 主页路径,默认使用菜单第一个有效路径,配置后使用此路径
export const HOME_PAGE_PATH = ''
export const HOME_PAGE_PATH = '/console'
+156 -99
View File
@@ -1,153 +1,210 @@
import type { AppRouteRecord } from '@/types/router'
/**
* 前端路由(Demo 参考页 + 系统管理)
* 前端路由(系统管理 + 基础信息管理 + 细胞存储 + 工作流)
* 与后端菜单对齐时请同步 `backend/app/api/menu.py`。
*/
export const sqxpAdminRoutes: AppRouteRecord[] = [
{
id: '10000000000000000000000000000002',
name: 'Demo',
path: '/demo',
id: '10000000000000000000000000000001_child',
name: 'Console',
path: '/console',
component: '/dashboard/console/index',
meta: {
title: '工作台',
/** 无 icon:侧栏用与一级菜单同宽的虚拟槽对齐标题 */
virtualMenuIcon: true,
keepAlive: true,
fixedTab: true,
menuCode: 'dashboard'
}
},
{
id: '60000000000000000000000000000001',
name: 'Operations',
path: '/operations',
component: '/index/index',
meta: {
title: 'Demo',
icon: 'grid',
title: '运营支撑',
icon: 'operation',
keepAlive: false,
roles: ['admin']
},
children: [
{
id: '10000000000000000000000000000001_child',
name: 'Console',
path: 'console',
component: '/dashboard/console/index',
meta: {
title: '工作台',
icon: 'home-filled',
keepAlive: true,
fixedTab: true,
menuCode: 'dashboard'
}
id: '60000000000000000000000000000002',
name: 'CleanRoom',
path: 'clean-room',
component: '/operations/clean-room/index',
meta: { title: '洁净室管理', keepAlive: true }
},
{
id: '10000000000000000000000000000005',
name: 'Unit',
path: 'unit',
component: '/system/unit/index',
meta: { title: '商品单位', keepAlive: true }
id: '60000000000000000000000000000003',
name: 'StorageFacility',
path: 'storage-facility',
component: '/operations/storage-facility/index',
meta: { title: '库位管理', keepAlive: true }
},
{
id: '10000000000000000000000000000021',
name: 'OrderList',
path: 'order',
component: '/system/order/index',
meta: { title: '订单列表', keepAlive: true }
id: '60000000000000000000000000000004',
name: 'ExhibitionAppointment',
path: 'exhibition-appointment',
component: '/operations/exhibition-appointment/index',
meta: { title: '展馆预约', keepAlive: true }
},
{
id: '10000000000000000000000000000006',
name: 'Product',
path: 'product',
component: '/system/product/index',
meta: { title: '商品管理', keepAlive: true }
},
{
id: '10000000000000000000000000000004',
name: 'Category',
path: 'category',
component: '/system/category/index',
meta: { title: '商品分类', keepAlive: true }
id: '60000000000000000000000000000005',
name: 'OperationsDemo',
path: 'demo',
component: '/operations/demo/index',
meta: { title: 'demo', keepAlive: true }
}
]
},
{
id: '20000000000000000000000000000001',
name: 'System',
path: '/system',
id: '40000000000000000000000000000001',
name: 'BasicInfo',
path: '/basic-info',
component: '/index/index',
meta: {
title: '系统管理',
icon: 'setting',
title: '基础信息管理',
icon: 'folder-opened',
keepAlive: false,
roles: ['admin']
},
children: [
{
id: '20000000000000000000000000000002',
name: 'Tenant',
path: 'tenant',
component: '/system/tenant/index',
meta: { title: '租户管理', keepAlive: true }
id: '40000000000000000000000000000002',
name: 'BizCustomer',
path: 'customer',
component: '/basic-info/customer/index',
meta: { title: '客户管理', keepAlive: true }
},
{
id: 'user-management-route',
name: 'SystemUser',
path: 'user',
component: '/system/user/index',
meta: { title: '用户管理', keepAlive: true }
id: '40000000000000000000000000000003',
name: 'BizCellSampleType',
path: 'cell-sample-type',
component: '/basic-info/cell-sample-type/index',
meta: { title: '细胞样本类型管理', keepAlive: true }
},
{
id: 'user-detail-route',
name: 'SystemUserDetail',
path: 'user/detail',
component: '/system/user/detail',
meta: { title: '用户详情', isHide: true, keepAlive: true }
id: '40000000000000000000000000000004',
name: 'BizCollectionRegion',
path: 'collection-region',
component: '/basic-info/collection-region/index',
meta: { title: '采集地区及医院管理', keepAlive: true }
},
{
id: 'role-management-route',
name: 'SystemRole',
path: 'role',
component: '/system/role/index',
meta: { title: '角色管理', keepAlive: true }
id: '40000000000000000000000000000005',
name: 'BizCollectionProtocolNo',
path: 'collection-protocol-no',
component: '/basic-info/collection-protocol-no/index',
meta: { title: '采集协议号管理', keepAlive: true }
},
{
id: 'menu-management-route',
name: 'SystemMenu',
path: 'menu',
component: '/system/menu/index',
meta: { title: '菜单管理', keepAlive: true }
id: '40000000000000000000000000000006',
name: 'BizSampleCode',
path: 'sample-code',
component: '/basic-info/sample-code/index',
meta: { title: '样本编码管理', keepAlive: true }
}
]
},
{
id: '50000000000000000000000000000001',
name: 'CellStorage',
path: '/cell-storage',
component: '/index/index',
meta: {
title: '细胞存储管理',
icon: 'collection-tag',
keepAlive: false,
roles: ['admin']
},
children: [
{
id: '50000000000000000000000000000002',
name: 'CellStorageProtocol',
path: 'protocol',
component: '/cell-storage/protocol/index',
meta: { title: '采集协议单', keepAlive: true }
},
{
id: 'dept-management-route',
name: 'SystemDept',
path: 'dept',
component: '/system/dept/index',
meta: { title: '组织管理', keepAlive: true }
id: '50000000000000000000000000000003',
name: 'CellStorageProtocolAudit',
path: 'protocol-audit',
component: '/cell-storage/protocol-audit/index',
meta: { title: '采集协议单审核', keepAlive: true }
},
{
id: 'dict-management-route',
name: 'SystemDict',
path: 'dict',
component: '/system/dict/index',
meta: { title: '字典管理', keepAlive: true }
id: '50000000000000000000000000000004',
name: 'CellStoragePaymentConfirm',
path: 'payment-confirm',
component: '/cell-storage/payment-confirm/index',
meta: { title: '收款确认(财务)', keepAlive: true }
},
{
id: 'site-management-route',
name: 'SystemSite',
path: 'site',
component: '/system/site/index',
meta: { title: '站点管理', keepAlive: true }
id: '50000000000000000000000000000005',
name: 'CellStorageRefundConfirm',
path: 'refund-confirm',
component: '/cell-storage/refund-confirm/index',
meta: { title: '退费确认(财务)', keepAlive: true }
},
{
id: 'post-management-route',
name: 'SystemPost',
path: 'post',
component: '/system/post/index',
meta: { title: '职位管理', keepAlive: true }
id: '50000000000000000000000000000006',
name: 'CellStorageInstallmentWarning',
path: 'installment-warning',
component: '/cell-storage/installment-warning/index',
meta: { title: '分期缴费预警', keepAlive: true }
}
]
},
{
id: '30000000000000000000000000000001',
name: 'Workflow',
path: '/workflow',
component: '/index/index',
meta: {
title: '工作流管理',
icon: 'workflow',
keepAlive: false,
roles: ['admin']
},
children: [
{
id: '10000000000000000000000000000wf01',
name: 'WorkflowProcess',
path: 'process',
component: '/system/workflow/process/index',
meta: { title: '流程配置', keepAlive: true, icon: 'workflow' }
},
{
id: 'unit-management-route',
name: 'SystemUnit',
path: 'unit',
component: '/system/unit/index',
meta: { title: '物品单位', keepAlive: true }
id: '10000000000000000000000000000wf02',
name: 'WorkflowPending',
path: 'pending',
component: '/system/workflow/task-pending/index',
meta: { title: '待办中心', keepAlive: true }
},
{
id: 'express-management-route',
name: 'SystemExpress',
path: 'express',
component: '/system/express/index',
meta: { title: '快递公司管理', keepAlive: true }
id: '10000000000000000000000000000wf03',
name: 'WorkflowCompleted',
path: 'completed',
component: '/system/workflow/task-completed/index',
meta: { title: '已办中心', keepAlive: true }
},
{
id: '10000000000000000000000000000wf05',
name: 'WorkflowMyApplications',
path: 'my-applications',
component: '/system/workflow/my-applications/index',
meta: { title: '我的申请', keepAlive: true }
},
{
id: '10000000000000000000000000000wf04',
name: 'LeaveRequest',
path: 'leave',
component: '/system/leave/index',
meta: { title: '请假申请', keepAlive: true }
}
]
}
+7 -7
View File
@@ -89,13 +89,13 @@ export const useWorktabStore = defineStore(
return !tab.fixedTab
}
/**
* 过滤不应展示在 worktab 中的父级占位路由。
* `/demo` 仅用于承载与重定向,真实标签页为其子路由(如 `/demo/console`)。
*/
const shouldIgnoreTab = (tab: Partial<WorkTab>): boolean => {
return tab.path === '/demo' || tab.path === '/system'
}
/**
* 过滤不应展示在 worktab 中的父级占位路由。
* `/system` 仅用于承载与重定向,真实标签页为其子路由(如 `/system/tenant`)。
*/
const shouldIgnoreTab = (tab: Partial<WorkTab>): boolean => {
return tab.path === '/system'
}
/**
* 安全的路由跳转
+230 -1
View File
@@ -14,7 +14,7 @@ declare namespace Api {
regionName?: string
email?: string
roles?: string[]
/** 自定义头像 URL,空则前端使用中科兴皖 logo */
/** 自定义头像 URL,空则前端使用 `/avatart.jpg` */
avatarUrl?: string | null
}
@@ -479,6 +479,97 @@ declare namespace Api {
}
}
namespace BizCustomer {
interface CustomerItem {
id: string
customerName: string
sex: string
idCardNo: string
age: number | null
phoneNo: string
customerTags: string
tenantNo: string
orderNum: number
remark: string
createTime: string
updateTime: string
}
}
namespace BizCellSampleType {
interface CellSampleTypeItem {
id: string
typeCode: string
typeName: string
storageYears: number | null
storagePrice: number | null
tenantNo: string
orderNum: number
remark: string
createTime: string
updateTime: string
}
}
namespace BizCollectionRegion {
interface RegionItem {
id: string
regionName: string
hospitalNames: string[]
tenantNo: string
orderNum: number
remark: string
createTime: string
updateTime: string
}
}
namespace BizCollectionHospital {
interface HospitalItem {
id: string
regionId: string
hospitalName: string
tenantNo: string
orderNum: number
remark: string
createTime: string
updateTime: string
}
}
namespace BizCollectionProtocolNo {
interface ProtocolNoItem {
id: string
protocolNo: string
issued: number
issuedUserId: string
issuedUserName: string
issuedTime: string
tenantNo: string
orderNum: number
remark: string
createTime: string
updateTime: string
}
}
namespace BizSampleCode {
interface SampleCodeItem {
id: string
sampleCode: string
sampleCodeType: string
issued: number
issuedUserId: string
issuedUserName: string
issuedTime: string
tenantNo: string
orderNum: number
remark: string
createTime: string
updateTime: string
}
}
namespace Menu {
interface MenuItem {
id: string
@@ -526,6 +617,144 @@ declare namespace Api {
updateTime: string
}
}
namespace Leave {
interface LeaveItem {
id: string
leaveType: string
leaveTypeLabel?: string
startDate: string
endDate: string
days: number
reason: string
wfInstanceId: string
status: string
tenantNo?: string
orderNum?: number
remark?: string
createBy?: string
createTime?: string
updateBy?: string
updateTime?: string
}
}
namespace Workflow {
interface ProcessDefItem {
id: string
processCode: string
processName: string
status: string
latestVersion: number | null
tenantNo: string
orderNum: number
remark: string
createTime: string
updateTime: string
}
interface VersionItem {
id: string
versionNo: number
isLatest: string
remark: string
createTime: string
updateTime: string
}
interface NodeData {
nodeKey: string
nodeType: string
nodeName: string | null
configJson: string | null
}
interface TransitionData {
fromNodeKey: string
toNodeKey: string
conditionExpr: string | null
}
interface DesignerData {
graphJson: string | null
versionNo: number
nodes: NodeData[]
transitions: TransitionData[]
}
interface TaskItem {
id: string
instanceId: string
nodeKey: string | null
assigneeUserId: string | null
status: string | null
commentText: string | null
createTime: string
updateTime: string
processName: string | null
businessType: string | null
businessId: string | null
starterUserId: string | null
instanceStatus: string | null
instanceCreateTime: string | null
}
interface MyInstanceItem {
id: string
processName: string | null
businessType: string | null
businessId: string | null
starterUserId: string | null
status: string
createTime: string
updateTime: string
businessTypeLabel?: string
starterUserName?: string
}
interface TaskDetail {
id: string
nodeKey: string | null
nodeName?: string | null
assigneeUserId: string | null
assigneeUserName?: string | null
status: string | null
commentText: string | null
createTime: string
updateTime: string
}
interface InstanceDetail {
id: string
processVersionId: string
businessType: string | null
businessId: string | null
starterUserId: string | null
status: string | null
variables: string
createTime: string
tasks: TaskDetail[]
}
interface BusinessAllTasks {
businessType: string
businessId: string
businessFormFields: Array<{ label: string; value: string }>
tasks: Array<{
id: string
instanceId: string
instanceStatus: string
nodeKey: string | null
nodeName: string
assigneeUserId: string | null
assigneeUserName: string
status: string | null
commentText: string | null
createTime: string
updateTime: string
}>
}
}
}
declare module '*.vue' {
+3 -1
View File
@@ -29,8 +29,10 @@ import { RouteRecordRaw } from 'vue-router'
export interface RouteMeta extends Record<string | number | symbol, unknown> {
/** 路由标题 */
title: string
/** 路由图标 */
/** 路由图标(Element / Iconify 名) */
icon?: string
/** 无 `icon` 时仍在一级侧栏预留与图标同宽占位,使标题与其它一级菜单左对齐 */
virtualMenuIcon?: boolean
/** 是否显示徽章 */
showBadge?: boolean
/** 文本徽章 */
+5 -1
View File
@@ -2,11 +2,15 @@
* 分页循环请求直至拿全数据(接口需返回 { list, total })。
* 用于分类、单位、用户等列表接口,避免只取第一页导致下拉选项不全。
*/
/** 与后端 `/web/admin/*` 列表普遍 `Query(..., le=100)` 一致,超出会 422 */
export const MAX_ADMIN_LIST_PAGE_SIZE = 100
export async function fetchAllPagedRecords<T>(
fetchPage: (page: number, pageSize: number) => Promise<{ list?: T[]; total?: number }>,
options?: { pageSize?: number; maxPages?: number }
): Promise<T[]> {
const pageSize = options?.pageSize ?? 100
const requested = options?.pageSize ?? MAX_ADMIN_LIST_PAGE_SIZE
const pageSize = Math.min(Math.max(1, requested), MAX_ADMIN_LIST_PAGE_SIZE)
const maxPages = options?.maxPages ?? 50
let page = 1
const all: T[] = []
+1 -1
View File
@@ -23,7 +23,7 @@ import { BaseResponse } from '@/types'
import { decryptJson, deriveKey, encryptJson, randomNonce } from './crypto'
/** 请求配置常量 */
const REQUEST_TIMEOUT = 15000
const REQUEST_TIMEOUT = 60000
const LOGOUT_DELAY = 500
const RETRY_DELAY = 1000
/** 幂等请求在网络抖动、唤醒后首包失败时自动重试次数 */
+5
View File
@@ -17,6 +17,7 @@
import { AppRouteRecord } from '@/types/router'
import { router } from '@/router'
import { isNavigableMenuItem } from './route'
import { useSettingStore } from '@/store/modules/setting'
// 打开外部链接
export const openExternalLink = (link: string) => {
@@ -38,6 +39,10 @@ export const handleMenuJump = (item: AppRouteRecord, jumpToFirst: boolean = fals
// 如果不需要跳转到第一个子菜单,或者没有子菜单,直接跳转当前路径
if (!jumpToFirst || !item.children?.length) {
// 已经在当前页面时,刷新页面内容以重新加载列表数据
if (router.currentRoute.value.path === item.path) {
return useSettingStore().reload()
}
return router.push(item.path)
}
+4 -1
View File
@@ -2,6 +2,8 @@
* 新增时默认排序号:当前列表中最大 sortOrder + 1;无任何数据时为 0。
* 依赖列表接口按 sort_order 升序分页(最后一页含最大排序号)。
*/
import { MAX_ADMIN_LIST_PAGE_SIZE } from '@/utils/fetch-paged-list'
export async function fetchNextSortOrder(
fetchList: (params: {
page: number
@@ -11,7 +13,8 @@ export async function fetchNextSortOrder(
}) => Promise<{ list: { sortOrder?: number }[]; total: number }>,
options?: { pageSize?: number }
): Promise<number> {
const pageSize = options?.pageSize ?? 100
const requested = options?.pageSize ?? MAX_ADMIN_LIST_PAGE_SIZE
const pageSize = Math.min(Math.max(1, requested), MAX_ADMIN_LIST_PAGE_SIZE)
const first = await fetchList({ page: 1, pageSize })
const total = first.total ?? 0
if (total === 0) return 0
+13 -4
View File
@@ -11,8 +11,16 @@ export type TreePathFlatNode = Record<string, unknown>
export function buildTreePathLabelFromFlat(
nodeId: string | null | undefined,
flatList: TreePathFlatNode[] | null | undefined,
separator: string = DEFAULT_TREE_PATH_SEPARATOR
separatorOrOpts?: string | { separator?: string; nameKey?: string }
): string {
const separator =
typeof separatorOrOpts === 'string'
? separatorOrOpts
: separatorOrOpts?.separator ?? DEFAULT_TREE_PATH_SEPARATOR
const nameKey =
typeof separatorOrOpts === 'string'
? 'name'
: separatorOrOpts?.nameKey ?? 'name'
const cid = String(nodeId ?? '').trim()
if (!cid) return ''
const byId = new Map<string, TreePathFlatNode>()
@@ -26,7 +34,7 @@ export function buildTreePathLabelFromFlat(
while (cur && byId.has(cur) && !seen.has(cur)) {
seen.add(cur)
const cat: TreePathFlatNode = byId.get(cur)!
const nm = String(cat?.name ?? '').trim()
const nm = String(cat?.[nameKey] ?? '').trim()
if (nm) names.unshift(nm)
const pid: string = String(cat?.parentId ?? cat?.parent_id ?? '').trim()
cur = pid || null
@@ -70,12 +78,13 @@ export function resolveTreePathDisplay(
flatList: TreePathFlatNode[] | null | undefined,
fallbackName?: unknown,
separator: string = DEFAULT_TREE_PATH_SEPARATOR,
emptyPlaceholder = '—'
emptyPlaceholder = '—',
nameKey?: string
): string {
const path = buildTreePathLabelFromFlat(
String(nodeId ?? '').trim() || undefined,
flatList,
separator
{ separator, nameKey }
)
if (path) return path
const fb = String(fallbackName ?? '').trim()
+10 -2
View File
@@ -13,13 +13,16 @@ import {
CircleClose,
Close,
CloseBold,
CollectionTag,
Connection,
DArrowRight,
DataAnalysis,
DataBoard,
Delete,
Document,
Edit,
Expand,
Fold,
FolderOpened,
FullScreen,
Grid,
HomeFilled,
@@ -109,7 +112,12 @@ export const epIconMap: Record<string, Component> = {
smile: ChatDotRound,
brush: Brush,
// Status
warning: Warning
warning: Warning,
// Business
'folder-opened': FolderOpened,
'collection-tag': CollectionTag,
workflow: Connection,
'data-board': DataBoard
}
export function resolveEpIcon(name: string | undefined): Component | undefined {
+4 -4
View File
@@ -1,12 +1,12 @@
/** 未设置头像时统一使用中科兴皖 logo(与登录页、侧栏 ArtLogo 一致) */
export const DEFAULT_USER_AVATAR_URL = '/logo.png'
/** 未设置头像时使用 `public/avatart.jpg`(根路径 `/avatart.jpg`) */
export const DEFAULT_USER_AVATAR_URL = '/avatart.jpg'
/** @deprecated 各角色默认已统一为 logo,保留参数仅为兼容旧调用 */
/** @deprecated 各角色默认已统一为默认头像图,保留参数仅为兼容旧调用 */
export function defaultAvatarPathByRole(_role: string | undefined): string {
return DEFAULT_USER_AVATAR_URL
}
/** 展示用头像:有自定义 URL 用自定义,否则用中科兴皖 logo */
/** 展示用头像:`avatarUrl` 非空则用其值,否则用默认图 */
export function resolveUserAvatarUrl(avatarUrl: string | null | undefined, role: string | undefined): string {
const u = avatarUrl != null ? String(avatarUrl).trim() : ''
if (u) return u
@@ -0,0 +1,403 @@
<!-- 细胞样本类型管理 -->
<!-- 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 />
</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-icon><Plus /></el-icon>
新增类型
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="selectedRows.length === 0"
@click="handleBatchDelete"
>
批量删除
</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"
@row-dblclick="handleView"
>
<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="typeCode"
label="类型编码"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="typeName"
label="类型名称"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column
prop="storageYears"
label="存储年限(年)"
width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="storagePrice"
label="存储价格(元)"
width="120"
align="center"
header-align="center"
>
<template #default="{ row }">
{{ row.storagePrice != null ? row.storagePrice : '—' }}
</template>
</el-table-column>
<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>
</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="640px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-position="top"
class="biz-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="类型编码" prop="typeCode">
<el-input v-model="formData.typeCode" placeholder="租户内唯一" :disabled="isEdit" />
</el-form-item>
<el-form-item label="类型名称" prop="typeName">
<el-input v-model="formData.typeName" placeholder="必填" />
</el-form-item>
<el-form-item label="存储年限(年)">
<el-input
type="number"
step="any"
v-model="formData.storageYears"
:min="0"
:max="200"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="存储价格(元)">
<el-input
type="number"
step="any"
v-model="formData.storagePrice"
:min="0"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="备注" class="form-col-span-2">
<el-input v-model="formData.remark" type="textarea" :rows="2" 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" @click="handleSubmit" :loading="submitLoading">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.typeName || '类型详情'"
:icon="Collection"
:meta="`类型编码:${viewRow?.typeCode || ''}${viewRow?.createTime ? ' · ' + viewRow.createTime : ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check, View, Collection } from '@element-plus/icons-vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchCellSampleTypeList,
fetchCreateCellSampleType,
fetchUpdateCellSampleType,
fetchDeleteCellSampleType
} from '@/api/admin'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
defineOptions({ name: 'BizCellSampleType' })
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.BizCellSampleType.CellSampleTypeItem[]>([])
const selectedRows = ref<Api.BizCellSampleType.CellSampleTypeItem[]>([])
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 viewVisible = ref(false)
const viewRow = ref<Api.BizCellSampleType.CellSampleTypeItem | null>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
return [
{
title: '基本信息',
fields: [
{ label: '类型编码', value: row.typeCode },
{ label: '类型名称', value: row.typeName },
{ label: '存储年限(年)', value: row.storageYears },
{ label: '存储价格(元)', value: row.storagePrice },
{ label: '创建时间', value: row.createTime },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function handleView(row: Api.BizCellSampleType.CellSampleTypeItem) {
viewRow.value = row
viewVisible.value = true
}
const formData = reactive({
typeCode: '',
typeName: '',
storageYears: null as number | null,
storagePrice: null as number | null,
orderNum: 0,
remark: ''
})
const formRules = {
typeCode: [{ required: true, message: '请输入类型编码', trigger: 'blur' }],
typeName: [{ required: true, message: '请输入类型名称', trigger: 'blur' }]
}
const handleSelectionChange = (rows: Api.BizCellSampleType.CellSampleTypeItem[]) => {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchCellSampleTypeList({
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.typeCode = ''
formData.typeName = ''
formData.storageYears = null
formData.storagePrice = null
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.BizCellSampleType.CellSampleTypeItem) {
isEdit.value = true
dialogTitle.value = '编辑类型'
editingId.value = row.id
formData.typeCode = row.typeCode || ''
formData.typeName = row.typeName || ''
formData.storageYears = row.storageYears ?? null
formData.storagePrice = row.storagePrice ?? null
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 = {
typeCode: formData.typeCode.trim(),
typeName: formData.typeName.trim(),
storageYears: formData.storageYears,
storagePrice: formData.storagePrice,
orderNum: formData.orderNum,
remark: formData.remark?.trim() || undefined
}
if (isEdit.value && editingId.value) {
await fetchUpdateCellSampleType(editingId.value, {
typeName: payload.typeName,
storageYears: payload.storageYears,
storagePrice: payload.storagePrice,
orderNum: payload.orderNum,
remark: payload.remark
})
} else {
await fetchCreateCellSampleType(payload)
}
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
dialogVisible.value = false
await loadData()
} catch {
/* 全局 */
} finally {
submitLoading.value = false
}
}
async function handleDelete(row: Api.BizCellSampleType.CellSampleTypeItem) {
await ElMessageBox.confirm('确定要删除该类型吗?', '提示', { type: 'warning' })
await fetchDeleteCellSampleType(row.id)
ElMessage.success('删除成功')
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 fetchDeleteCellSampleType(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.biz-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
</style>
@@ -0,0 +1,684 @@
<!-- 采集协议号管理 -->
<!-- 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 />
</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-icon><Plus /></el-icon>
新增协议号
</el-button>
<el-button class="btn-ghost" @click="openBatchGenerate">
批量生成
</el-button>
<el-button
class="btn-ghost"
:disabled="selectedRows.length === 0"
@click="openBatchIssue"
>
批量下发
</el-button>
<el-button
class="btn-ghost"
:disabled="selectedRows.length === 0"
@click="handleBatchRevoke"
>
批量收回
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="selectedRows.length === 0"
@click="handleBatchDelete"
>
批量删除
</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"
@row-dblclick="handleView"
>
<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="protocolNo"
label="采集协议号"
min-width="160"
align="center"
header-align="center"
/>
<el-table-column
prop="issued"
label="是否下发"
width="80"
align="center"
header-align="center"
>
<template #default="{ row }">
<span>{{ row.issued === 1 ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column
prop="issuedUserName"
label="下发对象"
min-width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{ row.issuedUserName || '-' }}</template>
</el-table-column>
<el-table-column
prop="issuedTime"
label="下发时间"
min-width="180"
align="center"
header-align="center"
>
<template #default="{ row }">{{ row.issuedTime || '-' }}</template>
</el-table-column>
<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>
</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="batchGenVisible"
title="批量生成协议号"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="batchGenFormRef"
:model="batchGenForm"
:rules="batchGenRules"
label-position="top"
scroll-to-error
>
<div class="form-grid-2">
<el-form-item label="固定前缀" prop="prefix">
<el-input v-model="batchGenForm.prefix" placeholder="如 ZKZX" />
</el-form-item>
<el-form-item label="中间段" prop="middle">
<el-input v-model="batchGenForm.middle" placeholder="如 34" />
</el-form-item>
<el-form-item label="开始序号" prop="seqStart">
<el-input
type="number"
step="any"
v-model="batchGenForm.seqStart"
:min="0"
:max="99999"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="结束序号" prop="seqEnd">
<el-input
type="number"
step="any"
v-model="batchGenForm.seqEnd"
:min="0"
:max="99999"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="序号位数" prop="digitCount">
<template #label
>序号位数<span class="form-label-tip">补零后的总位数</span></template
>
<el-input
type="number"
step="any"
v-model="batchGenForm.digitCount"
:min="1"
:max="10"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="预览" class="form-col-span-2">
<span class="text-sm text-gray-500">{{ batchGenPreview }}</span>
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="batchGenVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" :loading="batchGenLoading" @click="handleBatchGenerate">
<el-icon><Check /></el-icon>
生成
</el-button>
</template>
</el-dialog>
<!-- 批量下发弹窗 -->
<el-dialog
v-model="batchIssueVisible"
title="批量下发协议号"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="batchIssueFormRef"
:model="batchIssueForm"
:rules="batchIssueRules"
label-position="top"
scroll-to-error
>
<el-form-item label="下发用户" prop="issuedUserId">
<el-select
v-model="batchIssueForm.issuedUserId"
placeholder="请选择用户"
filterable
style="width: 100%"
>
<el-option
v-for="opt in userOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
<el-form-item label="已选协议号">
<span class="text-sm text-gray-500">
已选 {{ selectedRows.length }} 条,下发后"是否下发"将变为"是"
</span>
</el-form-item>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="batchIssueVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" :loading="batchIssueLoading" @click="handleBatchIssue">
<el-icon><Check /></el-icon>
确定下发
</el-button>
</template>
</el-dialog>
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-position="top"
class="biz-dialog-form"
scroll-to-error
>
<div class="form-grid-2">
<el-form-item label="采集协议号" prop="protocolNo">
<el-input
v-model="formData.protocolNo"
placeholder="租户内唯一,最多32位"
maxlength="32"
/>
</el-form-item>
<el-form-item label="是否下发">
<el-switch
v-model="formData.issued"
:active-value="1"
:inactive-value="0"
inline-prompt
active-text="是"
inactive-text="否"
/>
</el-form-item>
<el-form-item v-if="formData.issued === 1" label="下发用户">
<el-select
v-model="formData.issuedUserId"
placeholder="请选择用户"
filterable
style="width: 100%"
>
<el-option
v-for="opt in userOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.issued === 1 && formData.issuedTime" label="下发时间">
<span class="text-sm text-gray-500">{{ formData.issuedTime }}</span>
</el-form-item>
<el-form-item label="备注" class="form-col-span-2">
<el-input v-model="formData.remark" type="textarea" :rows="2" 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" @click="handleSubmit" :loading="submitLoading">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.protocolNo || '协议号详情'"
:icon="Tickets"
:meta="viewRow?.createTime ? '创建时间:' + viewRow.createTime : ''"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check, View, Tickets } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchCollectionProtocolNoList,
fetchCreateCollectionProtocolNo,
fetchUpdateCollectionProtocolNo,
fetchDeleteCollectionProtocolNo,
fetchUserOptions,
fetchBatchGenerateProtocolNos,
fetchBatchIssueProtocolNos,
fetchBatchRevokeProtocolNos
} from '@/api/admin'
defineOptions({ name: 'BizCollectionProtocolNo' })
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.BizCollectionProtocolNo.ProtocolNoItem[]>([])
const selectedRows = ref<Api.BizCollectionProtocolNo.ProtocolNoItem[]>([])
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 viewVisible = ref(false)
const viewRow = ref<Api.BizCollectionProtocolNo.ProtocolNoItem | null>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
return [
{
title: '基本信息',
fields: [
{ label: '采集协议号', value: row.protocolNo },
{ label: '是否下发', value: row.issued === 1 ? '是' : '否' },
{ label: '下发对象', value: row.issuedUserName || '-' },
{ label: '下发时间', value: row.issuedTime || '-' },
{ label: '创建时间', value: row.createTime },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function handleView(row: Api.BizCollectionProtocolNo.ProtocolNoItem) {
viewRow.value = row
viewVisible.value = true
}
// --- 批量生成 ---
const batchGenVisible = ref(false)
const batchGenLoading = ref(false)
const batchGenFormRef = ref()
const batchGenForm = reactive({
prefix: 'ZKZX',
middle: '34',
seqStart: 1,
seqEnd: 100,
digitCount: 6,
})
const batchGenRules = {
prefix: [{ required: true, message: '请输入固定前缀', trigger: 'blur' }],
middle: [{ required: true, message: '请输入中间段', trigger: 'blur' }],
seqStart: [{ required: true, message: '请输入开始序号', trigger: 'blur' }],
seqEnd: [{ required: true, message: '请输入结束序号', trigger: 'blur' }],
digitCount: [{ required: true, message: '请输入序号位数', trigger: 'blur' }],
}
const batchGenPreview = computed(() => {
const p = batchGenForm.prefix || ''
const m = batchGenForm.middle || ''
const s = batchGenForm.seqStart ?? 0
const e = batchGenForm.seqEnd ?? 0
const d = batchGenForm.digitCount ?? 6
if (!p || e < s) return '—'
const first = `${p}${m}${String(s).padStart(d, '0')}`
const last = `${p}${m}${String(e).padStart(d, '0')}`
return `${first} ~ ${last}(共 ${e - s + 1} 条)`
})
// --- 批量下发 ---
const batchIssueVisible = ref(false)
const batchIssueLoading = ref(false)
const batchIssueFormRef = ref()
const batchIssueForm = reactive({
issuedUserId: '',
})
const batchIssueRules = {
issuedUserId: [{ required: true, message: '请选择下发用户', trigger: 'change' }],
}
const userOptions = ref<Array<{ label: string; value: string }>>([])
const formData = reactive({
protocolNo: '',
issued: 0,
issuedUserId: '',
issuedUserName: '',
issuedTime: '',
orderNum: 0,
remark: ''
})
const formRules = {
protocolNo: [{ required: true, message: '请输入采集协议号', trigger: 'blur' }]
}
const handleSelectionChange = (rows: Api.BizCollectionProtocolNo.ProtocolNoItem[]) => {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchCollectionProtocolNoList({
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.protocolNo = ''
formData.issued = 0
formData.issuedUserId = ''
formData.issuedUserName = ''
formData.issuedTime = ''
formData.orderNum = 0
formData.remark = ''
editingId.value = null
}
function handleAdd() {
isEdit.value = false
dialogTitle.value = '新增协议号'
resetForm()
dialogVisible.value = true
formRef.value?.clearValidate?.()
}
async function handleEdit(row: Api.BizCollectionProtocolNo.ProtocolNoItem) {
isEdit.value = true
dialogTitle.value = '编辑协议号'
editingId.value = row.id
formData.protocolNo = row.protocolNo || ''
formData.issued = row.issued === 1 ? 1 : 0
formData.issuedUserId = row.issuedUserId || ''
formData.issuedUserName = row.issuedUserName || ''
formData.issuedTime = row.issuedTime || ''
formData.orderNum = row.orderNum ?? 0
formData.remark = row.remark || ''
dialogVisible.value = true
formRef.value?.clearValidate?.()
if (!userOptions.value.length) {
try {
userOptions.value = await fetchUserOptions()
} catch { /* ignore */ }
}
}
async function handleSubmit() {
await formRef.value?.validate?.()
submitLoading.value = true
try {
const payload = {
protocolNo: formData.protocolNo.trim(),
issued: formData.issued,
issuedUserId: formData.issued === 1 ? formData.issuedUserId || undefined : null,
issuedUserName: formData.issued === 1 ? formData.issuedUserName || undefined : null,
issuedTime: formData.issuedTime || undefined,
orderNum: formData.orderNum,
remark: formData.remark?.trim() || undefined
}
if (isEdit.value && editingId.value) {
await fetchUpdateCollectionProtocolNo(editingId.value, payload)
} else {
await fetchCreateCollectionProtocolNo(payload)
}
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
dialogVisible.value = false
await loadData()
} catch {
/* */
} finally {
submitLoading.value = false
}
}
async function handleDelete(row: Api.BizCollectionProtocolNo.ProtocolNoItem) {
await ElMessageBox.confirm('确定要删除该协议号吗?', '提示', { type: 'warning' })
await fetchDeleteCollectionProtocolNo(row.id)
ElMessage.success('删除成功')
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 fetchDeleteCollectionProtocolNo(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
async function handleBatchRevoke() {
const ids = selectedRows.value.map((r) => r.id)
if (!ids.length) return
await ElMessageBox.confirm(
`确定收回选中的 ${ids.length} 条吗?收回后将清除下发信息。`,
'提示',
{ type: 'warning' }
)
await withFullscreenLoading(async () => {
await fetchBatchRevokeProtocolNos(ids)
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
// --- 批量生成 ---
function openBatchGenerate() {
batchGenForm.prefix = 'ZKZX'
batchGenForm.middle = '34'
batchGenForm.seqStart = 1
batchGenForm.seqEnd = 100
batchGenForm.digitCount = 6
batchGenVisible.value = true
}
async function handleBatchGenerate() {
await batchGenFormRef.value?.validate?.()
if (batchGenForm.seqStart > batchGenForm.seqEnd) {
ElMessage.warning('开始序号不能大于结束序号')
return
}
batchGenLoading.value = true
try {
await fetchBatchGenerateProtocolNos({
prefix: batchGenForm.prefix.trim(),
middle: batchGenForm.middle.trim(),
seqStart: batchGenForm.seqStart,
seqEnd: batchGenForm.seqEnd,
digitCount: batchGenForm.digitCount,
})
batchGenVisible.value = false
await loadData()
} finally {
batchGenLoading.value = false
}
}
// --- 批量下发 ---
async function openBatchIssue() {
if (!selectedRows.value.length) return
batchIssueForm.issuedUserId = ''
batchIssueVisible.value = true
// load user options
if (!userOptions.value.length) {
try {
userOptions.value = await fetchUserOptions()
} catch { /* ignore */ }
}
}
async function handleBatchIssue() {
await batchIssueFormRef.value?.validate?.()
batchIssueLoading.value = true
try {
const ids = selectedRows.value.map(r => r.id)
const userOpt = userOptions.value.find(u => u.value === batchIssueForm.issuedUserId)
await fetchBatchIssueProtocolNos({
ids,
issuedUserId: batchIssueForm.issuedUserId,
issuedUserName: userOpt?.label || undefined,
})
batchIssueVisible.value = false
selectedRows.value = []
await loadData()
} finally {
batchIssueLoading.value = false
}
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.biz-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
</style>
@@ -0,0 +1,665 @@
<!-- 采集地区及医院管理 -->
<!-- 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 />
</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-icon><Plus /></el-icon>
新增地区
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="selectedRows.length === 0"
@click="handleBatchDelete"
>
批量删除
</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"
@row-dblclick="handleView"
>
<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="regionName"
label="地区名称"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column
prop="createTime"
label="创建时间"
min-width="180"
align="center"
header-align="center"
/>
<el-table-column
label="医院信息"
min-width="240"
align="center"
header-align="center"
>
<template #default="{ row }">
<template v-if="row.hospitalNames && row.hospitalNames.length">
<div
v-for="(name, idx) in row.hospitalNames"
:key="idx"
class="hospital-cell-line"
>
{{ name }}
</div>
</template>
<span v-else class="muted">—</span>
</template>
</el-table-column>
<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="openHospitalDialog(row)"
>地区医院配置</el-button
>
<el-button class="btn-op-item" @click="handleEdit(row)">编辑</el-button>
<el-button class="btn-op-item" @click="handleDelete(row)">删除</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="regionDialogVisible"
:title="regionDialogTitle"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="regionFormRef"
:model="regionForm"
:rules="regionFormRules"
label-position="top"
class="biz-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="地区名称" prop="regionName" class="form-col-span-2">
<el-input v-model="regionForm.regionName" placeholder="必填" />
</el-form-item>
<el-form-item label="备注" class="form-col-span-2">
<el-input v-model="regionForm.remark" type="textarea" :rows="2" placeholder="可选" />
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="regionDialogVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button
class="btn-main"
type="primary"
@click="submitRegion"
:loading="regionSubmitLoading"
>
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<el-dialog
v-model="hospitalDialogVisible"
:title="hospitalDialogTitle"
width="800px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
@closed="onHospitalDialogClosed"
>
<div class="hospital-dialog-head">
<span class="muted">当前地区:{{ currentRegionName }}</span>
</div>
<div class="list-toolbar hospital-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">
已选 <span class="sel-num">{{ hospitalSelected.length }}</span> 项
</div>
<el-button class="btn-main" type="primary" @click="handleAddHospital">
<el-icon><Plus /></el-icon>
新增医院
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="hospitalSelected.length === 0"
@click="handleBatchDeleteHospital"
>
批量删除
</el-button>
</div>
</div>
<div class="list-body list-wrap hospital-table-wrap">
<el-table
class="list-table"
:data="hospitalTable"
v-loading="hospitalLoading"
stripe
row-key="id"
max-height="360"
@selection-change="onHospitalSelectionChange"
>
<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"
/>
<el-table-column
prop="hospitalName"
label="医院名称"
min-width="200"
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="handleEditHospital(row)"
>编辑</el-button
>
<el-button class="btn-op-item" @click="handleDeleteHospital(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
:current-page="hospitalPagination.page"
:page-size="hospitalPagination.pageSize"
:total="hospitalPagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="
(val) => (
(hospitalPagination.page = 1),
(hospitalPagination.pageSize = val),
loadHospitals()
)
"
@current-change="(val) => ((hospitalPagination.page = val), loadHospitals())"
/>
</div>
</div>
<el-dialog
v-model="hospitalFormVisible"
:title="hospitalFormTitle"
width="520px"
class="dialog-form-layout"
align-center
append-to-body
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="hospitalFormRef"
:model="hospitalForm"
:rules="hospitalFormRules"
label-position="top"
>
<el-form-item label="医院名称" prop="hospitalName">
<el-input v-model="hospitalForm.hospitalName" placeholder="必填" />
</el-form-item>
<el-form-item label="备注">
<el-input
v-model="hospitalForm.remark"
type="textarea"
:rows="2"
placeholder="可选"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="hospitalFormVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button
class="btn-main"
type="primary"
@click="submitHospital"
:loading="hospitalSubmitLoading"
>
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<template #footer>
<el-button class="btn-ghost" @click="hospitalDialogVisible = false">
<el-icon><Close /></el-icon>
关闭
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.regionName || '地区详情'"
:icon="Location"
:meta="viewRow?.createTime ? '创建时间:' + viewRow.createTime : ''"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
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 {
fetchCollectionRegionList,
fetchCreateCollectionRegion,
fetchUpdateCollectionRegion,
fetchDeleteCollectionRegion,
fetchHospitalList,
fetchCreateHospital,
fetchUpdateHospital,
fetchDeleteHospital
} from '@/api/admin'
defineOptions({ name: 'BizCollectionRegion' })
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.BizCollectionRegion.RegionItem[]>([])
const selectedRows = ref<Api.BizCollectionRegion.RegionItem[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const regionDialogVisible = ref(false)
const regionDialogTitle = ref('新增地区')
const regionIsEdit = ref(false)
const regionSubmitLoading = ref(false)
const regionFormRef = ref()
const editingRegionId = ref<string | null>(null)
const regionForm = reactive({ regionName: '', orderNum: 0, remark: '' })
const regionFormRules = {
regionName: [{ required: true, message: '请输入地区名称', trigger: 'blur' }]
}
const hospitalDialogVisible = ref(false)
const hospitalDialogTitle = ref('地区医院配置')
const currentRegionId = ref('')
const currentRegionName = ref('')
const hospitalTable = ref<Api.BizCollectionHospital.HospitalItem[]>([])
const hospitalSelected = ref<Api.BizCollectionHospital.HospitalItem[]>([])
const hospitalLoading = ref(false)
const hospitalPagination = reactive({ page: 1, pageSize: 10, total: 0 })
const hospitalFormVisible = ref(false)
const hospitalFormTitle = ref('新增医院')
const hospitalIsEdit = ref(false)
const hospitalSubmitLoading = ref(false)
const hospitalFormRef = ref()
const editingHospitalId = ref<string | null>(null)
// ---- 查看弹窗 ----
const viewVisible = ref(false)
const viewRow = ref<Api.BizCollectionRegion.RegionItem | null>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
const hospitals =
row.hospitalNames && row.hospitalNames.length > 0
? row.hospitalNames.join('、')
: '无'
return [
{
title: '基本信息',
fields: [
{ label: '地区名称', value: row.regionName },
{ label: '创建时间', value: row.createTime },
{ label: '关联医院', value: hospitals, span: true },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function handleView(row: Api.BizCollectionRegion.RegionItem) {
viewRow.value = row
viewVisible.value = true
}
const hospitalForm = reactive({ hospitalName: '', orderNum: 0, remark: '' })
const hospitalFormRules = {
hospitalName: [{ required: true, message: '请输入医院名称', trigger: 'blur' }]
}
function onHospitalSelectionChange(rows: Api.BizCollectionHospital.HospitalItem[]) {
hospitalSelected.value = rows
}
const handleSelectionChange = (rows: Api.BizCollectionRegion.RegionItem[]) => {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchCollectionRegionList({
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 handleAdd() {
regionIsEdit.value = false
regionDialogTitle.value = '新增地区'
editingRegionId.value = null
regionForm.regionName = ''
regionForm.orderNum = 0
regionForm.remark = ''
regionDialogVisible.value = true
regionFormRef.value?.clearValidate?.()
}
function handleEdit(row: Api.BizCollectionRegion.RegionItem) {
regionIsEdit.value = true
regionDialogTitle.value = '编辑地区'
editingRegionId.value = row.id
regionForm.regionName = row.regionName || ''
regionForm.orderNum = row.orderNum ?? 0
regionForm.remark = row.remark || ''
regionDialogVisible.value = true
regionFormRef.value?.clearValidate?.()
}
async function submitRegion() {
await regionFormRef.value?.validate?.()
regionSubmitLoading.value = true
try {
const payload = {
regionName: regionForm.regionName.trim(),
orderNum: regionForm.orderNum,
remark: regionForm.remark?.trim() || undefined
}
if (regionIsEdit.value && editingRegionId.value) {
await fetchUpdateCollectionRegion(editingRegionId.value, payload)
} else {
await fetchCreateCollectionRegion(payload)
}
ElMessage.success(regionIsEdit.value ? '更新成功' : '创建成功')
regionDialogVisible.value = false
await loadData()
} catch {
/* */
} finally {
regionSubmitLoading.value = false
}
}
async function handleDelete(row: Api.BizCollectionRegion.RegionItem) {
await ElMessageBox.confirm('删除地区将同时软删除其下属全部医院,确定继续?', '提示', {
type: 'warning'
})
await fetchDeleteCollectionRegion(row.id)
ElMessage.success('删除成功')
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 fetchDeleteCollectionRegion(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
function openHospitalDialog(row: Api.BizCollectionRegion.RegionItem) {
currentRegionId.value = row.id
currentRegionName.value = row.regionName || ''
hospitalPagination.page = 1
hospitalSelected.value = []
hospitalDialogTitle.value = `地区医院配置 — ${row.regionName}`
hospitalDialogVisible.value = true
loadHospitals()
}
async function loadHospitals() {
if (!currentRegionId.value) return
hospitalLoading.value = true
try {
const res = await fetchHospitalList(currentRegionId.value, {
page: hospitalPagination.page,
pageSize: hospitalPagination.pageSize
})
hospitalTable.value = res.list || []
hospitalPagination.total = res.total ?? 0
} finally {
hospitalLoading.value = false
}
}
function onHospitalDialogClosed() {
currentRegionId.value = ''
currentRegionName.value = ''
hospitalTable.value = []
}
function handleAddHospital() {
hospitalIsEdit.value = false
hospitalFormTitle.value = '新增医院'
editingHospitalId.value = null
hospitalForm.hospitalName = ''
hospitalForm.orderNum = 0
hospitalForm.remark = ''
hospitalFormVisible.value = true
hospitalFormRef.value?.clearValidate?.()
}
function handleEditHospital(row: Api.BizCollectionHospital.HospitalItem) {
hospitalIsEdit.value = true
hospitalFormTitle.value = '编辑医院'
editingHospitalId.value = row.id
hospitalForm.hospitalName = row.hospitalName || ''
hospitalForm.orderNum = row.orderNum ?? 0
hospitalForm.remark = row.remark || ''
hospitalFormVisible.value = true
hospitalFormRef.value?.clearValidate?.()
}
async function submitHospital() {
await hospitalFormRef.value?.validate?.()
hospitalSubmitLoading.value = true
try {
const rid = currentRegionId.value
const payload = {
hospitalName: hospitalForm.hospitalName.trim(),
orderNum: hospitalForm.orderNum,
remark: hospitalForm.remark?.trim() || undefined
}
if (hospitalIsEdit.value && editingHospitalId.value) {
await fetchUpdateHospital(rid, editingHospitalId.value, payload)
} else {
await fetchCreateHospital(rid, payload)
}
ElMessage.success(hospitalIsEdit.value ? '更新成功' : '创建成功')
hospitalFormVisible.value = false
await loadHospitals()
} catch {
/* */
} finally {
hospitalSubmitLoading.value = false
}
}
async function handleDeleteHospital(row: Api.BizCollectionHospital.HospitalItem) {
await ElMessageBox.confirm('确定删除该医院吗?', '提示', { type: 'warning' })
await fetchDeleteHospital(currentRegionId.value, row.id)
ElMessage.success('删除成功')
await loadHospitals()
}
async function handleBatchDeleteHospital() {
const ids = hospitalSelected.value.map((r) => r.id)
if (!ids.length) return
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 家医院吗?`, '提示', {
type: 'warning'
})
const rid = currentRegionId.value
await withFullscreenLoading(async () => {
for (const id of ids) {
await fetchDeleteHospital(rid, id)
}
ElMessage.success('批量删除成功')
hospitalSelected.value = []
await loadHospitals()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.biz-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
.hospital-dialog-head {
margin-bottom: 12px;
}
.hospital-dialog-head .muted {
font-size: 13px;
color: var(--mint-text-muted);
}
.hospital-toolbar {
margin-bottom: 0;
}
.hospital-table-wrap {
padding-top: 0;
}
.hospital-cell-line {
line-height: 1.8;
text-align: left;
padding-left: 8px;
}
.muted {
color: var(--mint-text-muted);
}
</style>
@@ -0,0 +1,431 @@
<!-- 客户管理 -->
<!-- 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
/>
</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-icon><Plus /></el-icon>
新增客户
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="selectedRows.length === 0"
@click="handleBatchDelete"
>
批量删除
</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"
@row-dblclick="handleView"
>
<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="customerName"
label="客户姓名"
min-width="120"
align="center"
header-align="center"
/>
<el-table-column prop="sex" label="性别" width="72" align="center" header-align="center">
<template #default="{ row }">{{ sexLabel(row.sex) }}</template>
</el-table-column>
<el-table-column
prop="idCardNo"
label="身份证号"
min-width="160"
align="center"
header-align="center"
/>
<el-table-column
prop="age"
label="年龄"
width="72"
align="center"
header-align="center"
/>
<el-table-column
prop="phoneNo"
label="联系电话"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="customerTags"
label="客户标签"
min-width="140"
show-overflow-tooltip
/>
<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>
</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="720px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-position="top"
class="biz-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="客户姓名" prop="customerName">
<el-input v-model="formData.customerName" placeholder="必填" />
</el-form-item>
<el-form-item label="性别" prop="sex">
<el-select v-model="formData.sex" placeholder="选择" style="width: 100%">
<el-option label="男" value="0" />
<el-option label="女" value="1" />
<el-option label="未知" value="2" />
</el-select>
</el-form-item>
<el-form-item label="身份证号" prop="idCardNo">
<el-input
v-model="formData.idCardNo"
placeholder="可选;填写后租户内不可重复"
clearable
/>
</el-form-item>
<el-form-item label="年龄">
<el-input
type="number"
step="any"
v-model="formData.age"
:min="0"
:max="150"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="联系电话">
<el-input v-model="formData.phoneNo" placeholder="可选" clearable />
</el-form-item>
<el-form-item label="客户标签" class="form-col-span-2">
<el-input v-model="formData.customerTags" placeholder="多个标签用英文逗号分隔" />
</el-form-item>
<el-form-item label="备注" class="form-col-span-2">
<el-input v-model="formData.remark" type="textarea" :rows="2" 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" @click="handleSubmit" :loading="submitLoading">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.customerName || '客户详情'"
:icon="User"
:meta="`身份证:${viewRow?.idCardNo || '—'}${viewRow?.createTime ? ' · ' + viewRow.createTime : ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check, View, User } from '@element-plus/icons-vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchCustomerList,
fetchCreateCustomer,
fetchUpdateCustomer,
fetchDeleteCustomer
} from '@/api/admin'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
defineOptions({ name: 'BizCustomer' })
function sexLabel(s: string) {
if (s === '0') return '男'
if (s === '1') return '女'
return '未知'
}
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.BizCustomer.CustomerItem[]>([])
const selectedRows = ref<Api.BizCustomer.CustomerItem[]>([])
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 viewVisible = ref(false)
const viewRow = ref<Api.BizCustomer.CustomerItem | null>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
return [
{
title: '基本信息',
fields: [
{ label: '客户姓名', value: row.customerName },
{ label: '性别', value: sexLabel(row.sex) },
{ label: '身份证号', value: row.idCardNo },
{ label: '年龄', value: row.age },
{ label: '联系电话', value: row.phoneNo },
{ label: '客户标签', value: row.customerTags, span: true },
{ label: '创建时间', value: row.createTime },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function handleView(row: Api.BizCustomer.CustomerItem) {
viewRow.value = row
viewVisible.value = true
}
const formData = reactive({
customerName: '',
sex: '2',
idCardNo: '',
age: null as number | null,
phoneNo: '',
customerTags: '',
orderNum: 0,
remark: ''
})
const formRules = {
customerName: [{ required: true, message: '请输入客户姓名', trigger: 'blur' }]
}
const handleSelectionChange = (rows: Api.BizCustomer.CustomerItem[]) => {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchCustomerList({
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.customerName = ''
formData.sex = '2'
formData.idCardNo = ''
formData.age = null
formData.phoneNo = ''
formData.customerTags = ''
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.BizCustomer.CustomerItem) {
isEdit.value = true
dialogTitle.value = '编辑客户'
editingId.value = row.id
formData.customerName = row.customerName || ''
formData.sex = row.sex || '2'
formData.idCardNo = row.idCardNo || ''
formData.age = row.age ?? null
formData.phoneNo = row.phoneNo || ''
formData.customerTags = row.customerTags || ''
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 = {
customerName: formData.customerName.trim(),
sex: formData.sex,
idCardNo: formData.idCardNo?.trim() || undefined,
age: formData.age,
phoneNo: formData.phoneNo?.trim() || undefined,
customerTags: formData.customerTags?.trim() || undefined,
orderNum: formData.orderNum,
remark: formData.remark?.trim() || undefined
}
if (isEdit.value && editingId.value) {
await fetchUpdateCustomer(editingId.value, payload)
} else {
await fetchCreateCustomer(payload)
}
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
dialogVisible.value = false
await loadData()
} catch {
/* 全局处理 */
} finally {
submitLoading.value = false
}
}
async function handleDelete(row: Api.BizCustomer.CustomerItem) {
await ElMessageBox.confirm('确定要删除该客户吗?', '提示', { type: 'warning' })
await fetchDeleteCustomer(row.id)
ElMessage.success('删除成功')
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 fetchDeleteCustomer(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.biz-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
</style>
@@ -0,0 +1,710 @@
<!-- 样本编码管理 -->
<!-- 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 />
</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-icon><Plus /></el-icon>
新增样本编码
</el-button>
<el-button class="btn-ghost" @click="openBatchGenerate">
批量生成
</el-button>
<el-button
class="btn-ghost"
:disabled="selectedRows.length === 0"
@click="openBatchIssue"
>
批量下发
</el-button>
<el-button
class="btn-ghost"
:disabled="selectedRows.length === 0"
@click="handleBatchRevoke"
>
批量收回
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="selectedRows.length === 0"
@click="handleBatchDelete"
>
批量删除
</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"
@row-dblclick="handleView"
>
<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="sampleCode"
label="样本编码"
min-width="160"
align="center"
header-align="center"
/>
<el-table-column
prop="sampleCodeType"
label="编码类型"
width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{ sampleCodeTypeLabel(row.sampleCodeType) }}</template>
</el-table-column>
<el-table-column
prop="issued"
label="是否下发"
width="80"
align="center"
header-align="center"
>
<template #default="{ row }">
<span>{{ row.issued === 1 ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column
prop="issuedUserName"
label="下发对象"
min-width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{ row.issuedUserName || '-' }}</template>
</el-table-column>
<el-table-column
prop="issuedTime"
label="下发时间"
min-width="180"
align="center"
header-align="center"
>
<template #default="{ row }">{{ row.issuedTime || '-' }}</template>
</el-table-column>
<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>
</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="batchGenVisible"
title="批量生成样本编码"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="batchGenFormRef"
:model="batchGenForm"
:rules="batchGenRules"
label-position="top"
scroll-to-error
>
<div class="form-grid-2">
<el-form-item label="编码类型" prop="sampleCodeType">
<el-select v-model="batchGenForm.sampleCodeType" placeholder="请选择" style="width: 100%">
<el-option label="造血编码 (ZKZX)" value="zxbm" />
<el-option label="脐带编码 (ZKQD)" value="qdbm" />
</el-select>
</el-form-item>
<el-form-item label="中间段" prop="middle">
<el-input v-model="batchGenForm.middle" placeholder="如 34" />
</el-form-item>
<el-form-item label="开始序号" prop="seqStart">
<el-input
type="number"
step="any"
v-model="batchGenForm.seqStart"
:min="0"
:max="99999"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="结束序号" prop="seqEnd">
<el-input
type="number"
step="any"
v-model="batchGenForm.seqEnd"
:min="0"
:max="99999"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="序号位数" prop="digitCount">
<template #label
>序号位数<span class="form-label-tip">补零后的总位数</span></template
>
<el-input
type="number"
step="any"
v-model="batchGenForm.digitCount"
:min="1"
:max="10"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="预览" class="form-col-span-2">
<span class="text-sm text-gray-500">{{ batchGenPreview }}</span>
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="batchGenVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" :loading="batchGenLoading" @click="handleBatchGenerate">
<el-icon><Check /></el-icon>
生成
</el-button>
</template>
</el-dialog>
<!-- 批量下发弹窗 -->
<el-dialog
v-model="batchIssueVisible"
title="批量下发样本编码"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="batchIssueFormRef"
:model="batchIssueForm"
:rules="batchIssueRules"
label-position="top"
scroll-to-error
>
<el-form-item label="下发用户" prop="issuedUserId">
<el-select
v-model="batchIssueForm.issuedUserId"
placeholder="请选择用户"
filterable
style="width: 100%"
>
<el-option
v-for="opt in userOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
<el-form-item label="已选编码">
<span class="text-sm text-gray-500">
已选 {{ selectedRows.length }} 条,下发后"是否下发"将变为"是"
</span>
</el-form-item>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="batchIssueVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" :loading="batchIssueLoading" @click="handleBatchIssue">
<el-icon><Check /></el-icon>
确定下发
</el-button>
</template>
</el-dialog>
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-position="top"
class="biz-dialog-form"
scroll-to-error
>
<div class="form-grid-2">
<el-form-item label="样本编码" prop="sampleCode">
<el-input
v-model="formData.sampleCode"
placeholder="租户内唯一,最多32位"
maxlength="32"
/>
</el-form-item>
<el-form-item v-if="isEdit" label="编码类型">
<span class="text-sm text-gray-500">{{ sampleCodeTypeLabel(formData.sampleCodeType) }}</span>
</el-form-item>
<el-form-item label="是否下发">
<el-switch
v-model="formData.issued"
:active-value="1"
:inactive-value="0"
inline-prompt
active-text="是"
inactive-text="否"
/>
</el-form-item>
<el-form-item v-if="formData.issued === 1" label="下发用户">
<el-select
v-model="formData.issuedUserId"
placeholder="请选择用户"
filterable
style="width: 100%"
>
<el-option
v-for="opt in userOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="formData.issued === 1 && formData.issuedTime" label="下发时间">
<span class="text-sm text-gray-500">{{ formData.issuedTime }}</span>
</el-form-item>
<el-form-item label="备注" class="form-col-span-2">
<el-input v-model="formData.remark" type="textarea" :rows="2" 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" @click="handleSubmit" :loading="submitLoading">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.sampleCode || '样本编码详情'"
:icon="Ticket"
:meta="`编码类型:${sampleCodeTypeLabel(viewRow?.sampleCodeType || '')}${viewRow?.createTime ? ' · ' + viewRow.createTime : ''}`"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Close, Check, View, Ticket } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchSampleCodeList,
fetchCreateSampleCode,
fetchUpdateSampleCode,
fetchDeleteSampleCode,
fetchUserOptions,
fetchBatchGenerateSampleCodes,
fetchBatchIssueSampleCodes,
fetchBatchRevokeSampleCodes
} from '@/api/admin'
defineOptions({ name: 'BizSampleCode' })
function sampleCodeTypeLabel(t: string) {
if (t === 'zxbm') return '造血编码'
if (t === 'qdbm') return '脐带编码'
return t || '-'
}
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<Api.BizSampleCode.SampleCodeItem[]>([])
const selectedRows = ref<Api.BizSampleCode.SampleCodeItem[]>([])
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 viewVisible = ref(false)
const viewRow = ref<Api.BizSampleCode.SampleCodeItem | null>(null)
const viewSections = computed(() => {
const row = viewRow.value
if (!row) return []
return [
{
title: '基本信息',
fields: [
{ label: '样本编码', value: row.sampleCode },
{ label: '编码类型', value: sampleCodeTypeLabel(row.sampleCodeType) },
{ label: '是否下发', value: row.issued === 1 ? '是' : '否' },
{ label: '下发对象', value: row.issuedUserName || '-' },
{ label: '下发时间', value: row.issuedTime || '-' },
{ label: '创建时间', value: row.createTime },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function handleView(row: Api.BizSampleCode.SampleCodeItem) {
viewRow.value = row
viewVisible.value = true
}
// --- 批量生成 ---
const batchGenVisible = ref(false)
const batchGenLoading = ref(false)
const batchGenFormRef = ref()
const batchGenForm = reactive({
sampleCodeType: 'zxbm',
middle: '34',
seqStart: 1,
seqEnd: 100,
digitCount: 6,
})
const batchGenRules = {
sampleCodeType: [{ required: true, message: '请选择编码类型', trigger: 'change' }],
middle: [{ required: true, message: '请输入中间段', trigger: 'blur' }],
seqStart: [{ required: true, message: '请输入开始序号', trigger: 'blur' }],
seqEnd: [{ required: true, message: '请输入结束序号', trigger: 'blur' }],
digitCount: [{ required: true, message: '请输入序号位数', trigger: 'blur' }],
}
const typePrefixMap: Record<string, string> = { zxbm: 'ZKZX', qdbm: 'ZKQD' }
const batchGenPreview = computed(() => {
const t = batchGenForm.sampleCodeType || ''
const m = batchGenForm.middle || ''
const s = batchGenForm.seqStart ?? 0
const e = batchGenForm.seqEnd ?? 0
const d = batchGenForm.digitCount ?? 6
const prefix = typePrefixMap[t] || ''
if (!prefix || e < s) return '—'
const first = `${prefix}${m}${String(s).padStart(d, '0')}`
const last = `${prefix}${m}${String(e).padStart(d, '0')}`
return `${first} ~ ${last}(共 ${e - s + 1} 条)`
})
// --- 批量下发 ---
const batchIssueVisible = ref(false)
const batchIssueLoading = ref(false)
const batchIssueFormRef = ref()
const batchIssueForm = reactive({
issuedUserId: '',
})
const batchIssueRules = {
issuedUserId: [{ required: true, message: '请选择下发用户', trigger: 'change' }],
}
const userOptions = ref<Array<{ label: string; value: string }>>([])
const formData = reactive({
sampleCode: '',
sampleCodeType: '',
issued: 0,
issuedUserId: '',
issuedUserName: '',
issuedTime: '',
orderNum: 0,
remark: ''
})
const formRules = {
sampleCode: [{ required: true, message: '请输入样本编码', trigger: 'blur' }]
}
const handleSelectionChange = (rows: Api.BizSampleCode.SampleCodeItem[]) => {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchSampleCodeList({
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.sampleCode = ''
formData.sampleCodeType = ''
formData.issued = 0
formData.issuedUserId = ''
formData.issuedUserName = ''
formData.issuedTime = ''
formData.orderNum = 0
formData.remark = ''
editingId.value = null
}
function handleAdd() {
isEdit.value = false
dialogTitle.value = '新增样本编码'
resetForm()
dialogVisible.value = true
formRef.value?.clearValidate?.()
}
async function handleEdit(row: Api.BizSampleCode.SampleCodeItem) {
isEdit.value = true
dialogTitle.value = '编辑样本编码'
editingId.value = row.id
formData.sampleCode = row.sampleCode || ''
formData.sampleCodeType = row.sampleCodeType || ''
formData.issued = row.issued === 1 ? 1 : 0
formData.issuedUserId = row.issuedUserId || ''
formData.issuedUserName = row.issuedUserName || ''
formData.issuedTime = row.issuedTime || ''
formData.orderNum = row.orderNum ?? 0
formData.remark = row.remark || ''
dialogVisible.value = true
formRef.value?.clearValidate?.()
if (!userOptions.value.length) {
try {
userOptions.value = await fetchUserOptions()
} catch { /* ignore */ }
}
}
async function handleSubmit() {
await formRef.value?.validate?.()
submitLoading.value = true
try {
const payload = {
sampleCode: formData.sampleCode.trim(),
issued: formData.issued,
issuedUserId: formData.issued === 1 ? formData.issuedUserId || undefined : null,
issuedUserName: formData.issued === 1 ? formData.issuedUserName || undefined : null,
issuedTime: formData.issuedTime || undefined,
orderNum: formData.orderNum,
remark: formData.remark?.trim() || undefined
}
if (isEdit.value && editingId.value) {
await fetchUpdateSampleCode(editingId.value, payload)
} else {
await fetchCreateSampleCode(payload)
}
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
dialogVisible.value = false
await loadData()
} catch {
/* */
} finally {
submitLoading.value = false
}
}
async function handleDelete(row: Api.BizSampleCode.SampleCodeItem) {
await ElMessageBox.confirm('确定要删除该样本编码吗?', '提示', { type: 'warning' })
await fetchDeleteSampleCode(row.id)
ElMessage.success('删除成功')
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 fetchDeleteSampleCode(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
async function handleBatchRevoke() {
const ids = selectedRows.value.map((r) => r.id)
if (!ids.length) return
await ElMessageBox.confirm(
`确定收回选中的 ${ids.length} 条吗?收回后将清除下发信息。`,
'提示',
{ type: 'warning' }
)
await withFullscreenLoading(async () => {
await fetchBatchRevokeSampleCodes(ids)
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
// --- 批量生成 ---
function openBatchGenerate() {
batchGenForm.sampleCodeType = 'zxbm'
batchGenForm.middle = '34'
batchGenForm.seqStart = 1
batchGenForm.seqEnd = 100
batchGenForm.digitCount = 6
batchGenVisible.value = true
}
async function handleBatchGenerate() {
await batchGenFormRef.value?.validate?.()
if (batchGenForm.seqStart > batchGenForm.seqEnd) {
ElMessage.warning('开始序号不能大于结束序号')
return
}
batchGenLoading.value = true
try {
await fetchBatchGenerateSampleCodes({
sampleCodeType: batchGenForm.sampleCodeType,
middle: batchGenForm.middle.trim(),
seqStart: batchGenForm.seqStart,
seqEnd: batchGenForm.seqEnd,
digitCount: batchGenForm.digitCount,
})
batchGenVisible.value = false
await loadData()
} finally {
batchGenLoading.value = false
}
}
// --- 批量下发 ---
async function openBatchIssue() {
if (!selectedRows.value.length) return
batchIssueForm.issuedUserId = ''
batchIssueVisible.value = true
if (!userOptions.value.length) {
try {
userOptions.value = await fetchUserOptions()
} catch { /* ignore */ }
}
}
async function handleBatchIssue() {
await batchIssueFormRef.value?.validate?.()
batchIssueLoading.value = true
try {
const ids = selectedRows.value.map(r => r.id)
const userOpt = userOptions.value.find(u => u.value === batchIssueForm.issuedUserId)
await fetchBatchIssueSampleCodes({
ids,
issuedUserId: batchIssueForm.issuedUserId,
issuedUserName: userOpt?.label || undefined,
})
batchIssueVisible.value = false
selectedRows.value = []
await loadData()
} finally {
batchIssueLoading.value = false
}
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.biz-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
</style>
@@ -0,0 +1,107 @@
<!-- 分期缴费预警 -->
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<div class="page-container">
<header class="page-head">
<h1>分期缴费预警</h1>
<p class="page-desc">仅展示待缴费分期;预警窗口为未来 15 天内应缴;逾期为应缴日早于今日。</p>
</header>
<section class="panel">
<div class="panel-top">
<h2 class="title-bar-heading">分期预警列表</h2>
</div>
<div class="filter-block">
<el-form class="filter-form" @submit.prevent>
<div class="filter-grid">
<el-form-item label="范围">
<el-select v-model="warningType" style="width: 100%" @change="handleSearch">
<el-option label="全部" value="all" />
<el-option label="预警(15天内)" value="warn" />
<el-option label="逾期" value="overdue" />
</el-select>
</el-form-item>
</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" />
<el-table-column prop="protocolNo" label="协议号" min-width="130" align="center" header-align="center" />
<el-table-column prop="installmentNo" label="期数" width="80" align="center" header-align="center" />
<el-table-column prop="installmentDueDate" label="应缴日" width="120" align="center" header-align="center" />
<el-table-column prop="warningType" label="分级" width="100" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="warningTagType(String(row.warningType || ''))" effect="plain">{{
warningTypeLabel(String(row.warningType || ''))
}}</el-tag>
</template>
</el-table-column>
<el-table-column prop="transferAmount" label="金额" width="120" align="center" header-align="center" />
</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>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { fetchInstallmentWarningList } from '@/api/collection-protocol'
defineOptions({ name: 'CellStorageInstallmentWarning' })
function warningTypeLabel(w: string) {
if (w === 'overdue') return '逾期'
if (w === 'warn') return '预警'
if (w === 'upcoming') return '未到期'
return '其他'
}
function warningTagType(w: string) {
if (w === 'overdue') return 'danger'
if (w === 'warn') return 'warning'
return 'info'
}
const warningType = ref('all')
const tableData = ref<Record<string, unknown>[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
async function loadData() {
loading.value = true
try {
const res = await fetchInstallmentWarningList({
page: pagination.page,
pageSize: pagination.pageSize,
warningType: warningType.value
})
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
loadData()
}
onMounted(() => {
loadData()
})
</script>
@@ -0,0 +1,125 @@
<!-- 收款确认(财务) -->
<!-- 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="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" />
<el-table-column prop="protocolNo" label="协议号" min-width="130" align="center" header-align="center" />
<el-table-column prop="installmentNo" label="期数" width="80" align="center" header-align="center" />
<el-table-column prop="installmentDueDate" label="应缴日" width="120" align="center" header-align="center" />
<el-table-column prop="transferAmount" label="金额" width="120" align="center" header-align="center" />
<el-table-column prop="payStatus" label="状态" width="120" align="center" header-align="center">
<template #default>缴费确认中</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
<el-table-column label="操作" width="140" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="openConfirm(row)">确认收款</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="确认收款"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
>
<el-form label-position="top" class="biz-dialog-form">
<el-form-item label="财务确认附件(MinIO 地址,逗号分隔,可选)">
<el-input v-model="confirmAttachments" type="textarea" :rows="3" placeholder="可选" />
</el-form-item>
</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="submitConfirm">
<el-icon><Check /></el-icon>
确认
</el-button>
</template>
</el-dialog>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { Close, Check } from '@element-plus/icons-vue'
import { fetchReceiptConfirmList, fetchReceiptConfirmSubmit } from '@/api/collection-protocol'
defineOptions({ name: 'CellStoragePaymentConfirm' })
const tableData = ref<Record<string, unknown>[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const dialogVisible = ref(false)
const submitLoading = ref(false)
const confirmAttachments = ref('')
const currentDetailId = ref<string | null>(null)
async function loadData() {
loading.value = true
try {
const res = await fetchReceiptConfirmList({
page: pagination.page,
pageSize: pagination.pageSize
})
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function openConfirm(row: Record<string, unknown>) {
currentDetailId.value = String(row.id)
confirmAttachments.value = ''
dialogVisible.value = true
}
async function submitConfirm() {
if (!currentDetailId.value) return
submitLoading.value = true
try {
await fetchReceiptConfirmSubmit(currentDetailId.value, {
financeConfirmAttachments: confirmAttachments.value || undefined
})
dialogVisible.value = false
loadData()
} finally {
submitLoading.value = false
}
}
onMounted(() => {
loadData()
})
</script>
@@ -0,0 +1,410 @@
<!-- 采集协议单审核 -->
<!-- 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 />
</el-form-item>
<el-form-item label="协议状态">
<el-select
v-model="searchForm.protocolStatus"
clearable
placeholder="全部"
style="width: 100%"
>
<el-option label="待生效" value="dsx" />
<el-option label="生效中" value="sxz" />
<el-option label="已过期" value="ygq" />
<el-option label="已作废" value="yzf" />
<el-option label="转科研" value="zky" />
</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-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
</div>
<el-button type="primary" class="btn-main" @click="handleAdd">
<el-icon><Plus /></el-icon>
新增
</el-button>
<el-button class="btn-ghost" :disabled="!selectedRows.length" @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"
@row-dblclick="handleView"
>
<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="protocolNo"
label="协议号"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="protocolStatus"
label="状态"
width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{
protocolStatusLabel(String(row.protocolStatus || ''))
}}</template>
</el-table-column>
<el-table-column
prop="registerDate"
label="登记日期"
width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="motherName"
label="母亲姓名"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="motherPhone"
label="母亲电话"
min-width="130"
align="center"
header-align="center"
/>
<el-table-column
prop="motherIdCard"
label="母亲身份证号"
min-width="190"
align="center"
header-align="center"
/>
<el-table-column
prop="fatherName"
label="父亲姓名"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="newbornSex"
label="新生儿性别"
width="110"
align="center"
header-align="center"
>
<template #default="{ row }">{{
newbornSexLabel(String(row.newbornSex || ''))
}}</template>
</el-table-column>
<el-table-column
prop="deliveryMode"
label="分娩方式"
width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{
deliveryModeLabel(String(row.deliveryMode || ''))
}}</template>
</el-table-column>
<el-table-column
prop="newbornWeightGram"
label="新生儿体重(克)"
width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="regionName"
label="采集地区"
min-width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="hospitalName"
label="采集医院"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="collectorUserName"
label="采集专员"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="salesUserName"
label="销售人员"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="sampleCollectTime"
label="样本采集时间"
min-width="180"
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-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>
<!-- 新增/编辑弹窗 -->
<ProtocolFormDialog
v-model="formDialogVisible"
:edit-id="formDialogEditId"
:list-row="formDialogRow"
@saved="onFormSaved"
/>
<!-- 查看弹窗 -->
<ProtocolViewDialog v-model="viewVisible" :protocol-id="viewProtocolId" :list-row="viewRow" />
</section>
</div>
</template>
<script setup lang="ts">
import { ElMessage, ElMessageBox } from 'element-plus'
import {
Plus,
View,
Edit,
Delete,
Search,
RefreshLeft
} from '@element-plus/icons-vue'
import ProtocolFormDialog from '../protocol/ProtocolFormDialog.vue'
import ProtocolViewDialog from '../protocol/ProtocolViewDialog.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchCollectionProtocolList,
fetchDeleteCollectionProtocol,
type CollectionProtocolRow
} from '@/api/collection-protocol'
defineOptions({ name: 'CellStorageProtocolAudit' })
/* ====== 标签映射 ====== */
function protocolStatusLabel(s: string) {
const m: Record<string, string> = {
dsx: '待生效',
sxz: '生效中',
ygq: '已过期',
yzf: '已作废',
zky: '转科研'
}
return m[s] || s || '-'
}
function newbornSexLabel(s: string) {
if (s === '1') return '男'
if (s === '0') return '女'
return s || '-'
}
function deliveryModeLabel(s: string) {
if (s === 'sc') return '顺产'
if (s === 'pgc') return '剖宫产'
return s || '-'
}
/* ====== 列表 ====== */
const searchForm = reactive<{ keyword: string; protocolStatus: string }>({
keyword: '',
protocolStatus: ''
})
const tableData = ref<CollectionProtocolRow[]>([])
const selectedRows = ref<CollectionProtocolRow[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const handleSelectionChange = (rows: CollectionProtocolRow[]) => {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchCollectionProtocolList({
page: pagination.page,
pageSize: pagination.pageSize,
keyword: searchForm.keyword || undefined,
protocolStatus: searchForm.protocolStatus || 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.protocolStatus = ''
pagination.page = 1
loadData()
}
/* ====== 查看弹窗 ====== */
const viewVisible = ref(false)
const viewProtocolId = ref<string | null>(null)
const viewRow = ref<CollectionProtocolRow | null>(null)
function handleView(row: CollectionProtocolRow) {
viewProtocolId.value = String(row.id)
viewRow.value = row
viewVisible.value = true
}
/* ====== 新增/编辑弹窗 ====== */
const formDialogVisible = ref(false)
const formDialogEditId = ref<string | null>(null)
const formDialogRow = ref<CollectionProtocolRow | null>(null)
function handleAdd() {
formDialogEditId.value = null
formDialogRow.value = null
formDialogVisible.value = true
}
function handleEdit(row: CollectionProtocolRow) {
formDialogEditId.value = row.id
formDialogRow.value = row
formDialogVisible.value = true
}
function onFormSaved() {
loadData()
}
/* ====== 删除 ====== */
function handleDelete(row: CollectionProtocolRow) {
ElMessageBox.confirm(`确认删除协议号「${row.protocolNo}」?`, '删除确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
await fetchDeleteCollectionProtocol(String(row.id))
loadData()
})
.catch(() => {})
}
async function handleBatchDelete() {
if (!selectedRows.value.length) return
await ElMessageBox.confirm(`确认删除选中的 ${selectedRows.value.length} 条记录?`, '批量删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
const rows = [...selectedRows.value]
await withFullscreenLoading(async () => {
for (const row of rows) {
await fetchDeleteCollectionProtocol(String(row.id))
}
ElMessage.success('批量删除成功')
selectedRows.value = []
loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
loadData()
})
</script>
@@ -0,0 +1,208 @@
<!-- 采集协议单 — 只读附件列表(样式对齐新增/编辑弹窗 attachment-upload) -->
<template>
<span v-if="!files.length" class="protocol-attachment-empty">暂无附件</span>
<div v-else class="attachment-upload">
<div class="attachment-list">
<div
v-for="(file, index) in files"
:key="file.id || file.fileUrl || index"
class="attachment-item"
>
<div
class="attachment-preview"
@click="isImageFile(file) && file.fileUrl ? emit('preview', file) : undefined"
>
<template v-if="isImageFile(file) && file.fileUrl">
<img :src="resolveFileUrl(file.fileUrl)" :alt="file.fileName" />
</template>
<template v-else-if="isVideoFile(file)">
<div class="attachment-preview__icon attachment-preview__icon--video">
<el-icon :size="28"><VideoPlay /></el-icon>
</div>
</template>
<template v-else>
<div class="attachment-preview__icon attachment-preview__icon--doc">
<el-icon :size="28"><Document /></el-icon>
</div>
</template>
</div>
<div class="attachment-footer">
<span class="attachment-name" :title="file.fileName">{{
file.fileName || '未命名'
}}</span>
<div class="attachment-actions">
<el-icon class="action-btn" title="下载" @click.stop="emit('download', file)">
<Download />
</el-icon>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { Document, Download, VideoPlay } from '@element-plus/icons-vue'
defineProps<{
files: Array<Record<string, any>>
}>()
const emit = defineEmits<{
(e: 'preview', file: Record<string, any>): void
(e: 'download', file: Record<string, any>): void
}>()
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
function resolveFileUrl(suffix: string) {
if (!suffix) return ''
if (suffix.startsWith('http://') || suffix.startsWith('https://') || suffix.startsWith('/')) {
return suffix
}
return `${minioBaseUrl}/${suffix}`
}
function isImageFile(file: { fileType?: string; fileName?: string; fileUrl?: string }) {
const url = (file.fileUrl || '').toLowerCase()
const name = (file.fileName || '').toLowerCase()
return (
/\.(jpg|jpeg|png|gif|bmp|webp|svg)(\?|$)/.test(url) ||
/\.(jpg|jpeg|png|gif|bmp|webp|svg)$/.test(name) ||
(file.fileType || '').startsWith('image/')
)
}
function isVideoFile(file: { fileType?: string; fileName?: string; fileUrl?: string }) {
const url = (file.fileUrl || '').toLowerCase()
const name = (file.fileName || '').toLowerCase()
return (
/\.(mp4|webm|ogg|mov|avi)(\?|$)/.test(url) ||
/\.(mp4|webm|ogg|mov|avi)$/.test(name) ||
(file.fileType || '').startsWith('video/')
)
}
</script>
<style scoped lang="scss">
.protocol-attachment-empty {
font-size: 13px;
color: #94a3b8;
}
.attachment-upload {
width: 100%;
}
.attachment-list {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.attachment-item {
width: 140px;
display: flex;
flex-direction: column;
border: 1px solid #e2e8f0;
border-radius: 8px;
background: #fff;
overflow: hidden;
transition:
border-color 0.15s,
box-shadow 0.15s;
&:hover {
border-color: #10b981;
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}
}
.attachment-preview {
width: 100%;
height: 96px;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
background: #f8fafc;
overflow: hidden;
cursor: pointer;
img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
}
.attachment-preview__icon {
width: 48px;
height: 48px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
&--video {
background: #ede9fe;
color: #7c3aed;
}
&--doc {
background: #e0f2fe;
color: #0284c7;
}
}
.attachment-footer {
display: flex;
flex-direction: column;
flex: 1;
padding: 6px 8px;
}
.attachment-name {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
font-size: 11px;
color: #334155;
line-height: 1.4;
word-break: break-all;
min-height: calc(11px * 1.4 * 2);
}
.attachment-actions {
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
margin-top: 4px;
flex-shrink: 0;
}
.action-btn {
width: 22px;
height: 22px;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: #64748b;
cursor: pointer;
background: #f1f5f9;
transition:
background 0.15s,
color 0.15s;
&:hover {
background: #10b981;
color: #fff;
}
}
</style>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,865 @@
<!-- 采集协议单 — 只读查看(字段与新增/编辑弹窗一致) -->
<template>
<el-dialog
:model-value="modelValue"
:title="dialogTitle"
width="1600px"
class="dialog-form-layout protocol-view-dialog"
align-center
destroy-on-close
:close-on-click-modal="false"
@update:model-value="emit('update:modelValue', $event)"
@closed="handleClosed"
>
<div v-loading="loading" class="protocol-view-body">
<div class="detail-tabs">
<div
v-for="tab in formTabs"
:key="tab.key"
class="detail-tab"
:class="{ active: activeTab === tab.key }"
@click="scrollToSection(tab.key)"
>
{{ tab.label }}
</div>
</div>
<template v-if="bundle">
<!-- 基本信息 -->
<div id="view-section-basic" class="form-tab-pane">
<dl class="view-kv-grid view-kv-grid--5">
<div class="view-kv">
<dt>协议号</dt>
<dd>{{ dash(protocol?.protocolNo) }}</dd>
</div>
<div class="view-kv">
<dt>协议状态</dt>
<dd>{{ protocolStatusLabel(String(protocol?.protocolStatus || '')) }}</dd>
</div>
<div class="view-kv">
<dt>登记日期</dt>
<dd>{{ formatYmd(protocol?.registerDate) }}</dd>
</div>
<div class="view-kv">
<dt>采集专员</dt>
<dd>{{ collectorDisplay }}</dd>
</div>
<div class="view-kv">
<dt>创建时间</dt>
<dd>{{ dash(protocol?.createTime) }}</dd>
</div>
<div class="view-field-block view-kv-span-2">
<div class="view-field-block__label">协议附件</div>
<ProtocolAttachmentReadonly
:files="protocolAttachments"
@preview="openPreview"
@download="downloadFile"
/>
</div>
<div class="view-kv view-kv-span-2">
<dt>备注</dt>
<dd>{{ dash(protocol?.remark) }}</dd>
</div>
</dl>
</div>
<!-- 客户信息 -->
<div id="view-section-party" class="form-tab-pane">
<h3 class="detail-section-title">母亲信息</h3>
<dl class="view-kv-grid view-kv-grid--5">
<div class="view-kv">
<dt>关联客户</dt>
<dd>{{ partyCustomer?.customerId ? dash(partyCustomer?.motherName) : '—' }}</dd>
</div>
<div class="view-kv">
<dt>母亲姓名</dt>
<dd>{{ dash(partyCustomer?.motherName) }}</dd>
</div>
<div class="view-kv">
<dt>母亲联系电话</dt>
<dd>{{ dash(partyCustomer?.motherPhone) }}</dd>
</div>
<div class="view-kv">
<dt>母亲身份证号</dt>
<dd>{{ dash(partyCustomer?.motherIdCard) }}</dd>
</div>
<div class="view-kv">
<dt>母亲出生年月</dt>
<dd>{{ formatYm(partyCustomer?.motherBirthYm) }}</dd>
</div>
<div class="view-kv">
<dt>母亲民族</dt>
<dd>{{ dash(partyCustomer?.motherEthnic) }}</dd>
</div>
<div class="view-kv view-kv-span-2">
<dt>母亲家庭住址</dt>
<dd>{{ dash(partyCustomer?.motherAddress) }}</dd>
</div>
</dl>
<div class="form-section-divider" />
<h3 class="detail-section-title">父亲信息</h3>
<dl class="view-kv-grid view-kv-grid--5">
<div class="view-kv">
<dt>父亲姓名</dt>
<dd>{{ dash(partyCustomer?.fatherName) }}</dd>
</div>
<div class="view-kv">
<dt>父亲电话</dt>
<dd>{{ dash(partyCustomer?.fatherPhone) }}</dd>
</div>
<div class="view-kv">
<dt>父亲身份证号</dt>
<dd>{{ dash(partyCustomer?.fatherIdCard) }}</dd>
</div>
</dl>
<div class="form-section-divider" />
<h3 class="detail-section-title">新生儿信息</h3>
<dl class="view-kv-grid view-kv-grid--5">
<div class="view-kv">
<dt>新生儿姓名</dt>
<dd>{{ dash(partyCustomer?.newbornName) }}</dd>
</div>
<div class="view-kv">
<dt>新生儿身份证</dt>
<dd>{{ dash(partyCustomer?.newbornIdCard) }}</dd>
</div>
<div class="view-kv">
<dt>新生儿分娩时间</dt>
<dd>{{ dash(partyCustomer?.newbornDeliveryTime) }}</dd>
</div>
<div class="view-kv">
<dt>新生儿性别</dt>
<dd>{{ newbornSexLabel(String(partyCustomer?.newbornSex || '')) }}</dd>
</div>
<div class="view-kv">
<dt>分娩方式</dt>
<dd>{{ deliveryModeLabel(String(partyCustomer?.deliveryMode || '')) }}</dd>
</div>
<div class="view-kv">
<dt>胎次</dt>
<dd>{{ dash(partyCustomer?.birthOrder) }}</dd>
</div>
<div class="view-kv">
<dt>新生儿体重(克)</dt>
<dd>{{ dash(partyCustomer?.newbornWeightGram) }}</dd>
</div>
<div class="view-kv">
<dt>新生儿评分1分钟</dt>
<dd>{{ dash(partyCustomer?.apgar1min) }}</dd>
</div>
<div class="view-kv">
<dt>新生儿评分5分钟</dt>
<dd>{{ dash(partyCustomer?.apgar5min) }}</dd>
</div>
</dl>
</div>
<!-- 采集信息 -->
<div id="view-section-collection" class="form-tab-pane">
<dl class="view-kv-grid view-kv-grid--5">
<div class="view-kv">
<dt>采集地区</dt>
<dd>{{ regionDisplay }}</dd>
</div>
<div class="view-kv">
<dt>采集医院</dt>
<dd>{{ hospitalDisplay }}</dd>
</div>
<div class="view-kv">
<dt>采集医护</dt>
<dd>{{ dash(collectionInfo?.medicalStaff) }}</dd>
</div>
<div class="view-kv">
<dt>销售人员</dt>
<dd>{{ salesDisplay }}</dd>
</div>
<div class="view-kv">
<dt>样本采集时间</dt>
<dd>{{ dash(collectionInfo?.sampleCollectTime) }}</dd>
</div>
<div class="view-kv">
<dt>母血采集时间</dt>
<dd>{{ dash(collectionInfo?.maternalBloodCollectTime) }}</dd>
</div>
</dl>
</div>
<!-- 样本及运输 -->
<div id="view-section-sample" class="form-tab-pane">
<el-table :data="samples" row-key="id" stripe border size="small" class="sub-view-table">
<el-table-column label="样本类型" min-width="140">
<template #default="{ row }">{{ sampleTypeName(row.sampleTypeId) }}</template>
</el-table-column>
<el-table-column prop="sampleCode" label="样本编码" min-width="140" />
<el-table-column prop="collectAmount" label="采集量" width="100" align="center" />
<el-table-column label="单位" width="100" align="center">
<template #default="{ row }">{{ unitName(row.unitId) }}</template>
</el-table-column>
<el-table-column prop="price" label="价格" width="100" align="center" />
<el-table-column prop="storageYears" label="存储年限(年)" width="120" align="center" />
<el-table-column label="样本状态" width="100" align="center">
<template #default="{ row }">{{
sampleStatusLabel(String(row.sampleStatus || ''))
}}</template>
</el-table-column>
<el-table-column label="运输类型" width="100" align="center">
<template #default="{ row }">
{{ transportTypeLabel(String(row.transport?.transportType || '')) }}
</template>
</el-table-column>
<el-table-column label="目的站点" min-width="110" show-overflow-tooltip>
<template #default="{ row }">
{{ siteName(String(row.transport?.destSiteId || '')) }}
</template>
</el-table-column>
<el-table-column label="预计到达" min-width="150" show-overflow-tooltip>
<template #default="{ row }">
{{ dash(row.transport?.etaTime) }}
</template>
</el-table-column>
<el-table-column label="快递/携带" min-width="160" show-overflow-tooltip>
<template #default="{ row }">
{{ sampleTransportExtra(row.transport) }}
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
</el-table>
<el-empty v-if="!samples.length" description="暂无样本" :image-size="48" />
</div>
<!-- 缴费信息 -->
<div id="view-section-payment" class="form-tab-pane">
<h3 class="detail-section-title">缴费主表</h3>
<dl class="view-kv-grid view-kv-grid--5">
<div class="view-kv">
<dt>缴费模式</dt>
<dd>{{ payModeLabel(String(payment?.payMode || '')) }}</dd>
</div>
<div class="view-kv">
<dt>合同金额</dt>
<dd>{{ dash(payment?.contractAmount) }}</dd>
</div>
<template v-if="payment?.payMode === 'dj'">
<div class="view-kv">
<dt>趸交截止时间</dt>
<dd>{{ formatYmd(payment?.lumpSumDeadline) }}</dd>
</div>
</template>
<template v-if="payment?.payMode === 'fq'">
<div class="view-kv">
<dt>分期期数</dt>
<dd>{{ dash(payment?.installmentCount) }}</dd>
</div>
<div class="view-kv">
<dt>每期间隔(月)</dt>
<dd>{{ dash(payment?.installmentIntervalMonths) }}</dd>
</div>
<div class="view-kv">
<dt>分期开始时间</dt>
<dd>{{ formatYmd(payment?.installmentStartDate) }}</dd>
</div>
</template>
</dl>
<div class="form-section-divider" />
<h3 class="detail-section-title">缴费明细</h3>
<div v-if="paymentDetails.length" class="payment-detail-cards">
<div
v-for="(detail, dIdx) in paymentDetails"
:key="detail.id || dIdx"
class="payment-detail-card"
>
<div class="payment-detail-card__header">
<span class="payment-detail-card__title">缴费明细 #{{ dIdx + 1 }}</span>
</div>
<div class="payment-detail-card__body">
<dl class="view-kv-grid view-kv-grid--4">
<div class="view-kv">
<dt>应缴费金额</dt>
<dd>{{ dash(detail.dueAmount) }}</dd>
</div>
<div class="view-kv">
<dt>转账方式</dt>
<dd>{{ transferTypeLabel(String(detail.transferType || '')) }}</dd>
</div>
<div class="view-kv">
<dt>转账金额</dt>
<dd>{{ dash(detail.transferAmount) }}</dd>
</div>
<div class="view-kv">
<dt>转账时间</dt>
<dd>{{ dash(detail.transferTime) }}</dd>
</div>
<div class="view-kv">
<dt>缴费状态</dt>
<dd>{{ payStatusLabel(String(detail.payStatus || '')) }}</dd>
</div>
<div v-if="payment?.payMode === 'fq'" class="view-kv">
<dt>应缴费时间</dt>
<dd>{{ formatYmd(detail.installmentDueDate) }}</dd>
</div>
<div v-if="payment?.payMode === 'fq'" class="view-kv">
<dt>分期期序号</dt>
<dd>{{ dash(detail.installmentNo) }}</dd>
</div>
<div class="view-field-block view-kv-span-2 payment-detail-card__attachments">
<div class="view-field-block__label">转账凭证</div>
<ProtocolAttachmentReadonly
:files="detailAttachments(detail)"
@preview="openPreview"
@download="downloadFile"
/>
</div>
</dl>
</div>
</div>
</div>
<el-empty v-else description="暂无缴费明细" :image-size="48" />
</div>
</template>
</div>
<template #footer>
<el-button class="btn-ghost" @click="emit('update:modelValue', false)">
<el-icon><Close /></el-icon>
关闭
</el-button>
</template>
</el-dialog>
<el-dialog v-model="previewVisible" title="文件预览" width="800px" align-center destroy-on-close>
<div v-if="previewType === 'image'" class="preview-container">
<img
:src="previewUrl"
alt="预览"
style="max-width: 100%; max-height: 70vh; display: block; margin: 0 auto"
/>
</div>
<div v-else class="preview-container">
<video
:src="previewUrl"
controls
style="max-width: 100%; max-height: 70vh; display: block; margin: 0 auto"
/>
</div>
</el-dialog>
</template>
<script setup lang="ts">
import { computed, nextTick, ref, watch } from 'vue'
import { Close } from '@element-plus/icons-vue'
import ProtocolAttachmentReadonly from './ProtocolAttachmentReadonly.vue'
import {
fetchCollectionProtocolDetail,
type CollectionProtocolRow
} from '@/api/collection-protocol'
import {
fetchCellSampleTypeList,
fetchItemUnitList,
fetchExpressCompanyList,
fetchSiteList,
fetchCollectionRegionList,
fetchHospitalList,
fetchUserList
} from '@/api/admin'
const props = defineProps<{
modelValue: boolean
protocolId: string | null
listRow?: CollectionProtocolRow | null
}>()
const emit = defineEmits<{
(e: 'update:modelValue', val: boolean): void
}>()
const formTabs = [
{ key: 'basic', label: '基本信息' },
{ key: 'party', label: '客户信息' },
{ key: 'collection', label: '采集信息' },
{ key: 'sample', label: '样本及运输信息' },
{ key: 'payment', label: '缴费信息' }
] as const
const loading = ref(false)
const bundle = ref<Record<string, any> | null>(null)
const activeTab = ref('basic')
const sampleTypeOptions = ref<Array<{ id: string; typeName: string }>>([])
const unitOptions = ref<Array<{ id: string; unitName: string }>>([])
const siteOptions = ref<Array<{ id: string; siteName: string }>>([])
const expressCompanyOptions = ref<Array<{ id: string; expressName: string }>>([])
const regionOptions = ref<Array<{ id: string; regionName: string }>>([])
const hospitalOptions = ref<Array<{ id: string; hospitalName: string }>>([])
const collectorUserOptions = ref<Array<{ id: string; nickName: string }>>([])
const salesUserOptions = ref<Array<{ id: string; nickName: string }>>([])
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
const protocol = computed(() => bundle.value?.protocol as Record<string, any> | undefined)
const partyCustomer = computed(() => bundle.value?.partyCustomer as Record<string, any> | null)
const collectionInfo = computed(() => bundle.value?.collectionInfo as Record<string, any> | null)
const payment = computed(() => bundle.value?.payment as Record<string, any> | null)
const samples = computed(() => (bundle.value?.samples as Array<Record<string, any>>) || [])
const paymentDetails = computed(
() => (bundle.value?.paymentDetails as Array<Record<string, any>>) || []
)
const protocolAttachments = computed(() => {
const list = bundle.value?.attachments
return Array.isArray(list) ? list : []
})
const dialogTitle = computed(() => {
const no = protocol.value?.protocolNo || props.listRow?.protocolNo
return no ? `查看协议单 — ${no}` : '查看协议单'
})
const collectorDisplay = computed(() => {
const fromList = props.listRow?.collectorUserName
if (fromList) return String(fromList)
const id = protocol.value?.collectorUserId
const u = collectorUserOptions.value.find((x) => x.id === id)
return u?.nickName || dash(id)
})
const salesDisplay = computed(() => {
const fromList = props.listRow?.salesUserName
if (fromList) return String(fromList)
const id = collectionInfo.value?.salesUserId
const u = salesUserOptions.value.find((x) => x.id === id)
return u?.nickName || dash(id)
})
const regionDisplay = computed(() => {
const fromList = props.listRow?.regionName
if (fromList) return String(fromList)
const id = collectionInfo.value?.regionId
const r = regionOptions.value.find((x) => x.id === id)
return r?.regionName || dash(id)
})
const hospitalDisplay = computed(() => {
const fromList = props.listRow?.hospitalName
if (fromList) return String(fromList)
const id = collectionInfo.value?.hospitalId
const h = hospitalOptions.value.find((x) => x.id === id)
return h?.hospitalName || dash(id)
})
function dash(val: unknown) {
if (val === null || val === undefined || val === '') return '—'
return String(val)
}
function formatYmd(val: unknown) {
const s = String(val || '').replace(/-/g, '')
if (s.length === 8) return `${s.slice(0, 4)}-${s.slice(4, 6)}-${s.slice(6, 8)}`
return dash(val)
}
function formatYm(val: unknown) {
const s = String(val || '')
if (s.length === 6) return `${s.slice(0, 4)}-${s.slice(4, 6)}`
return dash(val)
}
function protocolStatusLabel(s: string) {
const m: Record<string, string> = {
dsx: '待生效',
sxz: '生效中',
ygq: '已过期',
yzf: '已作废',
zky: '转科研'
}
return m[s] || s || '—'
}
function payModeLabel(s: string) {
if (s === 'dj') return '趸交'
if (s === 'fq') return '分期'
return s || '—'
}
function newbornSexLabel(s: string) {
if (s === '1') return '男'
if (s === '0') return '女'
return s || '—'
}
function deliveryModeLabel(s: string) {
if (s === 'sc') return '顺产'
if (s === 'pgc') return '剖宫产'
return s || '—'
}
function sampleStatusLabel(s: string) {
const m: Record<string, string> = { ycj: '已采集', jcz: '检测中', yrk: '已入库', yzf: '已作废' }
return m[s] || s || '—'
}
function transportTypeLabel(s: string) {
if (s === 'kdys') return '快递运输'
if (s === 'ryxd') return '人员携带'
return s || '—'
}
function transferTypeLabel(s: string) {
const m: Record<string, string> = { wxzz: '微信', zzbzz: '支付宝', yhkzz: '银行卡', xj: '现金' }
return m[s] || s || '—'
}
function payStatusLabel(s: string) {
const m: Record<string, string> = {
dfj: '待缴费',
jfqrz: '缴费确认中',
yjf: '已缴费',
tfqrz: '退费确认中',
ytf: '已退费'
}
return m[s] || s || '—'
}
function sampleTypeName(id: string) {
return sampleTypeOptions.value.find((x) => x.id === id)?.typeName || dash(id)
}
function unitName(id: string) {
return unitOptions.value.find((x) => x.id === id)?.unitName || dash(id)
}
function siteName(id: string) {
return siteOptions.value.find((x) => x.id === id)?.siteName || dash(id)
}
function expressName(id: string) {
return expressCompanyOptions.value.find((x) => x.id === id)?.expressName || dash(id)
}
function sampleTransportExtra(transport: Record<string, any> | undefined) {
if (!transport?.transportType) return '—'
if (transport.transportType === 'kdys') {
const parts: string[] = []
const ec = expressName(String(transport.expressCompanyId || ''))
if (ec !== '—') parts.push(ec)
if (transport.waybillNo) parts.push(String(transport.waybillNo))
if (transport.expressFee != null && transport.expressFee !== '') {
parts.push(`¥${transport.expressFee}`)
}
return parts.length ? parts.join(' · ') : '—'
}
if (transport.transportType === 'ryxd') {
const parts: string[] = []
if (transport.carrierName) parts.push(String(transport.carrierName))
if (transport.carrierPhone) parts.push(String(transport.carrierPhone))
return parts.length ? parts.join(' · ') : '—'
}
return '—'
}
function detailAttachments(detail: Record<string, any>) {
return Array.isArray(detail.attachments) ? detail.attachments : []
}
function fullFileUrl(suffix: string) {
if (!suffix) return ''
if (suffix.startsWith('http://') || suffix.startsWith('https://') || suffix.startsWith('/'))
return suffix
return `${minioBaseUrl}/${suffix}`
}
function isVideoFile(file: { fileType?: string; fileName?: string }) {
const t = (file.fileType || '').toLowerCase()
if (t.startsWith('video/')) return true
return /\.(mp4|webm|ogg|mov)$/i.test(file.fileName || '')
}
const previewVisible = ref(false)
const previewUrl = ref('')
const previewType = ref<'image' | 'video'>('image')
function openPreview(file: Record<string, any>) {
if (!file.fileUrl) return
previewUrl.value = fullFileUrl(file.fileUrl)
previewType.value = isVideoFile(file) ? 'video' : 'image'
previewVisible.value = true
}
function downloadFile(file: Record<string, any>) {
const url = fullFileUrl(file.fileUrl)
if (!url) return
const a = document.createElement('a')
a.href = url
a.download = file.fileName || ''
a.target = '_blank'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
async function loadLookups(data: Record<string, any>) {
const [stRes, uRes, ecRes, siteRes] = await Promise.all([
fetchCellSampleTypeList({ page: 1, pageSize: 100 }),
fetchItemUnitList({ page: 1, pageSize: 100 }),
fetchExpressCompanyList({ page: 1, pageSize: 100 }),
fetchSiteList({ page: 1, pageSize: 100 })
])
sampleTypeOptions.value = (stRes.list || []) as any
unitOptions.value = (uRes.list || []) as any
expressCompanyOptions.value = ecRes.list || []
siteOptions.value = siteRes.list || []
const ci = data.collectionInfo as Record<string, any> | null
const p = data.protocol as Record<string, any> | undefined
const tasks: Promise<void>[] = []
if (ci?.regionId) {
tasks.push(
fetchCollectionRegionList({ page: 1, pageSize: 100 }).then((res) => {
regionOptions.value = res.list || []
})
)
tasks.push(
fetchHospitalList(String(ci.regionId), { page: 1, pageSize: 100 }).then((res) => {
hospitalOptions.value = res.list || []
})
)
}
if (p?.collectorUserId) {
tasks.push(
fetchUserList({ page: 1, pageSize: 50, status: '1' }).then((res) => {
collectorUserOptions.value = res.list || []
})
)
}
if (ci?.salesUserId) {
tasks.push(
fetchUserList({ page: 1, pageSize: 50, status: '1' }).then((res) => {
salesUserOptions.value = res.list || []
})
)
}
await Promise.all(tasks)
}
async function loadDetail() {
if (!props.protocolId) return
loading.value = true
bundle.value = null
try {
const data = await fetchCollectionProtocolDetail(props.protocolId)
bundle.value = data as Record<string, any>
await loadLookups(data as Record<string, any>)
} finally {
loading.value = false
}
}
function scrollToSection(key: string) {
activeTab.value = key
nextTick(() => {
document
.getElementById(`view-section-${key}`)
?.scrollIntoView({ behavior: 'smooth', block: 'start' })
})
}
function handleClosed() {
bundle.value = null
activeTab.value = 'basic'
}
watch(
() => [props.modelValue, props.protocolId] as const,
([visible, id]) => {
if (visible && id) loadDetail()
}
)
</script>
<style scoped lang="scss">
.protocol-view-body {
overflow: visible;
}
.detail-tabs {
position: sticky;
top: 0;
z-index: 1000;
display: flex;
gap: 4px;
background: #f5f7fa;
padding: 4px;
border-radius: 8px;
margin-bottom: 16px;
width: fit-content;
isolation: isolate;
box-shadow: 0 1px 0 #f5f7fa;
}
.detail-tab {
padding: 10px 20px;
cursor: pointer;
border-radius: 6px;
font-size: 14px;
color: #606266;
transition: all 0.3s;
&.active {
background: #fff;
color: #059669;
font-weight: 500;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
&:hover:not(.active) {
color: #059669;
}
}
.form-tab-pane {
padding: 0 0 4px;
& + .form-tab-pane {
margin-top: 20px;
padding-top: 20px;
border-top: 1px dashed #e2e8f0;
}
}
.detail-section-title {
margin: 8px 0 12px;
padding-left: 10px;
font-size: 14px;
font-weight: 600;
color: #1e293b;
border-left: 3px solid #10b981;
}
.form-section-divider {
margin: 16px 0;
border: none;
border-top: 1px dashed #e2e8f0;
height: 0;
}
.view-kv-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px 28px;
&--4 {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
&--5 {
grid-template-columns: repeat(5, minmax(0, 1fr));
}
}
.view-kv {
display: grid;
grid-template-columns: auto 1fr;
gap: 4px 12px;
font-size: 13px;
align-items: start;
dt {
margin: 0;
color: #64748b;
font-weight: 500;
white-space: nowrap;
}
dd {
margin: 0;
color: #1e293b;
word-break: break-word;
}
}
.view-kv-span-2 {
grid-column: 1 / -1;
}
.view-field-empty {
font-size: 13px;
color: #94a3b8;
}
.sample-transport-panel {
padding: 12px 16px;
background: #f8fafc;
border-radius: 8px;
}
.sample-transport-title {
margin: 0 0 12px;
font-size: 13px;
font-weight: 600;
color: #334155;
}
.sub-view-table {
margin-bottom: 8px;
}
.payment-detail-cards {
display: flex;
flex-direction: column;
gap: 12px;
}
.payment-detail-card {
border: 1px solid #e2e8f0;
border-radius: 10px;
overflow: hidden;
}
.payment-detail-card__header {
padding: 10px 16px;
background: #f8fafc;
border-bottom: 1px solid #e2e8f0;
}
.payment-detail-card__title {
font-size: 13px;
font-weight: 600;
color: #334155;
}
.payment-detail-card__body {
padding: 14px 16px;
}
.payment-detail-card__attachments {
margin-top: 8px;
padding-top: 8px;
border-top: 1px dashed #e2e8f0;
}
.view-field-block {
display: flex;
flex-direction: column;
gap: 8px;
width: 100%;
}
.view-field-block__label {
font-size: 13px;
font-weight: 500;
color: #64748b;
}
.preview-container {
text-align: center;
}
@media (max-width: 1200px) {
.view-kv-grid--4,
.view-kv-grid--5 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
</style>
@@ -0,0 +1,410 @@
<!-- 采集协议单 -->
<!-- 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 />
</el-form-item>
<el-form-item label="协议状态">
<el-select
v-model="searchForm.protocolStatus"
clearable
placeholder="全部"
style="width: 100%"
>
<el-option label="待生效" value="dsx" />
<el-option label="生效中" value="sxz" />
<el-option label="已过期" value="ygq" />
<el-option label="已作废" value="yzf" />
<el-option label="转科研" value="zky" />
</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-toolbar">
<div class="list-toolbar-row">
<div class="list-toolbar-selected">
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
</div>
<el-button type="primary" class="btn-main" @click="handleAdd">
<el-icon><Plus /></el-icon>
新增
</el-button>
<el-button class="btn-ghost" :disabled="!selectedRows.length" @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"
@row-dblclick="handleView"
>
<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="protocolNo"
label="协议号"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="protocolStatus"
label="状态"
width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{
protocolStatusLabel(String(row.protocolStatus || ''))
}}</template>
</el-table-column>
<el-table-column
prop="registerDate"
label="登记日期"
width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="motherName"
label="母亲姓名"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="motherPhone"
label="母亲电话"
min-width="130"
align="center"
header-align="center"
/>
<el-table-column
prop="motherIdCard"
label="母亲身份证号"
min-width="190"
align="center"
header-align="center"
/>
<el-table-column
prop="fatherName"
label="父亲姓名"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="newbornSex"
label="新生儿性别"
width="110"
align="center"
header-align="center"
>
<template #default="{ row }">{{
newbornSexLabel(String(row.newbornSex || ''))
}}</template>
</el-table-column>
<el-table-column
prop="deliveryMode"
label="分娩方式"
width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{
deliveryModeLabel(String(row.deliveryMode || ''))
}}</template>
</el-table-column>
<el-table-column
prop="newbornWeightGram"
label="新生儿体重(克)"
width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="regionName"
label="采集地区"
min-width="120"
align="center"
header-align="center"
/>
<el-table-column
prop="hospitalName"
label="采集医院"
min-width="140"
align="center"
header-align="center"
/>
<el-table-column
prop="collectorUserName"
label="采集专员"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="salesUserName"
label="销售人员"
min-width="100"
align="center"
header-align="center"
/>
<el-table-column
prop="sampleCollectTime"
label="样本采集时间"
min-width="180"
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-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>
<!-- 新增/编辑弹窗 -->
<ProtocolFormDialog
v-model="formDialogVisible"
:edit-id="formDialogEditId"
:list-row="formDialogRow"
@saved="onFormSaved"
/>
<!-- 查看弹窗 -->
<ProtocolViewDialog v-model="viewVisible" :protocol-id="viewProtocolId" :list-row="viewRow" />
</section>
</div>
</template>
<script setup lang="ts">
import { ElMessage, ElMessageBox } from 'element-plus'
import {
Plus,
View,
Edit,
Delete,
Search,
RefreshLeft
} from '@element-plus/icons-vue'
import ProtocolFormDialog from './ProtocolFormDialog.vue'
import ProtocolViewDialog from './ProtocolViewDialog.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchCollectionProtocolList,
fetchDeleteCollectionProtocol,
type CollectionProtocolRow
} from '@/api/collection-protocol'
defineOptions({ name: 'CellStorageProtocol' })
/* ====== 标签映射 ====== */
function protocolStatusLabel(s: string) {
const m: Record<string, string> = {
dsx: '待生效',
sxz: '生效中',
ygq: '已过期',
yzf: '已作废',
zky: '转科研'
}
return m[s] || s || '-'
}
function newbornSexLabel(s: string) {
if (s === '1') return '男'
if (s === '0') return '女'
return s || '-'
}
function deliveryModeLabel(s: string) {
if (s === 'sc') return '顺产'
if (s === 'pgc') return '剖宫产'
return s || '-'
}
/* ====== 列表 ====== */
const searchForm = reactive<{ keyword: string; protocolStatus: string }>({
keyword: '',
protocolStatus: ''
})
const tableData = ref<CollectionProtocolRow[]>([])
const selectedRows = ref<CollectionProtocolRow[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const handleSelectionChange = (rows: CollectionProtocolRow[]) => {
selectedRows.value = rows
}
async function loadData() {
loading.value = true
try {
const res = await fetchCollectionProtocolList({
page: pagination.page,
pageSize: pagination.pageSize,
keyword: searchForm.keyword || undefined,
protocolStatus: searchForm.protocolStatus || 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.protocolStatus = ''
pagination.page = 1
loadData()
}
/* ====== 查看弹窗 ====== */
const viewVisible = ref(false)
const viewProtocolId = ref<string | null>(null)
const viewRow = ref<CollectionProtocolRow | null>(null)
function handleView(row: CollectionProtocolRow) {
viewProtocolId.value = String(row.id)
viewRow.value = row
viewVisible.value = true
}
/* ====== 新增/编辑弹窗 ====== */
const formDialogVisible = ref(false)
const formDialogEditId = ref<string | null>(null)
const formDialogRow = ref<CollectionProtocolRow | null>(null)
function handleAdd() {
formDialogEditId.value = null
formDialogRow.value = null
formDialogVisible.value = true
}
function handleEdit(row: CollectionProtocolRow) {
formDialogEditId.value = row.id
formDialogRow.value = row
formDialogVisible.value = true
}
function onFormSaved() {
loadData()
}
/* ====== 删除 ====== */
function handleDelete(row: CollectionProtocolRow) {
ElMessageBox.confirm(`确认删除协议号「${row.protocolNo}」?`, '删除确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
await fetchDeleteCollectionProtocol(String(row.id))
loadData()
})
.catch(() => {})
}
async function handleBatchDelete() {
if (!selectedRows.value.length) return
await ElMessageBox.confirm(`确认删除选中的 ${selectedRows.value.length} 条记录?`, '批量删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
const rows = [...selectedRows.value]
await withFullscreenLoading(async () => {
for (const row of rows) {
await fetchDeleteCollectionProtocol(String(row.id))
}
ElMessage.success('批量删除成功')
selectedRows.value = []
loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
loadData()
})
</script>
@@ -0,0 +1,124 @@
<!-- 退费确认(财务) -->
<!-- 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="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" />
<el-table-column prop="protocolNo" label="协议号" min-width="130" align="center" header-align="center" />
<el-table-column prop="installmentNo" label="期数" width="80" align="center" header-align="center" />
<el-table-column prop="transferAmount" label="金额" width="120" align="center" header-align="center" />
<el-table-column prop="payStatus" label="状态" width="120" align="center" header-align="center">
<template #default>退费确认中</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" min-width="180" align="center" header-align="center" />
<el-table-column label="操作" width="140" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="openConfirm(row)">确认退费</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="确认退费"
width="560px"
class="dialog-form-layout"
align-center
destroy-on-close
>
<el-form label-position="top" class="biz-dialog-form">
<el-form-item label="财务确认附件(MinIO 地址,逗号分隔,可选)">
<el-input v-model="confirmAttachments" type="textarea" :rows="3" placeholder="可选" />
</el-form-item>
</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="submitConfirm">
<el-icon><Check /></el-icon>
确认
</el-button>
</template>
</el-dialog>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { Close, Check } from '@element-plus/icons-vue'
import { fetchRefundConfirmList, fetchRefundConfirmSubmit } from '@/api/collection-protocol'
defineOptions({ name: 'CellStorageRefundConfirm' })
const tableData = ref<Record<string, unknown>[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const dialogVisible = ref(false)
const submitLoading = ref(false)
const confirmAttachments = ref('')
const currentDetailId = ref<string | null>(null)
async function loadData() {
loading.value = true
try {
const res = await fetchRefundConfirmList({
page: pagination.page,
pageSize: pagination.pageSize
})
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function openConfirm(row: Record<string, unknown>) {
currentDetailId.value = String(row.id)
confirmAttachments.value = ''
dialogVisible.value = true
}
async function submitConfirm() {
if (!currentDetailId.value) return
submitLoading.value = true
try {
await fetchRefundConfirmSubmit(currentDetailId.value, {
financeConfirmAttachments: confirmAttachments.value || undefined
})
dialogVisible.value = false
loadData()
} finally {
submitLoading.value = false
}
}
onMounted(() => {
loadData()
})
</script>
@@ -36,11 +36,11 @@
const router = useRouter()
const links = [
{ label: '商品单位', path: '/demo/unit' },
{ label: '订单列表', path: '/demo/order' },
{ label: '商品管理', path: '/demo/product' },
{ label: '商品分类', path: '/demo/category' },
{ label: '用户管理', path: '/demo/user' }
{ label: '商品单位', path: '/system/unit' },
{ label: '用户管理', path: '/system/user' },
{ label: '商品分类', path: '/system/category' },
{ label: '租户管理', path: '/system/tenant' },
{ label: '客户管理', path: '/basic-info/customer' }
]
const go = (path: string) => {
@@ -0,0 +1,829 @@
<!-- 洁净室管理 -->
<!-- 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 />
</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-icon><Plus /></el-icon>
新增洁净室
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="selectedRows.length === 0"
@click="handleBatchDelete"
>
批量删除
</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"
@row-dblclick="handleView"
>
<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="roomCode" label="编号" width="140" align="center" header-align="center" />
<el-table-column prop="roomName" label="名称" min-width="160" align="center" header-align="center" />
<el-table-column label="等级" width="100" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="gradeTagType(row.roomGrade)" effect="plain">
{{ gradeLabel(row.roomGrade) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" width="100" align="center" header-align="center">
<template #default="{ row }">
<el-tag :type="row.roomStatus === 'zc' ? 'success' : 'danger'" effect="plain">
{{ row.roomStatus === 'zc' ? '正常' : '异常' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="areaSqm" label="面积(m²)" width="120" 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-icon><Edit /></el-icon>编辑
</el-button>
<el-button class="btn-op-item" @click="handleAccessLog(row)">人员进出</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"
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-position="top"
class="clean-room-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="编号" prop="roomCode">
<el-input v-model="formData.roomCode" placeholder="如:CR-001" />
</el-form-item>
<el-form-item label="名称" prop="roomName">
<el-input v-model="formData.roomName" placeholder="如:一号洁净室" />
</el-form-item>
<el-form-item label="等级" prop="roomGrade">
<el-select v-model="formData.roomGrade" placeholder="请选择等级" style="width: 100%">
<el-option label="A级" value="A" />
<el-option label="B级" value="B" />
<el-option label="C级" value="C" />
<el-option label="D级" value="D" />
</el-select>
</el-form-item>
<el-form-item label="状态" prop="roomStatus">
<el-select v-model="formData.roomStatus" placeholder="请选择状态" style="width: 100%">
<el-option label="正常" value="zc" />
<el-option label="异常" value="yc" />
</el-select>
</el-form-item>
<el-form-item label="面积" prop="areaSqm">
<el-input
type="number"
step="any"
v-model="formData.areaSqm"
:min="0"
:controls="false"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="备注" class="form-col-span-2">
<el-input v-model="formData.remark" type="textarea" :rows="3" 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" @click="handleSubmit" :loading="submitLoading">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<!-- 查看详情 -->
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.roomName || '洁净室详情'"
:icon="OfficeBuilding"
:meta="viewRow?.createTime || ''"
:sections="viewSections"
/>
<!-- 人员进出记录弹窗 -->
<el-dialog
v-model="accessLogVisible"
:title="`人员进出记录 — ${accessLogRoom?.roomName || ''}`"
width="960px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<div class="list-toolbar" style="margin-bottom: 12px">
<div class="list-toolbar-row">
<el-button class="btn-main" type="primary" size="small" @click="handleAddLog">
<el-icon><Plus /></el-icon>
新增记录
</el-button>
</div>
</div>
<el-table
:data="accessLogData"
v-loading="accessLogLoading"
stripe
size="small"
row-key="id"
@row-dblclick="handleViewLog"
>
<el-table-column
type="index"
label="序号"
width="60"
align="center"
header-align="center"
:index="(index) => (logPagination.page - 1) * logPagination.pageSize + index + 1"
/>
<el-table-column prop="personName" label="人员姓名" min-width="100" align="center" header-align="center" />
<el-table-column prop="deptName" label="部门" min-width="100" align="center" header-align="center" />
<el-table-column prop="enterTime" label="进入时间" min-width="160" align="center" header-align="center" />
<el-table-column prop="purpose" label="目的" min-width="120" align="center" header-align="center" show-overflow-tooltip />
<el-table-column prop="leaveTime" label="离开时间" min-width="160" align="center" header-align="center" />
<el-table-column prop="bodyTemp" label="体温(℃)" width="90" 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" @click="handleViewLog(row)"
><el-icon><View /></el-icon>查看</el-button
>
<el-button class="btn-op-item primary" @click="handleEditLog(row)">
<el-icon><Edit /></el-icon>编辑
</el-button>
<el-button class="btn-op-item" @click="handleDeleteLog(row)">
<el-icon><Delete /></el-icon>删除
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar" style="margin-top: 12px">
<el-pagination
:current-page="logPagination.page"
:page-size="logPagination.pageSize"
:total="logPagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="(val) => ((logPagination.page = 1), (logPagination.pageSize = val), loadAccessLogData())"
@current-change="(val) => ((logPagination.page = val), loadAccessLogData())"
/>
</div>
<!-- 进出记录新增/编辑弹窗(嵌套) -->
<el-dialog
v-model="logDialogVisible"
:title="logDialogTitle"
width="520px"
class="dialog-form-layout"
align-center
destroy-on-close
:close-on-click-modal="false"
append-to-body
>
<el-form
ref="logFormRef"
:model="logFormData"
:rules="logFormRules"
label-position="top"
class="access-log-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="人员姓名" prop="personName">
<el-select
v-model="logFormData.personName"
class="w-full"
filterable
remote
clearable
allow-create
default-first-option
:remote-method="remoteSearchUsers"
:loading="userSearchLoading"
placeholder="输入姓名检索或手填"
@change="onPersonSelectChange"
>
<el-option
v-for="u in userOptions"
:key="u.id"
:label="formatUserLabel(u)"
:value="(u.nickName || '').trim()"
/>
</el-select>
</el-form-item>
<el-form-item label="部门" prop="deptName">
<el-input v-model="logFormData.deptName" placeholder="选择人员后自动填入,可手填修改" />
</el-form-item>
<el-form-item label="进入时间" prop="enterTime">
<el-date-picker
v-model="logFormData.enterTime"
type="datetime"
placeholder="选择日期时间"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="离开时间">
<el-date-picker
v-model="logFormData.leaveTime"
type="datetime"
placeholder="选择日期时间"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="目的" class="form-col-span-2">
<el-input
v-model="logFormData.purpose"
type="textarea"
:rows="2"
placeholder="请输入目的"
/>
</el-form-item>
<el-form-item label="体温(℃)">
<el-input
type="number"
step="any"
v-model="logFormData.bodyTemp"
:min="34"
:max="42"
:controls="false"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="logFormData.remark" placeholder="可选" />
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="logDialogVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button class="btn-main" type="primary" @click="handleLogSubmit" :loading="logSubmitLoading">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<!-- 进出记录查看详情 -->
<SystemViewDialog
v-model:visible="logViewVisible"
:title="logViewRow?.personName || '进出记录详情'"
:icon="User"
:meta="logViewRow?.enterTime || ''"
:sections="logViewSections"
/>
</el-dialog>
</section>
</div>
</template>
<script setup lang="ts">
import { Plus, Close, Check, View, Edit, Delete, User, OfficeBuilding } from '@element-plus/icons-vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import { buildTreePathLabelFromFlat } from '@/utils/tree-path'
import {
fetchCleanRoomList,
fetchCreateCleanRoom,
fetchUpdateCleanRoom,
fetchDeleteCleanRoom,
fetchAccessLogList,
fetchCreateAccessLog,
fetchUpdateAccessLog,
fetchDeleteAccessLog,
fetchUserList,
fetchDeptTree
} from '@/api/admin'
defineOptions({ name: 'CleanRoom' })
// ── 主表 ──────────────────────────────────────────
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<any[]>([])
const selectedRows = ref<any[]>([])
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 viewVisible = ref(false)
const viewRow = ref<any>(null)
const formData = reactive({
roomCode: '',
roomName: '',
roomGrade: '',
roomStatus: 'zc',
areaSqm: null as number | null,
remark: ''
})
const formRules = {
roomCode: [{ required: true, message: '请输入编号', trigger: 'blur' }],
roomName: [{ required: true, message: '请输入名称', trigger: 'blur' }]
}
// ── 等级映射 ──────────────────────────────────────
const gradeOptions = [
{ label: 'A级', value: 'A' },
{ label: 'B级', value: 'B' },
{ label: 'C级', value: 'C' },
{ label: 'D级', value: 'D' }
]
function gradeTagType(grade: string) {
const map: Record<string, string> = { A: 'warning', B: '', C: 'info', D: 'info' }
return map[grade] ?? ''
}
function gradeLabel(grade: string) {
return gradeOptions.find((o) => o.value === grade)?.label ?? grade
}
// ── 选择 ──────────────────────────────────────────
const handleSelectionChange = (rows: any[]) => {
selectedRows.value = rows
}
// ── 查看详情 sections ────────────────────────────
const viewSections = computed(() => {
if (!viewRow.value) return []
const row = viewRow.value
return [
{
title: '基本信息',
fields: [
{ label: '编号', value: row.roomCode },
{ label: '名称', value: row.roomName },
{ label: '等级', value: gradeLabel(row.roomGrade) },
{ label: '状态', value: row.roomStatus === 'zc' ? '正常' : '异常' },
{ label: '面积', value: row.areaSqm ? `${row.areaSqm} m²` : '' },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
// ── 主表 加载 ─────────────────────────────────────
async function loadData() {
loading.value = true
try {
const res: any = await fetchCleanRoomList({
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.roomCode = ''
formData.roomName = ''
formData.roomGrade = ''
formData.roomStatus = 'zc'
formData.areaSqm = null
formData.remark = ''
editingId.value = null
}
function handleAdd() {
isEdit.value = false
dialogTitle.value = '新增洁净室'
resetForm()
dialogVisible.value = true
formRef.value?.clearValidate?.()
}
function handleEdit(row: any) {
isEdit.value = true
dialogTitle.value = '编辑洁净室'
editingId.value = row.id
formData.roomCode = row.roomCode || ''
formData.roomName = row.roomName || ''
formData.roomGrade = row.roomGrade || ''
formData.roomStatus = row.roomStatus || 'zc'
formData.areaSqm = row.areaSqm ?? null
formData.remark = row.remark || ''
dialogVisible.value = true
formRef.value?.clearValidate?.()
}
async function handleSubmit() {
await formRef.value?.validate?.()
submitLoading.value = true
try {
const payload = {
roomCode: formData.roomCode.trim(),
roomName: formData.roomName.trim(),
roomGrade: formData.roomGrade || undefined,
roomStatus: formData.roomStatus || 'zc',
areaSqm: formData.areaSqm ?? undefined,
remark: formData.remark?.trim() || undefined
}
if (isEdit.value && editingId.value) {
await fetchUpdateCleanRoom(editingId.value, payload)
} else {
await fetchCreateCleanRoom(payload)
}
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
dialogVisible.value = false
await loadData()
} catch {
/* 校验或接口错误已由全局处理 */
} finally {
submitLoading.value = false
}
}
function handleView(row: any) {
viewRow.value = row
viewVisible.value = true
}
async function handleDelete(row: any) {
await ElMessageBox.confirm('确定要删除该洁净室吗?', '提示', { type: 'warning' })
await fetchDeleteCleanRoom(row.id)
ElMessage.success('删除成功')
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 fetchDeleteCleanRoom(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
// ── 人员进出记录 ──────────────────────────────────
const accessLogVisible = ref(false)
const accessLogRoom = ref<any>(null)
const accessLogData = ref<any[]>([])
const accessLogLoading = ref(false)
const logPagination = reactive({ page: 1, pageSize: 10, total: 0 })
const logDialogVisible = ref(false)
const logDialogTitle = ref('新增记录')
const logIsEdit = ref(false)
const logSubmitLoading = ref(false)
const logFormRef = ref()
const logEditingId = ref<string | null>(null)
const logViewVisible = ref(false)
const logViewRow = ref<any>(null)
const logFormData = reactive({
personName: '',
deptName: '',
enterTime: '',
purpose: '',
leaveTime: '',
bodyTemp: null as number | null,
remark: ''
})
const logFormRules = {
personName: [{ required: true, message: '请输入人员姓名', trigger: 'blur' }]
}
// ── 人员检索 ──────────────────────────────────────
const userOptions = ref<Api.User.UserItem[]>([])
const userSearchLoading = ref(false)
const flatDeptList = ref<any[]>([])
function formatUserLabel(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 remoteSearchUsers(query: string) {
userSearchLoading.value = true
try {
const q = (query || '').trim()
const res: any = await fetchUserList({
page: 1,
pageSize: 50,
keyword: q || undefined,
status: '1'
})
userOptions.value = res.list || []
} catch (e) {
console.error('检索用户失败:', e)
userOptions.value = []
} finally {
userSearchLoading.value = false
}
}
function onPersonSelectChange(val: string | null | undefined) {
if (!val) {
logFormData.deptName = ''
return
}
const user = userOptions.value.find((u) => (u.nickName || '').trim() === val)
if (user && user.deptId) {
const deptPath = buildTreePathLabelFromFlat(user.deptId, flatDeptList.value, {
nameKey: 'deptName'
})
logFormData.deptName = deptPath || (user.deptName || '').trim()
}
}
async function loadDeptData() {
try {
const tree: any = await fetchDeptTree()
const flat: any[] = []
const walk = (nodes: any[]) => {
for (const n of nodes || []) {
flat.push(n)
if (n.children?.length) walk(n.children)
}
}
walk(tree || [])
flatDeptList.value = flat
} catch (e) {
console.error('加载部门数据失败:', e)
}
}
async function resolvePersonForEdit(name: string) {
if (!name) return
userSearchLoading.value = true
try {
const res: any = await fetchUserList({
page: 1,
pageSize: 50,
keyword: name,
status: '1'
})
const list = res.list || []
const match = list.find((u: any) => (u.nickName || '').trim() === name)
if (match) {
userOptions.value = list
}
} catch (e) {
console.error('匹配用户失败:', e)
} finally {
userSearchLoading.value = false
}
}
function handleAccessLog(row: any) {
accessLogRoom.value = row
logPagination.page = 1
accessLogVisible.value = true
loadAccessLogData()
}
async function loadAccessLogData() {
if (!accessLogRoom.value) return
accessLogLoading.value = true
try {
const res: any = await fetchAccessLogList({
page: logPagination.page,
pageSize: logPagination.pageSize,
cleanRoomId: accessLogRoom.value.id
})
accessLogData.value = res.list || []
logPagination.total = res.total ?? 0
} finally {
accessLogLoading.value = false
}
}
function resetLogForm() {
logFormData.personName = ''
logFormData.deptName = ''
logFormData.enterTime = ''
logFormData.purpose = ''
logFormData.leaveTime = ''
logFormData.bodyTemp = null
logFormData.remark = ''
logEditingId.value = null
userOptions.value = []
}
function handleAddLog() {
logIsEdit.value = false
logDialogTitle.value = '新增记录'
resetLogForm()
logDialogVisible.value = true
logFormRef.value?.clearValidate?.()
}
function handleEditLog(row: any) {
logIsEdit.value = true
logDialogTitle.value = '编辑记录'
logEditingId.value = row.id
logFormData.personName = row.personName || ''
logFormData.deptName = row.deptName || ''
logFormData.enterTime = row.enterTime || ''
logFormData.purpose = row.purpose || ''
logFormData.leaveTime = row.leaveTime || ''
logFormData.bodyTemp = row.bodyTemp ?? null
logFormData.remark = row.remark || ''
logDialogVisible.value = true
logFormRef.value?.clearValidate?.()
resolvePersonForEdit(row.personName || '')
}
async function handleLogSubmit() {
await logFormRef.value?.validate?.()
logSubmitLoading.value = true
try {
const payload = {
cleanRoomId: accessLogRoom.value.id,
personName: logFormData.personName.trim(),
deptName: logFormData.deptName?.trim() || undefined,
enterTime: logFormData.enterTime || undefined,
purpose: logFormData.purpose?.trim() || undefined,
leaveTime: logFormData.leaveTime || undefined,
bodyTemp: logFormData.bodyTemp != null ? String(logFormData.bodyTemp) : undefined,
remark: logFormData.remark?.trim() || undefined
}
if (logIsEdit.value && logEditingId.value) {
await fetchUpdateAccessLog(logEditingId.value, payload)
} else {
await fetchCreateAccessLog(payload)
}
ElMessage.success(logIsEdit.value ? '更新成功' : '创建成功')
logDialogVisible.value = false
await loadAccessLogData()
} catch {
/* 校验或接口错误已由全局处理 */
} finally {
logSubmitLoading.value = false
}
}
async function handleDeleteLog(row: any) {
await ElMessageBox.confirm('确定要删除该记录吗?', '提示', { type: 'warning' })
await fetchDeleteAccessLog(row.id)
ElMessage.success('删除成功')
await loadAccessLogData()
}
// ── 进出记录查看详情 ──────────────────────────────
const logViewSections = computed(() => {
if (!logViewRow.value) return []
const row = logViewRow.value
return [
{
title: '进出记录',
fields: [
{ label: '人员姓名', value: row.personName },
{ label: '部门', value: row.deptName },
{ label: '进入时间', value: row.enterTime },
{ label: '离开时间', value: row.leaveTime },
{ label: '目的', value: row.purpose, span: true },
{ label: '体温(℃)', value: row.bodyTemp ? `${row.bodyTemp}` : '' },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
function handleViewLog(row: any) {
logViewRow.value = row
logViewVisible.value = true
}
// ── 初始化 ────────────────────────────────────────
onMounted(() => {
loadData()
loadDeptData()
})
</script>
<style scoped lang="scss">
.clean-room-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
.access-log-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
</style>
@@ -0,0 +1,35 @@
<!-- Demo 下拉框示例 -->
<template>
<div class="page-container">
<header class="page-head">
<h1>demo</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="form" label-position="top" @submit.prevent>
<el-form-item label="请选择">
<el-select v-model="form.value" placeholder="请选择" clearable style="width: 240px">
<el-option label="A" value="A" />
<el-option label="B" value="B" />
<el-option label="C" value="C" />
</el-select>
</el-form-item>
</el-form>
</div>
</section>
</div>
</template>
<script setup lang="ts">
import { reactive } from 'vue'
const form = reactive({
value: ''
})
</script>
@@ -0,0 +1,363 @@
<!-- 展馆预约管理 -->
<!-- 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 />
</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-icon><Plus /></el-icon>
新增预约
</el-button>
<el-button
class="btn-ghost"
type="danger"
:disabled="selectedRows.length === 0"
@click="handleBatchDelete"
>
批量删除
</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"
@row-dblclick="handleView"
>
<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="appointmentNo" label="预约编号" min-width="150" align="center" header-align="center" />
<el-table-column prop="visitOrg" label="来访单位" min-width="150" align="center" header-align="center" />
<el-table-column prop="contactName" label="联系人" min-width="120" align="center" header-align="center" />
<el-table-column prop="visitDate" label="到访日期" min-width="180" align="center" header-align="center" />
<el-table-column prop="visitorCount" label="人数" min-width="80" 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>
</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"
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-position="top"
class="appointment-dialog-form"
scroll-to-error
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
>
<div class="form-grid-2">
<el-form-item label="预约编号">
<el-input v-model="formData.appointmentNo" placeholder="提交后自动生成" :disabled="true" />
</el-form-item>
<el-form-item label="来访单位" prop="visitOrg">
<el-input v-model="formData.visitOrg" placeholder="请输入来访单位" />
</el-form-item>
<el-form-item label="联系人">
<el-input v-model="formData.contactName" placeholder="请输入联系人" />
</el-form-item>
<el-form-item label="到访日期">
<el-date-picker
v-model="formData.visitDate"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="请选择到访日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="人数">
<el-input type="number" step="any" v-model="formData.visitorCount" :min="1" style="width: 100%" />
</el-form-item>
<el-form-item label="备注" class="form-col-span-2">
<el-input v-model="formData.remark" type="textarea" :rows="3" 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" @click="handleSubmit" :loading="submitLoading">
<el-icon><Check /></el-icon>
确定
</el-button>
</template>
</el-dialog>
<SystemViewDialog
v-model:visible="viewVisible"
:title="viewRow?.appointmentNo || '预约详情'"
:icon="Calendar"
:meta="viewRow?.createTime || ''"
:sections="viewSections"
/>
</section>
</div>
</template>
<script setup lang="ts">
import { Plus, Close, Check, View, Calendar } from '@element-plus/icons-vue'
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
import {
fetchExhibitionAppointmentList,
fetchCreateExhibitionAppointment,
fetchUpdateExhibitionAppointment,
fetchDeleteExhibitionAppointment
} from '@/api/admin'
defineOptions({ name: 'ExhibitionAppointment' })
interface AppointmentRow {
id: string
appointmentNo: string
visitOrg: string
contactName: string
visitDate: string
visitorCount: number
remark: string
createTime: string
[key: string]: any
}
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
const tableData = ref<AppointmentRow[]>([])
const selectedRows = ref<AppointmentRow[]>([])
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 viewVisible = ref(false)
const viewRow = ref<AppointmentRow | null>(null)
const formData = reactive({
appointmentNo: '',
visitOrg: '',
contactName: '',
visitDate: '',
visitorCount: 1,
remark: ''
})
const formRules = {
visitOrg: [{ required: true, message: '请输入来访单位', trigger: 'blur' }]
}
const handleSelectionChange = (rows: AppointmentRow[]) => {
selectedRows.value = rows
}
const viewSections = computed(() => {
if (!viewRow.value) return []
const row = viewRow.value
return [
{
title: '预约信息',
fields: [
{ label: '预约编号', value: row.appointmentNo },
{ label: '来访单位', value: row.visitOrg },
{ label: '联系人', value: row.contactName },
{ label: '到访日期', value: row.visitDate },
{ label: '人数', value: row.visitorCount },
{ label: '备注', value: row.remark, span: true }
]
}
]
})
async function loadData() {
loading.value = true
try {
const res = await fetchExhibitionAppointmentList({
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.appointmentNo = '提交后自动生成'
formData.visitOrg = ''
formData.contactName = ''
formData.visitDate = ''
formData.visitorCount = 1
formData.remark = ''
editingId.value = null
}
function handleAdd() {
isEdit.value = false
dialogTitle.value = '新增预约'
resetForm()
dialogVisible.value = true
formRef.value?.clearValidate?.()
}
function handleEdit(row: AppointmentRow) {
isEdit.value = true
dialogTitle.value = '编辑预约'
editingId.value = row.id
formData.appointmentNo = row.appointmentNo || ''
formData.visitOrg = row.visitOrg || ''
formData.contactName = row.contactName || ''
formData.visitDate = row.visitDate || ''
formData.visitorCount = row.visitorCount ?? 1
formData.remark = row.remark || ''
dialogVisible.value = true
formRef.value?.clearValidate?.()
}
async function handleSubmit() {
await formRef.value?.validate?.()
submitLoading.value = true
try {
const payload: Record<string, any> = {
visitOrg: formData.visitOrg.trim(),
contactName: formData.contactName?.trim() || undefined,
visitDate: formData.visitDate || undefined,
visitorCount: formData.visitorCount,
remark: formData.remark?.trim() || undefined
}
if (isEdit.value && editingId.value) {
await fetchUpdateExhibitionAppointment(editingId.value, payload)
} else {
await fetchCreateExhibitionAppointment(payload)
}
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
dialogVisible.value = false
await loadData()
} catch {
/* 校验或接口错误已由全局处理 */
} finally {
submitLoading.value = false
}
}
function handleView(row: AppointmentRow) {
viewRow.value = row
viewVisible.value = true
}
async function handleDelete(row: AppointmentRow) {
await ElMessageBox.confirm('确定要删除该预约吗?', '提示', { type: 'warning' })
await fetchDeleteExhibitionAppointment(row.id)
ElMessage.success('删除成功')
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 fetchDeleteExhibitionAppointment(id)
}
ElMessage.success('批量删除成功')
selectedRows.value = []
await loadData()
}, fullscreenLoadingText.batchDelete)
}
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.appointment-dialog-form {
:deep(.el-form-item) {
margin-bottom: 0;
}
}
</style>
File diff suppressed because it is too large. Load diff
+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>