Browse Source

共享表格设置字体后,引用后生效

cldu 3 weeks ago
parent
commit
af650e03be
2 changed files with 26 additions and 3 deletions
  1. 8 2
      src/components/sheet.vue
  2. 18 1
      src/hooks/sheet/useResizeTable.js

+ 8 - 2
src/components/sheet.vue

@@ -17,7 +17,8 @@ const {
   handleMouseMove,
   handleMouseOut,
   initTableCellsWid,
-  getSize
+  getSize,
+  SheetFFType,
 } = useResizeTable(tableRef)
 
 const props = defineProps({
@@ -44,6 +45,10 @@ const HtObj=ref({
   2:'right'
 })
 
+const handleFF = (ff) => {
+  return ff ? (typeof ff == 'number' ? SheetFFType[ff] :  ff) : ''
+}
+
 initTableCellsWid('init',props.sceneConfig)
 </script>
 
@@ -77,7 +82,8 @@ initTableCellsWid('init',props.sceneConfig)
             background: ${cell.bg};
             text-align: ${HtObj[cell.HorizontalType]};
             font-size: ${cell.fs||props.config.FontSize||12}px;
-            width:${index==0?getSize(cell_index,'width'):'auto'}
+            width:${index==0?getSize(cell_index,'width'):'auto'};
+            font-family: ${handleFF(cell.ff)};
           `"
           @mousemove="e =>isCanDrag && handleMouseMove(e,index,cell_index)"
           @mousedown="e =>isCanDrag && handleMouseDown(e,index,cell_index)"

+ 18 - 1
src/hooks/sheet/useResizeTable.js

@@ -233,6 +233,22 @@ export function useResizeTable(refName) {
     window.parent.postMessage(params,'*')
   }
 
+  const SheetFFType = {
+      0 : 'Times New Roman',
+      1 : 'Arial',
+      2 : 'Tahoma',
+      3 : 'Verdana',
+      4 : '微软雅黑',
+      5 : '宋体(Song)',
+      6 : '黑体(ST Heiti)',
+      7 : '楷体(ST Kaiti)',
+      8 : '仿宋(ST FangSong)',
+      9 : '新宋体(ST Song)',
+      10 : '华文新魏',
+      11 : '华文行楷',
+      12 : '华文隶书',
+  }
+
   return {
     columnsWArr,
     rowsHArr,
@@ -240,6 +256,7 @@ export function useResizeTable(refName) {
     handleMouseDown,
     initTableCellsWid,
     getSize,
-    postSheetHeightMsg
+    postSheetHeightMsg,
+    SheetFFType,
   }
 }