|
|
@@ -7,7 +7,7 @@
|
|
|
type="primary"
|
|
|
@click="toggleMypageAccess"
|
|
|
>
|
|
|
- {{ memberForm.mypageAccessAuth === 1 ? 'マイページ利用可' : 'マイページ利用停止' }}
|
|
|
+ {{ memberForm.myPageAccessAuth === 1 ? 'マイページ利用可' : 'マイページ利用停止' }}
|
|
|
</el-button>
|
|
|
<el-button type="primary" @click="submitForm" >会員情報保存</el-button>
|
|
|
</el-form-item>
|
|
|
@@ -47,7 +47,7 @@
|
|
|
<el-option label="VIP" :value="3"></el-option>
|
|
|
</el-select>
|
|
|
</template>
|
|
|
- <template v-else-if="item.prop === 'mypageAccessAuth'">
|
|
|
+ <template v-else-if="item.prop === 'myPageAccessAuth'">
|
|
|
<el-select v-model="memberForm[item.prop]" :disabled="item.disabled" class="small-input">
|
|
|
<el-option label="利用可" :value="1"></el-option>
|
|
|
<el-option label="利用停止" :value="0"></el-option>
|
|
|
@@ -91,7 +91,7 @@
|
|
|
<el-option label="VIP" :value="3"></el-option>
|
|
|
</el-select>
|
|
|
</template>
|
|
|
- <template v-else-if="item.prop === 'mypageAccessAuth'">
|
|
|
+ <template v-else-if="item.prop === 'myPageAccessAuth'">
|
|
|
<el-select v-model="memberForm[item.prop]" :disabled="item.disabled" class="small-input">
|
|
|
<el-option label="利用可" :value="1"></el-option>
|
|
|
<el-option label="利用停止" :value="0"></el-option>
|
|
|
@@ -116,7 +116,7 @@
|
|
|
<template v-if="item.prop === 'posId'">
|
|
|
<el-input
|
|
|
v-model="posForm[item.prop]"
|
|
|
- :disabled="!!posForm.posId"
|
|
|
+ :disabled="posForm.isSaved"
|
|
|
class="small-input"
|
|
|
/>
|
|
|
</template>
|
|
|
@@ -164,7 +164,7 @@
|
|
|
<template v-if="item.prop === 'posId'">
|
|
|
<el-input
|
|
|
v-model="posForm[item.prop]"
|
|
|
- :disabled="!!posForm.posId"
|
|
|
+ :disabled="posForm.isSaved"
|
|
|
class="small-input"
|
|
|
placeholder="POSレジIDを入力"
|
|
|
/>
|
|
|
@@ -213,7 +213,7 @@
|
|
|
// 1. 基础依赖导入
|
|
|
import { reactive, ref } from 'vue';
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
-import { getMemberEdit, getMemberPosEdit,updateMember } from "@/api/fcbi/fcMember.js";
|
|
|
+import { getMemberEdit, getMemberPosEdit,updateMember,updatePos,addMemberPos } from "@/api/fcbi/fcMember.js";
|
|
|
import useTagsViewStore from '@/store/modules/tagsView';
|
|
|
import {formatMsg} from "@/utils/yamada.js";
|
|
|
|
|
|
@@ -250,7 +250,8 @@ const createNewPosForm = () => ({
|
|
|
posConfigVersion: '',
|
|
|
posLinkInfo: '',
|
|
|
customSettings: '',
|
|
|
- posUpdateReason: ''
|
|
|
+ posUpdateReason: '',
|
|
|
+ isSaved: false
|
|
|
});
|
|
|
|
|
|
// 初始添加一个POS表单
|
|
|
@@ -264,7 +265,7 @@ const addPosForm = () => {
|
|
|
|
|
|
// 切换我的页面权限状态
|
|
|
const toggleMypageAccess = () => {
|
|
|
- memberForm.mypageAccessAuth = memberForm.mypageAccessAuth === 1 ? 0 : 1;
|
|
|
+ memberForm.myPageAccessAuth = memberForm.myPageAccessAuth === 1 ? 0 : 1;
|
|
|
};
|
|
|
|
|
|
// 返回上一页
|
|
|
@@ -286,7 +287,7 @@ const formItems = [
|
|
|
{ label: '連絡先電話番号', prop: 'contactPhone' },
|
|
|
{ label: '会員活性状態', prop: 'activeStatus' },
|
|
|
{ label: '会員タイプ', prop: 'fcMemberType' },
|
|
|
- { label: 'マイページ権限', prop: 'mypageAccessAuth', disabled: true },
|
|
|
+ { label: 'マイページ権限', prop: 'myPageAccessAuth', disabled: true },
|
|
|
{ label: 'ログイン情報送信状態', prop: 'loginInfoSent', disabled: true },
|
|
|
{ label: '最終ログイン日時', prop: 'lastLoginDate', disabled: true },
|
|
|
{ label: 'ログイン情報送信日時', prop: 'loginInfoSentTime', disabled: true },
|
|
|
@@ -329,27 +330,70 @@ const fetchPosEdit = async () => {
|
|
|
const requestData = { fcMemberId };
|
|
|
const response = await getMemberPosEdit(requestData);
|
|
|
if (response.code === 200) {
|
|
|
- posForms.length = 0;
|
|
|
- if (response.data) {
|
|
|
- posForms.push(response.data);
|
|
|
+ posForms.length = 0; // 清空原有表单
|
|
|
+ if (response.rows && response.rows.length > 0) {
|
|
|
+ // 从 rows 中取数据,逐个处理为带 isSaved 的结构
|
|
|
+ response.rows.forEach(item => {
|
|
|
+ posForms.push({ ...item, isSaved: true });
|
|
|
+ });
|
|
|
} else {
|
|
|
+ // 无数据时,初始化一个空表单
|
|
|
posForms.push(createNewPosForm());
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 会員情報保存方法
|
|
|
+// 会員情報保存方法(包含POS数据的新增/更新逻辑)
|
|
|
const submitForm = async () => {
|
|
|
- const requestData = {
|
|
|
- ...memberForm
|
|
|
- };
|
|
|
+ // 1. 先保存会员基本信息
|
|
|
+ const memberResponse = await updateMember({...memberForm});
|
|
|
+ if (memberResponse.code !== 200) {
|
|
|
+ proxy.$modal.msgError(formatMsg('E0001')); // 会员信息保存失败提示
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- const response = await updateMember(requestData);
|
|
|
+ // 2. 处理POS表单数据(区分更新和新增)
|
|
|
+ // 2.1 筛选需要更新的POS数据(posId输入框被禁用,即isSaved为true)
|
|
|
+ const updatePosList = posForms.filter(pos => pos.isSaved);
|
|
|
+ // 2.2 筛选需要新增的POS数据(posId输入框未被禁用,即isSaved为false且posId不为空)
|
|
|
+ const addPosList = posForms.filter(pos => !pos.isSaved && pos.posId.trim() !== '');
|
|
|
|
|
|
- if (response.code === 200) {
|
|
|
- proxy.$modal.msgSuccess(formatMsg('I0001'));
|
|
|
- await initData();
|
|
|
+ // 3. 批量处理更新操作
|
|
|
+ if (updatePosList.length > 0) {
|
|
|
+ for (const posData of updatePosList) {
|
|
|
+ // 调用更新API,传入会员ID和POS数据
|
|
|
+ const updateResponse = await updatePos({
|
|
|
+
|
|
|
+ ...posData
|
|
|
+ });
|
|
|
+ if (updateResponse.code !== 200) {
|
|
|
+ proxy.$modal.msgError(`POS更新失败:${posData.posId}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ // 4. 批量处理新增操作
|
|
|
+ if (addPosList.length > 0) {
|
|
|
+ for (const posData of addPosList) {
|
|
|
+ // 调用新增API,传入会员ID和POS数据
|
|
|
+ const addResponse = await addMemberPos({
|
|
|
+ fcMemberId: memberForm.fcMemberId,
|
|
|
+ ...posData
|
|
|
+ });
|
|
|
+ if (addResponse.code !== 200) {
|
|
|
+ proxy.$modal.msgError(`POS新增失败:${posData.posId}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 新增成功后标记为已保存(禁用posId输入框)
|
|
|
+ posData.isSaved = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 所有操作成功后的提示与数据刷新
|
|
|
+ proxy.$modal.msgSuccess(formatMsg('I0001')); // 保存成功提示
|
|
|
+ await initData(); // 重新加载数据,确保界面显示最新状态
|
|
|
};
|
|
|
|
|
|
// 页面加载时获取数据
|