|
|
|
|
<template>
|
|
|
|
|
<div class="cus-container">
|
|
|
|
|
<el-form :model="searchForm">
|
|
|
|
|
<div class="search">
|
|
|
|
|
<div style="display: flex; align-items: center">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="searchForm.projectInfoId"
|
|
|
|
|
placeholder="系统名称"
|
|
|
|
|
class="search-select"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in projectList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.projectName"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
>
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="searchForm.moduleName"
|
|
|
|
|
placeholder="模块名称"
|
|
|
|
|
class="search-select"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in moduleNamesList"
|
|
|
|
|
:key="item.moduleName"
|
|
|
|
|
:label="item.moduleName"
|
|
|
|
|
:value="item.moduleName"
|
|
|
|
|
>
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="searchForm.manageDeptId"
|
|
|
|
|
placeholder="管理部门"
|
|
|
|
|
class="search-select"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in deptsList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.fullName"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
>
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="searchForm.maintenanceDeptId"
|
|
|
|
|
placeholder="运维公司"
|
|
|
|
|
class="search-select"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in usersList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.name"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
>
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
<div style="display: flex">
|
|
|
|
|
<el-button class="search-btn" @click="searchHandle(1)"
|
|
|
|
|
>查询</el-button
|
|
|
|
|
>
|
|
|
|
|
<div class="search-reset" @click="searchHandle(2)">
|
|
|
|
|
<i class="el-icon-refresh-right" style="font-size: 20px"></i>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div style="display: flex">
|
|
|
|
|
|
|
|
|
|
<el-button
|
|
|
|
|
class="search-btn"
|
|
|
|
|
style="margin: 0; background: #2ee27c"
|
|
|
|
|
@click="addHandle"
|
|
|
|
|
>新增</el-button
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-form>
|
|
|
|
|
<div style="margin-top: 30px">
|
|
|
|
|
<avue-crud
|
|
|
|
|
id="avue-id"
|
|
|
|
|
ref="crud"
|
|
|
|
|
v-model="form"
|
|
|
|
|
:option="option"
|
|
|
|
|
:data="tableData"
|
|
|
|
|
:page.sync="page"
|
|
|
|
|
:table-loading="loading"
|
|
|
|
|
@row-save="rowSave"
|
|
|
|
|
@row-update="rowUpdate"
|
|
|
|
|
@row-del="rowDel"
|
|
|
|
|
@current-change="currentChange"
|
|
|
|
|
@size-change="sizeChange"
|
|
|
|
|
>
|
|
|
|
|
<template slot-scope="scope" slot="menu">
|
|
|
|
|
<el-button type="primary" @click="editHandle(scope.row)"
|
|
|
|
|
>编辑
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="danger" @click="rowDel(scope.row)">删除 </el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</avue-crud>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import {
|
|
|
|
|
getList,
|
|
|
|
|
add,
|
|
|
|
|
update,
|
|
|
|
|
remove,
|
|
|
|
|
getDictionaries,
|
|
|
|
|
} from "@/api/maintenance/system.js";
|
|
|
|
|
import { tableOption } from "@/const/maintenance/system.js";
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
form: {
|
|
|
|
|
moduleNameList: [
|
|
|
|
|
{
|
|
|
|
|
moduleName: "",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
searchForm: {},
|
|
|
|
|
option: tableOption,
|
|
|
|
|
page: {
|
|
|
|
|
current: 1,
|
|
|
|
|
total: 0,
|
|
|
|
|
size: 10,
|
|
|
|
|
},
|
|
|
|
|
// 表格数据
|
|
|
|
|
tableData: [],
|
|
|
|
|
loading: false,
|
|
|
|
|
// 4个字典下拉
|
|
|
|
|
usersList: [],
|
|
|
|
|
deptsList: [],
|
|
|
|
|
projectList: [],
|
|
|
|
|
moduleNamesList: [],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.getDict();
|
|
|
|
|
this.onLoad();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 字典请求
|
|
|
|
|
getDict() {
|
|
|
|
|
getDictionaries().then((res) => {
|
|
|
|
|
const { depts, moduleNames, projectNames, users } = res.data.data;
|
|
|
|
|
// 系统
|
|
|
|
|
this.projectList = projectNames;
|
|
|
|
|
const projectNamesColumn = this.findObject(
|
|
|
|
|
this.option.column,
|
|
|
|
|
"projectName"
|
|
|
|
|
);
|
|
|
|
|
projectNamesColumn.dicData = projectNames;
|
|
|
|
|
// 部门
|
|
|
|
|
this.deptsList = depts;
|
|
|
|
|
const deptsColumn = this.findObject(this.option.column, "manageDeptId");
|
|
|
|
|
deptsColumn.dicData = depts;
|
|
|
|
|
// 运维公司
|
|
|
|
|
this.usersList = users;
|
|
|
|
|
const usersColumn = this.findObject(
|
|
|
|
|
this.option.column,
|
|
|
|
|
"maintenanceDeptId"
|
|
|
|
|
);
|
|
|
|
|
usersColumn.dicData = users;
|
|
|
|
|
// 模块
|
|
|
|
|
this.moduleNamesList = moduleNames;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 列表
|
|
|
|
|
onLoad() {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
const { current, size } = this.page;
|
|
|
|
|
getList({ current, size, ...this.searchForm }).then((res) => {
|
|
|
|
|
const { total, records } = res.data.data;
|
|
|
|
|
this.page.total = total;
|
|
|
|
|
this.tableData = records;
|
|
|
|
|
this.loading = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 分页
|
|
|
|
|
currentChange(currentPage) {
|
|
|
|
|
this.page.current = currentPage;
|
|
|
|
|
this.onLoad();
|
|
|
|
|
},
|
|
|
|
|
sizeChange(pageSize) {
|
|
|
|
|
this.page.size = pageSize;
|
|
|
|
|
this.onLoad();
|
|
|
|
|
},
|
|
|
|
|
// 查询重置
|
|
|
|
|
searchHandle(index) {
|
|
|
|
|
this.page.current = 1;
|
|
|
|
|
if (index === 2) {
|
|
|
|
|
this.searchForm = {};
|
|
|
|
|
}
|
|
|
|
|
this.onLoad();
|
|
|
|
|
},
|
|
|
|
|
// 新增
|
|
|
|
|
addHandle() {
|
|
|
|
|
this.form = {
|
|
|
|
|
moduleNameList: [
|
|
|
|
|
{
|
|
|
|
|
moduleName: "",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
this.$refs.crud.rowAdd();
|
|
|
|
|
},
|
|
|
|
|
editHandle(row) {
|
|
|
|
|
this.$refs.crud.rowEdit(row);
|
|
|
|
|
},
|
|
|
|
|
// 新增
|
|
|
|
|
rowSave(row, done, loading) {
|
|
|
|
|
add(row).then(
|
|
|
|
|
(res) => {
|
|
|
|
|
const data = res.data.data;
|
|
|
|
|
row.id = data.id;
|
|
|
|
|
this.$message({ type: "success", message: "新增成功!" });
|
|
|
|
|
this.onLoad();
|
|
|
|
|
this.getDict();
|
|
|
|
|
// 数据回调进行刷新
|
|
|
|
|
done(row);
|
|
|
|
|
},
|
|
|
|
|
(error) => {
|
|
|
|
|
window.console.log(error);
|
|
|
|
|
loading();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
// 编辑
|
|
|
|
|
rowUpdate(row, index, done, loading) {
|
|
|
|
|
update(row).then(
|
|
|
|
|
() => {
|
|
|
|
|
this.onLoad(this.page);
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "success",
|
|
|
|
|
message: "修改成功!",
|
|
|
|
|
});
|
|
|
|
|
done();
|
|
|
|
|
},
|
|
|
|
|
(error) => {
|
|
|
|
|
window.console.log(error);
|
|
|
|
|
loading();
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
// 行删除
|
|
|
|
|
rowDel(row) {
|
|
|
|
|
this.$confirm("此操作会删除该数据,且无法恢复,确定删除数据?", "提示", {
|
|
|
|
|
confirmButtonText: "确定",
|
|
|
|
|
cancelButtonText: "取消",
|
|
|
|
|
type: "warning",
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
remove(row.id).then((res) => {
|
|
|
|
|
// 测试用的假方法
|
|
|
|
|
console.log(res);
|
|
|
|
|
this.$message.success("删除成功!");
|
|
|
|
|
this.onLoad(this.page[0]);
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
// this.$message({ type: "info", message: "已取消删除" });
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.search {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
.search-select {
|
|
|
|
|
width: 150px;
|
|
|
|
|
margin-right: 20px;
|
|
|
|
|
}
|
|
|
|
|
.search-input {
|
|
|
|
|
width: 288px;
|
|
|
|
|
}
|
|
|
|
|
.search-btn {
|
|
|
|
|
width: 130px;
|
|
|
|
|
height: 46px !important;
|
|
|
|
|
background: #2e92f6;
|
|
|
|
|
color: #fff;
|
|
|
|
|
margin: 0 20px;
|
|
|
|
|
}
|
|
|
|
|
.search-reset {
|
|
|
|
|
width: 46px;
|
|
|
|
|
height: 44px !important;
|
|
|
|
|
background: #ff9130;
|
|
|
|
|
margin-left: 0px;
|
|
|
|
|
color: #fff;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 46px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
/deep/ .el-input__inner {
|
|
|
|
|
height: 46px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|