<%--
  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";
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        v_list=cf.doQuery(conn,"select t1.zc_id,zc_name,pinpai,gg_type,t2.wx_id,sb_dept,sb_user,sb_user_tel" +
                ",wx_user,wx_user_tel,wx_time,gz_reason,wx_action" +
                " from zc_register t1  join zc_wx t2 on t1.zc_id=t2.zc_id" +
                " where t2.wx_id=? ",null,new Object[]{update_id});
        if (v_list == null) {
            out.println("查询出错");
            return;
        }
        if (v_list.size() > 0) {
            ht = (Hashtable) v_list.get(0);
            String wx_id=pub.trimNull((String)ht.get("wx_id"));
            if(!"".equals(wx_id)){
                action="update";
            }
        }
    } 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="opt" value="wx"/>
        <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-3">
                    <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-3">
                    <input type="text" name="zc_id" id="zc_id"  value="<%=pub.trimNull((String)ht.get("zc_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-3">
                    <input type="text" name="pinpai" value="<%=pub.trimNull((String)ht.get("pinpai"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">规格型号：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <input type="text" name="gg_type" id="gg_type" value="<%=pub.trimNull((String)ht.get("gg_type"))%>" 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-3">
                    <input type="text" name="sb_dept" value="<%=pub.trimNull((String)ht.get("sb_dept"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">申报人：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <input type="text" name="sb_user" id="sb_user" value="<%=pub.trimNull((String)ht.get("sb_user"))%>" 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-3">
                    <input type="text" name="sb_user_tel" value="<%=pub.trimNull((String)ht.get("sb_user_tel"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">维修人：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <input type="text" name="wx_user" id="wx_user" value="<%=pub.trimNull((String)ht.get("wx_user"))%>" 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-3">
                    <input type="text" name="wx_user_tel" value="<%=pub.trimNull((String)ht.get("wx_user_tel"))%>" class="input-text">
                </div>
                <label class="form-label col-xs-4 col-sm-1">维修时间：</label>
                <div class="formControls col-xs-8 col-sm-3">
                    <input type="text" name="wx_time" class="input-text Wdate"  autocomplete="off" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="<%=pub.trimNull((String)ht.get("wx_time"))%>" >
                </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="gz_reason" cols="" rows="2" class="textarea" placeholder=""
                          dragonfly="true"><%=pub.trimNull((String) ht.get("gz_reason"))%></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-9">
                <textarea name="wx_action" cols="" rows="2" class="textarea" placeholder=""
                          dragonfly="true"><%=pub.trimNull((String) ht.get("wx_action"))%></textarea>
                </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(){
        $.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>