ZaiZai 1 anno fa
parent
commit
4bfdcb3225

+ 16 - 4
src/plugins/HTableForm.js

@@ -35,6 +35,7 @@ const ARROW_RIGHT = 'ArrowRight'
 export default class HTableForm {
     static tableFormApp = null
     static tableFormVM = null
+    static vEnableBulk = true
 
     /**
      * 创建表单
@@ -390,6 +391,11 @@ export default class HTableForm {
         this.setFormStyle(key, 'hc-green-border', pid, !remove)
     }
 
+    //设置是否批量复制
+    static setEnableBulk(val = true) {
+        this.vEnableBulk = val
+    }
+
     /**
      * 设置全局键盘事件
      * @param {Object} options - 配置选项
@@ -401,9 +407,9 @@ export default class HTableForm {
      */
     static setOnEventKey({ onCtrlDown, onCtrlDownC, onCtrlDownV, onCtrlUp }) {
         const handleKeyDown = (event) => {
+            if (!this.vEnableBulk) return
             const { key, ctrlKey, metaKey } = event
             const isCtrl = window.isMac ? metaKey : window.isWin ? ctrlKey : false
-
             if (isCtrl) {
                 if (onCtrlDown && key === window?.isCtrl) {
                     onCtrlDown(event)
@@ -416,16 +422,22 @@ export default class HTableForm {
         }
 
         const handleKeyUp = (event) => {
+            if (!this.vEnableBulk) return
             const { key, ctrlKey, metaKey } = event
             const isCtrl = window.isMac ? metaKey : window.isWin ? ctrlKey : false
-
             if (!isCtrl && key === window?.isCtrl && onCtrlUp) {
                 onCtrlUp(event)
             }
         }
 
-        document.addEventListener('keydown', handleKeyDown)
-        document.addEventListener('keyup', handleKeyUp)
+        //是否可用
+        if (this.vEnableBulk) {
+            document.addEventListener('keydown', handleKeyDown)
+            document.addEventListener('keyup', handleKeyUp)
+        } else {
+            document.removeEventListener('keydown', handleKeyDown)
+            document.removeEventListener('keyup', handleKeyUp)
+        }
 
         // 返回一个清理函数
         return () => {

+ 27 - 4
src/views/data-fill/collapse-form/index.vue

@@ -89,6 +89,8 @@
                             </HcTooltip>
                         </div>
                         <div class="btn-action">
+                            <el-button v-if="isEnableBulk" color="#3794FF" size="small" style="color: white" @click="enableBulkReplication">关闭批量复制</el-button>
+                            <el-button v-else color="#3794FF" size="small" style="color: white" @click="enableBulkReplication">开启批量复制</el-button>
                             <HcTooltip keys="wbs_save_table">
                                 <el-button
                                     :disabled="!item?.isTableForm" :loading="tableFormSaveLoading"
@@ -297,7 +299,6 @@
 
 <script setup>
 import { nextTick, onActivated, onDeactivated, onMounted, onUnmounted, ref, watch } from 'vue'
-import { getStoreValue } from '~src/utils/storage'
 import HTableForm from '~src/plugins/HTableForm'
 import { useAppStore } from '~src/store'
 import wbsApi from '~api/data-fill/wbs'
@@ -315,6 +316,7 @@ import {
     arrIndex, deepClone,
     downloadBlob, getArrValue, getObjVal, getObjValue, isNullES, setPosRange,
 } from 'js-fast-way'
+import { getStoreValue, setStoreValue } from '~src/utils/storage'
 import { HcDelMsg, HcUploadFileApi } from 'hc-vue3-ui'
 import { toPdfPage } from '~uti/btn-auth'
 //参数
@@ -390,7 +392,7 @@ const draw_type = ref(props.drawType)
 const tree_AutoExpandKeys = ref(props.treeAutoExpandKeys)
 const treenodeDataInfo = ref(props.treenodeDataInfo)
 const newlistdata = ref(props.newlistdata)
-
+const isEnableBulk = ref(true)
 
 //表单变量
 const formDataList = ref([])
@@ -470,7 +472,10 @@ onMounted(() => {
     setTableFormMenu(useAppState.projectInfo)
     const { offsetHeight } = document.body
     DragModalHeight.value = offsetHeight - 200
-    setMountOnEventKey()
+    const isBulk = getStoreValue('isEnableBulk') || true
+    isEnableBulk.value = isBulk
+    HTableForm.setEnableBulk(isBulk)
+    if (isBulk) setMountOnEventKey()
 })
 
 //处理变动的数据
@@ -1386,9 +1391,26 @@ const excelTableFormClick = (key) => {
 
 //缓存被激活时
 onActivated(() => {
-    setMountOnEventKey()
+    if (isEnableBulk.value) {
+        setMountOnEventKey()
+    }
 })
 
+//开启/关闭 批量复制
+const enableBulkReplication = async () => {
+    const res = !isEnableBulk.value
+    HTableForm.setEnableBulk(res)
+    if (res) {
+        setMountOnEventKey()
+    } else {
+        HTableForm.unmountEventKey()
+        const refs = await setOnFuncFormRef()
+        refs?.setIsCtrlKey(false)
+    }
+    isEnableBulk.value = res
+    setStoreValue('isEnableBulk', res)
+}
+
 //缓存时被移除
 onDeactivated(() => {
     HTableForm.unmountEventKey()
@@ -1401,6 +1423,7 @@ onUnmounted(() => {
 
 const setMountOnEventKey = () => {
     HTableForm.setOnEventKey({
+        vEnableBulk: isEnableBulk.value,
         //按下ctrl键 或 control 键
         onCtrlDown: async () => {
             //window.$HcLog('全局按键', '按下ctrl键 或 control 键')

+ 1 - 3
src/views/data-fill/collapse-form/table-form-item.vue

@@ -92,9 +92,7 @@ watch(() => [
     props.height,
     props.width,
     props.pid,
-], (
-    [project_id, contract_id, tree_id, key_id, cid, nodeName, height, width, pid],
-) => {
+], ([project_id, contract_id, tree_id, key_id, cid, nodeName, height, width, pid]) => {
     projectId.value = project_id
     contractId.value = contract_id
     treeId.value = tree_id