离校前端框架,包括数据字典、工作队伍、新闻公告模块
diff --git a/leave-school-vue/src/mock/department.js b/leave-school-vue/src/mock/department.js
new file mode 100644
index 0000000..ce07f0b
--- /dev/null
+++ b/leave-school-vue/src/mock/department.js
@@ -0,0 +1,86 @@
+import Mock from 'mockjs'
+import { param2Obj, parseTime } from '@/utils'
+
+const deptList = Mock.mock({
+ 'list|26': [{
+ 'id': '@increment',
+ 'dwdm': '000@id',
+ 'dwmc': '@cword(6, 15)',
+ 'dwjc': '@cword(3, 5)',
+ 'dwywmc': '@word(6, 10)',
+ 'sfqy|1': ['启用', '未启用'],
+ 'sfqycode|1': ['1', '0'],
+ 'lbm|1': ['院系', '部门'],
+ 'lbmid|1': ['1', '2'],
+ 'cjsj': '@Date'
+ }]
+}).list
+
+export default{
+ getList: config => {
+ const { dwdm, dwmc, sfqy, lbm, pageIndex = 1, pageSize = 20 } = param2Obj(config.url)
+ const mockList = deptList.filter(item => {
+ if (dwdm && item.dwdm !== dwdm) return false
+ if (dwmc && item.dwmc !== dwmc) return false
+ if (sfqy && item.sfqycode !== sfqy) return false
+ if (lbm && item.lbmid !== lbm) 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
+ }
+ },
+ getAllList: config => {
+ return {
+ items: deptList,
+ code: 200
+ }
+ },
+ getItem: config => {
+ const { id } = param2Obj(config.url)
+ const mockList = deptList.filter(item => item.id + '' === id + '')
+ return {
+ data: mockList.length > 0 ? mockList[0] : null,
+ code: 200
+ }
+ },
+ createData: config => {
+ const dept = JSON.parse(config.body)
+ dept.cjsj = parseTime(new Date(), '{y}-{m}-{d}')
+ if (!dept.id) {
+ dept.id = '' + parseInt(Math.random() * 100) + 1024 // mock a id
+ deptList.unshift(dept)
+ } else {
+ for (let i = 0; i < deptList.length; i++) {
+ if (deptList[i].id + '' === dept.id + '') {
+ deptList.splice(i, 1, dept)
+ break
+ }
+ }
+ }
+ return {
+ item: dept,
+ code: 200
+ }
+ },
+ deleteData: config => {
+ const dept = JSON.parse(config.body)
+ let index = -1
+ for (let i = 0; i < deptList.length; i++) {
+ if (deptList[i].id + '' === dept.id + '') {
+ index = i
+ break
+ }
+ }
+ if (index > -1) {
+ deptList.splice(index, 1)
+ }
+ return {
+ code: 200
+ }
+ }
+}