作者 niuyongqing

管理员模块

<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/6/24
* Time: 15:30
*/
namespace app\products\controller;
use app\web\controller\BaseController;
use think\Db;
use think\Request;
class Mechanism extends BaseController
{
//获取用户列表
public function getMechanismList(Request $request){
$data = $request->param();
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset=($page-1)*$rows;
$data['offset']=$offset;
$data['rows']=$rows;
$where=[];
if(!empty($data['id']) && isset($data['id'])){
$where['id']=$data['id'];
}
if (isset($data['start']) && !empty($data['start']) && isset($data['end']) && !empty($data['end'])) {
$start_time = strtotime($data['start'].' 00:00:01');
$end_time = strtotime($data['end'].' 23:59:59');
$where['createTime'] = ['between', [$start_time, $end_time]];
} else if (isset($data['start']) && !empty($data['start']) && isset($data['end']) == false) {
$start_time = strtotime($data['start'].' 00:00:01');
$where['createTime'] = ['egt', $start_time];
} else if (isset($data['start']) == false && isset($data['end']) && !empty($data['end'])) {
$end_time = strtotime($data['end'].' 23:59:59');
$where['createTime'] = ['elt', $end_time];
}
if(!empty($data['names'])){
$where['mechanismName']=$data['names'];
}
//$org_id = session('organization.org_id');
$list= Db::table('sos_user_mechanism')->where($where)->limit($offset,$rows)->select()->toArray();
$total= Db::table('sos_user_mechanism')->where($where)->count();
foreach($list as $key=>$val ){
$list[$key]['createTime']=$val['createTime'] == ''? '' : date('Y-m-d H:i:s',$val['createTime']);
}
$result["total"] =$total;
$result['rows']=$list;
echo json_encode($result);
}
/**
* 获取机构列表
*/
public function getMechanism(){
$list= Db::table('sos_user_mechanism')->select()->toArray();
echo json_encode($list);
}
/**
* 获取机构下部门列表
*/
public function getdepartment(Request $request){
$data = $request->get();
$list= Db::table('sos_user_department')->where('mechanismId',$data['id'])->select()->toArray();
echo json_encode($list);
}
/**
* @param Request $request
* @return array|mixed|null
* 添加用户
*/
public function mechanism_add(Request $request)
{
$data = $request->param();
$data['password']=md5(md5($data['password']));
if(isset($data['mechanism_id']) && !empty($data['mechanism_id'])){
$data['updateTime']=time();
$where['id']=$data['mechanism_id'];
unset($data['mechanism_id']);
$res = Db::table('sos_user_mechanism')->where($where)->update($data);
}else{
unset($data['mechanism_id']);
$data['createTime']=time();
$res = Db::table('sos_user_mechanism')->insert($data);
}
$json=json_decode($res,true);
if(is_numeric($json)){
$data=[
'code'=>200,
'msg'=>'成功'
];
}else{
$data=[
'code'=>100,
'msg'=>'失败'
];
}
return $data;
}
/**
* @param Request $request
* @return \think\response\Json
* 自动生成员工编号
*/
public function generateNumber(Request $request){
$data = $request->get();
$rule_name= Db::table('sos_user_rule')->where('mechanismId',$data['id'])->find();
$rule_num= Db::table('sos_user_role')->order('id desc')->find();
$rule_number['num']=$rule_name['rule'].(substr($rule_num['personalNumber'], 2, 7)+1);
echo json_encode($rule_number);
}
}
\ No newline at end of file
... ...
... ... @@ -14,20 +14,43 @@ use think\Request;
class Role extends BaseController
{
public function user_management(){
return $this->fetch();
}
//获取用户列表
public function getUsers(Request $request){
$data = $request->param();
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset=($page-1)*$rows;
$data['offset']=$offset;
$data['rows']=$rows;
$where=[];
if(!empty($data['id']) && isset($data['id'])){
$where['id']=$data['id'];
}
if (isset($data['start']) && !empty($data['start']) && isset($data['end']) && !empty($data['end'])) {
$start_time = strtotime($data['start'].' 00:00:01');
$end_time = strtotime($data['end'].' 23:59:59');
$where['entryTime'] = ['between', [$start_time, $end_time]];
} else if (isset($data['start']) && !empty($data['start']) && isset($data['end']) == false) {
$start_time = strtotime($data['start'].' 00:00:01');
$where['entryTime'] = ['egt', $start_time];
} else if (isset($data['start']) == false && isset($data['end']) && !empty($data['end'])) {
$end_time = strtotime($data['end'].' 23:59:59');
$where['entryTime'] = ['elt', $end_time];
}
if(!empty($data['xiala'])){
$where['mechanism']=$data['xiala'];
}
if(!empty($data['names'])){
$where['name']=$data['names'];
}
if(!empty($data['tel'])){
$where['phone']=$data['tel'];
}
//$org_id = session('organization.org_id');
$list= Db::table('sos_user_role')->where($where)->select()->toArray();
$list= Db::table('sos_user_role')->where($where)->limit($offset,$rows)->select()->toArray();
$total= Db::table('sos_user_role')->where($where)->count();
$type=['','试用期','正式员工','已离职'];
foreach($list as $key=>$val ){
... ... @@ -48,7 +71,7 @@ class Role extends BaseController
$list[$key]['quitTime']=$val['quitTime'] == ''? '' : date('Y-m-d H:i:s',$val['entryTime']);
}
$result["total"] =count($list);
$result["total"] =$total;
$result['rows']=$list;
echo json_encode($result);
}
... ... @@ -59,7 +82,6 @@ class Role extends BaseController
*/
public function getMechanism(){
$list= Db::table('sos_user_mechanism')->select()->toArray();
echo json_encode($list);
}
... ... @@ -69,7 +91,6 @@ class Role extends BaseController
*/
public function getdepartment(Request $request){
$data = $request->get();
$list= Db::table('sos_user_department')->where('mechanismId',$data['id'])->select()->toArray();
echo json_encode($list);
... ... @@ -85,7 +106,7 @@ class Role extends BaseController
{
$data = $request->param();
$data['password']=md5(md5($data['password']));
if(isset($data['sex']) && $data['sex']=='on'){
$data['sex']=1;
}else{
... ... @@ -127,58 +148,21 @@ class Role extends BaseController
public function generateNumber(Request $request){
$data = $request->get();
$rule_name= Db::table('sos_user_rule')->where('mechanismId',$data['id'])->find();
$rule_name= Db::table('sos_user_mechanism')->where('id',$data['id'])->find();
if(isset($data['rule_id']) && !empty($data['rule_id'])){
$rule_num= Db::table('sos_user_role')->where('id',$data['rule_id'])->find();
$rule_number['num']=$rule_name['rule'].(substr($rule_num['personalNumber'], 2, 7));
}else{
$rule_num= Db::table('sos_user_role')->order('id desc')->find();
$rule_number['num']=$rule_name['rule'].(substr($rule_num['personalNumber'], 2, 7)+1);
echo json_encode($rule_number);
}
//修改用户
public function edit(Request $request){
$data = $request->post();
if($data['id']){
$data['uid'] = $data['id'];
}
$validate = new UserValidate();
$err_msg = $validate->scene("update")->check($data);
if ($err_msg) {
return json($this->renderError($validate->getError()));
}
$res = json_decode(curlPost($this->getUrl('edit'), $data),true);
if ($res['code'] == self::SUCCESS_CODE) {
return json($this->renderSuccess());
}
return json($res);
echo json_encode($rule_number);
}
//删除用户
public function del(Request $request){
$data = $request->get();
if (empty($data['id']) && $data['id'] !== 0) {
return json($this->renderError("删除失败!"));
}
$res = json_decode(curlPost($this->getUrl("del"),['uid'=>$data['id']]),true);
if ($res['code'] != self::SUCCESS_CODE) {
return json($res);
}
return json($this->renderSuccess());
}
}
\ No newline at end of file
... ...
... ... @@ -14,11 +14,18 @@ use app\web\validate\User as UserValidate;
*/
class Role extends BaseController
{
//列表
//人员列表
public function index()
{
$this->view->engine->layout(false);
return $this->fetch();
}
//机构列表树
public function mechanism()
{
$this->view->engine->layout(false);
return $this->fetch();
}
}
\ No newline at end of file
... ...
... ... @@ -207,62 +207,62 @@
</div>
<div data-options="region:'west',split:true,hideCollapsedContent:false,collapsed:false,title:'菜单',dataType:'json'" style="width:180px;min-width:160px;">
<div class="easyui-menu" data-options="inline:true,fit:true,itemHeight:40" style="border:0px;">
<!-- <div data-options="iconCls:'icon-cancel'">-->
<!-- <span>客户管理</span>-->
<!-- <div style="width:180px;">-->
<!-- <div data-options="iconCls:'icon-clear'"><b>客户管理</b></div>-->
<!-- <div data-options="iconCls:'icon-edit'">客户导入</div>-->
<!-- <div data-options="iconCls:'icon-remove'">客户调配</div>-->
<!-- <div data-options="iconCls:'icon-save'">数据处理</div>-->
<!-- <div class="menu-sep"></div>-->
<!-- <div data-options="iconCls:'icon-cut'">招聘管理</div>-->
<!-- <div data-options="iconCls:'icon-ok'">下发回收</div>-->
<!-- <div data-options="iconCls:'icon-no'">故障报修</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="menu-selected" data-options="iconCls:'hr-loading'">-->
<!-- <span>我的助手</span>-->
<!-- <div style="width:180px;">-->
<!-- <div><b>我的消息</b></div>-->
<!-- <div>消息提醒</div>-->
<!-- <div>通话记录</div>-->
<!-- <div>未接来电</div>-->
<!-- <div>公告管理</div>-->
<!-- <div>通讯录</div>-->
<!-- <div>个人设置</div>-->
<!-- <div>帮助向导</div>-->
<!-- </div>-->
<!-- </div>-->
<!---->
<div data-options="iconCls:'icon-reload'">
<span>转盘抽奖</span>
<div style="width:180px;">
<div onclick="$.h.menu.onMenuTurnPrizeManage();"><b>奖项列表</b></div>
<div onclick="$.h.menu.onMenuTurnPrizeUserManage();"><b>用户列表</b></div>
<div onclick="$.h.menu.onMenuTurnPrizeRuleManage();"><b>规则设置</b></div>
</div>
</div>
<div data-options="iconCls:'icon-reload'">
<span>抽奖管理</span>
<div style="width:180px;">
<div onclick="$.h.menu.onMenuPrizeManage();"><b>奖项列表</b></div>
<div onclick="$.h.menu.onMenuPrizeUserManage();"><b>用户列表</b></div>
<div onclick="$.h.menu.onMenuPrizeRuleManage();"><b>规则设置</b></div>
</div>
</div>
<div data-options="iconCls:'icon-reload'">
<span>产品管理</span>
<div style="width:180px;">
<div onclick="$.h.menu.onMenuProductManage();"><b>产品列表</b></div>
<div onclick="$.h.menu.onMenuProductOrderManage();"><b>订单列表</b></div>
</div>
</div>
<div data-options="iconCls:'icon-reload'">
<span>获客管理</span>
<div style="width:180px;">
<div onclick="$.h.menu.onMenuFuJiTongManage();"><b>客户列表</b></div>
</div>
</div>
<!-- <div data-options="iconCls:'icon-cancel'">-->
<!-- <span>客户管理</span>-->
<!-- <div style="width:180px;">-->
<!-- <div data-options="iconCls:'icon-clear'"><b>客户管理</b></div>-->
<!-- <div data-options="iconCls:'icon-edit'">客户导入</div>-->
<!-- <div data-options="iconCls:'icon-remove'">客户调配</div>-->
<!-- <div data-options="iconCls:'icon-save'">数据处理</div>-->
<!-- <div class="menu-sep"></div>-->
<!-- <div data-options="iconCls:'icon-cut'">招聘管理</div>-->
<!-- <div data-options="iconCls:'icon-ok'">下发回收</div>-->
<!-- <div data-options="iconCls:'icon-no'">故障报修</div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="menu-selected" data-options="iconCls:'hr-loading'">-->
<!-- <span>我的助手</span>-->
<!-- <div style="width:180px;">-->
<!-- <div><b>我的消息</b></div>-->
<!-- <div>消息提醒</div>-->
<!-- <div>通话记录</div>-->
<!-- <div>未接来电</div>-->
<!-- <div>公告管理</div>-->
<!-- <div>通讯录</div>-->
<!-- <div>个人设置</div>-->
<!-- <div>帮助向导</div>-->
<!-- </div>-->
<!-- </div>-->
<!---->
<!-- <div data-options="iconCls:'icon-reload'">-->
<!-- <span>转盘抽奖</span>-->
<!-- <div style="width:180px;">-->
<!-- <div onclick="$.h.menu.onMenuTurnPrizeManage();"><b>奖项列表</b></div>-->
<!-- <div onclick="$.h.menu.onMenuTurnPrizeUserManage();"><b>用户列表</b></div>-->
<!-- <div onclick="$.h.menu.onMenuTurnPrizeRuleManage();"><b>规则设置</b></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div data-options="iconCls:'icon-reload'">-->
<!-- <span>抽奖管理</span>-->
<!-- <div style="width:180px;">-->
<!-- <div onclick="$.h.menu.onMenuPrizeManage();"><b>奖项列表</b></div>-->
<!-- <div onclick="$.h.menu.onMenuPrizeUserManage();"><b>用户列表</b></div>-->
<!-- <div onclick="$.h.menu.onMenuPrizeRuleManage();"><b>规则设置</b></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div data-options="iconCls:'icon-reload'">-->
<!-- <span>产品管理</span>-->
<!-- <div style="width:180px;">-->
<!-- <div onclick="$.h.menu.onMenuProductManage();"><b>产品列表</b></div>-->
<!-- <div onclick="$.h.menu.onMenuProductOrderManage();"><b>订单列表</b></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div data-options="iconCls:'icon-reload'">-->
<!-- <span>获客管理</span>-->
<!-- <div style="width:180px;">-->
<!-- <div onclick="$.h.menu.onMenuFuJiTongManage();"><b>客户列表</b></div>-->
<!-- </div>-->
<!-- </div>-->
... ... @@ -281,12 +281,6 @@
<div onclick="$.h.menu.onMenuPersonnelManage();"><b>人员管理</b></div>
</div>
</div>
<div data-options="iconCls:'icon-reload'">
<span>编号规则</span>
<div style="width:180px;">
<div onclick="$.h.menu.onMenuNumberManage();"><b>编号列表</b></div>
</div>
</div>
</div>
</div>
<div data-options="region:'center',border:false" style="overflow:hidden;">
... ...
... ... @@ -31,54 +31,30 @@
</head>
<body style="margin-bottom: 54px;">
<div class="easyui-layout" data-options="fit:true">
<div data-options="split:false,region:'west',collapsible:true,footer:'#win_base_org_form_footer'" title="管理员列表" id="saveBox" style="width:100%;">
<div data-options="split:false,region:'west',collapsible:true,footer:'#win_base_org_form_footer'" title="员列表" id="saveBox" style="width:100%;">
<div class="easyui-panel" style="width:100%;max-width:100%;padding: 5px 5px">
<div style="margin-bottom:5px;">
<a id="name_add_but" href="#" data-options="iconCls:'icon-add'" class="my_but" style="vertical-align: middle;">新增</a>
</div>
</div>
<table id="dg" style="width: 100%; height: 100%"
<table id="dg" style="width: 100%; height: 92%"
data-options="rownumbers:true,singleSelect:true,pagination:true,toolbar:'#tb'">
</table>
<div id="tb" style="padding:5px;height:auto">
<div>
推送结果:
<input class="easyui-combobox" style="width:125px" name="materialname" id="materialname"
data-options="valueField:'id',
textField:'text',
data:
[{ 'id':0,
'text':'全部' ,
selected:true
},{ 'id':1,
'text':'成功' ,
},{
'id':2,
'text':'失败'
}] ,panelHeight:'auto'
"/>
地区:
<input class="easyui-combobox" style="width:125px" name="type" id="new_type"
data-options="valueField:'id',
textField:'text',
data:
[
{ 'id':0,
'text':'全部' ,
selected:true
},{ 'id':1,
'text':'湖南省内' ,
},{ 'id':2,
'text':'湖南省外' ,
}] ,panelHeight:'auto'
"/>
起始时间: <input class="easyui-datebox" id='start' name='start' style="width:180px">
所属机构:
<input id="xiala" name="xiala" class="easyui-combobox" data-options="
valueField: 'id',
textField: 'mechanismName',
url: '/products/role/getMechanism'">
入职时间: <input class="easyui-datebox" id='start' name='start' style="width:180px">
截止时间: <input class="easyui-datebox" id='end' name='end' style="width:180px">
<!-- 电话: <input class="easyui-numberbox" type="text" id='phone' name='phone'>-->
姓名: <input class="easyui-textbox" type="text" id='names' name='names'>
电话: <input class="easyui-numberbox" type="text" id='tel' name='tel'>
<a href="#" class="easyui-linkbutton" id="search_buttn" iconCls="icon-search">搜索</a>
<a id="derive_btn" href="/products/fu_ji_tong/to_excel" class="easyui-linkbutton" style="height:28px" data-options="iconCls:'icon-undo'">导出</a>
<!-- <a id="derive_btn" href="/products/fu_ji_tong/to_excel" class="easyui-linkbutton" style="height:28px" data-options="iconCls:'icon-undo'">导出</a>-->
</div>
</div>
</div>
... ... @@ -89,17 +65,9 @@
<form id="fm" name="frm" method="post" style="margin-top: 20px; margin-left: 20px;">
<table style="padding: 10px 20px;" cellspacing="10">
<tr>
<td>登录账号:</td>
<td><input class="easyui-textbox" type="text" name="username" id="username" /></td>
<input class="easyui-textbox" id="user_id" name="user_id" type="hidden">
</tr>
<tr>
<td>登录密码:</td>
<td><input class="easyui-textbox" type="text" name="password" id="password" /></td>
</tr>
<tr>
<td>用户名称:</td>
<td><input class="easyui-textbox" type="text" name="name" id="name" /></td>
<input class="easyui-textbox" id="user_id" name="user_id" type="hidden">
</tr>
<tr>
<td>性别:</td>
... ... @@ -112,22 +80,53 @@
<tr>
<td>所属机构:</td>
<td>
<!-- <input id="cc1" name="mechanism" class="easyui-combobox" data-options="-->
<!-- valueField: 'id',-->
<!-- textField: 'mechanismName',-->
<!-- url: '/products/role/getMechanism',-->
<!-- onSelect: function(rec){-->
<!-- var url = '/products/role/getDepartment?id='+rec.id;-->
<!-- $('#cc2').combobox('reload', url);-->
<!-- var url1 = '/products/role/generateNumber?id='+rec.id;-->
<!-- $.ajax({-->
<!-- url:url1,-->
<!-- success:function(e){-->
<!-- var arr = JSON.parse(e);-->
<!---->
<!-- $('#personalNumber').textbox('setValue',arr.num);-->
<!-- $('#personalNumber1').textbox('setValue',arr.num);-->
<!-- }-->
<!-- })-->
<!-- }">-->
<input id="cc1" name="mechanism" class="easyui-combobox" data-options="
valueField: 'id',
textField: 'mechanismName',
url: '/products/role/getMechanism',
onSelect: function(rec){
var url = '/products/role/getDepartment?id='+rec.id;
$('#cc2').combobox('reload', url);
var url1 = '/products/role/generateNumber?id='+rec.id;
$.ajax({
url:url,
success:function(a){
var arr1=JSON.parse(a);
console.log(JSON.parse(a))
$('#cc2').combobox({
data:JSON.parse(a),
valueField:'id',
textField: 'departmentName',
});
var url1 = '/products/role/generateNumber?id='+rec.id+'&rule_id='+rule_id;
$.ajax({
url:url1,
success:function(e){
var arr = JSON.parse(e);
$('#personalNumber').textbox('setValue',arr.num);
$('#personalNumber1').textbox('setValue',arr.num);
}
})
}
})
}">
</td>
... ... @@ -138,10 +137,16 @@
</tr>
<tr>
<td>个人编号:</td>
<td><input class="easyui-textbox" type="text" name="personalNumber" id="personalNumber" disabled/></td>
<td>
<input class="easyui-textbox" type="text" id="personalNumber" disabled/>
<input class="easyui-textbox" id="personalNumber1" name="personalNumber" type="hidden">
</td>
</tr>
<tr>
<td>入职时间:</td>
<!-- <td><input class="easyui-datebox" name="entryTime" id="entryTime" disabled/></td>-->
<td><input class="easyui-datebox" name="entryTime" id="entryTime" /></td>
</tr>
<tr>
... ... @@ -185,6 +190,7 @@
<script>
var rule_id='';
//下拉框搜索
init_datagrid('/products/role/getUsers', 0);
... ... @@ -193,30 +199,25 @@
$('#search_buttn').bind('click', function() {
var _data = $('#dg').data('datagrid'); // 拿到datagrid初始化的数据缓存
if(_data && _data.options){
_data.options.pageNumber = 1; // 修改缓存
}
$.data($('#dg')[0], 'datagrid', _data); // 把修改写回去
var xiala=$('#xiala').combobox('getValue');
var result=$('#materialname').combobox('getValue');
var new_type=$('#new_type').combobox('getValue');
var start = $("#start").val();
var end = $("#end").val();
var phone = $("#phone").val();
if(phone.length>0){
if(phone.length!=11){
var tel = $("#tel").val();
var names = $("#names").val();
if(tel.length>0){
if(tel.length!=11){
$.messager.alert('检索手机号','手机号格式错误,请重新输入');
return false;
}
}
var result = {
result,
new_type,
xiala,
start,
end,
phone
tel,
names
}
// console.log(result);return false;
init_datagrid('/products/role/getUsers', result);
... ... @@ -242,12 +243,6 @@
function dg_columns() {
var arr = new Array();
arr.push({
field: 'username',
title: '登录账号',
width: 120,
align: 'center'
});
arr.push({
field: 'name',
title: '用户名称',
width: 80,
... ... @@ -324,6 +319,9 @@
}
});
function addFile(){
rule_id='';
$('#entryTime').textbox({disabled:false})
$('#win').form('clear')
$('#win').dialog({
title: '新增',
width: 800,
... ... @@ -334,11 +332,62 @@
modal: true
});
}
// //修改
// function showUser(row){
// if(row){
// // alert(row);
// var id=row;
// var result = {
// id
// }
// $("#win").dialog("open").dialog("setTitle","人员信息修改");
//
// //ajax请求数据
// $.ajax({
// type: "post",
// data: result,
// async: false,
// url: "/products/role/getUsers",
// success: function(data) {
// var arr = JSON.parse(data);
//
// $('#user_id').textbox('setValue',arr.rows[0].id);
//
// $('#username').textbox('setValue',arr.rows[0].username);
// $('#password').textbox('setValue',arr.rows[0].password);
// $('#name').textbox('setValue',arr.rows[0].name);
// $('#personalNumber').textbox('setValue',arr.rows[0].personalNumber);
// //
// if(arr.rows[0].sex == "男") {
// $('#statusId').switchbutton('check');
// }else {
// $('#statusId').switchbutton('uncheck');
// }
// $('#phone').textbox('setValue',arr.rows[0].phone);
// $('#entryTime').textbox('setValue',arr.rows[0].entryTime);
// $('#quitTime').textbox('setValue',arr.rows[0].quitTime);
//
// $('#materialname').combobox('setValue', $('#materialname option')[2].value);
//
//
// },
// error:function(data){
// console.log(data)
// }
// });
// }
// }
//修改
function showUser(row){
if(row){
// alert(row);
var id=row;
rule_id=id;
if (rule_id){
$('#entryTime').textbox({disabled:true})
}
var result = {
id
}
... ... @@ -351,16 +400,43 @@
async: false,
url: "/products/role/getUsers",
success: function(data) {
// console.log(data);
var arr = JSON.parse(data);
console.log(arr.rows[0]);
$('#user_id').textbox('setValue',arr.rows[0].user_id);
$('#user_id').textbox('setValue',arr.rows[0].id);
$('#username').textbox('setValue',arr.rows[0].username);
$('#password').textbox('setValue',arr.rows[0].password);
$('#name').textbox('setValue',arr.rows[0].name);
$('#personalNumber').textbox('setValue',arr.rows[0].personalNumber);
$.ajax({
url:'/products/role/getMechanism',
success:function(e){
var mechanism=JSON.parse(e).find((v)=>{
if(v.mechanismName===arr.rows[0].mechanism){
$('#cc1').combobox('select',v.id);
$.ajax({
url:"/products/role/getDepartment?id="+v.id,
success:function(ee){
// console.log(JSON.parse(ee))
var department=JSON.parse(ee).find((vv)=>{
if(vv.departmentName===arr.rows[0].department){
$('#cc2').combobox('select',vv.id);
}
})
}
})
}
})
}
})
var statusData=$('#status').combobox('getData');
var status=statusData.find((ss)=>{
if(ss.text===arr.rows[0].status){
$('#status').combobox('select',ss.id);
}
})
//
if(arr.rows[0].sex == "男") {
$('#statusId').switchbutton('check');
... ... @@ -370,10 +446,7 @@
$('#phone').textbox('setValue',arr.rows[0].phone);
$('#entryTime').textbox('setValue',arr.rows[0].entryTime);
$('#quitTime').textbox('setValue',arr.rows[0].quitTime);
$('#materialname').combobox('setValue', $('#materialname option')[2].value);
},
error:function(data){
console.log(data)
... ... @@ -381,7 +454,6 @@
});
}
}
function submitForm(){
$('#fm').form('submit', {
url:'/products/role/user_add',
... ... @@ -392,7 +464,6 @@
},
success:function(data){
console.log(data);
return false;
var arr = JSON.parse(data);
$.messager.alert("提示", arr.msg);
$('#dg').datagrid('reload');
... ...
<!DOCTYPE html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>机构列表</title>
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/easyui.css" />
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/gray/menu.css" />
<link rel="stylesheet" type="text/css" href="/assets/common/css/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="/assets/web/css/jitnry.css" />
<link rel="stylesheet" type="text/css" href="/assets/web/css/common_car.css" />
<script type="text/javascript" src="/assets/common/js/jquery.min.1.9.4.js"></script>
<script type="text/javascript" src="/assets/common/js/jquery.easyui.min.1.9.4.js"></script>
<script type="text/javascript" src="/assets/common/js/jquery.cookie.1.4.1.js"></script>
<!-- 插件调用 --->
<script type="text/javascript" src="/assets/common/js/datagrid-detailview.js"></script>
<script type="text/javascript" src="/assets/common/locale/easyui-lang-zh_CN.js"></script>
<!-- 基础 JS 调用 -->
<script type="text/javascript" src="/assets/web/js/src/easyui.base.js"></script>
<script type="text/javascript" src="/assets/web/js/src/allCity.js"></script>
<style>
#fm>div {
width: 100%;
display: flex;
justify-content: space-around;
margin: 10px 0;
}
#fm>div input{
width: 180px;
}
</style>
</head>
<body style="margin-bottom: 54px;">
<div class="easyui-layout" data-options="fit:true">
<div data-options="split:false,region:'west',collapsible:true,footer:'#win_base_org_form_footer'" title="机构列表" id="saveBox" style="width:100%;">
<div class="easyui-panel" style="width:100%;max-width:100%;padding: 5px 5px">
<div style="margin-bottom:5px;">
<a id="name_add_but" href="#" data-options="iconCls:'icon-add'" class="my_but" style="vertical-align: middle;">新增</a>
</div>
</div>
<table id="dg" style="width: 100%; height: 92%"
data-options="rownumbers:true,singleSelect:true,pagination:true,toolbar:'#tb'">
</table>
<div id="tb" style="padding:5px;height:auto">
<div>
机构名称: <input class="easyui-textbox" type="text" id='names' name='names'>
起始时间: <input class="easyui-datebox" id='start' name='start' style="width:180px">
截止时间: <input class="easyui-datebox" id='end' name='end' style="width:180px">
<a href="#" class="easyui-linkbutton" id="search_buttn" iconCls="icon-search">搜索</a>
<!-- <a id="derive_btn" href="/products/fu_ji_tong/to_excel" class="easyui-linkbutton" style="height:28px" data-options="iconCls:'icon-undo'">导出</a>-->
</div>
</div>
</div>
</div>
<div id="win" class="easyui-dialog" title="提示" style="width: 500px; padding: 10px 20px; height: auto" closed="true" buttons="#dlg-buttons">
<form id="fm" name="frm" method="post" style="margin-top: 20px; margin-left: 20px;">
<table style="padding: 10px 20px;" cellspacing="10">
<tr>
<td>登录账号:</td>
<td><input class="easyui-textbox" type="text" name="username" id="username" /></td>
<input class="easyui-textbox" id="mechanism_id" name="mechanism_id" type="hidden">
</tr>
<tr>
<td>登录密码:</td>
<td><input class="easyui-textbox" placeholder="这里输入文字" type="text" name="password" id="password" /></td>
</tr>
<tr>
<td>机构名称:</td>
<td><input class="easyui-textbox" type="text" name="mechanismName" id="mechanismName" /></td>
</tr>
<tr>
<td>编号规则:</td>
<td><input class="easyui-textbox" type="text" name="rule" id="rule" /></td>
</tr>
<div id="dlg-buttons" style="display: block">
<a id="confirm" href="javascript:void(0)" class="easyui-linkbutton c6" iconcls="icon-ok" onclick="submitForm()" style="width: 90px">提交</a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#win').dialog('close')" style="width: 90px">取消</a>
</div>
</table>
</form>
</div>
</body>
<tbody id="html_table"></tbody>
<script type="text/javascript" src="/assets/web/js/src/common_fu.js"></script>
<script>
//下拉框搜索
init_datagrid('/products/Mechanism/getMechanismList', 0);
//下拉框搜索
$('#search_buttn').bind('click', function() {
var _data = $('#dg').data('datagrid'); // 拿到datagrid初始化的数据缓存
if(_data && _data.options){
_data.options.pageNumber = 1; // 修改缓存
}
$.data($('#dg')[0], 'datagrid', _data); // 把修改写回去
var names = $("#names").val();
var start = $("#start").val();
var end = $("#end").val();
var result = {
names,
start,
end
}
// console.log(result);return false;
init_datagrid('/products/Mechanism/getMechanismList', result);
});
function init_datagrid(data_url, res) {
//表头字段
var arr_columns = dg_columns();
$("#dg").datagrid({
rownumbers:true,
singleSelect:true,
pagination:true,
url:data_url,
queryParams: res,
method:'post',
columns: [arr_columns],
loadMsg: '正在加载数据',
emptyMsg: '列表为空',
});
}
function dg_columns() {
var arr = new Array();
arr.push({
field: 'username',
title: '登录账号',
width: 120,
align: 'center'
});
arr.push({
field: 'mechanismName',
title: '机构名称',
width: 250,
align: 'center'
});
arr.push({
field: 'rule',
title: '编号规则',
width: 80,
align: 'center'
});
arr.push({
field: 'createTime',
title: '创建时间',
width: 200,
align: 'center'
});
arr.push({
field: 'id',
title: '操作',
width: 90,
align: 'center',
formatter:formatOper
});
// console.log(arr)
return arr;
}
//操作框
function formatOper(val, row, index) {
return '<a href="javascript:void(0)" onclick="showUser(' + val + ')">编辑</a> <a href="javascript:void(0)" onclick="showUser(' + val + ')">查看</a>';
}
//添加
$('#name_add_but').linkbutton({
onClick: function () {
addFile();
}
});
function addFile(){
$('#win').dialog({
title: '新增',
width: 500,
height: "auto",
top:20,
closed: false,//显示对话框
cache: false,
modal: true
});
}
//修改
function showUser(row){
if(row){
// alert(row);
var id=row;
var result = {
id
}
$("#win").dialog("open").dialog("setTitle","人员信息修改");
//ajax请求数据
$.ajax({
type: "post",
data: result,
async: false,
url: "/products/Mechanism/getMechanismList",
success: function(data) {
var arr = JSON.parse(data);
$('#mechanism_id').textbox('setValue',arr.rows[0].id);
$('#username').textbox('setValue',arr.rows[0].username);
$('#mechanismName').textbox('setValue',arr.rows[0].mechanismName);
$('#rule').textbox('setValue',arr.rows[0].rule);
},
error:function(data){
console.log(data)
}
});
}
}
function submitForm(){
$('#fm').form('submit', {
url:'/products/Mechanism/mechanism_add',
onSubmit: function(){
console.log($(this))
// do some check
// return false to prevent submit;
},
success:function(data){
console.log(data);
var arr = JSON.parse(data);
$.messager.alert("提示", arr.msg);
$('#dg').datagrid('reload');
// console.log(data);
//$.messager.alert('',msg);
//console.log(data);
//alert(data)
}
});
$('#win').dialog({
closed: true, // 隱藏列表
});
}
</script>
</html>
\ No newline at end of file
... ...
... ... @@ -326,7 +326,7 @@
title: '机构管理'
}
});
$(id_MainIframe).attr('src','/web/Fu_ji_tong/index');
$(id_MainIframe).attr('src','/web/Role/mechanism');
objMainTabs.tabs('selectById', 'AgentCarManage');
},
/**
... ... @@ -364,24 +364,6 @@
objMainTabs.tabs('selectById', 'AgentCarManage');
},
/**
* 人事管理 编号规则
* @param e
*/
onMenuNumberManage:function(e){
var objMainTabs = $(id_MainTabs);
objMainTabs.tabs('update', {
tab: objMainTabs.tabs('getTab',0),
options: {
id: 'AgentSecondaryManage',
title: '编号管理'
}
});
$(id_MainIframe).attr('src','/web/Fu_ji_tong/index');
objMainTabs.tabs('selectById', 'AgentCarManage');
},
}
})(jQuery);
... ...