离校前端框架,包括数据字典、工作队伍、新闻公告模块
diff --git a/leave-school-vue/src/mock/schoolyear.js b/leave-school-vue/src/mock/schoolyear.js
new file mode 100644
index 0000000..7e37aa9
--- /dev/null
+++ b/leave-school-vue/src/mock/schoolyear.js
@@ -0,0 +1,70 @@
+import Mock from 'mockjs'
+import { param2Obj } from '@/utils'
+
+const schoolyearList = Mock.mock({
+ 'list|26': [{
+ 'id': '@increment',
+ 'xndm|1': ['2016', '2017', '2018'],
+ 'xnmc': '@xndm@cword(6, 15)'
+ }]
+}).list
+
+export default{
+ getList: config => {
+ const { xndm, xnmc, pageIndex = 1, pageSize = 20 } = param2Obj(config.url)
+ const mockList = schoolyearList.filter(item => {
+ if (xndm && item.xndm !== xndm) return false
+ if (xnmc && item.xnmc !== xnmc) return false
+ return true
+ })
+
+ const pageList = mockList.filter((item, index) => index < pageSize * pageIndex && index >= pageSize * (pageIndex - 1))
+ return {
+ items: pageList,
+ recordCount: mockList.length,
+ code: 200
+ }
+ },
+ getItem: config => {
+ const { id } = param2Obj(config.url)
+ const mockList = schoolyearList.filter(item => item.id + '' === id + '')
+ return {
+ data: mockList.length > 0 ? mockList[0] : null,
+ code: 200
+ }
+ },
+ createData: config => {
+ const schoolyear = JSON.parse(config.body)
+ if (!schoolyear.id) {
+ schoolyear.id = '' + parseInt(Math.random() * 100) + 1024 // mock a id
+ schoolyearList.unshift(schoolyear)
+ } else {
+ for (let i = 0; i < schoolyearList.length; i++) {
+ if (schoolyearList[i].id + '' === schoolyear.id + '') {
+ schoolyearList.splice(i, 1, schoolyear)
+ break
+ }
+ }
+ }
+ return {
+ item: schoolyear,
+ code: 200
+ }
+ },
+ deleteData: config => {
+ const schoolyear = JSON.parse(config.body)
+ let index = -1
+ for (let i = 0; i < schoolyearList.length; i++) {
+ if (schoolyearList[i].id + '' === schoolyear.id + '') {
+ index = i
+ break
+ }
+ }
+ if (index > -1) {
+ schoolyearList.splice(index, 1)
+ }
+ return {
+ code: 200
+ }
+ }
+}