<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>案例详情管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
        $(function(){
            $("#attachment_btn").click(function () {
                $("#attachment_file").click();
            });
            var oneSize = $(".oneTab").size();
            for(var i = 0;i < oneSize;i++){
                var hei = $(".oneTab:eq("+i+")").parent().height();
                $(".oneTab:eq("+i+")").css("height",hei)
                    .css("vertical-align","middle")
                    .css("line-height",hei+"px")
            }
            $("img").not(".upload_ico").each(function () {
                var num = 1 ;
                $(this).click(function () {
                    var flag = num%2;
                    if(flag == 1){
                        $(this).css("width","90%");
                        $(this).css("height","90%");
                        num++;
                    }else if(flag ==0){
                        $(this).css("width","50px");
                        $(this).css("height","50px");
                        num++;
                    }
                })
            });
        })
		var validateForm;
		/*function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){

              if(obj == 2){
                  $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/store?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
              }else if (obj == 3){
                  $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/save?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
              }else if (obj == 4){
                  $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/store?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
              }else{
                  $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/save?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
              }
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}*/
		$(document).ready(function() {
            $("input[name='ext']").on('ifChecked', function(event){
                var radioVal = $(this).val();
                if(radioVal == 0){
                    $("#td1").removeClass("hide");
                    $("#td2").addClass("hide");
                }else{
                    $("#td1").addClass("hide");
                    $("#td2").removeClass("hide");
                }
            });
            if("${caseInfo.ext}" == "1"){
                $("#ext1").iCheck('check')
            }else{
                $("#ext").iCheck('check')
            }


			validateForm = $("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			laydate.render({
				elem: '#startDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
				event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			});
			laydate.render({
				elem: '#endDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
				event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			});
		});
         //setInterval("requesting()",10000);
        function requesting(){
            console.log("-------------定时任务");
            var trlen = $("#workAccountList tr").length;
            var tdlen = $("#workAccountList tr td").length;
            var trArr = [];
            for(var i = 0;i < trlen;i++){
                var tableMap = {};
                tableMap["flag"] = $("#workAccountList tr").eq(i).find("td").eq(0).text();
                tableMap["name"] = $("#workAccountList tr").eq(i).find("td").eq(1).text();
                tableMap["specification"] = $("#workAccountList tr").eq(i).find("td").eq(2).text();
                tableMap["calculateUnit"] = $("#workAccountList tr").eq(i).find("td").eq(3).text();
                tableMap["taxPrice"] = $("#workAccountList tr").eq(i).find("td").eq(4).text();
                tableMap["price"] = $("#workAccountList tr").eq(i).find("td").eq(5).text();
                tableMap["useDate"] = $("#workAccountList tr").eq(i).find("td").eq(6).text();
                tableMap["source"] = $("#workAccountList tr").eq(i).find("td").eq(7).text();
                tableMap["tax"] = $("#workAccountList tr").eq(i).find("td").eq(8).text();
                tableMap["material"] = $("#workAccountList tr").eq(i).find("td").eq(9).text();
                tableMap["brand"] = $("#workAccountList tr").eq(i).find("td").eq(10).text();
                tableMap["pp"] = $("#workAccountList tr").eq(i).find("td").eq(11).text();
                tableMap["areaId"] = $("#workAccountList tr").eq(i).find("td").eq(12).text();
                trArr.push(tableMap);
            }
            //console.log("data------"+$("#inputForm").serialize());
            $.ajax({
                type:'post',
                url:'${ctx}/caseinfo/caseInfo/checkSame?tableMap='+encodeURI(encodeURI(JSON.stringify(trArr))),
                data:$("#inputForm").serialize(),
                success:function(result){
                    // $("#id").val(data);
                    // console.log(result.body.data);
                    $("#id").val(result.body.data.id);

                    for(var i = 0;i<result.body.data.caseDesignInfoList.length;i++){
                        $("#caseDesignInfoList"+i+"_id").val(result.body.data.caseDesignInfoList[i].id);
                    }
                    for(var i = 0;i<result.body.data.caseBuildInfoList.length;i++){
                        $("#caseBuildInfoList"+i+"_id").val(result.body.data.caseBuildInfoList[i].id);
                    }
                    for(var i = 0;i<result.body.data.caseExecuteInfoList.length;i++){
                        $("#caseExecuteInfoList"+i+"_id").val(result.body.data.caseExecuteInfoList[i].id);
                    }
                    /*for(var i = 0;i<result.body.data.caseMaterialsList.length;i++){
                        $("#caseMaterialsList"+i+"_id").val(result.body.data.caseMaterialsList[i].id);
                    }*/
                    for(var i = 0;i<result.body.data.caseMaterialsNormList.length;i++){
                        $("#caseMaterialsNormList"+i+"_id").val(result.body.data.caseMaterialsNormList[i].id);
                    }
                    for(var i = 0;i<result.body.data.caseMechanicalNormList.length;i++){
                        $("#caseMechanicalNormList"+i+"_id").val(result.body.data.caseMechanicalNormList[i].id);
                    }
                    for(var i = 0;i<result.body.data.casePeopleNormList.length;i++){
                        $("#casePeopleNormList"+i+"_id").val(result.body.data.casePeopleNormList[i].id);
                    }
                }
            })
        }
        function insertTitle(tValue){
            var list = "${caseInfo.workAttachments}";
            var size = (list.split('url')).length-1;
            var files = $("#attachment_file")[0].files;            for(var i = 0;i<files.length;i++) {                var file = files[i];
            var attachmentId = $("#id").val();
            var attachmentFlag = "76";
            console.log(file);
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/caseInfo/"+timestamp+"/"+file['name'];
            var uploadPath="http://gangwan-app.oss-cn-hangzhou.aliyuncs.com/"+storeAs;/*将这段字符串存到数据库即可*/
            var divId = "_attachment";
            $("#addFile"+divId).show();
            multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size);}
        }

        /*-------------------分割线-------------------*/

        function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            var trlen = $("#workAccountList tr").length;
            var tdlen = $("#workAccountList tr td").length;
            var trArr = [];
            for(var i = 0;i < trlen;i++){
                var tableMap = {};
                tableMap["flag"] = $("#workAccountList tr").eq(i).find("td").eq(0).text();
                tableMap["name"] = $("#workAccountList tr").eq(i).find("td").eq(1).text();
                tableMap["specification"] = $("#workAccountList tr").eq(i).find("td").eq(2).text();
                tableMap["calculateUnit"] = $("#workAccountList tr").eq(i).find("td").eq(3).text();
                tableMap["taxPrice"] = $("#workAccountList tr").eq(i).find("td").eq(4).text();
                tableMap["price"] = $("#workAccountList tr").eq(i).find("td").eq(5).text();
                tableMap["useDate"] = $("#workAccountList tr").eq(i).find("td").eq(6).text();
                tableMap["source"] = $("#workAccountList tr").eq(i).find("td").eq(7).text();
                tableMap["tax"] = $("#workAccountList tr").eq(i).find("td").eq(8).text();
                tableMap["material"] = $("#workAccountList tr").eq(i).find("td").eq(9).text();
                tableMap["brand"] = $("#workAccountList tr").eq(i).find("td").eq(10).text();
                tableMap["pp"] = $("#workAccountList tr").eq(i).find("td").eq(11).text();
                tableMap["areaId"] = $("#workAccountList tr").eq(i).find("td").eq(12).text();
                trArr.push(tableMap);
            }
            if(obj == 1){
                $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/save?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
            }else if(obj == 2){
                $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/store?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
            }else if (obj == 3){
                $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/save?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
            }else if (obj == 4){
                $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/store?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
            } else if (obj == 5){
                $("#inputForm").attr("action","${ctx}/caseinfo/caseInfo/saves?tableMap="+encodeURI(encodeURI(JSON.stringify(trArr))));
            }

            if(validateForm.form()){
                $("#inputForm").submit();
                return true;
            }else {
                parent.layer.msg("信息未填写完整!", {icon: 5});
            }
            return false;
        }
        var str = [],mon = [],editFlag = false;//i = 0
        function openBill(title,url,width,height,target,editFlag){

            if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端，就使用自适应大小弹窗
                width='auto';
                height='auto';
            }else{//如果是PC端，根据用户设置的width和height显示。

            }
            top.layer.open({
                type: 2,
                area: [width, height],
                title: title,
                maxmin: true, //开启最大化最小化按钮
                content: url ,
				skin:"two-btns",
                btn: ['确定','关闭'],
                yes: function(index, layero){
                    editFlag = editFlag;
                    var body = top.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中展示
//                    if(iframeWin.contentWindow.doSubmit(1) ){
                    //关闭对话框。
//                        location.reload();
//                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
//                    }
                    var map = iframeWin.contentWindow.doSubmit(editFlag);
                    map = JSON.parse(map);
                    if(!map.name){
                        parent.layer.msg("请填写材料名称",{icon:1});
                        return;
                    }
                    /*if(!map.officeId){
                        parent.layer.msg("请选择报销公司及部门",{icon:1});
                        return;
                    }
//                        if(!map.travelDays){
//                            parent.layer.msg("请填写出差天数",{icon:1});
//                            return;
//                        }
//                        if(!map.billNumber){
//                            parent.layer.msg("请填写单据张数",{icon:1});
//                            return;
//                        }
                    if(!map.money){
                        parent.layer.msg("请填写报销金额",{icon:1});
                        return;
                    }
                    if(!map.payMode){
                        parent.layer.msg("请填选择支付方式",{icon:1});
                        return;
                    }
                    if(!map.payMode){
                        parent.layer.msg("请填填写费用信息",{icon:1});
                        return;
                    }*/
                    console.log("------------"+map.index);
                    if(map.index){
                        i = map.index
                    }
                    if(editFlag){
                        str = [];
                        mon = [];
                        var trlen = $("#workAccountList tr").length;
                        for(var i = 0;i < trlen;i++){
                            var flag = $("#workAccountList tr").eq(i).find("td").eq(0).text();
                            var name = $("#workAccountList tr").eq(i).find("td").eq(1).text();
                            var specification = $("#workAccountList tr").eq(i).find("td").eq(2).text();
                            var calculateUnit = $("#workAccountList tr").eq(i).find("td").eq(3).text();
                            var taxPrice = $("#workAccountList tr").eq(i).find("td").eq(4).text();
                            var price = $("#workAccountList tr").eq(i).find("td").eq(5).text();
                            var useDate = $("#workAccountList tr").eq(i).find("td").eq(6).text();
                            var source = $("#workAccountList tr").eq(i).find("td").eq(7).text();
                            var tax = $("#workAccountList tr").eq(i).find("td").eq(8).text();
                            var material = $("#workAccountList tr").eq(i).find("td").eq(9).text();

                            var brand = $("#workAccountList tr").eq(i).find("td").eq(10).text();
                            var pp = $("#workAccountList tr").eq(i).find("td").eq(11).text();
                            var areaId = $("#workAccountList tr").eq(i).find("td").eq(12).text();
                            var rand = Math.floor(Math.random () * 900) + 100;
                            var t1 = '<tr id="index'+rand+'">'+
                                '<td class="hide">'+flag+'</td>'+
                                '<td title="'+ name + '">'+name+'</td>'+
                                '<td  width="80px" title="'+ specification + '">'+specification+'</td>'+
                                '<td  width="60px" title="'+ calculateUnit + '">'+calculateUnit+'</td>'+
                                '<td  width="85px" title="'+ taxPrice + '">'+taxPrice+'</td>'+
                                '<td width="85px" title="'+ price + '">'+price+'</td>'+
                                '<td width="90px" >'+useDate+'</td>'+
                                '<td class="hide">'+source+'</td>'+
                                '<td width="70px" title="'+ tax + '">'+tax+'</td>'+
                                '<td width="75px" title="'+ material + '">'+material+'</td>'+
                                '<td title="'+ brand + '">'+brand+'</td>'+
                                '<td class="hide">'+pp+'</td>'+
                                '<td class="hide">'+areaId+'</td>'+
                                '<td width="130px" class="text-center op-td">'+
                                '<a href="javascript:void(0)" onclick=\"openBill(\'修改\', \'${ctx}/casematerials/caseMaterials/addBill?wid=${caseInfo.id}'+
                                '&flag='+$.trim(flag)+''+
                                '&name='+$.trim(name)+''+
                                '&specification='+$.trim(specification)+''+
                                '&calculateUnit='+$.trim(calculateUnit)+''+
                                '&taxPrice='+$.trim(taxPrice)+''+
                                '&price='+$.trim(price)+''+
                                '&useDate='+$.trim(useDate)+''+
                                '&source='+$.trim(source)+''+
                                '&tax='+$.trim(tax)+''+
                                '&tax='+$.trim(material)+''+
                                '&tax='+$.trim(brand)+''+
                                '&tax='+$.trim(pp)+''+
                                '&tax='+$.trim(areaId)+''+
                                '&index='+$.trim(i)+''+
                                '\',\'90%\', \'90%\')\" class="op-btn op-btn-edit" ><i class="fa fa-edit"></i> 修改</a>'+
                                '    <a href="javascript:void(0)" onclick=\"delRows(this,\'#index'+rand+'\')\" class="op-btn op-btn-delete" ><i class="fa fa-edit"></i> 删除</a>'+
                                '</td></tr>';
                            str.push(t1);
                           /* mon.push(money);*/
                        }
                    }
                    var rand = Math.floor(Math.random () * 900) + 100;
                    var s = '<tr id="index'+rand+'">'+
                        '<td class="hide">'+map.flag+'</td>'+
                        '<td title="'+ map.name +'">'+map.name+'</td>'+
                        '<td width="80px" title="'+ map.specification +'">'+map.specification+'</td>'+
                        '<td width="60px" title="'+ map.calculateUnit +'">'+map.calculateUnit+'</td>'+
                        '<td width="85px" title="'+ map.taxPrice +'">'+map.taxPrice+'</td>'+
                        '<td width="85px" title="'+ map.price +'">'+map.price+'</td>'+
                        '<td width="90px" >'+map.useDate+'</td>'+
                        '<td class="hide">'+map.source+'</td>'+
                        '<td width="70px" title="'+ map.tax +'">'+map.tax+'</td>'+
                        '<td width="75px" title="'+ map.material +'">'+map.material+'</td>'+
                        '<td title="'+ map.brand +'">'+map.brand+'</td>'+
                        '<td class="hide">'+map.pp+'</td>'+
                        '<td class="hide">'+map.areaId+'</td>'+
                        '<td width="130px" class="text-center op-td">'+
                        '<a href="javascript:void(0)" onclick=\"openBill(\'修改\', \'${ctx}/casematerials/caseMaterials/addBill?wid=${caseInfo.id}'+
                        '&flag='+map.flag+''+
                        '&name='+$.trim(map.name)+''+
                        '&specification='+$.trim(map.specification)+''+
                        '&calculateUnit='+$.trim(map.calculateUnit)+''+
                        '&taxPrice='+$.trim(map.taxPrice)+''+
                        '&price='+$.trim(map.price)+''+
                        '&useDate='+$.trim(map.useDate)+''+
                        '&source='+$.trim(map.source)+''+
                        '&tax='+$.trim(map.tax)+''+
                        '&material='+$.trim(map.material)+''+
                        '&brand='+$.trim(map.brand)+''+
                        '&pp='+$.trim(map.pp)+''+
                        '&areaId='+$.trim(map.areaId)+''+
                        '&index='+$.trim(i)+''+
                        '\',\'90%\', \'90%\')\" class="op-btn op-btn-edit" ><i class="fa fa-edit"></i> 修改</a>'+
                        '    <a href="javascript:void(0)" onclick=\"delRows(this,\'#index'+rand+'\')\" class="op-btn op-btn-delete" ><i class="fa fa-edit"></i> 删除</a>'
						+
                    '</td></tr>';
                    if(map.index){
                        str[map.index] = s;
                        /*mon[map.index] = map.money;*/
                    }else{
                        str.push(s);
                       /* mon.push(map.money);*/
                    }
                    $("#workAccountList").html(str.join(" "));
//                        i++;
                    top.layer.close(index);
                   // countMoney();
                },
                cancel: function(index){
                }
            });
        };
        function deleteRow(obj,index){
            $(obj).parent().parent().remove();
            str[index] = " ";
            mon[index] = 0;
           /* countMoney();*/
        }
       /* function countMoney(){
            var m = 0;
            $.each(mon,function (index,item) {
                m += Number(item);
            });
            $("#mont").val(m);
        }*/

        /*-------------------分割线-------------------*/
        function addRow(list, idx, tpl, row){
            var idx1 = $("#caseBuildInfoList tr").length;
            if(list == '#caseBuildInfoList' && idx1 < 100){
                bornTemplete(list, idx, tpl, row, idx1);
            }
            var idx2 = $("#caseDesignInfoList tr").length;
            if(list == '#caseDesignInfoList' && idx2 < 100){
                bornTemplete(list, idx, tpl, row, idx2);
            }
            var idx3 = $("#caseExecuteInfoList tr").length;
            if(list == '#caseExecuteInfoList' && idx3 < 100){
                bornTemplete(list, idx, tpl, row, idx3);
            }

            var idx4 = $("#caseMaterialsNormList tr").length;
            if(list == '#caseMaterialsNormList' && idx4 < 100){
                bornTemplete(list, idx, tpl, row, idx4);
            }
            var idx5 = $("#caseMechanicalNormList tr").length;
            if(list == '#caseMechanicalNormList' && idx5 < 100){
                bornTemplete(list, idx, tpl, row, idx5);
            }
            var idx6 = $("#casePeopleNormList tr").length;
            if(list == '#casePeopleNormList' && idx6 < 100){
                bornTemplete(list, idx, tpl, row, idx6);
            }
           /* var idx4 = $("#caseProjectFeatureList tr").length;
            if(list == '#caseProjectFeatureList' && idx4 < 100){
                bornTemplete(list, idx, tpl, row, idx4);
            }
            var idx5 = $("#caseNormList tr").length;
            if(list == '#caseNormList' && idx5 < 100){
                bornTemplete(list, idx, tpl, row, idx5);
            }
            var idx6 = $("#caseMaterialsList tr").length;
            if(list == '#caseMaterialsList' && idx6 < 100){
                bornTemplete(list, idx, tpl, row, idx6);
            }*/
        }
        function bornTemplete(list, idx, tpl, row, idx1){
            $(list).append(Mustache.render(tpl, {
                idx: idx, delBtn: true, row: row,
                order:idx1 + 1
            }));
            $(list+idx).find("select").each(function(){
                $(this).val($(this).attr("data-value"));
            });
            $(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
                var ss = $(this).attr("data-value").split(',');
                for (var i=0; i<ss.length; i++){
                    if($(this).val() == ss[i]){
                        $(this).attr("checked","checked");
                    }
                }
            });
        }
        function delRow(obj, prefix){
            var id = $(prefix+"_id");
            var delFlag = $(prefix+"_delFlag");
            if (id.val() == ""){
                $(obj).parent().parent().remove();
            }else if(delFlag.val() == "0"){
                delFlag.val("1");
                $(obj).html("&divide;").attr("title", "撤回删除");
                $(obj).parent().parent().addClass("error");
                $(obj).parent().parent().addClass("hide");
            }else if(delFlag.val() == "1"){
                delFlag.val("0");
                $(obj).html("&times;").attr("title", "删除");
                $(obj).parent().parent().removeClass("error");
            }
            var idx1 = $("#caseBuildInfoList tr").length; //tr 总数
            for(var i = 0;i < idx1;i++){
                $("#caseBuildInfoList tr").eq(i).find("td").eq(1).html(i + 1);
            }
            var idx2 = $("#caseDesignInfoList tr").length; //tr 总数
            for(var i = 0;i < idx2;i++){
                $("#caseDesignInfoList tr").eq(i).find("td").eq(1).html(i + 1);
            }
            var idx3 = $("#caseExecuteInfoList tr").length; //tr 总数
            for(var i = 0;i < idx3;i++){
                $("#caseExecuteInfoList tr").eq(i).find("td").eq(1).html(i + 1);
            }

            var idx4 = $("#caseMaterialsNormList tr").length; //tr 总数
            for(var i = 0;i < idx4;i++){
                $("#caseMaterialsNormList tr").eq(i).find("td").eq(1).html(i + 1);
            }
            var idx5 = $("#caseMechanicalNormList tr").length; //tr 总数
            for(var i = 0;i < idx5;i++){
                $("#caseMechanicalNormList tr").eq(i).find("td").eq(1).html(i + 1);
            }
            var idx6 = $("#casePeopleNormList tr").length; //tr 总数
            for(var i = 0;i < idx6;i++){
                $("#casePeopleNormList tr").eq(i).find("td").eq(1).html(i + 1);
            }
           /* var idx4 = $("#caseProjectFeatureList tr").length; //tr 总数
            for(var i = 0;i < idx4;i++){
                $("#caseProjectFeatureList tr").eq(i).find("td").eq(1).html(i + 1);
            }
            var idx5 = $("#caseNormList tr").length; //tr 总数
            for(var i = 0;i < idx5;i++){
                $("#caseNormList tr").eq(i).find("td").eq(1).html(i + 1);
            }
            var idx6 = $("#caseMaterialsList tr").length; //tr 总数
            for(var i = 0;i < idx6;i++){
                $("#caseMaterialsList tr").eq(i).find("td").eq(1).html(i + 1);
            }*/
        }
        function delRows(obj, prefix){
            var id = $(prefix);
            if (id.val() == ""){
                $(obj).parent().parent().remove();
            }
        }
        function setV(obj){
            var a = $(obj).attr("id");
            var b = a.replace('allPrice','proportion');
            var value = obj.value;
            var p = $("#price").val() || 0;
            if(!p || p == 0){
                parent.layer.msg("请先填写造价指标,且不能为零",{icon:5});
                return;
			}
            var num = value/p ;
            if(!/^\d+(\.\d{1,4})?$/.test( value )){
                parent.layer.msg("合价必须输入数字",{icon:5});
            }else{
                $("#" +  b ).val(parseFloat(num.toFixed(2)));
			}
        }

	</script>
</head>
<body>
<div class="single-form">
	<div class="container">
		<form:form id="inputForm" modelAttribute="caseInfo" action="${ctx}/caseinfo/caseInfo/save" method="post" enctype="multipart/form-data" class="form-horizontal">
		<form:hidden path="id"/>
			<form:hidden path="home"/>
			<form:hidden path="processInstanceId"/>
			<div class="form-group layui-row first lw7">
				<div class="form-group-label"><h2>基础信息</h2></div>
				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label"><span class="require-item">*</span>案例类别：</label>
					<div class="layui-input-block with-icon">
						<sys:treeselect id="caseCategory" name="caseCategory.id" value="${caseInfo.caseCategory.id}" labelName="classId.name" labelValue="${caseInfo.caseCategory.name}"
										title="编号分类" url="/casecategory/caseCategory/treeData" cssClass="form-control layui-input required"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label double-line"><span class="require-item">*</span>案例名称(分部分项)：</label>
					<div class="layui-input-block">
						<form:input path="name" htmlEscape="false"    class="form-control layui-input required"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>施工时间：</label>
					<div class="layui-input-block with-icon">
						<input id="startDate" name="startDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date layui-input required laydate-icon"
							   value="<fmt:formatDate value="${caseInfo.startDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">案例来源：</label>
					<div class="layui-input-block">
						<form:select path="source" class="form-control simple-select">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('case_source')}" itemLabel="label" itemValue="value" htmlEscape="false"></form:options>
						</form:select>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>工程所在地：</label>
					<div class="layui-input-block with-icon">
						<sys:treeselect id="area" name="area.id" value="${caseInfo.area.id}" labelName="area.name" labelValue="${caseInfo.area.name}"
										title="区域" url="/sys/area/treeData" cssClass="form-control required layui-input" notAllowSelectParent="true"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">项目标识：</label>
					<div class="layui-input-block">
						<input type="radio" class="i-checks" name="ext" checked id="ext" value="0">
						<label for="ext">系统内项目</label>
						<input type="radio" class="i-checks" name="ext" id="ext1" value="1">
						<label for="ext1">系统外项目</label>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>所属项目：</label>
					<div class="layui-input-block with-icon" id="td1">
						<sys:gridcaseproject url="${ctx}/workinvoice/workInvoice/selectproject" id="project" name="project.id"  value="${caseInfo.project.id}"  title="选择所属项目" labelName="caseInfo.project.projectName"
													labelValue="${caseInfo.project.projectName}" cssClass="form-control required layui-input" fieldLabels="项目" fieldKeys="projectName" searchLabel="项目名称" searchKey="projectName" ></sys:gridcaseproject>
						<%--<sys:gridselect3 url="${ctx}/caseinfo/caseInfo/selectproject"
										 id="project" name="project.id"
										 value="${caseInfo.project.id}"
										 title="选择所属项目"
										 labelName="caseInfo.project.name"
										 labelValue="${caseInfo.project.name}${caseInfo.project.number}${caseInfo.project.sort}${caseInfo.project.createDate}"
										 cssClass="form-control layui-input"
										 fieldLabels="项目总表"
										 fieldKeys="name"
										 searchLabel="项目名称"
										 searchKey="name"
										 numberLabel="项目编号" numberKey="number"
										 sortLabel="项目分类" sortKey="sort"
										 createDateLabel="登记时间" createDateKey="createDate"
						></sys:gridselect3>--%>
					</div>
					<div class="layui-input-block hide" id="td2">
						<form:input path="contractName" id="contractName" htmlEscape="false" class="form-control required layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label">设计单位：</label>
					<div class="layui-input-block">
						<div class="layui-item nav-btns" style="padding-left:0px;">
							<a class="nav-btn nav-btn-add" onclick="addRow('#caseDesignInfoList', caseDesignInfoRowIdx, caseDesignInfoTpl);caseDesignInfoRowIdx = caseDesignInfoRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
						</div>
						<table id="bankinfo2" class="table table-bordered table-condensed can-edit">
							<thead>
							<tr>
								<th width="35">序号</th>
								<th >单位名称</th>
								<th width="100" class="">联系人名称</th>
								<th width="150">联系方式</th>
								<th width="150">邮箱</th>
								<th width="70">操作</th>
							</tr>
							</thead>
							<tbody id="caseDesignInfoList">

							</tbody>
						</table>
						<script type="text/template" id="caseDesignInfoTpl">//<!--
                                <tr id="caseDesignInfoList{{idx}}">
                                    <td class="hide">
                                        <input id="caseDesignInfoList{{idx}}_id" name="caseDesignInfoList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                        <input id="caseDesignInfoList{{idx}}_delFlag" name="caseDesignInfoList[{{idx}}].delFlag" type="hidden" value="0"/>
                                    </td>
                                    <td  class="order-num" width="35">
                                        {{order}}
                                    </td>
                                    <td>
                                        <input id="caseDesignInfoList{{idx}}_name" name="caseDesignInfoList[{{idx}}].name" type="text" value="{{row.name}}"    class="form-control required"/>
                                    </td>
									<td width="100">
                                        <input id="caseDesignInfoList{{idx}}_linkedman" name="caseDesignInfoList[{{idx}}].linkedman" type="text" value="{{row.linkedman}}"    class="form-control "/>
                                    </td>
                                    <td width="150">
                                        <input id="caseDesignInfoList{{idx}}_mobile" name="caseDesignInfoList[{{idx}}].mobile" type="text" value="{{row.mobile}}"    class="form-control isPhone"/>
                                    </td>
                                    <td width="150">
                                        <input id="caseDesignInfoList{{idx}}_email" name="caseDesignInfoList[{{idx}}].email" type="text" value="{{row.email}}"    class="form-control email"/>
                                    </td>
                                    <td class="text-center op-td" width="70">
                                        {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#caseDesignInfoList{{idx}}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>{{/delBtn}}
                                    </td>
                                </tr>//-->
						</script>
					</div>
				</div>
				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label">建设单位：</label>
					<div class="layui-input-block">
						<div class="layui-item nav-btns" style="padding-left:0px;">
							<a class="nav-btn nav-btn-add" onclick="addRow('#caseBuildInfoList', caseBuildInfoRowIdx, caseBuildInfoTpl);caseBuildInfoRowIdx = caseBuildInfoRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
						</div>
						<table id="bankinfo" class="table table-bordered table-condensed can-edit">
							<thead>
							<tr>
								<th width="35">序号</th>
								<th >单位名称</th>
								<th width="100"class="">联系人名称</th>
								<th width="150">联系方式</th>
								<th width="150">邮箱</th>
								<th width="70">操作</th>
							</tr>
							</thead>
							<tbody id="caseBuildInfoList">

							</tbody>
						</table>
						<script type="text/template" id="caseBuildInfoTpl">//<!--
                                <tr id="caseBuildInfoList{{idx}}">
                                    <td class="hide">
                                        <input id="caseBuildInfoList{{idx}}_id" name="caseBuildInfoList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                        <input id="caseBuildInfoList{{idx}}_delFlag" name="caseBuildInfoList[{{idx}}].delFlag" type="hidden" value="0"/>
                                    </td>
                                    <td class="order-num" width="35">
                                        {{order}}
                                    </td>
                                    <td >
                                        <input id="caseBuildInfoList{{idx}}_name" name="caseBuildInfoList[{{idx}}].name" type="text" value="{{row.name}}"    class="form-control required"/>
                                    </td>
									<td width="100">
                                        <input id="caseBuildInfoList{{idx}}_linkedman" name="caseBuildInfoList[{{idx}}].linkedman" type="text" value="{{row.linkedman}}"    class="form-control "/>
                                    </td>
                                    <td width="150">
                                        <input id="caseBuildInfoList{{idx}}_mobile" name="caseBuildInfoList[{{idx}}].mobile" type="text" value="{{row.mobile}}"    class="form-control isPhone"/>
                                    </td>
                                    <td width="150">
                                        <input id="caseBuildInfoList{{idx}}_email" name="caseBuildInfoList[{{idx}}].email" type="text" value="{{row.email}}"    class="form-control email"/>
                                    </td>
                                    <td class="text-center op-td" width="70">
                                        {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#caseBuildInfoList{{idx}}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>{{/delBtn}}
                                    </td>
                                </tr>//-->
						</script>
					</div>
				</div>
				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label">施工单位：</label>
					<div class="layui-input-block">
						<div class="layui-item nav-btns" style="padding-left:0px;">
							<a class="nav-btn nav-btn-add" onclick="addRow('#caseExecuteInfoList', caseExecuteInfoRowIdx, caseExecuteInfoTpl);caseExecuteInfoRowIdx = caseExecuteInfoRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
						</div>
						<table id="bankinfo3" class="table table-bordered table-condensed can-edit">
							<thead>
							<tr>
								<th width="35">序号</th>
								<th >单位名称</th>
								<th width="100">联系人名称</th>
								<th width="150">联系方式</th>
								<th width="150">邮箱</th>
								<th width="70">操作</th>
							</tr>
							</thead>
							<tbody id="caseExecuteInfoList">

							</tbody>
						</table>
						<script type="text/template" id="caseExecuteInfoTpl">//<!--
                                <tr id="caseExecuteInfoList{{idx}}">
                                    <td class="hide">
                                        <input id="caseExecuteInfoList{{idx}}_id" name="caseExecuteInfoList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                        <input id="caseExecuteInfoList{{idx}}_delFlag" name="caseExecuteInfoList[{{idx}}].delFlag" type="hidden" value="0"/>
                                    </td>
                                    <td class="order-num" width="35">
                                        {{order}}
                                    </td>
                                    <td>
                                        <input id="caseExecuteInfoList{{idx}}_name" name="caseExecuteInfoList[{{idx}}].name" type="text" value="{{row.name}}"    class="form-control required"/>
                                    </td>
									<td width="100">
                                        <input id="caseExecuteInfoList{{idx}}_linkedman" name="caseExecuteInfoList[{{idx}}].linkedman" type="text" value="{{row.linkedman}}"    class="form-control "/>
                                    </td>
                                    <td width="150">
                                        <input id="caseExecuteInfoList{{idx}}_mobile" name="caseExecuteInfoList[{{idx}}].mobile" type="text" value="{{row.mobile}}"    class="form-control isPhone"/>
                                    </td>
                                    <td width="150">
                                        <input id="caseExecuteInfoList{{idx}}_email" name="caseExecuteInfoList[{{idx}}].email" type="text" value="{{row.email}}"    class="form-control email"/>
                                    </td>
                                    <td class="text-center op-td" width="70">
                                        {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#caseExecuteInfoList{{idx}}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>{{/delBtn}}
                                    </td>
                                </tr>//-->
						</script>
					</div>
				</div>
				<div class="layui-item layui-col-sm6 with-textarea">
					<label class="layui-form-label"><span class="require-item">*</span>项目特征：</label>
					<div class="layui-input-block">
						<form:textarea path="peculiarity" htmlEscape="false" rows="4" maxlength="2000" class="form-control required"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6 with-textarea">
					<label class="layui-form-label">案例特性：</label>
					<div class="layui-input-block">
						<form:textarea path="feature" htmlEscape="false" rows="4"   maxlength="2000" class="form-control "/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label double-line">造价指标:单位造价(元)：</label>
					<div class="layui-input-block">
						<form:input id="price" path="price" htmlEscape="false"    class="form-control number layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>单位：</label>
					<div class="layui-input-block">
						<form:input path="unit" htmlEscape="false"    class="form-control required layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label double-line">材料消耗量指标：</label>
					<div class="layui-input-block">
						<div class="layui-item nav-btns" style="padding-left:0px;">
							<a class="nav-btn nav-btn-add" onclick="addRow('#caseMaterialsNormList', caseMaterialsNormRowIdx, caseMaterialsNormTpl);caseMaterialsNormRowIdx = caseMaterialsNormRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
						</div>
						<table id="bankinfo4" class="table table-bordered table-condensed can-edit">
							<thead>
							<tr>
								<th width="35">序号</th>
								<th >名称</th>
								<th width="220">型号</th>
								<th width="90">单位消耗量</th>
								<th width="90">单位</th>
								<th width="100">合价</th>
								<th width="80">比重</th>
								<th width="70">操作</th>

							</tr>
							</thead>
							<tbody id="caseMaterialsNormList">
							<c:if test="${not empty caseInfo.caseMaterialsNormList}">
								<c:forEach items="${caseInfo.caseMaterialsNormList}" var="caseMaterialsNorm" varStatus="index">
									<tr id="caseMaterialsNormList${index.index}">
										<td class="hide">
											<input id="caseMaterialsNormList${index.index}_id" name="caseMaterialsNormList[${index.index}].id" type="hidden" value="${caseMaterialsNorm.id}"/>
											<input id="caseMaterialsNormList${index.index}_delFlag" name="caseMaterialsNormList[${index.index}].delFlag" type="hidden" value="0"/>
										</td>
										<td class="order-num" width="35">
												${index.index + 1}
										</td>
										<td>
											<input id="caseMaterialsNormList${index.index}_name" name="caseMaterialsNormList[${index.index}].name" type="text" value="${caseMaterialsNorm.name}"    class="form-control "/>
										</td>
										<td width="220">
											<input id="caseMaterialsNormList${index.index}_type" name="caseMaterialsNormList[${index.index}].type" type="text" value="${caseMaterialsNorm.type}"    class="form-control "/>
										</td>
										<td width="90">
											<input id="caseMaterialsNormList${index.index}_unitContent" name="caseMaterialsNormList[${index.index}].unitContent" type="text" value="${caseMaterialsNorm.unitContent}"    class="form-control "/>
										</td>
										<td width="90">
											<input id="caseMaterialsNormList${index.index}_unit" name="caseMaterialsNormList[${index.index}].unit" type="text" value="${caseMaterialsNorm.unit}"    class="form-control "/>
										</td>
										<td width="100">
											<input id="caseMaterialsNormList${index.index}_allPrice" onblur="setV(this)" name="caseMaterialsNormList[${index.index}].allPrice" type="text" value="${caseMaterialsNorm.allPrice}"    class="form-control number"/>
										</td>
										<td width="80">
											<input id="caseMaterialsNormList${index.index}_proportion" name="caseMaterialsNormList[${index.index}].proportion" type="text" value="${caseMaterialsNorm.proportion}"    class="form-control number"/>
										</td>
										<td class="text-center op-td"  width="70">
											<span class="op-btn op-btn-delete" onclick="delRow(this, '#caseMaterialsNormList${index.index}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>
										</td>
									</tr>
								</c:forEach>
							</c:if>
							</tbody>
						</table>
						<script type="text/template" id="caseMaterialsNormTpl">//<!--
                                <tr id="caseMaterialsNormList{{idx}}">
                                    <td class="hide">
                                        <input id="caseMaterialsNormList{{idx}}_id" name="caseMaterialsNormList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                        <input id="caseMaterialsNormList{{idx}}_delFlag" name="caseMaterialsNormList[{{idx}}].delFlag" type="hidden" value="0"/>
                                    </td>
                                    <td class="order-num" width="35">
                                        {{order}}
                                    </td>
                                    <td>
                                        <input id="caseMaterialsNormList{{idx}}_name" name="caseMaterialsNormList[{{idx}}].name" type="text" value="{{row.name}}"    class="form-control required"/>
                                    </td>
									<td width="220">
                                        <input id="caseMaterialsNormList{{idx}}_type" name="caseMaterialsNormList[{{idx}}].type" type="text" value="{{row.type}}"    class="form-control "/>
                                    </td>
                                    <td width="90">
                                        <input id="caseMaterialsNormList{{idx}}_unitContent" name="caseMaterialsNormList[{{idx}}].unitContent" type="text" value="{{row.unitContent}}"    class="form-control "/>
                                    </td>
                                    <td width="90">
                                        <input id="caseMaterialsNormList{{idx}}_unit" name="caseMaterialsNormList[{{idx}}].unit" type="text" value="{{row.unit}}"    class="form-control "/>
                                    </td>
                                    <td  width="100">
                                        <input id="caseMaterialsNormList{{idx}}_allPrice" onblur="setV(this)" name="caseMaterialsNormList[{{idx}}].allPrice" type="text" value="{{row.allPrice}}"    class="form-control number"/>
                                    </td>
                                    <td width="80">
                                        <input id="caseMaterialsNormList{{idx}}_proportion" name="caseMaterialsNormList[{{idx}}].proportion" type="text" value="{{row.proportion}}"    class="form-control number"/>
                                    </td>
                                    <td class="text-center op-td" width="70">
                                        {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#caseMaterialsNormList{{idx}}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>{{/delBtn}}
                                    </td>
                                </tr>//-->
						</script>
					</div>
				</div>

				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label double-line">机械消耗量指标：</label>
					<div class="layui-input-block">
						<div class="layui-item nav-btns" style="padding-left:0px;">
							<a class="nav-btn nav-btn-add" onclick="addRow('#caseMechanicalNormList', caseMechanicalNormRowIdx, caseMechanicalNormTpl);caseMechanicalNormRowIdx = caseMechanicalNormRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
						</div>
						<table id="bankinfo5" class="table table-bordered table-condensed can-edit">
							<thead>
							<tr>
								<th width="35">序号</th>
								<th width="">名称</th>
								<th width="220">型号</th>
								<th width="90">单位消耗量</th>
								<th width="90">单位</th>
								<th width="100">合价</th>
								<th width="80">比重</th>
								<th width="70">操作</th>
							</tr>
							</thead>
							<tbody id="caseMechanicalNormList">
							<c:if test="${not empty caseInfo.caseMechanicalNormList}">
								<c:forEach items="${caseInfo.caseMechanicalNormList}" var="caseMechanicalNorm" varStatus="index">
									<tr id="caseMaterialsNormList${index.index}">
										<td class="hide">
											<input id="caseMechanicalNormList${index.index}_id" name="caseMechanicalNormList[${index.index}].id" type="hidden" value="${caseMechanicalNorm.id}"/>
											<input id="caseMechanicalNormList${index.index}_delFlag" name="caseMechanicalNormList[${index.index}].delFlag" type="hidden" value="0"/>
										</td>
										<td class="order-num" width="35">
												${index.index + 1}
										</td>
										<td>
											<input id="caseMechanicalNormList${index.index}_name" name="caseMechanicalNormList[${index.index}].name" type="text" value="${caseMechanicalNorm.name}"    class="form-control "/>
										</td>
										<td width="220">
											<input id="caseMechanicalNormList${index.index}_type" name="caseMechanicalNormList[${index.index}].type" type="text" value="${caseMechanicalNorm.type}"    class="form-control "/>
										</td>
										<td width="90">
											<input id="caseMechanicalNormList${index.index}_unitContent" name="caseMechanicalNormList[${index.index}].unitContent" type="text" value="${caseMechanicalNorm.unitContent}"    class="form-control "/>
										</td>
										<td width="90">
											<input id="caseMechanicalNormList${index.index}_unit" name="caseMechanicalNormList[${index.index}].unit" type="text" value="${caseMechanicalNorm.unit}"    class="form-control "/>
										</td>
										<td width="100">
											<input id="caseMechanicalNormList${index.index}_allPrice" onblur="setV(this)" name="caseMechanicalNormList[${index.index}].allPrice" type="text" value="${caseMechanicalNorm.allPrice}"    class="form-control number"/>
										</td>
										<td width="80">
											<input id="caseMechanicalNormList${index.index}_proportion" name="caseMechanicalNormList[${index.index}].proportion" type="text" value="${caseMechanicalNorm.proportion}"    class="form-control number"/>
										</td>
										<td class="text-center op-td" width="70">
											<span class="op-btn op-btn-delete" onclick="delRow(this, '#caseMechanicalNormList${index.index}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>
										</td>
									</tr>
								</c:forEach>
							</c:if>
							</tbody>
						</table>
						<script type="text/template" id="caseMechanicalNormTpl">//<!--
							<tr id="caseMechanicalNormList{{idx}}">
								<td class="hide">
									<input id="caseMechanicalNormList{{idx}}_id" name="caseMechanicalNormList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
									<input id="caseMechanicalNormList{{idx}}_delFlag" name="caseMechanicalNormList[{{idx}}].delFlag" type="hidden" value="0"/>
								</td>
								<td class="order-num" width="35">
									{{order}}
								</td>
								<td>
									<input id="caseMechanicalNormList{{idx}}_name" name="caseMechanicalNormList[{{idx}}].name" type="text" value="{{row.name}}"    class="form-control required"/>
								</td>
								<td width="220">
									<input id="caseMechanicalNormList{{idx}}_type" name="caseMechanicalNormList[{{idx}}].type" type="text" value="{{row.type}}"    class="form-control "/>
								</td>
								<td width="90">
									<input id="caseMechanicalNormList{{idx}}_unitContent" name="caseMechanicalNormList[{{idx}}].unitContent" type="text" value="{{row.unitContent}}"    class="form-control "/>
								</td>
								<td width="90">
									<input id="caseMechanicalNormList{{idx}}_unit" name="caseMechanicalNormList[{{idx}}].unit" type="text" value="{{row.unit}}"    class="form-control "/>
								</td>
								<td width="100">
									<input id="caseMechanicalNormList{{idx}}_allPrice" onblur="setV(this)" name="caseMechanicalNormList[{{idx}}].allPrice" type="text" value="{{row.allPrice}}"    class="form-control number"/>
								</td>
								<td width="80">
									<input id="caseMechanicalNormList{{idx}}_proportion" name="caseMechanicalNormList[{{idx}}].proportion" type="text" value="{{row.proportion}}"    class="form-control number"/>
								</td>
								<td class="text-center op-td" width="70">
									{{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#caseMechanicalNormList{{idx}}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>{{/delBtn}}
								</td>
							</tr>//-->
						</script>
					</div>
				</div>
				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label double-line">人工消耗量指标：</label>
					<div class="layui-input-block">
						<div class="layui-item nav-btns" style="padding-left:0px;">
							<a class="nav-btn nav-btn-add" onclick="addRow('#casePeopleNormList', casePeopleNormRowIdx, casePeopleNormTpl);casePeopleNormRowIdx = casePeopleNormRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
						</div>
						<table id="bankinfo6" class="table table-bordered table-condensed can-edit">
							<thead>
							<tr>
								<th width="35">序号</th>
								<th width="">名称</th>
								<th width="220">型号</th>
								<th width="90">单位消耗量</th>
								<th width="90">单位</th>
								<th width="100">合价</th>
								<th width="80">比重</th>
								<th width="70">操作</th>
							</tr>
							</thead>
							<tbody id="casePeopleNormList">
							<c:if test="${not empty caseInfo.casePeopleNormList}">
								<c:forEach items="${caseInfo.casePeopleNormList}" var="casePeopleNorm" varStatus="index">
									<tr id="caseMaterialsNormList${index.index}">
										<td class="hide">
											<input id="casePeopleNormList${index.index}_id" name="casePeopleNormList[${index.index}].id" type="hidden" value="${casePeopleNorm.id}"/>
											<input id="casePeopleNormList${index.index}_delFlag" name="casePeopleNormList[${index.index}].delFlag" type="hidden" value="0"/>
										</td>
										<td class="order-num" width="35">
												${index.index + 1}
										</td>
										<td>
											<input id="casePeopleNormList${index.index}_name" name="casePeopleNormList[${index.index}].name" type="text" value="${casePeopleNorm.name}"    class="form-control "/>
										</td>
										<td width="220">
											<input id="casePeopleNormList${index.index}_type" name="casePeopleNormList[${index.index}].type" type="text" value="${casePeopleNorm.type}"    class="form-control "/>
										</td>
										<td width="90">
											<input id="casePeopleNormList${index.index}_unitContent" name="casePeopleNormList[${index.index}].unitContent" type="text" value="${casePeopleNorm.unitContent}"    class="form-control "/>
										</td>
										<td width="90">
											<input id="casePeopleNormList${index.index}_unit" name="casePeopleNormList[${index.index}].unit" type="text" value="${casePeopleNorm.unit}"    class="form-control "/>
										</td>
										<td width="100">
											<input id="casePeopleNormList${index.index}_allPrice" onblur="setV(this)" name="casePeopleNormList[${index.index}].allPrice" type="text" value="${casePeopleNorm.allPrice}"    class="form-control number"/>
										</td>
										<td width="80">
											<input id="casePeopleNormList${index.index}_proportion" name="casePeopleNormList[${index.index}].proportion" type="text" value="${casePeopleNorm.proportion}"    class="form-control number"/>
										</td>
										<td class="text-center op-td"  width="70">
											<span class="op-btn op-btn-delete" onclick="delRow(this, '#casePeopleNormList${index.index}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>
										</td>
									</tr>
								</c:forEach>
							</c:if>
							</tbody>
						</table>
						<script type="text/template" id="casePeopleNormTpl">//<!--
							<tr id="casePeopleNormList{{idx}}">
								<td class="hide">
									<input id="casePeopleNormList{{idx}}_id" name="casePeopleNormList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
									<input id="casePeopleNormList{{idx}}_delFlag" name="casePeopleNormList[{{idx}}].delFlag" type="hidden" value="0"/>
								</td>
								<td class="order-num" width="35">
									{{order}}
								</td>
								<td>
									<input id="casePeopleNormList{{idx}}_name" name="casePeopleNormList[{{idx}}].name" type="text" value="{{row.name}}"    class="form-control required"/>
								</td>
								<td width="220">
									<input id="casePeopleNormList{{idx}}_type" name="casePeopleNormList[{{idx}}].type" type="text" value="{{row.type}}"    class="form-control "/>
								</td>
								<td width="90">
									<input id="casePeopleNormList{{idx}}_unitContent" name="casePeopleNormList[{{idx}}].unitContent" type="text" value="{{row.unitContent}}"    class="form-control "/>
								</td>
								<td width="90">
									<input id="casePeopleNormList{{idx}}_unit" name="casePeopleNormList[{{idx}}].unit" type="text" value="{{row.unit}}"    class="form-control "/>
								</td>
								<td width="100">
									<input id="casePeopleNormList{{idx}}_allPrice" onblur="setV(this)" name="casePeopleNormList[{{idx}}].allPrice" type="text" value="{{row.allPrice}}"    class="form-control number"/>
								</td>
								<td width="80">
									<input id="casePeopleNormList{{idx}}_proportion" name="casePeopleNormList[{{idx}}].proportion" type="text" value="{{row.proportion}}"    class="form-control number"/>
								</td>
								<td class="text-center op-td" width="70">
									{{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#casePeopleNormList{{idx}}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>{{/delBtn}}
								</td>
							</tr>//-->
						</script>
						<script type="text/javascript">
							var caseBuildInfoRowIdx = 0, caseBuildInfoTpl = $("#caseBuildInfoTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
							var caseDesignInfoRowIdx = 0, caseDesignInfoTpl = $("#caseDesignInfoTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
							var caseExecuteInfoRowIdx = 0, caseExecuteInfoTpl = $("#caseExecuteInfoTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");

							var caseMaterialsNormRowIdx = 0, caseMaterialsNormTpl = $("#caseMaterialsNormTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
							var caseMechanicalNormRowIdx = 0, caseMechanicalNormTpl = $("#caseMechanicalNormTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
							var casePeopleNormRowIdx = 0, casePeopleNormTpl = $("#casePeopleNormTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
							/*var caseProjectFeatureRowIdx = 0, caseProjectFeatureTpl = $("#caseProjectFeatureTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
							var caseNormRowIdx = 0, caseNormTpl = $("#caseNormTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
							var caseMaterialsRowIdx = 0, caseMaterialsTpl = $("#caseMaterialsTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");*/
							if($("#id").val()){
								caseMaterialsNormRowIdx = ${fn:length(caseInfo.caseMaterialsNormList)};
								caseMechanicalNormRowIdx = ${fn:length(caseInfo.caseMechanicalNormList)};
								casePeopleNormRowIdx = ${fn:length(caseInfo.casePeopleNormList)};
							}
							$(document).ready(function() {
								var data = ${fns:toJson(caseInfo.caseBuildInfoList)};
								for (var i=0; i<data.length; i++){
									addRow('#caseBuildInfoList', caseBuildInfoRowIdx, caseBuildInfoTpl, data[i]);
									caseBuildInfoRowIdx = caseBuildInfoRowIdx + 1;
								}
								var dataBank = ${fns:toJson(caseInfo.caseDesignInfoList)};
								for (var i=0; i<dataBank.length; i++){
									addRow('#caseDesignInfoList', caseDesignInfoRowIdx, caseDesignInfoTpl, dataBank[i]);
									caseDesignInfoRowIdx = caseDesignInfoRowIdx + 1;
								}
								var dataBank3 = ${fns:toJson(caseInfo.caseExecuteInfoList)};
								for (var i=0; i<dataBank3.length; i++){
									addRow('#caseExecuteInfoList', caseExecuteInfoRowIdx, caseExecuteInfoTpl, dataBank3[i]);
									caseExecuteInfoRowIdx = caseExecuteInfoRowIdx + 1;
								}
							   /* var dataBank4 = ${fns:toJson(caseInfo.caseMaterialsNormList)};
								for (var i=0; i<dataBank4.length; i++){
									addRow('#caseMaterialsNormList', caseMaterialsNormRowIdx, caseMaterialsNormTpl, dataBank4[i]);
									caseMaterialsNormRowIdx = caseMaterialsNormRowIdx + 1;
								}
								var dataBank5 = ${fns:toJson(caseInfo.caseMechanicalNormList)};
								for (var i=0; i<dataBank5.length; i++){
									addRow('#caseMechanicalNormList', caseMechanicalNormRowIdx, caseMechanicalNormTpl, dataBank5[i]);
									caseMechanicalNormRowIdx = caseMechanicalNormRowIdx + 1;
								}
								var dataBank6 = ${fns:toJson(caseInfo.casePeopleNormList)};
								for (var i=0; i<dataBank6.length; i++){
									addRow('#casePeopleNormList', casePeopleNormRowIdx, casePeopleNormTpl, dataBank6[i]);
									casePeopleNormRowIdx = casePeopleNormRowIdx + 1;
								}*/
								<%--var dataBank4 = ${fns:toJson(caseInfo.caseProjectFeatureList)};--%>
								<%--for (var i=0; i<dataBank4.length; i++){--%>
								<%--addRow('#caseProjectFeatureList', caseProjectFeatureRowIdx, caseProjectFeatureTpl, dataBank4[i]);--%>
								<%--caseProjectFeatureRowIdx = caseProjectFeatureRowIdx + 1;--%>
								<%--}--%>
								<%--var dataBank5 = ${fns:toJson(caseInfo.caseNormList)};--%>
								<%--for (var i=0; i<dataBank5.length; i++){--%>
								<%--addRow('#caseNormList', caseNormRowIdx, caseNormTpl, dataBank5[i]);--%>
								<%--caseNormRowIdx = caseNormRowIdx + 1;--%>
								<%--}--%>
								<%--var dataBank6 = ${fns:toJson(caseInfo.caseMaterialsList)};--%>
								<%--for (var i=0; i<dataBank6.length; i++){--%>
								<%--addRow('#caseMaterialsList', caseMaterialsRowIdx, caseMaterialsTpl, dataBank6[i]);--%>
								<%--caseMaterialsRowIdx = caseMaterialsRowIdx + 1;--%>
								<%--}--%>
							});
						</script>
					</div>
				</div>

				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label double-line">主要材料单价：</label>
					<div class="layui-input-block">
						<div class="layui-item nav-btns" style="padding-left:0px;">
							<a onclick="openBill('新增材料单价','${ctx}/casematerials/caseMaterials/addBill','90%','90%',false,true)" class="nav-btn nav-btn-add" ><i class="fa fa-plus"></i>新增材料单价</a>
						</div>
						<table id="contentTable" class="table table-bordered table-condensed details">
							<thead>
							<tr>
								<th>材料名称</th>
								<th width="80px">规格型号</th>
								<th width="60px">单位</th>
								<th width="85px">材料含税价</th>
								<th width="85px">材料除税价</th>
								<th width="90px">价格取用日期</th>
								<th width="70px">税率</th>
								<th width="75px">材质</th>
								<th>品牌</th>
								<th width="130px">操作</th>
							</tr>
							</thead>
							<tbody id="workAccountList">
							<c:forEach items="${caseInfo.caseMaterialsList}" var="caseMaterials" varStatus="status">
								<tr id="index${status.index}">
									<td class="hide">${caseMaterials.id}</td>
									<%--<td>
										&lt;%&ndash;<a  href="javascript:void(0)" onclick="openDialogView('查看材料单信息', '${ctx}/casematerials/caseMaterials/form?id=${caseMaterials.id}&tabId=1','90%','90%')">
												${caseMaterials.name}
										</a>&ndash;%&gt;
									</td>--%>
									<td title="${caseMaterials.name}">${caseMaterials.name}</td>
									<td  width="80px" title="${caseMaterials.specification}">${caseMaterials.specification}</td>
									<td  width="60px" title="${caseMaterials.calculateUnit}">${caseMaterials.calculateUnit}</td>
									<td  width="85px" title="${caseMaterials.taxPrice}">${caseMaterials.taxPrice}</td>
									<td width="85px" title="${caseMaterials.price}">${caseMaterials.price}</td>
									<td width="90px"><fmt:formatDate value="${caseMaterials.useDate}" pattern="yyyy-MM-dd"/></td>
									<td class="hide">${fns:getDictLabel(caseMaterials.source, 'caseM_source', '')}</td>
									<td width="70px" title="${caseMaterials.tax}">${caseMaterials.tax}</td>
									<td width="75px" title="${caseMaterials.material}">${caseMaterials.material}</td>
									<td title="${caseMaterials.brand}">${caseMaterials.brand}</td>
									<td class="hide">${caseMaterials.pp}</td>
									<td class="hide">${caseMaterials.area.id}</td>
									<td width="130px" class="text-center op-td">
										<div class="op-btn-box">
											<%--<a href="javascript:void(0)" onclick="openBill('修改报销单', '${ctx}/workAccount/workAccount/form?id=${workAccount.id}','90%','90%')" class="btn btn-success btn-xs" ><i class="fa fa-edit"></i> 修改</a>--%>
											<%--<a href="${ctx}/workAccount/workAccount/delete?id=${workAccount.id}" onclick="return confirmx('确认要删除该报销单吗？', this.href)"   class="btn btn-danger btn-xs"><i class="fa fa-trash"></i> 删除</a>--%>
										<a href="javascript:void(0)" onclick="openBill('修改材料单价',
												'${ctx}/casematerials/caseMaterials/addBill?/ '+
												'wid=${caseInfo.id}'+
												'&flag=${caseMaterials.id}'+
												'&name=${caseMaterials.name}'+
												'&specification=${caseMaterials.specification}'+
												'&calculateUnit=${caseMaterials.calculateUnit}'+
												'&taxPrice=${caseMaterials.taxPrice}'+
												'&price=${caseMaterials.price}'+
												'&useDate=${caseMaterials.useDate}'+
												'&source=${caseMaterials.source}'+
												'&tax=${caseMaterials.tax}'+
												'&material=${caseMaterials.material}'+
												'&brand=${caseMaterials.brand}'+
												'&pp=${caseMaterials.pp}'+
												'&areaId=${caseMaterials.area.id}'+
												'&index=${status.index}','90%','90%')" class="op-btn op-btn-edit" ><i class="fa fa-edit"></i> 修改</a>
										<a href="${ctx}/casematerials/caseMaterials/delete?id=${caseMaterials.id}" onclick="return confirmx('确认要删除吗？', this.href)"   class="op-btn op-btn-delete"><i class="fa fa-trash"></i> 删除</a>
										</div>
									</td>
								</tr>
							</c:forEach>
							</tbody>
						</table>
					</div>
				</div>

				<div class="layui-item layui-col-sm12 with-textarea">
					<label class="layui-form-label double-line">偏差分析/记录/其他情况：</label>
					<div class="layui-input-block">
						<form:textarea path="record" htmlEscape="false" rows="4" maxlength="2000"   class="form-control "/>
					</div>
				</div>

			</div>

			<div class="form-group layui-row">
				<div class="form-group-label"><h2>附件信息</h2></div>
				<div class="layui-item nav-btns">
					<a id="attachment_btn" class="nav-btn nav-btn-add" title="添加附件"><i class="fa fa-plus"></i>&nbsp;添加附件</a>
				</div>
				<div id="addFile_attachment" style="display: none" class="upload-progress">
					<span id="fileName_attachment" ></span>
					<b><span id="baifenbi_attachment" ></span></b>
					<div class="progress">
						<div id="jindutiao_attachment" class="progress-bar" style="width: 0%" aria-valuenow="0">
						</div>
					</div>
				</div>
				<input id="attachment_file" type="file" name="attachment_file" multiple="multiple" style="display: none;" onChange="if(this.value)insertTitle(this.value);"/>
				<span id="attachment_title"></span>
				<div class="layui-item layui-col-xs12" style="padding:0 16px;">
					<table id="upTable" class="table table-bordered table-condensed details">
						<thead>
						<tr>
								<%-- <th>序号</th>--%>
							<th>文件</th>
							<th>上传人</th>
							<th>上传时间</th>
							<th width="150px">操作</th>
						</tr>
						</thead>
						<tbody id="file_attachment">
							<c:forEach items="${caseInfo.workAttachments}" varStatus="status" var="workClientAttachment">
								<tr>
									<%--<td>${status.index + 1}</td>--%>
									<c:choose>
										<c:when test="${fn:containsIgnoreCase(workClientAttachment.attachmentName,'jpg')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'png')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'gif')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'bmp')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'jpeg')}">
											<td><img src="${workClientAttachment.url}" width="50" height="50" onclick="openDialogView('预览','${ctx}/sys/picturepreview/picturePreview?url=${workClientAttachment.url}','90%','90%')" alt="${workClientAttachment.attachmentName}">
										</c:when>
										<c:otherwise>
											<c:choose>
												<c:when test="${fn:containsIgnoreCase(workClientAttachment.attachmentName,'pdf')}">
													<td><a class="attention-info" href="javascript:void(0)" onclick="preview('预览','${workClientAttachment.url}','90%','90%','1')">${workClientAttachment.attachmentName}</a></td>
												</c:when>
												<c:otherwise>
													<td><a class="attention-info" href="javascript:void(0)" onclick="preview('预览','${workClientAttachment.url}','90%','90%')">${workClientAttachment.attachmentName}</a></td>
												</c:otherwise>
											</c:choose>
										</c:otherwise>
									</c:choose>
									<td>${workClientAttachment.createBy.name}</td>
									<td><fmt:formatDate value="${workClientAttachment.createDate}" pattern="yyyy-MM-dd"/></td>
									<td class="op-td">
										<div class="op-btn-box" >
										<a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttach?file='+encodeURIComponent(encodeURIComponent('${workClientAttachment.url}'));" class="op-btn op-btn-download">下载</a>

										<%--<a href="${ctx}/caseinfo/caseInfo/downLoadAttach?file=${workClientAttachment.url}" class="btn btn-success btn-xs">下载</a>--%>
										<%--<a href="${workClientAttachment.url}" class="btn btn-info btn-xs">下载</a>--%>
										<a href="javascript:void(0)" onclick="deleteFileFromAliyun(this,'${ctx}/caseinfo/caseInfo/deleteFileFromAliyun?attachmentId=${workClientAttachment.id}&id=${caseInfo.id}&type=2')" class="op-btn op-btn-delete" >删除</a>
										<%--<a href="${ctx}/caseinfo/caseInfo/deleteFileFromAliyun?attachmentId=${workClientAttachment.id}&id=${caseInfo.id}">删除</a>--%>
										</div>
									</td>
								</tr>
							</c:forEach>
							</tbody>
						</table>
				</div>
			</div>
			<div class="form-group layui-row page-end"></div>
		</form:form>
	</div>
</div>
</body>
</html>