Commit 0acb2834 by 张立顺

feat 功能联调

1 parent 1620ae95
......@@ -32,13 +32,13 @@
:rules="rules"
>
<div class="traffic-provider-information-content">
<template v-for="(i,index) in trafficProviderInformation">
<el-form-item
class="traffic-provider-information-item"
:label="i.label + ':'"
:key="`trafficProviderInformation${index}`"
:prop="isViewMode ? '' : i.key"
>
<el-form-item
v-for="(i,index) in trafficProviderInformation"
:key="`trafficProviderInformation${index}`"
class="traffic-provider-information-item"
:label="i.label + ':'"
:prop="isViewMode ? '' : i.key"
>
<template v-if="editStatus">
<template v-if="i.type == 'input'">
<el-input
......@@ -48,6 +48,23 @@
:placeholder="`请输入${i.label}`"
/>
</template>
<template v-else-if="i.type == 'select' && i.multiple">
<el-select
v-model="componentData[i.key]"
class="select"
multiple
collapse-tags
:placeholder="`请选择${i.label}`"
@change="onOtherServiceProvidersChange"
>
<el-option
v-for="item in i.options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
<template v-else-if="i.type == 'select'">
<el-select
v-model="componentData[i.key]"
......@@ -64,24 +81,26 @@
</template>
</template>
<template v-else>
<template v-if="i.type == 'select'">
{{ getSelectText(i) }}
<template v-if="i.type == 'select' && i.multiple">
{{ getServiceMultiSelectText(i) }}
</template>
<template v-else-if="i.type == 'select'">
{{ getSelectText(i) }}
</template>
<template v-else> {{ componentData[i.key] || '-' }}</template>
</template>
</el-form-item>
</template>
</el-form-item>
</div>
<div class="sub-title">人员信息</div>
<div class="traffic-provider-information-content">
<template v-for="(i,index) in customerInformation">
<el-form-item
class="traffic-provider-information-item"
:label="i.label + ':'"
:key="`customerInformation${index}`"
:prop="i.key"
>
<el-form-item
v-for="(i,index) in customerInformation"
:key="`customerInformation${index}`"
class="traffic-provider-information-item"
:label="i.label + ':'"
:prop="i.key"
>
<template v-if="editStatus">
<el-select
v-model="componentData[i.key]"
......@@ -101,8 +120,7 @@
<template v-else>
{{ getMultipleSelectText(i) }}
</template>
</el-form-item>
</template>
</el-form-item>
</div>
</el-form>
</div>
......@@ -118,6 +136,7 @@ import {
} from "@api/merchant";
import { qyMerchantPageList } from '@/api/salesManagement.js'
import { parseOtherServiceProvidersFromMi } from '@/views/systemConfig/merchant/merchantGroundingEdit/merchantDetailMap'
export default {
name: 'TrafficProviderInformation',
......@@ -153,14 +172,8 @@ export default {
},
data: {
handler (newVal) {
if (newVal) {
if (newVal.areaOpId) newVal.areaOpIdList = newVal.areaOpId.split(',')
if (newVal.onlineOpId) newVal.onlineOpIdList = newVal.onlineOpId.split(',')
if (newVal.regionSupervisorId) newVal.regionSupervisorIdList = newVal.regionSupervisorId.split(',')
}
this.componentData = deepClone(newVal)
this.componentData = this.normalizeTrafficFormFromProp(newVal)
},
deep: true,
immediate: true
}
},
......@@ -208,6 +221,14 @@ export default {
},
{ label: '服务商2/F公司', key: 'serviceMerchant2fId', type: 'select', viewKey: 'serviceMerchant2fName', options: [] },
{ label: '服务商', key: 'partnerId', type: 'select', viewKey: 'partnerName', options: [] },
{
label: '其他服务商',
key: 'otherServiceProvidersIdList',
type: 'select',
multiple: true,
viewKey: 'otherServiceProvidersName',
options: [],
},
{ label: '上级服务商', key: 'parentServiceMerchantName', type: 'input', maxlength: 50 },
{ label: '园区店', key: 'yqMerchantId', type: 'select', viewKey: 'yqMerchantName', options: [] },
],
......@@ -229,6 +250,25 @@ export default {
}
},
methods: {
normalizeTrafficFormFromProp (source) {
if (!source || typeof source !== 'object') return {}
const copy = deepClone(source)
if (copy.areaOpId) copy.areaOpIdList = String(copy.areaOpId).split(',')
if (copy.onlineOpId) copy.onlineOpIdList = String(copy.onlineOpId).split(',')
if (copy.regionSupervisorId) copy.regionSupervisorIdList = String(copy.regionSupervisorId).split(',')
if (!Array.isArray(copy.otherServiceProvidersIdList) || copy.otherServiceProvidersIdList.length === 0) {
const osp = parseOtherServiceProvidersFromMi(copy)
copy.otherServiceProvidersIdList = osp.ids
if (osp.namesStr && (copy.otherServiceProvidersName == null || String(copy.otherServiceProvidersName).trim() === '')) {
copy.otherServiceProvidersName = osp.namesStr
}
} else {
copy.otherServiceProvidersIdList = copy.otherServiceProvidersIdList
.map(id => Number(id))
.filter(n => !Number.isNaN(n))
}
return copy
},
syncDefaultEditState () {
if (this.isViewMode) {
this.editStatus = false
......@@ -253,10 +293,11 @@ export default {
cancel () {
this.editStatus = false
this.$emit('edit', false)
this.componentData = deepClone(this.data)
this.componentData = this.normalizeTrafficFormFromProp(this.data)
},
save () {
this.syncAllStaffNamesFromOptions()
this.syncOtherServiceProvidersNameFromOptions()
this.editStatus = false
this.$emit('updateData', deepClone(this.componentData))
this.$emit('edit', false)
......@@ -271,6 +312,27 @@ export default {
const option = i.options.find(item => item.value === value)
return option?.label || (i.viewKey && this.componentData[i.viewKey]) || value || '-'
},
getServiceMultiSelectText (i) {
const nameKey = i.viewKey || 'otherServiceProvidersName'
if (this.isViewMode && nameKey) {
const raw = this.componentData[nameKey]
if (raw != null && String(raw).trim() !== '') return String(raw).trim()
}
const values = this.componentData[i.key]
if (!values || !Array.isArray(values) || values.length === 0) {
const fallback = this.componentData.otherServiceProvidersName
if (fallback != null && String(fallback).trim() !== '') return String(fallback).trim()
return '-'
}
if (!i?.options?.length) {
const fallback = this.componentData.otherServiceProvidersName
return fallback != null && String(fallback).trim() !== '' ? String(fallback).trim() : '-'
}
const selectedNames = values
.map(v => i.options.find(item => Number(item.value) === Number(v))?.label)
.filter(Boolean)
return selectedNames.length > 0 ? selectedNames.join('/') : '-'
},
getMultipleSelectText (i) {
const nameByListKey = {
areaOpIdList: 'areaOpName',
......@@ -324,6 +386,39 @@ export default {
onStaffMultiChange (listKey) {
this.syncStaffNameFromOptions(listKey)
},
syncOtherServiceProvidersNameFromOptions () {
const row = this.trafficProviderInformation.find(item => item.key === 'otherServiceProvidersIdList')
const options = row?.options || []
const ids = this.componentData.otherServiceProvidersIdList
if (!Array.isArray(ids) || ids.length === 0) {
this.$set(this.componentData, 'otherServiceProvidersName', '')
return
}
if (!options.length) return
const parts = ids.map((id) => {
const opt = options.find(o => Number(o.value) === Number(id))
return opt?.label || ''
}).filter(Boolean)
const joined = parts.join('/')
if (!joined && this.componentData.otherServiceProvidersName) return
this.$set(this.componentData, 'otherServiceProvidersName', joined)
},
onOtherServiceProvidersChange () {
this.syncOtherServiceProvidersNameFromOptions()
},
buildOtherServiceProvidersForSubmit () {
const row = this.trafficProviderInformation.find(item => item.key === 'otherServiceProvidersIdList')
const options = row?.options || []
const ids = this.componentData.otherServiceProvidersIdList
if (!Array.isArray(ids) || ids.length === 0) {
return { otherServiceProviders: '' }
}
const payload = ids.map(id => {
const opt = options.find(o => Number(o.value) === Number(id))
return { merchantNo: Number(id), merchantName: opt?.label || '' }
})
return { otherServiceProviders: JSON.stringify(payload) }
},
async merchantStaffByRoleList () {
const [areaOpIdList, onlineOpIdList, regionSupervisorIdList] = await Promise.all([
merchantStaffByRoleList({ roleName: '区域运营' }),
......@@ -352,8 +447,9 @@ export default {
return { label: item.merchantName, value: Number(item.merchantNo) }
})
this.trafficProviderInformation.map(item => {
if (['serviceMerchant2fId', 'partnerId'].includes(item.key)) item.options = data
if (['serviceMerchant2fId', 'partnerId', 'otherServiceProvidersIdList'].includes(item.key)) item.options = data
})
this.$nextTick(() => this.syncOtherServiceProvidersNameFromOptions())
},
async qyMerchantPageList () {
const { list } = await qyMerchantPageList({ currentPage: 1, pageSize: 100000 })
......
......@@ -246,6 +246,10 @@ export default {
delete componentData.areaOpIdList
delete componentData.onlineOpIdList
delete componentData.regionSupervisorIdList
if (typeof trafficProviderInformationRef.buildOtherServiceProvidersForSubmit === 'function') {
Object.assign(componentData, trafficProviderInformationRef.buildOtherServiceProvidersForSubmit())
}
delete componentData.otherServiceProvidersIdList
trafficValidationData = componentData
}
resolve(valid)
......
......@@ -314,6 +314,9 @@ export default {
}
if (!this.validateProductDetailsForSave()) return;
const traffic = deepClone(trafficRef.componentData || this.trafficProviderData);
if (typeof trafficRef.buildOtherServiceProvidersForSubmit === "function") {
Object.assign(traffic, trafficRef.buildOtherServiceProvidersForSubmit());
}
const businessForm =
businessRef && typeof businessRef.getFormData === "function"
? businessRef.getFormData()
......
......@@ -58,7 +58,58 @@ export function storeProfitPerCar(mi) {
return String(NP.round(NP.divide(Number(r), Number(d)), 2));
}
/**
* 从详情/历史里的 otherServiceProviders(JSON 字符串或对象数组)解析多选 ID 与展示名。
* 元素结构约定:{ merchantNo, merchantName }(兼容 merchantId、name 等别名)
*/
export function parseOtherServiceProvidersFromMi(mi) {
const raw = mi?.otherServiceProviders;
if (raw == null || raw === "") {
return { ids: [], namesStr: "" };
}
let parsed = raw;
if (typeof raw === "string") {
try {
parsed = JSON.parse(raw);
} catch {
return { ids: [], namesStr: "" };
}
}
if (!Array.isArray(parsed)) {
return { ids: [], namesStr: "" };
}
const ids = [];
const names = [];
for (const item of parsed) {
if (item == null) continue;
if (typeof item === "number") {
if (!Number.isNaN(item)) ids.push(Number(item));
continue;
}
if (typeof item === "string") {
const n = Number(item);
if (!Number.isNaN(n)) ids.push(n);
continue;
}
if (typeof item === "object") {
const idRaw = item.merchantNo ?? item.merchantId ?? item.id ?? item.serviceProviderId;
const nameRaw = item.merchantName ?? item.name ?? "";
if (idRaw != null && idRaw !== "") {
const n = Number(idRaw);
if (!Number.isNaN(n)) ids.push(n);
}
if (nameRaw != null && String(nameRaw).trim() !== "") {
names.push(String(nameRaw).trim());
}
}
}
const namesStr = names.length ? names.join("/") : "";
return { ids, namesStr };
}
export function buildTrafficProviderData(mi, baseSceneList = []) {
const osp = parseOtherServiceProvidersFromMi(mi);
const nameFromMi = mi?.otherServiceProvidersName;
return {
trafficPartyName: mi.trafficPartyName || "",
parentName: mi.parentName || mi.parentMerchantName || "",
......@@ -80,6 +131,11 @@ export function buildTrafficProviderData(mi, baseSceneList = []) {
areaOpName: mi.areaOpName || "",
onlineOpName: mi.onlineOpName || "",
regionSupervisorName: mi.regionSupervisorName || "",
otherServiceProvidersIdList: osp.ids,
otherServiceProvidersName:
nameFromMi != null && String(nameFromMi).trim() !== ""
? String(nameFromMi).trim()
: osp.namesStr,
};
}
......
......@@ -172,6 +172,10 @@ export function buildMerchantOnShelfOpenPayload(options) {
areaOpName: (traffic && traffic.areaOpName) || "",
onlineOpName: (traffic && traffic.onlineOpName) || "",
regionSupervisorName: (traffic && traffic.regionSupervisorName) || "",
otherServiceProviders:
traffic && traffic.otherServiceProviders != null && traffic.otherServiceProviders !== ""
? String(traffic.otherServiceProviders)
: "",
};
const productDetailBusinessDataList = (productDetailsForSubmit || []).map(
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!