Files
wvp-platform/web_src/src/components/dialog/groupEdit.vue

106 lines
2.7 KiB
Vue
Raw Normal View History

2024-08-05 17:59:20 +08:00
<template>
<div id="groupEdit" v-loading="loading">
<el-dialog
title="分组编辑"
width="40%"
top="2rem"
:append-to-body="true"
:close-on-click-modal="false"
:visible.sync="showDialog"
:destroy-on-close="true"
@close="close()"
>
<div id="shared" style="margin-top: 1rem;margin-right: 100px;">
<el-form ref="form" :rules="rules" :model="group" label-width="140px" >
<el-form-item label="节点编号" prop="id" >
2024-08-05 18:02:19 +08:00
<el-input v-model="group.deviceId" placeholder="请输入编码">
<el-button slot="append" @click="buildDeviceIdCode(group.deviceId)">生成</el-button>
</el-input>
2024-08-05 17:59:20 +08:00
</el-form-item>
<el-form-item label="节点名称" prop="name">
<el-input v-model="group.name" clearable></el-input>
</el-form-item>
<el-form-item>
<div style="float: right;">
<el-button type="primary" @click="onSubmit" >确认</el-button>
<el-button @click="close">取消</el-button>
</div>
</el-form-item>
</el-form>
</div>
</el-dialog>
2024-08-05 18:02:19 +08:00
<channelCode ref="channelCode"></channelCode>
2024-08-05 17:59:20 +08:00
</div>
</template>
<script>
2024-08-05 18:02:19 +08:00
import channelCode from "./channelCode.vue";
2024-08-05 17:59:20 +08:00
export default {
name: "groupEdit",
2024-08-05 18:02:19 +08:00
components: {channelCode},
2024-08-05 17:59:20 +08:00
computed: {},
props: [],
created() {},
data() {
return {
submitCallback: null,
showDialog: false,
loading: false,
level: 0,
group: {},
};
},
methods: {
openDialog: function (group, callback) {
console.log(group)
this.group = group;
this.showDialog = true;
this.submitCallback = callback;
},
onSubmit: function () {
this.$axios({
method:"post",
url: this.group.id ? '/api/group/add':'/api/group/update',
data: this.group
}).then((res)=> {
if (res.data.code === 0) {
this.$message.success("保存成功")
if (this.submitCallback)this.submitCallback(this.group)
}else {
this.$message({
showClose: true,
message: res.data.msg,
type: "error",
});
}
this.close();
})
.catch((error)=> {
this.$message({
showClose: true,
message: error,
type: "error",
});
});
},
2024-08-05 18:02:19 +08:00
buildDeviceIdCode: function (deviceId){
this.$refs.channelCode.openDialog(code=>{
console.log(this.form)
console.log("code===> " + code)
this.group.deviceId = code;
console.log("code22===> " + code)
}, deviceId);
},
2024-08-05 17:59:20 +08:00
close: function () {
this.showDialog = false;
console.log(this.group)
},
},
};
</script>