ldong преди 2 месеца
родител
ревизия
a9ab167277

+ 15 - 6
src/views/datasheet_manage/components/BalanceTable.vue

@@ -25,22 +25,25 @@
           <div style="padding:20px;background-color: #fff;" @mouseleave="endSelection">
           <div class="table-wrap">
             <table
+              @mouseover="handleMouseOver" 
+              @mouseout="handleMouseOut"
               id="myTable"
-              width="auto"
               border="0"
               class="table"
               ref="tableRef"
               :style="disabled ? 'width:100%' : ''"
-              style="position: relative;"
+              style="position: relative;width: auto;"
               @mousedown="selectCellHandle"
             >
               <thead>
                 <tr>
                   <!-- 行头 -->
-                  <th class="th-tg sm"></th>
+                  <th class="th-tg sm"  style="width:36px"></th>
 
                   <!-- 列头 -->
                   <th
+                    :style="config.data[0][index].ShowStyle?getShowCss(config.data[0][index].ShowStyle,'header'):{}"
+                    @mousemove="handleMouseMove" @mouseout="handleMouseOut" @mousedown="handleMouseDown($event,index)"
                     v-for="(item, index) in columnHeader"
                     :key="index"
                     class="th-tg th-col"
@@ -57,6 +60,8 @@
                 <tr v-for="(row, index) in config.data" :key="index">
                   <!-- 行头 -->
                   <th
+                    :style="config.data[index][0].ShowStyle?getShowCss(config.data[index][0].ShowStyle,'height'):{}"
+                    @mousemove="handleMouseMoveHeight" @mouseout="handleMouseOutHeight" @mousedown="handleMouseDownHeight($event,index)"
                     class="th-tg th-row sm"
                     @contextmenu.prevent="rightClickHandle"
                     :data-rindex="rowHeader[index]"
@@ -82,8 +87,6 @@
                     @dblclick="dblClickCellHandle($event, cell)"
                     @contextmenu.prevent="rightClickHandle($event, cell)"
                     @mouseenter="getRelationEdbInfo(cell)"
-                    @copy="copyCellHandle($event, cell)"
-                    @paste="pasteCellHandle($event, cell)"
 
                     @mousedown="startSelection(index, cell_index)"
                     @mouseover="extendSelection(index, cell_index)"
@@ -1771,6 +1774,7 @@ export default {
           Value: "",
           DataType: 3,
           DataTime: "",
+          ShowStyle:JSON.stringify({width:140,height:35}),
           EdbInfoId: 0,
           Uid: md5.hex_md5(`${new Date().getTime()}${rindex}`),
           merData:isEnlargeCell?{
@@ -1980,12 +1984,13 @@ export default {
         const { CellRelation, Data } = initData;
         this.config.data = Data;
         this.insertRelationArr = JSON.parse(CellRelation);
+        this.getTableWidth()
       } else {
 
         this.config.data = new Array(8).fill("").map((_, _rindex) => {
           return new Array(5).fill("").map((cell, _cindex) => ({
             ShowValue: "",
-            ShowStyle: '',
+            ShowStyle:JSON.stringify({width:140,height:35}),
             ShowFormatValue: '',
             Value: "",
             DataType: 3,
@@ -1995,6 +2000,7 @@ export default {
             Uid: md5.hex_md5(`${new Date().getTime()}${_rindex}${_cindex}`)
           }));
         });
+        this.getTableWidth()
       }
       this.$nextTick(() => {
         this.hasInit = true
@@ -2748,4 +2754,7 @@ export default {
     padding: 0 !important;
   }
 }
+.table{
+  border-collapse: separate;
+}
 </style>

+ 21 - 12
src/views/datasheet_manage/components/MixedTable.vue

@@ -15,24 +15,27 @@
           @change="updateValueByFormula"
         />
       </div>
-
+      <div class="el-table__body-wrapper">
       <table
-        width="auto"
+        @mouseover="handleMouseOver" 
+        @mouseout="handleMouseOut"
         border="0"
-        class="table"
+        class="table el-table__body"
         id="myTable"
         :style="disabled ? 'width:100%' : ''"
         ref="tableRef"
-        style="position: relative;"
+        style="position: relative;width: auto;"
         @mousedown="selectCellHandle"
       >
         <thead>
           <tr>
             <!-- 行头 -->
-            <th class="th-tg sm"></th>
+            <th class="th-tg sm"   style="width:36px"></th>
 
             <!-- 列头 -->
             <th
+              :style="config.data[0][index].ShowStyle?getShowCss(config.data[0][index].ShowStyle,'header'):{}"
+              @mousemove="handleMouseMove" @mouseout="handleMouseOut" @mousedown="handleMouseDown($event,index)"
               v-for="(item, index) in columnHeader"
               :key="index"
               class="th-tg th-col"
@@ -49,6 +52,8 @@
           <tr v-for="(row, index) in config.data" :key="index">
             <!-- 行头 -->
             <th
+              :style="config.data[index][0].ShowStyle?getShowCss(config.data[index][0].ShowStyle,'height'):{}"
+              @mousemove="handleMouseMoveHeight" @mouseout="handleMouseOutHeight" @mousedown="handleMouseDownHeight($event,index)"
               class="th-tg th-row sm"
               @contextmenu.prevent="rightClickHandle"
               :data-rindex="rowHeader[index]"
@@ -74,8 +79,6 @@
               @dblclick="dblClickCellHandle($event,cell)"
               @contextmenu.prevent="rightClickHandle($event,cell)"
               @mouseenter="getRelationEdbInfo(cell)"
-              @copy="copyCellHandle($event,cell)"
-              @paste="pasteCellHandle($event,cell)"
             >
             <!-- 插入单元格禁止编辑 -->
             <!-- [4,5,6,7,8].includes(cell.DataType)&&!cell.CanEdit -->
@@ -156,12 +159,12 @@
                 <!-- @select="selectTarget($event,cell)"
                   @click="clickCell($event, cell)"
                 :highlight-first-item="cell.DataType===2"
-                 -->
+                -->
                 <template slot-scope="scope">
                     <edbDetailPopover :info="scope.item">
                       <div slot="reference" v-if="cell.DataType===2" class="edb-item">
-                         <span class="edb-item-name text_oneLine">{{ scope.item.EdbName }}</span>
-                         <i class="el-icon-check" style="color:#0052D9;font-size:18px;"/>
+                        <span class="edb-item-name text_oneLine">{{ scope.item.EdbName }}</span>
+                        <i class="el-icon-check" style="color:#0052D9;font-size:18px;"/>
                       </div>
 
                       <div slot="reference" v-else>{{ scope.item.EdbName }}</div>
@@ -178,7 +181,7 @@
         <div ref="rowColSelectRef" id="row-col-select" 
         style="position: absolute;border-color: #18ad18;border-style: solid;background-color: transparent;visibility: hidden;z-index: 1;pointer-events: none;"></div>
       </table>
-
+      </div>
       <!-- 右键菜单 -->
       <div class="contextMenu-wrapper" id="contextMenu-wrapper" @mouseleave="()=>{activeNames=[];hideContextMenu()}">
         <div :class="['item',{'deletesty': menu.key==='reset'}]" v-for="menu in config.contextMenuOption" :key="menu.key" @click="handleContext(menu.key)">
@@ -1223,6 +1226,7 @@ export default {
           Value: "",
           DataType: 3,
           DataTime: "",
+          ShowStyle:JSON.stringify({width:140,height:35}),
           EdbInfoId: 0,
           Uid: md5.hex_md5(`${new Date().getTime()}${rindex}`),
           merData:isEnlargeCell?{
@@ -1430,11 +1434,12 @@ export default {
         const { CellRelation,Data } = initData;
         this.config.data = Data;
         this.insertRelationArr = JSON.parse(CellRelation);
+        this.getTableWidth()
       }else {
         this.config.data = new Array(8).fill("").map((_,_rindex) => {
           return new Array(5).fill("").map((cell,_cindex) => ({
             ShowValue: "",
-            ShowStyle: '',
+            ShowStyle:JSON.stringify({width:140,height:35}),
             ShowFormatValue: '',
             Value: "",
             DataType: 3,
@@ -1444,6 +1449,7 @@ export default {
             Uid: md5.hex_md5(`${new Date().getTime()}${_rindex}${_cindex}`),
           }));
         });
+        this.getTableWidth()
       }
       this.$nextTick(()=>{
         this.hasInit=true
@@ -2103,4 +2109,7 @@ export default {
     padding: 0 !important;
   }
 }
+.el-table__body-wrapper{
+    overflow-x: auto;
+}
 </style>

+ 55 - 1
src/views/datasheet_manage/components/toolBarSection.vue

@@ -78,7 +78,7 @@ export default {
     */
     tools:{
       type:'String',
-      default:'cell-point-type,cell-merge,font-color,condition-format,cell-decimal',
+      default:'cell-point-type,cell-merge,font-color,condition-format,cell-decimal,cell-align',
     },
     // 回显参数
     echoParameter:{
@@ -228,6 +228,33 @@ export default {
           title: this.$t("MixSheet.fill_color"),
           tool:'font-color'
         },
+        { 
+          icon: `<svg t="1725333838752" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4024" width="20" height="20">
+            <path d="M96 128h832v96H96zM96 576h832v96H96zM96 352h576v96H96zM96 800h576v96H96z" p-id="4025"></path>
+            </svg>`,
+          key: 'font-left',
+          type:'icon',
+          title:'',
+          tool:'cell-align'
+        },
+        { 
+          icon: `<svg t="1725333920532" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5073" width="20" height="20">
+            <path d="M128 298.666667h768a42.666667 42.666667 0 0 0 0-85.333334H128a42.666667 42.666667 0 0 0 0 85.333334z m85.333333 85.333333a42.666667 42.666667 0 0 0 0 85.333333h597.333334a42.666667 42.666667 0 0 0 0-85.333333H213.333333z m682.666667 170.666667H128a42.666667 42.666667 0 0 0 0 85.333333h768a42.666667 42.666667 0 0 0 0-85.333333z m-85.333333 170.666666H213.333333a42.666667 42.666667 0 0 0 0 85.333334h597.333334a42.666667 42.666667 0 0 0 0-85.333334z" p-id="5074"></path>
+            </svg>`,
+          key: 'font-center',
+          type:'icon',
+          title:'',
+          tool:'cell-align'
+        },
+        { 
+          icon: `<svg t="1725333943661" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6100" width="20" height="20">
+            <path d="M96 128h832v96H96zM96 576h832v96H96zM352 352h576v96H352zM352 800h576v96H352z" p-id="6101"></path>
+            </svg>`,
+          key: 'font-right',
+          type:'icon',
+          title:'',
+          tool:'cell-align'
+        },
         { 
           icon: `<svg width="20" height="20" viewBox="0 0 20 20"  xmlns="http://www.w3.org/2000/svg">
             <path d="M9.16667 5.00002V2.50002H12.5V5.00002H9.16667ZM0.833333 5.00002V2.50002H4.16667V5.00002H0.833333ZM13.3333 5.00002V2.50002H16.6667V5.00002H13.3333ZM0.833333 8.33335V5.83335H4.16667V8.33335H0.833333ZM13.3333 8.33335V5.83335H16.6667V8.33335H13.3333ZM0.833333 11.6667V9.16669H4.16667V11.6667H0.833333ZM13.3333 11.6667V9.16669H16.6667V11.6667H13.3333ZM9.16667 15V12.5H12.5V15H9.16667ZM0.833333 15V12.5H4.16667V15H0.833333ZM13.3333 15V12.5H16.6667V15H13.3333ZM0 2.67835V14.8217C0 15.38 0.49 15.8334 1.09417 15.8334H16.4058C17.01 15.8334 17.5 15.38 17.5 14.8217V6.78252L17.4942 2.67752C17.4933 2.11919 17.0325 1.66669 16.4642 1.66669H1.09417C0.491667 1.66669 0 2.12002 0 2.67835Z" fill="#333333"/>
@@ -294,10 +321,37 @@ export default {
         'add-point': this.changeCellsPoint,
         'del-point': this.changeCellsPoint,
         'cell-merge': this.cellMergeHandle,
+        'font-left':this.changeCellsAlign,
+        'font-center':this.changeCellsAlign,
+        'font-right':this.changeCellsAlign
       }
 
       handlesMap[key]&&handlesMap[key](key)
     },
+
+    // 单元格对齐
+    changeCellsAlign(key){
+      this.cellArray.map(item =>{
+        if(!item.merData || item.merData.type=='merge'){
+          this.changeCellAlign(key,item)
+        }
+      })
+    },
+
+    changeCellAlign(key,cell){
+      let cellValueStyle = cell.ShowStyle?JSON.parse(cell.ShowStyle):{
+        nt: "",//numberType
+        pn: 0,//ponitNum
+      }
+      const keyObj={
+        'font-left':'left',
+        'font-center':'center',
+        'font-right':'right',
+      }
+      cellValueStyle.align=keyObj[key]
+      cell.ShowStyle = JSON.stringify({...cellValueStyle,align:cellValueStyle.align})
+    },
+
     // 选择提交格式类别
     chooseCellScondition(item){
       if(!this.cellArray.length&&item!=6){

+ 359 - 3
src/views/datasheet_manage/mixins/conditionTableMixin.js

@@ -1,6 +1,348 @@
 import { transDecimalPlace, getDecimalPlaces } from '../common/customTable';
 export default {
+    data() {
+        return {
+            copyCells: [],
+            dragState: {}, // 记录子表的列宽移动的一些数值
+            dragState1: {}, // 记录子表的行高移动的一些数值
+            dragging: false,//列宽
+            dragging1: false,//行高
+            isMouseOver: false//鼠标是否在表格内
+        }
+    },
+    mounted() {
+        window.addEventListener('keydown', this.handleEvent)
+    },
+
+    beforeDestroy() {
+        window.removeEventListener('keydown', this.handleEvent)
+    },
     methods: {
+        // 鼠标拖动行高
+        handleMouseMoveHeight(event) {
+            if (!['/addMixedSheet', '/editBalanceSheet'].includes(this.$route.path)) {
+                return
+            }
+            let target = event.target
+            while (target && target.tagName !== 'TH') {
+                target = target.parentNode
+            }
+            if (!this.dragging1) {
+                let rect = target.getBoundingClientRect()
+                const bodyStyle = event.target.style
+                if (rect.height > 12 && rect.bottom - event.pageY < 8) {
+                    // 拖拽的鼠标样式
+                    bodyStyle.cursor = 'row-resize'
+                } else if (!this.dragging1) {
+                    bodyStyle.cursor = ''
+                }
+            }
+        },
+        handleMouseOutHeight(event) {
+            event.target.style.cursor = ''
+        },
+        handleMouseDownHeight(event, rowIndex) {
+            if (!['/addMixedSheet', '/editBalanceSheet'].includes(this.$route.path)) {
+                return
+            }
+            let target = event.target
+            while (target && target.tagName !== 'TH') {
+                target = target.parentNode
+            }
+            let rect = target.getBoundingClientRect()
+            console.log(rect,event)
+            if (rect.height > 12 && rect.bottom - event.pageY < 8) {
+                // 开始拖拽
+                this.dragging1 = true
+                // 当前拖拽的列所在的表格
+                let tableEl = event.target
+                // 当前所在列(单元格)
+                let thEL = event.target
+                while (tableEl && tableEl.tagName !== 'TABLE') {
+                    tableEl = tableEl.parentNode
+                }
+                // 获取列宽拖拽的显示线(拖拽线)
+                let resizeProxy = tableEl.querySelector(
+                    'thead'
+                )
+                while (thEL && thEL.tagName !== 'TH') {
+                    thEL = thEL.parentNode
+                }
+                const columnRect = thEL.getBoundingClientRect()
+                thEL.classList.add('noclick')
+                this.dragState1 = {
+                    startMouseTop: event.clientY, // 鼠标开始的地方
+                    columnHeight: columnRect.height, // th开始拖拽的宽度
+                }
+                resizeProxy.classList.remove('dn')
+                document.onselectstart = function () {
+                    return false
+                }
+                document.ondragstart = function () {
+                    return false
+                }
+
+                const handleMouseMove = event => {
+                    // 拖拽中,拖拽线与鼠标的位置同步
+                    resizeProxy.style.top = event.clientY + 'px'
+                }
+
+                const handleMouseUp = () => {
+                    if (this.dragging1) {
+                        // 拖拽完毕
+                        // console.log(this.dragState1)
+                        // console.log(resizeProxy.style.top)
+                        const { startMouseTop, columnHeight } = this.dragState1
+                        const finalTop = parseInt(resizeProxy.style.top, 10)
+                        const columnHeightDiff = finalTop - startMouseTop
+                        const finalColumnHeight = columnHeightDiff + columnHeight
+                        // console.log(finalColumnHeight)
+                        // thEL.style.width = finalColumnWidth + 'px'
+                        // console.log(finalColumnWidth)
+                        this.config.data[rowIndex].forEach((el, index) => {
+                            let cellValueStyle = el.ShowStyle?JSON.parse(el.ShowStyle) : {}
+                            this.$set(this.config.data[rowIndex][index], 'ShowStyle', JSON.stringify({ ...cellValueStyle, height: finalColumnHeight }))
+                        })
+                        resizeProxy.style.top = '0px'
+                        event.target.style.cursor = ''
+                        this.dragging1 = false
+                        this.dragState1 = {}
+                        resizeProxy.classList.add('dn')
+                    }
+
+                    document.removeEventListener('mousemove', handleMouseMove)
+                    document.removeEventListener('mouseup', handleMouseUp)
+                    document.onselectstart = null
+                    document.ondragstart = null
+                    setTimeout(function () {
+                        thEL.classList.remove('noclick')
+                    }, 0)
+                }
+
+                document.addEventListener('mousemove', handleMouseMove)
+                document.addEventListener('mouseup', handleMouseUp)
+            }
+        },
+        // 鼠标拖动列宽
+        handleMouseMove(event) {
+            if (!['/addMixedSheet', '/editBalanceSheet'].includes(this.$route.path)) {
+                return
+            }
+            let target = event.target
+            while (target && target.tagName !== 'TH') {
+                target = target.parentNode
+            }
+            if (!this.dragging) {
+                let rect = target.getBoundingClientRect()
+                const bodyStyle = event.target.style
+                if (rect.width > 12 && rect.right - event.pageX < 8) {
+                    // 拖拽的鼠标样式
+                    bodyStyle.cursor = 'col-resize'
+                } else if (!this.dragging) {
+                    bodyStyle.cursor = ''
+                }
+            }
+        },
+        handleMouseOut(event) {
+            event.target.style.cursor = ''
+        },
+        handleMouseDown(event, colIndex) {
+            if (!['/addMixedSheet', '/editBalanceSheet'].includes(this.$route.path)) {
+                return
+            }
+            let target = event.target
+            while (target && target.tagName !== 'TH') {
+                target = target.parentNode
+            }
+            let rect = target.getBoundingClientRect()
+            // console.log(rect.width > 12 && rect.right - event.pageX < 8)
+            if (rect.width > 12 && rect.right - event.pageX < 8) {
+                // 开始拖拽
+                this.dragging = true
+                // 当前拖拽的列所在的表格
+                let tableEl = event.target
+                // 当前所在列(单元格)
+                let thEL = event.target
+                while (tableEl && tableEl.tagName !== 'TABLE') {
+                    tableEl = tableEl.parentNode
+                }
+                // 获取列宽拖拽的显示线(拖拽线)
+                let resizeProxy = tableEl.querySelector(
+                    'thead'
+                )
+                while (thEL && thEL.tagName !== 'TH') {
+                    thEL = thEL.parentNode
+                }
+                const columnRect = thEL.getBoundingClientRect()
+                thEL.classList.add('noclick')
+                this.dragState = {
+                    startMouseLeft: event.clientX, // 鼠标开始的地方
+                    columnWidth: columnRect.width, // th开始拖拽的宽度
+                }
+                resizeProxy.classList.remove('dn')
+                document.onselectstart = function () {
+                    return false
+                }
+                document.ondragstart = function () {
+                    return false
+                }
+
+                const handleMouseMove = event => {
+                    // 拖拽中,拖拽线与鼠标的位置同步
+                    resizeProxy.style.left = event.clientX + 'px'
+                }
+
+                const handleMouseUp = () => {
+                    if (this.dragging) {
+                        // 拖拽完毕
+                        const { startMouseLeft, columnWidth } = this.dragState
+                        const finalLeft = parseInt(resizeProxy.style.left, 10)
+                        const columnWidthDiff = finalLeft - startMouseLeft
+                        const finalColumnWidth = columnWidthDiff + columnWidth
+                        // thEL.style.width = finalColumnWidth + 'px'
+                        // console.log(finalColumnWidth)
+                        this.config.data.forEach((el, index) => {
+                            let cellValueStyle = el[colIndex].ShowStyle ? JSON.parse(el[colIndex].ShowStyle) : {}
+                            this.$set(this.config.data[index][colIndex], 'ShowStyle', JSON.stringify({ ...cellValueStyle, width: finalColumnWidth }))
+                        })
+                        this.getTableWidth()
+                        resizeProxy.style.left = '0px'
+                        event.target.style.cursor = ''
+                        this.dragging = false
+                        this.dragState = {}
+                        resizeProxy.classList.add('dn')
+                    }
+
+                    document.removeEventListener('mousemove', handleMouseMove)
+                    document.removeEventListener('mouseup', handleMouseUp)
+                    document.onselectstart = null
+                    document.ondragstart = null
+                    setTimeout(function () {
+                        thEL.classList.remove('noclick')
+                    }, 0)
+                }
+
+                document.addEventListener('mousemove', handleMouseMove)
+                document.addEventListener('mouseup', handleMouseUp)
+            }
+        },
+        // 获取表格宽度
+        getTableWidth() {
+            this.$nextTick(() => {
+                $(document.getElementById('myTable').querySelector('#row-col-select')).css({
+                    'top': 0,
+                    'left': 0,
+                    'visibility': `hidden`,
+                    'height': 0,
+                    'width': 0
+                })
+                var totalWidth = 36;
+                this.config.data.forEach((el, index) => {
+                    if (index == 0) {
+                        el.forEach(item => {
+                            let cellValueStyle = item.ShowStyle ? JSON.parse(item.ShowStyle) : {}
+                            totalWidth += cellValueStyle.width ? cellValueStyle.width : 140
+                        })
+                    }
+                })
+                // console.log(totalWidth)
+                // 设置table的宽度为所有列宽度之和
+                $('table').width(totalWidth);
+            })
+        },
+        handleMouseOver() {
+            this.isMouseOver = true;
+        },
+        handleMouseOut() {
+            this.isMouseOver = false;
+        },
+        // 键盘事件
+        async handleEvent(event) {
+            if (!['/addMixedSheet', '/editBalanceSheet'].includes(this.$route.path)) {
+                return
+            }
+            const cellsKey=this.$route.path=='/addMixedSheet'?'selectedCells':'mergeSelectedCells'
+            if ((event.ctrlKey || event.metaKey) && (event.key === 'c'|| event.key === 'C')) {
+                // console.log('ctrl + c')
+                const cellCopy = this.selectCell ? this.selectCell : this[cellsKey]
+                this.copyCells = Array.isArray(cellCopy) ? cellCopy : [cellCopy]
+                if (this.selectCell) {
+                    if (!this.isMouseOver) {
+                        return
+                    }
+                    // console.log(this.selectCell.ShowValue)
+                    // 创建一个临时的 textarea 元素。
+                    const el = document.createElement('textarea');
+                    // 将需要复制的文本内容赋值给 textarea 元素。
+                    el.value = this.selectCell.ShowValue;
+                    //将 textarea 元素添加到页面中。
+                    document.body.appendChild(el);
+                    //选中 textarea 元素中的文本。
+                    el.select();
+                    // 执行复制命令,将选中的文本复制到剪贴板
+                    document.execCommand('copy');
+                    //从页面中移除 textarea 元素。
+                    document.body.removeChild(el);
+                }
+            } else if ((event.ctrlKey || event.metaKey) && (event.key === 'v' || event.key === 'V')) {
+                // console.log('ctrl + v')
+                // console.log(this.copyCells)
+                if (this.selectCell && this.selectCell.CanEdit) {
+                    // console.log(this.selectCell,this.selectCell.CanEdit)
+                    return
+                    // event.preventDefault();
+                }
+                const cell = this.selectCell ? this.selectCell : this[cellsKey]
+                const pasteFirstCell = Array.isArray(cell) ? cell[0] : cell
+                const copyFitstCell = this.copyCells[0]
+                // console.log(pasteFirstCell, copyFitstCell)
+                if (!copyFitstCell) {
+                    return
+                }
+                const rowNum = pasteFirstCell.rIndex - copyFitstCell.rIndex
+                const colNum = pasteFirstCell.cIndex - copyFitstCell.cIndex
+                // console.log(rowNum, colNum, this.copyCells)
+                this.copyCells.forEach(item => {
+                    let el = JSON.parse(JSON.stringify(item))
+                    if (this.config.data[el.rIndex + rowNum] && this.config.data[el.rIndex + rowNum][el.cIndex + colNum]) {
+                        const styleCss = el.ShowStyle ? JSON.parse(el.ShowStyle) : {};
+                        el.ShowStyle = JSON.stringify({
+                            ...styleCss,
+                            glObj: null,
+                        })
+                        let obj = {
+                            DataType: el.DataType,
+                            ShowValue: el.ShowValue,
+                            Value: el.Value,
+                            DataTimeType: el.DataTimeType,
+                            DataTime: el.DataTime,
+                            EdbInfoId: el.EdbInfoId,
+                            Extra: el.Extra,
+                            ShowStyle: el.ShowStyle ? this.filterWidth(el.ShowStyle) : '',
+                            ShowFormatValue: el.ShowFormatValue,
+                        }
+                        for (let i in obj) {
+                            this.config.data[el.rIndex + rowNum][el.cIndex + colNum][i] = obj[i]
+                        }
+                        // // console.log(this.config.data[el.rIndex + rowNum][el.cIndex + colNum])
+                    }
+                })
+                this.commonInitCell()
+                // 禁止外部粘贴
+                // event.preventDefault();
+            }
+        },
+        // 过滤宽度高度
+        filterWidth(str) {
+            let obj = JSON.parse(str)
+            if (obj.width) {
+                delete obj.width
+            }
+            if (obj.height) {
+                delete obj.height
+            }
+            return JSON.stringify(obj)
+        },
         // 判断时间
         isDateInRange(dateStr) {
             const today = new Date();
@@ -293,16 +635,30 @@ export default {
             this.config.data[rindex][cindex]["rowIndex"] = row;
         },
         // 设置背景色及字体颜色
-        getShowCss(style) {
+        getShowCss(style, type = '') {
             const styleCss = JSON.parse(style);
             let color = styleCss.glObj ? styleCss.glObj["color"] : styleCss["color"];
             let BackgroundColor = styleCss.glObj
                 ? styleCss.glObj["background-color"]
                 : styleCss["background-color"];
-            return {
+            let obj = {
                 color: color,
                 "background-color": BackgroundColor,
-            };
+                'text-align': styleCss.align ? styleCss.align : 'center',
+                'width': styleCss.width ? styleCss.width + 'px' : '140px',
+                'height': styleCss.height ? styleCss.height + 'px' : '35px',
+            }
+            if (type == 'header') {
+                obj = {
+                    'width': styleCss.width ? styleCss.width + 'px' : '140px',
+                }
+            }
+            if (type == 'height') {
+                obj = {
+                    'height': styleCss.height ? styleCss.height + 'px' : '35px',
+                }
+            }
+            return obj;
         },
     },
 };

+ 6 - 0
src/views/ppt_manage/newVersion/components/formatEl/SheetEl.vue

@@ -18,6 +18,7 @@
                 font-weight: ${col.bl ? 'bold' : 'normal'};
                 font-style: ${col.it ? 'italic' : 'normal'};
                 background: ${col.bg||'transparent'};
+                text-align: ${HtObj[col.HorizontalType]};
               `"
           >
             <!-- 单元格拆分 -->
@@ -75,6 +76,11 @@ export default {
   },
   data() {
     return {
+      HtObj:{
+        0:"center",
+        1:'left',
+        2:'right'
+      },
       tableData:[],
       type:'sheet',
       tableKey:0,