中扬CRM客户关系管理系统
LSH
2023-08-22 e89a0bdd6041774d77408744993ba3b98a1e1c97
src/main/webapp/static/js/reimburseOnline/reimburseOnline.js
@@ -82,18 +82,20 @@
        toolbar: '#toolbar',
        cellMinWidth: 150,
        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: 'orderNum', align: 'center',title: '报销单号'}
            ,{field: 'planId$', 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: '报价数据'}
            // {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: 'checkData', align: 'center',title: '是否冲账',hide: false}
            ,{field: 'orderNum', align: 'center',title: '报销单号',width: 320, hide:false}
            ,{field: 'itemId', align: 'center',title: '项目号',hide: false}
            ,{field: 'createTime$', align: 'center',title: '创建时间',hide: false}
            ,{field: 'updateTime$', align: 'center',title: '更新时间',hide: false}
            ,{field: 'status$', align: 'center',title: '状态',hide: false}
            ,{field: 'memberId$', align: 'center',title: '业务员',hide: false}
            ,{field: 'user$', align: 'center',title: '创建人员',hide: false}
            ,{field: 'updateUserId$', align: 'center',title: '更新人员',hide: false}
            // // ,{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 +367,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 +449,287 @@
        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({
                            reimburseId: Number(data.field.id),
                            docType: Number(data.field.docType),
                            orderNo: data.field.planId,
                            templateName: data.field.templateName,
                            checkData: data.field.checkData,
                            reimburseOnlineDetls: nList
                        }),
                        contentType:'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function (res) {
                            console.log(data)
                            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({