fix: 修改opc_ua写入

This commit is contained in:
100011797 2023-05-31 16:09:49 +08:00
parent 5e0ca4e2aa
commit 573e42724d
5 changed files with 81 additions and 8 deletions

View File

@ -55,3 +55,6 @@ export const scanOpcUAList = (data: any) =>
data?.nodeId || '' data?.nodeId || ''
}`, }`,
); );
export const queryTypeList = () => server.get(`/data-collect/opc/data-types`);

View File

@ -19,13 +19,15 @@
<j-select <j-select
style="width: 100%" style="width: 100%"
v-model:value="formData.configuration.type" v-model:value="formData.configuration.type"
:options="[ :options="options
{ value: 'Number', label: '数值类型' }, // [
{ value: 'DateTime', label: '时间类型' }, // { value: 'Number', label: '' },
{ value: 'Array', label: '数组类型' }, // { value: 'DateTime', label: '' },
{ value: 'String', label: '文本类型' }, // { value: 'Array', label: '' },
{ value: 'Boolean', label: '布尔' }, // { value: 'String', label: '' },
]" // { value: 'Boolean', label: '' },
// ]
"
placeholder="请选择数据类型" placeholder="请选择数据类型"
allowClear allowClear
show-search show-search
@ -98,6 +100,7 @@ import {
savePoint, savePoint,
updatePoint, updatePoint,
_validateField, _validateField,
queryTypeList
} from '@/api/data-collect/collector'; } from '@/api/data-collect/collector';
import { OPCUARules } from '../../data.ts'; import { OPCUARules } from '../../data.ts';
import type { FormInstance } from 'ant-design-vue'; import type { FormInstance } from 'ant-design-vue';
@ -118,6 +121,7 @@ const formRef = ref<FormInstance>();
const id = props.data.id; const id = props.data.id;
const collectorId = props.data.collectorId; const collectorId = props.data.collectorId;
const provider = props.data.provider; const provider = props.data.provider;
const options = ref([]);
const formData = ref({ const formData = ref({
name: '', name: '',
@ -157,6 +161,19 @@ const filterOption = (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0; return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
}; };
onMounted(() => {
queryTypeList().then((resp: any) => {
if(resp.status === 200){
options.value = (resp?.result || []).map((item: any) => {
return {
label: item,
value: item
}
})
}
})
})
watch( watch(
() => props.data, () => props.data,
(value) => { (value) => {

View File

@ -130,6 +130,7 @@ const onCheck = (checkedKeys: any, info: any) => {
value: last ? last?.accessModes?.value : one?.accessModes || [], value: last ? last?.accessModes?.value : one?.accessModes || [],
check: true, check: true,
}, },
type: one?.type,
configuration: { configuration: {
...one?.configuration, ...one?.configuration,
interval: { interval: {

View File

@ -65,6 +65,7 @@ const handleOk = async () => {
pointKey: item.id, pointKey: item.id,
configuration: { configuration: {
interval: item.configuration?.interval?.value, interval: item.configuration?.interval?.value,
type: item.type,
}, },
features: !item.features?.value ? [] : ['changedOnly'], features: !item.features?.value ? [] : ['changedOnly'],
accessModes: item.accessModes?.value || [], accessModes: item.accessModes?.value || [],

View File

@ -30,6 +30,57 @@
showCount showCount
/> />
</j-form-item> </j-form-item>
<j-form-item
:label="data.name"
name="value"
:rules="[
{
required: true,
message: `请输入${data.name}`,
},
]"
v-else-if="data.provider === 'OPC_UA'"
>
<j-input-number
v-if="['Double', 'Float', 'LLong', 'Long', 'Integer', 'Short'].includes(valueType)"
style="width: 100%"
placeholder="请输入"
v-model:value="formData.value"
/>
<j-select
v-else-if="['Boolean'].includes(valueType)"
style="width: 100%"
v-model:value="formData.value"
:options="[
{
label: '是',
value: true,
},
{
label: '否',
value: false,
},
]"
placeholder="请选择"
allowClear
show-search
:filter-option="filterOption"
/>
<j-date-picker
v-else-if="['DateTime'].includes(valueType)"
style="width: 100%"
format="YYYY-MM-DD HH:mm:ss"
show-time
placeholder="请选择"
@change="onChange"
/>
<j-input
v-else
placeholder="请输入"
v-model:value="formData.value"
/>
</j-form-item>
<j-form-item <j-form-item
:label="data.name" :label="data.name"
name="value" name="value"
@ -111,7 +162,7 @@ const props = defineProps({
const valueType: string = ( const valueType: string = (
props.data?.provider === 'OPC_UA' props.data?.provider === 'OPC_UA'
? props?.data?.configuration?.type || 'Number' ? props?.data?.configuration?.type || 'String'
: props.data?.configuration?.codec?.provider || 'int8' : props.data?.configuration?.codec?.provider || 'int8'
).toLocaleLowerCase(); ).toLocaleLowerCase();