parent
7c481a8b3e
commit
cf8d1fa9b5
@ -0,0 +1,24 @@
|
||||
/*
|
||||
Target : MYSQL
|
||||
Author
|
||||
Date: 2019-10-08
|
||||
*/
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for DICT - 字典
|
||||
-- ----------------------------
|
||||
|
||||
CREATE TABLE `SYS_DICT` (
|
||||
`ID` BIGINT(20) NOT NULL COMMENT '主键',
|
||||
`DICT_NAME` VARCHAR(50) NOT NULL COMMENT '字典名称',
|
||||
`DICT_CODE` VARCHAR(50) NOT NULL COMMENT '字典代码',
|
||||
`VERSION` VARCHAR(50) NOT NULL COMMENT '字典版本号',
|
||||
`VALID` TINYINT(1) NOT NULL COMMENT '是否有效',
|
||||
`ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本',
|
||||
`IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除',
|
||||
`CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户',
|
||||
`CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',
|
||||
`LAST_UPDATE_BY` BIGINT(20) DEFAULT NULL COMMENT '最后更新用户',
|
||||
`LAST_UPDATE_TIME` DATETIME DEFAULT NULL COMMENT '最后更新时间',
|
||||
PRIMARY KEY (`ID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='字典';
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
Target : MYSQL
|
||||
Author
|
||||
Date: 2019-10-08
|
||||
*/
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for DICT_ITEM - 字典项
|
||||
-- ----------------------------
|
||||
|
||||
CREATE TABLE `SYS_DICT_ITEM` (
|
||||
`ID` BIGINT(20) NOT NULL COMMENT '主键',
|
||||
`DICT_ID` BIGINT(20) NOT NULL COMMENT '字典ID',
|
||||
`KEY` CHAR(10) NOT NULL COMMENT '字典KEY',
|
||||
`VALUE` VARCHAR(100) NOT NULL COMMENT '字典VALUE',
|
||||
`SORT` INTEGER(10) NOT NULL COMMENT '排序',
|
||||
`VALID` TINYINT(1) NOT NULL COMMENT '是否有效',
|
||||
`ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本',
|
||||
`IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除',
|
||||
`CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户',
|
||||
`CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',
|
||||
`LAST_UPDATE_BY` BIGINT(20) DEFAULT NULL COMMENT '最后更新用户',
|
||||
`LAST_UPDATE_TIME` DATETIME DEFAULT NULL COMMENT '最后更新时间',
|
||||
PRIMARY KEY (`ID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='字典项';
|
@ -1,42 +0,0 @@
|
||||
<#if dataBase == 'ORACLE'>
|
||||
/*
|
||||
Target : ORACLE
|
||||
Author
|
||||
Date: ${date?string("yyyy-MM-dd")}
|
||||
*/
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for ${table.tableName} - ${table.tableComment?default("")}
|
||||
-- ----------------------------
|
||||
|
||||
CREATE TABLE "${module.modulePrefix}${table.tableName}" (
|
||||
<#list table.fields as field>
|
||||
${dBmapper.getFieldSql(field)}<#if field_has_next>,</#if>
|
||||
</#list>
|
||||
);
|
||||
|
||||
COMMENT ON TABLE "${module.modulePrefix?default("")}${table.tableName}" is '${table.tableComment}';
|
||||
<#list table.fields as field>
|
||||
COMMENT ON COLUMN "${module.modulePrefix?default("")}${table.tableName}"."${field.fieldName?default("")}" is '${field.fieldComment?default("")}';
|
||||
</#list>
|
||||
</#if>
|
||||
<#if dataBase == 'MYSQL'>
|
||||
/*
|
||||
Target : MYSQL
|
||||
Author
|
||||
Date: ${date?string("yyyy-MM-dd")}
|
||||
*/
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for ${table.tableName} - ${table.tableComment?default("")}
|
||||
-- ----------------------------
|
||||
|
||||
CREATE TABLE `${module.modulePrefix?default("")}${table.tableName}` (
|
||||
<#list table.fields as field>
|
||||
${dBmapper.getFieldSql(field)}<#if field_has_next||module.hasSysFields>,</#if>
|
||||
</#list>
|
||||
<#if module.hasSysFields>
|
||||
PRIMARY KEY (`ID`)
|
||||
</#if>
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='${table.tableComment?default("")}';
|
||||
</#if>
|
@ -1,34 +0,0 @@
|
||||
<#if dataBase == 'ORACLE'>
|
||||
<#list module.tables as table>
|
||||
-- ----------------------------
|
||||
-- Table structure for ${table.tableName} - ${table.tableComment?default("")}
|
||||
-- ----------------------------
|
||||
CREATE TABLE "${module.modulePrefix?default("")}${table.tableName}" (
|
||||
<#list table.fields as field>
|
||||
${dBmapper.getFieldSql(field)}<#if field_has_next>,</#if>
|
||||
</#list>
|
||||
);
|
||||
COMMENT ON TABLE "${module.modulePrefix?default("")}${table.tableName}" is '${table.tableComment?default("")}';
|
||||
<#list table.fields as field>
|
||||
COMMENT ON COLUMN "${module.modulePrefix?default("")}${table.tableName}"."${field.fieldName?default("")}" is '${field.fieldComment?default("")}';
|
||||
</#list>
|
||||
|
||||
</#list>
|
||||
</#if>
|
||||
|
||||
<#if dataBase == 'MYSQL'>
|
||||
<#list module.tables as table>
|
||||
-- ----------------------------
|
||||
-- Table structure for ${table.tableName} - ${table.tableComment?default("")}
|
||||
-- ----------------------------
|
||||
CREATE TABLE `${module.modulePrefix?default("")}${table.tableName}` (
|
||||
<#list table.fields as field>
|
||||
${dBmapper.getFieldSql(field)}<#if field_has_next||module.hasSysFields>,</#if>
|
||||
</#list>
|
||||
<#if module.hasSysFields>
|
||||
PRIMARY KEY (`ID`)
|
||||
</#if>
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='${table.tableComment?default("")}';
|
||||
|
||||
</#list>
|
||||
</#if>
|
@ -0,0 +1,343 @@
|
||||
<div id="app" v-cloak>
|
||||
<el-card class="box-card">
|
||||
<el-form :inline="true" :model="vm" ref="vm" label-width="90px">
|
||||
<el-form-item label="字典名称" prop="dictName">
|
||||
<el-input v-model="vm.dictName" clearable size="small" placeholder=""></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="字典代码" prop="dictCode">
|
||||
<el-input v-model="vm.dictCode" clearable size="small" placeholder=""></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否有效" prop="valid">
|
||||
<el-select v-model="vm.valid" size="small" placeholder="">
|
||||
<el-option label="所有" value=""></el-option>
|
||||
<el-option label="有效" value="true"></el-option>
|
||||
<el-option label="无效" value="false"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="small" icon="el-icon-search" @click="onSearch">搜索</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-refresh-left" @click="onReset('vm')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-button type="success" size="small" icon="el-icon-plus" @click="onAction(['create',''])">新增
|
||||
</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-download">导出</el-button>
|
||||
|
||||
<el-dialog class="form" :title="form.title" :visible.sync="form.dialog">
|
||||
<el-form :model="form" :inline="true" :rules="formRules" ref="form" label-width="90px">
|
||||
<el-form-item label="字典名称" prop="dictName">
|
||||
<el-input size="small" v-model="form.dictName"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="字典代码" prop="dictCode">
|
||||
<el-input size="small" v-model="form.dictCode"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="字典版本" required>
|
||||
<el-date-picker size="small"
|
||||
v-model="form.version"
|
||||
type="datetime"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
placeholder="选择日期时间"
|
||||
align="right">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否有效" prop="valid">
|
||||
<el-switch size="small" v-model="form.valid"></el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button size="small" @click="form.dialog = false">取 消</el-button>
|
||||
<el-button size="small" type="primary" @click="onAction(['save',''])">保存</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12">
|
||||
<el-button-group style="float: right;">
|
||||
<el-button size="small" icon="el-icon-delete" @click="onBitchDelete"></el-button>
|
||||
<el-button size="small" icon="el-icon-refresh" @click="onFind"></el-button>
|
||||
</el-button-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
style="margin-top: 10px"
|
||||
@selection-change="onSelectionChange"
|
||||
empty-text="无数据"
|
||||
:data="result"
|
||||
size="small"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
align="center"
|
||||
type="selection"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="id"
|
||||
label="主键"
|
||||
width="140">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
width="80"
|
||||
label="是否有效">
|
||||
<template slot-scope="scope">
|
||||
<el-tag size="mini" v-if="scope.row.valid">有效</el-tag>
|
||||
<el-tag size="mini" type="danger" v-if="!scope.row.valid">无效</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="dictName"
|
||||
label="字典名称">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="dictCode"
|
||||
label="字典代码">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="version"
|
||||
label="字典版本">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="createTime"
|
||||
label="创建时间">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
fixed="right"
|
||||
width="120"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-dropdown size="mini" split-button type="primary" @click="onAction(['view',scope.row])"
|
||||
@command="onAction">
|
||||
<i class="el-icon-tickets"></i>查看
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="['edit',scope.row]" icon="el-icon-edit">编辑</el-dropdown-item>
|
||||
<el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
style="margin-top: 10px"
|
||||
v-if="vm.totalCount > vm.pageSize"
|
||||
@current-change="onPage"
|
||||
:current-page="vm.pageNumber"
|
||||
:page-size="vm.pageSize"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
:total="vm.totalCount">
|
||||
</el-pagination>
|
||||
</el-card>
|
||||
</div>
|
||||
<style>
|
||||
#app {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.box-card {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.form .el-dialog {
|
||||
width: 700px;
|
||||
}
|
||||
|
||||
.form .el-dialog .el-form-item__content {
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: "#app",
|
||||
data: {
|
||||
vm: {
|
||||
id: '',
|
||||
dictName: '',
|
||||
dictCode: '',
|
||||
valid: "",
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0
|
||||
},
|
||||
select: [],
|
||||
result: [],
|
||||
form: {
|
||||
title: "",
|
||||
dialog: false,
|
||||
id: '',
|
||||
dictName: '',
|
||||
dictCode: '',
|
||||
version: '',
|
||||
valid: false,
|
||||
rowVersion: '',
|
||||
},
|
||||
formRules: {
|
||||
dictName: [
|
||||
{required: true, message: '请输入字典名称', trigger: 'blur'},
|
||||
{min: 1, max: 50, message: '长度在 3 到 5 个字符', trigger: 'blur'}
|
||||
],
|
||||
dictCode: [
|
||||
{required: true, message: '请输入字典代码', trigger: 'blur'},
|
||||
{min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur'}
|
||||
],
|
||||
version: [
|
||||
{type: 'date', required: true, message: '字典版本不能为空', trigger: 'change'}
|
||||
],
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onSearch: function () {
|
||||
this.vm.pageNumber = 1;
|
||||
this.onFind();
|
||||
},
|
||||
onReset: function (form) {
|
||||
this.$refs[form].resetFields();
|
||||
nav.w('重置成功');
|
||||
},
|
||||
onFind: function () {
|
||||
ajax.dictFind(this.vm).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.result = response.result;
|
||||
this.vm.totalCount = Number(response.totalCount);
|
||||
}
|
||||
}.bind(this))
|
||||
},
|
||||
onPage: function (pageNumber) {
|
||||
this.vm.pageNumber = pageNumber;
|
||||
this.onFind();
|
||||
},
|
||||
onSelectionChange: function (select) {
|
||||
this.select = select;
|
||||
},
|
||||
onBitchDelete: function () {
|
||||
if (this.select.length == 0) {
|
||||
nav.w("至少选中一项");
|
||||
} else {
|
||||
this.$confirm('将删除已选择的项, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function () {
|
||||
for (var i = 0; i < this.select.length; i++) {
|
||||
var obj = this.select[i];
|
||||
ajax.dictDelete({id: obj.id}).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
for (var j = 0; j < this.select.length; j++) {
|
||||
if (this.select[j].id == obj.id) {
|
||||
this.select.splice(j, 1);
|
||||
}
|
||||
}
|
||||
if (this.select.length == 0) {
|
||||
nav.s("删除成功")
|
||||
this.onFind();
|
||||
}
|
||||
}
|
||||
}.bind(this))
|
||||
}
|
||||
}.bind(this)).catch(function (action) {
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
onAction: function (arg) {
|
||||
const action = arg[0];
|
||||
const item = arg[1];
|
||||
switch (action) {
|
||||
case "create":
|
||||
this.form.title = '新增字典';
|
||||
this.form.id = '';
|
||||
this.form.dictName = '';
|
||||
this.form.dictCode = '';
|
||||
this.form.version = '';
|
||||
this.form.valid = true;
|
||||
this.form.dialog = true;
|
||||
break;
|
||||
case "save":
|
||||
this.$refs['form'].validate(function (valid) {
|
||||
if (valid) {
|
||||
if (this.form.id) {
|
||||
ajax.dictUpdate(this.form).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.onFind();
|
||||
this.form.dialog = false;
|
||||
}
|
||||
}.bind(this))
|
||||
} else {
|
||||
ajax.dictCreate(this.form).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.onFind();
|
||||
this.form.dialog = false;
|
||||
}
|
||||
}.bind(this))
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}.bind(this));
|
||||
break;
|
||||
case "view":
|
||||
parent.index.addTab({
|
||||
title: "字典项管理",
|
||||
name: "dictItem" + item.id,
|
||||
url: "${context}/system/dictItem.htm?dictId=" + item.id
|
||||
});
|
||||
break;
|
||||
case "edit":
|
||||
this.form.title = '编辑字典';
|
||||
this.form.id = item.id;
|
||||
this.form.dictName = item.dictName;
|
||||
this.form.dictCode = item.dictCode;
|
||||
this.form.version = item.version;
|
||||
this.form.valid = item.valid;
|
||||
this.form.rowVersion = item.rowVersion;
|
||||
this.form.dialog = true;
|
||||
break;
|
||||
case "delete":
|
||||
this.$confirm('将删除该项, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function () {
|
||||
ajax.dictDelete({id: item.id}).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
nav.s("删除成功");
|
||||
this.onFind();
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
filters: {},
|
||||
created: function () {
|
||||
},
|
||||
mounted: function () {
|
||||
this.onFind();
|
||||
},
|
||||
watch: {}
|
||||
})
|
||||
</script>
|
@ -0,0 +1,339 @@
|
||||
<div id="app" v-cloak>
|
||||
<el-card class="box-card">
|
||||
<el-form :inline="true" :model="vm" ref="vm" label-width="90px">
|
||||
<el-form-item label="字典名称">
|
||||
<el-input disabled v-model="vm.dictName" clearable size="small"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="字典键" prop="key">
|
||||
<el-input v-model="vm.key" clearable size="small" placeholder=""></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="字典值" prop="value">
|
||||
<el-input v-model="vm.value" clearable size="small" placeholder=""></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否有效" prop="valid">
|
||||
<el-select v-model="vm.valid" size="small" placeholder="">
|
||||
<el-option label="所有" value=""></el-option>
|
||||
<el-option label="有效" value="true"></el-option>
|
||||
<el-option label="无效" value="false"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="small" icon="el-icon-search" @click="onSearch">搜索</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-refresh-left" @click="onReset('vm')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-button type="success" size="small" icon="el-icon-plus" @click="onAction(['create',''])">新增</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-download">导出</el-button>
|
||||
|
||||
<el-dialog class="form" :title="form.title" :visible.sync="form.dialog">
|
||||
<el-form :model="form":inline="true" :rules="formRules" ref="form" label-width="90px">
|
||||
<el-form-item label="字典键" prop="dictName">
|
||||
<el-input size="small" v-model="form.key"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="字典值" prop="dictCode">
|
||||
<el-input size="small" v-model="form.value"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序值" prop="dictCode">
|
||||
<el-input-number size="small" v-model="form.sort" :min="0" :max="10000"
|
||||
label="描述文字"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否有效" prop="valid">
|
||||
<el-switch size="small" v-model="form.valid"></el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button size="small" @click="form.dialog = false">取消</el-button>
|
||||
<el-button size="small" type="primary" @click="onAction(['save',''])">保存</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12">
|
||||
<el-button-group style="float: right;">
|
||||
<el-button size="small" icon="el-icon-delete" @click="onBitchDelete"></el-button>
|
||||
<el-button size="small" icon="el-icon-refresh" @click="onFind"></el-button>
|
||||
</el-button-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
@selection-change="onSelectionChange"
|
||||
empty-text="无数据"
|
||||
:data="result"
|
||||
size="small"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
align="center"
|
||||
type="selection"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="id"
|
||||
label="主键"
|
||||
width="140">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
width="80"
|
||||
label="是否有效">
|
||||
<template slot-scope="scope">
|
||||
<el-tag size="mini" v-if="scope.row.valid">有效</el-tag>
|
||||
<el-tag size="mini" type="danger" v-if="!scope.row.valid">无效</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="key"
|
||||
label="字典键">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="value"
|
||||
label="字典值">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="sort"
|
||||
label="排序">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="createTime"
|
||||
label="创建时间">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
fixed="right"
|
||||
width="120"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-dropdown size="mini" split-button type="primary" @click="onAction(['edit',scope.row])"
|
||||
@command="onAction">
|
||||
<i class="el-icon-edit"></i>编辑
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
v-if="vm.totalCount > vm.pageSize"
|
||||
@current-change="onPage"
|
||||
:current-page="vm.pageNumber"
|
||||
:page-size="vm.pageSize"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
:total="vm.totalCount">
|
||||
</el-pagination>
|
||||
</el-card>
|
||||
</div>
|
||||
<style>
|
||||
#app {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.box-card {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.form .el-dialog{
|
||||
width: 700px;
|
||||
}
|
||||
|
||||
.form .el-dialog .el-form-item__content {
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: "#app",
|
||||
data: {
|
||||
vm: {
|
||||
id: '',
|
||||
dictId: location.getParam("dictId"),
|
||||
dictName: '',
|
||||
key: '',
|
||||
value: '',
|
||||
valid: '',
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0
|
||||
},
|
||||
select: [],
|
||||
result: [],
|
||||
form: {
|
||||
title: "",
|
||||
dialog: false,
|
||||
id: '',
|
||||
dictId: location.getParam("dictId"),
|
||||
key: '',
|
||||
value: '',
|
||||
sort: 0,
|
||||
valid: true
|
||||
},
|
||||
formRules: {
|
||||
key: [
|
||||
{required: true, message: '请输入字典名称', trigger: 'blur'},
|
||||
{min: 1, max: 50, message: '长度在 3 到 5 个字符', trigger: 'blur'}
|
||||
],
|
||||
value: [
|
||||
{required: true, message: '请输入字典代码', trigger: 'blur'},
|
||||
{min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur'}
|
||||
],
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onSearch: function () {
|
||||
this.vm.pageNumber = 1;
|
||||
this.onFind();
|
||||
},
|
||||
onReset: function (form) {
|
||||
this.$refs[form].resetFields();
|
||||
nav.w('重置成功');
|
||||
},
|
||||
onFind: function () {
|
||||
ajax.dictItemFind(this.vm).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.result = response.result;
|
||||
this.vm.totalCount = Number(response.totalCount);
|
||||
}
|
||||
}.bind(this))
|
||||
},
|
||||
onPage: function (pageNumber) {
|
||||
this.vm.pageNumber = pageNumber;
|
||||
this.onFind();
|
||||
},
|
||||
onSelectionChange: function (select) {
|
||||
this.select = select;
|
||||
},
|
||||
onBitchDelete: function () {
|
||||
if (this.select.length == 0) {
|
||||
nav.w("至少选中一项");
|
||||
} else {
|
||||
this.$confirm('将删除已选择的项, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function () {
|
||||
for (var i = 0; i < this.select.length; i++) {
|
||||
var obj = this.select[i];
|
||||
ajax.dictItemDelete({id: obj.id}).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
for (var j = 0; j < this.select.length; j++) {
|
||||
if (this.select[j].id == obj.id) {
|
||||
this.select.splice(j, 1);
|
||||
}
|
||||
}
|
||||
if (this.select.length == 0) {
|
||||
nav.s("删除成功")
|
||||
this.onFind();
|
||||
}
|
||||
}
|
||||
}.bind(this))
|
||||
}
|
||||
}.bind(this)).catch(function (action) {
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
getDict: function () {
|
||||
ajax.dictGet({id: location.getParam("dictId")}).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.vm.dictName = response.dict.dictName;
|
||||
}
|
||||
}.bind(this))
|
||||
},
|
||||
onAction: function (arg) {
|
||||
const action = arg[0];
|
||||
const item = arg[1];
|
||||
switch (action) {
|
||||
case "create":
|
||||
this.form.title = '新增字典项';
|
||||
this.form.id = '';
|
||||
this.form.key = '';
|
||||
this.form.value = '';
|
||||
this.form.sort = this.vm.totalCount;
|
||||
this.form.valid = true;
|
||||
this.form.dialog = true;
|
||||
break;
|
||||
case "save":
|
||||
this.$refs['form'].validate(function (valid) {
|
||||
if (valid) {
|
||||
if (this.form.id) {
|
||||
ajax.dictItemUpdate(this.form).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.onFind();
|
||||
this.form.dialog = false;
|
||||
}
|
||||
}.bind(this))
|
||||
} else {
|
||||
ajax.dictItemCreate(this.form).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.onFind();
|
||||
this.form.dialog = false;
|
||||
}
|
||||
}.bind(this))
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}.bind(this));
|
||||
break;
|
||||
case "edit":
|
||||
this.form.title = '编辑字典项';
|
||||
this.form.id = item.id;
|
||||
this.form.key = item.key;
|
||||
this.form.value = item.value;
|
||||
this.form.valid = item.valid;
|
||||
this.form.sort = item.sort;
|
||||
this.form.rowVersion = item.rowVersion;
|
||||
this.form.dialog = true;
|
||||
break;
|
||||
case "delete":
|
||||
this.$confirm('将删除该项, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function () {
|
||||
ajax.dictItemDelete({id: item.id}).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
nav.s("删除成功")
|
||||
this.onFind();
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
filters: {},
|
||||
created: function () {
|
||||
},
|
||||
mounted: function () {
|
||||
this.getDict();
|
||||
this.onFind();
|
||||
},
|
||||
watch: {}
|
||||
})
|
||||
</script>
|
Loading…
Reference in new issue