<template>
|
<div class="view">
|
<div class="search-warp">
|
<el-form :inline="true" :model="searchForm" class="demo-form-inline" size="small">
|
<el-form-item label="字典类型">
|
<el-input clearable @clear="search" v-model="searchForm.dictTypeName" placeholder="字典类型"></el-input>
|
</el-form-item>
|
<el-form-item label="类型key">
|
<el-input clearable @clear="search" v-model="searchForm.dictTypeKey" placeholder="类型key"></el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="search">查找</el-button>
|
</el-form-item>
|
</el-form>
|
</div>
|
<OperateC
|
:top-level="topLevel"
|
:add="addDictType"
|
:edit="editDictType"
|
:remove="removeDictType"
|
:add-show="this.$getButtonAuth('dict:add')"
|
:remove-show="this.$getButtonAuth('dict:del:batch')"
|
/>
|
<DictTypeTable
|
:top-level="topLevel"
|
ref="DictTypeRef"
|
:edit-show="this.$getButtonAuth('dict:edit')"
|
:data-admin-show="this.$getButtonAuth('dict:data:admin')"
|
:del-show="this.$getButtonAuth('dict:del')"
|
/>
|
<DictTypeDialog></DictTypeDialog>
|
</div>
|
</template>
|
|
<script>
|
import DictTypeTable from "@/components/table/DictTypeTable";
|
import DictTypeDialog from "@/components/dialog/DictTypeDialog";
|
import OperateC from "@/components/OperateC";
|
import {deleteDictTypeByIds, getDictTypes} from "@/api/dict-type";
|
export default {
|
name: "DictTypeView",
|
components: {DictTypeTable, DictTypeDialog, OperateC},
|
data() {
|
return {
|
searchForm: {
|
dictTypeName: '',
|
dictTypeKey: '',
|
},
|
topLevel: 1
|
}
|
},
|
methods: {
|
search() {
|
this.$refs.DictTypeRef.getDictTypes(this.searchForm)
|
},
|
addDictType() {
|
// 打开添加dialog
|
var params = {
|
dialogTitle: "添加字典类型",
|
dialogFormVisible: true
|
}
|
this.$store.commit("dictType/openDialogForm",params);
|
},
|
editDictType() {
|
let selected = this.$store.state.dictType.multipleSelection;
|
if (selected.length < 1) {
|
this.$message.warning("你还没有选中数据哦!");
|
return;
|
}
|
if (selected.length > 1) {
|
this.$message.warning("一次只能修改一条数据哦!")
|
return;
|
}
|
this.$store.dispatch("dictType/editDictType", selected[0]);
|
},
|
removeDictType() {
|
let selected = this.$store.state.dictType.multipleSelection;
|
if (selected.length < 1) {
|
this.$message.warning("请先选择要删除的数据哦!");
|
return;
|
}
|
this.$confirm('确定删除吗?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
deleteDictTypeByIds(selected).then((res) => {
|
this.$message.success(res.data.msg);
|
// 刷新
|
var params = {
|
"current": this.$store.state.dictType.currentPage,
|
"size": this.$store.state.dictType.pageSize
|
};
|
getDictTypes(params).then((res) => {
|
this.$store.state.dictType.tableData = res.data.data;
|
this.$store.state.dictType.total = res.data.total;
|
})
|
})
|
}).catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|