离校前端框架,包括数据字典、工作队伍、新闻公告模块
diff --git a/leave-school-vue/src/mock/rostersyncinterface.js b/leave-school-vue/src/mock/rostersyncinterface.js
new file mode 100644
index 0000000..3a7259c
--- /dev/null
+++ b/leave-school-vue/src/mock/rostersyncinterface.js
@@ -0,0 +1,76 @@
+import Mock from 'mockjs'
+import { param2Obj } from '@/utils'
+
+const rostersyncinterfaceList = Mock.mock({
+ 'list|50': [{
+ 'id': '@increment',
+ 'dm': '@word(4)',
+ 'mc': '@cword(6, 15)',
+ 'tj': '@word(15)',
+ 'px': '@word(15)',
+ 'gglx': '@word(15)'
+ }]
+}).list
+
+export default{
+ getList: config => {
+ const { dm, mc, tj, px, gglx, pageIndex = 1, pageSize = 20 } = param2Obj(config.url)
+ const mockList = rostersyncinterfaceList.filter(item => {
+ if (dm && item.dm !== dm) return false
+ if (mc && item.mc !== mc) return false
+ if (tj && item.tj !== tj) return false
+ if (px && item.px !== px) return false
+ if (gglx && item.gglx !== gglx) 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 = rostersyncinterfaceList.filter(item => item.id + '' === id + '')
+ return {
+ data: mockList.length > 0 ? mockList[0] : null,
+ code: 200
+ }
+ },
+ createData: config => {
+ const rostersyncinterface = JSON.parse(config.body)
+ if (!rostersyncinterface.id) {
+ rostersyncinterface.id = '' + parseInt(Math.random() * 100) + 1024 // mock a id
+ rostersyncinterfaceList.unshift(rostersyncinterface)
+ } else {
+ for (let i = 0; i < rostersyncinterfaceList.length; i++) {
+ if (rostersyncinterfaceList[i].id + '' === rostersyncinterface.id + '') {
+ rostersyncinterfaceList.splice(i, 1, rostersyncinterface)
+ break
+ }
+ }
+ }
+ return {
+ item: rostersyncinterface,
+ code: 200
+ }
+ },
+ deleteData: config => {
+ const rostersyncinterface = JSON.parse(config.body)
+ let index = -1
+ for (let i = 0; i < rostersyncinterfaceList.length; i++) {
+ if (rostersyncinterfaceList[i].id + '' === rostersyncinterface.id + '') {
+ index = i
+ break
+ }
+ }
+ if (index > -1) {
+ rostersyncinterfaceList.splice(index, 1)
+ }
+ return {
+ code: 200
+ }
+ }
+}