Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/views/media/Device/Channel/index.vue
This commit is contained in:
XieYongHong 2023-07-11 18:09:00 +08:00
commit b73c9fdf92
11 changed files with 130 additions and 59 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,7 +31,7 @@
:columns="columns" :columns="columns"
:request="(e:any) => ChannelApi.list(e, route?.query.id as string)" :request="(e:any) => ChannelApi.list(e, route?.query.id as string)"
:defaultParams="{ :defaultParams="{
sorts: [{ name: 'notifyTime', order: 'desc' }], sorts: [{ name: 'modifyTime', order: 'desc' }],
}" }"
:params="params" :params="params"
:pagination="{ :pagination="{

View File

@ -74,7 +74,7 @@
> >
<template #description> <template #description>
<template v-if="!isPermission" <template v-if="!isPermission"
>暂无权限, 请联系管理员</template >暂无数据, 请联系管理员</template
> >
<template v-else> <template v-else>
暂无数据请先 暂无数据请先

View File

@ -156,19 +156,26 @@
</j-radio-button> </j-radio-button>
</j-radio-group> </j-radio-group>
</j-form-item> </j-form-item>
<j-form-item label="设备厂商"> <j-form-item label="设备厂商"
name="manufacturer"
:rules="[{ max: 64, message: '最多可输入64位字符', trigger: 'change' }]">
<j-input <j-input
v-model:value="formData.manufacturer" v-model:value="formData.manufacturer"
placeholder="请输入设备厂商" placeholder="请输入设备厂商"
/> />
</j-form-item> </j-form-item>
<j-form-item label="设备型号"> <j-form-item label="设备型号"
name="model"
:rules="[{ max: 64, message: '最多可输入64位字符', trigger: 'change' }]">
<j-input <j-input
v-model:value="formData.model" v-model:value="formData.model"
placeholder="请输入设备型号" placeholder="请输入设备型号"
/> />
</j-form-item> </j-form-item>
<j-form-item label="固件版本"> <j-form-item label="固件版本"
name="firmware"
:rules="[{ max: 64, message: '最多可输入64位字符', trigger: 'change' }]">
<j-input <j-input
v-model:value="formData.firmware" v-model:value="formData.firmware"
placeholder="请输入固件版本" placeholder="请输入固件版本"

View File

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

View File

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

View File

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