Commit 7c676bd0c6636952a4bcc11a36bca34666861320

Authored by xp.Huang
2 parents 678e24d3 7b53f85e

Merge branch 'ww' into 'main'

fix: BUG in teambition

See merge request huang/yun-teng-iot-front!299
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<svg width="54px" height="54px" viewBox="0 0 54 54" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  3 + <title>组件图标</title>
  4 + <g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
  5 + <g id="看板管理" transform="translate(-322.000000, -326.000000)" fill="#377DFF">
  6 + <g id="1" transform="translate(302.000000, 234.000000)">
  7 + <g id="组件图标" transform="translate(20.000000, 92.000000)">
  8 + <rect id="矩形" opacity="0.1" x="0" y="0" width="54" height="54" rx="22"></rect>
  9 + <g id="组件" transform="translate(13.500000, 15.000000)" fill-rule="nonzero">
  10 + <path d="M25.2323972,16.1837421 C25.0692247,16.1837421 24.9060522,16.2163766 24.7577136,16.2816456 L24.7517801,16.2846123 L24.7458465,16.2846123 L13.2377373,21.1886867 L1.72666139,16.2875791 L1.72072785,16.2875791 L1.7147943,16.2846123 C1.5664557,16.2223101 1.40921677,16.1867089 1.24011076,16.1867089 C0.554786392,16.1867089 0,16.7592959 0,17.4653877 C0,17.9994066 0.31744462,18.4533228 0.765427215,18.646163 L12.7482199,23.7519778 L12.760087,23.7549446 C13.0626978,23.8854826 13.4068434,23.8854826 13.7094541,23.7549446 L13.7153877,23.7519778 C13.7183544,23.7519778 13.7183544,23.7490111 13.7213212,23.7490111 L25.7041139,18.6431962 C26.1520965,18.450356 26.469553,17.9964399 26.469553,17.4624209 C26.4725079,16.7563291 25.9177215,16.1837421 25.2323972,16.1837421 Z M25.2323972,10.650712 C24.9980222,10.6447785 24.7577136,10.7456487 24.7577136,10.7456487 L13.2377373,15.6526899 L1.7147943,10.7456487 C1.7147943,10.7456487 1.40921677,10.650712 1.24011076,10.650712 C0.554786392,10.650712 0,11.2203323 0,11.9264241 C0,12.4574763 0.31744462,12.9143592 0.765427215,13.1042326 L12.7482199,18.2070807 C12.7511867,18.2070807 12.7511867,18.2100475 12.7541535,18.2100475 L12.7571203,18.2130142 C12.9054589,18.2753165 13.0626978,18.3109177 13.2318038,18.3109177 C13.4009098,18.3109177 13.5611155,18.2753165 13.7064873,18.2130142 L13.7124209,18.2100475 C13.7153877,18.2100475 13.7153877,18.2100475 13.7183544,18.2070807 L25.7011472,13.1042326 C26.1491297,12.9143592 26.4665744,12.4574763 26.469553,11.9264241 C26.4725079,11.2203323 25.9177215,10.650712 25.2323972,10.650712 L25.2323972,10.650712 Z M0.765427215,7.57120253 L12.7482199,12.6770174 C12.7511867,12.6770174 12.7511867,12.6770174 12.7541535,12.6799842 L12.7571203,12.6829509 C12.9054589,12.7452532 13.0626978,12.7778877 13.2318038,12.7778877 C13.3949763,12.7778877 13.555182,12.7452532 13.7064873,12.6829509 L13.7124209,12.6799842 L13.7183544,12.6770174 L25.7011472,7.5741693 C26.1491297,7.38132911 26.4665744,6.92741297 26.4695411,6.39636076 C26.4695411,5.86234177 26.1520965,5.40842563 25.7041139,5.21558544 L13.7213212,0.106803797 C13.7183544,0.106803797 13.7183544,0.106803797 13.7153877,0.103837025 L13.7094541,0.100870253 C13.4068434,-0.0296677215 13.0626978,-0.0296677215 12.760087,0.100870253 L12.7571203,0.103837025 L0.765427215,5.21261867 C0.31744462,5.40249209 0,5.859375 0,6.39339399 C0,6.9244462 0.31744462,7.37836234 0.765427215,7.57120253 Z" id="形状"></path>
  11 + </g>
  12 + </g>
  13 + </g>
  14 + </g>
  15 + </g>
  16 +</svg>
@@ -89,6 +89,16 @@ @@ -89,6 +89,16 @@
89 } 89 }
90 ); 90 );
91 91
  92 + watch(
  93 + () => props.radio,
  94 + () => {
  95 + const option = beforeUpdateFn(props.layout.componentType);
  96 + setTimeout(() => {
  97 + unref(chartRef)?.setOption((option(unref(getRadio)) as unknown as EChartsOption) || {});
  98 + });
  99 + }
  100 + );
  101 +
92 let timeout: Nullable<number> = null; 102 let timeout: Nullable<number> = null;
93 103
94 function handleRandomValue() { 104 function handleRandomValue() {
@@ -101,6 +111,7 @@ @@ -101,6 +111,7 @@
101 initChart(); 111 initChart();
102 props.add && props.add(props.value.id, update); 112 props.add && props.add(props.value.id, update);
103 if (props.random) timeout = setInterval(handleRandomValue, 2000) as unknown as number; 113 if (props.random) timeout = setInterval(handleRandomValue, 2000) as unknown as number;
  114 + console.log(unref(chartRef));
104 }); 115 });
105 116
106 onUnmounted(() => { 117 onUnmounted(() => {
@@ -107,10 +107,9 @@ export const instrumentComponent1 = (params?: Partial<ComponentInfo>): EChartsOp @@ -107,10 +107,9 @@ export const instrumentComponent1 = (params?: Partial<ComponentInfo>): EChartsOp
107 lineHeight: 30, 107 lineHeight: 30,
108 borderRadius: 8, 108 borderRadius: 8,
109 offsetCenter: [0, '-15%'], 109 offsetCenter: [0, '-15%'],
110 - // fontSize: 16,  
111 fontSize: 14, 110 fontSize: 14,
112 fontWeight: 'bolder', 111 fontWeight: 'bolder',
113 - formatter: `{value} ${unit ?? '°C'}`, 112 + formatter: `{value} ${unit ?? ''}`,
114 color: params?.fontColor || 'inherit', 113 color: params?.fontColor || 'inherit',
115 }, 114 },
116 data: [ 115 data: [
@@ -219,7 +218,7 @@ export const instrumentComponent2 = (params?: Partial<ComponentInfo>): EChartsOp @@ -219,7 +218,7 @@ export const instrumentComponent2 = (params?: Partial<ComponentInfo>): EChartsOp
219 }, 218 },
220 detail: { 219 detail: {
221 valueAnimation: true, 220 valueAnimation: true,
222 - formatter: `{value} ${unit}`, 221 + formatter: `{value} ${unit ?? ''}`,
223 color: params?.fontColor || 'inherit', 222 color: params?.fontColor || 'inherit',
224 fontSize: 14, 223 fontSize: 14,
225 }, 224 },
@@ -46,12 +46,18 @@ @@ -46,12 +46,18 @@
46 getAllDataSourceFieldValue: Fn<any, Recordable>; 46 getAllDataSourceFieldValue: Fn<any, Recordable>;
47 }>(); 47 }>();
48 48
  49 + const resetForm = () => {
  50 + isEdit.value = false;
  51 + frontId.value = '';
  52 + componentRecord.value = {} as unknown as DataBoardLayoutInfo;
  53 + componentDefaultConfig.value = {};
  54 + };
  55 +
49 const handleSubmit = () => { 56 const handleSubmit = () => {
50 const { getAllDataSourceFieldValue } = unref(basicConfigurationEl)!; 57 const { getAllDataSourceFieldValue } = unref(basicConfigurationEl)!;
51 const value = getAllDataSourceFieldValue(); 58 const value = getAllDataSourceFieldValue();
52 unref(isEdit) ? handleUpdateComponent(value) : handleAddComponent(value); 59 unref(isEdit) ? handleUpdateComponent(value) : handleAddComponent(value);
53 - isEdit.value = false;  
54 - frontId.value = ''; 60 + resetForm();
55 }; 61 };
56 62
57 const handleAddComponent = async (value: Recordable) => { 63 const handleAddComponent = async (value: Recordable) => {
@@ -111,6 +117,7 @@ @@ -111,6 +117,7 @@
111 width="70%" 117 width="70%"
112 :destroy-on-close="true" 118 :destroy-on-close="true"
113 @ok="handleSubmit" 119 @ok="handleSubmit"
  120 + @cancel="resetForm"
114 > 121 >
115 <section> 122 <section>
116 <Tabs type="card"> 123 <Tabs type="card">
@@ -228,6 +228,12 @@ @@ -228,6 +228,12 @@
228 // dataBoardList.value = []; 228 // dataBoardList.value = [];
229 loading.value = true; 229 loading.value = true;
230 const data = await getDataBoradDetail(); 230 const data = await getDataBoradDetail();
  231 +
  232 + if (!data.data.componentData) {
  233 + dataBoardList.value = [];
  234 + console.log(unref(dataBoardList));
  235 + return;
  236 + }
231 dataBoardList.value = data.data.componentData.map((item) => { 237 dataBoardList.value = data.data.componentData.map((item) => {
232 const index = data.data.componentLayout.findIndex((each) => item.id === each.id); 238 const index = data.data.componentLayout.findIndex((each) => item.id === each.id);
233 let layout; 239 let layout;
@@ -350,9 +356,9 @@ @@ -350,9 +356,9 @@
350 </template> 356 </template>
351 <template #extra> 357 <template #extra>
352 <Authority value="api:yt:data_component:add:post"> 358 <Authority value="api:yt:data_component:add:post">
353 - <Button v-if="!getIsSharePage" type="primary" @click="handleOpenCreatePanel"  
354 - >创建组件</Button  
355 - > 359 + <Button v-if="!getIsSharePage" type="primary" @click="handleOpenCreatePanel">
  360 + 创建组件
  361 + </Button>
356 </Authority> 362 </Authority>
357 </template> 363 </template>
358 <div> 364 <div>
@@ -77,6 +77,7 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { @@ -77,6 +77,7 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) {
77 // console.log({ dataSource: unref(dataSourceRef), cmdIdMapping }); 77 // console.log({ dataSource: unref(dataSourceRef), cmdIdMapping });
78 const res: ResponseMessage = JSON.parse(message.data); 78 const res: ResponseMessage = JSON.parse(message.data);
79 const { subscriptionId, data = {} } = res; 79 const { subscriptionId, data = {} } = res;
  80 + if (!subscriptionId) return;
80 const mappingRecord = cmdIdMapping.get(subscriptionId); 81 const mappingRecord = cmdIdMapping.get(subscriptionId);
81 if (!mappingRecord) return; 82 if (!mappingRecord) return;
82 const { attribute, recordIndex, dataSourceIndex } = mappingRecord; 83 const { attribute, recordIndex, dataSourceIndex } = mappingRecord;
@@ -102,8 +103,14 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { @@ -102,8 +103,14 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) {
102 let index = 0; 103 let index = 0;
103 unref(dataSourceRef).forEach((record, recordIndex) => { 104 unref(dataSourceRef).forEach((record, recordIndex) => {
104 const componentId = record.record.id; 105 const componentId = record.record.id;
105 - record.record.dataSource.forEach((dataSource, dataSourceIndex) => { 106 + for (
  107 + let dataSourceIndex = 0;
  108 + dataSourceIndex < record.record.dataSource.length;
  109 + dataSourceIndex++
  110 + ) {
  111 + const dataSource = record.record.dataSource[dataSourceIndex];
106 const { deviceId, attribute, slaveDeviceId, gatewayDevice } = dataSource; 112 const { deviceId, attribute, slaveDeviceId, gatewayDevice } = dataSource;
  113 + if (!attribute) continue;
107 const cmdId = index; 114 const cmdId = index;
108 index++; 115 index++;
109 setCmdId(cmdId, { 116 setCmdId(cmdId, {
@@ -117,7 +124,7 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) { @@ -117,7 +124,7 @@ export function useSocketConnect(dataSourceRef: Ref<DataBoardLayoutInfo[]>) {
117 messageList.push( 124 messageList.push(
118 generateMessage(gatewayDevice ? slaveDeviceId : deviceId, cmdId, attribute) 125 generateMessage(gatewayDevice ? slaveDeviceId : deviceId, cmdId, attribute)
119 ); 126 );
120 - }); 127 + }
121 }); 128 });
122 return { 129 return {
123 tsSubCmds: messageList, 130 tsSubCmds: messageList,
@@ -160,8 +160,8 @@ @@ -160,8 +160,8 @@
160 160
161 <template> 161 <template>
162 <PageWrapper> 162 <PageWrapper>
163 - <div class="flex mb-6 items-center">  
164 - <div class="text-lg mr-6 font-bold">自定义看板</div> 163 + <div class="flex mb-6 items-center bg-light-100 h-78px">
  164 + <div class="text-lg ml-30px mr-9px font-bold">自定义看板</div>
165 <Authority value="api:yt:data_board:add:post"> 165 <Authority value="api:yt:data_board:add:post">
166 <Button type="primary" @click="handleOpenDetailModal">创建看板</Button> 166 <Button type="primary" @click="handleOpenDetailModal">创建看板</Button>
167 </Authority> 167 </Authority>
@@ -171,11 +171,14 @@ @@ -171,11 +171,14 @@
171 ref="listEL" 171 ref="listEL"
172 :pagination="paginationProp" 172 :pagination="paginationProp"
173 :data-source="dataBoardList" 173 :data-source="dataBoardList"
174 - :grid="{ gutter: 5, column: 4, xs: 1, sm: 2, md: 2, lg: 3, xl: 3, xxl: 3 }" 174 + :grid="{ gutter: 20, column: 4, xs: 1, sm: 2, md: 2, lg: 3, xl: 3, xxl: 3 }"
175 > 175 >
176 <template #renderItem="{ item }"> 176 <template #renderItem="{ item }">
177 <ListItem> 177 <ListItem>
178 <Card class="data-card cursor-pointer"> 178 <Card class="data-card cursor-pointer">
  179 + <template #title>
  180 + <div>{{ item.name }}</div>
  181 + </template>
179 <template #extra> 182 <template #extra>
180 <Dropdown 183 <Dropdown
181 v-if="dropMenuList.length" 184 v-if="dropMenuList.length"
@@ -188,17 +191,17 @@ @@ -188,17 +191,17 @@
188 </template> 191 </template>
189 <!-- <template #cover>title</template> --> 192 <!-- <template #cover>title</template> -->
190 <section @click="handleViewBoard(item)"> 193 <section @click="handleViewBoard(item)">
191 - <div class="flex justify-between items-center">  
192 - <div>{{ item.name }}</div>  
193 - <div class="flex content-center">  
194 - <Statistic :value="item.componentNum"> 194 + <div class="flex data-card__info">
  195 + <div>
  196 + <div>组件数量</div>
  197 + <Statistic style="font-size: 22px" :value="item.componentNum">
195 <template #suffix> 198 <template #suffix>
196 - <span class="text-sm">个组件</span> 199 + <span class="text-sm">个</span>
197 </template> 200 </template>
198 </Statistic> 201 </Statistic>
199 </div> 202 </div>
200 </div> 203 </div>
201 - <div class="flex justify-between mt-4"> 204 + <div class="flex justify-between mt-4 text-sm" style="color: #999999">
202 <div> 205 <div>
203 <span> 206 <span>
204 {{ item.viewType === ViewType.PRIVATE_VIEW ? '私有看板' : '公共看板' }} 207 {{ item.viewType === ViewType.PRIVATE_VIEW ? '私有看板' : '公共看板' }}
@@ -221,13 +224,30 @@ @@ -221,13 +224,30 @@
221 </PageWrapper> 224 </PageWrapper>
222 </template> 225 </template>
223 226
224 -<style scoped> 227 +<style scoped lang="less">
225 .data-card:deep(.ant-card-head) { 228 .data-card:deep(.ant-card-head) {
  229 + padding: 20px;
  230 + }
  231 +
  232 + .data-card:deep(.ant-card-head-title) {
226 padding: 0; 233 padding: 0;
227 - height: 40px;  
228 - min-height: 40px;  
229 } 234 }
230 .data-card:deep(.ant-card-extra) { 235 .data-card:deep(.ant-card-extra) {
231 - padding: 8px; 236 + padding: 0;
  237 + }
  238 + .data-card:deep(.ant-card-body) {
  239 + padding: 20px;
  240 + }
  241 +
  242 + .data-card__info {
  243 + color: #666666;
  244 +
  245 + &::before {
  246 + content: '';
  247 + width: 54px;
  248 + height: 54px;
  249 + margin-right: 16px;
  250 + background-image: url('/@/assets/svg/component.svg');
  251 + }
232 } 252 }
233 </style> 253 </style>
@@ -112,7 +112,7 @@ @@ -112,7 +112,7 @@
112 const wrapRef = ref<HTMLDivElement | null>(null); 112 const wrapRef = ref<HTMLDivElement | null>(null);
113 const chartRef = ref<HTMLDivElement | null>(null); 113 const chartRef = ref<HTMLDivElement | null>(null);
114 const deviceAttrs = ref<string[]>([]); 114 const deviceAttrs = ref<string[]>([]);
115 - const { setOptions, getInstance } = useECharts(chartRef as Ref<HTMLDivElement>); 115 + const { setOptions, getInstance, resize } = useECharts(chartRef as Ref<HTMLDivElement>);
116 const isNull = ref(true); 116 const isNull = ref(true);
117 const { toPromise } = useScript({ src: BAI_DU_MAP_URL }); 117 const { toPromise } = useScript({ src: BAI_DU_MAP_URL });
118 const [registerDetailDrawer, { openDrawer }] = useDrawer(); 118 const [registerDetailDrawer, { openDrawer }] = useDrawer();
@@ -270,6 +270,7 @@ @@ -270,6 +270,7 @@
270 // 发送请求 270 // 发送请求
271 loading.value = true; 271 loading.value = true;
272 const res = await getDeviceHistoryInfo(searchParams); 272 const res = await getDeviceHistoryInfo(searchParams);
  273 + loading.value = false;
273 // 判断数据对象是否为空 274 // 判断数据对象是否为空
274 if (!Object.keys(res).length) { 275 if (!Object.keys(res).length) {
275 isNull.value = false; 276 isNull.value = false;
@@ -278,7 +279,6 @@ @@ -278,7 +279,6 @@
278 isNull.value = true; 279 isNull.value = true;
279 } 280 }
280 setChartOptions(res, value.keys); 281 setChartOptions(res, value.keys);
281 - loading.value = false;  
282 }, 282 },
283 }); 283 });
284 284
@@ -332,6 +332,7 @@ @@ -332,6 +332,7 @@
332 startTs: Date.now() - 1 * 24 * 60 * 60 * 1000, 332 startTs: Date.now() - 1 * 24 * 60 * 60 * 1000,
333 endTs: Date.now(), 333 endTs: Date.now(),
334 agg: AggregateDataEnum.NONE, 334 agg: AggregateDataEnum.NONE,
  335 + limit: 7,
335 }); 336 });
336 337
337 // 判断对象是否为空 338 // 判断对象是否为空
@@ -371,6 +372,7 @@ @@ -371,6 +372,7 @@
371 data: dataArray.filter((item1) => item1[2] === item), 372 data: dataArray.filter((item1) => item1[2] === item),
372 }; 373 };
373 }); 374 });
  375 + resize();
374 // 设置数据 376 // 设置数据
375 setOptions(eChartOptions(series, keys)); 377 setOptions(eChartOptions(series, keys));
376 } 378 }