| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 | 'use strict';/** * 变更令详细页js * * @author EllisRan. * @date 2018/11/22 * @version */$(document).ready(() => {    const cca = getLocalCache('change-checkbox-account-' + accountId);    if (cca !== null && cca !== undefined) {        $('#customCheck1').prop('checked', cca !== 'false');    }    changeSpreadSheet.setColumnVisible(3,$('#customCheck1').is(':checked'), GC.Spread.Sheets.SheetArea.viewport);    // 变更详情展示和隐藏    $('.change-detail-checkbox').on('click', function (e) {        if($(e.target).is('label')){            return;        }        // // 设置用户项目本地记录展示和隐藏情况        setLocalCache('change-checkbox-account-'+ accountId, $(this).is(':checked'));        changeSpreadSheet.setColumnVisible(3,$(this).is(':checked'), GC.Spread.Sheets.SheetArea.viewport);    });    //tab change    $('a[data-toggle="tab"]').on('shown.bs.tab', function () {        const tab = $(this).data('tab');        if (tab === 'bgfujian') {            $('#fujian_btn').show();        } else {            $('#fujian_btn').hide();        }    });    $('#add-bj').on('click', 'input[type="checkbox"]', function () {        const isCheck = $(this).prop('checked');        if (isCheck) {            $('#add-bj input[type="checkbox"]').each(function () {                $(this).prop('checked', false)            });            $(this).prop('checked', true)        }    });    $('#bg-copy').click(function() {        const cid = $('#add-bj input:checked').data('id');        postData(window.location.pathname + '/copy', cid, function () {            window.location.reload();        })    });    // 上传附件    $('#upload-file-btn').click(function () {        const files = $('#upload-file')[0].files;        const formData = new FormData();        formData.append('cid', $('#changeId').val());        formData.append('tid', $('#tenderId').val());        for (const file of files) {            if (file === undefined) {                toastr.error('未选择上传文件!');                return false;            }            const filesize = file.size;            if (filesize > 30 * 1024 * 1024) {                toastr.error('文件大小过大!');                return false;            }            const fileext = '.' + file.name.toLowerCase().split('.').splice(-1)[0];            if (whiteList.indexOf(fileext) === -1) {                toastr.error('只能上传指定格式的附件!');                return false;            }            formData.append('size', filesize);            formData.append('file[]', file);        }        if (auditList.findIndex(item => item.uid === parseInt(accountId)) === -1) {            return toastr.error('暂无权限上传!')        }        postDataWithFile(window.location.pathname + '/file/upload', formData, function (data) {            $('#addfujian').modal('hide');            let html = '';            let index = $('#attList tr').length + 1;            for (const fileInfo of data) {                html += '<tr> ' +                    `<td width="20"><input type="checkbox" class="check-file" file-id=${fileInfo.id}></td>` +                    '<td>' + index + '</td> ' +                    `<td><a href="javascript: void(0);" class="file-atn" f-id="${fileInfo.id}">${fileInfo.filename}${fileInfo.fileext}</a></td>`+                    '<td>' + fileInfo.in_time + '<br>' + fileInfo.filesize + '</td> ' +                    `<td><a href="/change/download/file/${fileInfo.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`+                    ( auditStatus === 4 ?                        fileInfo.extra_upload ? `<a class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : ''                        : ` <a href="javascript:void(0);" class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>`)+                    `</td>`+                    // '<td> <a class="btn btn-light btn-sm delete-file" data-attid="' + fileInfo.id + '"  title="删除附件"><span class="fa fa-trash text-danger"></span></a> </td> ' +                    '</tr>';                ++index;            }            $('#attList').append(html);        }, function () {        });        $('#upload-file').val('');    });    // 删除附件    $('body').on('click', '.delete-file', function () {        let attid = $(this).data('attid');        let self = $(this);        const data = {id: attid};        postData(window.location.pathname + '/file/delete', data, function (result) {            self.parents('tr').remove();            // 重新排序            let newsort = 1;            $('#attList tr').each(function(){                $(this).children('td').eq(1).text(newsort);                newsort++;            });        });    });    // /change/download/file/    $('#attList').on('click', '.file-atn', function() {        const id = $(this).attr('f-id');        postData(`/change/download/file/${id}`, {}, (data) => {            const { filepath } = data;            $('#file-upload').attr('href', filepath);            $('#file-upload')[0].click();        })    });    $('#attList').on('click', '.check-file', function() {        const checkedList = $('#attList').find('input:checked');        const childs = $('#attList').children().length;        const checkBox = $('#check-all-file');        if (checkedList.length === childs) {            checkBox.prop("checked", true);        } else {            checkBox.prop("checked", false);        }    });    $('#check-all-file').click(function() {        const isCheck = $(this).is(':checked');        $('#attList').children().each(function() {            $(this).find('input:checkbox').prop("checked", isCheck);        })    });    $('#bach-download').click(function() {        const fileIds = [];        $( '#attList .check-file:checked').each(function() {            const fileId = $(this).attr('file-id');            fileId && fileIds.push(fileId);        });        if (fileIds.length) {            const tid = $('#tenderId').val();            const cid = $('#changeId').val();            $('#downloadZip').attr('href', `/tender/${tid}/change/${cid}/download/compresse-file?fileIds=${JSON.stringify(fileIds)}`);            $('#downloadZip')[0].click();        }    });    $.subMenu({        menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',        toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',        key: 'menu.1.0.0',        miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',        callback: function (info) {            if (info.mini) {                $('.panel-title').addClass('fluid');                $('#sub-menu').removeClass('panel-sidebar');            } else {                $('.panel-title').removeClass('fluid');                $('#sub-menu').addClass('panel-sidebar');            }            autoFlashHeight();            changeSpread.refresh();        }    });});
 |