<template>
|
<div class="app-container">
|
<div class="search_form">
|
<div>
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
|
<el-form-item label="分类" prop="category">
|
<el-input
|
v-model="queryParams.category"
|
placeholder="请输入分类"
|
clearable
|
style="width: 240px"
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
<el-form-item label="标题" prop="label">
|
<el-input
|
v-model="queryParams.label"
|
placeholder="请输入标题"
|
clearable
|
style="width: 240px"
|
@keyup.enter.native="handleQuery"
|
/>
|
</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>
|
</div>
|
<div style="margin-top: 3px">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="mini"
|
@click="handleAdd"
|
v-hasPermi="['system:dict:add']"
|
>新增</el-button>
|
</div>
|
</div>
|
|
<el-table v-loading="loading" :data="typeList">
|
<el-table-column label="序号" align="center" prop="dictId" width="60px"/>
|
<el-table-column label="分类" align="center" prop="category" />
|
<el-table-column label="标题" align="center" prop="label" > </el-table-column>
|
<el-table-column label="参数" align="center" prop="value"></el-table-column>
|
<el-table-column label="优先级" align="center" prop="orderNum" />
|
<el-table-column label="类型" align="center" prop="type"></el-table-column>
|
<el-table-column label="创建用户" align="center" prop="createUserName" show-overflow-tooltip></el-table-column>
|
<el-table-column label="创建时间" align="center" prop="createTime" show-overflow-tooltip></el-table-column>
|
<el-table-column label="更新用户" align="center" prop="updateUserName"></el-table-column>
|
<el-table-column label="更新时间" align="center" prop="updateTime" show-overflow-tooltip></el-table-column>
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100px">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['system:dict:edit']"
|
>修改</el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row)"
|
v-hasPermi="['system:dict:remove']"
|
>删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<pagination
|
v-show="total>0"
|
:total="total"
|
:page.sync="page.current"
|
:limit.sync="page.size"
|
@pagination="getList"
|
/>
|
|
<!-- 添加或修改参数配置对话框 -->
|
<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="分类" prop="category">
|
<el-input v-model="form.category" placeholder="请输入字典名称" />
|
</el-form-item>
|
<el-form-item label="标题" prop="label">
|
<el-input v-model="form.label" placeholder="请输入字典类型" />
|
</el-form-item>
|
<el-form-item label="参数" prop="value">
|
<el-input v-model="form.value" placeholder="请输入字典类型" />
|
</el-form-item>
|
<el-form-item label="优先级" prop="orderNum">
|
<el-input v-model="form.orderNum" placeholder="请输入内容"></el-input>
|
</el-form-item>
|
<el-form-item label="类型" prop="type">
|
<el-select clearable v-model="form.type" placeholder="请选择类型" style="width:100%">
|
<el-option v-for="item in enumByCategoryOptions" :key="item.value" :value="item.value" :label="item.label"></el-option>
|
</el-select>
|
</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 {
|
listType,
|
getType,
|
delType,
|
addType,
|
updateType,
|
} from "@/api/system/dict/type";
|
|
export default {
|
name: "Dict",
|
dicts: ['sys_normal_disable'],
|
data() {
|
return {
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 字典表格数据
|
typeList: [],
|
// 弹出层标题
|
title: "",
|
// 是否显示弹出层
|
open: false,
|
// 查询参数
|
queryParams: {
|
category: undefined,
|
label: undefined,
|
orderBy: {
|
field: 'category,order_num,id',
|
order: 'asc'
|
}
|
},
|
page: {
|
current: 1,
|
size: 20,
|
},
|
// 表单参数
|
form: {},
|
// 表单校验
|
rules: {
|
category: [
|
{ required: true, message: "请填写分类", trigger: "blur" }
|
],
|
label: [
|
{ required: true, message: "请填写标题", trigger: "blur" }
|
],
|
value: [
|
{ required: true, message: "请填写参数", trigger: "blur" }
|
]
|
},
|
enumByCategoryOptions: [
|
{value:'', label:'默认'},
|
{value:'success', label:'成功'},
|
{value:'info', label:'信息'},
|
{value:'warning', label:'警告'},
|
{value:'danger', label:'错误'},
|
]
|
};
|
},
|
created() {
|
this.getList();
|
},
|
methods: {
|
/** 查询字典类型列表 */
|
getList() {
|
this.loading = true;
|
listType(this.pages, this.queryParams).then(response => {
|
this.typeList = response.rows;
|
this.total = response.total;
|
this.loading = false;
|
}
|
).catch(error => {
|
this.loading = false;
|
})
|
},
|
// 取消按钮
|
cancel() {
|
this.open = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
dictId: undefined,
|
category: undefined,
|
label: undefined,
|
value: undefined,
|
orderNum: undefined,
|
type: undefined,
|
};
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.page.current = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.resetForm("queryForm");
|
this.handleQuery();
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
this.open = true;
|
this.title = "添加字典类型";
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
const dictId = row.dictId || this.ids
|
getType(dictId).then(response => {
|
this.form = response.data;
|
this.open = true;
|
this.title = "修改字典类型";
|
});
|
},
|
/** 提交按钮 */
|
submitForm: function() {
|
this.$refs["form"].validate(valid => {
|
if (valid) {
|
if (this.form.dictId != undefined) {
|
updateType(this.form).then(response => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addType(this.form).then(response => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const dictIds = row.dictId || this.ids;
|
this.$modal.confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?').then(function() {
|
return delType({id: dictIds});
|
}).then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
}).catch(() => {});
|
},
|
}
|
};
|
</script>
|
<style scoped lang="scss">
|
.search_form {
|
display: flex;
|
justify-content: space-between;
|
}
|
</style>
|