lrf402788946 5 years ago
parent
commit
70517e9114
3 changed files with 133 additions and 0 deletions
  1. 1 0
      package.json
  2. 10 0
      src/router/index.js
  3. 122 0
      src/views/new-plan/index.vue

+ 1 - 0
package.json

@@ -17,6 +17,7 @@
     "core-js": "^3.4.4",
     "element-ui": "^2.13.0",
     "lodash": "^4.17.15",
+    "moment": "^2.24.0",
     "naf-core": "^0.1.2",
     "qrcode": "^1.4.4",
     "vue": "^2.6.10",

+ 10 - 0
src/router/index.js

@@ -5,12 +5,22 @@ import { Notification } from 'element-ui';
 
 Vue.use(VueRouter);
 
+const newPlan = [
+  {
+    path: '/newPlan/index',
+    name: 'newPlan_list',
+    meta: { title: '新计划', sub: '管理' },
+    component: () => import('@/views/new-plan/index.vue'),
+  },
+];
+
 const routes = [
   {
     path: '/',
     name: 'frame',
     component: () => import('@/views/index.vue'),
     children: [
+      ...newPlan,
       {
         path: '/plan/index',
         name: 'plan_list',

+ 122 - 0
src/views/new-plan/index.vue

@@ -0,0 +1,122 @@
+<template>
+  <div id="index">
+    <list-frame :title="pageTitle" @query="search" :total="total" :needFilter="false" :needAdd="false">
+      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit"></data-table>
+    </list-frame>
+    <el-dialog title="上报需要请假的日期" width="30%" :visible.sync="dialog" center :destroy-on-close="true" @close="handleClose">
+      <data-form :data="info" :fields="Ffields" :rules="rules" @save="handleSave" :isNew="!info.id" :styles="{ padding: 0 }" labelWidth="80px" :reset="false">
+        <template #custom="{item,form}">
+          <template v-if="item.model == 'daterange'">
+            <el-select v-model="form[item.model]" multiple @change="toSort">
+              <el-option v-for="i in 12" :key="i" :label="`${i}月`" :value="i"></el-option>
+            </el-select>
+          </template>
+        </template>
+      </data-form>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+var moment = require('moment');
+import _ from 'lodash';
+import Vue from 'vue';
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/data-table';
+import dataForm from '@frame/components/form';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
+const { mapActions: dirPlan } = createNamespacedHelpers('dirPlan');
+export default {
+  name: 'index',
+  props: {},
+  components: { listFrame, dataTable, dataForm },
+  data: () => {
+    return {
+      dialog: false,
+      opera: [
+        {
+          label: '上报需要请假的日期',
+          icon: 'el-icon-date',
+          method: 'edit',
+        },
+      ],
+      fields: [
+        { label: '年度', prop: 'year' },
+        { label: '标题', prop: 'title' },
+      ],
+      info: {},
+      form: {},
+      Ffields: [
+        { label: '年度', model: 'year', type: 'text' },
+        { label: '标题', model: 'title', type: 'text' },
+        { label: '请假日期', model: 'nodate', custom: true },
+      ],
+      rules: {},
+      list: [],
+      total: 0,
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...dirPlan({ dirQuery: 'query', dirCreatPlan: 'create', dirUpdatePlan: 'update' }),
+    ...trainplan(['query', 'create', 'delete', 'update']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async toEdit({ data }) {
+      let res = await this.dirQuery({ trainplanid: data.id, headteacherid: this.user.userid });
+      let { year, id, title } = data;
+      let plan = { schid: this.user.code, year, planid: id, title };
+      this.$set(this, `info`, plan);
+      if (this.$checkRes(res)) {
+        let daterange = JSON.parse(res.data[0].daterange);
+        if (res.data.length > 0) this.$set(this, `info`, { ...res.data[0], daterange, title });
+      }
+      this.dialog = true;
+    },
+    async handleSave({ data, isNew }) {
+      let res;
+      let msg;
+      let duplicate = JSON.parse(JSON.stringify(data));
+      duplicate.daterange = JSON.stringify(duplicate.daterange);
+      if (isNew) {
+        //create
+        res = await this.createSchPlan(duplicate);
+        msg = '添加成功';
+      } else {
+        //update
+        res = await this.updateSchPlan(duplicate);
+        msg = '修改成功';
+      }
+      if (this.$checkRes(res, msg, res.errmsg || '操作失败')) {
+        this.handleClose();
+      }
+    },
+    handleClose() {
+      this.dialog = false;
+      this.info = {};
+    },
+    toSort() {
+      this.info.daterange.sort((a, b) => a - b);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>