export function createTable(list: any[], column: { prop: string; label: string}[]) {
const table = document.createElement('table')
table.setAttribute('id', 'table_box')
const thead = document.createElement('thead')
const thead_tr = document.createElement('tr')
for (let i = 0; i < column.length; i++) {
const item = column[i]
const th = document.createElement('th')
th.innerHTML = item.label
thead_tr.appendChild(th)
}
thead.appendChild(thead_tr)
table.appendChild(thead)
const tbody = document.createElement('tbody')
for (let i = 0; i < list.length; i++) {
const item = list[i]
const tr = document.createElement('tr')
tbody.appendChild(tr)
for (let i = 0; i < column.length; i++) {
const columnItem = column[i]
if (item[columnItem.prop + '-span'] && item[columnItem.prop + '-span'].rowspan === 0) {
continue
}
const td = document.createElement('td')
if (item[columnItem.prop + '-span'] && item[columnItem.prop + '-span'].rowspan > 1) {
td.setAttribute('rowspan', item[columnItem.prop + '-span'].rowspan)
}
if (columnItem.prop === 'user_name' || columnItem.prop === 'workTaskName') {
td.setAttribute('class', 'table_props_center')
}
td.innerHTML = item[columnItem.prop]
tr.appendChild(td)
}
}
table.appendChild(tbody)
return table
}