<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="shuzhiadd.aspx.cs" Inherits="sanliuling.app.shuzhiadd" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>考核述职——<%=xxsoft_check.check.getseting("systitle") %></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../weui/css/weui.css"/>
    <link rel="stylesheet" href="../weui/css/weuix.css"/>

    <script src="../weui/js/zepto.min.js"></script>
    <script src="../weui/js/zepto.weui.js"></script>
    <script src="../weui/js/php.js"></script>
    <script>
	//解决表单控件不能回弹 只有微信ios有这个问题
           $("input,select,textarea").blur(function(){
setTimeout(() => {
const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
window.scrollTo(0, Math.max(scrollHeight - 1, 0));
}, 100);
})    
        function cleartxt(obj){
            $(obj).prev().find('.weui-input').val("");
            return false;
        }

        function cleararea(obj){
            $(obj).prev().find('.weui-textarea').val("").next().find("span").text(0);
            return false;
        }
    </script>
</head>

<body ontouchstart>
<div class="weui-header bg-blue"> 
  <div class="weui-header-left"> <a class="icon icon-109 f-white" href="javascript:history.go(-1);">返回</a>  </div>
   <h1 class="weui-header-title">填写述职</h1>
    <div class="weui-header-right"><a class="icon icon-112 f-white" href="exit.aspx"></a></div> 
    </div>

<div class="weui-cells">
    <div class="weui-cell">
        <div class="weui-cell__bd">
            <input class="weui-input" placeholder="请输入标题" type="text" name="title" id="title">
        </div>
        <i class="weui-icon-clear" onclick="cleartxt(this)"></i>
    </div>
</div>
<div class="weui-cells">
    <div class="weui-cell">
        <div class="weui-cell__bd" id="content">
            
        </div>
    </div>
</div>


<div class="weui-btn-area">
    <a class="weui-btn weui-btn_primary" href="javascript:" id="btn">确定</a>
</div>


<br>
<br>

     <script src="wangEditor/release/wangEditor.js"></script>
    <script>
         var E = window.wangEditor
        var editor = new E('#content')
        editor.config.zIndex = 500
        editor.customConfig.menus = [
            'link',  // 插入链接
            'list',  // 列表
            'emoticon',  // 表情
            'image',  // 插入图片
        ]
         editor.customConfig.uploadImgServer = 'upload.ashx'
         editor.customConfig.uploadImgMaxSize = 10 * 1024 * 1024
        editor.customConfig.uploadImgHooks = {
            customInsert: function (insertImg, result, editor) {
                // 图片上传并返回结果，自定义插入图片的事件（而不是编辑器自动插入图片！！！）
                // insertImg 是插入图片的函数，editor 是编辑器对象，result 是服务器端返回的结果
                // 举例：假如上传图片成功后，服务器端返回的是 {url:'....'} 这种格式，即可这样插入图片：
                var url = "../" + result.url
                insertImg(url)
                // result 必须是一个 JSON 格式字符串！！！否则报错
            }
        }
        editor.create()
        var id = $_GET('fanganid');
        $(function () {
            $.ajax({
                type: "post",
                url: 'myfangan.aspx?action=edit',
                data: { id: id },
                dataType: 'json',
                success: function (data) {
                    $("#title").val(data.shuzhititle);
                    editor.txt.html(decodeURI(data.shuzhi));
                },
                error: function (xhr) {
                    alert('获取数据出错');
                }
            });
            $(document).on("click", "#btn", function () {
                $.post('myfangan.aspx?action=addsave', {fanganid:id, title: $("#title").val(), content: encodeURI(editor.txt.html()) }, function (data, status) {
                    if (status == "success") {
                        var jsonData = data;
                        if (jsonData.isOk == 1) {
                            alert(jsonData.message, function () {
                                window.location.href = 'myfangan.aspx';
                            })
                        } else {
                            alert(jsonData.message);
                        }
                    }
                }, 'json');
            })
        })
</script>
</body>
</html>