Commit 286b841c827707037d795f4a04328e93316de67e

Authored by xp.Huang
2 parents 634a55d2 5e7233f8

Merge branch 'fix/DEFECT-1569' into 'main_dev'

fix: 修改看板历史趋势时间排序 mqtt数据流转

See merge request yunteng/thingskit-front!864
... ... @@ -126,7 +126,10 @@
126 126 password: getDataFlowParams.password ? getDataFlowParams.password : undefined,
127 127 }
128 128 : undefined,
  129 + appendClientIdSuffix: getDataFlowParams.appendClientIdSuffix || undefined,
  130 + type: undefined,
129 131 };
  132 +
130 133 const rest = isRabbitmq(getDataFlowMethod?.type)
131 134 ? await postAddConvertApi({ ...restData.data, ...data })
132 135 : await postAddConvertApi({ ...restData.data, ...data, configuration });
... ...
... ... @@ -12,7 +12,7 @@
12 12 import { useModalInner } from '/@/components/Modal';
13 13 import { getAllDeviceByOrg } from '/@/api/dataBoard';
14 14 import { useHistoryData } from '/@/views/device/list/hook/useHistoryData';
15   - import { BasicTable, useTable } from '/@/components/Table';
  15 + import { BasicColumn, BasicTable, useTable } from '/@/components/Table';
16 16 import { formatToDateTime } from '/@/utils/dateUtil';
17 17 import {
18 18 ModeSwitchButton,
... ... @@ -112,18 +112,14 @@
112 112 return mapping;
113 113 });
114 114
115   - const [registerTable] = useTable({
116   - showIndexColumn: false,
117   - showTableSetting: false,
118   - dataSource: historyData,
119   - maxHeight: 300,
120   - size: 'small',
121   - columns: [
  115 + const sortOrder = ref<any>('descend');
  116 + const columns: BasicColumn[] | any = computed(() => {
  117 + return [
122 118 {
123 119 title: '属性',
124 120 dataIndex: 'name',
125   - format: (value) => {
126   - return unref(getIdentifierNameMapping)[value];
  121 + format: (text) => {
  122 + return unref(getIdentifierNameMapping)[text];
127 123 },
128 124 },
129 125 {
... ... @@ -136,10 +132,47 @@
136 132 format: (val) => {
137 133 return formatToDateTime(val, 'YYYY-MM-DD HH:mm:ss');
138 134 },
  135 + sorter: true,
  136 + sortOrder: unref(sortOrder),
  137 + sortDirections: ['descend', 'ascend', 'descend'],
139 138 },
140   - ],
  139 + ];
141 140 });
142 141
  142 + const [registerTable, { setColumns }] = useTable({
  143 + showIndexColumn: false,
  144 + showTableSetting: false,
  145 + dataSource: historyData,
  146 + maxHeight: 300,
  147 + size: 'small',
  148 + columns: unref(columns),
  149 + });
  150 +
  151 + const getTableList = async (orderBy?: string) => {
  152 + // 表单验证
  153 + await method.validate();
  154 + const value = method.getFieldsValue();
  155 + const searchParams = getSearchParams(value);
  156 + if (!hasDeviceAttr()) return;
  157 + // 发送请求
  158 + loading.value = true;
  159 + const res = await getDeviceHistoryInfo(searchParams, orderBy);
  160 + historyData.value = getTableHistoryData(res);
  161 + loading.value = false;
  162 + };
  163 +
  164 + const handleTableChange = async (_pag, _filters, sorter: any) => {
  165 + sortOrder.value = sorter.order;
  166 + await setColumns(unref(columns));
  167 + if (sorter.field == 'ts') {
  168 + if (sorter.order == 'descend') {
  169 + getTableList('DESC');
  170 + } else {
  171 + getTableList('ASC');
  172 + }
  173 + }
  174 + };
  175 +
143 176 const getDeviceDataKey = async (record: DeviceOption) => {
144 177 const { organizationId, value } = record;
145 178 try {
... ... @@ -260,7 +293,7 @@
260 293 :show-ok-btn="false"
261 294 cancel-text="关闭"
262 295 width="70%"
263   - title="选择时间"
  296 + title="历史趋势"
264 297 >
265 298 <section
266 299 class="flex flex-col p-4 h-full w-full min-w-7/10"
... ... @@ -295,7 +328,11 @@
295 328 v-show="!isNull"
296 329 />
297 330
298   - <BasicTable v-show="mode === EnumTableChartMode.TABLE" @register="registerTable">
  331 + <BasicTable
  332 + v-show="mode === EnumTableChartMode.TABLE"
  333 + @change="handleTableChange"
  334 + @register="registerTable"
  335 + >
299 336 <template #toolbar>
300 337 <div class="flex h-70px items-center justify-end p-2">
301 338 <ModeSwitchButton
... ...