|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div id="detail">
|
|
|
<detail-frame :title="pageTitle" returns="./index">
|
|
|
- <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew">
|
|
|
+ <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew" :reset="false">
|
|
|
<template #radios="{item}">
|
|
|
<template v-if="item.model === 'type'">
|
|
|
<el-radio v-for="(i, index) in types" :key="index" :label="i.value">{{ i.label }}</el-radio>
|
|
@@ -81,10 +81,11 @@
|
|
|
<script>
|
|
|
import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
import dataForm from '@frame/components/form';
|
|
|
-import { lesson } from '@frame/config/lesson-template';
|
|
|
+import { lesson as lessons } from '@frame/config/lesson-template';
|
|
|
import _ from 'lodash';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: subject } = createNamespacedHelpers('subject');
|
|
|
+const { mapActions: lesson } = createNamespacedHelpers('lesson');
|
|
|
export default {
|
|
|
name: 'detail',
|
|
|
props: {},
|
|
@@ -122,7 +123,7 @@ export default {
|
|
|
{ label: '第六天类型', model: 'day6type', type: 'radio' },
|
|
|
{ label: '第六天安排', model: 'day6', custom: true },
|
|
|
],
|
|
|
- lessons: lesson,
|
|
|
+ lessons: lessons,
|
|
|
dayType: [{ label: '活动' }, { label: '课程' }],
|
|
|
actList: [
|
|
|
{ label: '--' },
|
|
@@ -144,24 +145,29 @@ export default {
|
|
|
...subject({
|
|
|
getSubjectList: 'query',
|
|
|
}),
|
|
|
+ ...lesson(['modelFetch', 'modelCreate', 'modelUpdate']),
|
|
|
async search() {
|
|
|
- const res = await this.fetch(this.id);
|
|
|
- if (this.$checkRes(res)) this.$set(this, `info`, res.data);
|
|
|
+ const res = await this.modelFetch(this.id);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `info`, res.data);
|
|
|
+ let { lessons } = res.data;
|
|
|
+ lessons = JSON.parse(lessons);
|
|
|
+ this.$set(this, `lessons`, lessons);
|
|
|
+ }
|
|
|
this.loading = false;
|
|
|
},
|
|
|
async handleSave({ isNew, data }) {
|
|
|
let res;
|
|
|
let msg;
|
|
|
data.lessons = JSON.stringify(this.lessons);
|
|
|
- console.log(data);
|
|
|
- // if (isNew) {
|
|
|
- // res = await this.create(data);
|
|
|
- // msg = `${this.pageTitle}添加成功`;
|
|
|
- // } else {
|
|
|
- // res = await this.update(data);
|
|
|
- // msg = `${this.pageTitle}修改成功`;
|
|
|
- // }
|
|
|
- // if (this.$checkRes(res, msg)) this.$router.push({ path: './index' });
|
|
|
+ if (isNew) {
|
|
|
+ res = await this.modelCreate(data);
|
|
|
+ msg = `${this.pageTitle}添加成功`;
|
|
|
+ } else {
|
|
|
+ res = await this.modelUpdate(data);
|
|
|
+ msg = `${this.pageTitle}修改成功`;
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, msg)) this.$router.push({ path: './index' });
|
|
|
},
|
|
|
async toEdit(data, index) {
|
|
|
let newData = JSON.parse(JSON.stringify(data));
|