更新初始化文件

pull/1/head
759675757@qq.com 2019-10-15 16:22:41 +08:00
parent e630ec9927
commit 8ae6cdce17
29 changed files with 945 additions and 137 deletions

View File

@ -21,7 +21,7 @@ USE `sparchetype`;
DROP TABLE IF EXISTS `sp_sys_dict`;
CREATE TABLE `sp_sys_dict` (
`id` varchar(64) NOT NULL COMMENT 'id',
`id` varchar(64) NOT NULL COMMENT '主键id',
`name` varchar(64) NOT NULL COMMENT '标签名',
`value` varchar(64) NOT NULL COMMENT '数据值',
`type` varchar(64) NOT NULL COMMENT '类型',
@ -39,13 +39,5 @@ CREATE TABLE `sp_sys_dict` (
/*Data for the table `sp_sys_dict` */
insert into `sp_sys_dict`(`id`,`name`,`value`,`type`,`descr`,`sort_num`,`parent_id`,`status`,`created`,`created_by`,`last_upd`,`last_upd_by`) values
('1166284627817877506','test','test','test','test',1,'0','0','2019-08-27 17:41:17','test','2019-08-27 17:41:17','test'),
('1300490103029792','','1','yes_no','是/否',1,'0','0','2019-08-26 00:00:00','sp','2019-08-26 16:08:47','sp'),
('1300490690232352','','1','yes_no','是/否',2,'0','0','2019-08-26 00:00:00','sp','2019-08-26 16:12:05','sp'),
('1300670302912544','test','test','test','test',1,'0','0','2019-08-27 15:58:52','test','2019-08-27 15:58:52','test');
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
insert into `sp_sys_dict`(`id`,`name`,`value`,`type`,`descr`,`sort_num`,`parent_id`,`status`,`created`,`created_by`,`last_upd`,`last_upd_by`) values
('1183935079065665538','足球','football','hobby','爱好足球',1,NULL,'0','2019-10-15 10:38:14','SongPeng','2019-10-15 10:38:14','SongPeng');

View File

@ -0,0 +1,78 @@
/*
Navicat Premium Data Transfer
Source Server : postgre-sp
Source Server Type : PostgreSQL
Source Server Version : 110003
Source Host : localhost:5432
Source Catalog : sparchetype
Source Schema : public
Target Server Type : PostgreSQL
Target Server Version : 110003
File Encoding : 65001
Date: 15/06/2019 17:03:33
*/
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS "public"."sys_user";
CREATE TABLE "public"."sys_user" (
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
"name" varchar(64) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"username" varchar(128) COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::character varying,
"password" varchar(64) COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::character varying,
"dept_id" varchar(64) COLLATE "pg_catalog"."default",
"email" varchar(100) COLLATE "pg_catalog"."default",
"mobile" varchar(32) COLLATE "pg_catalog"."default",
"tel" varchar(32) COLLATE "pg_catalog"."default",
"sex" char(2) COLLATE "pg_catalog"."default",
"birthday" timestamptz(0),
"pic_id" varchar(64) COLLATE "pg_catalog"."default",
"id_card" varchar(32) COLLATE "pg_catalog"."default",
"hobby" varchar(255) COLLATE "pg_catalog"."default",
"province" varchar(255) COLLATE "pg_catalog"."default",
"city" varchar(255) COLLATE "pg_catalog"."default",
"district" varchar(255) COLLATE "pg_catalog"."default",
"street" varchar(255) COLLATE "pg_catalog"."default",
"street_number" varchar(255) COLLATE "pg_catalog"."default",
"description" varchar(100) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"status" char(2) COLLATE "pg_catalog"."default" NOT NULL,
"created_by" varchar(64) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"created" timestamptz(0),
"last_upd_by" varchar(64) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"last_upd" timestamptz(0)
)
;
COMMENT ON COLUMN "public"."sys_user"."id" IS 'id';
COMMENT ON COLUMN "public"."sys_user"."name" IS '姓名';
COMMENT ON COLUMN "public"."sys_user"."username" IS '用户名';
COMMENT ON COLUMN "public"."sys_user"."password" IS '密码';
COMMENT ON COLUMN "public"."sys_user"."dept_id" IS '部门id';
COMMENT ON COLUMN "public"."sys_user"."email" IS '邮箱';
COMMENT ON COLUMN "public"."sys_user"."mobile" IS '手机号';
COMMENT ON COLUMN "public"."sys_user"."tel" IS '固定电话';
COMMENT ON COLUMN "public"."sys_user"."sex" IS '0: 女1: 男2: 其他';
COMMENT ON COLUMN "public"."sys_user"."birthday" IS '出生年月日';
COMMENT ON COLUMN "public"."sys_user"."pic_id" IS '图片id对应sys_file表中的id';
COMMENT ON COLUMN "public"."sys_user"."id_card" IS '身份证';
COMMENT ON COLUMN "public"."sys_user"."hobby" IS '爱好';
COMMENT ON COLUMN "public"."sys_user"."province" IS '省份';
COMMENT ON COLUMN "public"."sys_user"."city" IS '城市';
COMMENT ON COLUMN "public"."sys_user"."district" IS '区县';
COMMENT ON COLUMN "public"."sys_user"."street" IS '街道';
COMMENT ON COLUMN "public"."sys_user"."street_number" IS '门牌号';
COMMENT ON COLUMN "public"."sys_user"."description" IS '角色描述';
COMMENT ON COLUMN "public"."sys_user"."status" IS '状态0 删除1 正常2 禁用';
COMMENT ON COLUMN "public"."sys_user"."created_by" IS '创建人';
COMMENT ON COLUMN "public"."sys_user"."created" IS '创建时间';
COMMENT ON COLUMN "public"."sys_user"."last_upd_by" IS '最后更新人';
COMMENT ON COLUMN "public"."sys_user"."last_upd" IS '最后更新时间';
-- ----------------------------
-- Primary Key structure for table sys_user
-- ----------------------------
ALTER TABLE "public"."sys_user" ADD CONSTRAINT "test_by_sp_pkey" PRIMARY KEY ("id");

View File

@ -1,78 +1,42 @@
/*
Navicat Premium Data Transfer
/*Table structure for table `sp_sys_user` */
Source Server : postgre-sp
Source Server Type : PostgreSQL
Source Server Version : 110003
Source Host : localhost:5432
Source Catalog : sparchetype
Source Schema : public
DROP TABLE IF EXISTS `sp_sys_user`;
Target Server Type : PostgreSQL
Target Server Version : 110003
File Encoding : 65001
CREATE TABLE `sp_sys_user` (
`id` varchar(64) NOT NULL COMMENT '主键id',
`name` varchar(64) NOT NULL COMMENT '姓名',
`username` varchar(128) NOT NULL COMMENT '用户名',
`password` varchar(64) NOT NULL COMMENT '密码',
`dept_id` varchar(64) DEFAULT NULL COMMENT '部门id',
`email` varchar(64) DEFAULT NULL COMMENT '邮箱',
`mobile` varchar(32) NOT NULL COMMENT '手机号',
`tel` varchar(32) DEFAULT NULL COMMENT '固定电话',
`sex` char(1) NOT NULL COMMENT '性别(0:女;1:男;2:其他)',
`birthday` datetime DEFAULT NULL COMMENT '出生年月日',
`pic_id` varchar(64) DEFAULT NULL COMMENT '图片id对应sys_file表中的id',
`id_card` varchar(32) DEFAULT NULL COMMENT '身份证',
`hobby` varchar(255) DEFAULT NULL COMMENT '爱好',
`province` varchar(128) DEFAULT NULL COMMENT '省份',
`city` varchar(128) DEFAULT NULL COMMENT '城市',
`district` varchar(128) DEFAULT NULL COMMENT '区县',
`street` varchar(128) DEFAULT NULL COMMENT '街道',
`street_number` varchar(64) DEFAULT NULL COMMENT '门牌号',
`descr` varchar(255) DEFAULT NULL COMMENT '描述',
`status` char(1) NOT NULL COMMENT '状态(0:删除;1:正常;2:禁用)',
`created` datetime NOT NULL COMMENT '创建时间',
`created_by` varchar(64) NOT NULL COMMENT '创建人',
`last_upd` datetime NOT NULL COMMENT '最后更新时间',
`last_upd_by` varchar(64) NOT NULL COMMENT '最后更新人',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_sp_sys_user_username` (`username`) COMMENT '用户名唯一索引',
UNIQUE KEY `idx_sp_sys_user_mobile` (`mobile`) COMMENT '用户手机号唯一索引',
KEY `idx_sp_sys_user_email` (`email`) COMMENT '用户邮箱唯一索引',
KEY `idx_sp_sys_user_id_card` (`id_card`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Date: 15/06/2019 17:03:33
*/
/*Data for the table `sp_sys_user` */
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS "public"."sys_user";
CREATE TABLE "public"."sys_user" (
"id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
"name" varchar(64) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"username" varchar(128) COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::character varying,
"password" varchar(64) COLLATE "pg_catalog"."default" NOT NULL DEFAULT ''::character varying,
"dept_id" varchar(64) COLLATE "pg_catalog"."default",
"email" varchar(100) COLLATE "pg_catalog"."default",
"mobile" varchar(32) COLLATE "pg_catalog"."default",
"tel" varchar(32) COLLATE "pg_catalog"."default",
"sex" char(2) COLLATE "pg_catalog"."default",
"birthday" timestamptz(0),
"pic_id" varchar(64) COLLATE "pg_catalog"."default",
"id_card" varchar(32) COLLATE "pg_catalog"."default",
"hobby" varchar(255) COLLATE "pg_catalog"."default",
"province" varchar(255) COLLATE "pg_catalog"."default",
"city" varchar(255) COLLATE "pg_catalog"."default",
"district" varchar(255) COLLATE "pg_catalog"."default",
"street" varchar(255) COLLATE "pg_catalog"."default",
"street_number" varchar(255) COLLATE "pg_catalog"."default",
"description" varchar(100) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"status" char(2) COLLATE "pg_catalog"."default" NOT NULL,
"created_by" varchar(64) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"created" timestamptz(0),
"last_upd_by" varchar(64) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"last_upd" timestamptz(0)
)
;
COMMENT ON COLUMN "public"."sys_user"."id" IS 'id';
COMMENT ON COLUMN "public"."sys_user"."name" IS '姓名';
COMMENT ON COLUMN "public"."sys_user"."username" IS '用户名';
COMMENT ON COLUMN "public"."sys_user"."password" IS '密码';
COMMENT ON COLUMN "public"."sys_user"."dept_id" IS '部门id';
COMMENT ON COLUMN "public"."sys_user"."email" IS '邮箱';
COMMENT ON COLUMN "public"."sys_user"."mobile" IS '手机号';
COMMENT ON COLUMN "public"."sys_user"."tel" IS '固定电话';
COMMENT ON COLUMN "public"."sys_user"."sex" IS '0: 女1: 男2: 其他';
COMMENT ON COLUMN "public"."sys_user"."birthday" IS '出生年月日';
COMMENT ON COLUMN "public"."sys_user"."pic_id" IS '图片id对应sys_file表中的id';
COMMENT ON COLUMN "public"."sys_user"."id_card" IS '身份证';
COMMENT ON COLUMN "public"."sys_user"."hobby" IS '爱好';
COMMENT ON COLUMN "public"."sys_user"."province" IS '省份';
COMMENT ON COLUMN "public"."sys_user"."city" IS '城市';
COMMENT ON COLUMN "public"."sys_user"."district" IS '区县';
COMMENT ON COLUMN "public"."sys_user"."street" IS '街道';
COMMENT ON COLUMN "public"."sys_user"."street_number" IS '门牌号';
COMMENT ON COLUMN "public"."sys_user"."description" IS '角色描述';
COMMENT ON COLUMN "public"."sys_user"."status" IS '状态0 删除1 正常2 禁用';
COMMENT ON COLUMN "public"."sys_user"."created_by" IS '创建人';
COMMENT ON COLUMN "public"."sys_user"."created" IS '创建时间';
COMMENT ON COLUMN "public"."sys_user"."last_upd_by" IS '最后更新人';
COMMENT ON COLUMN "public"."sys_user"."last_upd" IS '最后更新时间';
-- ----------------------------
-- Primary Key structure for table sys_user
-- ----------------------------
ALTER TABLE "public"."sys_user" ADD CONSTRAINT "test_by_sp_pkey" PRIMARY KEY ("id");
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

View File

@ -5,12 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.songpeng.sparchetype.common.BaseController;
import com.songpeng.sparchetype.common.Result;
import com.songpeng.sparchetype.system.dto.SysDictDto;
import com.songpeng.sparchetype.system.entity.SysDict;
import com.songpeng.sparchetype.system.service.ISysDictService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@ -19,8 +17,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.time.LocalDateTime;
/**
* <p>
*
@ -37,27 +33,31 @@ public class SysDictController extends BaseController {
@Autowired
private ISysDictService sysDictService;
@PostMapping("/add")
@ResponseBody
public Result add(SysDict sysDict) {
boolean save = sysDictService.save(sysDict);
return Result.success(sysDict.getId());
}
@GetMapping("/list-ui")
public String listUI(Model model) {
return "system/dict/list";
}
@GetMapping("/add-or-upd-ui")
public String addOrUpdUI(Model model) {
return "system/dict/addOrUpd";
}
@PostMapping("/page")
@ResponseBody
@ResponseBody
public Result page(Page page) {
IPage result = sysDictService.page(page);
return Result.success(result);
}
@GetMapping("/add-or-upd-ui")
public String addOrUpdUI(Model model, SysDict record) {
if (StringUtils.isNotEmpty(record.getId())) {
SysDict dict = sysDictService.getById(record.getId());
model.addAttribute("dict", dict);
}
return "system/dict/addOrUpd";
}
@PostMapping("/add-or-upd")
@ResponseBody
public Result add(SysDict record) {
sysDictService.saveOrUpdate(record);
return Result.success(record.getId());
}
}

View File

@ -0,0 +1,63 @@
package com.songpeng.sparchetype.system.controller.admin;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.songpeng.sparchetype.common.BaseController;
import com.songpeng.sparchetype.common.Result;
import com.songpeng.sparchetype.system.entity.SysUser;
import com.songpeng.sparchetype.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* <p>
*
* </p>
*
* @author SongPeng
* @since 2019-10-15
*/
@Controller
@RequestMapping("/admin/sys/user")
@Slf4j
public class SysUserController extends BaseController {
@Autowired
private ISysUserService sysUserService;
@GetMapping("/list-ui")
public String listUI(Model model) {
return "system/user/list";
}
@PostMapping("/page")
@ResponseBody
public Result page(Page page) {
IPage result = sysUserService.page(page);
return Result.success(result);
}
@GetMapping("/add-or-upd-ui")
public String addOrUpdUI(Model model, SysUser record) {
if (StringUtils.isNotEmpty(record.getId())) {
SysUser user = sysUserService.getById(record.getId());
model.addAttribute("user", user);
}
return "system/user/addOrUpd";
}
@PostMapping("/add-or-upd")
@ResponseBody
public Result add(SysUser record) {
sysUserService.saveOrUpdate(record);
return Result.success(record.getId());
}
}

View File

@ -0,0 +1,16 @@
package com.songpeng.sparchetype.system.dto;
import com.songpeng.sparchetype.system.entity.SysUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author SongPeng
* @date 2019/9/30 9:49
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SysUserDto extends SysUser {
}

View File

@ -0,0 +1,123 @@
package com.songpeng.sparchetype.system.entity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableName;
import com.songpeng.sparchetype.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author SongPeng
* @since 2019-10-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sp_sys_user")
public class SysUser extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private String name;
/**
*
*/
private String username;
/**
*
*/
private String password;
/**
* id
*/
private String deptId;
/**
*
*/
private String email;
/**
*
*/
private String mobile;
/**
*
*/
private String tel;
/**
* (0:;1:;2:)
*/
private String sex;
/**
*
*/
private LocalDateTime birthday;
/**
* idsys_fileid
*/
private String picId;
/**
*
*/
private String idCard;
/**
*
*/
private String hobby;
/**
*
*/
private String province;
/**
*
*/
private String city;
/**
*
*/
private String district;
/**
*
*/
private String street;
/**
*
*/
private String streetNumber;
/**
*
*/
private String descr;
/**
* (0:;1:;2:)
*/
private String status;
}

View File

@ -0,0 +1,16 @@
package com.songpeng.sparchetype.system.mapper;
import com.songpeng.sparchetype.system.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper
* </p>
*
* @author SongPeng
* @since 2019-10-15
*/
public interface SysUserMapper extends BaseMapper<SysUser> {
}

View File

@ -0,0 +1,16 @@
package com.songpeng.sparchetype.system.service;
import com.songpeng.sparchetype.system.entity.SysUser;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
*
* </p>
*
* @author SongPeng
* @since 2019-10-15
*/
public interface ISysUserService extends IService<SysUser> {
}

View File

@ -0,0 +1,20 @@
package com.songpeng.sparchetype.system.service.impl;
import com.songpeng.sparchetype.system.entity.SysUser;
import com.songpeng.sparchetype.system.mapper.SysUserMapper;
import com.songpeng.sparchetype.system.service.ISysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
*
* </p>
*
* @author SongPeng
* @since 2019-10-15
*/
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
}

View File

@ -14,6 +14,8 @@ spring:
cache: false
expose-spring-macro-helpers: false
request-context-attribute: request
settings:
classic_compatible: true
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.songpeng.sparchetype.system.mapper.SysUserMapper">
</mapper>

View File

@ -469,7 +469,7 @@ table td {
width: 100%;
background-color: #222;
border-top: 1px solid rgba(255, 255, 255, 0.2);
line-height: 41px;
line-height: 36px;
color: #fff;
/*padding-left: 10px;*/
}

View File

@ -280,7 +280,7 @@ layui.define(['jquery', 'form', 'layer', 'element'], function(exports) {
* @todo 重新计算iframe高度
*/
function FrameWH() {
var h = $(window).height() - 164;
var h = $(window).height() - 126;
$("iframe").css("height", h + "px");
}
$(window).resize(function() {
@ -346,11 +346,11 @@ layui.define(['jquery', 'form', 'layer', 'element'], function(exports) {
shadeClose: true,
shade: 0.4,
title: title,
content: url,
content: url + '?id=' + id,
success: function(layero, index) {
//向iframe页的id=house的元素传值 // 参考 https://yq.aliyun.com/ziliao/133150
var body = layer.getChildFrame('body', index);
body.contents().find("#dataId").val(id);
body.contents().find("#js-id").val(id);
console.log(id);
},
error: function(layero, index) {

View File

@ -77,7 +77,7 @@
"id": 14,
"name": "管理员列表",
"icon": "",
"url": "/blog/article/listui"
"url": "/admin/sys/user/list-ui"
},
{
"id": 15,

View File

@ -412,7 +412,6 @@
function setTimeAgo(y, M, d, H, m, s,id){
var str = util.timeAgo(new Date(y, M||0, d||1, H||0, m||0, s||0));
$(id).html(str);
console.log(str);
};
});
</script>

View File

@ -192,14 +192,11 @@
if(data.length > 0) {
layer.msg("您点击了推荐操作");
for(var i = 0; i < data.length; i++) {
console.log("a:" + data[i].recommend);
data[i].recommend = "checked";
console.log("aa:" + data[i].recommend);
form.render();
}
} else {
console.log("b");
layer.msg("请先选择");
}
break;

View File

@ -22,7 +22,7 @@
<span class="we-red">*</span>标签名
</label>
<div class="layui-input-inline">
<input type="text" id="js-name" name="name" lay-verify="required" autocomplete="off" class="layui-input">
<input type="text" id="js-name" name="name" lay-verify="required" autocomplete="off" class="layui-input" value="${dict.name}">
</div>
</div>
@ -31,7 +31,7 @@
<span class="we-red">*</span>标签值
</label>
<div class="layui-input-inline">
<input type="text" id="js-value" name="value" lay-verify="required" autocomplete="off" class="layui-input">
<input type="text" id="js-value" name="value" lay-verify="required" autocomplete="off" class="layui-input" value="${dict.value}">
</div>
</div>
@ -40,7 +40,7 @@
<span class="we-red">*</span>类别
</label>
<div class="layui-input-inline">
<input type="text" id="js-type" name="type" lay-verify="required" autocomplete="off" class="layui-input">
<input type="text" id="js-type" name="type" lay-verify="required" autocomplete="off" class="layui-input" value="${dict.type}">
</div>
</div>
@ -49,7 +49,7 @@
<span class="we-red">*</span>描述
</label>
<div class="layui-input-inline">
<input type="text" id="js-descr" name="descr" lay-verify="required" autocomplete="off" class="layui-input">
<input type="text" id="js-descr" name="descr" lay-verify="required" autocomplete="off" class="layui-input" value="${dict.descr}">
</div>
</div>
@ -58,12 +58,12 @@
<span class="we-red">*</span>排序
</label>
<div class="layui-input-inline">
<input type="text" id="js-sort-num" name="sortNum" lay-verify="required|number" autocomplete="off" class="layui-input">
<input type="text" id="js-sort-num" name="sortNum" lay-verify="required|number" autocomplete="off" class="layui-input" value="${dict.sortNum}">
</div>
</div>
<div class="layui-form-item">
<label for="js-status" class="layui-form-label">状态</label>
<label for="js-status" class="layui-form-label"><span class="we-red">*</span>状态</label>
<div class="layui-input-block" id="js-status">
<input type="radio" name="status" value="0" title="正常" checked>
<input type="radio" name="status" value="1" title="已删除">
@ -71,6 +71,7 @@
</div>
<div class="layui-form-item">
<input type="hidden" name="id" id="js-id" value="" />
<label for="js-add-btn" class="layui-form-label"></label>
<button id="js-add-btn" class="layui-btn" lay-filter="add" lay-submit="">确定</button>
</div>
@ -100,16 +101,14 @@
//监听提交
form.on('submit(add)', function(data) {
console.log(data.field);
$.ajax({
type: "POST",
//请求的媒体类型
//contentType: "application/json;charset=UTF-8",
url: "${request.contextPath}/admin/sys/dict/add",
url: "${request.contextPath}/admin/sys/dict/add-or-upd",
//data: JSON.stringify(data),
data: data.field,
success: function(result) {
console.log(result);
if (result.code === 0) {
//获取提交成功的时间
var time = new Date();
@ -127,7 +126,6 @@
}
},
error: function(e){
console.log(e);
layer.alert(e, {
icon: 2
})

View File

@ -44,7 +44,7 @@
</form>
</div>
<!--数据表格-->
<table class="layui-hide" id="articleList" lay-filter="table-filter"></table>
<table class="layui-hide" id="record-table" lay-filter="table-filter"></table>
</div>
</body>
<script type="text/html" id="toolbar-top">
@ -68,7 +68,7 @@
</script>
<script type="text/html" id="operateTpl">
<a title="编辑" onclick="WeAdminEdit('编辑','./edit.html', 2, 600, 400)" href="javascript:;">
<a title="编辑" onclick="WeAdminEdit('编辑','${request.contextPath}/admin/sys/dict/add-or-upd-ui', '{{ d.id }}', 600, 400)" href="javascript:;">
<i class="layui-icon">&#xe642;</i>
</a>
<a title="查看" onclick="WeAdminShow('查看文章','./show.html',600,400)" href="javascript:;">
@ -98,7 +98,7 @@
});
var tableIns = table.render({
elem: '#articleList',
elem: '#record-table',
cellMinWidth: 80,
toolbar: '#toolbar-top',
method: 'POST',
@ -121,23 +121,22 @@
[{
type: 'checkbox'
}, {
field: 'name', title: '标签名',sort: true
field: 'name', title: '标签名'
}, {
field: 'value',title: '标签值',templet: '#usernameTpl'
field: 'value',title: '标签值'
}, {
field: 'type',title: '类别',sort: true
field: 'type',title: '类别'
}, {
field: 'descr',title: '描述',sort: true
field: 'descr',title: '描述'
}, {
field: 'status',title: '状态',sort: true
field: 'status',title: '状态'
}, {
field: 'operate',title: '操作',toolbar: '#operateTpl',unresize: true
field: 'operate',title: '操作', toolbar: '#operateTpl', unresize: true
}]
],
done: function(res, curr, count){
//如果是异步请求数据方式res即为你接口返回的信息。
//如果是直接赋值的方式res即为{data: [], count: 99} data为当前页数据、count为数据总长度
console.log(res);
}
});
@ -166,7 +165,7 @@
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
case 'getCheckData':
var checkStatus = table.checkStatus('articleList'),
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if(data.length > 0) {
layer.confirm('确认要删除吗?' + JSON.stringify(data), function(index) {
@ -181,19 +180,16 @@
}
break;
case 'recommend':
var checkStatus = table.checkStatus('articleList'),
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if(data.length > 0) {
layer.msg("您点击了推荐操作");
for(var i = 0; i < data.length; i++) {
console.log("a:" + data[i].recommend);
data[i].recommend = "checked";
console.log("aa:" + data[i].recommend);
form.render();
}
} else {
console.log("b");
layer.msg("请先选择");
}
break;

View File

@ -0,0 +1,266 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加用户</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="weadmin-body">
<form class="layui-form">
<div class="layui-form-item">
<label for="js-name" class="layui-form-label">
<span class="we-red">*</span>姓名
</label>
<div class="layui-input-inline">
<input type="text" id="js-name" name="name" lay-verify="required" autocomplete="off" class="layui-input" value="${user.name}">
</div>
</div>
<div class="layui-form-item">
<label for="js-username" class="layui-form-label">
<span class="we-red">*</span>用户名
</label>
<div class="layui-input-inline">
<input type="text" id="js-username" name="username" lay-verify="required" autocomplete="off" class="layui-input" value="${user.username}">
</div>
</div>
<div class="layui-form-item">
<label for="js-password" class="layui-form-label">
<span class="we-red">*</span>密码
</label>
<div class="layui-input-inline">
<input type="password" id="js-password" name="password" lay-verify="required" autocomplete="off" class="layui-input" value="${user.password}">
</div>
</div>
<div class="layui-form-item">
<label for="js-repassword" class="layui-form-label">
<span class="we-red">*</span>确认密码
</label>
<div class="layui-input-inline">
<input type="password" id="js-repassword" name="repassword" lay-verify="required" autocomplete="off" class="layui-input" value="${user.password}">
</div>
</div>
<div class="layui-form-item">
<label for="js-dept-id" class="layui-form-label">
部门id
</label>
<div class="layui-input-inline">
<input type="text" id="js-dept-id" name="deptId" lay-verify="" autocomplete="off" class="layui-input" value="${user.deptId}">
</div>
</div>
<div class="layui-form-item">
<label for="js-email" class="layui-form-label">
邮箱
</label>
<!--校验规则动态添加,根据鼠标焦点进行-->
<div class="layui-input-inline">
<input type="text" id="js-email" name="email" lay-verify="" autocomplete="off" class="layui-input" value="${user.email}">
</div>
</div>
<div class="layui-form-item">
<label for="js-mobile" class="layui-form-label">
<span class="we-red">*</span>手机号
</label>
<div class="layui-input-inline">
<input type="text" id="js-mobile" name="mobile" lay-verify="required|number" autocomplete="off" class="layui-input" value="${user.mobile}">
</div>
</div>
<div class="layui-form-item">
<label for="js-tel" class="layui-form-label">
固定电话
</label>
<div class="layui-input-inline">
<input type="text" id="js-tel" name="tel" lay-verify="" autocomplete="off" class="layui-input" value="${user.tel}">
</div>
</div>
<div class="layui-form-item">
<label for="js-sex" class="layui-form-label"><span class="we-red">*</span>性别</label>
<div class="layui-input-block" id="js-sex">
<input type="radio" name="sex" value="0" title="女" checked>
<input type="radio" name="sex" value="1" title="男">
<input type="radio" name="sex" value="2" title="其他">
</div>
</div>
<div class="layui-form-item">
<label for="js-birthday" class="layui-form-label">
出生年月日
</label>
<div class="layui-input-inline">
<input type="text" id="js-birthday" name="birthday" lay-verify="" autocomplete="off" class="layui-input" value="${user.birthday}">
</div>
</div>
<div class="layui-form-item">
<label for="js-pic-id" class="layui-form-label">
图片id
</label>
<div class="layui-input-inline">
<input type="text" id="js-pic-id" name="picId" lay-verify="" autocomplete="off" class="layui-input" value="${user.picId}">
</div>
</div>
<div class="layui-form-item">
<label for="js-id-card" class="layui-form-label">
身份证
</label>
<div class="layui-input-inline">
<input type="text" id="js-id-card" name="idCard" lay-verify="" autocomplete="off" class="layui-input" value="${user.idCard}">
</div>
</div>
<div class="layui-form-item">
<label for="js-hobby" class="layui-form-label">
爱好
</label>
<div class="layui-input-inline">
<input type="text" id="js-hobby" name="hobby" lay-verify="" autocomplete="off" class="layui-input" value="${user.hobby}">
</div>
</div>
<div class="layui-form-item">
<label for="js-province" class="layui-form-label">
省份
</label>
<div class="layui-input-inline">
<input type="text" id="js-province" name="province" lay-verify="" autocomplete="off" class="layui-input" value="${user.province}">
</div>
</div>
<div class="layui-form-item">
<label for="js-city" class="layui-form-label">
城市
</label>
<div class="layui-input-inline">
<input type="text" id="js-city" name="city" lay-verify="" autocomplete="off" class="layui-input" value="${user.city}">
</div>
</div>
<div class="layui-form-item">
<label for="js-district" class="layui-form-label">
区县
</label>
<div class="layui-input-inline">
<input type="text" id="js-district" name="district" lay-verify="" autocomplete="off" class="layui-input" value="${user.district}">
</div>
</div>
<div class="layui-form-item">
<label for="js-street" class="layui-form-label">
街道
</label>
<div class="layui-input-inline">
<input type="text" id="js-street" name="street" lay-verify="" autocomplete="off" class="layui-input" value="${user.street}">
</div>
</div>
<div class="layui-form-item">
<label for="js-street-number" class="layui-form-label">
门牌号
</label>
<div class="layui-input-inline">
<input type="text" id="js-street-number" name="streetNumber" lay-verify="" autocomplete="off" class="layui-input" value="${user.streetNumber}">
</div>
</div>
<div class="layui-form-item">
<label for="js-descr" class="layui-form-label">
描述
</label>
<div class="layui-input-inline">
<input type="text" id="js-descr" name="descr" lay-verify="" autocomplete="off" class="layui-input" value="${user.descr}">
</div>
</div>
<div class="layui-form-item">
<label for="js-status" class="layui-form-label"><span class="we-red">*</span>状态</label>
<div class="layui-input-block" id="js-status">
<input type="radio" name="status" value="0" title="正常" checked>
<input type="radio" name="status" value="1" title="已删除">
</div>
</div>
<div class="layui-form-item">
<input type="hidden" name="id" id="js-id" value="" />
<label for="js-add-btn" class="layui-form-label"></label>
<button id="js-add-btn" class="layui-btn" lay-filter="add" lay-submit="">确定</button>
</div>
</form>
</div>
</body>
<script>
layui.extend({
admin: '${request.contextPath}/js/admin'
});
layui.use(['form', 'jquery', 'util', 'admin', 'layer'], function() {
var form = layui.form,
$ = layui.jquery,
util = layui.util,
admin = layui.admin,
layer = layui.layer;
//失去焦点时判断值为空不验证,一旦填写必须验证
$('input[name="email"]').blur(function(){
//这里是失去焦点时的事件
if($('input[name="email"]').val()){
$('input[name="email"]').attr('lay-verify','email');
}else{
$('input[name="email"]').removeAttr('lay-verify');
}
});
//监听提交
form.on('submit(add)', function(data) {
$.ajax({
type: "POST",
//请求的媒体类型
//contentType: "application/json;charset=UTF-8",
url: "${request.contextPath}/admin/sys/user/add-or-upd",
//data: JSON.stringify(data),
data: data.field,
success: function(result) {
if (result.code === 0) {
//获取提交成功的时间
var time = new Date();
var timeNow = util.toDateString(time);
// 获得frame索引
var index = parent.layer.getFrameIndex(window.name);
//刷新父页面注意一定要在关闭当前iframe层之前执行刷新
parent.location.reload();
//关闭当前frame
parent.layer.close(index);
} else {
layer.alert(result.msg, {
icon: 2
})
}
},
error: function(e){
layer.alert(e, {
icon: 2
})
}
});
return false;
});
});
</script>
</html>

View File

@ -0,0 +1,257 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>系统用户列表</title>
<meta name="Description" content="基于layUI数据表格操作"/>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="weadmin-nav">
<span class="layui-breadcrumb">
<a href="">首页</a>
<a href="">系统用户列表管理</a>
<a><cite>系统用户列表</cite></a>
</span>
<a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
<i class="layui-icon" style="line-height:30px">&#xe669;</i>
</a>
</div>
<div class="weadmin-body">
<div class="layui-row">
<form class="layui-form layui-col-md12 we-search" lay-filter="search-form-filter">
<div class="layui-input-inline">
<select name="cateid">
<option>请选择分类</option>
<option>文章</option>
<option>会员</option>
<option>权限</option>
</select>
</div>
<div class="layui-inline">
<input class="layui-input" placeholder="开始日" name="start" id="start">
</div>
<div class="layui-inline">
<input class="layui-input" placeholder="截止日" name="end" id="end">
</div>
<div class="layui-inline">
<input type="text" name="keyword" placeholder="请输入关键字" autocomplete="off" class="layui-input">
</div>
<button class="layui-btn" lay-submit lay-filter="search-form-btn-filter"><i class="layui-icon">&#xe615;</i></button>
</form>
</div>
<!--数据表格-->
<table class="layui-hide" id="record-table" lay-filter="table-filter"></table>
</div>
</body>
<script type="text/html" id="toolbar-top">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="getCheckData"><i class="layui-icon">&#xe640;</i>批量删除</button>
<button class="layui-btn layui-btn-sm" lay-event="recommend"><i class="layui-icon">&#xe6c6;</i>推荐</button>
<button class="layui-btn layui-btn-sm" lay-event="top"><i class="layui-icon">&#xe619;</i>置顶</button>
<button class="layui-btn layui-btn-sm" lay-event="review"><i class="layui-icon">&#xe6b2;</i>审核</button>
<button class="layui-btn layui-btn-sm" onclick="WeAdminShow('添加用户','${request.contextPath}/admin/sys/user/add-or-upd-ui',600,400)"><i class="layui-icon">&#xe61f;</i>添加</button>
</div>
</script>
<script type="text/html" id="recommendTpl">
<input type="checkbox" name="zzz" lay-skin="switch" lay-text="已推荐|未推荐" {{d.recommend}}>
</script>
<script type="text/html" id="topTpl">
<input type="checkbox" name="show" lay-skin="switch" lay-text="已置顶|未置顶" {{d.top}}>
</script>
<script type="text/html" id="reviewTpl">
<!-- 这里的 checked 的状态只是演示 -->
<input type="checkbox" name="lock" value="{{d.id}}" title="锁定" lay-filter="lockDemo" {{ d.id == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="operateTpl">
<a title="编辑" onclick="WeAdminEdit('编辑','${request.contextPath}/admin/sys/user/add-or-upd-ui', '{{ d.id }}', 600, 400)" href="javascript:;">
<i class="layui-icon">&#xe642;</i>
</a>
<a title="查看" onclick="WeAdminShow('查看文章','./show.html',600,400)" href="javascript:;">
<i class="layui-icon">&#xe63c;</i>
</a>
<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
<i class="layui-icon">&#xe640;</i>
</a>
</script>
<script type="text/javascript">
layui.extend({
admin: '${request.contextPath}/js/admin'
});
layui.use(['table', 'jquery','form', 'admin', 'laydate'], function() {
var table = layui.table,
$ = layui.jquery,
form = layui.form,
admin = layui.admin,
laydate = layui.laydate;
laydate.render({
elem: '#start'
});
laydate.render({
elem: '#end'
});
var tableIns = table.render({
elem: '#record-table',
cellMinWidth: 80,
toolbar: '#toolbar-top',
method: 'POST',
event: true,
page: true,
url: '${request.contextPath}/admin/sys/user/page',
request: {
pageName: 'current' //页码的参数名称默认page
,limitName: 'size' //每页数据量的参数名默认limit
},
parseData: function(res){ //res 即为原始返回的数据
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data ? res.data.total : 0, //解析数据长度
"data": res.data ? res.data.records : [] //解析数据列表
};
},
cols: [
[{
type: 'checkbox'
}, {
field: 'name', title: '姓名'
}, {
field: 'username', title: '用户名', width: 130
}, {
field: 'password', title: '密码', width: 90
}, {
field: 'deptId', title: '部门id', width: 90
}, {
field: 'email', title: '邮箱', width: 90
}, {
field: 'mobile', title: '手机号', width: 120
}, {
field: 'tel', title: '固定电话', width: 120
}, {
field: 'sex', title: '性别', width: 60
}, {
field: 'birthday', title: '出生年月日', width: 120
}, {
field: 'picId', title: '图片id', width: 90
}, {
field: 'idCard', title: '身份证', width: 120
}, {
field: 'hobby', title: '爱好', width: 90
}, {
field: 'province', title: '省份', width: 90
}, {
field: 'city', title: '城市', width: 90
}, {
field: 'district', title: '区县', width: 90
}, {
field: 'street', title: '街道', width: 90
}, {
field: 'streetNumber', title: '门牌号', width: 90
}, {
field: 'descr', title: '描述', width: 90
}, {
field: 'status', title: '状态', width: 90
}, {
fixed: 'right', field: 'operate',title: '操作', toolbar: '#operateTpl', unresize: true, width: 90
}]
],
done: function(res, curr, count){
//如果是异步请求数据方式res即为你接口返回的信息。
//如果是直接赋值的方式res即为{data: [], count: 99} data为当前页数据、count为数据总长度
}
});
/*
* 数据表格中form表单元素是动态插入,所以需要更新渲染下
* http://www.layui.com/doc/modules/form.html#render
*/
$(function(){
form.render();
});
form.on('submit(search-form-btn-filter)', function(data){
tableIns.reload({
// 设定异步数据接口的额外参数,任意设
where: data.field,
page: {
curr: 1 //重新从第 1 页开始
}
});
// 阻止表单跳转。如果需要表单跳转,去掉这段即可。
return false;
});
//头工具栏事件
table.on('toolbar(table-filter)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
case 'getCheckData':
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if(data.length > 0) {
layer.confirm('确认要删除吗?' + JSON.stringify(data), function(index) {
layer.msg('删除成功', {
icon: 1
});
//找到所有被选中的,发异步进行删除
$(".layui-table-body .layui-form-checked").parents('tr').remove();
});
} else {
layer.msg("请先选择需要删除的文章!");
}
break;
case 'recommend':
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if(data.length > 0) {
layer.msg("您点击了推荐操作");
for(var i = 0; i < data.length; i++) {
data[i].recommend = "checked";
form.render();
}
} else {
layer.msg("请先选择");
}
break;
case 'top':
layer.msg("您点击了置顶操作");
break;
case 'review':
layer.msg("您点击了审核操作");
break;
};
});
/*用户-删除*/
window.member_del = function(obj, id) {
layer.confirm('确认要删除吗?', function(index) {
//发异步删除数据
$(obj).parents("tr").remove();
layer.msg('已删除!', {
icon: 1,
time: 1000
});
});
}
});
function delAll(argument) {
var data = tableCheck.getData();
layer.confirm('确认要删除吗?' + data, function(index) {
//捉到所有被选中的,发异步进行删除
layer.msg('删除成功', {
icon: 1
});
$(".layui-form-checked").not('.header').parents('tr').remove();
});
}
</script>
</html>