c5a03313 by lxs

入表功调整

1 parent 5b046d4a
......@@ -8,7 +8,7 @@ import { ElMessage, ElMessageBox, translate } from "element-plus";
import { MoreFilled } from '@element-plus/icons-vue'
import useUserStore from "@/store/modules/user";
import { changeNum } from "@/utils/common";
import { costDelete, getAssetCatalog, getCostList, sendEntryMsg } from "@/api/modules/dataEntry";
import { getAssetCatalog, getCostList, sendEntryMsg } from "@/api/modules/dataEntry";
import * as XLSXS from 'xlsx-js-style';
import { saveAs } from 'file-saver';
......@@ -22,7 +22,6 @@ const companyName = ref('');
/** 默认显示步骤 */
const step = ref(0);
const showAdd = ref(false);
const productList = ref([]);
const costFormRef = ref();
const entryFormRef = ref();
......@@ -277,10 +276,6 @@ const bookHeaders: any = ref([
]);
const transposedData = ref([]);
const popoverVisible = ref(false);
const popoverTriggerRef = ref(null)
const currentRow: any = ref({})
// 获取产品数据
const getProducts = () => {
getAssetCatalog().then((res: any) => {
......@@ -345,50 +340,10 @@ const setChecked = (level, code, check) => {
rowList.forEach(rData => rData[`checked${level}`] = check)
};
// 点击外部区域关闭处理
const handleClickOutside = (event) => {
const popoverEl = document.querySelector('.tree-item-edit-menu')
const triggerEl: any = popoverTriggerRef.value
if (!popoverVisible.value || !popoverEl || !triggerEl) return
const clickedInPopover = popoverEl.contains(event.target)
const clickedOnTrigger = triggerEl === event.target || triggerEl.contains(event.target)
if (!clickedInPopover && !clickedOnTrigger) {
popoverVisible.value = false
}
}
// 切换Popover显示/隐藏
const togglePopover = (row, event) => {
// 如果点击的是当前已激活的触发器,则关闭popover
if (popoverVisible.value && popoverTriggerRef.value === event.currentTarget) {
popoverVisible.value = false
return
}
// 设置当前行和触发器引用
currentRow.value = row
popoverTriggerRef.value = event.currentTarget
const level = Number(row.field.split('name')[1]);
showAdd.value = level == 3 ? true : false;
// 打开popover
popoverVisible.value = true
}
// 处理菜单点击
const handleMenuClick = (action) => {
const handleMenuClick = (action, rowData) => {
// 关闭popover
popoverVisible.value = false;
btnClick({ value: action, row: currentRow.value })
}
// Popover关闭后的处理
const handlePopoverClose = () => {
currentRow.value = null
popoverTriggerRef.value = null
btnClick({ value: action, row: { ...rowData, level: Number(rowData.field.split('name')[1]) } })
}
const selectChange = async (val, row, info) => {
......@@ -1334,18 +1289,8 @@ onActivated(() => {
getCostData();
});
onMounted(() => {
// 添加/移除全局点击监听
document.addEventListener('click', handleClickOutside)
})
onBeforeUnmount(() => {
document.removeEventListener('click', handleClickOutside)
})
onUpdated(() => {
// setItemLine();
});
</script>
......@@ -1406,11 +1351,23 @@ onUpdated(() => {
"--" : scope.row[item.field] }}
</span>
</span>
<el-icon v-if="item.field == 'name3' || (item.field == 'name4' && scope.row[item.field])"
class="list-more" color="#666"
@click="e => togglePopover({ ...item, ...scope.row, rIndex: scope.$index }, e)">
<MoreFilled />
</el-icon>
<template v-if="item.field == 'name3' || (item.field == 'name4' && scope.row[item.field])">
<el-popover placement="bottom-start" :width="110" trigger="click" popper-class="tree-item-edit-menu" :hide-after="0" :offset="8">
<template #reference>
<el-icon class="list-more" color="#666">
<MoreFilled />
</el-icon>
</template>
<div class="levitation-ul" @mousedown.stop>
<span class="levitation-li" @click="handleMenuClick('add-same', { ...item, ...scope.row, rIndex: scope.$index })"
:style="{ display: item.field == 'name3' ? 'block' : 'none' }">新增本级分类</span>
<span class="levitation-li" @click="handleMenuClick('add-lower', { ...item, ...scope.row, rIndex: scope.$index })"
:style="{ display: item.field == 'name3' ? 'block' : 'none' }">新增下级分类</span>
<span class="levitation-li" @click="handleMenuClick('edit', { ...item, ...scope.row, rIndex: scope.$index })">重命名</span>
<span class="levitation-li" @click="handleMenuClick('remove', { ...item, ...scope.row, rIndex: scope.$index })">删除</span>
</div>
</el-popover>
</template>
</div>
</template>
</el-table-column>
......@@ -1442,16 +1399,6 @@ onUpdated(() => {
</div>
</div>
</div>
<el-popover :visible="popoverVisible" placement="bottom-start" width="110" trigger="click"
popper-class="tree-item-edit-menu" :virtual-ref="popoverTriggerRef" virtual-triggering :hide-after="0" :offset="8"
@after-leave="handlePopoverClose">
<div class="levitation-ul" @mousedown.stop>
<span class="levitation-li" @click="handleMenuClick('add-same')" v-show="showAdd">新增本级分类</span>
<span class="levitation-li" @click="handleMenuClick('add-lower')" v-show="showAdd">新增下级分类</span>
<span class="levitation-li" @click="handleMenuClick('edit')">重命名</span>
<span class="levitation-li" @click="handleMenuClick('remove')">删除</span>
</div>
</el-popover>
</template>
<style lang="scss" scoped>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!