中扬CRM客户关系管理系统
LSH
2023-08-22 e89a0bdd6041774d77408744993ba3b98a1e1c97
src/main/webapp/static/js/priQuote/priQuote.js
@@ -3,14 +3,78 @@
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
    steps: 'steps/steps',
    cascader: 'cascader/cascader',
}).use(['table','laydate', 'form', 'admin', 'xmSelect', 'element', 'cascader', 'tree', 'dropdown'], function(){
}).use(['table','laydate', 'form', 'admin', 'xmSelect', 'element', 'cascader', 'steps', 'tree', 'dropdown','layer','upload', 'cascader'], function(){
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    admin = layui.admin;
    var tree = layui.tree;
    var steps = layui.steps;
    var element = layui.element;
    var upload = layui.upload;
    var xmSelect = layui.xmSelect;
    var cascader = layui.cascader;
    var dropdown = layui.dropdown;
    $('#organization').html(localStorage.getItem('nickname') + ' <i class="layui-icon">&#xe61a;</i>');
    // 部门人员 筛选
    dropdown.render({
        elem: '#organization'
        ,content: ['<div id="organizationTree" style="height: calc(100vh - 525px);border: none"></div>'].join('')
        ,style: 'width: 370px; height: 350px; padding: 0 15px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);'
        ,ready: function(){
            loadTree();
        }
    });
    // 树形图
    var organizationTree;
    window.loadTree = function(condition){
        var loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl+"/dept/user/tree/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                'condition': condition
            },
            method: 'POST',
            success: function (res) {
                layer.close(loadIndex);
                if (res.code === 200){
                    organizationTree = tree.render({
                        elem: '#organizationTree',
                        id: 'organizationTree',
                        onlyIconControl: true,
                        data: res.data,
                        click: function (obj) {
                            treeCond = {
                                key: obj.data.key,
                                val: obj.data.id
                            }
                            $('#organization').html(obj.data.title + ' <i class="layui-icon">&#xe61a;</i>');
                            $('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click');
                            $(obj.elem).children('.layui-tree-entry').addClass('ew-tree-click');
                            clearFormVal($('#search-box'));
                            tableIns.reload({
                                where: {[obj.data.key]: obj.data.id},
                                page: {curr: 1}
                            });
                        }
                    });
                    treeData = res.data;
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    layer.msg(res.msg)
                }
            }
        })
    }
    // 数据渲染
    tableIns = table.render({
@@ -25,16 +89,18 @@
        cols: [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
            ,{field: 'templateName', align: 'center',title: '模板名'}
            ,{field: 'orderNum', align: 'center',title: '报价预算单号'}
            ,{field: 'inOrderNum', align: 'center',title: '报价编号'}
            ,{field: 'itemId$', align: 'center',title: '项目名'}
            ,{field: 'createTime$', align: 'center',title: '创建时间'}
            ,{field: 'updateTime$', align: 'center',title: '更新时间'}
            ,{field: 'memberId$', align: 'center',title: '业务员'}
            ,{field: 'userId$', align: 'center',title: '创建人员'}
            ,{field: 'updateUserId$', align: 'center',title: '更新人员'}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:200}
            ,{field: 'templateName', align: 'center',title: '模板名', width: 220, style: 'color: #1890ff;cursor:pointer', event: 'more',hide: false}
            ,{field: 'orderNum', align: 'center',title: '报价预算单号',hide: false}
            ,{field: 'inOrderNum', align: 'center',title: '报价编号',hide: false}
            ,{field: 'planId$', align: 'center',title: '规划单号',hide: false}
            ,{field: 'planName$', align: 'center',title: '规划单名称',hide: false}
            ,{field: 'settle$', align: 'center',title: '进度', width: 150,hide: false}
            ,{field: 'createTime$', align: 'center',title: '创建时间',hide: false}
            ,{field: 'updateTime$', align: 'center',title: '更新时间',hide: false}
            ,{field: 'memberId$', align: 'center',title: '业务员',hide: false}
            ,{field: 'userId$', align: 'center',title: '创建人员',hide: true}
            ,{field: 'updateUserId$', align: 'center',title: '更新人员',hide: false}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:280}
        ]],
        request: {
            pageName: 'curr',
@@ -55,7 +121,7 @@
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            pageCurr=curr;
            pageCurr=curr;pageCount=count;
            limit();
        }
    });
@@ -86,6 +152,7 @@
    // 监听头工具栏事件
    table.on('toolbar(priQuote)', function (obj) {
        var checkStatus = table.checkStatus(obj.config.id);
        console.log(checkStatus)
        switch(obj.event) {
            case 'addBlank':
                showEditModel();
@@ -173,6 +240,42 @@
    table.on('tool(priQuote)', function(obj){
        var data = obj.data;
        switch (obj.event) {
            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 'refuse':
                layer.confirm('拒绝?', {
                    skin: 'layui-layer-admin',
                    shade: .1,
                    offset: '200px',
                    title: data.name
                }, function (i) {
                    layer.close(i);
                    refuse(data.id);
                });
                break;
            case 'more':
                top.priQuoteByMore = data.id;
                console.log(top.priQuoteByMore)
                admin.popupRight({
                    type: 1,
                    window: "top",
                    area: "1250px",
                    url: "priQuote_more.html",
                    end: function () {
                        // $(".layui-laypage-btn")[0].click();
                    }
                })
                break;
            case "quote":
                layer.open({
                    type: 2,
@@ -255,6 +358,59 @@
                layui.form.render('select');
            }
        });
    }
    function refuse(planId, plannerId, dIdx) {
        let loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl+"/priQuote/refuse/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                planId: planId,
                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(planId, plannerId, dIdx) {
        let loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl+"/priQuote/approval/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                planId: planId,
                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
@@ -383,7 +539,7 @@
        traditional:true,
        success: function (res) {
            if (res.code === 200){
                $("#itemName").val(res.data.itemId$)
                $("#planId").val(res.data.planId$)
                $("#priSalesNum").val(res.data.orderNum)
            } else if (res.code === 403){
                top.location.href = baseUrl+"/";