| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 | $(function () {    autoFlashHeight();    //编辑input及textarea    $('.edit-input').on('change', function () {        const newVal = _.trim($(this).val());        const id = $(this).data('id');        if (newVal.length > 1000) {            toastr.error('内容字符长度不能超过1000');            return false;        }        updateJsonData(newVal, id);    });    $('.edit-textarea').on('change', function () {        const newVal = $(this).val();        const id = $(this).data('id');        if (newVal.length > 10000) {            toastr.error('内容字符长度不能超过10000');            return false;        }        updateJsonData(newVal, id);    });    function updateJsonData(newVal, id) {        postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'update_json', updateData: { key: id, value: newVal } }, function (result) {        });    }    // 审签人选择    let timer = null    let oldSearchVal = null    $('#gr-search').bind('input propertychange', function(e) {        oldSearchVal = e.target.value        timer && clearTimeout(timer)        timer = setTimeout(() => {            const newVal = $('#gr-search').val()            let html = ''            if (newVal && newVal === oldSearchVal) {                accountList.filter(item => item && cur_uid !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {                    html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >                        <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span                                class="ml-auto">${item.mobile || ''}</span></p>                        <span class="text-muted">${item.role || ''}</span>                    </dd>`                })                $('.book-list').empty()                $('.book-list').append(html)            } else {                if (!$('.acc-btn').length) {                    accountGroup.forEach((group, idx) => {                        if (!group) return                        html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>                        </a> ${group.groupName}</dt>                        <div class="dd-content" data-toggleid="${idx}">`                        group.groupList.forEach(item => {                            if (item.id !== cur_uid) {                                html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >                                    <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span                                            class="ml-auto">${item.mobile || ''}</span></p>                                    <span class="text-muted">${item.role || ''}</span>                                </dd>`                            }                        });                        html += '</div>'                    })                    $('.book-list').empty()                    $('.book-list').append(html)                }            }        }, 400);    })    // 添加审批流程按钮逻辑    $('.book-list').on('click', 'dt', function () {        const idx = $(this).find('.acc-btn').attr('data-groupid')        const type = $(this).find('.acc-btn').attr('data-type')        if (type === 'hide') {            $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {                $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')                $(this).find('.acc-btn').attr('data-type', 'show')            })        } else {            $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {                $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')                $(this).find('.acc-btn').attr('data-type', 'hide')            })        }        return false    });    // 添加到审批流程中    $('dl').on('click', 'dd', function () {        const id = parseInt($(this).data('id'));        if (id) {            postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'set_shenpi', uid: id }, function (result) {                $('#show-shenpi-btn').hide();                $('#show-shenpi span').text(result.shenpi_username);                $('#show-shenpi').show();            });        }    });    $('.remove-shenpi-btn').on('click', function () {        postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'remove_shenpi' }, function (result) {            $('#show-shenpi-btn').show();            $('#show-shenpi span').text('');            $('#show-shenpi').hide();        });    });    $('body').on('click', '#start-btn', function () {        // 判断是否已选择审签人,有则提交        const username = $('#show-shenpi span').text() || $('#show-shenpi-input').val();        if (username == '') {            toastr.error('请选择审签人再提交');            return false;        }        postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'start' }, function (result) {            window.location.reload();        });    });    $('#edit-start').click(function () {        // $('#edit-end').show();        $('#edit-start').hide();        $('.edit-input').removeAttr('readonly');        $('.edit-textarea').removeAttr('readonly');        $(this).siblings('span').hide();        $(this).parents('.title-main').append('<a href="javascript:void(0);" id="start-btn" class="btn btn-sm btn-primary pull-right mr-2">提交审签</a>');        postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'checkNo' }, function (result) {            // window.location.reload();        });    });    // $('#edit-end').click(function () {    //     $('#edit-start').show();    //     $('#edit-end').hide();    //     $('.edit-input').attr('readonly', true);    //     $('.edit-textarea').attr('readonly', true);    // });    $('#check-btn').click(function () {        postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'checked' }, function (result) {            window.location.reload();        });    });    // 上传附件    $('#upload-file-btn').click(function () {        const files = $('#upload-file')[0].files;        const formData = new FormData();        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 (!filePermission) {            toastr.error('无权限上传!');            return false;        }        postDataWithFile('/construction/' + tender_id + '/log/' + log_id + '/file/upload', formData, function (data) {            attData = data.concat(attData);            // 重新生成List            getAllList();            $('#upload').modal('hide');        }, function () {        });        $('#upload-file').val('');    });    // 删除附件    $('body').on('click', '.delete-file', function () {        let attid = $(this).data('attid');        const data = {id: attid};        postData('/construction/' + tender_id + '/log/' + log_id + '/file/delete', data, function (result) {            // 删除到attData中            const att_index = attData.findIndex(function (item) {                return item.id === parseInt(attid);            });            attData.splice(att_index, 1);            getAllList();        });    });    // $('#attList').on('click', '.file-atn', function() {    //     const id = $(this).attr('f-id');    //     postData(`/construction/${tender_id}/log/${log_id}/file/${id}/download`, {}, (data) => {    //         const { filepath } = data;    //         $('#file-upload').attr('href', filepath);    //         $('#file-upload')[0].click();    //     })    // });    // 生成附件列表    function getAllList() {        let html = '';        for(const [index,att] of attData.entries()) {            html += `<tr class="text-center">        <td width="5%">${index+1}</td>        <td class="text-left"><a href="${att.filepath}" target="_blank">${att.filename}${att.fileext}</a></td>        <td width="15%">${moment(att.upload_time).format("YYYY-MM-DD HH:mm:ss")}</td>        <td width="10%">            <a href="/construction/${tender_id}/log/${log_id}/file/${att.id}/download" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`            html += (att.uid === accountId && (logStatus === constructionStatusConst.checked ? Boolean(att.extra_upload) : true)) ?                `<a href="javascript:void(0)" class="mr-2 delete-file" data-attid="${att.id}" title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : '';            html += `</td>`;        }        $('#attList').html(html);        $('#attList').on('click', 'tr', function() {            $('#attList tr').removeClass('bg-light');            $(this).addClass('bg-light');        });    }});
 |