<template>
<div class="detail-wrap">
<a-row class="details-content-inner-wrap">
<a-col :span="16" class="details-left-content-wrap detailsContent">
<detail-list :tableInfoFields="accountInfoFields" :tableData="accountInfo"
detailTitle="Ali Account Details"></detail-list>
<div class="account-btns" v-show="editVisible">
<!-- TODO: 先隐藏 -->
<a-button class="btn-light-grey" style="display: none">
<template #icon>
<ReloadOutlined />
</template>
Trigger Account Update
</a-button>
<a-button class="btn-light-grey" @click="preEditAccount">
<template #icon>
<EditOutlined />
</template>
Edit Account
</a-button>
</div>
</a-col>
<a-col :span="7" class="details-right-content-wrap">
<div>
<h4>Login Details</h4>
<div class="login-details-inner-wrap">
<div>
<p>
You have access to <strong>{{ rolesCount }} </strong> RAM
role(s) in this Cloud Room On the Cloud.
</p>
<div v-show="rolesCount > 0">
<p>
Please
<a :href="loginUrl.cloud_sso_login_url" target="_black">login to Alibaba with your Active Directory
credentials</a>
in order to access the following roles:
</p>
<ul v-if="accountInfo?.idp_user_roles?.length > 0">
<li v-for="role in accountInfo.idp_user_roles" :key="role">
{{ role }}
</li>
</ul>
</div>
</div>
</div>
</div>
</a-col>
</a-row>
<a-modal v-model:visible="formVisible" :title="title" @ok="handleOk"
:ok-button-props="{ disabled: updateBtnDisabled }" :cancel-button-props="{ disabled: formLoading }" width="900px"
okText="Update" :body-style="bodystyle">
<a-spin :spinning="formLoading">
<a-form :model="formState" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-item label="Region Category" v-bind="validateInfos.region_category">
<a-select v-model:value="formState.region_category" :disabled="editDisabledMap.region_category"
placeholder="please select region_category">
<a-select-option value="Global">Global</a-select-option>
<a-select-option value="China">China</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="Master Account" v-bind="validateInfos.master_account">
<a-input v-model:value="formState.master_account" :disabled="true" />
</a-form-item>
<a-form-item label="Ali Account ID" v-bind="validateInfos.account_id">
<a-input v-model:value="formState.account_id" :disabled="editDisabledMap.account_id" />
</a-form-item>
<a-form-item label="Creation Date" v-bind="validateInfos.creation_date">
<!-- TODO: 前端先手动写死disabled :disabled="editDisabledMap.creation_date" -->
<a-input v-model:value="formState.creation_date" :disabled="true" />
</a-form-item>
<a-form-item label="FPC Status" v-bind="validateInfos.fpc_status">
<a-select v-model:value="formState.fpc_status" :disabled="editDisabledMap.fpc_status"
placeholder="please select fpc_status" :options="fpcOptions">
</a-select>
</a-form-item>
<a-form-item label="Friendly Name" v-bind="validateInfos.account_friendly_name">
<!-- TODO: 前端先手动写死disabled :disabled="editDisabledMap.account_friendly_name" -->
<a-input v-model:value="formState.account_friendly_name" :disabled="true" />
</a-form-item>
<a-form-item label="Description" v-bind="validateInfos.description">
<a-input v-model:value="formState.description" :disabled="editDisabledMap.description" />
</a-form-item>
<!-- TODO: 暂定disabled, 之后还原::disabled="editDisabledMap.account_area" -->
<a-form-item label="Account Area" v-bind="validateInfos.account_area">
<a-select v-model:value="formState.account_area" :disabled="true" placeholder="please select account_area"
:options="accountAreaOptions">
</a-select>
</a-form-item>
<!-- TODO: 暂定disabled,之后还原::disabled="editDisabledMap.account_type" -->
<a-form-item label="Account Type" v-bind="validateInfos.account_type">
<a-select v-model:value="formState.account_type" :disabled="true" placeholder="please select account_type"
:options="accountTypeOptions">
</a-select>
</a-form-item>
<a-form-item label="Account Stage" v-bind="validateInfos.account_stage">
<a-select v-model:value="formState.account_stage" :disabled="editDisabledMap.account_stage"
placeholder="please select account_stage" :options="accountStageOptions">
</a-select>
</a-form-item>
<a-form-item label="Primary Responsible" v-bind="validateInfos.primary_responsible">
<a-input v-model:value="formState.primary_responsible" :disabled="editDisabledMap.primary_responsible" />
</a-form-item>
<a-form-item label="Secondary Responsible" v-bind="validateInfos.sec_responsible">
<a-input v-model:value="formState.sec_responsible" :disabled="editDisabledMap.sec_responsible" />
</a-form-item>
<a-form-item label="Responsible Manager" v-bind="validateInfos.manager_responsible">
<a-input v-model:value="formState.manager_responsible" :disabled="editDisabledMap.manager_responsible" />
</a-form-item>
<a-form-item label="APP-ID" v-bind="validateInfos.app_id">
<a-input v-model:value="formState.app_id" :disabled="editDisabledMap.app_id" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, PropType, ref, watch } from "vue";
import { Item } from "../types";
import DetailList from "@/components/DetailList/index.vue";
import { EditOutlined, ReloadOutlined } from "@ant-design/icons-vue";
import { useGetAccountInfo } from "./Cloudroom";
import { accountInfoFields } from "../config";
import { useGetLoginUrl } from "@/composition/useGetLoginUrl";
export default defineComponent({
name: "CloudRoom",
components: { DetailList, EditOutlined, ReloadOutlined },
props: {
accountData: {
type: Object as PropType<Item>,
default: () => ({}),
},
},
setup(props) {
const accountInfo = computed(() => {
const data = props.accountData;
data.it_responsible = props.accountData?.cost_data?.it_responsible ?? "-";
return data;
});
const rolesCount = computed(() => {
return accountInfo.value?.idp_user_roles?.length || 0;
});
const { loginUrl } = useGetLoginUrl();
const {
editVisible,
formVisible,
validateInfos,
formLoading,
formState,
fpcOptions,
accountAreaOptions,
accountStageOptions,
accountTypeOptions,
preEditAccount,
handleOk,
postponeDisabled,
timeDiff,
postponesleft,
postponeSuspension,
accountSuspensionVisible,
editDisabledMap,
updateBtnDisabled,
} = useGetAccountInfo(accountInfo.value);
watch(accountInfo, (newValue) => {
useGetAccountInfo(newValue);
}, { immediate: true });
return {
loginUrl,
editVisible,
rolesCount,
accountInfo,
accountInfoFields,
formState,
formVisible,
formLoading,
preEditAccount,
handleOk,
labelCol: { span: 8 },
wrapperCol: { span: 14 },
title: ref("Update Ali Account Record in MongoDB"),
bodystyle: {
height: "480px",
overflowY: "scroll",
},
fpcOptions,
accountAreaOptions,
accountStageOptions,
accountTypeOptions,
postponeDisabled,
timeDiff,
postponesleft,
postponeSuspension,
accountSuspensionVisible,
editDisabledMap,
updateBtnDisabled,
validateInfos,
};
},
});
</script>
<style scoped lang="less">
.account-btns {
margin: 0.41667rem 0 1.25rem 0;
padding: 1.25rem 1.66667rem 0.41667rem 1.66667rem;
button {
margin: 0 5px;
}
}
</style>
import { computed, reactive, ref, toRefs, UnwrapRef, watch } from "vue";
import store from "@/store/index";
import {
getOrganizationsDetails,
getUpdateAccountInformation,
postponeAccount,
updateAccountInforamtion,
} from "../services";
import moment from "moment";
import { toRaw } from "vue";
import { checkValueAgainstList } from "@/utils/util";
import { Form } from "ant-design-vue";
import { checkResponsibility } from "@/composition/useGetResponsibility";
import { FormState, IRules } from "../types";
import { Modal } from "ant-design-vue";
const useForm = Form.useForm;
export function useGetAccountInfo(accountInfo) {
// debugger
// const accountDetail = {
// "_id": "66d6a7e11029debac193fd17",
// "account_area": "fpc",
// "account_description": "",
// "account_friendly_name": "Resource Directory Management Account",
// "account_id": "1151306510165868",
// "account_stage": "prod",
// "account_type": "secure",
// "action": "create-account",
// "app_id": "APP-26165",
// "approval_status": "APPROVED",
// "cloudroom_organisation": "BMWCHINA",
// "creation_date": "2024-01-31 22:06:18",
// "description": "",
// "fpc_status": "enabled",
// "manager_responsible": "",
// "master_account": "1151306510165868",
// "orders": {},
// "org_id": "rd-cEFT62",
// "org_ou_id": "",
// "org_ou_name": "",
// "org_status": "ACTIVE",
// "primary_responsible": "chengjun.wang@bmw.com",
// "proposer": "automation.proposer@bmwgroup.com",
// "region_category": "China",
// "sec_responsible": "haihui.jiang@partner.bmw.com",
// "approval_expires": "2025-11-17 16:22:15",
// "audit_status": "APPROVED",
// "org_status_update": "2024-01-31 22:06:18",
// "app_name": "Telematics Location Platform",
// "approval_reviewed_at": 1732263735.017,
// "approval_reviewed_by": "yachao.he@partner.bmw.com",
// "suspension_postpones_left": "2",
// "access_update": "-",
// "it_responsible": "-"
// }
// let accountInfo = ref({})
console.log(accountInfo,'----accountInfo-----useGetAccountInfo----')
console.log(accountInfo.value,'----accountInfo.value-----useGetAccountInfo----')
// watch(accountDetail, (newValue) => {
// console.log(newValue,'-------------newValue---------------')
// // useGetAccountInfo(newValue);
// accountInfo.value = newValue;
// }, { immediate: true });
const { userId, permissions, accountAreas } = toRefs(store.state.user);
const updateBtnDisabled = ref(false);
let area_admin = false;
const responsible = checkResponsibility(accountInfo, userId.value);
if (accountInfo?.account_area) {
area_admin = checkValueAgainstList(
accountInfo.account_area,
accountAreas.value
);
}
const manage_organizations = checkValueAgainstList(
"manage_organizations",
permissions.value
);
const manage_accounts = checkValueAgainstList(
"manage_accounts",
permissions.value
);
const editVisible = computed(
() => manage_organizations || manage_accounts || responsible || area_admin
);
const editDisabledMap = reactive({
region_category: true,
master_account: true,
account_id: true,
creation_date: true,
fpc_status: true,
account_friendly_name: true,
description: true,
account_area: true,
account_type: true,
account_stage: true,
primary_responsible: true,
sec_responsible: true,
manager_responsible: true,
app_id: true,
});
const formVisible = ref<boolean>(false);
const formLoading = ref(false);
const preEditAccount = async () => {
formLoading.value = true;
formVisible.value = true;
await loadSettings();
formLoading.value = false;
};
const formState: UnwrapRef<FormState> = reactive({
region_category: "",
master_account: "",
account_id: "",
creation_date: "",
fpc_status: "",
account_friendly_name: "",
description: "",
account_area: "",
account_type: "",
account_stage: "",
primary_responsible: "",
sec_responsible: "",
manager_responsible: "",
app_id: "",
});
const rulesRef = reactive<IRules>({
region_category: [],
master_account: [],
account_id: [],
creation_date: [],
fpc_status: [],
account_friendly_name: [
{ message: "Please input Friendly Name", required: true },
],
description: [],
account_area: [{ message: "Please select Account Area", required: true }],
account_type: [{ message: "Please select Account Type", required: true }],
account_stage: [{ message: "Please select Account Stage", required: true }],
primary_responsible: [
{ message: "Please input Primary Responsible", required: true },
],
sec_responsible: [],
manager_responsible: [],
app_id: [],
});
const { resetFields, validate, validateInfos } = useForm(formState, rulesRef);
const handleOk = () => {
const rawState = toRaw(formState);
const payload = { ...rawState };
delete payload.creation_date;
validate().then(() => {
formLoading.value = true;
updateBtnDisabled.value = true;
updateAccountInforamtion(payload)
.then(() => {
location.reload();
})
.finally(() => {
resetFields();
formLoading.value = false;
formVisible.value = false;
updateBtnDisabled.value = false;
});
});
};
const editFields = [
"region_category",
"master_account",
"account_id",
"creation_date",
"fpc_status", //
"account_friendly_name",
"description",
"account_area",
"account_type",
"account_stage",
"primary_responsible",
"sec_responsible",
"manager_responsible",
"app_id",
];
function parseText(encodedStr) {
const parser = new DOMParser();
const dom = parser.parseFromString(encodedStr, "text/html");
return dom.body.textContent;
}
// fill the edit account form with current account information
function editAccount(settings, account_data) {
const { update_account_information: update_settings } = settings;
editFields.forEach(function (item) {
switch (item) {
case "description":
if (account_data[item]) {
formState[item] = parseText(account_data[item]) as string;
} else {
formState[item] = "";
}
break;
case "legacy":
if (account_data[item]) {
formState[item] = account_data[item];
} else {
formState[item] = "legacy";
}
break;
default:
if (account_data[item]) {
formState[item] = account_data[item];
} else {
formState[item] = "";
}
}
});
updateAccountAreas(settings, account_data);
// TODO: 延长账号使用时间
updatePostpone(account_data);
// 初始化editDisabledMap先全部disabled:true 禁掉
// 允许edit的项
updateFormItemEnabled(update_settings, account_data);
updateFpcStatus();
// editDisabledMap.account_type
if (accountTypeOptions.value.length === 0) {
delete rulesRef.account_type;
editDisabledMap.account_type = true;
} else {
editDisabledMap.account_type = false;
rulesRef.account_type = [
{ message: "Please select Account Type", required: true },
];
}
}
const editFieldsDisabledDeleted = ["fpc_status"];
function updateFpcStatus() {
const fpc_status = formState.fpc_status;
switch (fpc_status) {
case "deleted":
editFieldsDisabledDeleted.forEach(function (item) {
editDisabledMap[item] = true;
});
break;
case "halt":
Object.keys(editDisabledMap)
.filter((item) => {
return item !== "fpc_status";
})
.forEach((item) => {
editDisabledMap[item] = true;
});
break;
default:
}
}
interface IOption {
label: string;
value: string;
}
const fpcOptions = ref<IOption[]>([]);
const accountAreaOptions = ref<IOption[]>([]);
const accountStageOptions = ref<IOption[]>([]);
const accountTypeOptions = ref<IOption[]>([]);
function updateFpcStatusDropdown() {
// 先清空
fpcOptions.value.length = 0;
const fpc_stats = {
new: "New",
enabled: "Enabled",
halt: "Halt",
};
// const current_fpc_status = accountInfo.value['fpc_status']
// if (!fpc_stats[current_fpc_status]) {
// fpc_stats[current_fpc_status] = current_fpc_status
// }
for (const i in fpc_stats) {
fpcOptions.value.push({
label: fpc_stats[i],
value: i,
});
}
// console.log('fpcOptions', fpcOptions)
}
function getAccountStageOptions(account_data) {
const appid = account_data.app_id;
const appid_result = appid_pattern.test(appid);
const stages = {
pending: "pending",
};
if (appid_result) {
stages["dev"] = "dev";
}
if (appid_result) {
stages["test"] = "test";
stages["prod"] = "prod";
}
// if (!(account_data.account_stage in stages)) {
// stages[account_data.account_stage] = account_data.account_stage
// }
// 先清空
accountStageOptions.value.length = 0;
Object.keys(stages).forEach((key) => {
accountStageOptions.value.push({
label: key,
value: stages[key],
});
});
// console.log("accountStageOptions", accountStageOptions);
}
function updateAccountAreas(settings, account_data) {
// TODO: 获取accountAreaOptions
const masterAccount = account_data.master_account;
const accountArea = account_data.account_area;
const { organizations_details: orgDetailsSettings } = settings;
const { account_areas: masterAccountAreas = [] } =
orgDetailsSettings[masterAccount] || {};
// console.log('masterAccountAreas', masterAccountAreas)
const areas: Record<string, string> = {};
masterAccountAreas.forEach((item) => {
areas[item.value] = item.name;
});
// if (Object.keys(areas).length === 0) {
// areas['unknown'] = '-'
// }
if (accountArea && !(accountArea in areas)) {
areas[accountArea] = accountArea;
}
// 先清空
accountAreaOptions.value.length = 0;
Object.keys(areas).forEach((key) => {
accountAreaOptions.value.push({
label: areas[key],
value: key,
});
if (!accountArea && key === "fpc") {
formState.account_area = areas[key];
}
});
// console.log('accountAreaOptions', accountAreaOptions)
updateFpcStatusDropdown();
getAccountTypeOptions(settings, account_data);
}
watch(
() => formState.account_area,
(val, oldVal) => {
if (oldVal) {
formState.account_type = "";
}
getAccountTypeOptions(settings, formState);
}
);
watch(
() => [...accountTypeOptions.value],
(val) => {
if (val.length === 0) {
delete rulesRef.account_type;
editDisabledMap.account_type = true;
} else {
editDisabledMap.account_type = false;
rulesRef.account_type = [
{ message: "Please select Account Type", required: true },
];
}
},
{
immediate: true,
}
);
function getAccountTypeOptions(settings, account_data) {
const masterAccount = formState.master_account as string;
const accountArea = formState.account_area;
const { organizations_details: orgDetailsSettings } = settings;
const { account_areas: masterAccountAreas = [] } =
orgDetailsSettings[masterAccount] || {};
const types = {};
masterAccountAreas.forEach((item) => {
if (item.value === accountArea) {
item["account_types"].forEach((sub_item) => {
types[sub_item["value"]] = sub_item["name"];
});
}
});
// 先清空
accountTypeOptions.value.length = 0;
Object.keys(types).forEach((key) => {
accountTypeOptions.value.push({
label: types[key],
value: key,
});
});
getAccountStageOptions(account_data);
// console.log('accountTypeOptions', accountTypeOptions)
}
const postponeDisabled = ref(false);
const postponesleft = ref(0);
const timeDiff = ref(0);
const piaVisible = ref(false);
const accountSuspensionVisible = ref(false);
function updatePostpone(account_data) {
// 获取今天到截止时间的剩余时间 =》 账号还有多少天不能用
const days_left = updateSuspensionDate(account_data);
// appid_pattern: 使用后端传回的正则表达式
const appid_result = appid_pattern.test(account_data.app_id);
if (account_data.account_stage === "pending") {
if (!appid_result) {
postponeDisabled.value = false;
if (account_data.suspension_postpones_left) {
const suspension_postpones_left = parseInt(
account_data.suspension_postpones_left
);
if (suspension_postpones_left < 1) {
postponeDisabled.value = true;
}
postponesleft.value = account_data.suspension_postpones_left;
} else {
postponeDisabled.value = true;
postponesleft.value = 0;
}
if (days_left > 5) {
postponeDisabled.value = true;
}
piaVisible.value = false;
accountSuspensionVisible.value = true;
} else {
piaVisible.value = true;
accountSuspensionVisible.value = false;
}
} else if (account_data.account_stage === "legacy") {
accountSuspensionVisible.value = false;
if (!appid_result) {
piaVisible.value = false;
} else {
piaVisible.value = true;
}
} else if (
account_data.account_stage === "dev" ||
account_data.account_stage === "test" ||
account_data.account_stage === "prod"
) {
piaVisible.value = true;
accountSuspensionVisible.value = false;
}
}
function postponeSuspension() {
Modal.confirm({
title: () => "Are you sure?",
content: () =>
"Are you sure you want to postpone the account suspension?",
onOk() {
formLoading.value = true;
postponeAccount(accountInfo.account_id)
.then(() => {
formVisible.value = false;
formLoading.value = false;
location.reload();
})
.finally(() => {
formLoading.value = false;
});
},
cancelText: "Cancel",
});
}
// returns the difference in days between today and the account suspension date
function updateSuspensionDate(d) {
let suspension_days;
if (d.suspension_days) {
suspension_days = parseInt(d.suspension_days);
} else {
// suspend default 30 days
suspension_days = 30;
}
const today = moment();
const creation_date = new Date(d.creation_date);
const suspension_date = moment(creation_date).add(suspension_days, "days");
timeDiff.value = Math.ceil(
moment(suspension_date).diff(today, "days", true)
);
return timeDiff.value;
}
function updateFormItemEnabled(update_settings, account_data) {
let updateEnabled = true;
// 按条件 允许edit的项
if (manage_organizations) {
update_settings["org_admin_allowed_updates"].forEach((item) => {
if (Object.keys(editDisabledMap).includes(item)) {
editDisabledMap[item] = false;
}
});
} else if (manage_accounts) {
update_settings["admin_allowed_updates"].forEach(function (item) {
if (Object.keys(editDisabledMap).includes(item)) {
editDisabledMap[item] = false;
}
});
} else if (responsible || area_admin) {
update_settings["responsible_allowed_updates"].forEach(function (item) {
if (Object.keys(editDisabledMap).includes(item)) {
editDisabledMap[item] = false;
}
});
} else {
updateEnabled = false;
}
// form更新按钮
updateBtnDisabled.value = !updateEnabled;
// TODO: 先不加 ==== start ====
// const cloudroomDataRegion = account_data.region_category || ''
// let cloudroomOrganisation = account_data.cloudroom_organisation
// if (!cloudroomOrganisation) cloudroomOrganisation = cloudroomDataRegion.toLowerCase() === 'china' ? 'BMWCHINA' : 'BMWGROUP'
// // in this way we make the attribute editable manually for China
// if (cloudroomOrganisation !== 'BMWCHINA' || (cloudroomOrganisation === 'BMWCHINA' && !(responsible || area_admin || manage_accounts))) {
// editDisabledMap.app_id = true
// editDisabledMap.appd_id = true
// editDisabledMap.cost_center = true
// editDisabledMap.psp = true
// }
// TODO: ==== end ====
}
let appid_pattern;
let settings;
async function loadSettings() {
await Promise.all([
getOrganizationsDetails(),
getUpdateAccountInformation(),
]).then((res) => {
settings = {
organizations_details: res[0],
update_account_information: res[1],
};
const regex = res[1].regex;
Object.keys(regex).forEach((item) => {
if (item in rulesRef && item !== "creation_date") {
rulesRef[item].push({
pattern: new RegExp(regex[item]),
message: `does not match pattern /${regex[item]}/`,
});
}
if (item === "app_id") {
appid_pattern = new RegExp(regex[item]);
}
});
});
console.log(accountInfo,'----accountInfo-----edit----')
editAccount(settings, accountInfo);
}
return {
editVisible,
preEditAccount,
handleOk,
formVisible,
formLoading,
formState,
fpcOptions,
accountAreaOptions,
accountStageOptions,
accountTypeOptions,
postponeDisabled,
postponesleft,
timeDiff,
postponeSuspension,
accountSuspensionVisible,
editDisabledMap,
updateBtnDisabled,
validateInfos,
};
}
<script lang="ts">
import { computed, defineComponent, PropType, ref, watch } from "vue";
import { Item } from "../types";
import DetailList from "@/components/DetailList/index.vue";
import { EditOutlined, ReloadOutlined } from "@ant-design/icons-vue";
import { useGetAccountInfo } from "./Cloudroom";
import { accountInfoFields } from "../config";
import { useGetLoginUrl } from "@/composition/useGetLoginUrl";
export default defineComponent({
name: "CloudRoom",
components: { DetailList, EditOutlined, ReloadOutlined },
props: {
accountData: {
type: Object as PropType<Item>,
default: () => ({}),
},
},
setup(props) {
const accountInfo = computed(() => {
const data = props.accountData;
data.it_responsible = props.accountData?.cost_data?.it_responsible ?? "-";
return data;
});
const rolesCount = computed(() => {
return accountInfo.value?.idp_user_roles?.length || 0;
});
const { loginUrl } = useGetLoginUrl();
// 新增的 watch 监听
const {
editVisible,
formVisible,
validateInfos,
formLoading,
formState,
fpcOptions,
accountAreaOptions,
accountStageOptions,
accountTypeOptions,
preEditAccount,
handleOk,
postponeDisabled,
timeDiff,
postponesleft,
postponeSuspension,
accountSuspensionVisible,
editDisabledMap,
updateBtnDisabled,
} = ref({}); // 初始化为一个空对象
watch(accountInfo, (newValue) => {
if (newValue) {
// 只有在 accountInfo 有数据时才调用 useGetAccountInfo
const accountInfoData = useGetAccountInfo(newValue);
Object.assign(accountInfo, accountInfoData);
}
});
return {
loginUrl,
editVisible,
rolesCount,
accountInfo,
accountInfoFields,
formState,
formVisible,
formLoading,
preEditAccount,
handleOk,
labelCol: { span: 8 },
wrapperCol: { span: 14 },
title: ref("Update Ali Account Record in MongoDB"),
bodystyle: {
height: "480px",
overflowY: "scroll",
},
fpcOptions,
accountAreaOptions,
accountStageOptions,
accountTypeOptions,
postponeDisabled,
timeDiff,
postponesleft,
postponeSuspension,
accountSuspensionVisible,
editDisabledMap,
updateBtnDisabled,
validateInfos,
};
},
});
</script>
function filterUniqueValuesByPlatform(data, platform) {
const seenValues = new Set();
const result = [];
for (const item of data) {
if (!seenValues.has(item.value)) {
// 如果该项的 value 还未被记录,则添加到结果中
seenValues.add(item.value);
result.push(item);
} else {
// 如果该项的 value 已经存在,检查平台
const existingItem = result.find(existing => existing.value === item.value);
if (existingItem.platform !== platform && item.platform === platform) {
// 如果已有项的平台与当前项不同且当前项的平台匹配,则替换
const index = result.indexOf(existingItem);
result[index] = item; // 替换为当前项
}
}
}
return result;
}