代码生成、优化

This commit is contained in:
吕金泽
2022-03-27 22:44:48 +08:00
parent 43976afbee
commit 178e024cf8
115 changed files with 1140 additions and 302 deletions
+8 -8
View File
@@ -158,14 +158,14 @@ common.getUrl = (url, data) => {
return url
}
common.loadConfig = async() => {
await request({
url: 'config/list'
}).then(res => {
const { data } = res
global.filePrefix = data.filePrefix
})
}
// common.loadConfig = async() => {
// await request({
// url: 'config/list'
// }).then(res => {
// const { data } = res
// global.filePrefix = data.filePrefix
// })
// }
common.setDefaultValue = (obj, attr, value) => {
obj[attr] = obj[attr] === undefined ? value : obj[attr]
@@ -0,0 +1,6 @@
function gen(groupPath, data){
var magic = {}
}
export default gen
+50 -11
View File
@@ -26,35 +26,39 @@ function gen(groupPath, data){
}],
table: {
url: '${groupPath}/list',
where: {
`
where: {`
for(var i in data){
var d = data[i]
if(d.query){
html += `
${d.columnName}: {
label: '${d.columnComment}'
},
`
},`
}
}
html = html.substring(0, html.length - 1)
html += `
},
cols: [
`
cols: [`
for(var i in data){
var d = data[i]
if(d.list){
html += `
if(d.dictType){
html += `
{
dictType: '${d.dictType}',`
}else{
html += `
{
`
}
html += `
field: '${d.columnName}',
label: '${d.columnComment}'
},
`
},`
}
}
html += `
{
html += `{
label: '操作',
type: 'btns',
width: 140,
@@ -85,7 +89,42 @@ function gen(groupPath, data){
]
}
]
}
})
`
html += `
const formOptions = reactive({
detail: {
request: {
url: '${groupPath}/get'
}
},
form: {
request: {
url: "${groupPath}/save",
method: "post"
},
rows: [{
gutter: 24,
cols: [`
for(var i in data){
var d = data[i]
if(d.save){
html += `{
span: 12,
name: '${d.columnName}',
label: '${d.columnComment}',
${d.component}
},`
}
}
html = html.substring(0, html.length - 1)
html += `]
}]
}
})
`
console.log(html)
}
export default gen
+1 -1
View File
@@ -8,7 +8,7 @@ export default {
info: {},
permissionRoutes: []
},
filePrefix: '',
baseApi: import.meta.env.VITE_APP_BASE_API,
visitedViews: reactive([]),
tabValue: ref('')
}