|
@@ -15,11 +15,12 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import {ref, watch, onMounted, nextTick} from "vue"
|
|
|
|
|
|
+import {ref, watch, onMounted, nextTick, onUnmounted} from "vue"
|
|
import {useAppStore} from "~src/store";
|
|
import {useAppStore} from "~src/store";
|
|
import HTableForm from "~src/plugins/HTableForm"
|
|
import HTableForm from "~src/plugins/HTableForm"
|
|
import notableform from '~src/assets/view/notableform.svg'
|
|
import notableform from '~src/assets/view/notableform.svg'
|
|
-import {getObjNullValue, isAsyncFunction, isString, getArrValue, deepClone} from "vue-utils-plus"
|
|
|
|
|
|
+import {getStoreData, setStoreData, delStoreData} from "~uti/storage";
|
|
|
|
+import {getObjNullValue, isAsyncFunction, isString, getArrValue, deepClone, getIndex} from "vue-utils-plus"
|
|
|
|
|
|
const useAppState = useAppStore()
|
|
const useAppState = useAppStore()
|
|
|
|
|
|
@@ -233,7 +234,10 @@ const getExcelHtml = async (pkeyId, func, keys) => {
|
|
//表单正则效验
|
|
//表单正则效验
|
|
onBlur: (event, key, reg, val, msg) => {
|
|
onBlur: (event, key, reg, val, msg) => {
|
|
setTableFormBlurReg(pkeyId, event, key, reg, val, msg)
|
|
setTableFormBlurReg(pkeyId, event, key, reg, val, msg)
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ onLeftClick: (key) => {
|
|
|
|
+ setShiftTableForm(key)
|
|
|
|
+ },
|
|
})
|
|
})
|
|
tableFormInfo.value.isRenderForm = true
|
|
tableFormInfo.value.isRenderForm = true
|
|
await nextTick(() => {
|
|
await nextTick(() => {
|
|
@@ -287,6 +291,79 @@ const onRightClick = (pkeyId, event, KeyName) => {
|
|
emit('rightTap', {event, KeyName, startPos, endPos, pkeyId})
|
|
emit('rightTap', {event, KeyName, startPos, endPos, pkeyId})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const isCtrlKey = ref(false)
|
|
|
|
+const checkKeyList = ref([])
|
|
|
|
+const copyKeyList = ref(getStoreData('TableFormCopyKeyList') || [])
|
|
|
|
+
|
|
|
|
+//设置选择数据
|
|
|
|
+const setShiftTableForm = (key) => {
|
|
|
|
+ if (isCtrlKey.value) {
|
|
|
|
+ const form = tableFormInfo.value
|
|
|
|
+ const keys = checkKeyList.value
|
|
|
|
+ const index = getIndex(keys, 'key', key)
|
|
|
|
+ if (index === -1) {
|
|
|
|
+ keys.push({key, val: form[key] ?? ''})
|
|
|
|
+ } else {
|
|
|
|
+ keys.splice(index, 1)
|
|
|
|
+ }
|
|
|
|
+ checkKeyList.value = keys
|
|
|
|
+ HTableForm.setCheckKeyStyle(key, index !== -1)
|
|
|
|
+ //console.log(keys)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//全局按键按下监听
|
|
|
|
+document.onkeydown = (event) => {
|
|
|
|
+ const {key, ctrlKey} = event
|
|
|
|
+ //按下ctrl键
|
|
|
|
+ if (ctrlKey && key === 'Control') {
|
|
|
|
+ //console.log('按下ctrl键')
|
|
|
|
+ isCtrlKey.value = true
|
|
|
|
+ }
|
|
|
|
+ //按下复制快捷键
|
|
|
|
+ if (ctrlKey && key === 'c') {
|
|
|
|
+ const keysList = deepClone(checkKeyList.value)
|
|
|
|
+ setStoreData('TableFormCopyKeyList', keysList)
|
|
|
|
+ copyKeyList.value = keysList
|
|
|
|
+ keysList.forEach(item => {
|
|
|
|
+ HTableForm.setCheckKeyStyle(item['key'], true)
|
|
|
|
+ })
|
|
|
|
+ checkKeyList.value = []
|
|
|
|
+ }
|
|
|
|
+ //按下粘贴快捷键
|
|
|
|
+ if (ctrlKey && key === 'v') {
|
|
|
|
+ const keysList = deepClone(copyKeyList.value)
|
|
|
|
+ const checkList = checkKeyList.value
|
|
|
|
+ checkList.forEach(item => {
|
|
|
|
+ if (keysList.length > 0) {
|
|
|
|
+ tableFormInfo.value[item['key']] = keysList[0]?.val ?? item['val']
|
|
|
|
+ keysList.splice(0, 1) //删除第一个元素
|
|
|
|
+ }
|
|
|
|
+ HTableForm.setCheckKeyStyle(item['key'], true)
|
|
|
|
+ })
|
|
|
|
+ //清除缓存
|
|
|
|
+ checkKeyList.value = []
|
|
|
|
+ copyKeyList.value = []
|
|
|
|
+ delStoreData('TableFormCopyKeyList')
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//全局键盘放开监听
|
|
|
|
+document.onkeyup = (event) => {
|
|
|
|
+ const {key, ctrlKey} = event
|
|
|
|
+ if (!ctrlKey && key === 'Control') {
|
|
|
|
+ //console.log('放开ctrl键')
|
|
|
|
+ isCtrlKey.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//卸载页面
|
|
|
|
+onUnmounted(() => {
|
|
|
|
+ document.onkeydown = null
|
|
|
|
+ document.onkeyup = null
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+
|
|
//获取表单数据
|
|
//获取表单数据
|
|
const getFormData = () => {
|
|
const getFormData = () => {
|
|
return tableFormInfo.value
|
|
return tableFormInfo.value
|