fix: 优化物模型-全屏编辑

This commit is contained in:
XieYongHong 2023-07-26 17:57:57 +08:00
parent bdc85b877a
commit 0742110e69
15 changed files with 67 additions and 21 deletions

View File

@ -5,6 +5,7 @@
visible
width="70vw"
title="编辑规则"
:getContainer="(node) => fullRef || node"
@cancel="handleCancel"
:destroyOnClose="true"
>
@ -57,6 +58,7 @@
import Editor from './Editor/index.vue';
import Debug from './Debug/index.vue';
import Operator from './Operator/index.vue';
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
interface Emits {
(e: 'save', data: string | undefined): void;
@ -73,6 +75,7 @@ const props = defineProps({
const _value = ref<string | undefined>(props.value);
const _disabled = ref<boolean>(true);
const fullRef = inject(FULL_CODE);
const handleCancel = () => {
emit('close');

View File

@ -8,6 +8,7 @@
:options="options"
allowClear
style="width: 100%"
:getPopupContainer="getPopupContainer"
@change='selectChange'
/>
<j-time-picker
@ -16,6 +17,7 @@
allowClear
valueFormat="HH:mm:ss"
style="width: 100%"
:getPopupContainer="getPopupContainer"
@change='timeChange'
/>
<j-date-picker
@ -25,6 +27,7 @@
showTime
valueFormat="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
:getPopupContainer="getPopupContainer"
@change='dateChange'
/>
<j-input-number
@ -93,6 +96,7 @@
cancel-text="取消"
v-model:visible="modalVis"
width="700px"
:getPopupContainer="getPopupContainer"
@cancel="modalVis = false"
@ok="handleItemModalSubmit"
:zIndex='1100'
@ -149,6 +153,10 @@ const props = defineProps({
placeholder: {
type: String,
default: () => '',
},
getPopupContainer: {
type: Function,
default: undefined
}
});
// type Props = {

View File

@ -12,6 +12,7 @@
<script setup name="ConstraintSelect">
import { set, get } from 'lodash-es'
import {FULL_CODE} from "jetlinks-ui-components/es/DataTable";
const props = defineProps({
value: {
@ -25,6 +26,7 @@ const props = defineProps({
})
const emit = defineEmits(['update:value'])
const fullRef = inject(FULL_CODE);
const myValue = ref()

View File

@ -3,6 +3,7 @@
v-model:value="value"
:options="options"
:placeholder="placeholder"
:getPopupContainer="(node) => fullRef || node"
@change="change"
/>
</template>
@ -10,7 +11,7 @@
<script setup lang="ts" name="SelectColumnn">
import type { PropType } from 'vue';
import { ref, watch } from 'vue';
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
type Emits = {
(e: 'update:value', data: Record<string, any>): void;
@ -18,6 +19,8 @@ type Emits = {
};
type SizeType = 'small' | 'middle' | 'large' | undefined;
const fullRef = inject(FULL_CODE);
const emit = defineEmits<Emits>();
const props = defineProps({
value: {

View File

@ -3,6 +3,7 @@
v-model:value="value"
:options="options"
:placeholder="placeholder"
:get-popup-container="(node) => fullRef || node"
@change="change"
/>
</template>
@ -10,8 +11,8 @@
<script setup lang="ts" name="SelectColumnn">
import type { PropType } from 'vue';
import { ref, watch } from 'vue';
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
type Emits = {
(e: 'update:value', data: Record<string, any>): void;
(e: 'change', data: string): void;
@ -36,7 +37,7 @@
});
const value = ref(props.value.async);
const fullRef = inject(FULL_CODE);
const change = (v: string) => {
emit('update:value', {...props.value, async: value.value});
emit('change', v);

View File

@ -5,11 +5,13 @@
{ label: '固定值', value: 'false' },
{ label: '范围值', value: 'true' },
]"
:get-popup-container="(node) => fullRef || node"
@select="select"
/>
</template>
<script name="BooleanSelect" setup>
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
const props = defineProps({
value: {
@ -17,8 +19,10 @@ const props = defineProps({
default: () => ({})
}
})
const emit = defineEmits(['update:value'])
const fullRef = inject(FULL_CODE);
const myValue = ref()
const select = (e) => {
emit('update:value', {

View File

@ -90,6 +90,14 @@ const columns: any = [
form: {
required: true,
rules: [
{
callback(rule:any,value: any) {
if (!value) {
return Promise.reject('请输入指标名称')
}
return Promise.resolve()
}
},
{ max: 64, message: '最多可输入64个字符' },
]
},
@ -107,11 +115,11 @@ const columns: any = [
required: true,
rules: [
{
validator(_: any, value: any) {
callback(rule:any,value: any) {
if (!value) {
return Promise.reject('请配置指标')
}
return validatorConfig(value, true)
return Promise.resolve()
}
},
]
@ -148,7 +156,7 @@ const addItem = () => {
const data = {
id: undefined,
name: undefined,
range: 'false',
range: false,
value: undefined,
}

View File

@ -6,6 +6,7 @@
<j-popconfirm-modal
:show-cancel="false"
body-style="width: 300px"
:get-popup-container="(node) => fullRef || node"
@confirm="confirm"
>
<template #content>
@ -39,6 +40,7 @@ import type { PropType } from 'vue';
import Item from './item.vue'
import {Form} from "jetlinks-ui-components";
import {cloneDeep} from "lodash";
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
type ValueType = number | Array<number | undefined> | undefined;
@ -55,7 +57,7 @@ const props = defineProps({
const emit = defineEmits<Emit>();
const formItemContext = Form.useInjectFormItemContext();
const fullRef = inject(FULL_CODE);
const formData = reactive<{
@ -89,6 +91,7 @@ const confirm = () => {
return new Promise((resolve, reject) => {
formRef.value.validate().then(() => {
const value = props.value.range === true ? formData.rangeValue : formData.value
console.log('confirm',value, props.value)
emit('update:value', {
...props.value,
value: value

View File

@ -23,17 +23,20 @@
{ label: '否', value: 'false'},
{ label: '是', value: 'true'},
]"
:get-popup-container="(node) => fullRef || node"
/>
<j-date-picker
v-else-if="type === 'date' "
v-model:value="myValue"
show-time
placeholder="请选择"
:get-popup-container="(node) => fullRef || node"
@change="change"
/>
</template>
<script setup name="MetricValueItem">
import { Form } from 'jetlinks-ui-components'
import {FULL_CODE} from "jetlinks-ui-components/es/DataTable";
const props = defineProps({
value: {
@ -47,6 +50,7 @@ const formItemContext = Form.useInjectFormItemContext();
const type = inject('metricsType')
const myValue = ref(props.value)
const fullRef = inject(FULL_CODE);
const change = () => {
// formItemContext.onFieldChange()

View File

@ -3,6 +3,7 @@
body-style="padding-top:4px;width:600px;"
placement="topRight"
:disabled="disabled"
:get-popup-container="(node) => fullRef || node"
@confirm="confirm"
@cancel="cancel"
@visibleChange="visibleChange"
@ -27,6 +28,7 @@
label: a.text,
value: a.value,
}))"
:get-popup-container="(node) => fullRef || node"
/>
</template>
</j-table>
@ -63,6 +65,7 @@ import {useInstanceStore} from "store/instance";
import {getMetadataConfig, getMetadataDeviceConfig} from "@/api/device/product";
import ModelButton from '@/views/device/components/Metadata/Base/components/ModelButton.vue'
import {omit} from "lodash-es";
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
const props = defineProps({
value: {
@ -83,6 +86,8 @@ const props = defineProps({
},
})
const fullRef = inject(FULL_CODE);
const type = inject('_metadataType')
const productStore = useProductStore()

View File

@ -16,6 +16,7 @@
label: a.text,
value: a.value,
}))"
:get-popup-container="(node) => fullRef || node"
/>
</template>
</j-table>
@ -29,6 +30,7 @@ import type { PropType } from "vue";
import { defineExpose } from 'vue'
import {getMetadataConfig, getMetadataDeviceConfig} from "@/api/device/product";
import { omit } from 'lodash-es'
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
const props = defineProps({
type: {
@ -47,7 +49,7 @@ const props = defineProps({
const productStore = useProductStore()
const deviceStore = useInstanceStore()
const fullRef = inject(FULL_CODE);
const config = ref<any>([])
const configValue = ref(props.record?.expands)

View File

@ -4,17 +4,20 @@
v-model:value="myValue"
:options="PropertySource"
placeholder="请选择来源"
@change="onChange"
:disabled="disabled"
:get-popup-container="(node) => fullRef || node"
@change="onChange"
>
</j-select>
<j-popconfirm-modal
v-if="myValue != 'manual'"
@confirm="confirm"
:bodyStyle="{
width: '450px',
height: myValue === 'rule' ? '300px' : '80px',
}"
:get-popup-container="(node) => fullRef || node"
placement="topLeft"
@confirm="confirm"
>
<template #content>
<j-scrollbar v-if="myValue">
@ -39,6 +42,7 @@
import { isNoCommunity } from '@/utils/utils';
import VirtualRule from './VirtualRule/index.vue';
import { Form } from 'jetlinks-ui-components';
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
const PropertySource: { label: string; value: string }[] = isNoCommunity
? [
@ -72,6 +76,8 @@ type Emit = {
(e: 'update:value', data: Record<string, any>): void;
};
const fullRef = inject(FULL_CODE);
const props = defineProps({
value: {
type: Object,

View File

@ -7,6 +7,7 @@
{ label: '写', value: 'write'},
{ label: '上报', value: 'report'},
]"
:get-popup-container="(node) => fullRef || node"
placeholder="请选择读写类型"
@change="onChange"
/>
@ -15,6 +16,7 @@
<script setup lang="ts">
import type {PropType} from "vue";
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
type Emit = {
(e: 'update:value', data: any): void
@ -28,7 +30,7 @@ const props = defineProps({
})
const emit = defineEmits<Emit>()
const fullRef = inject(FULL_CODE);
const myValue = ref<Array<string>>([])
const onChange = () =>{

View File

@ -7,6 +7,7 @@
<j-radio-group
button-style="solid"
v-model:value="data.type"
@change="() => { getNetworkEcharts(data) }"
>
<j-radio-button value="bytesRead">
上行
@ -105,6 +106,7 @@ const serverData = reactive({
const pickerTimeChange = (value: any) => {
data.value.time.type = undefined;
getNetworkEcharts(data.value);
};
const getNetworkEcharts = async (val: any) => {
@ -220,13 +222,6 @@ watch(
{ immediate: true, deep: true },
);
// watchEffect(() => {
// const time = data.value.time.time
// if (time && Array.isArray(time) && time.length === 2 && time[0] && props.serviceId) {
//
// }
// })
</script>
<style lang="less" scoped>

View File

@ -3755,8 +3755,8 @@ jetlinks-ui-components@^1.0.23:
jetlinks-ui-components@^1.0.27:
version "1.0.27"
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.27.tgz#c2e62ebf26d9465aed5489fdde37297738d57f2b"
integrity sha512-IVWCPfC5awTIIMQ5t6V5KTHLjfENj0owb6HsHxqRLrHebz7FaDng6oNfebvn17P+gHGVwwMemTCF7b8PpWFiwg==
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.27.tgz#1f0984de391638429b147f45b0e7aca928fb80f8"
integrity sha512-87JBHVqqI3aNV2H8SFnMHegW5b1tjtCtxcEbQUFM7Mq7ZJQcR4GhaCmhP61E8PsZbHLPNFjNgb6GGwhdWT4MKQ==
dependencies:
"@vueuse/core" "^9.12.0"
"@vueuse/router" "^9.13.0"