diff --git a/components.d.ts b/components.d.ts index deaf208..a9afa58 100644 --- a/components.d.ts +++ b/components.d.ts @@ -22,6 +22,8 @@ declare module '@vue/runtime-core' { InParamConfig: typeof import('./src/components/ApiFlow/components/ApiEditer/components/InParamConfig.vue')['default'] InParamsConfigCard: typeof import('./src/components/ApiFlow/components/ApiEditer/components/InParamsConfigCard.vue')['default'] MultipleSelect: typeof import('./src/components/EditTabel/multipleSelect.vue')['default'] + NCode: typeof import('naive-ui')['NCode'] + NConfigProvider: typeof import('naive-ui')['NConfigProvider'] NumberArrayInput: typeof import('./src/components/ApiFlow/components/ApiEditer/components/NumberArrayInput.vue')['default'] OutParamConfig: typeof import('./src/components/ApiFlow/components/ApiEditer/components/OutParamConfig.vue')['default'] OutParamsConfigCard: typeof import('./src/components/ApiFlow/components/ApiEditer/components/OutParamsConfigCard.vue')['default'] diff --git a/src/api/crudApi.ts b/src/api/crudApi.ts index 65611cd..801966f 100644 --- a/src/api/crudApi.ts +++ b/src/api/crudApi.ts @@ -1,47 +1,62 @@ -import { api } from "./api" - -interface QueryParam{ - name: string - type: "=" | ">" | "<" | "<=" | ">=" | "like" | "in" | "range" | "find_in_set" - model?: "and" | "or" - value:any +import { api } from "./api"; +type QueryExpress = + | "=" + | ">" + | "<" + | "<=" + | ">=" + | "like" + | "in" + | "range" + | "find_in_set"; +interface QueryParam { + name: string; + type: QueryExpress; + model?: "and" | "or"; + value: any; } -interface OrderParam{ - order_by: string - type:'asc'|'desc' +interface OrderParam { + order_by: string; + type: "asc" | "desc"; } -interface QueryParams{ - param_list?: QueryParam[] - order?:OrderParam - page: number - page_size: number +interface QueryParams { + param_list?: QueryParam[]; + order?: OrderParam; + page: number; + page_size: number; } -class CrudApi{ - baseUrl: string - idKey:string - constructor(baseUrl: string,idKey="id") { - this.baseUrl = baseUrl - this.idKey=idKey +class CrudApi { + baseUrl: string; + idKey: string; + constructor(baseUrl: string, idKey = "id") { + this.baseUrl = baseUrl; + this.idKey = idKey; } async get(itemId: any) { - return await api.post(this.baseUrl+"/get",{[this.idKey]:itemId}) + return await api.post(this.baseUrl + "/get", { + [this.idKey]: itemId + }); } async add(newData: any) { - return await api.post(this.baseUrl+"/add",newData) + return await api.post(this.baseUrl + "/add", newData); } async update(newData) { - return await api.post(this.baseUrl + "/update", newData) - } + return await api.post(this.baseUrl + "/update", newData); + } async delete(itemId: any) { - return await api.post(this.baseUrl+"/delete",{[this.idKey]:itemId}) - } + return await api.post(this.baseUrl + "/delete", { + [this.idKey]: itemId + }); + } async queryCommon(queryParams: QueryParams) { - return await api.post(this.baseUrl+"/query_common",queryParams) - + return await api.post( + this.baseUrl + "/query_common", + queryParams + ); } } -export { CrudApi } -export type { QueryParams,QueryParam } +export { CrudApi }; +export type { QueryParams, QueryParam, queryExpress }; diff --git a/src/components/EditTabelPlus/EditTablePlus.vue b/src/components/EditTabelPlus/EditTablePlus.vue new file mode 100644 index 0000000..06176a6 --- /dev/null +++ b/src/components/EditTabelPlus/EditTablePlus.vue @@ -0,0 +1,89 @@ + + \ No newline at end of file diff --git a/src/components/EditTabelPlus/config.ts b/src/components/EditTabelPlus/config.ts new file mode 100644 index 0000000..fdcc046 --- /dev/null +++ b/src/components/EditTabelPlus/config.ts @@ -0,0 +1,13 @@ +import type { QueryTypeEnum, ColumnTypeEnum } from "./types"; +const queryTypeDefaultValueDic: { [key in QueryTypeEnum]?: any } = { + date: [null, null], + datetime: [null, null] +}; +const queryTypeExpressDic: { [key in QueryTypeEnum]?: QueryExpress } = { + date: "range", + datetime: "range", + find_in_set: "find_in_set", + enum: "=" +}; + +export { queryTypeDefaultValueDic, queryTypeExpressDic }; diff --git a/src/components/EditTabelPlus/types.ts b/src/components/EditTabelPlus/types.ts index d8a3ed1..11a24aa 100644 --- a/src/components/EditTabelPlus/types.ts +++ b/src/components/EditTabelPlus/types.ts @@ -1,10 +1,27 @@ +type QueryTypeEnum = "like" | "date" | "datetime" | "enum" | "find_in_set"; +type ColumnTypeEnum = + | "string" + | "text" + | "float" + | "int" + | "date" + | "datetime" + | "file" + | "enum" + | "set"; interface QueryConfigBase { - type: string; + type: QueryTypeEnum; } interface QueryLike extends QueryConfigBase { type: "like"; } +interface QueryDate extends QueryConfigBase { + type: "date"; +} +interface QueryDatetime extends QueryConfigBase { + type: "datetime"; +} interface QueryEnum extends QueryConfigBase { type: "enum"; options: any[] | { name: string; value: any }[]; @@ -13,12 +30,16 @@ interface QueryFindInSet extends QueryConfigBase { type: "find_in_set"; options: any[] | { name: string; value: any }[]; } -type QueryType = QueryLike | QueryEnum | QueryFindInSet; +type QueryType = + | QueryLike + | QueryEnum + | QueryFindInSet + | QueryDate + | QueryDatetime; interface TableColumnConfigBase { key: string; - type: string; + type: ColumnTypeEnum; name: string; - showInTable?: boolean; query?: QueryType; addNeed?: boolean; updateNeed?: boolean; @@ -32,6 +53,9 @@ interface ColumnString extends TableColumnConfigBase { maxLenght: number; }; } +interface ColumnText extends TableColumnConfigBase { + type: "text"; +} interface ColumnFloat extends TableColumnConfigBase { type: "float"; @@ -51,6 +75,10 @@ interface ColumnDateTime extends TableColumnConfigBase { type: "datetime"; config?: {}; } +interface ColumnFile extends TableColumnConfigBase { + type: "file"; + config?: {}; +} interface ColumnEnum extends TableColumnConfigBase { type: "enum"; @@ -73,9 +101,12 @@ type TableColumnConfig = | ColumnDate | ColumnDateTime | ColumnEnum - | ColumnSet; + | ColumnSet + | ColumnFile + | ColumnText; interface TableModel { + baseUrl?: string; idKey: string; tableName: string; name: string; @@ -114,4 +145,4 @@ let BookTableModel: TableModel = { } ] }; -export type { TableModel }; +export type { TableModel, QueryTypeEnum, ColumnTypeEnum }; diff --git a/src/components/EditTabelPlus/EditTabelPlus.vue b/src/components/EditTabelPlus2/EditTabelPlus.vue similarity index 100% rename from src/components/EditTabelPlus/EditTabelPlus.vue rename to src/components/EditTabelPlus2/EditTabelPlus.vue diff --git a/src/components/EditTabelPlus/columnTemplates.ts b/src/components/EditTabelPlus2/columnTemplates.ts similarity index 100% rename from src/components/EditTabelPlus/columnTemplates.ts rename to src/components/EditTabelPlus2/columnTemplates.ts diff --git a/src/components/EditTabelPlus/multipleSelect.vue b/src/components/EditTabelPlus2/multipleSelect.vue similarity index 100% rename from src/components/EditTabelPlus/multipleSelect.vue rename to src/components/EditTabelPlus2/multipleSelect.vue diff --git a/src/components/EditTabelPlus2/types.ts b/src/components/EditTabelPlus2/types.ts new file mode 100644 index 0000000..d8a3ed1 --- /dev/null +++ b/src/components/EditTabelPlus2/types.ts @@ -0,0 +1,117 @@ +interface QueryConfigBase { + type: string; +} + +interface QueryLike extends QueryConfigBase { + type: "like"; +} +interface QueryEnum extends QueryConfigBase { + type: "enum"; + options: any[] | { name: string; value: any }[]; +} +interface QueryFindInSet extends QueryConfigBase { + type: "find_in_set"; + options: any[] | { name: string; value: any }[]; +} +type QueryType = QueryLike | QueryEnum | QueryFindInSet; +interface TableColumnConfigBase { + key: string; + type: string; + name: string; + showInTable?: boolean; + query?: QueryType; + addNeed?: boolean; + updateNeed?: boolean; + config?: {}; + default?: any; +} + +interface ColumnString extends TableColumnConfigBase { + type: "string"; + config?: { + maxLenght: number; + }; +} + +interface ColumnFloat extends TableColumnConfigBase { + type: "float"; + config?: {}; +} + +interface ColumnInt extends TableColumnConfigBase { + type: "int"; + config?: {}; +} + +interface ColumnDate extends TableColumnConfigBase { + type: "date"; + config?: {}; +} +interface ColumnDateTime extends TableColumnConfigBase { + type: "datetime"; + config?: {}; +} + +interface ColumnEnum extends TableColumnConfigBase { + type: "enum"; + config: { + options: any[] | { name: string; value: any }[]; + }; +} + +interface ColumnSet extends TableColumnConfigBase { + type: "set"; + config: { + options: any[] | { name: string; value: any }[]; + }; +} + +type TableColumnConfig = + | ColumnString + | ColumnFloat + | ColumnInt + | ColumnDate + | ColumnDateTime + | ColumnEnum + | ColumnSet; + +interface TableModel { + idKey: string; + tableName: string; + name: string; + columns: TableColumnConfig[]; +} +let BookTableModel: TableModel = { + tableName: "book", + name: "书", + idKey: "id", + columns: [ + { + key: "id", + type: "int", + name: "ID" + }, + { + key: "name", + type: "string", + name: "名称" + }, + { + key: "price", + type: "float", + name: "价格" + }, + { + key: "belong", + type: "enum", + name: "所属分类", + config: { + options: [ + { value: 1, lable: "悬疑" }, + { value: 2, lable: "科普" } + ] + } + } + ] +}; +export type { TableModel }; diff --git a/tsconfig.json b/tsconfig.json index ec5d12c..6491b7c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,6 +19,7 @@ "resolveJsonModule": true, "lib": ["dom", "esnext"], "incremental": true, + "noImplicitAny": false, "paths": { "@/*": ["src/*"], "@build/*": ["build/*"]