|
@@ -31,6 +31,8 @@
|
|
|
<script>
|
|
|
import NavBar from '@/layout/common/topInfo.vue';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: experience } = createNamespacedHelpers('experience');
|
|
|
+const { mapActions: util } = createNamespacedHelpers('util');
|
|
|
export default {
|
|
|
name: 'experience',
|
|
|
props: {},
|
|
@@ -45,10 +47,44 @@ export default {
|
|
|
form: {},
|
|
|
};
|
|
|
},
|
|
|
- created() {},
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
methods: {
|
|
|
- onSubmit() {
|
|
|
- console.log(this.form);
|
|
|
+ ...util({ modelFetch: 'fetch' }),
|
|
|
+ ...experience(['update', 'create']),
|
|
|
+ async search() {
|
|
|
+ const { classid, userid } = this.user;
|
|
|
+ const res = await this.modelFetch({ model: 'experience', classid, studentid: userid });
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `form`, res.data || {});
|
|
|
+ },
|
|
|
+ async onSubmit() {
|
|
|
+ let duplicate = _.cloneDeep(this.form);
|
|
|
+ let res;
|
|
|
+ if (_.get(duplicate, '_id')) {
|
|
|
+ res = await this.update(duplicate);
|
|
|
+ } else {
|
|
|
+ const { termid, batchid, classid, userid } = this.user;
|
|
|
+ if (!termid) {
|
|
|
+ this.$toast({ type: 'fail', message: '学生缺少期信息' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!batchid) {
|
|
|
+ this.$toast({ type: 'fail', message: '学生缺少批次信息' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!classid) {
|
|
|
+ this.$toast({ type: 'fail', message: '学生缺少班级信息' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!userid) {
|
|
|
+ this.$toast({ type: 'fail', message: '缺少学生信息' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ duplicate = { ...duplicate, termid, batchid, classid, studentid: userid };
|
|
|
+ res = await this.create(duplicate);
|
|
|
+ }
|
|
|
+ this.$checkRes(res, '培训心得保存成功', res.errmsg || '培训心得保存失败');
|
|
|
},
|
|
|
},
|
|
|
computed: {
|