配置tablename和colname

master
fanluyan 1 year ago
parent 2acb92ec14
commit cdae77e028

@ -102,6 +102,15 @@ export function colListApi(data) {
}, },
}); });
} }
//更新更新ICD类型属性配置
export function icdupdateAttApi(data) {
return request({
url: "/icdconfig/updateAtt",
method: "post",
data,
});
}
//设备台账管理列表api //设备台账管理列表api
//变电站相关接口 //变电站相关接口

@ -0,0 +1,180 @@
<template>
<div class="colConfig">
<el-dialog
class="colDialogBox"
title="col配置"
:visible.sync="colDialogshow"
width="1020px"
>
<div class="colContain">
<el-table
v-loading="colLoading"
:data="attTableList"
stripe
border
style="width: 100%"
height="calc(100% - 0px)"
>
<el-table-column prop="doName" label="doName"> </el-table-column>
<el-table-column prop="lastName" label="lastName"> </el-table-column>
<el-table-column prop="colName" label="colName">
<template slot-scope="scope">
<el-select
v-show="scope.$index == cellIndex"
v-model="colName"
placeholder="请选择"
size="mini"
>
<el-option
v-for="item in colOptions"
:key="item"
:label="item"
:value="item"
></el-option>
</el-select>
<span v-show="scope.$index != cellIndex">{{
scope.row.colName
}}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="300" class-name="editClass">
<template slot-scope="scope">
<el-link
v-if="scope.$index != cellIndex"
type="primary"
@click="handlecolEditClick(scope)"
size="small"
icon="el-icon-document"
>
colName配置
</el-link>
<el-link
v-else
type="primary"
@click="handlecolSaveClick(scope)"
size="small"
icon="el-icon-document"
>
保存
</el-link>
<!-- <el-link
type="primary"
@click="handlecolEditClick(scope.row)"
size="small"
icon="el-icon-document"
>修改</el-link
> -->
</template>
</el-table-column>
</el-table>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="colDialogshow = false"
> </el-button
>
</div>
</el-dialog>
</div>
</template>
<script>
import { colListApi, icdupdateAttApi } from "@/utils/api/index";
export default {
props: ["colChildData"],
data() {
return {
colDialogshow: false,
colTableData: {},
colLoading: false,
innerVisible: false,
colName: "",
colOptions: [],
colData: "",
cellIndex: null,
attTableList: [],
colIndex: 0,
};
},
watch: {
colChildData: {
handler(newVal, oldVal) {
if (newVal && newVal.attList) {
console.log("gaibian", newVal);
this.attTableList = newVal.attList;
}
},
immediate: true,
deep: true, //deep false
},
},
mounted() {},
methods: {
//
handlecolEditClick({ $index, row }) {
this.colName = "";
this.cellIndex = $index;
this.colData = row;
},
//
handlecolSaveClick({ row }) {
icdupdateAttApi({
colName: this.colName,
id: row.id,
})
.then((res) => {
if (res.success) {
this.cellIndex = null;
console.log(this.colTableData);
this.$parent.geticdList(this.colTableData.iedName, this.colIndex);
}
})
.catch((err) => {});
},
//colName
getColList() {
this.colOptions = [];
colListApi({ tableName: this.colTableData.tableName })
.then((res) => {
console.log(res);
this.colOptions = res.data;
})
.catch((err) => {
console.log(err); //
});
},
display(val, index) {
this.colDialogshow = true;
this.colTableData = val;
this.attTableList = val.attList;
this.colIndex = index;
console.log(val, index);
this.getColList();
},
hide() {
this.colDialogshow = false;
},
},
};
</script>
<style lang="less">
.colConfig {
.colDialogBox {
.colContain {
height: 540px;
.el-table {
.editClass {
.el-link.el-link--primary {
margin-right: 14px;
}
}
}
}
}
}
.innerBox {
.el-select {
width: 268px;
}
}
</style>

@ -53,18 +53,56 @@
<el-table-column prop="ldeviceInst" label="ldeviceInst"> <el-table-column prop="ldeviceInst" label="ldeviceInst">
</el-table-column> </el-table-column>
<el-table-column prop="lnClass" label="lnClass"> </el-table-column> <el-table-column prop="lnClass" label="lnClass"> </el-table-column>
<el-table-column prop="doName" label="doName"> </el-table-column> <!-- <el-table-column prop="doName" label="doName"> </el-table-column> -->
<el-table-column prop="tableName" label="tableName"></el-table-column> <el-table-column prop="tableName" label="tableName">
<el-table-column prop="colName" label="colName"> </el-table-column> <template slot-scope="scope">
<el-select
v-show="scope.$index == cellIndex"
v-model="tableName"
placeholder="请选择"
@change="changeTablename"
size="mini"
>
<el-option
v-for="item in tableOptions"
:key="item"
:label="item"
:value="item"
></el-option>
</el-select>
<span v-show="scope.$index != cellIndex">{{
scope.row.tableName
}}</span>
</template>
</el-table-column>
<!-- <el-table-column prop="colName" label="colName"> </el-table-column> -->
<el-table-column label="操作" width="300" class-name="editClass"> <el-table-column label="操作" width="400" class-name="editClass">
<template slot-scope="scope"> <template slot-scope="scope">
<el-link <el-link
v-if="scope.$index != cellIndex"
type="primary"
@click="handleEditClick(scope)"
size="small"
icon="el-icon-document"
>
tableName配置
</el-link>
<el-link
v-else
type="primary" type="primary"
@click="handleEditClick(scope.row)" @click="handleSaveClick(scope)"
size="small" size="small"
icon="el-icon-document" icon="el-icon-document"
>修改</el-link >
保存
</el-link>
<el-link
type="primary"
@click="handlecolConfigClick(scope)"
size="small"
icon="el-icon-document"
>colName配置</el-link
> >
<el-link <el-link
type="danger" type="danger"
@ -78,59 +116,7 @@
</el-table> </el-table>
</div> </div>
</div> </div>
<el-dialog <colDialog ref="colDialogRef" :colChildData="colChildData"></colDialog>
class="editDialogBox"
title="修改配置"
:visible.sync="editDialogshow"
width="520px"
>
<el-form
label-position="left"
ref="formInfo"
label-width="104px"
:rules="rules"
:model="formData"
>
<el-form-item label="tableName" prop="tableName">
<el-select
v-model="formData.tableName"
placeholder="请选择"
@change="changeTablename"
>
<el-option
v-for="item in tableOptions"
:key="item"
:label="item"
:value="item"
></el-option>
</el-select>
<!-- <el-input
placeholder="请输入tableName"
v-model="formData.tableName"
autocomplete="off"
></el-input> -->
</el-form-item>
<el-form-item label="colName" prop="colName">
<el-select v-model="formData.colName" placeholder="请选择">
<el-option
v-for="item in colOptions"
:key="item"
:label="item"
:value="item"
></el-option>
</el-select>
<!-- <el-input
placeholder="请输入colName"
v-model="formData.colName"
></el-input> -->
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="editDialogshow = false"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
@ -141,18 +127,13 @@ import {
icdUpdateApi, icdUpdateApi,
icdDeleteApi, icdDeleteApi,
tableListApi, tableListApi,
colListApi,
} from "@/utils/api/index"; } from "@/utils/api/index";
import colDialog from "./colDialog.vue";
export default { export default {
components: {
colDialog,
},
data() { data() {
var validateInput = (rule, value, callback) => {
const reg = /^[a-zA-Z0-9_]+$/; // 线
if (!reg.test(value)) {
callback(new Error("请只输入英文、数字和下划线"));
} else {
callback();
}
};
return { return {
fileList: [], // fileList: [], //
reportData: {}, reportData: {},
@ -162,29 +143,12 @@ export default {
icdTableData: [], // icdTableData: [], //
icdLoading: true, icdLoading: true,
editDialogshow: false, editDialogshow: false,
formData: {}, // tableName: "",
rules: { currentData: "", //
tableName: [
{
required: true,
validator: validateInput,
trigger: "blur",
},
],
colName: [
{
required: true,
validator: validateInput,
trigger: "blur",
},
// { min: 6, max: 8, message: "6-8", trigger: "blur" },
],
},
tableOptions: [], tableOptions: [],
colOptions: [], tableSelectShow: false,
cellIndex: null,
colChildData: "",
}; };
}, },
mounted() { mounted() {
@ -236,6 +200,7 @@ export default {
}, },
//iedname //iedname
handleClick(item, index) { handleClick(item, index) {
this.cellIndex = null;
this.selectedIndex = index; this.selectedIndex = index;
console.log(item, index); console.log(item, index);
this.iedNameTitle = item; this.iedNameTitle = item;
@ -255,23 +220,10 @@ export default {
}); });
}, },
changeTablename(val) { changeTablename(val) {
this.formData.tableName = val; this.tableName = val;
this.getColList();
this.formData.colName = "";
},
getColList() {
this.colOptions = [];
colListApi({ tableName: this.formData.tableName })
.then((res) => {
console.log(res);
this.colOptions = res.data;
})
.catch((err) => {
console.log(err); //
});
}, },
//icd //icd
geticdList(val) { geticdList(val, index) {
this.icdTableData = []; this.icdTableData = [];
icdListApi({ icdListApi({
iedName: val, iedName: val,
@ -280,6 +232,8 @@ export default {
console.log(res); console.log(res);
this.icdLoading = false; this.icdLoading = false;
this.icdTableData = res.data; this.icdTableData = res.data;
this.colChildData = res.data[index];
console.log("我是更新后的", this.colChildData);
}) })
.catch((err) => { .catch((err) => {
this.icdLoading = false; this.icdLoading = false;
@ -287,27 +241,27 @@ export default {
}); });
}, },
//icd //icd
handleEditClick(val) { handleEditClick({ $index, row }) {
this.formData = { ...val }; this.tableName = "";
this.editDialogshow = true; this.tableSelectShow = true;
this.cellIndex = $index;
}, },
submitForm() { //tableName
this.$refs.formInfo.validate((valid) => { handleSaveClick({ row }) {
if (valid) { this.cellIndex = null;
icdUpdateApi(this.formData) icdUpdateApi({
tableName: this.tableName,
id: row.id,
})
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
this.editDialogshow = false; this.cellIndex = null;
this.geticdList(this.formData.iedName); this.geticdList(row.iedName);
} }
}) })
.catch((err) => {}); .catch((err) => {});
} else {
console.log("error submit!!");
return false;
}
});
}, },
//icd //icd
handleDeleteClick(val) { handleDeleteClick(val) {
console.log(val); console.log(val);
@ -335,6 +289,21 @@ export default {
}) })
.catch(() => {}); .catch(() => {});
}, },
//col
handlecolConfigClick({ $index, row }) {
if (row.tableName == null || row.tableName == "") {
this.$message({
duration: 1500,
showClose: true,
message: "请先配置tableName",
type: "success",
});
// this.handleEditClick(val);
} else {
console.log(row, $index);
this.$refs.colDialogRef.display(row, $index);
}
},
}, },
}; };
</script> </script>

Loading…
Cancel
Save