中扬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;
@@ -218,27 +219,52 @@
                })
                break;
            case 'edit':
                showEditModel(data);
                break;
                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
                }
        }
    });
@@ -250,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",
@@ -403,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);
            }
        });
    }
@@ -523,8 +550,59 @@
        })
    }
    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();