290 lines
10 KiB
Vue
290 lines
10 KiB
Vue
![]() |
<template>
|
||
|
<section class="app-container">
|
||
|
<el-row>
|
||
|
<el-col :span="24">
|
||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||
|
<el-form-item label="topicID">
|
||
|
<el-input v-model="queryParams.topicId" placeholder="请输入topicID" clearable size="small" style="width: 240px"
|
||
|
@keyup.enter.native="handleQuery" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="groupID">
|
||
|
<el-input v-model="queryParams.groupId" placeholder="请输入groupID" clearable size="small" style="width: 240px"
|
||
|
@keyup.enter.native="handleQuery" />
|
||
|
</el-form-item>
|
||
|
<el-form-item>
|
||
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||
|
</el-form-item>
|
||
|
</el-form>
|
||
|
<el-row :gutter="10" class="mb8">
|
||
|
<el-col :span="1.5">
|
||
|
<el-button size="mini" type="primary" icon="el-icon-plus" @click="handleAdd">增加</el-button>
|
||
|
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete">批量删除</el-button>
|
||
|
</el-col>
|
||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||
|
</el-row>
|
||
|
<el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
|
||
|
<el-table-column type="selection" width="55" align="center">
|
||
|
</el-table-column>
|
||
|
<el-table-column prop="topicId" align="center" label="topicID">
|
||
|
</el-table-column>
|
||
|
<el-table-column prop="groupId" align="center" label="groupID">
|
||
|
</el-table-column>
|
||
|
<el-table-column prop="remark" align="center" label="备注">
|
||
|
</el-table-column>
|
||
|
<el-table-column prop="status" align="center" label="状态">
|
||
|
</el-table-column>
|
||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300px">
|
||
|
<template slot-scope="scope">
|
||
|
<!-- <el-button size="mini" type="text" icon="el-icon-view" @click="handleview(scope.row)">查看</el-button> -->
|
||
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleEditPro(scope.row)">编辑项目</el-button>
|
||
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||
|
<el-button class="text-danger" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||
|
</template>
|
||
|
</el-table-column>
|
||
|
</el-table>
|
||
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
||
|
@pagination="getList" />
|
||
|
</el-col>
|
||
|
</el-row>
|
||
|
<!-- 添加参数配置对话框 -->
|
||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||
|
<el-form-item label="topicID" prop="topicId">
|
||
|
<el-input v-model="form.topicId" :disabled="!!form.id" placeholder="请输入topicID" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="groupID" prop="groupId">
|
||
|
<el-input v-model="form.groupId" :disabled="!!form.id" placeholder="请输入groupID" />
|
||
|
</el-form-item>
|
||
|
<el-form-item label="备注">
|
||
|
<el-input v-model="form.remark" />
|
||
|
</el-form-item>
|
||
|
</el-form>
|
||
|
<div slot="footer" class="dialog-footer">
|
||
|
<el-button type="primary" @click="submit">确 定</el-button>
|
||
|
<el-button @click="cancel">取 消</el-button>
|
||
|
</div>
|
||
|
</el-dialog>
|
||
|
<!-- 关联项目参数配置对话框 -->
|
||
|
<el-dialog :title="title" :visible.sync="projectListOpen" width="800px" append-to-body>
|
||
|
<el-checkbox-group v-model="projectIds">
|
||
|
<el-row>
|
||
|
<el-col style="margin-bottom: 15px" :span="12" v-for="data in projectList" :key="data.projectId">
|
||
|
<el-checkbox size="medium" :label="data.projectId">{{data.projectName}}</el-checkbox>
|
||
|
</el-col>
|
||
|
</el-row>
|
||
|
</el-checkbox-group>
|
||
|
<!-- <el-table :data="projectList" @selection-change="handleProjectSelectionChange">
|
||
|
<el-table-column type="selection" width="55" align="center">
|
||
|
</el-table-column>
|
||
|
<el-table-column prop="projectName" align="center" label="项目名称">
|
||
|
</el-table-column>
|
||
|
</el-table> -->
|
||
|
<div slot="footer" class="dialog-footer">
|
||
|
<el-button type="primary" @click="submitPro">确 定</el-button>
|
||
|
<el-button @click="cancel">取 消</el-button>
|
||
|
</div>
|
||
|
</el-dialog>
|
||
|
<!-- 查看项目列表弹框 -->
|
||
|
<!-- <el-dialog title="项目管理列表" :visible.sync="projectManagementOpen">
|
||
|
<el-row class="mb8">
|
||
|
<el-button type="danger" icon="el-icon-delete" size="mini" @click="batchHandleDelete">批量删除</el-button>
|
||
|
</el-row>
|
||
|
<el-table :data="proData" style="width: 100%" @selection-change="handleSelectionChange">
|
||
|
<el-table-column type="selection" width="55" align="center">
|
||
|
</el-table-column>
|
||
|
<el-table-column prop="projectId" align="center" label="项目ID">
|
||
|
</el-table-column>
|
||
|
<el-table-column prop="projectName" align="center" label="项目名称">
|
||
|
</el-table-column>
|
||
|
<el-table-column prop="topicId" align="center" label="topicId">
|
||
|
</el-table-column>
|
||
|
</el-table>
|
||
|
</el-dialog> -->
|
||
|
</section>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import { list, info, add, del, select } from "@/api/topicInfo/info";
|
||
|
import { ProList, ProInfo, save, saves, ProDel, ProSelect } from "@/api/topicInfo/management";
|
||
|
import { select as proSelect } from "@/api/hardware/project";
|
||
|
export default {
|
||
|
name: "InfoList",
|
||
|
data () {
|
||
|
return {
|
||
|
// 选中数组
|
||
|
ids: [],
|
||
|
projectIds: [],
|
||
|
// 所有项目
|
||
|
projectList: [],
|
||
|
// 表格数据
|
||
|
tableData: [],
|
||
|
proData: [],
|
||
|
// 显示搜索条件
|
||
|
showSearch: true,
|
||
|
// 总条数
|
||
|
total: 0,
|
||
|
// 弹出层标题
|
||
|
title: "",
|
||
|
// 是否显示弹出层
|
||
|
open: false,
|
||
|
projectListOpen: false,
|
||
|
projectManagementOpen: false,
|
||
|
// 表单参数
|
||
|
form: {},
|
||
|
// 查询参数
|
||
|
queryParams: {
|
||
|
pageNum: 1,
|
||
|
pageSize: 10
|
||
|
},
|
||
|
snapRow: {},
|
||
|
select: {},
|
||
|
row: {},
|
||
|
rules: {
|
||
|
topicId: [
|
||
|
{ required: true, message: "topicID不能为空", trigger: "blur" },
|
||
|
],
|
||
|
groupId: [
|
||
|
{ required: true, message: "groupID不能为空", trigger: "blur" },
|
||
|
]
|
||
|
},
|
||
|
}
|
||
|
},
|
||
|
created () {
|
||
|
this.getProjectList()
|
||
|
this.getList()
|
||
|
},
|
||
|
methods: {
|
||
|
// 获取Topic列表
|
||
|
getList () {
|
||
|
list(this.queryParams).then((res) => {
|
||
|
this.tableData = res.rows;
|
||
|
this.total = res.total;
|
||
|
});
|
||
|
},
|
||
|
// 获取项目列表
|
||
|
getProjectList () {
|
||
|
this.projectList = [];
|
||
|
proSelect().then((response) => {
|
||
|
this.projectList = response.select;
|
||
|
});
|
||
|
},
|
||
|
// 获取列表
|
||
|
getManagementList () {
|
||
|
ProList(this.queryParams).then((res) => {
|
||
|
this.proData = res.rows;
|
||
|
});
|
||
|
},
|
||
|
/** 搜索按钮操作 */
|
||
|
handleQuery () {
|
||
|
this.queryParams.pageNum = 1;
|
||
|
this.getList();
|
||
|
},
|
||
|
/** 重置按钮操作 */
|
||
|
resetQuery () {
|
||
|
this.queryParams = {};
|
||
|
this.resetForm("queryForm");
|
||
|
this.handleQuery();
|
||
|
},
|
||
|
/** 新增按钮操作 */
|
||
|
handleAdd () {
|
||
|
this.reset();
|
||
|
this.open = true;
|
||
|
this.title = "添加topic";
|
||
|
},
|
||
|
/** 修改按钮操作 */
|
||
|
handleUpdate (row) {
|
||
|
this.reset();
|
||
|
this.form = Object.assign({}, row);
|
||
|
this.open = true;
|
||
|
this.title = "修改topic";
|
||
|
},
|
||
|
/** 提交按钮 */
|
||
|
submit () {
|
||
|
add(this.form).then(res => {
|
||
|
this.open = false;
|
||
|
this.getList()
|
||
|
})
|
||
|
},
|
||
|
// handleview (row) {
|
||
|
// this.row = row;
|
||
|
// ProSelect(row.topicId).then(response => {
|
||
|
// this.snspPro = response.select.map(v => v.topicId);
|
||
|
// this.projectManagementOpen = true;
|
||
|
// });
|
||
|
// },
|
||
|
handleEditPro (row) {
|
||
|
ProSelect(row.topicId).then(response => {
|
||
|
this.projectIds = response.select.map(v => v.projectId);
|
||
|
});
|
||
|
this.snapRow = Object.assign({}, row);
|
||
|
this.projectListOpen = true;
|
||
|
},
|
||
|
submitPro () {
|
||
|
console.log(this.snapRow.topicId)
|
||
|
console.log(this.projectIds)
|
||
|
saves({ topicId: this.snapRow.topicId, projectIds: this.projectIds }).then(res => {
|
||
|
if (200 == res.code) {
|
||
|
this.msgSuccess(res.msg);
|
||
|
this.projectListOpen = false;
|
||
|
this.getProjectList()
|
||
|
} else {
|
||
|
this.msgError(res.msg);
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
/** 删除按钮操作 */
|
||
|
handleDelete (row) {
|
||
|
const ids = row.id || this.ids;
|
||
|
this.$confirm("是否确认删除?", "警告", {
|
||
|
confirmButtonText: "确定",
|
||
|
cancelButtonText: "取消",
|
||
|
type: "warning",
|
||
|
})
|
||
|
.then(() => {
|
||
|
return del(ids);
|
||
|
})
|
||
|
.then((res) => {
|
||
|
if (200 == res.code) {
|
||
|
this.getList();
|
||
|
this.msgSuccess("删除成功");
|
||
|
} else {
|
||
|
this.msgError(res.msg);
|
||
|
}
|
||
|
})
|
||
|
.catch((res) => { });
|
||
|
},
|
||
|
|
||
|
// 批量删除项目
|
||
|
batchHandleDelete () { },
|
||
|
// 表单重置
|
||
|
reset () {
|
||
|
this.form = {
|
||
|
topicId: "",
|
||
|
groupId: "",
|
||
|
status: "",
|
||
|
};
|
||
|
this.resetForm("form");
|
||
|
},
|
||
|
// 取消按钮
|
||
|
cancel () {
|
||
|
this.open = false;
|
||
|
this.projectListOpen = false;
|
||
|
this.reset();
|
||
|
},
|
||
|
// 多选框选中数据
|
||
|
handleSelectionChange (selection) {
|
||
|
this.ids = selection.map((item) => item.id);
|
||
|
this.multiple = !selection.length;
|
||
|
},
|
||
|
handleProjectSelectionChange (selection) {
|
||
|
this.projectIds = selection.map((item) => item.id);
|
||
|
this.multiple = !selection.length;
|
||
|
},
|
||
|
}
|
||
|
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style>
|
||
|
</style>
|