feige
feige
分享运营真实案例,用编程创造自己的产品

注册于 6月前

回答
40
文章
44
关注者
1

if(!checkInputAuthorReject()){        
        //如果提供了事件对象,则这是一个非IE浏览器
        if ( e && e.stopPropagation ){
             //因此它支持W3C的stopPropagation()方法
            e.stopPropagation(); 
        }     
        else{
            //否则,我们需要使用IE的方式来取消事件冒泡 
            window.event.cancelBubble = true;
        }
        
        return false;
}

这是个css样式的问题,参考一下

.title_reqstatus_running {
        margin-bottom: 30px;
        /*border: 1px solid rgba(45, 106, 230, 100);*/
        padding: 10px;
        position: relative;
    }
    .title_reqstatus_running::before {
            content: "";
            width:0;
            height: 0;
            border:60px solid transparent;
            border-right:60px solid #3a87ad;
            transform: rotate(135deg);
            position: absolute;
            right: -61px;
            top: -61px;
            cursor: pointer;
        }
    .title_reqstatus_running::after {
        content: "进行中";
        width: 45px;
        height: 35px;
        color: #FFF;
        transform: rotate(45deg);
        position: absolute;
        right: 13px;
        top: 16px;
        font-weight: bold;
        letter-spacing:2px;
        cursor: pointer;
    }

<div class="title_reqstatus_running"></div>

手动关闭弹窗,并刷新列表
parent.Layer.close(parent.Layer.getFrameIndex(window.name));
parent.$("#table").bootstrapTable('refresh', {});

<input id="c-endtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[endtime]" type="text" value="{:date('Y-m-d H:i:s', $row.endtime)}">

js

var selectedValue = $("#c-instruct_id").val();                
var url = "starwar/instruct/get";
    var data = {
        "instruct_id":selectedValue
    }
    $.ajax({
        //请求方式
        type : "GET",
        //请求地址
        url : url,
        dataType: "json",
        data: data, 
        async:false, //一定要同步
        //请求成功
        success : function(result) {                  
            var json = $.parseJSON(result);
            bb=json;
            var type = json["type"];
            //如果type= 102 中断
            if(type == "102"){
                $("#c-priority").val("99");
            }else{
                $("#c-priority").val("0");
            }
        },
        //请求失败,包含具体的错误信息
        error : function(e){                  
            console.log(e.status);
            console.log(e.responseText);
        }
});

php,后端获取get过来的参数
public function get()
{
$instructID = $this->request->param('instruct_id');
return json_encode($this->model::get($instructID));
}

php
后台获取post过来的参数
$req_id = $this->request->param('req_id');
$remarks = $this->request->param('remarks');

js:
{field: 'starttime', title: __('Starttime'), formatter: Table.api.formatter.datetime,operate:'RANGE', addclass:'datetimerange', autocomplete:false},

 public function getStarttimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['starttime']) ? $data['starttime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setStarttimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
   

原因文件名不能驼峰。可以第一个大写,后面全部要小写。
Axure2htmlQueue ×
Axure2htmlqueue √

关键点 data: $('#config-form').serialize(),

var url = "{:addon_url('ontimebackup/index/saveFullConfig')}";       
$.ajax({
//请求方式
type : "POST",
data: $('#config-form').serialize(),
//请求地址
url : url,                
//请求成功
success : function(result) {
var json = $.parseJSON(result);
var status = json.status;

关键点:构造json 数据,然后 $.ajax 的 data属性

var data = {
        "databaseHostname":databaseHostname,
        "databasePort":databasePort,
        "databaseName":databaseName,
        "databaseUsername":databaseUsername,
        "databasePassword":databasePassword
    }
$.ajax({
        //请求方式
        type : "GET",
        //请求地址
        url : url,  
        data: data,        
        //请求成功
        success : function(result) {                    
            var json = $.parseJSON(result);
            bb=json;
        },
        //请求失败,包含具体的错误信息
        error : function(e){                    
            console.log(e.status);
            console.log(e.responseText);
        }
    });   

前端字符转json:
var json = $.parseJSON(result);
var status = json.status;
var info = json.info;

后台数组转json:
json_encode(array('status' => '200', 'info' => '成功上传测试文件到七牛云。请访问七牛云确认。'));

php 调用 python ,显示出错 打印出错
https://blog.csdn.net/dezhihuang/article/details/53690023
exec('python '.$filePathShell.' 2>&1',$output);
$str = implode($output);

原因:button按钮类型为type=submit ,script中又自定用botton按钮点击提交ajax,造成冲突。
解决方法:button按钮类型改为 type=button

<button id="save" class="btn btn-primary btn-sm">${text('保存')}</button>
改为
<button id="save" type=button class="btn btn-primary btn-sm">${text('保存')}</button>

php 判断 python 是否安装, php执行 cmd命令

//检查python是否已经安装
public function isPythonInstalled(){
  $output = system('python --version');
  //要加这两行,否则前端ajax 请求的结果判断总认为是error。可能是system也会输出内容到浏览器
  ob_flush();
  ob_clean();
  return $output;
}

使用默认的html的解析引擎,输出解析后的内容
关键点:$this->view->fetch('XXX')

// 生成七牛云测试脚本的内容
public function genQiniuUploadTestShell()
{
  $config = get_addon_config('ontimebackup');
  $qiniuAccessKey = $config["qiniuAccessKey"];
  $qiniusScretKey = $config["qiniusScretKey"];
  $qiuiuBucket = $config["qiuiuBucket"];
  $this->view->assign("qiniuAccessKey", $qiniuAccessKey);
  $this->view->assign("qiniusScretKey", $qiniusScretKey);
  $this->view->assign("qiuiuBucket", $qiuiuBucket);
  $returnStr =  $this->view->fetch('genQiniuUploadTestShell');
  echo $returnStr;
}

注意fetch要填上值,为html文件名

发布
问题