diff --git a/src/api/api-base.ts b/src/api/api-base.ts
index 40c77e9..214d60d 100644
--- a/src/api/api-base.ts
+++ b/src/api/api-base.ts
@@ -18,7 +18,7 @@ class ApiBase {
* @type List-列表、Detail-详情、Add-添加、Edit-编辑
* @returns
*/
- public getColumns(path: string, type: string) {
+ public getColumns(path: string, type: string = 'List') {
const request = this.request;
// 1-列表List、2-详情Detail、3-添加Add、4-编辑Edit
let kind = 1;
@@ -52,7 +52,7 @@ class ApiBase {
item.name = 'id';
} else {
// 大驼峰命名改为小驼峰命名
- item.name = item.name.replace(/([A-Z])/g, '$1').toLowerCase();
+ item.name = item.name[0].toLowerCase() + item.name.substring(1);
}
}
return res;
diff --git a/src/api/config.ts b/src/api/config.ts
index cbf2524..98d6cee 100644
--- a/src/api/config.ts
+++ b/src/api/config.ts
@@ -1,31 +1,40 @@
-import ApiBase from './api-base'
+import ApiBase from './api-base';
export class ApiConfig extends ApiBase {
+ public getFields(path: string) {
+ const request = this.request;
+
+ return request({
+ url: path + '/GetFields',
+ method: 'get',
+ });
+ }
+
public getObject(path: string) {
- const request = this.request
+ const request = this.request;
return request({
- url: path + '/Index',
- method: 'get'
- })
+ url: path,
+ method: 'get',
+ });
}
public updateObject(path: string, obj: object) {
- const request = this.request
+ const request = this.request;
return request({
url: path + '/Update',
method: 'post',
- data: obj
- })
+ data: obj,
+ });
}
public getLoginConfig() {
- const request = this.request
+ const request = this.request;
return request({
url: '/Admin/Cube/GetLoginConfig',
- method: 'get'
- })
+ method: 'get',
+ });
}
}
diff --git a/src/views/common/objectForm.vue b/src/views/common/objectForm.vue
index 40e9ea7..6e93286 100644
--- a/src/views/common/objectForm.vue
+++ b/src/views/common/objectForm.vue
@@ -47,7 +47,14 @@
<el-form-item prop label-name>
<div
- style="position: fixed; margin: 30px; float:right; bottom: 0px; right: 0px; z-index: 1;"
+ style="
+ position: fixed;
+ margin: 30px;
+ float: right;
+ bottom: 0px;
+ right: 0px;
+ z-index: 1;
+ "
>
<el-button type="primary" @click="confirm">保存</el-button>
</div>
@@ -64,6 +71,7 @@ export default defineComponent({
return {
form: {} as any,
properties: [] as any,
+ fields: [] as any,
};
},
computed: {
@@ -81,13 +89,29 @@ export default defineComponent({
},
methods: {
init() {
+ this.getFields();
this.query();
},
+ getFields() {
+ let vm = this;
+ vm.$api.base.getColumns(vm.currentPath).then((res) => {
+ let fields = res.data;
+ // 对fields根据category进行分组
+ let properties = {} as any;
+ fields.forEach((item: any) => {
+ if (!properties[item.category]) {
+ properties[item.category] = [];
+ }
+ properties[item.category].push(item);
+ });
+
+ vm.properties = properties;
+ });
+ },
query() {
let vm = this;
vm.$api.config.getObject(vm.currentPath).then((res) => {
- vm.form = res.data.value;
- vm.properties = res.data.properties;
+ vm.form = res.data;
});
},
confirm() {