Browse Source

完成LIS页面

relver
zhangjiming 7 months ago
parent
commit
844bf02e0c
  1. 278
      src/pages/Index/Settings/Lis.vue
  2. 12
      src/router/router.ts
  3. 125
      src/services/Index/settings/settings.ts

278
src/pages/Index/Settings/Lis.vue

@ -1,10 +1,280 @@
<template>
<div>
<!-- -->
开发中
<div class="lis-setting">
<div class="setting-item">
<span class="label">类型</span>
<div class="options">
<button
v-for="(item, idx) in LISTypeItems"
:key="idx"
:class="{ active: lisSettings && lisSettings.LISType === item[0] }"
@click="updLisType(item[0])"
>
{{ item[1] }}
</button>
</div>
</div>
<div class="setting-item">
<span class="label">协议</span>
<div class="options">
<button
:class="{
active: lisSettings && lisSettings.LISProtocol === 'Boditech',
}"
@click="updLisProtocol('Boditech')"
>
Boditech
</button>
<button
:class="{
active: lisSettings && lisSettings.LISProtocol === 'Simens',
}"
@click="updLisProtocol('Simens')"
>
Simens
</button>
</div>
</div>
<div class="setting-item">
<span class="label">接口</span>
<div class="options">
<button
v-for="(item, idx) in LISInterfaceItems"
:key="idx"
:class="{ active: lisSettings && lisSettings.LIFIf === item[0] }"
@click="updLisInterface(item[0])"
>
{{ item[1] }}
</button>
</div>
</div>
<div
v-if="lisSettings && lisSettings.LIFIf === 'NETWORK'"
class="setting-item"
>
<span class="label">Host's IP</span>
<div class="options">
<input style="min-width: 250px" v-model="lisSettings.LISNetIp" type="text"></input>
<button @click="updLisIP(lisSettings.LISNetIp)" >设置</button>
</div>
</div>
<div
v-if="lisSettings && lisSettings.LIFIf === 'NETWORK'"
class="setting-item"
>
<span class="label">Host's Port</span>
<div class="options">
<input type="text" v-model="lisSettings.LISNetPort" ></input>
<button @click="updLisPort(lisSettings.LISNetPort)" >设置</button>
</div>
</div>
<div
v-if="lisSettings && lisSettings.LIFIf === 'SERIAL'"
class="setting-item"
>
<span class="label">传输速度</span>
<div class="options">
<button
v-for="(item, idx) in LISSerialBaudrateItems"
:key="idx"
:class="{
active: lisSettings && lisSettings.LISSerialBaudrate === item[0],
}"
@click="updLisSerialBaudrate(item[0])"
>
{{ item[1] }}
</button>
</div>
</div>
<div class="setting-item">
<span class="label">导出</span>
<div class="options">
<button
:class="{
active: lisSettings && lisSettings.LISAutoExport,
}"
@click="updLisAutoExport(true)"
>
自动
</button>
<button
:class="{
active: lisSettings && !lisSettings.LISAutoExport,
}"
@click="updLisAutoExport(false)"
>
手动
</button>
</div>
</div>
</div>
</template>
<script setup>
<script setup lang="ts">
import {
getLISSetting,
LISInterface,
LISInterfaceMap,
LISProtocol,
LISSerialBaudrate,
LISSerialBaudrateMap,
LISSettings,
LISType,
LISTypeMap,
setLISAutoExport,
setLISInterface,
setLISNetIp,
setLISNetPort,
setLISProtocol,
setLISSerialBaudrate,
setLISType,
} from '@/services'
import { onMounted, ref } from 'vue'
import * as R from 'ramda'
import { eMessage } from '../utils'
const LISInterfaceItems = R.toPairs(LISInterfaceMap)
const LISSerialBaudrateItems = R.toPairs(LISSerialBaudrateMap)
const LISTypeItems = R.toPairs(LISTypeMap)
const lisSettings = ref<LISSettings | undefined>(undefined)
const getLisSetting = async () => {
const res = await getLISSetting()
if (res && res.success) {
lisSettings.value = res.data
}
}
const updLisType = async (type:LISType) => {
const res = await setLISType(type)
if (res && res.success) {
getLisSetting()
} else {
res && res.data && res.data.info && eMessage.error(res.data.info)
}
}
const updLisProtocol = async (p: LISProtocol) => {
const res = await setLISProtocol(p)
if (res && res.success) {
getLisSetting()
} else {
res && res.data && res.data.info && eMessage.error(res.data.info)
}
}
const updLisInterface = async (f: LISInterface) => {
const res = await setLISInterface(f)
if (res && res.success) {
getLisSetting()
} else {
res && res.data && res.data.info && eMessage.error(res.data.info)
}
}
const updLisSerialBaudrate = async (s: LISSerialBaudrate) => {
const res = await setLISSerialBaudrate(s)
if (res && res.success) {
getLisSetting()
} else {
res && res.data && res.data.info && eMessage.error(res.data.info)
}
}
const updLisAutoExport = async (auto: boolean) => {
const res = await setLISAutoExport(auto)
if (res && res.success) {
getLisSetting()
} else {
res && res.data && res.data.info && eMessage.error(res.data.info)
}
}
const updLisIP = async (ip: string) => {
const res = await setLISNetIp(ip)
if (res && res.success) {
getLisSetting()
} else {
res && res.data && res.data.info && eMessage.error(res.data.info)
}
}
const updLisPort = async (port: number) => {
const res = await setLISNetPort(port)
if (res && res.success) {
getLisSetting()
} else {
res && res.data && res.data.info && eMessage.error(res.data.info)
}
}
onMounted(() => {
getLisSetting()
})
</script>
<style lang="less" scoped>
.lis-setting {
background-color: #f5f7fa;
width: 100%;
height: 90vh;
box-sizing: border-box;
padding: 20px;
display: flex;
flex-direction: column;
gap: 20px;
.setting-item {
background-color: #fff;
border-radius: 12px;
padding: 24px 32px;
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
.label {
font-size: 28px;
font-weight: 500;
color: #303133;
}
input {
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 30px;
transition: box-shadow 0.2s ease;
border-radius: 10px;
}
.options {
display: flex;
gap: 12px;
flex-wrap: wrap;
button {
min-width: 120px;
height: 56px;
padding: 0 24px;
border: 1px solid #dcdfe6;
background-color: #fff;
border-radius: 8px;
font-size: 24px;
color: #606266;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
&.active {
color: #fff;
background-color: #409eff;
border-color: #409eff;
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
}
}
}
}
}
</style>

12
src/router/router.ts

@ -118,12 +118,12 @@ router.beforeEach((to, from, next) => {
return next('/login') // 保存当前访问的路径,用于登录后重定向
}
// 判断是否需要 Admin 权限
if (
to.matched.some((record) => record.meta.requiresAdmin) &&
user.usrRole !== 'Admin'
) {
return next({ path: '/notFound' }) // 权限不足,重定向到首页或者其他页面
}
// if (
// to.matched.some((record) => record.meta.requiresAdmin) &&
// user.usrRole !== 'Admin'
// ) {
// return next({ path: '/notFound' }) // 权限不足,重定向到首页或者其他页面
// }
}
// next() // 删除这行,否则控制台警告

125
src/services/Index/settings/settings.ts

@ -4,7 +4,7 @@ import apiClient from '../../../utils/axios'
export const setTemperature = async (data: any) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setTemperature?val=${data}`,
`/api/v1/app/DeviceSetting/setTemperature?val=${data}`,
)
return res.data
} catch (error) {
@ -17,7 +17,7 @@ export const setLanguage = async (language: 'zh_CN' | 'en_US') => {
console.log('修改语言', language)
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setLanguage?val=${language}`,
`/api/v1/app/DeviceSetting/setLanguage?val=${language}`,
)
return res.data
} catch (error) {
@ -25,11 +25,52 @@ export const setLanguage = async (language: 'zh_CN' | 'en_US') => {
}
}
// 设置自动打印报告
export const setAutoPrint = async (data: any) => {
try {
const res = await apiClient.post(
`/api/v1/app/DeviceSetting/setAutoPrint?val=${data}`,
)
return res.data
} catch (error) {
console.log('设置自动打印出错', error)
}
}
// 设置自动登出
export const setAutoLogout = async (data: any) => {
try {
const res = await apiClient.post(
`/api/v1/app/DeviceSetting/setAutoLogout?val=${data}`,
)
return res.data
} catch (error) {
console.log('设置自动登出出错', error)
}
}
//获取系统设置
export const getSystemSettings = async () => {
try {
const res = await apiClient.post('/api/v1/app/DeviceSetting/getSetting')
return res.data
} catch (error) {
console.log('获取系统设置出错', error)
}
}
// LIS 相关
export type LISType = 'SINGLE_TRACK' | 'DOUBLE_TRACK'
export const LISTypeMap = {
SINGLE_TRACK: '单向',
DOUBLE_TRACK: '双向',
}
// 设置LIS类型
export const setLISType = async (data: any) => {
export const setLISType = async (data: LISType) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setLISType?val=${data}`,
`/api/v1/app/LISSetting/setLISType?val=${data}`,
)
return res.data
} catch (error) {
@ -37,11 +78,18 @@ export const setLISType = async (data: any) => {
}
}
export type LISSerialBaudrate = 'B9600' | 'B12800' | 'B19200' | 'B115200'
export const LISSerialBaudrateMap = {
B9600: '9,600bps',
B12800: '12,800bps',
B19200: '19,200bps',
B115200: '115,200bps',
}
// 设置LIS串口波特率
export const setLISSerialBaudrate = async (data: any) => {
export const setLISSerialBaudrate = async (data: LISSerialBaudrate) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setLISSerialBaudrate?val=${data}`,
`/api/v1/app/LISSetting/setLISSerialBaudrate?val=${data}`,
data,
)
return res.data
@ -49,12 +97,12 @@ export const setLISSerialBaudrate = async (data: any) => {
console.log('设置LIS串口波特率出错', error)
}
}
export type LISProtocol = 'Boditech' | 'Simens'
// 设置LIS协议
export const setLISProtocol = async (data: any) => {
export const setLISProtocol = async (data: LISProtocol) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setLISProtocol?val=${data}`,
`/api/v1/app/LISSetting/setLISProtocol?val=${data}`,
)
return res.data
} catch (error) {
@ -63,10 +111,10 @@ export const setLISProtocol = async (data: any) => {
}
// 设置LIS端口
export const setLISNetPort = async (data: any) => {
export const setLISNetPort = async (data: number | string) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setLISNetPort?val=${data}`,
`/api/v1/app/LISSetting/setLISNetPort?val=${data}`,
)
return res.data
} catch (error) {
@ -75,10 +123,10 @@ export const setLISNetPort = async (data: any) => {
}
// 设置LIS IP
export const setLISNetIp = async (data: any) => {
export const setLISNetIp = async (data: string) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setLISNetIp?val=${data}`,
`/api/v1/app/LISSetting/setLISNetIp?val=${data}`,
)
return res.data
} catch (error) {
@ -87,22 +135,26 @@ export const setLISNetIp = async (data: any) => {
}
// 设置LIS是否自动上传报告
export const setLISAutoExport = async (data: any) => {
export const setLISAutoExport = async (data: boolean) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setLISAutoExport?val=${data}`,
`/api/v1/app/LISSetting/setLISAutoExport?val=${data}`,
)
return res.data
} catch (error) {
console.log('设置LIS自动上传出错', error)
}
}
export type LISInterface = 'SERIAL' | 'NETWORK'
export const LISInterfaceMap = {
SERIAL: 'Serial',
NETWORK: 'TCP/IP',
}
// 设置LIS接口
export const setLISIF = async (data: any) => {
export const setLISInterface = async (data: LISInterface) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setLISIF?val=${data}`,
`/api/v1/app/LISSetting/setLIFIf?val=${data}`,
)
return res.data
} catch (error) {
@ -110,36 +162,21 @@ export const setLISIF = async (data: any) => {
}
}
// 设置自动打印报告
export const setAutoPrint = async (data: any) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setAutoPrint?val=${data}`,
)
return res.data
} catch (error) {
console.log('设置自动打印出错', error)
}
}
// 设置自动登出
export const setAutoLogout = async (data: any) => {
try {
const res = await apiClient.post(
`/api/v1/app/AppSetting/setAutoLogout?val=${data}`,
)
return res.data
} catch (error) {
console.log('设置自动登出出错', error)
}
export type LISSettings = {
LISType: LISType
LISProtocol: LISProtocol
LIFIf: LISInterface
LISAutoExport: boolean
LISSerialBaudrate: LISSerialBaudrate
LISNetIp: string
LISNetPort: number
}
//获取系统设置
export const getSystemSettings = async () => {
export const getLISSetting = async () => {
try {
const res = await apiClient.post('/api/v1/app/AppSetting/getAppSettings')
const res = await apiClient.post(`/api/v1/app/LISSetting/getSetting`)
return res.data
} catch (error) {
console.log('获取系统设置出错', error)
console.log('设置LIS配置出错', error)
}
}
Loading…
Cancel
Save