Compare commits
2 Commits
0ecacb9a21
...
e1cbf289ed
| Author | SHA1 | Date | |
|---|---|---|---|
| e1cbf289ed | |||
| 4f5d788fbd |
8
new3.code-workspace
Normal file
8
new3.code-workspace
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="image-upload-container">
|
<div class="image-upload-container">
|
||||||
|
<div class="left-col">
|
||||||
|
<div class="col-left">
|
||||||
<div class="image-wall-wrapper">
|
<div class="image-wall-wrapper">
|
||||||
<!-- Element Plus 图片墙上传组件 -->
|
<!-- Element Plus 图片墙上传组件 -->
|
||||||
<el-upload
|
<el-upload
|
||||||
@ -20,20 +22,20 @@
|
|||||||
>
|
>
|
||||||
<el-icon><Plus /></el-icon>
|
<el-icon><Plus /></el-icon>
|
||||||
<template #tip>
|
<template #tip>
|
||||||
<div class="el-upload__tip">
|
<div class="el-upload__tip">支持jpg/png格式,单张不超过10MB</div>
|
||||||
支持jpg/png格式,单张不超过10MB
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-right">
|
||||||
<div class="camera-section" v-if="hasPermission('index.ReferenceFile')">
|
<div class="camera-section" v-if="hasPermission('index.ReferenceFile')">
|
||||||
<div class="section-title">
|
<div class="section-title">
|
||||||
<el-icon><Camera /></el-icon>
|
<el-icon><Camera /></el-icon>
|
||||||
<span>摄像头拍照</span>
|
<span>摄像头拍照</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 摄像头预览区域 -->
|
<!-- 摄像头预览区域,仅展示预览与拍摄结果,按钮移至右侧面板 -->
|
||||||
<div class="camera-preview">
|
<div class="camera-preview">
|
||||||
<video
|
<video
|
||||||
ref="videoElement"
|
ref="videoElement"
|
||||||
@ -43,38 +45,23 @@
|
|||||||
playsinline
|
playsinline
|
||||||
></video>
|
></video>
|
||||||
|
|
||||||
<!-- 拍照结果显示 -->
|
|
||||||
<div v-if="capturedImage" class="captured-result">
|
<div v-if="capturedImage" class="captured-result">
|
||||||
<img :src="capturedImage" alt="拍摄的照片" />
|
<img :src="capturedImage" alt="拍摄的照片" />
|
||||||
<div class="capture-actions">
|
|
||||||
<el-button
|
|
||||||
type="success"
|
|
||||||
size="small"
|
|
||||||
@click="uploadCapturedImage"
|
|
||||||
:loading="captureUploading"
|
|
||||||
:disabled="!hasPermission('index.ReferenceFile')"
|
|
||||||
>
|
|
||||||
确认上传
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="info"
|
|
||||||
size="small"
|
|
||||||
@click="retakePhoto"
|
|
||||||
>
|
|
||||||
重新拍摄
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 摄像头未激活时的提示 -->
|
|
||||||
<div v-else-if="!isCameraActive" class="camera-placeholder">
|
<div v-else-if="!isCameraActive" class="camera-placeholder">
|
||||||
<el-icon class="placeholder-icon"><CameraFilled /></el-icon>
|
<el-icon class="placeholder-icon"><CameraFilled /></el-icon>
|
||||||
<p>点击下方按钮启动摄像头</p>
|
<p>点击右侧按钮启动摄像头</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 摄像头控制按钮 -->
|
<aside class="right-col">
|
||||||
<div class="camera-controls">
|
<div class="right-panel">
|
||||||
|
<div class="panel-actions">
|
||||||
|
<el-button @click="handleReset">重置</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="toggleCamera"
|
@click="toggleCamera"
|
||||||
@ -92,17 +79,31 @@
|
|||||||
<el-icon><Camera /></el-icon>
|
<el-icon><Camera /></el-icon>
|
||||||
拍照
|
拍照
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
size="small"
|
||||||
|
@click="uploadCapturedImage"
|
||||||
|
:loading="captureUploading"
|
||||||
|
:disabled="!capturedImage || !hasPermission('index.ReferenceFile')"
|
||||||
|
>
|
||||||
|
确认上传
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
size="small"
|
||||||
|
@click="retakePhoto"
|
||||||
|
:disabled="!capturedImage"
|
||||||
|
>
|
||||||
|
重新拍摄
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</aside>
|
||||||
|
|
||||||
<!-- 图片预览对话框 -->
|
<!-- 图片预览对话框 -->
|
||||||
<el-dialog
|
<el-dialog v-model="previewVisible" title="图片预览" width="80%" top="5vh" append-to-body>
|
||||||
v-model="previewVisible"
|
|
||||||
title="图片预览"
|
|
||||||
width="80%"
|
|
||||||
top="5vh"
|
|
||||||
append-to-body
|
|
||||||
>
|
|
||||||
<img :src="dialogImageUrl" alt="预览" style="width: 100%; max-height: 70vh; object-fit: contain;" />
|
<img :src="dialogImageUrl" alt="预览" style="width: 100%; max-height: 70vh; object-fit: contain;" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
@ -486,11 +487,42 @@ const uploadCapturedImage = async () => {
|
|||||||
captureUploading.value = false
|
captureUploading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
// 清理文件列表、停止摄像头并重置拍照图片
|
||||||
|
fileList.value = []
|
||||||
|
capturedImage.value = null
|
||||||
|
stopCamera()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.image-upload-container {
|
.image-upload-container {
|
||||||
padding: 10px;
|
padding: 12px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 320px;
|
||||||
|
gap: 0 16px;
|
||||||
|
align-items: start;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-col {
|
||||||
|
grid-column: 1 / 2;
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-right: 8px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-left {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.col-right {
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.image-wall-wrapper {
|
.image-wall-wrapper {
|
||||||
@ -546,18 +578,6 @@ const uploadCapturedImage = async () => {
|
|||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
.capture-actions {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 20px;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 15px;
|
|
||||||
background-color: rgba(0, 0, 0, 0.5);
|
|
||||||
padding: 10px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.camera-placeholder {
|
.camera-placeholder {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -570,9 +590,21 @@ const uploadCapturedImage = async () => {
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.camera-controls {
|
.right-col {
|
||||||
display: flex;
|
grid-column: 2 / 3;
|
||||||
justify-content: center;
|
height: 100%;
|
||||||
gap: 20px;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.right-panel {
|
||||||
|
position: sticky;
|
||||||
|
top: 20px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 12px;
|
||||||
|
box-shadow: 0 1px 4px rgba(0,0,0,0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-actions { text-align: right; display:flex; gap:8px; flex-wrap:wrap; align-items:center }
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import { useI18n } from 'vue-i18n'
|
|||||||
import { useAppStore } from '@/stores/modules/app'
|
import { useAppStore } from '@/stores/modules/app'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
|
||||||
const { locale } = useI18n()
|
const { locale, messages } = useI18n()
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
|
||||||
const language = computed(() => appStore.language)
|
const language = computed(() => appStore.language)
|
||||||
@ -31,10 +31,12 @@ const language = computed(() => appStore.language)
|
|||||||
const handleSetLanguage = (lang: string) => {
|
const handleSetLanguage = (lang: string) => {
|
||||||
locale.value = lang
|
locale.value = lang
|
||||||
appStore.setLanguage(lang)
|
appStore.setLanguage(lang)
|
||||||
|
console.log('当前语言包内容:', messages.value[lang])
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: 'Switch Language Success',
|
message: 'Switch Language Success',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
})
|
})
|
||||||
|
location.reload()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -194,17 +194,40 @@ const i18n = createI18n({
|
|||||||
/**
|
/**
|
||||||
* 递归深度合并对象
|
* 递归深度合并对象
|
||||||
*/
|
*/
|
||||||
function deepMerge(target: any, source: any) {
|
function deepMerge(target: any, source: any, parentKey: string = '') {
|
||||||
if (!source) return target
|
if (!source) return target
|
||||||
|
|
||||||
Object.keys(source).forEach(key => {
|
Object.keys(source).forEach(key => {
|
||||||
if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
const sourceValue = source[key]
|
||||||
if (!target[key] || typeof target[key] !== 'object') {
|
const targetValue = target[key]
|
||||||
|
const fullKey = parentKey ? `${parentKey}.${key}` : key
|
||||||
|
|
||||||
|
if (sourceValue && typeof sourceValue === 'object' && !Array.isArray(sourceValue)) {
|
||||||
|
if (!targetValue || typeof targetValue !== 'object') {
|
||||||
target[key] = {}
|
target[key] = {}
|
||||||
}
|
}
|
||||||
deepMerge(target[key], source[key])
|
deepMerge(target[key], sourceValue, fullKey)
|
||||||
} else {
|
} else {
|
||||||
target[key] = source[key]
|
// 只有当源对象有值时才尝试合并
|
||||||
|
if (sourceValue !== null && sourceValue !== undefined && sourceValue !== '') {
|
||||||
|
// 判断 sourceValue 是否是占位符 (例如 "dashboard.view" 这种 key 形式的字符串)
|
||||||
|
// 增加不区分大小写的比较,并处理 "prefix.key" 格式的匹配
|
||||||
|
const sourceLower = typeof sourceValue === 'string' ? sourceValue.toLowerCase() : '';
|
||||||
|
const fullKeyLower = fullKey.toLowerCase();
|
||||||
|
const keyLower = key.toLowerCase();
|
||||||
|
|
||||||
|
// 占位符判断:
|
||||||
|
// 1. 值完全等于当前的 fullKey (不区分大小写)
|
||||||
|
// 2. 值完全等于当前的 key (不区分大小写)
|
||||||
|
// 3. 值是 "xxx.key" 格式且等于 fullKey (不区分大小写)
|
||||||
|
const isPlaceholder = typeof sourceValue === 'string' &&
|
||||||
|
(sourceLower === fullKeyLower || sourceLower === keyLower);
|
||||||
|
|
||||||
|
// 如果不是占位符,或者目标对象还没有该翻译,则采用服务器提供的翻译
|
||||||
|
if (!isPlaceholder || !targetValue) {
|
||||||
|
target[key] = sourceValue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return target
|
return target
|
||||||
@ -237,6 +260,7 @@ export async function loadServerMessages(language: string | null = null) {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
i18n.global.setLocaleMessage(targetLanguage, mergedMessages)
|
i18n.global.setLocaleMessage(targetLanguage, mergedMessages)
|
||||||
|
|
||||||
|
console.log('整合后的语言包:', mergedMessages)
|
||||||
console.log(`✅ 服务器翻译加载并深度合并成功 (${targetLanguage})`);
|
console.log(`✅ 服务器翻译加载并深度合并成功 (${targetLanguage})`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -11,9 +11,9 @@
|
|||||||
v-bind="isExternal(shortcut.path) ? { href: shortcut.path, target: '_blank' } : { to: shortcut.path }"
|
v-bind="isExternal(shortcut.path) ? { href: shortcut.path, target: '_blank' } : { to: shortcut.path }"
|
||||||
class="shortcut-item"
|
class="shortcut-item"
|
||||||
>
|
>
|
||||||
<el-tooltip :content="$t('menu.' + shortcut.title)" placement="bottom" :show-after="500">
|
<el-tooltip :content="generateTitle(shortcut.title)" placement="bottom" :show-after="500">
|
||||||
<svg-icon v-if="shortcut.icon" :icon-class="shortcut.icon" />
|
<svg-icon v-if="shortcut.icon" :icon-class="shortcut.icon" />
|
||||||
<span :style="{ marginLeft: shortcut.icon ? '5px' : '0' }">{{ $t('menu.' + shortcut.title) }}</span>
|
<span :style="{ marginLeft: shortcut.icon ? '5px' : '0' }">{{ generateTitle(shortcut.title) }}</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</component>
|
</component>
|
||||||
</div>
|
</div>
|
||||||
@ -81,7 +81,7 @@ const scrollPane = ref()
|
|||||||
|
|
||||||
const visitedViews = computed(() => tagsViewStore.visitedViews)
|
const visitedViews = computed(() => tagsViewStore.visitedViews)
|
||||||
const routes = computed(() => permissionStore.routes)
|
const routes = computed(() => permissionStore.routes)
|
||||||
const shortcuts = computed(() => shortcutsStore.shortcuts)
|
const shortcuts = computed(() => shortcutsStore.$state?.shortcuts ?? [])
|
||||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||||
|
|
||||||
const toggleShortcut = () => {
|
const toggleShortcut = () => {
|
||||||
@ -101,10 +101,10 @@ const isAffix = (tag: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const generateTitle = (title: any) => {
|
const generateTitle = (title: any) => {
|
||||||
const hasKey = te('menu.' + title)
|
const titleKey = 'menu.' + title
|
||||||
|
const hasKey = te(titleKey)
|
||||||
if (hasKey) {
|
if (hasKey) {
|
||||||
const translatedTitle = t('menu.' + title)
|
return t(titleKey)
|
||||||
return translatedTitle
|
|
||||||
}
|
}
|
||||||
return title || 'no-name'
|
return title || 'no-name'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import getPageTitle from '@/utils/get-page-title'
|
|||||||
|
|
||||||
NProgress.configure({ showSpinner: false })
|
NProgress.configure({ showSpinner: false })
|
||||||
|
|
||||||
const whiteList = ['/login','/redirect']
|
const whiteList = ['/login','/redirect','/admin/land'] // no redirect whitelist
|
||||||
|
|
||||||
router.beforeEach(async (to, from) => {
|
router.beforeEach(async (to, from) => {
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
|
|||||||
@ -35,6 +35,12 @@ export const constantRoutes: RouteRecordRaw[] = [
|
|||||||
component: () => import('@/views/login/index.vue'),
|
component: () => import('@/views/login/index.vue'),
|
||||||
meta: { title: '登录', hidden: true }
|
meta: { title: '登录', hidden: true }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/admin/land',
|
||||||
|
name: 'AdminLand',
|
||||||
|
component: () => import('@/views/admin/land/index.vue'),
|
||||||
|
meta: { title: '语言翻译', hidden: true }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
|
|||||||
@ -16,4 +16,5 @@ export const componentMap: Record<string, any> = {
|
|||||||
'system/print/station': () => import('@/views/system/setting/printStation/index.vue'),
|
'system/print/station': () => import('@/views/system/setting/printStation/index.vue'),
|
||||||
// 'system/StoreManagement/station2': () => import('@/views/system/setting/printStation/index2.vue'),
|
// 'system/StoreManagement/station2': () => import('@/views/system/setting/printStation/index2.vue'),
|
||||||
// 'system/setting/printStation': () => import('@/views/system/setting/printStation/index.vue'),
|
// 'system/setting/printStation': () => import('@/views/system/setting/printStation/index.vue'),
|
||||||
|
// 'admin/land': () => import('@/views/admin/land/index.vue')
|
||||||
};
|
};
|
||||||
@ -47,14 +47,9 @@ export const useShortcutsStore = defineStore('shortcuts', () => {
|
|||||||
const is404 = resolved.matched.some(r => r.name === 'Page404' || r.path === '/:pathMatch(.*)*' || r.redirect === '/404')
|
const is404 = resolved.matched.some(r => r.name === 'Page404' || r.path === '/:pathMatch(.*)*' || r.redirect === '/404')
|
||||||
if (is404) return false
|
if (is404) return false
|
||||||
|
|
||||||
// Update title/icon from current route meta if available to keep it fresh
|
// Do not override title/icon if they already exist to avoid language-locked titles
|
||||||
if (resolved.meta?.title) {
|
// Only update if current meta title/icon is different from saved one
|
||||||
s.title = resolved.meta.title as string
|
// Removed forced s.title update to prevent saving translated strings
|
||||||
}
|
|
||||||
if (resolved.meta?.icon) {
|
|
||||||
s.icon = resolved.meta.icon as string
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -129,6 +124,11 @@ export const useShortcutsStore = defineStore('shortcuts', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Watch for shortcuts changes to save them, ensuring deep persistence
|
||||||
|
watch(shortcuts, () => {
|
||||||
|
saveShortcuts()
|
||||||
|
}, { deep: true })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
shortcuts,
|
shortcuts,
|
||||||
addShortcut,
|
addShortcut,
|
||||||
|
|||||||
542
src/views/admin/land/index.vue
Normal file
542
src/views/admin/land/index.vue
Normal file
@ -0,0 +1,542 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-tabs v-model="activeTab" type="border-card">
|
||||||
|
<!-- 展示本地语言包内容(zh-CN、en-US),此部分无法修改(改为可折叠查看) -->
|
||||||
|
<el-tab-pane label="本地语言包 (只读)" name="local">
|
||||||
|
<el-alert
|
||||||
|
title="说明:此部分内容为项目自带的本地语言包,仅供查看。"
|
||||||
|
type="info"
|
||||||
|
:closable="false"
|
||||||
|
style="margin-bottom: 20px"
|
||||||
|
/>
|
||||||
|
<el-collapse v-model="activeLocalCollapse">
|
||||||
|
<el-collapse-item title="zh-CN (本地)" name="zh-CN">
|
||||||
|
<div class="editor-container">
|
||||||
|
<el-input
|
||||||
|
v-model="localZhString"
|
||||||
|
type="textarea"
|
||||||
|
:rows="20"
|
||||||
|
readonly
|
||||||
|
class="json-editor"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
<el-collapse-item title="en-US (本地)" name="en-US">
|
||||||
|
<div class="editor-container">
|
||||||
|
<el-input
|
||||||
|
v-model="localEnString"
|
||||||
|
type="textarea"
|
||||||
|
:rows="20"
|
||||||
|
readonly
|
||||||
|
class="json-editor"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
</el-collapse>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<!-- 展示从服务器获取的语言包(目前有zh-CN、en-US),点击对应语言包可以展开查看对应语言包具体数据,语言包数据允许修改;此部分数据先使用本地模拟数据。 -->
|
||||||
|
<el-tab-pane label="服务器语言包" name="server">
|
||||||
|
<div class="pane-action-bar">
|
||||||
|
<el-button type="primary" size="small" @click="handleResetServerData">重置数据</el-button>
|
||||||
|
</div>
|
||||||
|
<el-collapse v-model="activeServerCollapse">
|
||||||
|
<el-collapse-item title="zh-CN (来自服务器)" name="zh-CN">
|
||||||
|
<div class="editor-container">
|
||||||
|
<el-input
|
||||||
|
v-model="serverZhString"
|
||||||
|
type="textarea"
|
||||||
|
:rows="15"
|
||||||
|
class="json-editor editable"
|
||||||
|
placeholder="请输入有效JSON格式数据"
|
||||||
|
/>
|
||||||
|
<div class="editor-footer">
|
||||||
|
<el-button type="success" size="small" @click="saveServerData('zh-CN')">保存数据并更新合并预览</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
<el-collapse-item title="en-US (来自服务器)" name="en-US">
|
||||||
|
<div class="editor-container">
|
||||||
|
<el-input
|
||||||
|
v-model="serverEnString"
|
||||||
|
type="textarea"
|
||||||
|
:rows="15"
|
||||||
|
class="json-editor editable"
|
||||||
|
placeholder="请输入有效JSON格式数据"
|
||||||
|
/>
|
||||||
|
<div class="editor-footer">
|
||||||
|
<el-button type="success" size="small" @click="saveServerData('en-US')">保存数据并更新合并预览</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
</el-collapse>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<!-- 能查看项目合并翻译后的语言包数据(改为可折叠面板,便于查看) -->
|
||||||
|
<el-tab-pane label="项目合并最终语言包" name="merged">
|
||||||
|
<el-alert
|
||||||
|
title="说明:此处展示的是本地语言包与服务器语言包合并后的最终结果 (服务器数据优先级高于本地)。"
|
||||||
|
type="success"
|
||||||
|
:closable="false"
|
||||||
|
style="margin-bottom: 20px"
|
||||||
|
/>
|
||||||
|
<el-collapse v-model="activeMergedCollapse">
|
||||||
|
<el-collapse-item title="zh-CN (合并结果)" name="zh-CN">
|
||||||
|
<div class="editor-container">
|
||||||
|
<el-input
|
||||||
|
v-model="mergedZhString"
|
||||||
|
type="textarea"
|
||||||
|
:rows="20"
|
||||||
|
readonly
|
||||||
|
class="json-editor"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
<el-collapse-item title="en-US (合并结果)" name="en-US">
|
||||||
|
<div class="editor-container">
|
||||||
|
<el-input
|
||||||
|
v-model="mergedEnString"
|
||||||
|
type="textarea"
|
||||||
|
:rows="20"
|
||||||
|
readonly
|
||||||
|
class="json-editor"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-collapse-item>
|
||||||
|
</el-collapse>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<!-- 新增语言页面(左右布局):左侧为新增语言卡片,右侧为翻译工具 -->
|
||||||
|
<el-tab-pane label="新增语言" name="add">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-card>
|
||||||
|
<div class="card-header">
|
||||||
|
<h3>新增语言信息</h3>
|
||||||
|
</div>
|
||||||
|
<el-form :model="newLangForm" label-width="120px">
|
||||||
|
<el-form-item label="自定义语言名称" required>
|
||||||
|
<el-input v-model="newLangForm.name" placeholder="例如:日本語" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="自定义语言代码" required>
|
||||||
|
<el-input v-model="newLangForm.code" placeholder="例如:ja-JP" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="初始语言JSON数据内容">
|
||||||
|
<el-input
|
||||||
|
v-model="newLangForm.content"
|
||||||
|
type="textarea"
|
||||||
|
:rows="12"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" size="large" @click="handleAddLanguage">提交新增语言</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="16">
|
||||||
|
<el-card>
|
||||||
|
<div class="card-header" style="display:flex;align-items:center;justify-content:space-between;">
|
||||||
|
<h3>翻译工具</h3>
|
||||||
|
<div>
|
||||||
|
<el-input v-model="targetLang" placeholder="目标语言代码 (例如 ja-JP)" size="small" style="width:200px; margin-right:8px;" />
|
||||||
|
<el-button type="primary" size="small" @click="getFields">获取字段</el-button>
|
||||||
|
<el-button type="success" size="small" @click="quickTranslate" style="margin-left:8px;">快速翻译</el-button>
|
||||||
|
<el-button type="warning" size="small" @click="fillTemplate" style="margin-left:8px;">模板填充</el-button>
|
||||||
|
<el-button type="warning" size="small" @click="resetTemplate" style="margin-left:8px;">重置模板</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tool-area" style="margin-top:12px; display:flex; gap:12px;">
|
||||||
|
<div class="fields-list" style="flex:1; max-height:420px; overflow:auto;">
|
||||||
|
<h4>字段列表</h4>
|
||||||
|
<el-list v-if="fieldsList.length">
|
||||||
|
<el-list-item v-for="(f, idx) in fieldsList" :key="f">
|
||||||
|
<div class="field-row">{{ f }}</div>
|
||||||
|
</el-list-item>
|
||||||
|
</el-list>
|
||||||
|
<div v-else class="empty-tip">尚未获取字段,点击“获取字段”以提取模板字段</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="translate-list" style="flex:1; max-height:420px; overflow:auto;">
|
||||||
|
<h4>目标语言翻译(可编辑)</h4>
|
||||||
|
<div v-if="fieldsList.length">
|
||||||
|
<div v-for="(f, idx) in fieldsList" :key="f" class="translate-row" style="margin-bottom:10px;">
|
||||||
|
<div style="font-size:12px;color:#606266;margin-bottom:6px;">{{ f }}</div>
|
||||||
|
<el-input v-model="translations[f]" placeholder="输入翻译文本,或使用快速翻译" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="empty-tip">无可翻译字段</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, computed, onMounted } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import localZh from '@/lang/zh-CN'
|
||||||
|
import localEn from '@/lang/en-US'
|
||||||
|
import _ from 'lodash'
|
||||||
|
import * as indexApi from '@/api/index'
|
||||||
|
|
||||||
|
// 标签页选中项
|
||||||
|
const activeTab = ref('local')
|
||||||
|
// 控制服务器语言包折叠面板,默认展开 zh-CN
|
||||||
|
const activeServerCollapse = ref<string[]>(['zh-CN'])
|
||||||
|
// 控制合并预览折叠面板
|
||||||
|
const activeMergedCollapse = ref<string[]>(['zh-CN'])
|
||||||
|
// 控制本地语言包折叠面板
|
||||||
|
const activeLocalCollapse = ref<string[]>(['zh-CN'])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本地语言数据 (只读展示)
|
||||||
|
*/
|
||||||
|
const localZhString = ref(JSON.stringify(localZh, null, 2))
|
||||||
|
const localEnString = ref(JSON.stringify(localEn, null, 2))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器语言包数据 (模拟数据)
|
||||||
|
*/
|
||||||
|
const serverZhString = ref('')
|
||||||
|
const serverEnString = ref('')
|
||||||
|
|
||||||
|
// 定义模拟的“服务器端重写”的数据内容,用于演示合并功能
|
||||||
|
const mockServerData = {
|
||||||
|
'zh-CN': {
|
||||||
|
"common": {
|
||||||
|
"add": "新增(来自服务器重写)",
|
||||||
|
"server_label": "服务器专用标识符"
|
||||||
|
},
|
||||||
|
"menu": {
|
||||||
|
"Dashboard": "远程主页控制台"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'en': {
|
||||||
|
"common": {
|
||||||
|
"add": "Add (Server Overwrite)",
|
||||||
|
"server_label": "Server-side specific key"
|
||||||
|
},
|
||||||
|
"menu": {
|
||||||
|
"Dashboard": "Remote Dashboard Panel"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归深度合并对象 (同步 src/lang/index.ts 的逻辑)
|
||||||
|
*/
|
||||||
|
function deepMerge(target: any, source: any, parentKey: string = '') {
|
||||||
|
if (!source) return target
|
||||||
|
|
||||||
|
Object.keys(source).forEach(key => {
|
||||||
|
const sourceValue = source[key]
|
||||||
|
const targetValue = target[key]
|
||||||
|
const fullKey = parentKey ? `${parentKey}.${key}` : key
|
||||||
|
|
||||||
|
if (sourceValue && typeof sourceValue === 'object' && !Array.isArray(sourceValue)) {
|
||||||
|
if (!targetValue || typeof targetValue !== 'object') {
|
||||||
|
target[key] = {}
|
||||||
|
}
|
||||||
|
deepMerge(target[key], sourceValue, fullKey)
|
||||||
|
} else {
|
||||||
|
// 只有当源对象有值时才尝试合并
|
||||||
|
if (sourceValue !== null && sourceValue !== undefined && sourceValue !== '') {
|
||||||
|
const sourceLower = typeof sourceValue === 'string' ? sourceValue.toLowerCase() : '';
|
||||||
|
const fullKeyLower = fullKey.toLowerCase();
|
||||||
|
const keyLower = key.toLowerCase();
|
||||||
|
|
||||||
|
// 占位符判断:如果值等于 key 或 fullKey,则视为未翻译
|
||||||
|
const isPlaceholder = typeof sourceValue === 'string' &&
|
||||||
|
(sourceLower === fullKeyLower || sourceLower === keyLower);
|
||||||
|
|
||||||
|
if (!isPlaceholder || !targetValue) {
|
||||||
|
target[key] = sourceValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return target
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目合并后的翻译包 (深度合并:本地 + 服务器)
|
||||||
|
*/
|
||||||
|
const mergedZhString = computed(() => {
|
||||||
|
try {
|
||||||
|
const serverObj = serverZhString.value ? JSON.parse(serverZhString.value) : {}
|
||||||
|
// 克隆本地数据以避免直接修改
|
||||||
|
const localCopy = JSON.parse(JSON.stringify(localZh))
|
||||||
|
const merged = deepMerge(localCopy, serverObj)
|
||||||
|
return JSON.stringify(merged, null, 2)
|
||||||
|
} catch (e) {
|
||||||
|
return '解析JSON失败:请确保服务器端输入的是有效的 JSON 字符串'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const mergedEnString = computed(() => {
|
||||||
|
try {
|
||||||
|
const serverObj = serverEnString.value ? JSON.parse(serverEnString.value) : {}
|
||||||
|
const localCopy = JSON.parse(JSON.stringify(localEn))
|
||||||
|
const merged = deepMerge(localCopy, serverObj)
|
||||||
|
return JSON.stringify(merged, null, 2)
|
||||||
|
} catch (e) {
|
||||||
|
return '解析JSON失败:请确保服务器端输入的是有效的 JSON 字符串'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语言表单功能
|
||||||
|
* 自动根据本地 zh-CN 语言包结构生成空值模板,用作新增语言的初始内容
|
||||||
|
*/
|
||||||
|
function makeTemplate(obj: any): any {
|
||||||
|
if (obj === null || typeof obj !== 'object') return ''
|
||||||
|
const out: any = Array.isArray(obj) ? [] : {}
|
||||||
|
for (const k in obj) {
|
||||||
|
const v = obj[k]
|
||||||
|
if (v && typeof v === 'object') {
|
||||||
|
out[k] = makeTemplate(v)
|
||||||
|
} else {
|
||||||
|
out[k] = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultNewLangContent = JSON.stringify(makeTemplate(localZh), null, 2)
|
||||||
|
|
||||||
|
const newLangForm = ref({
|
||||||
|
name: '',
|
||||||
|
code: '',
|
||||||
|
content: defaultNewLangContent
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// 尝试从后端接口获取数据并初始化,失败时回退到模拟数据
|
||||||
|
loadServerFromApi()
|
||||||
|
})
|
||||||
|
|
||||||
|
// 从后端加载服务器语言包并展示在“服务器语言包”区域,失败时使用 mock 数据
|
||||||
|
const loadServerFromApi = async () => {
|
||||||
|
try {
|
||||||
|
const resZh = await indexApi.getI18nMessage({ language: 'zh-CN' })
|
||||||
|
const resEn = await indexApi.getI18nMessage({ language: 'en' })
|
||||||
|
|
||||||
|
if (resZh && resZh.data) {
|
||||||
|
const payload = resZh.data.messages || resZh.data
|
||||||
|
serverZhString.value = JSON.stringify(payload, null, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resEn && resEn.data) {
|
||||||
|
const payload = resEn.data.messages || resEn.data
|
||||||
|
serverEnString.value = JSON.stringify(payload, null, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果两者都没有数据,则使用本地模拟数据
|
||||||
|
if ((!resZh || !resZh.data) && (!resEn || !resEn.data)) {
|
||||||
|
initMockServerData()
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// 回退到模拟数据
|
||||||
|
initMockServerData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const initMockServerData = () => {
|
||||||
|
serverZhString.value = JSON.stringify(mockServerData['zh-CN'], null, 2)
|
||||||
|
serverEnString.value = JSON.stringify(mockServerData['en'], null, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleResetServerData = async () => {
|
||||||
|
// 重置应优先从服务器拉取最新数据;失败时回退到模拟数据
|
||||||
|
try {
|
||||||
|
await loadServerFromApi()
|
||||||
|
ElMessage.success('已从服务器重新加载语言包(若服务器不可用则回退到模拟数据)')
|
||||||
|
} catch (e) {
|
||||||
|
initMockServerData()
|
||||||
|
ElMessage.success('服务器加载失败,已回退到初始模拟数据')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模拟保存服务器端数据修改
|
||||||
|
const saveServerData = (langCode: string) => {
|
||||||
|
try {
|
||||||
|
const val = langCode === 'zh-CN' ? serverZhString.value : serverEnString.value
|
||||||
|
JSON.parse(val) // 验证当前输入是否符合 JSON 规范
|
||||||
|
ElMessage.success(`${langCode} 数据已成功保存(本地模拟)`)
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error('JSON格式语法错误,请检查大括号、引号或逗号是否闭合且成对出现')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模拟新增语言功能
|
||||||
|
const handleAddLanguage = () => {
|
||||||
|
if (!newLangForm.value.name || !newLangForm.value.code) {
|
||||||
|
ElMessage.warning('名称和代码标识为必填项')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JSON.parse(newLangForm.value.content)
|
||||||
|
ElMessage.success(`[业务模拟] 成功向服务器提交新增语言包: ${newLangForm.value.name} (${newLangForm.value.code})`)
|
||||||
|
// 这里未来会执行实际的 API POST 请求
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error('输入的数据内容不符合标准 JSON 语法')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 翻译工具(前端模拟) ----------
|
||||||
|
const fieldsList = ref<string[]>([])
|
||||||
|
const translations = ref<Record<string, string>>({})
|
||||||
|
const targetLang = ref('')
|
||||||
|
|
||||||
|
// 从 newLangForm.content 中提取所有 leaf 字段路径
|
||||||
|
function collectFields(obj: any, prefix = ''): string[] {
|
||||||
|
if (obj === null || typeof obj !== 'object') return [prefix].filter(Boolean)
|
||||||
|
let res: string[] = []
|
||||||
|
for (const k in obj) {
|
||||||
|
const v = obj[k]
|
||||||
|
const path = prefix ? `${prefix}.${k}` : k
|
||||||
|
if (v && typeof v === 'object' && !Array.isArray(v)) {
|
||||||
|
res = res.concat(collectFields(v, path))
|
||||||
|
} else {
|
||||||
|
res.push(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
const getFields = () => {
|
||||||
|
try {
|
||||||
|
const obj = JSON.parse(newLangForm.value.content || '{}')
|
||||||
|
const keys = collectFields(obj)
|
||||||
|
fieldsList.value = keys
|
||||||
|
// 初始化 translations
|
||||||
|
const map: Record<string, string> = {}
|
||||||
|
keys.forEach(k => { map[k] = '' })
|
||||||
|
translations.value = map
|
||||||
|
ElMessage.success(`已提取 ${keys.length} 个字段`)
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error('无法解析模板 JSON,请检查格式')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模拟调用翻译接口,返回 map
|
||||||
|
function fakeTranslateRequest(items: string[], lang: string): Promise<Record<string, string>> {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const out: Record<string, string> = {}
|
||||||
|
items.forEach(i => {
|
||||||
|
out[i] = `${lang || 'auto'} 翻译: ${i.split('.').slice(-1)[0]}`
|
||||||
|
})
|
||||||
|
resolve(out)
|
||||||
|
}, 600)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const quickTranslate = async () => {
|
||||||
|
if (!fieldsList.value.length) {
|
||||||
|
ElMessage.warning('请先点击【获取字段】')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!targetLang.value) {
|
||||||
|
ElMessage.warning('请填写目标语言代码,例如:ja-JP')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const items = [...fieldsList.value]
|
||||||
|
const res = await fakeTranslateRequest(items, targetLang.value)
|
||||||
|
// 填充 translations
|
||||||
|
for (const k of Object.keys(res)) {
|
||||||
|
translations.value[k] = res[k] ?? ''
|
||||||
|
}
|
||||||
|
ElMessage.success('快速翻译已完成(模拟)')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置所有翻译输入框为空
|
||||||
|
const resetTemplate = () => {
|
||||||
|
if (!fieldsList.value.length) {
|
||||||
|
ElMessage.info('没有可重置的字段')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for (const k of Object.keys(translations.value)) {
|
||||||
|
translations.value[k] = ''
|
||||||
|
}
|
||||||
|
ElMessage.success('已重置所有翻译输入框')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 translations 填充回 newLangForm.content(覆盖模板对应叶子节点)
|
||||||
|
const fillTemplate = () => {
|
||||||
|
try {
|
||||||
|
const obj = JSON.parse(newLangForm.value.content || '{}')
|
||||||
|
for (const path of Object.keys(translations.value)) {
|
||||||
|
const parts = path.split('.')
|
||||||
|
let cur: any = obj
|
||||||
|
for (let i = 0; i < parts.length - 1; i++) {
|
||||||
|
const key = parts[i]
|
||||||
|
if (!key) continue
|
||||||
|
if (cur[key] == null || typeof cur[key] !== 'object') {
|
||||||
|
cur[key] = {}
|
||||||
|
}
|
||||||
|
cur = cur[key]
|
||||||
|
}
|
||||||
|
const lastKey = parts[parts.length - 1]
|
||||||
|
if (!lastKey) continue
|
||||||
|
cur[lastKey] = translations.value[path] ?? ''
|
||||||
|
}
|
||||||
|
newLangForm.value.content = JSON.stringify(obj, null, 2)
|
||||||
|
ElMessage.success('已将翻译结果填充到模板')
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error('模板填充失败:无法解析当前模板 JSON')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.app-container {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-header {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.json-editor {
|
||||||
|
font-family: ''SFMono-Regular'', Consolas, ''Liberation Mono'', Menlo, monospace;
|
||||||
|
:deep(.el-textarea__inner) {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
color: #444;
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.editable :deep(.el-textarea__inner) {
|
||||||
|
background-color: #ffffff;
|
||||||
|
color: #111;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pane-action-bar {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-container {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-footer {
|
||||||
|
margin-top: 15px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,8 +1,830 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="auth-approve-container">
|
<div class="approve-container">
|
||||||
<h1>审批管理</h1>
|
<!-- 审核表单 -->
|
||||||
|
<div v-if="!loading" class="approve-form">
|
||||||
|
<!-- 头部信息 -->
|
||||||
|
<div class="form-header">
|
||||||
|
<h1>{{ storeInfo?.company_name || '门店代号' }}</h1>
|
||||||
|
<div class="status-tag">
|
||||||
|
<el-tag :type="statusType" style="line-height: 1;">{{ statusText }}</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 申请者信息 -->
|
||||||
|
<el-card class="info-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>申请者信息</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="info">
|
||||||
|
<div class="info-grid">
|
||||||
|
<div class="info-item">
|
||||||
|
<div class="info-label">申请人</div>
|
||||||
|
<div class="info-value">{{ info.employees_name || info.name || '--' }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-item">
|
||||||
|
<div class="info-label">申请时间</div>
|
||||||
|
<div class="info-value">{{ formatDate(info.apply_time) }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 申请备注 -->
|
||||||
|
<div class="remark-section">
|
||||||
|
<h4>申请备注</h4>
|
||||||
|
<div class="remark-content">
|
||||||
|
{{ info.remark || '无' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="no-role-content" v-else>
|
||||||
|
<p>没有找到对应的申请信息,可能已被他人审核或者申请者重新提交了申请资料</p>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 角色选择(仅显示在通过申请时) -->
|
||||||
|
<el-card class="role-card" v-if="info && roles && roles.length > 0">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>选择角色(可多选)</span>
|
||||||
|
<div class="header-actions">
|
||||||
|
<el-tooltip content="可以为申请者分配多个角色" placement="top">
|
||||||
|
<el-icon>
|
||||||
|
<QuestionFilled />
|
||||||
|
</el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
<span class="selection-count" v-if="selectedRoleIds.length > 0">
|
||||||
|
已选择 {{ selectedRoleIds.length }} 个角色
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="role-selection-note">
|
||||||
|
<el-alert type="info" :closable="false">
|
||||||
|
<template #title>
|
||||||
|
温馨提示:通过申请时需要至少选择一个角色,拒绝申请时不需要选择角色
|
||||||
|
</template>
|
||||||
|
</el-alert>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-checkbox-group v-model="selectedRoleIds">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8" v-for="role in roles" :key="role.id" :xs="24" :sm="12" :md="8">
|
||||||
|
<el-card
|
||||||
|
class="role-option"
|
||||||
|
:class="{ 'selected': selectedRoleIds.includes(role.id) }"
|
||||||
|
@click.stop="toggleRoleSelection(role.id)"
|
||||||
|
>
|
||||||
|
<div class="role-content">
|
||||||
|
<el-checkbox :label="role.id" class="role-checkbox" :value="role.id">
|
||||||
|
<div class="role-info">
|
||||||
|
<div class="role-name">{{ role.role_name }}</div>
|
||||||
|
<div class="role-desc">{{ role.description || '暂无描述' }}</div>
|
||||||
|
</div>
|
||||||
|
</el-checkbox>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-checkbox-group>
|
||||||
|
|
||||||
|
<!-- 选择提示 -->
|
||||||
|
<div class="selection-tips" v-if="selectedRoleIds.length > 0 && info">
|
||||||
|
<div class="selected-roles-list">
|
||||||
|
<strong>已选角色:</strong>
|
||||||
|
<span v-for="roleId in selectedRoleIds" :key="roleId" class="selected-role-tag">
|
||||||
|
{{ getRoleName(roleId) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="selection-action">
|
||||||
|
<el-button size="small" @click="clearSelection">清空选择</el-button>
|
||||||
|
<el-button size="small" type="primary" @click="selectAll" v-if="selectedRoleIds.length < roles.length">
|
||||||
|
全选
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="no-selection-tips" v-else>
|
||||||
|
<el-alert type="warning" :closable="false">
|
||||||
|
<template #title>
|
||||||
|
请至少选择一个角色才能通过申请
|
||||||
|
</template>
|
||||||
|
</el-alert>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 无角色提示 -->
|
||||||
|
<el-card v-else-if="(!roles || roles.length === 0)" class="no-role-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>{{ storeInfo?.company_name || '门店' }}未创建角色</span>
|
||||||
|
<el-tooltip content="请创建角色后再审核" placement="top">
|
||||||
|
<el-icon>
|
||||||
|
<QuestionFilled />
|
||||||
|
</el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="no-role-content">
|
||||||
|
<p>当前门店尚未创建任何角色,无法通过申请。</p>
|
||||||
|
<p>您可以拒绝申请,或者联系管理员创建角色后重新审核。</p>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 审核备注 -->
|
||||||
|
<el-card class="remark-card" v-if="info">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>审核备注</span>
|
||||||
|
<span class="tip-text">(选填)</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-input
|
||||||
|
v-model="auditRemark"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
placeholder="请输入审核意见或备注"
|
||||||
|
maxlength="500"
|
||||||
|
show-word-limit
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 操作按钮 -->
|
||||||
|
<div class="action-buttons" v-if="info && info.audit_status === 'pending'">
|
||||||
|
<el-button type="danger" @click="handleReject" :loading="rejectLoading">
|
||||||
|
拒绝申请
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
:disabled="!(roles && roles.length > 0 && selectedRoleIds.length > 0)"
|
||||||
|
@click="handleApprove"
|
||||||
|
:loading="approveLoading"
|
||||||
|
>
|
||||||
|
通过申请
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 已审核显示 -->
|
||||||
|
<div v-if="info && info.audit_status !== 'pending'" class="audited-info">
|
||||||
|
<el-alert :title="auditResultTitle" :type="auditResultType" :closable="false" show-icon center />
|
||||||
|
<div class="audit-detail">
|
||||||
|
<p v-if="info.audited_roles && info.audited_roles.length > 0">
|
||||||
|
<strong>分配角色:</strong>
|
||||||
|
<span v-for="role in info.audited_roles" :key="role.id" class="role-tag">
|
||||||
|
{{ role.role_name }}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p v-if="info.audit_remark">
|
||||||
|
<strong>审核备注:</strong>{{ info.audit_remark }}
|
||||||
|
</p>
|
||||||
|
<p v-if="info.audit_time">
|
||||||
|
<strong>审核时间:</strong>{{ formatDate(info.audit_time) }}
|
||||||
|
</p>
|
||||||
|
<p v-if="info.audit_user_name">
|
||||||
|
<strong>审核人:</strong>{{ info.audit_user_name }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<el-button type="primary" @click="closePage">关闭页面</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="loading" class="loading-state">
|
||||||
|
<el-skeleton :rows="10" animated />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 拒绝理由弹窗 -->
|
||||||
|
<el-dialog v-model="rejectDialogVisible" title="请输入拒绝理由" width="500px" :close-on-click-modal="false">
|
||||||
|
<div class="reject-dialog-content">
|
||||||
|
<el-alert type="warning" :closable="false" class="reject-alert">
|
||||||
|
<template #title>
|
||||||
|
拒绝申请时不需要选择角色
|
||||||
|
</template>
|
||||||
|
</el-alert>
|
||||||
|
<el-input
|
||||||
|
v-model="rejectReason"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
placeholder="请详细说明拒绝的理由"
|
||||||
|
maxlength="500"
|
||||||
|
show-word-limit
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="rejectDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="danger" @click="confirmReject" :loading="rejectLoading" :disabled="!rejectReason.trim()">
|
||||||
|
确认拒绝
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 成功提示弹窗 -->
|
||||||
|
<el-dialog
|
||||||
|
v-model="successDialogVisible"
|
||||||
|
:title="dialogTitle"
|
||||||
|
width="400px"
|
||||||
|
:show-close="false"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<el-icon size="60" :color="dialogIconColor">
|
||||||
|
<component :is="dialogIconComponent" />
|
||||||
|
</el-icon>
|
||||||
|
<p style="margin: 20px 0; font-size: 16px;">{{ successMessage }}</p>
|
||||||
|
<div v-if="isApproved && successRoles.length > 0" class="success-roles">
|
||||||
|
<p>分配角色:</p>
|
||||||
|
<div class="success-roles-list">
|
||||||
|
<el-tag v-for="role in successRoles" :key="role.id" type="success" size="small">
|
||||||
|
{{ role.role_name }}
|
||||||
|
</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<el-button type="primary" @click="handleDialogClose">关闭页面</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref, computed, watch, onMounted } from 'vue'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { getStoreRoles, auditApply } from '@/api/store'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { QuestionFilled, CircleCheck, CircleClose } from '@element-plus/icons-vue'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
// 状态定义
|
||||||
|
const loading = ref(true)
|
||||||
|
const info = ref<any>(null)
|
||||||
|
const roles = ref<any[]>([])
|
||||||
|
const storeInfo = ref<any>(null)
|
||||||
|
|
||||||
|
// 表单数据
|
||||||
|
const selectedRoleIds = ref<number[]>([])
|
||||||
|
const auditRemark = ref('')
|
||||||
|
|
||||||
|
// 拒绝相关
|
||||||
|
const rejectDialogVisible = ref(false)
|
||||||
|
const rejectReason = ref('')
|
||||||
|
|
||||||
|
// 加载状态
|
||||||
|
const approveLoading = ref(false)
|
||||||
|
const rejectLoading = ref(false)
|
||||||
|
|
||||||
|
// 成功提示
|
||||||
|
const successDialogVisible = ref(false)
|
||||||
|
const successMessage = ref('')
|
||||||
|
const dialogTitle = ref('操作成功')
|
||||||
|
const dialogIconComponent = ref<any>(CircleCheck)
|
||||||
|
const dialogIconColor = ref('#67C23A')
|
||||||
|
const successRoles = ref<any[]>([])
|
||||||
|
const isApproved = ref(true)
|
||||||
|
|
||||||
|
// 计算属性
|
||||||
|
const statusType = computed(() => {
|
||||||
|
const status = info.value?.audit_status
|
||||||
|
const map: Record<string, string> = {
|
||||||
|
'pending': 'warning',
|
||||||
|
'approved': 'success',
|
||||||
|
'rejected': 'danger',
|
||||||
|
'processing': 'info'
|
||||||
|
}
|
||||||
|
return map[status] || 'info'
|
||||||
|
})
|
||||||
|
|
||||||
|
const statusText = computed(() => {
|
||||||
|
const status = info.value?.audit_status
|
||||||
|
const map: Record<string, string> = {
|
||||||
|
'pending': '待审核',
|
||||||
|
'approved': '已通过',
|
||||||
|
'rejected': '已拒绝',
|
||||||
|
'processing': '审核中'
|
||||||
|
}
|
||||||
|
return map[status] || '未知状态'
|
||||||
|
})
|
||||||
|
|
||||||
|
const auditResultTitle = computed(() => {
|
||||||
|
if (info.value?.audit_status === 'approved') {
|
||||||
|
return '申请已通过'
|
||||||
|
} else if (info.value?.audit_status === 'rejected') {
|
||||||
|
return '申请已拒绝'
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const auditResultType = computed(() => {
|
||||||
|
return info.value?.audit_status === 'approved' ? 'success' : 'error' as any
|
||||||
|
})
|
||||||
|
|
||||||
|
// 方法
|
||||||
|
const getData = async (code: string) => {
|
||||||
|
if (!code) return
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const response: any = await getStoreRoles({ code })
|
||||||
|
if (response.code === 200) {
|
||||||
|
info.value = response.data.info
|
||||||
|
roles.value = response.data.roles || []
|
||||||
|
storeInfo.value = response.data.store || {}
|
||||||
|
} else {
|
||||||
|
ElMessage.error(response.msg || '获取数据失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取数据失败:', error)
|
||||||
|
ElMessage.error('网络错误,请稍后重试')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleRoleSelection = (roleId: number) => {
|
||||||
|
const index = selectedRoleIds.value.indexOf(roleId)
|
||||||
|
if (index > -1) {
|
||||||
|
selectedRoleIds.value.splice(index, 1)
|
||||||
|
} else {
|
||||||
|
selectedRoleIds.value.push(roleId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectAll = () => {
|
||||||
|
selectedRoleIds.value = roles.value.map(role => role.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearSelection = () => {
|
||||||
|
selectedRoleIds.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
const getRoleName = (roleId: number) => {
|
||||||
|
const role = roles.value.find(r => r.id === roleId)
|
||||||
|
return role ? role.role_name : '未知角色'
|
||||||
|
}
|
||||||
|
|
||||||
|
const getSelectedRoles = () => {
|
||||||
|
return roles.value.filter(role => selectedRoleIds.value.includes(role.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleApprove = async () => {
|
||||||
|
if (selectedRoleIds.value.length === 0) {
|
||||||
|
ElMessage.warning('请至少选择一个角色')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确认通过申请并为用户分配 ${selectedRoleIds.value.length} 个角色吗?`,
|
||||||
|
'提示',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
approveLoading.value = true
|
||||||
|
const submitData = {
|
||||||
|
code: route.query.code,
|
||||||
|
role_ids: selectedRoleIds.value,
|
||||||
|
store_id: storeInfo.value.id,
|
||||||
|
audit_status: 'approved',
|
||||||
|
audit_remark: auditRemark.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const response: any = await auditApply(submitData)
|
||||||
|
if (response.code === 200) {
|
||||||
|
successMessage.value = response.msg || '申请已通过,页面即将关闭'
|
||||||
|
dialogTitle.value = '操作成功'
|
||||||
|
dialogIconComponent.value = CircleCheck
|
||||||
|
dialogIconColor.value = '#67C23A'
|
||||||
|
successRoles.value = getSelectedRoles()
|
||||||
|
isApproved.value = true
|
||||||
|
successDialogVisible.value = true
|
||||||
|
|
||||||
|
// 更新本地状态
|
||||||
|
if (info.value) {
|
||||||
|
info.value.audit_status = 'approved'
|
||||||
|
if (response.data) {
|
||||||
|
Object.assign(info.value, response.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ElMessage.error(response.msg || '操作失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (error !== 'cancel') {
|
||||||
|
console.error('审核失败:', error)
|
||||||
|
ElMessage.error('网络错误,请稍后重试')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
approveLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleReject = () => {
|
||||||
|
rejectDialogVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmReject = async () => {
|
||||||
|
if (!rejectReason.value.trim()) {
|
||||||
|
ElMessage.warning('请填写拒绝理由')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
rejectLoading.value = true
|
||||||
|
try {
|
||||||
|
const submitData = {
|
||||||
|
code: route.query.code,
|
||||||
|
audit_status: 'rejected',
|
||||||
|
audit_remark: rejectReason.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const response: any = await auditApply(submitData)
|
||||||
|
if (response.code === 200) {
|
||||||
|
successMessage.value = response.msg || '申请已拒绝,页面即将关闭'
|
||||||
|
dialogTitle.value = '操作成功'
|
||||||
|
dialogIconComponent.value = CircleClose
|
||||||
|
dialogIconColor.value = '#F56C6C'
|
||||||
|
successRoles.value = []
|
||||||
|
isApproved.value = false
|
||||||
|
successDialogVisible.value = true
|
||||||
|
rejectDialogVisible.value = false
|
||||||
|
|
||||||
|
// 更新本地状态
|
||||||
|
if (info.value) {
|
||||||
|
info.value.audit_status = 'rejected'
|
||||||
|
if (response.data) {
|
||||||
|
Object.assign(info.value, response.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ElMessage.error(response.msg || '操作失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('拒绝失败:', error)
|
||||||
|
ElMessage.error('网络错误,请稍后重试')
|
||||||
|
} finally {
|
||||||
|
rejectLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDialogClose = () => {
|
||||||
|
successDialogVisible.value = false
|
||||||
|
closePage()
|
||||||
|
}
|
||||||
|
|
||||||
|
const closePage = () => {
|
||||||
|
ElMessage({
|
||||||
|
message: '页面即将关闭',
|
||||||
|
type: 'info',
|
||||||
|
duration: 1000
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (window.self !== window.top) {
|
||||||
|
try {
|
||||||
|
window.parent.postMessage({
|
||||||
|
type: 'closeApprovePage',
|
||||||
|
code: route.query.code,
|
||||||
|
action: 'closed'
|
||||||
|
}, '*')
|
||||||
|
} catch (e) {
|
||||||
|
console.log('postMessage失败:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.opener && !window.opener.closed) {
|
||||||
|
window.close()
|
||||||
|
} else {
|
||||||
|
router.push('/').catch(() => {
|
||||||
|
window.location.href = '/'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, 1500)
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatDate = (dateStr: string) => {
|
||||||
|
if (!dateStr) return '--'
|
||||||
|
try {
|
||||||
|
return dayjs(dateStr).format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
} catch (e) {
|
||||||
|
return dateStr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听路由参数
|
||||||
|
watch(() => route.query.code, (newCode) => {
|
||||||
|
if (newCode) {
|
||||||
|
getData(newCode as string)
|
||||||
|
}
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (route.query.code) {
|
||||||
|
getData(route.query.code as string)
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.approve-container {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 20px auto;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: 100px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
border-bottom: 1px solid #ebeef5;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header h1 {
|
||||||
|
margin: 0 0 10px 0;
|
||||||
|
font-size: 24px;
|
||||||
|
color: #303133;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-tag {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-tag .el-tag {
|
||||||
|
font-size: 16px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-card,
|
||||||
|
.role-card,
|
||||||
|
.remark-card,
|
||||||
|
.no-role-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header .el-icon {
|
||||||
|
color: #909399;
|
||||||
|
cursor: help;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selection-count {
|
||||||
|
color: #409eff;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-selection-note {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-role-content {
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
color: #e6a23c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-role-content p {
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.remark-section {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding-top: 20px;
|
||||||
|
border-top: 1px solid #ebeef5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.remark-section h4 {
|
||||||
|
margin: 0 0 10px 0;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
.remark-content {
|
||||||
|
padding: 12px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-option {
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-option:hover {
|
||||||
|
border-color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-option.selected {
|
||||||
|
border-color: #409eff;
|
||||||
|
background-color: #f0f7ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-content {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-checkbox {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-info {
|
||||||
|
margin-left: 10px;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-name {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #303133;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-desc {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
line-height: 1.4;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selection-tips {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 15px;
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-roles-list {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-role-tag {
|
||||||
|
padding: 4px 10px;
|
||||||
|
background-color: #409eff;
|
||||||
|
color: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selection-action {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-selection-tips {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tip-text {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 30px;
|
||||||
|
padding-top: 30px;
|
||||||
|
border-top: 1px solid #ebeef5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons .el-button {
|
||||||
|
width: 120px;
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audited-info {
|
||||||
|
text-align: center;
|
||||||
|
padding: 40px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audit-detail {
|
||||||
|
margin: 20px 0 30px 0;
|
||||||
|
text-align: left;
|
||||||
|
max-width: 600px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audit-detail p {
|
||||||
|
margin: 10px 0;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-tag {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 2px 5px;
|
||||||
|
padding: 2px 8px;
|
||||||
|
background-color: #f0f9eb;
|
||||||
|
color: #67c23a;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reject-dialog-content {
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reject-alert {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-roles {
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-roles-list {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 12px;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid #ebeef5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-value {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #606266;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.approve-container {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header {
|
||||||
|
flex-direction: column;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-header .status-tag {
|
||||||
|
position: static;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons .el-button {
|
||||||
|
width: 100%;
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -123,11 +123,22 @@ const handleSubmit = async () => {
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const res = await joinStore(form)
|
const res:any = await joinStore(form)
|
||||||
authLink.value = res.data // Assuming API returns the link in data
|
const baseURL = window.location.origin
|
||||||
|
if (res && res.code === 200) {
|
||||||
|
const joinToken = res.data && res.data.joinToken
|
||||||
|
if (joinToken) {
|
||||||
|
authLink.value = `${baseURL}/auth/approve?type=store&code=${joinToken}`
|
||||||
ElMessage.success('生成链接成功')
|
ElMessage.success('生成链接成功')
|
||||||
|
} else {
|
||||||
|
ElMessage.error('未返回有效的链接数据')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res?.message || '生成链接失败')
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
ElMessage.error('生成链接失败')
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,11 +125,10 @@ const handleSubmit = async () => {
|
|||||||
try {
|
try {
|
||||||
const res: any = await joinWarehouse(form)
|
const res: any = await joinWarehouse(form)
|
||||||
const baseUrl = window.location.origin
|
const baseUrl = window.location.origin
|
||||||
// 与 vue2 保持一致:仅当后端返回 code === 200 时认为生成成功
|
|
||||||
if (res && res.code === 200) {
|
if (res && res.code === 200) {
|
||||||
const joinToken = res.data && res.data.joinToken
|
const joinToken = res.data && res.data.joinToken
|
||||||
if (joinToken) {
|
if (joinToken) {
|
||||||
authLink.value = `${baseUrl}/#/auth/approve?type=store&code=${joinToken}`
|
authLink.value = `${baseUrl}/auth/approve?type=store&code=${joinToken}`
|
||||||
ElMessage.success('生成链接成功')
|
ElMessage.success('生成链接成功')
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error('未返回有效的 joinToken')
|
ElMessage.error('未返回有效的 joinToken')
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="stock-log-container">
|
<div class="log-container">
|
||||||
<el-button-group class="toolbar-btn-group">
|
<el-button-group class="toolbar-btn-group">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@ -191,7 +191,7 @@ function backData(row: any) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.stock-log-container {
|
.log-container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="storage-container">
|
<div class="container">
|
||||||
<el-button-group class="toolbar-btn-group">
|
<el-button-group class="toolbar-btn-group">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@ -99,7 +99,7 @@ function handleClick(row: any) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.storage-container {
|
.container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@ -119,14 +119,14 @@
|
|||||||
@selection-change="selectionChange"
|
@selection-change="selectionChange"
|
||||||
>
|
>
|
||||||
<!-- 自定义状态列 -->
|
<!-- 自定义状态列 -->
|
||||||
<template #column-status="{ row }">
|
<!-- <template #column-status="{ row }">
|
||||||
<el-tag :type="row.status === 'enabled' ? 'success' : 'danger'" size="small">
|
<el-tag :type="row.status === 'enabled' ? 'success' : 'danger'" size="small">
|
||||||
{{ row.status === 'enabled' ? '启用' : '禁用' }}
|
{{ row.status === 'enabled' ? '启用' : '禁用' }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template> -->
|
||||||
|
|
||||||
<!-- 自定义列模板 -->
|
<!-- 自定义列模板 -->
|
||||||
<template #column-is_sn_mgmt="{ row }">
|
<!-- <template #column-is_sn_mgmt="{ row }">
|
||||||
<el-tag :type="row.is_sn_mgmt === 'Y' ? 'success' : 'info'" size="small">
|
<el-tag :type="row.is_sn_mgmt === 'Y' ? 'success' : 'info'" size="small">
|
||||||
{{ row.is_sn_mgmt === 'Y' ? '是' : '否' }}
|
{{ row.is_sn_mgmt === 'Y' ? '是' : '否' }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
@ -140,7 +140,7 @@
|
|||||||
<el-tag :type="row.is_batch_mgmt === 'Y' ? 'success' : 'info'" size="small">
|
<el-tag :type="row.is_batch_mgmt === 'Y' ? 'success' : 'info'" size="small">
|
||||||
{{ row.is_batch_mgmt === 'Y' ? '是' : '否' }}
|
{{ row.is_batch_mgmt === 'Y' ? '是' : '否' }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template> -->
|
||||||
|
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<div class="custom-empty">
|
<div class="custom-empty">
|
||||||
@ -224,12 +224,13 @@ import Recycle from './component/recycle.vue'
|
|||||||
|
|
||||||
// API
|
// API
|
||||||
import * as stockApi from '@/api/stock'
|
import * as stockApi from '@/api/stock'
|
||||||
import * as indexApi from '@/api/index'
|
import * as indexApi from '@/api/index.ts'
|
||||||
// Store
|
// Store
|
||||||
import { useUserStore } from '@/stores/modules/user'
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { parseTime } from '@/utils/index'
|
import { parseTime } from '@/utils/index'
|
||||||
|
import { labelInner } from 'echarts/types/src/label/labelStyle.js'
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const hasPermission = (perm: string) => {
|
const hasPermission = (perm: string) => {
|
||||||
@ -336,13 +337,13 @@ const accountColumns = [
|
|||||||
showOverflowTooltip: true,
|
showOverflowTooltip: true,
|
||||||
sortable: true
|
sortable: true
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
prop: 'status',
|
// prop: 'status',
|
||||||
label: '状态',
|
// label: '状态',
|
||||||
width: '80',
|
// width: '80',
|
||||||
align: 'center',
|
// align: 'center',
|
||||||
slotName: 'status'
|
// slotName: 'status'
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
prop: 'store_remask',
|
prop: 'store_remask',
|
||||||
label: '货主',
|
label: '货主',
|
||||||
@ -431,6 +432,13 @@ const accountColumns = [
|
|||||||
return formatNumber(available, 0)
|
return formatNumber(available, 0)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
prop: 'lock_rate_display',
|
||||||
|
label: '锁定率',
|
||||||
|
width: '100',
|
||||||
|
align: 'right',
|
||||||
|
formatter: (row: any) => row.lock_rate_display || '--'
|
||||||
|
},
|
||||||
// Units
|
// Units
|
||||||
{
|
{
|
||||||
prop: 'stock_unit',
|
prop: 'stock_unit',
|
||||||
@ -896,7 +904,7 @@ const handleTabChange = () => {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// Load stores, prohibited types etc.
|
// Load stores, prohibited types etc.
|
||||||
try {
|
try {
|
||||||
const res = await indexApi.loadStores()
|
const res = await indexApi.loadStores({ type: 'stock' })
|
||||||
if (res && (res as any).stores) {
|
if (res && (res as any).stores) {
|
||||||
(availableFields[0] as any).options = (res as any).stores
|
(availableFields[0] as any).options = (res as any).stores
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="receiving-details">
|
<div class="receiving-details">
|
||||||
<el-form-item label="收货单号" prop="receiving_number">
|
<el-form-item label="收货单号" prop="receiving_number">
|
||||||
|
|||||||
@ -3,61 +3,33 @@
|
|||||||
<div class="left-col">
|
<div class="left-col">
|
||||||
<div class="col-left">
|
<div class="col-left">
|
||||||
<el-form :model="form" label-width="120px" >
|
<el-form :model="form" label-width="120px" >
|
||||||
<el-form-item label="收货单号" prop="receiving_number">
|
<el-form-item
|
||||||
<el-input v-model="form.receiving_number" disabled />
|
v-for="field in detailpanel"
|
||||||
</el-form-item>
|
:key="field.prop"
|
||||||
<el-form-item label="收货状态" prop="status">
|
:label="field.label"
|
||||||
<el-select placeholder="请选择收货状态" v-model="form.status">
|
:prop="field.prop"
|
||||||
|
>
|
||||||
|
<template v-if="field.type === 'select'">
|
||||||
|
<el-select
|
||||||
|
v-model="(form as any)[field.prop]"
|
||||||
|
:placeholder="'请选择' + field.label"
|
||||||
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(cfg, key) in statusConfig"
|
v-for="item in availableFields.find(f => f.value === field.prop)?.options || []"
|
||||||
:key="key"
|
:key="item.value"
|
||||||
:label="cfg.text"
|
:label="item.label"
|
||||||
:value="key"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</template>
|
||||||
|
<template v-else>
|
||||||
<el-form-item label="货主" prop="store_name">
|
<el-input
|
||||||
<el-input v-model="form.store_name" disabled />
|
v-model="(form as any)[field.prop]"
|
||||||
</el-form-item>
|
:disabled="field.disabled"
|
||||||
|
:placeholder="'请输入' + field.label"
|
||||||
<el-form-item label="创建人" prop="creator_name">
|
|
||||||
<el-input v-model="form.creator_name" disabled></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="匹配状态" prop="detail_status">
|
|
||||||
<el-select placeholder="请选择匹配状态" v-model="form.detail_status">
|
|
||||||
<el-option
|
|
||||||
v-for="(cfg, key) in detailStatusConfig"
|
|
||||||
:key="key"
|
|
||||||
:label="cfg.text"
|
|
||||||
:value="key"
|
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</template>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="来货方式" prop="delivery_method">
|
|
||||||
<el-select placeholder="请选择来货方式" v-model="form.delivery_method">
|
|
||||||
<el-option
|
|
||||||
v-for="(cfg, key) in deliveryMethodConfig"
|
|
||||||
:key="key"
|
|
||||||
:label="cfg.text"
|
|
||||||
:value="key"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="装卸方式" prop="loading_method">
|
|
||||||
<el-select placeholder="请选择装卸方式" v-model="form.loading_method">
|
|
||||||
<el-option
|
|
||||||
v-for="(cfg, key) in loadingMethodConfig"
|
|
||||||
:key="key"
|
|
||||||
:label="cfg.text"
|
|
||||||
:value="key"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-right"></div>
|
<div class="col-right"></div>
|
||||||
@ -76,12 +48,14 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { statusConfig, detailStatusConfig, storageStatusConfig, deliveryMethodConfig, loadingMethodConfig } from '../receiving-config'
|
import { availableFields, detailpanel } from '../receiving-config'
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
const props = defineProps<{ id: string | number }>()
|
const props = defineProps<{
|
||||||
|
id: string | number,
|
||||||
|
row?: any
|
||||||
|
}>()
|
||||||
|
|
||||||
const data = ref<any>({})
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
receiving_number: '',
|
receiving_number: '',
|
||||||
store_name: '',
|
store_name: '',
|
||||||
@ -90,21 +64,13 @@ const form = ref({
|
|||||||
delivery_method: '',
|
delivery_method: '',
|
||||||
status: '',
|
status: '',
|
||||||
loading_method: '',
|
loading_method: '',
|
||||||
|
total_items: 0,
|
||||||
|
total_quantity: 0,
|
||||||
|
total_boxes: 0,
|
||||||
|
total_pallets: 0,
|
||||||
|
remark: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
// 模拟数据,用于本文件展示
|
|
||||||
const mockData = {
|
|
||||||
receiving_number: 'RCV-20260313-001',
|
|
||||||
store_name: '示例货主',
|
|
||||||
detail_status: '',
|
|
||||||
creator_name: '张三',
|
|
||||||
delivery_method: '',
|
|
||||||
status: '',
|
|
||||||
loading_method:'',
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const saveLoading = ref(false)
|
const saveLoading = ref(false)
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
@ -120,11 +86,18 @@ const handleSave = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听 row 变化,更新表单数据
|
||||||
|
import { watch } from 'vue'
|
||||||
|
watch(() => props.row, (newRow) => {
|
||||||
|
if (newRow) {
|
||||||
|
form.value = { ...newRow }
|
||||||
|
}
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
data.value = mockData
|
if (props.row) {
|
||||||
form.value = { ...mockData }
|
form.value = { ...props.row }
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -154,7 +127,7 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
.col-right {
|
.col-right {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
background: #7a2828;
|
background: #000000d8;
|
||||||
padding-right: 12px;
|
padding-right: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,180 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="receiving-logs">
|
<div class="log-container">
|
||||||
<p>操作日志组件 - ID: {{ id }}</p>
|
<el-button-group class="toolbar-btn-group">
|
||||||
<!-- TODO: 迁移并实现操作日志 -->
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
icon="Refresh"
|
||||||
|
@click="fetchStockInfo"
|
||||||
|
title="刷新"
|
||||||
|
:loading="loading"
|
||||||
|
class="toolbar-btn"
|
||||||
|
>
|
||||||
|
刷新
|
||||||
|
</el-button>
|
||||||
|
</el-button-group>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
:data="tableData"
|
||||||
|
border
|
||||||
|
stripe
|
||||||
|
style="width: 100%"
|
||||||
|
:height="tableHeight"
|
||||||
|
v-loading="loading"
|
||||||
|
>
|
||||||
|
<el-table-column prop="created_at" label="时间" width="250" />
|
||||||
|
<el-table-column prop="operator_name" label="操作人" width="120" />
|
||||||
|
<el-table-column prop="operation_name" label="操作名称" />
|
||||||
|
<el-table-column prop="platform_name" label="操作平台" />
|
||||||
|
|
||||||
|
<el-table-column label="操作" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
@click="viewData(scope.row)"
|
||||||
|
type="primary"
|
||||||
|
link
|
||||||
|
size="small"
|
||||||
|
v-if="scope.row.external_log_id"
|
||||||
|
>
|
||||||
|
查看报文
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
@click="backData(scope.row)"
|
||||||
|
type="primary"
|
||||||
|
link
|
||||||
|
size="small"
|
||||||
|
v-if="scope.row.operation_code === 'UPDATE'"
|
||||||
|
>
|
||||||
|
修改前快照
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<div class="pagination-container">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="pagination.page"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
:total="pagination.total"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
background
|
||||||
|
@size-change="handlePageSizeChange"
|
||||||
|
@current-change="handlePageChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-drawer
|
||||||
|
v-model="showRequestData"
|
||||||
|
direction="rtl"
|
||||||
|
:with-header="false"
|
||||||
|
size="800px"
|
||||||
|
class="el-drawers"
|
||||||
|
>
|
||||||
|
<RequestData
|
||||||
|
v-if="showRequestData"
|
||||||
|
:id="requestId"
|
||||||
|
:type="requestType"
|
||||||
|
/>
|
||||||
|
</el-drawer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const props = defineProps<{ id: string | number }>()
|
import { ref, reactive, watch, onMounted, computed } from 'vue'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { Refresh } from '@element-plus/icons-vue'
|
||||||
|
import * as stockApi from '@/api/stock'
|
||||||
|
import RequestData from '@/components/RequestData/index.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
id?: number
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const tableData = ref<any[]>([])
|
||||||
|
const showRequestData = ref(false)
|
||||||
|
const requestId = ref(0)
|
||||||
|
const requestType = ref('')
|
||||||
|
|
||||||
|
const pagination = reactive({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
total: 0
|
||||||
|
})
|
||||||
|
|
||||||
|
const tableHeight = computed(() => {
|
||||||
|
return window.innerHeight - 300 // 根据实际情况调整
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => props.id, (newVal) => {
|
||||||
|
if (newVal) {
|
||||||
|
fetchStockInfo()
|
||||||
|
} else {
|
||||||
|
tableData.value = []
|
||||||
|
pagination.total = 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.id) {
|
||||||
|
fetchStockInfo()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
async function handlePageChange(page: number) {
|
||||||
|
pagination.page = page
|
||||||
|
await fetchStockInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handlePageSizeChange(pageSize: number) {
|
||||||
|
pagination.pageSize = pageSize
|
||||||
|
pagination.page = 1
|
||||||
|
await fetchStockInfo()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchStockInfo() {
|
||||||
|
if (!props.id) return
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function viewData(row: any) {
|
||||||
|
requestId.value = row.external_log_id
|
||||||
|
requestType.value = row.external_log_type
|
||||||
|
showRequestData.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function backData(row: any) {
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
.receiving-logs { padding: 12px }
|
.log-container {
|
||||||
|
height: 100%;
|
||||||
|
padding: 10px 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-btn-group {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-table {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-drawer__body) {
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
573
src/views/storage/receiving/component/Product.vue
Normal file
573
src/views/storage/receiving/component/Product.vue
Normal file
@ -0,0 +1,573 @@
|
|||||||
|
<template>
|
||||||
|
<div class="product-details">
|
||||||
|
<div class="header-actions">
|
||||||
|
<div class="left-actions">
|
||||||
|
<el-button type="primary">批量操作</el-button>
|
||||||
|
<el-button>导出</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="right-actions">
|
||||||
|
<!-- 可以在这里添加搜索框或其他操作 -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="left-col">
|
||||||
|
<UpperTable
|
||||||
|
:data="tableData"
|
||||||
|
:columns="productquick"
|
||||||
|
:show-selection="true"
|
||||||
|
:pagination="pagination"
|
||||||
|
:query-time="queryTime"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
@page-size-change="handlePageSizeChange"
|
||||||
|
@page-change="handlePageChange"
|
||||||
|
@row-contextmenu="handleContextMenu"
|
||||||
|
>
|
||||||
|
<template #column-images="{ row }">
|
||||||
|
<div class="image-slot">
|
||||||
|
<el-image
|
||||||
|
v-if="row.images"
|
||||||
|
style="width: 40px; height: 40px"
|
||||||
|
:src="row.images"
|
||||||
|
:preview-src-list="[row.images]"
|
||||||
|
fit="cover"
|
||||||
|
/>
|
||||||
|
<span v-else>--</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</UpperTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 右键菜单 -->
|
||||||
|
<div v-if="menuVisible" :style="{ top: menuTop + 'px', left: menuLeft + 'px' }" class="context-menu">
|
||||||
|
<div class="menu-item" @click="handleProductDetail">货品详情</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 货品详情弹窗 -->
|
||||||
|
<div v-if="windowVisible" class="product-window" :class="{ 'is-fullscreen': isFullscreen }" :style="windowStyle">
|
||||||
|
<div class="window-header" @mousedown="startDrag">
|
||||||
|
<span class="window-title">货品详情 - {{ currentRow?.item_name }}</span>
|
||||||
|
<div class="window-actions">
|
||||||
|
<el-button link :icon="isFullscreen ? CopyDocument : FullScreen" @click="toggleFullscreen" :title="isFullscreen ? '还原' : '最大化'" />
|
||||||
|
<el-button link :icon="Close" @click="windowVisible = false" title="关闭" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="window-body">
|
||||||
|
<div class="window-body-top">
|
||||||
|
<div
|
||||||
|
v-for="tab in windowtopbar"
|
||||||
|
:key="tab.key"
|
||||||
|
class="window-tab-item"
|
||||||
|
:class="{ active: activeWindowTab === tab.key }"
|
||||||
|
@click="activeWindowTab = tab.key"
|
||||||
|
>
|
||||||
|
{{ tab.label }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="window-body-middle">
|
||||||
|
<KeepAlive>
|
||||||
|
<component
|
||||||
|
:is="currentWindowComponent"
|
||||||
|
:row="currentRow"
|
||||||
|
ref="basicRef"
|
||||||
|
/>
|
||||||
|
</KeepAlive>
|
||||||
|
</div>
|
||||||
|
<div class="window-body-bottom">
|
||||||
|
<el-button @click="resetForm">重置</el-button>
|
||||||
|
<el-button type="primary" @click="saveProductDetail">保存</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <aside class="right-col">
|
||||||
|
<div class="right-panel">
|
||||||
|
<div class="panel-actions">
|
||||||
|
<el-button>重置</el-button>
|
||||||
|
<el-button type="primary" @click="handleSave" :loading="saveLoading">
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aside> -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted, onUnmounted, computed, reactive } from 'vue'
|
||||||
|
import { productdetail,productquick,productsnapshop,windowtopbar } from '../receiving-config'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { FullScreen, Close, CopyDocument } from '@element-plus/icons-vue'
|
||||||
|
import UpperTable from '@/components/UpperTable/index.vue'
|
||||||
|
|
||||||
|
import basic from '../window/basic.vue'
|
||||||
|
import log from '../window/log.vue'
|
||||||
|
import product from '../window/product.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{ id?: string | number }>()
|
||||||
|
|
||||||
|
const tableData = ref<any[]>([])
|
||||||
|
const multipleSelection = ref<any[]>([])
|
||||||
|
const saveLoading = ref(false)
|
||||||
|
|
||||||
|
// 分页相关
|
||||||
|
const pagination = reactive({
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
total: 0
|
||||||
|
})
|
||||||
|
|
||||||
|
const queryTime = ref(0)
|
||||||
|
|
||||||
|
const handlePageSizeChange = (val: number) => {
|
||||||
|
pagination.pageSize = val
|
||||||
|
// 这里可以重新请求接口获取数据
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePageChange = (val: number) => {
|
||||||
|
pagination.currentPage = val
|
||||||
|
// 这里可以重新请求接口获取数据
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRowClick = (row: any) => {
|
||||||
|
currentRow.value = row
|
||||||
|
}
|
||||||
|
|
||||||
|
// 标签页相关
|
||||||
|
const activeWindowTab = ref('basic')
|
||||||
|
const windowComponentMap: Record<string, any> = {
|
||||||
|
basic: basic,
|
||||||
|
// product: product,
|
||||||
|
logs: log
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentWindowComponent = computed(() => windowComponentMap[activeWindowTab.value])
|
||||||
|
|
||||||
|
const basicRef = ref<any>(null)
|
||||||
|
|
||||||
|
// 右键菜单相关
|
||||||
|
const menuVisible = ref(false)
|
||||||
|
const menuTop = ref(0)
|
||||||
|
const menuLeft = ref(0)
|
||||||
|
const currentRow = ref<any>(null)
|
||||||
|
|
||||||
|
// 窗口控制
|
||||||
|
const windowVisible = ref(false)
|
||||||
|
const isFullscreen = ref(false)
|
||||||
|
const position = ref({ x: 350, y: 250 })
|
||||||
|
const isDragging = ref(false)
|
||||||
|
const dragOffset = ref({ x: 0, y: 0 })
|
||||||
|
|
||||||
|
const windowStyle = computed(() => {
|
||||||
|
if (isFullscreen.value) return {}
|
||||||
|
return {
|
||||||
|
top: `${position.value.y}px`,
|
||||||
|
left: `${position.value.x}px`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleSelectionChange = (val: any[]) => {
|
||||||
|
multipleSelection.value = val
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleContextMenu = (row: any, column: any, event: MouseEvent) => {
|
||||||
|
event.preventDefault()
|
||||||
|
currentRow.value = row
|
||||||
|
menuTop.value = event.clientY
|
||||||
|
menuLeft.value = event.clientX
|
||||||
|
menuVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeMenu = () => {
|
||||||
|
menuVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleProductDetail = () => {
|
||||||
|
if (currentRow.value) {
|
||||||
|
windowVisible.value = true
|
||||||
|
// 重置位置或保持原位
|
||||||
|
position.value = { x: 350, y: 250 }
|
||||||
|
isFullscreen.value = false
|
||||||
|
}
|
||||||
|
closeMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleFullscreen = () => {
|
||||||
|
isFullscreen.value = !isFullscreen.value
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拖拽逻辑
|
||||||
|
const startDrag = (e: MouseEvent) => {
|
||||||
|
if (isFullscreen.value) return
|
||||||
|
isDragging.value = true
|
||||||
|
dragOffset.value = {
|
||||||
|
x: e.clientX - position.value.x,
|
||||||
|
y: e.clientY - position.value.y
|
||||||
|
}
|
||||||
|
window.addEventListener('mousemove', onDrag)
|
||||||
|
window.addEventListener('mouseup', stopDrag)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onDrag = (e: MouseEvent) => {
|
||||||
|
if (!isDragging.value) return
|
||||||
|
position.value = {
|
||||||
|
x: Math.max(0, e.clientX - dragOffset.value.x),
|
||||||
|
y: Math.max(0, e.clientY - dragOffset.value.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopDrag = () => {
|
||||||
|
isDragging.value = false
|
||||||
|
window.removeEventListener('mousemove', onDrag)
|
||||||
|
window.removeEventListener('mouseup', stopDrag)
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
if (activeWindowTab.value === 'basic' && basicRef.value) {
|
||||||
|
basicRef.value.reset?.()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveProductDetail = async () => {
|
||||||
|
if (activeWindowTab.value === 'basic' && basicRef.value) {
|
||||||
|
const updatedData = basicRef.value.getFormData?.()
|
||||||
|
if (updatedData) {
|
||||||
|
// 模拟本地修改 tableData
|
||||||
|
const index = tableData.value.findIndex(item => item.id === updatedData.id)
|
||||||
|
if (index !== -1) {
|
||||||
|
tableData.value[index] = { ...updatedData }
|
||||||
|
ElMessage.success('本地模拟修改成功')
|
||||||
|
windowVisible.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模拟数据
|
||||||
|
const mockProductData = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
receiving_number: 'RCV202601180001',
|
||||||
|
item_name: '商品A - 测试商品',
|
||||||
|
barcodes: '6901234567890',
|
||||||
|
product_snapshot: '{"id": null, "name": "商品A - 测试商品", "barcode": "6901234567890", "spec": "500g/袋"}',
|
||||||
|
system_product_id: null,
|
||||||
|
actual_quantity: 20,
|
||||||
|
box_quantity: 2,
|
||||||
|
boxes_per_pallet: 10,
|
||||||
|
pallet_quantity: 0,
|
||||||
|
receiving_time: '2026-01-18 22:43:42',
|
||||||
|
receiving_status_display: '已完成',
|
||||||
|
storage_status: '未入库',
|
||||||
|
stored_quantity: 0,
|
||||||
|
batch_number: 'BATCH20231215A',
|
||||||
|
production_date: '2023-12-01',
|
||||||
|
expiry_date: '2024-12-01',
|
||||||
|
remark: '商品A测试明细 - 未匹配',
|
||||||
|
box_length: 40,
|
||||||
|
box_width: 30,
|
||||||
|
box_height: 25,
|
||||||
|
weight: 10.5,
|
||||||
|
space_id: 'A-01-01',
|
||||||
|
creator_id: 'EMP001',
|
||||||
|
updated_at_display: '2026-01-18 22:43:42',
|
||||||
|
created_at_display: '2026-01-18 22:43:42'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
receiving_number: 'RCV202601180001',
|
||||||
|
item_name: '商品B - 进口商品',
|
||||||
|
barcodes: '8801234567890',
|
||||||
|
product_snapshot: '{"id": null, "name": "商品B - 进口商品", "barcode": "8801234567890", "origin": "日本", "spec": "1kg/盒"}',
|
||||||
|
system_product_id: null,
|
||||||
|
actual_quantity: 15,
|
||||||
|
box_quantity: 1,
|
||||||
|
boxes_per_pallet: 15,
|
||||||
|
pallet_quantity: 1,
|
||||||
|
receiving_time: '2026-01-18 22:43:42',
|
||||||
|
receiving_status_display: '已完成',
|
||||||
|
storage_status: '未入库',
|
||||||
|
stored_quantity: 0,
|
||||||
|
batch_number: 'BATCH20231215B',
|
||||||
|
production_date: '2023-11-15',
|
||||||
|
expiry_date: '2024-11-15',
|
||||||
|
remark: '商品B测试明细 - 未匹配',
|
||||||
|
box_length: 50,
|
||||||
|
box_width: 40,
|
||||||
|
box_height: 30,
|
||||||
|
weight: 15.0,
|
||||||
|
space_id: 'B-02-05',
|
||||||
|
creator_id: 'EMP001',
|
||||||
|
updated_at_display: '2026-01-18 22:43:42',
|
||||||
|
created_at_display: '2026-01-18 22:43:42'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
receiving_number: 'RCV202601180001',
|
||||||
|
item_name: '商品C - 电子商品',
|
||||||
|
barcodes: '4901234567890',
|
||||||
|
product_snapshot: '{"id": null, "name": "商品C - 电子商品", "barcode": "4901234567890", "brand": "索尼", "model": "X-100"}',
|
||||||
|
system_product_id: 152656,
|
||||||
|
actual_quantity: 15,
|
||||||
|
box_quantity: 2,
|
||||||
|
boxes_per_pallet: 8,
|
||||||
|
pallet_quantity: 1,
|
||||||
|
receiving_time: '2026-01-18 21:43:42',
|
||||||
|
receiving_status_display: '已完成',
|
||||||
|
storage_status: '部分入库',
|
||||||
|
stored_quantity: 5,
|
||||||
|
batch_number: 'BATCH20231215C',
|
||||||
|
production_date: '2023-10-01',
|
||||||
|
expiry_date: '2025-10-01',
|
||||||
|
remark: '商品C测试明细 - 未匹配',
|
||||||
|
box_length: 30,
|
||||||
|
box_width: 20,
|
||||||
|
box_height: 15,
|
||||||
|
weight: 5.2,
|
||||||
|
space_id: 'C-01-12',
|
||||||
|
creator_id: 'EMP001',
|
||||||
|
updated_at_display: '2026-01-18 22:43:42',
|
||||||
|
created_at_display: '2026-01-18 22:43:42'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 48,
|
||||||
|
receiving_number: 'RCV2026020100002',
|
||||||
|
item_name: 'MOODAMOR绮梦茉莉香型香水',
|
||||||
|
barcodes: '6942233906190',
|
||||||
|
product_snapshot: '{"store_id":1000166,"store_name":"花颜物语","updated_at":"2026-02-02T08:37:06.691Z"}',
|
||||||
|
system_product_id: null,
|
||||||
|
actual_quantity: 1000,
|
||||||
|
box_quantity: 10,
|
||||||
|
boxes_per_pallet: 100,
|
||||||
|
pallet_quantity: 20,
|
||||||
|
receiving_time: '2026-02-02 07:10:26',
|
||||||
|
receiving_status_display: '收货中',
|
||||||
|
storage_status: '未入库',
|
||||||
|
stored_quantity: 0,
|
||||||
|
batch_number: '20260202',
|
||||||
|
production_date: '2025-12-01',
|
||||||
|
expiry_date: '2028-12-01',
|
||||||
|
remark: '1561534',
|
||||||
|
box_length: 45,
|
||||||
|
box_width: 35,
|
||||||
|
box_height: 30,
|
||||||
|
weight: 12.8,
|
||||||
|
space_id: 'D-05-01',
|
||||||
|
creator_id: 'EMP030',
|
||||||
|
updated_at_display: '2026-02-02 13:24:43',
|
||||||
|
created_at_display: '2026-02-02 07:10:26'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
try {
|
||||||
|
saveLoading.value = true
|
||||||
|
// 模拟保存逻辑
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 500))
|
||||||
|
ElMessage.success('保存成功')
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('保存失败')
|
||||||
|
} finally {
|
||||||
|
saveLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
tableData.value = [...mockProductData]
|
||||||
|
pagination.total = mockProductData.length
|
||||||
|
window.addEventListener('click', closeMenu)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('click', closeMenu)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.product-details {
|
||||||
|
padding: 12px;
|
||||||
|
/* display: grid; */
|
||||||
|
grid-template-columns: 1fr 320px;
|
||||||
|
grid-template-rows: auto 1fr;
|
||||||
|
gap: 12px 16px;
|
||||||
|
align-items: start;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #fff;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-window {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 2000;
|
||||||
|
width: 1250px;
|
||||||
|
height: 650px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #ebeef5;
|
||||||
|
box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 4px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-window.is-fullscreen {
|
||||||
|
top: 0 !important;
|
||||||
|
left: 0 !important;
|
||||||
|
width: 100vw !important;
|
||||||
|
height: 100vh !important;
|
||||||
|
border-radius: 0;
|
||||||
|
z-index: 3000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-header {
|
||||||
|
padding: 8px 12px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-bottom: 1px solid #ebeef5;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
cursor: move;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-title {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-body {
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.window-body-top {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: flex-start;
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
width: 100%;
|
||||||
|
height: 35px;
|
||||||
|
border-bottom: 1px solid #ebeef5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-tab-item {
|
||||||
|
padding: 0 20px;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #606266;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
border-right: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-tab-item:hover {
|
||||||
|
color: #409eff;
|
||||||
|
background-color: #ecf5ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-tab-item.active {
|
||||||
|
color: #409eff;
|
||||||
|
background-color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
border-right: 1px solid #ebeef5;
|
||||||
|
border-left: 1px solid #ebeef5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-tab-item.active:first-child {
|
||||||
|
border-left: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-body-middle {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 15px;
|
||||||
|
/* background-color: yellow; */
|
||||||
|
}
|
||||||
|
.window-body-bottom {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
width: 100%;
|
||||||
|
height: 35px;
|
||||||
|
background-color: antiquewhite;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.context-menu {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 3000;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #ebeef5;
|
||||||
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item {
|
||||||
|
padding: 8px 16px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #606266;
|
||||||
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item:hover {
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-actions {
|
||||||
|
grid-column: 1 / 3;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-col {
|
||||||
|
grid-column: 1 / 1;
|
||||||
|
grid-row: 2 / 3;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-col {
|
||||||
|
grid-column: 2 / 3;
|
||||||
|
grid-row: 2 / 3;
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-panel {
|
||||||
|
position: sticky;
|
||||||
|
top: 20px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 12px;
|
||||||
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-actions {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-slot {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,14 +1,118 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="receiving-storage">
|
<div class="container">
|
||||||
<p>入库记录组件 - ID: {{ id }}</p>
|
<el-button-group class="toolbar-btn-group">
|
||||||
<!-- TODO: 迁移并实现入库记录列表 -->
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
icon="Refresh"
|
||||||
|
@click="loadData"
|
||||||
|
title="刷新"
|
||||||
|
:loading="loading"
|
||||||
|
class="toolbar-btn"
|
||||||
|
>
|
||||||
|
刷新
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
size="small"
|
||||||
|
icon="Download"
|
||||||
|
@click="goToStorageLog"
|
||||||
|
title="库存流水"
|
||||||
|
class="toolbar-btn"
|
||||||
|
>
|
||||||
|
库存流水
|
||||||
|
</el-button>
|
||||||
|
</el-button-group>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
:data="tableData"
|
||||||
|
border
|
||||||
|
style="width: 100%"
|
||||||
|
:height="tableHeight"
|
||||||
|
v-loading="loading"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
fixed
|
||||||
|
prop="zone_name"
|
||||||
|
label="库区"
|
||||||
|
width="150"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="location_code"
|
||||||
|
label="库位"
|
||||||
|
width="120"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="quantity"
|
||||||
|
label="数量"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="batch_no"
|
||||||
|
label="批次"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="production_date"
|
||||||
|
label="生产日期"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="expiration_date"
|
||||||
|
label="过期日期"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="stock_type"
|
||||||
|
label="库存类型"
|
||||||
|
/>
|
||||||
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const props = defineProps<{ id: string | number }>()
|
import { ref, computed } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { Refresh, Download } from '@element-plus/icons-vue'
|
||||||
|
// import * as stockApi from '@/api/stock'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const loading = ref(false)
|
||||||
|
const tableData = ref<any[]>([])
|
||||||
|
|
||||||
|
const tableHeight = computed(() => {
|
||||||
|
return window.innerHeight - 300
|
||||||
|
})
|
||||||
|
|
||||||
|
function loadData() {
|
||||||
|
loading.value = true
|
||||||
|
// 暂无库存详情接口,保持与Vue2一致
|
||||||
|
setTimeout(() => {
|
||||||
|
loading.value = false
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToStorageLog() {
|
||||||
|
router.push('/storage/log')
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClick(row: any) {
|
||||||
|
console.log(row)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
.receiving-storage { padding: 12px }
|
.container {
|
||||||
|
height: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-btn-group {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-table {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -95,8 +95,9 @@
|
|||||||
|
|
||||||
<div class="lower-level" v-if="selectedReceivingId" :class="tableSize">
|
<div class="lower-level" v-if="selectedReceivingId" :class="tableSize">
|
||||||
<div class="detail-header">
|
<div class="detail-header">
|
||||||
<el-tabs v-model="activeTab" @tab-click="handlePageChange" class="detail-tab">
|
<el-tabs v-model="activeTab" class="detail-tab">
|
||||||
<el-tab-pane label="收货明细" name="details" />
|
<el-tab-pane label="收货明细" name="details" />
|
||||||
|
<el-tab-pane label="商品明细" name="product" />
|
||||||
<el-tab-pane label="入库记录" name="storage" />
|
<el-tab-pane label="入库记录" name="storage" />
|
||||||
<el-tab-pane label="操作日志" name="logs" />
|
<el-tab-pane label="操作日志" name="logs" />
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
@ -126,6 +127,7 @@ import UpperTable from '@/components/UpperTable/index.vue'
|
|||||||
import Details from './component/DetailsPanel.vue'
|
import Details from './component/DetailsPanel.vue'
|
||||||
import StorageComp from './component/Storage.vue'
|
import StorageComp from './component/Storage.vue'
|
||||||
import Logs from './component/Logs.vue'
|
import Logs from './component/Logs.vue'
|
||||||
|
import Product from './component/Product.vue'
|
||||||
import * as indexApi from '@/api/index'
|
import * as indexApi from '@/api/index'
|
||||||
import * as receivingApi from '@/api/storage/receiving'
|
import * as receivingApi from '@/api/storage/receiving'
|
||||||
import {
|
import {
|
||||||
@ -165,7 +167,8 @@ const quickSearch = ref('')
|
|||||||
const componentMap: Record<string, any> = {
|
const componentMap: Record<string, any> = {
|
||||||
details: Details,
|
details: Details,
|
||||||
storage: StorageComp,
|
storage: StorageComp,
|
||||||
logs: Logs
|
logs: Logs,
|
||||||
|
product: Product
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
||||||
@ -193,7 +196,7 @@ async function loadData() {
|
|||||||
}
|
}
|
||||||
const res: any = await receivingApi.getReceivingList(params)
|
const res: any = await receivingApi.getReceivingList(params)
|
||||||
if (res && res.code === 200) {
|
if (res && res.code === 200) {
|
||||||
//console.log('原始数据', res.data.list)
|
console.log('原始数据', res.data.list)
|
||||||
list.value = formatReceivingData(res.data.list || [])
|
list.value = formatReceivingData(res.data.list || [])
|
||||||
pagination.currentPage = res.data.pagination?.currentPage || pagination.currentPage
|
pagination.currentPage = res.data.pagination?.currentPage || pagination.currentPage
|
||||||
pagination.pageSize = res.data.pagination?.pageSize || pagination.pageSize
|
pagination.pageSize = res.data.pagination?.pageSize || pagination.pageSize
|
||||||
@ -212,7 +215,7 @@ async function loadData() {
|
|||||||
|
|
||||||
async function loadFilterData() {
|
async function loadFilterData() {
|
||||||
try {
|
try {
|
||||||
const [storesRes, presetRes]: any = await Promise.all([indexApi.loadStores(), indexApi.fastWhereTree('receiving')])
|
const [storesRes, presetRes]: any = await Promise.all([indexApi.loadStores({ type: 'receiving' }), indexApi.fastWhereTree('receiving')])
|
||||||
if (storesRes && storesRes.code === 200) {
|
if (storesRes && storesRes.code === 200) {
|
||||||
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||||||
if (f) f.options = storesRes.stores || []
|
if (f) f.options = storesRes.stores || []
|
||||||
@ -357,6 +360,13 @@ async function handleExport() {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
.toolbar-right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap:15px;
|
||||||
|
height: 30px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.upper-wrapper {
|
.upper-wrapper {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
@ -175,6 +175,87 @@ export const availableFields = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 详情面板表单配置
|
||||||
|
export const detailpanel = [
|
||||||
|
{ prop: 'receiving_number', label: '收货单号', type: 'input', disabled: true },
|
||||||
|
{ prop: 'store_name', label: '货主', type: 'input', disabled: true },
|
||||||
|
{ prop: 'creator_name', label: '创建人', type: 'input', disabled: true },
|
||||||
|
{ prop: 'status', label: '收货状态', type: 'select' },
|
||||||
|
{ prop: 'detail_status', label: '匹配状态', type: 'select' },
|
||||||
|
{ prop: 'storage_status', label: '入库状态', type: 'select' },
|
||||||
|
{ prop: 'delivery_method', label: '来货方式', type: 'select' },
|
||||||
|
{ prop: 'loading_method', label: '装卸方式', type: 'select' },
|
||||||
|
{ prop: 'total_items', label: '商品种类', type: 'number' },
|
||||||
|
{ prop: 'total_quantity', label: '总数量', type: 'number' },
|
||||||
|
{ prop: 'total_boxes', label: '总箱数', type: 'number' },
|
||||||
|
{ prop: 'total_pallets', label: '总托盘数', type: 'number' },
|
||||||
|
{ prop: 'remark', label: '备注', type: 'textarea' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const productsnapshop = [
|
||||||
|
{prop: 'id', label: '系统商品ID', width: '160', fixed: 'left' },
|
||||||
|
{ prop: 'name', label: '商品名称', width: '160' },
|
||||||
|
{ prop: 'barcode', label: '商品条码', width: '160' },
|
||||||
|
{ prop: 'spec', label: '规格型号', width: '160' },
|
||||||
|
{prop: 'origin', label: '产地', width: '160' },
|
||||||
|
{ prop: 'brand', label: '品牌', width: '160' },
|
||||||
|
{ prop: 'module', label: '所属模块', width: '160' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const productdetail = [
|
||||||
|
{ prop: 'receiving_number', label: '收货单号', width: '160', fixed: 'left' },
|
||||||
|
{ prop: 'item_name', label: '商品名称', width: '160', fixed: 'left' },
|
||||||
|
{ prop:'barcodes',label: '商品条码',width:'160' },
|
||||||
|
{ prop: 'product_snapshot', label: '商品信息快照', width: '160' },
|
||||||
|
{ prop: 'system_product_id', label: '关联系统商品ID', width: '160' },
|
||||||
|
{ prop:'actual_quantity',label: '实际收货数量',width:'160' },
|
||||||
|
{ prop: 'box_quantity', label: '箱数', width: '160' },
|
||||||
|
{ prop:'boxes_per_pallet',label: '箱规',width:'160' },
|
||||||
|
{ prop: 'pallet_quantity', label: '托盘数', width: '160' },
|
||||||
|
{ prop: 'receiving_time', label: '收货时间', width: '160' },
|
||||||
|
{ prop: 'receiving_status_display', label: '收货状态', width: '160' },
|
||||||
|
{ prop: 'storage_status', label: '入库状态', width: '160' },
|
||||||
|
{ prop: 'stored_quantity', label: '已入库数量', width: '160' },
|
||||||
|
{ prop: 'batch_number', label: '批次号', width: '160' },
|
||||||
|
{ prop: 'production_date', label: '生产日期', width: '160' },
|
||||||
|
{ prop: 'expiry_date', label: '保质期', width: '160' },
|
||||||
|
{ prop: 'remark', label: '备注', width: '160' },
|
||||||
|
{ prop: 'box_length', label: '箱长', width: '160' },
|
||||||
|
{ prop: 'box_width', label: '箱宽', width: '160' },
|
||||||
|
{ prop: 'box_height', label: '箱高', width: '160' },
|
||||||
|
{ prop: 'weight', label: '重量', width: '160' },
|
||||||
|
{ prop: 'space_id', label: '存放位置', width: '160' },
|
||||||
|
{ prop: 'creator_id', label: '创建人ID', width: '160' },
|
||||||
|
{ prop: 'updated_at_display', label: '更新时间', width: '160' },
|
||||||
|
{ prop: 'created_at_display', label: '创建时间', width: '160' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const productquick = [
|
||||||
|
{ prop: 'receiving_number', label: '收货单号', width: '160', fixed: 'left' },
|
||||||
|
{ prop: 'item_name', label: '商品名称', width: '160', fixed: 'left' },
|
||||||
|
{ prop:'actual_quantity',label: '实际收货数量',width:'160' },
|
||||||
|
{ prop: 'box_quantity', label: '箱数', width: '160' },
|
||||||
|
{ prop: 'storage_status', label: '入库状态', width: '160' },
|
||||||
|
{ prop: 'remark', label: '备注', width: '160' },
|
||||||
|
{ prop: 'box_length', label: '箱长', width: '160' },
|
||||||
|
{ prop: 'box_width', label: '箱宽', width: '160' },
|
||||||
|
{ prop: 'box_height', label: '箱高', width: '160' },
|
||||||
|
{ prop: 'space_id', label: '存放位置', width: '160' },
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const windowtopbar = [
|
||||||
|
{ label: '基本信息', key: 'basic' },
|
||||||
|
// { label: '商品信息', key: 'product' },
|
||||||
|
{ label: '操作日志', key: 'logs' }
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function formatReceivingData(list: any[] = []) {
|
export function formatReceivingData(list: any[] = []) {
|
||||||
return (list || []).map(item => ({
|
return (list || []).map(item => ({
|
||||||
...item,
|
...item,
|
||||||
|
|||||||
118
src/views/storage/receiving/window/basic.vue
Normal file
118
src/views/storage/receiving/window/basic.vue
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<template>
|
||||||
|
<div class="basic-info">
|
||||||
|
<el-form :model="formData" label-width="120px" disabled>
|
||||||
|
<div class="form-grid">
|
||||||
|
<template v-for="col in productdetail" :key="col.prop">
|
||||||
|
<el-form-item :label="col.label">
|
||||||
|
<!-- 图片字段 -->
|
||||||
|
<template v-if="col.prop === 'images'">
|
||||||
|
<div class="image-upload-wrapper">
|
||||||
|
<el-image
|
||||||
|
v-if="formData[col.prop]"
|
||||||
|
:src="formData[col.prop]"
|
||||||
|
class="preview-image"
|
||||||
|
fit="cover"
|
||||||
|
:preview-src-list="[formData[col.prop]]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 选择类型字段 -->
|
||||||
|
<el-select v-else-if="isSelectField(col.prop)" v-model="formData[col.prop]" placeholder=" ">
|
||||||
|
<el-option label="是" value="是" />
|
||||||
|
<el-option label="否" value="否" />
|
||||||
|
</el-select>
|
||||||
|
|
||||||
|
<!-- 数字类型字段 -->
|
||||||
|
<el-input-number
|
||||||
|
v-else-if="isNumberField(col.prop)"
|
||||||
|
v-model="formData[col.prop]"
|
||||||
|
controls-position="right"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 普通文本字段 -->
|
||||||
|
<el-input
|
||||||
|
v-else
|
||||||
|
v-model="formData[col.prop]"
|
||||||
|
placeholder=" "
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch, onMounted } from 'vue'
|
||||||
|
import { productdetail } from '../receiving-config'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
row?: any
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const formData = ref<any>({})
|
||||||
|
|
||||||
|
// 判断是否为选择类型字段
|
||||||
|
const isSelectField = (prop: string) => {
|
||||||
|
return ['is_sn_mgmt', 'is_shelf_life_mgmt', 'is_batch_mgmt', 'prohibited'].includes(prop)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断是否为数字类型字段
|
||||||
|
const isNumberField = (prop: string) => {
|
||||||
|
return ['gross_weight', 'net_weight', 'tag_price', 'retail_price', 'quantity', 'volume'].includes(prop)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听 row 变化进行赋值
|
||||||
|
watch(() => props.row, (newVal) => {
|
||||||
|
if (newVal) {
|
||||||
|
formData.value = { ...newVal }
|
||||||
|
}
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.row) {
|
||||||
|
formData.value = { ...props.row }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 暴露给父组件的方法
|
||||||
|
defineExpose({
|
||||||
|
getFormData: () => formData.value,
|
||||||
|
reset: () => {
|
||||||
|
if (props.row) {
|
||||||
|
formData.value = { ...props.row }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
.basic-info {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-upload-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-image {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid #dcdfe6;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-form-item) {
|
||||||
|
margin-bottom: 18px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
7
src/views/storage/receiving/window/log.vue
Normal file
7
src/views/storage/receiving/window/log.vue
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div class="">日志</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<style lang="css" scoped></style>
|
||||||
7
src/views/storage/receiving/window/product.vue
Normal file
7
src/views/storage/receiving/window/product.vue
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div class="">产品</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<style lang="css" scoped></style>
|
||||||
@ -73,13 +73,18 @@ const hasTemplate = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const handlePresetClick = async (data: any, node: any) => {
|
const handlePresetClick = async (data: any, node: any) => {
|
||||||
if (data.type === 'category') {
|
// 针对 RECEIPT 这种 businessType 节点,它可能既是 category 又包含 printItems,
|
||||||
|
// 且没有子节点(children 为空),这种情况下应该允许加载
|
||||||
|
if (data.type === 'category' && data.children && data.children.length > 0) {
|
||||||
node.expanded = !node.expanded
|
node.expanded = !node.expanded
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从父节点获取 printItems
|
// 查找可用元素列表(printItems)
|
||||||
if (node.parent && node.parent.data && node.parent.data.printItems) {
|
// 优先从当前节点找,如果没有则从父节点找
|
||||||
|
if (data.printItems && data.printItems.length > 0) {
|
||||||
|
printItems.value = data.printItems
|
||||||
|
} else if (node.parent && node.parent.data && node.parent.data.printItems) {
|
||||||
printItems.value = node.parent.data.printItems
|
printItems.value = node.parent.data.printItems
|
||||||
} else {
|
} else {
|
||||||
printItems.value = []
|
printItems.value = []
|
||||||
@ -88,6 +93,7 @@ const handlePresetClick = async (data: any, node: any) => {
|
|||||||
templateSelectItem.value = JSON.parse(JSON.stringify(data))
|
templateSelectItem.value = JSON.parse(JSON.stringify(data))
|
||||||
try {
|
try {
|
||||||
await printTemplateStore.loadTemplate(templateSelectItem.value)
|
await printTemplateStore.loadTemplate(templateSelectItem.value)
|
||||||
|
console.log('模板加载成功:', templateInfo.value)
|
||||||
ElMessage.success('模板加载成功')
|
ElMessage.success('模板加载成功')
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('加载模板失败:', error)
|
console.error('加载模板失败:', error)
|
||||||
@ -99,7 +105,8 @@ const loadTemplates = async () => {
|
|||||||
try {
|
try {
|
||||||
const res: any = await TemplatesApi.listTemplates({})
|
const res: any = await TemplatesApi.listTemplates({})
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
filteredPresetTree.value = res.presetTree || []
|
filteredPresetTree.value = res.presetTree || [];
|
||||||
|
console.log('加载模板树成功:', filteredPresetTree.value)
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error('加载模板失败: ' + (res.message || '未知错误'))
|
ElMessage.error('加载模板失败: ' + (res.message || '未知错误'))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user