Commit 735c2ff643d18d0846ea4a13ab589aab8bb3e9f2

Authored by xp.Huang
2 parents bb860e1d 0dc742a7

Merge branch 'feat/device-list-collect' into 'main_dev'

fix: 设备列表添加收藏等相关操作和显示

See merge request yunteng/thingskit-front!951
... ... @@ -45,6 +45,7 @@ enum DeviceManagerApi {
45 45 DEVICE_PUBLIC = '/customer/public/device',
46 46
47 47 DEVICE_PRIVATE = '/customer/device',
  48 + DEVICE_COLLECT = '/device/collect ', //收藏
48 49
49 50 /**
50 51 * @description 通过设备列表获取设备信息
... ... @@ -61,6 +62,13 @@ export const devicePage = (params: DeviceQueryParam) => {
61 62 });
62 63 };
63 64
  65 +export const deviceCollect = (params: Array<any>) => {
  66 + return defHttp.post({
  67 + url: `${DeviceManagerApi.DEVICE_COLLECT}`,
  68 + params,
  69 + });
  70 +};
  71 +
64 72 /**
65 73 * 分页查询设备配置页面
66 74 * @param params pageSize page name
... ...
... ... @@ -12,7 +12,7 @@ export const columns: BasicColumn[] = [
12 12 {
13 13 title: '状态',
14 14 dataIndex: 'deviceState',
15   - width: 80,
  15 + width: 110,
16 16 slots: { customRender: 'deviceState' },
17 17 },
18 18 {
... ... @@ -167,4 +167,17 @@ export const searchFormSchema: FormSchema[] = [
167 167 };
168 168 },
169 169 },
  170 + {
  171 + field: 'isCollect',
  172 + label: '是否收藏',
  173 + component: 'Select',
  174 + colProps: { span: 6 },
  175 + componentProps: {
  176 + options: [
  177 + { label: '是', value: 1 },
  178 + { label: '否', value: 0 },
  179 + ],
  180 + placeholder: '请选择',
  181 + },
  182 + },
170 183 ];
... ...
... ... @@ -34,6 +34,11 @@
34 34 批量分配
35 35 </a-button>
36 36 </Authority>
  37 + <!-- <Authority>
  38 + <a-button type="primary" @click="handelCollect()" :disabled="!isExistOption">
  39 + 批量收藏
  40 + </a-button>
  41 + </Authority> -->
37 42 </template>
38 43 <template #img="{ record }">
39 44 <TableImg
... ... @@ -85,7 +90,13 @@
85 90 </Tag>
86 91 </template>
87 92 <template #deviceState="{ record }">
  93 + <!-- <HeartOutlined v-if="!record.isCollect" class="mr-1" style="color: red" /> -->
  94 + <Tooltip>
  95 + <template #title> 我的收藏</template>
  96 + <HeartTwoTone v-if="record.isCollect" class="mr-1" twoToneColor="#3B82F6" />
  97 + </Tooltip>
88 98 <Tag
  99 + :style="{ marginLeft: !record.isCollect ? '17px' : '' }"
89 100 :color="
90 101 record.deviceState == DeviceState.INACTIVE
91 102 ? 'warning'
... ... @@ -154,6 +165,18 @@
154 165 icon: 'ant-design:rise-outlined',
155 166 onClick: handleUpAndDownRecord.bind(null, record),
156 167 },
  168 + !record.isCollect
  169 + ? {
  170 + label: '收藏',
  171 + icon: 'ant-design:heart-outlined',
  172 + onClick: handelCollect.bind(null, record),
  173 + }
  174 + : {
  175 + label: '取消收藏',
  176 + auth: 'api:yt:device:online:record',
  177 + icon: 'ant-design:heart-outlined',
  178 + onClick: handelCollect.bind(null, record),
  179 + },
157 180 {
158 181 label: '删除',
159 182 auth: 'api:yt:device:delete',
... ... @@ -195,10 +218,12 @@
195 218 } from '/@/api/device/model/deviceModel';
196 219 import { BasicTable, useTable, TableAction, TableImg } from '/@/components/Table';
197 220 import { columns, searchFormSchema } from './config/device.data';
198   - import { Tag, Popover, Popconfirm, Button } from 'ant-design-vue';
  221 + import { Tag, Popover, Popconfirm, Button, Tooltip } from 'ant-design-vue';
  222 + import { HeartTwoTone } from '@ant-design/icons-vue';
199 223 import {
200 224 deleteDevice,
201 225 devicePage,
  226 + deviceCollect,
202 227 cancelDispatchCustomer,
203 228 getGATEWAY,
204 229 privateDevice,
... ... @@ -244,6 +269,9 @@
244 269 Popconfirm,
245 270 BatchImportModal,
246 271 Button,
  272 + // HeartOutlined,
  273 + HeartTwoTone,
  274 + Tooltip,
247 275 },
248 276 setup(_) {
249 277 const { isCustomer } = useAuthDeviceDetail();
... ... @@ -462,6 +490,26 @@
462 490 } catch (error) {}
463 491 };
464 492
  493 + // 收藏 && 批量收藏
  494 + const handelCollect = async (record?: Recordable) => {
  495 + let ids: string[] = [];
  496 + if (record) {
  497 + ids.push(record.id);
  498 + } else {
  499 + ids = await getSelectRowKeys();
  500 + }
  501 + try {
  502 + setLoading(true);
  503 + await deviceCollect(ids);
  504 + createMessage.success('操作成功');
  505 + handleReload();
  506 + } catch (error) {
  507 + throw error;
  508 + } finally {
  509 + setLoading(false);
  510 + }
  511 + };
  512 +
465 513 onMounted(() => {
466 514 const queryParams = ROUTE.query as Record<'deviceProfileId', undefined | string>;
467 515 const { setFieldsValue } = getForm();
... ... @@ -489,6 +537,7 @@
489 537 copySN,
490 538 isExistOption,
491 539 handleDelete,
  540 + handelCollect,
492 541 // hasBatchDelete,
493 542 // handleDeleteOrBatchDelete,
494 543 handleReload,
... ...