Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev
This commit is contained in:
commit
0b126ad548
|
|
@ -195,7 +195,7 @@ import {
|
|||
import { FormValidate, FormState } from '../data';
|
||||
import type { FormInstance } from 'ant-design-vue';
|
||||
import type { FormDataType } from '../type.d';
|
||||
import { isArray } from 'lodash-es';
|
||||
import { cloneDeep, isArray } from 'lodash-es';
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
|
|
@ -217,7 +217,7 @@ const Options = ref({
|
|||
'security-policies': [],
|
||||
});
|
||||
|
||||
const formData = ref<FormDataType>(FormState);
|
||||
const formData = ref<FormDataType>(cloneDeep(FormState));
|
||||
|
||||
const handleOk = async () => {
|
||||
const params = await formRef.value?.validate();
|
||||
|
|
@ -238,11 +238,12 @@ const handleCancel = () => {
|
|||
const changeAuthType = (value: Array<string>) => {
|
||||
formData.value.configuration.authType = value[0];
|
||||
};
|
||||
|
||||
const isAuthType = computed(() => {
|
||||
const { authType } = formData.value.configuration;
|
||||
return isArray(authType)
|
||||
? authType[0] === 'username'
|
||||
: authType === 'username';
|
||||
? authType[0] === 'username' && formData.value.provider === 'OPC_UA'
|
||||
: authType === 'username' && formData.value.provider === 'OPC_UA';
|
||||
});
|
||||
const isSecurityMode = computed(() => {
|
||||
const { securityMode } = formData.value.configuration;
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ export const FormState: FormDataType = {
|
|||
host: '',
|
||||
port: '502',
|
||||
endpoint: '',
|
||||
securityPolicy: undefined,
|
||||
securityPolicy: 'None',
|
||||
securityMode: undefined,
|
||||
certificate: undefined,
|
||||
authType: undefined,
|
||||
authType: 'username',
|
||||
username: '',
|
||||
password: '',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -198,6 +198,9 @@ const columns = [
|
|||
dataIndex: 'description',
|
||||
key: 'description',
|
||||
ellipsis: true,
|
||||
search: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
|
|
@ -254,7 +257,7 @@ const getActions = (
|
|||
state === 'enabled' ? '请先禁用该组件,再删除。' : '删除',
|
||||
},
|
||||
popConfirm: {
|
||||
title: '确认删除?',
|
||||
title: '该操作将会删除下属采集器与点位,确定删除?',
|
||||
onConfirm: async () => {
|
||||
const res = await remove(data.id);
|
||||
if (res.success) {
|
||||
|
|
|
|||
|
|
@ -60,13 +60,10 @@
|
|||
:precision="0"
|
||||
/>
|
||||
</j-form-item>
|
||||
<p
|
||||
style="color: #616161"
|
||||
v-if="formData.configuration.function && formData.pointKey"
|
||||
>
|
||||
<p style="color: #616161" v-if="formData.configuration.function">
|
||||
PLC地址:{{
|
||||
InitAddress[formData.configuration.function] +
|
||||
formData.pointKey
|
||||
formData.pointKey || 0
|
||||
}}
|
||||
</p>
|
||||
<j-form-item
|
||||
|
|
@ -268,6 +265,7 @@ const id = props.data.id;
|
|||
const collectorId = props.data.collectorId;
|
||||
const provider = props.data.provider;
|
||||
const oldPointKey = props.data.pointKey;
|
||||
console.log(22, props.data);
|
||||
|
||||
const InitAddress = {
|
||||
Coils: 1,
|
||||
|
|
@ -293,7 +291,7 @@ const formData = ref({
|
|||
},
|
||||
},
|
||||
},
|
||||
pointKey: '',
|
||||
pointKey: undefined,
|
||||
accessModes: [],
|
||||
nspwc: false,
|
||||
features: [],
|
||||
|
|
@ -301,13 +299,7 @@ const formData = ref({
|
|||
});
|
||||
|
||||
const handleOk = async () => {
|
||||
console.log(2, formRef.value, formRef.value?.validate());
|
||||
|
||||
const data = await formRef.value?.validate().catch((err) => {
|
||||
console.log(23, err);
|
||||
});
|
||||
console.log(3, data);
|
||||
|
||||
const data = await formRef.value?.validate();
|
||||
delete data?.nspwc;
|
||||
const { codec } = data?.configuration;
|
||||
|
||||
|
|
@ -368,17 +360,21 @@ const checkProvider = (_rule: Rule, value: string): Promise<any> =>
|
|||
return checkProviderData[value] > Number(quantity) * 2
|
||||
? reject('数据类型长度需 <= 寄存器数量 * 2')
|
||||
: resolve('');
|
||||
} else {
|
||||
return reject('');
|
||||
}
|
||||
});
|
||||
|
||||
const checkPointKey = (_rule: Rule, value: string): Promise<any> =>
|
||||
new Promise(async (resolve, reject) => {
|
||||
if (value) {
|
||||
if (value || Number(value) === 0) {
|
||||
if (Number(oldPointKey) === Number(value)) return resolve('');
|
||||
const res: any = await _validateField(collectorId, {
|
||||
pointKey: value,
|
||||
});
|
||||
return res.result?.passed ? resolve('') : reject(res.result.reason);
|
||||
} else {
|
||||
return reject('');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
:allowClear="false"
|
||||
:show-time="{ format: 'HH:mm:ss' }"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
v-model="data.time"
|
||||
v-model:value="data.time.time"
|
||||
@change="pickerTimeChange"
|
||||
>
|
||||
<template #suffixIcon
|
||||
|
|
@ -39,24 +39,18 @@
|
|||
import { dashboard } from '@/api/data-collect/dashboard';
|
||||
import { getTimeByType, pointParams, pointOptionsSeries } from '../tool.ts';
|
||||
import * as echarts from 'echarts';
|
||||
import { Dayjs } from 'dayjs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const chartRef = ref<Record<string, any>>({});
|
||||
const loading = ref(false);
|
||||
const data = ref({
|
||||
const data: any = ref({
|
||||
time: {
|
||||
type: 'hour',
|
||||
end: 0,
|
||||
start: 0,
|
||||
time: [null, null],
|
||||
},
|
||||
});
|
||||
|
||||
const pickerTimeChange = (
|
||||
value: [Dayjs, Dayjs],
|
||||
dateString: [string, string],
|
||||
) => {
|
||||
data.value.time.start = Date.parse(dateString[0]);
|
||||
data.value.time.end = Date.parse(dateString[1]);
|
||||
const pickerTimeChange = () => {
|
||||
data.value.time.type = undefined;
|
||||
};
|
||||
|
||||
|
|
@ -114,8 +108,8 @@ const handleOptions = (x = [], y = []) => {
|
|||
watch(
|
||||
() => data.value.time.type,
|
||||
(value) => {
|
||||
data.value.time.end = Date.parse(Date());
|
||||
data.value.time.start = Date.parse(getTimeByType(value));
|
||||
const date = getTimeByType(value);
|
||||
data.value.time.time = [dayjs(date), dayjs(new Date())];
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
|
@ -123,7 +117,7 @@ watch(
|
|||
() => data.value,
|
||||
(value) => {
|
||||
const { time } = value;
|
||||
if (time.type || (time.end && time.start)) {
|
||||
if (time.type || (time.time[0] && time.time[1])) {
|
||||
getEcharts(value);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const getParams = (dt: any) => {
|
||||
switch (dt.type) {
|
||||
|
|
@ -21,7 +22,7 @@ const getParams = (dt: any) => {
|
|||
format: 'HH:mm',
|
||||
};
|
||||
default:
|
||||
const time = dt.end - dt.start;
|
||||
const time = dt.time[1] - dt.time[0];
|
||||
const hour = 60 * 60 * 1000;
|
||||
const days = hour * 24;
|
||||
const year = days * 365;
|
||||
|
|
@ -56,15 +57,15 @@ const getParams = (dt: any) => {
|
|||
export const getTimeByType = (type: string) => {
|
||||
switch (type) {
|
||||
case 'hour':
|
||||
return moment().subtract(1, 'hours');
|
||||
return dayjs().subtract(1, 'hours');
|
||||
case 'week':
|
||||
return moment().subtract(6, 'days');
|
||||
return dayjs().subtract(6, 'days');
|
||||
case 'month':
|
||||
return moment().subtract(29, 'days');
|
||||
return dayjs().subtract(29, 'days');
|
||||
case 'year':
|
||||
return moment().subtract(365, 'days');
|
||||
return dayjs().subtract(365, 'days');
|
||||
default:
|
||||
return moment().startOf('day');
|
||||
return dayjs().startOf('day');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -181,15 +181,15 @@
|
|||
</j-row>
|
||||
<j-divider style="margin: 12px 0" />
|
||||
<div class="content-bottom">
|
||||
<div v-if="slotProps.usedFlow === 0">
|
||||
<span class="flow-text">
|
||||
{{ slotProps.totalFlow }}
|
||||
</span>
|
||||
<span class="card-item-content-text">
|
||||
M 使用流量</span
|
||||
>
|
||||
</div>
|
||||
<div v-else>
|
||||
<!-- <div v-if="slotProps.usedFlow === 0">-->
|
||||
<!-- <span class="flow-text">-->
|
||||
<!-- {{ slotProps.totalFlow }}-->
|
||||
<!-- </span>-->
|
||||
<!-- <span class="card-item-content-text">-->
|
||||
<!-- M 使用流量</span-->
|
||||
<!-- >-->
|
||||
<!-- </div>-->
|
||||
<div>
|
||||
<div class="progress-text">
|
||||
<div>
|
||||
{{
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import Channel from '../components/Channel/index.vue';
|
|||
import Edge from '../components/Edge/index.vue';
|
||||
import Cloud from '../components/Cloud/index.vue';
|
||||
import { getProviders, detail } from '@/api/link/accessConfig';
|
||||
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||
import { accessConfigTypeFilter } from '@/utils/setting';
|
||||
|
||||
const route = useRoute();
|
||||
const id = route.params.id as string;
|
||||
|
|
@ -61,7 +61,7 @@ const type = ref(false);
|
|||
const loading = ref(true);
|
||||
const provider = ref({});
|
||||
const data = ref({});
|
||||
const showType = ref('');
|
||||
const showType: any = ref('');
|
||||
|
||||
const goProviders = (param: any) => {
|
||||
showType.value = param.type;
|
||||
|
|
@ -74,6 +74,19 @@ const goBack = () => {
|
|||
type.value = true;
|
||||
};
|
||||
|
||||
//network
|
||||
const TypeMap = new Map([
|
||||
['fixed-media', 'media'],
|
||||
['gb28181-2016', 'media'],
|
||||
['OneNet', 'cloud'],
|
||||
['Ctwing', 'cloud'],
|
||||
['modbus-tcp', 'channel'],
|
||||
['opc-ua', 'channel'],
|
||||
['official-edge-gateway', 'edge'],
|
||||
['edge-child-device', 'edge'],
|
||||
['network', 'network'],
|
||||
]);
|
||||
|
||||
const getTypeList = (result: Record<string, any>) => {
|
||||
const list = [];
|
||||
const media: any[] = [];
|
||||
|
|
@ -141,8 +154,8 @@ const getTypeList = (result: Record<string, any>) => {
|
|||
const queryProviders = async () => {
|
||||
const resp: any = await getProviders();
|
||||
if (resp.status === 200) {
|
||||
const data = resp.result || []
|
||||
dataSource.value = getTypeList(accessConfigTypeFilter(data as any[]));
|
||||
const _data = resp.result || [];
|
||||
dataSource.value = getTypeList(accessConfigTypeFilter(_data as any[]));
|
||||
// dataSource.value = getTypeList(resp.result)[0].list.filter(
|
||||
// (item) => item.name !== '插件设备接入',
|
||||
// );
|
||||
|
|
@ -153,8 +166,10 @@ const getProvidersData = async () => {
|
|||
if (id !== ':id') {
|
||||
getProviders().then((response: any) => {
|
||||
if (response.status === 200) {
|
||||
const data = response.result || []
|
||||
const list = getTypeList(accessConfigTypeFilter(data as any[]));
|
||||
const _data = response.result || [];
|
||||
const list = getTypeList(
|
||||
accessConfigTypeFilter(_data as any[]),
|
||||
);
|
||||
dataSource.value = list.filter(
|
||||
(item: any) =>
|
||||
item.channel === 'network' ||
|
||||
|
|
@ -165,11 +180,12 @@ const getProvidersData = async () => {
|
|||
const dt = response.result.find(
|
||||
(item: any) => item?.id === resp.result.provider,
|
||||
);
|
||||
|
||||
response.result.forEach((item: any) => {
|
||||
if (item.id === resp.result.provider) {
|
||||
resp.result.type = item.type;
|
||||
showType.value = item.type;
|
||||
resp.result.type = TypeMap.has(item.id)
|
||||
? TypeMap.get(item.id)
|
||||
: TypeMap.get('network');
|
||||
showType.value = resp.result.type;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -58,8 +58,12 @@ const typeList = [
|
|||
|
||||
const select = (s: string) => {
|
||||
selectorModel.value = s
|
||||
devices.value = []
|
||||
orgIds.value = []
|
||||
emit('update:selector', s)
|
||||
emit('update:selectorValues', [])
|
||||
emit('update:deviceKeys', [])
|
||||
emit('update:orgId', [])
|
||||
}
|
||||
|
||||
const updateDevice = (d: any[]) => {
|
||||
|
|
@ -69,7 +73,6 @@ const updateDevice = (d: any[]) => {
|
|||
}
|
||||
|
||||
const updateOrg = (d: any[]) => {
|
||||
console.log('updateOrg', d)
|
||||
orgIds.value = d
|
||||
emit('update:orgId', d)
|
||||
emit('update:selectorValues', d)
|
||||
|
|
|
|||
|
|
@ -75,6 +75,18 @@ const formModel = reactive({
|
|||
functionData: props.functionParameters
|
||||
})
|
||||
|
||||
const handlePropertiesOptions = (propertiesItem: any) => {
|
||||
const _type = propertiesItem?.valueType.type
|
||||
if (_type === 'boolean') {
|
||||
return [
|
||||
{ label: propertiesItem.valueType.falseText || '是', value: propertiesItem.valueType.falseValue || false },
|
||||
{ label: propertiesItem.valueType.trueText || '否', value: propertiesItem.valueType.trueValue || true },
|
||||
]
|
||||
}
|
||||
|
||||
return propertiesItem.valueType?.elements
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前选择功能属性
|
||||
*/
|
||||
|
|
@ -90,7 +102,7 @@ const functionData = computed(() => {
|
|||
name: datum.name,
|
||||
type: datum.valueType ? datum.valueType.type : '-',
|
||||
format: datum.valueType ? datum.valueType.format : undefined,
|
||||
options: datum.valueType ? datum.valueType.elements : undefined,
|
||||
options: handlePropertiesOptions(datum),
|
||||
value: undefined,
|
||||
});
|
||||
}
|
||||
|
|
@ -101,10 +113,13 @@ const functionData = computed(() => {
|
|||
|
||||
const rules = [{
|
||||
validator(_: string, value: any) {
|
||||
console.log(value)
|
||||
debugger
|
||||
if (!value?.length && functionData.value.length) {
|
||||
return Promise.reject('请输入功能值')
|
||||
} else {
|
||||
let hasValue = value.find((item: { name: string, value: any}) => !item.value)
|
||||
let hasValue = value.find((item: { name: string, value: any}) => item.value === undefined)
|
||||
console.log('hasValue', hasValue)
|
||||
if (hasValue) {
|
||||
const functionItem = functionData.value.find((item: any) => item.id === hasValue.name)
|
||||
return Promise.reject(functionItem?.name ? `请输入${functionItem?.name}值` : '请输入功能值')
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@
|
|||
:columns="columns"
|
||||
:request="query"
|
||||
:scroll="{
|
||||
y: 350
|
||||
y: 200
|
||||
}"
|
||||
:bodyStyle='{ padding: "16px 0 0 0"}'
|
||||
:expandable='{
|
||||
expandedRowKeys: openKeys,
|
||||
onExpandedRowsChange: expandedRowChange,
|
||||
|
|
|
|||
|
|
@ -192,28 +192,30 @@ const columns = [
|
|||
hideInTable: true,
|
||||
search: {
|
||||
type: 'treeSelect',
|
||||
options: getTreeData_api({ paging: false }).then((resp: any) => {
|
||||
const formatValue = (list: any[]) => {
|
||||
return list.map((item: any) => {
|
||||
if (item.children) {
|
||||
item.children = formatValue(item.children);
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
value: JSON.stringify({
|
||||
assetType: 'product',
|
||||
targets: [
|
||||
{
|
||||
type: 'org',
|
||||
id: item.id,
|
||||
},
|
||||
],
|
||||
}),
|
||||
}
|
||||
})
|
||||
}
|
||||
return formatValue(resp.result)
|
||||
}),
|
||||
options: () => new Promise((resolve) => {
|
||||
getTreeData_api({ paging: false }).then((resp: any) => {
|
||||
const formatValue = (list: any[]) => {
|
||||
return list.map((item: any) => {
|
||||
if (item.children) {
|
||||
item.children = formatValue(item.children);
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
value: JSON.stringify({
|
||||
assetType: 'product',
|
||||
targets: [
|
||||
{
|
||||
type: 'org',
|
||||
id: item.id,
|
||||
},
|
||||
],
|
||||
}),
|
||||
}
|
||||
})
|
||||
}
|
||||
resolve(formatValue(resp.result) || [])
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,15 +2,6 @@
|
|||
<div :class='["trigger-options-content", isAdd ? "is-add" : ""]'>
|
||||
<span v-if='!isAdd'> 点击配置定时触发 </span>
|
||||
<template v-else>
|
||||
<div class='center-item'>
|
||||
<AIcon v-if='options.selectorIcon' :type='options.selectorIcon' class='icon-padding-right' />
|
||||
<span class='trigger-options-name'>
|
||||
<Ellipsis style='max-width: 310px'>
|
||||
{{ options.name }}
|
||||
</Ellipsis>
|
||||
</span>
|
||||
<span v-if='options.extraName'>{{ options.extraName }}</span>
|
||||
</div>
|
||||
<div v-if='options.when'>
|
||||
<span className='trigger-options-when'>{{ options.when }}</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,261 +1,269 @@
|
|||
<template>
|
||||
<pro-search
|
||||
:columns="columns"
|
||||
type="simple"
|
||||
@search="handleSearch"
|
||||
class="scene-search"
|
||||
target="scene-trigger-device-product"
|
||||
/>
|
||||
<j-divider style="margin: 0" />
|
||||
<j-pro-table
|
||||
ref="actionRef"
|
||||
model="CARD"
|
||||
:columns="columns"
|
||||
:params="params"
|
||||
:request="productQuery"
|
||||
:gridColumn="2"
|
||||
:bodyStyle="{
|
||||
<pro-search
|
||||
:columns='columns'
|
||||
type='simple'
|
||||
@search='handleSearch'
|
||||
class='scene-search'
|
||||
target='scene-trigger-device-product'
|
||||
/>
|
||||
<j-divider style='margin: 0' />
|
||||
<j-pro-table
|
||||
ref='actionRef'
|
||||
model='CARD'
|
||||
:columns='columns'
|
||||
:params='params'
|
||||
:request='productQuery'
|
||||
:gridColumn='2'
|
||||
:bodyStyle='{
|
||||
paddingRight: 0,
|
||||
paddingLeft: 0,
|
||||
}"
|
||||
>
|
||||
<template #card="slotProps">
|
||||
<CardBox
|
||||
:value="slotProps"
|
||||
:active="rowKey === slotProps.id"
|
||||
:status="String(slotProps.state)"
|
||||
:statusText="slotProps.state === 1 ? '正常' : '禁用'"
|
||||
:statusNames="{ '1': 'processing', '0': 'error' }"
|
||||
@click="handleClick(slotProps)"
|
||||
>
|
||||
<template #img>
|
||||
<slot name="img">
|
||||
<img
|
||||
:width="88"
|
||||
:height="88"
|
||||
:src="
|
||||
}'
|
||||
>
|
||||
<template #card='slotProps'>
|
||||
<CardBox
|
||||
:value='slotProps'
|
||||
:active='rowKey === slotProps.id'
|
||||
:status='String(slotProps.state)'
|
||||
:statusText="slotProps.state === 1 ? '正常' : '禁用'"
|
||||
:statusNames="{ '1': 'processing', '0': 'error' }"
|
||||
@click='handleClick(slotProps)'
|
||||
>
|
||||
<template #img>
|
||||
<slot name='img'>
|
||||
<img
|
||||
:width='88'
|
||||
:height='88'
|
||||
:src="
|
||||
slotProps.photoUrl ||
|
||||
getImage('/device-product.png')
|
||||
"
|
||||
/>
|
||||
</slot>
|
||||
</template>
|
||||
<template #content>
|
||||
<div style="width: calc(100% - 100px)">
|
||||
<Ellipsis>
|
||||
<span style="font-size: 16px; font-weight: 600">
|
||||
/>
|
||||
</slot>
|
||||
</template>
|
||||
<template #content>
|
||||
<div style='width: calc(100% - 100px)'>
|
||||
<Ellipsis>
|
||||
<span style='font-size: 16px; font-weight: 600'>
|
||||
{{ slotProps.name }}
|
||||
</span>
|
||||
</Ellipsis>
|
||||
</div>
|
||||
<j-row>
|
||||
<j-col :span="12">
|
||||
<div class="card-item-content-text">设备类型</div>
|
||||
<Ellipsis>{{ slotProps.deviceType?.text }}</Ellipsis>
|
||||
</j-col>
|
||||
<j-col :span="12">
|
||||
<div class="card-item-content-text">接入方式</div>
|
||||
<Ellipsis>{{ slotProps?.accessName || '未接入' }}</Ellipsis>
|
||||
</j-col>
|
||||
</j-row>
|
||||
</template>
|
||||
</CardBox>
|
||||
</Ellipsis>
|
||||
</div>
|
||||
<j-row>
|
||||
<j-col :span='12'>
|
||||
<div class='card-item-content-text'>设备类型</div>
|
||||
<Ellipsis>{{ slotProps.deviceType?.text }}</Ellipsis>
|
||||
</j-col>
|
||||
<j-col :span='12'>
|
||||
<div class='card-item-content-text'>接入方式</div>
|
||||
<Ellipsis>{{ slotProps?.accessName || '未接入' }}</Ellipsis>
|
||||
</j-col>
|
||||
</j-row>
|
||||
</template>
|
||||
</j-pro-table>
|
||||
</CardBox>
|
||||
</template>
|
||||
</j-pro-table>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts' name='Product'>
|
||||
|
||||
<script setup lang='ts' name='Product'>
|
||||
import {
|
||||
getProviders,
|
||||
queryGatewayList,
|
||||
queryProductList,
|
||||
} from '@/api/device/product';
|
||||
import { queryTree } from '@/api/device/category';
|
||||
import { getTreeData_api } from '@/api/system/department';
|
||||
import { isNoCommunity } from '@/utils/utils';
|
||||
import { getImage } from '@/utils/comm';
|
||||
getProviders,
|
||||
queryGatewayList,
|
||||
queryProductList
|
||||
} from '@/api/device/product'
|
||||
import { queryTree } from '@/api/device/category'
|
||||
import { getTreeData_api } from '@/api/system/department'
|
||||
import { isNoCommunity } from '@/utils/utils'
|
||||
import { getImage } from '@/utils/comm'
|
||||
import { accessConfigTypeFilter } from '@/utils/setting'
|
||||
|
||||
type Emit = {
|
||||
(e: 'update:rowKey', data: string): void;
|
||||
(e: 'update:detail', data: string): void;
|
||||
(e: 'change', data: string): void;
|
||||
(e: 'update:rowKey', data: string): void;
|
||||
(e: 'update:detail', data: string): void;
|
||||
(e: 'change', data: string): void;
|
||||
};
|
||||
|
||||
const actionRef = ref();
|
||||
const params = ref({});
|
||||
const actionRef = ref()
|
||||
const params = ref({})
|
||||
const props = defineProps({
|
||||
rowKey: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
detail: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
rowKey: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
detail: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emit>();
|
||||
const emit = defineEmits<Emit>()
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
width: 300,
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
search: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
search: {
|
||||
type: 'string',
|
||||
first: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '网关类型',
|
||||
dataIndex: 'accessProvider',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
hideInTable: true,
|
||||
search: {
|
||||
type: 'select',
|
||||
options: () =>
|
||||
getProviders().then((resp: any) => {
|
||||
const data = resp.result || []
|
||||
return accessConfigTypeFilter(data)
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '接入方式',
|
||||
dataIndex: 'accessName',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
search: {
|
||||
type: 'select',
|
||||
options: () =>
|
||||
queryGatewayList().then((resp: any) =>
|
||||
resp.result.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '设备类型',
|
||||
dataIndex: 'deviceType',
|
||||
width: 150,
|
||||
search: {
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '直连设备', value: 'device' },
|
||||
{ label: '网关子设备', value: 'childrenDevice' },
|
||||
{ label: '网关设备', value: 'gateway' },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'state',
|
||||
width: '90px',
|
||||
search: {
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '禁用', value: 0 },
|
||||
{ label: '正常', value: 1 },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '说明',
|
||||
dataIndex: 'describe',
|
||||
ellipsis: true,
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
dataIndex: 'classifiedId',
|
||||
title: '分类',
|
||||
hideInTable: true,
|
||||
search: {
|
||||
type: 'treeSelect',
|
||||
options: queryTree({ paging: false }).then((resp) => resp.result),
|
||||
componentProps: {
|
||||
fieldNames: {
|
||||
label: 'name',
|
||||
value: 'id',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: 'id$dim-assets',
|
||||
title: '所属组织',
|
||||
hideInTable: true,
|
||||
search: {
|
||||
type: 'treeSelect',
|
||||
options: getTreeData_api({ paging: false }).then((resp: any) => {
|
||||
const formatValue = (list: any[]) => {
|
||||
return list.map((item: any) => {
|
||||
if (item.children) {
|
||||
item.children = formatValue(item.children);
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
value: JSON.stringify({
|
||||
assetType: 'product',
|
||||
targets: [
|
||||
{
|
||||
type: 'org',
|
||||
id: item.id,
|
||||
},
|
||||
],
|
||||
}),
|
||||
};
|
||||
});
|
||||
};
|
||||
return formatValue(resp.result);
|
||||
}),
|
||||
},
|
||||
},
|
||||
];
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
width: 300,
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
search: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
search: {
|
||||
type: 'string',
|
||||
first: true
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '网关类型',
|
||||
dataIndex: 'accessProvider',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
hideInTable: true,
|
||||
search: {
|
||||
type: 'select',
|
||||
options: () =>
|
||||
getProviders().then((resp: any) => {
|
||||
const data = resp.result || []
|
||||
return accessConfigTypeFilter(data)
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '接入方式',
|
||||
dataIndex: 'accessName',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
search: {
|
||||
type: 'select',
|
||||
options: () =>
|
||||
queryGatewayList().then((resp: any) =>
|
||||
resp.result.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '设备类型',
|
||||
dataIndex: 'deviceType',
|
||||
width: 150,
|
||||
search: {
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '直连设备', value: 'device' },
|
||||
{ label: '网关子设备', value: 'childrenDevice' },
|
||||
{ label: '网关设备', value: 'gateway' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'state',
|
||||
width: '90px',
|
||||
search: {
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '禁用', value: 0 },
|
||||
{ label: '正常', value: 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '说明',
|
||||
dataIndex: 'describe',
|
||||
ellipsis: true,
|
||||
width: 300
|
||||
},
|
||||
{
|
||||
dataIndex: 'classifiedId',
|
||||
title: '分类',
|
||||
hideInTable: true,
|
||||
search: {
|
||||
type: 'treeSelect',
|
||||
options: () => {
|
||||
return new Promise((res => {
|
||||
queryTree({ paging: false }).then(resp => {
|
||||
res(resp.result)
|
||||
})
|
||||
}))
|
||||
},
|
||||
componentProps: {
|
||||
fieldNames: {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
dataIndex: 'id$dim-assets',
|
||||
title: '所属组织',
|
||||
hideInTable: true,
|
||||
search: {
|
||||
type: 'treeSelect',
|
||||
options: () => new Promise((resolve) => {
|
||||
getTreeData_api({ paging: false }).then((resp: any) => {
|
||||
const formatValue = (list: any[]) => {
|
||||
return list.map((item: any) => {
|
||||
if (item.children) {
|
||||
item.children = formatValue(item.children)
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
value: JSON.stringify({
|
||||
assetType: 'product',
|
||||
targets: [
|
||||
{
|
||||
type: 'org',
|
||||
id: item.id
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
resolve(formatValue(resp.result) || [])
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const handleSearch = (p: any) => {
|
||||
params.value = p;
|
||||
};
|
||||
params.value = p
|
||||
}
|
||||
|
||||
const productQuery = (p: any) => {
|
||||
const sorts: any = [];
|
||||
const sorts: any = []
|
||||
|
||||
if (props.rowKey) {
|
||||
sorts.push({
|
||||
name: 'id',
|
||||
value: props.rowKey,
|
||||
});
|
||||
}
|
||||
sorts.push({ name: 'createTime', order: 'desc' });
|
||||
p.sorts = sorts;
|
||||
return queryProductList(p);
|
||||
};
|
||||
if (props.rowKey) {
|
||||
sorts.push({
|
||||
name: 'id',
|
||||
value: props.rowKey
|
||||
})
|
||||
}
|
||||
sorts.push({ name: 'createTime', order: 'desc' })
|
||||
p.sorts = sorts
|
||||
return queryProductList(p)
|
||||
}
|
||||
|
||||
const handleClick = (detail: any) => {
|
||||
emit('update:rowKey', detail.id);
|
||||
emit('update:detail', detail);
|
||||
emit('change', detail);
|
||||
};
|
||||
emit('update:rowKey', detail.id)
|
||||
emit('update:detail', detail)
|
||||
emit('change', detail)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang='less'>
|
||||
|
||||
<style scoped lang='less'>
|
||||
.search {
|
||||
margin-bottom: 0;
|
||||
padding-right: 0px;
|
||||
padding-left: 0px;
|
||||
margin-bottom: 0;
|
||||
padding-right: 0px;
|
||||
padding-left: 0px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -175,14 +175,14 @@ const handOptionByColumn = (option: any) => {
|
|||
termTypeOptions.value = option.termTypes || []
|
||||
tabsOptions.value[0].component = option.type
|
||||
if (option.type === 'boolean') {
|
||||
valueOptions.value = [
|
||||
{ name: '是', id: true },
|
||||
{ name: '否', id: false },
|
||||
valueOptions.value = option.options?.map((item: any) => ({ ...item, label: item.name, value: item.id})) || [
|
||||
{ label: '是', value: true },
|
||||
{ label: '否', value: false },
|
||||
]
|
||||
} else if(option.type === 'enum') {
|
||||
valueOptions.value = option.options?.map((item: any) => ({ ...item, label: item.name, value: item.id})) || []
|
||||
} else{
|
||||
valueOptions.value = option.options || []
|
||||
valueOptions.value = (option.options || []).map((item: any) => ({ ...item, label: item.name, value: item.id}))
|
||||
}
|
||||
valueColumnOptions.value = treeFilter(cloneDeep(columnOptions.value), option.type, 'type')
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -88,23 +88,19 @@ const handleOptions = (record: any) => {
|
|||
case 'enum':
|
||||
return (record?.options?.elements || []).map((item: any) => ({ label: item.text, value: item.value }))
|
||||
case 'boolean':
|
||||
return [
|
||||
{ label: '是', value: true },
|
||||
{ label: '否', value: false },
|
||||
]
|
||||
return record?.options
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
const valueChange = debounce(() => {
|
||||
const valueChange = () => {
|
||||
const _value = dataSource.value.map(item => ({
|
||||
name: item.id, value: item.value
|
||||
}))
|
||||
console.log(_value)
|
||||
emit('change', _value)
|
||||
emit('update:value', _value)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
watch(() => props.data, () => {
|
||||
dataSource.value = props.data.map((item: any) => {
|
||||
|
|
|
|||
|
|
@ -176,14 +176,14 @@ const handOptionByColumn = (option: any) => {
|
|||
}
|
||||
|
||||
if (option.dataType === 'boolean') {
|
||||
valueOptions.value = [
|
||||
valueOptions.value = option.options?.map((item: any) => ({ ...item, label: item.name, value: item.id})) || [
|
||||
{ label: '是', value: true },
|
||||
{ label: '否', value: false },
|
||||
]
|
||||
} else if(option.dataType === 'enum') {
|
||||
valueOptions.value = option.options?.map((item: any) => ({ ...item, label: item.name, value: item.id})) || []
|
||||
} else{
|
||||
valueOptions.value = option.options || []
|
||||
valueOptions.value = (option.options || []).map((item: any) => ({ ...item, label: item.name, value: item.id}))
|
||||
}
|
||||
} else {
|
||||
termTypeOptions.value = []
|
||||
|
|
|
|||
|
|
@ -18,21 +18,7 @@
|
|||
@change='updateValue'
|
||||
/>
|
||||
</j-form-item>
|
||||
<j-form-item v-if='showCron' name='cron' :rules="[
|
||||
{ max: 64, message: '最多可输入64个字符' },
|
||||
{
|
||||
validator: async (_, v) => {
|
||||
if (v) {
|
||||
if (!isCron(v)) {
|
||||
return Promise.reject(new Error('请输入正确的cron表达式'));
|
||||
}
|
||||
} else {
|
||||
return Promise.reject(new Error('请输入cron表达式'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
]">
|
||||
<j-form-item v-if='showCron' name='cron' :rules="cronRules">
|
||||
<j-input placeholder='corn表达式' v-model:value='formModel.cron' @change='updateValue' />
|
||||
</j-form-item>
|
||||
<template v-else>
|
||||
|
|
@ -139,6 +125,22 @@ const props = defineProps({
|
|||
|
||||
const emit = defineEmits<Emit>()
|
||||
|
||||
const cronRules = [
|
||||
{ max: 64, message: '最多可输入64个字符' },
|
||||
{
|
||||
validator: async (_: any, v: string) => {
|
||||
if (v) {
|
||||
if (!isCron(v)) {
|
||||
return Promise.reject(new Error('请输入正确的cron表达式'));
|
||||
}
|
||||
} else {
|
||||
return Promise.reject(new Error('请输入cron表达式'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const formModel = reactive<OperationTimer>({
|
||||
trigger: 'week',
|
||||
when: props.value.when || [],
|
||||
|
|
|
|||
|
|
@ -53,13 +53,17 @@
|
|||
</span>
|
||||
</Ellipsis>
|
||||
<div class="subTitle">
|
||||
<span class='subTitle-title'>
|
||||
说明:
|
||||
<Ellipsis :lineClamp="2">
|
||||
{{
|
||||
slotProps?.description ||
|
||||
typeMap.get(slotProps.triggerType)?.tip
|
||||
}}
|
||||
</Ellipsis>
|
||||
</span>
|
||||
<span class='subTitle-content'>
|
||||
<Ellipsis :lineClamp="2">
|
||||
{{
|
||||
slotProps?.description ||
|
||||
typeMap.get(slotProps.triggerType)?.tip
|
||||
}}
|
||||
</Ellipsis>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #actions="item">
|
||||
|
|
@ -378,10 +382,21 @@ const handleView = (id: string, triggerType: string) => {
|
|||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style scoped lang='less'>
|
||||
.subTitle {
|
||||
position: relative;
|
||||
margin-top: 10px;
|
||||
|
||||
.subTitle-title {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.subTitle-content {
|
||||
color: rgba(0, 0, 0, 0.65);
|
||||
font-size: 14px;
|
||||
margin-top: 10px;
|
||||
text-indent: 38px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -406,12 +406,7 @@ type assetType = {
|
|||
value: string;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => form.data.icon,
|
||||
() => {
|
||||
basicFormRef.value?.validate();
|
||||
},
|
||||
);
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
|||
|
|
@ -95,13 +95,15 @@ const confirm = () => {
|
|||
loading.value = true;
|
||||
formRef.value &&
|
||||
formRef.value.validate().then(() => {
|
||||
const buttons = toRaw(props.menuInfo?.buttons);
|
||||
const buttons = toRaw(props.menuInfo?.buttons) || [];
|
||||
const button = buttons?.find((item) => item.id === form.data.id);
|
||||
if (button) {
|
||||
Object.entries(form.data).forEach(([key, value]) => {
|
||||
button[key] = value;
|
||||
});
|
||||
} else buttons.push({ ...form.data });
|
||||
} else {
|
||||
buttons.push({ ...form.data });
|
||||
}
|
||||
const params = {
|
||||
...props.menuInfo,
|
||||
buttons,
|
||||
|
|
|
|||
Loading…
Reference in New Issue