Commit 1a6c4e733261205ade9b7c906dde1fb247518989

Authored by loveumiko
1 parent a869bf90

fix: 增加模型形历史数据更新时间排序

... ... @@ -12,11 +12,11 @@ export const getDeviceProfile = (deviceType?: string) => {
12 12 };
13 13
14 14 // 获取历史数据
15   -export const getDeviceHistoryInfo = (params: Recordable) => {
  15 +export const getDeviceHistoryInfo = (params: Recordable, orderBy) => {
16 16 return defHttp.get<HistoryData>(
17 17 {
18 18 url: `/plugins/telemetry/DEVICE/${params.entityId}/values/timeseries`,
19   - params: { ...params, entityId: null, orderBy: 'ASC' },
  19 + params: { ...params, entityId: null, orderBy },
20 20 },
21 21 {
22 22 joinPrefix: false,
... ...
... ... @@ -84,10 +84,22 @@
84 84 format: (val) => {
85 85 return formatToDateTime(val, 'YYYY-MM-DD HH:mm:ss');
86 86 },
  87 + sorter: 'descend',
87 88 },
88 89 ],
89 90 });
90 91
  92 + const handleTableChange = async (pag, filters, sorter: any) => {
  93 + console.log(pag, filters, sorter, 'pag, filters, sorter');
  94 + if (sorter.field == 'ts') {
  95 + if (sorter.order == 'descend') {
  96 + openHistoryPanel('ASC');
  97 + } else {
  98 + openHistoryPanel('DESC');
  99 + }
  100 + }
  101 + };
  102 +
91 103 const { setOptions, getInstance } = useECharts(chartRef as Ref<HTMLDivElement>);
92 104
93 105 const [register, method] = useTimePeriodForm({
... ... @@ -158,7 +170,7 @@
158 170 } catch (error) {}
159 171 };
160 172
161   - const openHistoryPanel = async () => {
  173 + const openHistoryPanel = async (orderBy?: string) => {
162 174 await nextTick();
163 175 method.updateSchema({
164 176 field: 'keys',
... ... @@ -177,14 +189,17 @@
177 189
178 190 const keys = props.attr ? props.attr : unref(getDeviceKeys).join();
179 191
180   - const res = await getDeviceHistoryInfo({
181   - entityId: props.deviceDetail.tbDeviceId,
182   - keys,
183   - startTs: Date.now() - 1 * 24 * 60 * 60 * 1000,
184   - endTs: Date.now(),
185   - agg: AggregateDataEnum.NONE,
186   - limit: 7,
187   - });
  192 + const res = await getDeviceHistoryInfo(
  193 + {
  194 + entityId: props.deviceDetail.tbDeviceId,
  195 + keys,
  196 + startTs: Date.now() - 1 * 24 * 60 * 60 * 1000,
  197 + endTs: Date.now(),
  198 + agg: AggregateDataEnum.NONE,
  199 + limit: 7,
  200 + },
  201 + orderBy
  202 + );
188 203 historyData.value = getTableHistoryData(res);
189 204
190 205 // 判断对象是否为空
... ... @@ -238,7 +253,11 @@
238 253 </div>
239 254 <Empty v-show="!isNull && mode === EnumTableChartMode.CHART" />
240 255
241   - <BasicTable v-show="mode === EnumTableChartMode.TABLE" @register="registerTable">
  256 + <BasicTable
  257 + @change="handleTableChange"
  258 + v-show="mode === EnumTableChartMode.TABLE"
  259 + @register="registerTable"
  260 + >
242 261 <template #toolbar>
243 262 <div class="flex h-70px items-center justify-end p-2">
244 263 <ModeSwitchButton
... ...