|
@ -24,20 +24,55 @@ |
|
|
</button> |
|
|
</button> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="setting-item"> |
|
|
|
|
|
<span class="label">孵育温度</span> |
|
|
|
|
|
<div class="options"> |
|
|
|
|
|
<button |
|
|
|
|
|
v-for="t in temperatures" |
|
|
|
|
|
:key="t" |
|
|
|
|
|
:class="{ active: settings.temperature === t }" |
|
|
|
|
|
@click="updateSetting('temperature', t)" |
|
|
|
|
|
> |
|
|
|
|
|
{{ t }} |
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
|
<div class="setting-item-box"> |
|
|
|
|
|
<div class="setting-item setting-item-no-border"> |
|
|
|
|
|
<span class="label">整体温度控制</span> |
|
|
|
|
|
<div class="options"> |
|
|
|
|
|
<input |
|
|
|
|
|
style="width: 150px" |
|
|
|
|
|
v-model="settings.allTemperature" |
|
|
|
|
|
type="number" |
|
|
|
|
|
@focus="showKeyboard('number', 1)" |
|
|
|
|
|
readonly |
|
|
|
|
|
/> |
|
|
|
|
|
<button @click="updateSetting('allTemperature', settings.allTemperature)"> |
|
|
|
|
|
设置 |
|
|
|
|
|
</button> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="setting-item setting-item-no-border"> |
|
|
|
|
|
<span class="label">孵育盘温度</span> |
|
|
|
|
|
<div class="options"> |
|
|
|
|
|
<input |
|
|
|
|
|
style="width: 150px" |
|
|
|
|
|
v-model="settings.incubateBoxTemperature" |
|
|
|
|
|
type="number" |
|
|
|
|
|
@focus="showKeyboard('number',2)" |
|
|
|
|
|
readonly |
|
|
|
|
|
/> |
|
|
|
|
|
<button @click="updateSetting('incubateBoxTemperature', settings.incubateBoxTemperature)"> |
|
|
|
|
|
设置 |
|
|
|
|
|
</button> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="setting-item setting-item-no-border"> |
|
|
|
|
|
<span class="label">板夹区温度</span> |
|
|
|
|
|
<div class="options"> |
|
|
|
|
|
<input |
|
|
|
|
|
style="width: 150px" |
|
|
|
|
|
v-model="settings.plateBoxTemperature" |
|
|
|
|
|
type="number" |
|
|
|
|
|
@focus="showKeyboard('number',3)" |
|
|
|
|
|
readonly |
|
|
|
|
|
/> |
|
|
|
|
|
<button @click="updateSetting('plateBoxTemperature', settings.plateBoxTemperature)"> |
|
|
|
|
|
设置 |
|
|
|
|
|
</button> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="setting-item"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="setting-item" style="border-radius: 0"> |
|
|
<span class="label">DHCP</span> |
|
|
<span class="label">DHCP</span> |
|
|
<div class="options"> |
|
|
<div class="options"> |
|
|
<button |
|
|
<button |
|
@ -65,7 +100,7 @@ |
|
|
style="min-width: 250px" |
|
|
style="min-width: 250px" |
|
|
v-model="settings.localIp" |
|
|
v-model="settings.localIp" |
|
|
type="text" |
|
|
type="text" |
|
|
@focus="showKeyboard()" |
|
|
|
|
|
|
|
|
@focus="showKeyboard(undefined, 4)" |
|
|
readonly |
|
|
readonly |
|
|
/> |
|
|
/> |
|
|
<button @click="updateSetting('localIP', settings.localIp)"> |
|
|
<button @click="updateSetting('localIP', settings.localIp)"> |
|
@ -126,6 +161,7 @@ |
|
|
<div class="keyboard" v-if="keyboardVisible"> |
|
|
<div class="keyboard" v-if="keyboardVisible"> |
|
|
<SimpleKeyboard |
|
|
<SimpleKeyboard |
|
|
:input="currentInputValue" |
|
|
:input="currentInputValue" |
|
|
|
|
|
:layout |
|
|
@onChange="handleKeyboardInput" |
|
|
@onChange="handleKeyboardInput" |
|
|
@onKeyPress="handleKeyPress" |
|
|
@onKeyPress="handleKeyPress" |
|
|
/> |
|
|
/> |
|
@ -142,20 +178,32 @@ import { |
|
|
setAutoPrint, |
|
|
setAutoPrint, |
|
|
setAutoLogout, |
|
|
setAutoLogout, |
|
|
getTemperatureRange, |
|
|
getTemperatureRange, |
|
|
setTemperature, |
|
|
|
|
|
setDHCP, |
|
|
setDHCP, |
|
|
setLocalIP, |
|
|
setLocalIP, |
|
|
setAutoLogoutTime, |
|
|
|
|
|
} from '../../../services/Index/settings/settings' |
|
|
|
|
|
|
|
|
setAutoLogoutTime, setAllTemperature, setIncubateBoxTemperature, setPlateBoxTemperature |
|
|
|
|
|
} from '@/services' |
|
|
import { eMessage, isValidIPv4 } from '../utils' |
|
|
import { eMessage, isValidIPv4 } from '../utils' |
|
|
|
|
|
|
|
|
|
|
|
const layout = ref() |
|
|
|
|
|
|
|
|
|
|
|
const numericLayout = { |
|
|
|
|
|
default: [ |
|
|
|
|
|
'1 2 3', |
|
|
|
|
|
'4 5 6', |
|
|
|
|
|
'7 8 9', |
|
|
|
|
|
'{bksp} 0 {enter}' // 包含删除和确认键 |
|
|
|
|
|
], |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 系统设置状态 |
|
|
// 系统设置状态 |
|
|
interface Settings { |
|
|
interface Settings { |
|
|
language: string |
|
|
language: string |
|
|
autoPrint: boolean |
|
|
autoPrint: boolean |
|
|
autoLogout: boolean |
|
|
autoLogout: boolean |
|
|
autoLogoutTimeout: number |
|
|
autoLogoutTimeout: number |
|
|
temperature: number |
|
|
|
|
|
|
|
|
allTemperature: number | undefined |
|
|
|
|
|
incubateBoxTemperature:number |
|
|
|
|
|
plateBoxTemperature: number |
|
|
DHCP: boolean |
|
|
DHCP: boolean |
|
|
localIp: string |
|
|
localIp: string |
|
|
} |
|
|
} |
|
@ -165,7 +213,9 @@ const settings = ref<Settings>({ |
|
|
autoPrint: true, |
|
|
autoPrint: true, |
|
|
autoLogout: false, |
|
|
autoLogout: false, |
|
|
autoLogoutTimeout: 10, |
|
|
autoLogoutTimeout: 10, |
|
|
temperature: 0, |
|
|
|
|
|
|
|
|
allTemperature: 20, |
|
|
|
|
|
incubateBoxTemperature:20, |
|
|
|
|
|
plateBoxTemperature: 20, |
|
|
DHCP: true, |
|
|
DHCP: true, |
|
|
localIp: '', |
|
|
localIp: '', |
|
|
}) |
|
|
}) |
|
@ -210,12 +260,21 @@ const fetchSettings = async () => { |
|
|
const res = await getSystemSettings() |
|
|
const res = await getSystemSettings() |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
settings.value = res.data |
|
|
settings.value = res.data |
|
|
|
|
|
if (res.data.incubateBoxTemperature === res.data.plateBoxTemperature) { |
|
|
|
|
|
settings.value.allTemperature = res.data.incubateBoxTemperature |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
eMessage.error('获取系统设置失败') |
|
|
eMessage.error('获取系统设置失败') |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isIntegerInRange(str: string): boolean { |
|
|
|
|
|
// 匹配 20-40 的整数 |
|
|
|
|
|
const regex = /^(2[0-9]|3[0-9]|40)$/; |
|
|
|
|
|
return regex.test(str); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 更新设置 |
|
|
// 更新设置 |
|
|
const updateSetting = async (key: string, value: any) => { |
|
|
const updateSetting = async (key: string, value: any) => { |
|
|
try { |
|
|
try { |
|
@ -233,8 +292,26 @@ const updateSetting = async (key: string, value: any) => { |
|
|
case 'autoLogoutTimeout': |
|
|
case 'autoLogoutTimeout': |
|
|
res = await setAutoLogoutTime(value) |
|
|
res = await setAutoLogoutTime(value) |
|
|
break |
|
|
break |
|
|
case 'temperature': |
|
|
|
|
|
res = await setTemperature(value) |
|
|
|
|
|
|
|
|
case 'allTemperature': |
|
|
|
|
|
if (!isIntegerInRange(value)) { |
|
|
|
|
|
eMessage.error('输入有误, 温度范围为20℃-40℃') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
res = await setAllTemperature(value) |
|
|
|
|
|
break |
|
|
|
|
|
case 'incubateBoxTemperature': |
|
|
|
|
|
if (!isIntegerInRange(value)) { |
|
|
|
|
|
eMessage.error('输入有误, 温度范围为20℃-40℃') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
res = await setIncubateBoxTemperature(value) |
|
|
|
|
|
break |
|
|
|
|
|
case 'plateBoxTemperature': |
|
|
|
|
|
if (!isIntegerInRange(value)) { |
|
|
|
|
|
eMessage.error('输入有误, 温度范围为20℃-40℃') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
res = await setPlateBoxTemperature(value) |
|
|
break |
|
|
break |
|
|
case 'DHCP': |
|
|
case 'DHCP': |
|
|
res = await setDHCP(value) |
|
|
res = await setDHCP(value) |
|
@ -252,8 +329,18 @@ const updateSetting = async (key: string, value: any) => { |
|
|
|
|
|
|
|
|
if (res?.success) { |
|
|
if (res?.success) { |
|
|
settings.value = { ...settings.value, [key]: value } |
|
|
settings.value = { ...settings.value, [key]: value } |
|
|
|
|
|
|
|
|
|
|
|
if(key === 'allTemperature') { |
|
|
|
|
|
settings.value.incubateBoxTemperature = settings.value.plateBoxTemperature = value |
|
|
|
|
|
} |
|
|
|
|
|
if(settings.value.incubateBoxTemperature === settings.value.plateBoxTemperature) { |
|
|
|
|
|
settings.value.allTemperature = settings.value.incubateBoxTemperature |
|
|
|
|
|
}else { |
|
|
|
|
|
settings.value.allTemperature = undefined |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
|
|
|
console.log(error) |
|
|
eMessage.error('设置更新失败') |
|
|
eMessage.error('设置更新失败') |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -284,17 +371,36 @@ const keyboardVisible = ref(false) |
|
|
const currentInputValue = ref('') |
|
|
const currentInputValue = ref('') |
|
|
|
|
|
|
|
|
// 显示键盘 |
|
|
// 显示键盘 |
|
|
const showKeyboard = () => { |
|
|
|
|
|
|
|
|
const showKeyboard = (KeyboardType: string | undefined, type: number) => { |
|
|
|
|
|
inputNumberType.value = type |
|
|
|
|
|
if (KeyboardType) { |
|
|
|
|
|
layout.value = numericLayout |
|
|
|
|
|
}else{ |
|
|
|
|
|
layout.value = undefined |
|
|
|
|
|
} |
|
|
|
|
|
keyboardVisible.value = false |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
keyboardVisible.value = true |
|
|
|
|
|
}, 200) |
|
|
// 清空当前输入值,避免累加 |
|
|
// 清空当前输入值,避免累加 |
|
|
currentInputValue.value = settings.value.localIp |
|
|
|
|
|
keyboardVisible.value = true |
|
|
|
|
|
|
|
|
currentInputValue.value = settings.value[inputType[type]] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const inputNumberType = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
const inputType = { |
|
|
|
|
|
1:'allTemperature', |
|
|
|
|
|
2:'incubateBoxTemperature', |
|
|
|
|
|
3:'plateBoxTemperature', |
|
|
|
|
|
4:'localIp', |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 处理键盘输入 |
|
|
// 处理键盘输入 |
|
|
const handleKeyboardInput = (value: string) => { |
|
|
const handleKeyboardInput = (value: string) => { |
|
|
|
|
|
|
|
|
// 更新当前输入值 |
|
|
// 更新当前输入值 |
|
|
currentInputValue.value = value |
|
|
currentInputValue.value = value |
|
|
settings.value.localIp = value |
|
|
|
|
|
|
|
|
settings.value[inputType[inputNumberType.value]] = value |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 处理键盘按键 |
|
|
// 处理键盘按键 |
|
@ -333,7 +439,15 @@ onUnmounted(() => { |
|
|
display: flex; |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
flex-direction: column; |
|
|
gap: 20px; |
|
|
gap: 20px; |
|
|
|
|
|
.setting-item-box > :nth-child(2) { |
|
|
|
|
|
border-top: 1px solid #ddd; |
|
|
|
|
|
border-bottom: 1px solid #ddd; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.setting-item-no-border { |
|
|
|
|
|
border-radius: 0 !important; |
|
|
|
|
|
box-shadow: none !important; |
|
|
|
|
|
} |
|
|
.setting-item { |
|
|
.setting-item { |
|
|
background-color: #fff; |
|
|
background-color: #fff; |
|
|
border-radius: 12px; |
|
|
border-radius: 12px; |
|
|