WebTM/views/ÏîÄ¿¹ÜÀí/ÏîÄ¿½×¶Î/PM_ProjectReportBill.html
@@ -64,9 +64,10 @@
        <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">
                    <div class="layui-tab" lay-filter="tab-POStockInBill" style="height:430px;">
                        <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>
                            <li lay-id="2" style="padding:1px;">其他信息</li>
                        </ul>
                        <div class="layui-tab-content">
@@ -91,9 +92,7 @@
                                            <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="HProNumber" name="HProNumber" id="HProNumber" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
                                                <input type="hidden" name="HProID" id="HProID" lay-verify="HProID" value="0">
                                                <input type="hidden" name="HMainSourceBillType" id="HMainSourceBillType" lay-verify="HMainSourceBillType" value="0">
                                                <input type="hidden" name="HMainSourceBillNo" id="HMainSourceBillNo" lay-verify="HMainSourceBillNo" value="0">
                                                <input type="hidden" name="HProjectID" id="HProjectID" lay-verify="HProjectID" value="0">
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearchHProNumber" id="btnSearchHProNumber" style="padding: 0 10px;float: right;margin-right: 3px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                                </button>
@@ -200,6 +199,67 @@
                                                <select name="HOrgID" id="HOrgID" lay-verify="HOrgID">
                                                    <!--动态渲染组织-->
                                                </select>
                                                <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" lay-verify="HMainSourceInterID" value="0">
                                                <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" lay-verify="HMainSourceEntryID" 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>
                                </div>
                            </div>
                            <!--附件信息-->
                            <div class="layui-tab-item">
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <div class="layui-upload">
                                        <button type="button" class="layui-btn" id="testList">选择文件</button><input class="layui-upload-file" type="file" accept="" name="file" multiple="">
                                        <div class="layui-tab" lay-filter="tab-fileList">
                                            <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>
                                            </ul>
                                            <div class="layui-tab-content">
                                                <!--等待上传-->
                                                <div class="layui-tab-item layui-show">
                                                    <div class="layui-form-item" style="padding-top: 10px;">
                                                        <div class="layui-upload-list">
                                                            <table class="layui-table">
                                                                <thead>
                                                                    <tr>
                                                                        <th>文件名</th>
                                                                        <th>大小</th>
                                                                        <th>状态</th>
                                                                        <th>操作</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody id="ProImgByList">
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                                <!--已经上传-->
                                                <div class="layui-tab-item">
                                                    <div class="layui-form-item" style="padding-top: 10px;">
                                                        <div class="layui-upload-list">
                                                            <table class="layui-table">
                                                                <thead>
                                                                    <tr>
                                                                        <th>文件名</th>
                                                                        <th>大小</th>
                                                                        <th>状态</th>
                                                                        <th>操作</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody id="ProImgByList1">
                                                                </tbody>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
@@ -332,14 +392,15 @@
            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_ProjectReportBill";
@@ -382,6 +443,8 @@
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
                //初始化项目阶段表
                get_InitGrid1();
                //文件选择初始化
                PicUpload();
            }
            //else if (OperationType == 2) {                                      //复制
            //    //禁用组织选项
@@ -405,12 +468,19 @@
                //初始化项目阶段表
                get_InitGrid1();
                RoadBillMain(linterid);
                //文件选择初始化
                PicUpload();
                //展示已上传的文件
                getFileList_loaded();
            } else if (OperationType == 4 && HProjectStageID != null) {
                ////禁用组织选项
                //$("#HOrgID").attr("disabled", true);
                OperationType = 4;
                //生成并设置主表的内码和单据号
                createBillNo();
                //汇报人初始化
                getHEmpByHUserName();
                //初始化制单人和制单时间
                $("#HMaker").val(sessionStorage["HUserName"]);
@@ -422,7 +492,8 @@
                get_InitGrid1();
                //下推-页面设置
                set_ProjectReport_Display();
                //文件选择初始化
                PicUpload();
            }
            //#endregion
@@ -654,6 +725,7 @@
            function createBillNo() {
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    async: false,
                    type: "GET",
                    data: { "HBillType": '4752' },
                    success: function (d) {
@@ -733,6 +805,7 @@
                        }
                        //设置表头数据
                        //设置文本框值
                        $("#HProjectID").val(checkStatus.data[0].HInterID);
                        $("#HProNumber").val(checkStatus.data[0].项目代码);
                        $("#HProjectStageID").val(checkStatus.data[0].HProjectStageID);
                        $("#HProjectStageName").val(checkStatus.data[0].项目阶段);
@@ -741,6 +814,13 @@
                        $("#HRelationGoods").val(checkStatus.data[0].阶段相关交付物);
                        $("#HIsKey").val((checkStatus.data[0].里程碑=='Y'?true:false));
                        $("#HRate").val(checkStatus.data[0].阶段业绩占比);
                        $("#HMainSourceInterID").val(checkStatus.data[0].HInterID);
                        $("#HMainSourceEntryID").val(checkStatus.data[0].HEntryID);
                        $("#HMainSourceBillNo").val(checkStatus.data[0].单据号);
                        $("#HMainSourceBillType").val(checkStatus.data[0].单据类型);
                        //设置复选框选中状态
                        if ($("#HIsKey").val() == "true") {
@@ -963,6 +1043,115 @@
            }
            //#endregion
            //#region æ–‡ä»¶ä¸Šä¼ 
            function PicUpload() {
                //多图片上传
                //多文件列表示例
                var ProImgByList = $('#ProImgByList')
                    , uploadListIns = upload.render({
                        elem: '#testList'
                        , url: GetWEBURL() + "/Cj_StationOutBill/UploadFile1"
                        , accept: 'file'
                        , multiple: true
                        , auto: false
                        //, bindAction: '#testListAction' //按扭绑定
                        , data: { "HBillNo": $("#HBillNo").val(), "HRemark": $("#HRemark").val(), "HUserName": sessionStorage["HUserName"] }
                        , choose: function (obj) {
                            var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                            //读取本地文件
                            obj.preview(function (index, file, result) {
                                var tr = $(['<tr id="upload-' + index + '">'
                                    , '<td>' + file.name + '</td>'
                                    , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
                                    , '<td>等待上传</td>'
                                    , '<td>'
                                    , '<button class="layui-btn layui-btn-xs demo-reload ">上传</button>'
                                    , '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                                    , '</td>'
                                    , '</tr>'].join(''));
                                //单个重传
                                tr.find('.demo-reload').on('click', function () {
                                    obj.upload(index, file);
                                    return false;
                                });
                                //删除
                                tr.find('.demo-delete').on('click', function () {
                                    delete files[index]; //删除对应的文件
                                    tr.remove();
                                    uploadListIns.config.elem.next()[0].value = ''; //清空 input file å€¼ï¼Œä»¥å…åˆ é™¤åŽå‡ºçŽ°åŒåæ–‡ä»¶ä¸å¯é€‰
                                });
                                ProImgByList.append(tr);
                            });
                        }
                        , done: function (res, index, upload) {
                            if (res.code == 1) { //上传成功
                                var tr = ProImgByList.find('tr#upload-' + index)
                                    , tds = tr.children();
                                tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                                tds.eq(3).html(''); //清空操作
                                //tds.eq(3).find('.demo-reload').addClass('layui-hide'); //隐藏上传
                                //展示该单据全部上传的文件
                                getFileList_loaded();
                                return delete this.files[index]; //删除文件队列已经上传成功的文件
                            }
                            this.error(index, upload);
                        }
                        , error: function (index, upload) {
                            var tr = ProImgByList.find('tr#upload-' + index)
                                , tds = tr.children();
                            tds.eq(2).html('<span style="color: #FF5722;">上传失败[检查文件名及文件格式]</span>');
                            tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示上传
                        }
                    });
            }
            //#endregion
            //#region ç¼–辑时,获取已上传的文件列表
            function getFileList_loaded() {
                var HBillNo = $("#HBillNo").val();
                if (HBillNo != null || HBillNo != undefined) {
                    var ProImgByList = $('#ProImgByList1')
                    $.ajax({
                        url: GetWEBURL() + '/Cj_StationOutBill/Filelist',
                        async: false,
                        type: "GET",
                        data: { "HBillNo": HBillNo },
                        success: function (data1) {
                            if (data1.count == 1) {
                                var index = 0;
                                $('#ProImgByList1').empty();
                                for (var i = 0; i < data1.data.length; i++) {
                                    var tr = $(['<tr id="upload-' + i + '">'
                                        , '<td style="display:none">' + data1.data[i].HItemID + '</td>'
                                        , '<td style="display:none">' + data1.data[i].HSourceBillNo + '</td>'
                                        , '<td>' + data1.data[i].HFileName + '</td>'
                                        , '<td>' + (data1.data[i].HFileSize / 1014).toFixed(1) + 'kb</td>'
                                        , '<td style="color: #5FB878;">上传成功</td>'
                                        , '<td style="display:none">' + data1.data[i].url + '</td>'
                                        , '<td>'
                                        , '<button class="layui-btn layui-btn-xs  demo-dowload" type="button" id="deltefile" onclick="javascript:dowload(this)"><i class="layui-icon layui-icon-download-circle layuiadmin-button-btn"></i>下载</button>'
                                        , '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" type="button" id="deltefile" onclick="javascript:toManager(this)"><i class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>删除</button>'
                                        , '</td>'
                                        , '</tr>'].join(''));
                                    $('#ProImgByList1').append(tr);
                                }
                            } else {
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                            }
                        }, error: function () {
                            layer.alert("接口请求失败!", { icon: 5 });
                        }
                    });
                }
            }
            //#endregion
            //#region ä¿å­˜HMaker
            function set_AddNew(data) {
                //获取子表数据
@@ -1055,6 +1244,12 @@
                            , "HRate": tableMain[0]["HRate"]
                            , "HOrgID": tableMain[0]["HOrgID"]
                            , "HRemark": tableMain[0]["HRemark"]
                            , "HMainSourceInterID": tableMain[0]["HMainSourceInterID"]
                            , "HMainSourceEntryID": tableMain[0]["HMainSourceEntryID"]
                            , "HMainSourceBillNo": tableMain[0]["HMainSourceBillNo"]
                            , "HMainSourceBillType": tableMain[0]["HMainSourceBillType"]
                            , "HMaker": tableMain[0]["HMaker"]
                            , "HUpdater": tableMain[0]["HUpdater"]
                            , "HChecker": tableMain[0]["HChecker"]
@@ -1106,10 +1301,8 @@
                        //主表 èµ‹å€¼
                        form.val("formData", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                            "HProID": tableMain[0]["HInterID"]
                            "HProjectID": tableMain[0]["HInterID"]
                            , "HProNumber": tableMain[0]["项目代码"]
                            , "HMainSourceBillNo": tableMain[0]["单据号"]
                            , "HMainSourceBillType": tableMain[0]["单据类型"]
                            , "HProjectStageID": tableMain[0]["HProjectStageID"]
                            , "HProjectStageName": tableMain[0]["项目阶段"]
                            , "HStageNote": tableMain[0]["项目阶段详细内容"]
@@ -1117,6 +1310,11 @@
                            , "HIsKey": tableMain[0]["里程碑"]=="Y"?true:false
                            , "HRate": tableMain[0]["阶段业绩占比"]
                            , "HOrgID": tableMain[0]["HOrgID"]
                            , "HMainSourceInterID": tableMain[0]["HInterID"]
                            , "HMainSourceEntryID": tableMain[0]["HEntryID"]
                            , "HMainSourceBillNo": tableMain[0]["单据号"]
                            , "HMainSourceBillType": tableMain[0]["单据类型"]
                        });
                        //若该阶段为里程碑,则设置里程碑复选框为选中
                        if (tableMain[0]["里程碑"]=="Y") {
@@ -1525,7 +1723,49 @@
        });
        //#region ä¸‹è½½å·²ä¸Šä¼ çš„æ–‡ä»¶
        function dowload(r) {
            //得到当前所在行
            var rows = r.parentNode.parentNode.rowIndex;
            //得到所在行的第五列的内容:文件地址
            var url = $("#ProImgByList1 tr:eq(" + (rows - 1) + ") td:eq(5)").html();
            /*window.location.href = url;*/
            window.open(url)
        }
        //#endregion
        //#region åˆ é™¤å·²ä¸Šä¼ çš„æ–‡ä»¶
        function toManager(r) {
            //得到当前所在行
            var rows = r.parentNode.parentNode.rowIndex;
            //得到所在行的第一列的内容:主键ID
            var HItemID = $("#ProImgByList1 tr:eq(" + (rows - 1) + ") td:eq(0)").html();
            //得到所在行的第二列的内容:单据号
            var HSourceBillNo = $("#ProImgByList1 tr:eq(" + (rows - 1) + ") td:eq(1)").html();
            //得到所在行的第三列的内容:文件名称
            var HFileName = $("#ProImgByList1 tr:eq(" + (rows - 1) + ") td:eq(2)").html();
            layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                //删除已上传文件
                $.ajax({
                    url: GetWEBURL() + '/Cj_StationOutBill/DeleteFilelist',
                    type: "GET",
                    data: { "HItemID": HItemID, "HSourceBillNo": HSourceBillNo, "HFileName": HFileName },
                    success: function (data1) {
                        if (data1.count == 1) {
                            layer.alert(data1.Message, { icon: 1 });
                            $("#ProImgByList1 tr").eq((rows - 1)).remove();
                        }
                        else {
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            })
        }
            //#endregion
    </script>
</body>