低代码前端完成

This commit is contained in:
aixianling
2022-06-22 11:20:42 +08:00
parent 17e2d3b12a
commit 03bd52194b
3 changed files with 39 additions and 3 deletions

View File

@@ -23,6 +23,32 @@ export default {
return hash == "#add" ? AcAdd : AcList
}
},
provide() {
return {
top: this
}
},
methods: {
handleGetCode(id) {
id && this.instance.post("/node/aicode/getCode", null, {
params: {id},
responseType: "blob"
}).then(res => {
if (res?.code == 1) {
this.$message.error(res.err)
} else {
const link = document.createElement('a')
let blob = new Blob([res], {type: 'application/zip'})
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
link.setAttribute('download', row.name + '.zip')
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
})
}
},
created() {
this.dict.load("detailType")
}

View File

@@ -1,7 +1,11 @@
<template>
<section class="acAdd">
<ai-detail list>
<ai-title slot="title" :title="pageTitle"/>
<ai-title slot="title" :title="pageTitle">
<template #rightBtn>
<el-button type="primary" v-if="isEdit" @click="top.handleGetCode($route.query.id)">生成代码</el-button>
</template>
</ai-title>
<template #content>
<el-form ref="AcForm" :model="form" size="small" label-width="120px" :rules="rules">
<el-tabs tab-position="left" @tab-click="handleSyncProps">
@@ -88,6 +92,9 @@ export default {
dict: Object,
permissions: Function
},
inject: {
top: {}
},
computed: {
isEdit: v => !!v.$route.query.id,
pageTitle: v => v.isEdit ? "编辑应用" : "新增应用"
@@ -164,7 +171,7 @@ export default {
}
}
return false;
}
},
},
created() {
this.getDetail()

View File

@@ -18,7 +18,7 @@
<template slot-scope="{row}">
<el-button type="text" @click="handleAdd(row.id)">编辑</el-button>
<el-button type="text" @click="handleDelete(row.id)">删除</el-button>
<el-button type="text" v-if="row.download&&row.target" @click="handleDownload(row)">下载</el-button>
<el-button type="text" v-if="row.download&&row.target" @click="top.handleGetCode(row.id)">下载</el-button>
</template>
</el-table-column>
</ai-table>
@@ -35,6 +35,9 @@ export default {
dict: Object,
permissions: Function
},
inject: {
top: {}
},
data() {
return {
search: {name: ""},