<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<%
    String param = request.getParameter("param");

%>
<html>
<head>
	<title>客户信息管理</title>
	<meta name="decorator" content="default"/>
    <%--<style type="text/css">--%>
        <%--.btn-file{--%>
            <%--margin-top:8px;--%>
        <%--}--%>
        <%--.btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open .dropdown-toggle.btn-default {--%>
            <%--background-color:#fff;--%>
            <%--color: #110F0F;--%>
        <%--}--%>
        <%--.btn-default{--%>
            <%--background-color:#fff;--%>
            <%--color: #110F0F;--%>
        <%--}--%>
    <%--</style>--%>
    <link href="${ctxStatic}/bootstrap-select-1.12.4/css/bootstrap-select.min.css" rel="stylesheet" />
    <style>
        #companyType-error{
            left:0;
            top:40px;
        }
        #clientType-error{
            left:0;
            top:40px;
        }
        #companyIndustry-error{
            left:0;
            top:40px;
        }
    </style>
    <script src="${ctxStatic}/bootstrap-select-1.12.4/js/bootstrap-select.min.js"></script>
	<script type="text/javascript">
		var validateForm;
		function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
			  $("#inputForm").submit();
			  return true;
		  }else {
              parent.layer.msg("信息未填写完整!", {icon: 5});
          }

		  return false;
		}
		$(document).ready(function() {
            checkContentKeyUp('unitIntroduction',500);
            $.validator.messages["orUnicode"] = true;
            $.validator.methods["orUnicode"] = function( value, element ) {
                return this.optional( element ) || /^[a-z0-9A-Z\-]*$/.test( value );
            }
            $.validator.messages["fax"] = true;
            $.validator.methods["fax"] = function( value, element ) {
                return this.optional( element ) || /^[0-9\-]*$/.test( value );
            }
            $.validator.messages["telephone"] = true;
            $.validator.methods["telephone"] = function( value, element ) {
                return this.optional( element ) || /^[0-9\-]*$/.test( value );
            }
            $.validator.messages["ourBank"] = true;
            $.validator.methods["ourBank"] = function( value, element ) {
                return this.optional( element ) || /^[\u4e00-\u9fa5]*$/.test( value );
            }
            $.validator.messages["taxId"] = true;
            $.validator.methods["taxId"] = function( value, element ) {
                return this.optional( element ) || /^[a-z0-9A-Z]*$/.test( value );
            }

            jQuery.validator.addMethod("isUscCode", function(value, element) {
                if (this.optional(element)){
                    return true;
                }
                var uscCode = /^((\w{15})|(\w{18})|(\w{20}))$/;
                return uscCode.test(value);
            }, "请填写正确的统一社会信用代码");

			validateForm = $("#inputForm").validate({
                rules:{
                    orUnicode:{
                        orUnicode:true
                    },
                    zipCode:{
                        digits:true
                    },
                    email:{
                        email:true
                    },
                    fax:{
                        fax:true
                    },
                    telephone:{
                        telephone:true
                    },
                    taxId:{
                        taxId:true
                    },
                    uscCode:{remote: "${ctx}/workclientinfo/workClientInfo/checkUscCode?oldUscCode=" + encodeURIComponent($("#oldUscCode").val())}
				},
                messages:{
                    orUnicode:{
                        orUnicode:"仅允许输入数字、大写拉丁字母、符号“-”"
                    },
                    zipCode:{
                        required:"必须输入数字"
                    },
                    email:{
                        email:"请输入合法的邮箱地址"
                    },
                    fax:{
                        fax:"仅允许输入数字、符号“-”"
                    },
                    telephone:{
                        telephone:"仅允许输入数字、符号“-”"
                    },
                    taxId:{
                        taxId:"仅允许输入数字、大写拉丁字母"
                    },
                    uscCode:{remote:"重复的统一社会信用代码"}
                },
                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);
					}
				}
			});
            $("#attachment_btn").click(function () {
                $("#attachment_file").click();
            });
            $('input[name="hasUscc"]').on('ifChecked', function(event){
                disUscc(event.target.defaultValue);
            });
            disUscc($('input[name="hasUscc"]:checked').val());
            if($("#uscCode").val()!=null&&$("#uscCode").val()!='') {
                $("#inputForm").validate().element($("#uscCode"));
            }

            var arr="${workClientInfo.clientType}".split(',');
            $('#clientType').selectpicker('val',arr);
        });
		function testOurBank(value){
		    if(!/^[\u4e00-\u9fa5]*$/.test( value )){
                parent.layer.msg("开户银行必须输入汉字",{icon:6});
            }
        }

        /**
         * 只允许输入数字
         * @param value
         */
        function testBankNumber(value){
            if(!/^\d*$/.test( value )){
                parent.layer.msg("开户帐号必须输入数字",{icon:6});
            }
        }
		function addRow(list, idx, tpl, row){
            var idx1 = $("#workClientBankList tr").length;
		    if(list == '#workClientBankList'){
                bornTemplete(list, idx, tpl, row, idx1);
            }
            var idx2 = $("#workClientLinkmanList tr").length;
            if(list == '#workClientLinkmanList'){
                bornTemplete(list, idx, tpl, row, idx2);
            }
		}
		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");
			}

		}
        function urlRedict(file,attach){
		    parent.layer.confirm('确定删除吗？', {
                btn: ['确认', '取消'] //可以无限个按钮
            }, function(index, layero){
                var index1 = parent.layer.load(0, {shade: false});
                $.post("${ctx}/workfullmanage/workFullManage/deleteFile",
                    {"file":file,"attach":attach},
                    function(result){
                        var d = JSON.parse(result);
                        if(d.str){
                            location.reload();
                            parent.layer.msg("删除成功！！！",{icon:6});
                            parent.layer.close(index1);
                            parent.layer.close(index);
                        }
                    });
            }, function(index){
                parent.layer.close(index)
            });

        }

        function insertTitle(tValue){
            var list = "${workClientInfo.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 = "";
                var attachmentFlag = "5";
                console.log(file);
                var timestamp = new Date().getTime();

                var storeAs = "attachment-file/workClientInfo/" + 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 disUscc(hasUscc) {
            if("2"==hasUscc){
                $(".companyType_uscCode").hide();
                /*$('input[name="uscCode"]').attr("class","form-control");*/
                $('input[name="uscCode"]').val("");
            }else {
                $(".companyType_uscCode").show();
                /*$('input[name="uscCode"]').attr("class","form-control required isUscCode layui-input");*/
            }
        }
	</script>

</head>
<body>
<div class="single-form">
    <div class="container">
        <input type="hidden" value="${param.param}" id="param">
        <form:form id="inputForm" modelAttribute="workClientInfo" enctype="multipart/form-data"
                   onkeydown="if(event.keyCode==13)return false;" action="${ctx}/workclientinfo/workClientInfo/save"
                   method="post" class="form-horizontal">
            <form:hidden path="id"/>
            <div class="form-group layui-row first">
                <div class="form-group-label"><h2>基本信息</h2></div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label"><span class="require-item">*</span>客户名称：</label>
                    <div class="layui-input-block">
                        <form:input path="name" htmlEscape="false" class="form-control required layui-input"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label double-line"><span class="require-item">*</span>拥有统一社会信用代码：</label>
                    <div class="layui-input-block">&nbsp;&nbsp;
                        <form:radiobutton class="usccClass i-checks" path="hasUscc" value="1" label="是" checked="true" />
                        &nbsp;&nbsp;
                        <form:radiobutton class="usccClass i-checks" path="hasUscc" value="2" label="否" />
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label"><span class="require-item">*</span>客户性质：</label>
                    <div class="layui-input-block">
                        <form:select path="companyType" class="form-control selectpicker required layui-input" id="companyType">
                            <form:option value="" label="--请选择客户性质--"/>
                            <form:options items="${fns:getMainDictList('company_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>

                        </form:select>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7 companyType_uscCode">
                    <label class="layui-form-label double-line"><span class="require-item">*</span>统一社会信用代码：</label>
                    <div class="layui-input-block">
                        <form:input path="uscCode" htmlEscape="false" class="form-control required isUscCode layui-input"/>
                        <input type="hidden" id="oldUscCode" value="${workClientInfo.uscCode}"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label"><span class="require-item">*</span>所在行业：</label>
                    <div class="layui-input-block">
                        <form:select path="companyIndustry" class="form-control selectpicker required layui-input">
                            <form:option value="" label="--请选择行业--"/>
                            <form:options items="${fns:getMainDictList('company_industry')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                        </form:select>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <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="${workClientInfo.area.id}" labelName="area.name"
                                        labelValue="${workClientInfo.area.name}"
                                        title="区域" url="/sys/area/treeData" cssClass="form-control required layui-input"
                                        allowClear="true" notAllowSelectParent="true"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label">法人代表：</label>
                    <div class="layui-input-block">
                        <form:input path="lawerPresint" htmlEscape="false" class="form-control layui-input"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label">邮政编码：</label>
                    <div class="layui-input-block">
                        <form:input path="zipCode" htmlEscape="false" minlength="6" maxlength="6"
                                    class="form-control digits layui-input"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label">传真：</label>
                    <div class="layui-input-block">
                        <form:input path="fax" htmlEscape="false" class="form-control isTel layui-input"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label"><span class="require-item">*</span>客户类型：</label>
                    <div class="layui-input-block width-icon">

                        <form:select path="clientType" class="form-control selectpicker required layui-input">
                            <form:option value="" label="--请选择客户类型--"/>
                            <form:options items="${fns:getMainDictList('client_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                        </form:select>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label"><span class="require-item">*</span>公司电话：</label>
                    <div class="layui-input-block">
                        <form:input path="telephone" htmlEscape="false"
                                    class="form-control isTel required layui-input"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm6 lw7">
                    <label class="layui-form-label">公司网址：</label>
                    <div class="layui-input-block">
                        <form:input path="companyUrl" htmlEscape="false" class="form-control isUrl layui-input"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm12 lw7">
                    <label class="layui-form-label"><span class="require-item">*</span>注册地址：</label>
                    <div class="layui-input-block">
                        <form:input path="registerAddress" htmlEscape="false"
                                    class="form-control required layui-input"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm12 lw7">
                    <label class="layui-form-label">详细地址：</label>
                    <div class="layui-input-block">
                        <form:input path="address" htmlEscape="false" class="form-control layui-input"/>
                    </div>
                </div>
                <div class="layui-item layui-col-sm12 lw7">
                    <label class="layui-form-label"><span class="require-item">*</span>开户行信息：</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('#workClientBankList', workClientBankRowIdx, workClientBankTpl);workClientBankRowIdx = workClientBankRowIdx + 1;"
                               title="新增"><i class="fa fa-plus"></i> 新增</a>
                        </div>
                        <table id="bankinfo" class="table table-bordered table-condensed can-edit">
                            <thead>
                            <tr>
                                <th class="sort-column companyType"><font color="red">*</font>开户银行</th>
                                <th width="400px;"><font color="red">*</font>开户账号</th>
                                <th width="100px">操作</th>
                            </tr>
                            </thead>
                            <tbody id="workClientBankList">

                            </tbody>
                        </table>
                        <script type="text/template" id="workClientBankTpl">//<!--
                                <tr id="workClientBankList{{idx}}">
                                    <td class="hide">
                                        <input id="workClientBankList{{idx}}_id" name="workClientBankList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                        <input id="workClientBankList{{idx}}_delFlag" name="workClientBankList[{{idx}}].delFlag" type="hidden" value="0"/>
                                    </td>

                                    <td>
                                        <input id="workClientBankList{{idx}}_ourBank" onblur="testOurBank(this.value)" name="workClientBankList[{{idx}}].ourBank" type="text" value="{{row.ourBank}}"    class="form-control required"/>
                                    </td>

                                    <td>
                                        <input id="workClientBankList{{idx}}_bankNumber" onblur="testBankNumber(this.value)" name="workClientBankList[{{idx}}].bankNumber" type="text" value="{{row.bankNumber}}"  minlength="16" maxlength="19"  class="form-control required digits "/>
                                    </td>

                                    <td class="text-center op-td" width="10">
                                        {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#workClientBankList{{idx}}')" title="删除"><i class="fa fa-trash"></i>&nbsp;删除</span>{{/delBtn}}
                                    </td>
                                </tr>//-->
                        </script>
                    </div>
                </div>
                <div class="layui-item layui-col-sm12 lw7">
                    <label class="layui-form-label">单位简介：</label>
                    <div class="layui-input-block">
                        <form:textarea path="unitIntroduction" htmlEscape="false" rows="4" maxlength="500"
                                       onkeyup="checkContentKeyUp('unitIntroduction',500);" class="form-control "/>
                    </div>
                    <span id="contentMsg" style="float: right"></span>
                </div>
            </div>


            <%--<td class="companyType_orUnicode width-15 active"><label class="pull-right"><font color="red">*</font>组织机构代码或税务号：</label></td>
            <td class="companyType_orUnicode width-35">
                <form:input path="orUnicode" htmlEscape="false"  class="form-control required"/>
            </td>

            <td class="companyType_taxId width-15 active"><label class="pull-right"><font color="red">*</font>组织机构代码或税务号：</label></td>
            <td class="companyType_taxId width-35" colspan="3">
                <form:input path="taxId" htmlEscape="false"    class="form-control required"/>
            </td>
            <script type="text/javascript">
                $(function () {
                    var defaultValue = $("#companyType option:selected").val();
                    var companyTypeValue = "${workClientInfo.companyType}";
                    console.log("defaultValue="+defaultValue);
                    if(defaultValue == 1 || companyTypeValue == 1){
                        $(".companyType_taxId").hide();
                        $(".companyType_orUnicode").show();
                    }else{
                        $(".companyType_orUnicode").hide();
                        $(".companyType_taxId").show();
                    }
                    $("select#companyType").change(function () {
                        var currentValue = $(this).val();
                        if(currentValue == 1){
                            $(".companyType_taxId").hide();
                            $(".companyType_orUnicode").show();
                        }else{
                            $(".companyType_orUnicode").hide();
                            $(".companyType_taxId").show();
                        }
                    });
                })
            </script>--%>

            <%--<tr>
            <td class="width-15 active"><label class="pull-right"><font color="red">*</font>客户类型：</label></td>
                   <td class="width-35">
                       <form:select path="clientType" class="form-control required">
                           <form:option value="" label=""/>
                           <form:options items="${fns:getMainDictList('client_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                       </form:select>
                   </td>
               <td class="width-15 active"><label class="pull-right">信用等级：</label></td>
                       <td class="width-35">
                           <form:select path="creditRank" class="form-control ">
                               <form:option value="" label=""/>
                               <form:options items="${fns:getDictList('credit_rank')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                           </form:select>
                       </td>
                   </tr>--%>

            <div class="form-group layui-row">
                <div class="form-group-label"><h2>联系人信息</h2></div>
                <div class="layui-item nav-btns">
                    <a class="nav-btn nav-btn-add"
                       onclick="addRow('#workClientLinkmanList', workClientLinkmanRowIdx, workClientLinkmanTpl);workClientLinkmanRowIdx = workClientLinkmanRowIdx + 1;"
                       title="新增"><i class="fa fa-plus"></i> 新增</a>
                </div>
                <div class="layui-item layui-col-xs12 form-table-container">
                    <table id="contentTable" class="table table-bordered table-condensed can-edit">
                        <thead>
                        <tr>
                            <th class="hide"></th>
                            <th width="100px"><font color="red">*</font>联系人姓名</th>
                            <th width="100px">部门</th>
                            <th width="100px">职务</th>
                            <th width="100px">QQ</th>
                            <th width="100px">联系方式1</th>
                            <th width="100px">联系方式2</th>
                            <th width="150px">E-mail</th>
                            <th width="100px">操作</th>
                        </tr>
                        </thead>
                        <tbody id="workClientLinkmanList">

                        </tbody>
                    </table>
                    <script type="text/template" id="workClientLinkmanTpl">//<!--
            <tr id="workClientLinkmanList{{idx}}">
                <td class="hide">
                    <input id="workClientLinkmanList{{idx}}_id" name="workClientLinkmanList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                    <input id="workClientLinkmanList{{idx}}_delFlag" name="workClientLinkmanList[{{idx}}].delFlag" type="hidden" value="0"/>
                </td>

                <td>
                    <input id="workClientLinkmanList{{idx}}_name" name="workClientLinkmanList[{{idx}}].name" type="text" value="{{row.name}}"    class="form-control required"/>
                </td>
                <td>
                    <input id="workClientLinkmanList{{idx}}_office" name="workClientLinkmanList[{{idx}}].office" type="text" value="{{row.office}}"    class="form-control "/>
                </td>
                <td>
                    <input id="workClientLinkmanList{{idx}}_position" name="workClientLinkmanList[{{idx}}].position" type="text" value="{{row.position}}"    class="form-control "/>
                </td>


                <td>
                    <input id="workClientLinkmanList{{idx}}_qq" name="workClientLinkmanList[{{idx}}].qq" type="text" value="{{row.qq}}"    class="form-control digits"/>
                </td>


                <td>
                    <input id="workClientLinkmanList{{idx}}_linkPhone" name="workClientLinkmanList[{{idx}}].linkPhone" type="text" value="{{row.linkPhone}}"    class="form-control isTel"/>
                </td>


                <td>
                    <input id="workClientLinkmanList{{idx}}_linkMobile" name="workClientLinkmanList[{{idx}}].linkMobile" type="text" value="{{row.linkMobile}}"    class="form-control isPhone"/>
                </td>


                <td>
                    <input id="workClientLinkmanList{{idx}}_email" name="workClientLinkmanList[{{idx}}].email" type="text" value="{{row.email}}"    class="form-control email"/>
                </td>

                <td class="text-center op-td" >
                    {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#workClientLinkmanList{{idx}}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>{{/delBtn}}
                </td>
            </tr>//-->
                    </script>
                    <script type="text/javascript">
                        var workClientLinkmanRowIdx = 0,
                            workClientLinkmanTpl = $("#workClientLinkmanTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, "");
                        var workClientBankRowIdx = 0,
                            workClientBankTpl = $("#workClientBankTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g, "");
                        $(document).ready(function () {
                            var data = ${fns:toJson(workClientInfo.workClientLinkmanList)};
                            for (var i = 0; i < data.length; i++) {
                                addRow('#workClientLinkmanList', workClientLinkmanRowIdx, workClientLinkmanTpl, data[i]);
                                workClientLinkmanRowIdx = workClientLinkmanRowIdx + 1;
                            }
                            var dataBank = ${fns:toJson(workClientInfo.workClientBankList)};
                            for (var i = 0; i < dataBank.length; i++) {
                                addRow('#workClientBankList', workClientBankRowIdx, workClientBankTpl, dataBank[i]);
                                workClientBankRowIdx = workClientBankRowIdx + 1;
                            }
                        });

                    </script>
                </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="${workClientInfo.workAttachments}" var="workClientAttachment"
                                   varStatus="status">
                            <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}" type="both"/></td>
                                <td class="op-td">
                                    <div class="op-btn-box">
                                        <a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttach?file='+encodeURIComponent('${workClientAttachment.url}');"
                                           class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
                                        <c:if test="${workClientAttachment.createBy.id eq fns:getUser().id}">
                                            <a href="javascript:void(0)"
                                               onclick="deleteFileFromAliyun(this,'${ctx}/sys/workattachment/deleteFileFromAliyun?url=${workClientAttachment.url}&id=${workClientAttachment.id}&type=2','addFile')"
                                               class="op-btn op-btn-delete"><i class="fa fa-trash"></i>&nbsp;删除</a>
                                        </c:if>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="form-group layui-row page-end"></div>
        </form:form>
    </div>
</div>



<%--<script type="text/javascript">--%>
  <%----%>
    <%--//上传--%>
    <%--function upload_image_button(index){--%>
        <%--$("#upload_file_"+index).click();--%>
    <%--}--%>
    <%--function upload_show_image(index){--%>
        <%--var image =$("#upload_file_"+index)[0].files[0];--%>
        <%--var url = window.URL.createObjectURL(image);--%>
        <%--if(image.name.indexOf("jpg") != -1--%>
            <%--|| image.name.indexOf("png") != -1--%>
            <%--|| image.name.indexOf("jpeg") != -1--%>
            <%--|| image.name.indexOf("gif") != -1--%>
            <%--|| image.name.indexOf("PNG") != -1){--%>
            <%--url = window.URL.createObjectURL(image);--%>
        <%--}else if(image.name.indexOf("pdf") != -1 || image.name.indexOf("PDF") != -1){--%>
            <%--url = "${ctxStatic}/common/img/pdf5.png";--%>
        <%--}else if(image.name.indexOf("doc") != -1 || image.name.indexOf("DOC") != -1--%>
            <%--|| image.name.indexOf("docx") != -1 || image.name.indexOf("DOCX") != -1){--%>
            <%--url = "${ctxStatic}/common/img/word.png";--%>
        <%--}else if(image.name.indexOf("xlsx") != -1 || image.name.indexOf("XLSX") != -1--%>
            <%--|| image.name.indexOf("xls") != -1 || image.name.indexOf("XLSX") != -1){--%>
            <%--url = "${ctxStatic}/common/img/excel.png";--%>
        <%--}else{--%>
            <%--url = "${ctxStatic}/common/img/file.jpg";--%>
        <%--}--%>
        <%--$("#upload_image_"+index).attr("src",url);--%>
        <%--var length = $("#upload_image_div :file").length;--%>
        <%--if( index == length &&  length < 5 ){--%>
            <%--upload_image_append(index);--%>
            <%--add_x(index);--%>
        <%--}else if(index == length && length ==5){--%>
            <%--var span = '<span id="upload_close_'+index+'" class="close_ico" style="cursor:pointer; position: absolute;top:-1px;right: -2px; display:inline-block;z-index:1;" onclick="close_img('+index+');"><i class="fa fa-close"></i></span>';--%>
            <%--$("#upload_image_5").before(span);--%>
        <%--}--%>
    <%--}--%>
    <%--function upload_image_append(index){--%>
        <%--var div1 = "<div id='upload_div_"+(index+1)+"' style='float:left;position:relative;width: 64px;height: 57px;margin-left:5px;'>";--%>
        <%--var img = '<img id="upload_image_'+(index+1)+'" class="upload_ico" width="50px" height="50px"  onclick="upload_image_button('+(index+1)+')" src = "${pageContext.request.contextPath}/static/uploadify/upload_ico.png" style="cursor:pointer;width:50px;height:50px;"/>';--%>
        <%--var input = '<input id="upload_file_'+(index+1)+'" type="file" style="display:none;" name="upload_files" onChange="upload_show_image('+(index+1)+')" /><br>';--%>
        <%--var div2 = "</div>";--%>
        <%--$("#upload_image_div").append(div1+img+input+div2);--%>
    <%--}--%>
    <%--function close_img(index) {--%>
        <%--$("#upload_div_"+index).remove();--%>
        <%--var length = $("#upload_image_div :file").length;--%>
        <%--if(length == 0){--%>
            <%--add_div();--%>
        <%--}else if(length == 1){--%>
            <%--var x = $("#upload_image_div").find("span").text();--%>
            <%--if("x" != x){--%>
                <%--add_div();--%>
            <%--}--%>
        <%--}--%>
    <%--}--%>
    <%--function add_x(index) {--%>
        <%--var span = '<span id="upload_close_'+index+'" class="close_ico" style="cursor:pointer; position: absolute;top:-1px;right: -2px; display:inline-block;z-index:1;" onclick="close_img('+index+');"><i class="fa fa-close"></i></span>';--%>
        <%--$("img:eq(-2)").before(span);--%>
    <%--}--%>
    <%--function add_div() {--%>
        <%--var upload_div_1 =--%>
            <%--'<div id="upload_div_1" style="float: left;position:relative;width: 64px;height: 57px;margin-left:5px;" >'+--%>
            <%--'<img  id="upload_image_1" class="upload_ico" style="cursor:pointer;width:50px;height:50px;"  src="${pageContext.request.contextPath}/static/uploadify/upload_ico.png"  onclick="upload_image_button(1)"/>'+--%>
            <%--'<input id="upload_file_1" type="file" style="display:none"  name="upload_files"  onchange="upload_show_image(1)" /><br>'+--%>
            <%--'</div>';--%>
        <%--$("#upload_image_div").html("").append(upload_div_1);--%>
    <%--}--%>


<%--</script>--%>
</body>
</html>