chenhaozhe
2026-04-04 820b3f7a95cd865b29b3ea8e19b47ee964e0a2c6
WebTM/views/ÏîÄ¿¹ÜÀí/¹¤×÷ÈÎÎñ/PM_WorkTaskReportBill.html
@@ -1,11 +1,13 @@
<!DOCTYPE html>
<html>
<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="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
@@ -14,6 +16,7 @@
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/PageTitle.js"></script>
    <!--<style>
        .main-btn { /*头部主按钮*/
            padding: 0 2px; /*调整按钮左右空隙大小*/
@@ -47,6 +50,7 @@
    </style>-->
</head>
<body>
    <div class="layui-fluid" style="padding: 0;">
        <div class="layui-card" style="padding: 2px;background-color: #efefef;">
@@ -57,14 +61,17 @@
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch">新增</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch">修改</button>-->
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">保存</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnEdit" id="btnEdit">退出</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit=""
                            lay-filter="btnSave" id="btnSave">保存</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit=""
                            lay-filter="btnEdit" id="btnEdit">退出</button>
                        <!--<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="set_CheckBill" id="set_CheckBill">审核</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="set_AbandonCheck" id="set_AbandonCheck">反审核</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="set_CloseBill" id="set_CloseBill">关闭</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="set_CancelCloseBill" id="set_CancelCloseBill">反关闭</button>-->
                    </div>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
                        <h1 style="text-align: center; padding: 10px 0;"><b>任务汇报</b></h1>
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li lay-id="1" style="padding:1px;" class="layui-this">基本信息</li>
                            <li lay-id="2" style="padding:1px;">其他信息</li>
@@ -75,24 +82,72 @@
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">单据号<label style="color:red"> * </label></label>
                                            <label class="layui-form-label" style="width: 85px;">单据号<label
                                                    style="color:red"> * </label></label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBillNo" lay-verify="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HInterID" id="HInterID" lay-verify="HInterID">
                                                <input type="text" class="layui-input" name="HBillNo"
                                                    lay-verify="HBillNo" id="HBillNo"
                                                    style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HInterID" id="HInterID"
                                                    lay-verify="HInterID">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">日期<label style="color:red"> * </label></label>
                                            <label class="layui-form-label" style="width: 85px;">日期<label
                                                    style="color:red"> * </label></label>
                                            <div class="layui-input-block" style="margin-left: 120px; width:180px;">
                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="padding-left: 80px;">
                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate"
                                                    id="HDate" style="padding-left: 80px;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;padding: 9px 18px;">汇报人<label style="color:red"> * </label></label>
                                            <label class="layui-form-label"
                                                style="width: 85px;padding: 9px 18px;">汇报人<label style="color:red"> *
                                                </label></label>
                                            <div class="layui-input-block" style="margin-left: 77px;">
                                                <input type="text" class="layui-input" lay-verify="HReportEmpName" name="HReportEmpName" id="HReportEmpName" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                                <input type="hidden" name="HReportEmpID" id="HReportEmpID" lay-verify="HReportEmpID" value="0">
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearchHReportEmp" id="btnSearchHReportEmp" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                <input type="text" class="layui-input" lay-verify="HReportEmpName"
                                                    name="HReportEmpName" id="HReportEmpName"
                                                    style="background-color:#efefef4d;width: 60%;display: inline-block;"
                                                    readonly>
                                                <input type="hidden" name="HReportEmpID" id="HReportEmpID"
                                                    lay-verify="HReportEmpID" value="0">
                                                <button class="layui-btn layuiadmin-btn-order" type="button"
                                                    lay-submit="" lay-filter="btnSearchHReportEmp"
                                                    id="btnSearchHReportEmp"
                                                    style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label"
                                                style="width: 85px;padding: 9px 18px;">接收人</label>
                                            <div class="layui-input-block" style="margin-left: 77px;">
                                                <input type="text" class="layui-input" lay-verify="HReceiveEmp"
                                                    name="HReceiveEmp" id="HReceiveEmp"
                                                    style="background-color:#efefef4d;width: 60%;display: inline-block;"
                                                    readonly>
                                                <!--<input type="hidden" name="HPMEmpID" id="HPMEmpID" lay-verify="HPMEmpID" value="0">-->
                                                <button class="layui-btn layuiadmin-btn-order" type="button"
                                                    lay-submit="" lay-filter="btnSearchHReceiveEmp"
                                                    id="btnSearchHReceiveEmp"
                                                    style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label"
                                                style="width: 85px;padding: 9px 18px;">抄送人</label>
                                            <div class="layui-input-block" style="margin-left: 77px;">
                                                <input type="text" class="layui-input" lay-verify="HCopyEmp"
                                                    name="HCopyEmp" id="HCopyEmp"
                                                    style="background-color:#efefef4d;width: 60%;display: inline-block;"
                                                    readonly>
                                                <!--<input type="hidden" name="HWorkEmpID" id="HWorkEmpID" lay-verify="HWorkEmpID" value="0">-->
                                                <button class="layui-btn layuiadmin-btn-order" type="button"
                                                    lay-submit="" lay-filter="btnSearchHCopyEmp" id="btnSearchHCopyEmp"
                                                    style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
                                            </div>
@@ -102,13 +157,15 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">备注</label>
                                            <div class="layui-input-block" style="margin-left: 120px; width: 501px;">
                                                <input type="text" class="layui-input" lay-verify="HRemark" name="HRemark" id="HRemark">
                                                <input type="text" class="layui-input" lay-verify="HRemark"
                                                    name="HRemark" id="HRemark">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">组织<label style="color:red"> * </label></label>
                                            <label class="layui-form-label" style="width: 85px;">组织<label
                                                    style="color:red"> * </label></label>
                                            <div class="layui-input-block" style="margin-left: 120px; width: 501px;">
                                                <select name="HOrgID" id="HOrgID" lay-verify="HOrgID">
                                                    <!--动态渲染组织-->
@@ -119,10 +176,14 @@
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <div class="layui-input-block" style="margin-left: 120px; width: 501px;">
                                                <input type="hidden" name="HProID" id="HProID" lay-verify="HProID" value="0">
                                                <input type="hidden" name="HProjectStageID" id="HProjectStageID" lay-verify="HProjectStageID" value="0">
                                                <input type="hidden" name="HMainSourceBillType" id="HMainSourceBillType" lay-verify="HMainSourceBillType" value="">
                                                <input type="hidden" name="HMainSourceBillNo" id="HMainSourceBillNo" lay-verify="HMainSourceBillNo" value="">
                                                <input type="hidden" name="HProID" id="HProID" lay-verify="HProID"
                                                    value="0">
                                                <input type="hidden" name="HProjectStageID" id="HProjectStageID"
                                                    lay-verify="HProjectStageID" value="0">
                                                <input type="hidden" name="HMainSourceBillType" id="HMainSourceBillType"
                                                    lay-verify="HMainSourceBillType" value="">
                                                <input type="hidden" name="HMainSourceBillNo" id="HMainSourceBillNo"
                                                    lay-verify="HMainSourceBillNo" value="">
                                            </div>
                                        </div>
                                    </div>
@@ -135,19 +196,22 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">制单人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMaker" id="HMaker" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HMaker" id="HMaker"
                                                    style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">修改人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HUpdater" id="HUpdater" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HUpdater" id="HUpdater"
                                                    style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">审核人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HChecker" id="HChecker" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HChecker" id="HChecker"
                                                    style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
@@ -156,19 +220,22 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">制单日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMakerDate" id="HMakerDate" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HMakerDate" id="HMakerDate"
                                                    style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">修改日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HUpdaterDate" id="HUpdaterDate" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HUpdaterDate"
                                                    id="HUpdaterDate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">审核日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HCheckerDate" id="HCheckerDate" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HCheckerDate"
                                                    id="HCheckerDate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -176,19 +243,22 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">关闭人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HCloseMan" id="HCloseMan" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HCloseMan" id="HCloseMan"
                                                    style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">作废人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HDeleteMan" id="HDeleteMan" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HDeleteMan" id="HDeleteMan"
                                                    style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">退回人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBacker" id="HBacker" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HBacker" id="HBacker"
                                                    style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -196,19 +266,22 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">关闭日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HCloseManDate" id="HCloseManDate" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HCloseManDate"
                                                    id="HCloseManDate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">作废日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HDeleteManDate" id="HDeleteManDate" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HDeleteManDate"
                                                    id="HDeleteManDate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">退回日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBackerDate" id="HBackerDate" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HBackerDate"
                                                    id="HBackerDate" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -216,7 +289,8 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">退回原因</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBackRemark" id="HBackRemark" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HBackRemark"
                                                    id="HBackRemark" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -225,8 +299,10 @@
                        </div>
                    </div>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li lay-id="1" style="padding:1px;" class="layui-this">项目阶段</li>
                            <li lay-id="2" style="padding:1px;" class="layui-this">附件</li>
                        </ul>
                        <div class="layui-tab-content">
                            <!--子表-->
@@ -238,9 +314,18 @@
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                                        <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="btn_up"><i class="layui-icon layui-icon-form"></i>上一行</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn_under"><i class="layui-icon layui-icon-form"></i>下一行</button>-->
                    <button type="button" class="layui-btn layui-btn-sm" lay-event="btn_under"><i class="layui-icon layui-icon-form"></i>下一行</button>-->
                                    </div>
                                </script>
                            </div>
                            <!-- å­è¡¨é™„ä»¶ -->
                            <div class="layui-tab-item layui-show">
                                <script type="text/html" id="toolbarAttachmentTable">
                                    <div class="layui-btn-container">
                                        <!-- <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-ChooseFile"><i class="layui-icon layui-icon-form"></i>上传附件</button> -->
                                    </div>
                                </script>
                                <table class="layui-hide" id="AttachmentTable" lay-filter="AttachmentTable"></table>
                            </div>
                        </div>
                    </div>
@@ -251,7 +336,24 @@
    <!--子表表:删除-->
    <script type="text/html" id="barDemo">
        <!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <!-- å­è¡¨é™„ä»¶ æ“ä½œæ  -->
    <script type="text/html" id="AttachmentOperate">
        <!-- ä¸Šä¼ å‰æ˜¾ç¤º -->
    <div {{d.uploadStatus==0 ? '' : 'style="display:none;"' }} class="waitUploaded">
        <a class="layui-btn layui-btn-xs" lay-event="fileSelect">选择文件</a>
    </div>
    <!-- å¾…上传显示 -->
    <div {{d.uploadStatus==1 ? '' : 'style="display:none;"' }} class="preUploaded">
        <a class="layui-btn layui-btn-xs" lay-event="fileUpload">上传文件</a>
    </div>
    <!-- ä¸Šä¼ åŽæ˜¾ç¤º -->
    <div {{d.uploadStatus==2 ? '' : 'style="display:none;"' }} class="uploaded">
        <a class="layui-btn layui-btn-xs" lay-event="downloadFile">下载</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delFile">删除</a>
    </div>
    </script>
    <!--复选框 å®Œæˆæ ‡è®°-->
@@ -272,30 +374,51 @@
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
        }).use(['index', 'form', 'laydate', 'table', 'element', 'upload'], function () {
            //#region å…¬å…±å˜é‡
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , element = layui.element;
                , element = layui.element
                , upload = layui.upload
                ;
            //模块名
            var HModName = "PM_WorkTaskReportBill";
            //表格渲染参数
            var option = {};            //项目阶段表渲染参数
            // é™„件表格渲染参数
            var attachmentOption = {};
            // æ–‡ä»¶ä¸Šä¼ ç»„件绑定实例
            fileUploadInst = {}
            //记录组织的值
            var HOrgIDBar = 0;
            //获取参数
            var params = getUrlVars();
            var OperationType = params[params[0]]; //从参数中获取 æ•°æ®ç±»åž‹  1添加 ä¿å­˜  2复制  3 ç¼–辑
            var linterid = params[params[1]]; //从参数中获取 å•据内码
            var HProjectStageID = params[params[3]]; //阶段内码
            var HEntryID = params[params[3]]; //从参数中获取 å•据内码
            //var HProjectStageID = params[params[3]]; //阶段内码
            // é™„件上传临时文件
            var tempFileMap = {};
            //全局变量
            window.OptionData = [];
            //#endregion
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
            //#region ã€åŠ¨æ€èŽ·å–æ¨¡å—åç§°ã€‘
            var HModuleType = "4754";
            //通过单据类型,从数据库动态获取单据模块命名,引用js文件 PageTitle.js
            var HPageTitle = get_PageTitle(HModuleType) == "" ? $("h1").html() : get_PageTitle(HModuleType);
            $("h1").html('<b>' + HPageTitle + '</b>');
            //#endregion
            //#region åˆ¤æ–­æ˜¯å¦ç™»å½• æœªç™»å½•则跳到登录页
            if (sessionStorage.login != "login") {
                layer.confirm("登录失效,请重新登录!", {
@@ -326,28 +449,38 @@
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
                //初始化项目阶段表
                get_InitGrid();
                //初始化 é™„件表
                get_InitAttachmentGrid();
            }
            //else if (OperationType == 2) {                                      //复制
            //    //禁用组织选项
            //    //$("#HOrgID").attr("disabled", true);
            //    RoadBillMain(linterid);
            //    $.ajax({
            //        url: GetWEBURL() + "/Web/GetMAXNum",
            //        type: "GET",
            //        async: false,
            //        data: { "HBillType": '4750' },
            //        success: function (d) {
            //            $("#HInterID").val(d.data[0].HInterID);
            //            $("#HBillNo").val(d.data[0].HBillNo);
            //            $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
            //        }
            //    });
            //}
            else if (OperationType == 2) {      //我的任务模块下推
                ////禁用组织选项
                //$("#HOrgID").attr("disabled", true);
                //生成并设置主表的内码和单据号
                createBillNo();
                //汇报人初始化
                getHEmpByHUserName();
                //初始化制单人和制单时间
                $("#HMaker").val(sessionStorage["HUserName"]);
                $("#HMakerDate").val(Format(new Date(), "yyyy-MM-dd"));
                //初始化日期
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
                //初始化项目阶段表
                get_InitGrid();
                //初始化 é™„件表
                get_InitAttachmentGrid();
                get_Display();
            }
            else if (OperationType == 3) {//如果修改则走下面 new                                        //编辑
                ////禁用组织选项
                //$("#HOrgID").attr("disabled", true);
                //初始化项目阶段表
                get_InitGrid();
                //初始化 é™„件表
                get_InitAttachmentGrid();
                RoadBillMain(linterid);
            } else if (OperationType == 4) {                     //下推
                //禁用组织选项
@@ -365,8 +498,11 @@
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
                //初始化项目阶段表
                get_InitGrid();
                //初始化 é™„件表
                get_InitAttachmentGrid();
                //下推-页面设置
                set_WorkTaskReport();
            }
            //#endregion
@@ -432,6 +568,18 @@
                set_CancelCloseBill(data);
            });
            //#endregion
            //#region é€‰æ‹©æŽ¥æ”¶äººæŒ‰é’®
            form.on('submit(btnSearchHReceiveEmp)', function () {
                get_checkSearchHReceiveEmp();
            });
            //#endregion
            //#region é€‰æ‹©æŠ„送人按钮
            form.on('submit(btnSearchHCopyEmp)', function () {
                get_checkSearchHCopyEmp();
            });
            //#endregion
            //#endregion
            //#endregion
@@ -462,11 +610,25 @@
                    , "HSourceBillNo": ""
                    , "HSourceBillType": ""
                };
                // æ–°å»º é™„件行数据
                var attachmentNewRaw = {
                    "HWeekReportFileAddr": ""
                    , "HWeekReportFileName": ""
                    , "HWeekProDays": "0"
                    , "Size": ""
                    , "Status": ""
                    , "uploadStatus": 0
                }
                switch (obj.event) {
                    case 'btn-AddLine':
                        table.cache["mainTable"].push(NewRow);
                        option.data = table.cache["mainTable"];
                        table.render(option);
                        table.cache["AttachmentTable"].push(attachmentNewRaw);
                        attachmentOption.data = table.cache["AttachmentTable"]
                        table.render(attachmentOption);
                        CheckedSet_tableSub();
                        for (var i = 1; i <= option.data.length; i++) {
@@ -492,6 +654,9 @@
                            table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.render(option);//将数据渲染到表格上
                            table.cache["AttachmentTable"].push(attachmentNewRaw);
                            attachmentOption.data = table.cache["AttachmentTable"]
                            table.render(attachmentOption);
                            CheckedSet_tableSub();
                            for (var i = 1; i <= option.data.length; i++) {
@@ -545,6 +710,82 @@
            })
            //#endregion
            table.on('tool(AttachmentTable)', function (obj) {
                var data = obj.data;      // å½“前行数据
                var that = this;          // å½“前点击的按钮
                var tr = $(this).closest("tr");
                var index = tr.data("index");
                if (obj.event === 'fileUpload') {
                    // åˆ¤æ–­æ˜¯å¦å·²é€‰æ‹©æ–‡ä»¶
                    console.log(tempFileMap, index)
                    if (!tempFileMap[index]) {
                        layer.msg("请先选择文件!");
                        return;
                    }
                    var formData = new FormData();
                    formData.append("file", tempFileMap[index]); // è¿½åŠ å·²é€‰æ‹©çš„æ–‡ä»¶
                    formData.append("HNumber", $("#HBillNo").val());
                    formData.append("HRemark", $("#HRemark").val());
                    formData.append("HUserName", sessionStorage["HUserName"]);
                    layer.load(); // åŠ è½½ä¸­
                    $.ajax({
                        url: GetWEBURL() + "/PM_WorkTaskReportBill/UploadFile",
                        type: "POST",
                        data: formData,
                        contentType: false,
                        processData: false,
                        success: function (res) {
                            layer.closeAll('loading');
                            if (res.count == 1) {
                                // èŽ·å–è¡¨æ ¼ç¼“å­˜
                                var cache = table.cache['AttachmentTable'];
                                cache[index].Status = "已上传";
                                cache[index].uploadStatus = 2;
                                cache[index].HWeekReportFileAddr = TransWebUrlToFileUrl(GetWEBURL(), res.data + cache[index].HWeekReportFileName)
                                console.log(cache[index].HWeekReportFileAddr)
                                table.reload('AttachmentTable', {
                                    data: cache,
                                });
                                layer.msg("上传成功");
                            } else {
                                layer.msg("上传失败:" + res.Message);
                            }
                        },
                        error: function () {
                            layer.closeAll('loading');
                            layer.msg("上传异常,请重试");
                        }
                    });
                } else if (obj.event == 'downloadFile') {
                    // ä¸‹è½½æ–‡ä»¶
                    downloadFile(index)
                } else if (obj.event == 'delFile') {
                    // åˆ é™¤ç¼“å­˜
                    var cache = table.cache['AttachmentTable'];
                    cache[index].HWeekReportFileAddr = "";
                    cache[index].HWeekReportFileName = "";
                    cache[index].Size = "";
                    cache[index].Status = "";
                    cache[index].HWeekProDays = 0;
                    cache[index].uploadStatus = 0;
                    table.reload('AttachmentTable', {
                        data: cache,
                    });
                    layer.msg("删除成功");
                }
            });
            //
@@ -576,6 +817,48 @@
            //#region æ­¤é¡µé¢æ‰€æœ‰çš„æ–¹æ³•
            function TransWebUrlToFileUrl(webUrl, fileAddr) {
                webUrl = webUrl.substr(0, webUrl.length - 1) // åŽ»é™¤åŽä¸€ä¸ª/
                lastbackSlashIndex = webUrl.lastIndexOf("/")
                webUrl = webUrl.substr(0, lastbackSlashIndex)
                return webUrl + "/" + fileAddr
            }
            //#region
            function downloadFile(index) {
                var cache = table.cache['AttachmentTable'];
                var row = cache[index];
                // ä¼˜å…ˆä½¿ç”¨æœ¬åœ°ä¸´æ—¶æ–‡ä»¶
                if (tempFileMap[index]) {
                    const file = tempFileMap[index];
                    const url = URL.createObjectURL(file);
                    const a = document.createElement('a');
                    a.href = url;
                    a.download = file.name;
                    document.body.appendChild(a);
                    a.click();
                    document.body.removeChild(a);
                    URL.revokeObjectURL(url);
                    return;
                }
                if (row.HWeekReportFileAddr) {
                    var fileUrl = row.HWeekReportFileAddr;
                    const a = document.createElement('a');
                    a.href = fileUrl;
                    a.download = row.HWeekReportFileName; // æ–‡ä»¶å
                    document.body.appendChild(a);
                    a.click();
                    document.body.removeChild(a);
                    return;
                }
                layer.msg('无可下载的文件');
            }
            //#endregion
            //#region èŽ·å–ç»„ç»‡
            function Organ() {
                //获取登录页组织列
@@ -590,7 +873,7 @@
                                Organization += '<option  style="color:blue;" value="' + data[i].ID + '">' + data[i].Name + '</option>';
                            }
                            $("#HOrgID").append(Organization);
                            if (OperationType == 1 || OperationType == 4) {
                            if (OperationType == 1 || OperationType == 4 || OperationType == 2) {
                                HOrgIDBar = sessionStorage["OrganizationID"];
                            }
                            $("#HOrgID").val(HOrgIDBar);
@@ -703,7 +986,47 @@
                CheckedSet_tableSub();
            }
            //#endregion
            //#region å­è¡¨é™„件表 åˆå§‹åŒ–
            function get_InitAttachmentGrid() {
                attachmentOption = {
                    elem: '#AttachmentTable',
                    toolbar: '#toolbarAttachmentTable'
                    , totalRow: true
                    , cellMinWidth: 120
                    , height: 400
                    , cols: [[
                        { type: 'numbers', title: '序号', style: 'background-color: #f9f9f9;' }
                        , { field: 'HWeekReportFileAddr', title: '人天单文件路径', hide: true, style: 'background-color: #f9f9f9;' }
                        , { field: 'HWeekReportFileName', title: '人天单文件名称', style: 'background-color: #f9f9f9;' }
                        , { field: 'HWeekProDays', title: '本周实施消耗人天', edit: true, style: 'background-color: #f9f9f9;' }
                        , { field: 'Size', title: '文件大小', style: 'background-color: #f9f9f9;' }
                        , { field: 'Status', title: '上传状态', style: 'background-color: #f9f9f9;' }
                        , { field: 'uploadStatus', title: '上传状态代码', hide: true, style: 'background-color: #f9f9f9;' }
                        , { fixed: 'right', title: '操作', toolbar: '#AttachmentOperate' }
                    ]]
                    , done: function () {
                        bindUploadToTable();
                    }
                }
                var rowDataAttachment = [
                    {
                        "HWeekReportFileAddr": ""
                        , "HWeekReportFileName": ""
                        , "HWeekProDays": "0"
                        , "Size": ""
                        , "Status": ""
                        , "uploadStatus": 0
                    },
                ];
                attachmentOption.data = rowDataAttachment;
                table.render(attachmentOption);
            }
            //#endregion
            //#region å®Œæˆæ ‡è®°
            form.on('checkbox(HFinishFlag)', function (data) {
                //获取下拉框选中的值
@@ -717,6 +1040,40 @@
            });
            //#endregion
            //#region è‡ªå®šä¹‰è¡¨æ ¼ç»‘定文件上传功能
            function bindUploadToTable() {
                // 1. é€‰æ‹©æœ¬åœ°æ–‡ä»¶ï¼ˆæœªé€‰æ‹© â†’ å¾…上传)
                upload.render({
                    elem: '[lay-event="fileSelect"]',
                    accept: 'file',
                    exts: 'doc|docx|xls|xlsx|pdf|zip|rar|txt',
                    auto: false,
                    choose: function (obj) {
                        var tr = this.item.parents('tr');
                        var index = tr.data('index');
                        var cache = table.cache['AttachmentTable'];
                        // é¢„览文件信息
                        obj.preview(function (i, file) {
                            // å­˜å…¥ä¸´æ—¶æ–‡ä»¶
                            tempFileMap[index] = file;
                            // æ›´æ–°è¡ŒçŠ¶æ€ â†’ å¾…上传
                            cache[index].HWeekReportFileName = file.name;
                            cache[index].Size = (file.size / 1024).toFixed(2) + 'KB';
                            cache[index].Status = "待上传";
                            cache[index].uploadStatus = 1;
                            table.reload('AttachmentTable', { data: cache });
                            console.log(tempFileMap)
                            layer.msg('已选择文件,请点击上传');
                        });
                    }
                });
            }
            //#endregion
            //#region æ±‡æŠ¥äººé€‰æ‹©é¡µé¢
            function get_checkSearchHReportEmp() {
                var HOrgID = $("#HOrgID").val();
@@ -726,7 +1083,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '员工表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?openType=2&HOrgID=' + HOrgID, 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?openType=HReport&HOrgID=' + HOrgID, 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -743,6 +1100,7 @@
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                    , end: function () { }
                })
            }
            //#endregion
@@ -754,9 +1112,12 @@
                for (var i = 0; i < table.cache["mainTable"].length; i++) {
                    if (table.cache["mainTable"][i] != "") {
                        table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
                        // åˆå¹¶ä¸»è¡¨å¯¹è±¡å’Œé™„件表对象
                        $.extend(true, table.cache["mainTable"][i], table.cache["AttachmentTable"][i])
                        num.push(table.cache["mainTable"][i])
                    }
                }
                //获取组织数据
                data.field.HPRDORGID = sessionStorage["OrganizationID"];//组织
                //若为编辑-保存,则更新修改人和修改时间
@@ -786,6 +1147,8 @@
                            $('#btnSave').addClass("layui-btn-disabled").attr("disabled", true);
                            layer.close(index);
                            layer.msg("提交成功");
                            var datas = num;
                            UpdateState(datas);
                        }
                        else {
                            layer.close(index);
@@ -795,6 +1158,121 @@
                    error: function (err) {
                        layer.close(index);
                        layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                });
            }
            //#endregion
            //循环子表数据,查看是否完成,完成就更新状态为已结束
            function UpdateState(datas) {
                var data = datas;
                for (var i = 0; i < data.length; i++) {
                    if (data[i].HFinishFlag == true) {
                        var InterID = data[i].HSourceInterID;
                        var nums = 2;
                        $.ajax({
                            type: "GET",
                            url: GetWEBURL() + "/PM_WorkTaskBill/BeginPM_WorkTaskBill", //方法所在页面和方法名
                            data: { "HInterID": InterID, "Type": nums, "user": sessionStorage["HUserName"] },
                            success: function (result) {
                                if (result.count == 1) {
                                    layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                        // å¾—到frame索引
                                        var index = layer.getFrameIndex(window.name);
                                        //关闭当前frame
                                        layer.close(index);
                                        //修改为功后刷新界面
                                        $("#btnSearch").trigger('click');
                                    });
                                } else {
                                    layer.alert(result.code + result.Message, { icon: 5 });
                                }
                            }, error: function () {
                                layer.alert("接口请求失败!", { icon: 5 });
                            }
                        });
                    }
                }
            }
            //#region æŽ¥æ”¶äººé€‰æ‹©é¡µé¢
            function get_checkSearchHReceiveEmp() {
                var HOrgID = $("#HOrgID").val();
                layer.open({
                    type: 2//弹窗类型
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['90%', '90%']//大小
                    , title: '员工表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?openType=HReceive&HOrgID=' + HOrgID, 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        //获取数据
                        $("#HReceiveEmp").val(checkStatus.data[0].职员名称);//接收人名称
                        if ($("#HReceiveEmp").val() == "") {
                            $("#HReceiveEmp").val(checkStatus.data[0].职员代码);
                        }
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                    , end: function () { }
                })
            }
            //#endregion
            //#region æŠ„送人选择页面
            function get_checkSearchHCopyEmp() {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '抄送人列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/transfer.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.transfer.getData('key123'); //获取已分配数量
                        if (checkStatus.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        var value = "";
                        var title = "";
                        for (var i = 0; i < checkStatus.length; i++) {
                            value += checkStatus[i].value + ",";
                            title += checkStatus[i].title + ",";
                        }
                        //去掉最后一个逗号(如果不需要去掉,就不用写)
                        if (value.length > 0) {
                            value = value.substr(0, value.length - 1);
                            title = title.substr(0, title.length - 1);
                        }
                        $("#HCopyEmp").val(title);
                        console.log(checkStatus, value, title);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            }
@@ -835,6 +1313,8 @@
                            , "HBackRemark": tableMain[0]["HBackRemark"]
                            , "HReportEmpID": tableMain[0]["HReportEmpID"]
                            , "HReportEmpName": tableMain[0]["HReportEmpName"]
                            , "HReceiveEmp": tableMain[0]["HReceiveEmp"]
                            , "HCopyEmp": tableMain[0]["HCopyEmp"]
                        });
                        //组织的值HOrgID变化,重新渲染
@@ -843,9 +1323,12 @@
                        //子表  èµ‹å€¼
                        for (var i = 0; i < tableSub.length; i++) {
                            tableSub[i].RowID = (i + 1) * 10;
                            tableSub[i]["uploadStatus"] = tableSub[i]["HWeekReportFileName"] ? 2 : 0
                        }
                        option.data = tableSub;
                        attachmentOption.data = tableSub;
                        table.render(option);
                        table.render(attachmentOption)
                        CheckedSet_tableSub();
                        form.render('select');
                    }
@@ -857,6 +1340,7 @@
            function set_WorkTaskReport() {
                var data = getUrlVars_JSON().data;
                var dataArray = [];
                var AttachmentArray = [];
                for (var i = 0; i < data.length; i++) {
                    var NewRow =
                    {
@@ -878,11 +1362,23 @@
                        , "HSourceBillNo": data[i].HSourceBillNo
                        , "HSourceBillType": data[i].HSourceBillType
                    };
                    var attachmentNewRaw = {
                        "HWeekReportFileAddr": ""
                        , "HWeekReportFileName": ""
                        , "HWeekProDays": "0"
                        , "Size": ""
                        , "Status": ""
                        , "uploadStatus": 0
                    }
                    dataArray.push(NewRow);
                    AttachmentArray.push(attachmentNewRaw)
                }
                option.data = dataArray;
                table.render(option);
                attachmentOption.data = AttachmentArray;
                table.render(attachmentOption)
                CheckedSet_tableSub();
@@ -1065,7 +1561,11 @@
                        if (HRelTimes.substring(HRelTimes.length - 1, HRelTimes.length) == ".") {
                            layer.msg("第" + (i + 1) + "行:耗用工时末尾不能为.!");
                            return;
                        } else {
                        } else if (HRelTimes == "0") {
                            layer.msg("第" + (i + 1) + "行:耗用工时不能为0!");
                            return;
                        }
                        else {
                            var ref = /^[0-9]+\.?[0-9]*$/;
                            if (!ref.test(HRelTimes)) {
                                layer.msg("第" + (i + 1) + "行:耗用工时请输正确入数字!");
@@ -1079,9 +1579,9 @@
                //#region å­è¡¨å…³é”®å­—段重复检验
                var num = [];
                for (var i = 0; i < option.data.length; i++) {
                    temp = option.data[i]["HProjectID"] + "|" + option.data[i]["HProjectStageID"] + "|" + option.data[i]["HName"];
                    temp = option.data[i]["HProjectID"] + "|" + option.data[i]["HProjectStageID"] + "|" + option.data[i]["HName"] + "|" + option.data[i]["HSourceInterID"] + "|" + option.data[i]["HSourceEntryID"];
                    if ($.inArray(temp, num) != -1) {
                        layer.msg("第" + (i + 1) + "行:项目代码、项目阶段、任务名称重复,请重新选择!");
                        layer.msg("第" + (i + 1) + "行:任务重复,请重新选择!");
                        return false;
                    }
                    num.push(temp);
@@ -1151,6 +1651,12 @@
                            oldData.splice(obj.tr.data('index'), 1)
                            option.data = oldData;//将数据绑定到data上
                            table.render(option);
                            var oldDataAttachment = table.cache['AttachmentTable'];
                            oldDataAttachment.splice(obj.tr.data('index'), 1)
                            attachmentOption.data = oldDataAttachment
                            table.render(attachmentOption)
                            CheckedSet_tableSub();
                            layer.close(index);
                        }
@@ -1267,12 +1773,74 @@
                                    layer.close(index);//关闭弹窗
                                }
                                , btn2: function (index, layero) { }
                                , end: function () {
                                    if (OptionData[0].关闭人 == null || OptionData[0].关闭人 == "") {
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HName": OptionData[0].任务名称
                                            , "HTaskNote": OptionData[0].任务描述
                                            , "HType": OptionData[0].任务类型
                                            , "HProjectID": OptionData[0].HProjectID
                                            , "HProNumber": OptionData[0].项目代码
                                            , "HProjectStageID": OptionData[0].HProjectStageID
                                            , "HProjectStageName": OptionData[0].项目阶段
                                            , "HSourceInterID": OptionData[0].HInterID
                                            , "HSourceEntryID": OptionData[0].HEntryID
                                            , "HSourceBillNo": OptionData[0].单据号
                                            , "HSourceBillType": OptionData[0].单据类型
                                        })
                                    } else {
                                        layer.msg("该任务已关闭,请重新选择!");
                                    }
                                }
                            })
                        }
                        obj.event = "";
                        return false;
                    }
                })
            }
            //#endregion
            //#region æŸ¥è¯¢  æˆ‘的任务下推查询数据
            function get_Display() {
                var ajaxLoad = layer.load();
                $.ajax({
                    url: GetWEBURL() + '/PM_WorkTaskBill/XTList',
                    type: "GET",
                    async: false,
                    data: { "HInterID": linterid, sWhere: sWhere, "user": sessionStorage["HUserName"] },
                    success: function (data1) {
                        if (data1.count == 1) {
                            var rowdata = [];
                            for (var i = 0; i < data1.data.length; i++) {
                                rowdata.push(
                                    {
                                        "HName": data1.data[i].任务名称
                                        , "HTaskNote": data1.data[i].任务描述
                                        , "HType": data1.data[i].任务类型
                                        , "HProjectID": data1.data[i].HProjectID
                                        , "HProNumber": data1.data[i].项目代码
                                        , "HProjectStageID": data1.data[i].HProjectStageID
                                        , "HProjectStageName": data1.data[i].项目阶段
                                        , "HSourceInterID": data1.data[i].HInterID
                                        , "HSourceEntryID": data1.data[i].HEntryID
                                        , "HSourceBillNo": data1.data[i].单据号
                                        , "HSourceBillType": data1.data[i].单据类型
                                        , "HRelTimes": data1.data[i].已耗用工时
                                    });
                            }
                            option.data = rowdata;
                            table.render(option);
                            CheckedSet_tableSub();
                            form.render('select');
                        }
                    }, error: function () {
                        layer.close(ajaxLoad);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
@@ -1442,8 +2010,22 @@
        });
        //子表f7 å·¥ä½œä»»åŠ¡
        function GetWorkTaskValue(obj) {
            OptionData = obj;
        }
        //汇报人
        function GetHReportValue(obj) {
            $("#HReportEmpID").val(obj[0].HItemID);//客户id
            $("#HReportEmpName").val(obj[0].职员名称);//客户名称
        }
        //接收人
        function GetHReceiveValue(obj) {
            $("#HReceiveEmp").val(obj[0].职员名称);//接收人名称
        }
    </script>
</body>
</html>