Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev

This commit is contained in:
JiangQiming 2023-03-31 14:02:18 +08:00
commit f2b1b6250e
18 changed files with 76 additions and 20 deletions

View File

@ -80,6 +80,7 @@
<script setup lang="ts">
import type { ActionsType } from '@/components/Table/index';
import { PropType } from 'vue';
import BadgeStatus from '@/components/BadgeStatus/index.vue';
type EmitProps = {
// (e: 'update:modelValue', data: Record<string, any>): void;

View File

@ -88,6 +88,17 @@ const TypeMap = new Map([
['edge-child-device', 'edge'],
['network', 'network'],
]);
// DataMap
const DataMap = new Map();
DataMap.set('fixed-media', { type: 'media', title: '视频类设备接入' });
DataMap.set('gb28181-2016', { type: 'media', title: '视频类设备接入' });
DataMap.set('OneNet', { type: 'cloud', title: '云平台接入' });
DataMap.set('Ctwing', { type: 'cloud', title: '云平台接入' });
DataMap.set('modbus-tcp', { type: 'channel', title: '通道类设备接入' });
DataMap.set('opc-ua', { type: 'channel', title: '通道类设备接入' });
DataMap.set('official-edge-gateway', { type: 'edge', title: '官方接入' });
DataMap.set('edge-child-device', { type: 'edge', title: '官方接入' });
DataMap.set('network', { type: 'network', title: '自定义设备接入' });
const getTypeList = (result: Record<string, any>) => {
const list = [];
@ -161,12 +172,14 @@ const queryProviders = async () => {
// dataSource.value = getTypeList(resp.result)[0].list.filter(
// (item) => item.name !== '',
// );
if (route.query.save) {
// -,
//
if (route.query.save && route.query?.type) {
const type = route.query.type;
goProviders(
dataSource.value
.find((f: any) => f.title === '视频类设备接入')
?.list?.find((f: any) => f.id === route.query.type),
.find((f: any) => f.title === DataMap.get(type).title)
?.list?.find((f: any) => f.id === type),
);
}
}

View File

@ -119,6 +119,10 @@ const onFinish = async (values: any) => {
if (resp.status === 200) {
onlyMessage('操作成功', 'success');
history.back();
if ((window as any).onTabSaveSuccess) {
(window as any).onTabSaveSuccess(resp);
setTimeout(() => window.close(), 300);
}
}
};

View File

@ -413,6 +413,10 @@ const saveData = async () => {
if (resp.status === 200) {
onlyMessage('操作成功', 'success');
history.back();
if ((window as any).onTabSaveSuccess) {
(window as any).onTabSaveSuccess(resp);
setTimeout(() => window.close(), 300);
}
}
};

View File

@ -501,6 +501,10 @@ const saveData = async () => {
if (resp.status === 200) {
onlyMessage('操作成功', 'success');
history.back();
if ((window as any).onTabSaveSuccess) {
(window as any).onTabSaveSuccess(resp);
setTimeout(() => window.close(), 300);
}
}
};

View File

@ -265,6 +265,10 @@ const onFinish = async (values: any) => {
if (resp.status === 200) {
onlyMessage('操作成功', 'success');
history.back();
if ((window as any).onTabSaveSuccess) {
(window as any).onTabSaveSuccess(resp);
setTimeout(() => window.close(), 300);
}
}
};

View File

@ -654,7 +654,7 @@ const saveData = () => {
onlyMessage('操作成功', 'success');
if (route.query.save) {
// @ts-ignore
window?.onSaveSuccess(resp.result);
window?.onTabSaveSuccess(resp.result);
window.close();
} else {
history.back();

View File

@ -124,7 +124,7 @@ const onFinish = async (values: any) => {
if (route.query.save) {
// @ts-ignore
window?.onSaveSuccess(resp.result);
window?.onTabSaveSuccess(resp.result);
window.close();
} else {
history.back();

View File

@ -522,7 +522,6 @@ const saveData = () => {
onlyMessage('操作成功', 'success');
history.back();
if ((window as any).onTabSaveSuccess) {
console.log(123);
if (resp.result?.id) {
(window as any).onTabSaveSuccess(resp);
setTimeout(() => window.close(), 300);

View File

@ -319,7 +319,7 @@ const handleAdd = () => {
const tab: any = window.open(
`${origin}/#/iot/link/accessConfig/detail/:id?save=true&view=false&type=${props.channel}`,
);
tab.onSaveSuccess = async (value: string) => {
tab.onTabSaveSuccess = async (value: string) => {
await getGatewayList();
handleClick(value);
};

View File

@ -86,6 +86,7 @@ import { storeToRefs } from 'pinia';
import {cloneDeep, flattenDeep, isArray, set} from 'lodash-es'
import { Form } from 'jetlinks-ui-components'
import {treeFilter} from "@/utils/comm";
import { timeTypeKeys } from '@/views/rule-engine/Scene/Save/components/Terms/util'
const sceneStore = useSceneStore()
const { data: formModel } = storeToRefs(sceneStore)
@ -160,7 +161,7 @@ const showDelete = ref(false)
const columnOptions: any = inject('filter-params') //
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) //
const valueOptions = ref<any[]>([]) //
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin']
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin', 'contains_all', 'contains_any', 'not_contains']
const valueColumnOptions = ref<any[]>([])
const tabsOptions = ref<Array<TabsOption>>(
@ -285,7 +286,19 @@ const columnSelect = (e: any) => {
const termsTypeSelect = (e: { key: string, name: string }) => {
const oldValue = isArray(paramsValue.value!.value) ? paramsValue.value!.value[0] : paramsValue.value!.value
const value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
// timeTypeKeys
if (timeTypeKeys.includes(e.key)) {
if (tabsOptions.value[0].component !== 'int') {
value = undefined
}
tabsOptions.value[0].component = 'int'
} else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') {
value = undefined
tabsOptions.value[0].component = 'date'
}
paramsValue.value = {
source: paramsValue.value?.source || tabsOptions.value[0].key,
value: value

View File

@ -77,7 +77,7 @@ import DropdownButton from '../DropdownButton'
import { getOption } from '../DropdownButton/util'
import ParamsDropdown, { DoubleParamsDropdown } from '../ParamsDropdown'
import { inject } from 'vue'
import { ContextKey } from './util'
import { ContextKey, arrayParamsKey, timeTypeKeys } from './util'
import { useSceneStore } from 'store/scene'
import { storeToRefs } from 'pinia';
import { Form } from 'jetlinks-ui-components'
@ -157,7 +157,6 @@ const valueOptions = ref<any[]>([]) // 默认手动输入下拉
const metricOption = ref<any[]>([]) // termType
const isMetric = ref<boolean>(false) //
const tabsOptions = ref<Array<TabsOption>>([{ label: '手动输入', key: 'manual', component: 'string' }])
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin']
const metricsCacheOption = ref<any[]>([]) //
const handOptionByColumn = (option: any) => {
@ -280,7 +279,18 @@ const columnSelect = (option: any) => {
const termsTypeSelect = (e: { key: string, name: string }) => {
const oldValue = isArray(paramsValue.value!.value) ? paramsValue.value!.value[0] : paramsValue.value!.value
const value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
// timeTypeKeys
if (timeTypeKeys.includes(e.key)) {
if (tabsOptions.value[0].component !== 'int') {
value = undefined
}
tabsOptions.value[0].component = 'int'
} else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') {
value = undefined
tabsOptions.value[0].component = 'date'
}
paramsValue.value = {
source: paramsValue.value?.source || tabsOptions.value[0].key,
value: value

View File

@ -1,6 +1,9 @@
import { BranchesThen } from '@/views/rule-engine/Scene/typings'
export const ContextKey = 'columnOptions'
export const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin', 'contains_all', 'contains_any', 'not_contains']
export const timeTypeKeys = ['time_gt_now', 'time_lt_now']
export const handleParamsData = (data: any[], key: string = 'column'): any[] => {
return data?.map(item => {

View File

@ -1771,7 +1771,7 @@ function getOrgIdList() {
// /
function clickAddItem(data: string[], target: string) {
const tab: any = window.open(`${origin}/#/system/${target}?save=true`);
tab.onSaveSuccess = (value: string) => {
tab.onTabSaveSuccess = (value: string) => {
data.push(value);
if (target === 'Role') getRoleIdList();
else getOrgIdList();

View File

@ -43,7 +43,7 @@
:status="slotProps.state?.value"
:statusText="slotProps.state?.text"
:statusNames="{
enabled: 'success',
enabled: 'processing',
disabled: 'error',
}"
>
@ -151,7 +151,7 @@
:status="slotProps.state.value"
:text="slotProps.state.text"
:statusNames="{
enabled: 'success',
enabled: 'processing',
disabled: 'error',
}"
></BadgeStatus>
@ -201,6 +201,7 @@ import { ActionsType } from '@/components/Table';
import { getImage } from '@/utils/comm';
import { useMenuStore } from '@/store/menu';
import { message } from 'jetlinks-ui-components';
import BadgeStatus from '@/components/BadgeStatus/index.vue';
const menuStory = useMenuStore();
const permission = 'system/Apply';

View File

@ -187,7 +187,7 @@ function delDepartment(id: string) {
}
function refresh(id: string) {
// @ts-ignore
window?.onSaveSuccess && window.onSaveSuccess(id);
window?.onTabSaveSuccess && window.onTabSaveSuccess(id);
window.close();
getTree();
}

View File

@ -63,7 +63,7 @@ const confirm = () => {
if (route.query.save) {
// @ts-ignore
window?.onSaveSuccess(resp.result.id);
window?.onTabSaveSuccess(resp.result.id);
window.close();
} else jumpPage(`system/Role/Detail`, { id: resp.result.id });
}

View File

@ -345,7 +345,7 @@ const form = reactive({
IsShow: (...typeList: modalType[]) => typeList.includes(props.type),
clickAddItem: (prop: 'roleIdList' | 'orgIdList', target: string) => {
const tab: any = window.open(`${origin}/#/system/${target}?save=true`);
tab.onSaveSuccess = (value: string) => {
tab.onTabSaveSuccess = (value: string) => {
form.data[prop] = [...(form.data[prop] || []), value];
if (prop === 'roleIdList') form.getRoleList();
else form.getDepartmentList();