guhongwei пре 3 година
родитељ
комит
16bc2bd581

+ 5 - 1
java代码/ruoyi-ui/src/store/index.js

@@ -9,6 +9,9 @@ import getters from './getters'
 import role_relation from './role_relation'
 import merits_user from './merits_user'
 import template from './template'
+import merits_apply from "./merits_apply"
+
+;
 Vue.use(Vuex)
 
 const store = new Vuex.Store({
@@ -20,7 +23,8 @@ const store = new Vuex.Store({
     settings,
     role_relation,
     merits_user,
-    template
+    template,
+    merits_apply
   },
   getters,
   name: false

+ 40 - 0
java代码/ruoyi-ui/src/store/merits_apply.js

@@ -0,0 +1,40 @@
+import Vue from "vue";
+import Vuex from "vuex";
+import _ from "lodash";
+Vue.use(Vuex);
+const api = {
+  interface: `/labelAchievement/api/apply`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = null, ...info } = {}) {
+    const res = await this.$axios.$get(api.interface, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.interface}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.interface}/${id}`, {
+      ...info,
+    });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 145 - 0
java代码/ruoyi-ui/src/views/merits/apply/form-frame.vue

@@ -0,0 +1,145 @@
+<template>
+  <div id="form-frame">
+    <el-row>
+      <el-col :span="24" class="formMain">
+        <el-col :span="24" class="one">
+          <el-button
+            type="primary"
+            plain
+            icon="el-icon-back"
+            size="mini"
+            @click="toBack"
+            >返回</el-button
+          ></el-col
+        >
+        <el-col :span="24" class="two">
+          <el-form :model="form" :rules="rules" ref="form" label-width="100px">
+            <el-form-item label="申请年度" prop="apply_year">
+              <el-input
+                v-model="form.apply_year"
+                placeholder="请输入申请年度"
+              ></el-input>
+            </el-form-item>
+            <el-col :span="24" class="btn">
+              <el-button type="primary" @click="onSubmit('form')"
+                >提交保存</el-button
+              >
+              <el-button type="warning" @click="onDraft()">保存草稿</el-button>
+              <el-button @click="onReset('form')">重置信息</el-button>
+            </el-col>
+          </el-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, mapGetters, createNamespacedHelpers } from "vuex";
+const { mapActions: merits_apply } = createNamespacedHelpers("merits_apply");
+export default {
+  name: "form-frame",
+  props: {
+    id: { type: String },
+  },
+  components: {},
+  data: function () {
+    return {
+      form: {},
+      rules: {
+        apply_year: [
+          { required: true, message: "请输入申请年度", trigger: "blur" },
+        ],
+      },
+    };
+  },
+  created() {
+    this.$set(this, `form`, { user_id: this.user_id, user_name: this.name });
+  },
+  methods: {
+    ...merits_apply(["fetch", "create", "update"]),
+    // 返回
+    toBack() {
+      this.$emit("toBack");
+    },
+    // 提交保存
+    onSubmit(formName) {
+      this.$refs[formName].validate(async (valid) => {
+        if (valid) {
+          let data = this.form;
+          data.status = "1";
+          let res;
+          if (data.id) res = await this.update(data);
+          else res = await this.create(data);
+          if (res.code === 200) {
+            this.$message({ type: `success`, message: res.msg });
+            this.toBack();
+          } else {
+            this.$message({ type: `error`, message: res.msg });
+          }
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+    // 保存草稿
+    async onDraft() {
+      let data = this.form;
+      let res;
+      if (data.id) res = await this.update(data);
+      else res = await this.create(data);
+      if (res.code === 200) {
+        this.$message({ type: `success`, message: res.msg });
+        this.toBack();
+      } else {
+        this.$message({ type: `error`, message: res.msg });
+      }
+    },
+    // 查看详情
+    async searchInfo(id) {
+      let res = await this.fetch(id);
+      if (res.code === 200) {
+        this.$set(this, `form`, res.data);
+      } else {
+        this.$message({ type: `error`, message: res.msg });
+      }
+    },
+    // 重置信息
+    onReset(formName) {
+      this.$refs[formName].resetFields();
+    },
+  },
+  computed: {
+    ...mapGetters(["user_id", "name"]),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    id: {
+      deep: true,
+      immediate: true,
+      handler(val) {
+        if (val) this.searchInfo(val);
+      },
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.formMain {
+  .one {
+    margin: 0 0 10px 0;
+  }
+  .two {
+    border: 1px solid #ccc;
+    padding: 10px;
+    .btn {
+      text-align: center;
+      margin: 10px 0 0 0;
+    }
+  }
+}
+</style>

+ 43 - 20
java代码/ruoyi-ui/src/views/merits/apply/index.vue

@@ -2,34 +2,57 @@
   <div id="index">
     <el-row>
       <el-col :span="24" class="main">
-        <el-col :span='24' class="one">
-          查询
-        </el-col>
-        <el-col :span='24' class="two">
-          
-          <el-button type='primary'>添加</el-button>
-        </el-col>
-        <el-col :span='24' class="thr">
-          列表
-        </el-col>
+        <list-frame
+          v-if="onShow == '1'"
+          @toAdd="toAdd"
+          @toEdit="toEdit"
+        ></list-frame>
+        <form-frame
+          v-else-if="onShow == '2'"
+          @toBack="toBack"
+          :id="id"
+        ></form-frame>
       </el-col>
     </el-row>
   </div>
 </template>
 
 <script>
-import { mapState, createNamespacedHelpers } from 'vuex';
+import listFrame from "./list-frame.vue";
+import formFrame from "./form-frame.vue";
+import { mapState, mapGetters, createNamespacedHelpers } from "vuex";
 export default {
-  name: 'index',
+  name: "index",
   props: {},
-  components: {},
+  components: {
+    listFrame,
+    formFrame,
+  },
   data: function () {
-    return {};
+    return {
+      // 显示
+      onShow: "1",
+      id: "",
+    };
+  },
+  async created() {},
+  methods: {
+    // 新增
+    toAdd() {
+      this.$set(this, `onShow`, "2");
+    },
+    // 修改
+    toEdit(data) {
+      this.$set(this, `id`, data._id);
+      this.$set(this, `onShow`, "2");
+    },
+    // 返回
+    toBack() {
+      this.$set(this, `onShow`, "1");
+    },
   },
-  created() {},
-  methods: {},
   computed: {
-    ...mapState(['user']),
+    ...mapGetters(["user_id"]),
   },
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -44,8 +67,8 @@ export default {
 };
 </script>
 
-<style lang="scss" scoped>
-.main{
-   padding: 25px 30px 30px;
+<style lang="less" scoped>
+.main {
+  padding: 25px 30px 30px;
 }
 </style>

+ 131 - 0
java代码/ruoyi-ui/src/views/merits/apply/list-frame.vue

@@ -0,0 +1,131 @@
+<template>
+  <div id="list-frame">
+    <el-row>
+      <el-col :span="24" class="listMain">
+        <el-col :span="24" class="one">
+          <data-table
+            :fields="fields"
+            :opera="opera"
+            :total="total"
+            :data="list"
+            @query="search"
+            @toView="toView"
+            @toEdit="toEdit"
+            @toCheck="toCheck"
+          >
+            <template #selfbtn>
+              <el-button type="primary" size="mini" @click="toAdd"
+                >添加</el-button
+              >
+            </template>
+          </data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import dataTable from "@/components/free/filter-page-table.vue";
+import { mapState, mapGetters, createNamespacedHelpers } from "vuex";
+const { mapActions: merits_apply } = createNamespacedHelpers("merits_apply");
+export default {
+  name: "list-frame",
+  props: {},
+  components: { dataTable },
+  data: function () {
+    return {
+      list: [],
+      total: 0,
+      fields: [
+        { label: "用户名称", prop: "user_name", filter: true },
+        { label: "申请年度", prop: "apply_year" },
+        {
+          label: "申报状态",
+          prop: "status",
+          format: (i) =>
+            i == "0"
+              ? "草稿"
+              : i == "1"
+              ? "待审中"
+              : i == "2"
+              ? "审核通过"
+              : i == "3"
+              ? "审核拒绝"
+              : "",
+        },
+      ],
+      opera: [
+        {
+          label: "查看",
+          method: "toView",
+        },
+        {
+          label: "修改",
+          method: "toEdit",
+          display: (i) => i.status == "0",
+        },
+        {
+          label: "提交",
+          method: "success",
+          display: (i) => i.status == "0",
+        },
+      ],
+    };
+  },
+  async created() {
+    await this.search();
+  },
+  methods: {
+    ...merits_apply(["query", "update"]),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      info.user_id = this.user_id;
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    // 新增
+    toAdd() {
+      this.$emit("toAdd");
+    },
+    // 查看信息
+    toView({ data }) {
+      console.log(data);
+    },
+    // 修改信息
+    toEdit({ data }) {
+      this.$emit("toEdit", data);
+    },
+    // 提交审核
+    async toCheck({ data }) {
+      let res = await this.update({ id: data._id, status: "1" });
+      if (res.code === 200) {
+        this.$message({ type: `success`, message: res.msg });
+      } else {
+        this.$message({
+          type: `error`,
+          message: res.msg || res.errmsg + ":" + res.details,
+        });
+      }
+      this.search();
+    },
+  },
+  computed: {
+    ...mapGetters(["user_id"]),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>