更新代码
This commit is contained in:
parent
0ecacb9a21
commit
4f5d788fbd
8
new3.code-workspace
Normal file
8
new3.code-workspace
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
@ -1,108 +1,109 @@
|
||||
<template>
|
||||
<div class="image-upload-container">
|
||||
<div class="image-wall-wrapper">
|
||||
<!-- Element Plus 图片墙上传组件 -->
|
||||
<el-upload
|
||||
ref="elUploadRef"
|
||||
action="#"
|
||||
v-model:file-list="fileList"
|
||||
list-type="picture-card"
|
||||
:auto-upload="false"
|
||||
:multiple="true"
|
||||
:limit="20"
|
||||
:on-change="handleChange"
|
||||
:on-preview="handlePictureCardPreview"
|
||||
:on-remove="handleRemove"
|
||||
:before-upload="beforeUpload"
|
||||
:on-exceed="handleExceed"
|
||||
:disabled="!hasPermission('index.ReferenceFile')"
|
||||
accept="image/*"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
支持jpg/png格式,单张不超过10MB
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</div>
|
||||
|
||||
<div class="camera-section" v-if="hasPermission('index.ReferenceFile')">
|
||||
<div class="section-title">
|
||||
<el-icon><Camera /></el-icon>
|
||||
<span>摄像头拍照</span>
|
||||
</div>
|
||||
|
||||
<!-- 摄像头预览区域 -->
|
||||
<div class="camera-preview">
|
||||
<video
|
||||
ref="videoElement"
|
||||
v-show="isCameraActive && !capturedImage"
|
||||
class="camera-video"
|
||||
autoplay
|
||||
playsinline
|
||||
></video>
|
||||
|
||||
<!-- 拍照结果显示 -->
|
||||
<div v-if="capturedImage" class="captured-result">
|
||||
<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 v-else-if="!isCameraActive" class="camera-placeholder">
|
||||
<el-icon class="placeholder-icon"><CameraFilled /></el-icon>
|
||||
<p>点击下方按钮启动摄像头</p>
|
||||
<div class="left-col">
|
||||
<div class="col-left">
|
||||
<div class="image-wall-wrapper">
|
||||
<!-- Element Plus 图片墙上传组件 -->
|
||||
<el-upload
|
||||
ref="elUploadRef"
|
||||
action="#"
|
||||
v-model:file-list="fileList"
|
||||
list-type="picture-card"
|
||||
:auto-upload="false"
|
||||
:multiple="true"
|
||||
:limit="20"
|
||||
:on-change="handleChange"
|
||||
:on-preview="handlePictureCardPreview"
|
||||
:on-remove="handleRemove"
|
||||
:before-upload="beforeUpload"
|
||||
:on-exceed="handleExceed"
|
||||
:disabled="!hasPermission('index.ReferenceFile')"
|
||||
accept="image/*"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">支持jpg/png格式,单张不超过10MB</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 摄像头控制按钮 -->
|
||||
<div class="camera-controls">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="toggleCamera"
|
||||
:loading="cameraLoading"
|
||||
:disabled="captureUploading"
|
||||
>
|
||||
{{ isCameraActive ? '关闭摄像头' : '启动摄像头' }}
|
||||
</el-button>
|
||||
<div class="col-right">
|
||||
<div class="camera-section" v-if="hasPermission('index.ReferenceFile')">
|
||||
<div class="section-title">
|
||||
<el-icon><Camera /></el-icon>
|
||||
<span>摄像头拍照</span>
|
||||
</div>
|
||||
|
||||
<el-button
|
||||
type="success"
|
||||
:disabled="!isCameraActive || capturedImage || captureUploading"
|
||||
@click="capturePhoto"
|
||||
>
|
||||
<el-icon><Camera /></el-icon>
|
||||
拍照
|
||||
</el-button>
|
||||
<!-- 摄像头预览区域,仅展示预览与拍摄结果,按钮移至右侧面板 -->
|
||||
<div class="camera-preview">
|
||||
<video
|
||||
ref="videoElement"
|
||||
v-show="isCameraActive && !capturedImage"
|
||||
class="camera-video"
|
||||
autoplay
|
||||
playsinline
|
||||
></video>
|
||||
|
||||
<div v-if="capturedImage" class="captured-result">
|
||||
<img :src="capturedImage" alt="拍摄的照片" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="!isCameraActive" class="camera-placeholder">
|
||||
<el-icon class="placeholder-icon"><CameraFilled /></el-icon>
|
||||
<p>点击右侧按钮启动摄像头</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside class="right-col">
|
||||
<div class="right-panel">
|
||||
<div class="panel-actions">
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="toggleCamera"
|
||||
:loading="cameraLoading"
|
||||
:disabled="captureUploading"
|
||||
>
|
||||
{{ isCameraActive ? '关闭摄像头' : '启动摄像头' }}
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
type="success"
|
||||
:disabled="!isCameraActive || capturedImage || captureUploading"
|
||||
@click="capturePhoto"
|
||||
>
|
||||
<el-icon><Camera /></el-icon>
|
||||
拍照
|
||||
</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>
|
||||
</aside>
|
||||
|
||||
<!-- 图片预览对话框 -->
|
||||
<el-dialog
|
||||
v-model="previewVisible"
|
||||
title="图片预览"
|
||||
width="80%"
|
||||
top="5vh"
|
||||
append-to-body
|
||||
>
|
||||
<el-dialog v-model="previewVisible" title="图片预览" width="80%" top="5vh" append-to-body>
|
||||
<img :src="dialogImageUrl" alt="预览" style="width: 100%; max-height: 70vh; object-fit: contain;" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
@ -486,11 +487,42 @@ const uploadCapturedImage = async () => {
|
||||
captureUploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
// 清理文件列表、停止摄像头并重置拍照图片
|
||||
fileList.value = []
|
||||
capturedImage.value = null
|
||||
stopCamera()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.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 {
|
||||
@ -546,18 +578,6 @@ const uploadCapturedImage = async () => {
|
||||
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 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -570,9 +590,21 @@ const uploadCapturedImage = async () => {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.camera-controls {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 20px;
|
||||
.right-col {
|
||||
grid-column: 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; display:flex; gap:8px; flex-wrap:wrap; align-items:center }
|
||||
|
||||
</style>
|
||||
|
||||
@ -144,4 +144,4 @@ export default {
|
||||
"status": "Status",
|
||||
"address": "Address"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
||||
Object.keys(source).forEach(key => {
|
||||
if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
||||
if (!target[key] || typeof target[key] !== 'object') {
|
||||
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], source[key])
|
||||
deepMerge(target[key], sourceValue, fullKey)
|
||||
} 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
|
||||
@ -237,6 +260,7 @@ export async function loadServerMessages(language: string | null = null) {
|
||||
// @ts-ignore
|
||||
i18n.global.setLocaleMessage(targetLanguage, mergedMessages)
|
||||
|
||||
console.log('整合后的语言包:', mergedMessages)
|
||||
console.log(`✅ 服务器翻译加载并深度合并成功 (${targetLanguage})`);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -144,4 +144,4 @@ export default {
|
||||
"status": "仓库状态",
|
||||
"address": "仓库地址"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ import getPageTitle from '@/utils/get-page-title'
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
const whiteList = ['/login','/redirect']
|
||||
const whiteList = ['/login','/redirect','/admin/land'] // no redirect whitelist
|
||||
|
||||
router.beforeEach(async (to, from) => {
|
||||
NProgress.start()
|
||||
|
||||
@ -35,6 +35,12 @@ export const constantRoutes: RouteRecordRaw[] = [
|
||||
component: () => import('@/views/login/index.vue'),
|
||||
meta: { title: '登录', hidden: true }
|
||||
},
|
||||
{
|
||||
path: '/admin/land',
|
||||
name: 'AdminLand',
|
||||
component: () => import('@/views/admin/land/index.vue'),
|
||||
meta: { title: '语言翻译', hidden: true }
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
component: Layout,
|
||||
|
||||
@ -16,4 +16,5 @@ export const componentMap: Record<string, any> = {
|
||||
'system/print/station': () => import('@/views/system/setting/printStation/index.vue'),
|
||||
// 'system/StoreManagement/station2': () => import('@/views/system/setting/printStation/index2.vue'),
|
||||
// 'system/setting/printStation': () => import('@/views/system/setting/printStation/index.vue'),
|
||||
// 'admin/land': () => import('@/views/admin/land/index.vue')
|
||||
};
|
||||
303
src/views/admin/land/index.vue
Normal file
303
src/views/admin/land/index.vue
Normal file
@ -0,0 +1,303 @@
|
||||
<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-form :model="newLangForm" label-width="120px" style="max-width: 600px; padding: 20px;">
|
||||
<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"
|
||||
placeholder='可用本地语言模板覆盖:{"common": {}, "menu": {}}'
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="large" @click="handleAddLanguage">立即新增语言数据</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</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'
|
||||
|
||||
// 标签页选中项
|
||||
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-US': {
|
||||
"common": {
|
||||
"add": "Add (Server Overwrite)",
|
||||
"server_label": "Server-side specific key"
|
||||
},
|
||||
"menu": {
|
||||
"Dashboard": "Remote Dashboard Panel"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目合并后的翻译包 (深度合并:本地 + 服务器)
|
||||
*/
|
||||
const mergedZhString = computed(() => {
|
||||
try {
|
||||
const serverObj = serverZhString.value ? JSON.parse(serverZhString.value) : {}
|
||||
// 服务器数据会覆盖本地同名冲突字段
|
||||
const merged = _.merge({}, localZh, 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 merged = _.merge({}, localEn, serverObj)
|
||||
return JSON.stringify(merged, null, 2)
|
||||
} catch (e) {
|
||||
return '解析JSON失败:请确保服务器端输入的是有效的 JSON 字符串'
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 语言表单功能
|
||||
*/
|
||||
const newLangForm = ref({
|
||||
name: '',
|
||||
code: '',
|
||||
content: '{\n "common": {},\n "menu": {}\n}'
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 模拟从后端接口获取数据并初始化
|
||||
initMockServerData()
|
||||
})
|
||||
|
||||
const initMockServerData = () => {
|
||||
serverZhString.value = JSON.stringify(mockServerData['zh-CN'], null, 2)
|
||||
serverEnString.value = JSON.stringify(mockServerData['en-US'], null, 2)
|
||||
}
|
||||
|
||||
const handleResetServerData = () => {
|
||||
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 语法')
|
||||
}
|
||||
}
|
||||
</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,5 +1,5 @@
|
||||
<template>
|
||||
<div class="stock-log-container">
|
||||
<div class="log-container">
|
||||
<el-button-group class="toolbar-btn-group">
|
||||
<el-button
|
||||
type="primary"
|
||||
@ -191,7 +191,7 @@ function backData(row: any) {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.stock-log-container {
|
||||
.log-container {
|
||||
height: 100%;
|
||||
padding: 10px 20px;
|
||||
overflow: hidden;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="storage-container">
|
||||
<div class="container">
|
||||
<el-button-group class="toolbar-btn-group">
|
||||
<el-button
|
||||
type="primary"
|
||||
@ -99,7 +99,7 @@ function handleClick(row: any) {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.storage-container {
|
||||
.container {
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
overflow: hidden;
|
||||
|
||||
@ -119,14 +119,14 @@
|
||||
@selection-change="selectionChange"
|
||||
>
|
||||
<!-- 自定义状态列 -->
|
||||
<template #column-status="{ row }">
|
||||
<!-- <template #column-status="{ row }">
|
||||
<el-tag :type="row.status === 'enabled' ? 'success' : 'danger'" size="small">
|
||||
{{ row.status === 'enabled' ? '启用' : '禁用' }}
|
||||
</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">
|
||||
{{ row.is_sn_mgmt === 'Y' ? '是' : '否' }}
|
||||
</el-tag>
|
||||
@ -140,7 +140,7 @@
|
||||
<el-tag :type="row.is_batch_mgmt === 'Y' ? 'success' : 'info'" size="small">
|
||||
{{ row.is_batch_mgmt === 'Y' ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</template> -->
|
||||
|
||||
<template #empty>
|
||||
<div class="custom-empty">
|
||||
@ -224,12 +224,13 @@ import Recycle from './component/recycle.vue'
|
||||
|
||||
// API
|
||||
import * as stockApi from '@/api/stock'
|
||||
import * as indexApi from '@/api/index'
|
||||
import * as indexApi from '@/api/index.ts'
|
||||
// Store
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
|
||||
// Utils
|
||||
import { parseTime } from '@/utils/index'
|
||||
import { labelInner } from 'echarts/types/src/label/labelStyle.js'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const hasPermission = (perm: string) => {
|
||||
@ -336,13 +337,13 @@ const accountColumns = [
|
||||
showOverflowTooltip: true,
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
width: '80',
|
||||
align: 'center',
|
||||
slotName: 'status'
|
||||
},
|
||||
// {
|
||||
// prop: 'status',
|
||||
// label: '状态',
|
||||
// width: '80',
|
||||
// align: 'center',
|
||||
// slotName: 'status'
|
||||
// },
|
||||
{
|
||||
prop: 'store_remask',
|
||||
label: '货主',
|
||||
@ -431,6 +432,13 @@ const accountColumns = [
|
||||
return formatNumber(available, 0)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'lock_rate_display',
|
||||
label: '锁定率',
|
||||
width: '100',
|
||||
align: 'right',
|
||||
formatter: (row: any) => row.lock_rate_display || '--'
|
||||
},
|
||||
// Units
|
||||
{
|
||||
prop: 'stock_unit',
|
||||
@ -896,7 +904,7 @@ const handleTabChange = () => {
|
||||
onMounted(async () => {
|
||||
// Load stores, prohibited types etc.
|
||||
try {
|
||||
const res = await indexApi.loadStores()
|
||||
const res = await indexApi.loadStores({ type: 'stock' })
|
||||
if (res && (res as any).stores) {
|
||||
(availableFields[0] as any).options = (res as any).stores
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ onMounted(() => {
|
||||
}
|
||||
.col-right {
|
||||
flex: 1;
|
||||
background: #7a2828;
|
||||
background: #000000d8;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
|
||||
@ -1,14 +1,180 @@
|
||||
<template>
|
||||
<div class="receiving-logs">
|
||||
<p>操作日志组件 - ID: {{ id }}</p>
|
||||
<!-- TODO: 迁移并实现操作日志 -->
|
||||
<div class="log-container">
|
||||
<el-button-group class="toolbar-btn-group">
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<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>
|
||||
|
||||
<style scoped>
|
||||
.receiving-logs { padding: 12px }
|
||||
<style scoped lang="scss">
|
||||
.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>
|
||||
|
||||
@ -1,14 +1,118 @@
|
||||
<template>
|
||||
<div class="receiving-storage">
|
||||
<p>入库记录组件 - ID: {{ id }}</p>
|
||||
<!-- TODO: 迁移并实现入库记录列表 -->
|
||||
<div class="container">
|
||||
<el-button-group class="toolbar-btn-group">
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<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>
|
||||
|
||||
<style scoped>
|
||||
.receiving-storage { padding: 12px }
|
||||
<style scoped lang="scss">
|
||||
.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>
|
||||
|
||||
@ -212,7 +212,7 @@ async function loadData() {
|
||||
|
||||
async function loadFilterData() {
|
||||
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) {
|
||||
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||||
if (f) f.options = storesRes.stores || []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user