属性添加type

jc1.0
fanluyan 1 year ago
parent a31863b159
commit 4cd069e579

@ -1,256 +0,0 @@
<template>
<div class="attributeList">
<el-dialog
class="attributesDialogBox"
title="属性配置"
:visible.sync="attributeshow"
width="620px"
:close-on-click-modal="false"
>
<div class="attBox" v-loading="attLoading">
<el-button
class="addAtt"
type="primary"
icon="el-icon-plus"
@click="handleAddAttClick"
>添加属性</el-button
>
<el-table
:data="attributesData"
stripe
border
style="width: 100%"
height="404px"
>
<el-table-column prop="field" label="字段名" width="180">
</el-table-column>
<el-table-column prop="fieldDesc" label="字段描述" width="180">
</el-table-column>
<el-table-column prop="unit" label="单位"> </el-table-column>
<el-table-column label="操作" class-name="editClass">
<template slot-scope="scope">
<el-link
type="danger"
@click="handleDeleteClick(scope.row)"
size="small"
icon="el-icon-delete"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
</div>
<el-dialog
width="450px"
title="新增"
:visible.sync="innerVisible"
append-to-body
class="attaddDialog"
>
<el-form
label-position="left"
ref="formInfo"
label-width="104px"
:rules="rules"
:model="formInfo"
>
<el-form-item label="属性名:">
<el-select v-model="formInfo.name" @change="changeName">
<el-option
v-for="item in attOptions"
:key="item.name"
:label="item.name"
:value="item.name"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="属性描述:" prop="comment">
<el-input v-model="formInfo.comment"></el-input>
</el-form-item>
<el-form-item label="类型:">
<el-select v-model="formInfo.typeVal" @change="changeName">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="innerVisible = false"> </el-button>
<el-button type="primary" @click="submitAddForm()"> </el-button>
</div>
</el-dialog>
<div slot="footer" class="dialog-footer">
<!-- <el-button @click="hide"> </el-button> -->
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
modevtypepointAddApi,
modevtypepointListApi,
modevtypepointDeleteApi,
colListApi,
} from "@/utils/api/index";
export default {
props: ["title"],
data() {
return {
rowData: "",
attributeshow: false,
innerVisible: false,
attLoading: false,
attributesData: [],
attOptions: [],
typeOptions: [
{
value: 1,
label: "遥信",
},
{
value: 2,
label: "遥测",
},
],
formInfo: {
name: "",
comment: "",
typeVal: 2,
},
rules: {},
};
},
created() {},
mounted() {},
watch: {},
methods: {
changeName(val) {
console.log(val);
this.formInfo.name = val;
console.log(this.attOptions.find((item) => item.name === val));
this.formInfo.comment = this.attOptions.find(
(item) => item.name === val
).comment;
},
display(val) {
//
this.rowData = val;
console.log(this.rowData);
this.attributeshow = true;
this.getListAll();
},
getListAll() {
this.attLoading = true;
modevtypepointListApi({
modevtypeId: this.rowData.id,
})
.then((res) => {
console.log(res);
this.attributesData = res.data;
this.attLoading = false;
})
.catch((err) => {
console.log(err); //
});
},
//
handleAddAttClick() {
this.innerVisible = true;
this.getcolList();
},
//colList
getcolList() {
colListApi({
tableName: this.rowData.tableName,
})
.then((res) => {
console.log(res);
this.attOptions = res.data;
this.formInfo.name = res.data[0].name;
this.formInfo.comment = res.data[0].comment;
})
.catch((err) => {
console.log(err); //
});
},
//
submitAddForm() {
console.log(this.formInfo);
modevtypepointAddApi({
sensorId: this.rowData.id,
field: this.formInfo.name,
fieldDesc: this.formInfo.comment,
type: this.formInfo.typeVal,
})
.then((res) => {
console.log(res);
this.innerVisible = false;
this.getListAll();
})
.catch((err) => {
console.log(err); //
});
},
//
handleDeleteClick(val) {
console.log(val);
this.$confirm("确定要删除记录吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
modevtypepointDeleteApi({ id: val.id }).then((res) => {
if (res.success) {
this.$message({
duration: 1500,
showClose: true,
type: "success",
message: "删除成功",
});
this.getListAll(); //
} else {
this.$message({
duration: 1500,
showClose: true,
type: "error",
message: res.errorMsg,
});
}
});
})
.catch(() => {});
},
submitForm() {
this.attributeshow = false;
},
hide() {
this.attributeshow = false;
},
},
};
</script>
<style lang="less">
.attributeList {
.attributesDialogBox {
.attBox {
.addAtt {
margin-bottom: 16px;
}
}
}
}
.attaddDialog {
.el-select {
width: 306px;
}
}
</style>

@ -68,17 +68,9 @@
<el-form-item label="属性描述:" prop="comment">
<el-input v-model="formInfo.comment"></el-input>
</el-form-item>
<!-- <el-form-item label="类型:">
<el-select v-model="formInfo.typeVal" @change="changeName">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item> -->
<el-form-item label="类型:">
<el-input v-model="formInfo.type" disabled></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="innerVisible = false"> </el-button>
@ -122,6 +114,7 @@ export default {
formInfo: {
name: "",
comment: "",
type: "",
//typeVal: 2,
},
rules: {
@ -142,6 +135,9 @@ export default {
this.formInfo.comment = this.attOptions.find(
(item) => item.name === val
).comment;
this.formInfo.type = this.attOptions.find(
(item) => item.name === val
).type;
},
display(val) {
//
@ -180,6 +176,7 @@ export default {
this.attOptions = res.data;
this.formInfo.name = res.data[0].name;
this.formInfo.comment = res.data[0].comment;
this.formInfo.type = res.data[0].type;
})
.catch((err) => {
console.log(err); //
@ -194,7 +191,7 @@ export default {
modevtypeId: this.rowData.id,
field: this.formInfo.name,
fieldDesc: this.formInfo.comment,
//type: this.formInfo.typeVal,
type: this.formInfo.type,
})
.then((res) => {
console.log(res);

Loading…
Cancel
Save