添加接口和新组件

main
suixy 1 month ago
parent 0b1d64bc05
commit e5978a0f48

@ -13,6 +13,7 @@ import { useAppStore } from '@/store/modules/app';
const appStore = useAppStore(); const appStore = useAppStore();
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
// //

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 KiB

After

Width:  |  Height:  |  Size: 1.9 MiB

@ -0,0 +1 @@
const websocketUrl = 'ws://119.45.202.115:7181/ws';

@ -130,7 +130,17 @@
:key="key" :key="key"
:label="monitorType.find((e) => e.value === key)?.label" :label="monitorType.find((e) => e.value === key)?.label"
:value="key" :value="key"
v-for="(value, key) in deviceData.find((e) => e.id === nodeData.id)?.options" v-for="key in [
...new Set(
nodeData.id
.replaceAll('', ',')
.split(',')
.map((v) => {
return Object.keys(deviceData.find((e) => e.id === v)?.options);
})
.flat()
)
]"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -161,6 +171,7 @@
<el-option label="左对齐" value="left" /> <el-option label="左对齐" value="left" />
<el-option label="居中" value="center" /> <el-option label="居中" value="center" />
<el-option label="右对齐" value="right" /> <el-option label="右对齐" value="right" />
<el-option label="中心对齐" value="center1" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="冒号居中" label-width="120px" v-if="Object.hasOwn(nodeStyle, 'isColonCentered')"> <el-form-item label="冒号居中" label-width="120px" v-if="Object.hasOwn(nodeStyle, 'isColonCentered')">
@ -779,9 +790,9 @@ const transformData = (arr) => {
} }
] ]
*/ */
const getDeviceData = () => { const getDeviceData = () => {
getIotEnvMonitorLatestAll().then((res) => { getIotEnvMonitorLatestAll().then((res) => {
console.log(transformData(res.data));
deviceData.value = transformData(res.data); deviceData.value = transformData(res.data);
//collectTime objid monitorCode monitorId monitorType //collectTime objid monitorCode monitorId monitorType
}); });
@ -910,6 +921,7 @@ watch(
} }
} }
} }
.moduleCard { .moduleCard {
width: calc(50% - 4px); width: calc(50% - 4px);
display: inline-block; display: inline-block;

@ -0,0 +1,184 @@
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="备注" prop="remark">
<el-input v-model="queryParams.remark" placeholder="请输入备注" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow="never">
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"></el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
</el-row>
</template>
<el-table v-loading="loading" border :data="emsBaseLocationJsonList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" width="70">
<template #default="scope">
<span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="ID" align="center" prop="id" width="100" />
<el-table-column label="备注" align="center" prop="remark" min-width="180" show-overflow-tooltip />
<el-table-column label="部门ID" align="center" prop="deptId" min-width="120" />
<el-table-column label="操作" align="center" fixed="right" width="100">
<template #default="scope">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
</el-card>
<el-dialog v-model="dialog.visible" :title="dialog.title" width="680px" append-to-body>
<el-form ref="emsBaseLocationJsonFormRef" :model="form" :rules="rules" label-width="90px">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts" name="VisualEditorList">
import { addEmsBaseLocationJson, delEmsBaseLocationJson, listEmsBaseLocationJson } from '@/api/ems/base/emsBaseLocationJson';
import type { EmsBaseLocationJsonForm, EmsBaseLocationJsonQuery, EmsBaseLocationJsonVO } from '@/api/ems/base/emsBaseLocationJson/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const emsBaseLocationJsonList = ref<EmsBaseLocationJsonVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(false);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const multiple = ref(true);
const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const emsBaseLocationJsonFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: EmsBaseLocationJsonForm = {
id: undefined,
json: '{}',
remark: undefined,
deptId: undefined
};
const data = reactive<PageData<EmsBaseLocationJsonForm, EmsBaseLocationJsonQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
json: undefined,
deptId: undefined,
params: {}
},
rules: {
json: [{ required: true, message: '请输入JSON内容', trigger: 'blur' }]
}
});
const { form, queryParams, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
try {
const res = await listEmsBaseLocationJson(queryParams.value);
emsBaseLocationJsonList.value = res.rows || [];
total.value = res.total || 0;
} finally {
loading.value = false;
}
};
const reset = () => {
form.value = { ...initFormData };
emsBaseLocationJsonFormRef.value?.resetFields();
};
const cancel = () => {
dialog.visible = false;
reset();
};
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
const handleSelectionChange = (selection: EmsBaseLocationJsonVO[]) => {
ids.value = selection.map((item) => item.id);
multiple.value = selection.length === 0;
};
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '新增前端电路图配置';
};
const submitForm = () => {
emsBaseLocationJsonFormRef.value?.validate(async (valid: boolean) => {
if (!valid) return;
buttonLoading.value = true;
try {
await addEmsBaseLocationJson(form.value);
proxy?.$modal.msgSuccess('新增成功');
dialog.visible = false;
await getList();
} finally {
buttonLoading.value = false;
}
});
};
const handleDelete = async (row?: EmsBaseLocationJsonVO) => {
const deleteIds = row?.id || ids.value;
if (!deleteIds || (Array.isArray(deleteIds) && deleteIds.length === 0)) {
return;
}
await proxy?.$modal.confirm(`是否确认删除前端电路图配置编号为"${deleteIds}"的数据项?`);
await delEmsBaseLocationJson(deleteIds);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
onMounted(() => {
getList();
});
</script>

@ -61,9 +61,7 @@ const props = defineProps({
required: true required: true
} }
}); });
onMounted(() => { onMounted(() => {});
console.log(props);
});
</script> </script>
<style scoped> <style scoped>
.custom-node { .custom-node {

@ -11,9 +11,10 @@
pointerEvents: props.isView ? 'auto' : 'none' pointerEvents: props.isView ? 'auto' : 'none'
}" }"
> >
<template v-for="ii in list">
<div <div
:key="k" :key="k"
v-for="(i, k) in list" v-for="(i, k) in ii"
:style="{ :style="{
whiteSpace: props.data.style.whiteSpace || 'nowrap', whiteSpace: props.data.style.whiteSpace || 'nowrap',
textAlign: props.data.style.isColonCentered ? 'none' : props.data.style.align || 'center' textAlign: props.data.style.isColonCentered ? 'none' : props.data.style.align || 'center'
@ -26,7 +27,11 @@
fontSize: `${props.data.style.fontSize || 12}px`, fontSize: `${props.data.style.fontSize || 12}px`,
display: props.data.style.isColonCentered ? 'inline-block' : 'inline', display: props.data.style.isColonCentered ? 'inline-block' : 'inline',
width: props.data.style.isColonCentered ? `calc(${props.data.style.ratio}% - ${(props.data.style.fontSize + 6) / 2}px)` : +'auto', width: props.data.style.isColonCentered ? `calc(${props.data.style.ratio}% - ${(props.data.style.fontSize + 6) / 2}px)` : +'auto',
textAlign: props.data.style.isColonCentered ? props.data.style.align || 'center' : 'none' textAlign: props.data.style.isColonCentered
? props.data.style.align === 'center1'
? 'right'
: props.data.style.align || 'center'
: 'none'
}" }"
>{{ i.label || i.key }}</span >{{ i.label || i.key }}</span
> >
@ -47,11 +52,16 @@
fontSize: `${props.data.style.fontSize || 12}px`, fontSize: `${props.data.style.fontSize || 12}px`,
display: props.data.style.isColonCentered ? 'inline-block' : 'inline', display: props.data.style.isColonCentered ? 'inline-block' : 'inline',
width: props.data.style.isColonCentered ? `calc(${100 - props.data.style.ratio}% - ${(props.data.style.fontSize + 6) / 2}px)` : +'auto', width: props.data.style.isColonCentered ? `calc(${100 - props.data.style.ratio}% - ${(props.data.style.fontSize + 6) / 2}px)` : +'auto',
textAlign: props.data.style.isColonCentered ? props.data.style.align || 'center' : 'none' textAlign: props.data.style.isColonCentered
? props.data.style.align === 'center1'
? 'left'
: props.data.style.align || 'center'
: 'none'
}" }"
>{{ i.value }}</span >{{ i.value }}</span
> >
</div> </div>
</template>
</div> </div>
</div> </div>
</template> </template>
@ -120,25 +130,46 @@ const props = defineProps({
} }
}); });
const list = ref([]); const list = ref([]);
const pNode = computed(() => props.nodes.find((n) => n.id === props.parentNodeId)); const pNode = computed(() => props.nodes?.find((n) => n.id === props.parentNodeId));
const getList = () => { const getList = () => {
let deviceData = props.networkData.find((e) => e.id === pNode.value.data.options.id)?.options; if (!pNode.value) return;
let options = pNode.value.data.options.infos; const ids = pNode.value.data.options.id.replaceAll('', ',').split(',');
list.value = const arr = ids.map((v) => {
return props.networkData.find((e) => e.id == v)?.options;
});
const options = pNode.value.data.options.infos;
list.value = arr.map((v) => {
return (
options?.map((e, i) => { options?.map((e, i) => {
let item = {}; const item = {};
item.label = props.monitorType.find((v) => v.value === e)?.label; item.label = props.monitorType.find((v) => v.value === e)?.label;
item.key = e; item.key = e;
item.value = deviceData[e]; item.value = v?.[e];
return item; return item;
}) || []; }) || []
);
});
console.log(list.value);
// let deviceData = props.networkData.find((e) => e.id === pNode.value.data.options.id)?.options;
//
// let options = pNode.value.data.options.infos;
// list.value =
// options?.map((e, i) => {
// let item = {};
// item.label = props.monitorType.find((v) => v.value === e)?.label;
// item.key = e;
// item.value = deviceData?.[e];
// return item;
// }) || [];
}; };
onMounted(() => { onMounted(() => {
getList(); getList();
}); });
watch( watch(
() => pNode.value, () => [pNode.value?.data.options.id, props.networkData, pNode.value?.data.options.infos],
(obj1, obj2) => { () => {
getList(); getList();
}, },
{ deep: true } { deep: true }

@ -72,9 +72,7 @@ const lineStyle = computed(() => {
}; };
}); });
onMounted(() => { onMounted(() => {});
console.log(props);
});
</script> </script>
<style scoped> <style scoped>
.custom-node { .custom-node {

Loading…
Cancel
Save