|
@@ -3,7 +3,7 @@ import ResourceSearchGroup from './resource-search-group';
|
|
import { NScrollbar, NSpin, useDialog, useMessage } from 'naive-ui';
|
|
import { NScrollbar, NSpin, useDialog, useMessage } from 'naive-ui';
|
|
import styles from './index.module.less';
|
|
import styles from './index.module.less';
|
|
import CardType from '/src/components/card-type';
|
|
import CardType from '/src/components/card-type';
|
|
-import { materialQueryPage } from '/src/views/natural-resources/api';
|
|
|
|
|
|
+import { favorite, materialQueryPage } from '/src/views/natural-resources/api';
|
|
import TheEmpty from '/src/components/TheEmpty';
|
|
import TheEmpty from '/src/components/TheEmpty';
|
|
import { usePrepareStore } from '/src/store/modules/prepareLessons';
|
|
import { usePrepareStore } from '/src/store/modules/prepareLessons';
|
|
import { useDebounceFn, useThrottleFn } from '@vueuse/core';
|
|
import { useDebounceFn, useThrottleFn } from '@vueuse/core';
|
|
@@ -186,6 +186,20 @@ export default defineComponent({
|
|
// });
|
|
// });
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ // 收藏
|
|
|
|
+ const onCollect = async (item: any) => {
|
|
|
|
+ try {
|
|
|
|
+ await favorite({
|
|
|
|
+ materialId: item.id,
|
|
|
|
+ favoriteFlag: item.isCollect ? 0 : 1,
|
|
|
|
+ type: item.type
|
|
|
|
+ });
|
|
|
|
+ item.isCollect = !item.isCollect;
|
|
|
|
+ } catch {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
getList();
|
|
getList();
|
|
});
|
|
});
|
|
@@ -230,13 +244,14 @@ export default defineComponent({
|
|
<CardType
|
|
<CardType
|
|
isShowAdd
|
|
isShowAdd
|
|
item={item}
|
|
item={item}
|
|
- isShowCollect={false}
|
|
|
|
|
|
+ isShowCollect={true}
|
|
disabledMouseHover={false}
|
|
disabledMouseHover={false}
|
|
onClick={() => {
|
|
onClick={() => {
|
|
if (item.type === 'IMG') return;
|
|
if (item.type === 'IMG') return;
|
|
state.show = true;
|
|
state.show = true;
|
|
state.item = item;
|
|
state.item = item;
|
|
}}
|
|
}}
|
|
|
|
+ onCollect={(item: any) => onCollect(item)}
|
|
isShowAddDisabled={!prepareStore.getIsEditResource}
|
|
isShowAddDisabled={!prepareStore.getIsEditResource}
|
|
onAdd={(item: any) => onAdd(item)}
|
|
onAdd={(item: any) => onAdd(item)}
|
|
/>
|
|
/>
|