分析排序

This commit is contained in:
liuzanying
2023-09-15 17:24:14 +08:00
parent 446d53bab9
commit a20598a0da
8 changed files with 150 additions and 23 deletions

View File

@@ -108,7 +108,10 @@ export default defineComponent({
} }
return obj return obj
}) })
let result = Object.entries(data[0]) let result = [];
if(data.length > 0){
result = Object.entries(data[0])
}
if(empty_option) { if(empty_option) {
result = result.filter(item => item[1] !== 0) result = result.filter(item => item[1] !== 0)
} }
@@ -180,16 +183,30 @@ export default defineComponent({
tableInstance.value.data = tableData tableInstance.value.data = tableData
tableInstance.value.columns = data.head tableInstance.value.columns = data.head
columns.value = data.head.map((item, index) => { columns.value = data.head.map((item, index) => {
return { if(item.key !== 'option' && item.key !== '1.00' && item.key !== '2.00'&& item.key !== '3.00'&& item.key !== '4.00'&& item.key !== '5.00'){
...item, return {
title: () => <RenderTableTitle title={item.title} />, ...item,
name: item.title, title: () => <RenderTableTitle title={item.title} />,
dataIndex: item.key, name: item.title,
slots: { customRender: item.key }, dataIndex: item.key,
width: 100, slots: { customRender: item.key },
// align: "center", width: 100,
fixed: index === 0 ? 'left' : null // align: "center",
}; fixed: index === 0 ? 'left' : null,
sorter: (a, b) => { return a[item.key] > b[item.key] ? 1 : -1 },
};
}else{
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
name: item.title,
dataIndex: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? 'left' : null
};
}
}); });
}, },
{ {

View File

@@ -125,7 +125,19 @@ export default defineComponent({
// align: "center", // align: "center",
fixed: index === 0 ? "left" : null, fixed: index === 0 ? "left" : null,
}; };
}else { } else if (item.key === 'number') {
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
dataIndex: item.key,
key: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? "left" : null,
sorter: (a, b) => { return a.number > b.number? 1 : -1 },
};
} else {
return { return {
...item, ...item,
title: () => <RenderTableTitle title={item.title} />, title: () => <RenderTableTitle title={item.title} />,
@@ -137,7 +149,7 @@ export default defineComponent({
fixed: index === 0 ? "left" : null, fixed: index === 0 ? "left" : null,
}; };
} }
}) || []; }) || [];
tableInstance.value.data = tableSource.value; tableInstance.value.data = tableSource.value;
tableInstance.value.columns = data.head; tableInstance.value.columns = data.head;

View File

@@ -124,16 +124,54 @@ export default defineComponent({
(data) => { (data) => {
tableInstance.value.columns = data.head tableInstance.value.columns = data.head
columns.value = data.head.map((item, index) => { columns.value = data.head.map((item, index) => {
return { if(item.key === 'avg'){
...item, return {
title: () => <RenderTableTitle title={item.title} />, ...item,
dataIndex: item.key, title: () => <RenderTableTitle title={item.title} />,
key: item.key, name: item.title,
slots: { customRender: item.key }, dataIndex: item.key,
width: 100, slots: { customRender: item.key },
// align: "center", width: 100,
fixed: index === 0 ? "left" : null, // align: "center",
}; fixed: index === 0 ? 'left' : null,
sorter: (a, b) => { return a.avg > b.avg? 1 : -1 },
};
}else if(item.key === 'min'){
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
name: item.title,
dataIndex: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? 'left' : null,
sorter: (a, b) => { return a.min > b.min? 1 : -1 },
};
}else if(item.key === 'max'){
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
name: item.title,
dataIndex: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? 'left' : null,
sorter: (a, b) => { return a.max > b.max? 1 : -1 },
};
}else {
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
dataIndex: item.key,
key: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? "left" : null,
};
}
}); });
tableSource.value = getTableData(data.head, data.option); tableSource.value = getTableData(data.head, data.option);

View File

@@ -137,6 +137,18 @@ watch(
// align: "center", // align: "center",
fixed: index === 0 ? "left" : null, fixed: index === 0 ? "left" : null,
}; };
}else if (item.key === 'number') {
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
dataIndex: item.key,
key: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? "left" : null,
sorter: (a, b) => { return a.number > b.number? 1 : -1 },
};
}else{ }else{
return { return {
...item, ...item,

View File

@@ -140,6 +140,18 @@ watch(
// align: "center", // align: "center",
fixed: index === 0 ? "left" : null, fixed: index === 0 ? "left" : null,
}; };
}else if (item.key === 'number') {
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
dataIndex: item.key,
key: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? "left" : null,
sorter: (a, b) => { return a.number > b.number? 1 : -1 },
};
}else{ }else{
return { return {
...item, ...item,

View File

@@ -132,6 +132,18 @@ watch(
// align: "center", // align: "center",
fixed: index === 0 ? "left" : null, fixed: index === 0 ? "left" : null,
}; };
}else if (item.key === 'number') {
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
dataIndex: item.key,
key: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? "left" : null,
sorter: (a, b) => { return a.number > b.number? 1 : -1 },
};
}else{ }else{
return { return {
...item, ...item,

View File

@@ -140,6 +140,18 @@ watch(
// align: "center", // align: "center",
fixed: index === 0 ? "left" : null, fixed: index === 0 ? "left" : null,
}; };
}else if (item.key === 'number') {
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
dataIndex: item.key,
key: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? "left" : null,
sorter: (a, b) => { return a.number > b.number? 1 : -1 },
};
}else{ }else{
return { return {
...item, ...item,

View File

@@ -140,6 +140,18 @@ watch(
// align: "center", // align: "center",
fixed: index === 0 ? "left" : null, fixed: index === 0 ? "left" : null,
}; };
}else if (item.key === 'number') {
return {
...item,
title: () => <RenderTableTitle title={item.title} />,
dataIndex: item.key,
key: item.key,
slots: { customRender: item.key },
width: 100,
// align: "center",
fixed: index === 0 ? "left" : null,
sorter: (a, b) => { return a.number > b.number? 1 : -1 },
};
}else{ }else{
return { return {
...item, ...item,