20260716173254
This commit is contained in:
1 parent
704dda07b5
commit
5cd4e1e1d2
46 files changed
+3569
-528
No files matched your search
@@ -0,0 +1,2 @@
|
||||
/mvnw text eol=lf
|
||||
*.cmd text eol=crlf
|
||||
@@ -0,0 +1,36 @@
|
||||
HELP.md
|
||||
target/
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Organization database configs ###
|
||||
/config/dbconfigs/*.properties
|
||||
@@ -0,0 +1,3 @@
|
||||
wrapperVersion=3.3.4
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.zip
|
||||
@@ -0,0 +1,16 @@
|
||||
# Organization Database Configs
|
||||
|
||||
Each organization uses one SQL Server connection file named `{ORG_ID}.properties`.
|
||||
Organization IDs are normalized to uppercase and may contain only letters, numbers,
|
||||
underscores, and hyphens.
|
||||
|
||||
Example: `G3HD.properties`
|
||||
|
||||
```properties
|
||||
url=jdbc:sqlserver://127.0.0.1:1433;databaseName=G3HD
|
||||
username=sa
|
||||
password=your-password
|
||||
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
```
|
||||
|
||||
The `*.properties` files in this directory are ignored by Git.
|
||||
Vendored
+295
@@ -0,0 +1,295 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Apache Maven Wrapper startup batch script, version 3.3.4
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
||||
# MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
set -euf
|
||||
[ "${MVNW_VERBOSE-}" != debug ] || set -x
|
||||
|
||||
# OS specific support.
|
||||
native_path() { printf %s\\n "$1"; }
|
||||
case "$(uname)" in
|
||||
CYGWIN* | MINGW*)
|
||||
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
|
||||
native_path() { cygpath --path --windows "$1"; }
|
||||
;;
|
||||
esac
|
||||
|
||||
# set JAVACMD and JAVACCMD
|
||||
set_java_home() {
|
||||
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
|
||||
if [ -n "${JAVA_HOME-}" ]; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACCMD="$JAVA_HOME/jre/sh/javac"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACCMD="$JAVA_HOME/bin/javac"
|
||||
|
||||
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
|
||||
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
|
||||
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v java
|
||||
)" || :
|
||||
JAVACCMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v javac
|
||||
)" || :
|
||||
|
||||
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
|
||||
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# hash string like Java String::hashCode
|
||||
hash_string() {
|
||||
str="${1:-}" h=0
|
||||
while [ -n "$str" ]; do
|
||||
char="${str%"${str#?}"}"
|
||||
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
|
||||
str="${str#?}"
|
||||
done
|
||||
printf %x\\n $h
|
||||
}
|
||||
|
||||
verbose() { :; }
|
||||
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
|
||||
|
||||
die() {
|
||||
printf %s\\n "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
trim() {
|
||||
# MWRAPPER-139:
|
||||
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
|
||||
# Needed for removing poorly interpreted newline sequences when running in more
|
||||
# exotic environments such as mingw bash on Windows.
|
||||
printf "%s" "${1}" | tr -d '[:space:]'
|
||||
}
|
||||
|
||||
scriptDir="$(dirname "$0")"
|
||||
scriptName="$(basename "$0")"
|
||||
|
||||
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
|
||||
while IFS="=" read -r key value; do
|
||||
case "${key-}" in
|
||||
distributionUrl) distributionUrl=$(trim "${value-}") ;;
|
||||
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
|
||||
esac
|
||||
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
|
||||
case "${distributionUrl##*/}" in
|
||||
maven-mvnd-*bin.*)
|
||||
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
|
||||
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
|
||||
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
|
||||
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
|
||||
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
|
||||
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
|
||||
*)
|
||||
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
|
||||
distributionPlatform=linux-amd64
|
||||
;;
|
||||
esac
|
||||
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
|
||||
;;
|
||||
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
||||
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
||||
esac
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
distributionUrlNameMain="${distributionUrlName%.*}"
|
||||
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
|
||||
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
|
||||
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
|
||||
|
||||
exec_maven() {
|
||||
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
|
||||
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
|
||||
}
|
||||
|
||||
if [ -d "$MAVEN_HOME" ]; then
|
||||
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
exec_maven "$@"
|
||||
fi
|
||||
|
||||
case "${distributionUrl-}" in
|
||||
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
|
||||
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
|
||||
esac
|
||||
|
||||
# prepare tmp dir
|
||||
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
|
||||
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
|
||||
trap clean HUP INT TERM EXIT
|
||||
else
|
||||
die "cannot create temp dir"
|
||||
fi
|
||||
|
||||
mkdir -p -- "${MAVEN_HOME%/*}"
|
||||
|
||||
# Download and Install Apache Maven
|
||||
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
verbose "Downloading from: $distributionUrl"
|
||||
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
# select .zip or .tar.gz
|
||||
if ! command -v unzip >/dev/null; then
|
||||
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
fi
|
||||
|
||||
# verbose opt
|
||||
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
|
||||
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
|
||||
|
||||
# normalize http auth
|
||||
case "${MVNW_PASSWORD:+has-password}" in
|
||||
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
esac
|
||||
|
||||
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
|
||||
verbose "Found wget ... using wget"
|
||||
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
|
||||
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
|
||||
verbose "Found curl ... using curl"
|
||||
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
|
||||
elif set_java_home; then
|
||||
verbose "Falling back to use Java to download"
|
||||
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
|
||||
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
cat >"$javaSource" <<-END
|
||||
public class Downloader extends java.net.Authenticator
|
||||
{
|
||||
protected java.net.PasswordAuthentication getPasswordAuthentication()
|
||||
{
|
||||
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
|
||||
}
|
||||
public static void main( String[] args ) throws Exception
|
||||
{
|
||||
setDefault( new Downloader() );
|
||||
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
|
||||
}
|
||||
}
|
||||
END
|
||||
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
|
||||
verbose " - Compiling Downloader.java ..."
|
||||
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
|
||||
verbose " - Running Downloader.java ..."
|
||||
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
|
||||
fi
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
if [ -n "${distributionSha256Sum-}" ]; then
|
||||
distributionSha256Result=false
|
||||
if [ "$MVN_CMD" = mvnd.sh ]; then
|
||||
echo "Checksum validation is not supported for maven-mvnd." >&2
|
||||
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
elif command -v sha256sum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
elif command -v shasum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
|
||||
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ $distributionSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# unzip and move
|
||||
if command -v unzip >/dev/null; then
|
||||
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
|
||||
else
|
||||
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
|
||||
fi
|
||||
|
||||
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||
actualDistributionDir=""
|
||||
|
||||
# First try the expected directory name (for regular distributions)
|
||||
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
|
||||
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
|
||||
actualDistributionDir="$distributionUrlNameMain"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||
if [ -z "$actualDistributionDir" ]; then
|
||||
# enable globbing to iterate over items
|
||||
set +f
|
||||
for dir in "$TMP_DOWNLOAD_DIR"/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
if [ -f "$dir/bin/$MVN_CMD" ]; then
|
||||
actualDistributionDir="$(basename "$dir")"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
set -f
|
||||
fi
|
||||
|
||||
if [ -z "$actualDistributionDir" ]; then
|
||||
verbose "Contents of $TMP_DOWNLOAD_DIR:"
|
||||
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
|
||||
die "Could not find Maven distribution directory in extracted archive"
|
||||
fi
|
||||
|
||||
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
|
||||
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||
|
||||
clean || :
|
||||
exec_maven "$@"
|
||||
Vendored
+189
@@ -0,0 +1,189 @@
|
||||
<# : batch portion
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.3.4
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
|
||||
@SET __MVNW_CMD__=
|
||||
@SET __MVNW_ERROR__=
|
||||
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
|
||||
@SET PSModulePath=
|
||||
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
|
||||
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
|
||||
)
|
||||
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
|
||||
@SET __MVNW_PSMODULEP_SAVE=
|
||||
@SET __MVNW_ARG0_NAME__=
|
||||
@SET MVNW_USERNAME=
|
||||
@SET MVNW_PASSWORD=
|
||||
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
|
||||
@echo Cannot start maven from wrapper >&2 && exit /b 1
|
||||
@GOTO :EOF
|
||||
: end batch / begin powershell #>
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ($env:MVNW_VERBOSE -eq "true") {
|
||||
$VerbosePreference = "Continue"
|
||||
}
|
||||
|
||||
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
|
||||
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
|
||||
if (!$distributionUrl) {
|
||||
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
}
|
||||
|
||||
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
|
||||
"maven-mvnd-*" {
|
||||
$USE_MVND = $true
|
||||
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
|
||||
$MVN_CMD = "mvnd.cmd"
|
||||
break
|
||||
}
|
||||
default {
|
||||
$USE_MVND = $false
|
||||
$MVN_CMD = $script -replace '^mvnw','mvn'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
if ($env:MVNW_REPOURL) {
|
||||
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
|
||||
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
|
||||
}
|
||||
$distributionUrlName = $distributionUrl -replace '^.*/',''
|
||||
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
|
||||
|
||||
$MAVEN_M2_PATH = "$HOME/.m2"
|
||||
if ($env:MAVEN_USER_HOME) {
|
||||
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
|
||||
}
|
||||
|
||||
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
|
||||
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
|
||||
}
|
||||
|
||||
$MAVEN_WRAPPER_DISTS = $null
|
||||
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
|
||||
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
|
||||
} else {
|
||||
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
|
||||
}
|
||||
|
||||
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
|
||||
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
|
||||
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
|
||||
|
||||
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
|
||||
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
exit $?
|
||||
}
|
||||
|
||||
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
|
||||
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
|
||||
}
|
||||
|
||||
# prepare tmp dir
|
||||
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
|
||||
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
|
||||
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
|
||||
trap {
|
||||
if ($TMP_DOWNLOAD_DIR.Exists) {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
}
|
||||
|
||||
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
|
||||
|
||||
# Download and Install Apache Maven
|
||||
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
Write-Verbose "Downloading from: $distributionUrl"
|
||||
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
|
||||
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
|
||||
}
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
|
||||
if ($distributionSha256Sum) {
|
||||
if ($USE_MVND) {
|
||||
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
|
||||
}
|
||||
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
|
||||
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
|
||||
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
|
||||
}
|
||||
}
|
||||
|
||||
# unzip and move
|
||||
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
|
||||
|
||||
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||
$actualDistributionDir = ""
|
||||
|
||||
# First try the expected directory name (for regular distributions)
|
||||
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
|
||||
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
|
||||
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
|
||||
$actualDistributionDir = $distributionUrlNameMain
|
||||
}
|
||||
|
||||
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||
if (!$actualDistributionDir) {
|
||||
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
|
||||
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
|
||||
if (Test-Path -Path $testPath -PathType Leaf) {
|
||||
$actualDistributionDir = $_.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$actualDistributionDir) {
|
||||
Write-Error "Could not find Maven distribution directory in extracted archive"
|
||||
}
|
||||
|
||||
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
|
||||
try {
|
||||
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
|
||||
} catch {
|
||||
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
|
||||
Write-Error "fail to move MAVEN_HOME"
|
||||
}
|
||||
} finally {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.1.0</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>cn.g3soft</groupId>
|
||||
<artifactId>fms-api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>fms-api</name>
|
||||
<description>fms-api</description>
|
||||
<url/>
|
||||
<licenses>
|
||||
<license/>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer/>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection/>
|
||||
<developerConnection/>
|
||||
<tag/>
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.2.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>0.12.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>0.12.6</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>0.12.6</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.g3soft.fmsapi;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ConfigurationPropertiesScan
|
||||
public class FmsApiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FmsApiApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.g3soft.fmsapi.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@ConfigurationProperties(prefix = "fms.auth")
|
||||
public class AuthProperties {
|
||||
|
||||
private String jwtSecret;
|
||||
private Duration jwtExpiration = Duration.ofHours(24);
|
||||
|
||||
public String getJwtSecret() {
|
||||
return jwtSecret;
|
||||
}
|
||||
|
||||
public void setJwtSecret(String jwtSecret) {
|
||||
this.jwtSecret = jwtSecret;
|
||||
}
|
||||
|
||||
public Duration getJwtExpiration() {
|
||||
return jwtExpiration;
|
||||
}
|
||||
|
||||
public void setJwtExpiration(Duration jwtExpiration) {
|
||||
this.jwtExpiration = jwtExpiration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package cn.g3soft.fmsapi.config;
|
||||
|
||||
import cn.g3soft.fmsapi.database.OrgContext;
|
||||
import cn.g3soft.fmsapi.utils.ApiResponse;
|
||||
import cn.g3soft.fmsapi.utils.JwtUtils;
|
||||
import io.jsonwebtoken.JwtException;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class JwtAuthFilter extends OncePerRequestFilter {
|
||||
|
||||
private static final String BEARER_PREFIX = "Bearer ";
|
||||
private static final String LOGIN_PATH = "/auth/login";
|
||||
|
||||
@Resource
|
||||
private JwtUtils jwtUtils;
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotFilter(HttpServletRequest request) {
|
||||
return "OPTIONS".equalsIgnoreCase(request.getMethod())
|
||||
|| LOGIN_PATH.equals(request.getServletPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
FilterChain filterChain
|
||||
) throws ServletException, IOException {
|
||||
String orgId;
|
||||
try {
|
||||
String token = getToken(request);
|
||||
orgId = jwtUtils.getOrgId(token);
|
||||
OrgContext.setOrgId(orgId);
|
||||
} catch (JwtException | IllegalArgumentException exception) {
|
||||
writeUnauthorized(response);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
filterChain.doFilter(request, response);
|
||||
} finally {
|
||||
OrgContext.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private String getToken(HttpServletRequest request) {
|
||||
String authorization = request.getHeader("Authorization");
|
||||
if (authorization == null || !authorization.startsWith(BEARER_PREFIX)) {
|
||||
throw new IllegalArgumentException("缺少登录凭证");
|
||||
}
|
||||
return authorization.substring(BEARER_PREFIX.length()).trim();
|
||||
}
|
||||
|
||||
private void writeUnauthorized(HttpServletResponse response) throws IOException {
|
||||
ApiResponse<Void> body = ApiResponse.fail(
|
||||
ApiResponse.AUTH_ERROR_CODE,
|
||||
"未登录或登录已失效"
|
||||
);
|
||||
response.setStatus(200);
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json");
|
||||
objectMapper.writeValue(response.getWriter(), body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.g3soft.fmsapi.controller;
|
||||
|
||||
import cn.g3soft.fmsapi.exception.BusinessException;
|
||||
import cn.g3soft.fmsapi.service.AuthService;
|
||||
import cn.g3soft.fmsapi.utils.ApiResponse;
|
||||
import cn.g3soft.fmsapi.utils.ParamUtils;
|
||||
import cn.g3soft.fmsapi.utils.StringUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AuthController {
|
||||
|
||||
@Resource
|
||||
private AuthService authService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public ApiResponse<Map<String, Object>> login(
|
||||
@RequestBody(required = false) Map<String, Object> request
|
||||
) throws SQLException {
|
||||
String orgId = ParamUtils.getString(request, "orgid");
|
||||
String userId = ParamUtils.getString(request, "userid");
|
||||
String password = ParamUtils.getString(request, "password");
|
||||
|
||||
if (StringUtils.isBlank(orgId)) {
|
||||
throw new BusinessException("机构码不能为空");
|
||||
}
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
throw new BusinessException("用户ID不能为空");
|
||||
}
|
||||
|
||||
Optional<Map<String, Object>> loginResponse = authService.login(
|
||||
orgId,
|
||||
userId,
|
||||
password
|
||||
);
|
||||
if (loginResponse.isEmpty()) {
|
||||
return ApiResponse.fail(
|
||||
ApiResponse.AUTH_ERROR_CODE,
|
||||
"机构码、账号或密码错误"
|
||||
);
|
||||
}
|
||||
return ApiResponse.success(loginResponse.get());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.g3soft.fmsapi.controller;
|
||||
|
||||
import cn.g3soft.fmsapi.service.DataService;
|
||||
import cn.g3soft.fmsapi.utils.ApiResponse;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data")
|
||||
public class DataController {
|
||||
|
||||
@Resource
|
||||
private DataService dataService;
|
||||
|
||||
@PostMapping("/loaddata")
|
||||
public ApiResponse<List<Map<String, Object>>> loadData(
|
||||
@RequestBody(required = false) Map<String, Object> params
|
||||
) throws SQLException {
|
||||
return ApiResponse.success(dataService.loadData(params));
|
||||
}
|
||||
|
||||
@PostMapping("/loaddatabysql")
|
||||
public ApiResponse<List<Map<String, Object>>> loadDataBySql(
|
||||
@RequestBody(required = false) Map<String, Object> params
|
||||
) throws SQLException {
|
||||
return ApiResponse.success(dataService.loadDataBySql(params));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.g3soft.fmsapi.database;
|
||||
|
||||
public final class OrgContext {
|
||||
|
||||
private static final ThreadLocal<String> ORG_ID_HOLDER = new ThreadLocal<>();
|
||||
|
||||
private OrgContext() {
|
||||
}
|
||||
|
||||
public static void setOrgId(String orgId) {
|
||||
if (orgId == null || orgId.isBlank()) {
|
||||
throw new IllegalArgumentException("机构码不能为空");
|
||||
}
|
||||
ORG_ID_HOLDER.set(orgId);
|
||||
}
|
||||
|
||||
public static String getOrgId() {
|
||||
return ORG_ID_HOLDER.get();
|
||||
}
|
||||
|
||||
public static String requireOrgId() {
|
||||
String orgId = getOrgId();
|
||||
if (orgId == null) {
|
||||
throw new IllegalStateException("当前请求未设置机构上下文");
|
||||
}
|
||||
return orgId;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
ORG_ID_HOLDER.remove();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.g3soft.fmsapi.database;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Component
|
||||
public class OrgDataSourceFactory {
|
||||
|
||||
@Resource
|
||||
private OrgDatabaseProperties properties;
|
||||
|
||||
public DruidDataSource create(String orgId, OrgDatabaseConfig config) {
|
||||
OrgDatabaseProperties.Pool poolProperties = properties.getPool();
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setName("fms-" + orgId);
|
||||
dataSource.setUrl(config.url());
|
||||
dataSource.setUsername(config.username());
|
||||
dataSource.setPassword(config.password());
|
||||
dataSource.setDriverClassName(config.driver());
|
||||
dataSource.setInitialSize(poolProperties.getInitialSize());
|
||||
dataSource.setMinIdle(poolProperties.getMinIdle());
|
||||
dataSource.setMaxActive(poolProperties.getMaxActive());
|
||||
dataSource.setMaxWait(poolProperties.getMaxWait());
|
||||
dataSource.setValidationQuery(poolProperties.getValidationQuery());
|
||||
dataSource.setTestWhileIdle(poolProperties.isTestWhileIdle());
|
||||
dataSource.setTestOnBorrow(poolProperties.isTestOnBorrow());
|
||||
dataSource.setTestOnReturn(poolProperties.isTestOnReturn());
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(
|
||||
poolProperties.getTimeBetweenEvictionRuns().toMillis()
|
||||
);
|
||||
dataSource.setMinEvictableIdleTimeMillis(
|
||||
poolProperties.getMinEvictableIdleTime().toMillis()
|
||||
);
|
||||
|
||||
try {
|
||||
dataSource.init();
|
||||
return dataSource;
|
||||
} catch (SQLException exception) {
|
||||
dataSource.close();
|
||||
throw new IllegalStateException("初始化机构数据库连接池失败: " + orgId, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.g3soft.fmsapi.database;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
@Component
|
||||
public class OrgDataSourceManager {
|
||||
|
||||
private final ConcurrentMap<String, DruidDataSource> dataSources = new ConcurrentHashMap<>();
|
||||
|
||||
@Resource
|
||||
private OrgDatabaseConfigLoader configLoader;
|
||||
|
||||
@Resource
|
||||
private OrgDataSourceFactory dataSourceFactory;
|
||||
|
||||
public DruidDataSource getDataSource(String orgId) {
|
||||
String normalizedOrgId = configLoader.normalizeOrgId(orgId);
|
||||
return dataSources.computeIfAbsent(normalizedOrgId, this::createDataSource);
|
||||
}
|
||||
|
||||
public Connection getConnection(String orgId) throws SQLException {
|
||||
return getDataSource(orgId).getConnection();
|
||||
}
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
return getConnection(OrgContext.requireOrgId());
|
||||
}
|
||||
|
||||
public boolean closeDataSource(String orgId) {
|
||||
String normalizedOrgId = configLoader.normalizeOrgId(orgId);
|
||||
DruidDataSource dataSource = dataSources.remove(normalizedOrgId);
|
||||
if (dataSource == null) {
|
||||
return false;
|
||||
}
|
||||
dataSource.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getDataSourceCount() {
|
||||
return dataSources.size();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void closeAll() {
|
||||
dataSources.values().forEach(DruidDataSource::close);
|
||||
dataSources.clear();
|
||||
}
|
||||
|
||||
private DruidDataSource createDataSource(String orgId) {
|
||||
OrgDatabaseConfig config = configLoader.load(orgId);
|
||||
return dataSourceFactory.create(orgId, config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.g3soft.fmsapi.database;
|
||||
|
||||
public record OrgDatabaseConfig(
|
||||
String url,
|
||||
String username,
|
||||
String password,
|
||||
String driver
|
||||
) {
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
package cn.g3soft.fmsapi.database;
|
||||
|
||||
import cn.g3soft.fmsapi.exception.BusinessException;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Component
|
||||
public class OrgDatabaseConfigLoader {
|
||||
|
||||
private static final Pattern ORG_ID_PATTERN = Pattern.compile("[A-Z0-9_-]{1,32}");
|
||||
private static final String DEFAULT_SQL_SERVER_DRIVER =
|
||||
"com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
||||
|
||||
@Resource
|
||||
private OrgDatabaseProperties properties;
|
||||
|
||||
private Path configDir;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.configDir = properties.getConfigDir().toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
public OrgDatabaseConfig load(String orgId) {
|
||||
String normalizedOrgId = normalizeOrgId(orgId);
|
||||
Path configFile = configDir.resolve(normalizedOrgId + ".properties").normalize();
|
||||
if (!configFile.startsWith(configDir)) {
|
||||
throw new IllegalArgumentException("机构配置文件路径不合法");
|
||||
}
|
||||
if (!Files.isRegularFile(configFile)) {
|
||||
throw new IllegalStateException("未找到机构数据库配置文件: " + configFile);
|
||||
}
|
||||
|
||||
Properties properties = new Properties();
|
||||
try (InputStream input = Files.newInputStream(configFile);
|
||||
InputStreamReader reader = new InputStreamReader(input, StandardCharsets.UTF_8)) {
|
||||
properties.load(reader);
|
||||
} catch (IOException exception) {
|
||||
throw new IllegalStateException("读取机构数据库配置文件失败: " + configFile, exception);
|
||||
}
|
||||
|
||||
String url = required(properties, "url", configFile);
|
||||
if (!url.toLowerCase(Locale.ROOT).startsWith("jdbc:sqlserver:")) {
|
||||
throw new IllegalStateException("机构数据库必须使用 SQL Server: " + configFile);
|
||||
}
|
||||
|
||||
return new OrgDatabaseConfig(
|
||||
url,
|
||||
required(properties, "username", configFile),
|
||||
requiredPassword(properties, configFile),
|
||||
readDriver(properties)
|
||||
);
|
||||
}
|
||||
|
||||
public String normalizeOrgId(String orgId) {
|
||||
if (orgId == null) {
|
||||
throw new BusinessException("机构码不能为空");
|
||||
}
|
||||
|
||||
String normalized = orgId.trim().toUpperCase(Locale.ROOT);
|
||||
if (!ORG_ID_PATTERN.matcher(normalized).matches()) {
|
||||
throw new BusinessException("机构码格式不正确");
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
public Path getConfigDir() {
|
||||
return configDir;
|
||||
}
|
||||
|
||||
private String required(Properties properties, String key, Path configFile) {
|
||||
String value = properties.getProperty(key);
|
||||
if (value == null || value.isBlank()) {
|
||||
throw new IllegalStateException("机构数据库配置缺少 " + key + ": " + configFile);
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
private String requiredPassword(Properties properties, Path configFile) {
|
||||
String password = properties.getProperty("password");
|
||||
if (password == null || password.isBlank()) {
|
||||
throw new IllegalStateException("机构数据库配置缺少 password: " + configFile);
|
||||
}
|
||||
return password;
|
||||
}
|
||||
|
||||
private String readDriver(Properties properties) {
|
||||
String driver = properties.getProperty("driver");
|
||||
return driver == null || driver.isBlank() ? DEFAULT_SQL_SERVER_DRIVER : driver.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package cn.g3soft.fmsapi.database;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
|
||||
@ConfigurationProperties(prefix = "fms.database")
|
||||
public class OrgDatabaseProperties {
|
||||
|
||||
private Path configDir = Path.of("./config/dbconfigs");
|
||||
private final Pool pool = new Pool();
|
||||
|
||||
public Path getConfigDir() {
|
||||
return configDir;
|
||||
}
|
||||
|
||||
public void setConfigDir(Path configDir) {
|
||||
this.configDir = configDir;
|
||||
}
|
||||
|
||||
public Pool getPool() {
|
||||
return pool;
|
||||
}
|
||||
|
||||
public static class Pool {
|
||||
|
||||
private int initialSize;
|
||||
private int minIdle;
|
||||
private int maxActive = 10;
|
||||
private long maxWait = 5000;
|
||||
private String validationQuery = "SELECT 1";
|
||||
private boolean testWhileIdle = true;
|
||||
private boolean testOnBorrow;
|
||||
private boolean testOnReturn;
|
||||
private Duration timeBetweenEvictionRuns = Duration.ofMinutes(1);
|
||||
private Duration minEvictableIdleTime = Duration.ofMinutes(5);
|
||||
|
||||
public int getInitialSize() {
|
||||
return initialSize;
|
||||
}
|
||||
|
||||
public void setInitialSize(int initialSize) {
|
||||
this.initialSize = initialSize;
|
||||
}
|
||||
|
||||
public int getMinIdle() {
|
||||
return minIdle;
|
||||
}
|
||||
|
||||
public void setMinIdle(int minIdle) {
|
||||
this.minIdle = minIdle;
|
||||
}
|
||||
|
||||
public int getMaxActive() {
|
||||
return maxActive;
|
||||
}
|
||||
|
||||
public void setMaxActive(int maxActive) {
|
||||
this.maxActive = maxActive;
|
||||
}
|
||||
|
||||
public long getMaxWait() {
|
||||
return maxWait;
|
||||
}
|
||||
|
||||
public void setMaxWait(long maxWait) {
|
||||
this.maxWait = maxWait;
|
||||
}
|
||||
|
||||
public String getValidationQuery() {
|
||||
return validationQuery;
|
||||
}
|
||||
|
||||
public void setValidationQuery(String validationQuery) {
|
||||
this.validationQuery = validationQuery;
|
||||
}
|
||||
|
||||
public boolean isTestWhileIdle() {
|
||||
return testWhileIdle;
|
||||
}
|
||||
|
||||
public void setTestWhileIdle(boolean testWhileIdle) {
|
||||
this.testWhileIdle = testWhileIdle;
|
||||
}
|
||||
|
||||
public boolean isTestOnBorrow() {
|
||||
return testOnBorrow;
|
||||
}
|
||||
|
||||
public void setTestOnBorrow(boolean testOnBorrow) {
|
||||
this.testOnBorrow = testOnBorrow;
|
||||
}
|
||||
|
||||
public boolean isTestOnReturn() {
|
||||
return testOnReturn;
|
||||
}
|
||||
|
||||
public void setTestOnReturn(boolean testOnReturn) {
|
||||
this.testOnReturn = testOnReturn;
|
||||
}
|
||||
|
||||
public Duration getTimeBetweenEvictionRuns() {
|
||||
return timeBetweenEvictionRuns;
|
||||
}
|
||||
|
||||
public void setTimeBetweenEvictionRuns(Duration timeBetweenEvictionRuns) {
|
||||
this.timeBetweenEvictionRuns = timeBetweenEvictionRuns;
|
||||
}
|
||||
|
||||
public Duration getMinEvictableIdleTime() {
|
||||
return minEvictableIdleTime;
|
||||
}
|
||||
|
||||
public void setMinEvictableIdleTime(Duration minEvictableIdleTime) {
|
||||
this.minEvictableIdleTime = minEvictableIdleTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.g3soft.fmsapi.database;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.jdbc.datasource.AbstractDataSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Primary
|
||||
@Component
|
||||
public class OrgRoutingDataSource extends AbstractDataSource {
|
||||
|
||||
@Resource
|
||||
private OrgDataSourceManager dataSourceManager;
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
return dataSourceManager.getConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection(String username, String password) throws SQLException {
|
||||
return dataSourceManager.getDataSource(OrgContext.requireOrgId())
|
||||
.getConnection(username, password);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.g3soft.fmsapi.exception;
|
||||
|
||||
public class BusinessException extends RuntimeException {
|
||||
|
||||
public BusinessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.g3soft.fmsapi.exception;
|
||||
|
||||
import cn.g3soft.fmsapi.utils.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public ApiResponse<Void> handleBusinessException(BusinessException exception) {
|
||||
return ApiResponse.fail(exception.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ApiResponse<Void> handleException(
|
||||
Exception exception,
|
||||
HttpServletRequest request
|
||||
) {
|
||||
LOGGER.error(
|
||||
"系统异常,method={},uri={}",
|
||||
request.getMethod(),
|
||||
request.getRequestURI(),
|
||||
exception
|
||||
);
|
||||
return ApiResponse.fail(
|
||||
ApiResponse.SYSTEM_ERROR_CODE,
|
||||
"系统异常,请稍后重试"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.g3soft.fmsapi.service;
|
||||
|
||||
import cn.g3soft.fmsapi.utils.DbUtils;
|
||||
import cn.g3soft.fmsapi.utils.JwtUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class AuthService {
|
||||
|
||||
@Resource
|
||||
private DbUtils dbUtils;
|
||||
|
||||
@Resource
|
||||
private JwtUtils jwtUtils;
|
||||
|
||||
public Optional<Map<String, Object>> login(
|
||||
String orgId,
|
||||
String userId,
|
||||
String password
|
||||
) throws SQLException {
|
||||
String normalizedOrgId = orgId.trim().toUpperCase(Locale.ROOT);
|
||||
String normalizedUserId = userId.trim();
|
||||
List<Map<String, Object>> users = dbUtils.loadData(
|
||||
normalizedOrgId,
|
||||
"b_user",
|
||||
"b_id = " + dbUtils.toSqlStringLiteral(normalizedUserId),
|
||||
null,
|
||||
List.of("b_id", "b_name", "b_password")
|
||||
);
|
||||
|
||||
if (users.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Map<String, Object> account = users.getFirst();
|
||||
String storedPassword = getString(account, "b_password");
|
||||
if (!passwordMatches(storedPassword, password)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
String accountId = getString(account, "b_id");
|
||||
String token = jwtUtils.generateToken(accountId, normalizedOrgId);
|
||||
|
||||
Map<String, Object> user = new LinkedHashMap<>();
|
||||
user.put("id", accountId);
|
||||
user.put("name", getString(account, "b_name"));
|
||||
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("token", token);
|
||||
result.put("orgid", normalizedOrgId);
|
||||
result.put("user", user);
|
||||
return Optional.of(result);
|
||||
}
|
||||
|
||||
private String getString(Map<String, Object> row, String column) {
|
||||
for (Map.Entry<String, Object> entry : row.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase(column)) {
|
||||
Object value = entry.getValue();
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean passwordMatches(String storedPassword, String submittedPassword) {
|
||||
if (storedPassword == null || submittedPassword == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return MessageDigest.isEqual(
|
||||
storedPassword.getBytes(StandardCharsets.UTF_8),
|
||||
submittedPassword.getBytes(StandardCharsets.UTF_8)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.g3soft.fmsapi.service;
|
||||
|
||||
import cn.g3soft.fmsapi.utils.DbUtils;
|
||||
import cn.g3soft.fmsapi.utils.ParamUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class DataService {
|
||||
|
||||
@Resource
|
||||
private DbUtils dbUtils;
|
||||
|
||||
public List<Map<String, Object>> loadData(Map<String, Object> params) throws SQLException {
|
||||
return dbUtils.loadData(
|
||||
ParamUtils.getRequiredString(params, "viewName"),
|
||||
ParamUtils.getString(params, "searchCondition"),
|
||||
ParamUtils.getString(params, "orderField"),
|
||||
ParamUtils.getList(params, "searchColumns")
|
||||
);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> loadDataBySql(Map<String, Object> params) throws SQLException {
|
||||
return dbUtils.loadDataBySql(
|
||||
ParamUtils.getRequiredString(params, "sql")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.g3soft.fmsapi.utils;
|
||||
|
||||
public record ApiResponse<T>(
|
||||
int code,
|
||||
String message,
|
||||
T data
|
||||
) {
|
||||
|
||||
public static final int SUCCESS_CODE = 0;
|
||||
public static final int AUTH_ERROR_CODE = 401;
|
||||
public static final int SYSTEM_ERROR_CODE = 500;
|
||||
public static final int BUSINESS_ERROR_CODE = 1000;
|
||||
|
||||
public static <T> ApiResponse<T> success(T data) {
|
||||
return new ApiResponse<>(SUCCESS_CODE, "操作成功", data);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> fail(String message) {
|
||||
return fail(BUSINESS_ERROR_CODE, message);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> fail(int code, String message) {
|
||||
return new ApiResponse<>(code, message, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
package cn.g3soft.fmsapi.utils;
|
||||
|
||||
import cn.g3soft.fmsapi.database.OrgDataSourceManager;
|
||||
import cn.g3soft.fmsapi.exception.BusinessException;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DbUtils {
|
||||
|
||||
private static final Pattern SAFE_IDENTIFIER = Pattern.compile("[A-Za-z_][A-Za-z0-9_]*");
|
||||
private static final Pattern READ_SQL_PATTERN = Pattern.compile("(?is)^\\s*(select|with)\\b");
|
||||
private static final Pattern WRITE_SQL_PATTERN = Pattern.compile(
|
||||
"(?i)\\b(insert|update|delete|merge|drop|truncate|alter|create|exec|execute|grant|revoke|backup|restore|dbcc|kill|use|into)\\b"
|
||||
);
|
||||
private static final Pattern SQL_COMMENT_PATTERN = Pattern.compile("--|/\\*|\\*/");
|
||||
|
||||
@Resource
|
||||
private OrgDataSourceManager dataSourceManager;
|
||||
|
||||
@Resource
|
||||
private DataSource dataSource;
|
||||
|
||||
public List<Map<String, Object>> loadData(String viewName) throws SQLException {
|
||||
return loadData(viewName, null, null, null);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> loadData(
|
||||
String viewName,
|
||||
String searchCondition,
|
||||
String orderField,
|
||||
List<String> searchColumns
|
||||
) throws SQLException {
|
||||
String sql = buildLoadDataSql(viewName, searchCondition, orderField, searchColumns);
|
||||
Connection connection = DataSourceUtils.getConnection(dataSource);
|
||||
try {
|
||||
return executeQuery(connection, sql);
|
||||
} finally {
|
||||
DataSourceUtils.releaseConnection(connection, dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> loadData(
|
||||
String orgId,
|
||||
String viewName,
|
||||
String searchCondition,
|
||||
String orderField,
|
||||
List<String> searchColumns
|
||||
) throws SQLException {
|
||||
String sql = buildLoadDataSql(viewName, searchCondition, orderField, searchColumns);
|
||||
try (Connection connection = dataSourceManager.getConnection(orgId)) {
|
||||
return executeQuery(connection, sql);
|
||||
}
|
||||
}
|
||||
|
||||
private String buildLoadDataSql(
|
||||
String viewName,
|
||||
String searchCondition,
|
||||
String orderField,
|
||||
List<String> searchColumns
|
||||
) {
|
||||
String columnsSql = buildColumns(searchColumns);
|
||||
StringBuilder sql = new StringBuilder("SELECT ")
|
||||
.append(columnsSql)
|
||||
.append(" FROM ")
|
||||
.append(quoteQualifiedIdentifier(viewName));
|
||||
|
||||
if (hasText(searchCondition)) {
|
||||
sql.append(" WHERE ").append(searchCondition.trim());
|
||||
}
|
||||
if (hasText(orderField)) {
|
||||
sql.append(" ORDER BY ").append(buildOrderBy(orderField));
|
||||
}
|
||||
|
||||
String querySql = sql.toString();
|
||||
validateReadOnlySql(querySql);
|
||||
return querySql;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> loadDataBySql(String sql) throws SQLException {
|
||||
validateReadOnlySql(sql);
|
||||
|
||||
Connection connection = DataSourceUtils.getConnection(dataSource);
|
||||
try {
|
||||
return executeQuery(connection, sql);
|
||||
} finally {
|
||||
DataSourceUtils.releaseConnection(connection, dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> loadDataBySql(
|
||||
Connection connection,
|
||||
String sql
|
||||
) throws SQLException {
|
||||
if (connection == null) {
|
||||
throw new IllegalArgumentException("数据库连接不能为空");
|
||||
}
|
||||
validateReadOnlySql(sql);
|
||||
|
||||
return executeQuery(connection, sql);
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> executeQuery(
|
||||
Connection connection,
|
||||
String sql
|
||||
) throws SQLException {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
try (ResultSet resultSet = statement.executeQuery(sql)) {
|
||||
return readRows(resultSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String toSqlStringLiteral(String value) {
|
||||
if (value == null) {
|
||||
return "NULL";
|
||||
}
|
||||
return "N'" + value.replace("'", "''") + "'";
|
||||
}
|
||||
|
||||
public void validateIdentifier(String identifier) {
|
||||
if (!hasText(identifier) || !SAFE_IDENTIFIER.matcher(identifier).matches()) {
|
||||
throw new BusinessException("非法数据库标识符: " + identifier);
|
||||
}
|
||||
}
|
||||
|
||||
public void validateReadOnlySql(String sql) {
|
||||
if (!hasText(sql)) {
|
||||
throw new BusinessException("查询 SQL 不能为空");
|
||||
}
|
||||
|
||||
String normalizedSql = sql.trim();
|
||||
if (!READ_SQL_PATTERN.matcher(normalizedSql).find()) {
|
||||
throw new BusinessException("只允许执行只读查询");
|
||||
}
|
||||
String sqlStructure = removeStringLiterals(normalizedSql);
|
||||
if (sqlStructure.contains(";")) {
|
||||
throw new BusinessException("查询 SQL 不允许包含分号");
|
||||
}
|
||||
if (SQL_COMMENT_PATTERN.matcher(sqlStructure).find()) {
|
||||
throw new BusinessException("查询 SQL 不允许包含注释");
|
||||
}
|
||||
if (WRITE_SQL_PATTERN.matcher(sqlStructure).find()) {
|
||||
throw new BusinessException("查询 SQL 包含非只读关键字");
|
||||
}
|
||||
}
|
||||
|
||||
private String removeStringLiterals(String sql) {
|
||||
StringBuilder result = new StringBuilder(sql.length());
|
||||
boolean inString = false;
|
||||
|
||||
for (int index = 0; index < sql.length(); index++) {
|
||||
char character = sql.charAt(index);
|
||||
if (character != '\'') {
|
||||
result.append(inString ? ' ' : character);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inString && index + 1 < sql.length() && sql.charAt(index + 1) == '\'') {
|
||||
result.append(" ");
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
inString = !inString;
|
||||
result.append(' ');
|
||||
}
|
||||
|
||||
if (inString) {
|
||||
throw new BusinessException("SQL 字符串未闭合");
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String buildColumns(List<String> searchColumns) {
|
||||
if (searchColumns == null || searchColumns.isEmpty()) {
|
||||
return "*";
|
||||
}
|
||||
return searchColumns.stream()
|
||||
.map(this::quoteQualifiedIdentifier)
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
private String buildOrderBy(String orderField) {
|
||||
String[] parts = orderField.trim().split("\\s+");
|
||||
if (parts.length > 2) {
|
||||
throw new BusinessException("排序字段格式不正确");
|
||||
}
|
||||
|
||||
String direction = "";
|
||||
if (parts.length == 2) {
|
||||
if (!"asc".equalsIgnoreCase(parts[1]) && !"desc".equalsIgnoreCase(parts[1])) {
|
||||
throw new BusinessException("排序方向只允许 ASC 或 DESC");
|
||||
}
|
||||
direction = " " + parts[1].toUpperCase();
|
||||
}
|
||||
return quoteQualifiedIdentifier(parts[0]) + direction;
|
||||
}
|
||||
|
||||
private String quoteQualifiedIdentifier(String identifier) {
|
||||
if (!hasText(identifier)) {
|
||||
throw new BusinessException("数据库标识符不能为空");
|
||||
}
|
||||
|
||||
return Arrays.stream(identifier.trim().split("\\."))
|
||||
.peek(this::validateIdentifier)
|
||||
.map(part -> "[" + part + "]")
|
||||
.collect(Collectors.joining("."));
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> readRows(ResultSet resultSet) throws SQLException {
|
||||
ResultSetMetaData metadata = resultSet.getMetaData();
|
||||
int columnCount = metadata.getColumnCount();
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
|
||||
while (resultSet.next()) {
|
||||
Map<String, Object> row = new LinkedHashMap<>(columnCount);
|
||||
for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
|
||||
row.put(metadata.getColumnLabel(columnIndex), resultSet.getObject(columnIndex));
|
||||
}
|
||||
rows.add(row);
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
private boolean hasText(String value) {
|
||||
return value != null && !value.isBlank();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.g3soft.fmsapi.utils;
|
||||
|
||||
import cn.g3soft.fmsapi.config.AuthProperties;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class JwtUtils {
|
||||
|
||||
@Resource
|
||||
private AuthProperties properties;
|
||||
|
||||
private SecretKey signingKey;
|
||||
private Duration expiration;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
String jwtSecret = properties.getJwtSecret();
|
||||
if (jwtSecret == null || jwtSecret.getBytes(StandardCharsets.UTF_8).length < 32) {
|
||||
throw new IllegalStateException("JWT 密钥长度不能少于 32 字节");
|
||||
}
|
||||
if (properties.getJwtExpiration() == null
|
||||
|| properties.getJwtExpiration().isZero()
|
||||
|| properties.getJwtExpiration().isNegative()) {
|
||||
throw new IllegalStateException("JWT 有效期必须大于 0");
|
||||
}
|
||||
|
||||
this.signingKey = Keys.hmacShaKeyFor(jwtSecret.getBytes(StandardCharsets.UTF_8));
|
||||
this.expiration = properties.getJwtExpiration();
|
||||
}
|
||||
|
||||
public String generateToken(String userId, String orgId) {
|
||||
Instant issuedAt = Instant.now();
|
||||
Instant expiresAt = issuedAt.plus(expiration);
|
||||
|
||||
return Jwts.builder()
|
||||
.subject(userId)
|
||||
.claim("orgid", orgId)
|
||||
.issuedAt(Date.from(issuedAt))
|
||||
.expiration(Date.from(expiresAt))
|
||||
.signWith(signingKey)
|
||||
.compact();
|
||||
}
|
||||
|
||||
public String getOrgId(String token) {
|
||||
return Jwts.parser()
|
||||
.verifyWith(signingKey)
|
||||
.build()
|
||||
.parseSignedClaims(token)
|
||||
.getPayload()
|
||||
.get("orgid", String.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.g3soft.fmsapi.utils;
|
||||
|
||||
import cn.g3soft.fmsapi.exception.BusinessException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class ParamUtils {
|
||||
|
||||
private ParamUtils() {
|
||||
}
|
||||
|
||||
public static String getString(Map<String, ?> params, String field) {
|
||||
return get(params, field, String.class);
|
||||
}
|
||||
|
||||
public static String getRequiredString(Map<String, ?> params, String field) {
|
||||
String value = getString(params, field);
|
||||
if (StringUtils.isBlank(value)) {
|
||||
throw new BusinessException(field + " 不能为空");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static <T> T get(Map<String, ?> params, String field, Class<T> type) {
|
||||
Object value = getValue(params, field);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (!type.isInstance(value)) {
|
||||
throw new BusinessException(field + " 参数类型不正确");
|
||||
}
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> List<T> getList(Map<String, ?> params, String field) {
|
||||
Object value = getValue(params, field);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (!(value instanceof List<?> values)) {
|
||||
throw new BusinessException(field + " 参数类型不正确");
|
||||
}
|
||||
return (List<T>) values;
|
||||
}
|
||||
|
||||
public static Object[] getArray(Map<String, ?> params, String field) {
|
||||
List<?> values = getList(params, field);
|
||||
if (values == null) {
|
||||
return null;
|
||||
}
|
||||
return values.toArray();
|
||||
}
|
||||
|
||||
private static Object getValue(Map<String, ?> params, String field) {
|
||||
return params == null ? null : params.get(field);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.g3soft.fmsapi.utils;
|
||||
|
||||
public final class StringUtils {
|
||||
|
||||
private StringUtils() {
|
||||
}
|
||||
|
||||
public static boolean isBlank(String value) {
|
||||
return value == null || value.isBlank();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
server:
|
||||
servlet:
|
||||
context-path: /api
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: fms-api
|
||||
|
||||
fms:
|
||||
auth:
|
||||
jwt-secret: "${FMS_JWT_SECRET:fms-api-development-jwt-secret-change-me}"
|
||||
jwt-expiration: 24h
|
||||
database:
|
||||
config-dir: ./config/dbconfigs
|
||||
pool:
|
||||
initial-size: 0
|
||||
min-idle: 0
|
||||
max-active: 10
|
||||
max-wait: 5000
|
||||
validation-query: SELECT 1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
time-between-eviction-runs: 60s
|
||||
min-evictable-idle-time: 5m
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.g3soft.fmsapi;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class FmsApiApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,9 @@
|
||||
"fmt:check": "oxfmt --check"
|
||||
},
|
||||
"dependencies": {
|
||||
"@antdv-next/icons": "1.1.1",
|
||||
"@lucide/vue": "^1.24.0",
|
||||
"antdv-next": "^1.4.2",
|
||||
"nprogress": "^0.2.0",
|
||||
"pinia": "^4.0.2",
|
||||
"pinia-plugin-persistedstate": "^4.7.1",
|
||||
"vue": "^3.5.39",
|
||||
|
||||
Generated
+20
-3
@@ -8,12 +8,15 @@ importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@antdv-next/icons':
|
||||
specifier: 1.1.1
|
||||
version: 1.1.1(vue@3.5.39)
|
||||
'@lucide/vue':
|
||||
specifier: ^1.24.0
|
||||
version: 1.24.0(vue@3.5.39)
|
||||
antdv-next:
|
||||
specifier: ^1.4.2
|
||||
version: 1.4.2(vue@3.5.39)
|
||||
nprogress:
|
||||
specifier: ^0.2.0
|
||||
version: 0.2.0
|
||||
pinia:
|
||||
specifier: ^4.0.2
|
||||
version: 4.0.2(@vue/devtools-api@8.1.5)(vue@3.5.39)
|
||||
@@ -171,6 +174,11 @@ packages:
|
||||
'@jridgewell/trace-mapping@0.3.31':
|
||||
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
|
||||
|
||||
'@lucide/vue@1.24.0':
|
||||
resolution: {integrity: sha512-5bNPX0G2YEWdUlBYk7pE8SgDg/f1mkIFpJ9vtE44pW/cwRz7Ioc0tOTESoVJAPvxIELSmYekX+XXIJMjsswNIg==}
|
||||
peerDependencies:
|
||||
vue: '>=3.0.1'
|
||||
|
||||
'@napi-rs/wasm-runtime@1.1.6':
|
||||
resolution: {integrity: sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==}
|
||||
peerDependencies:
|
||||
@@ -1094,6 +1102,9 @@ packages:
|
||||
nostics@1.1.4:
|
||||
resolution: {integrity: sha512-U4FApICSLCQ0dYiN59pxUCEZC053palQXi57yLaNdMaL6TBY4C4q3qZrJKUGcor2dGv8EhEwt8y5KvU2bo2kFg==}
|
||||
|
||||
nprogress@0.2.0:
|
||||
resolution: {integrity: sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA==}
|
||||
|
||||
obug@2.1.3:
|
||||
resolution: {integrity: sha512-9miFgM2OFba7hB+pRgvtV84pYTBaoTHohvmIgiRt6dRIzbwEOIaNaP+dIlGs2fNFoB0SeISs0Jz5WFVRid6Xyg==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
@@ -1481,6 +1492,10 @@ snapshots:
|
||||
'@jridgewell/resolve-uri': 3.1.2
|
||||
'@jridgewell/sourcemap-codec': 1.5.5
|
||||
|
||||
'@lucide/vue@1.24.0(vue@3.5.39)':
|
||||
dependencies:
|
||||
vue: 3.5.39
|
||||
|
||||
'@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)':
|
||||
dependencies:
|
||||
'@emnapi/core': 1.11.1
|
||||
@@ -2291,6 +2306,8 @@ snapshots:
|
||||
|
||||
nostics@1.1.4: {}
|
||||
|
||||
nprogress@0.2.0: {}
|
||||
|
||||
obug@2.1.3: {}
|
||||
|
||||
oxfmt@0.58.0:
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
<script setup>
|
||||
const themeConfig = {
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-app>
|
||||
<div class="theme-root">
|
||||
<router-view />
|
||||
</div>
|
||||
</a-app>
|
||||
<a-config-provider :theme="themeConfig">
|
||||
<a-app>
|
||||
<div class="theme-root">
|
||||
<router-view />
|
||||
</div>
|
||||
</a-app>
|
||||
</a-config-provider>
|
||||
</template>
|
||||
@@ -0,0 +1,134 @@
|
||||
export const mockRecords = [
|
||||
{
|
||||
id: "FY-2026-0001",
|
||||
name: "华东区域运费结算",
|
||||
state: "草稿",
|
||||
customer: "华东客户中心",
|
||||
businessType: "海运",
|
||||
owner: "张三",
|
||||
amount: "4,960.00",
|
||||
currency: "CNY",
|
||||
updated_at: "2026-07-16 09:20",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0002",
|
||||
name: "华南客户月度账单",
|
||||
state: "处理中",
|
||||
customer: "华南供应链有限公司",
|
||||
businessType: "空运",
|
||||
owner: "李四",
|
||||
amount: "6,240.00",
|
||||
currency: "CNY",
|
||||
updated_at: "2026-07-16 08:45",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0003",
|
||||
name: "北方港口代理费用",
|
||||
state: "已完成",
|
||||
customer: "北方港口服务公司",
|
||||
businessType: "陆运",
|
||||
owner: "王五",
|
||||
amount: "7,520.00",
|
||||
currency: "USD",
|
||||
updated_at: "2026-07-15 17:32",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0004",
|
||||
name: "国际空运服务费",
|
||||
state: "处理中",
|
||||
customer: "国际物流有限公司",
|
||||
businessType: "空运",
|
||||
owner: "张三",
|
||||
amount: "8,800.00",
|
||||
currency: "CNY",
|
||||
updated_at: "2026-07-15 16:10",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0005",
|
||||
name: "出口报关服务费用",
|
||||
state: "已完成",
|
||||
customer: "远洋贸易有限公司",
|
||||
businessType: "海运",
|
||||
owner: "李四",
|
||||
amount: "10,080.00",
|
||||
currency: "CNY",
|
||||
updated_at: "2026-07-15 14:56",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0006",
|
||||
name: "华中干线运输费用",
|
||||
state: "草稿",
|
||||
customer: "华中运输服务公司",
|
||||
businessType: "陆运",
|
||||
owner: "王五",
|
||||
amount: "11,360.00",
|
||||
currency: "USD",
|
||||
updated_at: "2026-07-15 11:24",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0007",
|
||||
name: "仓储增值服务结算",
|
||||
state: "已取消",
|
||||
customer: "城市仓储有限公司",
|
||||
businessType: "铁路",
|
||||
owner: "张三",
|
||||
amount: "12,640.00",
|
||||
currency: "CNY",
|
||||
updated_at: "2026-07-14 18:05",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0008",
|
||||
name: "跨境电商物流账单",
|
||||
state: "已完成",
|
||||
customer: "跨境电商有限公司",
|
||||
businessType: "空运",
|
||||
owner: "李四",
|
||||
amount: "13,920.00",
|
||||
currency: "CNY",
|
||||
updated_at: "2026-07-14 15:40",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0009",
|
||||
name: "西南区域配送费用",
|
||||
state: "处理中",
|
||||
customer: "西南配送服务中心",
|
||||
businessType: "陆运",
|
||||
owner: "王五",
|
||||
amount: "15,200.00",
|
||||
currency: "USD",
|
||||
updated_at: "2026-07-14 13:18",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0010",
|
||||
name: "危险品运输服务费",
|
||||
state: "草稿",
|
||||
customer: "特种运输有限公司",
|
||||
businessType: "海运",
|
||||
owner: "张三",
|
||||
amount: "16,480.00",
|
||||
currency: "CNY",
|
||||
updated_at: "2026-07-14 10:02",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0011",
|
||||
name: "铁路联运代理费用",
|
||||
state: "已完成",
|
||||
customer: "铁路联运服务公司",
|
||||
businessType: "铁路",
|
||||
owner: "李四",
|
||||
amount: "17,760.00",
|
||||
currency: "CNY",
|
||||
updated_at: "2026-07-13 16:27",
|
||||
},
|
||||
{
|
||||
id: "FY-2026-0012",
|
||||
name: "客户临时加急费用",
|
||||
state: "已取消",
|
||||
customer: "重点客户服务中心",
|
||||
businessType: "空运",
|
||||
owner: "王五",
|
||||
amount: "19,040.00",
|
||||
currency: "USD",
|
||||
updated_at: "2026-07-13 09:51",
|
||||
},
|
||||
];
|
||||
@@ -1,431 +1,54 @@
|
||||
<script setup>
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import {
|
||||
AppstoreOutlined,
|
||||
BarChartOutlined,
|
||||
BellOutlined,
|
||||
DollarOutlined,
|
||||
DownOutlined,
|
||||
FileTextOutlined,
|
||||
LogoutOutlined,
|
||||
MenuFoldOutlined,
|
||||
MenuUnfoldOutlined,
|
||||
SettingOutlined,
|
||||
TranslationOutlined,
|
||||
UserOutlined,
|
||||
} from "@antdv-next/icons";
|
||||
import { useAppStore } from "../stores/app";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const appStore = useAppStore();
|
||||
const authStore = useAuthStore();
|
||||
const profileOpen = ref(false);
|
||||
const logoutOpen = ref(false);
|
||||
|
||||
const menuItems = [
|
||||
{
|
||||
key: "/dashboard",
|
||||
icon: AppstoreOutlined,
|
||||
label: "工作台",
|
||||
},
|
||||
{
|
||||
key: "business",
|
||||
icon: FileTextOutlined,
|
||||
label: "业务管理",
|
||||
children: [{ key: "/business/orders", label: "业务单据" }],
|
||||
},
|
||||
{
|
||||
key: "fees",
|
||||
icon: DollarOutlined,
|
||||
label: "费用管理",
|
||||
children: [{ key: "/fees/receivable", label: "应收费用" }],
|
||||
},
|
||||
{
|
||||
key: "reports",
|
||||
icon: BarChartOutlined,
|
||||
label: "报表中心",
|
||||
children: [{ key: "/reports/operations", label: "运营报表" }],
|
||||
},
|
||||
{
|
||||
key: "system",
|
||||
icon: SettingOutlined,
|
||||
label: "系统设置",
|
||||
children: [{ key: "/system/users", label: "用户管理" }],
|
||||
},
|
||||
];
|
||||
|
||||
const selectedKeys = computed(() => [route.meta.menuKey || route.path]);
|
||||
const activeTab = computed(() => route.path);
|
||||
const tabItems = computed(() => appStore.visitedTabs);
|
||||
const languageMenu = computed(() => ({
|
||||
items: [
|
||||
{ key: "zh-CN", label: "简体中文" },
|
||||
{ key: "en", label: "English" },
|
||||
],
|
||||
onClick: ({ key }) => appStore.setLocale(key),
|
||||
selectable: true,
|
||||
selectedKeys: [appStore.locale],
|
||||
}));
|
||||
const userMenu = {
|
||||
items: [
|
||||
{ key: "profile", icon: UserOutlined, label: "个人资料" },
|
||||
{ key: "settings", icon: SettingOutlined, label: "账户设置" },
|
||||
{ type: "divider" },
|
||||
{ key: "logout", icon: LogoutOutlined, label: "退出登录", danger: true },
|
||||
],
|
||||
onClick: handleUserMenu,
|
||||
};
|
||||
|
||||
watch(
|
||||
() => appStore.locale,
|
||||
(locale) => document.documentElement.setAttribute("lang", locale),
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
if (!route.meta.title) return;
|
||||
appStore.addVisitedTab({
|
||||
key: route.path,
|
||||
label: route.meta.title,
|
||||
closable: route.path !== "/dashboard",
|
||||
});
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function navigate({ key }) {
|
||||
if (typeof key === "string" && key.startsWith("/")) {
|
||||
router.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
function changeTab(key) {
|
||||
if (key !== route.path) router.push(key);
|
||||
}
|
||||
|
||||
function editTab(targetKey, action) {
|
||||
if (action !== "remove" || typeof targetKey !== "string" || targetKey === "/dashboard") {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentIndex = appStore.visitedTabs.findIndex((item) => item.key === targetKey);
|
||||
const fallback =
|
||||
appStore.visitedTabs[currentIndex - 1] ??
|
||||
appStore.visitedTabs[currentIndex + 1] ??
|
||||
appStore.visitedTabs[0];
|
||||
|
||||
appStore.removeVisitedTab(targetKey);
|
||||
if (route.path === targetKey && fallback) router.push(fallback.key);
|
||||
}
|
||||
|
||||
function handleUserMenu({ key }) {
|
||||
if (key === "profile" || key === "settings") profileOpen.value = true;
|
||||
if (key === "logout") logoutOpen.value = true;
|
||||
}
|
||||
|
||||
function confirmLogout() {
|
||||
authStore.clearSession();
|
||||
logoutOpen.value = false;
|
||||
router.replace("/dashboard");
|
||||
}
|
||||
import AppSidebar from "./components/AppSidebar.vue";
|
||||
import AppTabs from "./components/AppTabs.vue";
|
||||
import AppToolbar from "./components/AppToolbar.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-layout class="app-layout">
|
||||
<a-layout-sider
|
||||
class="app-sider"
|
||||
:collapsed="appStore.sidebarCollapsed"
|
||||
:trigger="null"
|
||||
:collapsed-width="56"
|
||||
collapsible
|
||||
theme="light"
|
||||
width="208"
|
||||
>
|
||||
<div class="brand" :class="{ 'brand--collapsed': appStore.sidebarCollapsed }">
|
||||
<div class="brand__mark">F</div>
|
||||
<div class="brand__copy" :aria-hidden="appStore.sidebarCollapsed">
|
||||
<strong>FMS 管理系统</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sider-menu">
|
||||
<a-menu mode="inline" :items="menuItems" :selected-keys="selectedKeys" @click="navigate" />
|
||||
</div>
|
||||
|
||||
<div class="sider-footer">
|
||||
<a-tooltip :title="appStore.sidebarCollapsed ? '展开侧栏' : '收起侧栏'" placement="top">
|
||||
<a-button
|
||||
type="text"
|
||||
class="sider-collapse"
|
||||
aria-label="切换侧栏宽度"
|
||||
@click="appStore.toggleSidebar"
|
||||
>
|
||||
<template #icon>
|
||||
<MenuUnfoldOutlined v-if="appStore.sidebarCollapsed" />
|
||||
<MenuFoldOutlined v-else />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</a-layout-sider>
|
||||
<AppSidebar />
|
||||
|
||||
<a-layout class="app-main">
|
||||
<header class="tab-header">
|
||||
<a-tabs
|
||||
:active-key="activeTab"
|
||||
:items="tabItems"
|
||||
type="editable-card"
|
||||
size="small"
|
||||
hide-add
|
||||
:animated="false"
|
||||
@change="changeTab"
|
||||
@edit="editTab"
|
||||
>
|
||||
<template #rightExtra>
|
||||
<div class="global-actions">
|
||||
<a-tooltip title="切换语言" placement="bottom">
|
||||
<a-dropdown :menu="languageMenu" :trigger="['click']" placement="bottomRight">
|
||||
<a-button type="text" class="global-action" aria-label="切换语言">
|
||||
<template #icon><TranslationOutlined /></template>
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</a-tooltip>
|
||||
<a-tooltip title="通知提醒" placement="bottom">
|
||||
<a-button type="text" class="global-action" aria-label="通知提醒">
|
||||
<a-badge dot><BellOutlined /></a-badge>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-dropdown :menu="userMenu" :trigger="['click']" placement="bottomRight">
|
||||
<button type="button" class="header-user">
|
||||
<a-avatar :size="24"><UserOutlined /></a-avatar>
|
||||
<span>管理员</span>
|
||||
<DownOutlined class="header-user__arrow" />
|
||||
</button>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</a-tabs>
|
||||
</header>
|
||||
<AppToolbar />
|
||||
<AppTabs />
|
||||
|
||||
<a-layout-content class="app-content">
|
||||
<router-view v-slot="{ Component, route: currentRoute }">
|
||||
<router-view v-slot="{ Component, route }">
|
||||
<transition name="slide" mode="out-in">
|
||||
<component :is="Component" :key="currentRoute.path" />
|
||||
<keep-alive>
|
||||
<component :is="Component" :key="route.fullPath" />
|
||||
</keep-alive>
|
||||
</transition>
|
||||
</router-view>
|
||||
</a-layout-content>
|
||||
</a-layout>
|
||||
</a-layout>
|
||||
|
||||
<a-modal v-model:open="profileOpen" title="个人资料" :footer="null" width="420px">
|
||||
<a-descriptions :column="1" bordered size="small">
|
||||
<a-descriptions-item label="用户名">admin</a-descriptions-item>
|
||||
<a-descriptions-item label="姓名">管理员</a-descriptions-item>
|
||||
<a-descriptions-item label="角色">系统管理员</a-descriptions-item>
|
||||
<a-descriptions-item label="机构码">{{ authStore.orgid || "--" }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</a-modal>
|
||||
|
||||
<a-modal
|
||||
v-model:open="logoutOpen"
|
||||
title="退出登录"
|
||||
ok-text="确认退出"
|
||||
cancel-text="取消"
|
||||
@ok="confirmLogout"
|
||||
>
|
||||
确认退出当前账号吗?
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-layout {
|
||||
min-height: 100vh;
|
||||
background: var(--fms-bg);
|
||||
}
|
||||
|
||||
.app-sider {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
border-right: 1px solid var(--fms-border);
|
||||
|
||||
:deep(.ant-layout-sider-children) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
:deep(.ant-menu) {
|
||||
border-inline-end: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sider-menu {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.sider-footer {
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.sider-collapse {
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
padding-inline: 0;
|
||||
color: var(--fms-text-secondary);
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 48px;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
|
||||
&--collapsed {
|
||||
justify-content: center;
|
||||
padding-inline: 8px;
|
||||
|
||||
.brand__copy {
|
||||
max-width: 0;
|
||||
opacity: 0;
|
||||
transform: translateX(-4px);
|
||||
}
|
||||
}
|
||||
|
||||
&__mark {
|
||||
display: grid;
|
||||
flex: none;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
place-items: center;
|
||||
border-radius: 6px;
|
||||
background: #1677ff;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
&__copy {
|
||||
display: flex;
|
||||
max-width: 140px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
opacity: 1;
|
||||
line-height: 1;
|
||||
transform: translateX(0);
|
||||
transition:
|
||||
max-width 0.18s ease,
|
||||
opacity 0.12s ease,
|
||||
transform 0.18s ease;
|
||||
|
||||
strong {
|
||||
color: var(--fms-text);
|
||||
font-size: 14px;
|
||||
font-weight: 650;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: var(--fms-bg);
|
||||
}
|
||||
|
||||
.app-main {
|
||||
height: 100vh;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: var(--fms-bg);
|
||||
}
|
||||
|
||||
.tab-header {
|
||||
z-index: 15;
|
||||
flex: none;
|
||||
height: 44px;
|
||||
padding: 6px 8px 0;
|
||||
border-bottom: 1px solid var(--fms-border);
|
||||
background: var(--fms-surface);
|
||||
|
||||
:deep(.ant-tabs) {
|
||||
height: 37px;
|
||||
}
|
||||
|
||||
:deep(.ant-tabs-nav) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
:deep(.ant-tabs-content-holder) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.ant-tabs-tab) {
|
||||
min-width: 80px;
|
||||
padding: 5px 10px !important;
|
||||
justify-content: center;
|
||||
border-radius: 3px 3px 0 0 !important;
|
||||
}
|
||||
|
||||
:deep(.ant-tabs-extra-content) {
|
||||
height: 37px;
|
||||
}
|
||||
}
|
||||
|
||||
.global-actions {
|
||||
display: flex;
|
||||
height: 36px;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
.global-action {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding-inline: 0;
|
||||
color: var(--fms-text-secondary);
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.header-user {
|
||||
display: flex;
|
||||
height: 32px;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-left: 12px;
|
||||
padding: 0 8px 0 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
color: var(--fms-text);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover {
|
||||
background: var(--fms-hover);
|
||||
}
|
||||
|
||||
&__arrow {
|
||||
color: var(--fms-text-secondary);
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.app-content {
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.slide-enter-active,
|
||||
|
||||
@@ -0,0 +1,351 @@
|
||||
<script setup>
|
||||
import { computed, h, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import {
|
||||
Bug,
|
||||
ChartColumn,
|
||||
CircleQuestionMark,
|
||||
Database,
|
||||
FolderKanban,
|
||||
House,
|
||||
Landmark,
|
||||
PanelLeftClose,
|
||||
PanelLeftOpen,
|
||||
Settings,
|
||||
Wallet,
|
||||
} from "@lucide/vue";
|
||||
import { useAppStore } from "../../stores/app";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const appStore = useAppStore();
|
||||
const menuIcon = (icon) => () => h(icon, { size: 16, strokeWidth: 1.8 });
|
||||
|
||||
const menuItems = [
|
||||
{
|
||||
key: "/home",
|
||||
icon: menuIcon(House),
|
||||
label: "首页",
|
||||
},
|
||||
{
|
||||
key: "business",
|
||||
icon: menuIcon(FolderKanban),
|
||||
label: "业务管理",
|
||||
children: [
|
||||
{ key: "/business", label: "业务管理" },
|
||||
{ key: "/business/listcontainer", label: "排车列表" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "finance",
|
||||
icon: menuIcon(Wallet),
|
||||
label: "财务管理",
|
||||
children: [
|
||||
{
|
||||
key: "finance-receivable",
|
||||
label: "应收管理",
|
||||
children: [
|
||||
{ key: "/cw/ys/list", label: "应收费用列表" },
|
||||
{ key: "/cw/ys/listbill", label: "应收账单" },
|
||||
{ key: "/cw/ys/listinvoice", label: "应收发票" },
|
||||
{ key: "/cw/ys/listskd", label: "收款管理" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "finance-payable",
|
||||
label: "应付管理",
|
||||
children: [
|
||||
{ key: "/cw/yf/list", label: "应付费用列表" },
|
||||
{ key: "/cw/yf/listbill", label: "应付账单" },
|
||||
{ key: "/cw/yf/listinvoice", label: "应付发票" },
|
||||
{ key: "/cw/yf/listfkd", label: "付款管理" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "finance-daily",
|
||||
label: "日常费用",
|
||||
children: [
|
||||
{ key: "/cw/assistance/daily-expenses", label: "日常费用" },
|
||||
{ key: "/cw/assistance/payment-account", label: "收付账户" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "statistics",
|
||||
icon: menuIcon(ChartColumn),
|
||||
label: "统计分析",
|
||||
children: [
|
||||
{
|
||||
key: "statistics-receivable",
|
||||
label: "收款统计分析",
|
||||
children: [
|
||||
{ key: "/tj/ystj/tj_nots", label: "应收未收明细" },
|
||||
{ key: "/tj/ystj/tj_notsbydw", label: "应收未收按单位汇总" },
|
||||
{ key: "/tj/ystj/tj_notsbysales", label: "未收款按业务员汇总" },
|
||||
{ key: "/tj/ystj/tj_cwskxz", label: "收款明细统计" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "statistics-payable",
|
||||
label: "付款统计分析",
|
||||
children: [
|
||||
{ key: "/tj/yftj/tj_alone_notf", label: "应付未付明细" },
|
||||
{ key: "/tj/yftj/tj_notfbydw", label: "应付未付按单位汇总" },
|
||||
{ key: "/tj/yftj/tj_cwfkxz", label: "付款明细统计" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "statistics-profit",
|
||||
label: "利润统计分析",
|
||||
children: [
|
||||
{ key: "/tj/lrtj/tj_lr_module_id", label: "利润分析单票明细" },
|
||||
{ key: "/tj/lrtj/tj_lrbysales", label: "利润分析按业务员" },
|
||||
{ key: "/tj/lrtj/tj_lrbycustomer", label: "利润分析按客户" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "management",
|
||||
icon: menuIcon(Landmark),
|
||||
label: "管理中心",
|
||||
children: [
|
||||
{ key: "/shcenter", label: "审批中心" },
|
||||
{ key: "/partners/khht", label: "合同管理" },
|
||||
{ key: "/pricelist/list", label: "运费模版" },
|
||||
{ key: "/system/oa-management/companyAnnouncement", label: "企业公告" },
|
||||
{ key: "/system/approvalSettings", label: "审批设置" },
|
||||
{ key: "/system/oa-management/userReminder", label: "提醒设置" },
|
||||
{ key: "/partners/hl", label: "结算汇率" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "base-data",
|
||||
icon: menuIcon(Database),
|
||||
label: "基础数据",
|
||||
children: [
|
||||
{ key: "/partners", label: "合作伙伴" },
|
||||
{ key: "/partners/contact", label: "联系人" },
|
||||
{ key: "/base/other", label: "其他数据" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "system",
|
||||
icon: menuIcon(Settings),
|
||||
label: "系统管理",
|
||||
children: [
|
||||
{ key: "/system/permission", label: "权限管理" },
|
||||
{ key: "/system/field", label: "字段配置" },
|
||||
{ key: "/system/statisticalSettings", label: "查询设置" },
|
||||
{ key: "/system/mappingConfig", label: "映射配置" },
|
||||
{ key: "/system/moduleSettings", label: "模块设置" },
|
||||
{ key: "/system/autoId", label: "自动编码" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "help",
|
||||
icon: menuIcon(CircleQuestionMark),
|
||||
label: "系统帮助",
|
||||
children: [
|
||||
{ key: "/help", label: "帮助文档" },
|
||||
{ key: "/videos", label: "操作视频" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "test",
|
||||
icon: menuIcon(Bug),
|
||||
label: "功能测试",
|
||||
children: [{ key: "/test/test", label: "测试页面" }],
|
||||
},
|
||||
];
|
||||
|
||||
const selectedKeys = computed(() => [route.meta.menuKey || route.path]);
|
||||
const openKeys = ref([]);
|
||||
const parentKeyByRoute = new Map(
|
||||
menuItems.flatMap((item) =>
|
||||
item.children?.map((child) => [child.key, item.key]) ?? [],
|
||||
),
|
||||
);
|
||||
|
||||
watch(
|
||||
() => route.meta.menuKey || route.path,
|
||||
(menuKey) => {
|
||||
const parentKey = parentKeyByRoute.get(menuKey);
|
||||
if (parentKey && !openKeys.value.includes(parentKey)) {
|
||||
openKeys.value = [...openKeys.value, parentKey];
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function navigate({ key }) {
|
||||
if (typeof key === "string" && key.startsWith("/")) {
|
||||
router.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
function updateOpenKeys(keys) {
|
||||
openKeys.value = keys;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-layout-sider
|
||||
class="app-sider"
|
||||
:collapsed="appStore.sidebarCollapsed"
|
||||
:trigger="null"
|
||||
:collapsed-width="56"
|
||||
collapsible
|
||||
theme="light"
|
||||
width="208"
|
||||
>
|
||||
<div class="brand" :class="{ 'brand--collapsed': appStore.sidebarCollapsed }">
|
||||
<div class="brand__mark">F</div>
|
||||
<div class="brand__copy" :aria-hidden="appStore.sidebarCollapsed">
|
||||
<strong>FMS 管理系统</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sider-menu">
|
||||
<a-menu
|
||||
mode="inline"
|
||||
:items="menuItems"
|
||||
:selected-keys="selectedKeys"
|
||||
:open-keys="openKeys"
|
||||
@click="navigate"
|
||||
@open-change="updateOpenKeys"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="sider-footer">
|
||||
<a-tooltip :title="appStore.sidebarCollapsed ? '展开侧栏' : '收起侧栏'" placement="right">
|
||||
<a-button
|
||||
type="text"
|
||||
class="sider-collapse"
|
||||
aria-label="切换侧栏宽度"
|
||||
@click="appStore.toggleSidebar"
|
||||
>
|
||||
<template #icon>
|
||||
<PanelLeftOpen v-if="appStore.sidebarCollapsed" />
|
||||
<PanelLeftClose v-else />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</a-layout-sider>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-sider {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
border-right: 1px solid var(--fms-border);
|
||||
|
||||
:deep(.ant-layout-sider-children) {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
:deep(.ant-menu) {
|
||||
border-inline-end: 0;
|
||||
}
|
||||
|
||||
:deep(.ant-menu-item),
|
||||
:deep(.ant-menu-submenu-title) {
|
||||
width: 100%;
|
||||
height: 36px;
|
||||
margin: 0;
|
||||
border-radius: 0;
|
||||
line-height: 36px;
|
||||
}
|
||||
|
||||
:deep(.ant-menu-root > .ant-menu-item),
|
||||
:deep(.ant-menu-root > .ant-menu-submenu > .ant-menu-submenu-title) {
|
||||
padding-inline-start: 20px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.sider-menu {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.sider-footer {
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
padding: 4px;
|
||||
border-top: 1px solid var(--fms-border);
|
||||
}
|
||||
|
||||
.sider-collapse {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
padding-inline: 0;
|
||||
border-radius: 4px;
|
||||
color: var(--fms-text-secondary);
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 44px;
|
||||
gap: 8px;
|
||||
padding: 6px 12px 6px 15px;
|
||||
|
||||
&--collapsed {
|
||||
justify-content: flex-start;
|
||||
gap: 0;
|
||||
padding-inline: 15px;
|
||||
|
||||
.brand__copy {
|
||||
max-width: 0;
|
||||
opacity: 0;
|
||||
transform: translateX(-4px);
|
||||
}
|
||||
}
|
||||
|
||||
&__mark {
|
||||
display: grid;
|
||||
flex: none;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
place-items: center;
|
||||
border-radius: 6px;
|
||||
background: #1677ff;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
&__copy {
|
||||
display: flex;
|
||||
max-width: 140px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
opacity: 1;
|
||||
line-height: 1;
|
||||
transform: translateX(0);
|
||||
transition:
|
||||
max-width 0.18s ease,
|
||||
opacity 0.12s ease,
|
||||
transform 0.18s ease;
|
||||
|
||||
strong {
|
||||
color: var(--fms-text);
|
||||
font-size: 14px;
|
||||
font-weight: 650;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,322 @@
|
||||
<script setup>
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ChevronLeft, ChevronRight, X } from "@lucide/vue";
|
||||
import { theme } from "antdv-next";
|
||||
import { useAppStore } from "../../stores/app";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const appStore = useAppStore();
|
||||
const { token } = theme.useToken();
|
||||
const headerRef = ref(null);
|
||||
const trackRef = ref(null);
|
||||
const overflowed = ref(false);
|
||||
const canScrollLeft = ref(false);
|
||||
const canScrollRight = ref(false);
|
||||
const activeTab = computed(() => route.fullPath);
|
||||
const tabItems = computed(() => appStore.visitedTabs);
|
||||
let resizeObserver;
|
||||
|
||||
watch(
|
||||
() => route.fullPath,
|
||||
async () => {
|
||||
if (route.meta.title) {
|
||||
appStore.addVisitedTab({
|
||||
key: route.fullPath,
|
||||
label: getTabLabel(),
|
||||
closable: route.fullPath !== "/dashboard",
|
||||
});
|
||||
}
|
||||
|
||||
await nextTick();
|
||||
revealActiveTab();
|
||||
updateScrollState();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => appStore.visitedTabs.length,
|
||||
async () => {
|
||||
await nextTick();
|
||||
updateScrollState();
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
resizeObserver = new ResizeObserver(updateScrollState);
|
||||
if (headerRef.value) resizeObserver.observe(headerRef.value);
|
||||
updateScrollState();
|
||||
revealActiveTab("auto");
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => resizeObserver?.disconnect());
|
||||
|
||||
function changeTab(key) {
|
||||
if (key !== route.fullPath) router.push(key);
|
||||
}
|
||||
|
||||
function getTabLabel() {
|
||||
if (route.meta.detail && route.params.id) {
|
||||
return `${route.meta.listTitle || route.meta.title} ${route.params.id}`;
|
||||
}
|
||||
|
||||
return route.meta.title;
|
||||
}
|
||||
|
||||
function closeTab(targetKey) {
|
||||
if (typeof targetKey !== "string" || targetKey === "/dashboard") return;
|
||||
|
||||
const currentIndex = appStore.visitedTabs.findIndex((item) => item.key === targetKey);
|
||||
const fallback =
|
||||
appStore.visitedTabs[currentIndex - 1] ??
|
||||
appStore.visitedTabs[currentIndex + 1] ??
|
||||
appStore.visitedTabs[0];
|
||||
|
||||
appStore.removeVisitedTab(targetKey);
|
||||
if (route.fullPath === targetKey && fallback) router.push(fallback.key);
|
||||
}
|
||||
|
||||
function updateScrollState() {
|
||||
const header = headerRef.value;
|
||||
const track = trackRef.value;
|
||||
if (!header || !track) return;
|
||||
|
||||
const shouldOverflow = track.scrollWidth > header.clientWidth - 16 + 1;
|
||||
if (overflowed.value !== shouldOverflow) {
|
||||
overflowed.value = shouldOverflow;
|
||||
if (!shouldOverflow) track.scrollLeft = 0;
|
||||
nextTick(updateScrollState);
|
||||
return;
|
||||
}
|
||||
|
||||
canScrollLeft.value = shouldOverflow && track.scrollLeft > 1;
|
||||
canScrollRight.value =
|
||||
shouldOverflow && track.scrollLeft + track.clientWidth < track.scrollWidth - 1;
|
||||
}
|
||||
|
||||
function scrollTabs(direction) {
|
||||
const track = trackRef.value;
|
||||
if (!track) return;
|
||||
|
||||
track.scrollBy({
|
||||
left: direction * Math.max(track.clientWidth * 0.65, 120),
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
|
||||
function revealActiveTab(behavior = "smooth") {
|
||||
const track = trackRef.value;
|
||||
if (!track) return;
|
||||
|
||||
const activeElement = Array.from(track.querySelectorAll("[data-tab-key]")).find(
|
||||
(element) => element.dataset.tabKey === activeTab.value,
|
||||
);
|
||||
activeElement?.scrollIntoView({ behavior, block: "nearest", inline: "center" });
|
||||
}
|
||||
|
||||
function focusAdjacentTab(index, offset) {
|
||||
const items = tabItems.value;
|
||||
if (!items.length) return;
|
||||
|
||||
const nextIndex = (index + offset + items.length) % items.length;
|
||||
changeTab(items[nextIndex].key);
|
||||
nextTick(() => {
|
||||
const target = Array.from(trackRef.value?.querySelectorAll("[data-tab-key]") ?? []).find(
|
||||
(element) => element.dataset.tabKey === items[nextIndex].key,
|
||||
);
|
||||
target?.focus();
|
||||
});
|
||||
}
|
||||
|
||||
function handleTabKeydown(event, index) {
|
||||
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
||||
|
||||
event.preventDefault();
|
||||
focusAdjacentTab(index, event.key === "ArrowLeft" ? -1 : 1);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header
|
||||
ref="headerRef"
|
||||
class="tab-header"
|
||||
:style="{
|
||||
'--tabs-active-bg': token.colorPrimaryBg,
|
||||
'--tabs-active-color': token.colorPrimary,
|
||||
'--tabs-idle-bg': token.colorFillQuaternary,
|
||||
}"
|
||||
>
|
||||
<button
|
||||
v-if="overflowed"
|
||||
type="button"
|
||||
class="tab-nav-button"
|
||||
aria-label="向左滚动页签"
|
||||
:disabled="!canScrollLeft"
|
||||
@click="scrollTabs(-1)"
|
||||
>
|
||||
<ChevronLeft />
|
||||
</button>
|
||||
|
||||
<div ref="trackRef" class="tab-track" role="tablist" @scroll.passive="updateScrollState">
|
||||
<div
|
||||
v-for="(item, index) in tabItems"
|
||||
:key="item.key"
|
||||
class="tab-item"
|
||||
:class="{ 'tab-item--active': item.key === activeTab }"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="tab-item__select"
|
||||
role="tab"
|
||||
:data-tab-key="item.key"
|
||||
:aria-selected="item.key === activeTab"
|
||||
:tabindex="item.key === activeTab ? 0 : -1"
|
||||
@click="changeTab(item.key)"
|
||||
@keydown="handleTabKeydown($event, index)"
|
||||
>
|
||||
<span>{{ item.label }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="item.closable"
|
||||
type="button"
|
||||
class="tab-item__close"
|
||||
:aria-label="`关闭${item.label}`"
|
||||
@click.stop="closeTab(item.key)"
|
||||
>
|
||||
<X />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="overflowed"
|
||||
type="button"
|
||||
class="tab-nav-button"
|
||||
aria-label="向右滚动页签"
|
||||
:disabled="!canScrollRight"
|
||||
@click="scrollTabs(1)"
|
||||
>
|
||||
<ChevronRight />
|
||||
</button>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tab-header {
|
||||
z-index: 15;
|
||||
display: flex;
|
||||
flex: none;
|
||||
height: 34px;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 3px 8px;
|
||||
background: var(--fms-surface);
|
||||
}
|
||||
|
||||
.tab-track {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
gap: 6px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
overscroll-behavior-inline: contain;
|
||||
scrollbar-width: none;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
display: flex;
|
||||
flex: none;
|
||||
min-width: 64px;
|
||||
height: 28px;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
background: var(--tabs-idle-bg);
|
||||
color: var(--fms-text-secondary);
|
||||
|
||||
&:hover {
|
||||
color: var(--tabs-active-color);
|
||||
}
|
||||
|
||||
&--active {
|
||||
background: var(--tabs-active-bg);
|
||||
color: var(--tabs-active-color);
|
||||
}
|
||||
|
||||
&__select,
|
||||
&__close {
|
||||
height: 100%;
|
||||
border: 0;
|
||||
color: inherit;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&__select {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 7px;
|
||||
font-size: 12px;
|
||||
|
||||
span {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
&__close {
|
||||
display: grid;
|
||||
width: 18px;
|
||||
flex: none;
|
||||
padding: 0;
|
||||
place-items: center;
|
||||
|
||||
&:hover {
|
||||
background: rgb(0 0 0 / 6%);
|
||||
}
|
||||
|
||||
.lucide {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-nav-button {
|
||||
display: grid;
|
||||
flex: none;
|
||||
width: 26px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
place-items: center;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
color: var(--fms-text-secondary);
|
||||
background: var(--tabs-idle-bg);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
color: var(--tabs-active-color);
|
||||
background: var(--tabs-active-bg);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: default;
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
.lucide {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,179 @@
|
||||
<script setup>
|
||||
import { computed, h, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { Bell, ChevronDown, Languages, LogOut, Settings, UserRound } from "@lucide/vue";
|
||||
import { useAppStore } from "../../stores/app";
|
||||
import { useAuthStore } from "../../stores/auth";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const appStore = useAppStore();
|
||||
const authStore = useAuthStore();
|
||||
const profileOpen = ref(false);
|
||||
const logoutOpen = ref(false);
|
||||
const menuIcon = (icon) => () => h(icon, { size: 16, strokeWidth: 1.8 });
|
||||
|
||||
const breadcrumbItems = computed(() => {
|
||||
const items = [];
|
||||
|
||||
if (route.path === "/dashboard") return [{ label: "工作台" }];
|
||||
if (route.meta.section) items.push({ label: route.meta.section });
|
||||
if (route.meta.title) items.push({ label: route.meta.title });
|
||||
|
||||
return items;
|
||||
});
|
||||
|
||||
const languageMenu = computed(() => ({
|
||||
items: [
|
||||
{ key: "zh-CN", label: "简体中文" },
|
||||
{ key: "en", label: "English" },
|
||||
],
|
||||
onClick: ({ key }) => appStore.setLocale(key),
|
||||
selectable: true,
|
||||
selectedKeys: [appStore.locale],
|
||||
}));
|
||||
|
||||
const userMenu = {
|
||||
items: [
|
||||
{ key: "profile", icon: menuIcon(UserRound), label: "个人资料" },
|
||||
{ key: "settings", icon: menuIcon(Settings), label: "账户设置" },
|
||||
{ type: "divider" },
|
||||
{ key: "logout", icon: menuIcon(LogOut), label: "退出登录", danger: true },
|
||||
],
|
||||
onClick: handleUserMenu,
|
||||
};
|
||||
|
||||
watch(
|
||||
() => appStore.locale,
|
||||
(locale) => document.documentElement.setAttribute("lang", locale),
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function handleUserMenu({ key }) {
|
||||
if (key === "profile" || key === "settings") profileOpen.value = true;
|
||||
if (key === "logout") logoutOpen.value = true;
|
||||
}
|
||||
|
||||
function confirmLogout() {
|
||||
authStore.clearSession();
|
||||
logoutOpen.value = false;
|
||||
router.replace("/dashboard");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="top-toolbar">
|
||||
<a-breadcrumb class="toolbar-breadcrumb" separator=">">
|
||||
<a-breadcrumb-item v-for="item in breadcrumbItems" :key="item.label">
|
||||
{{ item.label }}
|
||||
</a-breadcrumb-item>
|
||||
</a-breadcrumb>
|
||||
|
||||
<div class="toolbar-actions">
|
||||
<a-tooltip title="切换语言" placement="bottom">
|
||||
<a-dropdown :menu="languageMenu" :trigger="['click']" placement="bottomRight">
|
||||
<a-button type="text" class="toolbar-action" aria-label="切换语言">
|
||||
<template #icon><Languages /></template>
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</a-tooltip>
|
||||
<a-tooltip title="通知提醒" placement="bottom">
|
||||
<a-button type="text" class="toolbar-action" aria-label="通知提醒">
|
||||
<a-badge dot><Bell /></a-badge>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-dropdown :menu="userMenu" :trigger="['click']" placement="bottomRight">
|
||||
<button type="button" class="toolbar-user" aria-label="用户菜单">
|
||||
<a-avatar :size="24"><UserRound /></a-avatar>
|
||||
<span>管理员</span>
|
||||
<ChevronDown class="toolbar-user__arrow" />
|
||||
</button>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<a-modal v-model:open="profileOpen" title="个人资料" :footer="null" width="420px">
|
||||
<a-descriptions :column="1" bordered size="small">
|
||||
<a-descriptions-item label="用户名">admin</a-descriptions-item>
|
||||
<a-descriptions-item label="姓名">管理员</a-descriptions-item>
|
||||
<a-descriptions-item label="角色">系统管理员</a-descriptions-item>
|
||||
<a-descriptions-item label="机构码">{{ authStore.orgid || "--" }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</a-modal>
|
||||
|
||||
<a-modal
|
||||
v-model:open="logoutOpen"
|
||||
title="退出登录"
|
||||
ok-text="确认退出"
|
||||
cancel-text="取消"
|
||||
@ok="confirmLogout"
|
||||
>
|
||||
确认退出当前账号吗?
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.top-toolbar {
|
||||
z-index: 16;
|
||||
display: flex;
|
||||
flex: none;
|
||||
height: 44px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 0 8px 0 12px;
|
||||
border-bottom: 1px solid var(--fms-border);
|
||||
background: var(--fms-surface);
|
||||
}
|
||||
|
||||
.toolbar-breadcrumb {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.toolbar-actions {
|
||||
display: flex;
|
||||
flex: none;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.toolbar-action {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding-inline: 0;
|
||||
border-radius: 4px;
|
||||
color: var(--fms-text-secondary);
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.toolbar-user {
|
||||
display: flex;
|
||||
height: 32px;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-left: 4px;
|
||||
padding: 0 6px 0 4px;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
color: var(--fms-text);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
|
||||
&:hover {
|
||||
background: var(--fms-hover);
|
||||
}
|
||||
|
||||
&__arrow {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
color: var(--fms-text-secondary);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,8 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import NProgress from "nprogress";
|
||||
import "nprogress/nprogress.css";
|
||||
|
||||
NProgress.configure({ showSpinner: false });
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@@ -26,6 +30,19 @@ const routes = [
|
||||
source: "v_bs_business",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "business/orders/:id",
|
||||
name: "business-order-detail",
|
||||
component: () => import("../views/DetailView.vue"),
|
||||
meta: {
|
||||
title: "业务单据详情",
|
||||
listTitle: "业务单据",
|
||||
section: "业务管理",
|
||||
menuKey: "/business/orders",
|
||||
listPath: "/business/orders",
|
||||
detail: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "fees/receivable",
|
||||
name: "fees-receivable",
|
||||
@@ -37,6 +54,19 @@ const routes = [
|
||||
source: "v_fee_receivable",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "fees/receivable/:id",
|
||||
name: "fees-receivable-detail",
|
||||
component: () => import("../views/DetailView.vue"),
|
||||
meta: {
|
||||
title: "应收费用详情",
|
||||
listTitle: "应收费用",
|
||||
section: "费用管理",
|
||||
menuKey: "/fees/receivable",
|
||||
listPath: "/fees/receivable",
|
||||
detail: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "reports/operations",
|
||||
name: "reports-operations",
|
||||
@@ -48,6 +78,19 @@ const routes = [
|
||||
source: "v_report_operations",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "reports/operations/:id",
|
||||
name: "reports-operations-detail",
|
||||
component: () => import("../views/DetailView.vue"),
|
||||
meta: {
|
||||
title: "运营报表详情",
|
||||
listTitle: "运营报表",
|
||||
section: "报表中心",
|
||||
menuKey: "/reports/operations",
|
||||
listPath: "/reports/operations",
|
||||
detail: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "system/users",
|
||||
name: "system-users",
|
||||
@@ -59,6 +102,19 @@ const routes = [
|
||||
source: "sys_user",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "system/users/:id",
|
||||
name: "system-users-detail",
|
||||
component: () => import("../views/DetailView.vue"),
|
||||
meta: {
|
||||
title: "用户管理详情",
|
||||
listTitle: "用户管理",
|
||||
section: "系统设置",
|
||||
menuKey: "/system/users",
|
||||
listPath: "/system/users",
|
||||
detail: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -74,9 +130,18 @@ const router = createRouter({
|
||||
});
|
||||
|
||||
router.beforeEach((to) => {
|
||||
NProgress.start();
|
||||
document.title = to.meta.title ? `${to.meta.title} - FMS 管理系统` : "FMS 管理系统";
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done();
|
||||
});
|
||||
|
||||
router.onError(() => {
|
||||
NProgress.done();
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -1,10 +1,12 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
const createDefaultVisitedTabs = () => [{ key: "/dashboard", label: "工作台", closable: false }];
|
||||
|
||||
export const useAppStore = defineStore("app", {
|
||||
state: () => ({
|
||||
locale: "zh-CN",
|
||||
sidebarCollapsed: false,
|
||||
visitedTabs: [{ key: "/dashboard", label: "工作台", closable: false }],
|
||||
visitedTabs: createDefaultVisitedTabs(),
|
||||
}),
|
||||
actions: {
|
||||
toggleSidebar() {
|
||||
@@ -24,6 +26,10 @@ export const useAppStore = defineStore("app", {
|
||||
},
|
||||
persist: {
|
||||
key: "fms-app",
|
||||
pick: ["locale", "sidebarCollapsed", "visitedTabs"],
|
||||
pick: ["locale"],
|
||||
afterHydrate: ({ store }) => {
|
||||
store.sidebarCollapsed = false;
|
||||
store.visitedTabs = createDefaultVisitedTabs();
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -16,12 +16,15 @@ body,
|
||||
#app,
|
||||
.ant-app,
|
||||
.theme-root {
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
min-width: 1200px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
button,
|
||||
@@ -35,6 +38,14 @@ a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.lucide {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex: none;
|
||||
stroke-width: 1.8;
|
||||
vertical-align: -0.125em;
|
||||
}
|
||||
|
||||
.theme-root {
|
||||
--fms-bg: #f5f7fa;
|
||||
--fms-surface: #ffffff;
|
||||
@@ -46,6 +57,7 @@ a {
|
||||
|
||||
color: var(--fms-text);
|
||||
background: var(--fms-bg);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
<script setup>
|
||||
import {
|
||||
CheckCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
DollarOutlined,
|
||||
FileTextOutlined,
|
||||
PlusOutlined,
|
||||
} from "@antdv-next/icons";
|
||||
import { CircleCheck, Clock3, DollarSign, FileText, Plus } from "@lucide/vue";
|
||||
|
||||
const metrics = [
|
||||
{ label: "今日新增", value: "0", tone: "blue", icon: FileTextOutlined },
|
||||
{ label: "待处理", value: "0", tone: "amber", icon: ClockCircleOutlined },
|
||||
{ label: "本月应收", value: "¥ 0.00", tone: "green", icon: DollarOutlined },
|
||||
{ label: "本月完成", value: "0", tone: "gray", icon: CheckCircleOutlined },
|
||||
{ label: "今日新增", value: "0", tone: "blue", icon: FileText },
|
||||
{ label: "待处理", value: "0", tone: "amber", icon: Clock3 },
|
||||
{ label: "本月应收", value: "¥ 0.00", tone: "green", icon: DollarSign },
|
||||
{ label: "本月完成", value: "0", tone: "gray", icon: CircleCheck },
|
||||
];
|
||||
|
||||
const columns = [
|
||||
@@ -44,7 +38,7 @@ const columns = [
|
||||
<span>最近更新</span>
|
||||
</div>
|
||||
<a-button type="primary">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
<template #icon><Plus /></template>
|
||||
新建业务
|
||||
</a-button>
|
||||
</div>
|
||||
@@ -52,7 +46,7 @@ const columns = [
|
||||
:columns="columns"
|
||||
:data-source="[]"
|
||||
:pagination="false"
|
||||
size="middle"
|
||||
size="small"
|
||||
:scroll="{ x: 620 }"
|
||||
/>
|
||||
</div>
|
||||
@@ -66,15 +60,15 @@ const columns = [
|
||||
</div>
|
||||
<nav class="quick-links">
|
||||
<router-link to="/business/orders">
|
||||
<FileTextOutlined />
|
||||
<FileText />
|
||||
<span>业务单据</span>
|
||||
</router-link>
|
||||
<router-link to="/fees/receivable">
|
||||
<DollarOutlined />
|
||||
<DollarSign />
|
||||
<span>应收费用</span>
|
||||
</router-link>
|
||||
<router-link to="/reports/operations">
|
||||
<CheckCircleOutlined />
|
||||
<CircleCheck />
|
||||
<span>运营报表</span>
|
||||
</router-link>
|
||||
</nav>
|
||||
@@ -86,13 +80,13 @@ const columns = [
|
||||
<style lang="scss" scoped>
|
||||
.dashboard {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.metric-card {
|
||||
@@ -100,7 +94,7 @@ const columns = [
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 12px;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--fms-border);
|
||||
border-radius: 4px;
|
||||
background: var(--fms-surface);
|
||||
@@ -135,6 +129,11 @@ const columns = [
|
||||
border-radius: 4px;
|
||||
font-size: 17px;
|
||||
|
||||
:deep(.lucide) {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
&--blue {
|
||||
background: #e6f4ff;
|
||||
color: #1677ff;
|
||||
@@ -160,7 +159,7 @@ const columns = [
|
||||
.dashboard-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
@@ -171,11 +170,11 @@ const columns = [
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
min-height: 46px;
|
||||
min-height: 42px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 7px 10px;
|
||||
padding: 5px 8px;
|
||||
border-bottom: 1px solid var(--fms-border);
|
||||
|
||||
h2 {
|
||||
|
||||
@@ -1,140 +1,493 @@
|
||||
<script setup>
|
||||
import { computed, reactive, ref, watch } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { PlusOutlined, ReloadOutlined, SearchOutlined } from "@antdv-next/icons";
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { Ellipsis, ListFilter, Plus, Search } from "@lucide/vue";
|
||||
import { mockRecords } from "../data/mockRecords";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const loading = ref(false);
|
||||
const rows = ref([]);
|
||||
const total = ref(0);
|
||||
const filters = reactive({ keyword: "" });
|
||||
const filters = reactive({ field: "name", keyword: "" });
|
||||
const pagination = reactive({ current: 1, pageSize: 20 });
|
||||
const title = computed(() => route.meta.title);
|
||||
const tableAreaRef = ref(null);
|
||||
const tableScrollY = ref(240);
|
||||
const advancedOpen = ref(false);
|
||||
const appliedFilterCount = ref(0);
|
||||
let resizeObserver;
|
||||
|
||||
const columns = computed(() => [
|
||||
{ title: "编号", dataIndex: "id", key: "id", width: 180 },
|
||||
{ title: "名称", dataIndex: "name", key: "name" },
|
||||
{ title: "状态", dataIndex: "state", key: "state", width: 120 },
|
||||
{ title: "更新时间", dataIndex: "updated_at", key: "updated_at", width: 180 },
|
||||
]);
|
||||
const columns = [
|
||||
{ title: "编号", dataIndex: "id", key: "id", width: 160 },
|
||||
{ title: "名称", dataIndex: "name", key: "name", width: 240 },
|
||||
{ title: "状态", dataIndex: "state", key: "state", width: 100 },
|
||||
{ title: "更新时间", dataIndex: "updated_at", key: "updated_at", width: 160 },
|
||||
];
|
||||
const fieldOptions = [
|
||||
{ label: "名称", value: "name" },
|
||||
{ label: "编号", value: "id" },
|
||||
{ label: "状态", value: "state" },
|
||||
];
|
||||
const businessTypeOptions = ["海运", "空运", "陆运", "铁路"].map((value) => ({
|
||||
label: value,
|
||||
value,
|
||||
}));
|
||||
const statusOptions = ["草稿", "处理中", "已完成", "已取消"].map((value) => ({
|
||||
label: value,
|
||||
value,
|
||||
}));
|
||||
const ownerOptions = ["张三", "李四", "王五"].map((value) => ({ label: value, value }));
|
||||
const departmentOptions = ["销售部", "操作部", "财务部"].map((value) => ({
|
||||
label: value,
|
||||
value,
|
||||
}));
|
||||
const settlementOptions = ["未结算", "部分结算", "已结算"].map((value) => ({
|
||||
label: value,
|
||||
value,
|
||||
}));
|
||||
const currencyOptions = ["CNY", "USD", "EUR"].map((value) => ({ label: value, value }));
|
||||
const advancedFilters = reactive(createEmptyAdvancedFilters());
|
||||
const draftFilterCount = computed(
|
||||
() => Object.values(advancedFilters).filter(isFilterValueFilled).length,
|
||||
);
|
||||
|
||||
function createEmptyAdvancedFilters() {
|
||||
return {
|
||||
documentNo: "",
|
||||
customerName: "",
|
||||
businessType: undefined,
|
||||
status: undefined,
|
||||
businessDate: [],
|
||||
owner: undefined,
|
||||
department: undefined,
|
||||
settlementStatus: undefined,
|
||||
currency: undefined,
|
||||
amountMin: null,
|
||||
amountMax: null,
|
||||
creator: "",
|
||||
createdDate: [],
|
||||
remark: "",
|
||||
};
|
||||
}
|
||||
|
||||
function isFilterValueFilled(value) {
|
||||
if (Array.isArray(value)) return value.some(isFilterValueFilled);
|
||||
return value !== undefined && value !== null && value !== "";
|
||||
}
|
||||
function loadData() {
|
||||
loading.value = true;
|
||||
rows.value = [];
|
||||
total.value = 0;
|
||||
const keyword = filters.keyword.trim().toLowerCase();
|
||||
const filteredRows = keyword
|
||||
? mockRecords.filter((row) =>
|
||||
String(row[filters.field] ?? "")
|
||||
.toLowerCase()
|
||||
.includes(keyword),
|
||||
)
|
||||
: mockRecords;
|
||||
const start = (pagination.current - 1) * pagination.pageSize;
|
||||
rows.value = filteredRows.slice(start, start + pagination.pageSize);
|
||||
total.value = filteredRows.length;
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
filters.keyword = "";
|
||||
pagination.current = 1;
|
||||
function openDetail(record) {
|
||||
router.push(`${route.path}/${encodeURIComponent(record.id)}`);
|
||||
}
|
||||
|
||||
function changePage(page, pageSize) {
|
||||
pagination.current = page;
|
||||
pagination.pageSize = pageSize;
|
||||
loadData();
|
||||
}
|
||||
|
||||
function resetAdvancedFilters() {
|
||||
Object.assign(advancedFilters, createEmptyAdvancedFilters());
|
||||
}
|
||||
|
||||
function applyAdvancedFilters() {
|
||||
pagination.current = 1;
|
||||
appliedFilterCount.value = draftFilterCount.value;
|
||||
advancedOpen.value = false;
|
||||
loadData();
|
||||
}
|
||||
|
||||
function updateTableHeight() {
|
||||
const tableArea = tableAreaRef.value;
|
||||
if (!tableArea) return;
|
||||
|
||||
const headerHeight =
|
||||
tableArea.querySelector(".ant-table-thead")?.getBoundingClientRect().height ?? 39;
|
||||
tableScrollY.value = Math.max(Math.floor(tableArea.clientHeight - headerHeight), 80);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
resizeObserver = new ResizeObserver(updateTableHeight);
|
||||
if (tableAreaRef.value) resizeObserver.observe(tableAreaRef.value);
|
||||
nextTick(updateTableHeight);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => resizeObserver?.disconnect());
|
||||
|
||||
watch(() => route.meta.source, loadData, { immediate: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="data-page">
|
||||
<section class="data-toolbar">
|
||||
<div class="data-toolbar__title">
|
||||
<h1>{{ title }}</h1>
|
||||
<span>共 {{ total }} 条</span>
|
||||
</div>
|
||||
<a-button type="primary">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
<section class="filter-bar" aria-label="查询条件">
|
||||
<a-button type="primary" class="toolbar-button">
|
||||
<template #icon><Plus /></template>
|
||||
新增
|
||||
</a-button>
|
||||
</section>
|
||||
|
||||
<section class="filter-bar">
|
||||
<a-input
|
||||
v-model:value="filters.keyword"
|
||||
class="keyword-input"
|
||||
placeholder="输入名称查询"
|
||||
allow-clear
|
||||
@press-enter="loadData"
|
||||
>
|
||||
<template #prefix><SearchOutlined /></template>
|
||||
</a-input>
|
||||
<a-button type="primary" @click="loadData">查询</a-button>
|
||||
<a-button @click="reset">
|
||||
<template #icon><ReloadOutlined /></template>
|
||||
重置
|
||||
</a-button>
|
||||
<div class="filter-fields">
|
||||
<a-space-compact class="search-compact">
|
||||
<a-select
|
||||
v-model:value="filters.field"
|
||||
class="keyword-select"
|
||||
:options="fieldOptions"
|
||||
aria-label="查询字段"
|
||||
/>
|
||||
<a-input-search
|
||||
id="data-keyword"
|
||||
v-model:value="filters.keyword"
|
||||
class="keyword-search"
|
||||
allow-clear
|
||||
enter-button="搜索"
|
||||
@search="loadData"
|
||||
/>
|
||||
</a-space-compact>
|
||||
|
||||
<a-tooltip title="高级查询" placement="bottom">
|
||||
<a-badge :count="appliedFilterCount" size="small">
|
||||
<a-button
|
||||
shape="circle"
|
||||
class="round-action"
|
||||
aria-label="高级查询"
|
||||
@click="advancedOpen = true"
|
||||
>
|
||||
<template #icon><ListFilter /></template>
|
||||
</a-button>
|
||||
</a-badge>
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip title="更多" placement="bottom">
|
||||
<a-button shape="circle" class="round-action" aria-label="更多">
|
||||
<template #icon><Ellipsis /></template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="table-panel">
|
||||
<a-table
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:data-source="rows"
|
||||
:loading="loading"
|
||||
:pagination="{
|
||||
current: pagination.current,
|
||||
pageSize: pagination.pageSize,
|
||||
total,
|
||||
showSizeChanger: true,
|
||||
showTotal: (value) => `共 ${value} 条`,
|
||||
}"
|
||||
:scroll="{ x: 760 }"
|
||||
/>
|
||||
<div
|
||||
ref="tableAreaRef"
|
||||
class="table-area"
|
||||
:style="{ '--table-body-height': `${tableScrollY}px` }"
|
||||
>
|
||||
<a-table
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:data-source="rows"
|
||||
:loading="loading"
|
||||
bordered
|
||||
size="small"
|
||||
:pagination="false"
|
||||
:scroll="{ x: 'max-content', y: tableScrollY }"
|
||||
>
|
||||
<template #bodyCell="{ column, text, record }">
|
||||
<a-button
|
||||
v-if="column.key === 'id'"
|
||||
type="link"
|
||||
class="table-id-link"
|
||||
@click="openDetail(record)"
|
||||
>
|
||||
{{ text }}
|
||||
</a-button>
|
||||
<template v-else>{{ text }}</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
|
||||
<footer class="table-footer">
|
||||
<a-pagination
|
||||
size="small"
|
||||
:current="pagination.current"
|
||||
:page-size="pagination.pageSize"
|
||||
:total="total"
|
||||
show-size-changer
|
||||
@change="changePage"
|
||||
/>
|
||||
</footer>
|
||||
</section>
|
||||
|
||||
<a-drawer
|
||||
v-model:open="advancedOpen"
|
||||
root-class="advanced-filter-drawer"
|
||||
title="高级查询"
|
||||
placement="left"
|
||||
:size="560"
|
||||
:styles="{
|
||||
body: { padding: '12px 16px' },
|
||||
footer: { padding: '8px 16px' },
|
||||
}"
|
||||
>
|
||||
<a-form layout="vertical" class="advanced-filter-form">
|
||||
<a-form-item label="单据编号">
|
||||
<a-input v-model:value="advancedFilters.documentNo" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item label="客户名称">
|
||||
<a-input
|
||||
v-model:value="advancedFilters.customerName"
|
||||
allow-clear
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="业务类型">
|
||||
<a-select
|
||||
v-model:value="advancedFilters.businessType"
|
||||
allow-clear
|
||||
:options="businessTypeOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="业务状态">
|
||||
<a-select
|
||||
v-model:value="advancedFilters.status"
|
||||
allow-clear
|
||||
:options="statusOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="业务日期" class="filter-span-full">
|
||||
<a-range-picker
|
||||
v-model:value="advancedFilters.businessDate"
|
||||
:allow-empty="[true, true]"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="负责人">
|
||||
<a-select
|
||||
v-model:value="advancedFilters.owner"
|
||||
allow-clear
|
||||
:options="ownerOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="所属部门">
|
||||
<a-select
|
||||
v-model:value="advancedFilters.department"
|
||||
allow-clear
|
||||
:options="departmentOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="结算状态">
|
||||
<a-select
|
||||
v-model:value="advancedFilters.settlementStatus"
|
||||
allow-clear
|
||||
:options="settlementOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="币种">
|
||||
<a-select
|
||||
v-model:value="advancedFilters.currency"
|
||||
allow-clear
|
||||
:options="currencyOptions"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="金额下限">
|
||||
<a-input-number
|
||||
v-model:value="advancedFilters.amountMin"
|
||||
:min="0"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="金额上限">
|
||||
<a-input-number
|
||||
v-model:value="advancedFilters.amountMax"
|
||||
:min="0"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="创建人">
|
||||
<a-input v-model:value="advancedFilters.creator" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item label="创建日期">
|
||||
<a-range-picker
|
||||
v-model:value="advancedFilters.createdDate"
|
||||
:allow-empty="[true, true]"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="备注关键词" class="filter-span-full">
|
||||
<a-input v-model:value="advancedFilters.remark" allow-clear />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<template #footer>
|
||||
<div class="drawer-footer">
|
||||
<a-button @click="resetAdvancedFilters">重置</a-button>
|
||||
<a-button type="primary" @click="applyAdvancedFilters">
|
||||
<template #icon><Search /></template>
|
||||
查询
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
</a-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.data-page {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
background: var(--fms-surface);
|
||||
}
|
||||
|
||||
.data-toolbar,
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
flex: none;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
.data-toolbar {
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
.filter-fields {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
&__title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
.search-compact {
|
||||
align-items: center;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: var(--fms-text);
|
||||
font-size: 16px;
|
||||
}
|
||||
.keyword-select {
|
||||
width: 82px;
|
||||
}
|
||||
|
||||
span {
|
||||
color: var(--fms-text-secondary);
|
||||
font-size: 11px;
|
||||
}
|
||||
.keyword-search {
|
||||
width: 260px;
|
||||
}
|
||||
|
||||
.toolbar-button {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.round-action {
|
||||
width: 32px;
|
||||
min-width: 32px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
border-radius: 50% !important;
|
||||
|
||||
:deep(.lucide) {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--fms-border);
|
||||
border-radius: 4px;
|
||||
background: var(--fms-surface);
|
||||
}
|
||||
|
||||
.keyword-input {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.table-panel {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
padding: 0;
|
||||
border: 1px solid var(--fms-border);
|
||||
border-radius: 4px;
|
||||
background: var(--fms-surface);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-area {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin: 8px;
|
||||
overflow: hidden;
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 2;
|
||||
height: 1px;
|
||||
background: var(--fms-border);
|
||||
content: "";
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
:deep(.ant-table-wrapper) {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
:deep(.ant-table-body) {
|
||||
height: var(--table-body-height);
|
||||
min-height: var(--table-body-height);
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr:nth-child(even) > td) {
|
||||
background: var(--fms-bg);
|
||||
}
|
||||
|
||||
.table-id-link {
|
||||
height: auto;
|
||||
padding: 0;
|
||||
font-size: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.table-footer {
|
||||
display: flex;
|
||||
flex: none;
|
||||
min-height: 38px;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.advanced-filter-form {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
column-gap: 12px;
|
||||
row-gap: 0;
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
min-width: 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
:deep(.ant-form-item-label) {
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
|
||||
:deep(.ant-select),
|
||||
:deep(.ant-picker),
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.filter-span-full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.drawer-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
:global(.advanced-filter-drawer .ant-drawer-content-wrapper) {
|
||||
max-width: 100vw;
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.advanced-filter-form {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.filter-span-full {
|
||||
grid-column: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,125 @@
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ArrowLeft } from "@lucide/vue";
|
||||
import { mockRecords } from "../data/mockRecords";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const remark = ref("");
|
||||
|
||||
const recordId = computed(() => String(route.params.id ?? ""));
|
||||
const detailTitle = computed(() => route.meta.listTitle || route.meta.title || "详情");
|
||||
const record = computed(
|
||||
() =>
|
||||
mockRecords.find((item) => item.id === recordId.value) ?? {
|
||||
id: recordId.value,
|
||||
name: `${detailTitle.value} ${recordId.value}`,
|
||||
state: "草稿",
|
||||
businessType: "未设置",
|
||||
owner: "未设置",
|
||||
customer: "未设置",
|
||||
amount: "0.00",
|
||||
currency: "CNY",
|
||||
updated_at: "--",
|
||||
},
|
||||
);
|
||||
|
||||
function backToList() {
|
||||
router.push(String(route.meta.listPath || "/dashboard"));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="detail-page">
|
||||
<header class="detail-toolbar">
|
||||
<a-button type="text" size="small" @click="backToList">
|
||||
<template #icon><ArrowLeft /></template>
|
||||
返回列表
|
||||
</a-button>
|
||||
<div class="detail-heading">
|
||||
<strong>{{ detailTitle }}</strong>
|
||||
<span>{{ recordId }}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="detail-content">
|
||||
<a-descriptions bordered size="small" :column="{ xs: 1, sm: 2, md: 3 }">
|
||||
<a-descriptions-item label="编号">{{ recordId }}</a-descriptions-item>
|
||||
<a-descriptions-item label="名称">{{ record.name }}</a-descriptions-item>
|
||||
<a-descriptions-item label="状态">{{ record.state }}</a-descriptions-item>
|
||||
<a-descriptions-item label="客户">{{ record.customer }}</a-descriptions-item>
|
||||
<a-descriptions-item label="业务类型">{{ record.businessType }}</a-descriptions-item>
|
||||
<a-descriptions-item label="负责人">{{ record.owner }}</a-descriptions-item>
|
||||
<a-descriptions-item label="金额">{{ record.amount }} {{ record.currency }}</a-descriptions-item>
|
||||
<a-descriptions-item label="更新时间">{{ record.updated_at }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
|
||||
<section class="detail-remark">
|
||||
<div class="detail-remark__label">备注</div>
|
||||
<a-textarea v-model:value="remark" :rows="3" />
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.detail-page {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
background: var(--fms-surface);
|
||||
}
|
||||
|
||||
.detail-toolbar {
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 38px;
|
||||
padding: 3px 8px;
|
||||
}
|
||||
|
||||
.detail-toolbar :deep(.lucide) {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.detail-heading {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
color: var(--fms-text);
|
||||
font-size: 13px;
|
||||
|
||||
strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
span {
|
||||
color: var(--fms-text-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin: 8px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.detail-remark {
|
||||
margin-top: 12px;
|
||||
|
||||
&__label {
|
||||
margin-bottom: 5px;
|
||||
color: var(--fms-text);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { reactive, ref } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { LockOutlined, UserOutlined } from "@antdv-next/icons";
|
||||
import { LockKeyhole, UserRound } from "@lucide/vue";
|
||||
import { authApi } from "../services/api";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
|
||||
@@ -12,7 +12,7 @@ const loading = ref(false);
|
||||
const errorMessage = ref("");
|
||||
const form = reactive({
|
||||
orgid: "",
|
||||
username: "",
|
||||
userid: "",
|
||||
password: "",
|
||||
});
|
||||
|
||||
@@ -59,12 +59,12 @@ async function submit() {
|
||||
<a-input v-model:value="form.orgid" size="large" autocomplete="organization" />
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="用户名"
|
||||
name="username"
|
||||
:rules="[{ required: true, message: '请输入用户名' }]"
|
||||
label="用户ID"
|
||||
name="userid"
|
||||
:rules="[{ required: true, message: '请输入用户ID' }]"
|
||||
>
|
||||
<a-input v-model:value="form.username" size="large" autocomplete="username">
|
||||
<template #prefix><UserOutlined /></template>
|
||||
<a-input v-model:value="form.userid" size="large" autocomplete="username">
|
||||
<template #prefix><UserRound /></template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
@@ -77,7 +77,7 @@ async function submit() {
|
||||
size="large"
|
||||
autocomplete="current-password"
|
||||
>
|
||||
<template #prefix><LockOutlined /></template>
|
||||
<template #prefix><LockKeyhole /></template>
|
||||
</a-input-password>
|
||||
</a-form-item>
|
||||
<a-button type="primary" html-type="submit" size="large" block :loading="loading">
|
||||
@@ -91,7 +91,10 @@ async function submit() {
|
||||
<style lang="scss" scoped>
|
||||
.login-page {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background:
|
||||
|
||||
@@ -6,6 +6,11 @@ import Components from "unplugin-vue-components/vite";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
server: {
|
||||
host: "127.0.0.1",
|
||||
port: 5180,
|
||||
strictPort: true,
|
||||
},
|
||||
plugins: [
|
||||
tailwindcss(),
|
||||
vue(),
|
||||
|
||||
Reference in new issue
Block a user