Commit 2a833fc7 by wangzhihui

```

feat(api): 新增驻店管理相关API接口

新增以下API函数:
- assignStoreV2Api: 分配门店v2版本接口
- accountRecordListApi: 账号记录列表接口
- accountRecordDetailApi: 账号记录详情接口
- disableAccountV2Api: 禁用账号v2版本接口
- query4sByYqMerchantApi: 根据园区店查询4S店接口
```
1 parent 9af15414
......@@ -808,6 +808,32 @@ export function assignStoreApi(data = {}) {
data.method = "dj.api.smartcarlife.staffBaseInfo.account.merchant.assign";
return request(data, "post");
}
export function assignStoreV2Api(data = {}) {
data.method =
"dj.api.smartcarlife.staffBaseInfo.account.merchant.assign.v2";
return request(data, "post");
}
export function accountRecordListApi(data = {}) {
data.method = "dj.api.smartcarlife.staffBaseInfo.accountRecord.list";
return request(data, "post");
}
export function accountRecordDetailApi(data = {}) {
data.method = "dj.api.smartcarlife.staffBaseInfo.accountRecord.detail";
return request(data, "post");
}
export function disableAccountV2Api(data = {}) {
data.method = "dj.api.smartcarlife.staffBaseInfo.account.disable.v2";
return request(data, "post");
}
export function query4sByYqMerchantApi(data = {}) {
data.method = "dj.api.smartcarlife.merchant.scene.query4sByYqMerchant";
return request(data, "post");
}
//北森岗位
export function beiSenJobPostPageApi(data = {}) {
data.method = "dj.api.smartcarlife.staffBaseInfo.beiSenJobPost.page";
......
......@@ -15,7 +15,7 @@
</el-row>
<el-row style="font-size: 14px; line-height: 28px;">
<el-col :span="24">
<span style="color: #666;">门店:</span><span style="color: #333;">{{ merchantName }}</span>
<span style="color: #666;">园区店:</span><span style="color: #333;">{{ merchantName }}</span>
</el-col>
</el-row>
</div>
......@@ -33,7 +33,7 @@
</template>
<script>
import { beiSenEmployeeDisableApi } from "@/api/resident";
import { disableAccountV2Api } from "@/api/resident";
export default {
name: "DisableAccountDialog",
......@@ -82,14 +82,14 @@ export default {
}
},
merchantName() {
return this.currentRow ? this.currentRow.merchantName : '';
return this.currentRow ? this.currentRow.yqMerchantName : '';
}
},
methods: {
confirmDisable() {
if (!this.currentRow) return;
const row = this.currentRow;
beiSenEmployeeDisableApi({ accountId: row.id }).then(() => {
disableAccountV2Api({ accountRecordId: row.accountRecordId }).then(() => {
this.$message.success('账号已禁用');
this.visible = false;
this.$emit("refreshDetail");
......
......@@ -191,28 +191,50 @@
<h2>账号信息</h2>
<div class="info-wrap">
<div class="info-item-line">
<d2-table ref="allocateStoreTable" :table-params="tableParams" :table-data="tableData"
:has-page="false">
<template slot="brand" slot-scope="scope">
<el-popover v-if="scope.scope.carBrand" placement="top" width="300" trigger="hover">
<div class="merchant-name-box">
{{ remarkFilter(scope.scope) }}
</div>
<div slot="reference">
{{ remarkFilter(scope.scope, 20) }}
</div>
</el-popover>
<span v-else>-</span>
</template>
<template slot="operationHtml" slot-scope="scope">
<!-- N:未删除;I:禁用 -->
<el-switch v-model="scope.scope.deletedFlag" active-value="N" inactive-value="I"
@change="(e) => switchChange(scope.scope)"></el-switch>
<span class="switch-text">{{ scope.scope.deletedFlag === 'N' ? '禁用账号' : '启用账号'
}}</span>
</template>
</d2-table>
<el-table :data="tableData" border style="width: 100%" :span-method="objectSpanMethod">
<el-table-column label="序号" width="60" align="center">
<template slot-scope="scope">
{{ getIndex(scope.$index) }}
</template>
</el-table-column>
<el-table-column prop="yqMerchantName" label="园区店" width="180" align="center">
<template slot-scope="scope">
{{ scope.row.yqMerchantName ? `${scope.row.yqMerchantName}${scope.row.yqMerchantId}` :
'-' }}
</template>
</el-table-column>
<el-table-column prop="merchantName" label="门店" width="250" align="center">
<template slot-scope="scope">
{{ scope.row.merchantName || '-' }}
</template>
</el-table-column>
<el-table-column label="适配业务" min-width="150" align="center">
<template slot-scope="scope">
{{ scope.row.accountSceneStr || '-' }}
</template>
</el-table-column>
<el-table-column label="驻店类型" width="150" align="center">
<template slot-scope="scope">
{{ scope.row.stationType === 1 ? '门店常驻' : scope.row.stationType === 2 ? '临时调动支援' : '-'
}}
</template>
</el-table-column>
<el-table-column label="开通时间" width="160" align="center">
<template slot-scope="scope">
{{ scope.row.createdDate ? formatDate(scope.row.createdDate) : '-' }}
</template>
</el-table-column>
<el-table-column prop="createdBy" label="开通人" width="150"></el-table-column>
<el-table-column label="操作" width="200" align="center">
<template slot-scope="scope">
<el-switch v-model="scope.row.deletedFlag" active-value="N" inactive-value="I"
@change="(e) => switchChange(scope.row)"></el-switch>
<span class="switch-text">{{ scope.row.deletedFlag === 'N' ? '禁用账号' : '启用账号' }}</span>
<el-button type="text" style="margin-left: 10px;"
@click="handleEditAccount(scope.row)">编辑</el-button>
</template>
</el-table-column>
</el-table>
</div>
<el-button size="small" @click="handleAllocateStore" class="add-allocate"
icon="el-icon-plus">新增门店账号</el-button>
......@@ -687,6 +709,12 @@
:formatted-scene-label="currentDisableRow ? currentDisableRow.accountSceneStr : ''" v-if="disableDialogVisible"
@dialogClose="closeDisableDialog" @refreshDetail="getDetail" @disableFailed="handleDisableFailed">
</disable-account-dialog>
<!-- 编辑门店权限弹窗 -->
<edit-store-permission-dialog v-if="editPermissionVisible" :visibleSync.sync="editPermissionVisible"
:detail="{ ...detail, staffId: queryData.id }" :currentRow="currentEditRow"
@refreshTable="closeEditPermissionDialog">
</edit-store-permission-dialog>
</div>
</template>
......@@ -697,8 +725,9 @@ import dayjs from "dayjs";
import assignStoreDialog from "./assignStoreDialog.vue";
import syncBeiSenDialog from "./syncBeiSenDialog.vue";
import disableAccountDialog from "./disableAccountDialog.vue";
import editStorePermissionDialog from "./editStorePermissionDialog.vue";
import { updateRecordOrderConfig } from "@api/inStoreManage";
import { updateBatchSalary, beiSenEmployeeDisableApi } from "@/api/resident";
import { updateBatchSalary, accountRecordListApi, disableAccountV2Api } from "@/api/resident";
import { staffLevelList, staffSceneLabelList } from "@/common/constants";
import { Util, deepClone } from "@/common/util";
import {
......@@ -723,6 +752,7 @@ export default {
AssignStoreDialog: assignStoreDialog,
syncBeiSenDialog,
disableAccountDialog,
editStorePermissionDialog
},
props: {
queryData: {
......@@ -1006,6 +1036,13 @@ export default {
// 禁用账号弹窗相关
disableDialogVisible: false,
currentDisableRow: null,
// 编辑权限弹窗相关
editPermissionVisible: false,
currentEditRow: null,
spanArr: [],
pos: 0
};
},
mounted() {
......@@ -1247,10 +1284,80 @@ export default {
}
this.detail = Object.assign(res, bsEffectiveRule) || {};
console.log(this.detail, " this.detail");
this.tableData = res?.accountRecordList || [];
this.getAccountRecordList();
}
);
},
getAccountRecordList() {
accountRecordListApi({ staffPhone: this.queryData?.staffPhone }).then(res => {
this.formatTableData(res || []);
});
},
formatTableData(data) {
let flatData = [];
data.forEach(park => {
if (park.fourSShopList && park.fourSShopList.length > 0) {
park.fourSShopList.forEach(shop => {
let accountSceneStr = (shop.sceneList || []).map(s => s.name).join(', ');
flatData.push({
staffPhone: park.staffPhone,
yqMerchantId: park.yqMerchantId,
yqMerchantName: park.yqMerchantName,
accountRecordId: shop.accountRecordId,
merchantId: shop.merchantId,
merchantName: shop.merchantName,
stationType: shop.stationType,
sceneList: shop.sceneList || [],
accountSceneStr: accountSceneStr,
createdDate: shop.createdDate,
createdBy: shop.createdBy,
deletedFlag: shop.deletedFlag
});
});
}
});
this.tableData = flatData;
this.getSpanArr(this.tableData);
},
getSpanArr(data) {
this.spanArr = [];
this.pos = 0;
for (let i = 0; i < data.length; i++) {
if (i === 0) {
this.spanArr.push(1);
this.pos = 0;
} else {
if (data[i].yqMerchantId === data[i - 1].yqMerchantId) {
this.spanArr[this.pos] += 1;
this.spanArr.push(0);
} else {
this.spanArr.push(1);
this.pos = i;
}
}
}
},
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
// Merge 序号(0), 园区店(1), 操作(7)
if (columnIndex === 0 || columnIndex === 1 || columnIndex === 7) {
const _row = this.spanArr[rowIndex];
const _col = _row > 0 ? 1 : 0;
return {
rowspan: _row,
colspan: _col
};
}
},
getIndex(index) {
let count = 0;
for (let i = 0; i <= index; i++) {
if (this.spanArr[i] > 0) count++;
}
return count;
},
formatDate(date) {
return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
},
// 获取帮带导师数据
getResidentTeacherList() {
getResidentTeacherListApi({
......@@ -1309,7 +1416,7 @@ export default {
} else {
// 当切换到启用时,直接调用接口
beiSenEmployeeDisableApi({ accountId: row.id }).then(() => {
disableAccountV2Api({ accountRecordId: row.accountRecordId }).then(() => {
this.$message.success('账号已启用');
this.getDetail();
}).catch(() => {
......@@ -1326,6 +1433,16 @@ export default {
this.currentDisableRow = null;
},
handleEditAccount(row) {
this.currentEditRow = row;
this.editPermissionVisible = true;
},
closeEditPermissionDialog() {
this.getDetail(); // refresh data
this.editPermissionVisible = false;
},
handleDisableFailed(row) {
if (row) {
row.deletedFlag = 'N'; // 恢复状态
......@@ -1581,6 +1698,7 @@ export default {
this.getDetail();
this.allocateStoreVisible = !this.allocateStoreVisible;
},
......
<template>
<baseDialog :dialog-config="dialogConfig" :config="config" :is-show.sync="visible" @handleClick="handleConfirm">
<div class="edit-permission-dialog">
<div class="tip-banner">
可调整门店的业务场景权限(不勾选视为未开通该门店权限)
</div>
<div class="park-store-name">
园区店:{{ currentRow.yqMerchantName }}
</div>
<div class="table-container" v-loading="loading">
<el-table :data="tableData" border style="width: 100%">
<el-table-column prop="shopMerchantName" label="门店" width="220"></el-table-column>
<el-table-column label="开单业务场景(可多选)" min-width="300">
<template slot-scope="scope">
<el-checkbox-group v-model="scope.row.checkedScenes">
<el-checkbox v-for="scene in scope.row.sceneList" :key="scene.baseSceneCode"
:label="scene.baseSceneCode">{{ scene.sceneName }}</el-checkbox>
</el-checkbox-group>
</template>
</el-table-column>
<el-table-column label="驻店类型" width="250">
<template slot-scope="scope">
<el-radio-group v-model="scope.row.stationType">
<el-radio :label="1">门店常驻</el-radio>
<el-radio :label="2">临时调动支援</el-radio>
</el-radio-group>
</template>
</el-table-column>
</el-table>
<div class="tips-block">
<div style="display: flex; align-items: flex-start;">
<i class="el-icon-info" style="color: #409EFF; margin-top: 3px; margin-right: 5px;"></i>
<div>
<div style="font-weight: bold;">提示:</div>
<div>1. 不勾选某个门店的业务场景,视为该人员未开通该门店的业务权限。</div>
<div>2. 一次性不要超过10个门店的场景分配,避免页面卡顿负载。</div>
</div>
</div>
</div>
</div>
</div>
</baseDialog>
</template>
<script>
import { query4sByYqMerchantApi, accountRecordDetailApi, assignStoreV2Api } from "@api/resident";
export default {
name: "EditStorePermissionDialog",
props: {
visibleSync: {
type: Boolean,
default: false,
},
detail: {
type: Object,
default: () => ({}),
},
currentRow: {
type: Object,
default: () => ({}),
}
},
data() {
return {
config: {
showClose: true,
appendToBody: false,
isShowFooter: true,
cancel_name: "取消",
confirm_name: "保存",
},
dialogConfig: {
title: "编辑门店权限",
width: "1080px",
},
tableData: [],
loading: false,
};
},
computed: {
visible: {
get() {
return this.visibleSync;
},
set(newVal) {
this.$emit("update:visibleSync", newVal);
},
},
},
mounted() {
this.initData();
},
methods: {
async initData() {
this.loading = true;
try {
// 1. 获取全量园区店下所有4s店及场景
const allStoresRes = await query4sByYqMerchantApi({
yqMerchantIdList: [this.currentRow.yqMerchantId]
});
let allStores = [];
if (allStoresRes && allStoresRes.length > 0 && allStoresRes[0].shopList) {
allStores = allStoresRes[0].shopList;
}
// 2. 获取已选择的园区店信息
const detailRes = await accountRecordDetailApi({
accountRecordId: this.currentRow.accountRecordId
});
let selectedStores = [];
if (detailRes && detailRes.fourSShopList) {
selectedStores = detailRes.fourSShopList;
}
// 3. 回显数据映射
const formattedData = [];
allStores.forEach(shop => {
const matchedSelected = selectedStores.find(s => s.merchantId === shop.shopMerchantId);
let checkedScenes = [];
let stationType = 1;
if (matchedSelected) {
checkedScenes = (matchedSelected.sceneList || []).map(s => s.baseSceneCode);
stationType = matchedSelected.stationType || 1;
}
formattedData.push({
yqMerchantId: this.currentRow.yqMerchantId,
yqMerchantName: this.currentRow.yqMerchantName,
shopMerchantId: shop.shopMerchantId,
shopMerchantName: shop.shopMerchantName,
sceneList: shop.sceneList || [],
checkedScenes: checkedScenes,
stationType: stationType
});
});
this.tableData = formattedData;
} catch (error) {
console.error(error);
} finally {
this.loading = false;
}
},
handleConfirm() {
// 校验:所有渲染出来的门店中,必须至少勾选一个场景才能提交
let hasSelectedAtLeastOneScene = false;
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].checkedScenes && this.tableData[i].checkedScenes.length > 0) {
hasSelectedAtLeastOneScene = true;
break;
}
}
if (!hasSelectedAtLeastOneScene) {
return this.$message.warning("请至少勾选一个开单业务场景");
}
const fourSShopList = [];
this.tableData.forEach(row => {
if (!row.checkedScenes || row.checkedScenes.length === 0) {
return;
}
const sceneList = row.checkedScenes.map(code => {
const sceneObj = row.sceneList.find(s => s.baseSceneCode === code);
return {
baseSceneCode: code,
sceneType: sceneObj ? sceneObj.sceneType : null
};
});
fourSShopList.push({
merchantId: row.shopMerchantId,
merchantName: row.shopMerchantName,
stationType: row.stationType,
sceneList: sceneList
});
});
const shopItemList = [
{
yqMerchantId: this.currentRow.yqMerchantId,
yqMerchantName: this.currentRow.yqMerchantName,
fourSShopList: fourSShopList
}
];
const params = {
staffId: this.detail.staffId || this.detail.id,
staffPhone: this.detail.staffPhone,
staffName: this.detail.staffName,
shopItemList: shopItemList,
editFlag: true // 编辑标识
};
assignStoreV2Api(params).then(() => {
this.$message.success("编辑门店权限成功");
this.$emit("refreshTable");
this.visible = false;
});
}
}
};
</script>
<style scoped lang="scss">
.edit-permission-dialog {
padding: 0 10px;
}
.tip-banner {
background-color: #f4f7fc;
color: #2a58ad;
padding: 12px 16px;
border-radius: 4px;
font-size: 14px;
margin-bottom: 16px;
}
.park-store-name {
font-size: 14px;
color: #666;
margin-bottom: 16px;
}
.table-container {
margin-top: 15px;
}
.tips-block {
background: #f4f4f5;
padding: 15px;
margin-top: 15px;
border-radius: 4px;
font-size: 13px;
color: #606266;
line-height: 1.6;
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!