You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/extend/service/FormBuilder.php

65 lines
2.8 KiB

<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace service;
use FormBuilder\Form;
class FormBuilder extends Form
{
/**
* 快速创建POST提交表单
* @param $title
* @param array $field
* @param $url
* @param $jscallback null 不执行 1 父级刷新 2 父级刷新关闭弹框 str 自定义
* @return $this
*/
public static function make_post_form($title, $field = [], $url = '', $jscallback = null)
{
if (is_numeric($url)) $jscallback = $url;
if (is_string($field)) $url = $field;
if (is_array($title)) {
$field = $title;
$title = '';
}
$form = Form::create($url);//提交地址
$form->setMethod('POST');//提交方式
$form->components($field);//表单字段
$form->setTitle($title);//表单标题
$js = '';//提交成功不执行任何动作
switch ($jscallback) {
case 1://刷新父页面
$js = 'parent.$(".J_iframe:visible")[0].contentWindow.location.reload();';//提交成功父级页面刷新
break;
case 2://关闭当前页面并延迟刷新
$js = 'parent.$(".J_iframe:visible")[0].contentWindow.location.reload(); setTimeout(function(){parent.layer.close(parent.layer.getFrameIndex(window.name));},2000);';//提交成功父级页面刷新并关闭当前页面
break;
case 3://关闭当前页面
$js = 'parent.layer.close(parent.layer.getFrameIndex(window.name));';
break;
case 4://关闭并刷新父页面不延迟
$js = 'parent.layer.close(parent.layer.getFrameIndex(window.name));parent.$(".J_iframe:visible")[0].contentWindow.location.reload()';
break;
case 5://关闭并刷新父页面不延迟
$js = 'setTimeout(function(){parent.layer.close(parent.layer.getFrameIndex(window.name));parent.layer.close(parent.layer.getFrameIndex(window.name));},2000);';
break;
default:
$js = $jscallback;
break;
}
$form->setSuccessScript($js);//提交成功执行js
return $form;
}
}