文章编写和导航
This commit is contained in:
326
ebts-ui/src/views/sist/navigation/index.vue
Normal file
326
ebts-ui/src/views/sist/navigation/index.vue
Normal file
@@ -0,0 +1,326 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="站点类型" prop="sitetype">
|
||||
<el-select v-model="queryParams.sitetype" placeholder="请选择站点类型 1: sist 2: lab" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in sitetypeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="导航名称" prop="title">
|
||||
<el-input
|
||||
v-model="queryParams.title"
|
||||
placeholder="请输入导航名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="delflag">
|
||||
<el-select v-model="queryParams.delflag" placeholder="请选择站点状态" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in delflagOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</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="['sist:navigation:add']"
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="navigationList"
|
||||
row-key="id"
|
||||
default-expand-all
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
>
|
||||
<el-table-column label="导航名称" align="center" prop="title"/>
|
||||
<el-table-column label="英语名称" align="center" prop="englishTitle"/>
|
||||
<el-table-column label="站点类型" align="center" prop="sitetype" :formatter="sitetypeFormat"/>
|
||||
<el-table-column label="导航链接" align="center" prop="link"/>
|
||||
<el-table-column label="状态" align="center" prop="delflag" :formatter="delflagFormat"/>
|
||||
<el-table-column label="排序" align="center" prop="sort"/>
|
||||
<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="['sist:navigation:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['sist:navigation:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加或修改导航对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="父ID" prop="pid">
|
||||
<treeselect v-model="form.pid" :options="navigationOptions" :normalizer="normalizer" placeholder="请选择父ID"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="站点类型" prop="sitetype">
|
||||
<el-select v-model="form.sitetype" placeholder="请选择站点类型">
|
||||
<el-option
|
||||
v-for="dict in sitetypeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="导航名称" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入导航名称"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="英语名称" prop="englishTitle">
|
||||
<el-input v-model="form.englishTitle" placeholder="英语名称"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="导航链接" prop="link">
|
||||
<el-input v-model="form.link" placeholder="请输入导航链接"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="delflag">
|
||||
<el-radio-group v-model="form.delflag">
|
||||
<el-radio-button v-for="(item, index) in delflagOptions" :key="index"
|
||||
:label="item.dictValue">{{ item.dictLabel }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="form.sort" type="number" value="0" placeholder="请输入排序"/>
|
||||
</el-form-item>
|
||||
</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 {
|
||||
listNavigation,
|
||||
getNavigation,
|
||||
delNavigation,
|
||||
addNavigation,
|
||||
updateNavigation,
|
||||
exportNavigation
|
||||
} from "@/api/sist/navigation";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
export default {
|
||||
name: "Navigation",
|
||||
components: {
|
||||
Treeselect
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 导航表格数据
|
||||
navigationList: [],
|
||||
// 导航树选项
|
||||
navigationOptions: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 站点类型 1: sist 2: lab字典
|
||||
sitetypeOptions: [],
|
||||
// 1: 正常 0:软删除字典
|
||||
delflagOptions: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
sitetype: null,
|
||||
title: null,
|
||||
englishTitle: null,
|
||||
delflag: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
pid: [
|
||||
{required: true, message: "父ID不能为空", trigger: "blur"}
|
||||
],
|
||||
sitetype: [
|
||||
{required: true, message: "站点类型 ", trigger: "change"}
|
||||
],
|
||||
title: [
|
||||
{required: true, message: "导航名称不能为空", trigger: "blur"}
|
||||
],
|
||||
englishTitle: [
|
||||
{required: true, message: "英语名称不能为空", trigger: "blur"}
|
||||
],
|
||||
link: [
|
||||
{required: true, message: "导航链接不能为空", trigger: "blur"}
|
||||
],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getDicts("site_type").then(response => {
|
||||
this.sitetypeOptions = response.data;
|
||||
});
|
||||
this.getDicts("delflag").then(response => {
|
||||
this.delflagOptions = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询导航列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listNavigation(this.queryParams).then(response => {
|
||||
this.navigationList = this.handleTree(response.data, "id", "pid");
|
||||
console.log(this.navigationList)
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 转换导航数据结构 */
|
||||
normalizer(node) {
|
||||
if (node.children && !node.children.length) {
|
||||
delete node.children;
|
||||
}
|
||||
return {
|
||||
id: node.id,
|
||||
label: node.title,
|
||||
children: node.children
|
||||
};
|
||||
},
|
||||
/** 查询部门下拉树结构 */
|
||||
getTreeselect() {
|
||||
listNavigation(this.queryParams).then(response => {
|
||||
this.navigationOptions = [];
|
||||
const data = {id: 0, title: '顶级节点', children: []};
|
||||
data.children = this.handleTree(response.data, "id", "pid");
|
||||
this.navigationOptions.push(data);
|
||||
});
|
||||
},
|
||||
// 站点类型 1: sist 2: lab字典翻译
|
||||
sitetypeFormat(row, column) {
|
||||
return this.selectDictLabel(this.sitetypeOptions, row.sitetype);
|
||||
},
|
||||
// 1: 正常 0:软删除字典翻译
|
||||
delflagFormat(row, column) {
|
||||
return this.selectDictLabel(this.delflagOptions, row.delflag);
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
pid: null,
|
||||
sitetype: null,
|
||||
title: null,
|
||||
link: null,
|
||||
delflag: null,
|
||||
sort: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.getTreeselect();
|
||||
this.open = true;
|
||||
this.title = "添加导航";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
this.getTreeselect();
|
||||
if (row != null) {
|
||||
this.form.pid = row.id;
|
||||
}
|
||||
getNavigation(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 != null) {
|
||||
updateNavigation(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addNavigation(this.form).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
this.$confirm('是否确认删除导航编号为"' + row.id + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function () {
|
||||
return delNavigation(row.id);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user