页面渲染 逻辑处理

This commit is contained in:
taoxu 2023-12-09 18:15:29 +08:00
parent f805ef513e
commit 1202742ead
5 changed files with 491 additions and 221 deletions

View File

@ -9,36 +9,42 @@
</view> </view>
<view class="substance"> <view class="substance">
<!-- 渲染Text --> <!-- 渲染Text -->
<text :class="{ 'active': itemActive[item.id] === TextIndex }" v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex" <text :class="{ 'active': itemActive[item.id] === TextIndex }"
@click="Bages_addActive(TextIndex,item.id) "> v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex"
@click="Bages_addActive(TextIndex,item.id) ">
{{TextItem.name}} {{TextItem.name}}
</text> </text>
</view> </view>
<!-- 渲染part --> <!-- 渲染part -->
<view v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex"> <view v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex">
<view v-for="(partitem,partindex) in TextItem.parts" :key="partindex" v-if="itemActive[item.id] === TextIndex"> <view v-for="(partitem,partindex) in TextItem.parts" :key="partindex"
v-if="itemActive[item.id] === TextIndex">
<view> <view>
<view class="Part1"> <view class="Part1">
<view class="imaflex" @click="icon(partitem.id)"> <view class="imaflex" @click="icon(partitem.id)">
<!-- part前面的图表 --> <!-- part前面的图表 -->
<view class="image"> <view class="image">
<image src="http://tmp/IFVuR12hLLNO034931f24322ab271b1f57fdf626bcbf.png" mode="" v-if="image"></image> <image src="http://tmp/IFVuR12hLLNO034931f24322ab271b1f57fdf626bcbf.png" mode=""
<image src="http://tmp/8OOgvfEpdnT2e4e421b97006c70b30a9df99e51a6df1.png" mode="" v-else></image> v-if="image"></image>
<image src="http://tmp/8OOgvfEpdnT2e4e421b97006c70b30a9df99e51a6df1.png" mode=""
v-else></image>
</view> </view>
<view>{{partitem.name}}</view> <view>{{partitem.name}}</view>
</view> </view>
<!-- part的多选框 --> <!-- part的多选框 -->
<view> <view>
<u-checkbox @change="checkboxChange(partitem,$event)" v-model="partitem.checked" shape="circle"></u-checkbox> <u-checkbox @change="checkboxChange(partitem,$event)" v-model="partitem.checked"
shape="circle"></u-checkbox>
</view> </view>
</view> </view>
<view class="partshow" v-if="tk==partitem.id"> <view class="partshow" v-if="tk==partitem.id">
<view class="Part2" v-for="(quesitem,quesindex) in partitem.modules" :key="quesindex"> <view class="Part2" v-for="(quesitem,quesindex) in partitem.modules" :key="quesindex">
<view class="imaflex"> <view class="imaflex">
<view>{{quesitem.typeText}}</view> <view>{{quesitem.number}} {{quesitem.typeText}}</view>
</view> </view>
<view> <view>
<u-checkbox @change="checkoutzj(quesitem,$event)" v-model="quesitem.subsets"></u-checkbox> <u-checkbox @change="handleCheckboxChange(quesitem)"
v-model="quesitem.subsets"></u-checkbox>
</view> </view>
</view> </view>
</view> </view>
@ -59,6 +65,7 @@
itemActive: {}, itemActive: {},
image: true, image: true,
tk: null, tk: null,
selectwrite: [],
} }
}, },
@ -66,78 +73,165 @@
this.hearing() this.hearing()
}, },
methods: { methods: {
// updatawrite(data){
this.selectwrite=data
},
hearing() { hearing() {
this.$u.get('https://api.admin-v2.langsi.online/admin-api/ielts/paper/list', { this.$u
classify: 1 .get("https://api.admin-v2.langsi.online/admin-api/ielts/paper/list", {
}).then(res => { classify: 1,
this.listHearing = res.data })
let activeindex = {} .then((res) => {
let arr = res.data this.listHearing = res.data;
for (let parper of arr) { let activeindex = {};
let test = parper.tests[0] let arr = res.data;
activeindex[parper.id] = 0 for (let parper of arr) {
} let test = parper.tests[0];
this.itemActive = activeindex activeindex[parper.id] = 0;
}) }
this.itemActive = activeindex;
this.updateSubsetsInListHearing()
console.log(this.listHearing, "this.itemActivethis.itemActive");
});
}, },
// test
Bages_addActive(TextIndex, id) { Bages_addActive(TextIndex, id) {
this.itemActive[id] = TextIndex this.itemActive[id] = TextIndex;
this.$forceUpdate() this.$forceUpdate();
}, },
//
icon(id) { icon(id) {
this.image = !this.image this.image = !this.image;
this.tk = id this.tk = id;
if (this.image == false) { if (this.image == false) {
this.tk = id this.tk = id;
}else { } else {
this.tk = null this.tk = null;
} }
}, },
checkboxChange(parat, e) { checkboxChange(partitem, e) {
if (e.value) { if (e.value) {
this.checked.push(parat.id) this.listHearing.forEach((paper) => {
const allItemsNoSubsets = parat.modules.every(item => !('subsets' in item)); paper.tests.forEach((test, testIndex) => {
parat.modules.forEach(item=>{ test.parts.forEach((part) => {
this.$set(item, 'subsets', item.id); if (part.id === partitem.id) {
item.subsets = item.id; part.modules.forEach((quesitem, quesIndex) => {
this.subsets.push(item.id) this.addToSelectWrite(
console.log( item.subsets) quesitem,
}) partitem.id,
testIndex + 1,
paper.title
);
});
}
});
});
});
} else { } else {
let index = this.checked.indexOf(parat.id); partitem.modules.forEach((quesitem) => {
if (index !== -1) { this.removeFromSelectWrite(quesitem.id);
this.checked.splice(index, 1); });
parat.modules.forEach(item=>{
this.$delete(item, 'subsets');
const index = this.subsets.indexOf(item.id);
if (index !== -1) {
this.subsets.splice(index, 1);
}
})
}
} }
console.log(this.checked,'part数组') this.$forceUpdate();
this.$forceUpdate() console.log(this.selectwrite, "selectwriteselectwrite");
console.log(this.listHearing, "this.listHearing");
// selectwrite listHearing subsets
this.updateSubsetsInListHearing();
this.$parent.updatalisten(this.selectwrite)
}, },
checkoutzj(quesitem, id) { handleCheckboxChange(quesitems) {
if (id.value) { const existingIndex = this.selectwrite.findIndex(item => item.id === quesitems.id);
this.subsets.push(quesitem.id)
console.log(quesitem) if (existingIndex !== -1) {
} else { // subsets false
let index2 = this.subsets.indexOf(quesitem.id); this.selectwrite.splice(existingIndex, 1);
if (index2 !== -1) { quesitems.subsets = false;
this.subsets.splice(index2, 1); } else {
} // subsets true
this.listHearing.forEach((paper) => {
paper.tests.forEach((test, testIndex) => {
test.parts.forEach((part) => {
part.modules.forEach((quesitem, quesIndex) => {
if (quesitem.id == quesitems.id) {
this.addToSelectWrite(
quesitems,
quesitems.id, // 使 quesitem id
testIndex + 1, // 使 testIndex
paper.title // 使 quesitem paperTitle
);
}
});
});
});
});
quesitems.subsets = true;
}
console.log(this.selectwrite, 'selectwriteselectwrite');
this.updateSubsetsInListHearing()
this.$parent.updatalisten(this.selectwrite)
},
// listHearing subsets
updateSubsetsInListHearing() {
this.listHearing.forEach((paper) => {
paper.tests.forEach((test) => {
test.parts.forEach((part) => {
part.modules.forEach((quesitem) => {
const selected = this.selectwrite.find((item) => {
return item.id === quesitem.id;
});
if (selected) {
quesitem.subsets = true;
} else {
quesitem.subsets = false;
}
});
});
});
});
// listHearing part modules subsets true
this.listHearing.forEach((paper) => {
paper.tests.forEach((test) => {
test.parts.forEach((part) => {
part.checked = part.modules.every((quesitem) => quesitem.subsets);
});
});
});
},
// selectwrite
addToSelectWrite(quesitem, partId, testIndex, paperTitle) {
// Split the guideText into words
const words = quesitem.guideText.split(/\s+/);
// Take the first five words excluding "Complete"
const questionname = words.slice(0, 5).filter(word => word !== "Complete").join(' ');
const item = {
id: quesitem.id,
paperId: quesitem.paperId,
papername: paperTitle,
partId: partId,
testId: quesitem.testId,
testname: `Test ${testIndex}`,
typeName: quesitem.typeText,
questionname: questionname,
};
this.selectwrite.push(item);
},
removeFromSelectWrite(itemId) {
const index = this.selectwrite.findIndex((item) => item.id === itemId);
if (index !== -1) {
this.selectwrite.splice(index, 1);
} }
console.log(this.subsets,'题型数组') },
} },
}
} }
</script> </script>
@ -200,4 +294,4 @@
height: 20rpx; height: 20rpx;
margin-right: 10rpx; margin-right: 10rpx;
} }
</style> </style>

View File

@ -71,7 +71,28 @@ export default {
created() { created() {
this.getCompose() this.getCompose()
}, },
methods: { methods: {
updatawrite(data){
this.selectwrite=data
},
updateSubsetArr() {
// this.transformedData
for (const item of this.transformedData) {
// this.selectwrite
for (const selectedItem of this.selectwrite) {
const { id, test, task } = selectedItem;
// task1 id
if (item[test] && item[test][task] && String(item[test][task].id) === id) {
this.$set(item[test][task], 'subsetArr', true);
} else {
this.$set(item[test][task], 'subsetArr', false);
}
}
}
},
// //
getCompose() { getCompose() {
this.$u.post('https://api.admin-v2.langsi.online/admin-api/writing/all/search', this.comsapi).then(res => { this.$u.post('https://api.admin-v2.langsi.online/admin-api/writing/all/search', this.comsapi).then(res => {
@ -81,8 +102,9 @@ export default {
} }
this.transformedData = arr this.transformedData = arr
this.orgtransformedData = JSON.parse(JSON.stringify(arr)); this.orgtransformedData = JSON.parse(JSON.stringify(arr));
// let json = JSON.stringify(this.transformedData) let json = JSON.stringify(this.transformedData)
console.log(this.transformedData, 'this.transformedData'); // console.log(json, 'this.transformedData');
this.updateSubsetArr()
}) })
}, },
textClick(item, text) { textClick(item, text) {

View File

@ -9,36 +9,42 @@
</view> </view>
<view class="substance"> <view class="substance">
<!-- 渲染Text --> <!-- 渲染Text -->
<text :class="{ 'active': itemActive[item.id] === TextIndex }" v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex" <text :class="{ 'active': itemActive[item.id] === TextIndex }"
@click="Bages_addActive(TextIndex,item.id) "> v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex"
@click="Bages_addActive(TextIndex,item.id) ">
{{TextItem.name}} {{TextItem.name}}
</text> </text>
</view> </view>
<!-- 渲染part --> <!-- 渲染part -->
<view v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex"> <view v-for="(TextItem,TextIndex) in item.tests" :key="TextIndex">
<view v-for="(partitem,partindex) in TextItem.parts" :key="partindex" v-if="itemActive[item.id] === TextIndex"> <view v-for="(partitem,partindex) in TextItem.parts" :key="partindex"
v-if="itemActive[item.id] === TextIndex">
<view> <view>
<view class="Part1"> <view class="Part1">
<view class="imaflex" @click="icon(partitem.id)"> <view class="imaflex" @click="icon(partitem.id)">
<!-- part前面的图表 --> <!-- part前面的图表 -->
<view class="image"> <view class="image">
<image src="http://tmp/IFVuR12hLLNO034931f24322ab271b1f57fdf626bcbf.png" mode="" v-if="image"></image> <image src="http://tmp/IFVuR12hLLNO034931f24322ab271b1f57fdf626bcbf.png" mode=""
<image src="http://tmp/8OOgvfEpdnT2e4e421b97006c70b30a9df99e51a6df1.png" mode="" v-else></image> v-if="image"></image>
<image src="http://tmp/8OOgvfEpdnT2e4e421b97006c70b30a9df99e51a6df1.png" mode=""
v-else></image>
</view> </view>
<view>{{partitem.name}}</view> <view>{{partitem.name}}</view>
</view> </view>
<!-- part的多选框 --> <!-- part的多选框 -->
<view> <view>
<u-checkbox @change="checkboxChange(partitem,$event)" v-model="partitem.checked" shape="circle"></u-checkbox> <u-checkbox @change="checkboxChange(partitem,$event)" v-model="partitem.checked"
shape="circle"></u-checkbox>
</view> </view>
</view> </view>
<view class="partshow" v-if="tk==partitem.id"> <view class="partshow" v-if="tk==partitem.id">
<view class="Part2" v-for="(quesitem,quesindex) in partitem.modules" :key="quesindex"> <view class="Part2" v-for="(quesitem,quesindex) in partitem.modules" :key="quesindex">
<view class="imaflex"> <view class="imaflex">
<view>{{quesitem.typeText}}</view> <view>{{quesitem.number}}{{quesitem.typeText}}</view>
</view> </view>
<view> <view>
<u-checkbox @change="checkoutzj(quesitem,$event)" v-model="quesitem.subsets"></u-checkbox> <u-checkbox @change="handleCheckboxChange(quesitem)"
v-model="quesitem.subsets"></u-checkbox>
</view> </view>
</view> </view>
</view> </view>
@ -59,6 +65,7 @@
itemActive: {}, itemActive: {},
image: true, image: true,
tk: null, tk: null,
selectwrite: [],
} }
}, },
@ -66,6 +73,10 @@
this.hearing() this.hearing()
}, },
methods: { methods: {
updatawrite(data){
this.selectwrite=data
},
// //
hearing() { hearing() {
this.$u.get('https://api.admin-v2.langsi.online/admin-api/ielts/paper/list', { this.$u.get('https://api.admin-v2.langsi.online/admin-api/ielts/paper/list', {
@ -79,6 +90,7 @@
activeindex[parper.id] = 0 activeindex[parper.id] = 0
} }
this.itemActive = activeindex this.itemActive = activeindex
this.updateSubsetsInListHearing()
}) })
}, },
// test // test
@ -92,51 +104,128 @@
this.tk = id this.tk = id
if (this.image == false) { if (this.image == false) {
this.tk = id this.tk = id
}else { } else {
this.tk = null this.tk = null
} }
}, },
checkboxChange(parat, e) { checkboxChange(partitem, e) {
if (e.value) { if (e.value) {
this.checked.push(parat.id) this.listHearing.forEach((paper) => {
const allItemsNoSubsets = parat.modules.every(item => !('subsets' in item)); paper.tests.forEach((test, testIndex) => {
parat.modules.forEach(item=>{ test.parts.forEach((part) => {
this.$set(item, 'subsets', item.id); if (part.id === partitem.id) {
item.subsets = item.id; part.modules.forEach((quesitem, quesIndex) => {
this.subsets.push(item.id) this.addToSelectWrite(
console.log( item.subsets) quesitem,
}) partitem.id,
testIndex + 1,
paper.title
);
});
}
});
});
});
} else { } else {
let index = this.checked.indexOf(parat.id); partitem.modules.forEach((quesitem) => {
if (index !== -1) { this.removeFromSelectWrite(quesitem.id);
this.checked.splice(index, 1); });
parat.modules.forEach(item=>{
this.$delete(item, 'subsets');
const index = this.subsets.indexOf(item.id);
if (index !== -1) {
this.subsets.splice(index, 1);
}
})
}
} }
console.log(this.checked,'part数组') this.$forceUpdate();
this.$forceUpdate()
// selectwrite listHearing subsets
this.updateSubsetsInListHearing();
this.$parent.updataread(this.selectwrite)
}, },
checkoutzj(quesitem, id) { handleCheckboxChange(quesitems) {
if (id.value) { const existingIndex = this.selectwrite.findIndex(item => item.id === quesitems.id);
this.subsets.push(quesitem.id)
console.log(quesitem) if (existingIndex !== -1) {
// subsets false
this.selectwrite.splice(existingIndex, 1);
quesitems.subsets = false;
} else { } else {
let index2 = this.subsets.indexOf(quesitem.id); // subsets true
if (index2 !== -1) { this.listHearing.forEach((paper) => {
this.subsets.splice(index2, 1); paper.tests.forEach((test, testIndex) => {
} test.parts.forEach((part) => {
part.modules.forEach((quesitem, quesIndex) => {
if (quesitem.id == quesitems.id) {
this.addToSelectWrite(
quesitems,
quesitems.id, // 使 quesitem id
testIndex + 1, // 使 testIndex
paper.title // 使 quesitem paperTitle
);
}
});
});
});
});
quesitems.subsets = true;
} }
console.log(this.subsets,'题型数组')
} console.log(this.selectwrite, 'selectwriteselectwrite');
this.updateSubsetsInListHearing()
this.$parent.updataread(this.selectwrite)
},
// listHearing subsets
updateSubsetsInListHearing() {
this.listHearing.forEach((paper) => {
paper.tests.forEach((test) => {
test.parts.forEach((part) => {
part.modules.forEach((quesitem) => {
const selected = this.selectwrite.find((item) => {
return item.id === quesitem.id;
});
if (selected) {
quesitem.subsets = true;
} else {
quesitem.subsets = false;
}
});
});
});
});
// listHearing part modules subsets true
this.listHearing.forEach((paper) => {
paper.tests.forEach((test) => {
test.parts.forEach((part) => {
part.checked = part.modules.every((quesitem) => quesitem.subsets);
});
});
});
},
// selectwrite
addToSelectWrite(quesitem, partId, testIndex, paperTitle) {
// Split the guideText into words
const item = {
id: quesitem.id,
paperId: quesitem.paperId,
papername: paperTitle,
partId: partId,
testId: quesitem.testId,
testname: `Test ${testIndex}`,
typeName: quesitem.typeText,
questionname: quesitem.number,
};
this.selectwrite.push(item);
},
removeFromSelectWrite(itemId) {
const index = this.selectwrite.findIndex((item) => item.id === itemId);
if (index !== -1) {
this.selectwrite.splice(index, 1);
}
},
} }
} }
</script> </script>
@ -200,4 +289,4 @@
height: 20rpx; height: 20rpx;
margin-right: 10rpx; margin-right: 10rpx;
} }
</style> </style>

View File

@ -118,73 +118,94 @@
<view class="view_tubiao"> <view class="view_tubiao">
<view class="view_title">作业安排</view> <view class="view_title">作业安排</view>
</view> </view>
<view>
<view class="Ielts">IELTS 18</view> </view>
<view>
<view v-for="(item,index) in selectreadlist" :key="index">
<view class="Ielts">{{item.papername}}</view>
<view <view
style="background-color: #fff; padding: 32rpx 40rpx; border-radius: 20rpx 20rpx 20rpx 20rpx;"> style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;">
<u-time-line> <u-time-line>
<u-time-line-item nodeTop="2"> <u-time-line-item nodeTop="2"
v-for="(items,indexs) in item.message" :key="indexs">
<template v-slot:content> <template v-slot:content>
<view> <view>
<view style="display: flex;"> <view style="display: flex;flex-wrap: nowrap;">
<view class="Test">Test 2</view> <view class="Test"
>{{items.testname}}</view>
<view class="greener">听力</view>
<view class="ellipses">阅读</view>
</view> </view>
<view class="u-order-desc"> <view class="u-order-desc">
<text>Part 1多选题</text> <text>{{items.questionname}} {{items.typeName}}</text>
</view>
</view>
</template>
</u-time-line-item>
<u-time-line-item nodeTop="2">
<template v-slot:content>
<view>
<view style="display: flex;">
<view class="Test">Test 2</view>
<view class="greener">听力</view>
</view>
<view class="u-order-desc">
<text>Part 1多选题</text>
</view>
</view>
</template>
</u-time-line-item>
<u-time-line-item nodeTop="2">
<template v-slot:content>
<view>
<view style="display: flex;">
<view class="Test">Test 2</view>
<view class="greener">听力</view>
</view>
<view class="u-order-desc">
<text>Part 1多选题</text>
</view> </view>
</view> </view>
</template> </template>
</u-time-line-item> </u-time-line-item>
</u-time-line> </u-time-line>
</view> </view>
</view> </view>
</view> </view>
<view v-for="(item,index) in selectwritelist" :key="index"> <view>
<view class="Ielts">{{item.examName}}</view> <view v-for="(item,index) in selectlistenlist" :key="index">
<view style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;" v-for="(items,indexs) in item.message" :key="indexs"> <view class="Ielts">{{item.papername}}</view>
<view style="display: flex; align-items: center;"> <view
<view class="yuandi"></view> style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;">
<view class="Test">{{items.test}}</view> <u-time-line>
<view class="ellipses">写作</view> <u-time-line-item nodeTop="2"
v-for="(items,indexs) in item.message" :key="indexs">
<template v-slot:content>
<view>
<view style="display: flex;flex-wrap: nowrap;">
<view class="Test"
>{{items.testname}}</view>
<view class="greener">听力</view>
</view>
<view class="u-order-desc">
<text>{{items.questionname}} {{items.typeName}}</text>
</view>
</view>
</template>
</u-time-line-item>
</u-time-line>
</view> </view>
<view class="u-order-desc"> </view>
<text>{{items.task}}</text> </view>
<view>
<view v-for="(item,index) in selectwritelist" :key="index">
<view class="Ielts">{{item.examName}}</view>
<view
style="background-color: #fff; padding: 32rpx 40rpx;border-radius: 20rpx 20rpx 20rpx 20rpx;">
<u-time-line>
<u-time-line-item nodeTop="2"
v-for="(items,indexs) in item.message" :key="indexs">
<template v-slot:content>
<view>
<view style="display: flex;flex-wrap: nowrap;">
<view class="Test"
>{{items.test}}</view>
<view class="ellipses" style="background: rgba(63,122,242,0.2);color: #3F7AF2;">写作</view>
</view>
<view class="u-order-desc">
<text>{{items.task}}</text>
</view>
</view>
</template>
</u-time-line-item>
</u-time-line>
</view> </view>
</view> </view>
</view> </view>
@ -317,7 +338,9 @@ export default {
selectwrite: [], selectwrite: [],
selectlisten: [], selectlisten: [],
selectread: [], selectread: [],
selectwritelist: [] selectwritelist: [],
selectlistenlist: [],
selectreadlist: [],
} }
}, },
@ -365,8 +388,8 @@ export default {
this.selectwrite = selectforwork.selectwrite this.selectwrite = selectforwork.selectwrite
this.selectlisten = selectforwork.selectlisten this.selectlisten = selectforwork.selectlisten
this.selectread = selectforwork.selectread this.selectread = selectforwork.selectread
this.selectwrite = selectforwork.selectwrite; // this.selectwrite = selectforwork.selectwrite;
//
const groupedItems = {}; const groupedItems = {};
this.selectwrite.forEach(item => { this.selectwrite.forEach(item => {
@ -385,11 +408,66 @@ export default {
id: item.id id: item.id
}); });
}); });
// Convert groupedItems object to an array
this.selectwritelist = Object.values(groupedItems); this.selectwritelist = Object.values(groupedItems);
//
const groupedItems1 = {};
this.selectlisten.forEach(item => {
const papername = item.papername;
if (!groupedItems1[papername]) {
groupedItems1[papername] = {
papername: papername,
message: []
};
}
groupedItems1[papername].message.push({
id: item.id,
paperId: item.paperId,
// papername: paperTitle,
partId: item.partId,
testId: item.testId,
testname: item.testname,
typeName: item.typeName,
questionname:item. questionname,
});
});
// Convert groupedItems object to an array
this.selectlistenlist = Object.values(groupedItems1);
const groupedItems2 = {};
this.selectread.forEach(item => {
const papername = item.papername;
if (!groupedItems2[papername]) {
groupedItems2[papername] = {
papername: papername,
message: []
};
}
groupedItems2[papername].message.push({
id: item.id,
paperId: item.paperId,
// papername: paperTitle,
partId: item.partId,
testId: item.testId,
testname: item.testname,
typeName: item.typeName,
questionname:item. questionname,
});
});
// Convert groupedItems object to an array
this.selectreadlist = Object.values(groupedItems2);
console.log(this.selectwritelist, 'selectwritelist'); console.log(this.selectreadlist, 'this.selectread');
console.log(this.selectlistenlist, 'this.selectlisten');
// Remove duplicates from this.classinfo // Remove duplicates from this.classinfo
// this.stuinfo = this.stuinfo.filter(item => !selectedstuInfo.some(selectedItem => selectedItem.id === item.id)); // this.stuinfo = this.stuinfo.filter(item => !selectedstuInfo.some(selectedItem => selectedItem.id === item.id));
@ -400,52 +478,16 @@ export default {
}, },
methods: { methods: {
mergeObjectsByExamName(existingArray, newArray) {
const mergedArray = [];
newArray.forEach(newObj => {
const existingObjIndex = existingArray.findIndex(existingObj => existingObj.examName === newObj.examName);
if (existingObjIndex !== -1) {
// examName
const existingObj = existingArray[existingObjIndex];
existingObj.message.push({
test: newObj.test,
task: newObj.task,
id: newObj.id,
// ...
});
//
existingArray[existingObjIndex] = existingObj;
} else {
// examName
mergedArray.push({
examName: newObj.examName,
message: [{
test: newObj.test,
task: newObj.task,
id: newObj.id,
// ...
}],
// ...
});
}
});
// existingArray
existingArray.forEach(existingObj => {
const existingObjIndex = mergedArray.findIndex(obj => obj.examName === existingObj.examName);
if (existingObjIndex === -1) {
mergedArray.push(existingObj);
}
});
return mergedArray;
},
addwork() { addwork() {
const dataToSave = {
selectspeak: this.selectspeak,
selectwrite: this.selectwrite,
selectlisten: this.selectlisten,
selectread: this.selectread
};
uni.navigateTo({ uni.navigateTo({
url: "/pages_teacher/teacher_teachers/teacher_writeadd?classinfo=" + encodeURIComponent(JSON.stringify(this.classinfo)) url: "/pages_teacher/teacher_teachers/teacher_writeadd?dataToSave=" + encodeURIComponent(JSON.stringify(dataToSave))
}).then(res => { }).then(res => {
}).catch(err => { }).catch(err => {

View File

@ -226,15 +226,15 @@
<!-- 写作 --> <!-- 写作 -->
<swiper-item> <swiper-item>
<compose></compose> <compose ref="compose"></compose>
</swiper-item> </swiper-item>
<!--听力 --> <!--听力 -->
<swiper-item> <swiper-item>
<audiology></audiology> <audiology ref="audiology"></audiology>
</swiper-item> </swiper-item>
<!-- 阅读 --> <!-- 阅读 -->
<swiper-item> <swiper-item>
<reading></reading> <reading ref="reading"></reading>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
@ -282,7 +282,7 @@ export default {
// v-if // v-if
radioValue: '', radioValue: '',
part1: true, part1: true,
current: 1, current: 0,
search: true, search: true,
listType: [], listType: [],
idList: [], idList: [],
@ -341,16 +341,39 @@ export default {
reading, reading,
compose compose
}, },
created() { onShow() {
this.getList() this.getList()
}, },
onLoad(option) {
const dataToSave =JSON.parse(decodeURIComponent(option.dataToSave))
this.selectspeak=dataToSave.selectspeak
this.selectwrite=dataToSave.selectwrite
this.selectlisten=dataToSave.selectlisten
this.selectread=dataToSave.selectread
this.$refs.compose.updatawrite(this.selectwrite)
this.$refs.audiology.updatawrite(this.selectlisten)
this.$refs.reading.updatawrite(this.selectread)
this.calculateTotalLength()
},
methods: { methods: {
updatawrite(data){ updatawrite(data){
this.selectwrite=data this.selectwrite=data
console.log(this.selectwrite, ' this.selectwrite this.selectwrite'); console.log(this.selectwrite, ' this.selectwrite this.selectwrite');
this.calculateTotalLength() this.calculateTotalLength()
}, },
updataread(data){
this.selectread=data
console.log(this.selectread, ' this.selectwrite this.selectwrite');
this.calculateTotalLength()
},
updatalisten(data){
this.selectlisten=data
console.log(this.selectlisten, ' this.selectwrite this.selectwrite');
this.calculateTotalLength()
},
submessage(){ submessage(){
const dataToSave = { const dataToSave = {
selectspeak: this.selectspeak, selectspeak: this.selectspeak,