|
@@ -0,0 +1,350 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="app-container">
|
|
|
|
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
|
|
|
|
+ <el-form-item label="参数名称" prop="menuName">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="queryParams.name"
|
|
|
|
+ placeholder="请输入参数名称"
|
|
|
|
+ clearable
|
|
|
|
+ @keyup.enter.native="handleQuery"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="所属分类" prop="categoryId">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="queryParams.categoryId"
|
|
|
|
+ clearable
|
|
|
|
+ style="width: 240px">
|
|
|
|
+ <el-option v-for="item in categoryList" :key="item.id" :label="item.categoryName" :value="item.id"/>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-button type="primary" 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
|
|
|
|
+ type="primary"
|
|
|
|
+ plain
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
+ size="mini"
|
|
|
|
+ @click="handleAdd"
|
|
|
|
+ v-hasPermi="['document:techparam:add']"
|
|
|
|
+ >新增
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="1.5">
|
|
|
|
+ <el-button
|
|
|
|
+ type="info"
|
|
|
|
+ plain
|
|
|
|
+ icon="el-icon-sort"
|
|
|
|
+ size="mini"
|
|
|
|
+ @click="toggleExpandAll"
|
|
|
|
+ >展开/折叠
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-table
|
|
|
|
+ v-if="refreshTable"
|
|
|
|
+ :data="menuList"
|
|
|
|
+ row-key="id"
|
|
|
|
+ size="small"
|
|
|
|
+ :default-expand-all="isExpandAll"
|
|
|
|
+ :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
|
|
|
+ <el-table-column prop="name" label="参数名称" :show-overflow-tooltip="true" width="160"></el-table-column>
|
|
|
|
+ <el-table-column prop="categoryName" label="所属分类"></el-table-column>
|
|
|
|
+ <el-table-column prop="perms" label="产品名称"></el-table-column>
|
|
|
|
+ <el-table-column prop="component" label="组件路径"></el-table-column>
|
|
|
|
+ <el-table-column prop="updateUserName" label="修改人"/>
|
|
|
|
+ <el-table-column label="修改时间" align="center" prop="createTime">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <span>{{ parseTime(scope.row.createTime) }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-button
|
|
|
|
+ size="mini"
|
|
|
|
+ type="text"
|
|
|
|
+ icon="el-icon-edit"
|
|
|
|
+ @click="handleUpdate(scope.row)"
|
|
|
|
+ v-hasPermi="['document:techparam:edit']"
|
|
|
|
+ >修改
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ size="mini"
|
|
|
|
+ type="text"
|
|
|
|
+ icon="el-icon-view"
|
|
|
|
+ @click="handleDelete(scope.row)"
|
|
|
|
+ v-hasPermi="['document:techparam:query']"
|
|
|
|
+ >查看
|
|
|
|
+ </el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+
|
|
|
|
+ <!-- 添加或修改参数对话框 -->
|
|
|
|
+ <el-dialog :title="title" :visible.sync="open" width="680px" append-to-body>
|
|
|
|
+ <el-form ref="form" class="form" :model="form" :rules="rules" size="mini" label-width="80px">
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="12">
|
|
|
|
+ <el-form-item label="参数名称" prop="name">
|
|
|
|
+ <el-input v-model="form.name" placeholder="请输入参数名称" style="width: 240px"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="12">
|
|
|
|
+ <el-form-item label="参数类型" prop="paramType">
|
|
|
|
+ <el-radio-group v-model="form.paramType">
|
|
|
|
+ <el-radio label="1">系统参数</el-radio>
|
|
|
|
+ <el-radio label="2">模块参数</el-radio>
|
|
|
|
+ </el-radio-group>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="12">
|
|
|
|
+ <el-form-item label="所属分类" prop="categoryId">
|
|
|
|
+ <el-select
|
|
|
|
+ v-model="queryParams.categoryId"
|
|
|
|
+ clearable
|
|
|
|
+ style="width: 240px">
|
|
|
|
+ <el-option v-for="item in categoryList" :key="item.id" :label="item.categoryName" :value="item.id"/>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="12">
|
|
|
|
+ <el-form-item label="产品名称" prop="productName">
|
|
|
|
+ <el-input v-model="form.productName" placeholder="请输入产品名称" style="width: 240px"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-form-item label="参数详情" prop="path">
|
|
|
|
+ <el-button type="primary" size="mini" icon="el-icon-circle-plus-outline" @click="addChild">添加</el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-card class="form-child" shadow="always" v-for="(child,index) in form.children" :key="index">
|
|
|
|
+ <el-form :rules="rules" label-width="55px" inline>
|
|
|
|
+ <el-form-item :label="'参数'+(index+1)">
|
|
|
|
+ <el-input v-model="child.name" size="small" placeholder="请输入参数名称" style="width: 200px"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-input v-model="child.value" size="small" placeholder="请输入参数值" style="width: 325px"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-button type="text" icon="el-icon-delete" @click="delChild(index)" style="color: red"></el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-card>
|
|
|
|
+
|
|
|
|
+ </el-form>
|
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+import {listMenu, getMenu, delMenu, addMenu, updateMenu} from "@/api/system/menu";
|
|
|
|
+import {getCategoryList} from "@/api/task/category";
|
|
|
|
+
|
|
|
|
+export default {
|
|
|
|
+ name: "Techparam",
|
|
|
|
+
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ categoryList: [],
|
|
|
|
+ // 参数表格树数据
|
|
|
|
+ menuList: [],
|
|
|
|
+ // 参数树选项
|
|
|
|
+ menuOptions: [],
|
|
|
|
+ // 弹出层标题
|
|
|
|
+ title: "",
|
|
|
|
+ // 是否显示弹出层
|
|
|
|
+ open: false,
|
|
|
|
+ // 是否展开,默认全部折叠
|
|
|
|
+ isExpandAll: false,
|
|
|
|
+ // 重新渲染表格状态
|
|
|
|
+ refreshTable: true,
|
|
|
|
+ // 查询参数
|
|
|
|
+ queryParams: {
|
|
|
|
+ menuName: undefined,
|
|
|
|
+ visible: undefined
|
|
|
|
+ },
|
|
|
|
+ // 表单参数
|
|
|
|
+ form: {},
|
|
|
|
+ // 表单校验
|
|
|
|
+ rules: {
|
|
|
|
+ menuName: [
|
|
|
|
+ {required: true, message: "参数名称不能为空", trigger: "blur"}
|
|
|
|
+ ],
|
|
|
|
+ orderNum: [
|
|
|
|
+ {required: true, message: "参数顺序不能为空", trigger: "blur"}
|
|
|
|
+ ],
|
|
|
|
+ path: [
|
|
|
|
+ {required: true, message: "路由地址不能为空", trigger: "blur"}
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.getList();
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ /** 查询参数列表 */
|
|
|
|
+ getList() {
|
|
|
|
+ getCategoryList().then(res => {
|
|
|
|
+ this.categoryList = res.data;
|
|
|
|
+ })
|
|
|
|
+ listMenu(this.queryParams).then(response => {
|
|
|
|
+ this.menuList = this.handleTree(response.data, "id");
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /** 搜索按钮操作 */
|
|
|
|
+ handleQuery() {
|
|
|
|
+ this.getList();
|
|
|
|
+ },
|
|
|
|
+ /** 重置按钮操作 */
|
|
|
|
+ resetQuery() {
|
|
|
|
+ this.$refs.queryForm.resetFields();
|
|
|
|
+ this.handleQuery();
|
|
|
|
+ },
|
|
|
|
+ /** 查询参数下拉树结构 */
|
|
|
|
+ getTreeSelect() {
|
|
|
|
+ listMenu().then(response => {
|
|
|
|
+ this.menuOptions = [];
|
|
|
|
+ const menu = {id: 0, menuName: '主类目', children: []};
|
|
|
|
+ menu.children = this.handleTree(response.data, "id");
|
|
|
|
+ this.menuOptions.push(menu);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ /** 转换参数数据结构 */
|
|
|
|
+ normalizer(node) {
|
|
|
|
+ if (node.children && !node.children.length) {
|
|
|
|
+ delete node.children;
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ id: node.id,
|
|
|
|
+ label: node.menuName,
|
|
|
|
+ children: node.children
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ // 选择图标
|
|
|
|
+ selected(name) {
|
|
|
|
+ this.form.icon = name;
|
|
|
|
+ },
|
|
|
|
+ // 取消按钮
|
|
|
|
+ cancel() {
|
|
|
|
+ this.open = false;
|
|
|
|
+ this.reset();
|
|
|
|
+ },
|
|
|
|
+ // 表单重置
|
|
|
|
+ reset() {
|
|
|
|
+ this.form = {
|
|
|
|
+ id: undefined,
|
|
|
|
+ parentId: 0,
|
|
|
|
+ name: undefined,
|
|
|
|
+ paramType: undefined,
|
|
|
|
+ orderNum: undefined,
|
|
|
|
+ };
|
|
|
|
+ // this.resetForm("form");
|
|
|
|
+ },
|
|
|
|
+ addChild() {
|
|
|
|
+ let child = {
|
|
|
|
+ name: undefined,
|
|
|
|
+ value: undefined,
|
|
|
|
+ }
|
|
|
|
+ this.form.children.push(child)
|
|
|
|
+ },
|
|
|
|
+ delChild(index) {
|
|
|
|
+ this.form.children.splice(index, 1)
|
|
|
|
+ },
|
|
|
|
+ /** 新增按钮操作 */
|
|
|
|
+ handleAdd() {
|
|
|
|
+ this.reset()
|
|
|
|
+ this.open = true
|
|
|
|
+ this.form = {
|
|
|
|
+ name: undefined,
|
|
|
|
+ paramType: undefined,
|
|
|
|
+ orderNum: undefined,
|
|
|
|
+ children: []
|
|
|
|
+ }
|
|
|
|
+ this.title = "添加参数"
|
|
|
|
+ },
|
|
|
|
+ /** 展开/折叠操作 */
|
|
|
|
+ toggleExpandAll() {
|
|
|
|
+ this.refreshTable = false;
|
|
|
|
+ this.isExpandAll = !this.isExpandAll;
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.refreshTable = true;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ /** 修改按钮操作 */
|
|
|
|
+ handleUpdate(row) {
|
|
|
|
+ this.reset();
|
|
|
|
+ this.getTreeSelect();
|
|
|
|
+ getMenu(row.id).then(response => {
|
|
|
|
+ this.form = response.data;
|
|
|
|
+ this.open = true;
|
|
|
|
+ this.title = "修改参数";
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ /** 提交按钮 */
|
|
|
|
+ submitForm() {
|
|
|
|
+ this.$refs["form"].validate(valid => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ if (this.form.id != undefined) {
|
|
|
|
+ updateMenu(this.form).then(response => {
|
|
|
|
+ this.$message.success("修改成功");
|
|
|
|
+ this.open = false;
|
|
|
|
+ this.getList();
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ addMenu(this.form).then(response => {
|
|
|
|
+ this.$message.success("新增成功");
|
|
|
|
+ this.open = false;
|
|
|
|
+ this.getList();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ /** 删除按钮操作 */
|
|
|
|
+ handleDelete(row) {
|
|
|
|
+ this.$confirm('是否确认删除名称为"' + row.menuName + '"的数据项?').then(() => {
|
|
|
|
+ return delMenu(row.id);
|
|
|
|
+ }).then(() => {
|
|
|
|
+ this.getList();
|
|
|
|
+ this.$message.success("删除成功");
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style scoped lang="scss">
|
|
|
|
+.form {
|
|
|
|
+ ::v-deep .el-form-item__label {
|
|
|
|
+ font-size: 13px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .form-child {
|
|
|
|
+ margin-bottom: 5px;
|
|
|
|
+
|
|
|
|
+ ::v-deep.el-form-item {
|
|
|
|
+ margin-bottom: 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep.el-card__header {
|
|
|
|
+ padding: 5px 10px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep.el-card__body {
|
|
|
|
+ padding: 5px;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|