|
@@ -10,6 +10,8 @@ import { musicSheetPage } from '/src/views/prepare-lessons/api';
|
|
|
import TrainUpdate from '/src/views/attend-class/model/train-update';
|
|
|
import requestOrigin from 'umi-request';
|
|
|
import CardPreview from '/src/components/card-preview';
|
|
|
+import { evaluateDifficult } from '/src/utils/contants';
|
|
|
+import { eventGlobal } from '/src/utils';
|
|
|
export default defineComponent({
|
|
|
name: 'share-resources',
|
|
|
setup() {
|
|
@@ -48,7 +50,11 @@ export default defineComponent({
|
|
|
state.loading = false;
|
|
|
const tempRows = data.rows || [];
|
|
|
const temp: any = [];
|
|
|
+
|
|
|
tempRows.forEach((row: any) => {
|
|
|
+ const index = prepareStore.getTrainList.findIndex(
|
|
|
+ (course: any) => course.musicId === row.id
|
|
|
+ );
|
|
|
temp.push({
|
|
|
id: row.id,
|
|
|
coverImg: row.musicSvg,
|
|
@@ -57,7 +63,8 @@ export default defineComponent({
|
|
|
isCollect: false,
|
|
|
isSelected: true,
|
|
|
content: row.id,
|
|
|
- xmlFileUrl: row.xmlFileUrl
|
|
|
+ xmlFileUrl: row.xmlFileUrl,
|
|
|
+ exist: index !== -1 ? true : false // 是否存在
|
|
|
});
|
|
|
});
|
|
|
state.tableList.push(...temp);
|
|
@@ -81,6 +88,21 @@ export default defineComponent({
|
|
|
onSearch(state.searchGroup);
|
|
|
}
|
|
|
);
|
|
|
+ watch(
|
|
|
+ () => prepareStore.trainList,
|
|
|
+ () => {
|
|
|
+ state.tableList.forEach((item: any) => {
|
|
|
+ const index = prepareStore.getTrainList.findIndex(
|
|
|
+ (course: any) => course.musicId === item.id
|
|
|
+ );
|
|
|
+ item.exist = index !== -1 ? true : false; // 是否存在
|
|
|
+ });
|
|
|
+ },
|
|
|
+ {
|
|
|
+ deep: true,
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
const throttledFn = useThrottleFn(() => {
|
|
|
state.pagination.page = state.pagination.page + 1;
|
|
@@ -118,8 +140,32 @@ export default defineComponent({
|
|
|
state.editStatus = true;
|
|
|
};
|
|
|
|
|
|
+ const typeFormat = (trainingType: string, configJson: any) => {
|
|
|
+ let tList: string[] = [];
|
|
|
+
|
|
|
+ if (trainingType === 'EVALUATION') {
|
|
|
+ tList = [
|
|
|
+ `${evaluateDifficult[configJson.evaluateDifficult]}`,
|
|
|
+ '全部小节',
|
|
|
+ // `速度${configJson.evaluateSpeed}`,
|
|
|
+ `${configJson.trainingTimes}分合格`
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ tList = [
|
|
|
+ `${configJson.practiceChapterBegin}-${configJson.practiceChapterEnd}小节`,
|
|
|
+ `速度${configJson.practiceSpeed}`,
|
|
|
+ `${configJson.trainingTimes}分钟`
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return tList;
|
|
|
+ };
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
getList();
|
|
|
+
|
|
|
+ eventGlobal.on('onTrainDragItem', (item: any) => {
|
|
|
+ onAdd(item);
|
|
|
+ });
|
|
|
});
|
|
|
return () => (
|
|
|
<div>
|
|
@@ -154,7 +200,8 @@ export default defineComponent({
|
|
|
isShowAdd
|
|
|
isShowCollect={false}
|
|
|
item={item}
|
|
|
- isShowAddDisabled={!prepareStore.getIsEditTrain}
|
|
|
+ draggable
|
|
|
+ // isShowAddDisabled={!prepareStore.getIsEditTrain}
|
|
|
disabledMouseHover={false}
|
|
|
onClick={() => {
|
|
|
if (item.type === 'IMG') return;
|
|
@@ -181,10 +228,26 @@ export default defineComponent({
|
|
|
title="作业设置">
|
|
|
<TrainUpdate
|
|
|
item={state.editItem}
|
|
|
+ type="homework"
|
|
|
onClose={() => (state.editStatus = false)}
|
|
|
- onConfirm={() => {
|
|
|
- state.editItem = {};
|
|
|
- prepareStore.setIsAddTrain(true);
|
|
|
+ onConfirm={(item: any) => {
|
|
|
+ // state.editItem = {};
|
|
|
+ // prepareStore.setIsAddTrain(true);
|
|
|
+
|
|
|
+ const tList = typeFormat(
|
|
|
+ item.trainingType,
|
|
|
+ item.trainingConfigJson
|
|
|
+ );
|
|
|
+ //
|
|
|
+ const train = {
|
|
|
+ ...item,
|
|
|
+ id: null,
|
|
|
+ musicName: state.editItem.title,
|
|
|
+ typeList: tList
|
|
|
+ };
|
|
|
+
|
|
|
+ console.log(train, '1212');
|
|
|
+ eventGlobal.emit('onTrainAddItem', train);
|
|
|
}}
|
|
|
/>
|
|
|
</NModal>
|