Files
dvcp-node-service/tpl/add.vue
2022-07-01 18:12:01 +08:00

82 lines
1.6 KiB
Vue

<template>
<section class="add">
<ai-detail>
<ai-title slot="title" :title="pageTitle" isShowBottomBorder/>
<template #content>
<el-form ref="AddForm" :model="form" size="small" label-width="120px" :rules="rules">
@content
</el-form>
</template>
<template #footer>
<el-button @click="back">取消</el-button>
<el-button type="primary" @click="submit">提交</el-button>
</template>
</ai-detail>
</section>
</template>
<script>
export default {
name: "add",
props: {
instance: Function,
dict: Object,
permissions: Function
},
computed: {
isEdit: v => !!v.$route.query.id,
pageTitle: v => v.isEdit ? "编辑@name" : "新增@name"
},
data() {
return {
form: {},
rules: {
@rules
},
}
},
methods: {
getDetail() {
let {id} = this.$route.query
id && this.instance.post("/node/@rightCode/detail", null, {
params: {id}
}).then(res => {
if (res?.data) {
this.form = res.data
}
})
},
back() {
this.$router.push({})
},
submit() {
this.$refs.AddForm.validate(v => {
if (v) {
this.instance.post("/node/@rightCode/addOrUpdate", this.form).then(res => {
if (res?.code == 0) {
this.$message.success("提交成功!")
this.back()
}
})
}
})
},
},
created() {
this.getDetail()
}
}
</script>
<style lang="scss" scoped>
.add {
.half {
width: 50%;
& + .half {
margin-left: 16px;
}
}
}
</style>