右键复制

This commit is contained in:
luojiaquan
2026-10-13 17:16:27 +08:00
parent d6a6ec4d53
commit 3598a0d669
5 changed files with 354 additions and 4 deletions
@@ -129,7 +129,9 @@
<column-settings :columns="columnDefs" :visible-map="colVisible" @toggle="toggleColumn" @reset="resetColumns" />
</el-row>
<el-table v-loading="loading" border :data="customerList" @selection-change="handleSelectionChange">
<el-table v-loading="loading" border :data="customerList"
@selection-change="handleSelectionChange"
@row-contextmenu="onTableRowContextmenu">
<el-table-column type="selection" width="55" align="center" fixed="left" />
<!-- <el-table-column label="客户ID" align="center" prop="customerId" />-->
<el-table-column v-if="isColVisible('customerCode')" label="客户编码" width="100" align="center" prop="customerCode" />
@@ -285,13 +287,22 @@
:customer-name="logCustomer.customerName"
:customer-code="logCustomer.customerCode"
/>
<!-- 右键复制列值 -->
<table-copy-menu
ref="copyMenuRef"
:columns="copyColumns"
:selected-rows="selectedRows"
:visible-keys="visibleCopyKeys"
/>
</div>
</template>
<script setup name="Customer">
<script setup name="Customerinfo">
import { listCustomer, delCustomer } from "@/api/customersuppliermanagement/customerinfo/customer.js"
import { listPriceSetOption, batchBindCustomerPriceSet } from "@/api/customersuppliermanagement/customerinfo/customerPriceSet.js"
import { useProducts, parseProductCodes } from '@/components/ProductSelect/useProducts'
import { useUsers } from '@/components/UserSelect/useUsers'
import CustomerLogDialog from './components/CustomerLogDialog.vue'
import { useColumnSettings } from '@/utils/columnSettings'
@@ -339,12 +350,48 @@ function productNames(productCodes) {
}
ensureProducts()
/** 员工ID -> 姓名(与表格 UserName 展示同源) */
const { ensureUsers, getUserName } = useUsers()
ensureUsers()
/** 格式化余额(数据源 customer_account 余额表) */
function formatBalance(val) {
const num = Number(val)
return isNaN(num) ? '0.00' : num.toFixed(2)
}
/* ================= 右键复制列值 ================= */
const copyMenuRef = ref(null)
/** 右键可复制列(取值口径与表格展示一致) */
const copyColumns = computed(() => [
{ key: 'customerCode', label: '客户编码', get: r => r.customerCode || '' },
{ key: 'customerName', label: '客户名称', get: r => r.customerName || '' },
{ key: 'customerCodeDw', label: '对外代码', get: r => r.customerCodeDw || '' },
{ key: 'creditCode', label: '统一社会信用代码', get: r => r.creditCode || '' },
{ key: 'customerType', label: '业务类型', get: r => proxy.selectDictLabel(customer_type.value, r.customerType) },
{ key: 'isEnable', label: '启用状态', get: r => proxy.selectDictLabel(sys_normal_disable.value, r.isEnable) },
{ key: 'salesUserId', label: '业务员', get: r => r.salesUserNickName || r.salesUser || r.salesUserId || '' },
{ key: 'zq', label: '回款账期', get: r => (r.zq === null || r.zq === undefined ? '' : r.zq) },
{ key: 'settlementUserId', label: '结算员', get: r => getUserName(r.settlementUserId) },
{ key: 'serviceUserId', label: '客服', get: r => getUserName(r.serviceUserId) },
{ key: 'settlementType', label: '结算方式', get: r => proxy.selectDictLabel(settlement_type.value, r.settlementType) },
{ key: 'tempEd', label: '临时额度', get: r => (r.tempEd === null || r.tempEd === undefined ? '' : r.tempEd) },
{ key: 'accountBalance', label: '账户余额(CNY)', get: r => formatBalance(r.accountBalance) },
{ key: 'weightThreshold', label: '重量阈值', get: r => (r.weightThreshold === null || r.weightThreshold === undefined ? '' : r.weightThreshold) },
{ key: 'throwRatio', label: '抛比', get: r => (r.throwRatio === null || r.throwRatio === undefined ? '' : r.throwRatio) },
{ key: 'creditEd', label: '信用额度', get: r => (r.creditEd === null || r.creditEd === undefined ? '' : r.creditEd) },
{ key: 'productCodes', label: '绑定产品', get: r => productNames(r.productCodes) },
{ key: 'priceSetName', label: '绑定套餐', get: r => r.priceSetName || '' },
{ key: 'remark', label: '备注说明', get: r => r.remark || '' }
])
/** 右键菜单只展示当前「列设置」中可见的列 */
const visibleCopyKeys = computed(() =>
columnDefs.filter(c => isColVisible(c.key)).map(c => c.key)
)
function onTableRowContextmenu(row, column, event) {
copyMenuRef.value && copyMenuRef.value.open(row, event)
}
const data = reactive({
queryParams: {
pageNum: 1,
@@ -376,6 +423,7 @@ const { queryParams } = toRefs(data)
/** 查询客户主列表 */
function getList() {
copyMenuRef.value && copyMenuRef.value.close()
loading.value = true
listCustomer(queryParams.value).then(response => {
customerList.value = response.rows
@@ -119,7 +119,9 @@
<column-settings :columns="columnDefs" :visible-map="colVisible" @toggle="toggleColumn" @reset="resetColumns" />
</el-row>
<el-table v-loading="loading" border :data="supplierList" @selection-change="handleSelectionChange">
<el-table v-loading="loading" border :data="supplierList"
@selection-change="handleSelectionChange"
@row-contextmenu="onTableRowContextmenu">
<el-table-column type="selection" width="55" align="center" fixed="left" />
<el-table-column v-if="isColVisible('supplierCode')" label="供应商编码" align="center" width="130" prop="supplierCode" />
<el-table-column v-if="isColVisible('supplierName')" label="供应商名称" align="center" width="130" prop="supplierName" :show-overflow-tooltip="true" />
@@ -189,12 +191,21 @@
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 右键复制列值 -->
<table-copy-menu
ref="copyMenuRef"
:columns="copyColumns"
:selected-rows="selectedRows"
:visible-keys="visibleCopyKeys"
/>
</div>
</template>
<script setup name="Supplier">
import { listSupplier, delSupplier } from "@/api/customersuppliermanagement/supplierinfo/supplier.js"
import { useChannels, parseChannelCodes } from '@/components/ChannelSelect/useChannels'
import { useUsers } from '@/components/UserSelect/useUsers'
import { useColumnSettings } from '@/utils/columnSettings'
const { proxy } = getCurrentInstance()
@@ -281,6 +292,47 @@ function formatDateOnly(value) {
return s.length > 10 ? s.substring(0, 10) : s
}
/** 员工ID -> 姓名(与表格 UserName 展示同源) */
const { ensureUsers, getUserName } = useUsers()
ensureUsers()
/* ================= 右键复制列值 ================= */
const copyMenuRef = ref(null)
/** 右键可复制列(取值口径与表格展示一致) */
const copyColumns = computed(() => [
{ key: 'supplierCode', label: '供应商编码', get: r => r.supplierCode || '' },
{ key: 'supplierName', label: '供应商名称', get: r => r.supplierName || '' },
{ key: 'supplierCodeDw', label: '对外代码', get: r => r.supplierCodeDw || '' },
{ key: 'creditCode', label: '统一社会信用代码', get: r => r.creditCode || '' },
{ key: 'supplierType', label: '供应商类型', get: r => formatOption(supplierTypeOptions.value, r.supplierType) },
{ key: 'invoiceType', label: '开票类型', get: r => formatOption(invoiceTypeOptions.value, r.invoiceType) },
{ key: 'kacheType', label: '卡车行类型', get: r => formatOption(kacheTypeOptions.value, r.kacheType) },
{ key: 'isEnable', label: '启用状态', get: r => proxy.selectDictLabel(sys_normal_disable.value, r.isEnable) },
{ key: 'purchaserUserId', label: '采购员', get: r => getUserName(r.purchaserUserId) },
{ key: 'ed', label: '应付额度', get: r => (r.ed === null || r.ed === undefined ? '' : r.ed) },
{ key: 'zq', label: '应付账期', get: r => (r.zq === null || r.zq === undefined ? '' : r.zq) },
{ key: 'settlementUserId', label: '结算员', get: r => getUserName(r.settlementUserId) },
{ key: 'serviceUserId', label: '跟单员', get: r => getUserName(r.serviceUserId) },
{ key: 'settlementType', label: '结算方式', get: r => proxy.selectDictLabel(settlement_type.value, r.settlementType) },
{ key: 'tempEd', label: '临时额度', get: r => (r.tempEd === null || r.tempEd === undefined ? '' : r.tempEd) },
{ key: 'accountBalance', label: '应付余额', get: r => (r.accountBalance === null || r.accountBalance === undefined ? '' : r.accountBalance) },
{ key: 'foreignCurrencyBalance', label: '外币应付余额', get: r => (r.foreignCurrencyBalance === null || r.foreignCurrencyBalance === undefined ? '' : r.foreignCurrencyBalance) },
{ key: 'creditEd', label: '信用额度', get: r => (r.creditEd === null || r.creditEd === undefined ? '' : r.creditEd) },
{ key: 'weightThreshold', label: '重量阈值', get: r => (r.weightThreshold === null || r.weightThreshold === undefined ? '' : r.weightThreshold) },
{ key: 'throwRatio', label: '抛比', get: r => (r.throwRatio === null || r.throwRatio === undefined ? '' : r.throwRatio) },
{ key: 'cooperationStartDate', label: '合作开始日期', get: r => formatDateOnly(r.cooperationStartDate) },
{ key: 'cooperationStatus', label: '合作状态', get: r => formatOption(cooperationStatusOptions.value, r.cooperationStatus) },
{ key: 'channelIds', label: '绑定渠道', get: r => channelNames(r.channelIds) },
{ key: 'remark', label: '备注说明', get: r => r.remark || '' }
])
/** 右键菜单只展示当前「列设置」中可见的列 */
const visibleCopyKeys = computed(() =>
columnDefs.filter(c => isColVisible(c.key)).map(c => c.key)
)
function onTableRowContextmenu(row, column, event) {
copyMenuRef.value && copyMenuRef.value.open(row, event)
}
const data = reactive({
queryParams: {
pageNum: 1,
@@ -315,6 +367,7 @@ const { queryParams } = toRefs(data)
/** 查询供应商列表 */
function getList() {
copyMenuRef.value && copyMenuRef.value.close()
loading.value = true
listSupplier(queryParams.value).then(response => {
supplierList.value = response.rows