中扬CRM客户关系管理系统
#
LSH
2023-12-02 afa3bc1e2f39f66f59ee9b15d6af16593acdc9a4
src/main/webapp/static/js/contract/contract.js
@@ -1,7 +1,8 @@
var pageCurr;
var sign=false;
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).use(['table', 'laydate', 'form', 'admin', 'tree', 'dropdown'], function () {
}).use(['table', 'laydate', 'form', 'admin','xmSelect', 'tree', 'dropdown'], function () {
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
@@ -88,11 +89,12 @@
            , {field: 'status$', align: 'center', title: '状态'}
            , {field: 'userId$', align: 'center', title: '添加人员'}
            , {field: 'createTime$', align: 'center', title: '添加时间'}
            , {field: 'settle$', align: 'center',title: '进度', style: 'color: #1890ff;cursor:pointer', event: 'more',hide: false}
            , {field: 'updateBy$', align: 'center', title: '修改人员'}
            , {field: 'updateTime$', align: 'center', title: '修改时间'}
            , {field: 'memo', align: 'center', title: '备注'}
            , {fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 400}
            , {fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 500}
        ]],
        request: {
            pageName: 'curr',
@@ -193,28 +195,76 @@
    table.on('tool(contract)', function (obj) {
        var data = obj.data;
        switch (obj.event) {
            case 'edit':
                showEditModel(data);
            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 'more':
                top.contractByMore = data.id;
                admin.popupRight({
                    type: 1,
                    window: "top",
                    area: "1250px",
                    url: "contract_more.html",
                    end: function () {
                        // $(".layui-laypage-btn")[0].click();
                    }
                })
                break;
            case 'edit':
                if (sign){
                    showEditModel(data);
                    break;
                }else {
                    layer.msg('抱歉你没权限', {icon: 2});
                    break
                }
            case "del":
                del([data.id]);
                break;
            case "generate":
                //生成合同
                generate(data)
                break
                if (sign){
                    //生成合同
                    generate(data)
                    break
                }else {
                    layer.msg('抱歉你没权限', {icon: 2});
                    break
                }
            case "sales":
                //合同明细
                sales(data);
                break
                if (sign){
                    //合同明细
                    sales(data);
                    break
                }else {
                    layer.msg('抱歉你没权限', {icon: 2});
                    break
                }
            case "upload":
                //上传合同
                upload(data)
                break
                if (sign){
                    //上传合同
                    upload(data)
                    break
                }else {
                    layer.msg('抱歉你没权限', {icon: 2});
                    break
                }
            case "download":
                //下载合同
                download(data)
                break
                if (sign){
                    //下载合同
                    download(data)
                    break
                }else {
                    layer.msg('抱歉你没权限', {icon: 2});
                    break
                }
        }
    });
@@ -226,9 +276,12 @@
            title: (mData ? '修改' : '添加') + '合同',
            content: $('#editDialog').html(),
            success: function (layero, dIndex) {
                let loadNameXml = loadNameXmlSel()
                console.log(loadNameXml)
                layDateRender(mData);
                form.val('detail', mData);
                form.on('submit(editSubmit)', function (data) {
                    data.field.customer = loadNameXml.getValue()[0] ? loadNameXml.getValue()[0].name : null;
                    var loadIndex = layer.load(2);
                    $.ajax({
                        url: baseUrl + "/contract/" + (mData ? 'update' : 'add') + "/auth",
@@ -379,30 +432,28 @@
            headers: {'token': localStorage.getItem('token')},
            data: data,
            method: 'GET',
            xhrFields: {
                responseType: "blob" // 设置响应类型为二进制数据
            },
            success: function (res) {
                // 创建一个临时的下载链接
                const url = window.URL.createObjectURL(res);
                // 创建一个隐藏的 <a> 元素并设置下载链接
                const a = document.createElement("a");
                a.style.display = "none";
                a.href = url;
                let list = data.filepath.split(".")
                let suffix = "." + list[list.length - 1]//获取后缀名
                a.download = data.name + suffix; // 指定下载的文件名
                document.body.appendChild(a);
                // 触发点击事件以开始下载
                a.click();
                // 清理临时资源
                setTimeout(function () {
                    window.URL.revokeObjectURL(url);
                    document.body.removeChild(a);
                }, 100);
                location.href = res.data
                // // 创建一个临时的下载链接
                // const url = window.URL.createObjectURL(res);
                // // 创建一个隐藏的 <a> 元素并设置下载链接
                // const a = document.createElement("a");
                // a.style.display = "none";
                // a.href = url;
                //
                // let list = data.filepath.split(".")
                // let suffix = "." + list[list.length - 1]//获取后缀名
                // a.download = data.name + suffix; // 指定下载的文件名
                // document.body.appendChild(a);
                //
                // // 触发点击事件以开始下载
                // a.click();
                //
                // // 清理临时资源
                // setTimeout(function () {
                //     window.URL.revokeObjectURL(url);
                //     document.body.removeChild(a);
                // }, 100);
            }
        });
    }
@@ -472,8 +523,86 @@
    layDateRender();
    function approval(contractId, plannerId, dIdx) {
        let loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl+"/contract/approval/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                contractId: contractId,
                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});
                }
            }
        })
    }
    window.loadNameXmlSel = function () {
        return xmSelect.render({
            el: '#nameXmlSel',
            autoRow: true,
            filterable: true,
            remoteSearch: true,
            clickClose: true,
            radio: true,
            remoteMethod: function (val, cb, show) {
                $.ajax({
                    url: baseUrl + "/cstmr/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});
                        }
                    }
                });
            },
        });
    }
    f();
});
function f() {
    let token = localStorage.getItem("token");
    layui.jquery.ajax({
        url: baseUrl + "/dashboard/popup/auth",
        data:{token : token},
        method: 'GET',
        success: function (res) {
            if (res.code === 200) {
                if (res.msg === "true"){
                    sign=true;
                }else {
                }
                console.log(sign)
                // showPopupGenerate(res.msg)
                // showPopupDel(res.msg)
                // showPopupEdit(res.msg)
            }
        }
    })
}
// 关闭动作
$(document).on('click','#data-detail-close', function () {
    parent.layer.closeAll();