Commit fce834bf by qianmo

update: 增加/修改/删除字段完成时不刷新整个页面

parent 6d6c3ac1
......@@ -159,7 +159,7 @@
<script setup>
import {ref,toRefs} from 'vue'
import {ElMessage, ElMessageBox} from "element-plus";
import {DeleteProtocolCmd, EditProtocolCmd} from "../dao/device";
import {AddProtocolCMd, DeleteProtocolCmd, EditProtocolCmd} from "../dao/device";
const flag = ref(false)
const dialogVisible = ref(false)
......@@ -242,6 +242,7 @@ const addField = () => {
}
fields.value['cmd_name'] = toRefs(props).info.value
fields.value['cmd_type'] = toRefs(props).type.value
fields.value['fieldindex'] = tableData.value.length + 1
fields.value['minvalue'] = 'null'
fields.value['maxvalue'] = 'null'
fields.value['lua_script_in'] = 'null'
......@@ -283,6 +284,10 @@ async function Delete(id){
await DeleteProtocolCmd(id)
}
async function Add(params){
await AddProtocolCMd(params)
}
function confirm(str, data){
if (str === 'delete'){
operation = '删除'
......@@ -316,11 +321,19 @@ function confirm(str, data){
}
}
Edit(params['id'], params)
window.location.reload()
for (const item of Object.keys(fields.value)){
tableData.value[fields.value['fieldindex'] -1 ][item] = fields.value[item]
}
}else if (operation === '删除'){
console.log("id", data['id'])
Delete(data['id'])
window.location.reload()
tableData.value.splice(data['fieldindex'] -1 , 1)
}else if (operation === '增加'){
Add(fields.value)
let params = {}
for (const item of Object.keys(fields.value)){
params[item] = fields.value[item]
}
tableData.value.push(params)
}
})
.catch(() => {
......
......@@ -29,4 +29,12 @@ export function DeleteProtocolCmd(id){
return response.data
}
)
}
export function AddProtocolCMd(params){
return axios.post('http://192.168.0.214:8000/op/all_dev_cmd_define/' , params).then(
function (response){
return response.data
}
)
}
\ No newline at end of file
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment