$(document).off('click', '.batch-btn').on('click', '.batch-btn', function() { const dtable = zui.DTable.query($(this).target); const checkedList = dtable.$.getChecks(); if(!checkedList.length) return; const url = $(this).data('url'); const form = new FormData(); checkedList.forEach((id) => form.append('ticketIDList[]', id)); if($(this).hasClass('ajax-btn')) { $.ajaxSubmit({url, data:form}); } else { postAndLoadPage(url, form); } }); window.firstRendered = false; window.toggleCheckRows = function(idList) { if(!idList?.length || firstRendered) return; firstRendered = true; const dtable = zui.DTable.query($('#tickets')); dtable.$.toggleCheckRows(idList.split(','), true); } window.checkedChange = function(changes) { if(!this._checkedRows) this._checkedRows = {}; Object.keys(changes).forEach((rowID) => { const row = this.getRowInfo(rowID); if(row !== undefined) this._checkedRows[rowID] = row.data; }); } window.insertListToDoc = function() { const dtable = zui.DTable.query($('#tickets')); const myTable = dtable.$; const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; let {cols} = dtable.options; const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=ticket&blockID=${blockID}`); const formData = new FormData(); formData.append('cols', JSON.stringify(cols)); formData.append('data', JSON.stringify(data)); formData.append('idList', checkedList.join(',')); formData.append('url', insertListLink); $.post(url, formData, function(resp) { resp = JSON.parse(resp); if(resp.result == 'success') { const oldBlockID = resp.oldBlockID; const newBlockID = resp.newBlockID; zui.Modal.hide(); window.insertZentaoList && window.insertZentaoList('ticket', newBlockID, null, oldBlockID) ; } }); } /** * 来源列显示额外的内容。 * Display extra content in the title column. * * @param object result * @param object info * @access public * @return object */ window.onRenderCell = function(result, {row, col}) { if(result && col.name == 'title') { const module = this.options.modules[row.data.module]; if(module) result.unshift({html: '' + module + ''}); // 添加模块标签 } if(result && col.name == 'feedbackTip' && row.data.feedbackTip != '') { if(typeof result[0].props != 'undefined') result[0].props.className = 'overflow-hidden'; result.push({html: '' + feedbackLang + ''}); // 添加反馈标签 } return result; }