Commit ef941f44 by wusiyi

feat: 工厂订单new支持批量复制订单号到筛选框进行筛选 #1009627

parent 3e0881e1
......@@ -4,8 +4,8 @@
class="right-click-menu"
:style="{ left: position.x + 'px', top: position.y + 'px' }"
>
<div class="menu-item" @click="onChangeCopy('select-all')">全部选择</div>
<div class="menu-item" @click="onChangeCopy('cancel-select')">取消选择</div>
<div v-if="showSelectionMenu" class="menu-item" @click="onChangeCopy('select-all')">全部选择</div>
<div v-if="showSelectionMenu" class="menu-item" @click="onChangeCopy('cancel-select')">取消选择</div>
<div
v-if="showCopySubShopNumber"
class="menu-item"
......@@ -48,6 +48,10 @@ defineProps({
type: Boolean,
default: true,
},
showSelectionMenu: {
type: Boolean,
default: true,
},
})
const setPosition = ({ x, y }: { x: number; y: number }) => {
......
......@@ -796,6 +796,7 @@
v-loading="loading"
element-loading-text="加载中..."
class="table-list flex-1 overflow-hidden"
@contextmenu.prevent="rightClick"
>
<TableView
ref="tableRef"
......@@ -956,6 +957,7 @@
:paginated-data="operationOrderList"
:columns="operationOrderColumns"
serial-numberable
@row-contextmenu="handleOperationOrderContextMenu"
/>
</div>
</el-tab-pane>
......@@ -1179,6 +1181,31 @@
:warehouse-list="warehouseList"
:selected-rows="selectedRows"
/>
<RightClickMenu
ref="rightMenuRef"
:show-copy-count="false"
:show-copy-sub-shop-number="false"
:show-copy-shop-number="rightClickContext === 'main'"
:show-selection-menu="rightClickContext === 'main'"
@on-change="rightChange"
>
<template #default>
<div
v-if="rightClickContext === 'main'"
class="menu-item"
@click="rightChange('order-number')"
>
复制订单编号
</div>
<div
v-if="rightClickContext === 'operation'"
class="menu-item"
@click="rightChange('operationNo')"
>
复制操作单号
</div>
</template>
</RightClickMenu>
</div>
</template>
......@@ -1194,6 +1221,7 @@ import {
import { computed, nextTick, onMounted, ref } from 'vue'
import splitDiv from '@/components/splitDiv/splitDiv.vue'
import TableView from '@/components/TableView.vue'
import RightClickMenu from '@/components/RightClickMenu.vue'
import ResultInfo from '@/views/order/components/ResultInfo.vue'
import type { BaseRespData } from '@/types/api'
import type {
......@@ -1650,11 +1678,73 @@ const handleSuspendTabClick = (value: number) => {
// statusCurrentPageRef.value = 1
// refreshTableList()
// }
const handleCopyCell = (e: Event, text?: string) => {
e.stopPropagation()
const handleCopyCell = (e: Event | null, text?: string) => {
e && e.stopPropagation()
if (text) window.navigator.clipboard.writeText(text)
ElMessage.success('复制成功')
}
const rightMenuRef = ref()
const rightClickContext = ref<'main' | 'operation'>('main')
const operationRightClickItem = ref<operateOrderListData | null>(null)
const rightClick = (e: MouseEvent) => {
rightClickContext.value = 'main'
operationRightClickItem.value = null
rightMenuRef.value?.setPosition({
x: e.clientX,
y: e.clientY,
})
}
const handleOperationOrderContextMenu = (
row: unknown,
_column: unknown,
event: Event,
) => {
event.preventDefault()
rightClickContext.value = 'operation'
operationRightClickItem.value = null
rightMenuRef.value?.setPosition({
x: (event as MouseEvent).clientX,
y: (event as MouseEvent).clientY,
})
}
const rightChange = async (code: string) => {
if (code === 'select-all') {
tableRef.value?.toggleAllSelection()
return
}
if (code === 'cancel-select') {
tableRef.value?.clearSelection()
return
}
const targetRows = selectedRows.value
if (code === 'copy_shopNumber') {
const str = targetRows
.map((item) => item.shopNumber)
.filter(Boolean)
.join(',')
handleCopyCell(null, str)
} else if (code === 'order-number') {
const str = targetRows
.map((item) => item.factoryOrderNumber)
.filter(Boolean)
.join(',')
handleCopyCell(null, str)
} else if (code === 'operationNo') {
const str = operationOrderList.value
.map((item) => item?.operationNo)
.filter(Boolean)
.join(',')
if (!str) return ElMessage.warning('当前数据没有操作单号')
handleCopyCell(null, str)
}
}
const mainColumns = computed(() => [
{
prop: 'factoryOrderNumber',
......
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