fix: 修改dueros

This commit is contained in:
100011797 2023-07-11 18:05:24 +08:00
parent 3dedcb8a5c
commit 57b5a08365
8 changed files with 118 additions and 54 deletions

View File

@ -78,6 +78,7 @@
/>
<j-input
v-else
:placeholder="placeholder"
allowClear
type="text"
v-model:value="myValue"
@ -144,6 +145,10 @@ const props = defineProps({
mode: {
type: String as PropType<'multiple' | 'tags' | 'combobox' | ''>,
default: ''
},
placeholder: {
type: String,
default: () => '',
}
});
// type Props = {

View File

@ -14,7 +14,7 @@
:name="['dataSource', index, 'value']"
:rules="[
{
required: true,
required: record.required,
message:
record.type === 'enum' ||
record.type === 'boolean'

View File

@ -56,7 +56,7 @@
placeholder="请选择属性"
v-model:value="modelRef.message.properties"
show-search
@change="onPropertyChange"
@change="(val) => onPropertyChange(val, false)"
>
<j-select-option
v-for="i in metadata?.properties || []"
@ -89,6 +89,7 @@
:itemType="
property.valueType?.type || property.type || 'int'
"
:placeholder="property.valueType?.type === 'array' ? '多个数据用英文,分割' : ''"
:options="
property.valueType?.type === 'enum'
? (property?.valueType?.elements || []).map(
@ -101,8 +102,8 @@
)
: property.valueType?.type === 'boolean'
? [
{ label: '是', value: true },
{ label: '否', value: false },
{ label: property.valueType?.trueText, value: property.valueType?.trueValue },
{ label: property.valueType?.falseText, value: property.valueType?.falseValue },
]
: undefined
"
@ -208,9 +209,9 @@ const onPropertyChange = (val: string, flag?: boolean) => {
(item: any) => item.id === val,
);
property.value = _item || {};
if(!flag){
modelRef.message.value = undefined
}
}
if(!flag){
modelRef.message.value = undefined
}
};
@ -249,6 +250,7 @@ const funcChange = (val: string) => {
name: item.name,
value: undefined,
valueType: item?.valueType?.type,
required: item?.expands?.required
};
});
modelRef.message.inputs = list;
@ -265,7 +267,6 @@ const saveBtn = () =>
resolve(false);
});
}
console.log(_data)
emit('update:modelValue', _data)
resolve(_data);
})

View File

@ -42,6 +42,10 @@
required: true,
message: '请选择产品',
},
// {
// validator: _validator,
// trigger: 'change',
// },
]"
>
<j-select
@ -147,11 +151,23 @@
: `动作映射${index + 1}`
"
>
<template #extra
><AIcon
type="DeleteOutlined"
@click="delItem(index)"
/></template>
<template #extra>
<div
style="width: 20px"
@click.stop
>
<j-popconfirm
title="确认删除?"
@confirm.prevent="
delItem(index)
"
>
<AIcon
type="DeleteOutlined"
/>
</j-popconfirm>
</div>
</template>
<j-row :gutter="24">
<j-col :span="12">
<j-form-item
@ -326,15 +342,25 @@
: `属性映射${index + 1}`
"
>
<template #extra
><AIcon
type="DeleteOutlined"
@click="
delPropertyItem(
index,
)
"
/></template>
<template #extra>
<div
style="width: 20px"
@click.stop
>
<j-popconfirm
title="确认删除?"
@confirm.prevent="
delPropertyItem(
index,
)
"
>
<AIcon
type="DeleteOutlined"
/>
</j-popconfirm>
</div>
</template>
<j-row :gutter="24">
<j-col :span="12">
<j-form-item
@ -392,7 +418,6 @@
v-model:value="
item.target
"
mode="tags"
show-search
>
<j-select-option
@ -486,7 +511,7 @@ import {
savePatch,
detail,
} from '@/api/northbound/dueros';
import _ from 'lodash';
import _, { cloneDeep } from 'lodash';
import { useMenuStore } from '@/store/menu';
import { onlyMessage } from '@/utils/comm';
@ -517,7 +542,7 @@ const modelRef = reactive({
propertyMappings: [
{
source: undefined,
target: [],
target: undefined,
},
],
description: undefined,
@ -569,25 +594,31 @@ const addItem = () => {
const delItem = (index: number) => {
modelRef.actionMappings.splice(index, 1);
if (!modelRef.actionMappings.length) {
addItem();
}
};
const addPropertyItem = () => {
propertyActiveKey.value.push(String(modelRef.propertyMappings.length));
modelRef.propertyMappings.push({
source: undefined,
target: [],
target: undefined,
});
};
const delPropertyItem = (index: number) => {
modelRef.propertyMappings.splice(index, 1);
if (!modelRef.propertyMappings.length) {
addPropertyItem();
}
};
const productChange = (value: string) => {
modelRef.propertyMappings = modelRef.propertyMappings.map((item) => {
return { source: item.source, target: [] };
modelRef.propertyMappings = modelRef.propertyMappings?.map((item) => {
return { source: item.source, target: undefined };
});
modelRef.actionMappings = modelRef.actionMappings.map((item) => {
modelRef.actionMappings = modelRef.actionMappings?.map((item) => {
return {
...item,
command: {
@ -608,10 +639,10 @@ const productChange = (value: string) => {
};
const typeChange = () => {
modelRef.propertyMappings = modelRef.propertyMappings.map((item) => {
modelRef.propertyMappings = modelRef.propertyMappings?.map((item) => {
return { source: undefined, target: item.target };
});
modelRef.actionMappings = modelRef.actionMappings.map((item) => {
modelRef.actionMappings = modelRef.actionMappings?.map((item) => {
return { ...item, action: undefined };
});
};
@ -645,49 +676,60 @@ const getTypes = async () => {
};
const getDuerOSProperties = (val: string) => {
console.log(val);
const arr = modelRef.propertyMappings.map((item) => item?.source) || [];
const arr = modelRef.propertyMappings?.map((item) => item?.source) || [];
const checked = _.cloneDeep(arr);
const _index = checked.findIndex((i) => i === val);
//
checked.splice(_index, 1);
const targetList = findApplianceType.value?.properties;
const list = targetList?.filter(
(i: { id: string }) => !checked.includes(i?.id as any),
(i: { id: string }) => !checked?.includes(i?.id as any),
);
return list || [];
};
const getProductProperties = (val: string[]) => {
const items =
modelRef.propertyMappings.map((item: { target: string[] }) =>
item?.target.map((j) => j),
) || [];
const checked = _.flatMap(items);
modelRef.propertyMappings?.map((item: any) => item?.target) || [];
const checked = items.filter((i) => i);
const _checked: any[] = [];
checked.map((_item) => {
if (!val.includes(_item)) {
checked?.map((_item) => {
if (!val?.includes(_item)) {
_checked.push(_item);
}
});
const sourceList = findProductMetadata.value?.properties;
const list = sourceList?.filter(
(i: { id: string }) => !_checked.includes(i.id),
(i: { id: string }) => !_checked?.includes(i.id),
);
return list || [];
};
const getTypesActions = (val: string) => {
const items = modelRef.actionMappings.map((item) => item?.action) || [];
const items = modelRef.actionMappings?.map((item) => item?.action) || [];
const checked = _.cloneDeep(items);
const _index = checked.findIndex((i) => i === val);
checked.splice(_index, 1);
const actionsList = findApplianceType.value?.actions || [];
const list = actionsList?.filter(
(i: { id: string; name: string }) => !checked.includes(i?.id as any),
(i: { id: string; name: string }) => !checked?.includes(i?.id as any),
);
return list || [];
};
// const _validator = (_rule: any, value: string): Promise<any> =>
// new Promise((resolve, reject) => {
// const _item = productList.value.find((item) => item.id === value);
// if (!_item) {
// return reject('');
// }
// return resolve('');
// });
watchEffect(() => {
console.log(modelRef.id)
})
const saveBtn = async () => {
const tasks: any[] = [];
for (let i = 0; i < command.value.length; i++) {
@ -704,6 +746,16 @@ const saveBtn = async () => {
.then(async (data: any) => {
if (tasks.every((item) => item) && data) {
loading.value = true;
data.propertyMappings = data.propertyMappings?.map(
(it: any) => {
return {
source: it.source,
target: Array.isArray(it?.target)
? it?.target
: [it?.target],
};
},
);
const resp = await savePatch(data).finally(() => {
loading.value = false;
});
@ -715,12 +767,12 @@ const saveBtn = async () => {
}
})
.catch((err: any) => {
const _arr = err.errorFields.map((item: any) => item.name);
_arr.map((item: string | any[]) => {
const _arr = err.errorFields?.map((item: any) => item.name);
_arr?.map((item: string | any[]) => {
if (item.length >= 3) {
if (
item[0] === 'propertyMappings' &&
!propertyActiveKey.value.includes(item[1])
!propertyActiveKey.value?.includes(item[1])
) {
propertyActiveKey.value.push(item[1]);
}
@ -738,16 +790,16 @@ watch(
() => route.params?.id,
async (newId) => {
if (newId) {
getProduct(newId as string);
await getProduct(newId as string);
getTypes();
if (newId === ':id') return;
const resp = await detail(newId as string);
const _data: any = resp.result;
const _obj = cloneDeep(_data);
if (_data) {
_data.applianceType = _data?.applianceType?.value;
_obj.applianceType = _obj?.applianceType?.value;
}
Object.assign(modelRef, _data);
console.log(modelRef.propertyMappings);
Object.assign(modelRef, _obj);
}
},
{ immediate: true, deep: true },

View File

@ -26,7 +26,7 @@ export const USER_CENTER_MENU_DATA = {
permissions: [
{
permission: 'user',
action: ['update-self-pwd']
actions: ['update-self-pwd']
},
{
permission: 'system_config',

View File

@ -6,7 +6,7 @@
@cancel="emit('close')"
@ok="onSave"
>
<Role v-model="_selectedRowKeys" :gridColumn="1" />
<Role v-model="_selectedRowKeys" :gridColumn="2" />
</j-modal>
</template>

View File

@ -304,12 +304,12 @@ const onAction = (e: boolean) => {
role: {
idList: [],
},
permissions: [
permissions: props.provider === 'alarm' ? [
{
id: 'alarm-config',
actions: ['query'],
},
],
] : [],
},
},
],

View File

@ -8,6 +8,7 @@
noPagination
model="TABLE"
>
<!-- :rowKey="(record) => record.id + record.method" -->
<template #url="slotProps">
<span
style="color: #1d39c4; cursor: pointer"
@ -68,6 +69,11 @@ const columns = [
key: 'summary',
},
];
watchEffect(() => {
console.log(props.tableData)
})
const rowSelection = {
// onSelect: (record: any) => {
// const targetId = record.id;