添加功能
parent
f2863c5283
commit
cfa6f732f1
@ -0,0 +1,266 @@
|
|||||||
|
<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({
|
||||||
|
modevtypeId: this.rowData.id,
|
||||||
|
field: this.formInfo.name,
|
||||||
|
fieldDesc: this.formInfo.comment,
|
||||||
|
//type: this.formInfo.typeVal,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
|
||||||
|
if (res.success) {
|
||||||
|
this.innerVisible = false;
|
||||||
|
this.getListAll();
|
||||||
|
} else {
|
||||||
|
this.$message({
|
||||||
|
duration: 1500,
|
||||||
|
showClose: true,
|
||||||
|
type: "error",
|
||||||
|
message: res.errorMsg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.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>
|
Loading…
Reference in New Issue