1
This commit is contained in:
@@ -97,6 +97,8 @@
|
||||
<el-button type="primary" size="small" icon="el-icon-refresh-right" @click="handleBatchSyncLogistics" :loading="batchSyncLoading" title="批量同步物流链接到腾讯文档">一键发货到腾峰</el-button>
|
||||
<el-button type="success" size="small" icon="el-icon-check" @click="handleBatchMarkRebateReceived" :loading="batchMarkLoading" title="批量将赔付金额大于0的订单标记为后返到账(仅执行一次)">批量标记后返到账</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-sort" @click="handleReverseSyncThirdPartyOrderNo" :loading="reverseSyncLoading" title="从腾讯文档第850行开始,通过物流链接反向匹配订单,将腾讯文档的单号列值写入到订单的第三方单号字段">反向同步第三方单号</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-document-copy" @click="handleBatchCopyExcelText" :disabled="selectedRows.length === 0" title="批量复制选中订单的录单格式(Excel可粘贴)">批量复制录单格式</el-button>
|
||||
<el-button type="success" size="small" icon="el-icon-document-copy" @click="handleBatchCopyRebateText" :disabled="selectedRows.length === 0" title="批量复制选中订单的后返录表格式(Excel可粘贴)">批量复制后返录表</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -108,9 +110,12 @@
|
||||
border
|
||||
stripe
|
||||
:default-sort="{prop: 'createTime', order: 'descending'}"
|
||||
@sort-change="handleSortChange"
|
||||
@sort-change="handleSortChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
style="width: 100%;"
|
||||
class="order-table">
|
||||
<!-- 多选列 -->
|
||||
<el-table-column type="selection" width="55" fixed="left" align="center"/>
|
||||
<!-- 核心信息列 -->
|
||||
<el-table-column label="内部单号" prop="remark" width="140" sortable fixed="left"/>
|
||||
<el-table-column label="订单号" prop="orderId" width="180"/>
|
||||
@@ -642,7 +647,9 @@ export default {
|
||||
// 复制录单格式loading状态
|
||||
copyExcelTextLoading: false,
|
||||
// 已复制录单格式的订单ID集合(页面级缓存,刷新后消失)
|
||||
copiedExcelTextOrderIds: new Set()
|
||||
copiedExcelTextOrderIds: new Set(),
|
||||
// 选中的行数据
|
||||
selectedRows: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -666,7 +673,9 @@ export default {
|
||||
{ key: 'touser', label: '接收人配置', type: 'warning', icon: 'el-icon-user', handler: () => { this.showTouserConfig = true } },
|
||||
{ key: 'sync', label: '一键发货到腾峰', type: 'primary', icon: 'el-icon-refresh-right', handler: () => this.handleBatchSyncLogistics(), loading: this.batchSyncLoading },
|
||||
{ key: 'mark', label: '批量标记后返到账', type: 'success', icon: 'el-icon-check', handler: () => this.handleBatchMarkRebateReceived(), loading: this.batchMarkLoading },
|
||||
{ key: 'reverse', label: '反向同步第三方单号', type: 'warning', icon: 'el-icon-sort', handler: () => this.handleReverseSyncThirdPartyOrderNo(), loading: this.reverseSyncLoading }
|
||||
{ key: 'reverse', label: '反向同步第三方单号', type: 'warning', icon: 'el-icon-sort', handler: () => this.handleReverseSyncThirdPartyOrderNo(), loading: this.reverseSyncLoading },
|
||||
{ key: 'batchCopyExcel', label: '批量复制录单格式', type: 'primary', icon: 'el-icon-document-copy', handler: () => this.handleBatchCopyExcelText(), disabled: this.selectedRows.length === 0 },
|
||||
{ key: 'batchCopyRebate', label: '批量复制后返录表', type: 'success', icon: 'el-icon-document-copy', handler: () => this.handleBatchCopyRebateText(), disabled: this.selectedRows.length === 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -1770,6 +1779,201 @@ export default {
|
||||
} finally {
|
||||
this.reverseSyncLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
/** 处理表格选择变化 */
|
||||
handleSelectionChange(selection) {
|
||||
this.selectedRows = selection
|
||||
},
|
||||
|
||||
/** 批量复制录单格式 */
|
||||
handleBatchCopyExcelText() {
|
||||
if (!this.selectedRows || this.selectedRows.length === 0) {
|
||||
this.$message.warning('请先选择要复制的订单')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const lines = []
|
||||
|
||||
// 遍历选中的每一行,生成录单格式文本
|
||||
this.selectedRows.forEach(row => {
|
||||
// 日期(格式:yyyy/MM/dd)
|
||||
let dateStr = ''
|
||||
if (row.orderTime) {
|
||||
const date = new Date(row.orderTime)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
dateStr = `${year}/${month}/${day}`
|
||||
}
|
||||
|
||||
// 多多单号(第三方单号,如果没有则使用内部单号)
|
||||
const duoduoOrderNo = (row.thirdPartyOrderNo && row.thirdPartyOrderNo.trim())
|
||||
? row.thirdPartyOrderNo : (row.remark || '')
|
||||
|
||||
// 型号
|
||||
const modelNumber = row.modelNumber || ''
|
||||
|
||||
// 数量(固定为1)
|
||||
const quantity = '1'
|
||||
|
||||
// 地址
|
||||
const address = row.address || ''
|
||||
|
||||
// 姓名(从地址中提取,地址格式通常是"姓名 电话 详细地址")
|
||||
let buyer = ''
|
||||
if (address) {
|
||||
// 提取地址中的第一个词作为姓名
|
||||
const addressParts = address.trim().split(/\s+/)
|
||||
if (addressParts.length > 0) {
|
||||
buyer = addressParts[0]
|
||||
}
|
||||
}
|
||||
|
||||
// 售价(固定为0)
|
||||
const sellingPriceStr = '0'
|
||||
|
||||
// 成本(售价 - 利润,售价是0)
|
||||
const costStr = '' // 售价是0,成本也设为空
|
||||
|
||||
// 利润(后返金额)
|
||||
const profitStr = ''
|
||||
|
||||
// 京东单号
|
||||
const orderId = row.orderId || ''
|
||||
|
||||
// 物流链接
|
||||
const logisticsLink = row.logisticsLink || ''
|
||||
|
||||
// 下单付款
|
||||
const paymentAmountStr = row.paymentAmount
|
||||
? row.paymentAmount.toFixed(2) : ''
|
||||
|
||||
// 后返
|
||||
const rebateAmountStr = row.rebateAmount
|
||||
? row.rebateAmount.toFixed(2) : ''
|
||||
const shopName = ''
|
||||
|
||||
// 按顺序拼接:日期、多多单号、型号、数量、姓名、地址、售价、成本、利润、京东单号、物流、下单付款、后返
|
||||
const text = [
|
||||
dateStr,
|
||||
duoduoOrderNo,
|
||||
shopName,
|
||||
modelNumber,
|
||||
quantity,
|
||||
buyer,
|
||||
address,
|
||||
sellingPriceStr,
|
||||
costStr,
|
||||
profitStr,
|
||||
orderId,
|
||||
logisticsLink,
|
||||
paymentAmountStr,
|
||||
rebateAmountStr
|
||||
].join('\t')
|
||||
|
||||
lines.push(text)
|
||||
})
|
||||
|
||||
// 将所有行用换行符连接
|
||||
const finalText = lines.join('\n')
|
||||
|
||||
this.copyToClipboard(finalText)
|
||||
|
||||
// 记录已复制的订单ID
|
||||
this.selectedRows.forEach(row => {
|
||||
if (row.id) {
|
||||
this.copiedExcelTextOrderIds.add(row.id)
|
||||
}
|
||||
})
|
||||
|
||||
this.$message.success(`已复制 ${this.selectedRows.length} 条订单的录单格式到剪贴板,可以直接粘贴到Excel`)
|
||||
} catch (e) {
|
||||
this.$message.error('批量复制失败:' + (e.message || '未知错误'))
|
||||
console.error('批量复制录单格式失败', e)
|
||||
}
|
||||
},
|
||||
|
||||
/** 批量复制后返录表 */
|
||||
handleBatchCopyRebateText() {
|
||||
if (!this.selectedRows || this.selectedRows.length === 0) {
|
||||
this.$message.warning('请先选择要复制的订单')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const lines = []
|
||||
|
||||
// 遍历选中的每一行,生成后返录表格式文本
|
||||
this.selectedRows.forEach(row => {
|
||||
// 前5列:空(发过运营、需要重发运营、已经重发、需要二次重发运营、二次重发)
|
||||
const emptyCols = ['', '', '', '', '']
|
||||
|
||||
// 单号:orderId
|
||||
const orderId = row.orderId || ''
|
||||
|
||||
// 型号:modelNumber
|
||||
const modelNumber = row.modelNumber || ''
|
||||
|
||||
// 返现金额(团长):空
|
||||
const leaderRebateAmount = ''
|
||||
|
||||
// 晒单金额(主图没标):空
|
||||
const reviewRebateAmount = ''
|
||||
|
||||
// 总共返现:rebateAmount(整数格式)
|
||||
const totalRebateAmount = row.rebateAmount
|
||||
? Math.round(row.rebateAmount).toString() : ''
|
||||
|
||||
// 确认收货日期:finishTime,格式yyyy/MM/dd
|
||||
let finishDateStr = ''
|
||||
if (row.finishTime) {
|
||||
const finishDate = new Date(row.finishTime)
|
||||
const year = finishDate.getFullYear()
|
||||
const month = String(finishDate.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(finishDate.getDate()).padStart(2, '0')
|
||||
finishDateStr = `${year}/${month}/${day}`
|
||||
}
|
||||
|
||||
// 认领人:buyer
|
||||
const buyer = row.buyer || ''
|
||||
|
||||
// 下单日期:orderTime,格式yyyyMMdd
|
||||
let orderDateStr = ''
|
||||
if (row.orderTime) {
|
||||
const orderDate = new Date(row.orderTime)
|
||||
const year = orderDate.getFullYear()
|
||||
const month = String(orderDate.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(orderDate.getDate()).padStart(2, '0')
|
||||
orderDateStr = `${year}${month}${day}`
|
||||
}
|
||||
|
||||
// 按顺序拼接:发过运营、需要重发运营、已经重发、需要二次重发运营、二次重发、单号、型号、返现金额(团长)、晒单金额(主图没标)、总共返现、确认收货日期、认领人、下单日期
|
||||
const text = [
|
||||
...emptyCols,
|
||||
orderId,
|
||||
modelNumber,
|
||||
leaderRebateAmount,
|
||||
reviewRebateAmount,
|
||||
totalRebateAmount,
|
||||
finishDateStr,
|
||||
buyer,
|
||||
orderDateStr
|
||||
].join('\t')
|
||||
|
||||
lines.push(text)
|
||||
})
|
||||
|
||||
// 将所有行用换行符连接
|
||||
const finalText = lines.join('\n')
|
||||
|
||||
this.copyToClipboard(finalText)
|
||||
this.$message.success(`已复制 ${this.selectedRows.length} 条订单的后返录表格式到剪贴板,可以直接粘贴到Excel`)
|
||||
} catch (e) {
|
||||
this.$message.error('批量复制失败:' + (e.message || '未知错误'))
|
||||
console.error('批量复制后返录表格式失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user