低代码前端完成

This commit is contained in:
aixianling
2022-06-22 11:08:55 +08:00
parent 98762e996c
commit 834132fec2
3 changed files with 53 additions and 48 deletions

View File

@@ -4,7 +4,7 @@
<ai-title slot="title" :title="pageTitle"/>
<template #content>
<el-form ref="AcForm" :model="form" size="small" label-width="120px" :rules="rules">
<el-tabs tab-position="left">
<el-tabs tab-position="left" @tab-click="handleSyncProps">
<el-tab-pane label="基本信息" lazy>
<ai-card title="基本信息">
<template #content>
@@ -42,6 +42,7 @@
</ai-card>
<ai-card title="字段设置">
<template #right>
<el-button type="text" @click="handleAddProps">批量添加</el-button>
<el-button type="text" @click="form.props.push({})">添加</el-button>
</template>
<template #content>
@@ -49,7 +50,7 @@
<el-table-column v-for="col in colConfigs" :key="col.slot" v-bind="col">
<template slot-scope="{row}">
<el-checkbox v-if="col.type=='checkBox'" v-model="row[col.slot]"/>
<span v-else-if="col.type=='chbShow'" v-text="row[col.slot]==1?'':''"/>
<span v-else-if="col.type=='chbShow'" v-text="row[col.slot]==true?'':''"/>
<el-input v-else size="small" v-model="row[col.slot]" placeholder="请输入" clearable/>
</template>
</el-table-column>
@@ -63,7 +64,7 @@
</ai-card>
</el-tab-pane>
<el-tab-pane label="详情设计" lazy>
<detail-layout v-bind="$props" :form="form" v-model="form.props"/>
<detail-layout v-bind="$props" :form="form" v-model="form.detailConfig"/>
</el-tab-pane>
</el-tabs>
</el-form>
@@ -116,7 +117,7 @@ export default {
}).then(res => {
if (res?.data) {
this.form = res.data
this.form.props.map(e => ({...e, isDetail: !!e.groupName}))
this.handleSyncProps()
}
})
},
@@ -135,6 +136,35 @@ export default {
}
})
},
handleSyncProps() {
let detailPorps = this.form.detailConfig?.map(e => e.column)?.flat()?.map(e => e.prop)
this.form.props = this.form.props.map(e => ({...e, isDetail: !!detailPorps?.includes(e.prop)}))
},
handleAddProps() {
this.$prompt("请输入swagger示例JSON字符串", {
type: 'warning',
title: "批量添加字段",
dangerouslyUseHTMLString: true,
center: true,
}).then(({value}) => {
if (this.$checkJson(value)) {
Object.keys(JSON.parse(value)).map(prop => {
this.form.props.push({prop})
})
}
}).catch(() => 0)
},
$checkJson(str) {
if (typeof str == 'string') {
try {
let obj = JSON.parse(str);
return !!(typeof obj == 'object' && obj);
} catch (e) {
return false;
}
}
return false;
}
},
created() {
this.getDetail()