Commit 8216aa96 by Jaxon

Merge branch 'SAAS+V5.8.2' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into SAAS+V5.8.2
2 parents 83c8e8b4 0f6c040a
Showing 80 changed files with 3456 additions and 561 deletions
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"build:nomock": "vue-cli-service build --mode nomock", "build:nomock": "vue-cli-service build --mode nomock",
"lint": "vue-cli-service lint --fix", "lint": "vue-cli-service lint --fix",
"test:unit": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service test:unit", "test:unit": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service test:unit",
"test:financialRules": "vue-cli-service test:unit tests/unit/financialRules --no-coverage",
"report": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --report" "report": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --report"
}, },
"dependencies": { "dependencies": {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
import request from "./request"; import request from "./request";
import RequestMethods from "./request.methods"; import RequestMethods from "./request.methods";
import { applyDivisionRuleTestGetMock } from "./mockDivisionRuleTestGetResponse";
const path = "dj.api."; const path = "dj.api.";
const path2 = "dj.api.smartcarlife."; const path2 = "dj.api.smartcarlife.";
...@@ -280,7 +281,9 @@ export function scenemerchantrefQueryServiceRefByShop(data) { ...@@ -280,7 +281,9 @@ export function scenemerchantrefQueryServiceRefByShop(data) {
// 获取商户财务设置进度 // 获取商户财务设置进度
export function divisionRuleTestGet(data) { export function divisionRuleTestGet(data) {
data.method = `${path2}divisionRuleTest.get`; data.method = `${path2}divisionRuleTest.get`;
return request(data, RequestMethods.POST); return request(data, RequestMethods.POST).then((result) =>
applyDivisionRuleTestGetMock(result)
);
} }
// 分账测试验证分账金额 // 分账测试验证分账金额
...@@ -288,6 +291,24 @@ export function divisionRuleTestMoneyValid(data) { ...@@ -288,6 +291,24 @@ export function divisionRuleTestMoneyValid(data) {
data.method = `${path2}divisionRuleTest.money.valid`; data.method = `${path2}divisionRuleTest.money.valid`;
return request(data, RequestMethods.POST); return request(data, RequestMethods.POST);
} }
/** 分账测试-重新测试 divisionRuleId + paymentChannelId */
export function divisionRuleTestRetest(data) {
data.method = `${path2}divisionRuleTest.retest`;
return request(data, RequestMethods.POST);
}
/** 分账测试-步骤2发起分账 */
export function divisionRuleTestDivisionSubmit(data) {
data.method = `${path2}divisionRuleTest.division.submit`;
return request(data, RequestMethods.POST);
}
/** 分账测试-同步主步骤 progress 1/2/3 */
export function divisionRuleTestUpdateMainProgress(data) {
data.method = `${path2}divisionRuleTest.updateMainProgress`;
return request(data, RequestMethods.POST);
}
// // 分账测算 // // 分账测算
// export function merchantSettleDistributeRuleTestRule(data) { // export function merchantSettleDistributeRuleTestRule(data) {
// data.method = `${path}merchantSettleDistributeRule.testRule` // data.method = `${path}merchantSettleDistributeRule.testRule`
......
/** 联调:强制 divisionRuleTest.get 回包 subProgress(根级 + divisionRuleTestItem) */
export const FORCE_DIVISION_TEST_SUB_PROGRESS = 35
/**
* 联调开关:true 时 get 回包 subProgress 强制为 35;也可设 VUE_APP_MOCK_DIVISION_TEST_SUB_PROGRESS=true
*/
export const ENABLE_DIVISION_TEST_SUB_PROGRESS_MOCK =
process.env.VUE_APP_MOCK_DIVISION_TEST_SUB_PROGRESS === 'true'
/**
* divisionRuleTest.get 回包处理入口(按开关决定是否 mock)
* @param {*} result
* @returns {*}
*/
export function applyDivisionRuleTestGetMock(result) {
if (!ENABLE_DIVISION_TEST_SUB_PROGRESS_MOCK) {
return result
}
return mockDivisionRuleTestGetSubProgress(result)
}
/**
* @param {*} result divisionRuleTest.get 原始回包
* @returns {*} 注入 subProgress 后的回包
*/
export function mockDivisionRuleTestGetSubProgress(result) {
if (result == null || typeof result !== 'object') {
return result
}
const sp = FORCE_DIVISION_TEST_SUB_PROGRESS
const next = { ...result, subProgress: sp }
if (next.divisionRuleTestItem && typeof next.divisionRuleTestItem === 'object') {
next.divisionRuleTestItem = {
...next.divisionRuleTestItem,
subProgress: sp
}
}
if (Array.isArray(next.divisionRuleTests)) {
next.divisionRuleTests = next.divisionRuleTests.map((item) => {
if (!item || typeof item !== 'object') return item
const patch = { ...item, subProgress: sp }
if (item.divisionRuleTestItem && typeof item.divisionRuleTestItem === 'object') {
patch.divisionRuleTestItem = {
...item.divisionRuleTestItem,
subProgress: sp
}
}
return patch
})
}
return next
}
<template>
<div v-if="provinceView">
<el-form ref="provinceForm" :model="provinceForm" inline="true" class="province" style="padding-left: 0;">
<el-select size="small" v-model="provinceForm.provinceName" clearable :disabled="isDisabled" placeholder="选择省份" :style="{ width: defaultWidth }" @change="selectProvince" class="select-padding">
<el-option v-for="item in AllData" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectProvince(item)"></el-option>
</el-select>
<el-select size="small" v-model="provinceForm.cityName" clearable :disabled="isDisabled" placeholder="选择市" :style="{ width: defaultWidth }" @change="selectCity" class="select-padding">
<el-option v-for="item in cityList" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectCity(item)"></el-option>
</el-select>
<el-select v-if="subdistrict == 3" size="small" v-model="provinceForm.townName" clearable :disabled="isDisabled" placeholder="选择区" :style="{ width: defaultWidth }" @change="selectTown" class="select-padding">
<el-option v-for="item in townList" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectTown(item)"></el-option>
</el-select>
</el-form>
</div>
</template>
<script>
export default {
name: 'GLProvince',
props: {
// 省市级别,2--只显示省市,3--显示省市区,默认只显示省市
subdistrict: {
type: Number,
default: 2
},
// 省市下拉组件宽度
defaultWidth: {
type: String,
default: '150px'
},
// 组件是否展示,默认展示
provinceView: {
type: Boolean,
default: true
},
isDisabled: {
type: Boolean,
default: false
}
},
data() {
return {
// 所有数据
AllData: [],
// 城市列表
cityList: [],
// 地区列表
townList: [],
provinceForm: {
// 省份名称
provinceName: '',
// 城市名称
cityName: '',
// 地区名称
townName: '',
// 省份代码
provinceCode: '',
// 城市代码
cityCode: '',
// 地区代码
townCode: ''
}
}
},
mounted() {
this.provinceList()
},
methods: {
/*
* @params:传入的为一个key-value的对象
1、keywords --查询关键字,只支持单个关键词语搜索关键词支持:行政区名称、citycode、adcode
列如:this.provinceList({keywords: '山东省'}),这样就可以筛选出山东省下的市、区信息
2、subdistrict --设置显示下级行政区级数,0:不返回下级行政区;1:返回下一级行政区;2:返回下两级行政区;3:返回下三级行政区;
不传的话默认为2,可以在组件中穿,也可以在调用方法的时候传,如果需要展示省市组件,传值最小为2
3、page --最外层的districts最多会返回20个数据,若超过限制,请用page请求下一页数据。
例如page=2;page=3。默认page=1
4、extensions --控制行政区信息中返回行政区边界坐标点; 可选值:base、all;
base:不返回行政区边界坐标点;(默认)
all:只返回当前查询district的边界值,不返回子节点的边界值;目前不能返回乡镇/街道级别的边界值
5、filter -- 按照指定行政区划进行过滤,填入后则只返回该省/直辖市信息,需填入adcode,为了保证数据的正确,强烈建议填入此参数
6、callback -- callback值是用户定义的函数名称,此参数只在output=JSON时有效
7、output --返回数据格式类型,可选值:JSON,XML(默认JSON)
* @return:返回的是一个promise对象,如果不需要展示组件,只需要获取值,可以直接调用方法,异步获取返回值
列如:
const p = this.$refs.provinceForm.provinceList({xxxx(可传值,传值可参考上文params描述) })
p.then(r => {
// r 为返回结果
console.log(r)
})
**/
// 获取省市信息
provinceList(params = {}) {
params ? (params.subdistrict ? '' : (params.subdistrict = this.subdistrict)) : (params.subdistrict = this.subdistrict)
let data = ''
for (const key in params) {
data += '&' + key + '=' + params[key]
}
let path = `https://restapi.amap.com/v3/config/district?key=d22348363c34c266f772ae9b635eef2a`
path = path + data
const pro = fetch(path).then(res => {
return res.json()
})
if (this.provinceView) {
pro.then(r => {
this.AllData = r.districts[0].districts
})
}
return pro
},
// 省市回显
init(province, city, town) {
this.provinceForm = {
provinceName: province,
cityName: city,
townName: town
}
if (province) {
this.AllData.map(item => {
if (item.name.indexOf(province) != -1) {
this.provinceForm.provinceName = item.name
this.cityList = item.districts
this.provinceForm.provinceCode = item.adcode
if (city) {
this.cityList.map(itm => {
if (itm.name.indexOf(city) != -1) {
this.provinceForm.cityCode = itm.adcode
this.provinceForm.cityName = itm.name
this.townList = itm.districts
if (town) {
this.townList.map(itmx => {
if (itmx.name.indexOf(town) != -1) {
this.provinceForm.townCode = itmx.adcode
this.provinceForm.townName = itmx.name
}
})
}
}
})
}
}
})
}
},
// 选择省
selectProvince(val) {
this.provinceForm.cityName = ''
this.provinceForm.townName = ''
this.cityList = val.districts
this.$emit('selectProvince', { provinceName: val.name, provinceCode: val.adcode })
},
// 选择市
selectCity(val) {
this.provinceForm.townName = ''
this.townList = val.districts
this.$emit('selectCity', { cityName: val.name, cityCode: val.adcode })
},
// 选择区
selectTown(val) {
this.$emit('selectTown', { townName: val.name, townCode: val.adcode })
}
}
}
</script>
<style lang="scss">
.province {
display: inline-flex;
.el-select .el-input {
width: auto !important;
}
}
.select-padding {
margin-right: 10px;
}
</style>
...@@ -41,10 +41,6 @@ ...@@ -41,10 +41,6 @@
<span class="label">配件性质:</span> <span class="label">配件性质:</span>
<span class="value">{{ formatAccessoryType($$(commodityInfo.goodsInfo, 'accessoryType')) }}</span> <span class="value">{{ formatAccessoryType($$(commodityInfo.goodsInfo, 'accessoryType')) }}</span>
</p> </p>
<p class="item_class">
<span class="label">供应商:</span>
<EllipsisPopover class="value" :content="$$(commodityInfo.goodsInfo, 'providerName') || '-'"></EllipsisPopover>
</p>
<p class="item_class"> <p class="item_class">
<span class="label">供应方:</span> <span class="label">供应方:</span>
<span class="value">{{ $$(commodityInfo.goodsInfo, 'supplierName') || '-' }}</span> <span class="value">{{ $$(commodityInfo.goodsInfo, 'supplierName') || '-' }}</span>
...@@ -78,6 +74,9 @@ ...@@ -78,6 +74,9 @@
<el-form-item class="d2-drawer-item" label="运营成本/元:"> <el-form-item class="d2-drawer-item" label="运营成本/元:">
<EllipsisPopover :content="!filterEmpty(item.operationCost) ? priceFilter(item.operationCost) : '-'"></EllipsisPopover> <EllipsisPopover :content="!filterEmpty(item.operationCost) ? priceFilter(item.operationCost) : '-'"></EllipsisPopover>
</el-form-item> </el-form-item>
<el-form-item class="d2-drawer-item" label="供应商:">
<EllipsisPopover :content="item.providerName || '-'"></EllipsisPopover>
</el-form-item>
</div> </div>
</el-form> </el-form>
<!-- 分页 --> <!-- 分页 -->
......
...@@ -37,10 +37,6 @@ ...@@ -37,10 +37,6 @@
<span class="label">配件性质:</span> <span class="label">配件性质:</span>
<span class="value">{{ formatAccessoryType($$(commodityInfo.goodsInfo, "accessoryType")) }}</span> <span class="value">{{ formatAccessoryType($$(commodityInfo.goodsInfo, "accessoryType")) }}</span>
</p> </p>
<p class="item_class">
<span class="label">供应商:</span>
<EllipsisPopover class="value" :content="$$(commodityInfo.goodsInfo, 'providerName') || '-'"></EllipsisPopover>
</p>
<p class="item_class"> <p class="item_class">
<span class="label">供应方:</span> <span class="label">供应方:</span>
<span class="value">{{ $$(commodityInfo.goodsInfo, "supplierName") || "-" }}</span> <span class="value">{{ $$(commodityInfo.goodsInfo, "supplierName") || "-" }}</span>
...@@ -88,6 +84,9 @@ ...@@ -88,6 +84,9 @@
<el-form-item class="d2-drawer-item" label="运营成本/元:"> <el-form-item class="d2-drawer-item" label="运营成本/元:">
<EllipsisPopover :content="!filterEmpty(item.operationCost) ? priceFilter(item.operationCost) : '-'"></EllipsisPopover> <EllipsisPopover :content="!filterEmpty(item.operationCost) ? priceFilter(item.operationCost) : '-'"></EllipsisPopover>
</el-form-item> </el-form-item>
<el-form-item class="d2-drawer-item" label="供应商:">
<EllipsisPopover :content="item.providerName || '-'"></EllipsisPopover>
</el-form-item>
</div> </div>
</el-form> </el-form>
</div> </div>
......
...@@ -168,7 +168,8 @@ export default { ...@@ -168,7 +168,8 @@ export default {
specsValueList: val.specificationData?.split(';~;'), specsValueList: val.specificationData?.split(';~;'),
type: val.type, type: val.type,
thirdPartyName: val.thirdPartyName, thirdPartyName: val.thirdPartyName,
thirdPartyCode: val.thirdPartyCode, thirdPartyCode: val.thirdPartyCode,
providerIds: val.providerIds || [],
priceUnitType, priceUnitType,
priceUnitName, priceUnitName,
purchaseCost: val.purchaseCost, purchaseCost: val.purchaseCost,
...@@ -254,8 +255,7 @@ export default { ...@@ -254,8 +255,7 @@ export default {
supplierCode: res.goodsInfo.supplierCode, supplierCode: res.goodsInfo.supplierCode,
merchantGoodsInfos: res?.merchantGoodsInfos, merchantGoodsInfos: res?.merchantGoodsInfos,
scrmFlag: res?.goodsInfo?.scrmFlag, scrmFlag: res?.goodsInfo?.scrmFlag,
accessoryType: res.goodsInfo?.accessoryType, accessoryType: res.goodsInfo?.accessoryType
providerId: res.goodsInfo?.providerId
} }
this.productFormData = deepClone({ ...res.goodsInfo, status: res?.status, oldconvertedValue: res.goodsInfo?.convertedValue, tempGoodsType, secondaryGoodsType: res.goodsInfo.secondaryGoodsType, thirdLevelGoodsType: res.goodsInfo.thirdLevelGoodsType }) || {} this.productFormData = deepClone({ ...res.goodsInfo, status: res?.status, oldconvertedValue: res.goodsInfo?.convertedValue, tempGoodsType, secondaryGoodsType: res.goodsInfo.secondaryGoodsType, thirdLevelGoodsType: res.goodsInfo.thirdLevelGoodsType }) || {}
this.setUpdateGoodsInfo(objData) this.setUpdateGoodsInfo(objData)
...@@ -345,7 +345,8 @@ export default { ...@@ -345,7 +345,8 @@ export default {
warrantyPeriod: this.membraneTypeList.includes(productFormData?.goodsType) || !isEquityOrExtend ? warrantyVal : '', // 质保时间 膜类或非权益/延保类 warrantyPeriod: this.membraneTypeList.includes(productFormData?.goodsType) || !isEquityOrExtend ? warrantyVal : '', // 质保时间 膜类或非权益/延保类
type: item.type, type: item.type,
thirdPartyName: item.thirdPartyName, thirdPartyName: item.thirdPartyName,
thirdPartyCode: item.thirdPartyCode, thirdPartyCode: item.thirdPartyCode,
providerIds: item.providerIds || [],
priceUnitType: item.priceUnitType, priceUnitType: item.priceUnitType,
priceUnitName: item.priceUnitName, priceUnitName: item.priceUnitName,
productTemplateId: item?.productTemplateId, productTemplateId: item?.productTemplateId,
...@@ -419,7 +420,8 @@ export default { ...@@ -419,7 +420,8 @@ export default {
warrantyPeriod: this.membraneTypeList.includes(productFormData?.goodsType) || !isEquityOrExtend ? warrantyVal : '', // 质保时间 膜类或非权益/延保类 warrantyPeriod: this.membraneTypeList.includes(productFormData?.goodsType) || !isEquityOrExtend ? warrantyVal : '', // 质保时间 膜类或非权益/延保类
type: item.type, type: item.type,
thirdPartyName: item.thirdPartyName, thirdPartyName: item.thirdPartyName,
thirdPartyCode: item.thirdPartyCode, thirdPartyCode: item.thirdPartyCode,
providerIds: item.providerIds || [],
priceUnitType: item.priceUnitType, priceUnitType: item.priceUnitType,
priceUnitName: item.priceUnitName, priceUnitName: item.priceUnitName,
purchaseCost: item.purchaseCost, purchaseCost: item.purchaseCost,
...@@ -528,7 +530,8 @@ export default { ...@@ -528,7 +530,8 @@ export default {
specsValueList: specName ? `${specName}`.split(';~;') : [], specsValueList: specName ? `${specName}`.split(';~;') : [],
type, type,
thirdPartyName: '', thirdPartyName: '',
thirdPartyCode: '', thirdPartyCode: '',
providerIds: [],
priceUnitType: '', priceUnitType: '',
priceUnitName: '', priceUnitName: '',
purchaseCost: '', purchaseCost: '',
...@@ -624,6 +627,7 @@ export default { ...@@ -624,6 +627,7 @@ export default {
item.operationCostEmpty = true // 运营成本必填 item.operationCostEmpty = true // 运营成本必填
item.applicableAreaEmpty = true // 适用区域必填 item.applicableAreaEmpty = true // 适用区域必填
item.purchaseCostEmpty = true // 采购成本必填 item.purchaseCostEmpty = true // 采购成本必填
item.providerIdsEmpty = true // 供应商必填
if (this.equitySceneType.includes(this.goodsInfoData.goodsType) && !this.baseConfig.supplierCode.includes(`${this.goodsInfoData.supplierCode}`)) { if (this.equitySceneType.includes(this.goodsInfoData.goodsType) && !this.baseConfig.supplierCode.includes(`${this.goodsInfoData.supplierCode}`)) {
// 会员权益升级类目(仅供应方是非第三方) 服务项目、嘀加成本必填 // 会员权益升级类目(仅供应方是非第三方) 服务项目、嘀加成本必填
item.serviceItemArrEmpty = true item.serviceItemArrEmpty = true
...@@ -644,7 +648,7 @@ export default { ...@@ -644,7 +648,7 @@ export default {
} }
let specialList = [] let specialList = []
// 1. 基础必填字段 产品编码、采购成本、运营系数、运营成本、适用区域 // 1. 基础必填字段 产品编码、采购成本、运营系数、运营成本、适用区域
const baseFields = ['specificationData', 'type', 'purchaseCost', 'operationCoefficient', 'operationCost', 'upgradeGoodsAreaList'] const baseFields = ['specificationData', 'type', 'providerIds', 'purchaseCost', 'operationCoefficient', 'operationCost', 'upgradeGoodsAreaList']
const { goodsType, supplierCode } = this.goodsInfoData const { goodsType, supplierCode } = this.goodsInfoData
// 2. 权益/延保类 // 2. 权益/延保类
if (isEquityOrExtend) { if (isEquityOrExtend) {
......
...@@ -109,6 +109,11 @@ ...@@ -109,6 +109,11 @@
<span>供应来源</span> <span>供应来源</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td style="position: relative">
<span class="color-red">*</span>
<span>供应商</span>
<div class="resize-handle" @mousedown="onResizeStart"></div>
</td>
<!-- 仅延保类/权益服务 广联直营展示 --> <!-- 仅延保类/权益服务 广联直营展示 -->
<td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)" style="position: relative"> <td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)" style="position: relative">
<span class="color-red">*</span> <span class="color-red">*</span>
...@@ -215,6 +220,12 @@ ...@@ -215,6 +220,12 @@
<el-option v-for="opt in supplySourceOptions" :key="opt.value" :label="opt.label" :value="opt.value" /> <el-option v-for="opt in supplySourceOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select> </el-select>
</td> </td>
<td>
<SupplierSelect
v-model="row.item.providerIds"
:custom-class="!row.item.providerIds.length && row.item.providerIdsEmpty ? 'border-red' : ''"
width="calc(100% - 40px)" />
</td>
<td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)"> <td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)">
<div style="transform: translateX(6px)"> <div style="transform: translateX(6px)">
<el-input v-model="row.item.djCost" class="w-150-per" :class="{ 'border-red': filterEmpty(row.item.djCost) && row.item.djCostEmpty }" :disabled="true" placeholder="请输入" size="small" @input="handlePrice($event, row.originalIndex, 'djCost')"></el-input> <el-input v-model="row.item.djCost" class="w-150-per" :class="{ 'border-red': filterEmpty(row.item.djCost) && row.item.djCostEmpty }" :disabled="true" placeholder="请输入" size="small" @input="handlePrice($event, row.originalIndex, 'djCost')"></el-input>
...@@ -368,7 +379,7 @@ import carSeriesDialog from './carSeriesDialog.vue' ...@@ -368,7 +379,7 @@ import carSeriesDialog from './carSeriesDialog.vue'
import extendServiceItemsDialog from './extendServiceItemsDialog.vue' import extendServiceItemsDialog from './extendServiceItemsDialog.vue'
import serviceItemsDialog from './serviceItemsDialog.vue' import serviceItemsDialog from './serviceItemsDialog.vue'
import specsManage from './specsManage.vue' import specsManage from './specsManage.vue'
import SupplierSelect from './SupplierSelect.vue'
export default { export default {
name: 'MultipleSpecificationForm', name: 'MultipleSpecificationForm',
components: { components: {
...@@ -377,7 +388,8 @@ export default { ...@@ -377,7 +388,8 @@ export default {
CarSeriesDialog: carSeriesDialog, CarSeriesDialog: carSeriesDialog,
SpecsManage: specsManage, SpecsManage: specsManage,
// ApplicableAreaSelect, // ApplicableAreaSelect,
ApplicableAreaQuerySelect ApplicableAreaQuerySelect,
SupplierSelect
}, },
mixins: [useTableVirtualScroll, useResizableColumns], mixins: [useTableVirtualScroll, useResizableColumns],
inject: ['pageData'], inject: ['pageData'],
...@@ -1272,7 +1284,8 @@ export default { ...@@ -1272,7 +1284,8 @@ export default {
specsValueList: [this.goodsInfoData.specificationDetailList[i]?.specificationValueList[j]?.specificationValue], specsValueList: [this.goodsInfoData.specificationDetailList[i]?.specificationValueList[j]?.specificationValue],
type: '', type: '',
thirdPartyName: '', thirdPartyName: '',
thirdPartyCode: '', thirdPartyCode: '',
providerIds: [],
priceUnitType: null, priceUnitType: null,
priceUnitName: '', priceUnitName: '',
purchaseCost: '', purchaseCost: '',
...@@ -1330,7 +1343,8 @@ export default { ...@@ -1330,7 +1343,8 @@ export default {
item.oldwarningValueMax = temp.warningValueMax item.oldwarningValueMax = temp.warningValueMax
item.type = temp.type item.type = temp.type
item.thirdPartyName = temp.thirdPartyName item.thirdPartyName = temp.thirdPartyName
item.thirdPartyCode = temp.thirdPartyCode item.thirdPartyCode = temp.thirdPartyCode
item.providerIds = temp.providerIds || []
item.priceUnitType = temp.priceUnitType item.priceUnitType = temp.priceUnitType
item.priceUnitName = temp.priceUnitName item.priceUnitName = temp.priceUnitName
item.purchaseCost = temp.purchaseCost item.purchaseCost = temp.purchaseCost
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
<span>供应商编码</span> <span>供应商编码</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<!-- 轻改/延保展示,延保不必填 -->
<td style="position: relative"> <td style="position: relative">
<span v-if="!isEquityOrExtendType" class="color-red">*</span> <span v-if="!isEquityOrExtendType" class="color-red">*</span>
<span>计价单位</span> <span>计价单位</span>
...@@ -89,6 +88,11 @@ ...@@ -89,6 +88,11 @@
<span>供应来源</span> <span>供应来源</span>
<div class="resize-handle" @mousedown="onResizeStart"></div> <div class="resize-handle" @mousedown="onResizeStart"></div>
</td> </td>
<td style="position: relative">
<span class="color-red">*</span>
<span>供应商</span>
<div class="resize-handle" @mousedown="onResizeStart"></div>
</td>
<!-- 延保/权益 非第三方展示 --> <!-- 延保/权益 非第三方展示 -->
<td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)" style="position: relative"> <td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)" style="position: relative">
<span class="color-red">*</span> <span class="color-red">*</span>
...@@ -317,7 +321,12 @@ ...@@ -317,7 +321,12 @@
:value="opt.value" /> :value="opt.value" />
</el-select> </el-select>
</td> </td>
<td>
<SupplierSelect
v-model="row.item.providerIds"
:custom-class="!row.item.providerIds.length && row.item.providerIdsEmpty ? 'border-red' : ''"
width="calc(100% - 40px)" />
</td>
<td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)"> <td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)">
<el-input v-model="row.item.djCost" <el-input v-model="row.item.djCost"
class="w-150-per" class="w-150-per"
...@@ -542,7 +551,7 @@ import useTableVirtualScroll from "@/views/goods/productManage/mixins/useTableVi ...@@ -542,7 +551,7 @@ import useTableVirtualScroll from "@/views/goods/productManage/mixins/useTableVi
import carSeriesDialog from "./carSeriesDialog.vue"; import carSeriesDialog from "./carSeriesDialog.vue";
import extendServiceItemsDialog from "./extendServiceItemsDialog.vue"; import extendServiceItemsDialog from "./extendServiceItemsDialog.vue";
import serviceItemsDialog from "./serviceItemsDialog.vue"; import serviceItemsDialog from "./serviceItemsDialog.vue";
import SupplierSelect from './SupplierSelect.vue'
export default { export default {
name: "SingleSpecificationForm", name: "SingleSpecificationForm",
components: { components: {
...@@ -551,6 +560,7 @@ export default { ...@@ -551,6 +560,7 @@ export default {
CarSeriesDialog: carSeriesDialog, CarSeriesDialog: carSeriesDialog,
// ApplicableAreaSelect, // ApplicableAreaSelect,
ApplicableAreaQuerySelect, ApplicableAreaQuerySelect,
SupplierSelect
}, },
mixins: [useTableVirtualScroll, useResizableColumns], mixins: [useTableVirtualScroll, useResizableColumns],
props: { props: {
...@@ -1083,6 +1093,7 @@ export default { ...@@ -1083,6 +1093,7 @@ export default {
type: "", type: "",
thirdPartyName: "", thirdPartyName: "",
thirdPartyCode: "", thirdPartyCode: "",
providerIds: [],
priceUnitType: null, priceUnitType: null,
priceUnitName: "", priceUnitName: "",
purchaseCost: "", purchaseCost: "",
......
...@@ -13,15 +13,12 @@ ...@@ -13,15 +13,12 @@
:origin-data="editData" :origin-data="editData"
@accessoryTypeChange="handleAccessoryTypeChange" @accessoryTypeChange="handleAccessoryTypeChange"
@handleAddBrandSupplyConfirm="handleAddBrandSupplyConfirm" @handleAddBrandSupplyConfirm="handleAddBrandSupplyConfirm"
@handleEditBrandSupplyConfirm="handleEditBrandSupplyConfirm" @handleEditBrandSupplyConfirm="handleEditBrandSupplyConfirm">
@handleAddSupplierConfirm="handleAddSupplierConfirm"
@handleEditSupplierConfirm="handleEditSupplierConfirm">
</ProductForm> </ProductForm>
</div> </div>
</template> </template>
<script> <script>
import { addGoodsProvider, editGoodsProvider, getGoodsProviderList } from "@api/productManage";
import { mapActions } from "vuex"; import { mapActions } from "vuex";
import { addBrandSupplyMerchant, editBrandSupplyMerchant, getAllCategory, getBrandSupplyMerchant } from "@/api/product"; import { addBrandSupplyMerchant, editBrandSupplyMerchant, getAllCategory, getBrandSupplyMerchant } from "@/api/product";
import { deepClone } from "@/common/util"; import { deepClone } from "@/common/util";
...@@ -53,8 +50,6 @@ export default { ...@@ -53,8 +50,6 @@ export default {
brandMerchantName: "", brandMerchantName: "",
supplierCode: "", supplierCode: "",
supplierName: "", supplierName: "",
providerId: "",
providerName: "",
address: "", address: "",
contactName: "", contactName: "",
contactPhone: "", contactPhone: "",
...@@ -123,19 +118,6 @@ export default { ...@@ -123,19 +118,6 @@ export default {
isDisabled: false, isDisabled: false,
}, },
{ {
name: "providerId",
label: "供应商",
isRequired: true,
type: "dialog-add-select",
multiple: false,
isClear: true,
optionList: [],
optionId: "id",
optionLabel: "providerName",
width: "432px",
isDisabled: false,
},
{
name: "thumbUrl", name: "thumbUrl",
label: "缩略图", label: "缩略图",
type: "photo", type: "photo",
...@@ -210,8 +192,6 @@ export default { ...@@ -210,8 +192,6 @@ export default {
this.getBrandSupplyList(2); this.getBrandSupplyList(2);
// 获取类目 // 获取类目
this.getGoodTypeList(); this.getGoodTypeList();
// 获取供应商
this.getGoodsProvider();
}, },
methods: { methods: {
...mapActions({ ...mapActions({
...@@ -309,34 +289,6 @@ export default { ...@@ -309,34 +289,6 @@ export default {
this.getBrandSupplyList(data.partitionFlag); this.getBrandSupplyList(data.partitionFlag);
}); });
}, },
// 获取供应商
getGoodsProvider() {
return getGoodsProviderList({ currentPage: 1, pageSize: 9999 }).then((res) => {
this.editForm[0].formBlock[this.editForm[0].formBlock.findIndex(val => val.name == "providerId")].optionList = res?.list || [];
return res?.list || [];
});
},
// 新增供应商
handleAddSupplierConfirm(data, done) {
const supplierIndex = this.editForm[0]?.formBlock.findIndex(val => val.name === "providerId");
if (supplierIndex === -1)
return;
addGoodsProvider(data).then((res) => {
this.getGoodsProvider().then(() => {
done && done(res);
});
});
},
// 编辑供应商
handleEditSupplierConfirm(data, done) {
const supplierIndex = this.editForm[0]?.formBlock.findIndex(val => val.name === "providerId");
if (supplierIndex === -1)
return;
editGoodsProvider(data).then((res) => {
this.getGoodsProvider();
done && done(res);
});
},
handleAccessoryTypeChange(val) { handleAccessoryTypeChange(val) {
this.$emit("accessoryTypeChange", val); this.$emit("accessoryTypeChange", val);
}, },
......
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
v-if="(equitySceneType.includes(formData[item.key]) || extendedPosiType.includes(formData[item.key])) && !baseConfig.supplierCode.includes(`${formData.supplierCode}`)"> v-if="(equitySceneType.includes(formData[item.key]) || extendedPosiType.includes(formData[item.key])) && !baseConfig.supplierCode.includes(`${formData.supplierCode}`)">
<div class="label">嘀加成本元/件:</div> <div class="label">嘀加成本元/件:</div>
<div class="value"> <div class="value">
<ellipsis-popover <ellipsis-popover :content="priceFilter(formData.upgradeGoods['djCost']) || ''"></ellipsis-popover>
:content="priceFilter(formData.upgradeGoods['djCost']) || ''"></ellipsis-popover>
</div> </div>
</div> </div>
<!-- 商品分类 1太阳膜 --> <!-- 商品分类 1太阳膜 -->
...@@ -58,8 +57,7 @@ ...@@ -58,8 +57,7 @@
<div class="item" v-if="membraneTypeList.includes(formData[item.key])"> <div class="item" v-if="membraneTypeList.includes(formData[item.key])">
<div class="label">质保年限/年:</div> <div class="label">质保年限/年:</div>
<div class="value"> <div class="value">
<ellipsis-popover <ellipsis-popover :content="`${formData.upgradeGoods['warrantyPeriod']}年` || ''"></ellipsis-popover>
:content="`${formData.upgradeGoods['warrantyPeriod']}年` || ''"></ellipsis-popover>
</div> </div>
</div> </div>
</div> </div>
...@@ -104,10 +102,9 @@ ...@@ -104,10 +102,9 @@
<div v-else> <div v-else>
<el-form-item :prop="item.name" <el-form-item :prop="item.name"
:label="item.label ? (item.unit ? (membraneTypeList.includes(formData['goodsType']) ? item.label + `(元)/车` : (item.label + '(元)/件')) : item.label) + ':' : ''" :label="item.label ? (item.unit ? (membraneTypeList.includes(formData['goodsType']) ? item.label + `(元)/车` : (item.label + '(元)/件')) : item.label) + ':' : ''"
:id="item.name" :label-width="item.label ? '180px' : '0px'" class="dis-in-block" :id="item.name" :label-width="item.label ? '180px' : '0px'" class="dis-in-block" style="margin-bottom: 0">
style="margin-bottom: 0">
<div> <div>
<span>{{ item.unit ? priceFilter(formData[item.name]) : formData[item.name] }}</span> <span>{{ item.unit ? priceFilter(formData[item.name]) : formData[item.name] || '-' }}</span>
<span v-if="item.name == 'minSellPrice'">{{ formData['validMinSellPrice'] == 'Y' ? '(校验最低价)' : <span v-if="item.name == 'minSellPrice'">{{ formData['validMinSellPrice'] == 'Y' ? '(校验最低价)' :
'(不校验最低价)' }}</span> '(不校验最低价)' }}</span>
</div> </div>
......
...@@ -11,17 +11,16 @@ ...@@ -11,17 +11,16 @@
<div v-for="(item, index) in i.formBlock" :key="index"> <div v-for="(item, index) in i.formBlock" :key="index">
<!-- 单选 --> <!-- 单选 -->
<!-- 太阳膜类商品 上架部位 --> <!-- 太阳膜类商品 上架部位 -->
<div v-if=" <div v-if="item.type === 'radio' &&
item.type === 'radio' &&
formData['goodsType'] == 1 && formData['goodsType'] == 1 &&
!item.index !item.index
"> ">
<el-form-item :prop="item.name" :label="item.label ? item.label + ':' : ''" :id="item.name" <el-form-item :prop="item.name" :label="item.label ? item.label + ':' : ''" :id="item.name"
:label-width="item.label ? '180px' : '0px'" class="dis-in-block" :label-width="item.label ? '180px' : '0px'" class="dis-in-block"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }"> :style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<el-radio-group v-model="formData[item.name]"> <el-radio-group v-model="formData[item.name]">
<el-radio v-for="(subItem, subIndex) in item.radioGroupList" :key="subIndex" <el-radio v-for="(subItem, subIndex) in item.radioGroupList" :key="subIndex" :label="subItem.confId">{{
:label="subItem.confId">{{ subItem.confName }}</el-radio> subItem.confName }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</div> </div>
...@@ -32,29 +31,28 @@ ...@@ -32,29 +31,28 @@
<div class="label"> <div class="label">
{{ {{
subItem.unit subItem.unit
? membraneTypeList.includes(formData[item.key]) ? membraneTypeList.includes(formData[item.key])
? subItem.label + ? subItem.label +
`(元)/${subItem.value == "purchasePrice" ? "卷" : "卷" `(元)/${subItem.value == "purchasePrice" ? "卷" : "卷"
}` }`
: subItem.label + "(元)/件" : subItem.label + "(元)/件"
: subItem.label : subItem.label
}}: }}:
</div> </div>
<div class="value"> <div class="value">
<ellipsis-popover :content="subItem.unit <ellipsis-popover :content="subItem.unit
? priceFilter(formData.upgradeGoods[subItem.value]) ? priceFilter(formData.upgradeGoods[subItem.value])
: formData.upgradeGoods[subItem.value] || '' : formData.upgradeGoods[subItem.value] || ''
"></ellipsis-popover> "></ellipsis-popover>
</div> </div>
</div> </div>
<!-- 权益/延保非第三方展示 --> <!-- 权益/延保非第三方展示 -->
<div class="item" v-if=" <div class="item" v-if="(equitySceneType.includes(formData[item.key]) ||
(equitySceneType.includes(formData[item.key]) || extendedPosiType.includes(formData[item.key])) &&
extendedPosiType.includes(formData[item.key])) &&
!baseConfig.supplierCode.includes( !baseConfig.supplierCode.includes(
`${formData.supplierCode}` `${formData.supplierCode}`
) )
"> ">
<div class="label">嘀加成本元/件:</div> <div class="label">嘀加成本元/件:</div>
<div class="value"> <div class="value">
<ellipsis-popover :content="priceFilter(formData.upgradeGoods['djCost']) || '-' <ellipsis-popover :content="priceFilter(formData.upgradeGoods['djCost']) || '-'
...@@ -69,12 +67,11 @@ ...@@ -69,12 +67,11 @@
</div> </div>
</div> </div>
<!-- 商品分类 权益类(供应方为非第三方) --> <!-- 商品分类 权益类(供应方为非第三方) -->
<div class="item" v-if=" <div class="item" v-if="equitySceneType.includes(formData[item.key]) &&
equitySceneType.includes(formData[item.key]) &&
!baseConfig.supplierCode.includes( !baseConfig.supplierCode.includes(
`${formData.supplierCode}` `${formData.supplierCode}`
) )
"> ">
<div class="label">服务项目:</div> <div class="label">服务项目:</div>
<div class="value"> <div class="value">
<ellipsis-popover :content="formData.upgradeGoods['serviceItemNames'] || ''"></ellipsis-popover> <ellipsis-popover :content="formData.upgradeGoods['serviceItemNames'] || ''"></ellipsis-popover>
...@@ -86,8 +83,8 @@ ...@@ -86,8 +83,8 @@
<div class="value"> <div class="value">
{{ {{
formData.upgradeGoods["entityCardFlag"] == "Y" formData.upgradeGoods["entityCardFlag"] == "Y"
? "是" ? "是"
: "否" : "否"
}} }}
</div> </div>
</div> </div>
...@@ -102,11 +99,10 @@ ...@@ -102,11 +99,10 @@
</div> </div>
</div> </div>
<!-- 下拉框/输入框 --> <!-- 下拉框/输入框 -->
<div v-if=" <div v-if="item.type === 'input' ||
item.type === 'input' ||
item.type === 'select' || item.type === 'select' ||
item.type === 'searchSelect' item.type === 'searchSelect'
"> ">
<el-form-item :prop="item.name" :label="item.label <el-form-item :prop="item.name" :label="item.label
? (item.unit ? (item.unit
? membraneTypeList.includes(formData['goodsType']) ? membraneTypeList.includes(formData['goodsType'])
...@@ -128,8 +124,8 @@ ...@@ -128,8 +124,8 @@
</template> </template>
<!-- 选择框 --> <!-- 选择框 -->
<el-select v-else-if="item.type === 'select'" v-model="formData[item.name]" :clearable="item.isClear" <el-select v-else-if="item.type === 'select'" v-model="formData[item.name]" :clearable="item.isClear"
:ref="'selectRefs_' + item.name" :placeholder="'请选择' + item.label" :ref="'selectRefs_' + item.name" :placeholder="'请选择' + item.label" @change="selectAddAttr($event, item)"
@change="selectAddAttr($event, item)" :style="{ width: item.width || formItemWidth }" filterable> :style="{ width: item.width || formItemWidth }" filterable>
<el-option v-for="subItem in item.optionList" :key="subItem[item.optionId]" <el-option v-for="subItem in item.optionList" :key="subItem[item.optionId]"
:label="subItem[item.optionLabel]" :value="subItem[item.optionId]" /> :label="subItem[item.optionLabel]" :value="subItem[item.optionId]" />
</el-select> </el-select>
...@@ -145,7 +141,7 @@ ...@@ -145,7 +141,7 @@
</el-option> </el-option>
</el-select> --> </el-select> -->
<el-button v-else-if="item.type === 'searchSelect'" icon="el-icon-plus" <el-button v-else-if="item.type === 'searchSelect'" icon="el-icon-plus"
@click="handleSelectGoods">选择商品</el-button> @click="handleSelectGoods">选择产品</el-button>
</el-form-item> </el-form-item>
</div> </div>
<!-- 财务规则校验 --> <!-- 财务规则校验 -->
...@@ -195,8 +191,7 @@ ...@@ -195,8 +191,7 @@
: :
</span> </span>
<el-checkbox-group v-model="formData[item.name]"> <el-checkbox-group v-model="formData[item.name]">
<el-checkbox v-for="(subItem, subIndex) in item.checkGroupList" :key="subIndex" <el-checkbox v-for="(subItem, subIndex) in item.checkGroupList" :key="subIndex" :label="subItem.confId">
:label="subItem.confId">
{{ subItem.confName }} {{ subItem.confName }}
</el-checkbox> </el-checkbox>
</el-checkbox-group> </el-checkbox-group>
...@@ -328,7 +323,7 @@ ...@@ -328,7 +323,7 @@
:initial-index="initialIndex" /> :initial-index="initialIndex" />
<select-goods-dialog v-if="selectGoodsVisible" :select-goods-visible="selectGoodsVisible" <select-goods-dialog v-if="selectGoodsVisible" :select-goods-visible="selectGoodsVisible"
@handleSelectGoodsConfirm="handleSelectGoodsConfirm" @handleSelectGoodsClose="handleSelectGoodsClose" @handleSelectGoodsConfirm="handleSelectGoodsConfirm" @handleSelectGoodsClose="handleSelectGoodsClose"
:upgrade-goods-id="formData.upgradeGoodsId"></select-goods-dialog> :upgrade-goods-id="formData.upgradeGoodsId" :is-shelves="true"></select-goods-dialog>
</div> </div>
</template> </template>
...@@ -387,6 +382,13 @@ export default { ...@@ -387,6 +382,13 @@ export default {
} }
} }
], ],
// purchaseGoodsName: [
// {
// validator: (rule, value, callback) => {
// value.length > 30 ? callback(new Error("产品别名不能超过30个字符")) : callback()
// }
// }
// ],
// minSellPrice: [ // minSellPrice: [
// { required: true, message: "请输入最低售价", trigger: "blur" }, // { required: true, message: "请输入最低售价", trigger: "blur" },
// { // {
......
...@@ -29,10 +29,10 @@ export default { ...@@ -29,10 +29,10 @@ export default {
addOrEdit: 'add', addOrEdit: 'add',
proFormRef: 'pro', proFormRef: 'pro',
editForm: [{ editForm: [{
title: '商品信息', title: '产品信息',
formBlock: [{ formBlock: [{
name: 'upgradeGoodsId', name: 'upgradeGoodsId',
label: '上架商品', label: '上架产品',
isRequired: true, isRequired: true,
type: 'searchSelect', type: 'searchSelect',
optionList: [], optionList: [],
...@@ -86,9 +86,21 @@ export default { ...@@ -86,9 +86,21 @@ export default {
}, { }, {
label: '产品ID', label: '产品ID',
value: 'upgradeCommodityCode' value: 'upgradeCommodityCode'
},
{
label: '供应商名称',
value: 'thirdPartyName'
}] }]
}, },
{ {
name: 'purchaseGoodsName',
label: '产品别名',
type: 'input',
width: '432px',
maxlength: 30,
value: "purchaseGoodsName"
},
{
name: 'purchasePrice', name: 'purchasePrice',
label: '采购价', label: '采购价',
type: 'input', type: 'input',
...@@ -159,7 +171,8 @@ export default { ...@@ -159,7 +171,8 @@ export default {
voucherList: [], voucherList: [],
// validMinSellPriceFlag: true, // validMinSellPriceFlag: true,
// validMinSellPrice: 'Y', // validMinSellPrice: 'Y',
suitCarType: 1 suitCarType: 1,
purchaseGoodsName: ''
}, },
secondGoodsList: [], secondGoodsList: [],
goodsNameKeyword: '', goodsNameKeyword: '',
...@@ -343,6 +356,7 @@ export default { ...@@ -343,6 +356,7 @@ export default {
confirmEvent(params, num) { confirmEvent(params, num) {
const obj = { // 商品信息 const obj = { // 商品信息
position: '', position: '',
purchaseGoodsName: '',
goodsAlias: '', goodsAlias: '',
warrantyType: '', warrantyType: '',
productType: [], productType: [],
......
...@@ -44,10 +44,10 @@ export default { ...@@ -44,10 +44,10 @@ export default {
financeCheckFlagStr: [{ required: true }] financeCheckFlagStr: [{ required: true }]
}, },
editForm: [{ editForm: [{
title: '商品信息', title: '产品信息',
formBlock: [{ formBlock: [{
name: 'goodsName', name: 'goodsName',
label: '上架商品', label: '上架产品',
type: 'incidBox', type: 'incidBox',
key: 'goodsType', key: 'goodsType',
detailInfo: [{ detailInfo: [{
...@@ -91,9 +91,19 @@ export default { ...@@ -91,9 +91,19 @@ export default {
}, { }, {
label: '产品ID', label: '产品ID',
value: 'upgradeCommodityCode' value: 'upgradeCommodityCode'
},
{
label: '供应商名称',
value: 'thirdPartyName'
}] }]
}, },
{ {
name: 'purchaseGoodsName',
label: '产品别名',
width: '432px',
handleInput: true
},
{
name: 'purchasePrice', name: 'purchasePrice',
label: '采购价', label: '采购价',
type: 'input', type: 'input',
......
...@@ -117,11 +117,8 @@ ...@@ -117,11 +117,8 @@
:selected-scene="batchCopySelectScene" @handleBatchCopyConfirm="handleBatchCopyConfirm" :selected-scene="batchCopySelectScene" @handleBatchCopyConfirm="handleBatchCopyConfirm"
@handleBatchCopyClose="handleBatchCopyClose"> @handleBatchCopyClose="handleBatchCopyClose">
</batch-copy-dialog> </batch-copy-dialog>
<d2-file-import-dialog :is-visible="fileVisible" <d2-file-import-dialog :is-visible="fileVisible" title="上传文件" @closeDialog="handleBatchImport"
title="上传文件" @confirmDialog="handleConfirmImport" @downloadTemplate="exportTemplate" />
@closeDialog="handleBatchImport"
@confirmDialog="handleConfirmImport"
@downloadTemplate="exportTemplate" />
</d2-container> </d2-container>
</template> </template>
<script> <script>
...@@ -158,7 +155,9 @@ export default { ...@@ -158,7 +155,9 @@ export default {
status: '', status: '',
yqMerchantId: '', yqMerchantId: '',
goodsSource: 0, goodsSource: 0,
financeCheckFlag: '' financeCheckFlag: '',
thirdPartyName: '',
thirdPartyCode: ''
}, },
tempGoodsType: [], tempGoodsType: [],
getListApi: getGroundingManageList, getListApi: getGroundingManageList,
...@@ -250,6 +249,12 @@ export default { ...@@ -250,6 +249,12 @@ export default {
isClear: true, isClear: true,
keyFn: this.keyDowmGetList keyFn: this.keyDowmGetList
}, { }, {
label: '供应商名称',
name: 'thirdPartyName',
type: 'input',
isClear: true,
keyFn: this.keyDowmGetList
}, {
label: '供应商编码', label: '供应商编码',
name: 'thirdPartyCode', name: 'thirdPartyCode',
type: 'input', type: 'input',
...@@ -295,7 +300,25 @@ export default { ...@@ -295,7 +300,25 @@ export default {
// formatter: (cellValue) => { // formatter: (cellValue) => {
// return cellValue.upgradeGoods.upgradeGoodsName || '-' // return cellValue.upgradeGoods.upgradeGoodsName || '-'
// } // }
}, { },
{
label: '供应商名称',
prop: 'thirdPartyName',
parentProp: 'upgradeGoods',
width: 100,
formatter: (cellValue) => {
return cellValue?.upgradeGoods?.thirdPartyName || '-'
}
},
{
label: '产品别名',
prop: 'purchaseGoodsName',
width: 120,
formatter: (cellValue) => {
return cellValue?.purchaseGoodsName || '-'
}
},
{
label: '规格', label: '规格',
prop: 'thirdPartyCode', prop: 'thirdPartyCode',
width: 140, width: 140,
...@@ -322,17 +345,17 @@ export default { ...@@ -322,17 +345,17 @@ export default {
label: '产品编码', label: '产品编码',
prop: 'type', prop: 'type',
parentProp: 'upgradeGoods', parentProp: 'upgradeGoods',
// formatter: (cellValue) => { formatter: (cellValue) => {
// return cellValue.upgradeGoods.type || '-' return cellValue.upgradeGoods.type || '-'
// } }
}, { }, {
label: '供应商编码', label: '供应商编码',
prop: 'thirdPartyCode', prop: 'thirdPartyCode',
parentProp: 'upgradeGoods', parentProp: 'upgradeGoods',
width: 100, width: 100,
// formatter: (cellValue) => { formatter: (cellValue) => {
// return cellValue?.upgradeGoods?.thirdPartyCode || '-' return cellValue?.upgradeGoods.thirdPartyCode || '-'
// } }
}, { }, {
label: '上架商户', label: '上架商户',
name: '', name: '',
......
<template> <template>
<div> <div>
<baseDialog :is-show.sync="dialogShow" :config="dialogConfig.setting" :dialog-config="dialogConfig.config" @closeDialog="handleDetailClose(false)"> <baseDialog :is-show.sync="dialogShow" :config="dialogConfig.setting" :dialog-config="dialogConfig.config"
@closeDialog="handleDetailClose(false)">
<div class="edit-order-dialog" v-if="dialogShow"> <div class="edit-order-dialog" v-if="dialogShow">
<div class="table-class"> <div class="table-class">
<d2-table ref="purchaseOrderDetailTable" :table-params="tableParams" :has-page="hasPage" @refreshTable="refreshTable" :table-data="tableList" :table-total="detailInfo.tableTotal"> <d2-table ref="purchaseOrderDetailTable" :table-params="tableParams" :has-page="hasPage"
@refreshTable="refreshTable" :table-data="tableList" :table-total="detailInfo.tableTotal">
<div slot="nowPurNum" slot-scope="scope" style="margin: 0 8px;"> <div slot="nowPurNum" slot-scope="scope" style="margin: 0 8px;">
<el-select v-model="nowPurNumList[scope.index]" placeholder="请选择" clearable> <el-select v-model="nowPurNumList[scope.index]" placeholder="请选择" clearable>
<el-option v-for="item in staffList" :key="item.uuid" :label="item.staffName" :value="item.uuid"> <el-option v-for="item in staffList" :key="item.uuid" :label="item.staffName" :value="item.uuid">
...@@ -33,12 +35,17 @@ ...@@ -33,12 +35,17 @@
</div> </div>
<div class="footer"> <div class="footer">
<el-button @click="handleDetailClose(false)">取消</el-button> <el-button @click="handleDetailClose(false)">取消</el-button>
<el-button @click="submit" type="primary" v-preventReClick :loading="$store.state.d2admin.loading.value">确定</el-button> <el-button @click="submit" type="primary" v-preventReClick
:loading="$store.state.d2admin.loading.value">确定</el-button>
</div> </div>
</div> </div>
</baseDialog> </baseDialog>
<card-dialog v-if="cardVisible" :card-visible="cardVisible" :order-info="orderInfo" :selected-list="selectedCardList" @handleClose="handleCardDialog" @handleConfirm="handleCardConfirm"></card-dialog> <card-dialog v-if="cardVisible" :card-visible="cardVisible" :order-info="orderInfo" :selected-list="selectedCardList"
<glsk-form-dialog v-if="batchVisible" :selectVisible="batchVisible" :dialogConfig="batchDialogConfig" label-width="200px" :formRules="batchRules" :editData="batchForm" :editFormData="batchEditFormData" :baseData="{ staffList: staffList }" @handleClose="batchDialogVisible" @handleConfirm="handleBatchConfirm"></glsk-form-dialog> @handleClose="handleCardDialog" @handleConfirm="handleCardConfirm"></card-dialog>
<glsk-form-dialog v-if="batchVisible" :selectVisible="batchVisible" :dialogConfig="batchDialogConfig"
label-width="200px" :formRules="batchRules" :editData="batchForm" :editFormData="batchEditFormData"
:baseData="{ staffList: staffList }" @handleClose="batchDialogVisible"
@handleConfirm="handleBatchConfirm"></glsk-form-dialog>
</div> </div>
</template> </template>
...@@ -131,6 +138,11 @@ export default { ...@@ -131,6 +138,11 @@ export default {
prop: 'upgradeGoodsName' prop: 'upgradeGoodsName'
}, },
{ {
label: "供应商名称",
prop: 'thirdPartyName',
width: 100,
},
{
label: '产品编码', label: '产品编码',
prop: 'type' prop: 'type'
...@@ -140,11 +152,20 @@ export default { ...@@ -140,11 +152,20 @@ export default {
prop: 'specificationData' prop: 'specificationData'
}, },
{ {
label: '供应商编码',
prop: 'thirdPartyCode',
width: 100
},
{
label: '适用车型', label: '适用车型',
addHtml: 'carName', addHtml: 'carName',
width: 200 width: 200
}, },
{ {
label: "产品别名",
prop: "purchaseGoodsName",
},
{
label: '系列', label: '系列',
prop: 'goodsName' prop: 'goodsName'
}, },
...@@ -347,7 +368,7 @@ export default { ...@@ -347,7 +368,7 @@ export default {
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
> span { >span {
margin-right: 20px; margin-right: 20px;
margin-bottom: 10px; margin-bottom: 10px;
} }
......
<template> <template>
<div> <div>
<baseDialog :is-show.sync="dialogShow" :config="dialogConfig.setting" :dialog-config="dialogConfig.config" @closeDialog="handleDetailClose(false)"> <baseDialog :is-show.sync="dialogShow" :config="dialogConfig.setting" :dialog-config="dialogConfig.config"
@closeDialog="handleDetailClose(false)">
<div class="edit-order-dialog" v-if="dialogShow"> <div class="edit-order-dialog" v-if="dialogShow">
<div class="addressTitle"> <div class="addressTitle">
<img src="../images/addressIcon.webp" alt="" class="icon" /> <img src="../images/addressIcon.webp" alt="" class="icon" />
...@@ -23,18 +24,19 @@ ...@@ -23,18 +24,19 @@
{{ detailInfo.purchaseOrderRemark }}</span></span> {{ detailInfo.purchaseOrderRemark }}</span></span>
</div> --> </div> -->
<div class="table-class"> <div class="table-class">
<d2-table ref="purchaseOrderDetailTable" :table-params="tableParams" :has-page="hasPage" :table-data="tableList"> <d2-table ref="purchaseOrderDetailTable" :table-params="tableParams" :has-page="hasPage"
:table-data="tableList">
<div slot="nowPurNum" slot-scope="scope" style="margin: 0 8px;"> <div slot="nowPurNum" slot-scope="scope" style="margin: 0 8px;">
<!-- 未退货才可以 --> <!-- 未退货才可以 -->
<div v-if=" <div v-if="(tableList[scope.index].purchaseNumber == 0 ||
(tableList[scope.index].purchaseNumber == 0 || tableList[scope.index].purchaseNumber !=
tableList[scope.index].purchaseNumber != tableList[scope.index].goodsNumber) && scope.scope.refundStatus != 'Y'
tableList[scope.index].goodsNumber) && scope.scope.refundStatus != 'Y' ">
">
<!-- 判断是否当前账户发货 --> <!-- 判断是否当前账户发货 -->
<el-input v-if=" <el-input v-if="(isEmptyEdit &&
(isEmptyEdit && !tableList[scope.index].shipperUuid) || tableList[scope.index].shipperUuid == userInfo.detail.uuid"
!tableList[scope.index].shipperUuid) || tableList[scope.index].shipperUuid == userInfo.detail.uuid" :class="{ 'border-red': !nowPurNumList[scope.index] && isSubmit }" placeholder="请输入" v-model="nowPurNumList[scope.index]" @input="(e) => handleInput(e, scope)"></el-input> :class="{ 'border-red': !nowPurNumList[scope.index] && isSubmit }" placeholder="请输入"
v-model="nowPurNumList[scope.index]" @input="(e) => handleInput(e, scope)"></el-input>
<!-- <div v-if="detailInfo.tableData[scope.index].shipperUuid != userInfo.detail.uuid">{{ detailInfo.tableData[scope.index].shipper }}</div> --> <!-- <div v-if="detailInfo.tableData[scope.index].shipperUuid != userInfo.detail.uuid">{{ detailInfo.tableData[scope.index].shipper }}</div> -->
<div v-else> <div v-else>
已分配:{{ tableList[scope.index].shipper }} 已分配:{{ tableList[scope.index].shipper }}
...@@ -43,13 +45,14 @@ ...@@ -43,13 +45,14 @@
<div v-else> <div v-else>
{{ {{
tableList[scope.index].shipperUuid tableList[scope.index].shipperUuid
? "已分配:" + tableList[scope.index].shipper ? "已分配:" + tableList[scope.index].shipper
: "--" : "--"
}} }}
</div> </div>
</div> </div>
<div slot="cardNum" slot-scope="scope" style="margin: 0 8px;"> <div slot="cardNum" slot-scope="scope" style="margin: 0 8px;">
<div v-if="tableList[scope.index].entityCardFlag != 'Y' || (tableList[scope.index].shipperUuid && tableList[scope.index].shipperUuid != userInfo.detail.uuid)"> <div
v-if="tableList[scope.index].entityCardFlag != 'Y' || (tableList[scope.index].shipperUuid && tableList[scope.index].shipperUuid != userInfo.detail.uuid)">
- -
</div> </div>
<div v-else-if="tableList[scope.index].purchaseNumber != tableList[scope.index].goodsNumber"> <div v-else-if="tableList[scope.index].purchaseNumber != tableList[scope.index].goodsNumber">
...@@ -83,10 +86,12 @@ ...@@ -83,10 +86,12 @@
<div class="form-content"> <div class="form-content">
<el-form label-width="100px" :rules="dialogRules" :model="dialogData" ref="delivery-dialog-form"> <el-form label-width="100px" :rules="dialogRules" :model="dialogData" ref="delivery-dialog-form">
<el-form-item label="承运公司:" prop="deliveryCompany"> <el-form-item label="承运公司:" prop="deliveryCompany">
<el-input placeholder="请输入承运物流公司" maxlength="20" v-model.trim="dialogData.deliveryCompany" class="dis-in-block" /> <el-input placeholder="请输入承运物流公司" maxlength="20" v-model.trim="dialogData.deliveryCompany"
class="dis-in-block" />
</el-form-item> </el-form-item>
<el-form-item label="承运单号:" prop="deliveryNumber"> <el-form-item label="承运单号:" prop="deliveryNumber">
<el-input maxlength="50" placeholder="请输入承运物流单号" v-model.trim="dialogData.deliveryNumber" class="dis-in-block" @input="deliveryNumberInput" /> <el-input maxlength="50" placeholder="请输入承运物流单号" v-model.trim="dialogData.deliveryNumber"
class="dis-in-block" @input="deliveryNumberInput" />
</el-form-item> </el-form-item>
<el-form-item label="发货时间:" prop="deliveryDate"> <el-form-item label="发货时间:" prop="deliveryDate">
<el-date-picker class="dis-in-block" v-model="dialogData.deliveryDate" type="datetime" placeholder="选择日期时间"> <el-date-picker class="dis-in-block" v-model="dialogData.deliveryDate" type="datetime" placeholder="选择日期时间">
...@@ -108,11 +113,15 @@ ...@@ -108,11 +113,15 @@
:value="item.id" :value="item.id"
/> />
</el-select> --> </el-select> -->
<el-select class="dis-in-block" v-model="dialogData.shippingWarehouseId" clearable placeholder="请选择发货仓库" @change="selectChange($event)" @blur="selectBlur" @focus="selectFocus" filterable> <el-select class="dis-in-block" v-model="dialogData.shippingWarehouseId" clearable placeholder="请选择发货仓库"
<el-option v-for="(item, index) in shippingWarehouseList" :key="item.id" :label="item.name" :value="item.id"> @change="selectChange($event)" @blur="selectBlur" @focus="selectFocus" filterable>
<el-option v-for="(item, index) in shippingWarehouseList" :key="item.id" :label="item.name"
:value="item.id">
<!-- 发货仓库 --> <!-- 发货仓库 -->
<div class="flex-option"> <div class="flex-option">
<el-input v-show="editOptionIndex == index" :maxlength="10" class="add-option-input" :autofocus="true" @click.stop.native="editOptionFocus" v-model.trim="editOptionValue" size="small" placeholder="请输入" /> <el-input v-show="editOptionIndex == index" :maxlength="10" class="add-option-input"
:autofocus="true" @click.stop.native="editOptionFocus" v-model.trim="editOptionValue" size="small"
placeholder="请输入" />
<span v-show="editOptionIndex == -1 || editOptionIndex != index <span v-show="editOptionIndex == -1 || editOptionIndex != index
" class="add-option-input">{{ item.name }}</span> " class="add-option-input">{{ item.name }}</span>
<div> <div>
...@@ -122,15 +131,18 @@ ...@@ -122,15 +131,18 @@
<i v-show="shippingWarehouseList.length > 1 && <i v-show="shippingWarehouseList.length > 1 &&
editOptionIndex == index editOptionIndex == index
" class="el-icon-check option_icon add_icon" @click.stop="editOptionConfirm(item.id)" /> " class="el-icon-check option_icon add_icon" @click.stop="editOptionConfirm(item.id)" />
<i v-if="shippingWarehouseList.length > 1" class="el-icon-close del_icon" @click.stop="delOption(item.id)" /> <i v-if="shippingWarehouseList.length > 1" class="el-icon-close del_icon"
@click.stop="delOption(item.id)" />
</div> </div>
</div> </div>
</el-option> </el-option>
<div class="add-option"> <div class="add-option">
<div v-if="showOptionInput" class="flex-option"> <div v-if="showOptionInput" class="flex-option">
<el-input class="add-option-input" :maxlength="10" v-model.trim="addOptionValue" size="small" placeholder="请输入" @blur="clearValidateHandle" id="add-option-input" /> <el-input class="add-option-input" :maxlength="10" v-model.trim="addOptionValue" size="small"
placeholder="请输入" @blur="clearValidateHandle" id="add-option-input" />
<div> <div>
<i v-if="addOptionValue" class="el-icon-check option_icon add_icon" @click.stop="addOptionConfirm()" /> <i v-if="addOptionValue" class="el-icon-check option_icon add_icon"
@click.stop="addOptionConfirm()" />
<i class="el-icon-close option_icon del_icon" @click.stop="delOption(undefined)" /> <i class="el-icon-close option_icon del_icon" @click.stop="delOption(undefined)" />
</div> </div>
</div> </div>
...@@ -152,11 +164,13 @@ ...@@ -152,11 +164,13 @@
<div class="footer"> <div class="footer">
<el-button @click="handleDetailClose(false)">取消</el-button> <el-button @click="handleDetailClose(false)">取消</el-button>
<el-button @click="submit" type="primary" v-preventReClick :loading="$store.state.d2admin.loading.value">确定</el-button> <el-button @click="submit" type="primary" v-preventReClick
:loading="$store.state.d2admin.loading.value">确定</el-button>
</div> </div>
</div> </div>
</baseDialog> </baseDialog>
<card-dialog v-if="cardVisible" :card-visible="cardVisible" :order-info="orderInfo" :card-max-num="cardMaxNum" :selected-list="selectedCardList" @handleClose="handleCardDialog" @handleConfirm="handleCardConfirm"></card-dialog> <card-dialog v-if="cardVisible" :card-visible="cardVisible" :order-info="orderInfo" :card-max-num="cardMaxNum"
:selected-list="selectedCardList" @handleClose="handleCardDialog" @handleConfirm="handleCardConfirm"></card-dialog>
</div> </div>
</template> </template>
...@@ -254,6 +268,11 @@ export default { ...@@ -254,6 +268,11 @@ export default {
prop: 'upgradeGoodsName' prop: 'upgradeGoodsName'
}, },
{ {
label: "供应商名称",
prop: 'thirdPartyName',
width: 100,
},
{
label: "产品编码", label: "产品编码",
prop: "type" prop: "type"
}, },
...@@ -261,6 +280,11 @@ export default { ...@@ -261,6 +280,11 @@ export default {
label: "规格", label: "规格",
prop: "specificationData" prop: "specificationData"
}, },
{
label: '供应商编码',
prop: 'thirdPartyCode',
width: 100
},
{ {
label: '适用车型', label: '适用车型',
...@@ -309,6 +333,10 @@ export default { ...@@ -309,6 +333,10 @@ export default {
width: 150 width: 150
}, },
{ {
label: "产品别名",
prop: "purchaseGoodsName",
},
{
label: "已发货数量", label: "已发货数量",
prop: "purchaseNumber", prop: "purchaseNumber",
width: 120, width: 120,
...@@ -661,7 +689,7 @@ export default { ...@@ -661,7 +689,7 @@ export default {
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
> span { >span {
margin-right: 20px; margin-right: 20px;
margin-bottom: 10px; margin-bottom: 10px;
} }
......
<!-- 发货单详情弹窗 --> <!-- 发货单详情弹窗 -->
<template> <template>
<div> <div>
<baseDialog title="详细信息" :is-show.sync="detailVisible" :config="dialogConfig.setting" :dialog-config="dialogConfig.config" width="1050px" :no-cancel="true" btn-ok-label="关闭" @closeDialog="handleClose" @confirmDialog="handleClose"> <baseDialog title="详细信息" :is-show.sync="detailVisible" :config="dialogConfig.setting"
:dialog-config="dialogConfig.config" width="1050px" :no-cancel="true" btn-ok-label="关闭" @closeDialog="handleClose"
@confirmDialog="handleClose">
<div class="stockMonthDailog"> <div class="stockMonthDailog">
<div class="addressTitle"> <div class="addressTitle">
<img src="../images/addressIcon.webp" alt="" class="icon"> <img src="../images/addressIcon.webp" alt="" class="icon">
...@@ -30,11 +32,13 @@ ...@@ -30,11 +32,13 @@
<span>{{ itemList.deliveryDate }}</span> <span>{{ itemList.deliveryDate }}</span>
</div> </div>
<div> <div>
<el-button style="padding: 0;" v-if="itemList.putStatus == 0" type="text" @click="handleEdit(itemList)">编辑</el-button> <el-button style="padding: 0;" v-if="itemList.putStatus == 0" type="text"
@click="handleEdit(itemList)">编辑</el-button>
<el-button style="padding: 0;" type="text" @click="handleSign(itemList)">发货签收单</el-button> <el-button style="padding: 0;" type="text" @click="handleSign(itemList)">发货签收单</el-button>
</div> </div>
</div> </div>
<d2-table ref="recordTable" :table-data="itemList.deliveryDetailList" :table-params="tableParams" :has-page="false"> <d2-table ref="recordTable" :table-data="itemList.deliveryDetailList" :table-params="tableParams"
:has-page="false">
<span slot="deliveryCard" slot-scope="scope"> <span slot="deliveryCard" slot-scope="scope">
<template v-if="scope.scope.deliveryCardList && scope.scope.deliveryCardList.length > 1"> <template v-if="scope.scope.deliveryCardList && scope.scope.deliveryCardList.length > 1">
<!-- {{ scope.scope.deliveryCardList.length || 0 }} --> <!-- {{ scope.scope.deliveryCardList.length || 0 }} -->
...@@ -52,12 +56,17 @@ ...@@ -52,12 +56,17 @@
</div> </div>
</div> </div>
</baseDialog> </baseDialog>
<baseDialog title="查看发货卡号" :config="carDialogConfig.setting" :dialog-config="carDialogConfig.config" :is-show.sync="handleDeliveryCardVisible" width="500px" :no-cancel="true" btn-ok-label="关闭" @closeDialog="handleDeliveryCardVisible = false" @confirmDialog="handleDeliveryCardVisible = false"> <baseDialog title="查看发货卡号" :config="carDialogConfig.setting" :dialog-config="carDialogConfig.config"
<d2-table class="deliveryCardCon" ref="recordTable" :table-data="deliveryCardList" :table-params="innerParams" :has-page="false"> :is-show.sync="handleDeliveryCardVisible" width="500px" :no-cancel="true" btn-ok-label="关闭"
@closeDialog="handleDeliveryCardVisible = false" @confirmDialog="handleDeliveryCardVisible = false">
<d2-table class="deliveryCardCon" ref="recordTable" :table-data="deliveryCardList" :table-params="innerParams"
:has-page="false">
</d2-table> </d2-table>
</baseDialog> </baseDialog>
<!-- 编辑 --> <!-- 编辑 -->
<glsk-form-dialog v-if="editVisible" :selectVisible="editVisible" :dialogConfig="editDialogConfig" label-width="104px" dialog-width="520px" :formRules="editRules" :editData="editData" :editFormData="editFormData" :base-data="baseData" @handleClose="editVisible = false" @handleConfirm="handleEditConfirm"></glsk-form-dialog> <glsk-form-dialog v-if="editVisible" :selectVisible="editVisible" :dialogConfig="editDialogConfig" label-width="104px"
dialog-width="520px" :formRules="editRules" :editData="editData" :editFormData="editFormData" :base-data="baseData"
@handleClose="editVisible = false" @handleConfirm="handleEditConfirm"></glsk-form-dialog>
</div> </div>
</template> </template>
...@@ -120,6 +129,11 @@ export default { ...@@ -120,6 +129,11 @@ export default {
prop: 'upgradeGoodsName' prop: 'upgradeGoodsName'
}, },
{ {
label: "供应商名称",
prop: 'thirdPartyName',
width: 100,
},
{
label: '产品编码', label: '产品编码',
prop: 'type' prop: 'type'
}, },
...@@ -128,6 +142,15 @@ export default { ...@@ -128,6 +142,15 @@ export default {
prop: 'specificationData' prop: 'specificationData'
}, },
{ {
label: '供应商编码',
prop: 'thirdPartyCode',
width: 100
},
{
label: "产品别名",
prop: "purchaseGoodsName",
},
{
label: '发货数量', label: '发货数量',
prop: 'purchaseNumber', prop: 'purchaseNumber',
formatter: cellValue => { formatter: cellValue => {
...@@ -321,7 +344,7 @@ export default { ...@@ -321,7 +344,7 @@ export default {
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
> span { >span {
margin-right: 20px; margin-right: 20px;
margin-bottom: 10px; margin-bottom: 10px;
} }
...@@ -347,10 +370,12 @@ export default { ...@@ -347,10 +370,12 @@ export default {
display: flex; display: flex;
width: 319px; width: 319px;
} }
.detail-label { .detail-label {
width: 70px; width: 70px;
flex-shrink: 0; flex-shrink: 0;
} }
span { span {
color: #333333ff; color: #333333ff;
} }
......
<!-- 编辑 - 审核 --> <!-- 编辑 - 审核 -->
<template> <template>
<d2-container v-loading="loading"> <d2-container v-loading="loading">
<div class="edit-page edit-tmpl"> <div class="edit-page edit-tmpl">
<div class="title"> <div class="title">
产品信息 产品信息
</div> </div>
<div class="content-box"> <div class="content-box">
<d2-table ref="purchaseOrderDetailTable" <d2-table ref="purchaseOrderDetailTable" :table-params="tableParams" :table-data="detailInfo.tableData"
:table-params="tableParams" :layout="layout" :table-total="detailInfo.tableTotal" @refreshTable="refreshTable">
:table-data="detailInfo.tableData" <template #upgradeGoodsName="scope">
:layout="layout" <div>
:table-total="detailInfo.tableTotal" <img v-if="scope.scope.refundStatus == 'Y'" class="return" src="@/assets/retrun.png" alt="">
@refreshTable="refreshTable"> <span>{{ scope.scope.upgradeGoodsName }}</span>
<template #upgradeGoodsName="scope"> </div>
<div> </template>
<img v-if="scope.scope.refundStatus == 'Y'" <template #filmRollNo="scope">
class="return" <div v-if="scope.scope.filmRollList && scope.scope.filmRollList.length == 1">
src="@/assets/retrun.png" {{ scope.scope.filmRollList[0] }}
alt=""> </div>
<span>{{ scope.scope.upgradeGoodsName }}</span> <div v-else-if="scope.scope.filmRollList && scope.scope.filmRollList.length > 1">
</div> <el-popover placement="top" width="200" trigger="hover">
</template> <div class="film-roll-box">
<template #filmRollNo="scope"> <div class="title">
<div v-if="scope.scope.filmRollList && scope.scope.filmRollList.length == 1"> 膜卷号
{{ scope.scope.filmRollList[0] }} </div>
</div> <div v-for="(subItem, subIndex) in scope.scope.filmRollList" :key="subIndex"
<div v-else-if="scope.scope.filmRollList && scope.scope.filmRollList.length > 1"> class="merchant-item">
<el-popover placement="top" {{ subItem }}
width="200" </div>
trigger="hover"> </div>
<div class="film-roll-box"> <template #reference>
<div class="title"> <div>
膜卷号 <!-- <img style="width: 14px;height: 13px;" src="./images/merchant_icon.png"> -->
</div> <span style="color: #2A58AD;">(…{{ scope.scope.filmRollList.length }})</span>
<div v-for="(subItem, subIndex) in scope.scope.filmRollList" </div>
:key="subIndex" </template>
class="merchant-item"> </el-popover>
{{ subItem }} </div>
</div> <div v-else>
</div> <span style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{ '-' }}</span>
<template #reference> </div>
<div> </template>
<!-- <img style="width: 14px;height: 13px;" src="./images/merchant_icon.png"> --> <template #carName="scope">
<span style="color: #2A58AD;">(…{{ scope.scope.filmRollList.length }})</span> <el-tooltip v-if="scope.scope.suitCarTypeList && scope.scope.suitCarTypeList.length"
</div> placement="top">
</template> <template #content>
</el-popover> <div class="car-type-list">
</div> <div v-for="(item, index) in scope.scope.suitCarTypeList" :key="index">
<div v-else> {{
<span style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{ '-' }}</span> `${item.brandName}-${item.childName}-${item.seriesName}-${item.carTypeName}` }}
</div> </div>
</template> </div>
<template #carName="scope"> </template>
<el-tooltip v-if="scope.scope.suitCarTypeList && scope.scope.suitCarTypeList.length" placement="top"> <div>{{ scope.scope.suitCarTypeList | formatCar }}</div>
<template #content> </el-tooltip>
<div class="car-type-list"> <div v-else>
<div v-for="(item, index) in scope.scope.suitCarTypeList" :key="index"> -
{{ </div>
`${item.brandName}-${item.childName}-${item.seriesName}-${item.carTypeName}` }} </template>
</div> </d2-table>
</div> </div>
</template> </div>
<div>{{ scope.scope.suitCarTypeList | formatCar }}</div> <div class="content-box">
</el-tooltip> <glsx-combi-form ref="editFormRef" class="edit-form-container" label-width="150px" default-width="470px"
<div v-else> :is-block="isBlock" :form-ref="editChildRef" :form-obj="infoForm" :form-data="editFormData"
- :form-rules="formRules">
</div> </glsx-combi-form>
</template> <ExamineRecord :use-expand="false" :list="detailInfo.auditDetaiList" style="margin-top:20px;" />
</d2-table>
</div>
</div>
<div class="content-box">
<glsx-combi-form ref="editFormRef"
class="edit-form-container"
label-width="150px"
default-width="470px"
:is-block="isBlock"
:form-ref="editChildRef"
:form-obj="infoForm"
:form-data="editFormData"
:form-rules="formRules">
</glsx-combi-form>
<ExamineRecord :use-expand="false"
:list="detailInfo.auditDetaiList"
style="margin-top:20px;" />
</div> </div>
<div class="footer"> <div class="footer">
<el-button type="primary" <el-button type="primary" :loading="loading" @click="handleConfirm">
:loading="loading" 确定
@click="handleConfirm"> </el-button>
确定 <el-button @click="handleCancel">
</el-button> 取消
<el-button @click="handleCancel"> </el-button>
取消 </div>
</el-button> </d2-container>
</div>
</d2-container>
</template> </template>
<script> <script>
...@@ -140,6 +121,11 @@ export default { ...@@ -140,6 +121,11 @@ export default {
prop: "upgradeGoodsName", prop: "upgradeGoodsName",
}, },
{ {
label: "供应商名称",
prop: 'thirdPartyName',
width: 100,
},
{
label: "产品编码", label: "产品编码",
prop: "type", prop: "type",
}, },
...@@ -147,6 +133,12 @@ export default { ...@@ -147,6 +133,12 @@ export default {
label: "规格", label: "规格",
prop: "specificationData", prop: "specificationData",
}, },
{
label: '供应商编码',
prop: 'thirdPartyCode',
width: 100
},
{ {
label: "采购数量", label: "采购数量",
prop: "goodsNumber", prop: "goodsNumber",
...@@ -163,6 +155,7 @@ export default { ...@@ -163,6 +155,7 @@ export default {
return this.paramsObj.purchaseType == 1 ? condition : `${cellValue.goodsNumber}件`; return this.paramsObj.purchaseType == 1 ? condition : `${cellValue.goodsNumber}件`;
}, },
}, },
{ {
label: "已发货数量", label: "已发货数量",
prop: "purchaseNumber", prop: "purchaseNumber",
...@@ -172,6 +165,10 @@ export default { ...@@ -172,6 +165,10 @@ export default {
}, },
}, },
{ {
label: "产品别名",
prop: "purchaseGoodsName",
},
{
label: "单价", label: "单价",
prop: "upgradePurchasePrice", prop: "upgradePurchasePrice",
formatter: (row) => { formatter: (row) => {
...@@ -420,6 +417,7 @@ export default { ...@@ -420,6 +417,7 @@ export default {
::v-deep .d2-container-full { ::v-deep .d2-container-full {
bottom: 60px !important; bottom: 60px !important;
} }
.edit-page.edit-tmpl { .edit-page.edit-tmpl {
background: #ffffff; background: #ffffff;
...@@ -433,11 +431,13 @@ export default { ...@@ -433,11 +431,13 @@ export default {
color: #333333; color: #333333;
} }
} }
.content-box { .content-box {
padding: 20px; padding: 20px;
background: #ffffff; background: #ffffff;
box-sizing: border-box; box-sizing: border-box;
} }
.car-type-list { .car-type-list {
max-height: 300px; max-height: 300px;
overflow-y: scroll; overflow-y: scroll;
...@@ -481,7 +481,7 @@ export default { ...@@ -481,7 +481,7 @@ export default {
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
> span { >span {
margin-right: 20px; margin-right: 20px;
margin-bottom: 10px; margin-bottom: 10px;
} }
...@@ -505,6 +505,7 @@ export default { ...@@ -505,6 +505,7 @@ export default {
margin-bottom: 8px; margin-bottom: 8px;
} }
} }
.remark-input { .remark-input {
width: 85%; width: 85%;
} }
......
<template> <template>
<div class="classificationCptContainer"> <div class="classificationCptContainer">
<ClassificationRuleHeader :goods-type-group-division-id="goodsTypeGroupDivisionId" <ClassificationRuleHeader @rule-test="ruleTest" />
@rule-test="ruleTest"
@get-progress="getProgress" />
<el-form ref="classification" <el-form ref="classification"
:model="classificationObj" :model="classificationObj"
:rules="rules" :rules="rules"
...@@ -1012,18 +1010,6 @@ ...@@ -1012,18 +1010,6 @@
:table-select-options="tableSelectOptions" :table-select-options="tableSelectOptions"
:classification-obj-select="tableClassificationObjSelect" :classification-obj-select="tableClassificationObjSelect"
@distribution-rules-change="onDistributionRulesChange" /> @distribution-rules-change="onDistributionRulesChange" />
<TipsDialog v-if="tipsDialogVisible"
:account-valid-merchants="accountValidMerchants"
:visible.sync="tipsDialogVisible" />
<FinancialCalculationDialog v-if="financialCalculationVisible"
:financial-calculation-obj="financialCalculationObj"
:visible.sync="financialCalculationVisible"
v-on="$listeners" />
<ChannelSelectDialog v-if="channelSelectDialogVisible"
:division-rule-tests="divisionRuleTests"
:visible.sync="channelSelectDialogVisible"
v-on="$listeners"
@handleConfirm="channelConfirm" />
</div> </div>
</template> </template>
...@@ -1040,9 +1026,6 @@ import { ...@@ -1040,9 +1026,6 @@ import {
getUpgradeGoodsRowKey, getUpgradeGoodsRowKey,
filterUpgradeGoodsByMerchantCode, filterUpgradeGoodsByMerchantCode,
} from "../../merchantStep/utils/groundingUpgradeList"; } from "../../merchantStep/utils/groundingUpgradeList";
import { divisionRuleTestGet } from "@api/merchant";
// 1按毛利比例;2按收入比例;3按固定金额
// 1按收入比例;2按毛利比例;3按固定金额;4按(产值-流量成本)比例;5按(产值-流量成本-其他费用不包含产品成本))比例;6按(产值-流量成本-其他费用包含产品成本)比例);其他费用:1按收入比例
import { mapGetters, mapMutations } from "vuex"; import { mapGetters, mapMutations } from "vuex";
import { import {
defaultSelectOptions, defaultSelectOptions,
...@@ -1053,20 +1036,14 @@ import { limitPrice } from "@/common/format"; ...@@ -1053,20 +1036,14 @@ import { limitPrice } from "@/common/format";
import { deepClone } from "@/common/util"; import { deepClone } from "@/common/util";
import { expenseSideRowKey } from "../utils/expenseRowKey"; import { expenseSideRowKey } from "../utils/expenseRowKey";
import { CLASSIFICATION_EMIT } from "../utils/classificationEmitTypes"; import { CLASSIFICATION_EMIT } from "../utils/classificationEmitTypes";
import channelSelectDialog from "./channelSelectDialog";
import ClassificationRuleHeader from "./classificationCpt/ClassificationRuleHeader.vue"; import ClassificationRuleHeader from "./classificationCpt/ClassificationRuleHeader.vue";
import GoodsSourceCategoryPicker from "./classificationCpt/GoodsSourceCategoryPicker.vue"; import GoodsSourceCategoryPicker from "./classificationCpt/GoodsSourceCategoryPicker.vue";
import financialCalculationDialog from "./financialCalculationDialog";
import tableAccount from "./tableAccount"; import tableAccount from "./tableAccount";
import tipsDialog from "./tipsDialog";
export default { export default {
name: "ClassificationCpt", name: "ClassificationCpt",
components: { components: {
TableAccount: tableAccount, TableAccount: tableAccount,
TipsDialog: tipsDialog,
FinancialCalculationDialog: financialCalculationDialog,
ChannelSelectDialog: channelSelectDialog,
ClassificationRuleHeader, ClassificationRuleHeader,
GoodsSourceCategoryPicker, GoodsSourceCategoryPicker,
}, },
...@@ -1147,11 +1124,6 @@ export default { ...@@ -1147,11 +1124,6 @@ export default {
: callback(new Error("请输入折算比例")); : callback(new Error("请输入折算比例"));
}; };
return { return {
channelSelectDialogVisible: false,
divisionRuleTests: [],
financialCalculationVisible: false,
tipsDialogVisible: false,
accountValidMerchants: [],
classificationObj: { classificationObj: {
goodsTypes: [], goodsTypes: [],
// trafficSide: [], // trafficSide: [],
...@@ -1235,7 +1207,6 @@ export default { ...@@ -1235,7 +1207,6 @@ export default {
], ],
}, },
serviceSelectList: [], serviceSelectList: [],
financialCalculationObj: {},
currentPage: 1, currentPage: 1,
pageSize: 20, pageSize: 20,
currentPagePackage: 1, currentPagePackage: 1,
...@@ -1468,15 +1439,6 @@ export default { ...@@ -1468,15 +1439,6 @@ export default {
// return this.classificationObjSelect // return this.classificationObjSelect
// } // }
}, },
goodsTypeGroupDivisionId() {
// console.log(
// this.tabItem.groupDivisionRuleId,
// "this.tabItem.groupDivisionRuleId"
// )
const id
= this.tabItem.testFlag == "N" ? this.tabItem.groupDivisionRuleId : false;
return id || false;
},
}, },
watch: { watch: {
"classificationObj.goodsSource": { "classificationObj.goodsSource": {
...@@ -1601,13 +1563,6 @@ export default { ...@@ -1601,13 +1563,6 @@ export default {
deep: true, deep: true,
// immediate: true // immediate: true
}, },
"tabItem.groupDivisionRuleId": {
handler() {
this.resetGoodsTypeGroupDivisionId();
},
deep: true,
immediate: true,
},
"tabItem.pendingCalculateErrorOps": { "tabItem.pendingCalculateErrorOps": {
handler() { handler() {
this.$nextTick(() => this.replayPendingCalculateErrorOps()); this.$nextTick(() => this.replayPendingCalculateErrorOps());
...@@ -1905,66 +1860,6 @@ export default { ...@@ -1905,66 +1860,6 @@ export default {
); );
}, },
// ...mapActions("FinancialRules", ["reset"]), // ...mapActions("FinancialRules", ["reset"]),
resetGoodsTypeGroupDivisionId() {
// goodsTypeGroupDivisionId() {
// console.log(
// this.tabItem.groupDivisionRuleId,
// "this.tabItem.groupDivisionRuleId"
// )
// const id = this.tabItem.testFlag != 'Y' ? this.tabItem.groupDivisionRuleId : false
// this.goodsTypeGroupDivisionId = id || false
// }
},
getProgress() {
if (!this.goodsTypeGroupDivisionId)
return;
divisionRuleTestGet({
goodsTypeGroupDivisionId: this.goodsTypeGroupDivisionId,
}).then((result) => {
if (!result)
return;
const {
notInForceAccountMerchants,
divisionRuleTests,
subProgress,
accountValidMerchants,
} = result;
if (notInForceAccountMerchants) {
this.tipsDialogVisible = true;
this.accountValidMerchants = notInForceAccountMerchants;
return;
}
if (subProgress == 32) {
this.tipsDialogVisible = true;
this.accountValidMerchants = accountValidMerchants;
return;
}
if (Array.isArray(divisionRuleTests) && divisionRuleTests.length > 0) {
if (divisionRuleTests.length === 1) {
this.channelConfirm(divisionRuleTests[0]);
} else {
this.channelSelectDialogVisible = true;
this.divisionRuleTests = divisionRuleTests;
}
return;
}
const sp = Number(subProgress);
if ([34, 35, 36, 31].includes(sp)) {
this.financialCalculationVisible = true;
this.financialCalculationObj = result;
}
}).catch((err) => {
console.error("[FinancialRules/classificationCpt] getProgress", err);
});
},
channelConfirm(result) {
this.financialCalculationVisible = true;
this.financialCalculationObj = { ...result, ...result.divisionRuleTestItem };
// }
},
ruleTest() { ruleTest() {
this.emitClassificationChange(CLASSIFICATION_EMIT.RULES_TEST); this.emitClassificationChange(CLASSIFICATION_EMIT.RULES_TEST);
}, },
...@@ -2264,8 +2159,6 @@ export default { ...@@ -2264,8 +2159,6 @@ export default {
"upgradeGoods", "upgradeGoods",
"packageGoods", "packageGoods",
"goodsSource", "goodsSource",
"testFlag",
"groupDivisionRuleId",
"goodsCostConvertRate", "goodsCostConvertRate",
"virtualAccountCostConvertRate", "virtualAccountCostConvertRate",
"recoveryCostConvertRate", "recoveryCostConvertRate",
...@@ -2487,8 +2380,6 @@ export default { ...@@ -2487,8 +2380,6 @@ export default {
partnerDeductChargeFlag: obj.partnerDeductChargeFlag, partnerDeductChargeFlag: obj.partnerDeductChargeFlag,
virtualAccountCostFlag: obj.virtualAccountCostFlag, virtualAccountCostFlag: obj.virtualAccountCostFlag,
recoveryCostFlag: obj.recoveryCostFlag, recoveryCostFlag: obj.recoveryCostFlag,
testFlag: obj.testFlag,
groupDivisionRuleId: obj.groupDivisionRuleId,
djCostFlag: obj.djCostFlag, djCostFlag: obj.djCostFlag,
thirdPartyCostFlag: obj.thirdPartyCostFlag, thirdPartyCostFlag: obj.thirdPartyCostFlag,
goodsCostFlag: obj.goodsCostFlag, goodsCostFlag: obj.goodsCostFlag,
......
...@@ -2,20 +2,12 @@ ...@@ -2,20 +2,12 @@
<div class="hederContainer"> <div class="hederContainer">
<span class="tips ruleTest">不确定规则是否正确?点击 <span class="tips ruleTest">不确定规则是否正确?点击
<el-button type="text" @click="$emit('rule-test')">进行测算</el-button></span> <el-button type="text" @click="$emit('rule-test')">进行测算</el-button></span>
<span v-show="goodsTypeGroupDivisionId" class="tips dimensionTest">未进行分账测试,点击
<el-button type="text" @click="$emit('get-progress')">立即测试</el-button></span>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "ClassificationRuleHeader", name: "ClassificationRuleHeader"
props: {
goodsTypeGroupDivisionId: {
type: [String, Number, Boolean],
default: false
}
}
} }
</script> </script>
...@@ -42,9 +34,5 @@ export default { ...@@ -42,9 +34,5 @@ export default {
background: #185efe; background: #185efe;
} }
} }
.dimensionTest {
margin-left: 80px;
}
} }
</style> </style>
<template>
<div class="division-test-step1">
<div v-if="!step1Paid" class="pay-qrcode-wrap">
<img v-if="qrCodeURL" :src="qrCodeURL" class="pay-qrcode" alt="支付二维码">
<div v-else class="pay-qrcode pay-qrcode--loading" v-loading="true" />
<p class="pay-tip">微信扫码支付({{ payAmount }}元)</p>
</div>
<div v-else class="order-linked">
<span>关联测试订单:{{ orderCode }}</span>
<el-button
type="text"
class="retest-link"
@click="$emit('retest')"
>
重新测试
</el-button>
</div>
</div>
</template>
<script>
export default {
name: 'DivisionTestStep1Pay',
props: {
step1Paid: {
type: Boolean,
default: false
},
orderCode: {
type: String,
default: ''
},
qrCodeURL: {
type: String,
default: ''
},
payAmount: {
type: [String, Number],
default: 3.5
},
readOnly: {
type: Boolean,
default: false
}
}
}
</script>
<style scoped lang="scss">
.division-test-step1 {
min-height: 280px;
display: flex;
align-items: center;
justify-content: center;
background: #f5f7fa;
border-radius: 8px;
padding: 24px;
}
.pay-qrcode-wrap {
text-align: center;
}
.pay-qrcode {
width: 200px;
height: 200px;
object-fit: contain;
display: block;
margin: 0 auto 16px;
background: #fff;
}
.pay-qrcode--loading {
min-height: 200px;
}
.pay-tip {
font-size: 14px;
color: #333;
margin: 0;
}
.order-linked {
font-size: 14px;
color: #333;
.retest-link {
margin-left: 8px;
padding: 0;
}
}
</style>
<template>
<div class="division-test-step2">
<div class="merchant-grid">
<div
v-for="(item, index) in merchants"
:key="merchantKey(item, index)"
class="merchant-grid-item"
>
<p class="merchant-name">
<span class="bullet">•</span>{{ item.merchantName }}
</p>
<div v-if="item.testCompleted" class="completed-tag">已完成测试</div>
<el-input
v-else
:value="item.displayDivisionMoney"
size="small"
disabled
placeholder="请输入分润金额"
/>
</div>
</div>
<p class="step2-hint">
设置待测试商户的分润金额<br>
说明:分润总金额必须等于3.5元,最后一个商户默认承担手续费
</p>
</div>
</template>
<script>
export default {
name: 'DivisionTestStep2Allocate',
props: {
merchants: {
type: Array,
default: () => []
}
},
methods: {
merchantKey(item, index) {
return item.merchantId ?? item.merchantName ?? index
}
}
}
</script>
<style scoped lang="scss">
.division-test-step2 {
background: #f5f7fa;
border-radius: 8px;
padding: 24px 32px 20px;
min-height: 280px;
}
.merchant-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px 40px;
max-width: 640px;
margin: 0 auto;
}
.merchant-grid-item {
.merchant-name {
margin: 0 0 8px;
font-size: 14px;
color: #333;
.bullet {
margin-right: 4px;
color: #666;
}
}
.completed-tag {
height: 32px;
line-height: 32px;
font-size: 14px;
color: #2b58ad;
padding-left: 8px;
}
}
.step2-hint {
text-align: center;
font-size: 12px;
color: #666;
line-height: 1.6;
margin: 24px 0 0;
}
</style>
<template>
<div class="division-test-step3">
<el-form ref="verifyForm" :model="form" :rules="rules" class="merchant-grid-form">
<div class="merchant-grid">
<el-form-item
v-for="(item, index) in form.testMerchantDivisions"
:key="merchantKey(item, index)"
:prop="'testMerchantDivisions.' + index + '.confirmDivisionMoney'"
:rules="item.testCompleted ? [] : amountRules"
class="merchant-grid-item"
>
<p class="merchant-name">
<span class="bullet">•</span>{{ item.merchantName }}
</p>
<div v-if="item.testCompleted" class="completed-tag">已完成测试</div>
<el-input
v-else
v-model="form.testMerchantDivisions[index].confirmDivisionMoney"
size="small"
placeholder="请输入到账金额"
:disabled="readOnly"
@input="onAmountInput($event, index)"
/>
</el-form-item>
</div>
</el-form>
<p class="step3-hint">次日分账成功后确认分账方到账金额</p>
</div>
</template>
<script>
/** 步骤3仅负责表单;提交由父组件 handleCompleteTest 调用 divisionRuleTest.money.valid */
import { limitPrice } from '@/common/format'
import { isValidAmountInput, mergeStep3FormMerchants } from '../../utils/validateStep3Amounts'
export default {
name: 'DivisionTestStep3Verify',
props: {
merchants: {
type: Array,
default: () => []
},
readOnly: {
type: Boolean,
default: false
}
},
data() {
return {
form: {
testMerchantDivisions: []
},
amountRules: [
{
required: true,
message: '请输入到账金额',
trigger: ['blur', 'change']
},
{
validator: (rule, value, callback) => {
if (!isValidAmountInput(value)) {
callback(new Error('请输入0-3.5的数字,最多两位小数'))
} else {
callback()
}
},
trigger: ['blur', 'change']
}
]
}
},
computed: {
rules() {
return {}
}
},
watch: {
merchants: {
immediate: true,
deep: true,
handler(list) {
this.form.testMerchantDivisions = mergeStep3FormMerchants(
list,
this.form.testMerchantDivisions
)
}
}
},
methods: {
merchantKey(item, index) {
return item.merchantId ?? item.merchantName ?? index
},
onAmountInput(val, index) {
this.form.testMerchantDivisions[index].confirmDivisionMoney = limitPrice(val, 0, 6, 2)
},
validate() {
return new Promise((resolve) => {
if (!this.$refs.verifyForm) {
resolve(false)
return
}
this.$refs.verifyForm.validate((valid) => resolve(valid))
})
},
getSubmitMerchants() {
return this.form.testMerchantDivisions
}
}
}
</script>
<style scoped lang="scss">
.division-test-step3 {
background: #f5f7fa;
border-radius: 8px;
padding: 24px 32px 20px;
min-height: 280px;
}
.merchant-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px 40px;
max-width: 640px;
margin: 0 auto;
}
.merchant-grid-item {
margin-bottom: 0;
::v-deep .el-form-item__content {
line-height: normal;
}
.merchant-name {
margin: 0 0 8px;
font-size: 14px;
color: #333;
.bullet {
margin-right: 4px;
color: #666;
}
}
.completed-tag {
height: 32px;
line-height: 32px;
font-size: 14px;
color: #2b58ad;
padding-left: 8px;
}
}
.step3-hint {
text-align: center;
font-size: 12px;
color: #666;
margin: 24px 0 0;
}
</style>
<template>
<div class="division-test-stepper">
<div class="stepper-track">
<template v-for="n in 3">
<button
:key="'node-' + n"
type="button"
class="stepper-node"
:class="'is-' + stepVisualState(n)"
@click="onStepClick(n)"
>
<i v-if="stepVisualState(n) === 'done'" class="el-icon-check stepper-check" />
<span v-else class="stepper-num">{{ n }}</span>
</button>
<div
v-if="n < 3"
:key="'line-' + n"
class="stepper-line"
:class="{ 'is-done': isConnectorDone(n) }"
/>
</template>
</div>
</div>
</template>
<script>
export default {
name: 'DivisionTestStepper',
props: {
maxReachedStep: {
type: Number,
default: 1
},
viewStep: {
type: Number,
default: 1
},
stepCompletedFlags: {
type: Array,
default: () => [false, false, false]
}
},
methods: {
/** done=蓝色勾 | current=蓝色序号 | wait=灰色序号 */
stepVisualState(stepNum) {
const idx = stepNum - 1
const completed =
!!this.stepCompletedFlags[idx] || stepNum < Number(this.viewStep)
if (completed) return 'done'
if (stepNum === Number(this.viewStep)) return 'current'
return 'wait'
},
/** 步骤 n 与 n+1 之间的连线:前序步骤已完成时为蓝色 */
isConnectorDone(stepNum) {
return this.stepVisualState(stepNum) === 'done'
},
onStepClick(stepNum) {
this.$emit('step-click', stepNum)
}
}
}
</script>
<style scoped lang="scss">
$step-primary: #2a58ad;
$step-wait-border: #dcdfe6;
$step-wait-text: #c0c4cc;
$step-line-wait: #dcdfe6;
.division-test-stepper {
margin-bottom: 24px;
padding: 0 40px;
}
.stepper-track {
display: flex;
align-items: center;
justify-content: center;
max-width: 360px;
margin: 0 auto;
}
.stepper-node {
flex-shrink: 0;
display: inline-flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
padding: 0;
border-radius: 50%;
border: 1px solid $step-wait-border;
background: #fff;
cursor: pointer;
outline: none;
cursor: pointer;
transition: border-color 0.2s, color 0.2s;
&:focus-visible {
box-shadow: 0 0 0 2px rgba($step-primary, 0.25);
}
&.is-done {
border-color: $step-primary;
color: $step-primary;
}
&.is-current {
border-color: $step-primary;
color: $step-primary;
}
&.is-wait {
border-color: $step-wait-border;
color: $step-wait-text;
}
}
.stepper-check {
font-size: 14px;
font-weight: 700;
line-height: 1;
}
.stepper-num {
font-size: 14px;
font-weight: 500;
line-height: 1;
}
.stepper-line {
flex: 1;
height: 1px;
min-width: 48px;
margin: 0 8px;
background: $step-line-wait;
transition: background-color 0.2s;
&.is-done {
background: $step-primary;
}
}
</style>
import { deepClone } from "@/common/util"
import {
getStableReconciliationRuleId,
mergeReconciliationRuleServerFields
} from "../../merchantStep/utils/reconciliationIncrementalRules"
/**
* 删 Tab 时收集待提交的 DELETE 快照(sessionAdded 的新 Tab 不产生 DELETE)。
*
* @param {object} params
* @param {object|null|undefined} params.removedRule
* @param {object|null|undefined} params.removedTabMeta
* @param {boolean} params.isSessionOnlyNew
* @returns {object|null}
*/
export function collectPendingDeleteForRemovedTab({
removedRule,
removedTabMeta,
isSessionOnlyNew
}) {
if (isSessionOnlyNew) return null
let rid =
removedRule && typeof removedRule === "object"
? getStableReconciliationRuleId(removedRule)
: ""
if (!rid && removedTabMeta) {
const gid = removedTabMeta.groupDivisionRuleId
if (gid != null && String(gid).trim() !== "") {
rid = String(gid).trim()
}
}
if (!rid) return null
const ruleSnapshot =
removedRule && typeof removedRule === "object"
? deepClone(removedRule)
: {}
delete ruleSnapshot.type
delete ruleSnapshot.tabPaneIndex
if (
ruleSnapshot.groupDivisionRuleId == null
|| String(ruleSnapshot.groupDivisionRuleId).trim() === ""
) {
ruleSnapshot.groupDivisionRuleId =
removedTabMeta && removedTabMeta.groupDivisionRuleId != null
? removedTabMeta.groupDivisionRuleId
: rid
}
return ruleSnapshot
}
/**
* splice 后按 oldIdx 从 prev 缓存 merge 服务端 id 字段。
*
* @param {Array<object>} goodsTypeGroupRules
* @param {number} tabIndex
* @param {Array<object>} prevGoodsTypeGroupRules
* @returns {Array<object>}
*/
export function mergeRemainingRulesAfterTabRemoval(
goodsTypeGroupRules,
tabIndex,
prevGoodsTypeGroupRules
) {
const remaining = goodsTypeGroupRules.slice()
remaining.splice(tabIndex, 1)
const prev = prevGoodsTypeGroupRules || []
for (let index = 0; index < remaining.length; index++) {
const oldIdx = index < tabIndex ? index : index + 1
const cachedForId = prev[oldIdx]
if (cachedForId) {
remaining[index] = mergeReconciliationRuleServerFields(
remaining[index],
cachedForId
)
}
}
return remaining
}
/**
* removeTab 核心纯逻辑:收集 pending DELETE + 剩余规则 id 合并。
*
* @param {object} params
* @returns {{ remainingRules: Array<object>, pendingDelete: object|null }}
*/
export function applyRemoveTabToGoodsTypeGroupRules({
goodsTypeGroupRules,
tabIndex,
prevGoodsTypeGroupRules,
removedRule,
removedTabMeta,
isSessionOnlyNew
}) {
const pendingDelete = collectPendingDeleteForRemovedTab({
removedRule,
removedTabMeta,
isSessionOnlyNew
})
const remainingRules = mergeRemainingRulesAfterTabRemoval(
goodsTypeGroupRules,
tabIndex,
prevGoodsTypeGroupRules
)
return { remainingRules, pendingDelete }
}
/**
* 删 Tab 后按 oldIdx 恢复 editableTabs meta(revision / touched / sessionAdded)。
*
* @param {Array<object>} prevTabsMeta
* @param {number} tabIndex
* @param {number} remainingCount
* @returns {Array<object>}
*/
export function mapTabMetaAfterTabRemoval(prevTabsMeta, tabIndex, remainingCount) {
const out = []
for (let index = 0; index < remainingCount; index++) {
const oldIdx = index < tabIndex ? index : index + 1
const meta = prevTabsMeta[oldIdx]
out.push({
sessionAdded: !!(meta && meta.sessionAdded),
ruleCacheRevision:
meta && meta.ruleCacheRevision != null ? Number(meta.ruleCacheRevision) : 0,
confirmedRuleCacheRevision:
meta && meta.confirmedRuleCacheRevision != null
? Number(meta.confirmedRuleCacheRevision)
: 0,
classificationUserTouched: !!(meta && meta.classificationUserTouched)
})
}
return out
}
/**
* 分账测试相关接口公共入参(使用财务详情 divisionRuleId,不再传 goodsTypeGroupDivisionId)
*/
export function buildDivisionRuleTestParams(ctx = {}) {
const {
merchantId,
sceneType,
paymentChannelId,
divisionRuleId,
baseSceneCode
} = ctx
const params = {}
if (merchantId != null && merchantId !== '') {
params.merchantId = merchantId
}
if (sceneType != null && sceneType !== '') {
params.sceneType = sceneType
}
if (paymentChannelId != null && paymentChannelId !== '') {
params.paymentChannelId = paymentChannelId
}
if (divisionRuleId != null && divisionRuleId !== '') {
params.divisionRuleId = divisionRuleId
}
if (baseSceneCode != null && baseSceneCode !== '') {
params.baseSceneCode = baseSceneCode
}
return params
}
/** divisionRuleTest.retest:仅 divisionRuleId + paymentChannelId */
export function buildDivisionRuleTestRetestParams(ctx = {}) {
const { divisionRuleId, paymentChannelId } = ctx
const params = {}
if (divisionRuleId != null && divisionRuleId !== '') {
params.divisionRuleId = divisionRuleId
}
if (paymentChannelId != null && paymentChannelId !== '') {
params.paymentChannelId = paymentChannelId
}
return params
}
/** divisionRuleTest.money.valid:divisionRuleId + paymentChannelId + testMerchantDivisions */
export function buildDivisionRuleTestMoneyValidParams({
testObj = {},
testMerchantDivisions,
divisionRuleId
} = {}) {
const params = {
testMerchantDivisions: testMerchantDivisions || []
}
if (divisionRuleId != null && divisionRuleId !== '') {
params.divisionRuleId = divisionRuleId
}
if (testObj.paymentChannelId != null && testObj.paymentChannelId !== '') {
params.paymentChannelId = testObj.paymentChannelId
}
return params
}
/** divisionRuleTest.updateMainProgress:divisionRuleId + paymentChannelId + progress(1|2|3) */
export function buildDivisionRuleTestUpdateMainProgressParams(ctx = {}) {
const { divisionRuleId, paymentChannelId, progress } = ctx
const params = {}
if (divisionRuleId != null && divisionRuleId !== '') {
params.divisionRuleId = divisionRuleId
}
if (paymentChannelId != null && paymentChannelId !== '') {
params.paymentChannelId = paymentChannelId
}
const p = Number(progress)
if (p >= 1 && p <= 3) {
params.progress = p
}
return params
}
import { deepClone } from "@/common/util"
import { fillDjGoodsTypeGroupRelations } from "../../merchantStep/utils/reconciliationShared"
/**
* 与 index.vue buildFullMergedGoodsTypeGroupRules 一致:冲突检测用全量规则视图。
*
* @param {object} params
* @param {number} params.tabCount editableTabs.length
* @param {Record<number, object>} [params.validatedByIndex]
* @param {Array<object>} [params.slotCaches] financialObj.goodsTypeGroupRules
* @returns {Array<object>}
*/
export function buildFullMergedGoodsTypeGroupRules({
tabCount,
validatedByIndex,
slotCaches
}) {
const n = tabCount
const out = []
const map = validatedByIndex || {}
const caches = slotCaches || []
for (let i = 0; i < n; i++) {
if (map[i]) {
out.push(map[i])
} else {
const cached = caches[i]
out.push(fillDjGoodsTypeGroupRelations(deepClone(cached || {})))
}
}
return out
}
import { sortDivisionTestMerchants, isPlatformMerchant } from './sortDivisionTestMerchants'
import { isMerchantCompletedFromDetail } from './validateStep3Amounts'
export const PLATFORM_FIXED_AMOUNT = 0.5
export const ALLOCATABLE_POOL = 3
export const TOTAL_PROFIT_AMOUNT = 3.5
/** distributionMoney 为 0、null、'' 表示已完成分账测试 */
export function isMerchantTestCompleted(item) {
if (!item) return false
if (item.testCompleted === true) return true
const v = item.distributionMoney
if (v == null || v === '') return true
const n = Number(v)
return Number.isFinite(n) && n === 0
}
function roundMoney(n) {
return Math.round(n * 100) / 100
}
function hasDistributionMoneyValue(item) {
const v = item?.distributionMoney
if (v == null || v === '') return false
const n = Number(v)
return Number.isFinite(n) && n !== 0
}
function hasPresetDivisionMoney(item) {
if (hasDistributionMoneyValue(item)) return true
const v = item.divisionMoney ?? item.testDivisionMoney ?? item.allocateDivisionMoney
return v != null && v !== ''
}
/**
* 对未完成测试的非平台商户随机分配 ALLOCATABLE_POOL 元,最后一户承担尾差。
* @param {object[]} pendingMerchants
* @param {() => number} [randomFn] 0-1,便于单测
*/
export function randomAllocatePool(pendingMerchants, randomFn = Math.random) {
const n = pendingMerchants.length
if (n === 0) return []
if (n === 1) return [ALLOCATABLE_POOL]
const weights = []
let sum = 0
for (let i = 0; i < n - 1; i++) {
const w = randomFn() + 0.01
weights.push(w)
sum += w
}
const amounts = []
let allocated = 0
for (let i = 0; i < n - 1; i++) {
const part = roundMoney((weights[i] / sum) * ALLOCATABLE_POOL)
amounts.push(part)
allocated += part
}
amounts.push(roundMoney(ALLOCATABLE_POOL - allocated))
return amounts
}
function resolveDisplayAmount(item, platform, cache, randomAmounts, pendingIdxRef) {
if (hasDistributionMoneyValue(item)) {
return String(item.distributionMoney)
}
if (platform) {
if (hasPresetDivisionMoney(item)) {
return String(
item.distributionMoney
?? item.divisionMoney
?? item.testDivisionMoney
?? PLATFORM_FIXED_AMOUNT
)
}
return String(PLATFORM_FIXED_AMOUNT)
}
if (hasPresetDivisionMoney(item)) {
return String(
item.distributionMoney
?? item.divisionMoney
?? item.testDivisionMoney
?? item.allocateDivisionMoney
)
}
const key = String(item.merchantId ?? item.merchantName ?? '')
if (cache[key] != null && cache[key] !== '') {
return String(cache[key])
}
const amount = randomAmounts[pendingIdxRef.idx] ?? 0
pendingIdxRef.idx += 1
return String(amount)
}
/**
* @param {object[]} testMerchantDivisions
* @param {{ randomFn?: () => number, cachedAllocations?: Record<string, string> }} [options]
* @returns {object[]} 带 displayDivisionMoney、testCompleted 的副本(已排序)
*/
export function buildStep2DisplayMerchants(testMerchantDivisions, options = {}) {
const sorted = sortDivisionTestMerchants(testMerchantDivisions || [])
const randomFn = options.randomFn || Math.random
const cache = options.cachedAllocations || {}
const pending = sorted.filter((m) => !isMerchantTestCompleted(m) && !isPlatformMerchant(m))
const randomAmounts = randomAllocatePool(pending, randomFn)
const pendingIdxRef = { idx: 0 }
return sorted.map((item) => {
const completed = isMerchantTestCompleted(item)
const platform = isPlatformMerchant(item)
const displayDivisionMoney = completed
? ''
: resolveDisplayAmount(item, platform, cache, randomAmounts, pendingIdxRef)
return {
...item,
testCompleted: completed,
displayDivisionMoney
}
})
}
/** 步骤 3:同一商户列表与完成态,保留 confirmDivisionMoney 供填写 */
export function buildStep3VerifyMerchants(testMerchantDivisions) {
const sorted = sortDivisionTestMerchants(testMerchantDivisions || [])
return sorted.map((m) => ({
...m,
testCompleted: isMerchantCompletedFromDetail(m),
confirmDivisionMoney: m.confirmDivisionMoney ?? ''
}))
}
export function sumDisplayDivisionMoney(merchants) {
return (merchants || []).reduce((sum, m) => {
if (m.testCompleted) return sum
const v = parseFloat(m.displayDivisionMoney)
return sum + (Number.isFinite(v) ? v : 0)
}, 0)
}
export function isTotalProfitAmountValid(merchants, total = TOTAL_PROFIT_AMOUNT) {
const sum = roundMoney(sumDisplayDivisionMoney(merchants))
return Math.abs(sum - total) < 0.001
}
export function buildWebSocketUrl(rawUrl, pageProtocol) {
if (!rawUrl || typeof rawUrl !== "string") return ""
let url = rawUrl.trim()
const secure =
pageProtocol != null
? pageProtocol === "https:"
: typeof window !== "undefined" && window.location.protocol === "https:"
if (/^wss?:\/\//i.test(url)) {
if (secure && /^ws:\/\//i.test(url)) {
return "wss://" + url.slice(5)
}
return url
}
const scheme = secure ? "wss://" : "ws://"
return scheme + url.replace(/^\/\//, "")
}
import { deepClone } from "@/common/util"
import { mergeChildClassificationPayload } from "./mergeClassificationPayload"
/**
* 与 index.vue getAllParams 一致:按 editableTabs 顺序收集 rules。
*
* @param {object} params
* @param {Array<object>} params.editableTabs
* @param {Array<object>|undefined} params.slotCaches financialObj.goodsTypeGroupRules
* @param {(paneName: string) => object|null|undefined} [params.getChildPayloadByPaneName]
* 激活 Tab 返回 getClassificationParams();未挂载返回 null/undefined
* @returns {Array<object>}
*/
export function collectGoodsTypeGroupRulesFromTabs({
editableTabs,
slotCaches,
getChildPayloadByPaneName
}) {
const list = deepClone(editableTabs)
const goodsTypeGroupRules = []
const caches = slotCaches || []
for (let index = 0; index < list.length; index++) {
const tabindex = editableTabs.findIndex(
(item) => item.name === list[index].name
)
const getPayload = getChildPayloadByPaneName
let payload = null
if (typeof getPayload === "function") {
try {
payload = getPayload(list[index].name)
} catch (e) {
payload = undefined
}
}
if (payload != null && typeof payload === "object") {
try {
const cached = caches[tabindex]
const { next } = mergeChildClassificationPayload(payload, cached)
goodsTypeGroupRules.push(next)
} catch (e) {
const cached = caches[tabindex]
goodsTypeGroupRules.push(cached ? deepClone(cached) : {})
}
} else {
const cached = caches[tabindex]
goodsTypeGroupRules.push(cached ? deepClone(cached) : {})
}
}
return goodsTypeGroupRules
}
/** autoFlag=Y 且 testFlag 严格为 N(未通过分账测试) */
export function isDivisionRuleAutoTestPending(item) {
return item && item.autoFlag == "Y" && item.testFlag == "N"
}
export function buildDivisionRuleAutosByChannelId(divisionRuleAutos) {
const map = {}
;(divisionRuleAutos || []).forEach((item) => {
if (item && item.paymentChannelId != null) {
map[item.paymentChannelId] = {
paymentChannelId: item.paymentChannelId,
autoFlag: item.autoFlag,
testFlag: item.testFlag
}
}
})
return map
}
/**
* 立即测试按钮:须已有 divisionRuleId,当前开启自动分账,且服务端(详情/保存回包)判定待测。
* 本地切换 autoFlag 不触发显示,避免后端尚未生成测算 id。
*/
export function shouldShowDivisionTestButton(
currentChannel,
serverChannelById,
divisionRuleId
) {
if (divisionRuleId == null || divisionRuleId === "") return false
if (!currentChannel || currentChannel.autoFlag != "Y") return false
const serverChannel =
serverChannelById && serverChannelById[currentChannel.paymentChannelId]
return isDivisionRuleAutoTestPending(serverChannel)
}
export function hasPendingDivisionRuleAutoTest(divisionRuleAutos) {
return (divisionRuleAutos || []).some(isDivisionRuleAutoTestPending)
}
export function findPendingDivisionRuleAutoTestIndices(divisionRuleAutos) {
return (divisionRuleAutos || [])
.map((item, index) => (isDivisionRuleAutoTestPending(item) ? index : -1))
.filter((i) => i >= 0)
}
/** 从 divisionRuleTest.get 的 divisionRuleTests 中匹配当前渠道 */
export function findDivisionRuleTestByChannelId(divisionRuleTests, paymentChannelId) {
if (!Array.isArray(divisionRuleTests) || paymentChannelId == null) return null
return (
divisionRuleTests.find(
(t) =>
t?.paymentChannelId == paymentChannelId
|| t?.divisionRuleTestItem?.paymentChannelId == paymentChannelId
) || null
)
}
/** subProgress 进行中:34 步骤1 / 35 已付款 / 36 已分账 / 31 失败(不驱动展示步骤) */
export const DIVISION_TEST_SUB_PROGRESS_IN_PROGRESS = [34, 35, 36, 31]
export function isDivisionTestInProgress(subProgress) {
const sp = Number(subProgress)
return DIVISION_TEST_SUB_PROGRESS_IN_PROGRESS.includes(sp)
}
export function isDivisionTestPassed(subProgress) {
const sp = Number(subProgress)
return sp > 0 && !isDivisionTestInProgress(sp)
}
function hasOutTradeNo(payload = {}) {
const v = payload.outTradeNo
return v != null && v !== ''
}
function isOrderPaidFromPayload(payload, sp) {
if (payload.orderPaid === true) return true
if (payload.paymentSuccess === true) return true
if (payload.payStatus === 1 || payload.payStatus === '1' || payload.payStatus === 'Y') {
return true
}
if (sp === 31 && hasOutTradeNo(payload)) return true
return sp >= 35
}
/**
* 仅从 subProgress / 支付状态解析业务态,不映射展示步骤
* @param {number|string} subProgress
* @param {{ orderPaid?: boolean, payStatus?: *, paymentSuccess?: boolean, outTradeNo?: string }} [payload]
*/
export function mapSubProgressToUi(subProgress, payload = {}) {
const sp = Number(subProgress)
const step1Paid = isOrderPaidFromPayload(payload, sp)
return {
step1Paid,
subProgress: sp,
isFailed: sp === 31
}
}
/** 步骤条完成态:[0]=步骤1已付款 [1]=步骤2已到达 [2]=步骤3失败标记(仅 max>=3 时) */
export function buildStepCompletedFlags(step1Paid, maxReachedStep, isFailed = false) {
const max = Number(maxReachedStep) || 1
return [
!!step1Paid,
max >= 2,
!!isFailed && max >= 3
]
}
/**
* @param {number} targetStep
* @param {{ maxReachedStep: number, step1Paid?: boolean }} uiState
*/
export function canNavigateToStep(targetStep, uiState) {
const step = Number(targetStep)
const max = Number(uiState.maxReachedStep) || 1
if (step < 1 || step > 3) return false
return step <= max
}
/**
* 回看已完成步骤时为只读
* @param {number} viewStep
* @param {{ maxReachedStep: number }} uiState
*/
export function isStepReadOnly(viewStep, uiState) {
const v = Number(viewStep)
const max = Number(uiState.maxReachedStep) || 1
return v < max
}
/**
* subProgress 决定可达的最大步骤
* @param {number|string} subProgress
* @param {number|string} [progress] 服务端主步骤 1/2/3
* @returns {number} 1 | 2 | 3
*/
export function resolveMaxReachedStepFromSubProgress(subProgress, progress) {
const sp = Number(subProgress) || 0
const mp = Number(progress) || 0
if (sp === 36) return 3
if (sp >= 35) return 2
if (sp === 31 && mp >= 1 && mp <= 3) return mp
return 1
}
/**
* 打开弹窗时决定初始展示步骤:优先 progress(1/2/3),无 progress 时回退 subProgress
* @param {number|string} subProgress
* @param {number|string} [progress] 服务端主步骤 1/2/3
* @returns {{ viewStep: number, maxReachedStep: number }}
*/
export function resolveInitialWizardSteps(subProgress, progress) {
const sp = Number(subProgress) || 0
const mp = Number(progress) || 0
let maxReachedStep = resolveMaxReachedStepFromSubProgress(sp, mp)
if (mp >= 1 && mp <= 3) {
maxReachedStep = Math.max(maxReachedStep, mp)
return { viewStep: mp, maxReachedStep }
}
if (sp === 36) {
return { viewStep: 3, maxReachedStep: 3 }
}
if (sp === 31 && maxReachedStep > 1) {
return { viewStep: maxReachedStep, maxReachedStep }
}
return { viewStep: 1, maxReachedStep }
}
export function isDivisionTestFailed(subProgress) {
return Number(subProgress) === 31
}
/**
* subProgress=31/36 等需按服务端 progress 恢复展示步骤
*/
export function shouldSyncWizardStepsFromProgress(subProgress) {
const sp = Number(subProgress)
return sp === 31 || sp === 36
}
/**
* 步骤1是否展示「关联测试订单」(而非二维码)
* @param {{ step1Paid?: boolean, subProgress?: number|string, outTradeNo?: string, maxReachedStep?: number, viewStep?: number }} params
*/
export function shouldShowStep1OrderLinked({
step1Paid = false,
subProgress = 0,
outTradeNo = '',
maxReachedStep = 1,
viewStep = 1
} = {}) {
if (step1Paid) return true
if (Number(subProgress) === 31 && outTradeNo) return true
if (Number(maxReachedStep) > 1 && Number(viewStep) === 1) return true
return false
}
/**
* 保证「全部品类」(groupType===1) 位于 goodsTypeGroupRules[0]。
*
* 旧逻辑在首条为特殊品类时 unshift 空壳 { groupType: 1 },若接口已在其它下标返回带 groupDivisionRuleId
* 的 groupType 1,会导致 Tab0 无 id、真实全部品类错位,提交时 type 误判为 ADD。
*
* @param {Array<object>|null|undefined} rules
* @returns {Array<object>}
*/
export function ensureAllCategoryRuleFirst(rules) {
let list = Array.isArray(rules) ? [...rules] : []
if (!list.length) {
return [{ groupType: 1 }]
}
const allIdx = list.findIndex((r) => r && r.groupType == 1)
if (allIdx > 0) {
const reordered = [...list]
const [allRule] = reordered.splice(allIdx, 1)
reordered.unshift(allRule)
return reordered
}
if (allIdx === 0) {
return list
}
if (list[0] && list[0].groupType == 2) {
return [{ groupType: 1 }, ...list]
}
return list
}
import { getStableReconciliationRuleId } from "../../merchantStep/utils/reconciliationIncrementalRules"
import { shouldIncludeReconciliationTabForProcess } from "../../merchantStep/utils/reconciliationSubmitTabGate"
import { reconciliationRulePayloadIsSubstantive } from "../../merchantStep/utils/validateReconciliationRulePayload"
import { financialRulePayloadDeepEqual } from "./rulePayloadCanonicalCompare"
import { prepareRuleForValidation } from "./validateGoodsTypeGroupRulePayload"
/**
* @param {Array<object>|null|undefined} baseline
* @param {number} ti
* @returns {boolean}
*/
export function financialBaselineHasSlotForTabIndex(baseline, ti) {
const prevRaw = Array.isArray(baseline) ? baseline[ti] : null
return !!(prevRaw && typeof prevRaw === "object")
}
/**
* @param {object|null|undefined} baselineRule
* @param {object|null|undefined} currentRule
* @returns {boolean}
*/
export function financialRulePayloadEqualsNormalized(baselineRule, currentRule) {
if (!baselineRule || typeof baselineRule !== "object") {
if (!currentRule || typeof currentRule !== "object") return true
return !reconciliationRulePayloadIsSubstantive(currentRule)
}
if (!currentRule || typeof currentRule !== "object") return true
const curNorm = prepareRuleForValidation(currentRule)
const prevNorm = prepareRuleForValidation(baselineRule)
return financialRulePayloadDeepEqual(curNorm, prevNorm)
}
/**
* 当前 Tab 槽位规则是否与进入页时的基线不一致。
*
* @param {Array<object>|null|undefined} baseline
* @param {number} ti
* @param {object|null|undefined} currentRule
* @returns {boolean}
*/
export function financialTabDiffersFromBaseline(baseline, ti, currentRule) {
if (!Array.isArray(baseline)) return false
const prevRaw = baseline[ti]
if (!prevRaw) {
if (!currentRule) return false
return reconciliationRulePayloadIsSubstantive(currentRule)
}
return !financialRulePayloadEqualsNormalized(prevRaw, currentRule)
}
/**
* 校验通过后的单条规则快照是否与进入页基线一致(用于收缩 goodsTypeGroupRules 增量)。
*
* @param {Array<object>|null|undefined} baseline
* @param {number} ti
* @param {object|null|undefined} snapshot
* @returns {boolean}
*/
export function financialSnapshotEqualsBaseline(baseline, ti, snapshot) {
if (!Array.isArray(baseline) || !snapshot || typeof snapshot !== "object") {
return false
}
const prevRaw = baseline[ti]
if (!prevRaw) {
if (!reconciliationRulePayloadIsSubstantive(snapshot)) return true
return false
}
return financialRulePayloadEqualsNormalized(prevRaw, snapshot)
}
/**
* 全量保存:与 merchantCheck indicesToProcess 同款语义。
* 仅 touched/sessionAdded 且与基线 diff(或无基线槽位)的 Tab 进入增量候选。
*
* @param {Array<object>} editableTabs
* @param {Array<object>|null|undefined} baseline
* @param {Array<object>|null|undefined} slotCaches financialObj.goodsTypeGroupRules
* @returns {number[]}
*/
export function resolveIndicesForFinancialIncrementalSubmit(
editableTabs,
baseline,
slotCaches
) {
const indices = []
const tabs = editableTabs || []
const caches = slotCaches || []
for (let i = 0; i < tabs.length; i++) {
const tab = tabs[i]
if (!tab || String(tab.name) === "add") continue
const differs = financialTabDiffersFromBaseline(baseline, i, caches[i])
const isSessionAdded = tab.sessionAdded === true
if (!differs && !isSessionAdded) continue
if (differs) {
if (
!shouldIncludeReconciliationTabForProcess({
hasBaselineSlot: financialBaselineHasSlotForTabIndex(baseline, i),
classificationUserTouched: tab.classificationUserTouched === true,
sessionAdded: isSessionAdded
})
) {
continue
}
}
indices.push(i)
}
return indices
}
/**
* 校验通过的 Tab 中,仅「快照与基线仍不一致」的进入提交(无基线时仅 sessionAdded 且 substantive)。
*
* @param {number[]} dirtyIndices
* @param {Record<number, object>} validatedByIndex
* @param {Array<object>|null|undefined} baseline
* @param {Array<object>} editableTabs
* @returns {number[]}
*/
export function filterFinancialIndicesToSubmitIncremental(
dirtyIndices,
validatedByIndex,
baseline,
editableTabs
) {
const tabs = editableTabs || []
return (dirtyIndices || []).filter((ti) => {
const rule = validatedByIndex[ti]
if (!rule || typeof rule !== "object") return false
if (!Array.isArray(baseline)) {
return (
tabs[ti]?.sessionAdded === true
&& reconciliationRulePayloadIsSubstantive(rule)
)
}
return !financialSnapshotEqualsBaseline(baseline, ti, rule)
})
}
...@@ -9,6 +9,25 @@ const GUARD_EMPTY_ARRAY_KEYS = [ ...@@ -9,6 +9,25 @@ const GUARD_EMPTY_ARRAY_KEYS = [
"packageGoods" "packageGoods"
] ]
/** 服务端主键/关联 id:子组件 getClassificationParams 不带,须从槽位缓存保留 */
const SERVER_ID_FIELDS = ["groupDivisionRuleId", "id", "groupSettleRuleId"]
function preserveServerIdFieldsFromBase(next, base, payload) {
for (let i = 0; i < SERVER_ID_FIELDS.length; i++) {
const key = SERVER_ID_FIELDS[i]
const fromPayload = payload[key]
const payloadHasValue =
Object.prototype.hasOwnProperty.call(payload, key)
&& fromPayload != null
&& String(fromPayload).trim() !== ""
if (payloadHasValue) continue
const fromBase = base[key]
if (fromBase != null && String(fromBase).trim() !== "") {
next[key] = fromBase
}
}
}
/** /**
* 将子组件 getClassificationParams() 的 payload 与槽位缓存合并为 next(与 index buildMerged 一致)。 * 将子组件 getClassificationParams() 的 payload 与槽位缓存合并为 next(与 index buildMerged 一致)。
* *
...@@ -53,5 +72,6 @@ export function mergeChildClassificationPayload(payload, prevStoredRaw) { ...@@ -53,5 +72,6 @@ export function mergeChildClassificationPayload(payload, prevStoredRaw) {
next[key] = b next[key] = b
} }
}) })
preserveServerIdFieldsFromBase(next, base, payload)
return { next, prevStored: prevStoredRaw } return { next, prevStored: prevStoredRaw }
} }
export function resolveDivisionRuleIdFromApi(payload) {
if (!payload || typeof payload !== "object") return undefined
const top = payload.divisionRuleId
if (top != null && top !== "") return top
const nested = payload.merchantSettleDistributeRule
if (nested && nested.divisionRuleId != null && nested.divisionRuleId !== "") {
return nested.divisionRuleId
}
return undefined
}
function findDivisionRuleTestChannelEntry(payload = {}) {
const channelId = payload.paymentChannelId
if (!Array.isArray(payload.divisionRuleTests) || !payload.divisionRuleTests.length) {
return null
}
return channelId != null
? payload.divisionRuleTests.find((t) => t && t.paymentChannelId == channelId)
: payload.divisionRuleTests[0]
}
/**
* 分账测试订单号:优先取 divisionRuleTests 项下 divisionRuleTestItem.orderCode
*/
export function resolveDivisionTestOrderCode(payload = {}) {
if (!payload || typeof payload !== 'object') return ''
const entry = findDivisionRuleTestChannelEntry(payload)
const fromList = entry?.divisionRuleTestItem?.orderCode
if (fromList != null && fromList !== '') {
return String(fromList)
}
const fromItem = payload.divisionRuleTestItem?.orderCode
if (fromItem != null && fromItem !== '') {
return String(fromItem)
}
if (payload.orderCode != null && payload.orderCode !== '') {
return String(payload.orderCode)
}
return ''
}
/**
* 分账测试支付流水号:优先取 divisionRuleTests 项下 divisionRuleTestItem.outTradeNo
*/
export function resolveDivisionTestOutTradeNo(payload = {}) {
if (!payload || typeof payload !== 'object') return ''
const entry = findDivisionRuleTestChannelEntry(payload)
const fromList = entry?.divisionRuleTestItem?.outTradeNo
if (fromList != null && fromList !== '') {
return String(fromList)
}
const fromItem = payload.divisionRuleTestItem?.outTradeNo
if (fromItem != null && fromItem !== '') {
return String(fromItem)
}
if (payload.outTradeNo != null && payload.outTradeNo !== '') {
return String(payload.outTradeNo)
}
return ''
}
/**
* 分账测试进度:优先取 divisionRuleTests 项下 divisionRuleTestItem.subProgress
*/
export function resolveDivisionTestSubProgress(payload = {}, fallback) {
if (!payload || typeof payload !== 'object') {
return fallback != null ? Number(fallback) || 0 : 0
}
const entry = findDivisionRuleTestChannelEntry(payload)
const fromList = entry?.divisionRuleTestItem?.subProgress ?? entry?.subProgress
if (fromList != null && fromList !== '') {
return Number(fromList) || 0
}
const fromItem = payload.divisionRuleTestItem?.subProgress
if (fromItem != null && fromItem !== '') {
return Number(fromItem) || 0
}
if (payload.subProgress != null && payload.subProgress !== '') {
return Number(payload.subProgress) || 0
}
if (fallback != null && fallback !== '') {
return Number(fallback) || 0
}
return 0
}
/**
* 主步骤 progress(1/2/3):与 subProgress 同源解析
*/
export function resolveDivisionTestProgress(payload = {}, fallback) {
if (!payload || typeof payload !== 'object') {
return fallback != null && fallback !== '' ? Number(fallback) || 0 : 0
}
const entry = findDivisionRuleTestChannelEntry(payload)
const fromList = entry?.divisionRuleTestItem?.progress ?? entry?.progress
if (fromList != null && fromList !== '') {
return Number(fromList) || 0
}
const fromItem = payload.divisionRuleTestItem?.progress
if (fromItem != null && fromItem !== '') {
return Number(fromItem) || 0
}
if (payload.progress != null && payload.progress !== '') {
return Number(payload.progress) || 0
}
if (fallback != null && fallback !== '') {
return Number(fallback) || 0
}
return 0
}
/**
* money.valid 用 goodsTypeGroupDivisionId:与 orderCode 同源解析
*/
export function resolveGoodsTypeGroupDivisionId(payload = {}) {
if (!payload || typeof payload !== 'object') return undefined
const entry = findDivisionRuleTestChannelEntry(payload)
const fromList = entry?.divisionRuleTestItem?.goodsTypeGroupDivisionId
if (fromList != null && fromList !== '') {
return fromList
}
const fromItem = payload.divisionRuleTestItem?.goodsTypeGroupDivisionId
if (fromItem != null && fromItem !== '') {
return fromItem
}
if (payload.goodsTypeGroupDivisionId != null && payload.goodsTypeGroupDivisionId !== '') {
return payload.goodsTypeGroupDivisionId
}
return undefined
}
/**
* 分账测试商户列表:优先取 divisionRuleTests 项下 divisionRuleTestItem.testMerchantDivisions
*/
export function resolveDivisionTestMerchantDivisions(payload = {}) {
if (!payload || typeof payload !== 'object') return []
const entry = findDivisionRuleTestChannelEntry(payload)
const fromList = entry?.divisionRuleTestItem?.testMerchantDivisions
if (Array.isArray(fromList) && fromList.length) {
return fromList
}
const fromItem = payload.divisionRuleTestItem?.testMerchantDivisions
if (Array.isArray(fromItem) && fromItem.length) {
return fromItem
}
if (Array.isArray(payload.testMerchantDivisions)) {
return payload.testMerchantDivisions
}
return []
}
/** 合并接口数据并写入规范化 orderCode、outTradeNo、subProgress、testMerchantDivisions */
export function normalizeDivisionTestPayload(payload = {}) {
const orderCode = resolveDivisionTestOrderCode(payload)
const outTradeNo = resolveDivisionTestOutTradeNo(payload)
const subProgress = resolveDivisionTestSubProgress(payload, payload.subProgress)
const progress = resolveDivisionTestProgress(payload, payload.progress)
const testMerchantDivisions = resolveDivisionTestMerchantDivisions(payload)
return {
...payload,
orderCode,
outTradeNo,
subProgress,
progress,
testMerchantDivisions
}
}
/**
* 与 index.vue getGoodsTypeGroupRules 全量提交路径一致:
* 仅 touched 或 sessionAdded 的 Tab 进入 indicesForIncremental。
*
* @param {Array<object>} editableTabs
* @returns {number[]}
*/
export function resolveIndicesForIncrementalSubmit(editableTabs) {
const indices = []
const tabs = editableTabs || []
for (let i = 0; i < tabs.length; i++) {
const tab = tabs[i]
if (
tab
&& String(tab.name) !== "add"
&& (tab.classificationUserTouched === true || tab.sessionAdded === true)
) {
indices.push(i)
}
}
return indices
}
/** testMerchantDivisions 展示顺序:targetMerchantType 3 → 2 → 1(4 与 1 同为平台方) */
const TARGET_MERCHANT_TYPE_DISPLAY_ORDER = { 3: 0, 2: 1, 1: 2, 4: 2 }
/**
* @param {object} item testMerchantDivisions 单项
* @returns {number} 越小越靠前
*/
export function getTargetMerchantTypeSortKey(item) {
if (item == null) return 99
const n = Number(item.targetMerchantType)
if (!Number.isFinite(n)) return 99
return TARGET_MERCHANT_TYPE_DISPLAY_ORDER[n] ?? 50
}
export function getMerchantTargetType(item) {
if (item == null) return 99
const tt = Number(item.targetType ?? item.merchantTargetType ?? item.applicationObjectType)
if (Number.isFinite(tt)) return tt
if (item.platformFlag === 'Y' || item.isPlatform === true) return 4
return 99
}
export function isPlatformMerchant(item) {
const tmt = Number(item?.targetMerchantType)
if (tmt === 1 || tmt === 4) return true
const tt = getMerchantTargetType(item)
return tt === 3 || tt === 4
}
/** 按 testMerchantDivisions[].targetMerchantType 顺序 3、2、1 展示;同类型按商户名 */
export function sortDivisionTestMerchants(list) {
if (!Array.isArray(list)) return []
return [...list].sort((a, b) => {
const oa = getTargetMerchantTypeSortKey(a)
const ob = getTargetMerchantTypeSortKey(b)
if (oa !== ob) return oa - ob
return (a.merchantName || '').localeCompare(b.merchantName || '', 'zh')
})
}
const MAX_AMOUNT = 3.5
/**
* 详情回显 distributionMoney 为 0 时视为已完成,不参与 money.valid 提交
*(用户输入 confirmDivisionMoney 为 0 的待确认商户仍应提交)
*/
export function isMerchantCompletedFromDetail(item) {
if (!item) return false
const v = item.distributionMoney
if (v == null || v === '') return false
const n = Number(v)
return Number.isFinite(n) && n === 0
}
/** 步骤3待提交商户(排除详情已为 0 的已完成商户) */
export function getStep3PendingMerchants(merchants) {
return (merchants || []).filter((m) => !isMerchantCompletedFromDetail(m))
}
export function isValidAmountInput(value) {
if (value === '' || value == null) return false
const s = String(value).trim()
if (!/^\d+(\.\d{1,2})?$/.test(s)) return false
const n = parseFloat(s)
return Number.isFinite(n) && n >= 0 && n <= MAX_AMOUNT
}
/**
* @param {object[]} merchants 步骤3表单行(含 confirmDivisionMoney)
* @returns {{ valid: boolean, message?: string }}
*/
export function validateStep3Amounts(merchants) {
const pending = getStep3PendingMerchants(merchants)
if (pending.length === 0) {
return { valid: false, message: '没有待确认到账的商户' }
}
for (const item of pending) {
const val = item.confirmDivisionMoney
if (!isValidAmountInput(val)) {
return { valid: false, message: '请填写正确的到账金额(0-3.5,最多两位小数)' }
}
}
return { valid: true }
}
function step3MerchantKey(item) {
return String(item?.merchantId ?? item?.merchantName ?? '')
}
/** 同步 props 商户列表时保留步骤3已填写的 confirmDivisionMoney */
export function mergeStep3FormMerchants(merchants, previousFormRows) {
const prevMap = new Map()
;(previousFormRows || []).forEach((m) => {
const key = step3MerchantKey(m)
if (key) prevMap.set(key, m.confirmDivisionMoney)
})
return (merchants || []).map((m) => {
const key = step3MerchantKey(m)
const prev = prevMap.get(key)
return {
...m,
confirmDivisionMoney: prev !== undefined ? prev : (m.confirmDivisionMoney ?? '')
}
})
}
export function buildStep3SubmitMerchants(displayMerchants, formMerchants) {
const formMap = new Map()
;(formMerchants || []).forEach((m) => {
const key = step3MerchantKey(m)
if (key) formMap.set(key, m)
})
return getStep3PendingMerchants(displayMerchants).map((m) => {
const key = step3MerchantKey(m)
const form = formMap.get(key) || m
return {
...m,
confirmDivisionMoney: form.confirmDivisionMoney
}
})
}
...@@ -33,6 +33,12 @@ export function mergeReconciliationRuleServerFields(snapshot, cachedRule) { ...@@ -33,6 +33,12 @@ export function mergeReconciliationRuleServerFields(snapshot, cachedRule) {
if (cachedRule.id != null && String(cachedRule.id).trim() !== "") { if (cachedRule.id != null && String(cachedRule.id).trim() !== "") {
out.id = cachedRule.id out.id = cachedRule.id
} }
if (
cachedRule.groupSettleRuleId != null
&& String(cachedRule.groupSettleRuleId).trim() !== ""
) {
out.groupSettleRuleId = cachedRule.groupSettleRuleId
}
return out return out
} }
......
# 真实脱敏 Fixture
将脱敏后的详情/提交 JSON 放在此目录,文件名建议:
- `detail-with-special.json` — 全部品类 + 多特殊品类详情响应
- `submit-after-delete-special.json` — 删光特殊品类后的 submit body
单测通过 `loadFixture(name)` 优先加载 `real/`,不存在则回退 `synthetic/`。
{
"goodsTypeGroupRules": [
{
"groupType": 1,
"groupDivisionRuleId": 17805,
"groupSettleRuleId": 17942,
"shop4sDeductChargeFlag": "Y",
"partnerDeductChargeFlag": "Y",
"goodsCostFlag": "N",
"expenseCategoryRules": [
{
"calculateMode": 1,
"expenseCategoryCalculateType": 1,
"expenseCategoryValue": "10"
}
],
"merchantDistributionRules": [{ "merchantId": "100" }],
"owningMerchantDistributionRules": [{ "merchantId": "100" }]
}
]
}
{
"goodsTypeGroupRules": [
{
"groupType": 1,
"groupDivisionRuleId": 17805,
"groupSettleRuleId": 17942,
"shop4sDeductChargeFlag": "Y",
"partnerDeductChargeFlag": "Y",
"goodsCostFlag": "N",
"expenseCategoryRules": [
{
"calculateMode": 1,
"expenseCategoryCalculateType": 1,
"expenseCategoryValue": "10"
}
],
"merchantDistributionRules": [{ "merchantId": "100" }],
"owningMerchantDistributionRules": [{ "merchantId": "100" }]
},
{
"groupType": 2,
"groupDivisionRuleId": 17806,
"groupSettleRuleId": 17943,
"goodsSource": 1,
"goodsTypeGroupRelations": [{ "goodsType": "G1" }],
"shop4sDeductChargeFlag": "Y",
"partnerDeductChargeFlag": "Y",
"goodsCostFlag": "N",
"expenseCategoryRules": [
{
"calculateMode": 1,
"expenseCategoryCalculateType": 1,
"expenseCategoryValue": "10"
}
],
"merchantDistributionRules": [{ "merchantId": "100" }],
"owningMerchantDistributionRules": [{ "merchantId": "100" }]
},
{
"groupType": 2,
"groupDivisionRuleId": 17808,
"groupSettleRuleId": 17944,
"goodsSource": 1,
"goodsTypeGroupRelations": [{ "goodsType": "G2" }],
"shop4sDeductChargeFlag": "Y",
"partnerDeductChargeFlag": "Y",
"goodsCostFlag": "N",
"expenseCategoryRules": [
{
"calculateMode": 1,
"expenseCategoryCalculateType": 1,
"expenseCategoryValue": "10"
}
],
"merchantDistributionRules": [{ "merchantId": "100" }],
"owningMerchantDistributionRules": [{ "merchantId": "100" }]
}
]
}
{
"description": "删光特殊品类 Tab 后期望的增量提交形态(合成)",
"incrementalRules": [
{
"groupType": 1,
"groupDivisionRuleId": "17805",
"groupSettleRuleId": 17942,
"type": "UPDATE",
"tabPaneIndex": 0
}
],
"pendingDeletes": [
{ "groupType": 2, "groupDivisionRuleId": "17806" },
{ "groupType": 2, "groupDivisionRuleId": "17808" }
],
"mergedSubmitExpectation": {
"firstEntryType": "UPDATE",
"firstEntryId": "17805",
"deleteIds": ["17806", "17808"]
}
}
import {
appendDeleteOpsToIncremental
} from "@/views/systemConfig/merchant/financialRules/utils/buildGoodsTypeGroupIncrementalRules"
import { GOODS_TYPE_GROUP_RULE_OP } from "@/views/systemConfig/merchant/financialRules/utils/goodsTypeGroupRuleOpType"
describe("appendDeleteOpsToIncremental", () => {
test("空 deletedEntries → 原样返回", () => {
const base = [{ type: GOODS_TYPE_GROUP_RULE_OP.UPDATE, groupDivisionRuleId: "17805" }]
expect(appendDeleteOpsToIncremental(base, null)).toEqual(base)
expect(appendDeleteOpsToIncremental(base, [])).toEqual(base)
})
test("追加 DELETE(字符串 id)", () => {
const base = [{ type: GOODS_TYPE_GROUP_RULE_OP.UPDATE, groupDivisionRuleId: "17805" }]
const out = appendDeleteOpsToIncremental(base, ["17806"])
expect(out).toHaveLength(2)
expect(out[1]).toEqual({
type: GOODS_TYPE_GROUP_RULE_OP.DELETE,
groupDivisionRuleId: "17806"
})
})
test("追加 DELETE(完整规则对象)", () => {
const base = [{ type: GOODS_TYPE_GROUP_RULE_OP.UPDATE, groupDivisionRuleId: "17805" }]
const out = appendDeleteOpsToIncremental(base, [
{ groupType: 2, groupDivisionRuleId: 17808, groupSettleRuleId: 17944 }
])
expect(out[1].type).toBe(GOODS_TYPE_GROUP_RULE_OP.DELETE)
expect(out[1].groupDivisionRuleId).toBe("17808")
expect(out[1].groupType).toBe(2)
expect(out[1].groupSettleRuleId).toBe(17944)
expect(out[1].tabPaneIndex).toBeUndefined()
})
test("deletedEntries 内重复 id → 去重", () => {
const out = appendDeleteOpsToIncremental([], ["17806", "17806", 17806])
expect(out).toHaveLength(1)
expect(out[0].groupDivisionRuleId).toBe("17806")
})
test("与 incremental 已有 DELETE 重复 → 跳过", () => {
const base = [
{ type: GOODS_TYPE_GROUP_RULE_OP.DELETE, groupDivisionRuleId: "17806" }
]
const out = appendDeleteOpsToIncremental(base, ["17806", "17808"])
expect(out).toHaveLength(2)
expect(out[1].groupDivisionRuleId).toBe("17808")
})
test("无 id 的对象 entry → 不产出 DELETE", () => {
const out = appendDeleteOpsToIncremental([], [{ groupType: 2, sessionAdded: true }])
expect(out).toHaveLength(0)
})
test("id 字段 fallback", () => {
const out = appendDeleteOpsToIncremental([], [{ id: "99", groupType: 2 }])
expect(out[0].groupDivisionRuleId).toBe("99")
})
})
import {
buildDivisionRuleTestParams,
buildDivisionRuleTestRetestParams,
buildDivisionRuleTestMoneyValidParams,
buildDivisionRuleTestUpdateMainProgressParams
} from "@/views/systemConfig/merchant/financialRules/utils/buildDivisionRuleTestParams"
describe("buildDivisionRuleTestParams", () => {
it("includes divisionRuleId from financial detail, not goodsTypeGroupDivisionId", () => {
const params = buildDivisionRuleTestParams({
merchantId: "m1",
sceneType: 1,
paymentChannelId: "ch1",
divisionRuleId: 4928,
baseSceneCode: "SC001"
})
expect(params).toEqual({
merchantId: "m1",
sceneType: 1,
paymentChannelId: "ch1",
divisionRuleId: 4928,
baseSceneCode: "SC001"
})
expect(params.goodsTypeGroupDivisionId).toBeUndefined()
})
it("omits empty divisionRuleId", () => {
const params = buildDivisionRuleTestParams({
merchantId: "m1",
sceneType: 1,
divisionRuleId: ""
})
expect(params.divisionRuleId).toBeUndefined()
})
it("buildDivisionRuleTestRetestParams only divisionRuleId and paymentChannelId", () => {
const params = buildDivisionRuleTestRetestParams({
divisionRuleId: 4928,
paymentChannelId: "ch1",
merchantId: "m1",
sceneType: 1
})
expect(params).toEqual({
divisionRuleId: 4928,
paymentChannelId: "ch1"
})
})
it("buildDivisionRuleTestMoneyValidParams requires explicit divisionRuleId", () => {
const testMerchantDivisions = [
{ merchantId: "m1", distributionMoney: "1.0", confirmDivisionMoney: "1.0" }
]
const params = buildDivisionRuleTestMoneyValidParams({
testObj: { paymentChannelId: "ch1", divisionRuleId: 100 },
testMerchantDivisions
})
expect(params.divisionRuleId).toBeUndefined()
expect(params.paymentChannelId).toBe("ch1")
expect(params.testMerchantDivisions).toEqual(testMerchantDivisions)
})
it("buildDivisionRuleTestMoneyValidParams uses explicit divisionRuleId and paymentChannelId", () => {
const testMerchantDivisions = [
{ merchantId: "m1", distributionMoney: "1.0", confirmDivisionMoney: "1.0" }
]
const params = buildDivisionRuleTestMoneyValidParams({
testObj: { paymentChannelId: "ch2" },
testMerchantDivisions,
divisionRuleId: 4928
})
expect(params).toEqual({
divisionRuleId: 4928,
paymentChannelId: "ch2",
testMerchantDivisions
})
expect(params.goodsTypeGroupDivisionId).toBeUndefined()
})
it("buildDivisionRuleTestUpdateMainProgressParams three fields", () => {
const params = buildDivisionRuleTestUpdateMainProgressParams({
divisionRuleId: 4928,
paymentChannelId: "ch1",
progress: 2
})
expect(params).toEqual({
divisionRuleId: 4928,
paymentChannelId: "ch1",
progress: 2
})
})
it("buildDivisionRuleTestUpdateMainProgressParams omits invalid progress", () => {
const params = buildDivisionRuleTestUpdateMainProgressParams({
divisionRuleId: 1,
paymentChannelId: "ch1",
progress: 0
})
expect(params.progress).toBeUndefined()
})
})
/**
* @jest-environment jsdom
*/
import { buildFullMergedGoodsTypeGroupRules } from "@/views/systemConfig/merchant/financialRules/utils/buildFullMergedGoodsTypeGroupRules"
import { loadFixture } from "./helpers/financialRulesTestHelpers"
describe("buildFullMergedGoodsTypeGroupRules", () => {
test("validated 槽位用快照,其余用缓存 fillDj", () => {
const fixture = loadFixture("all-plus-special-tabs")
const caches = fixture.goodsTypeGroupRules
const validated = { 1: { groupType: 2, groupDivisionRuleId: "validated-only" } }
const out = buildFullMergedGoodsTypeGroupRules({
tabCount: 3,
validatedByIndex: validated,
slotCaches: caches
})
expect(out).toHaveLength(3)
expect(out[0].groupDivisionRuleId).toBe(17805)
expect(out[1].groupDivisionRuleId).toBe("validated-only")
expect(out[2].groupDivisionRuleId).toBe(17808)
})
test("空缓存槽位 → fillDj 空对象", () => {
const out = buildFullMergedGoodsTypeGroupRules({
tabCount: 1,
validatedByIndex: {},
slotCaches: []
})
expect(out).toHaveLength(1)
expect(out[0]).toEqual({})
})
})
import {
buildStep2DisplayMerchants,
buildStep3VerifyMerchants,
isMerchantTestCompleted,
randomAllocatePool,
sumDisplayDivisionMoney,
isTotalProfitAmountValid,
PLATFORM_FIXED_AMOUNT,
ALLOCATABLE_POOL
} from "@/views/systemConfig/merchant/financialRules/utils/buildStep2DisplayMerchants"
describe("buildStep2DisplayMerchants", () => {
it("randomAllocatePool sums to 3", () => {
const amounts = randomAllocatePool(
[{}, {}, {}],
() => 0.5
)
const sum = amounts.reduce((a, b) => a + b, 0)
expect(Math.round(sum * 100)).toBe(Math.round(ALLOCATABLE_POOL * 100))
})
it("shows distributionMoney in step2 input", () => {
const list = [
{ merchantName: "流量", targetType: 1, distributionMoney: "2.5" },
{ merchantName: "平台", targetType: 4, distributionMoney: "0.5" }
]
const display = buildStep2DisplayMerchants(list)
expect(display.find((m) => m.merchantName === "流量").displayDivisionMoney).toBe("2.5")
expect(display.find((m) => m.merchantName === "平台").displayDivisionMoney).toBe("0.5")
})
it("distributionMoney 0 or empty means testCompleted", () => {
expect(isMerchantTestCompleted({ distributionMoney: 0 })).toBe(true)
expect(isMerchantTestCompleted({ distributionMoney: "0" })).toBe(true)
expect(isMerchantTestCompleted({ distributionMoney: "" })).toBe(true)
expect(isMerchantTestCompleted({ distributionMoney: null })).toBe(true)
expect(isMerchantTestCompleted({ distributionMoney: "1.5" })).toBe(false)
const display = buildStep2DisplayMerchants([
{ merchantName: "已测", targetType: 2, distributionMoney: 0 },
{ merchantName: "待测", targetType: 1, distributionMoney: "3" }
])
expect(display.find((m) => m.merchantName === "已测").testCompleted).toBe(true)
expect(display.find((m) => m.merchantName === "已测").displayDivisionMoney).toBe("")
expect(display.find((m) => m.merchantName === "待测").testCompleted).toBe(false)
expect(display.find((m) => m.merchantName === "待测").displayDivisionMoney).toBe("3")
})
it("platform fallback when no distributionMoney", () => {
const list = [
{ merchantName: "流量", targetType: 1, distributionMoney: "3" },
{ merchantName: "平台", targetType: 4, distributionMoney: "0.5" }
]
const display = buildStep2DisplayMerchants(list, { randomFn: () => 1 })
expect(display.find((m) => m.merchantName === "平台").displayDivisionMoney).toBe("0.5")
})
it("isTotalProfitAmountValid excludes completed merchants", () => {
const merchants = [
{ testCompleted: true, displayDivisionMoney: "" },
{ testCompleted: false, displayDivisionMoney: "0.5" },
{ testCompleted: false, displayDivisionMoney: "3" }
]
expect(isTotalProfitAmountValid(merchants)).toBe(true)
expect(sumDisplayDivisionMoney(merchants)).toBe(3.5)
})
it("uses cache when distributionMoney missing on refetch", () => {
const list = [
{ merchantId: "1", merchantName: "A", targetType: 1, distributionMoney: "3" }
]
const first = buildStep2DisplayMerchants(list)
const cache = { 1: first[0].displayDivisionMoney }
const second = buildStep2DisplayMerchants(
[{ merchantId: "1", merchantName: "A", targetType: 1, distributionMoney: "3" }],
{ randomFn: () => 0.9, cachedAllocations: cache }
)
expect(second[0].displayDivisionMoney).toBe("3")
})
it("buildStep3VerifyMerchants shares testCompleted", () => {
const list = [
{ merchantName: "A", distributionMoney: 0 },
{ merchantName: "B", distributionMoney: "1.2", confirmDivisionMoney: "1.2" }
]
const step3 = buildStep3VerifyMerchants(list)
expect(step3[0].testCompleted).toBe(true)
expect(step3[1].testCompleted).toBe(false)
expect(step3[1].confirmDivisionMoney).toBe("1.2")
})
})
import { buildWebSocketUrl } from "@/views/systemConfig/merchant/financialRules/utils/buildWebSocketUrl"
describe("buildWebSocketUrl", () => {
it("uses wss on https pages for host-only url", () => {
expect(buildWebSocketUrl("host/path?query", "https:")).toBe(
"wss://host/path?query"
)
})
it("uses ws on http pages for host-only url", () => {
expect(buildWebSocketUrl("host/path", "http:")).toBe("ws://host/path")
})
it("upgrades ws:// to wss:// on https pages", () => {
expect(buildWebSocketUrl("ws://host/path", "https:")).toBe("wss://host/path")
})
it("keeps wss:// on https pages", () => {
expect(buildWebSocketUrl("wss://host/path", "https:")).toBe("wss://host/path")
})
it("returns empty string for invalid input", () => {
expect(buildWebSocketUrl("", "https:")).toBe("")
expect(buildWebSocketUrl(null, "https:")).toBe("")
})
it("strips leading // before adding scheme", () => {
expect(buildWebSocketUrl("//host/path", "http:")).toBe("ws://host/path")
})
})
/**
* @jest-environment jsdom
*/
import { collectGoodsTypeGroupRulesFromTabs } from "@/views/systemConfig/merchant/financialRules/utils/collectGoodsTypeGroupRulesFromTabs"
describe("collectGoodsTypeGroupRulesFromTabs", () => {
test("激活 Tab 走 mergeChildClassificationPayload", () => {
const caches = [
{ groupType: 1, groupDivisionRuleId: 17805, expenseCategoryRules: [{ id: 1 }] }
]
const tabs = [{ name: "1", title: "全部品类" }]
const out = collectGoodsTypeGroupRulesFromTabs({
editableTabs: tabs,
slotCaches: caches,
getChildPayloadByPaneName: () => ({ groupType: 1, expenseCategoryRules: [{ id: 1 }] })
})
expect(out[0].groupDivisionRuleId).toBe(17805)
})
test("非激活 Tab 读缓存", () => {
const caches = [
{ groupType: 1, groupDivisionRuleId: 17805 },
{ groupType: 2, groupDivisionRuleId: 17806 }
]
const tabs = [{ name: "1" }, { name: "2" }]
const out = collectGoodsTypeGroupRulesFromTabs({
editableTabs: tabs,
slotCaches: caches,
getChildPayloadByPaneName: (name) => (name === "1" ? { groupType: 1 } : null)
})
expect(out[1].groupDivisionRuleId).toBe(17806)
expect(out[1].groupType).toBe(2)
})
})
import {
isDivisionRuleAutoTestPending,
hasPendingDivisionRuleAutoTest,
findPendingDivisionRuleAutoTestIndices,
findDivisionRuleTestByChannelId,
buildDivisionRuleAutosByChannelId,
shouldShowDivisionTestButton
} from "@/views/systemConfig/merchant/financialRules/utils/divisionRuleAutoTest"
describe("divisionRuleAutoTest", () => {
it("isDivisionRuleAutoTestPending: strict testFlag N and autoFlag Y", () => {
expect(
isDivisionRuleAutoTestPending({ autoFlag: "Y", testFlag: "N" })
).toBe(true)
expect(
isDivisionRuleAutoTestPending({ autoFlag: "Y", testFlag: "Y" })
).toBe(false)
expect(
isDivisionRuleAutoTestPending({ autoFlag: "Y" })
).toBe(false)
expect(
isDivisionRuleAutoTestPending({ autoFlag: "N", testFlag: "N" })
).toBe(false)
})
it("hasPendingDivisionRuleAutoTest", () => {
const list = [
{ autoFlag: "Y", testFlag: "Y" },
{ autoFlag: "Y", testFlag: "N" }
]
expect(hasPendingDivisionRuleAutoTest(list)).toBe(true)
expect(hasPendingDivisionRuleAutoTest([{ autoFlag: "Y", testFlag: "Y" }])).toBe(false)
})
it("findPendingDivisionRuleAutoTestIndices", () => {
const list = [
{ autoFlag: "N", testFlag: "N" },
{ autoFlag: "Y", testFlag: "N" },
{ autoFlag: "Y", testFlag: "Y" }
]
expect(findPendingDivisionRuleAutoTestIndices(list)).toEqual([1])
})
it("findDivisionRuleTestByChannelId matches paymentChannelId", () => {
const tests = [
{ paymentChannelId: "ch1", divisionRuleTestItem: { orderCode: "A" } },
{
paymentChannelId: "ch2",
divisionRuleTestItem: { paymentChannelId: "ch2", orderCode: "B" }
}
]
expect(findDivisionRuleTestByChannelId(tests, "ch2").divisionRuleTestItem.orderCode).toBe("B")
expect(findDivisionRuleTestByChannelId(tests, "ch9")).toBe(null)
})
it("buildDivisionRuleAutosByChannelId", () => {
const map = buildDivisionRuleAutosByChannelId([
{ paymentChannelId: 1, autoFlag: "Y", testFlag: "N" },
{ paymentChannelId: 2, autoFlag: "N", testFlag: "N" }
])
expect(map[1]).toEqual({ paymentChannelId: 1, autoFlag: "Y", testFlag: "N" })
expect(map[2].autoFlag).toBe("N")
})
it("buildDivisionRuleAutosByChannelId: snapshot isolated from local autoFlag toggle", () => {
const channel = { paymentChannelId: 10, autoFlag: "N", testFlag: "N" }
const map = buildDivisionRuleAutosByChannelId([channel])
channel.autoFlag = "Y"
expect(map[10].autoFlag).toBe("N")
expect(
shouldShowDivisionTestButton(channel, map, "rule-1")
).toBe(false)
})
it("shouldShowDivisionTestButton: server pending and local auto on", () => {
const serverMap = buildDivisionRuleAutosByChannelId([
{ paymentChannelId: 10, autoFlag: "Y", testFlag: "N" }
])
expect(
shouldShowDivisionTestButton(
{ paymentChannelId: 10, autoFlag: "Y", testFlag: "N" },
serverMap,
"rule-1"
)
).toBe(true)
})
it("shouldShowDivisionTestButton: local auto on without server pending stays hidden", () => {
const serverMap = buildDivisionRuleAutosByChannelId([
{ paymentChannelId: 10, autoFlag: "N", testFlag: "N" }
])
expect(
shouldShowDivisionTestButton(
{ paymentChannelId: 10, autoFlag: "Y", testFlag: "N" },
serverMap,
"rule-1"
)
).toBe(false)
})
it("shouldShowDivisionTestButton: no divisionRuleId", () => {
const serverMap = buildDivisionRuleAutosByChannelId([
{ paymentChannelId: 10, autoFlag: "Y", testFlag: "N" }
])
expect(
shouldShowDivisionTestButton(
{ paymentChannelId: 10, autoFlag: "Y", testFlag: "N" },
serverMap,
undefined
)
).toBe(false)
})
it("shouldShowDivisionTestButton: local auto off hides even if server pending", () => {
const serverMap = buildDivisionRuleAutosByChannelId([
{ paymentChannelId: 10, autoFlag: "Y", testFlag: "N" }
])
expect(
shouldShowDivisionTestButton(
{ paymentChannelId: 10, autoFlag: "N", testFlag: "N" },
serverMap,
"rule-1"
)
).toBe(false)
})
})
import {
mapSubProgressToUi,
isDivisionTestInProgress,
isDivisionTestPassed,
canNavigateToStep,
isStepReadOnly,
buildStepCompletedFlags,
resolveMaxReachedStepFromSubProgress,
resolveInitialWizardSteps,
shouldShowStep1OrderLinked,
isDivisionTestFailed,
shouldSyncWizardStepsFromProgress
} from "@/views/systemConfig/merchant/financialRules/utils/divisionTestStepProgress"
describe("divisionTestStepProgress", () => {
it("isDivisionTestInProgress", () => {
expect(isDivisionTestInProgress(34)).toBe(true)
expect(isDivisionTestInProgress(35)).toBe(true)
expect(isDivisionTestInProgress(36)).toBe(true)
expect(isDivisionTestInProgress(31)).toBe(true)
expect(isDivisionTestInProgress(30)).toBe(false)
})
it("isDivisionTestPassed", () => {
expect(isDivisionTestPassed(37)).toBe(true)
expect(isDivisionTestPassed(34)).toBe(false)
})
it("mapSubProgressToUi: 34 unpaid", () => {
const ui = mapSubProgressToUi(34, { orderCode: "" })
expect(ui.step1Paid).toBe(false)
expect(ui.currentStep).toBeUndefined()
})
it("mapSubProgressToUi: 35 paid but no display step mapping", () => {
const ui = mapSubProgressToUi(35, { orderCode: "ORD001" })
expect(ui.step1Paid).toBe(true)
expect(ui.currentStep).toBeUndefined()
})
it("mapSubProgressToUi: 31 with outTradeNo treated as paid", () => {
const ui = mapSubProgressToUi(31, { outTradeNo: "OUT001" })
expect(ui.step1Paid).toBe(true)
expect(ui.isFailed).toBe(true)
})
it("mapSubProgressToUi: 31 without outTradeNo unpaid failed", () => {
const ui = mapSubProgressToUi(31, {})
expect(ui.step1Paid).toBe(false)
expect(ui.isFailed).toBe(true)
})
it("shouldShowStep1OrderLinked: 31 with outTradeNo", () => {
expect(
shouldShowStep1OrderLinked({
subProgress: 31,
outTradeNo: "OUT001"
})
).toBe(true)
})
it("shouldShowStep1OrderLinked: maxReachedStep>1 back to step1", () => {
expect(
shouldShowStep1OrderLinked({
step1Paid: false,
maxReachedStep: 3,
viewStep: 1
})
).toBe(true)
})
it("shouldShowStep1OrderLinked: 34 unpaid on step1", () => {
expect(
shouldShowStep1OrderLinked({
step1Paid: false,
subProgress: 34,
maxReachedStep: 1,
viewStep: 1
})
).toBe(false)
})
it("isDivisionTestFailed", () => {
expect(isDivisionTestFailed(31)).toBe(true)
expect(isDivisionTestFailed(34)).toBe(false)
})
it("canNavigateToStep uses maxReachedStep only", () => {
expect(canNavigateToStep(2, { maxReachedStep: 1, step1Paid: true })).toBe(false)
expect(canNavigateToStep(2, { maxReachedStep: 2 })).toBe(true)
expect(canNavigateToStep(3, { maxReachedStep: 2 })).toBe(false)
})
it("isStepReadOnly when viewing earlier step", () => {
expect(isStepReadOnly(1, { maxReachedStep: 2 })).toBe(true)
expect(isStepReadOnly(2, { maxReachedStep: 2 })).toBe(false)
})
it("buildStepCompletedFlags", () => {
expect(buildStepCompletedFlags(true, 2)).toEqual([true, true, false])
expect(buildStepCompletedFlags(true, 3)).toEqual([true, true, false])
expect(buildStepCompletedFlags(true, 3, true)).toEqual([true, true, true])
expect(buildStepCompletedFlags(true, 2, true)).toEqual([true, true, false])
})
it("resolveMaxReachedStepFromSubProgress", () => {
expect(resolveMaxReachedStepFromSubProgress(34)).toBe(1)
expect(resolveMaxReachedStepFromSubProgress(35)).toBe(2)
expect(resolveMaxReachedStepFromSubProgress(36)).toBe(3)
expect(resolveMaxReachedStepFromSubProgress(31, 3)).toBe(3)
expect(resolveMaxReachedStepFromSubProgress(31, 2)).toBe(2)
expect(resolveMaxReachedStepFromSubProgress(31, 1)).toBe(1)
})
it("resolveInitialWizardSteps: 31 with progress opens matching step", () => {
expect(resolveInitialWizardSteps(31, 3)).toEqual({ viewStep: 3, maxReachedStep: 3 })
expect(resolveInitialWizardSteps(31, 2)).toEqual({ viewStep: 2, maxReachedStep: 2 })
expect(resolveInitialWizardSteps(31, 1)).toEqual({ viewStep: 1, maxReachedStep: 1 })
})
it("shouldSyncWizardStepsFromProgress", () => {
expect(shouldSyncWizardStepsFromProgress(31)).toBe(true)
expect(shouldSyncWizardStepsFromProgress(36)).toBe(true)
expect(shouldSyncWizardStepsFromProgress(34)).toBe(false)
})
it("resolveInitialWizardSteps: progress takes priority over subProgress", () => {
expect(resolveInitialWizardSteps(35, 3)).toEqual({ viewStep: 3, maxReachedStep: 3 })
expect(resolveInitialWizardSteps(34, 3)).toEqual({ viewStep: 3, maxReachedStep: 3 })
expect(resolveInitialWizardSteps(36, 1)).toEqual({ viewStep: 1, maxReachedStep: 3 })
})
it("resolveInitialWizardSteps: 36 without progress falls back to step3", () => {
expect(resolveInitialWizardSteps(36)).toEqual({ viewStep: 3, maxReachedStep: 3 })
})
it("resolveInitialWizardSteps: 35 without progress defaults step1", () => {
expect(resolveInitialWizardSteps(35)).toEqual({ viewStep: 1, maxReachedStep: 2 })
expect(resolveInitialWizardSteps(35, 2)).toEqual({ viewStep: 2, maxReachedStep: 2 })
})
it("resolveInitialWizardSteps: 34 without progress stays step1", () => {
expect(resolveInitialWizardSteps(34)).toEqual({ viewStep: 1, maxReachedStep: 1 })
})
})
/**
* @jest-environment jsdom
*/
import {
filterFinancialIndicesToSubmitIncremental,
financialSnapshotEqualsBaseline,
financialTabDiffersFromBaseline,
resolveIndicesForFinancialIncrementalSubmit
} from "@/views/systemConfig/merchant/financialRules/utils/financialRulesIncrementalGate"
import { buildGoodsTypeGroupIncrementalRules } from "@/views/systemConfig/merchant/financialRules/utils/buildGoodsTypeGroupIncrementalRules"
import { GOODS_TYPE_GROUP_RULE_OP } from "@/views/systemConfig/merchant/financialRules/utils/goodsTypeGroupRuleOpType"
const baselineRule = {
groupType: 1,
groupDivisionRuleId: "17805",
expenseCategoryRules: [
{
expenseCategoryId: 1,
expenseCategoryCalculateType: 1,
expenseCategoryValue: "10",
children: []
}
],
merchantDistributionRules: [{ merchantId: 1, merchantName: "平台" }],
owningMerchantDistributionRules: [{ merchantId: 2, merchantName: "流量" }]
}
function makeTabs(overrides = {}) {
return [
{
name: "1",
classificationUserTouched: false,
sessionAdded: false,
...overrides
}
]
}
describe("resolveIndicesForFinancialIncrementalSubmit", () => {
test("无 touched、无 diff → 空数组", () => {
const baseline = [baselineRule]
const caches = [baselineRule]
expect(
resolveIndicesForFinancialIncrementalSubmit(makeTabs(), baseline, caches)
).toEqual([])
})
test("有基线槽位、diff 但无 touched/sessionAdded:不进入(挡无操作假脏)", () => {
const baseline = [baselineRule]
const caches = [
{
...baselineRule,
expenseCategoryRules: [
{
expenseCategoryId: 1,
expenseCategoryCalculateType: 1,
expenseCategoryValue: "20",
children: []
}
]
}
]
expect(
resolveIndicesForFinancialIncrementalSubmit(makeTabs(), baseline, caches)
).toEqual([])
})
test("有 touched 且 diff → 进入", () => {
const baseline = [baselineRule]
const caches = [
{
...baselineRule,
expenseCategoryRules: [
{
expenseCategoryId: 1,
expenseCategoryCalculateType: 1,
expenseCategoryValue: "20",
children: []
}
]
}
]
expect(
resolveIndicesForFinancialIncrementalSubmit(
makeTabs({ classificationUserTouched: true }),
baseline,
caches
)
).toEqual([0])
})
test("sessionAdded 新 Tab → 进入", () => {
const baseline = [baselineRule]
const caches = [baselineRule, { groupType: 2 }]
const tabs = [
{ name: "1", classificationUserTouched: false, sessionAdded: false },
{ name: "2", classificationUserTouched: false, sessionAdded: true }
]
expect(
resolveIndicesForFinancialIncrementalSubmit(tabs, baseline, caches)
).toEqual([1])
})
})
describe("filterFinancialIndicesToSubmitIncremental", () => {
test("有 touched 但无 diff → 第一层 gate 即不进入", () => {
const baseline = [baselineRule]
expect(
resolveIndicesForFinancialIncrementalSubmit(
makeTabs({ classificationUserTouched: true }),
baseline,
[baselineRule]
)
).toEqual([])
})
test("有 touched 但快照 equals baseline → 过滤后为空", () => {
const baseline = [baselineRule]
const validatedByIndex = { 0: baselineRule }
const dirty = [0]
const tabs = makeTabs({ classificationUserTouched: true })
expect(
filterFinancialIndicesToSubmitIncremental(
dirty,
validatedByIndex,
baseline,
tabs
)
).toEqual([])
})
test("有 touched 且快照与基线不同 → 保留", () => {
const baseline = [baselineRule]
const changed = {
...baselineRule,
expenseCategoryRules: [
{
expenseCategoryId: 1,
expenseCategoryCalculateType: 1,
expenseCategoryValue: "99",
children: []
}
]
}
const validatedByIndex = { 0: changed }
expect(
filterFinancialIndicesToSubmitIncremental(
[0],
validatedByIndex,
baseline,
makeTabs({ classificationUserTouched: true })
)
).toEqual([0])
})
test("端到端:误 touched + 未改规则 → 不产生 UPDATE", () => {
const baseline = [baselineRule]
const validatedByIndex = { 0: baselineRule }
const dirty = resolveIndicesForFinancialIncrementalSubmit(
makeTabs({ classificationUserTouched: true }),
baseline,
[baselineRule]
)
expect(dirty).toEqual([])
const indicesToSubmit = filterFinancialIndicesToSubmitIncremental(
dirty,
validatedByIndex,
baseline,
makeTabs({ classificationUserTouched: true })
)
expect(indicesToSubmit).toEqual([])
const incremental = buildGoodsTypeGroupIncrementalRules(
validatedByIndex,
indicesToSubmit,
false
)
expect(incremental).toEqual([])
})
test("真实修改 → filter 后仍生成 UPDATE", () => {
const baseline = [baselineRule]
const changed = {
...baselineRule,
expenseCategoryRules: [
{
expenseCategoryId: 1,
expenseCategoryCalculateType: 1,
expenseCategoryValue: "50",
children: []
}
]
}
const validatedByIndex = { 0: changed }
const dirty = resolveIndicesForFinancialIncrementalSubmit(
makeTabs({ classificationUserTouched: true }),
baseline,
[changed]
)
const indicesToSubmit = filterFinancialIndicesToSubmitIncremental(
dirty,
validatedByIndex,
baseline,
makeTabs({ classificationUserTouched: true })
)
const incremental = buildGoodsTypeGroupIncrementalRules(
validatedByIndex,
indicesToSubmit,
false
)
expect(incremental).toHaveLength(1)
expect(incremental[0].type).toBe(GOODS_TYPE_GROUP_RULE_OP.UPDATE)
})
})
describe("financialTabDiffersFromBaseline / financialSnapshotEqualsBaseline", () => {
test("相同规则:diff false,snapshot equals true", () => {
const baseline = [baselineRule]
expect(financialTabDiffersFromBaseline(baseline, 0, baselineRule)).toBe(false)
expect(financialSnapshotEqualsBaseline(baseline, 0, baselineRule)).toBe(true)
})
})
/**
* @jest-environment jsdom
*/
import { ensureAllCategoryRuleFirst } from "@/views/systemConfig/merchant/financialRules/utils/ensureAllCategoryRuleFirst"
import { buildGoodsTypeGroupIncrementalRules } from "@/views/systemConfig/merchant/financialRules/utils/buildGoodsTypeGroupIncrementalRules"
import { GOODS_TYPE_GROUP_RULE_OP } from "@/views/systemConfig/merchant/financialRules/utils/goodsTypeGroupRuleOpType"
import { mergeChildClassificationPayload } from "@/views/systemConfig/merchant/financialRules/utils/mergeClassificationPayload"
import {
getStableReconciliationRuleId,
mergeReconciliationRuleServerFields
} from "@/views/systemConfig/merchant/merchantStep/utils/reconciliationIncrementalRules"
import {
mergeActiveTabPayload,
mergePreparedWithCache,
simulateRemoveTab
} from "./helpers/financialRulesTestHelpers"
function resolveIncrementalType(preparedRule, cachedRule) {
const merged = mergeReconciliationRuleServerFields(preparedRule, cachedRule)
const idStr = getStableReconciliationRuleId(merged)
return idStr ? GOODS_TYPE_GROUP_RULE_OP.UPDATE : GOODS_TYPE_GROUP_RULE_OP.ADD
}
describe("ensureAllCategoryRuleFirst", () => {
test("空数组 → 默认 { groupType: 1 }", () => {
expect(ensureAllCategoryRuleFirst(null)).toEqual([{ groupType: 1 }])
})
test("groupType 1 已在 index 0 且带 groupDivisionRuleId 时原样保留", () => {
const rules = [
{
groupType: 1,
groupDivisionRuleId: 17805,
groupSettleRuleId: 17942
}
]
expect(ensureAllCategoryRuleFirst(rules)).toEqual(rules)
expect(getStableReconciliationRuleId(rules[0])).toBe("17805")
})
test("首条为特殊品类、groupType 1 在后时:整条移至 index 0(保留 id)", () => {
const input = [
{ groupType: 2, groupDivisionRuleId: "sp-1" },
{
groupType: 1,
groupDivisionRuleId: 17805,
groupSettleRuleId: 17942
}
]
const out = ensureAllCategoryRuleFirst(input)
expect(out).toHaveLength(2)
expect(out[0].groupType).toBe(1)
expect(out[0].groupDivisionRuleId).toBe(17805)
expect(out[0].groupSettleRuleId).toBe(17942)
expect(out[1].groupType).toBe(2)
})
test("仅有特殊品类时 prepend 空壳全部品类", () => {
const out = ensureAllCategoryRuleFirst([
{ groupType: 2, groupDivisionRuleId: "sp-1" }
])
expect(out[0]).toEqual({ groupType: 1 })
expect(out[1].groupDivisionRuleId).toBe("sp-1")
})
})
describe("goodsTypeGroup ADD type reason (API 有 id)", () => {
test("Tab0 缓存有 groupDivisionRuleId 17805 → UPDATE", () => {
const rules = ensureAllCategoryRuleFirst([
{ groupType: 2, groupDivisionRuleId: "sp-1" },
{ groupType: 1, groupDivisionRuleId: 17805, groupSettleRuleId: 17942 }
])
const cached = rules[0]
const prepared = { groupType: 1, expenseCategoryRules: [{}] }
expect(resolveIncrementalType(prepared, cached)).toBe(
GOODS_TYPE_GROUP_RULE_OP.UPDATE
)
const validatedByIndex = {
0: mergePreparedWithCache(prepared, cached)
}
const out = buildGoodsTypeGroupIncrementalRules(validatedByIndex, [0], false)
expect(out[0].type).toBe(GOODS_TYPE_GROUP_RULE_OP.UPDATE)
expect(out[0].groupDivisionRuleId).toBe(17805)
expect(out[0].groupSettleRuleId).toBe(17942)
})
test("mergeChildClassificationPayload 保留 groupDivisionRuleId / groupSettleRuleId", () => {
const prev = {
groupType: 1,
groupDivisionRuleId: 17805,
groupSettleRuleId: 17942
}
const { next } = mergeChildClassificationPayload(
{ groupType: 1, expenseCategoryRules: [] },
prev
)
expect(next.groupDivisionRuleId).toBe(17805)
expect(next.groupSettleRuleId).toBe(17942)
})
})
describe("removeTab / getAllParams id retention", () => {
test("getAllParams merge 后 index 0 仍保留 groupDivisionRuleId", () => {
const slotCache = {
groupType: 1,
groupDivisionRuleId: 17805,
groupSettleRuleId: 17942,
expenseCategoryRules: [{ id: 1 }]
}
const childPayload = {
groupType: 1,
expenseCategoryRules: [{ id: 1 }]
}
const merged = mergeActiveTabPayload(childPayload, slotCache)
expect(merged.groupDivisionRuleId).toBe(17805)
expect(merged.groupSettleRuleId).toBe(17942)
})
test("删 Tab 后 index 0 保留 id 且 incremental type 为 UPDATE", () => {
const prevRules = [
{
groupType: 1,
groupDivisionRuleId: 17805,
groupSettleRuleId: 17942,
expenseCategoryRules: []
},
{ groupType: 2, groupDivisionRuleId: 17806, groupSettleRuleId: 17943 },
{ groupType: 2, groupDivisionRuleId: 17808, groupSettleRuleId: 17944 }
]
const allParams = [
{ groupType: 1, expenseCategoryRules: [] },
{ groupType: 2, expenseCategoryRules: [] },
{ groupType: 2, expenseCategoryRules: [] }
]
const mergedAllParams = allParams.map((payload, i) => {
const { next } = mergeChildClassificationPayload(payload, prevRules[i])
return next
})
const removedTabIndex = 1
const remaining = simulateRemoveTab(mergedAllParams, prevRules, removedTabIndex)
expect(remaining).toHaveLength(2)
expect(remaining[0].groupDivisionRuleId).toBe(17805)
expect(remaining[0].groupSettleRuleId).toBe(17942)
expect(remaining[1].groupDivisionRuleId).toBe(17808)
const prepared = { groupType: 1, expenseCategoryRules: [] }
expect(resolveIncrementalType(prepared, remaining[0])).toBe(
GOODS_TYPE_GROUP_RULE_OP.UPDATE
)
const validatedByIndex = {
0: mergePreparedWithCache(prepared, remaining[0])
}
const out = buildGoodsTypeGroupIncrementalRules(validatedByIndex, [0], false)
expect(out[0].type).toBe(GOODS_TYPE_GROUP_RULE_OP.UPDATE)
expect(out[0].groupDivisionRuleId).toBe(17805)
expect(out[0].groupSettleRuleId).toBe(17942)
})
test("删光特殊品类后仅剩全部品类仍带 id → UPDATE", () => {
const prevRules = [
{
groupType: 1,
groupDivisionRuleId: 17805,
groupSettleRuleId: 17942
},
{ groupType: 2, groupDivisionRuleId: 17806 },
{ groupType: 2, groupDivisionRuleId: 17808 }
]
let allParams = prevRules.map((cached) =>
mergeChildClassificationPayload(
{ groupType: cached.groupType, expenseCategoryRules: [] },
cached
).next
)
let prevCache = prevRules.slice()
allParams = simulateRemoveTab(allParams, prevCache, 2)
prevCache = simulateRemoveTab(prevCache, prevCache, 2)
allParams = simulateRemoveTab(allParams, prevCache, 1)
expect(allParams).toHaveLength(1)
expect(allParams[0].groupDivisionRuleId).toBe(17805)
const validatedByIndex = {
0: mergePreparedWithCache(
{ groupType: 1, expenseCategoryRules: [] },
allParams[0]
)
}
const out = buildGoodsTypeGroupIncrementalRules(validatedByIndex, [0], false)
expect(out[0].type).toBe(GOODS_TYPE_GROUP_RULE_OP.UPDATE)
expect(out[0].groupDivisionRuleId).toBe(17805)
})
})
import path from "path"
import fs from "fs"
import { mergeChildClassificationPayload } from "@/views/systemConfig/merchant/financialRules/utils/mergeClassificationPayload"
import { mergeReconciliationRuleServerFields } from "@/views/systemConfig/merchant/merchantStep/utils/reconciliationIncrementalRules"
import { applyRemoveTabToGoodsTypeGroupRules } from "@/views/systemConfig/merchant/financialRules/utils/applyRemoveTabToGoodsTypeGroupRules"
const FIXTURE_ROOT = path.join(__dirname, "../../../fixtures/financialRules")
/**
* 优先 real/,回退 synthetic/
* @param {string} name 不含扩展名
*/
export function loadFixture(name) {
const realPath = path.join(FIXTURE_ROOT, "real", `${name}.json`)
if (fs.existsSync(realPath)) {
return JSON.parse(fs.readFileSync(realPath, "utf8"))
}
const syntheticPath = path.join(FIXTURE_ROOT, "synthetic", `${name}.json`)
if (fs.existsSync(syntheticPath)) {
return JSON.parse(fs.readFileSync(syntheticPath, "utf8"))
}
throw new Error(`Fixture not found: ${name}`)
}
/** getAllParams 激活 Tab 分支:子组件 payload 与槽位缓存 merge */
export function mergeActiveTabPayload(childPayload, slotCache) {
const { next } = mergeChildClassificationPayload(childPayload, slotCache)
return next
}
/** removeTab 核心:splice + oldIdx 服务端 id 合并 */
export function simulateRemoveTab(rules, prevRules, removedTabIndex) {
const { remainingRules } = applyRemoveTabToGoodsTypeGroupRules({
goodsTypeGroupRules: rules,
tabIndex: removedTabIndex,
prevGoodsTypeGroupRules: prevRules,
removedRule: rules[removedTabIndex],
removedTabMeta: {},
isSessionOnlyNew: false
})
return remainingRules
}
export function mergeChildPayloadAtIndex(payload, cached) {
return mergeChildClassificationPayload(payload, cached).next
}
export function mergePreparedWithCache(prepared, cached) {
return mergeReconciliationRuleServerFields(prepared, cached)
}
/**
* @jest-environment jsdom
*/
import { mergeChildClassificationPayload } from "@/views/systemConfig/merchant/financialRules/utils/mergeClassificationPayload"
describe("mergeChildClassificationPayload", () => {
test("子组件空数组不覆盖缓存非空数组", () => {
const prev = {
expenseCategoryRules: [{ id: 1, calculateMode: 1 }],
merchantDistributionRules: [{ merchantId: "100" }],
owningMerchantDistributionRules: [{ merchantId: "100" }],
goodsTypes: [{ goodsType: "G1" }]
}
const { next } = mergeChildClassificationPayload(
{
expenseCategoryRules: [],
merchantDistributionRules: [],
owningMerchantDistributionRules: [],
goodsTypes: []
},
prev
)
expect(next.expenseCategoryRules).toEqual(prev.expenseCategoryRules)
expect(next.merchantDistributionRules).toEqual(prev.merchantDistributionRules)
expect(next.owningMerchantDistributionRules).toEqual(prev.owningMerchantDistributionRules)
expect(next.goodsTypes).toEqual(prev.goodsTypes)
})
test("payload 未带 expenseCategoryRules → 保留 base", () => {
const prev = { expenseCategoryRules: [{ id: 1 }] }
const { next } = mergeChildClassificationPayload({ groupType: 1 }, prev)
expect(next.expenseCategoryRules).toEqual(prev.expenseCategoryRules)
})
test("payload 带非空 expenseCategoryRules → 覆盖", () => {
const prev = { expenseCategoryRules: [{ id: 1 }] }
const incoming = [{ id: 2, calculateMode: 1 }]
const { next } = mergeChildClassificationPayload(
{ expenseCategoryRules: incoming },
prev
)
expect(next.expenseCategoryRules).toEqual(incoming)
})
test("保留 SERVER_ID_FIELDS", () => {
const prev = {
groupDivisionRuleId: 17805,
groupSettleRuleId: 17942,
id: "x"
}
const { next } = mergeChildClassificationPayload({ groupType: 1 }, prev)
expect(next.groupDivisionRuleId).toBe(17805)
expect(next.groupSettleRuleId).toBe(17942)
expect(next.id).toBe("x")
})
})
import {
FORCE_DIVISION_TEST_SUB_PROGRESS,
applyDivisionRuleTestGetMock,
mockDivisionRuleTestGetSubProgress
} from '@/api/mockDivisionRuleTestGetResponse'
describe('mockDivisionRuleTestGetSubProgress', () => {
it('applyDivisionRuleTestGetMock passes through when mock disabled', () => {
const raw = { subProgress: 10 }
expect(applyDivisionRuleTestGetMock(raw)).toBe(raw)
expect(applyDivisionRuleTestGetMock(raw).subProgress).toBe(10)
})
it('forces root and nested subProgress to 35', () => {
const raw = {
subProgress: 10,
divisionRuleTestItem: { subProgress: 20, orderCode: 'O1' },
divisionRuleTests: [
{
paymentChannelId: 1,
subProgress: 30,
divisionRuleTestItem: { subProgress: 31 }
}
]
}
const out = mockDivisionRuleTestGetSubProgress(raw)
expect(out.subProgress).toBe(FORCE_DIVISION_TEST_SUB_PROGRESS)
expect(out.divisionRuleTestItem.subProgress).toBe(35)
expect(out.divisionRuleTests[0].subProgress).toBe(35)
expect(out.divisionRuleTests[0].divisionRuleTestItem.subProgress).toBe(35)
expect(out.divisionRuleTestItem.orderCode).toBe('O1')
})
it('returns nullish as-is', () => {
expect(mockDivisionRuleTestGetSubProgress(null)).toBe(null)
expect(mockDivisionRuleTestGetSubProgress(undefined)).toBe(undefined)
})
})
...@@ -27,7 +27,8 @@ describe("normalizeRuleGoodsTypesForCategory", () => { ...@@ -27,7 +27,8 @@ describe("normalizeRuleGoodsTypesForCategory", () => {
categoryType: 2, categoryType: 2,
upgradeGoodsId: "u1", upgradeGoodsId: "u1",
upgradeGoodsName: "U", upgradeGoodsName: "U",
commodityCode: "C1" commodityCode: "C1",
merchantGoodsCode: "M1"
} }
] ]
} }
...@@ -38,7 +39,12 @@ describe("normalizeRuleGoodsTypesForCategory", () => { ...@@ -38,7 +39,12 @@ describe("normalizeRuleGoodsTypesForCategory", () => {
expect(item.goodsTypes).toEqual([]) expect(item.goodsTypes).toEqual([])
expect(item.upgradeGoods).toHaveLength(1) expect(item.upgradeGoods).toHaveLength(1)
expect(upgradeArr).toEqual([ expect(upgradeArr).toEqual([
{ upgradeGoodsId: "u1", upgradeGoodsName: "U", commodityCode: "C1" } {
upgradeGoodsId: "u1",
upgradeGoodsName: "U",
commodityCode: "C1",
merchantGoodsCode: "M1"
}
]) ])
expect(packageArr).toHaveLength(0) expect(packageArr).toHaveLength(0)
}) })
......
import {
getStableReconciliationRuleId,
mergeReconciliationRuleServerFields
} from "@/views/systemConfig/merchant/merchantStep/utils/reconciliationIncrementalRules"
describe("getStableReconciliationRuleId", () => {
test("优先 groupDivisionRuleId", () => {
expect(getStableReconciliationRuleId({ groupDivisionRuleId: 17805 })).toBe("17805")
expect(getStableReconciliationRuleId({ groupDivisionRuleId: "17805" })).toBe("17805")
})
test("groupDivisionRuleId 空时 fallback id", () => {
expect(getStableReconciliationRuleId({ id: 99 })).toBe("99")
expect(getStableReconciliationRuleId({ groupDivisionRuleId: "", id: "abc" })).toBe("abc")
})
test("无效输入 → 空字符串", () => {
expect(getStableReconciliationRuleId(null)).toBe("")
expect(getStableReconciliationRuleId({})).toBe("")
})
})
describe("mergeReconciliationRuleServerFields", () => {
test("prepared 无 id、cached 有 id → 保留", () => {
const prepared = { groupType: 1, expenseCategoryRules: [] }
const cached = {
groupDivisionRuleId: 17805,
groupSettleRuleId: 17942,
id: "server-id"
}
const out = mergeReconciliationRuleServerFields(prepared, cached)
expect(out.groupDivisionRuleId).toBe(17805)
expect(out.groupSettleRuleId).toBe(17942)
expect(out.id).toBe("server-id")
expect(out.groupType).toBe(1)
})
test("cached 有 id 时合并进 prepared", () => {
const prepared = { groupType: 1 }
const cached = { groupDivisionRuleId: "old" }
const out = mergeReconciliationRuleServerFields(prepared, cached)
expect(out.groupDivisionRuleId).toBe("old")
})
test("无 cached → 原样返回", () => {
const prepared = { groupType: 1 }
expect(mergeReconciliationRuleServerFields(prepared, null)).toEqual(prepared)
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!