From 585daa6db39559bae67a369667f3b8254e591112 Mon Sep 17 00:00:00 2001 From: zhaoxiaohao <279049017@qq.com> Date: Wed, 25 Nov 2020 09:13:05 +0800 Subject: [PATCH] 添加taocan 的功能,继续完善 --- kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/rechargeupdate.html | 984 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 984 insertions(+), 0 deletions(-) diff --git a/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/rechargeupdate.html b/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/rechargeupdate.html new file mode 100644 index 0000000..04662e6 --- /dev/null +++ b/kidgrow-web/kidgrow-web-manager/src/main/resources/static/pages/opration/rechargeupdate.html @@ -0,0 +1,984 @@ +<form id="recharge-form" lay-filter="recharge-form" class="layui-form"> + <div style="overflow-y: auto; height:700px;"> + <div class="layui-tab"> + <ul class="layui-tab-title"> + <li class="layui-this">合同信息</li> + </ul> + <div class="layui-tab-content" style="margin: 0px 0px -10px 0px;"> + <div class="layui-tab-item layui-show"> + + <div class="layui-form-item" style="margin-bottom: 10px;"> + <div class="layui-row"> + <div class="layui-col-sm5"> + <label class="layui-form-label" style="padding: 0;">医院名称</label> + <div class="layui-input-block"> + <input name="hospitalName" id="hospitalName" type="text" class="layui-input" + style="border: none; margin-top:-10px" readonly /> + </div> + </div> + <div class="layui-col-sm3"> + <label class="layui-form-label" style="padding: 0;">科室名称</label> + <div class="layui-input-block"> + <input name="departmentName" id="departmentName" + style="border: none; margin-top:-10px" readonly class="layui-input" /> + </div> + </div> + <div class="layui-col-sm2"> + <label class="layui-form-label" style="padding: 0;">服务人员</label> + <div class="layui-input-block"> + <input name="serverUserName" id="serverUserName" + style="border: none; margin-top:-10px;width: 120px;" readonly + class="layui-input" /> + </div> + </div> + </div> + </div> + + <div class="layui-form-item" style="margin-bottom: 10px;"> + <div class="layui-row"> + <div class="layui-col-sm5"> + <label class="layui-form-label" style="padding: 0;">地区</label> + <div class="layui-input-block"> + <input name="hospitalAreas" id="hospitalAreas" type="text" + style="border: none; margin-top:-10px" readonly class="layui-input" /> + </div> + </div> + <div class="layui-col-sm3"> + <label class="layui-form-label" style="padding: 0;">联系电话</label> + <div class="layui-input-block"> + <input name="hospitalTel" id="hospitalTel" type="text" class="layui-input" + style="border: none; margin-top:-10px" readonly /> + </div> + </div> + <div class="layui-col-sm2"> + <label class="layui-form-label" style="padding: 0;">联系人</label> + <div class="layui-input-block"> + <input name="hospitalLink" type="text" class="layui-input" + style="border: none; margin-top:-10px;" readonly /> + </div> + </div> + </div> + </div> + <div class="layui-form-item" style="margin-bottom: 10px;"> + <div class="layui-row"> + <div class="layui-col-sm6"> + <label class="layui-form-label" style="padding: 0;">合同名称</label> + <div class="layui-input-block"> + <input name="contractTitle" id="contractTitle" type="text" class="layui-input" + readonly style="border: none; margin-top:-10px" /> + </div> + </div> + <div class="layui-col-sm6"> + <label class="layui-form-label" style="padding: 0;">合同编号</label> + <div class="layui-input-block"> + <input name="contractNo" id="contractNo" type="text" class="layui-input" + style="border: none; margin-top:-10px" readonly /> + </div> + </div> + </div> + </div> + <div class="layui-form-item" style="margin-bottom: 10px;"> + <div class="layui-row"> + <div class="layui-col-sm6"> + <label class="layui-form-label" style="padding: 0;">软件服务周期:</label> + <!-- <div class="layui-col-sm3" style="margin-right: 30px;"> + <input autocomplete="off" name="contractBeginTime" id="contractBeginTime" + type="text" placeholder="请输开始时间" class="layui-input" readonly style="border: none; margin-top:-10px"/> + </div> + <div class="layui-col-sm3"> + <input autocomplete="off" name="contractEndTime" id="contractEndTime" type="text" + placeholder="请输入结束时间" class="layui-input" readonly style="border: none; margin-top:-10px" /> + </div> --> + <div class="layui-input-block"> + <input autocomplete="off" name="contractBeginTime" id="contractBeginTime" + type="text" placeholder="请输开始时间" class="layui-input" readonly + style="border: none; margin-top:-10px;display: inline-block;width: 46%;" /> + <input autocomplete="off" name="contractEndTime" id="contractEndTime" type="text" + placeholder="请输入结束时间" class="layui-input" readonly + style="border: none; margin-top:-10px;display: inline-block;width: 46%;" /> + </div> + </div> + <div class="layui-col-sm3"> + <label class="layui-form-label" style="padding: 0;">合同充值总量:</label> + <div class="layui-input-block"> + <input autocomplete="off" name="contractNum" id="contractNum" + onkeyup="this.value=this.value.replace(/[^\d]/g,'') " type="text" + class="layui-input" readonly style="border: none; margin-top:-10px" /> + </div> + </div> + <div class="layui-col-sm3"> + <label class="layui-form-label" style="padding: 0;">未充值量:</label> + <div class="layui-input-block"> + <span name="contractNum"></span> + <input autocomplete="off" name="contractNum_not" id="contractNum_not" + onkeyup="this.value=this.value.replace(/[^\d]/g,'') " type="text" + class="layui-input" readonly style="border: none; margin-top:-10px" /> + </div> + </div> + </div> + </div> + </div> + </div> + </div> + <div class="layui-tab" style="margin: 0px;"> + <ul class="layui-tab-title"> + <li class="layui-this">已充值产品</li> + </ul> + <div class="layui-tab-content" style="margin: -10px 0px -10px 0px;"> + <div class="layui-tab-item layui-show" style="padding-top: 0px;"> + <table class="layui-table" id="product-table-now" lay-filter="product-table-now" + style="margin: 0px;"> + </table> + </div> + </div> + </div> + + <div class="layui-tab" style="margin: 0px;"> + <ul class="layui-tab-title"> + <li class="layui-this">套餐列表</li> + <li>自定义充值</li> + </ul> + <div class="layui-tab-content" style="margin: -10px 0px -10px 0px;"> + <div class="layui-tab-item layui-show" style="padding-top: 0px;"> + <table class="layui-table" id="product-table" lay-filter="product-table" style="margin: 0px;"> + </table> + </div> + <div class="layui-tab-item"> + <div class="layui-form-item" style="margin: 10px 0px 0px 0px;"> + <div class="layui-row"> + <div class="layui-col-sm12"> + <label class="layui-form-label">充值名称:</label> + <div class="layui-input-inline"> + <input autocomplete="off" id="custom_proName" type="text" class="layui-input" + maxlength="50" value="1000" lay-verify="required" required /> + </div> + </div> + </div> + </div> + <div class="layui-form-item" style="margin: 10px 0px 0px 0px;"> + <div class="layui-row"> + <div class="layui-col-sm6"> + <label class="layui-form-label">读片充值量:</label> + <div class="layui-input-inline"> + <input autocomplete="off" id="custom_ailightCount" + onkeyup="this.value=this.value.replace(/[^\d]/g,'') " type="text" + class="layui-input" maxlength="50" value="1000" lay-verify="required" + required />张 + </div> + </div> + <div class="layui-col-sm6"> + <div class="layui-input-inline"> + <input type="radio" id="custom_isShare" name="gongxiang" value="1" title="是否共享" /> + </div> + </div> + </div> + </div> + <div class="layui-form-item" style="margin: 10px 0px 0px 0px;"> + <div class="layui-row"> + <div class="layui-col-sm6"> + <div class="layui-input-inline"> + <input type="radio" id="termType" name="termType" value="true" title="期限限制" /> + </div> + </div> + <div class="layui-col-sm6"> + <div class="layui-col-sm4" style="margin-right: 30px;"> + <input autocomplete="off" id="custom_beginTime" type="text" placeholder="请输开始时间" + class="layui-input" maxlength="50" /> + </div> + <div class="layui-col-sm4 "> + <input autocomplete="off" type="text" placeholder="请输入结束时间" id="custom_endTime" + class="layui-input" maxlength="50" /> + </div> + </div> + </div> + </div> + <div class="layui-form-item"> + <div class="layui-input-block" style="width: 50;"> + <input class="layui-btn" type="button" id="custom_submit" value="确定" /> + </div> + </div> + </div> + </div> + </div> + + <div class="layui-tab" style="margin: 0px;"> + <ul class="layui-tab-title"> + <li class="layui-this">待充值产品</li> + </ul> + <div class="layui-tab-content" style="margin: -10px 0px -10px 0px;"> + <div class="layui-tab-item layui-show" style="padding-top: 0px;"> + <table class="layui-table" id="product-table-temp" lay-filter="product-table-temp" + style="margin: 0px;"> + </table> + </div> + </div> + </div> + </div> + <div class="layui-form-item model-form-footer" style="margin-right: 20px;"> + <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button> + <button class="layui-btn permissions" permissions="product-rechage" lay-submit id="submit">确定充值</button> + </div> + <input type="hidden" value="" id="departmentId" name="departmentId" /> + <input type="hidden" value="" id="hospitalId" name="hospitalId" /> + <input type="hidden" value="" id="orgId" name="orgId" /> + <input type="hidden" value="" id="serverUserId" name="serverUserId" /> +</form> +<!-- 表格操作列 --> +<script type="text/html" id="product-tpl-bar-now"> + {{# if (d.ailightCount !=d.count){}} + {{# if (d.enabled){}} + <a class="layui-btn layui-btn-xs" lay-event="order_detail_enable">禁用</a> + {{# } else { }} + <a class="layui-btn layui-btn-disabled" >禁用</a> + {{#}}} + + {{# } else { }} + <a class="layui-btn layui-btn-xs" lay-event="order_detail_del">删除</a> + {{#}}} +</script> +<!-- 表格状态列 --> +<script type="text/html" id="product-tpl-bar-state"> + <input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="正常|锁定" disabled + {{d.enabled==true?'checked':''}} class="permissions" permissions="doctortemplete-enable"/> +</script> +<!-- 表格操作列 --> +<script type="text/html" id="product-tpl-bar"> + <a class="layui-btn layui-btn-xs" lay-event="pay">加入待充值</a> +</script> +<!-- 表格操作列 --> +<script type="text/html" id="product-tpl-bar-temp"> + <a class="layui-btn layui-btn-danger" lay-event="del">移除</a> +</script> +<!-- 表格状态列 --> +<script type="text/html" id="product-tpl-isShare"> + <input type="checkbox" lay-filter="product-tpl-isShare" value="{{d.id}}" lay-skin="switch" lay-text="共享|不共享" /> +</script> +<script> + layui.use(['form', 'table', 'util', 'config', 'laydate', 'jquery', 'admin'], function () { + var form = layui.form; + var table = layui.table; + var config = layui.config; + var layer = layui.layer; + var util = layui.util; + var admin = layui.admin; + // element=layui.element; + var $ = layui.jquery; + var laydate = layui.laydate; + + var contractNum = 0; + + //充值进行中 + var isRun = false; + //执行一个laydate实例 + laydate.render({ + elem: '#contractBeginTime', //指定元素 + done: function (value, date, endDate) { + var startDate = new Date(value).getTime(); + var endTime = new Date($('#contractEndTime').val()).getTime(); + if (endTime < startDate) { + layer.msg('结束时间不能小于开始时间'); + $('#contractBeginTime').val($('#contractEndTime').val()); + } + } + }); + laydate.render({ + elem: '#contractEndTime', //指定元素 + done: function (value, date, endDate) { + var startDate = new Date($('#contractBeginTime').val()).getTime(); + var endTime = new Date(value).getTime(); + if (endTime < startDate) { + layer.msg('结束时间不能小于开始时间'); + $('#contractEndTime').val($('#contractBeginTime').val()); + } + } + }); + laydate.render({ + elem: '#contractBeginTime_not' //指定元素 + }); + laydate.render({ + elem: '#contractEndTime_not' //指定元素 + }); + laydate.render({ + elem: '#custom_beginTime', //指定元素 + done: function (value, date, endDate) { + var startDate = new Date(value).getTime(); + var endTime = new Date($('#custom_endTime').val()).getTime(); + if (endTime < startDate) { + layer.msg('结束时间不能小于开始时间'); + $('#custom_beginTime').val($('#custom_endTime').val()); + } + } + }); + laydate.render({ + elem: '#custom_endTime', //指定元素 + done: function (value, date, endDate) { + var startDate = new Date($('#custom_beginTime').val()).getTime(); + var endTime = new Date(value).getTime(); + if (endTime < startDate) { + layer.msg('结束时间不能小于开始时间'); + $('#custom_endTime').val($('#custom_beginTime').val()); + } + } + }); + //现将临时数据清理 + admin.putTempData("t_tempProduct", ""); + //待充值列表 + var waitRecharge = function () { + table.render({ + elem: '#product-table-temp', + data: admin.getTempData("t_tempProduct"), + page: false, + cellMinWidth: 100, + cols: [ + [{ + field: 'proName', + width: 330, + title: '产品名称', + align: 'center', + fixed: 'left' + }, + { + field: 'proType', + align: 'center', + width: 80, + templet: function (d) { + if (d.proType === 0) + return "试用" + else + return "正式" + }, + title: '类型' + }, + { + field: 'proTime', + width: 100, + title: '时长', + align: 'center', + templet: function (d) { + switch (d.proTimeUnit) { + case 0: + return d.proTime + "天"; + break; + case 1: + return d.proTime + "月"; + break; + case 2: + return d.proTime + "年"; + break; + } + return ""; + } + }, + { + field: 'ailightCount', + width: 100, + align: 'center', + title: '读片量' + }, + { + field: 'recordCount', + width: 100, + align: 'center', + title: '报告量' + }, + { + field: 'beginTime', + align: 'center', + width: 120, + title: '开始日期' + }, + { + field: 'endTime', + align: 'center', + width: 120, + title: '结束日期' + }, + { + field: 'isShare', + fixed: 'right', + align: 'center', + width: 100, + templet: function (d) { + if (d.isShare == 0) + return "不共享" + else + return "共享" + }, + title: '共享' + }, + { + field: 'id', + fixed: 'right', + align: 'center', + width: 100, + toolbar: '#product-tpl-bar-temp', + title: '操作' + } + ] + ] + }); + } + //待充值列表 + var nowContract = function () { + table.render({ + elem: '#product-table-now', + data: admin.getTempData("t_tempProduct"), + page: false, + url: config.base_server + 'api-opration/productorderdetail?orderId=' + admin.getTempData('t_hospital').id, + cellMinWidth: 100, + headers: { + 'Authorization': 'Bearer ' + config.getToken().access_token + }, + cols: [ + [{ + field: 'proName', width: 200, title: '产品名称', align: 'center', fixed: 'left' + }, + { + field: 'proType', align: 'center', width: 80, templet: function (d) { + if (d.proType === 0) + return "试用" + else + return "正式" + }, title: '类型' + }, + { + field: 'createTime', width: 180, title: '充值时间', align: 'center' + }, + { + field: 'ailightCount', width: 100, align: 'center', title: '读片剩余量' + }, + { + field: 'count', width: 100, align: 'center', title: '读片使用量', templet: function (d) { + return d.count - d.ailightCount; + } + }, + { + field: 'proBegintime', align: 'center', width: 180, title: '开始日期', templet: function (d) { return layui.util.toDateString(d.proBegintime, 'yyyy-MM-dd'); } + }, + { + field: 'proEndtime', align: 'center', width: 180, title: '结束日期', templet: function (d) { return layui.util.toDateString(d.proEndtime, 'yyyy-MM-dd'); } + }, + { field: 'enabled', align: 'center', width: 100, templet: '#product-tpl-bar-state', title: '状态' }, + { + field: 'isShare', fixed: 'right', align: 'center', width: 100, + templet: function (d) { + if (d.isShare == 0) + return "不共享" + else + return "共享" + }, title: '共享' + }, + { + field: 'id', fixed: 'right', align: 'center', width: 100, toolbar: '#product-tpl-bar-now', title: '操作' + } + ], + ], + done: function (res, curr, count) { + //如果是异步请求数据方式,res即为你接口返回的信息。 + //如果是直接赋值的方式,res即为:{data: [], count: 99} data为当前页数据、count为数据总长度 + var num = 0; + res.data.forEach(element => { + if (element.enabled) { + num += element.count; + } else { + num += (element.count - element.ailightCount) + } + }); + $("#contractNum_not").val($("#contractNum").val() - num); + } + }); + } + // 产品待充值数据 + var tempDataList = function (data) { + if (!strUtil.isEmpty(data)) { + var listData = admin.getTempData("t_tempProduct"); + if (strUtil.isEmpty(listData)) { + listData = new Array(); + } + listData.push(data); + admin.putTempData("t_tempProduct", listData); + } else { + admin.putTempData("t_tempProduct", ""); + } + } + var getHospitalAddress=function(id){ + admin.req('api-user/syshospital/' + id, {}, + function (data) { + if(data.code==0){ + var hospitalData=data.data; + var hospitalProvince=hospitalData.hospitalProvince!=null ? hospitalData.hospitalProvince: "" + var hospitalCity=hospitalData.hospitalCity!=null ? hospitalData.hospitalCity: "" + var hospitalArea=hospitalData.hospitalArea!=null ? hospitalData.hospitalArea: "" + $("#hospitalAreas").val(hospitalProvince + " " + hospitalCity + " " +hospitalArea); + } + + },"get") + } + + //回显医院基本数据 + let hospitalData = admin.getTempData('t_hospital'); + + if (hospitalData != null) { + nowContract(); + admin.req('api-user/sysdepartment/getPayMes?departmentId=' + hospitalData.departmentId, {}, + function (data) { + layer.closeAll('loading'); + if (0 === data.code) { + queryData = data.data; + if (queryData === true) { + admin.finishPopupCenter(); + layer.msg("当前科室开通了单次支付功能,不能进行充值业务!", { + icon: 3, + time: 5000 + }); + } else { + hospitalData.contractBeginTime = layui.util.toDateString(hospitalData.contractBeginTime, 'yyyy-MM-dd') + hospitalData.contractEndTime = layui.util.toDateString(hospitalData.contractEndTime, 'yyyy-MM-dd') + form.val('recharge-form', hospitalData); + getHospitalAddress(hospitalData.hospitalId); + //装载产品数据 + table.render({ + elem: '#product-table', + url: config.base_server + 'api-opration/product/all', + method: 'GET', + cellMinWidth: 50, + headers: { + 'Authorization': 'Bearer ' + config.getToken().access_token + }, + page: false, + where: { + is_del: 0, + enabled: 1 + }, + cols: [ + [{ + field: 'proName', + sort: true, + width: 330, + title: '产品名称', + align: 'center', + fixed: 'left' + }, + { + field: 'proType', + sort: true, + align: 'center', + width: 80, + templet: function (d) { + if (d.proType === 0) + return "试用" + else + return "正式" + }, + title: '类型' + }, + { + field: 'proTime', + width: 100, + title: '时长', + align: 'center', + templet: function (d) { + switch (d.proTimeUnit) { + case 0: + return d.proTime + "天"; + break; + case 1: + return d.proTime + "月"; + break; + case 2: + return d.proTime + "年"; + break; + } + } + }, + { + field: 'ailightCount', + width: 100, + align: 'center', + title: '读片量' + }, + { + field: 'recordCount', + width: 100, + align: 'center', + title: '报告量' + }, + { + field: 'beginTime', + align: 'center', + width: 120, + title: '开始日期', + event: "date" + }, + { + field: 'endTime', + align: 'center', + width: 120, + title: '结束日期', + event: "date" + }, + { + field: 'isShare', + fixed: 'right', + align: 'center', + width: 100, + templet: '#product-tpl-isShare', + title: '共享' + }, + { + field: 'id', + fixed: 'right', + align: 'center', + width: 100, + toolbar: '#product-tpl-bar', + title: '操作' + } + ] + ], + done: function (res) { + permissionsInput(res, config); + } + }); + } + } + else { + admin.finishPopupCenter(); + layer.msg("验证医院科室数据异常!", { + icon: 2, + time: 3000 + }); + } + }, 'get'); + //报告数量事件 + $("#contractNum").blur(function () { + if ($("#contractNum").val() <= 0) { + layer.msg("输入的读片量大于0"); + $("#contractNum").val("") + return false; + } + var listData = admin.getTempData("t_tempProduct"); + var listNum = 0; + if (!strUtil.isEmpty(listData)) { + listData.forEach(item => { + listNum += item.ailightCount; + }) + } + if ($("#contractNum").val() < listNum) { + layer.msg("请先删除待充值套餐"); + $("#contractNum").val(contractNum) + return false; + } else { + contractNum = $("#contractNum").val(); + } + }) + //自定义的确定 + $("#custom_submit").click(function () { + var custom_proName = $("#custom_proName").val() + var custom_ailightCount = $("#custom_ailightCount").val() + var custom_isShare = $("#custom_isShare").prop("checked") ? 1 : 0; + var termType = $("#termType").prop("checked") ? 1 : 0; + var custom_beginTime = ""; + var custom_endTime = ""; + if (termType == 1) { + custom_beginTime = $("#custom_beginTime").val(); + custom_endTime = $("#custom_endTime").val(); + } else { + custom_beginTime = $("#contractBeginTime").val(); + custom_endTime = $("#contractEndTime").val(); + } + var listData = admin.getTempData("t_tempProduct"); + //添加一个id,删除用 + var max = 0; + if (strUtil.isEmpty(listData)) { + listData = new Array(); + } + listData.forEach(element => { + if (max < element.id) { + max = element.id + } + }); + //判断待加入产品的总数是否大于合同的总数 + var msg = isthenNum(parseInt(custom_ailightCount)); + if (msg != null) { + layer.msg(msg); + return false; + } + + var data = { + id: max + 1, + ailightCount: parseInt(custom_ailightCount), + beginTime: custom_beginTime, + endTime: custom_endTime, + isShare: custom_isShare, + proName: custom_proName, + proTime: "", + proType: 1, + termType: termType + } + tempDataList(data); + waitRecharge(); + }) + //确定充值按钮 + $("#submit").click(function () { + submit(); + }) + } + //已充值列表 功能操作 + table.on('tool(product-table-now)', function (obj) { + if (obj.event === "order_detail_del") { + if (!strUtil.isEmpty(obj.data.id)) { + admin.req('api-opration/productorderdetail/' + obj.data.id, {}, function (data) { + layer.closeAll('loading'); + if (data.code == 0) { + layer.msg(data.msg, { icon: 1, time: 2000 }); + table.reload('product-table-now', {}); + } else { + layer.msg(data.msg, { icon: 2, time: 2000 }); + } + }, 'delete'); + obj.del(); + } + } else if (obj.event === "order_detail_enable") { + if (!strUtil.isEmpty(obj.data.id)) { + admin.req('api-opration/productorderdetail/updateEnabled', { + id: obj.data.id, + enabled: false + }, function (data) { + layer.closeAll('loading'); + if (data.code == 0) { + layer.msg(data.msg, { icon: 1, time: 2000 }); + table.reload('product-table-now', {}); + } else { + layer.msg(data.msg, { icon: 2, time: 2000 }); + form.render('checkbox'); + } + }, 'GET'); + obj.del(); + } + } + }); + //待充值列表功能操作 + table.on('tool(product-table-temp)', function (obj) { + if (obj.event === "del") { + if (!strUtil.isEmpty(obj.data.id)) { + delTempDataById(obj.data.id); + obj.del(); + } + } + }); + //单元格点击事件 + table.on('tool(product-table)', function (obj) { + var newdata = {}; + var data = obj.data; + var selectData = {}; + if (obj.event === 'date') { + var field = $(this).data('field'); + laydate.render({ + elem: this.firstChild, + format: "yyyy-MM-dd", + show: true, + done: function (value, date) { + var nowTr = obj.tr; + if (field === "beginTime") { + var endTimes = getNowDate(data.proTime, data.proTimeUnit, + value); + newdata["beginTime"] = value; + newdata["endTime"] = endTimes; + } else if (field === "endTime") { + newdata["endTime"] = value; + var beginTimes = getNowDate((0 - parseInt(data.proTime)), + data.proTimeUnit, value); + newdata["beginTime"] = beginTimes; + } + obj.update(newdata); + } + }); + } + if (obj.event === "pay") { + data.beginTime = obj.tr.find("td[data-field='beginTime'] input").val(); + data.endTime = obj.tr.find("td[data-field='endTime'] input").val(); + data.beginTime = (!strUtil.isEmpty(data.beginTime)) ? data.beginTime : obj.tr.find( + "td[data-field='beginTime'] div").text(); + data.endTime = (!strUtil.isEmpty(data.endTime)) ? data.endTime : obj.tr.find( + "td[data-field='endTime'] div").text(); + data.isShare = obj.tr.find("td[data-field='isShare'] em").text(); + data.isShare = (data.isShare.indexOf("不") == 0) ? 0 : 1; + //判断待加入产品的总数是否大于合同的总数 + var msg = isthenNum(data.ailightCount); + if (msg != null) { + layer.msg(msg); + return false; + } + if (!strUtil.isEmpty(data.beginTime) && !strUtil.isEmpty(data.endTime)) { + if (dateUtil.compareDate(data.endTime, data.beginTime)) { + data.id = data.id + ''; + tempDataList(data); + waitRecharge(); + } else { + layer.msg("结束时间必须大于开始时间!"); + return false; + } + } else { + layer.msg("时间格式有误!"); + return false; + } + } + }); + function isthenNum(num) { + if (num <= 0) { + return "请输入读片量且大于0"; + } + var listData = admin.getTempData("t_tempProduct"); + var listNum = 0; + if (!strUtil.isEmpty(listData)) { + listData.forEach(item => { + listNum += item.ailightCount; + }) + } + listNum += num; + if ($("#contractNum_not").val() == undefined || $("#contractNum_not").val() == "") { + return "请输入读片量!"; + } else { + if ($("#contractNum_not").val() < listNum) { + return "当前产品总数不得大于合同总量"; + } else { + return null; + } + } + } + //监听单元格编辑 判断日期格式 + table.on('edit(product-table)', function (obj) { + var value = obj.value //得到修改后的值 + , + data = obj.data //得到所在行所有键值 + , + field = obj.field; //得到字段 + if (dateUtil.isDate(value)) { } else { + layer.msg("输入的日期格式无效!"); + } + }); + //自动计算时间 + var getNowDate = function (proTime, proTimeUnit, now) { + if (strUtil.isEmpty(now)) { + now = new Date(); + } else { + now = dateUtil.strTurnDate(now); + } + if (strUtil.isEmpty(proTime) && strUtil.isEmpty(proTimeUnit)) { + return now.dateFormat("yyyy-MM-dd"); + } else { + proTime = strUtil.isEmpty(proTime) ? 0 : proTime; + proTimeUnit = strUtil.isEmpty(proTimeUnit) ? 0 : proTimeUnit; + switch (proTimeUnit) { + case 0: + return new Date(now.setDate(now.getDate() + proTime)).dateFormat("yyyy-MM-dd"); + break; + case 1: + return new Date(now.setMonth(now.getMonth() + proTime)).dateFormat( + "yyyy-MM-dd"); + break; + case 2: + return new Date(now.setFullYear(now.getFullYear() + proTime)).dateFormat( + "yyyy-MM-dd"); + break; + } + } + } + + //移除指定数据 + var delTempDataById = function (id) { + if (!strUtil.isEmpty(id)) { + var listData = admin.getTempData("t_tempProduct"); + $.each(listData, function (index, value) { + if (value.id === id) { + //移除 + listData.splice(index, 1); + return false; + } + }) + admin.putTempData("t_tempProduct", listData); + } + } + function submit() { + console.log(1111111) + if (!isRun) { + layer.load(2); + var listData = admin.getTempData("t_tempProduct"); + if (listData != null) { + layer.confirm("确定要将待充值列表中的" + listData.length + "个产品充值给当前医院的科室吗?", { + btn: ["确定", "返回"] + }, function () { + isRun = true; + layer.closeAll('loading'); + //处理订单明细数据 + var listDetailData = new Array(); + $.each(listData, function (index, item) { + var detailData = { + orderId: hospitalData.id + '', + proId: item.termType == null ? item.id + '' : "0", + proType: item.proType, + proName: item.proName, + isShare: item.isShare, + ailightCount: item.ailightCount != null ? item.ailightCount : 0, + recordCount: item.recordCount != null ? item.recordCount : 0, + termType: item.termType, + proBegintime: item.beginTime != "" ? item.beginTime + + ' 00:00:00' : "", + proEndtime: item.endTime != "" ? item.endTime + + ' 23:59:59' : "", + count: item.ailightCount + }; + listDetailData.push(detailData); + }) + if (listDetailData.length > 0) { + //提交订单数据 + admin.req( + 'api-opration/productorderdetail/saveall', + JSON.stringify(listDetailData), + function (data) { + isRun = false; + layer.closeAll('loading'); + if (data.code === 0) { + //现将临时数据清理 + admin.putTempData( + "t_tempProduct", + ""); + layer.msg(data.msg, { + icon: 1, + time: 2000 + }, function () { + admin + .finishPopupCenter(); + }); + } else { + layer.msg(data.msg, { + icon: 2, + time: 1000 + }); + } + }, 'POST'); + } else { + layer.msg("充值数据异常为空!", { + icon: 2, + time: 1000 + }); + isRun = false; + } + }) + } else { + layer.msg("请先将要充值的产品加入待充值!", { + icon: 2, + time: 2000 + }); + } + layer.closeAll('loading'); + return false; + } + }; + }); +</script> +<style> + .layui-form-label { + width: 100px; + } +</style> \ No newline at end of file -- Gitblit v1.8.0