<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="我的流程" libs=["table"]/>
<div class="container-div" id="_app">
	<div class="row">
	<div class="col-sm-12 search-collapse">
	<@f.form id="form-form">
        <div class="select-list">
            <ul>
                <li>
                    <@ctx.i18n text = "表单名称"/>：
                    <input type="text" class="form-control" name="formName"/>
                </li>
                <li>
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;&nbsp;<@ctx.i18n text = "查询"/></a>
                    <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;<@ctx.i18n text = "重置"/></a>
                </li>
            </ul>
        </div>
     </@f.form>
     </div>
    <@table id="bootstrap-table"/>
    </div>
</div>
<@footer>
    <script type="text/javascript">
        var prefix = baseURL + "bpm/process";
        var insStatusDatas = ${dict.getDictListJson('sys_bpm_ins_status')};
        $(function() {
            var options = {
                url: prefix + "/myProcess/list",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                clickToSelect: true,
                uniqueId:    'id'                                   , /* 唯一ID */
                columns: [
                    {title: $.i18n.prop("序号"), width: 5,formatter: function (value, row, index) {
                            return $.table.serialNumber(index);}},
                    {field : 'formName',title : '<@ctx.i18n text = "流程名称"/>'},
                    {field : 'starter',title : '<@ctx.i18n text = "发起人"/>'},
                    {field : 'startTime',title : '<@ctx.i18n text = "发起时间"/>',width: 170},
                    {field : 'endTime',title : '<@ctx.i18n text = "结束时间"/>',width: 170},
                    {field : 'status',title : '<@ctx.i18n text = "流程状态"/>',formatter: function(value, row, index) {
                            return $.table.selectDictLabel(insStatusDatas, value);}},
                    {title:"<@ctx.i18n text = "操作"/>",class:'action',width:100,formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "流程跟踪"/>" onclick="preview(\'' + row.processInstanceId + '\')"><i class="fa icon-picture"></i></a> ');
                            actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "表单详情"/>" onclick="fromInfo(\''+row.businessKey+'\',\'' + row.prefixUrl +
                                '\',\'' + row.applyType + '\',\'' + row.processInstanceId + '\')"><i class="fa icon-note"></i></a> ');
                            <#--actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "表单详情"/>" onclick="fromInfo(\''+row.businessKey+'\',\'' + row.prefixUrl +-->
                            <#--    '\',\'' + row.approvalType + '\')"><i class="fa icon-note"></i></a> ');-->
                            return actions.join('');
                    }}
                ]
            };
            $.table.init(options);
        });

        function preview(id) {
            var options = {
                url: baseURL + "bpm/processInstance/preview/" + id,
                title: '<i class="fa icon-loop"></i> <@ctx.i18n text = "流程跟踪"/>',
                btn:['<i class="fa fa-close"></i> '+$.i18n.prop("取消")],
                width: $(top.window).width() - 300,
                height: $(top.window).height() - 200
            };
            opt.modal.openMainWin(options);
        }

        function fromInfo(id,prefixUrl,applyType,processInstanceId){
            if(applyType == "0"){
                opt.modal.open('<i class="fa icon-note"></i> <@ctx.i18n text = "表单详情"/>',
                    baseURL +prefixUrl +"/view?taskId="+processInstanceId+"&businessKey="+id);
            }else if(applyType == "1"){
                opt.modal.openTab('<i class="fa icon-note"></i> <@ctx.i18n text = "表单详情"/>',
                    baseURL +prefixUrl +"/view?taskId="+processInstanceId+"&businessKey="+id);
            }
        }
        <#--function fromInfo(businessKey,prefixUrl,approvalType){-->
        <#--    if(approvalType == "0"){-->
        <#--        opt.modal.open('<i class="fa icon-note"></i> <@ctx.i18n text = "表单详情"/>',-->
        <#--            baseURL +prefixUrl +"/revoke?businessKey="+businessKey);-->
        <#--    }else if(approvalType == "1"){-->
        <#--        opt.modal.openTab('<@ctx.i18n text = "表单详情"/>',-->
        <#--            baseURL +prefixUrl +"/revoke?businessKey="+businessKey);-->
        <#--    }-->
        <#--}-->
    </script>
</@footer>
</@pageTheme>