From 1ca7b0411ab10ff36d7184d6a71c39be886d7af5 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期四, 17 八月 2023 17:01:50 +0800
Subject: [PATCH] #报销申请第二版

---
 src/main/webapp/static/js/reimburseOnline/reimburseOnline.js |  368 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 343 insertions(+), 25 deletions(-)

diff --git a/src/main/webapp/static/js/reimburseOnline/reimburseOnline.js b/src/main/webapp/static/js/reimburseOnline/reimburseOnline.js
index 90f1f1b..6cd9c1c 100644
--- a/src/main/webapp/static/js/reimburseOnline/reimburseOnline.js
+++ b/src/main/webapp/static/js/reimburseOnline/reimburseOnline.js
@@ -84,16 +84,17 @@
         cols: [[
             {type: 'checkbox', fixed: 'left'}
             ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80,hide: true}
-            ,{field: 'templateName', align: 'center',title: '鎶ラ攢鍚�',hide: false}
+            ,{field: 'templateName', align: 'center',title: '鎶ラ攢绫诲瀷',hide: false}
             ,{field: 'orderNum', align: 'center',title: '鎶ラ攢鍗曞彿'}
-            ,{field: 'planId$', align: 'center',title: '瑙勫垝鍗曞彿'}
+            ,{field: 'orderId$', align: 'center',title: '椤圭洰鍙�'}
             ,{field: 'createTime$', align: 'center',title: '鍒涘缓鏃堕棿'}
             ,{field: 'updateTime$', align: 'center',title: '鏇存柊鏃堕棿'}
             ,{field: 'status$', align: 'center',title: '鐘舵��'}
             ,{field: 'memberId$', align: 'center',title: '涓氬姟鍛�'}
             ,{field: 'user$', align: 'center',title: '鍒涘缓浜哄憳'}
             ,{field: 'updateUserId$', align: 'center',title: '鏇存柊浜哄憳'}
-            ,{field: 'checkDataStatus$', align: 'center',title: '鎶ヤ环鏁版嵁'}
+            // // ,{field: 'checkDataStatus$', align: 'center',title: '鎶ヤ环鏁版嵁'}
+            ,{align: 'center', title: '鎶ラ攢鏄庣粏', toolbar: '#tbLook', minWidth: 160, width: 160}
             ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:350}
         ]],
         request: {
@@ -365,6 +366,78 @@
                     }
                 });
                 break;
+            case "look":
+                var $a = $(obj.tr).find('a[lay-event="look"]');
+                var offset = $a.offset();
+                var top = offset.top;
+                var left = offset.left;
+                layer.open({
+                    type: 1,
+                    title: false,
+                    area: '2100px',
+                    offset: [top + 'px', (left - 1730 + $a.outerWidth()) + 'px'],
+                    shade: .01,
+                    shadeClose: true,
+                    fixed: false,
+                    content: '<table id="lookSSXMTable" lay-filter="lookSSXMTable"></table>',
+                    success: function (layero) {
+                        table.render({
+                            elem: '#lookSSXMTable',
+                            headers: {token: localStorage.getItem('token')},
+                            url: baseUrl+'/reimburseOnlineDetl/list/auth',
+                            where: {
+                                order_id: data.id
+                            },
+                            page: true,
+                            cellMinWidth: 100,
+                            cols: [[
+                                // {type: 'numbers'},
+                                {field: 'occupation', title: '浜嬬敱', width: 100},
+                                // {field: 'expenseType', title: '璐圭敤绫诲瀷', width: 100},
+                                {field: 'expenseType$', title: '璐圭敤绫诲瀷', width: 100},
+                                {field: 'taxRate', title: '绋庣巼', width: 60},
+                                {field: 'untaxedAmountInLocalCurrency', title: '鏈◣鏈竵閲戦', style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110},
+                                {field: 'untaxedAmount', title: '鏈◣閲戦', width: 100},
+                                {field: 'taxAmount', title: '绋庨', width: 60},
+                                {field: 'invoiceValue', title: '鍙戠エ閲戦',  style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110},
+                                {field: 'invoiceAmountInLocalCurrency', title: '鍙戠エ鏈竵閲戦',  style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110},
+                                {field: 'reimbursementRatio', title: '鎶ラ攢姣斾緥', width: 100},
+                                {field: 'reimbursementAmount', title: '鎶ラ攢閲戦', width: 100},
+                                {field: 'reimbursementAmountInLocalCurrency', title: '鎶ラ攢鏈竵閲戦', width: 120},
+                                {field: 'cashierConfirmationAmount', title: '鍑虹撼纭閲戦', width: 120},
+                                {field: 'cashierCurrency', title: '鍑虹撼甯佺', width: 100},
+                                {field: 'departureTime', title: '鍑哄彂鏃ユ湡', width: 100},
+                                {field: 'cashierConfirmationAmount', title: '鍑虹撼纭閲戦', width: 120},
+                                {field: 'userId', title: '鍒楁敮浜哄憳', width: 120},
+                                {field: 'deptId', title: '鍒楁敮閮ㄩ棬', width: 120},
+                                {field: 'updateTime', title: '鏇存柊鏃ユ湡', width: 100},
+                                // {field: 'updateUserId', title: '鏇存柊浜哄憳ID', width: 160},
+                                {field: 'updateUserName', title: '鏇存柊浜哄憳鍚嶅瓧'},
+                                // {field: 'creationTime', title: '鍒涘缓鏃ユ湡', width: 160}
+                            ]],
+                            request: {
+                                pageName: 'curr',
+                                pageSize: 'limit'
+                            },
+                            parseData: function (res) {
+                                return {
+                                    'code': res.code,
+                                    'msg': res.msg,
+                                    'count': res.data.total,
+                                    'data': res.data.records
+                                }
+                            },
+                            response: {
+                                statusCode: 200
+                            },
+                            done: function () {
+                                $(layero).find('.layui-table-view').css('margin', '0');
+                            },
+                            size: ''
+                        });
+                    }
+                });
+                break;
         }
     });
 
@@ -375,39 +448,284 @@
         tableReload();
     });
 
-    /* 寮圭獥 - 鏂板銆佷慨鏀� */
-    function showEditModel(mData) {
+    // 鏄剧ず琛ㄥ崟寮圭獥
+    function showEditModel(expTpe) {
         admin.open({
             type: 1,
-            area: '800px',
-            title: (mData ? '淇敼' : '娣诲姞') + '鏍镐环',
+            title: (expTpe ? '淇敼' : '娣诲姞') + '鎶ラ攢瀹℃壒',
             content: $('#editDialog').html(),
+            area: '2200px',
             success: function (layero, dIndex) {
-                form.val('detail', mData);
-                form.on('submit(editSubmit)', function (data) {
-                    var loadIndex = layer.load(2);
-                    layer.close(loadIndex);
-                    layer.close(dIndex);
-                    layer.open({
-                        type: 2,
-                        title: '鏂板',
-                        maxmin: true,
-                        area: [top.detailWidth, top.detailHeight],
-                        shadeClose: false,
-                        content: 'reimburseOnline_detail.html?item_id=' + data.field.planId + "&pri_id=" + data.field.priId,
-                        success: function(layero, index){
-                            clearFormVal(layer.getChildFrame('#detail', index));
-                            // layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
+                $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                var isExpAdd = !expTpe;
+                // 鍥炴樉鏁版嵁
+                form.val('editForm', expTpe);
+                if (expTpe) {
+                    // $('#orderNo').attr("disabled", "disabled");
+                }
+                // 琛ㄥ崟鎻愪氦浜嬩欢
+                form.on('submit(orderEditSubmit)', function (data) {
+                    // 缁勮鏁版嵁
+                    if (xxDataList.length <= 0) {
+                        layer.tips('璇锋坊鍔犳姤閿�鏄庣粏', '#matAddBtnComment', {tips: [1, '#ff4c4c']});
+                        return false;
+                    }
+                    let nList = admin.util.deepClone(xxDataList);
+                    for (let xi = 0; xi < nList.length; xi++) {
+                        // if (nList[xi].anfme <= 0){
+                        //     layer.msg('鏄庣粏淇敼鏁伴噺涓嶅悎娉�', {icon: 2});
+                        //     return false;
+                        // }
+                    }
+                    layer.load(2);
+                    $.ajax({
+                        url: baseUrl+"/reimburseOnline/from/" + (isExpAdd?"add":"modify") + "/auth",
+                        headers: {'token': localStorage.getItem('token')},
+                        data: JSON.stringify({
+                            orderId: Number(data.field.id),
+                            docType: Number(data.field.docType),
+                            orderNo: data.field.orderNo,
+                            orderDetlList: nList
+                        }),
+                        contentType:'application/json;charset=UTF-8',
+                        method: 'POST',
+                        success: function (res) {
+                            layer.closeAll('loading');
+                            if (res.code === 200){
+                                layer.close(dIndex);
+                                $(".layui-laypage-btn")[0].click();
+                                layer.msg(res.msg, {icon: 1});
+                            } else if (res.code === 403){
+                                top.location.href = baseUrl+"/";
+                            }else {
+                                layer.msg(res.msg, {icon: 2});
+                            }
                         }
-                    });
+                    })
                     return false;
                 });
-                $(layero).children('.layui-layer-content').css('overflow', 'visible');
-                layui.form.render('select');
+                // 鏄庣粏琛ㄦ牸
+                var xxDataList = [];
+                var tbOptions = {
+                    elem: '#formSSXMTable',
+                    headers: {token: localStorage.getItem('token')},
+                    data: xxDataList,
+                    page: true,
+                    height: '350px;',
+                    cellMinWidth: 100,
+                    cols: [[
+                        {type: 'numbers', title: '#'},
+                        {field: 'occupation', title: '浜嬬敱', width: 100},
+                        // {field: 'expenseType', title: '璐圭敤绫诲瀷', width: 100},
+                        {field: 'expenseType$', title: '璐圭敤绫诲瀷', width: 100},
+                        {field: 'taxRate', title: '绋庣巼', width: 60},
+                        {field: 'untaxedAmountInLocalCurrency', title: '鏈◣鏈竵閲戦', width: 120},
+                        {field: 'untaxedAmount', title: '鏈◣閲戦', width: 100},
+                        {field: 'taxAmount', title: '绋庨', width: 60},
+                        {field: 'invoiceValue', title: '鍙戠エ閲戦', width: 100},
+                        {field: 'invoiceAmountInLocalCurrency', title: '鍙戠エ鏈竵閲戦', width: 120},
+                        {field: 'reimbursementRatio', title: '鎶ラ攢姣斾緥', width: 100},
+                        {field: 'reimbursementAmount', title: '鎶ラ攢閲戦', width: 100},
+                        {field: 'reimbursementAmountInLocalCurrency', title: '鎶ラ攢鏈竵閲戦', width: 120},
+                        {field: 'cashierConfirmationAmount', title: '鍑虹撼纭閲戦', width: 120},
+                        {field: 'cashierCurrency', title: '鍑虹撼甯佺', width: 100},
+                        {field: 'departureTime', title: '鍑哄彂鏃ユ湡', width: 100},
+                        {field: 'cashierConfirmationAmount', title: '鍑虹撼纭閲戦', width: 120},
+                        {field: 'userId', title: '鍒楁敮浜哄憳', width: 120},
+                        {field: 'deptId', title: '鍒楁敮閮ㄩ棬', width: 120},
+                        {field: 'updateTime', title: '鏇存柊鏃ユ湡', width: 100},
+                        // {field: 'updateUserId', title: '鏇存柊浜哄憳ID', width: 160},
+                        {field: 'updateUserName', title: '鏇存柊浜哄憳鍚嶅瓧'},
+                        // {field: 'creationTime', title: '鍒涘缓鏃ユ湡', width: 160}
+                    ]],
+                    done: function (res) {
+                        $(layero).find('.layui-table-view').css('margin', '0');
+                    },
+                    size: ''
+                };
+                if (!isExpAdd) {
+                    $.ajax({
+                        url: baseUrl+"/reimburseOnline/detl/all/auth?reimburseId=" + expTpe.id,
+                        headers: {'token': localStorage.getItem('token')},
+                        method: 'GET',
+                        async: false,
+                        success: function (res) {
+                            if (res.code === 200){
+                                xxDataList = res.data;
+                                tbOptions.data = xxDataList;
+                            } else if (res.code === 403){
+                                top.location.href = baseUrl+"/";
+                            }else {
+                                layer.msg(res.msg, {icon: 2})
+                            }
+                        }
+                    })
+                }
+                var insTbSSXM = table.render(tbOptions);
+                // 宸ュ叿鏉$偣鍑讳簨浠�
+                table.on('tool(formSSXMTable)', function (obj) {
+                    var data = obj.data;
+                    var layEvent = obj.event;
+                    if (layEvent === 'edit') {
+                        showEditModel2(data);
+                    } else if (layEvent === 'del') {
+                        layer.confirm('纭畾瑕佸垹闄ゅ悧锛�', {
+                            shade: .1,
+                            skin: 'layui-layer-admin'
+                        }, function (i) {
+                            layer.close(i);
+                            for (var j = 0; j < xxDataList.length; j++) {
+                                if (xxDataList[j].matnr === data.matnr && xxDataList[j].batch === data.batch) {
+                                    xxDataList.splice(j, 1);
+                                    break;
+                                }
+                            }
+                            insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
+                        });
+                    }
+                });
+                // 鏄庣粏鏁版嵁淇敼
+                table.on('edit(formSSXMTable)', function (obj) {
+                    let index = obj.tr.attr("data-index");
+                    let data = xxDataList[index];
+                    if (obj.field === 'anfme'){
+                        let vle = Number(obj.value);
+                        if (isNaN(vle)) {
+                            layer.msg("璇疯緭鍏ユ暟瀛�", {icon: 2});
+                            return false;
+                        } else {
+                            if (vle <= 0) {
+                                layer.msg("鏁伴噺蹇呴』澶т簬闆�", {icon: 2});
+                                return false;
+                            }
+                        }
+                    }
+                    data[obj.field] = obj.value;
+                    insTbSSXM.reload({data: xxDataList});
+                });
+
+                $('#matAddBtnComment').click(function () {
+                    showEditModel2();
+                });
+
+                // 鏄剧ず娣诲姞鏄庣粏琛ㄥ崟寮圭獥
+                function showEditModel2(exp) {
+                    admin.open({
+                        type: 1,
+                        offset: '150px',
+                        area: '680px',
+                        title: (exp ? '淇敼' : '娣诲姞') + '鏄庣粏',
+                        content: $('#matEditDialog').html(),
+                        success: function (layero, dIndex) {
+                            // 鍥炴樉鏁版嵁
+                            form.val('matEditForm', exp);
+                            // 琛ㄥ崟鎻愪氦浜嬩欢
+                            form.on('submit(matEditSubmit)', function (data) {
+                                let selectList = matXmSelect.getValue();
+                                for (let i = 0; i<selectList.length; i++) {
+                                    let item = selectList[i];
+                                    // 鏌ヨ鐗╂枡璇︽儏
+                                    $.ajax({
+                                        url: baseUrl+"/reimburseCostTypes/covert/"+item.value+"/auth",
+                                        headers: {'token': localStorage.getItem('token')},
+                                        method: 'GET',
+                                        async: false,
+                                        success: function (res) {
+                                            if (res.code === 200){
+                                                var bige=true;
+                                                for (var j = 0; j < xxDataList.length; j++) {
+                                                    if (xxDataList[j].matnr === res.data.matnr && xxDataList[j].batch === res.data.batch) {
+                                                        bige=false;
+                                                        break;
+                                                    }
+                                                }
+                                                if (bige){
+                                                    xxDataList.push(res.data);
+                                                    insTbSSXM.reload({data: xxDataList, page: {curr: 1}});
+                                                }
+                                            } else if (res.code === 403){
+                                                top.location.href = baseUrl+"/";
+                                            }else {
+                                                layer.msg(res.msg, {icon: 2})
+                                            }
+                                        }
+                                    })
+                                }
+                                layer.close(dIndex);
+                                return false;
+                            });
+                            // 娓叉煋鐗╂枡閫夋嫨
+                            var matXmSelect = xmSelect.render({
+                                el: '#reimburseCostTypes',
+                                style: {
+                                    width: '340px',
+                                },
+                                autoRow: true,
+                                toolbar: { show: true },
+                                filterable: true,
+                                remoteSearch: true,
+                                remoteMethod: function(val, cb, show){
+                                    $.ajax({
+                                        url: baseUrl+"/reimburseCostTypes/all/get/kv",
+                                        headers: {'token': localStorage.getItem('token')},
+                                        data: {
+                                            condition: val
+                                        },
+                                        method: 'POST',
+                                        success: function (res) {
+                                            if (res.code === 200){
+                                                cb(res.data)
+                                            } else {
+                                                cb([]);
+                                                layer.msg(res.msg, {icon: 2});
+                                            }
+                                        }
+                                    });
+                                }
+                            })
+                            // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯
+                            $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                            layui.form.render('select');
+                        }
+                    });
+                }
             }
         });
     }
 
+    /* 寮圭獥 - 鏂板銆佷慨鏀� */
+    // function showEditModel(mData) {
+    //     admin.open({
+    //         type: 1,
+    //         area: '800px',
+    //         title: (mData ? '淇敼' : '娣诲姞') + '鏍镐环',
+    //         content: $('#editDialog').html(),
+    //         success: function (layero, dIndex) {
+    //             form.val('detail', mData);
+    //             form.on('submit(editSubmit)', function (data) {
+    //                 var loadIndex = layer.load(2);
+    //                 layer.close(loadIndex);
+    //                 layer.close(dIndex);
+    //                 layer.open({
+    //                     type: 2,
+    //                     title: '鏂板',
+    //                     maxmin: true,
+    //                     area: [top.detailWidth, top.detailHeight],
+    //                     shadeClose: false,
+    //                     content: 'reimburseOnline_detail.html?item_id=' + data.field.planId + "&pri_id=" + data.field.priId,
+    //                     success: function(layero, index){
+    //                         clearFormVal(layer.getChildFrame('#detail', index));
+    //                         // layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
+    //                     }
+    //                 });
+    //                 return false;
+    //             });
+    //             $(layero).children('.layui-layer-content').css('overflow', 'visible');
+    //             layui.form.render('select');
+    //         }
+    //     });
+    // }
+
     //鏇存柊form
     function showEditForm(mData) {
         admin.open({

--
Gitblit v1.9.1