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