Merge branch 'dev'

# Conflicts:
#	src/views/oauth/index.vue
This commit is contained in:
xieyonghong 2023-05-05 17:52:07 +08:00
commit 8933b9498d
15 changed files with 111 additions and 41 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash
docker build -t registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-vue:2.1 .
docker push registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-vue:2.1
docker build -t registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-vue:2.1.0-SNAPSHOT .
docker push registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-vue:2.1.0-SNAPSHOT

View File

@ -84,7 +84,7 @@
</j-form-item>
<j-form-item
v-if="formData.configuration.function === 'HoldingRegisters'"
v-if="['HoldingRegisters', 'InputRegisters'].includes(formData.configuration.function)"
label="数据类型"
:name="['configuration', 'codec', 'provider']"
:rules="[
@ -327,7 +327,7 @@ const handleOk = async () => {
delete data?.nspwc;
const { codec } = data?.configuration;
if (data?.configuration.function !== 'HoldingRegisters') {
if (!['HoldingRegisters', 'InputRegisters'].includes(data?.configuration.function)) {
codec.provider = 'int8';
}
const { interval } = formData.value.configuration;

View File

@ -19,7 +19,7 @@
<template #label>
<Ellipsis>{{ `${item.name}${item.key})` }}</Ellipsis>
</template>
<Ellipsis>{{ item?.value }}</Ellipsis>
<Ellipsis>{{ findName(item) }}</Ellipsis>
</j-descriptions-item>
</j-descriptions>
<Save v-if="visible" @close="visible = false" @save="saveBtn" />
@ -46,4 +46,13 @@ const saveBtn = () => {
instanceStore.refresh(instanceStore.current.id);
}
};
const findName = (item: any) => {
let name = undefined
if (item.dataType) {
const _element = item.dataType.elements?.find((a: any) => a.value === item.value)
name = _element?.text
}
return name
}
</script>

View File

@ -523,6 +523,9 @@ const queryAccessDetail = async (id: string) => {
}).then((res: any) => {
if (res.status === 200) {
access.value = res.result.data[0];
if (access.value?.transportDetail?.metadata) {
productData.metadata = JSON.parse(access.value?.transportDetail?.metadata)
}
}
});
};

View File

@ -14,7 +14,7 @@
<j-col :span="12"><DeviceCountCard /></j-col>
<j-col :span="12"><BasicCountCard /></j-col>
<j-col :span="24" style="margin-top: 24px">
<PlatformPicCard image="/images/home/content1.svg" />
<PlatformPicCard image="/images/home/content.png" />
</j-col>
</j-row>
</j-col>

View File

@ -45,7 +45,7 @@ const props = defineProps({
width: 100%;
height: calc(100% - 50px);
margin-top: 40px;
background-size: contain;
background-size: 95%;
background-position: center;
background-repeat: no-repeat;
}

View File

@ -154,8 +154,8 @@ const getLoginUser = async (data?: any) => {
if (res.success) {
userName.value = res.result?.user.name
isLogin.value = true
getApplication(data.client_id || params.value.client_id)
if (data.internal === 'true' || internal.value === 'true') { // oauth2
getApplication(data?.client_id || params.value.client_id)
if (data?.internal === 'true' || internal.value === 'true') { // oauth2
goOAuth2Fn(data)
}
} else if (res.status === 401) {
@ -163,14 +163,14 @@ const getLoginUser = async (data?: any) => {
spinning.value = false
})
getCode()
getApplication(data.client_id || params.value.client_id)
getApplication(data?.client_id || params.value.client_id)
} else {
setTimeout(() => {
spinning.value = false
})
}
} else {
getApplication(data.client_id || params.value.client_id)
getApplication(data?.client_id || params.value.client_id)
setTimeout(() => {
spinning.value = false
})

View File

@ -11,6 +11,7 @@ import { query as deviceQuery } from '@/api/device/instance'
import noticeConfig from '@/api/notice/config'
import noticeTemplate from '@/api/notice/template'
import { Form } from 'jetlinks-ui-components'
import { EventEmitter, EventSubscribeKeys } from '@/views/rule-engine/Scene/Save/util'
const sceneStore = useSceneStore();
const { data: _data } = storeToRefs(sceneStore);
@ -31,6 +32,8 @@ const props = defineProps({
},
});
const sub = ref()
const rules = [{
validator(_: any, v?: ActionsType) {
console.log('validator',v)
@ -62,7 +65,6 @@ const checkDeviceDelete = async () => {
return
}
if (item?.selector === 'fixed') {
console.log(item)
const deviceList = item!.selectorValues?.map(item => item.value) || []
const deviceResp = await deviceQuery({ terms: [{ terms: [{ column: 'id', termType: 'in', value: deviceList.toString() }]}]})
if (deviceResp.success && (deviceResp.result as any)?.total < (item!.selectorValues?.length || 0)) { //
@ -71,6 +73,19 @@ const checkDeviceDelete = async () => {
return
}
}
if (item!.source === 'upper') { // id
if (props.name === 0) {
formTouchOff()
return
} else {
const prevItem = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name - 1].device
if (prevItem?.productId !== item?.productId) {
formTouchOff()
return
}
}
}
}
/**
@ -92,14 +107,52 @@ const checkNoticeDelete = async () => {
}
}
nextTick(() => {
const check = () => {
const _executor = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.executor
if (_executor === 'device' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.device) {
if (_executor === 'device' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.device) { //
checkDeviceDelete()
} else if (_executor === 'notify' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.notify) {
checkNoticeDelete
checkNoticeDelete()
}
})
}
const checkPrevData = (data: any) => {
console.log(data)
const _executor = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.executor
if (_executor === 'device' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.device) { //
//
// id
} else if (_executor === 'notify' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.notify) {
//
}
}
const subscribe = (newName: number, oldName: number) => {
const _key = EventSubscribeKeys({
branch: props.branchesName,
branchGroup: props.thenName,
action: props.name - 1
})
if (sub.value) {
const oldKey = EventSubscribeKeys({
branch: props.branchesName,
branchGroup: props.thenName,
action: oldName - 1
})
sub.value.unSubscribe(oldKey, checkPrevData)
}
sub.value = EventEmitter.subscribe(_key, checkPrevData)
}
watch(() => props.name, (newName, oldName) => {
// subscribe(newName, oldName || 0)
}, { immediate: true })
check()
</script>

View File

@ -445,11 +445,11 @@ const emit = defineEmits(['delete', 'update']);
const visible = ref<boolean>(false);
const triggerVisible = ref<boolean>(false);
const actionType = ref('');
const eventEmitterKey = EventEmitterKeys({
const eventEmitterKey = ref(EventEmitterKeys({
branch: props.branchesName,
branchGroup: props.thenName,
action: props.name
})
}))
const formItemContext = Form.useInjectFormItemContext()
const termsOptions = computed(() => {
if (!props.parallel) {
@ -464,7 +464,7 @@ const termsOptions = computed(() => {
const onDelete = () => {
const key = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].key
EventEmitter.emit(key!, { isDelete: true })
EventEmitter.emit(key!, { isDelete: true }) //
if (props.name !== 0 && !props.parallel) { // options.termsColumnsterms
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name - 1].options!.termsColumns = []
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name - 1].options!.terms = []
@ -524,7 +524,6 @@ const onType = (_type: string) => {
*/
const onSave = (data: ActionsType, options: any) => {
const { key, terms } = _data.value.branches![props.branchesName].then?.[props.thenName].actions?.[props.name]
console.log({...props.options, ...options})
const columns = new Set([...(props.options?.termsColumns || []), ...(options.otherColumns.filter((item?: string) => item))])
@ -535,14 +534,11 @@ const onSave = (data: ActionsType, options: any) => {
terms
}
console.log(actionItem)
_data.value.branches![props.branchesName].then[props.thenName].actions.splice(props.name, 1, actionItem)
visible.value = false;
if (props.parallel === false) { //
EventEmitter.emit(eventEmitterKey, data)
}
EventEmitter.emit(eventEmitterKey.value, data) //
};
/**

View File

@ -84,7 +84,7 @@ const onSave = (data: any, options?: any) => {
key: data.key,
options: {
...options,
columns: options.otherColumns.filter((item?: string) => item)
columns: options.otherColumns?.filter((item?: string) => item) || []
},
};
emit('add', item)

View File

@ -344,7 +344,7 @@ const onChange = (
}
} else {
const item = treeDataMap.get(_value)
const _isRelation = item.isRelation
const _isRelation = item?.isRelation
_values = getObj(_source, _value, _isRelation);
}
emit('update:value', _values);

View File

@ -1,6 +1,6 @@
<template>
<j-menu class='scene-dropdown-menus' @click='click' :selectedKeys='[myValue]'>
<j-menu-item v-for='item in myOptions' :key='item.value' :title='item.label'>
<j-menu-item v-for='item in myOptions' :key='item[valueName]' :value='item.value' :title='item.label'>
<div>
<Ellipsis >
{{ item.label }}
@ -63,12 +63,11 @@ const handleBoolean = (key: string) => {
}
const click = (e: any) => {
let _key = ['true', 'false'].includes(e.key) ? handleBoolean(e.key) : e.key
if (isString(_key) && _key.startsWith('[') && _key.endsWith(']')) {
_key = JSON.parse(_key)
}
const option = getOption(myOptions.value, _key, props.valueName)
myValue.value = e.key
let _key = ['true', 'false'].includes(e.item?.value) ? handleBoolean(e.item?.value) : e.item?.value
const findKeyValue = e.key
const findKey = ['true', 'false'].includes(findKeyValue) ? handleBoolean(findKeyValue) : findKeyValue
const option = getOption(myOptions.value, findKey, props.valueName)
myValue.value = findKeyValue
emit('update:value', _key)
emit('click', _key, {
key: _key,

View File

@ -39,7 +39,7 @@
v-if='(["metric", "upper"].includes(item.key) ? metricOptions : options).length'
:options='["metric", "upper"].includes(item.key) ? metricOptions : options'
:value='myValue'
:valueName='valueName'
:valueName='props.source === "metric" ? "id" : valueName'
@click='onSelect'
/>
<div class='scene-select-empty' v-else>
@ -114,7 +114,7 @@ const visible = ref(false)
nextTick(() => {
mySource.value = props.source
myValue.value = props.value
myValue.value = props.source === 'metric' ? props.metric : props.value
})
const tabsChange = (e: string) => {
@ -143,6 +143,7 @@ const valueItemChange = (e: string) => {
const onSelect = (e: string, option: any) => {
visible.value = false
label.value = option[props.labelName]
console.log(e, option)
emit('update:value', e)
emit('select', e, label.value, { 0: label.value }, option)
}
@ -160,18 +161,22 @@ const visibleChange = (v: boolean) => {
watchEffect(() => {
const _options = ['metric', 'upper'].includes(props.source) ? props.metricOptions : props.options
const option = getOption(_options, props.value as string, props.valueName) // label
myValue.value = props.value
const isMetric = props.source === 'metric' //
const _value = isMetric ? props.metric : props.value
const _valueName = isMetric ? 'id' : props.valueName
const option = getOption(_options, _value as string, _valueName) // label
myValue.value = isMetric ? props.metric : props.value
mySource.value = props.source
console.log(option)
if (option) {
label.value = option[props.labelName] || option.name
treeOpenKeys.value = openKeysByTree(_options, props.value, props.valueName)
} else {
let doubleNull = false
if (isArray(props.value)) {
doubleNull = !!props.value.filter(item => !!item).length
if (isMetric) { //
label.value = props.metric !== undefined ? props.value : props.placeholder
} else {
label.value = props.value !== undefined ? props.value : props.placeholder
}
label.value = props.value !== undefined && !doubleNull ? props.value : props.placeholder
}
})

View File

@ -53,5 +53,9 @@ export const defaultSetting = {
tabsOptions: {
type: Array as PropType<Array<TabsOption>>,
default: () => []
},
metric: {
type: String,
default: undefined
}
}

View File

@ -54,6 +54,7 @@
:options='valueOptions'
:metricOptions='metricOption'
:tabsOptions='tabsOptions'
:metric='paramsValue.value?.metric'
v-model:value='paramsValue.value.value'
v-model:source='paramsValue.value.source'
@select='valueSelect'