<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>备件信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
</head>
<body>
<div class="layui-card md-0">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="layuiadmin-form-admin" >
            <div class="layui-form-item layui-col-xs12">
                <div class="layui-col-xs6 mb-5">
                    <input class="layui-hide" id="callId" value="${call.id}">
                    <input class="layui-hide" id="orderId" value="${order.id}">
                    <label class="layui-form-label">服务时长：</label>
                    发布-完工：${hour} 小时
                </div>
                <div class="layui-col-xs6 mb-5">
                    <label class="layui-form-label">里程参考：</label>
                    ${map.address}
                    <input type="hidden"  id="mileageHide" value="${map.address}" >
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-lg4 layui-col-sm4">
                        <label class="layui-form-label"><i class="mark">*</i>服务态度：</label>
                        <div class="layui-input-inline">
                            <select name="serviceAttitude"  lay-verify="required">
                                <option value="5" <c:if test="${call.serviceAttitude  eq 5}">selected</c:if>>十分满意</option>
                                <option value="4" <c:if test="${call.serviceAttitude  eq 4}">selected</c:if>>满意</option>
                                <option value="3" <c:if test="${call.serviceAttitude  eq 3}">selected</c:if>>一般</option>
                                <option value="2" <c:if test="${call.serviceAttitude  eq 2}">selected</c:if>>不满意</option>
                                <option value="1" <c:if test="${call.serviceAttitude  eq 1}">selected</c:if>>十分不满意</option>
                      <%--          <option value="6" <c:if test="${call.serviceAttitude  eq 6}">selected</c:if>>无效回访</option>
                                <option value="7" <c:if test="${call.serviceAttitude  eq 7}">selected</c:if>>回访未成功</option>--%>
                                //1.十分不满意 2.不满意 3.一般 4.满意 5.十分满意6.无效回访7.回访未成功

                            </select>
                        </div>
                    </div>
                    <div class="layui-col-lg4 layui-col-sm4">
                        <label class="layui-form-label">多次上门：</label>
                        <div class="layui-input-inline">
                            <select name="visitMany" id="visitMany" >
                                <option value="0" <c:if test="${call.visitMany  eq 0}">selected</c:if> >否</option>
                                <option value="1" <c:if test="${call.visitMany  eq 1}">selected</c:if> >是</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-col-lg7 " >
                    <div class="layui-col-xs12 mb-10">
                        <label class="layui-form-label">回访内容：</label>
                        <div class="layui-input-block">
                            <textarea name="remarks" placeholder="" value="${call.remarks}" class="layui-textarea" >${call.remarks}</textarea>
                        </div>
                    </div>

                </div>
                <div class="layui-form-item">
                    <div class="layui-col-lg4 layui-col-sm4">
                        <label class="layui-form-label">收款总额：</label>
                        <div class="layui-input-inline">
                            <input type="text"   class="layui-input layui-bg-gray" value="${order.totalCollections}" disabled>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-lg4 layui-col-sm4">
                        <label class="layui-form-label">回访总额：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="visitTotal" value="${call.visitTotal}" class="layui-input" id="visitTotal" >
                        </div>
                    </div>
                    <div class="layui-col-lg3 layui-col-sm3">
                        <label class="layui-form-label"><i class="mark">*</i>回访结果：</label>
                        <div class="layui-input-inline">
                            <select name="result"  lay-verify="required" lay-filter="result">
                                <option value="">请选择</option>
                                <option value="1" <c:if test="${call.result  eq 1}">selected</c:if>>已回访</option>
                                <option value="2" <c:if test="${call.result  eq 2}">selected</c:if> >仍需上门</option>
                                <option value="3"  <c:if test="${call.result  eq 3}">selected</c:if> >无人接听</option>
                                <option value="4"  <c:if test="${call.result  eq 4}">selected</c:if> >回访驳回</option>
                             <%--   <option value="5"  <c:if test="${call.result  eq 5}">selected</c:if> >多次回访</option>--%>
                            </select>
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item text-c"  >
                <button class="layui-btn" lay-submit="callOrder" id="sureSubmit" lay-filter="callOrder">保存</button>
                <button class="layui-btn" onclick="cancel()">取消</button>
            </div>
        </form>
    </div>
</div>


<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script>
    var orderId = "${order.id}";
    layui.use(['form', 'jquery','laydate','upload'], function () {
        $ = layui.$
            , element = layui.element
            , form = layui.form
            , laydate = layui.laydate;


        form.on('submit(callOrder)',function(){
            var  cost =/^(\-)?\d+(.\d{1,2})?$/;
            var zhengshu=/^([1-9]\d*|[0]{1,1})$/;
            var id=$("#callId").val();
            var serviceAttitude = $("select[name='serviceAttitude']").val();
            var visitMany=$("#visitMany").val();
            var remarks=  $("textarea[name='remarks']").val();
            var visitTotal=$("#visitTotal").val();
            var result = $("select[name='result']").val();
            var res = result;
        /*    if(isBlank(remarks)){
                layer.msg("请输入回访内容!",{icon:2});
                return false
            }*/
            if(isBlank(result)){
                layer.msg("请输入回访结果!",{icon:2});
                return false
            }
            $.ajax({
                type:"POST",
                url:"${ctx}/callback/anewCallbackUpdate",
                data:{
                    id:id,
                    orderId:orderId,
                    serviceAttitude:serviceAttitude,
                    visitMany:visitMany,
                    remarks:remarks,
                    visitTotal:visitTotal,
                    result:result,
                },
                success:function(result){
                    console.log(result)
                    if(result.code =="200"){
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.msg('回访成功！', {icon:1,time:1000},function(){
                           parent.layer.close(index);
                            if (res == '2') {
                                parent.parent.location.reload(); //刷新父页面
                            } else {
                                parent.location.reload();
                            }
                        })
                    }else if (result.code=="401"){
                        layer.msg('回访失败,该工单不在待结算状态', {icon:2,time:1000});
                    } else{
                        layer.msg('回访失败,数据有误', {icon:2,time:1000});
                    }
                }
            });
            return false;

        })

    });

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }
    function cancel(){
        var index=parent.layer.getFrameIndex(window.name);//获取当前弹出层的层级
        parent.layer.close(index);//关闭弹出层
    }
</script>
</body>
</html>