代码拉取完成,页面将自动刷新
同步操作将从 skyqi/脑力PHPCMS 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
die;
//////////////////////////////////////////////////////////////////////////////////////////////
$model = Db::name($this->table);
// POST请求, 数据自动存库
protected function _form($dbQuery = null, $tplFile = '', $pkField = '', $where = [], $extendData = [])
{
$db = is_null($dbQuery) ? Db::name($this->table) : (is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery);
$pk = empty($pkField) ? ($db->getPk() ? $db->getPk() : 'id') : $pkField;
$pkValue = $this->request->request($pk, isset($where[$pk]) ? $where[$pk] : (isset($extendData[$pk]) ? $extendData[$pk] : null));
// 非POST请求, 获取数据并显示表单页面
if (!$this->request->isPost()) {
$vo = ($pkValue !== null) ? array_merge((array)$db->where($pk, $pkValue)->where($where)->find(), $extendData) : $extendData;
if (false !== $this->_callback('_form_filter', $vo, [])) {
empty($this->title) || $this->assign('title', $this->title);
return $this->fetch($tplFile, ['vo' => $vo]);
}
return $vo;
}
// POST请求, 数据自动存库
$data = array_merge($this->request->post(), $extendData);
if (false !== $this->_callback('_form_filter', $data, [])) {
$result = DataService::save($db, $data, $pk, $where);
if (false !== $this->_callback('_form_result', $result, $data)) {
if ($result !== false) {
$this->success('恭喜, 数据保存成功!', '');
}
$this->error('数据保存失败, 请稍候再试!');
}
}
}
----------------------------DataService::save----------------------------
Db::name('user')->insertAll($data);
try{
$saveRet = DataService::save(SYS_MODULE_NAME,$_POST);
exception('开班时间与周期时间不匹配,请检查');
}catch(\Exception $e){
$this->error('执行错误');
//parent::returnMsg('error',)
}
$id = Db::getLastInsID();
public static function save($dbQuery, $data, $key = 'id', $where = [])
{
$db = is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery;
$where[] = [$key, 'eq', isset($data[$key]) ? $data[$key] : ''];
if (Db::table($db->getTable())->where($where)->count() > 0) {
return Db::table($db->getTable())->strict(false)->where($where)->update($data) !== false;
}
return Db::table($db->getTable())->strict(false)->insert($data) !== false;
}
----------------------------js提交表单----------------------------
<script>
layui.use('form', function(){
var form = layui.form;
form.on('submit', function(data){
$.form.load($("#myform").attr('action'),$("#myform").serialize(),'post');
$.form.load($("#myform").attr('action'),$("#myform").serialize(),'post');
return false;
});
});
</script>
----------------------------html源码处理----------------------------
{$r|getform=$form,###|raw} //raw
<td>{$vo.class_title|getCacheField='classes',###,'title'}</td>
---------------------------记不住的模板-----------------------------------------
{if condition="($name == 1) OR ($name > 100) "} value1
{elseif condition="$name eq 2"/}value2
{else /} value3
{/if}
<a href="{:adminUrl($controller_name.'/edit',['id'=>$vo['id']])}">
1.{$create_time|date="y-m-d",###}
---------------------------------array_column--------------------------------------------------
<?php
// 表示由数据库返回的可能记录集的数组
$a = array(
array(
'id' => 5698,
'first_name' => 'Bill',
'last_name' => 'Gates',
),
array(
'id' => 4767,
'first_name' => 'Steve',
'last_name' => 'Jobs',
)
array(
'id' => 3809,
'first_name' => 'Mark',
'last_name' => 'Zuckerberg',
)
);
$last_names = array_column($a, 'last_name', 'id');
print_r($last_names);
?>
输出:
Array
(
[5698] => Gates
[4767] => Jobs
[3809] => Zuckerberg
)
------------------------------$Think think---------------------------------------------------------------
{$Think.server.script_name} // 输出$_SERVER['SCRIPT_NAME']变量
2.{$Think.session.user_id} // 输出$_SESSION['user_id']变量
3.{$Think.get.pageNumber} // 输出$_GET['pageNumber']变量
4.{$Think.cookie.name} // 输出$_COOKIE['name']变量
--------------------------------------------input-------------------------------------------
例如:
1.input('get.id/d');
2.input('post.name/s');
3.input('post.ids/a');
4.Request::instance()->get('id/d');
ThinkPHP5.0版本默认的变量修饰符是/s,如果需要传入字符串之外的变量可以使用下面的修饰符,包括:
修饰符
s 强制转换为字符串类型
d 强制转换为整型类型
b 强制转换为布尔类型
a 强制转换为数组类型
f 强制转换为浮点类型
如果你要获取的数据为数组,请一定注意要加上 /a 修饰符才能正确获取到。
-----------------------------appRoot 输出:http://ivehice2.mydanweb.com www -----------------------------------------------------------------------------
$appRoot = $this->request->root(true);
$this->assign('appRoot',$appRoot);
list($get, $db) = [$this->request->get(), Db::name($this->table)];
$this->request->post()
$staff_type = $this->request->post('staff_type', '', 'trim');
$campus_id = $this->request->post('campus_id', 0, 'intval');$this->request->request('action','','trim') ;
$tbField =
--------------------------------- JS ---------------------------------------------------------------------------------------------------------------
<a href="javascript:confirm_delete(\'delect_acion\',\''.url('types/delete',array( 'id' => $r['id'])).'\')">'.L('delete').'</a> ';
/*! 删除关键字 */
$('[data-delete]').on('click', function () {
var id = this.getAttribute('data-delete');
var url = this.getAttribute('data-action');
var dialogIndex = $.msg.confirm('确定要删除这条记录吗?', function () {
$.form.load(url, {id: id}, 'post', function (ret) {
if (ret.code === "SUCCESS") {
window.location.reload();
}
$.msg.close(dialogIndex);
});
})
});
$.post(_url,function (_res) {
if (false!=_res.msg) layer.msg(_res.msg,{time: 2000});
if (_res.code==1) {
reload();
}
return false;
})
-----------------------------------模板---------------------------------------------------------------------------------------------
<select name='parentid' class='layui-select full-width' lay-ignore>
<!--{foreach $menus as $menu}-->
<!--{eq name='menu.id' value='$vo.parentid|default=0'}-->
<option selected value='{$menu.id}'>{$menu.spl|raw}{$menu.name}</option>
<!--{else}-->
<option value='{$menu.id}'>{$menu.spl|raw}{$menu.name}</option>
<!--{/eq}-->
<!--{/foreach}-->
</select>
-------------------------------------------类存在,add函数不存在-----------------------------------------------------------
// prt(class_exists($class),0);
// prt(!method_exists($controller,$action),0 );
// prt( $action,0 );
//类存在,add函数不存在
if(class_exists($class) && !method_exists($controller,$action) && $action=='add' ){
action("{$controller}/edit");
return false;
}
$this->MethodClass = "app\admin\controller\Method" ;
$call_method_name = strtolower($this->controller_name);
$_method = "Method/{$call_method_name}_after_list";
//缓存--------------------------------------------------------------------------------------------------------------------
$tablename = $db->getTable();
if(in_array($tablename,$this->cache_model_lists)) $this->savecache($tablename);
$moduleId = $this->getModuleId($tablename);
$this->FieldCache($moduleId,'w');
//****************************************上传图片***********************************************************************************
application/admin/view/slide/slideattrdata_form.html:11
<div class="layui-form-item">
<label class="layui-form-label">pic</label>
<div class="layui-input-block">
<img data-tips-image="" style="height:auto;max-height:32px;min-width:32px" src="{:$vo.pic?$vo.pic:''}">
<input type="hidden" name="pic" onchange="$(this).prev('img').attr('src', this.value)" value="" class="layui-input" data-md5="c7a4ee573d8daebe34cc41c5bd026779">
<a class="btn btn-link" data-file="one" data-uptype="local" data-type="png,jpg,bmp" data-field="pic">上传图片(png,jpg,bmp)</a>
</div>
</div>
///****************************************myform数据验证 每个表单尾部放**********************************************************************************************
application/admin/view/field/edit.html:206
$(function () {
$("#myform").validate({
submitHandler: function(form) {
form.submit();
return false;
}
});
})
///**************************************** thinkphp **********************************************************************************************
查询某个字段的值可以用
2.Db::table('think_user')->where('id',1)->value('name'); 1.// 返回某个字段的值
2.Db::table('think_user')->where('status',1)->column('name'); // 返回数组
4.Db::table('think_user')->where('status',1)->column('name','id'); 3.// 指定索引
//where的条件,不能使用 $map['get_start_time'] = ['ELT',time()],报错
$map[] = ['get_start_time','ELT',time()];
$map[] = ['get_end_time','EGT',time()];
$map[] = ['status','eq',1];
$map[] = ['last_num','gt',0];
$res = $this->couponDB->where($condition)->select();
////********************** validate **********************************************************************************************************************
$_validate = array(
array(false==$_POST['classroom'],"分校管理必须输入!"),
array(false==intval($_POST['classroom']),"分校管理必须数值型!"),
array(false==$_POST['teacher_id'],"教师必须输入!"),
array(false==intval($_POST['teacher_id']),"教师必须输入数值型!"),
array(($_POST['cycle'] == 'week' && empty($_POST['schedule_week'])),'未选择排课周时间!'),
array(($_POST['cycle'] == 'day' && empty($_POST['schedule_time'])),'未选择排课时间!'),
array($has_intersect_stu,'有学员同时出现在固定学员,临时学员内,错误!'),
);
foreach ($_validate as $k=>$v) {
if ($v[0]) $this->error($v[1]);
}
<?php echo $CreateFromControl::select($select_list['teacher'],array("select_val"=>$vo['teacher_id'],'option_null'=>'','name'=>'teacher_id','id'=>'teacher_id')); ?>
{volist name="fields" id="r"}
{if condition="$r['field']=='campus_id'"}
<tr>
<td >{if condition="$r['required']"}<font color="red">*</font>{/if}{$r.name}</td>
<td id="box_{$r['field']}">
{$r|$FieldFromClass::index=###,$vo|raw}
</td>
</tr>
{/if}
{/volist}
============================================================ post ajax getStudentsList =========
{block name="script"}
<script type="text/javascript">
$(document).on("change","select[name='campus_id']",function(){
_self = $(this) ;
_campus_id = $(this).val();
if (!_self) return false;
_url = "{:url('admin/ajaxs/getStudentsList')}";
_data = {};
_data.campus_id = _campus_id;
$.post(_url,_data,function (_res) {
if (_res.msg) {
layer.alert(_res.msg); //
}
if(_res.code == 0){
$("#students_id").html(_res.data);
}
})
})
</script>
{/block}
<a class='layui-btn layui-btn-primary' href='/admin#{$url_index}'>返回</a>
==================针对layui表 取选中的id checkbox ==================================================================
$(document).on("submit",".exerciseform",function () {
_f = $(this);
_url = _f.attr("action");
_ids = [];
$(".layui-table-view").find('.pk_check:checked').each(function(){
console.log(this.value);
_ids.push(this.value);
})
_data ={};
_data.ids = _ids;
$.post(_url,_data,function (_res) {
debugger;
if (_res.code != 1) {
layer.alert(_res.msg);
return false;
}
reload();
})
})
===================== 权限的控制 =====================================================================================
$pk = $db->getPk();
$db->order("$pk desc");
$map = [];
if (false!= ($study_status=intval($_REQUEST['study_status']))) {
$map[] = ['study_status','=',$study_status];
}
if (session('user.campus_id')>0) {
if (in_array("campus_id",$db->getTableFields())){
$map[] = ['campus_id', '=', session('user.campus_id')];
}
}
$db->where($map);
$tbList = $this->_list( $db ,true,false);
======================layui ajax=================================================================================================
<script>
layui.use('form', function(){
var form = layui.form;
form.on('submit', function(data){
$.form.load($("#myform").attr('action'),$("#myform").serialize(),'post');
return false;
});
});
</script>
===================================================================================================================================
<!--- 在脑力使用配合的代码
<label class="layui-form-label" style="width: 200px;">是否启动RBAC权限控制</label>
<div class="layui-input-block">
<input type="checkbox" name="list[node][auth]" value='1' title="请输入RBAC权限控制" placeholder="请输入RBAC权限控制" class="layui-input" checked style="margin: 10px;">
</div>
<div class="layui-input-block">
<div class="tooltips" tooltip="加入了节点,系统才进行控制菜单及权限。未加入的不能管理节点菜单,但是权限是默认充许权限的" tooltip-position="top" tooltip-type="primary">Tips<span></span></div>
</div>
-->
========================================刷新父页============================================================================================
layer.open({
type: 2,
content: 'test/iframe.html',
success: function(layero, index){
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
console.log(body.html()) //得到iframe页的body内容
body.find('input').val('Hi,我是从父页来的')
}
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。