lrf402788946 5 年之前
父节点
当前提交
9ed54fcf1c
共有 3 个文件被更改,包括 161 次插入0 次删除
  1. 1 0
      package.json
  2. 10 0
      src/router/index.js
  3. 150 0
      src/views/new-plan/index.vue

+ 1 - 0
package.json

@@ -18,6 +18,7 @@
     "element-ui": "^2.13.0",
     "jsonwebtoken": "^8.5.1",
     "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',

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

@@ -0,0 +1,150 @@
+<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="120px" :reset="false">
+        <template #custom="{item,form}">
+          <template v-if="item.model == 'date'">
+            <el-date-picker v-model="form[item.model]" type="date" placeholder="选择择" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="pushDate">
+            </el-date-picker>
+          </template>
+          <template v-if="item.model == 'nodate'">
+            <data-table :fields="dateFields" :data="form[item.model]" :opera="dateOpera" @delete="toDateDelete" height="200px"></data-table>
+          </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',
+        },
+      ],
+      dateOpera: [
+        {
+          label: '删除',
+          icon: 'el-icon-delete',
+          method: 'delete',
+        },
+      ],
+      fields: [
+        { label: '年度', prop: 'year' },
+        { label: '标题', prop: 'title' },
+      ],
+      info: {},
+      form: {},
+      Ffields: [
+        { label: '年度', model: 'year', type: 'text' },
+        { label: '标题', model: 'title', type: 'text' },
+        { label: '请选择日期', model: 'date', custom: true },
+        { label: '请假日期表', model: 'nodate', custom: true },
+      ],
+      dateFields: [{ label: '日期', prop: 'date' }],
+      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 = { year, trainplanid: id, title, headteacherid: this.user.userid, nodate: [] };
+      this.$set(this, `info`, plan);
+      if (this.$checkRes(res)) {
+        if (res.data.length > 0) {
+          let nodate = res.data[0].nodate.map(i => {
+            return { date: i };
+          });
+          this.$set(this, `info`, { ...res.data[0], year, title, nodate });
+        }
+      }
+      this.dialog = true;
+    },
+    async handleSave({ data, isNew }) {
+      let res;
+      let msg;
+      let duplicate = JSON.parse(JSON.stringify(data));
+      duplicate.nodate = duplicate.nodate.map(i => i.date);
+      duplicate.daterange = JSON.stringify(duplicate.daterange);
+      if (isNew) {
+        //create
+        res = await this.dirCreatPlan(duplicate);
+        msg = '添加成功';
+      } else {
+        //update
+        res = await this.dirUpdatePlan(duplicate);
+        msg = '修改成功';
+      }
+      if (this.$checkRes(res, msg, res.errmsg || '操作失败')) {
+        this.handleClose();
+      }
+    },
+    handleClose() {
+      this.dialog = false;
+      this.info = { nodate: [] };
+    },
+    pushDate(date) {
+      if (!_.isArray(this.info.nodate)) {
+        this.info.nodate = [];
+      }
+      this.info.nodate.push({ date: JSON.parse(JSON.stringify(date)) });
+      this.info.nodate.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
+      this.info.date = '';
+    },
+    toDateDelete({ data, index }) {
+      this.info.nodate.splice(index, 1);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>