格式化代码

This commit is contained in:
Theluyuan 2023-11-20 11:29:35 +08:00
parent 7d7ee0e05b
commit d87341b99a
4 changed files with 67 additions and 63 deletions

View File

@ -104,7 +104,10 @@ watch(
//
const footOnOk = () => {
emits("update:modelValue", Month.value || Month.value === 0 ? Month.value : -1);
emits(
"update:modelValue",
Month.value || Month.value === 0 ? Month.value : -1
);
if (datePicker.range) {
//
emits("ok");

View File

@ -49,8 +49,8 @@ const emit = defineEmits([
"update:selectedKey",
]);
function toThousands(num: number | string | undefined) {
if(typeof num == 'undefined'){
return ''
if (typeof num == "undefined") {
return "";
}
if (typeof num == "string") {
num = parseFloat(num || "0");
@ -475,7 +475,7 @@ const radioProps = props.getRadioProps(props.data, props.index);
@click="handleExpand"
></lay-icon>
<template v-if="page">
{{ index + 1 + ((page.current - 1) * page.limit) }}
{{ index + 1 + (page.current - 1) * page.limit }}
</template>
<template v-else>
{{ index + 1 }}

View File

@ -399,46 +399,45 @@ const print = () => {
* @param name 导出文件名称
*/
function exportElcel(list: any, header: any, name: string) {
const ws = utils.json_to_sheet(list, {
header,
skipHeader: true
})
console.log(ws)
skipHeader: true,
});
console.log(ws);
var tmpWB = {
SheetNames: ['sheet'], //
SheetNames: ["sheet"], //
Sheets: {
sheet: Object.assign(
{},
ws, //
{}
)
}
}
),
},
};
writeFile(tmpWB, name + ".xlsx", {
bookType: 'xlsx',
type: 'binary'
})
bookType: "xlsx",
type: "binary",
});
}
//
const exportData = () => {
var tableStr = ``;
let head:any = []
let list:any = []
let title:any = {}
let head: any = [];
let list: any = [];
let title: any = {};
for (let tableHeadColumn of tableHeadColumns.value) {
// tableStr += "<tr>";
for (let column of tableHeadColumn) {
// tableStr += `<td colspan=${column.colspan} rowspan=${column.rowspan}>${column.title}</td>`;
title[column.key] = column.title
head.push(column.key)
title[column.key] = column.title;
head.push(column.key);
}
// tableStr += "</tr>";
}
list.push(title)
console.log(tableDataSource.value,tableHeadColumns.value)
list.push(title);
console.log(tableDataSource.value, tableHeadColumns.value);
tableDataSource.value.forEach((item, rowIndex) => {
let info:any = {}
let info: any = {};
tableBodyColumns.value.forEach((tableColumn, columnIndex) => {
Object.keys(item).forEach((name) => {
if (tableColumn.key === name) {
@ -454,12 +453,14 @@ const exportData = () => {
// tableStr += `<td colspan=${colspan} rowspan=${rowspan}${tableColumn.valueType == 'str' ? ' x:str' : ''}>${item[name] || ''}</td>`;
// }
if (tableColumn.valueType == "str") {
info[name] = item[name]
info[name] = item[name];
} else {
info[name] = isNaN(Number(item[name])) || (!item[name] && item[name] !== 0) ? item[name] : Number(item[name])
info[name] =
isNaN(Number(item[name])) || (!item[name] && item[name] !== 0)
? item[name]
: Number(item[name]);
}
}
});
if (tableColumn.type == "number") {
// const rowColSpan = props.spanMethod(
@ -473,11 +474,11 @@ const exportData = () => {
// if (rowspan != 0 && colspan != 0) {
// tableStr += `<td colspan=${colspan} rowspan=${rowspan}>${rowIndex + 1}</td>`;
// }
info[tableColumn.key] = rowIndex + 1
info[tableColumn.key] = rowIndex + 1;
}
});
// tableStr += "</tr>";
list.push(info)
list.push(info);
});
// var worksheet = "Sheet1";
// var uri = "data:application/vnd.ms-excel;base64,";
@ -497,7 +498,7 @@ const exportData = () => {
// a.download = (props.download || "") + ".xls";
// a.click();
// window.location.href =
exportElcel(list,head,(props.download || "下载文件"))
exportElcel(list, head, props.download || "下载文件");
return;
};

View File

@ -24,5 +24,5 @@ export default defineConfig({
},
},
plugins,
base:"./"
base: "./",
});