This commit is contained in:
ann 2023-02-13 11:03:34 +08:00
parent e662916577
commit d098ee6f50
2 changed files with 31 additions and 6 deletions

View File

@ -10,6 +10,14 @@ export function getEdgeDataByIpPath(params) {
})
}
export function getProfileByIpPath(params) {
return request({
url: edgePreUrl + '/getProfile',
method: 'get',
params: params
})
}
export function getEdgeServiceByIp(params) {
return request({
url: edgePreUrl + '/registryCenter',

View File

@ -80,11 +80,15 @@
:columns="columns2"
:table-list-data="blockList2"
tooltip-effect="dark"
/>
<el-dialog :close-on-click-modal="false" title="编辑" :visible.sync="dialogEditProfileVisible">
>
<template v-slot:filterBtns>
<el-button size="medium" type="primary" @click="addProfile">添加</el-button>
</template>
</List>
<el-dialog :close-on-click-modal="false" :title="add?'添加':'编辑'" :visible.sync="dialogEditProfileVisible">
<codemirror v-model="code" class="code-mirror" :options="cmOption" />
<div slot="footer" class="dialog-footer">
<el-button icon="el-icon-close" circle @click="dialogEditProfileVisible = false" />
<el-button icon="el-icon-close" circle @click="dialogEditProfileVisible = false; code = ``" />
<el-button icon="el-icon-check" circle @click="submitProfile" />
</div>
</el-dialog>
@ -97,7 +101,7 @@
<script>
import List from '@/components/list'
import { deleteService, getEdgeDataByIpPath, patchDeviceservice, putDeviceservice } from '@/api/edge/edge'
import { deleteService, getEdgeDataByIpPath, patchDeviceservice, putDeviceservice, getProfileByIpPath, postDeviceservice } from '@/api/edge/edge'
export default {
components: {
@ -114,6 +118,7 @@ export default {
dialogAutoEventsVisible: false,
serviceData: {},
code: ``,
add: true,
cmOption: {
autoCloseBrackets: true,
tabSize: 4,
@ -229,16 +234,28 @@ export default {
})
},
editProfile(row) {
getEdgeDataByIpPath({ address: this.$route.query.ip, path: '/api/v2/profile/yaml/name/' + row.name }).then(e => {
getProfileByIpPath({ address: this.$route.query.ip, path: '/api/v2/profile/yaml/name/' + row.name }).then(e => {
this.dialogEditProfileVisible = true
this.code = JSON.stringify(e.data, null, 2)
})
},
addProfile() {
this.add = true
this.code = ``
this.dialogEditProfileVisible = true
},
submitProfile() {
putDeviceservice({ address: this.$route.query.ip, path: '/api/v2/profile/yaml', profile: this.code }).then(e => {
this.add ? postDeviceservice({ address: this.$route.query.ip, path: '/api/v2/profile/yaml', postContent: [JSON.parse(this.code)] }).then(e => {
if (e.code === 200) {
this.dialogEditProfileVisible = false
this.$message.success('添加成功')
this.getProfileList()
}
}) : putDeviceservice({ address: this.$route.query.ip, path: '/api/v2/profile/yaml', profile: JSON.parse(this.code) }).then(e => {
if (e.code === 200) {
this.dialogEditProfileVisible = false
this.$message.success('修改成功')
this.getProfileList()
}
})
},