<template>
|
<a-row :gutter="24">
|
<a-col :md="24">
|
<a-card :style="cardStyle" :bordered="false">
|
<!-- 查询区域 -->
|
<div class="table-page-search-wrapper">
|
<a-form layout="inline" @keyup.enter.native="searchQuery">
|
<a-row :gutter="24">
|
<a-col :md="6" :sm="24">
|
<a-form-item label="字典编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input placeholder="请输入字典编码" v-model="queryParam.dictCode"></a-input>
|
</a-form-item>
|
</a-col>
|
<a-col :md="6" :sm="24">
|
<a-form-item label="字典名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input placeholder="请输入字典名称" v-model="queryParam.dictName"></a-input>
|
</a-form-item>
|
</a-col>
|
<a-col :md="6" :sm="24">
|
<a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-select placeholder="请选择状态" v-model="queryParam.status" allowClear>
|
<a-select-option :value="0">停用</a-select-option>
|
<a-select-option :value="1">启用</a-select-option>
|
</a-select>
|
</a-form-item>
|
</a-col>
|
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
|
<a-col :md="6" :sm="24">
|
<a-button type="primary" @click="searchQuery">查询</a-button>
|
<a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
|
</a-col>
|
</span>
|
</a-row>
|
</a-form>
|
</div>
|
<!-- 操作按钮区域 -->
|
<div class="table-operator" style="margin-top: 5px">
|
<a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
|
<a-button type="primary" icon="delete" @click="batchDel">删除</a-button>
|
</div>
|
<!-- table区域-begin -->
|
<div>
|
<a-table
|
ref="table"
|
size="middle"
|
bordered
|
rowKey="id"
|
:columns="columns"
|
:dataSource="dataSource"
|
:pagination="ipagination"
|
:loading="loading"
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
@change="handleTableChange">
|
<span slot="action" slot-scope="text, record">
|
<a @click="handleEdit(record)">编辑</a>
|
<a-divider type="vertical" />
|
<a @click="handleItems(record)">字典项</a>
|
<a-divider type="vertical" />
|
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
|
<a>删除</a>
|
</a-popconfirm>
|
</span>
|
<template slot="statusSlot" slot-scope="text">
|
<a-tag :color="text === 1 ? 'green' : 'orange'">
|
{{ text === 1 ? '启用' : '停用' }}
|
</a-tag>
|
</template>
|
</a-table>
|
</div>
|
<!-- table区域-end -->
|
|
<!-- 表单区域 -->
|
<sys-dict-modal ref="modalForm" @ok="modalFormOk"></sys-dict-modal>
|
<sys-dict-item-modal ref="itemModalForm" @ok="modalFormOk"></sys-dict-item-modal>
|
</a-card>
|
</a-col>
|
</a-row>
|
</template>
|
|
<script>
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
import SysDictModal from './modules/SysDictModal'
|
import SysDictItemModal from './modules/SysDictItemModal'
|
import { deleteAction } from '@/api/manage'
|
|
export default {
|
name: "SysDictList",
|
mixins:[JeecgListMixin],
|
components: {
|
SysDictModal,
|
SysDictItemModal
|
},
|
data () {
|
return {
|
description: '字典管理页面',
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
// 查询条件
|
queryParam: {
|
dictCode: '',
|
dictName: '',
|
status: undefined
|
},
|
// 表头
|
columns: [
|
{
|
title: '#',
|
dataIndex: '',
|
key:'rowIndex',
|
width:60,
|
align:"center",
|
customRender:function (t,r,index) {
|
return parseInt(index)+1;
|
}
|
},
|
{
|
title: '操作',
|
dataIndex: 'action',
|
width:150,
|
align:"center",
|
scopedSlots: { customRender: 'action' }
|
},
|
{
|
title: '字典编码',
|
align:"left",
|
dataIndex: 'dictCode'
|
},
|
{
|
title: '字典名称',
|
align:"left",
|
dataIndex: 'dictName'
|
},
|
{
|
title: '描述',
|
align:"left",
|
dataIndex: 'description'
|
},
|
{
|
title: '状态',
|
align:"center",
|
dataIndex: 'status',
|
scopedSlots: { customRender: 'statusSlot' }
|
},
|
{
|
title: '创建时间',
|
align:"center",
|
dataIndex: 'createTime',
|
width: 180
|
}
|
],
|
url: {
|
list: "/sysDict/list",
|
delete: "/sysDict/delete",
|
deleteBatch: "/sysDict/deleteBatch"
|
},
|
btnEnableList: [],
|
cardStyle: {
|
height: '100%'
|
}
|
}
|
},
|
methods: {
|
searchReset() {
|
this.queryParam = {
|
dictCode: '',
|
dictName: '',
|
status: undefined
|
}
|
this.loadData(1);
|
},
|
handleEdit: function (record) {
|
this.$refs.modalForm.edit(record);
|
this.$refs.modalForm.title = "编辑";
|
this.$refs.modalForm.disableSubmit = false;
|
},
|
handleAdd: function () {
|
this.$refs.modalForm.add();
|
this.$refs.modalForm.title = "新增";
|
this.$refs.modalForm.disableSubmit = false;
|
},
|
handleItems: function (record) {
|
this.$refs.itemModalForm.show(record);
|
this.$refs.itemModalForm.title = "字典项管理";
|
this.$refs.itemModalForm.disableSubmit = false;
|
},
|
handleDelete(id) {
|
deleteAction(this.url.delete, {id: id}).then((res) => {
|
if (res.success) {
|
this.$message.success(res.message);
|
this.loadData();
|
} else {
|
this.$message.warning(res.message);
|
}
|
});
|
},
|
batchDel() {
|
if (this.selectedRowKeys.length <= 0) {
|
this.$message.warning('请选择一条记录!');
|
return;
|
}
|
let ids = "";
|
this.selectedRowKeys.forEach(function(val) {
|
ids+=val+",";
|
});
|
ids = ids.substring(0,ids.length-1);
|
deleteAction(this.url.deleteBatch, {ids: ids}).then((res) => {
|
if (res.success) {
|
this.$message.success(res.message);
|
this.loadData();
|
this.selectedRowKeys = [];
|
} else {
|
this.$message.warning(res.message);
|
}
|
});
|
}
|
}
|
}
|
</script>
|
<style scoped>
|
@import '~@assets/less/common.less'
|
</style>
|