<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.censoft.common.base.Pub" %>
<%@ page import="com.censoft.common.db.ConnectionFactory" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.util.*" %>
<%
    Connection conn = null;
    Vector v_list;
    Hashtable ht = new Hashtable();
    Pub pub = new Pub();
    ConnectionFactory cf = new ConnectionFactory();
    String update_id = pub.trimNull(request.getParameter("update_id"));
    String action="add";
	String get_time="";
	String use_dept="";
    if(!"".equals(update_id)){
        action="update";
    }
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        v_list=cf.doQuery(conn,"select * from zc_register where reg_id=? ",null,new Object[]{update_id});
        if (v_list == null) {
            out.println("查询出错");
            return;
        }
        if (v_list.size() > 0) {
            ht = (Hashtable) v_list.get(0);
			get_time=pub.trimNull((String)ht.get("get_time"));
			if(!"".equals(get_time)){
				get_time="&nbsp;&nbsp;取得时期："+get_time;
			}
			use_dept=pub.trimNull((String)ht.get("use_dept"));
			if(!"".equals(use_dept)){
				use_dept="&nbsp;&nbsp;使用部门："+use_dept;
			}
        }
    } catch (Exception e) {
        try {
            if(conn != null){
                conn.rollback();
            }
        } catch (SQLException e1) {
            e1.printStackTrace();
        }
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>
<style>
    .col-sm-1{width: 12%;}
</style>
<article class="page-container" style="overflow: hidden;">
    <form class="form form-horizontal" id="form-admin-add">
        <input type="hidden" name="action" value="<%=action%>"/>
        <input type="hidden" name="update_id" value="<%=update_id%>"/>
        <input type="hidden" name="counts_check" value="<%=pub.trimNull((String)ht.get("counts"))%>"/>
        <div class="cl pd-5  bk-gray divOverflow" style="overflow:hidden;margin-bottom: 20px;">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">资产名称：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="zc_name" id="zc_name"  value="<%=pub.trimNull((String)ht.get("zc_name"))%>" class="input-text ">
                </div>
                <label class="form-label col-xs-4 col-sm-1">国标大类：</label>
                <div class="formControls col-xs-8 col-sm-2" id="zc_gj_type">
                    <script>
                        var value='<%=pub.trimNull((String)ht.get("zc_gj_type"))%>';
						var reg_id='<%=update_id%>';
                        value=encodeURI(encodeURI(value));
                        $.post("../zd/zd_view_list.jsp?value="+value+"&name_id=zc_gj_type&reg_id="+reg_id+"&zd_e_name=gjdl&math="+Math.random(),function(data){
                                document.getElementById("zc_gj_type").innerHTML=data;
                            }
                        );
                    </script>
                </div>
                <label class="form-label col-xs-4 col-sm-1">资产分类：</label>
                <div class="formControls col-xs-8 col-sm-2" id="zc_fl">
                    <script>
                        var value='<%=pub.trimNull((String)ht.get("zc_fl"))%>';
						var reg_id='<%=update_id%>';
                        value=encodeURI(encodeURI(value));
                        $.post("../zd/zd_view_list.jsp?value="+value+"&name_id=zc_fl&reg_id="+reg_id+"&zd_e_name=zc_fl&math="+Math.random(),function(data){
                                document.getElementById("zc_fl").innerHTML=data;
                            }
                        );
                    </script>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">资产分类代码：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="zc_fl_code" id="zc_fl_code" value="<%=pub.trimNull((String)ht.get("zc_fl_code"))%>" class="input-text ">
                </div>
                <label class="form-label col-xs-4 col-sm-1">设备类型：</label>
                <div class="formControls col-xs-8 col-sm-2" id="sb_type">
                    <script>
                        var value='<%=pub.trimNull((String)ht.get("sb_type"))%>';
						var reg_id='<%=update_id%>';
                        value=encodeURI(encodeURI(value));
                        $.post("../zd/zd_view_list.jsp?value="+value+"&name_id=sb_type&reg_id="+reg_id+"&zd_e_name=sb_type&math="+Math.random(),function(data){
                                document.getElementById("sb_type").innerHTML=data;
                            }
                        );
                    </script>
                </div>
                <label class="form-label col-xs-4 col-sm-1">品牌：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="pinpai" value="<%=pub.trimNull((String)ht.get("pinpai"))%>" class="input-text">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">规格型号：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="gg_type" id="gg_type" value="<%=pub.trimNull((String)ht.get("gg_type"))%>" class="input-text ">
                </div>
                <label class="form-label col-xs-4 col-sm-1">价值类型：</label>
                <div class="formControls col-xs-8 col-sm-2" id="jz_type">
                    <script>
                        var value='<%=pub.trimNull((String)ht.get("jz_type"))%>';
						var reg_id='<%=update_id%>';
                        value=encodeURI(encodeURI(value));
                        $.post("../zd/zd_view_list.jsp?value="+value+"&name_id=jz_type&reg_id="+reg_id+"&zd_e_name=jz_type&math="+Math.random(),function(data){
                                document.getElementById("jz_type").innerHTML=data;
                            }
                        );
                    </script>
                </div>
                <label class="form-label col-xs-4 col-sm-1">价   值：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="jiazhi" id="jiazhi" value="<%=pub.trimNull((String)ht.get("jiazhi"))%>" class="input-text">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">资产来源：</label>
                <div class="formControls col-xs-8 col-sm-2" id="zc_resource">
                    <script>
                        var value='<%=pub.trimNull((String)ht.get("zc_resource"))%>';
						var reg_id='<%=update_id%>';
                        value=encodeURI(encodeURI(value));
                        $.post("../zd/zd_view_list.jsp?value="+value+"&name_id=zc_resource&reg_id="+reg_id+"&zd_e_name=zc_resource&math="+Math.random(),function(data){
                                document.getElementById("zc_resource").innerHTML=data;
                            }
                        );
                    </script>
                </div>
                <label class="form-label col-xs-4 col-sm-1">数量：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="counts" id="counts" value="<%=pub.trimNull((String)ht.get("counts"))%>" class="input-text ">
                </div>
                <label class="form-label col-xs-4 col-sm-1">管理部门：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="dept" value="<%=pub.trimNull((String)ht.get("dept"))%>" class="input-text">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">出厂日期：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="chuchang_date" class="input-text Wdate"  autocomplete="off" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="<%=pub.trimNull((String)ht.get("chuchang_date"))%>" >
                </div>
                <label class="form-label col-xs-4 col-sm-1">财务入账日期：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="cw_date" value="<%=pub.trimNull((String)ht.get("cw_date"))%>" class="input-text Wdate"  autocomplete="off" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})">
                </div>
                <label class="form-label col-xs-4 col-sm-1">会计凭证号：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="kj_id" value="<%=pub.trimNull((String)ht.get("kj_id"))%>" class="input-text">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">财政性资金：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="czx_money" value="<%=pub.trimNull((String)ht.get("czx_money"))%>" class="input-text ">
                </div>
                <label class="form-label col-xs-4 col-sm-1">非财政性资金：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="fczx_money" value="<%=pub.trimNull((String)ht.get("fczx_money"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">累计折旧：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="ljzj" value="<%=pub.trimNull((String)ht.get("ljzj"))%>" class="input-text">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">净    值：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="jingzhi" value="<%=pub.trimNull((String)ht.get("jingzhi"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">已提月折旧：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="ytyzj" value="<%=pub.trimNull((String)ht.get("ytyzj"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">是否利旧：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="is_lj" value="<%=pub.trimNull((String)ht.get("is_lj"))%>" class="input-text ">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">备注：</label>
                <div class="formControls col-xs-8 col-sm-9">
                <textarea name="beizhu" cols="" rows="2" class="textarea" placeholder=""
                          dragonfly="true"><%=pub.trimNull((String) ht.get("beizhu"))%><%=get_time%><%=use_dept%></textarea>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">车辆识别号：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="car_id" value="<%=pub.trimNull((String)ht.get("car_id"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">车辆用途分类：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="car_type" value="<%=pub.trimNull((String)ht.get("car_type"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">发动机号：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="car_fdj_id" value="<%=pub.trimNull((String)ht.get("car_fdj_id"))%>" class="input-text ">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-1">存放地：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" name="car_address" value="<%=pub.trimNull((String)ht.get("car_address"))%>" class="input-text ">
                </div>
            </div>
        </div>
    </form>
    <div class="cl mb-10  bk-gray " style="height: 50px;">
        <div class="col-sm-3 pd-10" style="width:100%;text-align: center;">
            <input class="btn btn-primary radius btn-green" type="button" onclick="javascript:saveForm();" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
        </div>
    </div>
</article>
<script>
    function saveForm(){
        if($("#zc_name").val()==''){
            layer.msg('资产名称不能为空', {
                icon: 5,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            });
            return false;
        }if($("#counts").val()==''){
            layer.msg('资产数量不能为空', {
                icon: 5,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            });
            return false;
        }if($("#jiazhi").val()==''){
            layer.msg('资产价值不能为空', {
                icon: 5,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            });
            return false;
        }
        $.ajax({
            type: "POST",
            url: "./action.jsp",
            data: $('#form-admin-add').serialize(),
            success: function (msg) {
                if (msg.indexOf("success") >= 0) {
                    layer.msg('操作成功!', {icon: 1, time: 1000},
                        function () {
                            parent.searchModel();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                } else {
                    layer.msg('操作失败'+msg, {
                        icon: 5,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                    });
                }
            }
        });
    }
</script>