123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <script setup lang="ts">
- import { computed, ref, watch } from 'vue';
- import SvgIcon from '@/components/SvgIcon.vue';
- import { useRequest } from '@/hooks/request';
- import { useViewVisible } from '@/hooks/view-visible';
- import { getDeviceParams } from '@/api';
- import type { DeviceParamGroup, DeviceParamItem, OptionItem } from '@/types';
- interface Props {
- devId: number;
- }
- const props = defineProps<Props>();
- const { visible, showView, hideView } = useViewVisible();
- const { isLoading, handleRequest } = useRequest();
- const allParamGroups = ref<DeviceParamGroup[]>([]);
- const activeGroup = ref(-1);
- const groupList = computed<OptionItem<number>[]>(() => {
- return allParamGroups.value.map((item) => ({
- value: item.id,
- label: item.deviceParamGroupName,
- }));
- });
- const paramList = computed<DeviceParamItem[]>(() => {
- const params = allParamGroups.value.find((item) => item.id === activeGroup.value);
- if (params) {
- return params.valueVos;
- }
- return [];
- });
- watch(visible, () => {
- if (visible.value) {
- getAllParamGroups();
- }
- });
- const getAllParamGroups = () => {
- handleRequest(async () => {
- const data = await getDeviceParams(props.devId, false);
- allParamGroups.value = data;
- if (data.length) {
- activeGroup.value = data[0].id;
- }
- });
- };
- const viewData = () => {
- return;
- };
- const handleClose = () => {
- allParamGroups.value = [];
- activeGroup.value = -1;
- };
- defineExpose({
- showView,
- hideView,
- });
- </script>
- <template>
- <AModal
- v-model:open="visible"
- wrap-class-name="dev-work-params-modal"
- :title="$t('createDevice.parameters')"
- :width="920"
- centered
- :footer="null"
- :after-close="handleClose"
- >
- <AEmpty v-show="!groupList.length" />
- <ASpin class="center-loading" :spinning="isLoading" />
- <ATabs class="hide-tabs-border" v-model:active-key="activeGroup">
- <ATabPane v-for="item in groupList" :key="item.value" :tab="item.label" />
- </ATabs>
- <div class="param-list">
- <ARow :gutter="[16, 16]">
- <ACol v-for="item in paramList" :key="item.deviceParamCode" :span="8">
- <div class="param-container">
- <div class="param-header">
- <div class="ellipsis-text param-name">{{ item.paramName }}</div>
- <div class="param-view" @click="viewData">{{ $t('deviceWorkStatus.viewData') }}</div>
- <SvgIcon name="right" :size="12" color="rgba(0, 0, 0, 0.25)" />
- </div>
- <div class="param-body">
- <div class="param-value">{{ item.value }}{{ item.unit }}</div>
- <div class="param-time">{{ item.time }}</div>
- </div>
- </div>
- </ACol>
- </ARow>
- </div>
- </AModal>
- </template>
- <style lang="scss">
- .dev-work-params-modal {
- .ant-modal,
- .ant-modal > div,
- .ant-modal-content {
- height: 640px;
- }
- .ant-modal-content {
- display: flex;
- flex-direction: column;
- overflow: hidden;
- }
- .ant-modal-body {
- display: flex;
- flex-direction: column;
- height: calc(100% - 32px);
- }
- .ant-empty {
- margin-top: 150px;
- }
- }
- </style>
- <style lang="scss" scoped>
- .param-list {
- height: 100%;
- overflow: hidden auto;
- }
- .param-container {
- width: 280px;
- height: 156px;
- background: #fff;
- border: 1px solid #e4e7ed;
- border-radius: 8px;
- }
- .param-header {
- display: flex;
- align-items: center;
- height: 50px;
- padding-right: 12px;
- padding-left: 16px;
- border-bottom: 1px solid #e4e7ed;
- }
- .param-name {
- flex: 1;
- margin-right: 16px;
- font-size: 14px;
- line-height: 22px;
- color: var(--antd-color-text);
- }
- .param-view {
- margin-right: 4px;
- font-size: 14px;
- font-weight: 500;
- line-height: 24px;
- color: var(--antd-color-primary);
- cursor: pointer;
- }
- .param-body {
- padding: 24px 16px;
- }
- .param-value {
- margin-bottom: 8px;
- font-size: 18px;
- font-weight: 600;
- line-height: 26px;
- color: var(--antd-color-text);
- }
- .param-time {
- font-size: 14px;
- line-height: 24px;
- color: var(--antd-color-text-tertiary);
- }
- </style>
|