Merge branch 'dev' into dev-hub
This commit is contained in:
commit
45f634b37c
|
@ -4,6 +4,7 @@ import { defineStore } from "pinia";
|
|||
type DepartmentStateType = {
|
||||
productId: string;
|
||||
optType: string | undefined;
|
||||
crossPageKeys: string[];
|
||||
}
|
||||
|
||||
export const useDepartmentStore = defineStore({
|
||||
|
@ -13,14 +14,20 @@ export const useDepartmentStore = defineStore({
|
|||
// 设备资产分配弹窗操作类型:
|
||||
// 1. optType === 'handle': 手动点击资产分配按钮;
|
||||
// 2. optType === ': 产品资产分配后, 自动弹出设备资产分配
|
||||
optType: ''
|
||||
optType: '',
|
||||
crossPageKeys: [], // 表格跨页多选的keys
|
||||
}),
|
||||
actions: {
|
||||
setProductId(value: string) {
|
||||
this.productId = value
|
||||
this.productId = value;
|
||||
},
|
||||
setType(value: string | undefined) {
|
||||
this.optType = value
|
||||
this.optType = value;
|
||||
},
|
||||
setSelectedKeys(value: string[], type?: string) {
|
||||
// 分页保留选中项
|
||||
// this.crossPageKeys = type === 'pagination' ? [...new Set([...this.crossPageKeys, ...value])] : value;
|
||||
this.crossPageKeys = [...new Set([...this.crossPageKeys, ...value])];
|
||||
}
|
||||
}
|
||||
})
|
|
@ -208,6 +208,7 @@ const onPropertyChange = (val: string) => {
|
|||
(item: any) => item.id === val,
|
||||
);
|
||||
property.value = _item || {};
|
||||
modelRef.message.value = undefined
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -214,6 +214,12 @@
|
|||
item.actionType
|
||||
"
|
||||
show-search
|
||||
@change="
|
||||
() =>
|
||||
onActionTypeChange(
|
||||
index,
|
||||
)
|
||||
"
|
||||
>
|
||||
<j-select-option
|
||||
value="command"
|
||||
|
@ -491,6 +497,18 @@ const onActionCollChange = (_key: string[]) => {
|
|||
actionActiveKey.value = _key;
|
||||
};
|
||||
|
||||
const onActionTypeChange = (_index: number) => {
|
||||
modelRef.actionMappings[_index].command = {
|
||||
messageType: undefined,
|
||||
message: {
|
||||
properties: undefined,
|
||||
functionId: undefined,
|
||||
inputs: [],
|
||||
value: undefined
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const addItem = () => {
|
||||
actionActiveKey.value.push(String(modelRef.actionMappings.length));
|
||||
modelRef.actionMappings.push({
|
||||
|
@ -527,6 +545,20 @@ const productChange = (value: string) => {
|
|||
modelRef.propertyMappings = modelRef.propertyMappings.map((item) => {
|
||||
return { source: item.source, target: [] };
|
||||
});
|
||||
modelRef.actionMappings = modelRef.actionMappings.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
command: {
|
||||
messageType: undefined,
|
||||
message: {
|
||||
properties: undefined,
|
||||
functionId: undefined,
|
||||
inputs: [],
|
||||
value: undefined,
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
const item = productList.value.find((item) => item.id === value);
|
||||
if (item) {
|
||||
modelRef.productName = item.name;
|
||||
|
@ -571,7 +603,7 @@ const getTypes = async () => {
|
|||
};
|
||||
|
||||
const getDuerOSProperties = (val: string) => {
|
||||
console.log(val)
|
||||
console.log(val);
|
||||
const arr = modelRef.propertyMappings.map((item) => item?.source) || [];
|
||||
const checked = _.cloneDeep(arr);
|
||||
const _index = checked.findIndex((i) => i === val);
|
||||
|
@ -673,7 +705,7 @@ watch(
|
|||
_data.applianceType = _data?.applianceType?.value;
|
||||
}
|
||||
Object.assign(modelRef, _data);
|
||||
console.log(modelRef.propertyMappings)
|
||||
console.log(modelRef.propertyMappings);
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
|
|
|
@ -439,7 +439,7 @@ const setDevMesChartOption = (
|
|||
// // },
|
||||
// },
|
||||
{
|
||||
name: '占比',
|
||||
name: '消息量',
|
||||
data: y,
|
||||
// data: percentageY,
|
||||
type: 'line',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<pro-search class="search" type="simple" :columns="columns" target="device-instance-running-events" @search="handleSearch" />
|
||||
<pro-search class="device-search" type="simple" :columns="columns" target="device-instance-running-events" @search="handleSearch" />
|
||||
<JProTable
|
||||
ref="eventsRef"
|
||||
:columns="columns"
|
||||
|
@ -62,14 +62,14 @@ const _getEventList = (_params: any) =>
|
|||
|
||||
watchEffect(() => {
|
||||
if (events.data?.valueType?.type === 'object') {
|
||||
(events.data.valueType?.properties || []).map((i: any) => {
|
||||
(events.data.valueType?.properties || []).reverse().map((i: any) => {
|
||||
columns.value.splice(0, 0, {
|
||||
key: i.id,
|
||||
title: i.name,
|
||||
dataIndex: `${i.id}_format`,
|
||||
search: {
|
||||
type: 'string',
|
||||
},
|
||||
type: i?.valueType?.type || 'string',
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
@ -97,8 +97,8 @@ const detail = (_info: any) => {
|
|||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.search {
|
||||
padding: 0 0 0 24px;
|
||||
<style lang="less">
|
||||
.device-search {
|
||||
margin: 0 0 24px 0 ;
|
||||
}
|
||||
</style>
|
|
@ -33,8 +33,10 @@
|
|||
}指标值`,
|
||||
}"
|
||||
:name="['metrics', index, 'value', 0]"
|
||||
:label="item?.name || '指标值'"
|
||||
>
|
||||
<template #label>
|
||||
<Ellipsis>{{ item?.name || '指标值' }}</Ellipsis>
|
||||
</template>
|
||||
<ValueItem
|
||||
v-model:modelValue="item.value[0]"
|
||||
:itemType="data.valueType?.type"
|
||||
|
@ -95,6 +97,7 @@
|
|||
import { queryMetric, saveMetric } from '@/api/device/instance';
|
||||
import { useInstanceStore } from '@/store/instance';
|
||||
import { message } from 'jetlinks-ui-components';
|
||||
import { isNumber } from 'lodash-es';
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
|
@ -110,7 +113,7 @@ const instanceStore = useInstanceStore();
|
|||
const formRef = ref();
|
||||
|
||||
const modelRef = reactive<{
|
||||
metrics: any[]
|
||||
metrics: any[];
|
||||
}>({
|
||||
metrics: [],
|
||||
});
|
||||
|
@ -132,8 +135,8 @@ watch(
|
|||
) {
|
||||
const list = resp?.result.map((item: any) => {
|
||||
const val = Array.isArray(item?.value)
|
||||
? [item?.value]
|
||||
: item?.value?.split(',');
|
||||
? item?.value
|
||||
: (isNumber(item?.value) ? [item.value] : item?.value?.split(','))
|
||||
return {
|
||||
...item,
|
||||
value: val,
|
||||
|
@ -172,7 +175,7 @@ watch(
|
|||
const handleSave = () => {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(async () => {
|
||||
.then(async (_data: any) => {
|
||||
loading.value = true;
|
||||
const list = (toRaw(modelRef)?.metrics || []).map((item: any) => {
|
||||
return {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
justify-content: center;
|
||||
height: 630px;
|
||||
padding: 20px;
|
||||
background-color: #e6e6e6;
|
||||
border: 1px solid #e6e6e6;
|
||||
}
|
||||
|
||||
.driver {
|
||||
|
@ -45,6 +45,7 @@
|
|||
line-height: 22px !important;
|
||||
background-color: #fff !important;
|
||||
}
|
||||
|
||||
.driver-prev-btn.driver-disabled {
|
||||
display: none !important;
|
||||
}
|
||||
|
@ -70,4 +71,4 @@
|
|||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1035,13 +1035,6 @@ nextTick(() => {
|
|||
.item-style {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.info {
|
||||
height: 630px;
|
||||
padding: 20px;
|
||||
background-color: #e6e6e6;
|
||||
}
|
||||
|
||||
.ellipsis-style {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
|
|
|
@ -180,7 +180,7 @@ const deviceList = ref([
|
|||
const form = reactive({
|
||||
id: undefined,
|
||||
name: '',
|
||||
classifiedId: '',
|
||||
classifiedId: undefined,
|
||||
classifiedName: '',
|
||||
deviceType: '',
|
||||
describe: undefined,
|
||||
|
@ -278,7 +278,7 @@ const show = (data: any) => {
|
|||
idDisabled.value = true;
|
||||
} else if (props.isAdd === 1) {
|
||||
form.name = '';
|
||||
form.classifiedId = '';
|
||||
form.classifiedId = undefined;
|
||||
form.classifiedName = '';
|
||||
form.photoUrl = getImage('/device/instance/device-card.png');
|
||||
form.deviceType = '';
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
/>
|
||||
</j-tooltip>
|
||||
</template>
|
||||
<j-input v-model:value="modalForm.publicHost">
|
||||
<j-input v-model:value="modalForm.publicHost" placeholder="请输入公网地址">
|
||||
</j-input>
|
||||
</j-form-item>
|
||||
</j-col>
|
||||
|
@ -83,7 +83,7 @@
|
|||
/>
|
||||
</j-tooltip>
|
||||
</template>
|
||||
<j-select v-model:value="modalForm.port">
|
||||
<j-select v-model:value="modalForm.port" placeholder="请选择本地端口" show-search>
|
||||
<j-select-option
|
||||
v-for="item in optionPorts"
|
||||
:key="item"
|
||||
|
@ -105,6 +105,7 @@
|
|||
</template>
|
||||
<j-input-number
|
||||
v-model:value="modalForm.publicPort"
|
||||
placeholder="请输入公网端口"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</j-form-item>
|
||||
|
@ -142,9 +143,6 @@ const visible = ref<boolean>(false);
|
|||
*/
|
||||
const modalForm = reactive<modalState>({
|
||||
host: '0.0.0.0',
|
||||
port: '',
|
||||
publicHost: '',
|
||||
publicPort: null,
|
||||
});
|
||||
/**
|
||||
* 校验官网地址
|
||||
|
|
|
@ -13,68 +13,80 @@
|
|||
<script lang="ts" setup>
|
||||
import { getImage } from '@/utils/comm';
|
||||
import BaseMenu from '../data/baseMenu';
|
||||
import { getSystemPermission } from '@/api/initHome'
|
||||
import { getSystemPermission , updateMenus } from '@/api/initHome';
|
||||
/**
|
||||
* 获取菜单数据
|
||||
*/
|
||||
const menuDatas = reactive({
|
||||
count: 0,
|
||||
/**
|
||||
* 获取当前系统权限信息
|
||||
*/
|
||||
getSystemPermissionData: async () => {
|
||||
const resp = await getSystemPermission();
|
||||
if (resp.status === 200) {
|
||||
const newTree = menuDatas.filterMenu(
|
||||
resp.result.map((item: any) => JSON.parse(item).id),
|
||||
BaseMenu,
|
||||
);
|
||||
const _count = menuDatas.menuCount(newTree);
|
||||
menuDatas.count = _count;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 过滤菜单
|
||||
*/
|
||||
filterMenu: (permissions: string[], menus: any[]) => {
|
||||
return menus.filter((item) => {
|
||||
let isShow = false;
|
||||
if (item.showPage && item.showPage.length) {
|
||||
isShow = item.showPage.every((pItem: any) => {
|
||||
return permissions.includes(pItem);
|
||||
});
|
||||
}
|
||||
if (item.children) {
|
||||
item.children = menuDatas.filterMenu(
|
||||
permissions,
|
||||
item.children,
|
||||
);
|
||||
}
|
||||
return isShow || !!item.children?.length;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 计算菜单数量
|
||||
*/
|
||||
menuCount: (menus: any[]) => {
|
||||
return menus.reduce((pre, next) => {
|
||||
let _count = 1;
|
||||
if (next.children) {
|
||||
_count = menuDatas.menuCount(next.children);
|
||||
}
|
||||
return pre + _count;
|
||||
}, 0);
|
||||
},
|
||||
current:undefined,
|
||||
});
|
||||
/**
|
||||
* 获取当前系统权限信息
|
||||
*/
|
||||
const getSystemPermissionData = async () => {
|
||||
const resp = await getSystemPermission();
|
||||
if (resp.status === 200) {
|
||||
const newTree = filterMenu(
|
||||
resp.result.map((item: any) => JSON.parse(item).id),
|
||||
BaseMenu,
|
||||
);
|
||||
const _count = menuCount(newTree);
|
||||
menuDatas.current = newTree;
|
||||
menuDatas.count = _count;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 过滤菜单
|
||||
*/
|
||||
const filterMenu = (permissions: string[], menus: any[]) => {
|
||||
return menus.filter((item) => {
|
||||
let isShow = false;
|
||||
if (item.showPage && item.showPage.length) {
|
||||
isShow = item.showPage.every((pItem: any) => {
|
||||
return permissions.includes(pItem);
|
||||
});
|
||||
}
|
||||
if (item.children) {
|
||||
item.children = filterMenu(permissions, item.children);
|
||||
}
|
||||
return isShow || !!item.children?.length;
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 计算菜单数量
|
||||
*/
|
||||
const menuCount = (menus: any[]) => {
|
||||
return menus.reduce((pre, next) => {
|
||||
let _count = 1;
|
||||
if (next.children) {
|
||||
_count = menuCount(next.children);
|
||||
}
|
||||
return pre + _count;
|
||||
}, 0);
|
||||
};
|
||||
/**
|
||||
* 初始化菜单
|
||||
*/
|
||||
const initMenu = () =>{
|
||||
return new Promise((resolve) => {
|
||||
updateMenus(menuDatas.current).then((res) => {
|
||||
resolve(res.status === 200);
|
||||
})
|
||||
})
|
||||
}
|
||||
const { count } = toRefs(menuDatas);
|
||||
menuDatas.getSystemPermissionData();
|
||||
getSystemPermissionData();
|
||||
defineExpose({
|
||||
updataMenu:initMenu
|
||||
})
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.menu-style {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.menu-img {
|
||||
margin-right: 16px;
|
||||
}
|
||||
}
|
||||
.menu-style {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.menu-img {
|
||||
margin-right: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -29,6 +29,21 @@ export const RoleData = {
|
|||
|
||||
export default {
|
||||
[ROLEKEYS.device]: [
|
||||
{
|
||||
assetAccesses: [],
|
||||
code: "device/DashBoard",
|
||||
createTime: 1679906031144,
|
||||
granted: true,
|
||||
icon: "icon-keshihua",
|
||||
id:"68a02c9efa9fb4885c89b007f97d074d",
|
||||
level:3,
|
||||
name:"仪表盘",
|
||||
owner: "iot",
|
||||
parentId :"b6327c3ff01b49c9a7a96101606dc27a",
|
||||
path:"WXaI-KCgA-gBU0",
|
||||
sortIndex:1,
|
||||
url:"/iot/device/DashBoard",
|
||||
},
|
||||
{
|
||||
id: '1-3-2',
|
||||
parentId: '1-3',
|
||||
|
|
|
@ -3,9 +3,9 @@ import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
|
|||
/** 初始化数据提交表单 */
|
||||
export interface modalState {
|
||||
host: string; // 本地地址
|
||||
port: string; // 本地端口
|
||||
publicHost: string; // 公网地址
|
||||
publicPort: number | null; // 公网端口
|
||||
port?: string; // 本地端口
|
||||
publicHost?: string; // 公网地址
|
||||
publicPort?: number | null; // 公网端口
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
</template>
|
||||
<Basic ref="basicRef" />
|
||||
</j-collapse-panel>
|
||||
<j-collapse-panel key="2" >
|
||||
<j-collapse-panel key="2" forceRender>
|
||||
<template #header>
|
||||
<span class="title">菜单初始化</span>
|
||||
<span class="sub-title"
|
||||
>初始化菜单数据</span
|
||||
>
|
||||
</template>
|
||||
<Menu></Menu>
|
||||
<Menu ref="menuRef"></Menu>
|
||||
</j-collapse-panel>
|
||||
<j-collapse-panel key="3" forceRender>
|
||||
<template #header>
|
||||
|
@ -74,6 +74,7 @@ import { message } from 'jetlinks-ui-components';
|
|||
const basicRef = ref();
|
||||
const roleRef = ref();
|
||||
const initDataRef = ref();
|
||||
const menuRef = ref();
|
||||
const loading = ref(false);
|
||||
/**
|
||||
* 默认打开第一个初始菜单
|
||||
|
@ -97,11 +98,12 @@ const jump = () => {
|
|||
const submitData = async () => {
|
||||
loading.value = true;
|
||||
const basicRes = await basicRef.value.submitBasic();
|
||||
const menuRes = await menuRef.value.updataMenu();
|
||||
const roleRes = await roleRef.value.submitRole();
|
||||
const initDataRes = await initDataRef.value.save();
|
||||
loading.value = false;
|
||||
// 当前数据是否成功提交
|
||||
if (basicRes && roleRes && initDataRes) {
|
||||
if (basicRes && menuRes && roleRes && initDataRes ) {
|
||||
message.success('保存成功');
|
||||
// // 记录初始化数据,跳转首页
|
||||
const res = await saveInit();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
:columns="columns"
|
||||
type='simple'
|
||||
@search="handleSearch"
|
||||
class='search'
|
||||
class='scene-search'
|
||||
target="scene-triggrt-device-category"
|
||||
/>
|
||||
<j-divider style='margin: 0' />
|
||||
|
|
|
@ -171,7 +171,13 @@ const columns = [
|
|||
hideInTable: true,
|
||||
search: {
|
||||
type: 'treeSelect',
|
||||
options: queryTree({ paging: false }).then(resp => resp.result),
|
||||
options: () => {
|
||||
return new Promise((res => {
|
||||
queryTree({ paging: false }).then(resp => {
|
||||
res(resp.result)
|
||||
})
|
||||
}))
|
||||
},
|
||||
componentProps: {
|
||||
fieldNames: {
|
||||
label: 'name',
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
@select="onChange"
|
||||
>
|
||||
<template v-slot="{ label }">
|
||||
<j-input :value="label" />
|
||||
<j-input :value="label" readonly />
|
||||
</template>
|
||||
</ParamsDropdown>
|
||||
</template>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
@select="onValueChange"
|
||||
>
|
||||
<template v-slot="{ label }">
|
||||
<j-input :value="label" placeholder="请选择" />
|
||||
<j-input readonly :value="label" placeholder="请选择" />
|
||||
</template>
|
||||
</ParamsDropdown>
|
||||
</j-form-item>
|
||||
|
@ -112,7 +112,6 @@ const filterParamsData = (type?: string, data?: any[]): any[] => {
|
|||
item.children = _children;
|
||||
return _children.length ? true : false;
|
||||
} else if (item.type === type) {
|
||||
// optionMap.current.set(item.id, item);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -132,12 +131,12 @@ const handleOptions = computed(() => {
|
|||
if (_type === 'boolean') {
|
||||
return [
|
||||
{
|
||||
label: _item.trueText,
|
||||
value: _item.trueValue,
|
||||
label: _item.trueText || true,
|
||||
value: _item.trueValue || true,
|
||||
},
|
||||
{
|
||||
label: _item.falseText,
|
||||
value: _item.falseValue,
|
||||
label: _item.falseText || false,
|
||||
value: _item.falseValue || false,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -22,18 +22,19 @@
|
|||
showSearch
|
||||
placeholder="请选择功能"
|
||||
v-model:value="modelRef.message.functionId"
|
||||
@select="functionSelect"
|
||||
@change="functionSelect"
|
||||
>
|
||||
<j-select-option
|
||||
v-for="item in metadata?.functions || []"
|
||||
:value="item?.id"
|
||||
:key="item?.id"
|
||||
:label="item?.name"
|
||||
>{{ item?.name }}</j-select-option
|
||||
>
|
||||
</j-select>
|
||||
</j-form-item>
|
||||
<j-form-item
|
||||
v-if="modelRef.message.functionId"
|
||||
v-if="modelRef.message.functionId && functions.length"
|
||||
:name="['message', 'inputs']"
|
||||
:rules="functionRules"
|
||||
>
|
||||
|
@ -54,6 +55,7 @@
|
|||
showSearch
|
||||
placeholder="请选择属性"
|
||||
v-model:value="modelRef.message.properties[0]"
|
||||
@change="propertySelect"
|
||||
>
|
||||
<j-select-option
|
||||
v-for="item in metadata?.properties.filter((i) =>
|
||||
|
@ -61,6 +63,7 @@
|
|||
) || []"
|
||||
:value="item?.id"
|
||||
:key="item?.id"
|
||||
:label="item?.name"
|
||||
>{{ item?.name }}</j-select-option
|
||||
>
|
||||
</j-select>
|
||||
|
@ -130,8 +133,14 @@ const props = defineProps({
|
|||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
productDetail: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['change']);
|
||||
|
||||
const formRef = ref();
|
||||
|
||||
const modelRef = reactive({
|
||||
|
@ -146,8 +155,19 @@ const modelRef = reactive({
|
|||
|
||||
const writeFormRef = ref();
|
||||
|
||||
const functionSelect = () => {
|
||||
const functionSelect = (val: any, options?: any) => {
|
||||
modelRef.message.inputs = [];
|
||||
emit('change', {
|
||||
propertiesName: options?.label,
|
||||
propertiesValue: modelRef.propertiesValue,
|
||||
});
|
||||
};
|
||||
|
||||
const propertySelect = (val: any, options?: any) => {
|
||||
emit('change', {
|
||||
propertiesName: options?.label,
|
||||
propertiesValue: modelRef.propertiesValue,
|
||||
});
|
||||
};
|
||||
|
||||
const functionRules = [
|
||||
|
@ -156,11 +176,11 @@ const functionRules = [
|
|||
if (!value?.length && functions.value.length) {
|
||||
return Promise.reject('请输入功能值');
|
||||
} else {
|
||||
const hasValue = value.find(
|
||||
const hasValue = value?.find(
|
||||
(item: { name: string; value: any }) => !item.value,
|
||||
);
|
||||
if (hasValue) {
|
||||
const functionItem = functions.value.find(
|
||||
const functionItem = functions.value?.find(
|
||||
(item: any) => item.id === hasValue.name,
|
||||
);
|
||||
return Promise.reject(
|
||||
|
@ -239,11 +259,11 @@ const onMessageTypeChange = (val: string) => {
|
|||
};
|
||||
|
||||
watch(
|
||||
() => props.values,
|
||||
() => props.productDetail,
|
||||
(newVal) => {
|
||||
if (newVal?.productDetail?.id) {
|
||||
if (newVal?.selector === 'fixed') {
|
||||
const id = newVal?.selectorValues?.[0]?.value;
|
||||
if (newVal?.id) {
|
||||
if (props.values?.selector === 'fixed') {
|
||||
const id = props.values?.selectorValues?.[0]?.value;
|
||||
if (id) {
|
||||
detail(id).then((resp) => {
|
||||
if (resp.status === 200) {
|
||||
|
@ -254,9 +274,7 @@ watch(
|
|||
});
|
||||
}
|
||||
} else {
|
||||
metadata.value = JSON.parse(
|
||||
newVal?.productDetail?.metadata || '{}',
|
||||
);
|
||||
metadata.value = JSON.parse(newVal?.metadata || '{}');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -282,6 +300,13 @@ watch(
|
|||
|
||||
const onWriteChange = (val: string) => {
|
||||
modelRef.propertiesValue = val;
|
||||
emit('change', {
|
||||
propertiesName:
|
||||
deviceMessageType.value === 'INVOKE_FUNCTION'
|
||||
? _function.value?.name
|
||||
: _property.value?.name,
|
||||
propertiesValue: modelRef.propertiesValue,
|
||||
});
|
||||
};
|
||||
|
||||
const onFormSave = () => {
|
||||
|
@ -295,19 +320,19 @@ const onFormSave = () => {
|
|||
reject(false);
|
||||
}
|
||||
}
|
||||
// 处理三种情况的值的格式
|
||||
const obj = {
|
||||
resolve({
|
||||
message: {
|
||||
...modelRef.message,
|
||||
..._data.message,
|
||||
propertiesName:
|
||||
deviceMessageType.value === 'INVOKE_FUNCTION'
|
||||
? _function.value?.name
|
||||
: _property.value?.name,
|
||||
propertiesValue: modelRef.propertiesValue,
|
||||
},
|
||||
};
|
||||
resolve(obj);
|
||||
});
|
||||
emit('change', {
|
||||
propertiesName:
|
||||
deviceMessageType.value === 'INVOKE_FUNCTION'
|
||||
? _function.value?.name
|
||||
: _property.value?.name,
|
||||
propertiesValue: modelRef.propertiesValue,
|
||||
});
|
||||
})
|
||||
.catch((err: any) => {
|
||||
reject(err);
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
</template>
|
||||
|
||||
<script setup lang='ts' name='Product'>
|
||||
import { query } from '@/api/device/instance';
|
||||
import { query, detail } from '@/api/device/instance';
|
||||
import { getImage } from '@/utils/comm';
|
||||
import { PropType } from 'vue';
|
||||
|
||||
|
@ -161,16 +161,27 @@ const deviceQuery = (p: any) => {
|
|||
return query(p);
|
||||
};
|
||||
|
||||
const handleClick = (detail: any) => {
|
||||
if (props.value?.[0]?.value === detail.id) {
|
||||
const handleClick = (_detail: any) => {
|
||||
if (props.value?.[0]?.value === _detail.id) {
|
||||
emit('update:value', undefined);
|
||||
emit('change', {});
|
||||
} else {
|
||||
emit('update:value', [{ value: detail.id, name: detail.name }]);
|
||||
emit('change', detail);
|
||||
emit('update:value', [{ value: _detail.id, name: _detail.name }]);
|
||||
emit('change', _detail);
|
||||
}
|
||||
};
|
||||
|
||||
watch(() => props.value, async (newVal) => {
|
||||
if(newVal[0]?.value){
|
||||
const { result } = await detail(newVal[0]?.value)
|
||||
emit('update:value', [{ value: result?.id, name: result?.name }]);
|
||||
emit('change', result);
|
||||
}
|
||||
}, {
|
||||
deep: true,
|
||||
immediate: true
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
params.value = {
|
||||
...params.value,
|
||||
|
|
|
@ -177,15 +177,8 @@ const onValueChange = () => {
|
|||
value: item.value,
|
||||
};
|
||||
});
|
||||
const arr = _data.map((item: any) => {
|
||||
return {
|
||||
column: item.name,
|
||||
type: item.type,
|
||||
value: item.value,
|
||||
};
|
||||
});
|
||||
emits('update:value', [{ value: newValue, name: '标签' }]);
|
||||
emits('change', [{ value: newValue, name: '标签' }], arr);
|
||||
emits('change', [{ value: newValue, name: '标签' }], _data);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -13,18 +13,12 @@
|
|||
@change="onSelectorChange"
|
||||
/>
|
||||
</j-form-item>
|
||||
<!-- <j-form-item
|
||||
v-if="modelRef.selector === 'fixed'"
|
||||
name="selectorValues"
|
||||
:rules="[{ required: true, message: '请选择设备' }]"
|
||||
> -->
|
||||
<Device
|
||||
v-if="modelRef.selector === 'fixed'"
|
||||
:productId="values.productDetail.id"
|
||||
:productId="productDetail.id"
|
||||
v-model:value="modelRef.selectorValues"
|
||||
@change="onDeviceChange"
|
||||
/>
|
||||
<!-- </j-form-item> -->
|
||||
<j-form-item
|
||||
v-else-if="modelRef.selector === 'relation'"
|
||||
label="关系"
|
||||
|
@ -107,6 +101,10 @@ const props = defineProps({
|
|||
parallel: {
|
||||
type: Boolean,
|
||||
},
|
||||
productDetail: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
// save保存deviceDetail
|
||||
|
@ -122,9 +120,7 @@ const modelRef = reactive({
|
|||
selectorValues: undefined,
|
||||
deviceId: '',
|
||||
source: '',
|
||||
relationName: '',
|
||||
upperKey: '',
|
||||
message: undefined,
|
||||
});
|
||||
|
||||
const list = ref<any[]>([]);
|
||||
|
@ -166,10 +162,11 @@ const filterTree = (nodes: any[]) => {
|
|||
if (
|
||||
it.children.find(
|
||||
(item: any) =>
|
||||
item.id.indexOf('deviceId' || 'device_id' || 'device_Id') >
|
||||
-1,
|
||||
item?.id?.indexOf(
|
||||
'deviceId' || 'device_id' || 'device_Id',
|
||||
) > -1,
|
||||
) &&
|
||||
!it.children.find((item: any) => item.id.indexOf('boolean') > -1)
|
||||
!it.children.find((item: any) => item?.id.indexOf('boolean') > -1)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
@ -197,7 +194,7 @@ const sourceChangeEvent = async () => {
|
|||
const productId =
|
||||
data.value?.branches?.[props.branchesName].then?.[props.thenName]
|
||||
?.actions?.[props.name > 0 ? props.name - 1 : 0]?.device?.productId;
|
||||
if (productId === props.values?.productDetail?.id) {
|
||||
if (productId === props?.productDetail?.id) {
|
||||
const _data = await getParams(_params, unref(data));
|
||||
builtInList.value = handleParamsData(filterTree(_data), 'id');
|
||||
} else {
|
||||
|
@ -205,7 +202,7 @@ const sourceChangeEvent = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
const filterType = async () => {
|
||||
const filterType = async (newVal: any) => {
|
||||
const _list = TypeList.filter((item) => item.value === 'fixed');
|
||||
if (unref(data)?.trigger?.type === 'device') {
|
||||
//关系
|
||||
|
@ -221,10 +218,9 @@ const filterType = async () => {
|
|||
_list.push(...array);
|
||||
}
|
||||
//标签
|
||||
const tag = JSON.parse(
|
||||
props.values.productDetail?.metadata || '{}',
|
||||
)?.tags;
|
||||
const tag = JSON.parse(newVal?.metadata || '{}')?.tags;
|
||||
if (tag && tag.length !== 0) {
|
||||
tagList.value = tag || [];
|
||||
const array = TypeList.filter((item) => item.value === 'tag');
|
||||
_list.push(...array);
|
||||
}
|
||||
|
@ -251,23 +247,23 @@ const filterType = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
const onSelectorChange = () => {
|
||||
const onSelectorChange = (val: string) => {
|
||||
modelRef.selectorValues = undefined;
|
||||
modelRef.selector = val;
|
||||
};
|
||||
|
||||
const onDeviceChange = (_detail: any) => {
|
||||
if (_detail) {
|
||||
if (_detail.id) {
|
||||
modelRef.deviceId = _detail.id;
|
||||
modelRef.deviceId = _detail?.id;
|
||||
modelRef.selectorValues = [
|
||||
{ value: _detail.id, name: _detail.name },
|
||||
] as any;
|
||||
modelRef.message = {} as any;
|
||||
} else {
|
||||
modelRef.deviceId = '';
|
||||
modelRef.selectorValues = [] as any;
|
||||
}
|
||||
emits('save', unref(modelRef), _detail);
|
||||
emits('save', unref(modelRef), { name: _detail.name });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -276,8 +272,7 @@ const onRelationChange = (val: any, options: any) => {
|
|||
modelRef.source = 'upper';
|
||||
modelRef.selectorValues = val;
|
||||
modelRef.upperKey = 'scene.deviceId';
|
||||
modelRef.relationName = options.label;
|
||||
emits('save', unref(modelRef), {});
|
||||
emits('save', unref(modelRef), { relationName: options.label });
|
||||
};
|
||||
|
||||
const onTagChange = (val: any[], arr: any[]) => {
|
||||
|
@ -285,27 +280,61 @@ const onTagChange = (val: any[], arr: any[]) => {
|
|||
modelRef.deviceId = 'deviceId';
|
||||
modelRef.source = 'fixed';
|
||||
}
|
||||
emits('save', unref(modelRef), {}, arr ? { tagList: arr } : {});
|
||||
const tagName = arr.map((i, _index) => {
|
||||
return `${_index !== 0 && _index !== (arr || []).length && i.type}${
|
||||
i.name
|
||||
}为${i.value}`;
|
||||
});
|
||||
emits(
|
||||
'save',
|
||||
unref(modelRef),
|
||||
{},
|
||||
arr ? { tagName: tagName.join('') } : {},
|
||||
);
|
||||
};
|
||||
|
||||
const onVariableChange = (val: any, node: any) => {
|
||||
modelRef.deviceId = val;
|
||||
modelRef.selectorValues = [{ value: val, name: node.description }] as any;
|
||||
emits('save', unref(modelRef), node);
|
||||
emits('save', unref(modelRef), { name: node.description });
|
||||
};
|
||||
|
||||
watchEffect(() => {
|
||||
Object.assign(modelRef, props.values);
|
||||
});
|
||||
watch(
|
||||
() => props.values,
|
||||
(newVal) => {
|
||||
Object.assign(modelRef, newVal);
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: true,
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.values.productDetail,
|
||||
() => props.productDetail,
|
||||
async (newVal) => {
|
||||
await sourceChangeEvent();
|
||||
if (newVal) {
|
||||
const metadata = JSON.parse(newVal?.metadata || '{}');
|
||||
tagList.value = metadata?.tags || [];
|
||||
filterType();
|
||||
filterType(newVal);
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: true,
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => [props.values, builtInList.value],
|
||||
([newVal1, newVal2]) => {
|
||||
if (newVal2 && newVal2.length) {
|
||||
const param = newVal1?.selectorValues?.[0]?.value;
|
||||
const isVariable = (newVal2 || [])?.find((item: any) => {
|
||||
return item.children.find((i: any) => i.id === param);
|
||||
});
|
||||
if (isVariable) {
|
||||
modelRef.selector = 'variable';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -319,14 +348,14 @@ const onFormSave = () => {
|
|||
formRef.value
|
||||
.validate()
|
||||
.then(async (_data: any) => {
|
||||
if(modelRef.selector === 'fixed'){
|
||||
if(!modelRef?.selectorValues?.[0]?.value){
|
||||
onlyMessage('请选择设备', 'error')
|
||||
if (modelRef.selector === 'fixed') {
|
||||
if (!modelRef?.selectorValues?.[0]?.value) {
|
||||
onlyMessage('请选择设备', 'error');
|
||||
reject(false);
|
||||
} else {
|
||||
resolve({
|
||||
..._data,
|
||||
selectorValues: modelRef.selectorValues
|
||||
selectorValues: modelRef.selectorValues,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<Product
|
||||
v-if="current === 0"
|
||||
v-model:rowKey="DeviceModel.productId"
|
||||
v-model:detail="DeviceModel.productDetail"
|
||||
v-model:detail="productDetail"
|
||||
@change="onProductChange"
|
||||
/>
|
||||
<Device
|
||||
|
@ -34,6 +34,7 @@
|
|||
:thenName="thenName"
|
||||
:values="DeviceModel"
|
||||
@save="onDeviceSave"
|
||||
:productDetail="productDetail"
|
||||
ref="deviceRef"
|
||||
/>
|
||||
<Action
|
||||
|
@ -42,7 +43,9 @@
|
|||
:branchesName="branchesName"
|
||||
:thenName="thenName"
|
||||
:values="DeviceModel"
|
||||
:productDetail="productDetail"
|
||||
ref="actionRef"
|
||||
@change="onActionsChange"
|
||||
/>
|
||||
</div>
|
||||
<template #footer>
|
||||
|
@ -61,7 +64,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { DeviceModelType } from './typings';
|
||||
import { DeviceModelType, DeviceOptionType } from './typings';
|
||||
import Product from './Product.vue';
|
||||
import Device from './device/index.vue';
|
||||
import Action from './actions/index.vue';
|
||||
|
@ -105,26 +108,22 @@ const current = ref<number>(0);
|
|||
const deviceRef = ref<any>();
|
||||
const actionRef = ref<any>();
|
||||
|
||||
const productDetail = ref<any>({});
|
||||
|
||||
const DeviceModel = reactive<DeviceModelType>({
|
||||
productId: '',
|
||||
deviceId: '',
|
||||
productDetail: {},
|
||||
device: {},
|
||||
deviceDetail: {},
|
||||
options: {},
|
||||
selector: 'fixed',
|
||||
selectorValues: [],
|
||||
upperKey: '',
|
||||
source: 'fixed',
|
||||
relationName: '',
|
||||
message: {},
|
||||
propertiesName: '',
|
||||
propertiesValue: '',
|
||||
columns: [],
|
||||
actionName: '',
|
||||
tagList: [],
|
||||
message: {
|
||||
messageType: 'INVOKE_FUNCTION',
|
||||
},
|
||||
});
|
||||
|
||||
const DeviceOptions = ref<DeviceOptionType>({});
|
||||
|
||||
const emit = defineEmits<Emit>();
|
||||
|
||||
const onCancel = () => {
|
||||
|
@ -139,7 +138,6 @@ const onSave = (_data: any) => {
|
|||
productId: DeviceModel.productId,
|
||||
message: _data.message,
|
||||
};
|
||||
//处理按变量
|
||||
if (DeviceModel.selector === 'variable') {
|
||||
item.selector = 'fixed';
|
||||
}
|
||||
|
@ -152,55 +150,46 @@ const onSave = (_data: any) => {
|
|||
properties: '', //属性功能
|
||||
propertiesValue: '', //设置功能
|
||||
selector: DeviceModel.selector, //选择器标识
|
||||
productName: DeviceModel.productDetail.name,
|
||||
relationName: DeviceModel.relationName,
|
||||
triggerName: data.value.options?.trigger?.name || '触发设备',
|
||||
tagList: [],
|
||||
columns: [],
|
||||
otherColumns: [],
|
||||
...DeviceOptions.value,
|
||||
};
|
||||
_options.name =
|
||||
DeviceModel.deviceDetail?.name || DeviceModel.selectorValues?.[0]?.name;
|
||||
const _type = _data.message.messageType;
|
||||
if (_type === 'INVOKE_FUNCTION') {
|
||||
_options.type = '执行';
|
||||
_options.properties = _data.message.propertiesName;
|
||||
}
|
||||
if (_type === 'READ_PROPERTY') {
|
||||
_options.type = '读取';
|
||||
_options.properties = _data.message.propertiesName;
|
||||
}
|
||||
if (_type === 'WRITE_PROPERTY') {
|
||||
_options.type = '设置';
|
||||
_options.properties = _data.message.propertiesName;
|
||||
_options.propertiesValue =
|
||||
typeof _data.message.propertiesValue === 'object'
|
||||
? JSON.stringify(_data.message.propertiesValue)
|
||||
: `${_data.message.propertiesValue}`;
|
||||
_options.columns = DeviceModel.columns;
|
||||
_options.otherColumns = DeviceModel.columns;
|
||||
const cur: any = Object.values(_data.message.properties)?.[0];
|
||||
if (cur?.source === 'upper') {
|
||||
_options.propertiesValue = DeviceModel.actionName;
|
||||
}
|
||||
}
|
||||
if (_options.selector === 'tag') {
|
||||
_options.taglist = DeviceModel.tagList.map((it) => ({
|
||||
name: it.column || it.name,
|
||||
type: it.type ? (it.type === 'and' ? '并且' : '或者') : '',
|
||||
value: it.value,
|
||||
}));
|
||||
}
|
||||
if (_options.selector === 'variable') {
|
||||
_options.name = DeviceModel.selectorValues?.[0]?.name;
|
||||
(typeof _options?.propertiesValue === 'object'
|
||||
? JSON.stringify(_options?.propertiesValue)
|
||||
: `${_options?.propertiesValue}`) || DeviceModel?.selectorValues?.[0]?.value;
|
||||
}
|
||||
emit('save', item, _options);
|
||||
};
|
||||
|
||||
const onProductChange = () => {
|
||||
DeviceModel.selectorValues = undefined
|
||||
DeviceModel.message = {}
|
||||
}
|
||||
const onProductChange = (_val: any) => {
|
||||
DeviceModel.selectorValues = undefined;
|
||||
DeviceModel.message = {
|
||||
messageType: 'INVOKE_FUNCTION',
|
||||
};
|
||||
DeviceOptions.value.productName = _val?.name;
|
||||
};
|
||||
|
||||
const onDeviceSave = (_data: any, obj?: any) => {
|
||||
Object.assign(DeviceModel, { ..._data });
|
||||
DeviceOptions.value = { ...unref(DeviceOptions), ...obj };
|
||||
};
|
||||
|
||||
const onActionsChange = (options?: any) => {
|
||||
const obj = {
|
||||
...DeviceOptions.value,
|
||||
...options,
|
||||
};
|
||||
DeviceOptions.value = obj;
|
||||
};
|
||||
|
||||
const save = async (step?: number) => {
|
||||
let _step = step !== undefined ? step : current.value;
|
||||
|
@ -215,7 +204,7 @@ const save = async (step?: number) => {
|
|||
} else if (DeviceModel.selectorValues?.length) {
|
||||
current.value = 2;
|
||||
} else {
|
||||
onlyMessage('请选择设备', 'error')
|
||||
onlyMessage('请选择设备', 'error');
|
||||
}
|
||||
} else {
|
||||
if (actionRef.value) {
|
||||
|
@ -239,41 +228,14 @@ const prev = () => {
|
|||
|
||||
const saveClick = () => save();
|
||||
|
||||
const onDeviceSave = (_data: any, _detail: any, obj?: any) => {
|
||||
Object.assign(DeviceModel, { ..._data, ...obj });
|
||||
DeviceModel.deviceDetail = _detail;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(newValue) => {
|
||||
Object.assign(DeviceModel, newValue);
|
||||
Object.assign(DeviceModel, {...newValue});
|
||||
if (newValue?.productId) {
|
||||
detail(newValue.productId).then((resp) => {
|
||||
if (resp.status === 200) {
|
||||
DeviceModel.productDetail = resp.result;
|
||||
if (
|
||||
DeviceModel.selector === 'tag' &&
|
||||
DeviceModel.selectorValues[0]?.value
|
||||
) {
|
||||
const metadata = JSON.parse(
|
||||
DeviceModel.productDetail?.metadata || '{}',
|
||||
);
|
||||
const tags = metadata.tags || [];
|
||||
const arr = DeviceModel.selectorValues[0]?.value
|
||||
.filter((item: any) => !!item.value)
|
||||
.map((item: any) => {
|
||||
return {
|
||||
column:
|
||||
tags.find(
|
||||
(i: any) => i.id === item.column,
|
||||
)?.name || item.column,
|
||||
type: item.type,
|
||||
value: item.value,
|
||||
};
|
||||
});
|
||||
DeviceModel.tagList = arr;
|
||||
}
|
||||
productDetail.value = resp.result;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,27 +2,27 @@ import { ProductItem } from '@/views/device/Product/typings';
|
|||
import { ActionsDeviceProps } from '../../../typings';
|
||||
|
||||
type DeviceModelType = {
|
||||
// steps: {
|
||||
// key: string;
|
||||
// title: string;
|
||||
// content: React.ReactNode;
|
||||
// }[];
|
||||
// current: number;
|
||||
productId: string;
|
||||
deviceId: string;
|
||||
productDetail: ProductItem | any;
|
||||
device: Partial<ActionsDeviceProps>;
|
||||
deviceDetail: any;
|
||||
options: any;
|
||||
source: string;
|
||||
selector: string;
|
||||
selectorValues: any;
|
||||
upperKey: string;
|
||||
source: string;
|
||||
relationName: string;
|
||||
message: any;
|
||||
propertiesName: string;
|
||||
propertiesValue: string | any;
|
||||
columns: string[];
|
||||
actionName: string;
|
||||
tagList: any[];
|
||||
}
|
||||
upperKey: string;
|
||||
deviceId: string;
|
||||
message: {
|
||||
properties?: any;
|
||||
messageType: string;
|
||||
inputs?: any[]
|
||||
}
|
||||
}
|
||||
|
||||
type DeviceOptionType = {
|
||||
name?: string;
|
||||
productName?: string;
|
||||
propertiesValue?: string;
|
||||
propertiesName?: any;
|
||||
tagName?: string;
|
||||
relationName?: string;
|
||||
actionName?: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@
|
|||
{{data?.options?.name}}
|
||||
</Ellipsis>
|
||||
<Ellipsis style='max-width: 400px;'>
|
||||
{{data?.options?.properties}}
|
||||
{{data?.options?.propertiesName}}
|
||||
</Ellipsis>
|
||||
|
||||
<Ellipsis style='max-width: 200px;'>
|
||||
|
@ -295,21 +295,9 @@
|
|||
"
|
||||
/>
|
||||
{{ data?.options?.type }}
|
||||
<span
|
||||
v-for="(i, _index) in data?.options?.taglist ||
|
||||
[]"
|
||||
:key="i.value"
|
||||
>
|
||||
{{
|
||||
_index !== 0 &&
|
||||
_index !==
|
||||
(data?.options?.taglist || []).length &&
|
||||
i.type
|
||||
}}
|
||||
{{ i.name }}为{{ i.value }}
|
||||
</span>
|
||||
<span>{{ data?.options?.tagName }}</span>
|
||||
的{{ data?.options?.productName }}
|
||||
{{ data?.options?.properties }}
|
||||
{{ data?.options?.propertiesName }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="data?.device?.selector === 'relation'">
|
||||
|
@ -328,7 +316,7 @@
|
|||
>具有相同 {{ data?.options?.relationName }}的{{
|
||||
data?.options?.productName
|
||||
}}设备的
|
||||
{{ data?.options?.properties }}
|
||||
{{ data?.options?.propertiesName }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
|
|
@ -53,8 +53,9 @@
|
|||
</span>
|
||||
</Ellipsis>
|
||||
<div class="subTitle">
|
||||
说明:
|
||||
<Ellipsis :lineClamp="2">
|
||||
说明:{{
|
||||
{{
|
||||
slotProps?.description ||
|
||||
typeMap.get(slotProps.triggerType)?.tip
|
||||
}}
|
||||
|
|
|
@ -117,9 +117,7 @@
|
|||
</j-form-item>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'notnull'">
|
||||
<j-form-item
|
||||
:name="['data', index, 'notnull']"
|
||||
>
|
||||
<j-form-item :name="['data', index, 'notnull']">
|
||||
<j-radio-group
|
||||
v-model:value="record.notnull"
|
||||
button-style="solid"
|
||||
|
@ -134,9 +132,7 @@
|
|||
</j-form-item>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'comment'">
|
||||
<j-form-item
|
||||
:name="['data', index, 'notnull']"
|
||||
>
|
||||
<j-form-item :name="['data', index, 'notnull']">
|
||||
<j-input
|
||||
v-model:value="record.comment"
|
||||
placeholder="请输入说明"
|
||||
|
@ -167,20 +163,27 @@
|
|||
</j-button>
|
||||
</div>
|
||||
</div>
|
||||
<j-modal v-model:visible="dialog.visible" title="新增" @ok="handleOk">
|
||||
<j-form :model="dialog.form" ref="addFormRef">
|
||||
<j-modal
|
||||
:visible="true"
|
||||
v-if="dialog.visible"
|
||||
title="新增"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<j-form :model="dialog.form" ref="addFormRef" :layout="'vertical'">
|
||||
<j-form-item
|
||||
label="名称"
|
||||
name="name"
|
||||
:required="true"
|
||||
:rules="[
|
||||
{
|
||||
required: true,
|
||||
message: '请输入名称',
|
||||
},
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请输入名称',
|
||||
// },
|
||||
{
|
||||
max: 64,
|
||||
message: '最多可输入64个字符',
|
||||
trigger: 'blur',
|
||||
trigger: 'change',
|
||||
},
|
||||
{
|
||||
// pattern: /^[0-9].*$/,
|
||||
|
@ -191,7 +194,7 @@
|
|||
{
|
||||
pattern: /^\w+$/,
|
||||
message: '名称只能由数字、字母、下划线、中划线组成',
|
||||
trigger: 'blur',
|
||||
trigger: 'change',
|
||||
},
|
||||
]"
|
||||
>
|
||||
|
@ -410,6 +413,11 @@ const handleOk = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
dialog.visible = false;
|
||||
addFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
watch(
|
||||
[() => leftData.searchValue, () => leftData.sourceTree],
|
||||
([m, n]) => {
|
||||
|
@ -458,6 +466,8 @@ const checkName = (_: any, value: any) =>
|
|||
} else {
|
||||
resolve('');
|
||||
}
|
||||
} else {
|
||||
reject('请输入名称');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
:pagination="{
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: ['10', '20', '50', '100'],
|
||||
change: handlePageChange,
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
|
@ -42,6 +43,9 @@
|
|||
<script setup lang="ts">
|
||||
import { bindUser_api, getBindUserList_api } from '@/api/system/department';
|
||||
import { message } from 'jetlinks-ui-components';
|
||||
import { useDepartmentStore } from '@/store/department';
|
||||
|
||||
const department = useDepartmentStore();
|
||||
|
||||
const emits = defineEmits(['confirm', 'update:visible']);
|
||||
|
||||
|
@ -52,17 +56,19 @@ const props = defineProps<{
|
|||
// 弹窗相关
|
||||
const loading = ref(false);
|
||||
const confirm = () => {
|
||||
if (table._selectedRowKeys.length && props.parentId) {
|
||||
if (department.crossPageKeys.length && props.parentId) {
|
||||
loading.value = true;
|
||||
bindUser_api(props.parentId, table._selectedRowKeys)
|
||||
bindUser_api(props.parentId, department.crossPageKeys)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
emits('confirm');
|
||||
emits('update:visible', false);
|
||||
table._selectedRowKeys = [];
|
||||
})
|
||||
.finally(() => (loading.value = false));
|
||||
} else {
|
||||
emits('update:visible', false);
|
||||
// emits('update:visible', false);
|
||||
message.warning('请选择要绑定的用户');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -134,6 +140,36 @@ const table = reactive({
|
|||
table._selectedRowKeys = [];
|
||||
},
|
||||
});
|
||||
|
||||
watch(
|
||||
() => table._selectedRowKeys,
|
||||
(val: string[]) => {
|
||||
// console.log('_selectedRowKeys: ', val);
|
||||
department.setSelectedKeys(val);
|
||||
|
||||
// const newKeys = [];
|
||||
// val.forEach((key: string) => {
|
||||
// if (!department.crossPageKeys.includes(key)) {
|
||||
// newKeys.push(key);
|
||||
// }
|
||||
// });
|
||||
// if (newKeys.length) {
|
||||
// department.setSelectedKeys(val);
|
||||
// console.log('_selectedRowKeys: ', val);
|
||||
// }
|
||||
},
|
||||
);
|
||||
// watch(
|
||||
// () => department.crossPageKeys,
|
||||
// (val: string[]) => {
|
||||
// // console.log('crossPageKeys: ', val);
|
||||
// table._selectedRowKeys = val;
|
||||
// },
|
||||
// );
|
||||
const handlePageChange = () => {
|
||||
console.log('PageChange');
|
||||
// department.setSelectedKeys([], 'pagination');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
@ -83,10 +83,10 @@ const form = reactive({
|
|||
const updateTree = updatePrimissTree_api(roleId, {
|
||||
menus: form.menus,
|
||||
});
|
||||
|
||||
console.log(form.menus);
|
||||
Promise.all([updateRole, updateTree]).then((resp) => {
|
||||
message.success('操作成功');
|
||||
router.push('/system/Role');
|
||||
// router.push('/system/Role');
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3:
|
|||
|
||||
jetlinks-ui-components@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#27312836506c4833dcaaef075e1d3c694d75ae4d"
|
||||
integrity sha512-oum7zipoDUVkm/tPd7yu+mw9mR5NmfBcvBf49ebf55s+nz4zyArFOITzldQJ3Wx6BwaUUH/BiDwskHH+KgBVyg==
|
||||
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#c93a8863ed93b90f620d3c011ec79ada218625dd"
|
||||
integrity sha512-ESpadoDCZHkedS0oFgQmuSUvoMLUk2OrCXwB6x4ED4crfKynLJtqjBYeY/f8Eb2TuRTLxElL/qv6dr+MTaJSeQ==
|
||||
dependencies:
|
||||
"@vueuse/core" "^9.12.0"
|
||||
ant-design-vue "^3.2.15"
|
||||
|
|
Loading…
Reference in New Issue