From ac3d27cbf4a8d649e80380b715cc15ddc1390da5 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Sun, 24 Jan 2021 22:25:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E6=88=90=E5=A4=9A=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 + .../i18n/TranslationViewController.java | 50 ++++++ .../V1.0_20210124_0001__add_i18n_table.sql | 12 ++ .../assets/modular/system/i18n/translation.js | 142 ++++++++++++++++++ .../modular/system/i18n/translation_add.js | 46 ++++++ .../modular/system/i18n/translation_edit.js | 51 +++++++ .../modular/system/i18n/translation.html | 35 +++++ .../modular/system/i18n/translation_add.html | 48 ++++++ .../modular/system/i18n/translation_edit.html | 48 ++++++ 9 files changed, 439 insertions(+) create mode 100644 src/main/java/cn/stylefeng/guns/modular/system/i18n/TranslationViewController.java create mode 100644 src/main/resources/db/migration/V1.0_20210124_0001__add_i18n_table.sql create mode 100644 src/main/webapp/assets/modular/system/i18n/translation.js create mode 100644 src/main/webapp/assets/modular/system/i18n/translation_add.js create mode 100644 src/main/webapp/assets/modular/system/i18n/translation_edit.js create mode 100644 src/main/webapp/pages/modular/system/i18n/translation.html create mode 100644 src/main/webapp/pages/modular/system/i18n/translation_add.html create mode 100644 src/main/webapp/pages/modular/system/i18n/translation_edit.html diff --git a/pom.xml b/pom.xml index ea1fcbc0..dcd763d4 100644 --- a/pom.xml +++ b/pom.xml @@ -127,6 +127,13 @@ 1.0.0 + + + cn.stylefeng.roses + i18n-spring-boot-starter + 1.0.0 + + cn.stylefeng.roses diff --git a/src/main/java/cn/stylefeng/guns/modular/system/i18n/TranslationViewController.java b/src/main/java/cn/stylefeng/guns/modular/system/i18n/TranslationViewController.java new file mode 100644 index 00000000..5610dcd2 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/system/i18n/TranslationViewController.java @@ -0,0 +1,50 @@ +package cn.stylefeng.guns.modular.system.i18n; + +import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource; +import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource; +import org.springframework.stereotype.Controller; + +/** + * 多语言界面 + * + * @author fengshuonan + * @date 2021/1/24 19:15 + */ +@Controller +@ApiResource(name = "多语言界面") +public class TranslationViewController { + + /** + * 多语言主界面 + * + * @author fengshuonan + * @date 2021/1/24 19:15 + */ + @GetResource(name = "文件管理首页", path = "/view/i18n") + public String index() { + return "/modular/system/i18n/translation.html"; + } + + /** + * 多语言新增界面 + * + * @author fengshuonan + * @date 2021/1/24 19:16 + */ + @GetResource(name = "多语言新增界面", path = "/view/i18n/add") + public String add() { + return "/modular/system/i18n/translation_add.html"; + } + + /** + * 多语言编辑界面 + * + * @author fengshuonan + * @date 2021/1/24 19:16 + */ + @GetResource(name = "文件管理首页", path = "/view/i18n/edit") + public String edit() { + return "/modular/system/i18n/translation_edit.html"; + } + +} diff --git a/src/main/resources/db/migration/V1.0_20210124_0001__add_i18n_table.sql b/src/main/resources/db/migration/V1.0_20210124_0001__add_i18n_table.sql new file mode 100644 index 00000000..fe5aae36 --- /dev/null +++ b/src/main/resources/db/migration/V1.0_20210124_0001__add_i18n_table.sql @@ -0,0 +1,12 @@ +CREATE TABLE `sys_translation` ( + `tran_id` bigint(20) NOT NULL COMMENT '主键id', + `tran_code` varchar(255) NOT NULL COMMENT '编码', + `tran_name` varchar(255) NOT NULL COMMENT '多语言条例名称', + `language` int(11) NOT NULL COMMENT '1:中文 2:英语', + `tran_value` varchar(255) NOT NULL COMMENT '翻译的值', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `create_user` bigint(20) DEFAULT NULL COMMENT '创建人', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `update_user` bigint(20) DEFAULT NULL COMMENT '更新人', + PRIMARY KEY (`tran_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='多语言表'; diff --git a/src/main/webapp/assets/modular/system/i18n/translation.js b/src/main/webapp/assets/modular/system/i18n/translation.js new file mode 100644 index 00000000..e0561890 --- /dev/null +++ b/src/main/webapp/assets/modular/system/i18n/translation.js @@ -0,0 +1,142 @@ +layui.use(['table', 'admin', 'ax', 'func'], function () { + var $ = layui.$; + var table = layui.table; + var $ax = layui.ax; + var admin = layui.admin; + var func = layui.func; + + /** + * 多语言表管理 + */ + var Translation = { + tableId: "translationTable" + }; + + /** + * 初始化表格的列 + */ + Translation.initColumn = function () { + return [[ + {type: 'checkbox'}, + {field: 'tranId', hide: true, title: '主键id'}, + {field: 'tranCode', sort: true, title: '编码'}, + {field: 'tranName', sort: true, title: '名称'}, + { + field: 'languages', sort: true, title: '语种', templet: function (d) { + if (d.languages === 1) { + return "中文"; + } else if (d.languages === 2) { + return "英文"; + } + } + }, + {field: 'tranValue', sort: true, title: '翻译的值'}, + {field: 'createTime', sort: true, title: '创建时间'}, + {field: 'updateTime', sort: true, title: '更新时间'}, + {align: 'center', toolbar: '#tableBar', title: '操作'} + ]]; + }; + + /** + * 点击查询按钮 + */ + Translation.search = function () { + var queryData = {}; + queryData['condition'] = $("#condition").val(); + table.reload(Translation.tableId, { + where: queryData, page: {curr: 1} + }); + }; + + /** + * 弹出添加对话框 + */ + Translation.openAddDlg = function () { + func.open({ + title: '添加多语言表', + content: Feng.ctxPath + '/translation/add', + tableId: Translation.tableId + }); + }; + + /** + * 点击编辑 + * + * @param data 点击按钮时候的行数据 + */ + Translation.openEditDlg = function (data) { + func.open({ + title: '修改多语言表', + content: Feng.ctxPath + '/translation/edit?tranId=' + data.tranId, + tableId: Translation.tableId + }); + }; + + /** + * 导出excel按钮 + */ + Translation.exportExcel = function () { + var checkRows = table.checkStatus(Translation.tableId); + if (checkRows.data.length === 0) { + Feng.error("请选择要导出的数据"); + } else { + table.exportFile(tableResult.config.id, checkRows.data, 'xls'); + } + }; + + /** + * 点击删除 + * + * @param data 点击按钮时候的行数据 + */ + Translation.onDeleteItem = function (data) { + var operation = function () { + var ajax = new $ax(Feng.ctxPath + "/translation/delete", function (data) { + Feng.success("删除成功!"); + table.reload(Translation.tableId); + }, function (data) { + Feng.error("删除失败!" + data.responseJSON.message + "!"); + }); + ajax.set("tranId", data.tranId); + ajax.start(); + }; + Feng.confirm("是否删除?", operation); + }; + + // 渲染表格 + var tableResult = table.render({ + elem: '#' + Translation.tableId, + url: Feng.ctxPath + '/translation/list', + page: true, + height: "full-158", + cellMinWidth: 100, + cols: Translation.initColumn() + }); + + // 搜索按钮点击事件 + $('#btnSearch').click(function () { + Translation.search(); + }); + + // 添加按钮点击事件 + $('#btnAdd').click(function () { + Translation.openAddDlg(); + }); + + // 导出excel + $('#btnExp').click(function () { + Translation.exportExcel(); + }); + + // 工具条点击事件 + table.on('tool(' + Translation.tableId + ')', function (obj) { + var data = obj.data; + var layEvent = obj.event; + + if (layEvent === 'edit') { + Translation.openEditDlg(data); + } else if (layEvent === 'delete') { + Translation.onDeleteItem(data); + } + }); +}); diff --git a/src/main/webapp/assets/modular/system/i18n/translation_add.js b/src/main/webapp/assets/modular/system/i18n/translation_add.js new file mode 100644 index 00000000..5550e90e --- /dev/null +++ b/src/main/webapp/assets/modular/system/i18n/translation_add.js @@ -0,0 +1,46 @@ +/** + * 添加或者修改页面 + */ +var TranslationInfoDlg = { + data: { + tranCode: "", + tranName: "", + languages: "", + tranValue: "", + createTime: "", + createUser: "", + updateTime: "", + updateUser: "" + } +}; + +layui.use(['form', 'admin', 'ax'], function () { + var $ = layui.jquery; + var $ax = layui.ax; + var form = layui.form; + var admin = layui.admin; + + //让当前iframe弹层高度适应 + admin.iframeAuto(); + + //表单提交事件 + form.on('submit(btnSubmit)', function (data) { + var ajax = new $ax(Feng.ctxPath + "/translation/addItem", function (data) { + Feng.success("添加成功!"); + + //传给上个页面,刷新table用 + admin.putTempData('formOk', true); + + //关掉对话框 + admin.closeThisDialog(); + + }, function (data) { + Feng.error("添加失败!" + data.responseJSON.message) + }); + ajax.set(data.field); + ajax.start(); + + return false; + }); + +}); \ No newline at end of file diff --git a/src/main/webapp/assets/modular/system/i18n/translation_edit.js b/src/main/webapp/assets/modular/system/i18n/translation_edit.js new file mode 100644 index 00000000..f7e938b4 --- /dev/null +++ b/src/main/webapp/assets/modular/system/i18n/translation_edit.js @@ -0,0 +1,51 @@ +/** + * 详情对话框 + */ +var TranslationInfoDlg = { + data: { + tranCode: "", + tranName: "", + languages: "", + tranValue: "", + createTime: "", + createUser: "", + updateTime: "", + updateUser: "" + } +}; + +layui.use(['form', 'admin', 'ax'], function () { + var $ = layui.jquery; + var $ax = layui.ax; + var form = layui.form; + var admin = layui.admin; + + //让当前iframe弹层高度适应 + admin.iframeAuto(); + + //获取详情信息,填充表单 + var ajax = new $ax(Feng.ctxPath + "/translation/detail?tranId=" + Feng.getUrlParam("tranId")); + var result = ajax.start(); + form.val('translationForm', result.data); + + //表单提交事件 + form.on('submit(btnSubmit)', function (data) { + var ajax = new $ax(Feng.ctxPath + "/translation/editItem", function (data) { + Feng.success("更新成功!"); + + //传给上个页面,刷新table用 + admin.putTempData('formOk', true); + + //关掉对话框 + admin.closeThisDialog(); + + }, function (data) { + Feng.error("更新失败!" + data.responseJSON.message) + }); + ajax.set(data.field); + ajax.start(); + + return false; + }); + +}); \ No newline at end of file diff --git a/src/main/webapp/pages/modular/system/i18n/translation.html b/src/main/webapp/pages/modular/system/i18n/translation.html new file mode 100644 index 00000000..42ed41c9 --- /dev/null +++ b/src/main/webapp/pages/modular/system/i18n/translation.html @@ -0,0 +1,35 @@ +@layout("/common/_container.html",{js:["/assets/modular/i18n/translation.js"]}){ + +
+ 多语言表管理 +
+ +
+
+
+
+
+
+
+
+ +
+
+ + + +
+
+
+
+
+
+
+
+
+ + +@} \ No newline at end of file diff --git a/src/main/webapp/pages/modular/system/i18n/translation_add.html b/src/main/webapp/pages/modular/system/i18n/translation_add.html new file mode 100644 index 00000000..a60db877 --- /dev/null +++ b/src/main/webapp/pages/modular/system/i18n/translation_add.html @@ -0,0 +1,48 @@ +@layout("/common/_form.html",{js:["/assets/modular/i18n/translation_add.js"]}){ + +
+
+
+
基本信息
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ + +
+ +
+ +@} \ No newline at end of file diff --git a/src/main/webapp/pages/modular/system/i18n/translation_edit.html b/src/main/webapp/pages/modular/system/i18n/translation_edit.html new file mode 100644 index 00000000..11e7b5a3 --- /dev/null +++ b/src/main/webapp/pages/modular/system/i18n/translation_edit.html @@ -0,0 +1,48 @@ +@layout("/common/_form.html",{js:["/assets/modular/i18n/translation_edit.js"]}){ + +
+
+
+
基本信息
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+ + +
+ +
+ +@} \ No newline at end of file