Commit a291be25 by qinjianhui

fix: 表格加右击事件

parent ce3d6f24
...@@ -32,7 +32,6 @@ declare module 'vue' { ...@@ -32,7 +32,6 @@ declare module 'vue' {
ElImage: typeof import('element-plus/es')['ElImage'] ElImage: typeof import('element-plus/es')['ElImage']
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElLink: typeof import('element-plus/es')['ElLink']
ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption'] ElOption: typeof import('element-plus/es')['ElOption']
...@@ -58,7 +57,6 @@ declare module 'vue' { ...@@ -58,7 +57,6 @@ declare module 'vue' {
LogList: typeof import('./src/components/LogList.vue')['default'] LogList: typeof import('./src/components/LogList.vue')['default']
NavMenu: typeof import('./src/components/NavMenu.vue')['default'] NavMenu: typeof import('./src/components/NavMenu.vue')['default']
RenderColumn: typeof import('./src/components/RenderColumn.vue')['default'] RenderColumn: typeof import('./src/components/RenderColumn.vue')['default']
RightClickMenu: typeof import('./src/components/TableRightClickMenu.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView'] RouterView: typeof import('vue-router')['RouterView']
Select: typeof import('./src/components/Form.vue/Select.vue')['default'] Select: typeof import('./src/components/Form.vue/Select.vue')['default']
...@@ -66,7 +64,6 @@ declare module 'vue' { ...@@ -66,7 +64,6 @@ declare module 'vue' {
SplitDiv: typeof import('./src/components/splitDiv/splitDiv.vue')['default'] SplitDiv: typeof import('./src/components/splitDiv/splitDiv.vue')['default']
'Switch ': typeof import('./src/components/Form.vue/Switch .vue')['default'] 'Switch ': typeof import('./src/components/Form.vue/Switch .vue')['default']
TableRightClickMenu: typeof import('./src/components/TableRightClickMenu.vue')['default'] TableRightClickMenu: typeof import('./src/components/TableRightClickMenu.vue')['default']
TableRightMenu: typeof import('./src/components/TableRightMenu.vue')['default']
TableView: typeof import('./src/components/TableView.vue')['default'] TableView: typeof import('./src/components/TableView.vue')['default']
UploadExcel: typeof import('./src/components/UploadExcel.vue')['default'] UploadExcel: typeof import('./src/components/UploadExcel.vue')['default']
UploadImage: typeof import('./src/components/UploadImage.vue')['default'] UploadImage: typeof import('./src/components/UploadImage.vue')['default']
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
> >
<div class="menu-item" @click="handleSelectAll">全选</div> <div class="menu-item" @click="handleSelectAll">全选</div>
<div class="menu-item" @click="handleUnselectAll">取消全选</div> <div class="menu-item" @click="handleUnselectAll">取消全选</div>
<div class="menu-item" @click="handleCopyShopNumbers">复制店铺单号</div> <div class="menu-item" @click="onChangeCopy('shop-numbers')">
复制店铺单号
</div>
</div> </div>
</template> </template>
...@@ -14,12 +16,19 @@ ...@@ -14,12 +16,19 @@
import { ref, defineExpose, onMounted, onUnmounted } from 'vue' import { ref, defineExpose, onMounted, onUnmounted } from 'vue'
import type { TableInstance } from 'element-plus' import type { TableInstance } from 'element-plus'
const visible = ref(false) const visible = ref(false)
const position = ref({ x: 0, y: 0 }) const position = ref({ x: 0, y: 0 })
const tableRef = ref<TableInstance>() const tableRef = ref<TableInstance>()
const emit = defineEmits(['copyShopNumbers']) const emit = defineEmits(['onChange'])
const setPosition = ({ x, y, el }: { x: number; y: number; el: TableInstance }) => { const setPosition = ({
x,
y,
el,
}: {
x: number
y: number
el: TableInstance
}) => {
position.value = { x, y } position.value = { x, y }
visible.value = true visible.value = true
tableRef.value = el tableRef.value = el
...@@ -39,8 +48,8 @@ const handleUnselectAll = () => { ...@@ -39,8 +48,8 @@ const handleUnselectAll = () => {
visible.value = false visible.value = false
} }
const handleCopyShopNumbers = () => { const onChangeCopy = (value: string) => {
emit('copyShopNumbers') emit('onChange', value)
visible.value = false visible.value = false
} }
...@@ -61,7 +70,7 @@ onUnmounted(() => { ...@@ -61,7 +70,7 @@ onUnmounted(() => {
}) })
defineExpose({ defineExpose({
setPosition setPosition,
}) })
</script> </script>
...@@ -86,4 +95,4 @@ defineExpose({ ...@@ -86,4 +95,4 @@ defineExpose({
background-color: #f5f7fa; background-color: #f5f7fa;
color: #409eff; color: #409eff;
} }
</style> </style>
\ No newline at end of file
...@@ -58,10 +58,7 @@ ...@@ -58,10 +58,7 @@
</RenderColumn> </RenderColumn>
</template> </template>
</ElTable> </ElTable>
<RightClickMenu <RightClickMenu ref="rightMenuRef" @on-change="onChange" />
@copy-shop-numbers="emit('copyShopNumbers')"
ref="rightMenuRef"
/>
</div> </div>
</template> </template>
<script setup lang="tsx" generic="T"> <script setup lang="tsx" generic="T">
...@@ -101,7 +98,7 @@ defineProps({ ...@@ -101,7 +98,7 @@ defineProps({
const attrs = useAttrs() const attrs = useAttrs()
const slots = useSlots() as Record<string, Slot> const slots = useSlots() as Record<string, Slot>
const emit = defineEmits(['copyShopNumbers']) const emit = defineEmits(['onChange'])
const handleContextMenu = (e: MouseEvent) => { const handleContextMenu = (e: MouseEvent) => {
if (rightMenuRef.value && tableRef.value) { if (rightMenuRef.value && tableRef.value) {
rightMenuRef.value.setPosition({ rightMenuRef.value.setPosition({
...@@ -111,7 +108,9 @@ const handleContextMenu = (e: MouseEvent) => { ...@@ -111,7 +108,9 @@ const handleContextMenu = (e: MouseEvent) => {
}) })
} }
} }
const onChange = (type: string) => {
emit('onChange', type)
}
const setCurrentRow = (row: T) => { const setCurrentRow = (row: T) => {
tableRef.value?.setCurrentRow(row) tableRef.value?.setCurrentRow(row)
} }
......
...@@ -271,9 +271,11 @@ ...@@ -271,9 +271,11 @@
v-loading="loading" v-loading="loading"
element-loading-text="加载中..." element-loading-text="加载中..."
class="order-list flex-1 overflow-hidden" class="order-list flex-1 overflow-hidden"
@contextmenu.prevent="handleContextMenu"
> >
<ElTable <ElTable
v-show="statusCode !== 6" v-show="statusCode !== 6"
ref="tableRef"
:data="tableData" :data="tableData"
:span-method="arraySpanMethod" :span-method="arraySpanMethod"
default-expand-all default-expand-all
...@@ -597,6 +599,7 @@ ...@@ -597,6 +599,7 @@
</ElTable> </ElTable>
<ElTable <ElTable
v-show="statusCode === 6" v-show="statusCode === 6"
ref="tableQaRef"
:data="tableData" :data="tableData"
:span-method="arraySpanMethod" :span-method="arraySpanMethod"
default-expand-all default-expand-all
...@@ -973,6 +976,12 @@ ...@@ -973,6 +976,12 @@
> >
<OrderDetail :order-detail-data="orderDetailData" /> <OrderDetail :order-detail-data="orderDetailData" />
</ElDrawer> </ElDrawer>
<RightMenu
ref="rightMenuRef"
:show-copy-count="false"
:show-copy-sub-shop-number="statusCode !== 6"
@change="onChange"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Shipment from './Shipment.vue' import Shipment from './Shipment.vue'
...@@ -990,7 +999,12 @@ import type { ...@@ -990,7 +999,12 @@ import type {
} from '@/types/api/order' } from '@/types/api/order'
import { nextTick, onMounted, reactive, ref } from 'vue' import { nextTick, onMounted, reactive, ref } from 'vue'
import useElTableColumnWidth from '@/utils/hooks/useElTableColumnWidth' import useElTableColumnWidth from '@/utils/hooks/useElTableColumnWidth'
import { ArrowDown, ArrowUp, DocumentCopy, EditPen } from '@element-plus/icons-vue' import {
ArrowDown,
ArrowUp,
DocumentCopy,
EditPen,
} from '@element-plus/icons-vue'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
import { import {
getOrderList, getOrderList,
...@@ -1023,6 +1037,7 @@ import OrderDetail from './OrderDetail.vue' ...@@ -1023,6 +1037,7 @@ import OrderDetail from './OrderDetail.vue'
import useShipment from './hook/useShipment' import useShipment from './hook/useShipment'
import useQuarantine from './hook/useQuarantine' import useQuarantine from './hook/useQuarantine'
import Quarantine from './Quarantine.vue' import Quarantine from './Quarantine.vue'
import RightMenu from './pod/rightMenu.vue'
const [searchForm] = useValue<SearchForm>({ const [searchForm] = useValue<SearchForm>({
mainSku: '', mainSku: '',
...@@ -1644,7 +1659,65 @@ const cancelOrder = async (id: number) => { ...@@ -1644,7 +1659,65 @@ const cancelOrder = async (id: number) => {
// showError(e) // showError(e)
} }
} }
const rightMenuRef = ref()
const handleContextMenu = (e: MouseEvent) => {
rightMenuRef.value?.setPosition({
x: e.clientX,
y: e.clientY,
cardItem: e.clientY,
el: e,
})
}
const tableQaRef = ref()
const tableRef = ref()
const onChange = (key: string) => {
if (key === 'check_all') {
if (statusCode.value === 6) {
tableQaRef.value?.toggleAllSelection()
} else {
tableRef.value?.toggleAllSelection()
}
} else if (key === 'clear_check') {
if (statusCode.value === 6) {
tableQaRef.value?.clearSelection()
} else {
tableRef.value?.clearSelection()
}
} else if (key === 'copy_code') {
const shopNumberList: string[] = []
for (const item of selection.value) {
item.productList?.forEach((el) => {
if (el.shopNumber) {
shopNumberList.push(el.shopNumber)
}
})
}
copy(shopNumberList.join(','))
} else if (key === 'copy_shopNumber') {
const subOrderNumber: string[] = []
if (statusCode.value === 6) {
for (const item of selection.value) {
item.detailList?.forEach((el) => {
if (el.shopNumber) {
subOrderNumber.push(el.shopNumber || '')
}
})
}
} else {
for (const item of selection.value) {
item.productList?.forEach((el) => {
if (el.subOrderNumber) {
subOrderNumber.push(el.subOrderNumber)
}
})
}
}
copy(subOrderNumber.join(','))
} else if (key === 'count') {
const count = selection.value.length
copy(count.toString())
}
}
const onChangeCurrentRow = (item: ProductList) => { const onChangeCurrentRow = (item: ProductList) => {
currentRow.value = item currentRow.value = item
} }
......
...@@ -231,7 +231,12 @@ ...@@ -231,7 +231,12 @@
v-if="['TO_BE_CONFIRMED', 'IN_PRODUCTION'].includes(status)" v-if="['TO_BE_CONFIRMED', 'IN_PRODUCTION'].includes(status)"
class="item" class="item"
> >
<ElButton :loading="syncLoading" type="warning" is-dark @click="synchronousPlan"> <ElButton
:loading="syncLoading"
type="warning"
is-dark
@click="synchronousPlan"
>
同步素材图</ElButton 同步素材图</ElButton
> >
</span> </span>
...@@ -481,7 +486,7 @@ ...@@ -481,7 +486,7 @@
" "
> >
{{ cardItem?.processName }} {{ cardItem?.processName }}
</span> </span>
</el-col> </el-col>
<el-col <el-col
:span="12" :span="12"
...@@ -544,11 +549,10 @@ ...@@ -544,11 +549,10 @@
> >
<img width="20" src="@/assets/images/id.png" /> <img width="20" src="@/assets/images/id.png" />
<el-tooltip :content="cardItem?.productionFileId"> <el-tooltip :content="cardItem?.productionFileId">
<span class="over-hidden" title="素材ID"> <span class="over-hidden" title="素材ID">
{{ cardItem?.productionFileId }} {{ cardItem?.productionFileId }}
</span> </span>
</el-tooltip> </el-tooltip>
</a> </a>
</el-col> </el-col>
<el-col <el-col
...@@ -594,7 +598,7 @@ ...@@ -594,7 +598,7 @@
default-expand-all default-expand-all
:span-method="arraySpanMethod" :span-method="arraySpanMethod"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
@contextmenu.prevent="handleContextMenu" @on-change="onChange"
> >
<template #expand="{ row }"> <template #expand="{ row }">
<div v-if="row.productList" class="table-expand"> <div v-if="row.productList" class="table-expand">
...@@ -974,6 +978,9 @@ ...@@ -974,6 +978,9 @@
:show-copy-shop-number=" :show-copy-shop-number="
['IN_PRODUCTION', 'TO_BE_CONFIRMED', 'WAIT_SHIPMENT'].includes(status) ['IN_PRODUCTION', 'TO_BE_CONFIRMED', 'WAIT_SHIPMENT'].includes(status)
" "
:show-copy-count="
['IN_PRODUCTION', 'TO_BE_CONFIRMED', 'WAIT_SHIPMENT'].includes(status)
"
@change="rightChange" @change="rightChange"
/> />
<fastProduction <fastProduction
...@@ -986,11 +993,6 @@ ...@@ -986,11 +993,6 @@
@on-success="handleSuccess" @on-success="handleSuccess"
@close="fastClose" @close="fastClose"
></fastProduction> ></fastProduction>
<table-right-menu
ref="tableRightMenuRef"
:table-right-menu-visible="tableRightMenuVisible"
@on-copy-change="onCopyChange"
/>
<el-dialog <el-dialog
v-model="completeShipmentVisible" v-model="completeShipmentVisible"
title="完成发货" title="完成发货"
...@@ -1105,7 +1107,6 @@ import { ...@@ -1105,7 +1107,6 @@ import {
SearchForm, SearchForm,
Tab, Tab,
LogListData, LogListData,
PodProductList, PodProductList,
cardImages, cardImages,
imageAryInter, imageAryInter,
...@@ -1825,7 +1826,9 @@ const synchronousPlan = async () => { ...@@ -1825,7 +1826,9 @@ const synchronousPlan = async () => {
return return
} }
try { try {
const res = await syncSubOrderDesignImages(selection.value.map(item=>item.id)) const res = await syncSubOrderDesignImages(
selection.value.map((item) => item.id),
)
await loadDiffList() await loadDiffList()
await loadTabData() await loadTabData()
syncLoading.value = false syncLoading.value = false
...@@ -2161,10 +2164,8 @@ const invalidOrder = async (row: ProductList) => { ...@@ -2161,10 +2164,8 @@ const invalidOrder = async (row: ProductList) => {
} }
}) })
} }
const tableRightMenuVisible = ref(false) const onChange = (type: string) => {
const tableRightMenuRef = ref() if (type === 'shop-numbers') {
const onCopyChange = (type: string) => {
if (type === 'copy_shop_number') {
const shopNumberList = [] const shopNumberList = []
for (const item of tableData.value) { for (const item of tableData.value) {
if (item.productList) { if (item.productList) {
...@@ -2174,16 +2175,6 @@ const onCopyChange = (type: string) => { ...@@ -2174,16 +2175,6 @@ const onCopyChange = (type: string) => {
copy(shopNumberList.join(',')) copy(shopNumberList.join(','))
} }
} }
const handleContextMenu = (e: MouseEvent) => {
tableRightMenuVisible.value = true
tableRightMenuRef.value?.setRightMenuOptions({
contextMenuX: e.clientX,
contextMenuY: e.clientY,
})
}
const listenerClick = () => {
tableRightMenuVisible.value = false
}
const getUserMark = async () => { const getUserMark = async () => {
try { try {
...@@ -2208,7 +2199,6 @@ const openMaterial = async (item: PodProductList) => { ...@@ -2208,7 +2199,6 @@ const openMaterial = async (item: PodProductList) => {
} }
onMounted(async () => { onMounted(async () => {
document.addEventListener('keydown', listenerKeydown) document.addEventListener('keydown', listenerKeydown)
document.addEventListener('click', listenerClick)
await loadTabData() await loadTabData()
getUserMark() getUserMark()
getLogisticsList() getLogisticsList()
...@@ -2216,7 +2206,6 @@ onMounted(async () => { ...@@ -2216,7 +2206,6 @@ onMounted(async () => {
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
document.removeEventListener('keydown', listenerKeydown) document.removeEventListener('keydown', listenerKeydown)
document.removeEventListener('click', listenerClick)
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -2491,9 +2480,9 @@ onBeforeUnmount(() => { ...@@ -2491,9 +2480,9 @@ onBeforeUnmount(() => {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.over-hidden{ .over-hidden {
width: 150px; width: 150px;
display:inline-block; display: inline-block;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
......
<template> <template>
<!-- <div class="wrap" @click="close"> --> <!-- <div class="wrap" @click="close"> -->
<div v-if="show" ref="right_menu" class="right_menu"> <div v-if="show" ref="right_menu" class="right_menu">
<button @click="$emit('change', 'check_all')"> <button @click="$emit('change', 'check_all')">全部选择</button>
全部选择
</button>
<button @click="$emit('change', 'clear_check')">取消选择</button> <button @click="$emit('change', 'clear_check')">取消选择</button>
<button @click="$emit('change', 'copy_code')">复制选中生产单号</button> <button v-if="showCopySubShopNumber" @click="$emit('change', 'copy_code')">
复制选中生产单号
</button>
<button v-if="showCopyShopNumber" @click="$emit('change', 'copy_shopNumber')">复制选中店铺单号</button> <button
<button v-if="showCopyShopNumber" @click="$emit('change', 'count')">统计数量</button> v-if="showCopyShopNumber"
@click="$emit('change', 'copy_shopNumber')"
>
复制选中店铺单号
</button>
<button v-if="showCopyCount" @click="$emit('change', 'count')">
统计数量
</button>
</div> </div>
<!-- </div> --> <!-- </div> -->
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ref,defineProps,defineExpose} from 'vue' import { ref, defineProps, defineExpose } from 'vue'
interface E{ interface E {
x:number x: number
el:HTMLElement el: HTMLElement
y:number y: number
} }
defineProps({ defineProps({
showCopyShopNumber:{ showCopyShopNumber: {
type:Boolean, type: Boolean,
default:true default: true,
} },
showCopyCount: {
type: Boolean,
default: true,
},
showCopySubShopNumber: {
type: Boolean,
default: true,
},
}) })
const row = ref() const row = ref()
const show = ref(false) const show = ref(false)
const right_menu = ref<HTMLElement>() const right_menu = ref<HTMLElement>()
const close = ()=>{ const close = () => {
show.value = false show.value = false
document.body.onclick = null document.body.onclick = null
} }
const setPosition = (o:E)=> { const setPosition = (o: E) => {
console.log(o) console.log(o)
show.value = true show.value = true
const clientX = o.x const clientX = o.x
...@@ -42,18 +57,17 @@ const setPosition = (o:E)=> { ...@@ -42,18 +57,17 @@ const setPosition = (o:E)=> {
document.body.onclick = function () { document.body.onclick = function () {
close() close()
} }
row.value = row.value = setTimeout(() => {
setTimeout(() => { if (!right_menu.value) return
if(!right_menu.value) return
if (x < 150) { if (x < 150) {
right_menu.value.style.cssText = `top:${o.y}px;right:${x}px` right_menu.value.style.cssText = `top:${o.y}px;right:${x}px`
} else { } else {
right_menu.value.style.cssText = `top:${o.y}px;left:${o.x}px` right_menu.value.style.cssText = `top:${o.y}px;left:${o.x}px`
} }
}, 1) }, 1)
} }
defineExpose({ defineExpose({
setPosition setPosition,
}) })
</script> </script>
<style scoped> <style scoped>
...@@ -89,7 +103,7 @@ defineExpose({ ...@@ -89,7 +103,7 @@ defineExpose({
background: rgb(65, 192, 251); background: rgb(65, 192, 251);
color: white; color: white;
} }
button{ button {
outline: none; outline: none;
border: none; border: none;
} }
......
...@@ -364,7 +364,7 @@ ...@@ -364,7 +364,7 @@
:paginated-data="tableData" :paginated-data="tableData"
:cell-style="onCellStyle" :cell-style="onCellStyle"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
@copy-shop-numbers="handleCopyShopNumbers" @on-change="onChange"
> >
<template #goods="{ row }"> <template #goods="{ row }">
<div class="goods-info-box"> <div class="goods-info-box">
...@@ -909,7 +909,7 @@ ...@@ -909,7 +909,7 @@
</div> </div>
<right-menu <right-menu
ref="rightMenuRef" ref="rightMenuRef"
:show-copy-shop-number="false" :show-copy-count="false"
@change="rightChange" @change="rightChange"
/> />
<el-dialog <el-dialog
...@@ -1882,6 +1882,12 @@ const rightChange = async (code: string) => { ...@@ -1882,6 +1882,12 @@ const rightChange = async (code: string) => {
.join() .join()
navigator.clipboard.writeText(str) navigator.clipboard.writeText(str)
ElMessage.success('复制成功') ElMessage.success('复制成功')
} else if (code === 'copy_shopNumber') {
const str = cardSelection.value
.map((item) => item.shopNumber)
.join()
navigator.clipboard.writeText(str)
ElMessage.success('复制成功')
} }
} }
const currentImage = ref('') const currentImage = ref('')
...@@ -2487,13 +2493,15 @@ onMounted(() => { ...@@ -2487,13 +2493,15 @@ onMounted(() => {
loadProductionClient() loadProductionClient()
loadWarehouseList() loadWarehouseList()
}) })
const handleCopyShopNumbers = () => { const onChange = (value: string) => {
const shopNumbers = (tableData.value as PodUsOrderListData[]) if (value === 'shop-numbers') {
.map((item) => item.shopNumber) const shopNumbers = (tableData.value as PodUsOrderListData[])
.join(',') .map((item) => item.shopNumber)
navigator.clipboard.writeText(shopNumbers).then(() => { .join(',')
ElMessage.success('店铺单号已复制到剪贴板') navigator.clipboard.writeText(shopNumbers).then(() => {
}) ElMessage.success('店铺单号已复制到剪贴板')
})
}
} }
const handleExceptionCommand = (command: number) => { const handleExceptionCommand = (command: number) => {
exceptionStatus.value = command exceptionStatus.value = command
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment