<%--
  Created by IntelliJ IDEA.
  User: user
  Date: 2019/8/7
  Time: 18:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
    <title>wbs</title>
    <link rel="stylesheet" href="${ctxp}/static/plugin/assets/layui/css/layui.css">
    <link rel="stylesheet" href="${ctxp}/static/plugin/assets/common.css"/>
    <script type="text/javascript" src="${ctxp}/static/plugin/assets/jquery-3.2.1.min.js"></script>
</head>
<style>
    .btn_out{
        width: 100px;
        margin: 0;
        float: right;
        margin-right:2%;

    }
    .div_main_form{
        width: 50%;
        margin-left: 10px;
    }
    .layui-icon-layer{
        display: none;
    }
    .layui-icon-file{
        display: none;
    }

     .layui-table-view .layui-table {width:100%}
</style>
<body style="background-color: white ;height: 100%">
    <sys:message content="${message}"/>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>结算汇总表</legend>
    </fieldset>
    <div class="" style="margin-left: 10px;margin-right: 10px;">
        <table class="layui-hide" id="settlement" lay-filter="settle"></table>
    </div>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>本体部分</legend>
    </fieldset>
    <div class="" style="margin-left: 10px;margin-right: 10px;margin-top: 10px;">
       <c:forEach items="${map.list1}" var="data1" varStatus="index">
           <input id="type" hidden value="${data1.type}">
         <a class="layui-btn" href="${ctx}/jkxl/export?id=${data1.id}&type=${data1.type}">导出</a>
           <a class="layui-btn" href="${ctx}/project/tolist">返回</a>
       </c:forEach>
            <%--<table:importExcel url="${ctx}/propertycostreminder/propertyCostReminder/import"></table:importExcel>--%>
        <table id="table1" class="layui-table" lay-filter="table1"></table>
    </div>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>其他部分</legend>
    </fieldset>
    <div class="" style="margin-left: 10px;margin-right: 10px;">
        <table id="table2" class="layui-table" lay-filter="table2"></table>
    </div>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>未识别部分</legend>
    </fieldset>
    <div class="" style="margin-left: 10px;width:70%;margin-right: 10px;">
        <input hidden="hidden" name="" id="newid" value=""/>
        <input hidden="hidden" name="" id="xmmc1" value=""/>
        <input hidden="hidden" name="" id="fyje1" value=""/>
        <table class="layui-hide" id="xmmc" lay-filter="freestr"></table>
    </div>
    <div style="width: 100%;height: 100px"></div>
    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs" lay-event="fttz">分摊调整</a>
        <a class="layui-btn layui-btn-xs" lay-event="ddtz">单独调整</a>
    </script>
</body>
<script src="${ctxp}/static/plugin/assets/layui/layui.js"></script>
<script>
    layui.config({
        base: '${ctxp}/static/plugin/assets/'
    }).extend({
        treetable: 'treetable-lay/treetable'
    }).use(['layer', 'table', 'treetable'], function () {
        var $ = layui.jquery;
        var table = layui.table;
        var layer = layui.layer;
        var treetable = layui.treetable;

        var renderTable1 = function () {
            layer.load(2);
            treetable.render({
                treeColIndex: 1,
                treeSpid: -1,
                treeIdName: 'id',
                treePidName: 'pid',
                treeDefaultClose: false,
                treeLinkage: false,
                elem: '#table1',
                <%--url: '${ctxp}/webpage/modules/sys/free/selfwbs.json',--%>
                page: false,
                cols: [[
                    {type:'numbers',title: '序号', rowspan: 2, totalRowText: "合计",},
                    {field: 'wbsys', title: 'WBS要素',width:200, rowspan:'2'},

                    {field:'wbssbm',width:100, align:'center',rowspan:'2',title:"wbs识别码",rowspan:'2'},
                    {field:'fbfxysj', align:'center', title: '分部分项(原数据)',colspan:'6'},
                    {field:'fbfxtch',align:'center',title:'分部分项(调差后)',colspan:'4'},
                    {field:'fbfxtch',align:'center',title:'共性分摊费用',colspan:'10'},

                    {field:'hj',align:'center',width:120,title:'合计',rowspan:'2',totalRow: true}
//                  {templet: '#oper-col', title: 'oper'}
                ],[
                    {field:'hjje', width:120,align:'center',title:'合计金额',totalRow: true},
                    {field:'zjgcf', width:120,align:'center',title:'直接工程费',totalRow: true},
                    {field:'rgf1', width:120,align:'center',title:'人工费',totalRow: true},
                    {field:'cbrcg1', width:120,align:'center',title:'承包人采购',totalRow: true},
                    {field:'fbrcg1', width:120,align:'center',title:'发包人采购',totalRow: true},
                    {field:'jxf1', width:120,align:'center',title:'机械费',totalRow: true},

                    {field:'rgf2', width:120,align:'center',title:'人工费',totalRow: true},
                    {field:'cbrcg2', width:120,align:'center',title:'承包人采购',totalRow: true},
                    {field:'fbrcg2', width:120,align:'center',title:'发包人采购',totalRow: true},
                    {field:'jxf2', width:120,align:'center',title:'机械费',totalRow: true},

                    {field:'rgf3', width:120,align:'center',title:'人工费',totalRow: true},
                    {field:'cbrcg3', width:120,align:'center',title:'承包人采购',totalRow: true},
                    {field:'fbrcg3', width:120,align:'center',title:'发包人采购',totalRow: true},
                    {field:'jxf3', width:120,align:'center',title:'机械费',totalRow: true},

                    {field:'csf_1',width:120,title:'措施费-1',align:'center',totalRow: true},
                    {field:'csf_2',width:120,title:'措施费-2',align:'center',totalRow: true},
                    {field:'csf2',align:'center',width:120,title:'措施费二',totalRow: true},
                    {field:'qtf',align:'center',width:120,title:'其他费',totalRow: true},
                    {field:'gf',align:'center',width:120,title:'规费',totalRow: true},
                    {field:'sf',align:'center',width:120,title:'税金',totalRow: true},
                    // {field:'gxfy',align:'center',width:120,title: '共性费用',rowspan:'2',totalRow: true},
                ]]
                ,data: [
                <c:if test="${ not empty map.list}">
                <c:forEach items="${map.list}" var="data" varStatus="index">
                    <c:if test="${data.feeType eq '1'}">
                {
                    "id": "${data.wbsCode}",
                    "wbsys":"${data.describe}",
                    "wbssbm": "${data.wbsCode}",

                    "hjje": "${data.originalTotalCost}",
                    "zjgcf":"${data.zjgcFee}",
                    "rgf1": "${data.originalRgCost}",
                    "cbrcg1": "${data.originalCbrCost}",
                    "fbrcg1": "${data.originalFbrCost}",
                    "jxf1": "${data.originalJxCost}",

                    "rgf2": "${data.rgCost}",
                    "cbrcg2": "${data.cbrCost}",
                    "fbrcg2":"${data.fbrCost}",
                    "jxf2": "${data.jxCost}",

                    <%--"rgf3": "${data.rgFtFee}",--%>
                    "rgf3": "<c:if test="${ empty data.rgFtFee and not empty data.originalTotalCost}">0.0</c:if><c:if test="${ not empty data.rgFtFee}">${data.rgFtFee}</c:if> ",
                    "cbrcg3": "<c:if test="${ empty data.cbrFtFee and not empty data.originalTotalCost}">0.0</c:if><c:if test="${ not empty data.cbrFtFee}">${data.cbrFtFee}</c:if>",
                    "fbrcg3": "<c:if test="${ empty data.fbrFtFee and not empty data.originalTotalCost}">0.0</c:if><c:if test="${ not empty data.fbrFtFee}">${data.fbrFtFee}</c:if>",
                    "jxf3": "<c:if test="${ empty data.jxFtFee and not empty data.originalTotalCost}">0.0</c:if><c:if test="${ not empty data.jxFtFee}">${data.jxFtFee}</c:if>",

                    "csf_1": "${data.measuresFee1}",
                    "csf_2": "${data.measuresFee2}",
                    "csf2": "<c:if test="${ empty data.measuresFee3 and not empty data.originalTotalCost}">0.0</c:if><c:if test="${ not empty data.measuresFee3}">${data.measuresFee3}</c:if>",
                    "qtf":"${data.otherCost}",
                    "gf":"${data.fees}",
                    "sf":"${data.tex}",
                    "hj": "${data.totalFee}",
                    "gxfy": "${data.gxFee}",
                    "pid": "${data.parentNode}"
                },
                    </c:if>
                </c:forEach>
                </c:if>
            ],
                done: function () {
                    layer.closeAll('loading');
                }
            });
        };

        renderTable1();
    });
</script>
<script>
    layui.use(['table', 'form', 'element', 'treetable'], function () {
        var $ = layui.jquery;
        var table = layui.table;
        var form = layui.form;
        var element = layui.element;
        var treetable = layui.treetable;

        // 渲染表格
        var renderTable2 = function () {
            layer.load(2);
            treetable.render({
                treeColIndex: 1,
                treeSpid: -1,
                treeIdName: 'd_id',
                treePidName: 'd_pid',
                elem: '#table2',
                <%--url: '${ctxp}/webpage/modules/sys/free/other.json',--%>
                page: false,
                cols: [[
                    {type: 'numbers'},
                    {field: 'wbsys', title: 'WBS要素'},
                    {field: 'wbssbm', title: 'WBS识别码'},
                    {field: 'money', title: '金额'},
                ]]
                ,data: [
                <c:if test="${ not empty map.list}">
                <c:forEach items="${map.list}" var="data" varStatus="index">
                <c:if test="${data.feeType eq '0'}">
                {
                    "d_id": "${data.wbsCode}",
                    "wbsys": "${data.describe}",
                    "wbssbm": "${data.wbsCode}",
                    "money": "${data.totalFee}",
                    "d_pid": "${data.parentNode}"

                },
                    </c:if>
                </c:forEach>
                </c:if>
            ],
                done: function () {
                    layer.closeAll('loading');
                }
            });
        };

        renderTable2();
    });
</script>
<script>
    layui.use('table', function(){
        var table = layui.table;
    });
</script>
<script>
    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#xmmc'
            ,title: '未标识'
            ,cols: [[
                {field:'xmmc', width:200,title:'项目名称'}
                ,{field:'fyje', width:178,title:'费用金额'}
                ,{width:178,  toolbar: '#barDemo',title:'操作'}
            ]]
            ,data:[
            <c:if test="${ not empty map.list}">
               <c:forEach items="${map.list2}" var="data" varStatus="index">
                {
                    "id":"${data.id}",
                    "xmmc": "${data.type}",
                    "fyje": "${data.fee}"
                },
                </c:forEach>
                </c:if>
            ]
            ,page: false
        });
        //监听工具条
        table.on('tool(freestr)', function(obj){
            var datacount="";
            var data = obj.data;
            if(obj.event === 'fttz'){
                sureradio(data);
            } else if(obj.event === 'ddtz'){
                sureradio2(data,'${ctx}/jkxl/getft?id='+data.id);
            }
            // alert(datacount);
        });
    });
</script>
<script>
    function sureradio2(data,url){
        var newid = data.id;
        var xmmc = data.xmmc;
        var fyje = data.fyje;
        $("#newid").val(newid);
        $("#xmmc1").val(xmmc);
        $("#fyje1").val(fyje);
        layui.use(['table','layer'],function(){

            layer.open({
                type: 2,
                title: '单独调整',
                area: ['70%', '90%'],
                shade: 0.8,
                maxmin: true,
                shadeClose: true,
                <%--content: '${ctxp}/webpage/modules/sg/free/alongst.jsp'--%>
                content: url
                , btn: ['确定','关闭']
                ,yes: function(index, layero){
                    var bodyparent = layer.getChildFrame('body', index);
                    bodyparent.find('#freenl').click();
                }
                ,btn2: function(index, layero){
//		  		alert(layero);
                    layer.close(index);
                }
            })
        })
    }
</script>
<script>
    function sureradio(data,target){
        var newid = data.id;
        var xmmc = data.xmmc;
        var fyje = data.fyje;
        $("#newid").val(newid);
        $("#xmmc1").val(xmmc);
        $("#fyje1").val(fyje);
        layui.use(['table','layer'],function(){

           layer.open({
                type: 2,
                title: xmmc,
                area: ['40%', '90%'],
                shade: 0.8,
                shadeClose: true,
                content: '${ctxp}/webpage/modules/sg/free/avgpage.jsp'
                , btn: ['调整','关闭']
                ,yes: function(index, layero){
                    var body = layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    iframeWin.contentWindow.doSubmit();

                    layer.close(index);//关闭对话框。

                }

            })
        })
    }
</script>
<script>
    layui.use('table', function(){
        var table = layui.table;
        table.render({
            elem: '#settlement'
            ,limit:Number.MAX_VALUE
            ,title: '结算汇总表'
            ,cols: [[
                {width:50, title: '序号',type:'numbers'}
                ,{field:'setname',title:'项目或费用名称'}
                ,{field:'setmoney',title:'金额'}
                ,{field:'settext', title:'备注'}
                ,{field:'op',align:'center',title:"数据核验", templet:function(d){
                        ////对操作进行初始化
                        var xml = "";
                        if(d.status=="1")
                            xml += "<a style='margin-top: 3px;' class='layui-btn layui-btn-danger layui-btn-xs' lay-event='byz'>不一致</a>";
                        if(d.status == "0")
                            xml+="<a style='margin-top: 3px;' class='layui-btn layui-btn-xs' lay-event='byz'>一致</a>";
                        return xml;
                    }}
            ]]
            ,data:[
                <c:if test="${not empty map.list3}">
                <c:forEach items="${map.list3}" var="data">
                {
                    "id":"${data.id}",
                    "setname": "${data.entryName}",
                    "setmoney":"${data.money}",
                    "settext":"${data.remarks}",
                    "status":"${data.status}",
                    "reason":"${data.reason}"
                },
                </c:forEach>
                </c:if>
            ]
            // ,page: false
        });
        //监听行工具事件
        table.on('tool(settle)', function(obj){
            var data = obj.data;
            if(obj.event === 'byz'){
                layer.open({
                    type: 1,
                    title:data.setname,
                    // skin: 'layui-layer-rim',
                    area: ['50%', '70%'],
                    content: "<div style='padding: 16px'>"+data.reason+"</div>"
                });
            }
        });
    });
</script>
</html>
