Commit 0acb2834 by 张立顺

feat 功能联调

1 parent 1620ae95
...@@ -32,11 +32,11 @@ ...@@ -32,11 +32,11 @@
:rules="rules" :rules="rules"
> >
<div class="traffic-provider-information-content"> <div class="traffic-provider-information-content">
<template v-for="(i,index) in trafficProviderInformation">
<el-form-item <el-form-item
v-for="(i,index) in trafficProviderInformation"
:key="`trafficProviderInformation${index}`"
class="traffic-provider-information-item" class="traffic-provider-information-item"
:label="i.label + ':'" :label="i.label + ':'"
:key="`trafficProviderInformation${index}`"
:prop="isViewMode ? '' : i.key" :prop="isViewMode ? '' : i.key"
> >
<template v-if="editStatus"> <template v-if="editStatus">
...@@ -48,6 +48,23 @@ ...@@ -48,6 +48,23 @@
:placeholder="`请输入${i.label}`" :placeholder="`请输入${i.label}`"
/> />
</template> </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'"> <template v-else-if="i.type == 'select'">
<el-select <el-select
v-model="componentData[i.key]" v-model="componentData[i.key]"
...@@ -64,22 +81,24 @@ ...@@ -64,22 +81,24 @@
</template> </template>
</template> </template>
<template v-else> <template v-else>
<template v-if="i.type == 'select'"> <template v-if="i.type == 'select' && i.multiple">
{{ getServiceMultiSelectText(i) }}
</template>
<template v-else-if="i.type == 'select'">
{{ getSelectText(i) }} {{ getSelectText(i) }}
</template> </template>
<template v-else> {{ componentData[i.key] || '-' }}</template> <template v-else> {{ componentData[i.key] || '-' }}</template>
</template> </template>
</el-form-item> </el-form-item>
</template>
</div> </div>
<div class="sub-title">人员信息</div> <div class="sub-title">人员信息</div>
<div class="traffic-provider-information-content"> <div class="traffic-provider-information-content">
<template v-for="(i,index) in customerInformation">
<el-form-item <el-form-item
v-for="(i,index) in customerInformation"
:key="`customerInformation${index}`"
class="traffic-provider-information-item" class="traffic-provider-information-item"
:label="i.label + ':'" :label="i.label + ':'"
:key="`customerInformation${index}`"
:prop="i.key" :prop="i.key"
> >
<template v-if="editStatus"> <template v-if="editStatus">
...@@ -102,7 +121,6 @@ ...@@ -102,7 +121,6 @@
{{ getMultipleSelectText(i) }} {{ getMultipleSelectText(i) }}
</template> </template>
</el-form-item> </el-form-item>
</template>
</div> </div>
</el-form> </el-form>
</div> </div>
...@@ -118,6 +136,7 @@ import { ...@@ -118,6 +136,7 @@ import {
} from "@api/merchant"; } from "@api/merchant";
import { qyMerchantPageList } from '@/api/salesManagement.js' import { qyMerchantPageList } from '@/api/salesManagement.js'
import { parseOtherServiceProvidersFromMi } from '@/views/systemConfig/merchant/merchantGroundingEdit/merchantDetailMap'
export default { export default {
name: 'TrafficProviderInformation', name: 'TrafficProviderInformation',
...@@ -153,14 +172,8 @@ export default { ...@@ -153,14 +172,8 @@ export default {
}, },
data: { data: {
handler (newVal) { handler (newVal) {
if (newVal) { this.componentData = this.normalizeTrafficFormFromProp(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)
}, },
deep: true,
immediate: true immediate: true
} }
}, },
...@@ -208,6 +221,14 @@ export default { ...@@ -208,6 +221,14 @@ export default {
}, },
{ label: '服务商2/F公司', key: 'serviceMerchant2fId', type: 'select', viewKey: 'serviceMerchant2fName', options: [] }, { label: '服务商2/F公司', key: 'serviceMerchant2fId', type: 'select', viewKey: 'serviceMerchant2fName', options: [] },
{ label: '服务商', key: 'partnerId', type: 'select', viewKey: 'partnerName', 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: 'parentServiceMerchantName', type: 'input', maxlength: 50 },
{ label: '园区店', key: 'yqMerchantId', type: 'select', viewKey: 'yqMerchantName', options: [] }, { label: '园区店', key: 'yqMerchantId', type: 'select', viewKey: 'yqMerchantName', options: [] },
], ],
...@@ -229,6 +250,25 @@ export default { ...@@ -229,6 +250,25 @@ export default {
} }
}, },
methods: { 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 () { syncDefaultEditState () {
if (this.isViewMode) { if (this.isViewMode) {
this.editStatus = false this.editStatus = false
...@@ -253,10 +293,11 @@ export default { ...@@ -253,10 +293,11 @@ export default {
cancel () { cancel () {
this.editStatus = false this.editStatus = false
this.$emit('edit', false) this.$emit('edit', false)
this.componentData = deepClone(this.data) this.componentData = this.normalizeTrafficFormFromProp(this.data)
}, },
save () { save () {
this.syncAllStaffNamesFromOptions() this.syncAllStaffNamesFromOptions()
this.syncOtherServiceProvidersNameFromOptions()
this.editStatus = false this.editStatus = false
this.$emit('updateData', deepClone(this.componentData)) this.$emit('updateData', deepClone(this.componentData))
this.$emit('edit', false) this.$emit('edit', false)
...@@ -271,6 +312,27 @@ export default { ...@@ -271,6 +312,27 @@ export default {
const option = i.options.find(item => item.value === value) const option = i.options.find(item => item.value === value)
return option?.label || (i.viewKey && this.componentData[i.viewKey]) || 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) { getMultipleSelectText (i) {
const nameByListKey = { const nameByListKey = {
areaOpIdList: 'areaOpName', areaOpIdList: 'areaOpName',
...@@ -324,6 +386,39 @@ export default { ...@@ -324,6 +386,39 @@ export default {
onStaffMultiChange (listKey) { onStaffMultiChange (listKey) {
this.syncStaffNameFromOptions(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 () { async merchantStaffByRoleList () {
const [areaOpIdList, onlineOpIdList, regionSupervisorIdList] = await Promise.all([ const [areaOpIdList, onlineOpIdList, regionSupervisorIdList] = await Promise.all([
merchantStaffByRoleList({ roleName: '区域运营' }), merchantStaffByRoleList({ roleName: '区域运营' }),
...@@ -352,8 +447,9 @@ export default { ...@@ -352,8 +447,9 @@ export default {
return { label: item.merchantName, value: Number(item.merchantNo) } return { label: item.merchantName, value: Number(item.merchantNo) }
}) })
this.trafficProviderInformation.map(item => { 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 () { async qyMerchantPageList () {
const { list } = await qyMerchantPageList({ currentPage: 1, pageSize: 100000 }) const { list } = await qyMerchantPageList({ currentPage: 1, pageSize: 100000 })
......
...@@ -246,6 +246,10 @@ export default { ...@@ -246,6 +246,10 @@ export default {
delete componentData.areaOpIdList delete componentData.areaOpIdList
delete componentData.onlineOpIdList delete componentData.onlineOpIdList
delete componentData.regionSupervisorIdList delete componentData.regionSupervisorIdList
if (typeof trafficProviderInformationRef.buildOtherServiceProvidersForSubmit === 'function') {
Object.assign(componentData, trafficProviderInformationRef.buildOtherServiceProvidersForSubmit())
}
delete componentData.otherServiceProvidersIdList
trafficValidationData = componentData trafficValidationData = componentData
} }
resolve(valid) resolve(valid)
......
...@@ -314,6 +314,9 @@ export default { ...@@ -314,6 +314,9 @@ export default {
} }
if (!this.validateProductDetailsForSave()) return; if (!this.validateProductDetailsForSave()) return;
const traffic = deepClone(trafficRef.componentData || this.trafficProviderData); const traffic = deepClone(trafficRef.componentData || this.trafficProviderData);
if (typeof trafficRef.buildOtherServiceProvidersForSubmit === "function") {
Object.assign(traffic, trafficRef.buildOtherServiceProvidersForSubmit());
}
const businessForm = const businessForm =
businessRef && typeof businessRef.getFormData === "function" businessRef && typeof businessRef.getFormData === "function"
? businessRef.getFormData() ? businessRef.getFormData()
......
...@@ -58,7 +58,58 @@ export function storeProfitPerCar(mi) { ...@@ -58,7 +58,58 @@ export function storeProfitPerCar(mi) {
return String(NP.round(NP.divide(Number(r), Number(d)), 2)); 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 = []) { export function buildTrafficProviderData(mi, baseSceneList = []) {
const osp = parseOtherServiceProvidersFromMi(mi);
const nameFromMi = mi?.otherServiceProvidersName;
return { return {
trafficPartyName: mi.trafficPartyName || "", trafficPartyName: mi.trafficPartyName || "",
parentName: mi.parentName || mi.parentMerchantName || "", parentName: mi.parentName || mi.parentMerchantName || "",
...@@ -80,6 +131,11 @@ export function buildTrafficProviderData(mi, baseSceneList = []) { ...@@ -80,6 +131,11 @@ export function buildTrafficProviderData(mi, baseSceneList = []) {
areaOpName: mi.areaOpName || "", areaOpName: mi.areaOpName || "",
onlineOpName: mi.onlineOpName || "", onlineOpName: mi.onlineOpName || "",
regionSupervisorName: mi.regionSupervisorName || "", 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) { ...@@ -172,6 +172,10 @@ export function buildMerchantOnShelfOpenPayload(options) {
areaOpName: (traffic && traffic.areaOpName) || "", areaOpName: (traffic && traffic.areaOpName) || "",
onlineOpName: (traffic && traffic.onlineOpName) || "", onlineOpName: (traffic && traffic.onlineOpName) || "",
regionSupervisorName: (traffic && traffic.regionSupervisorName) || "", regionSupervisorName: (traffic && traffic.regionSupervisorName) || "",
otherServiceProviders:
traffic && traffic.otherServiceProviders != null && traffic.otherServiceProviders !== ""
? String(traffic.otherServiceProviders)
: "",
}; };
const productDetailBusinessDataList = (productDetailsForSubmit || []).map( 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!