fix:供应商账单测试

This commit is contained in:
GaoHao
2025-04-08 11:18:37 +08:00
parent 164dd52afa
commit a2361b39c4
16 changed files with 396 additions and 148 deletions

View File

@@ -7,8 +7,14 @@
<el-input v-model="state.query.name" clearable placeholder="请输入分店名称" style="width: 100%" class="filter-item"
@keyup.enter="getTableData" />
</el-col>
<el-col :span="4">
<el-select v-model="state.par.dataSyncMethod" @change="setDataSync" placeholder="请设置同步方式"
style="width: 100%">
<el-option v-for="item in state.status" :key="item.type" :label="item.label" :value="item.type" />
</el-select>
</el-col>
<el-col :span="6">
<el-col :span="12">
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
</el-col>
@@ -19,41 +25,42 @@
<el-card shadow="never">
<el-table v-loading="state.tableData.loading" :data="state.tableData.list">
<el-table-column prop="status" label="ID" width="80" />
<el-table-column label="店铺信息" >
<el-table-column label="店铺信息">
<template v-slot="scope">
<div>{{ scope.row.shopName }}{{ scope.row.shopName }}</div>
<div>账号{{ scope.row.shopName }}</div>
<div>账号{{ scope.row.account }}</div>
<div>联系电话{{ scope.row.phone }}</div>
</template>
</el-table-column>
<el-table-column prop="status" label="商品同步" width="120">
<el-table-column prop="isEnableProdSync" label="商品同步" width="120">
<template v-slot="scope">
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" disabled />
<el-tag :type="scope.row.isEnableProdSync == 1 ? 'success' : 'error'" effect="dark"> {{ scope.row.isEnableProdSync == 1 ? '启用' : '禁用' }} </el-tag>
</template>
</el-table-column>
<el-table-column prop="status" label="会员同步" width="120">
<el-table-column prop="isEnableVipSync" label="会员同步" width="120">
<template v-slot="scope">
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" disabled />
<el-tag :type="scope.row.isEnableVipSync == 1 ? 'success' : 'error'" effect="dark"> {{ scope.row.isEnableVipSync == 1 ? '启用' : '禁用' }} </el-tag>
</template>
</el-table-column>
<el-table-column prop="status" label="耗材同步" width="120">
<el-table-column prop="isEnableConsSync" label="耗材同步" width="120">
<template v-slot="scope">
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" disabled />
<el-tag :type="scope.row.isEnableConsSync == 1 ? 'success' : 'error'" effect="dark"> {{ scope.row.isEnableConsSync == 1 ? '启用' : '禁用' }} </el-tag>
</template>
</el-table-column>
<el-table-column prop="status" label="账号状态" width="120">
<el-table-column prop="isAllowAccountLogin" label="账号状态" width="120">
<template v-slot="scope">
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" disabled />
<el-tag :type="scope.row.isAllowAccountLogin == 1 ? 'success' : 'error'" effect="dark"> {{ scope.row.isAllowAccountLogin == 1 ? '启用' : '禁用' }} </el-tag>
</template>
</el-table-column>
<el-table-column prop="createdAt" label="备注" />
<el-table-column label="操作" width="200">
<template v-slot="scope">
<el-button type="primary" size="small" link icon="edit" @click="handleSync(scope.row)">
<el-button v-if="!scope.row.isEnableProdSync || !scope.row.isEnableVipSync || !scope.row.isEnableConsSync"
type="primary" size="small" link icon="edit" @click="handleSync(scope.row)">
同步启用
</el-button>
<el-button type="primary" size="small" link icon="edit" @click="handleAccount(scope.row.id)">
账号启用
<el-button type="primary" size="small" link icon="edit" @click="handleAccount(scope.row)">
{{ scope.row.isAllowAccountLogin ? '账号禁用' : '账号启用' }}
</el-button>
</template>
</el-table-column>
@@ -71,22 +78,19 @@
<script setup>
import dayjs from "dayjs";
import ShopApi from "@/api/account/shop";
import ShopBranchApi from "@/api/account/shopBranch";
import { ElNotification, ElMessageBox } from "element-plus";
const state = reactive({
query: {
name: "",
},
par: {
dataSyncMethod: '',
},
status: [
{
type: 1,
label: "开启",
},
{
type: 0,
label: "关闭",
},
{ type: 'auto', label: "实时自动同步", },
{ type: 'manual', label: "手动同步", }
],
tableData: {
list: [],
@@ -99,15 +103,14 @@ const state = reactive({
onMounted(() => {
getTableData();
});
// 获取商家列表
// 获取分店列表
async function getTableData() {
state.tableData.loading = true;
try {
const res = await ShopApi.getList({
const res = await ShopBranchApi.getList({
page: state.tableData.page,
size: state.tableData.size,
shopName: state.query.name,
account: state.query.account,
status: state.query.status,
});
state.tableData.loading = false;
@@ -117,6 +120,16 @@ async function getTableData() {
console.log(error);
}
}
// 设置数据同步
async function setDataSync() {
await ShopBranchApi.setDataSync(state.par.dataSyncMethod);
ElMessage({
type: "success",
message: "设置成功",
});
}
// 开启同步
function handleSync(e) {
console.log(e)
ElMessageBox.confirm(`同步功能开启后不能关闭,请确认是否给${e.shopName}开启同步?`, "提示", {
@@ -124,7 +137,7 @@ function handleSync(e) {
cancelButtonText: "取消",
type: "warning",
}).then(async () => {
const res = await ShopApi.delete({ id: row.id });
await ShopBranchApi.dataSync(e.id)
ElMessage({
type: "success",
message: "同步成功",
@@ -132,6 +145,17 @@ function handleSync(e) {
getTableData();
}).catch(() => { });
}
// 账号启用/禁用
async function handleAccount(row) {
if (row.isAllowAccountLogin) {
await ShopBranchApi.disable(row.id);
} else {
await ShopBranchApi.enable(row.id);
}
getTableData();
}
// 重置查询
function resetHandle() {
state.query.name = "";

View File

@@ -13,13 +13,13 @@
</el-radio-group>
<div class="tips">请谨慎修改</div>
</el-form-item>
<el-form-item label="是否为主店" prop="isMainStore">
<el-radio-group v-model="state.form.isMainStore" @change=" state.form.mainId = ''">
<el-radio value="1"></el-radio>
<el-radio value="0"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="主店账号" prop="mainId" v-if="state.form.isMainStore == '0'">
<el-form-item label="是否为主店" prop="isHeadShop">
<el-radio-group v-model="state.form.isHeadShop" @change=" state.form.mainId = ''">
<el-radio value="1"></el-radio>
<el-radio value="0"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="主店账号" prop="mainId" v-if="state.form.isHeadShop == '0'">
<!-- <el-form-item label="主店账号" prop="mainId" v-if="state.form.shopType != 'only'"> -->
<el-select v-model="state.form.mainId" placeholder="请选择主店铺" filterable reserve-keyword
:remote-method="getTableData" :loading="state.shopListLoading">
@@ -208,7 +208,7 @@ const state = reactive({
cities: "",
districts: "",
chainName: "",
isMainStore: '0',
isHeadShop: '0',
},
resetForm: "",
rules: {
@@ -226,7 +226,7 @@ const state = reactive({
trigger: "blur",
},
],
isMainStore: [
isHeadShop: [
{
required: true,
message: " ",
@@ -354,6 +354,7 @@ function submitHandle() {
type: "success",
});
close();
location.reload()
} catch (error) {
state.formLoading = false;
console.log(error);
@@ -528,4 +529,4 @@ defineExpose({
.amap-sug-result {
z-index: 2000;
}
</style>
</style>

View File

@@ -68,7 +68,7 @@
<template v-slot="scope">
<div>
<span>{{ scope.row.shopName }}</span>
<div>(主店)</div>
<div>(主店{{ scope.row.headShopName }})</div>
</div>
</template>
</el-table-column>

View File

@@ -1,6 +1,7 @@
import type { ISearchConfig } from "@/components/CURD/types";
import { paramTypeOptions } from './config'
import UserAPI from "@/api/product/productclassification";
import ShopApi from "@/api/account/shop";
const searchConfig: ISearchConfig = {
@@ -19,7 +20,17 @@ const searchConfig: ISearchConfig = {
},
options: [],
async initFn(formItem) {
formItem.options = await UserAPI.getList();
// formItem.options = await UserAPI.getList();
let res = await ShopApi.getBranchList();
let options = [];
res.map(v=>{
options.push({
label: v.shopName,
value: v.shopId,
})
})
formItem.options = options
},
},
{