格式化代码
This commit is contained in:
		
							parent
							
								
									7d7ee0e05b
								
							
						
					
					
						commit
						d87341b99a
					
				| @ -104,7 +104,10 @@ watch( | |||||||
| 
 | 
 | ||||||
| //关闭回调 | //关闭回调 | ||||||
| const footOnOk = () => { | 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) { |   if (datePicker.range) { | ||||||
|     //关闭菜单 |     //关闭菜单 | ||||||
|     emits("ok"); |     emits("ok"); | ||||||
|  | |||||||
| @ -49,8 +49,8 @@ const emit = defineEmits([ | |||||||
|   "update:selectedKey", |   "update:selectedKey", | ||||||
| ]); | ]); | ||||||
| function toThousands(num: number | string | undefined) { | function toThousands(num: number | string | undefined) { | ||||||
|   if(typeof num == 'undefined'){ |   if (typeof num == "undefined") { | ||||||
|     return '' |     return ""; | ||||||
|   } |   } | ||||||
|   if (typeof num == "string") { |   if (typeof num == "string") { | ||||||
|     num = parseFloat(num || "0"); |     num = parseFloat(num || "0"); | ||||||
| @ -474,12 +474,12 @@ const radioProps = props.getRadioProps(props.data, props.index); | |||||||
|                 :type="expandIconType" |                 :type="expandIconType" | ||||||
|                 @click="handleExpand" |                 @click="handleExpand" | ||||||
|               ></lay-icon> |               ></lay-icon> | ||||||
|                 <template v-if="page"> |               <template v-if="page"> | ||||||
|                   {{ index + 1 + ((page.current - 1) * page.limit) }} |                 {{ index + 1 + (page.current - 1) * page.limit }} | ||||||
|                 </template> |               </template> | ||||||
|                 <template v-else> |               <template v-else> | ||||||
|                   {{ index + 1 }} |                 {{ index + 1 }} | ||||||
|                 </template> |               </template> | ||||||
|             </td> |             </td> | ||||||
|           </template> |           </template> | ||||||
|         </template> |         </template> | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ export default { | |||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
| import {  utils, writeFile } from "xlsx"; | import { utils, writeFile } from "xlsx"; | ||||||
| 
 | 
 | ||||||
| import "./index.less"; | import "./index.less"; | ||||||
| import { | import { | ||||||
| @ -398,47 +398,46 @@ const print = () => { | |||||||
|  * @param header 信息的键名 |  * @param header 信息的键名 | ||||||
|  * @param name 导出文件名称 |  * @param name 导出文件名称 | ||||||
|  */ |  */ | ||||||
| function exportElcel(list:any,header:any,name:string){ | function exportElcel(list: any, header: any, name: string) { | ||||||
|      |   const ws = utils.json_to_sheet(list, { | ||||||
|     const ws = utils.json_to_sheet(list, { |     header, | ||||||
|         header, |     skipHeader: true, | ||||||
|         skipHeader: true |   }); | ||||||
|     }) |   console.log(ws); | ||||||
|     console.log(ws) |   var tmpWB = { | ||||||
|     var tmpWB = { |     SheetNames: ["sheet"], //保存的表标题 | ||||||
|         SheetNames: ['sheet'], //保存的表标题 |     Sheets: { | ||||||
|         Sheets: { |       sheet: Object.assign( | ||||||
|             sheet: Object.assign( |         {}, | ||||||
|                 {}, |         ws, //内容 | ||||||
|                 ws, //内容 |         {} | ||||||
|                 {} |       ), | ||||||
|             ) |     }, | ||||||
|         } |   }; | ||||||
|     } |   writeFile(tmpWB, name + ".xlsx", { | ||||||
|     writeFile(tmpWB,name + ".xlsx",{ |     bookType: "xlsx", | ||||||
|         bookType: 'xlsx', |     type: "binary", | ||||||
|         type: 'binary' |   }); | ||||||
|     }) |  | ||||||
| } | } | ||||||
| // 报表导出 | // 报表导出 | ||||||
| const exportData = () => { | const exportData = () => { | ||||||
|   var tableStr = ``; |   var tableStr = ``; | ||||||
|   let head:any = [] |   let head: any = []; | ||||||
|   let list:any = [] |   let list: any = []; | ||||||
|   let title:any = {} |   let title: any = {}; | ||||||
|   for (let tableHeadColumn of tableHeadColumns.value) { |   for (let tableHeadColumn of tableHeadColumns.value) { | ||||||
|     // tableStr += "<tr>"; |     // tableStr += "<tr>"; | ||||||
|     for (let column of tableHeadColumn) { |     for (let column of tableHeadColumn) { | ||||||
|       // tableStr += `<td colspan=${column.colspan} rowspan=${column.rowspan}>${column.title}</td>`; |       // tableStr += `<td colspan=${column.colspan} rowspan=${column.rowspan}>${column.title}</td>`; | ||||||
|       title[column.key] = column.title |       title[column.key] = column.title; | ||||||
|       head.push(column.key) |       head.push(column.key); | ||||||
|     } |     } | ||||||
|     // tableStr += "</tr>"; |     // tableStr += "</tr>"; | ||||||
|   } |   } | ||||||
|   list.push(title) |   list.push(title); | ||||||
|   console.log(tableDataSource.value,tableHeadColumns.value) |   console.log(tableDataSource.value, tableHeadColumns.value); | ||||||
|   tableDataSource.value.forEach((item, rowIndex) => { |   tableDataSource.value.forEach((item, rowIndex) => { | ||||||
|     let info:any = {} |     let info: any = {}; | ||||||
|     tableBodyColumns.value.forEach((tableColumn, columnIndex) => { |     tableBodyColumns.value.forEach((tableColumn, columnIndex) => { | ||||||
|       Object.keys(item).forEach((name) => { |       Object.keys(item).forEach((name) => { | ||||||
|         if (tableColumn.key === name) { |         if (tableColumn.key === name) { | ||||||
| @ -453,31 +452,33 @@ const exportData = () => { | |||||||
|           // if (rowspan != 0 && colspan != 0) { |           // if (rowspan != 0 && colspan != 0) { | ||||||
|           //   tableStr += `<td colspan=${colspan} rowspan=${rowspan}${tableColumn.valueType == 'str' ? ' x:str' : ''}>${item[name] || ''}</td>`; |           //   tableStr += `<td colspan=${colspan} rowspan=${rowspan}${tableColumn.valueType == 'str' ? ' x:str' : ''}>${item[name] || ''}</td>`; | ||||||
|           // } |           // } | ||||||
|           if(tableColumn.valueType == "str"){ |           if (tableColumn.valueType == "str") { | ||||||
|             info[name] = item[name] |             info[name] = item[name]; | ||||||
|           }else{ |           } 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"){ |       if (tableColumn.type == "number") { | ||||||
|           // const rowColSpan = props.spanMethod( |         // const rowColSpan = props.spanMethod( | ||||||
|           //   item, |         //   item, | ||||||
|           //   tableColumn, |         //   tableColumn, | ||||||
|           //   rowIndex, |         //   rowIndex, | ||||||
|           //   columnIndex |         //   columnIndex | ||||||
|           // ); |         // ); | ||||||
|           // const rowspan = rowColSpan ? rowColSpan[0] : 1; |         // const rowspan = rowColSpan ? rowColSpan[0] : 1; | ||||||
|           // const colspan = rowColSpan ? rowColSpan[1] : 1; |         // const colspan = rowColSpan ? rowColSpan[1] : 1; | ||||||
|           // if (rowspan != 0 && colspan != 0) { |         // if (rowspan != 0 && colspan != 0) { | ||||||
|           //   tableStr += `<td colspan=${colspan} rowspan=${rowspan}>${rowIndex + 1}</td>`; |         //   tableStr += `<td colspan=${colspan} rowspan=${rowspan}>${rowIndex + 1}</td>`; | ||||||
|           // } |         // } | ||||||
|           info[tableColumn.key] = rowIndex + 1 |         info[tableColumn.key] = rowIndex + 1; | ||||||
|         } |       } | ||||||
|     }); |     }); | ||||||
|     // tableStr += "</tr>"; |     // tableStr += "</tr>"; | ||||||
|     list.push(info) |     list.push(info); | ||||||
|   }); |   }); | ||||||
|   // var worksheet = "Sheet1"; |   // var worksheet = "Sheet1"; | ||||||
|   // var uri = "data:application/vnd.ms-excel;base64,"; |   // var uri = "data:application/vnd.ms-excel;base64,"; | ||||||
| @ -497,7 +498,7 @@ const exportData = () => { | |||||||
|   // a.download = (props.download || "下载文件") + ".xls"; |   // a.download = (props.download || "下载文件") + ".xls"; | ||||||
|   // a.click(); |   // a.click(); | ||||||
|   // window.location.href = |   // window.location.href = | ||||||
|   exportElcel(list,head,(props.download || "下载文件")) |   exportElcel(list, head, props.download || "下载文件"); | ||||||
|   return; |   return; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -880,7 +881,7 @@ watch( | |||||||
|       // pagecurrent || |       // pagecurrent || | ||||||
|       change({ |       change({ | ||||||
|         limit: props.page.limit, |         limit: props.page.limit, | ||||||
|         current:  props.page.current, |         current: props.page.current, | ||||||
|         isReload: true, |         isReload: true, | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -24,5 +24,5 @@ export default defineConfig({ | |||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
|   plugins, |   plugins, | ||||||
|   base:"./" |   base: "./", | ||||||
| }); | }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user