<!-- -->
|
<template>
|
<div style="width: 100%; height: 100%; display: flex">
|
<left-tree
|
:treedata="treeData"
|
:defaultSelectValue="defaultSelectValue"
|
:selectData="selectData"
|
:selectProps="selectProps"
|
:defaultProps="treeProps"
|
:selectIsShow="true"
|
:defaultExpandedKeys="defaultExpandedKeys"
|
:currentNodeKey="currentNodeKey"
|
:isShowEditIcon="true"
|
:isShowDeleteIcon="true"
|
:expand-on-click-node="false"
|
@selectchange="selectchange"
|
@click="handleNodeClick"
|
@treeEdit="treeEdit"
|
@treeDelete="treeDelete"
|
>
|
<template v-slot:titleright>
|
<div class="titleSlotRight">
|
<fks-button
|
icon="fks-icon-plus"
|
type="text"
|
style="margin-right: 5px"
|
@click="addFaultGroupFormVisible = true"
|
></fks-button>
|
</div>
|
</template>
|
</left-tree>
|
<div class="boxright">
|
<titleBoxVue style="background-color: #fff" :title="titleName">
|
<template v-slot:right>
|
<div class="titleSlotRight">
|
<fks-button
|
icon="fks-icon-plus"
|
type="primary"
|
@click="addFaultTreeFormVisible"
|
>添加</fks-button
|
>
|
</div>
|
</template>
|
</titleBoxVue>
|
<fks-table
|
ref="multipleTable"
|
id="out-table"
|
:data="tableData"
|
stripe
|
tooltip-effect="dark"
|
@selection-change="handleSelectionChange"
|
style="width: 100%; height: calc(100% - 50px); margin-top: 10px"
|
>
|
<fks-table-column type="selection"></fks-table-column>
|
<fks-table-column prop="Name" label="故障名称" width="180">
|
</fks-table-column>
|
<fks-table-column prop="Code" label="故障编码" width="180">
|
</fks-table-column>
|
<fks-table-column prop="TagName" label="标签名称" width="180">
|
</fks-table-column>
|
<fks-table-column prop="Description" label="说明"> </fks-table-column>
|
<fks-table-column label="操作" width="100">
|
<template slot-scope="scope">
|
<fks-button @click="editFault(scope.row)" type="text" size="small"
|
>编辑</fks-button
|
>
|
<fks-button @click="deleteFault(scope.row)" type="text" size="small"
|
>删除</fks-button
|
>
|
</template>
|
</fks-table-column>
|
</fks-table>
|
|
<fks-dialog
|
title="添加故障"
|
width="400px"
|
:visible.sync="addFaultFormVisible"
|
>
|
<span slot="title">
|
<fks-button icon="fks-icon-plus" type="text"></fks-button>
|
|
<span class="fks-dialog__title">添加故障</span>
|
</span>
|
<fks-form
|
:model="addFaultForm"
|
ref="addFaultList"
|
:rules="addFaultFormRules"
|
label-width="80px"
|
>
|
<fks-form-item label="故障名称" prop="name">
|
<fks-input
|
placeholder="请输入故障名称"
|
v-model="addFaultForm.name"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
<fks-form-item label="故障编码" prop="code">
|
<fks-input
|
placeholder="请输入唯一故障编码"
|
v-model="addFaultForm.code"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
<fks-form-item label="标签名称" prop="tagname">
|
<fks-input
|
placeholder="请输入唯一标签名称"
|
v-model="addFaultForm.tagname"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
<fks-form-item label="标签列表">
|
<fks-select
|
style="width: 100%"
|
v-model="addFaultForm.flags"
|
multiple
|
filterable
|
allow-create
|
default-first-option
|
placeholder="请选择或输入标签"
|
>
|
<fks-option
|
v-for="item in addFaultForm.options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</fks-option>
|
</fks-select>
|
</fks-form-item>
|
|
<fks-form-item label="详细说明">
|
<fks-input
|
placeholder="请输入详细说明"
|
type="textarea"
|
:rows="3"
|
autocomplete="off"
|
v-model="addFaultForm.note"
|
>
|
</fks-input>
|
</fks-form-item>
|
</fks-form>
|
<div slot="footer" class="dialog-footer">
|
<fks-button @click="addFaultFormVisible = false">取 消</fks-button>
|
<fks-button type="primary" @click="addFaultList('addFaultList')"
|
>确 定</fks-button
|
>
|
</div>
|
</fks-dialog>
|
|
<fks-dialog
|
title="编辑故障"
|
width="400px"
|
:visible.sync="editFaultFormVisible"
|
>
|
<span slot="title">
|
<fks-button icon="fks-icon-edit" type="text"></fks-button>
|
|
<span class="fks-dialog__title">编辑故障</span>
|
</span>
|
<fks-form
|
:model="editFaultForm"
|
ref="editFaultList"
|
:rules="editFaultFormRules"
|
label-width="80px"
|
>
|
<fks-form-item label="故障名称" prop="name">
|
<fks-input
|
placeholder="请输入故障名称"
|
v-model="editFaultForm.name"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
<fks-form-item label="故障编码" prop="code">
|
<fks-input
|
placeholder="请输入唯一故障编码"
|
v-model="editFaultForm.code"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
<fks-form-item label="标签名称">
|
<fks-input
|
placeholder="请输入唯一标签名称"
|
v-model="editFaultForm.tagname"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
<fks-form-item label="标签列表">
|
<fks-select
|
style="width: 100%"
|
v-model="editFaultForm.flags"
|
multiple
|
filterable
|
allow-create
|
default-first-option
|
placeholder="请选择或输入标签"
|
>
|
<fks-option
|
v-for="item in editFaultForm.options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</fks-option>
|
</fks-select>
|
</fks-form-item>
|
<fks-form-item label="详细说明">
|
<fks-input
|
placeholder="请输入详细说明"
|
type="textarea"
|
:rows="3"
|
autocomplete="off"
|
v-model="editFaultForm.note"
|
>
|
</fks-input>
|
</fks-form-item>
|
</fks-form>
|
<div slot="footer" class="dialog-footer">
|
<fks-button @click="editFaultFormVisible = false">取 消</fks-button>
|
<fks-button type="primary" @click="editFaultList('editFaultList')"
|
>确 定</fks-button
|
>
|
</div>
|
</fks-dialog>
|
|
<fks-dialog
|
title="添加故障分组"
|
width="400px"
|
:visible.sync="addFaultGroupFormVisible"
|
>
|
<span slot="title">
|
<fks-button icon="fks-icon-plus" type="text"></fks-button>
|
|
<span class="fks-dialog__title">添加故障分组</span>
|
</span>
|
<fks-form
|
ref="addFaultGroupForm"
|
:model="addFaultGroupForm"
|
:rules="addFaultGroupFormRules"
|
label-width="80px"
|
>
|
<fks-form-item label="名称" prop="name">
|
<fks-input
|
placeholder="请输入名称"
|
v-model="addFaultGroupForm.name"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
|
<fks-form-item label="标签名称" prop="tagname">
|
<fks-input
|
placeholder="请输入唯一标签名称"
|
v-model="addFaultGroupForm.tagname"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
<fks-form-item label="标签列表">
|
<fks-select
|
style="width: 100%"
|
v-model="addFaultGroupForm.flags"
|
multiple
|
filterable
|
allow-create
|
default-first-option
|
placeholder="请选择或输入标签"
|
>
|
<fks-option
|
v-for="item in addFaultGroupForm.options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</fks-option>
|
</fks-select>
|
</fks-form-item>
|
<fks-form-item label="说明">
|
<fks-input
|
placeholder="请输入说明"
|
type="textarea"
|
:rows="3"
|
autocomplete="off"
|
v-model="addFaultGroupForm.note"
|
>
|
</fks-input>
|
</fks-form-item>
|
</fks-form>
|
<div slot="footer" class="dialog-footer">
|
<fks-button @click="addFaultGroupFormVisible = false"
|
>取 消</fks-button
|
>
|
<fks-button type="primary" @click="addFaultGroup('addFaultGroupForm')"
|
>确 定</fks-button
|
>
|
</div>
|
</fks-dialog>
|
<fks-dialog
|
title="编辑故障分组"
|
width="400px"
|
:visible.sync="editFaultGroupFormVisible"
|
>
|
<span slot="title">
|
<fks-button icon="fks-icon-edit" type="text"></fks-button>
|
|
<span class="fks-dialog__title">编辑故障分组</span>
|
</span>
|
<fks-form
|
:model="editFaultGroupForm"
|
:rules="editFaultGroupFormRules"
|
ref="editFaultGroupForm"
|
label-width="80px"
|
>
|
<fks-form-item label="名称" prop="name">
|
<fks-input
|
placeholder="请输入名称"
|
v-model="editFaultGroupForm.name"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
|
<fks-form-item label="标签名称" prop="tagname">
|
<fks-input
|
placeholder="请输入唯一标签名称"
|
v-model="editFaultGroupForm.tagname"
|
autocomplete="off"
|
></fks-input>
|
</fks-form-item>
|
|
<fks-form-item label="标签列表">
|
<fks-select
|
style="width: 100%"
|
v-model="editFaultGroupForm.flags"
|
multiple
|
filterable
|
allow-create
|
default-first-option
|
placeholder="请选择或输入标签"
|
>
|
<fks-option
|
v-for="item in editFaultGroupForm.options"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</fks-option>
|
</fks-select>
|
</fks-form-item>
|
|
<fks-form-item label="说明">
|
<fks-input
|
placeholder="请输入说明"
|
type="textarea"
|
:rows="3"
|
autocomplete="off"
|
v-model="editFaultGroupForm.note"
|
>
|
</fks-input>
|
</fks-form-item>
|
</fks-form>
|
<div slot="footer" class="dialog-footer">
|
<fks-button @click="editFaultGroupFormVisible = false"
|
>取 消</fks-button
|
>
|
<fks-button
|
type="primary"
|
@click="editFaultGroup('editFaultGroupForm')"
|
>确 定</fks-button
|
>
|
</div>
|
</fks-dialog>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { getDay, maxInArray } from "@/utils/istation/common";
|
import titleBoxVue from "@/views/main/components/titleBox.vue";
|
import treeSelect from "@/views/main/components/treeSelect2.vue";
|
|
import leftTree from "@/views/main/components/leftTreeOrTreeSelectByData.vue";
|
import {
|
GetTreeListByObjectType,
|
GetFaultTreeGroupByCatalogID,
|
AddFaultTreeGroup,
|
EditFaultTreeGroup,
|
GetFaultTreeListByGroupID,
|
AddFaultTreeList,
|
EditFaultTreeList,
|
EditFaultTreeSortCode,
|
EditFaultTreeGroupSortCode,
|
DeleteFaultTreeGroup,
|
FaultTreeGroupIsExistTagName,
|
FaultTreeIsExistTagName,
|
FaultTreeIsExistCode,
|
DeleteFaultTreeList,
|
} from "@/api/fault";
|
import FileSaver from "file-saver";
|
import XLSX from "xlsx";
|
const tableData = [
|
{
|
name: "水泵无法启动",
|
code: "FAULT_PUMP_001",
|
labelName: "",
|
note: "",
|
},
|
{
|
name: "水泵出口压力过低",
|
code: "FAULT_PUMP_002",
|
labelName: "",
|
note: "",
|
},
|
{
|
name: "水泵不吸水",
|
code: "FAULT_PUMP_003",
|
labelName: "",
|
note: "",
|
},
|
{
|
name: "轴承过热",
|
code: "FAULT_PUMP_004",
|
labelName: "",
|
note: "",
|
},
|
];
|
|
/* list数据转成 dtree使用格式 */
|
function treeCorprationDataFormat(data) {
|
if (!Array.isArray(data)) {
|
return data;
|
}
|
let tree = [];
|
const listToTree = (list, tree, parentId, length) => {
|
list.forEach((org) => {
|
// 判断是否为父级菜单
|
if (length == 0) {
|
if (org.ParentIds.length == 0) {
|
let child = org;
|
child.Children = [];
|
// 迭代 list, 找到当前菜单相符合的所有子菜单
|
listToTree(list, child.Children, org.ID, org.ParentIds.length + 1);
|
// 删掉不存在 children 值的属性
|
if (child.Children.length <= 0) {
|
delete child.Children;
|
}
|
// 加入到树中
|
tree.push(child);
|
}
|
} else {
|
if (
|
org.ParentIds.length == length &&
|
org.ParentIds.indexOf(parentId) != -1
|
) {
|
let child = org;
|
child.Children = [];
|
// 迭代 list, 找到当前菜单相符合的所有子菜单
|
listToTree(list, child.Children, org.ID, org.ParentIds.length + 1);
|
// 删掉不存在 children 值的属性
|
if (child.Children.length <= 0) {
|
delete child.Children;
|
}
|
// 加入到树中
|
tree.push(child);
|
}
|
}
|
});
|
};
|
listToTree(data, tree, 0, 0);
|
return tree;
|
}
|
|
/* 根据id获取树id 用于获取默认选中高亮 */
|
function getTreeIdById(list, ID) {
|
let obj = [];
|
if (list.length === 0) {
|
return obj;
|
}
|
const getDtreeId = (obj, list, ID) => {
|
if (ID) {
|
for (var i = 0; i < list.length; i++) {
|
var item = list[i];
|
if (!item.Children) {
|
item.Children = [];
|
}
|
if (item.ID == ID) {
|
obj.push(item);
|
// break;
|
}
|
if (item.Children.length != 0) {
|
getDtreeId(obj, item.Children, ID);
|
}
|
}
|
} else {
|
if (!list[0].Children) {
|
list[0].Children = [];
|
}
|
if (list[0].Children.length == 0) {
|
obj.push(list[0]);
|
}
|
if (list[0].Children.length != 0) {
|
getDtreeId(obj, list[0].Children, ID);
|
}
|
}
|
};
|
getDtreeId(obj, list, ID);
|
return obj;
|
}
|
|
export default {
|
name: "vibrationDemo",
|
components: {
|
titleBoxVue,
|
leftTree,
|
treeSelect,
|
},
|
data() {
|
var validateFaultGroupTagName = async (rule, value, callback) => {
|
if (value !== "") {
|
let bool = await this.faultTreeGroupIsExistTagName(value);
|
if (!bool) {
|
callback();
|
} else {
|
callback(new Error("标签名称已存在"));
|
}
|
}
|
callback();
|
};
|
var validateFaultTagName = async (rule, value, callback) => {
|
if (value !== "") {
|
let bool = await this.faultTreeIsExistTagName(value);
|
if (!bool) {
|
callback();
|
} else {
|
callback(new Error("标签名称已存在"));
|
}
|
}
|
callback();
|
};
|
var validateFaultCode = async (rule, value, callback) => {
|
if (value !== "") {
|
let bool = await this.faultTreeIsExistCode(value);
|
if (!bool) {
|
callback();
|
} else {
|
callback(new Error("故障编码已存在"));
|
}
|
}
|
callback();
|
};
|
var validateFaultGroupTagNameEdit = async (rule, value, callback) => {
|
if (value !== this.editFaultGroupForm.data.TagName) {
|
console.log(value, this.editFaultGroupForm.data, 481);
|
let bool = await this.faultTreeGroupIsExistTagName(value);
|
if (!bool) {
|
callback();
|
} else {
|
callback(new Error("标签名称已存在"));
|
}
|
// this.$refs.ruleForm.validateField('checkPass');
|
}
|
callback();
|
};
|
var validateFaultTagNameEdit = async (rule, value, callback) => {
|
if (value !== this.editFaultForm.data.TagName) {
|
console.log(value, this.editFaultForm.data, 481);
|
let bool = await this.faultTreeIsExistTagName(value);
|
if (!bool) {
|
callback();
|
} else {
|
callback(new Error("标签名称已存在"));
|
}
|
// this.$refs.ruleForm.validateField('checkPass');
|
}
|
callback();
|
};
|
var validateFaultCodeEdit = async (rule, value, callback) => {
|
if (value !== this.editFaultForm.data.Code) {
|
let bool = await this.faultTreeIsExistCode(value);
|
if (!bool) {
|
callback();
|
} else {
|
callback(new Error("故障编码已存在"));
|
}
|
}
|
callback();
|
};
|
return {
|
titleName: "运行故障",
|
tableData: [],
|
multipleSelection: [],
|
addFaultFormVisible: false,
|
editFaultFormVisible: false,
|
addFaultGroupFormVisible: false,
|
editFaultGroupFormVisible: false,
|
treeData: [],
|
/**tree当前选中节点key */
|
currentNodeKey: "",
|
/**tree默认展开节点keys */
|
defaultExpandedKeys: [""],
|
/**treeselect 默认选中值 */
|
defaultSelectValue: "",
|
selectData: [],
|
/**添加故障树表单 */
|
addFaultForm: {
|
name: "",
|
code: "",
|
tagname: "",
|
note: "",
|
sort: 0,
|
flags: [],
|
options: [{ label: "振动", value: "振动" }],
|
},
|
/**添加故障树表单验证规则 */
|
addFaultFormRules: {
|
name: [{ required: true, message: "请输入名称", trigger: "change" }],
|
code: [{ validator: validateFaultCode, trigger: "blur" }],
|
tagname: [{ validator: validateFaultTagName, trigger: "blur" }],
|
},
|
/**编辑故障树表单 */
|
editFaultForm: {
|
name: "",
|
code: "",
|
tagname: "",
|
note: "",
|
sort: "",
|
flags: [],
|
options: [{ label: "振动", value: "振动" }],
|
},
|
/**编辑故障树表单验证规则 */
|
editFaultFormRules: {
|
name: [{ required: true, message: "请输入名称", trigger: "change" }],
|
code: [{ validator: validateFaultCodeEdit, trigger: "blur" }],
|
tagname: [{ validator: validateFaultTagNameEdit, trigger: "blur" }],
|
},
|
/**添加故障树组表单 */
|
addFaultGroupForm: {
|
name: "",
|
sort: 0,
|
parentid: "",
|
note: "",
|
tagname: "",
|
customvalue: "",
|
flags: [],
|
options: [{ label: "振动", value: "振动" }],
|
},
|
/**添加故障树组表单验证规则 */
|
addFaultGroupFormRules: {
|
name: [{ required: true, message: "请输入名称", trigger: "change" }],
|
tagname: [{ validator: validateFaultGroupTagName, trigger: "blur" }],
|
},
|
/**编辑故障树组表单 */
|
editFaultGroupForm: {
|
name: "",
|
tagname: "",
|
note: "",
|
sort: "",
|
flags: [],
|
options: [{ label: "振动", value: "振动" }],
|
},
|
/**编辑故障树组表单验证规则 */
|
editFaultGroupFormRules: {
|
name: [{ required: true, message: "请输入名称", trigger: "change" }],
|
tagname: [
|
{ validator: validateFaultGroupTagNameEdit, trigger: "blur" },
|
],
|
},
|
/**下拉树 默认属性配置 */
|
selectProps: {
|
id: "ID",
|
label: "Name",
|
children: "Children",
|
},
|
/**树 默认属性配置 */
|
treeProps: {
|
id: "ID",
|
label: "Name",
|
children: "Children",
|
},
|
/**公司ID */
|
CorpID: 13,
|
/**当前选中结构类型id */
|
currentCatalogID: "",
|
/**故障树当前选中的节点 */
|
currentFaultTreeNode: null,
|
};
|
},
|
created() {},
|
mounted() {
|
this.getLeftTreeSelectData();
|
},
|
computed: {},
|
watch: {},
|
methods: {
|
faultTreeGroupIsExistTagName(tagname) {
|
return new Promise((r, e) => {
|
let TagName = tagname;
|
FaultTreeGroupIsExistTagName({ TagName: TagName, CorpID: this.CorpID })
|
.then((res) => {
|
// console.log(res, 655);
|
r(res.Data);
|
})
|
.catch((e) => {
|
e(e);
|
});
|
});
|
},
|
faultTreeIsExistTagName(tagname) {
|
return new Promise((r, e) => {
|
let TagName = tagname;
|
FaultTreeIsExistTagName({ TagName: TagName, CorpID: this.CorpID })
|
.then((res) => {
|
console.log(res, 633);
|
r(res.Data);
|
})
|
.catch((e) => {
|
e(e);
|
});
|
});
|
},
|
faultTreeIsExistCode(code) {
|
return new Promise((r, e) => {
|
let Code = code;
|
FaultTreeIsExistCode({ Code: Code, CorpID: this.CorpID })
|
.then((res) => {
|
console.log(res, 643);
|
r(res.Data);
|
})
|
.catch((e) => {
|
e(e);
|
});
|
});
|
},
|
/**获取下拉选择数据 */
|
getLeftTreeSelectData() {
|
GetTreeListByObjectType({ CorpID: this.CorpID, ObjectType: "设备" })
|
.then((res) => {
|
// console.log(res, 433);
|
let resdata = [];
|
if (res && res.Data) {
|
resdata = res.Data;
|
}
|
this.selectData = resdata;
|
this.defaultSelectValue = resdata[0]?.ID;
|
this.currentCatalogID = this.defaultSelectValue;
|
this.getLeftTreeData();
|
})
|
.catch((err) => {});
|
},
|
/**获取树结构数据 */
|
getLeftTreeData() {
|
let CatalogID = this.currentCatalogID;
|
this.currentNodeKey = "";
|
this.currentFaultTreeNode = null;
|
if (!CatalogID) {
|
this.treeData = [];
|
return;
|
}
|
GetFaultTreeGroupByCatalogID({
|
CatalogID: CatalogID,
|
CorpID: this.CorpID,
|
}).then(async (res) => {
|
// console.log(res, 379);
|
let resdata = [];
|
if (res && res.Data) {
|
resdata = res.Data;
|
}
|
let treedata = await treeCorprationDataFormat(resdata);
|
this.defaultExpandedKeys = [treedata[0]?.ID];
|
let currentnode = getTreeIdById(treedata, treedata[0]?.ID);
|
this.currentNodeKey = currentnode[0]?.ID;
|
this.currentFaultTreeNode = currentnode[0];
|
this.titleName = currentnode[0]?.Name;
|
this.treeData = treedata;
|
this.getTableData();
|
});
|
},
|
/**下拉选择变化 */
|
selectchange(label, node) {
|
// console.log(label, node, 186);
|
if (!node) {
|
this.currentCatalogID = "";
|
return;
|
}
|
let CatalogID = node?.ID;
|
this.currentCatalogID = CatalogID;
|
this.getLeftTreeData();
|
},
|
/**树点击事件 */
|
handleNodeClick(data) {
|
// console.log(data, 74);
|
this.titleName = data.Name;
|
this.currentNodeKey = data?.ID;
|
this.currentFaultTreeNode = data;
|
// console.log(this.currentFaultTreeNode,data,601)
|
this.getTableData();
|
},
|
|
getTableData() {
|
let GroupID = this.currentNodeKey;
|
if (!GroupID) {
|
this.tableData = [];
|
return;
|
}
|
GetFaultTreeListByGroupID({ CorpID: this.CorpID, GroupID: GroupID }).then(
|
(res) => {
|
// console.log(res, 581);
|
let resdata = [];
|
if (res && res.Data) {
|
resdata = res.Data;
|
}
|
|
this.tableData = resdata;
|
}
|
);
|
},
|
/**表格复选框变化事件 */
|
handleSelectionChange(val) {
|
this.multipleSelection = val;
|
},
|
|
addFaultTreeFormVisible() {
|
this.addFaultFormVisible = true;
|
},
|
/**提交故障树组 */
|
addFaultGroup(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
this.addFaultGroupFormVisible = false;
|
let formdata = this.addFaultGroupForm;
|
|
let ParentIds = [];
|
let sort = 0;
|
if (this.currentFaultTreeNode) {
|
ParentIds = JSON.parse(
|
JSON.stringify(this.currentFaultTreeNode.ParentIds)
|
);
|
ParentIds.push(this.currentFaultTreeNode.ID);
|
if (this.currentFaultTreeNode.Children.length > 0) {
|
let sorts = this.currentFaultTreeNode.Children.map((x) => {
|
return x.SortCode;
|
});
|
let maxSort = maxInArray(sorts);
|
sort = this.currentFaultTreeNode.Children.length;
|
}
|
}
|
|
let postdata = {
|
CorpID: this.CorpID,
|
CatalogID: this.currentCatalogID,
|
ParentIds: ParentIds,
|
Name: formdata.name,
|
Flags: formdata.flags,
|
TagName: formdata.tagname,
|
SortCode: sort,
|
Description: formdata.note,
|
};
|
console.log(postdata, formdata, 699);
|
|
// return;
|
AddFaultTreeGroup(postdata).then((res) => {
|
// console.log(res, 441);
|
|
if (res.Data) {
|
this.getLeftTreeData();
|
this.$message({
|
message: "添加成功",
|
type: "success",
|
});
|
} else {
|
this.$message({
|
message: "添加失败",
|
type: "error",
|
});
|
}
|
});
|
} else {
|
console.log("error submit!!");
|
return false;
|
}
|
});
|
},
|
addFaultList(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
this.addFaultFormVisible = false;
|
let formdata = this.addFaultForm;
|
let sort = this.tableData.length;
|
|
let postdata = {
|
CorpID: this.CorpID,
|
GroupID: this.currentNodeKey,
|
Code: formdata.code,
|
Name: formdata.name,
|
Flags: formdata.flags,
|
TagName: formdata.tagname,
|
SortCode: sort,
|
Description: formdata.note,
|
};
|
|
// return;
|
AddFaultTreeList(postdata).then((res) => {
|
// console.log(res, 686);
|
|
if (res.Data) {
|
this.getTableData();
|
this.addFaultForm.flags = [];
|
this.$refs[formName].resetFields();
|
this.$message({
|
message: "添加成功",
|
type: "success",
|
});
|
} else {
|
this.$message({
|
message: "添加失败",
|
type: "error",
|
});
|
}
|
});
|
} else {
|
console.log("error submit!!");
|
return false;
|
}
|
});
|
},
|
|
/**树节点编辑事件 */
|
treeEdit(data, node) {
|
console.log(data, node, 358);
|
this.editFaultGroupFormVisible = true;
|
this.editFaultGroupForm.name = data.Name;
|
this.editFaultGroupForm.tagname = data.TagName;
|
this.editFaultGroupForm.note = data.Description;
|
this.editFaultGroupForm.sort = data.SortCode;
|
this.editFaultGroupForm.flags = data.Flags;
|
this.editFaultGroupForm.data = data;
|
},
|
/**树节点编辑事件 */
|
treeDelete(data, node) {
|
console.log(data, node, 737);
|
let ID = data?.ID;
|
if (!ID) {
|
this.$message({
|
type: "error",
|
message: "删除失败,删除元素ID不能为空",
|
});
|
return;
|
}
|
this.$confirm("此操作将永久删除, 是否继续?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
DeleteFaultTreeGroup({ ID: ID, CorpID: this.CorpID }).then((res) => {
|
// console.log(res, 733);
|
if (res.Data) {
|
if (res.Data.Success) {
|
this.getLeftTreeData();
|
this.$message({
|
message: "删除成功",
|
type: "success",
|
});
|
} else {
|
let reason = res.Data?.Reason || "";
|
this.$message({
|
message: "删除失败,原因:" + reason,
|
type: "error",
|
});
|
}
|
} else {
|
this.$message({
|
message: res.Message,
|
type: "error",
|
});
|
}
|
});
|
})
|
.catch((err) => {
|
this.$message({
|
type: "info",
|
message: "已取消删除",
|
description: err.message,
|
});
|
});
|
},
|
editFaultGroup(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
this.editFaultGroupFormVisible = false;
|
let formdata = this.editFaultGroupForm;
|
|
// console.log(formdata, 653);
|
let postdata = {
|
ID: formdata.data.ID,
|
CorpID: this.CorpID,
|
Name: formdata.name,
|
Flags: formdata.flags,
|
TagName: formdata.tagname,
|
Description: formdata.note,
|
};
|
|
// return;
|
EditFaultTreeGroup(postdata).then((res) => {
|
// console.log(res, 666);
|
|
if (res.Data) {
|
this.getLeftTreeData();
|
this.$message({
|
message: "编辑成功",
|
type: "success",
|
});
|
} else {
|
this.$message({
|
message: "编辑失败",
|
type: "error",
|
});
|
}
|
});
|
} else {
|
// console.log("error submit!!");
|
return false;
|
}
|
});
|
},
|
/**表格编辑事件 */
|
editFault(row) {
|
this.editFaultFormVisible = true;
|
this.editFaultForm.name = row.Name;
|
this.editFaultForm.code = row.Code;
|
this.editFaultForm.tagname = row.TagName;
|
this.editFaultForm.note = row.Description;
|
this.editFaultForm.sort = row.SortCode;
|
this.editFaultForm.flags = row.Flags;
|
this.editFaultForm.data = row;
|
// console.log(row, 771);
|
},
|
deleteFault(row) {
|
console.log(row, 1025);
|
let ID = row.ID;
|
this.$confirm("此操作将永久删除, 是否继续?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
DeleteFaultTreeList({ ID: ID, CorpID: this.CorpID }).then((res) => {
|
console.log(res, 1020);
|
if (res.Data) {
|
if (res.Data.Success) {
|
this.getTableData();
|
this.$message({
|
message: "删除成功",
|
type: "success",
|
});
|
} else {
|
let reason = res.Data?.Reason || "";
|
this.$message({
|
message: "删除失败,原因:" + reason,
|
type: "error",
|
});
|
}
|
} else {
|
this.$message({
|
message: "删除失败",
|
type: "error",
|
});
|
}
|
});
|
})
|
.catch((err) => {
|
this.$message({
|
type: "info",
|
message: "已取消删除",
|
description: err.message,
|
});
|
});
|
},
|
editFaultList(formName) {
|
this.$refs[formName].validate((valid) => {
|
if (valid) {
|
this.editFaultFormVisible = false;
|
let formdata = this.editFaultForm;
|
|
// console.log(formdata, 653);
|
let postdata = {
|
ID: formdata.data.ID,
|
CorpID: this.CorpID,
|
Code: formdata.code,
|
Name: formdata.name,
|
Flags: formdata.flags,
|
TagName: formdata.tagname,
|
Description: formdata.note,
|
};
|
console.log(postdata, 809);
|
|
// return;
|
EditFaultTreeList(postdata).then((res) => {
|
// console.log(res, 813);
|
|
if (res.Data) {
|
this.getTableData();
|
this.$message({
|
message: "编辑成功",
|
type: "success",
|
});
|
} else {
|
this.$message({
|
message: "编辑失败",
|
type: "error",
|
});
|
}
|
});
|
} else {
|
// console.log("error submit!!");
|
return false;
|
}
|
});
|
},
|
updateFaultSortCode(postdata) {
|
EditFaultTreeSortCode(postdata).then((res) => {
|
// console.log(res, 823);
|
|
if (res.Data) {
|
this.getTableData();
|
// this.$message({
|
// message: "编辑成功",
|
// type: "success",
|
// });
|
} else {
|
// this.$message({
|
// message: "编辑失败",
|
// type: "error",
|
// });
|
}
|
});
|
},
|
updateFaultGroupSortCode(postdata) {
|
EditFaultTreeGroupSortCode(postdata).then((res) => {
|
// console.log(res, 852);
|
|
if (res.Data) {
|
this.getLeftTreeData();
|
// this.$message({
|
// message: "编辑成功",
|
// type: "success",
|
// });
|
} else {
|
// this.$message({
|
// message: "编辑失败",
|
// type: "error",
|
// });
|
}
|
});
|
},
|
},
|
};
|
</script>
|
<style scoped>
|
.boxright {
|
flex: 1;
|
height: 100%;
|
overflow: auto;
|
background: transparent;
|
margin-left: 20px;
|
}
|
|
.titleSlotRight {
|
display: flex;
|
align-items: center;
|
justify-content: flex-end;
|
}
|
</style>
|