当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
4 Star 10 Fork 3

万孝国 / 校友捐赠管理系统
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

项目介绍

项目启动

  • IDE: 我这里使用的vs-code
  • 导入后首先安装依赖
cnpm install
  • 启动项目
npm run serve
  • 生产阶段启动
npm run build
  • 使用eslint 检查
npm run lint

后台项目启动

  • 导入数据库adms.sql
  • 选择微服务或者单体应用版本
  • 打开浏览器输入 localhost 到后台系统登录页 默认是超级管理员账号

添加配置文件

  • 添加vue.config.js
  • 自定义html-webpack-plugin信息: 修改标题
  • options参考
module.exports = {
  // 修改或新增html-webpack-plugin的值,在index.html里面能读取htmlWebpackPlugin.options.title
  chainWebpack: config => {
    config.plugin('html')
      .tap(args => {
        args[0].title = '校友捐赠管理系统'
        return args
      })
  }
}

文件说明

  • assets: 放置静态资源文件
  • views: 放的<router-view/> 显示的视图页面
  • components: 放置模块所需要的组件
  • router: 放置路由
  • store: 放置vuex状态管理文件,并且单独写在一个文件,这里还没有进行模块管理,内容也不多
  • utils: 放置一些工具类
    • axiosUtil: 对axios的请求进行封装,并使用element-ui组件进行提示 并在 main.js 添加到原型上
    • checkUtil: 加入一些常用的校验规则, 包含手机号、邮箱、身份证号码
    • storageUtil: 使用浏览器的session、local存储信息
    • commonUtil: 通用工具类:判空
  • main.js: 入口文件
  • vue.config.js: webpack配置,标题,启动选项

登录

  • router/index.js 定义路由 并把'/'重定向 登录页
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login')
  },
  • 在router/index.js 添加路由守卫 , 对于本地未存储token 的路径访问强制跳转到 login
// 挂载路由导航守卫
router.beforeEach((to, from, next) => {
  // to 将要访问的路径
  // from 代表从哪个路径跳转而来
  // next 是一个函数,表示放行
  //     next()  放行    next('/login')  强制跳转
  if (to.path === '/login') return next()
  // 获取token
  const tokenStr = window.sessionStorage.getItem('token')
  if (!tokenStr) return next('/login')
  next()
})
  • axios 添加拦截器 在请求头里放入 token 值
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 在最后必须 return config
  return config
})
  • 登录成功后把token存储起来
window.sessionStorage.setItem('token', res.data.token)

使用props在父子组件传值

  • 在子组件 使用props来接收父组件传过来的值
      <el-breadcrumb-item>{{msg2}}</el-breadcrumb-item>

<script>
export default {
  props: ['msg1', 'msg2']
}
</script>
  • 在父组件 导入子组件并加载到组件中,使用时传参数时 对与非字符串和变量应使用数据绑定:
    <Breadcrumb msg1="基本信息管理" :msg2="常数类别列表" />

<script>
import Breadcrumb from '@/components/Breadcrumb'
export default {
   components: {
    Breadcrumb
  },
}
</script>

.sync 修饰符

  • 文档位置
  • 对于constant-type 和 edit.vue 组件
  • constant-type/index.vue
<el-dialog :title="title" :visible.sync="show" :close-on-click-modal="false" width="500px">
  <ConstantTypeEdit v-if="show" :show.sync="show" @getData="getData()" :editid="editid"></ConstantTypeEdit>
</el-dialog>
  • edit.vue
<script>
export default {
  name: 'ConstantTypeEdit',
  props: ['editid'],
  methods: {
    save () {
        // 方法表达对其赋新值  :show.sync="show" 修改父组件show = false
        this.$emit('update:show', false)
      }
    }
  }
}
</script>

vuex使用

  • 原理图 dR7KWd.png

  • 将vuex不同属性定义再不同的文件里,这里举一个左侧菜单栏的折叠功能

//state.js
export default {
  isCollapse: false
}
// 推荐把mutation里的方法采用变量定义,且将方法名定义到另外一个常量文件里 比如mutation-types.js
export const TOGGLE_COLLAPSE = 'toggleCollapse' // 折叠左侧菜单栏
// mutation.js
import { TOGGLE_COLLAPSE } from './mutation-types'

export default {
  [TOGGLE_COLLAPSE] (state) {
    state.isCollapse = !state.isCollapse
  }
}
// action

import { TOGGLE_COLLAPSE } from './mutation-types'

export default {
  toggle_collapse ({ commit }) {
    commit(TOGGLE_COLLAPSE)
  }
}
  • 在组件里的使用
  • Menu.vue
import { mapState } from 'vuex'

export default {
  /* 
  从 store 实例中读取状态最简单的方法就是在计算属性中返回某个状态
  当 状态 变化的时候, 都会重新求取计算属性,并且触发更新相关联的 DOM。
  获取方式一: this.$store.state.isCollapse  
  通过在根实例中注册 store 选项,该 store 实例会注入到根组件下的所有子组件中,且子组件能通过 this.$store 访问到。
  获取方式二: 使用 mapState 辅助函数帮助生成计算属性 并且使用了对象展开运算符 传对象的时候方便自己定义名称
  */
  computed: {
    ...mapState({
      isCollapse: 'isCollapse'
    })
  }
}
  • Home.vue
import { mapState, mapActions } from 'vuex'

export default {
  computed: {
    ...mapState({
      isCollapse: 'isCollapse'
    })
  },
  methods: {
    /*
   在组件中使用  this.$store.dispatch('xxx') 分发 action
    mapActions 是action的辅助函数 ,同时可以传数组,选择自己需要的action 函数
    */
    ...mapActions([
      'toggleCollapse'
    ])
  },
}

批量删除

  • 利用post方法
@Override
public boolean batchdel(Integer[] ids) {

    ConstantType constantType = new ConstantType();
    constantType.setActive(0);

    UpdateWrapper<ConstantType> wrapper = new UpdateWrapper<>();
    List<Integer> list = new ArrayList<>(ids.length);
    Collections.addAll(list,ids);
    wrapper.in("id",list);
    return this.update(constantType,wrapper);
}
  • 对于使用delete 方法 直接传参时 url为 http://127.0.0.1:8088/constantTypes/batchdel?ids[]=6 未对数据使用深度序列化,需要配置选择
  • 我采用字符串,分割的方式降低难度
batchdel () {
  if (this.selectedrow.length === 0) {
    this.$message('没有任何被选中的数据')
  } else {
    const ids = []
    for (let i = 0; i < this.selectedrow.length; i++) {
      ids.push(this.selectedrow[i].id)
    }
    this.$axios.del('/constantTypes/batchdel',
      () => {
        if (this.total === (this.queryInfo.page - 1) * this.queryInfo.limit + ids.length) this.queryInfo.page -= 1
        this.getData()
      },
      {
        ids: ids.join(',')
      }
    )
  }
},
  • 后端
@DeleteMapping("/batchdel")
public Result batchDel(@RequestParam String ids){
    String [] idList = ids.split(",");
    List<Integer> list = new ArrayList<>(idList.length);
    for (String id:idList){
        list.add(Integer.parseInt(id));
    }
    if(constantTypeService.removeByIds(list)) return ResultGenerator.getSuccessResult("","删除成功");
    return ResultGenerator.getFailResult("","删除失败");
}
  • 也可以使用mybatis-plus提供逻辑删除

表单添加自定义规则

data () {
    // name 必须唯一的
    var checkName = (rule, value, cb) => {
      // console.log(value)
      // value 传入的校验值
      const promise = this.$axios.http.get('/constantTypes/check', { params: { name: value } })
      promise.then(
        response => {
          if (response.data.status !== 200) {
            // 返回ERROR 表示 验证不符合要求
            cb(new Error('该常数类别代码存在'))
          }
          // 这是返回正确的
          cb()
        }
      )
    },
    rules: {
        code: [
          { required: true, message: '编码不能为空', trigger: 'blur' },
          { min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur' },
          { validator: checkName, trigger: 'blur' }
        ]
      }
    }
  }

ajax请求包axios

  • 对axios进行一些处理,包装一下

  • 定义自己的请求基路径axios.defaults.baseURL

  • 为了能够在全局使用把axios挂载到Vue函数对象的原型上Vue.prototype.$axios = axios,这样在组件里通过this.$axios访问

路径使用

  • ./指当前目录
  • ../指当前目录的上一层目录
  • vue的使用路径中的@代表“src目录”这个是webpack起的别名;在webpack.base.conf.js中有声明
  • extensions: 在导入语句没带文件后缀时,webpack会自动按照顺序添加后缀名查找
// 连接路径并返回
function resolve(dir) {
  return path.join(__dirname, '..', dir)
}

module.exports = {
  
  resolve: {
    // 在导入语句没带文件后缀时,webpack会自动按照顺序添加后缀名查找
    extensions: ['.js', '.vue', '.json'],
    // 配置别名
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      // 将项目根目录中,src的路径配置为别名@
      '@': resolve('src'),
    }
  }
}
  • 在webpack中有这个配置resolve.mainFiles: ["index"] 解析目录时要使用的文件名。
  • 根据上面说的() => import('@/views/constant-type') 以及实际项目情况对应的路径是 项目根路径/src/views/constant-type/index.vue
  • 在浏览器的中对'/home' 中/ 会解析为 协议://主机名:端口号/ 再拼接上home 作为路径

问题记录

  • 如果在删除的数据,当前页的数据刚好为删除数据的个数此时 应该修改当前页
this.$axios.del(`/constantTypes/${id}`, () => {
  if (this.total === (this.queryInfo.page - 1) * this.queryInfo.limit + 1) this.queryInfo.page -= 1
  this.getData()
})
  • element-ui select 下拉框位置错乱
<!-- 默认是插入到body -->
<el-select v-model="form.deptId" placeholder="请选择" :popper-append-to-body="false">
<!-- 添加自己样式 -->
<style scoped>
.el-select-dropdown {
  top: 38px !important;
  left: 0 !important;
}
</style>
  • 使用Steps步骤条和Tabs 选项卡组件的 使用 :active="parseInt(activeIndex)" 两者使用不同的类型

    • Steps active 是需要数值
    • Tab name 需要字符串
  • element-ui checkbox

    • 在这里需要显示所有的角色,向后台传角色的id,前台显示角色名称
    • :label 是向后台传送的值 显示的值应使用{{}} 不能true-labelfalse-label 指定相同的值,不然如何点击
<el-checkbox border
  v-for="(role, id) in roles"
  :key="id"
  :label="id"
>{{role.name}}</el-checkbox>

vscode插件推荐

vscode插件

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

校友捐赠管理系统前端仓库地址 展开 收起
JavaScript
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/wanxiaoguo/adms.git
git@gitee.com:wanxiaoguo/adms.git
wanxiaoguo
adms
校友捐赠管理系统
master

搜索帮助