<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.css" media="all">
    <style>
        html {background-color: #fff;padding-bottom: 50px;}td, th {text-align: center !important;}
        .layui-btn-danger {
            background-color: #cd2323;
        }
    </style>
</head>

<body>
<div class="layui-form">
    <div class="layui-card-body layui-col-xs12" id="LAY_app">
        <blockquote class="layui-elem-quote">订单信息</blockquote>
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-row layui-col-space12 layui-form-item mt-5">
                    <%--<div class="layui-col-xs3">
                        <label class="layui-form-label"><i class="red">*</i>备货类型：</label>
                        <div class="layui-input-block">
                            <select name="fittingType" lay-verify="required" lay-filter="fittingType" id="fittingType">
                                <option value="">请选择</option>
                                <option value="1" <c:if test="${'1' eq apply.fittingType}">selected</c:if>>组件</option>
                                <option value="0" <c:if test="${'0' eq apply.fittingType}">selected</c:if>>其他</option>
                            </select>
                        </div>
                    </div>--%>
                    <div class="layui-col-xs3">
                        <label class="layui-form-label"><i class="red">*</i>入库仓库：</label>
                        <div class="layui-input-block">
                            <select name="inWarehouseId" lay-verify="required" lay-filter="inWarehouseId">
                                <option value="">请选择</option>
                                <c:forEach items="${wares}" var="warehouse">
                                    <option value="${warehouse.columns.id}"
                                        ${wares.size() == 1 ? 'selected': ''}
                                            <c:if test="${warehouse.columns.id eq apply.inWarehouseId}">selected</c:if>
                                    >${warehouse.columns.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-xs3">
                        <label class="layui-form-label">申请人：</label>
                        <div class="layui-input-block">
                            <input type="text" autocomplete="off" name="createName" id="person_in_charge" class="layui-input layui-bg-gray" readonly  value="${empty apply ? user.userName:apply.createName}">
                        </div>
                    </div>
                    <div class="layui-col-xs3">
                        <label class="layui-form-label">申请时间：</label>
                        <div class="layui-input-block">
                            <input type="text" autocomplete="off" id="createTime" name="createTime" class="layui-input layui-bg-gray" value="${createTime}" readonly>
                        </div>
                    </div>
                    <div class="layui-col-xs12">
                        <label class="layui-form-label">备注：</label>
                        <div class="layui-input-block ">
                            <input type="text" name="remarks" autocomplete="off" placeholder="" class="layui-input" value="${apply.remarks}">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-card">

            <blockquote class="layui-elem-quote">物料清单</blockquote>
            <div class="layui-card-body ">
                <div class="layui-row layui-col-space12 layui-form-item">
                    <div class="layui-col-xs12 mb-10 pr-30 pl-30">

                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th style="width: 5%">序号</th>
                                <th style="width: 18%">物料类型</th>
                                <th style="width: 20%">物料规格</th>
                                <th style="width: 10%">备货数量</th>
                                <th style="width: 20%">备注</th>
                                <th style="width: 15%">操作</th>
                            </tr>
                            </thead>
                            <tbody id="materialBody">
                            <c:if test="${not empty details}">
                                <c:forEach items="${details}" var="de" varStatus="vs">
                                    <tr class="materialtr">
                                        <td>${vs.count}</td>
                                        <td>
                                            <select class="materialType" name="materialType" lay-filter="materialType">
                                                <option value="">请选择</option>
                                                <%--<c:if test="${'1' eq apply.fittingType}">--%>
                                                    <option value="${de.columns.material_type_id}" selected>${de.columns.material_type}</option>
                                               <%-- </c:if>
                                                <c:if test="${'0' eq apply.fittingType}">--%>
                                                     <c:forEach var="type" items="${typeList}">
                                                         <option value="${type.columns.id}"  <c:if test="${de.columns.material_type_id eq type.columns.id}">selected</c:if>>${type.columns.name}</option>
                                                     </c:forEach>
                                               <%-- </c:if>--%>
                                            </select>
                                        </td>
                                        <td>
                                            <select class="materialSpecs" name="materialSpecs">
                                                <option value="${de.columns.material_spec}" selected>${de.columns.material_spec}<c:if test="${'组件' eq de.columns.material_type}">W</c:if></option>
                                            </select>
                                        </td>
                                        <td><input type="text" class="layui-input" name="amount" value="${de.columns.amount}"  onkeyup="value=(value.replace(/\D/g,'')==''?'':parseInt(value))"/></td>
                                        <td><input type="text" class="layui-input" name="remark" value="${de.columns.remark}" /></td>
                                        <td>
                                            <button type="button" class="layui-btn layui-btn-sm layui-btn-danger addDaili <c:if test="${!vs.last}">layui-hide</c:if>" onclick="addtr(this)">添加</button>
                                            <button type="button" class="layui-btn layui-btn-sm layui-btn-danger deleteBut <%--<c:if test="${vs.count==1}">layui-hide</c:if>--%> " onclick="delete1(this)">删除</button>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty details}">
                                <tr class="materialtr">
                                    <td>1</td>
                                    <td >
                                        <select class="materialType" name="materialType" lay-filter="materialType" >
                                            <option value="">请选择</option>
                                            <option value="${typeZ.columns.id}">${typeZ.columns.name}</option>
                                            <c:forEach var="type" items="${typeList}">
                                                <option value="${type.columns.id}">${type.columns.name}</option>
                                            </c:forEach>
                                        </select>
                                    </td>
                                    <td>
                                        <select class="materialSpecs" name="materialSpecs">
                                        </select>
                                    </td>
                                    <td><input type="text" class="layui-input" name="amount"  onkeyup="value=(value.replace(/\D/g,'')==''?'':parseInt(value))"/></td>
                                    <td><input type="text" class="layui-input" name="remark" /></td>
                                    <td>
                                        <button type="button" class="layui-btn layui-btn-sm layui-btn-danger addDaili" onclick="addtr(this)">添加</button>
                                        <button type="button" class="layui-btn layui-btn-sm layui-btn-danger deleteBut layui-hide" onclick="delete1(this)">删除</button>
                                    </td>
                                </tr>
                            </c:if>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
       <%-- <div class="layui-card">
            <blockquote class="layui-elem-quote">非标准物料</blockquote>
            <div class="layui-card-body ">
                <div class="layui-col-xs12 mb-10 pr-30">
                    <div class="layui-inline layui-col-md3 layui-col-sm3">
                        <label class="layui-form-label">代码：</label>
                        <div class="layui-input-block">
                            <div id="code"></div>
                        </div>
                    </div>
                    <div class="layui-inline layui-col-md3 layui-col-sm3">
                        <input type="button" class="layui-btn layui-btn-sm ml-10 mt-5" id="importPlan" value="批量导入"/>
                    </div>
                </div>
                <div class="layui-row layui-col-space12 layui-form-item">
                    <div class="layui-col-xs12 mb-10 pr-30 pl-30">

                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>物料代码</th>
                                <th>物料名称</th>
                                <th>物料类型</th>
                                <th>物料品牌</th>
                                <th>物料规格</th>
                                <th>申请数量</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="optionalMaterialBody">

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>--%>

        <div class="layui-form-item operate-footer" style="text-align: center;">
            <input type="button" lay-submit lay-filter="templeSave" id="templeSave" class="layui-btn" value="暂存">
            <input type="button" lay-submit lay-filter="save" id="save" class="layui-btn " value="提交">
            <input type="button"   value="取消" class="layui-btn layui-btn-primary " onclick="closeDiv();" >
        </div>

    </div>
    <%--<div class="mt-10 layui-col-sm1 text-c">
        <input type="button" lay-submit lay-filter="save" id="save" class="layui-btn " value="保存">
    </div>--%>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/xm-select.js"></script>
<script type="text/javascript">
    //初始数据
    var $form;
    var form;
    var $;
    var imgs = '';
    var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    var matypeList ;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form', 'layedit', 'laydate', 'jquery', 'layer'], function () {
        $ = layui.jquery;
        form = layui.form;
        $form = $('form');

        var codeXm = xmSelect.render({
            el: '#code',
            name: 'code',
            radio: true,
            tips: '请输入查询',
            clickClose: true,
            filterable: true,
            remoteSearch: true,
            remoteMethod: function (val, cb, show) {
                searchVal(val, cb, {
                    code: val,
                    attribute: '1'
                }, 'code');
            },
            on: function (data) {
                if (data.isAdd && data.arr.length > 0) {
                    appendTr(data);
                }
            }
        });

        function appendTr(data) {
            var d = data.arr[0].origin;
            var html = '<tr>'
                + '<td data-id="' + d.id + '" ></td>'
                + '<td>' + d.code + '</td>'
                + '<td>' + d.material_name + '</td>'
                + '<td>' + d.material_type + '</td>'
                + '<td>' + d.material_brand + '</td>'
                + '<td>' + d.material_specs + '</td>'
                + '<td><input type="text" class="layui-input" name="amount" lay-verify="required" /></td>'
                + '<td><button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick="del(this)">删除</button></td>'
                + '</tr>';

            var $trs ;
            if(d.type =='1'){
                //自选物料
                $trs = $('#optionalMaterialBody>tr');
            } else {
                return;
            }
            var exist = false;
            for (var i = 0; i < $trs.length; i++) {
                var $tr = $trs.eq(i);
                var id = $tr.find('td:first').data('id');
                if (id === d.id) {
                    exist = true;
                    break;
                }
            }
            if (!exist) {
                if(d.type =='1'){
                    $('#optionalMaterialBody').append(html);
                    appendOpSort();
                }
            } else {
                layer.msg('物料已存在');
            }
            data.arr.length = 0;
            codeXm.reset();
            // descXm.reset();
        }

        window.del = function(obj){
            $(obj).closest('tr').remove();
        }

        $('#importPlan').click(function(){

            layer.open({
                title: '导入物料',
                type: 2,
                area: ['550px', '300px'],
                content: '${ctx}/material/apply/ImportMaterialForm'
            });
        });

        window.importMaterialApply = function(data){

            var html = "";
            var zizhuhtml ="";
            var ziin=1;
            var inva=1;
            for(var i=0; i<data.materialList.length; i++){
                var d = data.materialList[i];
                if(d.materialAttribute=='1'){
                    zizhuhtml += '<tr>'
                        + '<td data-id="' + d.materialId + '" >' + ziin + '</td>'
                        + '<td>' + d.code + '</td>'
                        + '<td>' + d.name + '</td>'
                        + '<td>' + d.type + '</td>'
                        + '<td>' + d.materialBrand + '</td>'
                        + '<td>' + d.materialSpecs + '</td>'
                        + '<td><input type="text" class="layui-input" name="amount" lay-verify="required" value="'+d.amount+'"/></td>'
                        + '<td><button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick="del(this)">删除</button></td>'
                        + '</tr>';
                    ziin ++;
                }

            }

            $('#optionalMaterialBody').empty().append(zizhuhtml);
        };

        function searchVal(val, cb, searchData, filed) {
            if (!isBlank(val)) {
                $.ajax({
                    type: 'post',
                    url: '${ctx}/material/apply/findCanApplyMaterials',
                    data: searchData,
                    async: false,
                    dataType: 'json',
                    success: function (d) {
                        var arr = [];
                        for (var i = 0; i < d.length; i++) {
                            var data = {};
                            data.name = d[i][filed];
                            data.value = d[i].id;
                            data.origin = d[i];
                            arr.push(data);
                        }
                        cb(arr);
                    }
                });
            } else {
                cb([]);
            }
        }

        function appendOpSort() {
            $('#optionalMaterialBody>tr').each(function (i) {
                $(this).find('td:first').html(i + 1);
            });
        }

        form.on('select(fittingType)',function(data){
           var value = $(data.elem).find("option:selected").val();
            if(isBlank(value)){
                return
            }
            var html = '<option value="">请选择</option>';
            if("0" == value){
                <c:forEach var="type" items="${typeList}">
                html += '<option value="${type.columns.id}">${type.columns.name}</option>';
                </c:forEach>
            }else if("1" == value){
                html += '<option value="${typeZ.columns.id}">${typeZ.columns.name}</option>';
            }
            $(".materialType").html("");
            $(".materialType").append(html);
            form.render('select');
        })


        form.on('submit(save)', function (data) {
            var $trs = $('#materialBody>tr');

            var $trszi = $('#optionalMaterialBody>tr');
            if ($trs.length === 0 && $trszi.length === 0) {
                layer.msg('请添加物料');
                return;
            }
            var arr = [];
            for (var i = 0; i < $trs.length; i++) {
                var obj = {};
                var $tr = $trs.eq(i);
                var materialType = $tr.find('select[name=materialType]').find('option:selected').text();
                if (isBlank(materialType)) {
                    continue;
                }
                var materialTypeId = $tr.find('select[name=materialType]').find('option:selected').val();
                obj.materialType = materialType;
                obj.materialTypeId = materialTypeId;
                var materialSpecs = $tr.find('select[name=materialSpecs]').val();
                if (isBlank(materialSpecs)) {
                    continue;
                }
                obj.materialSpecs = $tr.find('select[name=materialSpecs]').val();
                obj.amount = $tr.find('input[name=amount]').val();
                if (isBlank(obj.amount)) {
                    layer.msg('第' + (i + 1) + '行申请数量为空');
                    return;
                }
                if (!/^\d+(\.\d{1,2})?$/.test(obj.amount)) {
                    layer.msg('第' + (i + 1) + '行申请数量格式不正确');
                    return;
                }
                var remark= $tr.find('input[name=remark]').val();
                obj.remark=remark;
                arr.push(obj);
            }
            /*for (var i = 0; i < $trszi.length; i++) {
                var obj = {};
                var $tr = $trszi.eq(i);
                var $fisrtTd = $tr.find('td:first');
                obj.targetId = $fisrtTd.data('id');
                obj.amount = $tr.find('input[name=amount]').val();
                if (!/^\d+(\.\d{1,2})?$/.test(obj.amount)) {
                    layer.msg('第' + (i + 1) + '行申请数量格式不正确');
                    return;
                }
                arr.push(obj);
            }*/
            if (arr.length < 1) {
                layer.msg('请添加物料');
                return;
            }
            var inWarehouseId = data.field.inWarehouseId;
            $.ajax({
                url: '${ctx}/fittingStockUp/saveFittingStockApply',
                type: 'post',
                contentType: 'application/json',
                data: JSON.stringify({
                    actionType:'2',
                    id: '${id}',
                    inWarehouseId: inWarehouseId,
                    remarks: data.field.remarks,
                    createName:data.field.createName,
                    materialType:data.field.materialType,
                    createTime:data.field.createTime,
                    fittingType:data.field.fittingType,
                    details: arr
                }),
                dataType: 'JSON',
                success: function (res) {
                    if (res.code === "200") {
                        layer.msg("保存成功", {time: 2000}, function(){
                            closeDiv();
                            parent.table.reload('test-table-reload');
                        });
                    }else {
                        layer.msg("保存失败"+res.errMsg, {time: 3000});
                    }
                },
                error: function (data) {
                }
            });
        });

        form.on('submit(templeSave)', function (data) {
            var $trs = $('#materialBody>tr');
            if ($trs.length > 0) {
                var arr = [];
                for (var i = 0; i < $trs.length; i++) {
                    var obj = {};
                    var $tr = $trs.eq(i);
                    var materialType = $tr.find('select[name=materialType]').find('option:selected').text();
                    if (isBlank(materialType)) {
                        continue;
                    }
                    var materialTypeId = $tr.find('select[name=materialType]').find('option:selected').val();
                    obj.materialType = materialType;
                    obj.materialTypeId=materialTypeId;
                    var materialSpecs = $tr.find('select[name=materialSpecs]').val();
                    if (isBlank(materialSpecs)) {
                        continue;
                    }
                    obj.materialSpecs = $tr.find('select[name=materialSpecs]').val();
                    obj.amount = $tr.find('input[name=amount]').val();
                    if (isBlank(obj.amount)) {
                        layer.msg('第' + (i + 1) + '行申请数量为空');
                        return;
                    }
                    if (!/^\d+(\.\d{1,2})?$/.test(obj.amount)) {
                        layer.msg('第' + (i + 1) + '行申请数量格式不正确');
                        return;
                    }
                    var remark= $tr.find('input[name=remark]').val();
                    obj.remark=remark;
                    arr.push(obj);
                }
            }

          /*  for (var i = 0; i < $trszi.length; i++) {
                var obj = {};
                var $tr = $trszi.eq(i);
                var $fisrtTd = $tr.find('td:first');
                obj.targetId = $fisrtTd.data('id');
                obj.amount = $tr.find('input[name=amount]').val();
                if (!/^\d+(\.\d{1,2})?$/.test(obj.amount)) {
                    layer.msg('第' + (i + 1) + '行申请数量格式不正确');
                    return;
                }
                arr.push(obj);
            }
            if (arr.length < 1) {
                layer.msg('请添加物料');
                return;
            }*/
            var inWarehouseId = data.field.inWarehouseId;
            $.ajax({
                url: '${ctx}/fittingStockUp/saveFittingStockApply',
                type: 'post',
                contentType: 'application/json',
                data: JSON.stringify({
                    actionType:'1',
                    id: '${id}',
                    inWarehouseId: inWarehouseId,
                    remarks: data.field.remarks,
                    createName:data.field.createName,
                    materialType:data.field.materialType,
                    createTime:data.field.createTime,
                    fittingType:data.field.fittingType,
                    details: arr
                }),
                dataType: 'JSON',
                success: function (res) {
                    if (res.code === "200") {
                        layer.msg("保存成功", {time: 2000}, function(){
                            closeDiv();
                            parent.table.reload('test-table-reload');
                        });
                    }else {
                        layer.msg("保存失败"+res.errMsg, {time: 2500});
                    }
                },
                error: function (data) {
                }
            });
        });

        form.on('select(province)', function(data){
            var province = $(data.elem).find("option:selected").val();
            provinceOrder(province);
        });
        form.on('select(city)', function(data){
            var city = $(data.elem).find("option:selected").val();
            cityOrder(city);

        });

        form.on('select(materialType)', function (data) {
            var type = $(data.elem).val();
            if (isBlank(type)) {
                $(this).parents(".materialtr").find('.materialSpecs').empty();
                form.render('select');
                return;
            }
            var that_ = $(this);
            $.ajax({
                type:"POST",
                url:'${ctx}/material/apply/findElectricMaterialDate',
                data:{
                    type:type
                },
                success:function(result){
                    var html ="<option value=''>请选择</option>";
                    for(var i=0;i<result.length;i++){
                        var specs = result[i];
                        if (type == '3') {
                            html += '<option value="'+specs+'" >'+specs+'W</option>';
                        } else {
                            html += '<option value="'+specs+'" >'+specs+'</option>';
                        }
                    }
                    that_.parents(".materialtr").find('.materialSpecs').empty().append(html);
                    form.render('select');
                }
            });

        })

        function provinceOrder(province,_city){
            $("#city").empty();
            $("#area").empty();
            if(isBlank(province)){
                $("#city").append("<option value=''>请选择</option>");
                return "";
            }
            $.ajax({
                type:"POST",
                url:"${ctx}/main/redirect/getCitysByProName",
                data:{
                    province:province
                },
                success:function(result){
                    if(result =="205"){
                        layer.msg("暂无数据!")
                        return
                    }
                    var html =" <option value=''>请选择</option>";
                    for(var i=0;i<result.length;i++){
                        var city = result[i];
                        if(city.columns.CityName==_city){
                            html =html+ '<option value="'+city.columns.CityName+'" selected title="'+city.columns.CityID+'">'+city.columns.CityName+'</option>';
                        }else{
                            html =html+ '<option value="'+city.columns.CityName+'" <c:if test=""> selected</c:if> title="'+city.columns.CityID+'">'+city.columns.CityName+'</option>';
                        }
                    }
                    console.log(_city)
                    if(!isBlank(_city)){
                        $("#city").val(_city)
                    }
                    $("#city").append(html);
                    form.render('select');
                }
            });

        }

        function cityOrder(city,arean){
            $("#area").empty()
            if(isBlank(city)){
                $("#area").append("<option value=''>请选择</option>");
                return "";
            }
            $.ajax({
                type:"POST",
                url:"${ctx}/main/redirect/getAreaByCityName",
                data:{
                    city:city
                },
                success:function(result){
                    if(result =="205"){
                        layer.msg("暂无数据!")
                        return
                    }
                    var html ="<option value=''>请选择</option>";
                    for(var i=0;i<result.length;i++){
                        var area = result[i];
                        html =html+ '<option value="'+area.columns.DistrictName+'" >'+area.columns.DistrictName+'</option>';
                    }
                    $("#area").append(html);
                    if(!isBlank(arean)){
                        $("#area").val(arean)
                    }

                    form.render('select');
                }
            });

        }
    })

    function closeDiv() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

    // 新增组件
    function addtr(that) {
        var fittingType= $("#fittingType").find("option:selected").val();
        $(that).addClass("layui-hide");
        $(that).next().removeClass('layui-hide');
        var html = '';
        html += '<tr class="materialtr">';
        html += '<td></td>';
        html += '<td >';
        html += '<select class="materialType" name="materialType" lay-filter="materialType">';
        html += '<option value="">请选择</option>';
        html += '<option value="${typeZ.columns.id}">${typeZ.columns.name}</option>';
        <c:forEach var="type" items="${typeList}">
        html += '<option value="${type.columns.id}">${type.columns.name}</option>';
        </c:forEach>
        html += '</select>';
        html += '</td>';
        html += '<td>';
        html += '<select class="materialSpecs" name="materialSpecs">';
        html += '</select>';
        html += '</td>';
        html+=`<td><input type="text" class="layui-input" name="amount" onkeyup="value=(value.replace(/\D/g,'')==''?'':parseInt(value))"/></td>`;
      /*  html += '<td><input type="text" class="layui-input" name="amount" /></td>';*/
        html += '<td><input type="text" class="layui-input" name="remark" /></td>';
        html += '<td><button type="button" class="layui-btn layui-btn-sm layui-btn-danger addDaili" onclick="addtr(this)">添加</button>';
        html += '<button type="button" class="layui-btn layui-btn-sm layui-btn-danger deleteBut" onclick="delete1(this)">删除</button></td>';
        html += '</tr>';
        $("#materialBody").append(html);
        form.render('select');
        appendSort();
    }

    function delete1(that) {
        if (!$(that).parents(".materialtr").next().hasClass("materialtr")) {
            $(that).parents(".materialtr").prev().find(".addDaili").removeClass("layui-hide");
        }
        $(that).closest('tr').remove();
        if ($('#materialBody>tr').length < 2) {
            $('#materialBody>tr').find(".addDaili").removeClass("layui-hide");
            $('#materialBody>tr').find(".deleteBut").addClass("layui-hide");
        }
        appendSort();
    }

    function appendSort() {
        $('#materialBody>tr').each(function (i) {
            $(this).find('td:first').html(i + 1);
        });
    }

</script>
</body>
</html>

