|
@@ -0,0 +1,139 @@
|
|
|
|
+<template>
|
|
|
|
+ <div id="detail">
|
|
|
|
+ <detail-frame :title="mainTitle" returns="/teacher/list">
|
|
|
|
+ <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew">
|
|
|
|
+ <!-- <template #custom="{ item, form }"> </template> -->
|
|
|
|
+ <template #options="{item}">
|
|
|
|
+ <template v-if="item.model === 'tramid'">
|
|
|
|
+ <el-option v-for="(item, index) in deptList" :key="index" :label="item.name" :value="item.newTermnum"></el-option>
|
|
|
|
+ </template>
|
|
|
|
+ </template>
|
|
|
|
+
|
|
|
|
+ <template #custom="{ item, form }">
|
|
|
|
+ <el-upload
|
|
|
|
+ class="upload-demo"
|
|
|
|
+ action="/files/train/upload"
|
|
|
|
+ :on-preview="handlePreview"
|
|
|
|
+ :on-remove="handleRemove"
|
|
|
|
+ :before-remove="beforeRemove"
|
|
|
|
+ multiple
|
|
|
|
+ :limit="3"
|
|
|
|
+ :on-exceed="handleExceed"
|
|
|
|
+ >
|
|
|
|
+ <el-button size="small" type="primary">点击上传</el-button>
|
|
|
|
+ <div slot="tip" class="el-upload__tip">不超过500kb</div>
|
|
|
|
+ </el-upload>
|
|
|
|
+ </template>
|
|
|
|
+ </data-form>
|
|
|
|
+ </detail-frame>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
|
+import dataForm from '@frame/components/form';
|
|
|
|
+import { createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions } = createNamespacedHelpers('schoolimport');
|
|
|
|
+const { mapActions: mapDept } = createNamespacedHelpers('schPlan');
|
|
|
|
+export default {
|
|
|
|
+ metaInfo: { title: '教师信息' },
|
|
|
|
+ name: 'detail',
|
|
|
|
+ props: {},
|
|
|
|
+ components: { detailFrame, dataForm },
|
|
|
|
+ data: () => ({
|
|
|
|
+ deptList: [],
|
|
|
|
+ info: {},
|
|
|
|
+
|
|
|
|
+ fields: [
|
|
|
|
+ { label: '期次', model: 'tramid', type: 'select' },
|
|
|
|
+ // { label: '学校', model: 'schid', type: 'select' },
|
|
|
|
+ { label: '上传学生名单', model: 'filepath', type: 'upload', custom: true },
|
|
|
|
+ ],
|
|
|
|
+ rules: {},
|
|
|
|
+ loading: true,
|
|
|
|
+ }),
|
|
|
|
+ created() {
|
|
|
|
+ this.otherList();
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ isNew() {
|
|
|
|
+ return this.$route.query.id ? false : true;
|
|
|
|
+ },
|
|
|
|
+ id() {
|
|
|
|
+ return this.$route.query.id;
|
|
|
|
+ },
|
|
|
|
+ mainTitle() {
|
|
|
|
+ let meta = this.$route.meta;
|
|
|
|
+ let main = meta.title || '';
|
|
|
|
+ let sub = meta.sub || '';
|
|
|
|
+ return `${main}${sub}`;
|
|
|
|
+ },
|
|
|
|
+ keyWord() {
|
|
|
|
+ let meta = this.$route.meta;
|
|
|
|
+ let main = meta.title || '';
|
|
|
|
+ return main;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ id: {
|
|
|
|
+ immediate: true,
|
|
|
|
+ handler(val) {
|
|
|
|
+ if (val) this.loading = false;
|
|
|
|
+ else this.search();
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ methods: {
|
|
|
|
+ ...mapDept({ dept: 'query' }),
|
|
|
|
+ ...mapActions(['fetch', 'create', 'update']),
|
|
|
|
+ async search() {
|
|
|
|
+ // const res = await this.fetch(this.id);
|
|
|
|
+ // if (this.$checkRes(res)) this.$set(this, `info`, res.data);
|
|
|
|
+ // this.loading = false;
|
|
|
|
+ },
|
|
|
|
+ async handleSave({ isNew, data }) {
|
|
|
|
+ let res;
|
|
|
|
+ let msg;
|
|
|
|
+ if (isNew) {
|
|
|
|
+ res = await this.create(data);
|
|
|
|
+ msg = `${this.keyWord}添加成功`;
|
|
|
|
+ } else {
|
|
|
|
+ res = await this.update(data);
|
|
|
|
+ msg = `${this.keyWord}修改成功`;
|
|
|
|
+ }
|
|
|
|
+ if (this.$checkRes(res, msg)) this.$router.push({ path: '/dept/index' });
|
|
|
|
+ },
|
|
|
|
+ async otherList() {
|
|
|
|
+ const res = await this.dept({ planid: this.info.id, schname: '测试学校' });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ for (let val of res.data) {
|
|
|
|
+ console.log(val.term);
|
|
|
|
+ for (let lets of val.term) {
|
|
|
|
+ console.log(lets);
|
|
|
|
+ val.newTermnum = lets.termnum;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ console.log(res.data);
|
|
|
|
+ this.$set(this, `deptList`, res.data);
|
|
|
|
+ console.log(res.data.length);
|
|
|
|
+ console.log(res.data);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ handleRemove(file, fileList) {
|
|
|
|
+ console.log(file, fileList);
|
|
|
|
+ },
|
|
|
|
+ handlePreview(file) {
|
|
|
|
+ console.log(file);
|
|
|
|
+ },
|
|
|
|
+ handleExceed(files, fileList) {
|
|
|
|
+ this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
|
|
|
|
+ },
|
|
|
|
+ beforeRemove(file, fileList) {
|
|
|
|
+ return this.$confirm(`确定移除 ${file.name}?`);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="less" scoped></style>
|