2026-01-26 17:00:12 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="dashboard-container">
|
|
|
|
|
|
<el-card class="welcome-card">
|
|
|
|
|
|
<template #header>
|
|
|
|
|
|
<div class="card-header">
|
2026-02-04 15:55:20 +08:00
|
|
|
|
<span class="title">👋 欢迎回来,{{ userStore.username }}</span>
|
2026-02-11 14:26:43 +08:00
|
|
|
|
<div style="display: flex; align-items: center; gap: 10px;">
|
|
|
|
|
|
<el-tag type="success">系统运行正常</el-tag>
|
|
|
|
|
|
<el-button type="info" plain size="small" @click="openPrinterDialog" :icon="Setting" class="printer-btn">
|
|
|
|
|
|
打印设置
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
2026-01-26 17:00:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2026-01-27 15:50:23 +08:00
|
|
|
|
|
2026-01-26 17:00:12 +08:00
|
|
|
|
<div class="card-body">
|
2026-01-27 15:50:23 +08:00
|
|
|
|
<h2>IRIS 库存管理系统</h2>
|
|
|
|
|
|
<p class="subtitle">请选择您要进行的业务操作:</p>
|
2026-01-26 17:00:12 +08:00
|
|
|
|
|
|
|
|
|
|
<div class="action-buttons">
|
2026-01-27 15:50:23 +08:00
|
|
|
|
<el-button type="primary" size="large" @click="handleNav('/inventory/buy')">
|
|
|
|
|
|
<el-icon style="margin-right: 5px"><ShoppingCart /></el-icon>
|
|
|
|
|
|
采购入库
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
|
|
|
|
|
<el-button type="success" size="large" @click="handleNav('/material/index')">
|
2026-01-26 17:00:12 +08:00
|
|
|
|
<el-icon style="margin-right: 5px"><Box /></el-icon>
|
2026-01-28 08:54:11 +08:00
|
|
|
|
基础信息
|
2026-01-26 17:00:12 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
|
2026-01-27 15:50:23 +08:00
|
|
|
|
<el-button type="warning" size="large" @click="handleNav('/operation/borrow')">
|
|
|
|
|
|
<el-icon style="margin-right: 5px"><Operation /></el-icon>
|
|
|
|
|
|
借库申请
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
2026-01-26 17:00:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-card>
|
2026-02-11 14:26:43 +08:00
|
|
|
|
|
|
|
|
|
|
<el-dialog v-model="printerDialogVisible" title="打印机 IP 配置" width="500px">
|
|
|
|
|
|
<el-form :model="printerForm" label-width="120px">
|
|
|
|
|
|
<el-form-item label="标签打印机 IP">
|
|
|
|
|
|
<el-input v-model="printerForm.label_ip" placeholder="例如 192.168.9.221" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="标签打印机端口">
|
|
|
|
|
|
<el-input v-model.number="printerForm.label_port" placeholder="例如 9100" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="网络打印机 IP">
|
|
|
|
|
|
<el-input v-model="printerForm.network_ip" placeholder="例如 192.168.9.250" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="网络打印机端口">
|
|
|
|
|
|
<el-input v-model.number="printerForm.network_port" placeholder="例如 9100" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
|
<el-button @click="printerDialogVisible = false">取消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="savePrinterConfig" :loading="loading">保存</el-button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
2026-01-26 17:00:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-02-11 14:29:56 +08:00
|
|
|
|
import { ref, reactive } from 'vue'
|
2026-01-27 15:50:23 +08:00
|
|
|
|
import { useRouter } from 'vue-router'
|
2026-02-04 15:55:20 +08:00
|
|
|
|
// 1. 引入 User Store
|
|
|
|
|
|
import { useUserStore } from '@/stores/user'
|
2026-01-27 15:50:23 +08:00
|
|
|
|
// 引入需要的图标
|
2026-02-11 14:26:43 +08:00
|
|
|
|
import { Box, TrendCharts, ShoppingCart, Operation, Setting } from '@element-plus/icons-vue'
|
|
|
|
|
|
import { getPrinterConfig, updatePrinterConfig } from '@/api/common/print'
|
|
|
|
|
|
import { ElMessage } from 'element-plus'
|
2026-01-27 15:50:23 +08:00
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
2026-02-04 15:55:20 +08:00
|
|
|
|
// 2. 实例化 store
|
|
|
|
|
|
const userStore = useUserStore()
|
2026-01-27 15:50:23 +08:00
|
|
|
|
|
2026-02-11 14:26:43 +08:00
|
|
|
|
// 打印机配置相关
|
|
|
|
|
|
const printerDialogVisible = ref(false)
|
|
|
|
|
|
const printerForm = reactive({
|
|
|
|
|
|
label_ip: '',
|
|
|
|
|
|
label_port: '',
|
|
|
|
|
|
network_ip: '',
|
|
|
|
|
|
network_port: ''
|
|
|
|
|
|
})
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
const openPrinterDialog = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
const res = await getPrinterConfig()
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
const config = res.data
|
|
|
|
|
|
printerForm.label_ip = config.label_printer?.ip || ''
|
|
|
|
|
|
printerForm.label_port = config.label_printer?.port || ''
|
|
|
|
|
|
printerForm.network_ip = config.network_printer?.ip || ''
|
|
|
|
|
|
printerForm.network_port = config.network_printer?.port || ''
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error(e)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
printerDialogVisible.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const savePrinterConfig = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
const config = {
|
|
|
|
|
|
label_printer: {
|
|
|
|
|
|
ip: printerForm.label_ip,
|
|
|
|
|
|
port: Number(printerForm.label_port)
|
|
|
|
|
|
},
|
|
|
|
|
|
network_printer: {
|
|
|
|
|
|
ip: printerForm.network_ip,
|
|
|
|
|
|
port: Number(printerForm.network_port)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
const res = await updatePrinterConfig(config)
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
ElMessage.success('保存成功')
|
|
|
|
|
|
printerDialogVisible.value = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.error(res.msg || '保存失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
ElMessage.error('请求异常')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-27 15:50:23 +08:00
|
|
|
|
// 统一跳转函数
|
|
|
|
|
|
const handleNav = (path: string) => {
|
|
|
|
|
|
router.push(path)
|
|
|
|
|
|
}
|
2026-01-26 17:00:12 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.dashboard-container {
|
2026-01-27 15:50:23 +08:00
|
|
|
|
/* 使用 100% 宽度和高度,利用 Flex 居中显示 */
|
|
|
|
|
|
height: calc(100vh - 84px); /* 减去顶部导航栏的高度,防止出现双滚动条 */
|
2026-01-26 17:00:12 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
2026-01-27 15:50:23 +08:00
|
|
|
|
align-items: center;
|
|
|
|
|
|
background-color: #f0f2f5; /* 给背景加个淡灰色,突出卡片 */
|
2026-01-26 17:00:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.welcome-card {
|
2026-01-27 15:50:23 +08:00
|
|
|
|
width: 800px; /*稍微加宽一点 */
|
2026-01-26 17:00:12 +08:00
|
|
|
|
text-align: center;
|
2026-01-27 15:50:23 +08:00
|
|
|
|
border-radius: 8px; /* 圆角更好看 */
|
2026-01-26 17:00:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-27 15:50:23 +08:00
|
|
|
|
.card-header {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
font-weight: bold;
|
2026-01-26 17:00:12 +08:00
|
|
|
|
color: #303133;
|
2026-01-27 15:50:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.card-body {
|
|
|
|
|
|
padding: 20px 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.card-body h2 {
|
|
|
|
|
|
font-size: 28px;
|
|
|
|
|
|
color: #409EFF; /* 使用主题蓝 */
|
2026-01-26 17:00:12 +08:00
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-27 15:50:23 +08:00
|
|
|
|
.subtitle {
|
|
|
|
|
|
color: #909399;
|
|
|
|
|
|
margin-bottom: 40px;
|
|
|
|
|
|
font-size: 14px;
|
2026-01-26 17:00:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.action-buttons {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
gap: 20px;
|
2026-01-27 15:50:23 +08:00
|
|
|
|
flex-wrap: wrap; /* 防止屏幕过窄时按钮挤压 */
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 给按钮加一点悬浮效果 */
|
|
|
|
|
|
.el-button {
|
|
|
|
|
|
transition: all 0.3s;
|
|
|
|
|
|
}
|
|
|
|
|
|
.el-button:hover {
|
|
|
|
|
|
transform: translateY(-2px);
|
|
|
|
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
2026-01-26 17:00:12 +08:00
|
|
|
|
}
|
2026-02-11 14:26:43 +08:00
|
|
|
|
</style>
|