nsgm-cli 1.0.26 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +13 -0
- package/LICENSE +201 -201
- package/README.md +161 -162
- package/client/layout/index.tsx +245 -0
- package/client/redux/reducers.ts +5 -0
- package/{generation/client → client}/redux/store.ts +50 -44
- package/{generation/client → client}/redux/template/manage/actions.ts +190 -190
- package/{generation/client → client}/redux/template/manage/reducers.ts +118 -118
- package/{generation/client → client}/redux/template/manage/types.ts +24 -24
- package/client/service/template/manage.ts +97 -0
- package/{generation/client → client}/styled/common.ts +27 -28
- package/client/styled/layout/index.ts +26 -0
- package/{generation/client → client}/styled/template/manage.ts +51 -51
- package/client/utils/common.ts +86 -0
- package/client/utils/cookie.ts +52 -0
- package/{generation/client → client}/utils/fetch.ts +25 -25
- package/client/utils/menu.tsx +27 -0
- package/generation/.DS_Store +0 -0
- package/generation/.babelrc +3 -2
- package/generation/README.md +19 -18
- package/generation/app.js +2 -2
- package/generation/client/redux/reducers.ts +5 -5
- package/generation/client/utils/menu.tsx +27 -26
- package/generation/gitignore +5 -4
- package/generation/mysql.config.js +13 -12
- package/generation/next.config.js +6 -6
- package/generation/package.json +25 -20
- package/generation/project.config.js +12 -12
- package/generation/server/rest.js +20 -20
- package/generation/server/utils/common.js +7 -0
- package/generation/tsconfig.json +30 -29
- package/index.js +10 -10
- package/lib/args.d.ts +6 -6
- package/lib/args.js +47 -47
- package/lib/generate.d.ts +3 -3
- package/lib/generate.js +735 -590
- package/lib/index.d.ts +2 -2
- package/lib/index.js +259 -182
- package/lib/server/db.d.ts +5 -5
- package/lib/server/db.js +110 -47
- package/lib/server/graphql.d.ts +7 -7
- package/lib/server/graphql.js +119 -119
- package/lib/server/plugins/date.d.ts +5 -5
- package/lib/server/plugins/date.js +16 -16
- package/lib/tsconfig.build.tsbuildinfo +1 -0
- package/mysql.config.js +14 -14
- package/next-env.d.ts +6 -0
- package/next.config.js +194 -174
- package/package.json +125 -113
- package/{generation/pages → pages}/_app.tsx +44 -44
- package/{generation/pages → pages}/_document.tsx +4 -2
- package/pages/index.tsx +68 -0
- package/{generation/pages → pages}/template/manage.tsx +278 -280
- package/project.config.js +14 -14
- package/public/slbhealthcheck.html +10 -0
- package/scripts/shutdown.sh +10 -0
- package/scripts/startup.sh +35 -0
- package/{generation/server → server}/apis/template.js +17 -18
- package/{generation/server → server}/modules/template/resolver.js +29 -35
- package/{generation/server → server}/modules/template/schema.js +33 -33
- package/server/rest.js +20 -0
- package/{generation/server → server}/sql/template.sql +8 -8
- package/server/utils/common.js +7 -0
- package/generation/client/layout/index.tsx +0 -223
- package/generation/client/service/template/manage.ts +0 -74
- package/generation/client/styled/layout/index.ts +0 -14
- package/generation/client/utils/common.ts +0 -45
- package/generation/next-env.d.ts +0 -2
- package/generation/pages/index.tsx +0 -55
- /package/{generation/public → public}/images/zhizuotu_1.png +0 -0
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
const express = require('express')
|
|
2
|
-
const XLSX = require('xlsx')
|
|
3
|
-
const { templateBatchAdd } = require('../modules/template/resolver')
|
|
4
|
-
const router = express.Router()
|
|
5
|
-
|
|
6
|
-
router.post('/import', (req, res) => {
|
|
7
|
-
//console.log('files', req.files)
|
|
8
|
-
const workbook = XLSX.read(req.files.file.data, { type: "buffer" })
|
|
9
|
-
//console.log('Sheets', workbook.Sheets)
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
const express = require('express')
|
|
2
|
+
const XLSX = require('xlsx')
|
|
3
|
+
const { templateBatchAdd } = require('../modules/template/resolver')
|
|
4
|
+
const router = express.Router()
|
|
5
|
+
|
|
6
|
+
router.post('/import', (req, res) => {
|
|
7
|
+
//console.log('files', req.files)
|
|
8
|
+
const workbook = XLSX.read(req.files.file.data, { type: "buffer" })
|
|
9
|
+
//console.log('Sheets', workbook.Sheets)
|
|
10
|
+
|
|
11
|
+
const datas = XLSX.utils.sheet_to_json(workbook.Sheets["Template"])
|
|
12
|
+
//console.log('datas', datas)
|
|
13
|
+
|
|
14
|
+
templateBatchAdd({ datas })
|
|
15
|
+
res.json({ name: 'Template' })
|
|
16
|
+
})
|
|
17
|
+
|
|
19
18
|
module.exports = router
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { getConnection } = require('../../utils/common')
|
|
2
2
|
const _ = require('lodash')
|
|
3
3
|
|
|
4
|
-
const { getConnection } = serverDB
|
|
5
|
-
|
|
6
4
|
module.exports = {
|
|
7
5
|
template: ({ page = 0, pageSize = 10 }) => {
|
|
8
6
|
return new Promise((resolve, reject)=>{
|
|
@@ -11,16 +9,16 @@ module.exports = {
|
|
|
11
9
|
const countSql = 'SELECT count(*) as counts from template'
|
|
12
10
|
const values = [pageSize, page * pageSize]
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
console.log('sql', sql, values, countSql)
|
|
15
13
|
|
|
16
14
|
connection.query(sql, values, (error, results, fields) => {
|
|
17
15
|
if (error) throw error
|
|
18
|
-
|
|
16
|
+
console.log('results', results)
|
|
19
17
|
|
|
20
18
|
connection.query(countSql, (countError, countResults, countFields) => {
|
|
21
19
|
if (countError) throw countError
|
|
22
20
|
const totalCounts = countResults[0].counts
|
|
23
|
-
|
|
21
|
+
console.log('totalCounts', totalCounts)
|
|
24
22
|
|
|
25
23
|
resolve({
|
|
26
24
|
totalCounts,
|
|
@@ -33,7 +31,7 @@ module.exports = {
|
|
|
33
31
|
})
|
|
34
32
|
},
|
|
35
33
|
templateGet: ({ id }) => {
|
|
36
|
-
|
|
34
|
+
console.log('templateGet', id)
|
|
37
35
|
return new Promise((resolve, reject)=>{
|
|
38
36
|
getConnection().then((connection)=>{
|
|
39
37
|
let sql = 'SELECT id, name from template WHERE 1=1'
|
|
@@ -44,10 +42,10 @@ module.exports = {
|
|
|
44
42
|
values.push(id)
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
console.log('sql', sql, values)
|
|
48
46
|
connection.query(sql, values, (error, results, fields) => {
|
|
49
47
|
if (error) throw error
|
|
50
|
-
|
|
48
|
+
console.log('results', results)
|
|
51
49
|
|
|
52
50
|
if(results.length > 0)
|
|
53
51
|
resolve(results[0])
|
|
@@ -59,7 +57,7 @@ module.exports = {
|
|
|
59
57
|
})
|
|
60
58
|
},
|
|
61
59
|
templateSearch: ({ page = 0, pageSize = 10, data }) => {
|
|
62
|
-
|
|
60
|
+
console.log('templateSearch', page, pageSize, data)
|
|
63
61
|
const { name } = data
|
|
64
62
|
return new Promise((resolve, reject)=>{
|
|
65
63
|
getConnection().then((connection)=>{
|
|
@@ -79,16 +77,16 @@ module.exports = {
|
|
|
79
77
|
values.push(pageSize)
|
|
80
78
|
values.push(page * pageSize)
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
console.log('sql', sql, values, countSql)
|
|
83
81
|
|
|
84
82
|
connection.query(sql, values, (error, results, fields) => {
|
|
85
83
|
if (error) throw error
|
|
86
|
-
|
|
84
|
+
console.log('results', results)
|
|
87
85
|
|
|
88
86
|
connection.query(countSql, countsValues, (countError, countResults, countFields) => {
|
|
89
87
|
if (countError) throw countError
|
|
90
88
|
const totalCounts = countResults[0].counts
|
|
91
|
-
|
|
89
|
+
console.log('totalCounts', totalCounts)
|
|
92
90
|
|
|
93
91
|
resolve({
|
|
94
92
|
totalCounts,
|
|
@@ -101,7 +99,7 @@ module.exports = {
|
|
|
101
99
|
})
|
|
102
100
|
},
|
|
103
101
|
templateAdd: ({ data }) => {
|
|
104
|
-
|
|
102
|
+
console.log('templateAdd', data)
|
|
105
103
|
const { name } = data
|
|
106
104
|
return new Promise((resolve, reject)=>{
|
|
107
105
|
getConnection().then((connection)=>{
|
|
@@ -109,10 +107,10 @@ module.exports = {
|
|
|
109
107
|
let sql = 'INSERT INTO template (name) values (?)'
|
|
110
108
|
let values = [name]
|
|
111
109
|
|
|
112
|
-
|
|
110
|
+
console.log('sql', sql, values)
|
|
113
111
|
connection.query(sql, values, (error, results, fields) => {
|
|
114
112
|
if (error) throw error
|
|
115
|
-
|
|
113
|
+
console.log('results', results)
|
|
116
114
|
|
|
117
115
|
resolve(results.insertId)
|
|
118
116
|
connection.end()
|
|
@@ -121,7 +119,7 @@ module.exports = {
|
|
|
121
119
|
})
|
|
122
120
|
},
|
|
123
121
|
templateBatchAdd: ({ datas }) => {
|
|
124
|
-
|
|
122
|
+
console.log('templateBatchAdd', datas)
|
|
125
123
|
return new Promise((resolve, reject)=>{
|
|
126
124
|
getConnection().then((connection)=>{
|
|
127
125
|
|
|
@@ -136,10 +134,10 @@ module.exports = {
|
|
|
136
134
|
|
|
137
135
|
sql = sql.substring(0, sql.length - 1)
|
|
138
136
|
|
|
139
|
-
|
|
137
|
+
console.log('sql', sql, values)
|
|
140
138
|
connection.query(sql, values, (error, results, fields) => {
|
|
141
139
|
if (error) throw error
|
|
142
|
-
|
|
140
|
+
console.log('results', results)
|
|
143
141
|
|
|
144
142
|
resolve(results.insertId)
|
|
145
143
|
connection.end()
|
|
@@ -148,7 +146,7 @@ module.exports = {
|
|
|
148
146
|
})
|
|
149
147
|
},
|
|
150
148
|
templateUpdate: ({ id, data }) => {
|
|
151
|
-
|
|
149
|
+
console.log('templateUpdate', id, data)
|
|
152
150
|
const { name } = data
|
|
153
151
|
return new Promise((resolve, reject)=>{
|
|
154
152
|
getConnection().then((connection)=>{
|
|
@@ -156,22 +154,18 @@ module.exports = {
|
|
|
156
154
|
let values = []
|
|
157
155
|
|
|
158
156
|
if(name !== undefined){
|
|
159
|
-
sql += ' name
|
|
157
|
+
sql += ' name=?, '
|
|
160
158
|
values.push(name)
|
|
161
159
|
}
|
|
162
160
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
values.push(id)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
sql += ' WHERE id=? '
|
|
161
|
+
sql += ' id=? WHERE id=? '
|
|
162
|
+
values.push(id)
|
|
169
163
|
values.push(id)
|
|
170
164
|
|
|
171
|
-
|
|
165
|
+
console.log('sql', sql, values)
|
|
172
166
|
connection.query(sql, values, (error, results, fields) => {
|
|
173
167
|
if (error) throw error
|
|
174
|
-
|
|
168
|
+
console.log('results', results)
|
|
175
169
|
|
|
176
170
|
resolve(true)
|
|
177
171
|
connection.end()
|
|
@@ -180,16 +174,16 @@ module.exports = {
|
|
|
180
174
|
})
|
|
181
175
|
},
|
|
182
176
|
templateDelete: ({ id }) => {
|
|
183
|
-
|
|
177
|
+
console.log('templateDelete', id)
|
|
184
178
|
return new Promise((resolve, reject)=>{
|
|
185
179
|
getConnection().then((connection)=>{
|
|
186
180
|
const sql = 'DELETE FROM template WHERE id=?'
|
|
187
181
|
const values = [id]
|
|
188
|
-
|
|
182
|
+
console.log('sql', sql, values)
|
|
189
183
|
|
|
190
184
|
connection.query(sql, values, (error, results, fields) => {
|
|
191
185
|
if (error) throw error
|
|
192
|
-
|
|
186
|
+
console.log('results', results)
|
|
193
187
|
|
|
194
188
|
resolve(true)
|
|
195
189
|
connection.end()
|
|
@@ -198,7 +192,7 @@ module.exports = {
|
|
|
198
192
|
})
|
|
199
193
|
},
|
|
200
194
|
templateBatchDelete: ({ ids }) => {
|
|
201
|
-
|
|
195
|
+
console.log('templateBatchDelete', ids)
|
|
202
196
|
return new Promise((resolve, reject)=>{
|
|
203
197
|
getConnection().then((connection)=>{
|
|
204
198
|
let sql = 'DELETE FROM template WHERE id in ('
|
|
@@ -214,11 +208,11 @@ module.exports = {
|
|
|
214
208
|
sql += ')'
|
|
215
209
|
|
|
216
210
|
const values = ids
|
|
217
|
-
|
|
211
|
+
console.log('sql', sql, values)
|
|
218
212
|
|
|
219
213
|
connection.query(sql, values, (error, results, fields) => {
|
|
220
214
|
if (error) throw error
|
|
221
|
-
|
|
215
|
+
console.log('results', results)
|
|
222
216
|
|
|
223
217
|
resolve(true)
|
|
224
218
|
connection.end()
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
query: `
|
|
3
|
-
template(page: Int, pageSize: Int): Templates
|
|
4
|
-
templateGet(id: Int): Template
|
|
5
|
-
templateSearch(page: Int, pageSize: Int, data: TemplateSearchInput): Templates
|
|
6
|
-
`,
|
|
7
|
-
mutation: `
|
|
8
|
-
templateAdd(data: TemplateAddInput): Int
|
|
9
|
-
templateBatchAdd(datas: [TemplateAddInput]): Int
|
|
10
|
-
templateUpdate(id: Int, data: TemplateAddInput): Boolean
|
|
11
|
-
templateDelete(id: Int): Boolean
|
|
12
|
-
templateBatchDelete(ids: [Int]): Boolean
|
|
13
|
-
`,
|
|
14
|
-
subscription: ``,
|
|
15
|
-
type: `
|
|
16
|
-
type Template {
|
|
17
|
-
id: Int
|
|
18
|
-
name: String
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type Templates {
|
|
22
|
-
totalCounts: Int
|
|
23
|
-
items: [Template]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
input TemplateAddInput {
|
|
27
|
-
name: String
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
input TemplateSearchInput {
|
|
31
|
-
name: String
|
|
32
|
-
}
|
|
33
|
-
`
|
|
1
|
+
module.exports = {
|
|
2
|
+
query: `
|
|
3
|
+
template(page: Int, pageSize: Int): Templates
|
|
4
|
+
templateGet(id: Int): Template
|
|
5
|
+
templateSearch(page: Int, pageSize: Int, data: TemplateSearchInput): Templates
|
|
6
|
+
`,
|
|
7
|
+
mutation: `
|
|
8
|
+
templateAdd(data: TemplateAddInput): Int
|
|
9
|
+
templateBatchAdd(datas: [TemplateAddInput]): Int
|
|
10
|
+
templateUpdate(id: Int, data: TemplateAddInput): Boolean
|
|
11
|
+
templateDelete(id: Int): Boolean
|
|
12
|
+
templateBatchDelete(ids: [Int]): Boolean
|
|
13
|
+
`,
|
|
14
|
+
subscription: ``,
|
|
15
|
+
type: `
|
|
16
|
+
type Template {
|
|
17
|
+
id: Int
|
|
18
|
+
name: String
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Templates {
|
|
22
|
+
totalCounts: Int
|
|
23
|
+
items: [Template]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
input TemplateAddInput {
|
|
27
|
+
name: String
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
input TemplateSearchInput {
|
|
31
|
+
name: String
|
|
32
|
+
}
|
|
33
|
+
`
|
|
34
34
|
}
|
package/server/rest.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const express = require('express')
|
|
2
|
+
const moment = require('moment')
|
|
3
|
+
const template = require('./apis/template')
|
|
4
|
+
|
|
5
|
+
const router = express.Router()
|
|
6
|
+
|
|
7
|
+
router.use((req, res, next) => {
|
|
8
|
+
const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl
|
|
9
|
+
console.log(moment().format('YYYY-MM-DD HH:mm:ss') + ' ' + fullUrl)
|
|
10
|
+
next()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
router.use('/template', template)
|
|
14
|
+
|
|
15
|
+
router.get('/*', (req, res) => {
|
|
16
|
+
res.statusCode = 200
|
|
17
|
+
res.json({ name: 'REST' })
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
module.exports = router
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
use crm_demo;
|
|
2
|
-
|
|
3
|
-
CREATE TABLE `template` (
|
|
4
|
-
`id` integer NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
5
|
-
`name` varchar(100) DEFAULT '' COMMENT '名称',
|
|
6
|
-
`create_date` TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
|
|
7
|
-
`update_date` TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
|
|
8
|
-
PRIMARY KEY (`id`)
|
|
1
|
+
use crm_demo;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE `template` (
|
|
4
|
+
`id` integer NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
5
|
+
`name` varchar(100) DEFAULT '' COMMENT '名称',
|
|
6
|
+
`create_date` TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
|
|
7
|
+
`update_date` TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '更新时间',
|
|
8
|
+
PRIMARY KEY (`id`)
|
|
9
9
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { Layout, Menu, Breadcrumb, Image } from 'antd'
|
|
3
|
-
import { Container } from '../styled/layout'
|
|
4
|
-
import { useRouter } from 'next/router'
|
|
5
|
-
import _ from 'lodash'
|
|
6
|
-
import menuConfig from '../utils/menu'
|
|
7
|
-
|
|
8
|
-
const { SubMenu } = Menu
|
|
9
|
-
const { Header, Content, Sider } = Layout
|
|
10
|
-
|
|
11
|
-
const getLocationKey = () => {
|
|
12
|
-
const result = {
|
|
13
|
-
topMenu: '1',
|
|
14
|
-
slideMenu: '0'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof window !== 'undefined') {
|
|
18
|
-
const locationHref = window.location.href
|
|
19
|
-
|
|
20
|
-
let locationHrefArr = locationHref.split('?')
|
|
21
|
-
if (locationHrefArr.length > 0) {
|
|
22
|
-
locationHrefArr = locationHrefArr[0].split('//')
|
|
23
|
-
|
|
24
|
-
if (locationHrefArr.length > 1) {
|
|
25
|
-
let locationStr = locationHrefArr[1]
|
|
26
|
-
const locationIndex = locationStr.indexOf('/')
|
|
27
|
-
locationStr = locationStr.substring(locationIndex)
|
|
28
|
-
|
|
29
|
-
console.log('locationStr', locationStr)
|
|
30
|
-
|
|
31
|
-
_.each(menuConfig, (item:any, index:any) => {
|
|
32
|
-
const { key, url, subMenus } = item
|
|
33
|
-
|
|
34
|
-
if (subMenus) {
|
|
35
|
-
_.each(subMenus, (subItem:any, subIndex:any) => {
|
|
36
|
-
const { key: subKey, url: subUrl } = subItem
|
|
37
|
-
|
|
38
|
-
if (locationStr === subUrl.split('?')[0]) {
|
|
39
|
-
const subKeyArr = subKey.split('_')
|
|
40
|
-
const subKeyArrLen = subKeyArr.length
|
|
41
|
-
|
|
42
|
-
if (subKeyArrLen > 0) result.topMenu = subKeyArr[0]
|
|
43
|
-
if (subKeyArrLen > 1) result.slideMenu = subKeyArr[1]
|
|
44
|
-
|
|
45
|
-
return false
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
} else {
|
|
49
|
-
if (locationStr === url.split('?')[0]) {
|
|
50
|
-
result.topMenu = key
|
|
51
|
-
return false
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
console.log('result', result)
|
|
59
|
-
return result
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const routerPush = (router: any, url: string) => {
|
|
63
|
-
console.log('routerPush', url)
|
|
64
|
-
|
|
65
|
-
if (router && url) {
|
|
66
|
-
router.push(url)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const LayoutComponent = ({ children }) => {
|
|
71
|
-
const router = useRouter()
|
|
72
|
-
const [topMenuKey, setTopMenuKey] = useState('1')
|
|
73
|
-
const [sliderMenuKey, setSliderMenuKey] = useState('1')
|
|
74
|
-
|
|
75
|
-
console.log('topMenuKey: ' + topMenuKey, ', sliderMenuKey: ' + sliderMenuKey)
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
const { topMenu, slideMenu } = getLocationKey()
|
|
79
|
-
setTopMenuKey(topMenu)
|
|
80
|
-
setSliderMenuKey(slideMenu)
|
|
81
|
-
}, [])
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<Layout>
|
|
85
|
-
<Container>
|
|
86
|
-
<Header className="header">
|
|
87
|
-
<div className="logo">
|
|
88
|
-
<Image width={100} src="../images/zhizuotu_1.png" preview={false} />
|
|
89
|
-
</div>
|
|
90
|
-
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['1']} selectedKeys={[topMenuKey]}>
|
|
91
|
-
{_.map(menuConfig, (item:any, index:any) => {
|
|
92
|
-
const { key, text, url, subMenus } = item
|
|
93
|
-
if (key) {
|
|
94
|
-
return (
|
|
95
|
-
<Menu.Item
|
|
96
|
-
key={key}
|
|
97
|
-
onClick={() => {
|
|
98
|
-
routerPush(router, url)
|
|
99
|
-
setTopMenuKey(key)
|
|
100
|
-
|
|
101
|
-
if (subMenus) {
|
|
102
|
-
setSliderMenuKey('1')
|
|
103
|
-
} else {
|
|
104
|
-
setSliderMenuKey('0')
|
|
105
|
-
}
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
{text}
|
|
109
|
-
</Menu.Item>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
})}
|
|
113
|
-
</Menu>
|
|
114
|
-
</Header>
|
|
115
|
-
<Layout>
|
|
116
|
-
<Sider width={200} className="site-layout-background">
|
|
117
|
-
<Menu
|
|
118
|
-
mode="inline"
|
|
119
|
-
defaultSelectedKeys={['slider_1_0']}
|
|
120
|
-
defaultOpenKeys={['slider_1']}
|
|
121
|
-
selectedKeys={['slider_' + topMenuKey + '_' + sliderMenuKey]}
|
|
122
|
-
openKeys={['slider_' + topMenuKey]}
|
|
123
|
-
style={{ height: '100%', borderRight: 0 }}
|
|
124
|
-
>
|
|
125
|
-
{_.map(menuConfig, (item:any, index:any) => {
|
|
126
|
-
const { key, text, url, icon, subMenus } = item
|
|
127
|
-
|
|
128
|
-
if (subMenus) {
|
|
129
|
-
return (
|
|
130
|
-
<SubMenu
|
|
131
|
-
key={'slider_' + key}
|
|
132
|
-
icon={icon}
|
|
133
|
-
title={text}
|
|
134
|
-
onTitleClick={() => {
|
|
135
|
-
setTopMenuKey(key)
|
|
136
|
-
setSliderMenuKey('1')
|
|
137
|
-
}}
|
|
138
|
-
>
|
|
139
|
-
{_.map(subMenus, (subItem:any, subIndex:any) => {
|
|
140
|
-
const { key: subKey, text: subText, url: subUrl } = subItem
|
|
141
|
-
return (
|
|
142
|
-
<Menu.Item
|
|
143
|
-
key={'slider_' + subKey}
|
|
144
|
-
onClick={() => {
|
|
145
|
-
routerPush(router, subUrl)
|
|
146
|
-
|
|
147
|
-
const subKeyArr = subKey.split('_')
|
|
148
|
-
const subKeyArrLen = subKeyArr.length
|
|
149
|
-
|
|
150
|
-
console.log(subKeyArr, subKeyArrLen)
|
|
151
|
-
|
|
152
|
-
if (subKeyArrLen >= 1) setTopMenuKey(subKeyArr[0])
|
|
153
|
-
|
|
154
|
-
if (subKeyArrLen >= 2) setSliderMenuKey(subKeyArr[1])
|
|
155
|
-
}}
|
|
156
|
-
>
|
|
157
|
-
{subText}
|
|
158
|
-
</Menu.Item>
|
|
159
|
-
)
|
|
160
|
-
})}
|
|
161
|
-
</SubMenu>
|
|
162
|
-
)
|
|
163
|
-
} else {
|
|
164
|
-
if (key) {
|
|
165
|
-
return (
|
|
166
|
-
<Menu.Item
|
|
167
|
-
key={'slider_' + key + '_0'}
|
|
168
|
-
icon={icon}
|
|
169
|
-
onClick={() => {
|
|
170
|
-
routerPush(router, url)
|
|
171
|
-
setTopMenuKey(key)
|
|
172
|
-
setSliderMenuKey('0')
|
|
173
|
-
}}
|
|
174
|
-
>
|
|
175
|
-
{text}
|
|
176
|
-
</Menu.Item>
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
})}
|
|
181
|
-
</Menu>
|
|
182
|
-
</Sider>
|
|
183
|
-
<Layout style={{ padding: '0 24px 24px' }}>
|
|
184
|
-
<Breadcrumb style={{ margin: '16px 0' }}>
|
|
185
|
-
{_.map(menuConfig, (item:any, index:any) => {
|
|
186
|
-
const { key, text, subMenus } = item
|
|
187
|
-
|
|
188
|
-
if (key && key === topMenuKey) {
|
|
189
|
-
if (subMenus) {
|
|
190
|
-
const subContent = []
|
|
191
|
-
_.each(subMenus, (subItem:any, subIndex:any) => {
|
|
192
|
-
const { key: subKey, text: subText } = subItem
|
|
193
|
-
if (subKey === key + '_' + sliderMenuKey) {
|
|
194
|
-
subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{text}</Breadcrumb.Item>)
|
|
195
|
-
subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{subText}</Breadcrumb.Item>)
|
|
196
|
-
return false
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
return subContent
|
|
200
|
-
} else {
|
|
201
|
-
return <Breadcrumb.Item key={'breadcrumb' + index}>{text}</Breadcrumb.Item>
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
})}
|
|
205
|
-
</Breadcrumb>
|
|
206
|
-
<Content
|
|
207
|
-
className="site-layout-background"
|
|
208
|
-
style={{
|
|
209
|
-
padding: 24,
|
|
210
|
-
margin: 0,
|
|
211
|
-
minHeight: 280
|
|
212
|
-
}}
|
|
213
|
-
>
|
|
214
|
-
{children}
|
|
215
|
-
</Content>
|
|
216
|
-
</Layout>
|
|
217
|
-
</Layout>
|
|
218
|
-
</Container>
|
|
219
|
-
</Layout>
|
|
220
|
-
)
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export default LayoutComponent
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { getLocalGraphql } from '../../utils/fetch'
|
|
2
|
-
import _ from 'lodash'
|
|
3
|
-
|
|
4
|
-
export const getTemplateService = (page=0, pageSize=10) => {
|
|
5
|
-
const getTemplateQuery = `query { template(page:` + page + `, pageSize:` + pageSize + `) {
|
|
6
|
-
totalCounts items {
|
|
7
|
-
id name
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}`
|
|
11
|
-
return getLocalGraphql(getTemplateQuery)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const searchTemplateByIdService = (id: number) => {
|
|
15
|
-
const searchTemplateByIdQuery = `query { templateGet(id:` + id + `) {
|
|
16
|
-
id name
|
|
17
|
-
}
|
|
18
|
-
}`
|
|
19
|
-
return getLocalGraphql(searchTemplateByIdQuery)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const searchTemplateService = (page = 0, pageSize = 10, data: any) => {
|
|
23
|
-
const { name } = data
|
|
24
|
-
const searchTemplateQuery = `query { templateSearch(page:` + page + `, pageSize:` + pageSize + `, data: { name: "` + name + `" }) {
|
|
25
|
-
totalCounts items {
|
|
26
|
-
id name
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}`
|
|
30
|
-
return getLocalGraphql(searchTemplateQuery)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const addTemplateService = (data: any) => {
|
|
34
|
-
const { name } = data
|
|
35
|
-
|
|
36
|
-
const addTemplateQuery = `mutation { templateAdd(data: { name: "` + name + `"}) }`
|
|
37
|
-
|
|
38
|
-
return getLocalGraphql(addTemplateQuery)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const updateTemplateService = (id: number, data: any) => {
|
|
42
|
-
const { name } = data
|
|
43
|
-
|
|
44
|
-
const updateTemplateQuery = `mutation { templateUpdate(id: ` + id + `, data: { name: "` + name + `"}) }`
|
|
45
|
-
|
|
46
|
-
return getLocalGraphql(updateTemplateQuery)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const deleteTemplateService = (id: number) => {
|
|
50
|
-
const deleteTemplateQuery = `mutation { templateDelete(id: ` + id + `) }`
|
|
51
|
-
|
|
52
|
-
return getLocalGraphql(deleteTemplateQuery)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const batchAddTemplateService = (datas: any) => {
|
|
56
|
-
let batchStr = ''
|
|
57
|
-
_.each(datas, (item, index) => {
|
|
58
|
-
const { name } = item
|
|
59
|
-
batchStr += `{ name: "` + name + `" },`
|
|
60
|
-
})
|
|
61
|
-
batchStr = batchStr.substring(0, batchStr.length - 1)
|
|
62
|
-
|
|
63
|
-
const batchAddTemplateQuery = `mutation { templateBatchAdd(datas: [` + batchStr + `]) }`
|
|
64
|
-
|
|
65
|
-
return getLocalGraphql(batchAddTemplateQuery)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const batchDeleteTemplateService = (ids: any) => {
|
|
69
|
-
const batchStr = ids.join(',')
|
|
70
|
-
|
|
71
|
-
const batchDeleteTemplateQuery = `mutation { templateBatchDelete(ids: [` + batchStr + `]) }`
|
|
72
|
-
|
|
73
|
-
return getLocalGraphql(batchDeleteTemplateQuery)
|
|
74
|
-
}
|