18号的更新
This commit is contained in:
parent
4f5d788fbd
commit
e1cbf289ed
@ -23,7 +23,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useAppStore } from '@/stores/modules/app'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const { locale } = useI18n()
|
||||
const { locale, messages } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
|
||||
const language = computed(() => appStore.language)
|
||||
@ -31,10 +31,12 @@ const language = computed(() => appStore.language)
|
||||
const handleSetLanguage = (lang: string) => {
|
||||
locale.value = lang
|
||||
appStore.setLanguage(lang)
|
||||
console.log('当前语言包内容:', messages.value[lang])
|
||||
ElMessage({
|
||||
message: 'Switch Language Success',
|
||||
type: 'success'
|
||||
})
|
||||
location.reload()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
v-bind="isExternal(shortcut.path) ? { href: shortcut.path, target: '_blank' } : { to: shortcut.path }"
|
||||
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" />
|
||||
<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>
|
||||
</component>
|
||||
</div>
|
||||
@ -81,7 +81,7 @@ const scrollPane = ref()
|
||||
|
||||
const visitedViews = computed(() => tagsViewStore.visitedViews)
|
||||
const routes = computed(() => permissionStore.routes)
|
||||
const shortcuts = computed(() => shortcutsStore.shortcuts)
|
||||
const shortcuts = computed(() => shortcutsStore.$state?.shortcuts ?? [])
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
|
||||
const toggleShortcut = () => {
|
||||
@ -101,10 +101,10 @@ const isAffix = (tag: any) => {
|
||||
}
|
||||
|
||||
const generateTitle = (title: any) => {
|
||||
const hasKey = te('menu.' + title)
|
||||
const titleKey = 'menu.' + title
|
||||
const hasKey = te(titleKey)
|
||||
if (hasKey) {
|
||||
const translatedTitle = t('menu.' + title)
|
||||
return translatedTitle
|
||||
return t(titleKey)
|
||||
}
|
||||
return title || 'no-name'
|
||||
}
|
||||
|
||||
@ -47,14 +47,9 @@ export const useShortcutsStore = defineStore('shortcuts', () => {
|
||||
const is404 = resolved.matched.some(r => r.name === 'Page404' || r.path === '/:pathMatch(.*)*' || r.redirect === '/404')
|
||||
if (is404) return false
|
||||
|
||||
// Update title/icon from current route meta if available to keep it fresh
|
||||
if (resolved.meta?.title) {
|
||||
s.title = resolved.meta.title as string
|
||||
}
|
||||
if (resolved.meta?.icon) {
|
||||
s.icon = resolved.meta.icon as string
|
||||
}
|
||||
|
||||
// Do not override title/icon if they already exist to avoid language-locked titles
|
||||
// Only update if current meta title/icon is different from saved one
|
||||
// Removed forced s.title update to prevent saving translated strings
|
||||
return true
|
||||
})
|
||||
} 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 {
|
||||
shortcuts,
|
||||
addShortcut,
|
||||
|
||||
@ -36,12 +36,12 @@
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- 展示从服务器获取的语言包(目前有zh-CN、en-US),点击对应语言包可以展开查看对应语言包具体数据,语言包数据允许修改;此部分数据先使用本地模拟数据。 -->
|
||||
<el-tab-pane label="服务器语言包 (可编辑)" name="server">
|
||||
<el-tab-pane label="服务器语言包" name="server">
|
||||
<div class="pane-action-bar">
|
||||
<el-button type="primary" size="small" @click="handleResetServerData">重置模拟数据</el-button>
|
||||
<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">
|
||||
<el-collapse-item title="zh-CN (来自服务器)" name="zh-CN">
|
||||
<div class="editor-container">
|
||||
<el-input
|
||||
v-model="serverZhString"
|
||||
@ -55,7 +55,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="en-US (来自服务器 - 模拟)" name="en-US">
|
||||
<el-collapse-item title="en-US (来自服务器)" name="en-US">
|
||||
<div class="editor-container">
|
||||
<el-input
|
||||
v-model="serverEnString"
|
||||
@ -106,27 +106,73 @@
|
||||
</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-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>
|
||||
@ -138,6 +184,7 @@ 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')
|
||||
@ -171,7 +218,7 @@ const mockServerData = {
|
||||
"Dashboard": "远程主页控制台"
|
||||
}
|
||||
},
|
||||
'en-US': {
|
||||
'en': {
|
||||
"common": {
|
||||
"add": "Add (Server Overwrite)",
|
||||
"server_label": "Server-side specific key"
|
||||
@ -182,14 +229,51 @@ const mockServerData = {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归深度合并对象 (同步 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 merged = _.merge({}, localZh, serverObj)
|
||||
// 克隆本地数据以避免直接修改
|
||||
const localCopy = JSON.parse(JSON.stringify(localZh))
|
||||
const merged = deepMerge(localCopy, serverObj)
|
||||
return JSON.stringify(merged, null, 2)
|
||||
} catch (e) {
|
||||
return '解析JSON失败:请确保服务器端输入的是有效的 JSON 字符串'
|
||||
@ -199,7 +283,8 @@ const mergedZhString = computed(() => {
|
||||
const mergedEnString = computed(() => {
|
||||
try {
|
||||
const serverObj = serverEnString.value ? JSON.parse(serverEnString.value) : {}
|
||||
const merged = _.merge({}, localEn, serverObj)
|
||||
const localCopy = JSON.parse(JSON.stringify(localEn))
|
||||
const merged = deepMerge(localCopy, serverObj)
|
||||
return JSON.stringify(merged, null, 2)
|
||||
} catch (e) {
|
||||
return '解析JSON失败:请确保服务器端输入的是有效的 JSON 字符串'
|
||||
@ -208,26 +293,75 @@ const mergedEnString = computed(() => {
|
||||
|
||||
/**
|
||||
* 语言表单功能
|
||||
* 自动根据本地 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: '{\n "common": {},\n "menu": {}\n}'
|
||||
content: defaultNewLangContent
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 模拟从后端接口获取数据并初始化
|
||||
initMockServerData()
|
||||
// 尝试从后端接口获取数据并初始化,失败时回退到模拟数据
|
||||
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-US'], null, 2)
|
||||
serverEnString.value = JSON.stringify(mockServerData['en'], null, 2)
|
||||
}
|
||||
|
||||
const handleResetServerData = () => {
|
||||
initMockServerData()
|
||||
ElMessage.success('已清空手动修改内容并重置为初始模拟数据')
|
||||
const handleResetServerData = async () => {
|
||||
// 重置应优先从服务器拉取最新数据;失败时回退到模拟数据
|
||||
try {
|
||||
await loadServerFromApi()
|
||||
ElMessage.success('已从服务器重新加载语言包(若服务器不可用则回退到模拟数据)')
|
||||
} catch (e) {
|
||||
initMockServerData()
|
||||
ElMessage.success('服务器加载失败,已回退到初始模拟数据')
|
||||
}
|
||||
}
|
||||
|
||||
// 模拟保存服务器端数据修改
|
||||
@ -255,6 +389,111 @@ const handleAddLanguage = () => {
|
||||
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>
|
||||
|
||||
@ -1,8 +1,830 @@
|
||||
<template>
|
||||
<div class="auth-approve-container">
|
||||
<h1>审批管理</h1>
|
||||
<div class="approve-container">
|
||||
<!-- 审核表单 -->
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
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>
|
||||
|
||||
<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>
|
||||
@ -98,7 +98,7 @@ const moduleComponents: Record<string, any> = {
|
||||
joinStore: defineAsyncComponent(() => import('./forms/joinStore.vue')),
|
||||
createWarehouse: defineAsyncComponent(() => import('./forms/createWarehouse.vue')),
|
||||
joinWarehouse: defineAsyncComponent(() => import('./forms/joinWarehouse.vue'))
|
||||
}
|
||||
}
|
||||
|
||||
const formTitles: Record<string, string> = {
|
||||
createStore: '创建货主',
|
||||
|
||||
@ -123,11 +123,22 @@ const handleSubmit = async () => {
|
||||
if (valid) {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await joinStore(form)
|
||||
authLink.value = res.data // Assuming API returns the link in data
|
||||
ElMessage.success('生成链接成功')
|
||||
const res:any = await joinStore(form)
|
||||
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('生成链接成功')
|
||||
} else {
|
||||
ElMessage.error('未返回有效的链接数据')
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(res?.message || '生成链接失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
ElMessage.error('生成链接失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@ -125,11 +125,10 @@ const handleSubmit = async () => {
|
||||
try {
|
||||
const res: any = await joinWarehouse(form)
|
||||
const baseUrl = window.location.origin
|
||||
// 与 vue2 保持一致:仅当后端返回 code === 200 时认为生成成功
|
||||
if (res && res.code === 200) {
|
||||
const joinToken = res.data && res.data.joinToken
|
||||
if (joinToken) {
|
||||
authLink.value = `${baseUrl}/#/auth/approve?type=store&code=${joinToken}`
|
||||
authLink.value = `${baseUrl}/auth/approve?type=store&code=${joinToken}`
|
||||
ElMessage.success('生成链接成功')
|
||||
} else {
|
||||
ElMessage.error('未返回有效的 joinToken')
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
<template>
|
||||
<div class="receiving-details">
|
||||
<el-form-item label="收货单号" prop="receiving_number">
|
||||
|
||||
@ -3,61 +3,33 @@
|
||||
<div class="left-col">
|
||||
<div class="col-left">
|
||||
<el-form :model="form" label-width="120px" >
|
||||
<el-form-item label="收货单号" prop="receiving_number">
|
||||
<el-input v-model="form.receiving_number" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="收货状态" prop="status">
|
||||
<el-select placeholder="请选择收货状态" v-model="form.status">
|
||||
<el-option
|
||||
v-for="(cfg, key) in statusConfig"
|
||||
:key="key"
|
||||
:label="cfg.text"
|
||||
:value="key"
|
||||
<el-form-item
|
||||
v-for="field in detailpanel"
|
||||
:key="field.prop"
|
||||
:label="field.label"
|
||||
:prop="field.prop"
|
||||
>
|
||||
<template v-if="field.type === 'select'">
|
||||
<el-select
|
||||
v-model="(form as any)[field.prop]"
|
||||
:placeholder="'请选择' + field.label"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in availableFields.find(f => f.value === field.prop)?.options || []"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-input
|
||||
v-model="(form as any)[field.prop]"
|
||||
:disabled="field.disabled"
|
||||
:placeholder="'请输入' + field.label"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="货主" prop="store_name">
|
||||
<el-input v-model="form.store_name" disabled />
|
||||
</el-form-item>
|
||||
|
||||
<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>
|
||||
</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>
|
||||
</div>
|
||||
<div class="col-right"></div>
|
||||
@ -76,12 +48,14 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
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';
|
||||
|
||||
const props = defineProps<{ id: string | number }>()
|
||||
const props = defineProps<{
|
||||
id: string | number,
|
||||
row?: any
|
||||
}>()
|
||||
|
||||
const data = ref<any>({})
|
||||
const form = ref({
|
||||
receiving_number: '',
|
||||
store_name: '',
|
||||
@ -90,21 +64,13 @@ const form = ref({
|
||||
delivery_method: '',
|
||||
status: '',
|
||||
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 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(() => {
|
||||
data.value = mockData
|
||||
form.value = { ...mockData }
|
||||
if (props.row) {
|
||||
form.value = { ...props.row }
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
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>
|
||||
@ -95,8 +95,9 @@
|
||||
|
||||
<div class="lower-level" v-if="selectedReceivingId" :class="tableSize">
|
||||
<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="product" />
|
||||
<el-tab-pane label="入库记录" name="storage" />
|
||||
<el-tab-pane label="操作日志" name="logs" />
|
||||
</el-tabs>
|
||||
@ -126,6 +127,7 @@ import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import Details from './component/DetailsPanel.vue'
|
||||
import StorageComp from './component/Storage.vue'
|
||||
import Logs from './component/Logs.vue'
|
||||
import Product from './component/Product.vue'
|
||||
import * as indexApi from '@/api/index'
|
||||
import * as receivingApi from '@/api/storage/receiving'
|
||||
import {
|
||||
@ -165,7 +167,8 @@ const quickSearch = ref('')
|
||||
const componentMap: Record<string, any> = {
|
||||
details: Details,
|
||||
storage: StorageComp,
|
||||
logs: Logs
|
||||
logs: Logs,
|
||||
product: Product
|
||||
}
|
||||
|
||||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
||||
@ -193,7 +196,7 @@ async function loadData() {
|
||||
}
|
||||
const res: any = await receivingApi.getReceivingList(params)
|
||||
if (res && res.code === 200) {
|
||||
//console.log('原始数据', res.data.list)
|
||||
console.log('原始数据', res.data.list)
|
||||
list.value = formatReceivingData(res.data.list || [])
|
||||
pagination.currentPage = res.data.pagination?.currentPage || pagination.currentPage
|
||||
pagination.pageSize = res.data.pagination?.pageSize || pagination.pageSize
|
||||
@ -357,6 +360,13 @@ async function handleExport() {
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
}
|
||||
.toolbar-right {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap:15px;
|
||||
height: 30px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.upper-wrapper {
|
||||
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[] = []) {
|
||||
return (list || []).map(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) => {
|
||||
if (data.type === 'category') {
|
||||
// 针对 RECEIPT 这种 businessType 节点,它可能既是 category 又包含 printItems,
|
||||
// 且没有子节点(children 为空),这种情况下应该允许加载
|
||||
if (data.type === 'category' && data.children && data.children.length > 0) {
|
||||
node.expanded = !node.expanded
|
||||
return
|
||||
}
|
||||
|
||||
// 从父节点获取 printItems
|
||||
if (node.parent && node.parent.data && node.parent.data.printItems) {
|
||||
// 查找可用元素列表(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
|
||||
} else {
|
||||
printItems.value = []
|
||||
@ -88,6 +93,7 @@ const handlePresetClick = async (data: any, node: any) => {
|
||||
templateSelectItem.value = JSON.parse(JSON.stringify(data))
|
||||
try {
|
||||
await printTemplateStore.loadTemplate(templateSelectItem.value)
|
||||
console.log('模板加载成功:', templateInfo.value)
|
||||
ElMessage.success('模板加载成功')
|
||||
} catch (error: any) {
|
||||
console.error('加载模板失败:', error)
|
||||
@ -99,7 +105,8 @@ const loadTemplates = async () => {
|
||||
try {
|
||||
const res: any = await TemplatesApi.listTemplates({})
|
||||
if (res.code === 200) {
|
||||
filteredPresetTree.value = res.presetTree || []
|
||||
filteredPresetTree.value = res.presetTree || [];
|
||||
console.log('加载模板树成功:', filteredPresetTree.value)
|
||||
} else {
|
||||
ElMessage.error('加载模板失败: ' + (res.message || '未知错误'))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user