|
|
@ -71,11 +71,11 @@ |
|
|
|
<div class="options"> |
|
|
|
<input |
|
|
|
type="text" |
|
|
|
v-model="lisSettings.LISNetPort" |
|
|
|
v-model="lisSettings.LISNetPortStr" |
|
|
|
@focus="showKeyboard('port')" |
|
|
|
readonly |
|
|
|
/> |
|
|
|
<button @click="updLisPort(lisSettings.LISNetPort)">设置</button> |
|
|
|
<button @click="updLisPort(lisSettings.LISNetPortStr)">设置</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div |
|
|
@ -151,17 +151,22 @@ import { |
|
|
|
} from '@/services' |
|
|
|
import { onMounted, onUnmounted, ref } from 'vue' |
|
|
|
import * as R from 'ramda' |
|
|
|
import { eMessage } from '../utils' |
|
|
|
import { eMessage, isValidIPv4 } from '../utils' |
|
|
|
|
|
|
|
const LISInterfaceItems = R.toPairs(LISInterfaceMap) |
|
|
|
const LISSerialBaudrateItems = R.toPairs(LISSerialBaudrateMap) |
|
|
|
const LISTypeItems = R.toPairs(LISTypeMap) |
|
|
|
|
|
|
|
const lisSettings = ref<LISSettings | undefined>(undefined) |
|
|
|
const lisSettings = ref<(LISSettings & { LISNetPortStr: string }) | undefined>( |
|
|
|
undefined, |
|
|
|
) |
|
|
|
const getLisSetting = async () => { |
|
|
|
const res = await getLISSetting() |
|
|
|
if (res && res.success) { |
|
|
|
lisSettings.value = res.data |
|
|
|
lisSettings.value = { |
|
|
|
...res.data, |
|
|
|
LISNetPortStr: res.data.LISNetPort.toString(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -211,8 +216,13 @@ const updLisAutoExport = async (auto: boolean) => { |
|
|
|
} |
|
|
|
|
|
|
|
const updLisIP = async (ip: string) => { |
|
|
|
const addr = ip.trim() |
|
|
|
if (!isValidIPv4(addr)) { |
|
|
|
eMessage.error('请输入合法的IP地址') |
|
|
|
return |
|
|
|
} |
|
|
|
hideKeyboard() |
|
|
|
const res = await setLISNetIp(ip) |
|
|
|
const res = await setLISNetIp(addr) |
|
|
|
if (res && res.success) { |
|
|
|
getLisSetting() |
|
|
|
} else { |
|
|
@ -220,9 +230,14 @@ const updLisIP = async (ip: string) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const updLisPort = async (port: number) => { |
|
|
|
const updLisPort = async (port: string) => { |
|
|
|
const p = port.toString().trim() |
|
|
|
if (!/^\d+$/.test(p)) { |
|
|
|
eMessage.error('请输入合法的端口值') |
|
|
|
return |
|
|
|
} |
|
|
|
hideKeyboard() |
|
|
|
const res = await setLISNetPort(port) |
|
|
|
const res = await setLISNetPort(p) |
|
|
|
if (res && res.success) { |
|
|
|
getLisSetting() |
|
|
|
} else { |
|
|
@ -245,7 +260,7 @@ const showKeyboard = (field: 'ip' | 'port') => { |
|
|
|
currentInputValue.value = lisSettings.value?.LISNetIp || '' |
|
|
|
} |
|
|
|
if (field === 'port') { |
|
|
|
currentInputValue.value = lisSettings.value?.LISNetPort.toString() || '' |
|
|
|
currentInputValue.value = lisSettings.value?.LISNetPortStr || '' |
|
|
|
} |
|
|
|
currentInputField.value = field |
|
|
|
keyboardVisible.value = true |
|
|
@ -260,7 +275,7 @@ const handleKeyboardInput = (value: string) => { |
|
|
|
if (currentInputField.value === 'ip') { |
|
|
|
lisSettings.value!.LISNetIp = value |
|
|
|
} else { |
|
|
|
lisSettings.value!.LISNetPort = +value |
|
|
|
lisSettings.value!.LISNetPortStr = value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|