订单数据源增加订单对比功能

This commit is contained in:
wuweihua
2026-10-20 13:55:55 +08:00
parent 8093cb52e7
commit 45969a4d29
20 changed files with 1865 additions and 96 deletions
+14 -59
View File
@@ -48,27 +48,11 @@
</el-select>
</el-form-item>
<el-form-item label="产品" prop="productCodeList">
<el-select
<el-input
v-model="form.productCodeList"
:multiple="!isEdit"
filterable
remote
clearable
collapse-tags
collapse-tags-tooltip
reserve-keyword
:placeholder="isEdit ? '空=全部产品' : '多选将按产品展开为多行,空=全部'"
:remote-method="searchProduct"
:loading="productLoading"
style="width: 100%"
>
<el-option
v-for="p in productOptions"
:key="p.productCode"
:label="(p.productName || '') + ' (' + p.productCode + ')'"
:value="p.productCode"
/>
</el-select>
:placeholder="isEdit ? '产品代码,空=全部' : '产品代码,多个用逗号/换行分隔,空=全部'"
/>
</el-form-item>
<el-form-item label="国家" prop="countryCodeList">
<el-select
@@ -140,7 +124,6 @@
<script setup name="BizRuleConfig">
import { listBizRule, getBizRule, addBizRule, updateBizRule, delBizRule } from '@/api/data/bizRule'
import { listProductOptions } from '@/api/price/product'
import { listRegionOptions } from '@/api/data/region'
const { proxy } = getCurrentInstance()
@@ -151,8 +134,6 @@ const formRef = ref()
const open = ref(false)
const title = ref('')
const isEdit = ref(false)
const productLoading = ref(false)
const productOptions = ref([])
const countryOptions = ref([])
const statusOptions = [
@@ -223,12 +204,21 @@ function toList(v) {
return [v]
}
function parseCodes(v) {
if (Array.isArray(v)) return v.map(x => String(x).trim()).filter(Boolean)
if (v == null || v === '') return []
return String(v)
.split(/[,;\r\n,;、]+/)
.map(x => x.trim())
.filter(Boolean)
}
function resetForm() {
form.value = {
ruleId: undefined,
ruleName: '',
ruleType: 'THREE_SIDE',
productCodeList: [],
productCodeList: '',
countryCodeList: [],
customerCodeList: [],
weightMin: undefined,
@@ -238,7 +228,6 @@ function resetForm() {
status: '0',
remark: ''
}
productOptions.value = []
}
function handleAdd() {
@@ -260,10 +249,6 @@ function handleUpdate(row) {
countryCodeList: d.countryCode || '',
customerCodeList: d.customerCode || ''
}
if (d.productCode) {
productOptions.value = [{ productCode: d.productCode, productName: d.productCode }]
searchProduct(d.productCode)
}
title.value = '修改规则'
open.value = true
loadCountries()
@@ -272,7 +257,7 @@ function handleUpdate(row) {
function buildPayload() {
const f = form.value
const products = toList(f.productCodeList)
const products = parseCodes(f.productCodeList)
const countries = toList(f.countryCodeList)
const customers = toList(f.customerCodeList)
const base = {
@@ -325,36 +310,6 @@ function handleDelete(ids) {
}).catch(() => {})
}
function searchProduct(keyword) {
productLoading.value = true
const kw = (keyword || '').trim()
const base = { status: '1' }
// product_code / product_name are separate likes; query both and merge
const reqs = kw
? [
listProductOptions({ ...base, productCode: kw }),
listProductOptions({ ...base, productName: kw })
]
: [listProductOptions(base)]
Promise.all(reqs).then(results => {
const map = new Map()
results.forEach(res => {
;(res.data || res.rows || []).forEach(p => {
if (p && p.productCode) map.set(p.productCode, p)
})
})
// keep already-selected options visible
toList(form.value.productCodeList).forEach(code => {
if (code && !map.has(code)) {
const hit = productOptions.value.find(p => p.productCode === code)
map.set(code, hit || { productCode: code, productName: code })
}
})
productOptions.value = Array.from(map.values())
}).finally(() => {
productLoading.value = false
})
}
function loadCountries() {
if (countryOptions.value.length) return