zhoucg 1 年間 前
コミット
5a55139188

+ 3 - 3
src/components/config/globalConfig.ts

@@ -67,7 +67,7 @@ const tableColTemplate = {
         width: 80,
         height: 30
     },
-    element: {}
+    // element: {}
 }
 
 const tableRowTemplate = {
@@ -187,8 +187,8 @@ export const elementList = [
             },
         },
         style: {
-            width: 'auto',
-            height: 'auto',
+            // width: 'auto',
+            // height: 'auto',
             fontSize: 12,
             fontFamily: 'default',
             color: '#000000',

+ 5 - 1
src/components/elements/yvan-table/YvanComplexTablePropsAttr.vue

@@ -66,7 +66,7 @@
 import {mapState} from "pinia";
 import {globalStore} from "@/store";
 import commonMixin from "@/mixin/commonMixin";
-import {fontList, borderTypeList, tableRowTemplate} from "@/components/config/globalConfig";
+import {fontList, borderTypeList, tableRowTemplate, tableColTemplate} from "@/components/config/globalConfig";
 
 export default {
   name: "YvanComplexTablePropsAttr",
@@ -102,6 +102,10 @@ export default {
       const rowTemplate = this.deepCopy(tableRowTemplate)
       const rows = this.activeComponent.config[bandRowName].rows;
       rowTemplate.rowNo = rows.length + 1;
+      const columnNum = this.activeComponent.config.columnNum
+      for (let i = 1; i <= columnNum; i++) {
+        rowTemplate.cols[i] = this.deepCopy(tableColTemplate)
+      }
       this.activeComponent.config[bandRowName].rows.push(rowTemplate);
     },
     showOrHideRemoveRowBtn(bandRowName) {

+ 2 - 3
src/mixin/commonMixin.ts

@@ -1,10 +1,9 @@
 import system from '@/utils/system';
-import {deepCopy} from '@/utils/html-util';
 import {elementList} from "@/components/config/globalConfig";
 
 export default {
     methods: {
-        deepCopy,
+        deepCopy: system.deepCopy,
         getUuid: system.getUuid,
         isBlank(value) {
             return value === undefined || value === null || value === ''
@@ -27,7 +26,7 @@ export default {
             }
             return elementList.findLast(element => element.code === elementCode)
         },
-        isQrCodeElement(element):boolean {
+        isQrCodeElement(element): boolean {
             return element && element?.component === 'YvanQrcode'
         }
     }

+ 3 - 3
src/store/global.ts

@@ -3,7 +3,7 @@ import {defineStore} from 'pinia'
 import copy from '@/store/copy'
 import lock from '@/store/lock'
 import layer from '@/store/layer'
-import System from "@/utils/system"
+import system from "@/utils/system"
 import compose from '@/store/compose'
 import snapshot from '@/store/snapshot'
 import Constant from "@/utils/constant";
@@ -301,7 +301,7 @@ export const globalStore = defineStore('global', {
             if (elementId !== undefined) {
                 const tableElement = elementBand.elements.find(ele => ele.id === elementId);
                 if (!tableElement) {
-                    System.alert(`未获取到id=${elementId}的元素`)
+                    system.alert(`未获取到id=${elementId}的元素`)
                     return;
                 }
                 const col = tableElement.config[bandRowName].rows[rowNo].cols[colNo];
@@ -336,7 +336,7 @@ export const globalStore = defineStore('global', {
                 }
                 const rows = element.config[tableBandCode].rows
                 for (let row of rows) {
-                    row.cols[colNo] = tableColTemplate
+                    row.cols[colNo] = system.deepCopy(tableColTemplate)
                 }
             }
         },

+ 6 - 8
src/store/snapshot.ts

@@ -1,12 +1,12 @@
-import {deepCopy} from '@/utils/html-util'
+import system from '@/utils/system'
 import toast from '@/utils/toast'
 
 const MAX_SNAP_SHOT_LENGTH = 3
 
 // 设置画布默认数据 https://github.com/woai3c/visual-drag-demo/issues/92
-let defaultComponentData = []
+let defaultComponentData: any[] = []
 
-function getDefaultComponentData() {
+function getDefaultComponentData() : any[] {
     return defaultComponentData
 }
 
@@ -23,8 +23,7 @@ export default {
         undo(state) {
             if (state.snapshotIndex >= 1) {
                 state.snapshotIndex--
-                const componentData =
-                    deepCopy(state.snapshotData[state.snapshotIndex]) || getDefaultComponentData()
+                const componentData = system.deepCopy(state.snapshotData[state.snapshotIndex]) || getDefaultComponentData()
                 if (state.curComponent) {
                     // 如果当前组件不在 componentData 中,则置空
                     const needClean = !componentData.find(
@@ -49,7 +48,7 @@ export default {
                 state.snapshotIndex++
                 store.commit(
                     'printTemplateModule/setComponentData',
-                    deepCopy(state.snapshotData[state.snapshotIndex])
+                    system.deepCopy(state.snapshotData[state.snapshotIndex])
                 )
             } else {
                 toast('不能再恢复了')
@@ -58,8 +57,7 @@ export default {
 
         recordSnapshot() {
             // 添加新的快照
-            // console.log("snapshotData >>> ", this.snapshotData)
-            this.snapshotData[++this.snapshotIndex] = deepCopy(this.componentData)
+            this.snapshotData[++this.snapshotIndex] = system.deepCopy(this.componentData)
             // 在 undo 过程中,添加新的快照时,要将它后面的快照清理掉
             if (this.snapshotIndex < this.snapshotData.length - 1) {
                 this.snapshotData = this.snapshotData.slice(0, this.snapshotIndex + 1)

+ 6 - 6
src/utils/system.ts

@@ -28,12 +28,12 @@ class System {
         return Dialog({componentName, ...props})
     }
 
-    public renderIcon(iconName: string): any {
-        if (!iconName) {
-            return
-        }
-        return () => h(ElIcon, null, {default: () => h(FaIcon[iconName])});
-    }
+    // public renderIcon(iconName: string): any {
+    //     if (!iconName) {
+    //         return
+    //     }
+    //     return () => h(ElIcon, null, {default: () => h(FaIcon[iconName])});
+    // }
 
     public loading(): string {
         const loadingId = nanoid();