Quellcode durchsuchen

Merge branch 'master' of http://git.cc-lotus.info/new_train/train-student

guhongwei vor 5 Jahren
Ursprung
Commit
7495e4e7aa

+ 150 - 0
src/components/upload-file.vue

@@ -0,0 +1,150 @@
+<template>
+  <div id="upload-file">
+    <el-upload
+      ref="uploadFile"
+      :action="url"
+      :before-remove="handleRemove"
+      :before-upload="changeFile"
+      :on-success="onSuccess"
+      :limit="limit"
+      multiple
+      :on-exceed="outLimit"
+      :file-list="fileList"
+      :on-preview="onPreview"
+      :on-remove="remove"
+      list-type="text"
+    >
+      <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
+      <div slot="tip" class="el-upload__tip">{{ desc === undefined ? '只能上传不超过2MB的文件' : desc }}</div>
+    </el-upload>
+    <el-dialog title="查看" :visible.sync="dialog" center>
+      <el-row>
+        <el-form :model="disObject" label-position="left" label-width="auto">
+          <el-form-item label="文件名" prop="name">
+            <el-input v-model="disObject.name" placeholder="请输入新文件名"></el-input>
+          </el-form-item>
+          <el-image style="width: 100%; height: 100%" :src="disObject.url" fit="scale-down" v-if="disObject.type === 'pic'"></el-image>
+        </el-form>
+      </el-row>
+      <template #footer>
+        <el-row type="flex" align="middle" justify="center">
+          <el-col :span="6"><el-button type="info" @click="dialog = false">返回 </el-button></el-col>
+          <el-col :span="6" v-if="disObject.type === 'file'"><el-button @click="downLoad(disObject.url)">下载文件</el-button></el-col>
+          <el-col :span="6"><el-button type="primary" @click="changeName()">修改文件名</el-button></el-col>
+        </el-row>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+export default {
+  name: 'upload-file',
+  props: {
+    url: { type: null },
+    type: { type: String },
+    limit: { type: Number },
+    data: { type: null },
+    desc: { type: String },
+  },
+  components: {},
+  data: () => ({
+    fileList: [],
+    dialog: false,
+    disObject: {},
+    test: {},
+  }),
+  created() {
+    if (this.data) {
+      this.defalutProcess(this.data);
+    }
+  },
+  computed: {},
+  watch: {
+    data: {
+      handler(val) {
+        this.defalutProcess(val);
+      },
+    },
+  },
+  methods: {
+    handleRemove(file) {
+      return true;
+    },
+    changeFile(file, fileList) {
+      let size = file.size / 1024 / 1024;
+      if (size > 2) {
+        return false;
+      }
+    },
+    onSuccess(response, file, fileList) {
+      //将文件整理好传回父组件
+      this.$emit('upload', { type: this.type, data: response });
+    },
+    outLimit() {
+      this.$message.error(`只允许上传${this.limit}个文件`);
+    },
+    onPreview(file) {
+      let duplicate = JSON.parse(JSON.stringify(file));
+      let res = this.isPic(duplicate.url);
+      if (this.isPic(duplicate.url)) {
+        this.disObject.type = 'pic';
+      } else {
+        this.disObject.type = 'file';
+      }
+      this.disObject.url = duplicate.url;
+      this.dialog = true;
+    },
+    defalutProcess(val) {
+      if (typeof val === 'object' && _.get(val, length) !== undefined) {
+        let newArr = [];
+        val.map(item => {
+          let object = {};
+          object.name = item.name;
+          object.url = item.uri;
+          newArr.push(object);
+        });
+        this.$set(this, `fileList`, newArr);
+      } else if (typeof val === 'object' && _.get(val, length) === undefined) {
+        let object = {};
+        object.name = val.name;
+        object.url = val.uri;
+        this.$set(this, `fileList`, []);
+      } else {
+        this.$set(this, `fileList`, [{ name: '附件', url: val }]);
+      }
+    },
+    isPic(url) {
+      if (url.includes('.jpg')) {
+        return true;
+      }
+      if (url.includes('.bmp')) {
+        return true;
+      }
+      if (url.includes('.jpge')) {
+        return true;
+      }
+      if (url.includes('.png')) {
+        return true;
+      }
+      if (url.includes('.gif')) {
+        return true;
+      }
+    },
+    downLoad(url) {
+      window.open(url);
+    },
+    changeName() {
+      this.$emit('changeName', { type: this.type, data: this.disObject });
+      this.dialog = false;
+      this.disObject = {};
+    },
+    remove(file) {
+      this.$emit('toRemove', { type: this.type, data: file });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 3 - 0
src/layout/user/clickBtn.vue

@@ -8,6 +8,9 @@
         <el-col :span="24" class="native">
           <van-cell is-link @click="$router.push({ path: '/user/checkWork' })">考勤</van-cell>
         </el-col>
+        <el-col :span="24" class="native">
+          <van-cell is-link @click="$router.push({ path: '/user/homework' })">作业管理</van-cell>
+        </el-col>
       </el-col>
     </el-row>
   </div>

+ 104 - 0
src/layout/user/datiList.vue

@@ -0,0 +1,104 @@
+<template>
+  <div id="leaveList">
+    <el-row>
+      <el-col class="info">
+        <el-form ref="form" :model="form">
+          <el-col :span="24" class="topTitle">
+            {{ datilist.name }}
+          </el-col>
+          <el-col :span="24" v-for="(item, index) in datilist.question" :key="index">
+            <el-form-item>
+              <span slot="label">{{ index + 1 }} . {{ item.topic }}</span>
+            </el-form-item>
+            <template v-if="item.type === '0'">
+              <el-col :span="24" v-for="(items, index) in item.option" :key="index">
+                <el-radio v-model="item.answer" :label="items.opname">{{ items.number }}{{ items.opname }}</el-radio>
+              </el-col>
+            </template>
+            <template v-else-if="item.type === '1'">
+              <el-checkbox-group v-model="item.answer">
+                <el-col :span="24" v-for="(items, index) in item.option" :key="index">
+                  <el-checkbox :label="items.opname">{{ items.number }}{{ items.opname }}</el-checkbox>
+                </el-col>
+              </el-checkbox-group>
+            </template>
+            <span v-else>
+              <el-input
+                type="textarea"
+                placeholder="请输入内容"
+                v-model="item.answer"
+                :autosize="{ minRows: 4, maxRows: 6 }"
+                maxlength="300"
+                show-word-limit
+              ></el-input>
+            </span>
+          </el-col>
+          <el-col :span="24" class="btn">
+            <el-button type="primary" @click="onSubmit">提交</el-button>
+          </el-col>
+        </el-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'leaveList',
+  props: {
+    datilist: null,
+  },
+  components: {},
+  data: () => ({
+    form: {
+      name: '',
+      region: '',
+      date1: '',
+      date2: '',
+      delivery: false,
+      type: [],
+      resource: '',
+      desc: '',
+    },
+  }),
+  created() {},
+  watch: {
+    info: {
+      handler(val) {
+        if (_.get(val, `id`)) this.$set(this, `task`, val);
+      },
+      immediate: true,
+      deep: true,
+    },
+  },
+  computed: {},
+  methods: {
+    onSubmit() {
+      console.log('submit!');
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.style {
+  min-height: 300px;
+  padding: 0 40px;
+}
+.topTitle {
+  text-align: center;
+  height: 50px;
+  line-height: 50px;
+  border-bottom: 1px dashed #333;
+}
+/deep/.el-form-item {
+  margin: 0;
+}
+/deep/.el-form-item__label {
+  color: #389ff0;
+}
+.btn {
+  text-align: center;
+  padding: 30px 0;
+}
+</style>

+ 83 - 0
src/layout/user/shangchuan.vue

@@ -0,0 +1,83 @@
+<template>
+  <div id="leaveList">
+    <el-row>
+      <el-col :span="24" class="list">
+        <el-col :span="14" class="time">
+          <el-form ref="form" :model="form" label-width="80px">
+            <el-form-item label="文件上传" prop="zynumberfile">
+              <upload :limit="1" :data="form.picrul" type="picrul" :url="`/files/teacher/upload`" @upload="uploadSuccess"></upload>
+            </el-form-item>
+
+            <div style="margin: 16px;">
+              <el-form-item>
+                <el-button type="primary" @click="onSubmit()">上传</el-button>
+              </el-form-item>
+            </div>
+          </el-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import upload from '@frame/components/upload.vue';
+export default {
+  name: 'leaveList',
+  props: {
+    form: null,
+    workLists: null,
+  },
+  components: {
+    upload,
+  },
+  data: () => ({
+    dialogVisible: false,
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    onSubmit() {
+      this.$emit('onConfirm', { data: this.form });
+    },
+
+    //上传
+    uploadSuccess({ type, data }) {
+      if (type !== 'picrul') {
+        let arr = _.get(this.form, type);
+        if (arr !== undefined) {
+          this.form[type].push({ name: data.name, uri: data.uri });
+        } else {
+          let newArr = [{ name: data.name, uri: data.uri }];
+          this.$set(this.form, `${type}`, newArr);
+        }
+      } else {
+        this.$set(this.form, `${type}`, data.uri);
+      }
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+p {
+  padding: 0;
+  margin: 0;
+}
+.list {
+  width: 97%;
+  padding: 15px;
+  background-color: #fff;
+  border-radius: 15px;
+  margin: 0 5px 5px 5px;
+}
+.list .time p {
+  padding: 5px 0;
+}
+.list .ispass {
+  padding: 20px 0;
+}
+.anniu {
+  padding: 20px 0 0 0;
+}
+</style>

+ 63 - 0
src/layout/user/workList.vue

@@ -0,0 +1,63 @@
+<template>
+  <div id="leaveList">
+    <el-row>
+      <el-col :span="24" class="list" v-for="(item, index) in workLists" :key="index">
+        <el-col :span="14" class="time">
+          <el-col>科目:{{ item.name }}</el-col>
+          <el-col>标题{{ item.title }}</el-col>
+          <el-col :span="24" class="anniu">
+            <el-button type="primary" size="small" @click="clickBtn(item.id)">在线作答</el-button>
+            <el-button type="primary" size="small" @click="clickzy(item.id)">上传作业</el-button>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'leaveList',
+  props: {
+    workLists: null,
+  },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    clickBtn(id) {
+      console.log(id);
+      this.$router.push({ path: '/user/dati', query: { id: id } });
+    },
+
+    clickzy(id) {
+      console.log(id);
+      this.$router.push({ path: '/user/chuanzuoye', query: { id: id } });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+p {
+  padding: 0;
+  margin: 0;
+}
+.list {
+  width: 97%;
+  padding: 15px;
+  background-color: #fff;
+  border-radius: 15px;
+  margin: 0 5px 5px 5px;
+}
+.list .time p {
+  padding: 5px 0;
+}
+.list .ispass {
+  padding: 20px 0;
+}
+.anniu {
+  padding: 20px 0 0 0;
+}
+</style>

+ 16 - 1
src/router/index.js

@@ -101,7 +101,22 @@ const routes = [
     meta: { title: '考勤管理', isleftarrow: true },
     component: () => import('../views/user/checkWork.vue'),
   },
-
+  //作业管理
+  {
+    path: '/user/homework',
+    meta: { title: '作业管理', isleftarrow: true },
+    component: () => import('../views/user/homework.vue'),
+  },
+  {
+    path: '/user/dati',
+    meta: { title: '作业详情', isleftarrow: true },
+    component: () => import('../views/user/dati.vue'),
+  },
+  {
+    path: '/user/chuanzuoye',
+    meta: { title: '上传作业', isleftarrow: true },
+    component: () => import('../views/user/chuanzuoye.vue'),
+  },
   //正在登陆
   {
     path: '/login',

+ 2 - 0
src/store/index.js

@@ -14,6 +14,7 @@ import subject from '@frame/store/subject';
 import uploadtask from '@frame/store/uploadtask';
 import score from '@frame/store/score';
 import termquest from '@frame/store/termquest';
+import task from '@frame/store/task';
 import login from '@frame/store/login';
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
@@ -40,5 +41,6 @@ export default new Vuex.Store({
     classes,
     uploadtask,
     subject,
+    task,
   },
 });

+ 98 - 0
src/views/user/chuanzuoye.vue

@@ -0,0 +1,98 @@
+<template>
+  <div id="homework">
+    <el-row>
+      <el-col :span="24" class="style">
+        <el-col :span="24" class="top">
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
+        </el-col>
+        <el-col :span="24" class="main">
+          <el-col :span="24" class="leaveBtn"> </el-col>
+          <el-col :span="24" class="leaveList">
+            <shangchuan :form="form" @onConfirm="onsave"></shangchuan>
+          </el-col>
+          <el-col :span="24" class="foot">
+            <footInfo></footInfo>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import NavBar from '@/layout/common/topInfo.vue';
+import shangchuan from '@/layout/user/shangchuan.vue';
+import footInfo from '@/layout/common/footInfo.vue';
+import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapUploadtask } = createNamespacedHelpers('uploadtask');
+export default {
+  name: 'homework',
+  props: {},
+  components: {
+    NavBar, //头部导航
+    shangchuan,
+    footInfo,
+  },
+  data: () => ({
+    form: {
+      // picrul: [{ url: 'fksdfhksdhfsk' }],
+    },
+    show: false,
+    navShow: true,
+    title: '',
+    isleftarrow: '',
+  }),
+  mounted() {
+    this.title = this.$route.meta.title;
+    this.isleftarrow = this.$route.meta.isleftarrow;
+  },
+  watch: {
+    $route(to, from) {
+      this.title = to.meta.title;
+      this.isleftarrow = to.meta.isleftarrow;
+    },
+  },
+  created() {},
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  methods: {
+    ...mapUploadtask({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
+    //提交上传
+    async onsave(form) {
+      console.log(form);
+      this.form.termid = this.user.termid;
+      this.form.batchid = this.user.batchid;
+      this.form.classid = this.user.classid;
+      this.form.studentid = this.user.userid;
+      this.form.lessonid = this.id;
+      let data = this.form;
+      console.log(data);
+      let res = await this.add(data);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.style {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #f9fafc;
+}
+.top {
+  height: 46px;
+  overflow: hidden;
+}
+.main {
+  min-height: 570px;
+}
+.main .leaveBtn {
+  text-align: center;
+  padding: 15px 0;
+}
+</style>

+ 91 - 0
src/views/user/dati.vue

@@ -0,0 +1,91 @@
+<template>
+  <div id="homework">
+    <el-row>
+      <el-col :span="24" class="style">
+        <el-col :span="24" class="top">
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
+        </el-col>
+        <el-col :span="24" class="main">
+          <el-col :span="24" class="leaveBtn"> </el-col>
+          <el-col :span="24" class="leaveList">
+            <datiList :datilist="datilist"></datiList>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import NavBar from '@/layout/common/topInfo.vue';
+import datiList from '@/layout/user/datiList.vue';
+import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapTask } = createNamespacedHelpers('task');
+export default {
+  name: 'homework',
+  props: {},
+  components: {
+    NavBar, //头部导航
+    datiList,
+  },
+  data: () => ({
+    loading: true,
+    datilist: {},
+    show: false,
+    navShow: true,
+    title: '',
+    isleftarrow: '',
+  }),
+  mounted() {
+    this.title = this.$route.meta.title;
+    this.isleftarrow = this.$route.meta.isleftarrow;
+  },
+  watch: {
+    $route(to, from) {
+      this.title = to.meta.title;
+      this.isleftarrow = to.meta.isleftarrow;
+    },
+  },
+  created() {
+    this.search();
+  },
+
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  methods: {
+    ...mapTask({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
+    async search() {
+      console.log(this.id);
+
+      const res = await this.fet(this.id);
+      console.log(res.data);
+      this.$set(this, `datilist`, res.data);
+      this.loading = false;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.style {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #f9fafc;
+}
+.top {
+  height: 46px;
+  overflow: hidden;
+}
+.main {
+  min-height: 570px;
+}
+.main .leaveBtn {
+  text-align: center;
+  padding: 15px 0;
+}
+</style>

+ 90 - 0
src/views/user/homework.vue

@@ -0,0 +1,90 @@
+<template>
+  <div id="homework">
+    <el-row>
+      <el-col :span="24" class="style">
+        <el-col :span="24" class="top">
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
+        </el-col>
+        <el-col :span="24" class="main">
+          <el-col :span="24" class="leaveBtn"> </el-col>
+          <el-col :span="24" class="leaveList">
+            <workList v-if="!loading" :workLists="workLists"></workList>
+          </el-col>
+          <el-col :span="24" class="foot">
+            <footInfo></footInfo>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import NavBar from '@/layout/common/topInfo.vue';
+import footInfo from '@/layout/common/footInfo.vue';
+import workList from '@/layout/user/workList.vue';
+import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapTask } = createNamespacedHelpers('task');
+export default {
+  name: 'homework',
+  props: {},
+  components: {
+    NavBar, //头部导航
+    workList,
+    footInfo,
+  },
+  data: () => ({
+    loading: true,
+    workLists: [],
+    show: false,
+    navShow: true,
+    title: '',
+    isleftarrow: '',
+  }),
+  mounted() {
+    this.title = this.$route.meta.title;
+    this.isleftarrow = this.$route.meta.isleftarrow;
+  },
+  watch: {
+    $route(to, from) {
+      this.title = to.meta.title;
+      this.isleftarrow = to.meta.isleftarrow;
+    },
+  },
+  created() {
+    this.search();
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  methods: {
+    ...mapTask({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
+    async search() {
+      const res = await this.list();
+      console.log(res.data);
+      this.$set(this, `workLists`, res.data);
+      this.loading = false;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.style {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #f9fafc;
+}
+.top {
+  height: 46px;
+  overflow: hidden;
+}
+.main {
+  min-height: 570px;
+}
+.main .leaveBtn {
+  text-align: center;
+  padding: 15px 0;
+}
+</style>

+ 1 - 20
src/views/user/index.vue

@@ -3,7 +3,6 @@
     <el-row>
       <el-col :span="24" class="style">
         <el-col :span="24" class="top">
-          <!-- <topInfo></topInfo> -->
           <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
         </el-col>
         <el-col :span="24" class="main">
@@ -39,25 +38,7 @@ export default {
     clickBtn, //功能按钮
   },
   data: () => ({
-    info: {
-      // name: '顾红伟',
-      // id_number: '220182199603257019',
-      // phone: '17319450324',
-      // gender: '男',
-      // nation: '汉族',
-      // school_name: '吉林大学',
-      // faculty: '计算机学院',
-      // major: '应用软件技术专业',
-      // entry_year: '2016',
-      // finish_year: '2020',
-      // school_job: '班长',
-      // qq: '1345526645',
-      // email: 'guhongwei0324@163.com',
-      // family_place: '吉林省长春市朝阳区力旺广场B座16楼',
-      // family_is_hard: '1',
-      // have_grant: '1',
-      // job: '班长',
-    },
+    info: {},
     title: '',
     isleftarrow: '',
     transitionName: 'fade',