中扬CRM客户关系管理系统
LSH
2024-04-03 674aef62d298f9fbce41b9b1725c71d056dfd55b
src/main/webapp/static/js/weekly/weekly.js
@@ -5,6 +5,20 @@
var htmlCstmrData;
var indexS = "9999,8888";
var indexDelSign = 0;
let nowUserId2 = 0;
fWeekly();
function fWeekly() {
    layui.jquery.ajax({
        url: baseUrl + "/dashboard/user/id/popup/auth",
        data:{token : localStorage.getItem('token')},
        method: 'GET',
        success: function (res) {
            if (res.code === 200) {
                nowUserId2 = res.data;
            }
        }
    })
}
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
@@ -21,6 +35,8 @@
    admin = layui.admin;
    $('#organization').html(localStorage.getItem('nickname') + ' <i class="layui-icon">&#xe61a;</i>');
    $(".laytable-cell-2-0-7").css('color', 'rgba(0, 0, 0, 0)');
    // 部门人员 筛选
    dropdown.render({
@@ -97,7 +113,6 @@
            ,{field: 'deptId$', align: 'center',title: '所属部门',hide : true}
            ,{field: 'cstmrIdsReality', align: 'center',title: '实际甲方单位ID集合',hide : true}
            ,{field: 'status$', align: 'center',title: '状态',hide : false}
            ,{field: 'settle$', align: 'center',title: '进度',hide : false}
            ,{field: 'settleMsg', align: 'center',title: '审核进度',hide : true}
            ,{field: 'weeklyDailyPlan', align: 'center',title: '日计划',hide : false, toolbar: '#tbLookPlan'}
            ,{field: 'weeklyDailyReality', align: 'center',title: '日行程',hide : false, toolbar: '#tbLookReality'}
@@ -107,12 +122,16 @@
            ,{field: 'updateBy$', align: 'center',title: '修改人员',hide : true}
            ,{field: 'updateTime$', align: 'center',title: 'update_time',hide : true}
            ,{field: 'memo', align: 'center',title: '备注(50字)',hide : false}
            ,{field: 'director$', align: 'center',title: '审批人',hide : true}
            ,{field: 'director$', align: 'center',title: '审核节点',hide : true}
            ,{field: 'director', align: 'center',title: '审核节点',hide : true}
            ,{field: 'settle', align: 'center',title: '进度',hide : true}
            ,{field: 'settleSize', align: 'center',title: '流程长度',hide : true}
            ,{field: 'settle$', align: 'center',title: '进度', style: 'color: #1890ff;cursor:pointer', event: 'more',hide: false}
            ,{field: 'settleCurrent', align: 'center',title: '当前进度',hide : true}
            ,{field: 'cstmrIdsPlan', align: 'center',title: '计划甲方单位ID集合',hide : true}
            ,{field: 'weeklyAll', align: 'center',title: '周数',hide : true}
            ,{field: 'weeklyNowMonth', align: 'center',title: '当月第几周',hide : true}
            ,{field: 'nowUserId', align: 'center', title: 'nowUserId', hide: true, templet:function(){ return nowUserId2 }}
            ,{field: 'weeklyYear', align: 'center',title: '年',hide : true}
            ,{field: 'weeklyMonth', align: 'center',title: '月',hide : true}
            ,{field: 'weeklyDay', align: 'center',title: '日',hide : true}
@@ -288,7 +307,6 @@
                        url: baseUrl+"/weekly/delete/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: {ids: data.id},
                        method: 'POST',
                        traditional:true,
                        success: function (res) {
                            if (res.code === 200){
@@ -336,7 +354,7 @@
                            cols: [[
                                {type: 'numbers'}
                                ,{field: 'weeklyDay$', align: 'center',title: '星期'}
                                ,{field: 'dailyTime$', align: 'center',title: '日期'}
                                ,{field: 'dailyTime$',width : 120, align: 'center',title: '日期'}
                                ,{field: 'workContent', align: 'center', title: '工作内容', edit:false}
                                ,{field: 'workPurpose', title: '工作目的', edit:false}
                                ,{field: 'comment', title: '评论', edit:false}
@@ -346,7 +364,7 @@
                                // ,{field: 'director', align: 'center',title: '负责人'}
                                // ,{field: 'settleSize', align: 'center',title: '流程长度'}
                                // ,{field: 'settleCurrent', align: 'center',title: '当前进度'}
                                ,{field: 'cstmrId', align: 'center',title: '甲方单位ID'}//, templet: function () { return htmlCstme;}
                                ,{field: 'cstmrId$', align: 'center',title: '甲方单位ID'}//, templet: function () { return htmlCstme;}
                                ,{field: 'memo', align: 'center',title: '备注',   edit:false}
                            ]],
                            request: {
@@ -399,7 +417,7 @@
                            cols: [[
                                {type: 'numbers'}
                                ,{field: 'weeklyDay$', align: 'center',title: '星期'}
                                ,{field: 'dailyTime$', align: 'center',title: '日期'}
                                ,{field: 'dailyTime$',width : 120, align: 'center',title: '日期'}
                                ,{field: 'workContent', align: 'center', title: '工作内容', edit:false}
                                ,{field: 'workPurpose', title: '工作目的', edit:false}
                                ,{field: 'comment', title: '评论', edit:false}
@@ -409,7 +427,7 @@
                                // ,{field: 'director', align: 'center',title: '负责人'}
                                // ,{field: 'settleSize', align: 'center',title: '流程长度'}
                                // ,{field: 'settleCurrent', align: 'center',title: '当前进度'}
                                ,{field: 'cstmrId', align: 'center',title: '甲方单位ID'}//, templet: function () { return htmlCstme;}
                                ,{field: 'cstmrId$', align: 'center',title: '甲方单位ID'}//, templet: function () { return htmlCstme;}
                                ,{field: 'memo', align: 'center',title: '备注',   edit:false}
                            ]],
                            request: {
@@ -435,8 +453,84 @@
                    }
                });
                break;
            case 'approval':
                layer.confirm('审批通过?', {
                    skin: 'layui-layer-admin',
                    shade: .1,
                    offset: '200px',
                    title: data.name
                }, function (i) {
                    layer.close(i);
                    approval(data.id);
                });
                break;
            case 'approvalEnd':
                layer.confirm('审批拒绝?', {
                    skin: 'layui-layer-admin',
                    shade: .1,
                    offset: '200px',
                    title: data.name
                }, function (i) {
                    layer.close(i);
                    approvalEnd(data.id);
                });
                break;
        }
    });
    function approvalEnd(weeklyId, plannerId, dIdx) {
        let loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl+"/weekly/approvalEnd/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                weeklyId: weeklyId,
                plannerId: plannerId
            },
            method: 'POST',
            success: function (res) {
                if (dIdx) {
                    layer.close(dIdx);
                }
                layer.close(loadIndex);
                if (res.code === 200){
                    layer.msg(res.msg, {icon: 1});
                    tableReload();
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }
        })
    }
    function approval(weeklyId, plannerId, dIdx) {
        let loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl+"/weekly/approval/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                weeklyId: weeklyId,
                plannerId: plannerId
            },
            method: 'POST',
            success: function (res) {
                if (dIdx) {
                    layer.close(dIdx);
                }
                layer.close(loadIndex);
                if (res.code === 200){
                    layer.msg(res.msg, {icon: 1});
                    tableReload();
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }
        })
    }
    // 搜索
    form.on('submit(search)', function (data) {
@@ -504,7 +598,12 @@
                            }
                        }
                    })
                    location.reload();
                    return false;
                });
                $('#cancelBtn').on('click', function () {
                    location.reload();
                });
                // 明细表格
                var xxDataList = [];
@@ -520,6 +619,7 @@
                        ,{field: 'weeklyDay$', align: 'center',title: '星期'}
                        ,{field: 'workContent', title: '工作内容', style: 'color: blue;font-weight: bold', edit:true}
                        ,{field: 'workPurpose', title: '工作目的', style: 'color: blue;font-weight: bold', edit:true}
                        ,{field: 'addr', title: '地址', style: 'color: blue;font-weight: bold', edit:true}
                        ,{field: 'comment', title: '评论', style: 'color: blue;font-weight: bold', edit:true}
                        ,{field: 'weeklyMatter', title: '需协助事项', style: 'color: blue;font-weight: bold', edit:true}
                        // ,{field: 'dailyTime$', align: 'center',title: '日报日期'}
@@ -541,7 +641,7 @@
                    },
                    done: function (res, curr, count) {
                        $(".layui-table-cell").css('overflow', 'visible');//解决layui数据表格中嵌套下拉框显示问题
                        $(".laytable-cell-2-0-6").css('color', 'rgba(0, 0, 0, 0)');
                        $(".laytable-cell-2-0-7").css('color', 'rgba(0, 0, 0, 0)');
                        $(layero).find('.layui-table-view').css('margin', '0');
                        var options = this;
@@ -549,29 +649,22 @@
                        // 获取当前行数据
                        table.getRowData = function(elem){
                            var index = $(elem).closest('tr').data('index');
                            console.log("index-----")
                            console.log(index)
                            var indexArray = indexS.split(","); // 将字符串拆分为数组
                            // 遍历数组中的每个元素
                            for (var i = 0; i < indexArray.length; i++) {
                                var element = Number(indexArray[i]);
                                // 进行相应的操作
                                console.log("element-----");
                                console.log(element);
                                if (element===index){
                                    indexSign = 1;
                                }
                            }
                            if (indexSign === 0){
                                indexS = indexS+","+index;
                                console.log("indexS-----")
                                console.log(indexS)
                            }
                            return table.cache[options.id][index] || {};
                        };
                        if (indexSign === 0 && indexDelSign === 0){
                            console.log("渲染")
                            // 渲染搜索模板
                            $.ajax({
                                url: baseUrl+"/cstmr/all/get/kv",
@@ -582,10 +675,10 @@
                                method: 'POST',
                                // async: false, // 设置为同步执行
                                success: function (res) {
                                    console.log(res)
                                    console.log($("#cstmrId").html())
                                    // console.log(res)
                                    // console.log($("#cstmrId").html())
                                    res.data.forEach((item) => {
                                        console.log(item)
                                        // console.log(item)
                                        $("#cstmrId").append("<option value='" + item.value  + "';"+" class=\"cstmrDetl\""+">" + item.name + "</option>")
                                    })
                                }
@@ -593,7 +686,7 @@
                        }
                        $('.select-cstmr').on('change', function(){
                            console.log("cstmrId")
                            // console.log("cstmrId")
                            var value = this.value; // 获取选中项 value
                            var data = table.getRowData(this);
                            xxDataList.forEach(res => {
@@ -839,6 +932,7 @@
                            }
                        }
                    })
                    location.reload();
                    return false;
                });
                // 明细表格
@@ -855,6 +949,7 @@
                        ,{field: 'weeklyDay$', align: 'center',title: '星期'}
                        ,{field: 'workContent', title: '工作内容', style: 'color: blue;font-weight: bold', edit:true}
                        ,{field: 'workPurpose', title: '工作目的', style: 'color: blue;font-weight: bold', edit:true}
                        ,{field: 'addr', title: '地址', style: 'color: blue;font-weight: bold', edit:true}
                        ,{field: 'comment', title: '评论', style: 'color: blue;font-weight: bold', edit:true}
                        ,{field: 'weeklyMatter', title: '需协助事项', style: 'color: blue;font-weight: bold', edit:true}
                        // ,{field: 'dailyTime$', align: 'center',title: '日报日期'}
@@ -876,19 +971,52 @@
                    },
                    done: function (res, curr, count) {
                        $(".layui-table-cell").css('overflow', 'visible');//解决layui数据表格中嵌套下拉框显示问题
                        // $(".laytable-cell-2-0-6").css('color', 'rgba(0, 0, 0, 0)');
                        $(".laytable-cell-2-0-6").css('color', 'rgba(0, 0, 0, 0)');
                        $(layero).find('.layui-table-view').css('margin', '0');
                        var options = this;
                        var indexSign = 0;
                        // 获取当前行数据
                        table.getRowData = function(elem){
                            var index = $(elem).closest('tr').data('index');
                            var indexArray = indexS.split(","); // 将字符串拆分为数组
                            // 遍历数组中的每个元素
                            for (var i = 0; i < indexArray.length; i++) {
                                var element = Number(indexArray[i]);
                                // 进行相应的操作
                                if (element===index){
                                    indexSign = 1;
                                }
                            }
                            if (indexSign === 0){
                                indexS = indexS+","+index;
                            }
                            return table.cache[options.id][index] || {};
                        };
                        if (indexSign === 0 && indexDelSign === 0){
                            // 渲染搜索模板
                            $.ajax({
                                url: baseUrl+"/cstmr/all/get/kv",
                                headers: {'token': localStorage.getItem('token')},
                                data: {
                                    limit: 9999
                                },
                                method: 'POST',
                                // async: false, // 设置为同步执行
                                success: function (res) {
                                    // console.log(res)
                                    // console.log($("#cstmrId").html())
                                    res.data.forEach((item) => {
                                        // console.log(item)
                                        $("#cstmrId").append("<option value='" + item.value  + "';"+" class=\"cstmrDetl\""+">" + item.name + "</option>")
                                    })
                                }
                            })
                        }
                        $('.select-cstmr').on('change', function(){
                            console.log("cstmrId")
                            // console.log("cstmrId")
                            var value = this.value; // 获取选中项 value
                            var data = table.getRowData(this);
                            xxDataList.forEach(res => {
@@ -898,6 +1026,29 @@
                                    res.cstmrId = value;
                                }
                            })
                        });
                        $(document).ready(function () {
                            $.ajax({
                                url: baseUrl + "/cstmr/all/get/kv",
                                headers: { 'token': localStorage.getItem('token') },
                                data: {
                                    limit: 9999
                                },
                                method: 'POST',
                                success: function (res) {
                                    if (res.code === 200) {
                                        // console.log("res111111111111")
                                        // console.log(res)
                                        var template = $('#cstmrId').html(); // 获取模板内容
                                        var compiledTemplate = Handlebars.compile(template); // 编译模板
                                        var html = compiledTemplate(res.data); // 将数据应用到模板中
                                        $('.select-cstmr').html(html); // 渲染模板到页面
                                    } else {
                                        // 处理异常情况
                                    }
                                }
                            });
                        });
                    },
                    size: ''
@@ -1081,8 +1232,10 @@
// 关闭动作
$(document).on('click','#data-detail-close', function () {
    parent.layer.closeAll();
    location.reload();
});
function tableReload(child) {
    var searchData = {};
    $.each($('#search-box [name]').serializeArray(), function() {