Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from EasyOC/列表管理
Browse files Browse the repository at this point in the history
列表管理&菜单管理
  • Loading branch information
hyzx86 authored Feb 12, 2022
2 parents 6ef311a + b10b062 commit 74eb194
Show file tree
Hide file tree
Showing 70 changed files with 3,791 additions and 839 deletions.
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Edge",
"port": 3100,
"request": "attach",
"type": "pwa-msedge",
"webRoot": "${workspaceFolder}"
},
{
"type": "chrome",
"request": "launch",
Expand Down
5 changes: 3 additions & 2 deletions admin/config/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { configThemePlugin } from './theme'
import { configImageminPlugin } from './imagemin'
import { configSvgIconsPlugin } from './svgSprite'
import { configProxy } from './proxy'

import monacoEditorPlugin from 'vite-plugin-monaco-editor'
export const configVitePlugins = (viteEnv: ViteEnv, isBuild: boolean) => {
const {
VITE_USE_IMAGEMIN,
Expand Down Expand Up @@ -74,7 +74,8 @@ export const configVitePlugins = (viteEnv: ViteEnv, isBuild: boolean) => {
// vite-plugin-pwa
vitePlugins.push(configPwaConfig(viteEnv))
}

//Add Monaco
vitePlugins.push(monacoEditorPlugin())
return vitePlugins
}

Expand Down
3 changes: 3 additions & 0 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"tinymce": "^5.10.2",
"vditor": "^3.8.10",
"vue": "^3.2.26",
"vue-draggable-next": "^2.1.1",
"vue-json-pretty": "^1.8.2",
"vue-router": "^4.0.12",
"xlsx": "^0.17.4"
Expand All @@ -68,6 +69,7 @@
"@types/mockjs": "^1.0.4",
"@types/nprogress": "^0.2.0",
"@types/qrcode": "^1.4.2",
"monaco-editor": "^0.32.1",
"@types/qs": "^6.9.7",
"@types/showdown": "^1.9.4",
"@types/sortablejs": "^1.10.7",
Expand All @@ -87,6 +89,7 @@
"vite-plugin-html": "^2.1.2",
"vite-plugin-imagemin": "^0.5.1",
"vite-plugin-mock": "^2.9.6",
"vite-plugin-monaco-editor": "^1.0.10",
"vite-plugin-purge-icons": "^0.7.0",
"vite-plugin-pwa": "^0.11.12",
"vite-plugin-svg-icons": "^1.1.0",
Expand Down
210 changes: 210 additions & 0 deletions admin/src/api/ContentTypeService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
import { BasicColumn, FormSchema } from '@/components/Table'
import { useAppStore } from '@/store/app'
// import { } from "@service/eoc/";
import {
ContentTypeDefinitionDto,
ContentPartDefinitionDto,
ContentManagementServiceProxy,
} from '@service/api/app-service-proxies'
export class GraphqlQuery {
public query!: string
public hasTotal = true
}

export class ContentTypeService {
constructor(contentType: string) {
this.ContentType = contentType
this.ContentManagementService = new ContentManagementServiceProxy()
}

public async loadType() {
this.ContentTypeDefinitionDto =
await this.ContentManagementService.getTypeDefinition({
name: this.ContentType,
withSettings: true,
})
}

public async getTableSchema(graphQLQuery: GraphqlQuery) {
const appStore = useAppStore()
await appStore.loadGraphQLSchema()
console.log(appStore.graphqlSchema, 'appStore.graphqlSchema')
return graphQLQuery
}

public ContentManagementService: ContentManagementServiceProxy

public ContentType: string
public ContentTypeDefinitionDto!: ContentTypeDefinitionDto

public getColumns(
def: ContentTypeDefinitionDto | ContentPartDefinitionDto | any,
rootPath = '',
): BasicColumn[] {
if (def instanceof ContentTypeDefinitionDto) {
return this.getColumnsFromType(def as ContentTypeDefinitionDto, rootPath)
} else {
return this.getColumsFromPart(def as ContentPartDefinitionDto, rootPath)
}
}

public getColumsFromPart(
partDef: ContentPartDefinitionDto,
parentPath = '',
): BasicColumn[] {
const cols: BasicColumn[] = []
if (!!parentPath && !parentPath.endsWith('.')) {
parentPath = parentPath + '.'
}
const dataPath = parentPath
partDef.fields?.forEach((x) => {
const col: BasicColumn = {
title: x.displayName,
}

const valuePath = this.buildPath(x.fieldDefinition.name)

col.dataIndex = `${dataPath}${x.name}.${valuePath}`.split('.')
cols.push(col)
})
return cols
}

public getColumnsFromType(
typeDef: ContentTypeDefinitionDto,
parentPath = '',
): BasicColumn[] {
const cols: BasicColumn[] = []
if (!!parentPath && !parentPath.endsWith('.')) {
parentPath = parentPath + '.'
}
const dataPath = parentPath
typeDef.parts?.forEach((x) => {
if (x.partDefinition.name == 'TitlePart') {
cols.push({
title: 'DisplayName',
dataIndex: dataPath + 'TitlePart.Title',
})
} else {
cols.push(
...this.getColumsFromPart(x.partDefinition, `${dataPath}${x.name}`),
)
}
})
return cols
}

public getColumnsFromUserProperties(
userProperties: ContentTypeDefinitionDto[],
parentPath = 'properties.',
): BasicColumn[] {
const cols: BasicColumn[] = []
if (!!parentPath && !parentPath.endsWith('.')) {
parentPath = parentPath + '.'
}
console.log(userProperties, 'userProperties')

userProperties.forEach((x) => {
console.log(x, 'userProperties.' + x.displayName)
cols.push(...this.getColumnsFromType(x, `${parentPath}${x.name}`))
})
return cols
}

public getFormSchemaFromUserProperties(
userProperties: ContentTypeDefinitionDto[],
parentPath = 'properties.',
): FormSchema[] {
const cols: FormSchema[] = []
if (!!parentPath && !parentPath.endsWith('.')) {
parentPath = parentPath + '.'
}
console.log(userProperties, 'userProperties')

userProperties.forEach((x) => {
console.log(x, 'userProperties.' + x.displayName)
cols.push(...this.getFormSchemaFromType(x, `${parentPath}${x.name}`))
})
return cols
}

public getFormSchemaFromType(
typeDef: ContentTypeDefinitionDto,
parentPath = '',
): FormSchema[] {
const cols: FormSchema[] = []
if (!!parentPath && !parentPath.endsWith('.')) {
parentPath = parentPath + '.'
}
const dataPath = parentPath
typeDef.parts?.forEach((x) => {
if (x.partDefinition.name == 'TitlePart') {
cols.push({
label: 'DisplayName',
field: dataPath + 'TitlePart.Title',
component: 'Input',
})
} else {
cols.push(
...this.getFormSchemaFromPart(
x.partDefinition,
`${dataPath}${x.name}`,
),
)
}
})
return cols
}

public getFormSchemaFromPart(
partDef: ContentPartDefinitionDto,
parentPath = '',
): FormSchema[] {
const cols: FormSchema[] = []
if (!!parentPath && !parentPath.endsWith('.')) {
parentPath = parentPath + '.'
}
const dataPath = parentPath
partDef.fields?.forEach((x) => {
let valuePath = this.buildPath(x.fieldDefinition.name)
valuePath = `${dataPath}${x.name}.${valuePath}`
const formItem: FormSchema = {
label: x.displayName || '',
field: valuePath,
component: 'Input',
}

cols.push(formItem)
})
return cols
}

public buildPath(fieldName: string | null) {
let valuePath = 'Value'
switch (fieldName) {
case 'TextField':
valuePath = 'Text'
break
case 'BooleanField':
valuePath = 'Value'
break
case 'DateField':
valuePath = 'Value'
break
case 'TimeField':
valuePath = 'Value'
break
case 'Date&Timefield':
valuePath = 'Value'
break
case 'NumericField':
valuePath = 'Value'
break
case 'ContentPickerField':
case 'UserPickerField':
valuePath = 'DisplayText'
break
}
return valuePath
}
}
Loading

0 comments on commit 74eb194

Please sign in to comment.