mirror of https://gitee.com/karson/fastadmin.git
添加了部门管理功能
parent
c6ef72f5fa
commit
f392441f8e
|
|
@ -27,6 +27,7 @@ CREATE TABLE `fa_admin` (
|
||||||
`updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
|
`updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
|
||||||
`token` varchar(59) NOT NULL DEFAULT '' COMMENT 'Session标识',
|
`token` varchar(59) NOT NULL DEFAULT '' COMMENT 'Session标识',
|
||||||
`status` varchar(30) NOT NULL DEFAULT 'normal' COMMENT '状态',
|
`status` varchar(30) NOT NULL DEFAULT 'normal' COMMENT '状态',
|
||||||
|
`orgid` int(10) COMMENT '部门名称',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `username` (`username`) USING BTREE
|
UNIQUE KEY `username` (`username`) USING BTREE
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='管理员表';
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='管理员表';
|
||||||
|
|
@ -35,7 +36,7 @@ CREATE TABLE `fa_admin` (
|
||||||
-- Records of fa_admin
|
-- Records of fa_admin
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO `fa_admin` VALUES (1, 'admin', 'Admin', '075eaec83636846f51c152f29b98a2fd', 's4f3', '/assets/img/avatar.png', 'admin@fastadmin.net', 0, 1502029281, 1492186163, 1502029281, 'd3992c3b-5ecc-4ecb-9dc2-8997780fcadc', 'normal');
|
INSERT INTO `fa_admin` VALUES (1, 'admin', 'Admin', '075eaec83636846f51c152f29b98a2fd', 's4f3', '/assets/img/avatar.png', 'admin@fastadmin.net', 0, 1502029281, 1492186163, 1502029281, 'd3992c3b-5ecc-4ecb-9dc2-8997780fcadc', 'normal',0);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
@ -244,6 +245,12 @@ INSERT INTO `fa_auth_rule` VALUES (81, 'file', 79, 'user/rule/del', 'Del', 'fa f
|
||||||
INSERT INTO `fa_auth_rule` VALUES (82, 'file', 79, 'user/rule/add', 'Add', 'fa fa-circle-o', '', '', 0, 1516374729, 1516374729, 0, 'normal');
|
INSERT INTO `fa_auth_rule` VALUES (82, 'file', 79, 'user/rule/add', 'Add', 'fa fa-circle-o', '', '', 0, 1516374729, 1516374729, 0, 'normal');
|
||||||
INSERT INTO `fa_auth_rule` VALUES (83, 'file', 79, 'user/rule/edit', 'Edit', 'fa fa-circle-o', '', '', 0, 1516374729, 1516374729, 0, 'normal');
|
INSERT INTO `fa_auth_rule` VALUES (83, 'file', 79, 'user/rule/edit', 'Edit', 'fa fa-circle-o', '', '', 0, 1516374729, 1516374729, 0, 'normal');
|
||||||
INSERT INTO `fa_auth_rule` VALUES (84, 'file', 79, 'user/rule/multi', 'Multi', 'fa fa-circle-o', '', '', 0, 1516374729, 1516374729, 0, 'normal');
|
INSERT INTO `fa_auth_rule` VALUES (84, 'file', 79, 'user/rule/multi', 'Multi', 'fa fa-circle-o', '', '', 0, 1516374729, 1516374729, 0, 'normal');
|
||||||
|
INSERT INTO `fa_auth_rule` VALUES (85, 'file', 0, 'orgnazation', '部门管理', 'fa fa-chain', '', '', 1, 1525710486, 1532965621, 0, 'normal');
|
||||||
|
INSERT INTO `fa_auth_rule` VALUES (86, 'file', 85, 'orgnazation/index', '查看', 'fa fa-circle-o', '', '', 0, 1525710486, 1530111884, 0, 'normal');
|
||||||
|
INSERT INTO `fa_auth_rule` VALUES (87, 'file', 85, 'orgnazation/add', '添加', 'fa fa-circle-o', '', '', 0, 1525710486, 1530111884, 0, 'normal');
|
||||||
|
INSERT INTO `fa_auth_rule` VALUES (88, 'file', 85, 'orgnazation/edit', '编辑', 'fa fa-circle-o', '', '', 0, 1525710486, 1530111884, 0, 'normal');
|
||||||
|
INSERT INTO `fa_auth_rule` VALUES (89, 'file', 85, 'orgnazation/del', '删除', 'fa fa-circle-o', '', '', 0, 1525710486, 1530111884, 0, 'normal');
|
||||||
|
INSERT INTO `fa_auth_rule` VALUES (90, 'file', 85, 'orgnazation/multi', '批量更新', 'fa fa-circle-o', '', '', 0, 1525710486, 1530111884, 0, 'normal');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
@ -577,3 +584,22 @@ INSERT INTO `fa_version` (`id`, `oldversion`, `newversion`, `packagesize`, `cont
|
||||||
(1, '1.1.1,2', '1.2.1', '20M', '更新内容', 'https://www.fastadmin.net/download.html', 1, 1520425318, 0, 0, 'normal');
|
(1, '1.1.1,2', '1.2.1', '20M', '更新内容', 'https://www.fastadmin.net/download.html', 1, 1520425318, 0, 0, 'normal');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for fa_orgnazation
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `fa_orgnazation`;
|
||||||
|
CREATE TABLE `fa_orgnazation` (
|
||||||
|
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`pid` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '父ID',
|
||||||
|
`name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
|
`fullname` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '部门全称',
|
||||||
|
`description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '描述',
|
||||||
|
`createtime` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '创建时间',
|
||||||
|
`updatetime` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '修改时间',
|
||||||
|
`weigh` int(11) NULL DEFAULT 0 COMMENT '权重',
|
||||||
|
`status` varchar(30) NOT NULL DEFAULT 'normal' COMMENT '状态',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='部门表';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\common\controller\Backend;
|
||||||
|
use app\admin\model\Orgnazation as OrgnazationModel;
|
||||||
|
use fast\Tree;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织管理
|
||||||
|
*
|
||||||
|
* @icon fa fa-circle-o
|
||||||
|
*/
|
||||||
|
class Orgnazation extends Backend
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Orgnazation模型对象
|
||||||
|
*/
|
||||||
|
protected $model = null;
|
||||||
|
protected $orglist = [];
|
||||||
|
protected $noNeedRight = ['selectpage'];
|
||||||
|
|
||||||
|
public function _initialize()
|
||||||
|
{
|
||||||
|
parent::_initialize();
|
||||||
|
$this->request->filter(['strip_tags']);
|
||||||
|
$this->model = model('Orgnazation');
|
||||||
|
|
||||||
|
$tree = Tree::instance();
|
||||||
|
$tree->init(collection($this->model->order('weigh desc,id desc')->select())->toArray(), 'pid');
|
||||||
|
$this->orglist = $tree->getTreeList($tree->getTreeArray(0), 'name');
|
||||||
|
//halt($this->orglist);
|
||||||
|
$orgdata = [0 => ['type' => 'all', 'name' => __('None')]];
|
||||||
|
foreach ($this->orglist as $k => $v)
|
||||||
|
{
|
||||||
|
$orgdata[$v['id']] = $v;
|
||||||
|
}
|
||||||
|
//$this->view->assign("flagList", $this->model->getFlagList());
|
||||||
|
//$this->view->assign("typeList", OrgnazationModel::getTypeList());
|
||||||
|
$this->view->assign("parentList", $orgdata);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||||
|
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||||
|
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -61,6 +61,17 @@ class Admin extends Backend
|
||||||
$groupdata = $result;
|
$groupdata = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tree = Tree::instance();
|
||||||
|
$tree->init(collection(model('Orgnazation')->order('weigh desc,id desc')->select())->toArray(), 'pid');
|
||||||
|
$this->orglist = $tree->getTreeList($tree->getTreeArray(0), 'name');
|
||||||
|
//halt($this->orglist);
|
||||||
|
$orgdata = [0 => ['type' => 'all', 'name' => __('None')]];
|
||||||
|
foreach ($this->orglist as $k => $v)
|
||||||
|
{
|
||||||
|
$orgdata[$v['id']] = $v;
|
||||||
|
}
|
||||||
|
$this->view->assign("orgList", $orgdata);
|
||||||
|
|
||||||
$this->view->assign('groupdata', $groupdata);
|
$this->view->assign('groupdata', $groupdata);
|
||||||
$this->assignconfig("admin", ['id' => $this->auth->id]);
|
$this->assignconfig("admin", ['id' => $this->auth->id]);
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +114,7 @@ class Admin extends Backend
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$list = $this->model
|
$list = $this->model
|
||||||
|
->with('orgnazation')
|
||||||
->where($where)
|
->where($where)
|
||||||
->where('id', 'in', $this->childrenAdminIds)
|
->where('id', 'in', $this->childrenAdminIds)
|
||||||
->field(['password', 'salt', 'token'], true)
|
->field(['password', 'salt', 'token'], true)
|
||||||
|
|
@ -252,6 +264,92 @@ class Admin extends Backend
|
||||||
$this->error();
|
$this->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入
|
||||||
|
*/
|
||||||
|
protected function import()
|
||||||
|
{
|
||||||
|
$file = $this->request->request('file');
|
||||||
|
if (!$file) {
|
||||||
|
$this->error(__('Parameter %s can not be empty', 'file'));
|
||||||
|
}
|
||||||
|
$filePath = ROOT_PATH . DS . 'public' . DS . $file;
|
||||||
|
if (!is_file($filePath)) {
|
||||||
|
$this->error(__('No results were found'));
|
||||||
|
}
|
||||||
|
$PHPReader = new \PHPExcel_Reader_Excel2007();
|
||||||
|
if (!$PHPReader->canRead($filePath)) {
|
||||||
|
$PHPReader = new \PHPExcel_Reader_Excel5();
|
||||||
|
if (!$PHPReader->canRead($filePath)) {
|
||||||
|
$PHPReader = new \PHPExcel_Reader_CSV();
|
||||||
|
if (!$PHPReader->canRead($filePath)) {
|
||||||
|
$this->error(__('Unknown data format'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
|
||||||
|
$importHeadType = isset($this->importHeadType) ? $this->importHeadType : 'comment';
|
||||||
|
|
||||||
|
$table = $this->model->getQuery()->getTable();
|
||||||
|
$database = \think\Config::get('database.database');
|
||||||
|
$fieldArr = [];
|
||||||
|
$list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]);
|
||||||
|
foreach ($list as $k => $v) {
|
||||||
|
if ($importHeadType == 'comment') {
|
||||||
|
$fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME'];
|
||||||
|
} else {
|
||||||
|
$fieldArr[$v['COLUMN_NAME']] = $v['COLUMN_NAME'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$PHPExcel = $PHPReader->load($filePath); //加载文件
|
||||||
|
$currentSheet = $PHPExcel->getSheet(0); //读取文件中的第一个工作表
|
||||||
|
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
|
||||||
|
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
|
||||||
|
$maxColumnNumber = \PHPExcel_Cell::columnIndexFromString($allColumn);
|
||||||
|
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
|
||||||
|
for ($currentColumn = 0; $currentColumn < $maxColumnNumber; $currentColumn++) {
|
||||||
|
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
|
||||||
|
$fields[] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$insert = [];
|
||||||
|
for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
|
||||||
|
$values = [];
|
||||||
|
for ($currentColumn = 0; $currentColumn < $maxColumnNumber; $currentColumn++) {
|
||||||
|
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
|
||||||
|
$values[] = is_null($val) ? '' : $val;
|
||||||
|
}
|
||||||
|
$row = [];
|
||||||
|
$temp = array_combine($fields, $values);
|
||||||
|
halt($temp);
|
||||||
|
foreach ($temp as $k => $v) {
|
||||||
|
if (isset($fieldArr[$k]) && $k !== '') {
|
||||||
|
$row[$fieldArr[$k]] = $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if ($row) {
|
||||||
|
$insert[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$insert) {
|
||||||
|
$this->error(__('No rows were updated'));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
|
||||||
|
$this->model->saveAll($insert);
|
||||||
|
} catch (\think\exception\PDOException $exception) {
|
||||||
|
$this->error($exception->getMessage());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量更新
|
* 批量更新
|
||||||
* @internal
|
* @internal
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,5 @@ return [
|
||||||
'Group' => '所属组别',
|
'Group' => '所属组别',
|
||||||
'Loginfailure' => '登录失败次数',
|
'Loginfailure' => '登录失败次数',
|
||||||
'Login time' => '最后登录',
|
'Login time' => '最后登录',
|
||||||
|
'Orgnazation'=>'部门全称',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'Pid' => '父ID',
|
||||||
|
'Fullname' => '部门全称',
|
||||||
|
'Description' => '描述',
|
||||||
|
'Createtime' => '创建时间',
|
||||||
|
'Updatetime' => '修改时间',
|
||||||
|
'Weigh' => '权重',
|
||||||
|
'Status' => '状态'
|
||||||
|
];
|
||||||
|
|
@ -4,6 +4,7 @@ namespace app\admin\model;
|
||||||
|
|
||||||
use think\Model;
|
use think\Model;
|
||||||
use think\Session;
|
use think\Session;
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
class Admin extends Model
|
class Admin extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -31,4 +32,64 @@ class Admin extends Model
|
||||||
return $encrypt($password . $salt);
|
return $encrypt($password . $salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $username
|
||||||
|
* @param $password
|
||||||
|
* @return bool when user is valid return user, invalid return 0
|
||||||
|
* @throws \think\exception\DbException
|
||||||
|
*/
|
||||||
|
public static function isValid($username, $password)
|
||||||
|
{
|
||||||
|
$rule = [
|
||||||
|
'username' => 'require|length:3,30',
|
||||||
|
'password' => 'require|length:3,30',
|
||||||
|
];
|
||||||
|
$data = [
|
||||||
|
'username' => $username,
|
||||||
|
'password' => $password,
|
||||||
|
];
|
||||||
|
$validate = new Validate($rule);
|
||||||
|
|
||||||
|
if(! $validate->check($data)) return false;
|
||||||
|
|
||||||
|
$user = self::get(['username' => $username]);
|
||||||
|
if (!$user){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ($user->password != md5(md5($password) . $user->salt))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function orgnazation()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Orgnazation','orgid');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证用户是否属于用户组
|
||||||
|
* @param $username 用户名
|
||||||
|
* @param $groupname 组名
|
||||||
|
* @return bool
|
||||||
|
* @throws \think\exception\DbException
|
||||||
|
*/
|
||||||
|
public static function isGroup($username,$groupname)
|
||||||
|
{
|
||||||
|
$user = self::get(['username' => $username]);
|
||||||
|
if (!$user){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$group = AuthGroup::get(['name'=>$groupname]);
|
||||||
|
if(!$group){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$inGroup = AuthGroupAccess::get(['uid'=>$user->id,'group_id'=>$group->id]);
|
||||||
|
if(!$inGroup) return false;
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
class Orgnazation extends Model
|
||||||
|
{
|
||||||
|
// 表名
|
||||||
|
protected $name = 'orgnazation';
|
||||||
|
|
||||||
|
// 自动写入时间戳字段
|
||||||
|
protected $autoWriteTimestamp = 'int';
|
||||||
|
|
||||||
|
// 定义时间戳字段名
|
||||||
|
protected $createTime = 'createtime';
|
||||||
|
protected $updateTime = 'updatetime';
|
||||||
|
|
||||||
|
// 追加属性
|
||||||
|
protected $append = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate;
|
||||||
|
|
||||||
|
use think\Validate;
|
||||||
|
|
||||||
|
class Orgnazation extends Validate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 验证规则
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
];
|
||||||
|
/**
|
||||||
|
* 提示消息
|
||||||
|
*/
|
||||||
|
protected $message = [
|
||||||
|
];
|
||||||
|
/**
|
||||||
|
* 验证场景
|
||||||
|
*/
|
||||||
|
protected $scene = [
|
||||||
|
'add' => [],
|
||||||
|
'edit' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,16 @@
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
{:build_select('group[]', $groupdata, null, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])}
|
{:build_select('group[]', $groupdata, null, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2">{:__('Orgnazation')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<select id="c-orgid" data-rule="required" class="form-control selectpicker" name="row[orgid]">
|
||||||
|
{foreach name="orgList" item="vo"}
|
||||||
|
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo.name}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
|
<label for="username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,21 @@
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
{:build_select('group[]', $groupdata, $groupids, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])}
|
{:build_select('group[]', $groupdata, $groupids, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2">{:__('Orgnazation')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[orgid]">
|
||||||
|
{foreach name="orgList" item="vo"}
|
||||||
|
<option value="{$key}" {in name="key" value="$row.orgid"}selected{/in}>{$vo.name}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
|
<label for="username" class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
<input type="text" class="form-control" id="username" name="row[username]" value="{$row.username}" data-rule="required;username" />
|
<input type="text" class="form-control" id="username" name="row[username]" value="{$row.username}" data-rule="required;" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-pid" class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[pid]">
|
||||||
|
{foreach name="parentList" item="vo"}
|
||||||
|
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo.name}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-name" class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-name" class="form-control" name="row[name]" type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-fullname" class="control-label col-xs-12 col-sm-2">{:__('Fullname')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-fullname" class="form-control" name="row[fullname]" type="text" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-description" class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-description" class="form-control" name="row[description]" type="text" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-weight" class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-weight" class="form-control" name="row[weigh]" type="number" value="0">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-status" class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
{:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')])}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group layer-footer">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
|
||||||
|
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-pid" class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[pid]">
|
||||||
|
{foreach name="parentList" item="vo"}
|
||||||
|
<option value="{$key}" {in name="key" value="$row.pid"}selected{/in}>{$vo.name}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-name" class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-fullname" class="control-label col-xs-12 col-sm-2">{:__('Fullname')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-fullname" class="form-control" name="row[fullname]" type="text" value="{$row.fullname}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-description" class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-description" class="form-control" name="row[description]" type="text" value="{$row.description}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-weight" class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<input id="c-weight" class="form-control" name="row[weigh]" type="number" value="{$row.weigh}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="c-status" class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
{:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group layer-footer">
|
||||||
|
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||||
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
|
||||||
|
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<div class="panel panel-default panel-intro">
|
||||||
|
{:build_heading()}
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<div id="myTabContent" class="tab-content">
|
||||||
|
<div class="tab-pane fade active in" id="one">
|
||||||
|
<div class="widget-body no-padding">
|
||||||
|
<div id="toolbar" class="toolbar">
|
||||||
|
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||||
|
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('orgnazation/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||||
|
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('orgnazation/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||||
|
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('orgnazation/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||||
|
<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('orgnazation/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
|
||||||
|
|
||||||
|
<div class="dropdown btn-group {:$auth->check('orgnazation/multi')?'':'hide'}">
|
||||||
|
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
|
||||||
|
<ul class="dropdown-menu text-left" role="menu">
|
||||||
|
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
|
||||||
|
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table id="table" class="table table-striped table-bordered table-hover"
|
||||||
|
data-operate-edit="{:$auth->check('orgnazation/edit')}"
|
||||||
|
data-operate-del="{:$auth->check('orgnazation/del')}"
|
||||||
|
width="100%">
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -18,7 +18,7 @@ return [
|
||||||
// 应用命名空间
|
// 应用命名空间
|
||||||
'app_namespace' => 'app',
|
'app_namespace' => 'app',
|
||||||
// 应用调试模式
|
// 应用调试模式
|
||||||
'app_debug' => Env::get('app.debug', false),
|
'app_debug' => Env::get('app.debug', true),
|
||||||
// 应用Trace
|
// 应用Trace
|
||||||
'app_trace' => Env::get('app.trace', false),
|
'app_trace' => Env::get('app.trace', false),
|
||||||
// 应用模式状态
|
// 应用模式状态
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ return [
|
||||||
// 密码
|
// 密码
|
||||||
'password' => Env::get('database.password', ''),
|
'password' => Env::get('database.password', ''),
|
||||||
// 端口
|
// 端口
|
||||||
'hostport' => Env::get('database.hostport', ''),
|
'hostport' => Env::get('database.hostport', '3307'),
|
||||||
// 连接dsn
|
// 连接dsn
|
||||||
'dsn' => '',
|
'dsn' => '',
|
||||||
// 数据库连接参数
|
// 数据库连接参数
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||||
{field: 'id', title: 'ID'},
|
{field: 'id', title: 'ID'},
|
||||||
{field: 'username', title: __('Username')},
|
{field: 'username', title: __('Username')},
|
||||||
{field: 'nickname', title: __('Nickname')},
|
{field: 'nickname', title: __('Nickname')},
|
||||||
|
{field: 'orgnazation.name', title: __('Orgnazation')},
|
||||||
{field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
|
{field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
|
||||||
{field: 'email', title: __('Email')},
|
{field: 'email', title: __('Email')},
|
||||||
{field: 'status', title: __("Status"), formatter: Table.api.formatter.status},
|
{field: 'status', title: __("Status"), formatter: Table.api.formatter.status},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||||
|
|
||||||
|
var Controller = {
|
||||||
|
index: function () {
|
||||||
|
// 初始化表格参数配置
|
||||||
|
Table.api.init({
|
||||||
|
extend: {
|
||||||
|
index_url: 'orgnazation/index',
|
||||||
|
add_url: 'orgnazation/add',
|
||||||
|
edit_url: 'orgnazation/edit',
|
||||||
|
del_url: 'orgnazation/del',
|
||||||
|
multi_url: 'orgnazation/multi',
|
||||||
|
table: 'orgnazation',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var table = $("#table");
|
||||||
|
|
||||||
|
// 初始化表格
|
||||||
|
table.bootstrapTable({
|
||||||
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||||
|
pk: 'id',
|
||||||
|
sortName: 'id',
|
||||||
|
columns: [
|
||||||
|
[
|
||||||
|
{checkbox: true},
|
||||||
|
{field: 'id', title: __('Id')},
|
||||||
|
{field: 'pid', title: __('Pid')},
|
||||||
|
{field: 'name', title: __('Name')},
|
||||||
|
{field: 'fullname', title: __('Fullname')},
|
||||||
|
{field: 'description', title: __('Description')},
|
||||||
|
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
|
||||||
|
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
|
||||||
|
{field: 'weigh', title: __('Weigh')},
|
||||||
|
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||||
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 为表格绑定事件
|
||||||
|
Table.api.bindevent(table);
|
||||||
|
},
|
||||||
|
add: function () {
|
||||||
|
Controller.api.bindevent();
|
||||||
|
},
|
||||||
|
edit: function () {
|
||||||
|
Controller.api.bindevent();
|
||||||
|
},
|
||||||
|
api: {
|
||||||
|
bindevent: function () {
|
||||||
|
Form.api.bindevent($("form[role=form]"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return Controller;
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue