|
@@ -5,18 +5,54 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import _ from 'lodash';
|
|
|
import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: lesson } = createNamespacedHelpers('lesson');
|
|
|
+const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
export default {
|
|
|
name: 'term-lesson',
|
|
|
props: {},
|
|
|
components: { detailFrame },
|
|
|
data: function() {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ options: {},
|
|
|
+ lessonList: [],
|
|
|
+ classList: [],
|
|
|
+ };
|
|
|
},
|
|
|
created() {},
|
|
|
- methods: {},
|
|
|
+ methods: {
|
|
|
+ ...lesson({ getLesson: 'query' }),
|
|
|
+ ...classes({ getClass: 'query' }),
|
|
|
+ async search() {
|
|
|
+ let termid = _.get(this.defaultOption, `termid`);
|
|
|
+ if (!termid) return;
|
|
|
+ let lessons = await this.getLesson({ termid });
|
|
|
+ if (this.$checkRes(lessons)) this.$set(this, `lessonList`, lessons.data);
|
|
|
+ let classes = await this.getClass({ termid });
|
|
|
+ if (this.$checkRes(classes)) this.$set(this, `classList`, classes.data);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ defaultOption: {
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ handler(val) {
|
|
|
+ if (!_.get(this, 'options')) {
|
|
|
+ this.$set(this, `options`, _.cloneDeep(val));
|
|
|
+ this.search();
|
|
|
+ } else {
|
|
|
+ let ntermid = _.get(val, 'termid');
|
|
|
+ let otermid = _.get(this.options, 'termid');
|
|
|
+ if (ntermid && !_.isEqual(ntermid, otermid)) {
|
|
|
+ this.$set(this, `options`, _.cloneDeep(val));
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
computed: {
|
|
|
...mapState(['user', 'defaultOption']),
|
|
|
pageTitle() {
|