修复商户账号添加功能

This commit is contained in:
2024-10-19 15:25:02 +08:00
parent e8a8ba353f
commit 28e7ce4015
8 changed files with 89 additions and 72 deletions
@@ -27,13 +27,16 @@
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image
v-if="record.image"
:src="record.image"
:preview="false"
:width="45"
/>
<template v-if="column.key === 'merchantName'">
<a-space>
<a-avatar
v-if="record.image"
:src="record.image"
:preview="false"
:width="45"
/>
{{ record.merchantName }}
</a-space>
</template>
<template v-if="column.key === 'shopType'">
<a-tag v-if="record.shopType === 10">企业</a-tag>
@@ -86,12 +89,6 @@
// 表格配置
const columns = ref<ColumnItem[]>([
{
title: 'LOGO',
dataIndex: 'image',
key: 'image',
align: 'center'
},
{
title: '商户名称',
dataIndex: 'merchantName'
+4 -4
View File
@@ -166,7 +166,7 @@
SearchOutlined
} from '@ant-design/icons-vue';
import { storeToRefs } from 'pinia';
import { copyText, openNew, openUrl } from '@/utils/common';
import { copyText, getMerchantId, openNew, openUrl } from "@/utils/common";
import { useThemeStore } from '@/store/modules/theme';
import HeaderNotice from './header-notice.vue';
import PasswordModal from './password-modal.vue';
@@ -331,8 +331,9 @@
}
// 更新商户ID和名称
if (hasRole('merchant') && loginUser.value.merchantId == null) {
listMerchant({ phone: loginUser.value.phone }).then((res) => {
if (!getMerchantId() && loginUser.value.merchantId == null) {
listMerchantAccount({ phone: loginUser.value.phone }).then((res) => {
console.log(res);
if (res.length > 0) {
const item = res[0];
authUser({
@@ -342,7 +343,6 @@
});
localStorage.setItem('MerchantId', `${item.merchantId}`);
localStorage.setItem('MerchantName', `${item.merchantName}`);
localStorage.setItem('MerchantLogo', `${item.image}`);
}
});
}
@@ -19,7 +19,7 @@
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="商户图标" name="image">
<a-form-item label="店铺图标" name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
+20 -20
View File
@@ -7,24 +7,24 @@
</template>
<span>添加</span>
</a-button>
<a-button class="ele-btn-icon" @click="openUrl(`/shop/index`)">
<span>店铺管理</span>
</a-button>
<a-button class="ele-btn-icon" @click="openUrl(`/shop/index`)">
<span>门店职员</span>
</a-button>
<a-button class="ele-btn-icon" @click="openUrl(`/goods/category/:id`)">
<span>商品分类</span>
</a-button>
<a-button class="ele-btn-icon" @click="openUrl(`/shop/apply`)">
<span>入驻申请</span>
</a-button>
<a-button class="ele-btn-icon" @click="openUrl(`/shop/desk`)">
<span>桌号管理</span>
</a-button>
<a-button class="ele-btn-icon" @click="openUrl(`/shop/type`)">
<span>店铺类型</span>
</a-button>
<!-- <a-button class="ele-btn-icon" @click="openUrl(`/shop/index`)">-->
<!-- <span>店铺管理</span>-->
<!-- </a-button>-->
<!-- <a-button class="ele-btn-icon" @click="openUrl(`/shop/index`)">-->
<!-- <span>门店职员</span>-->
<!-- </a-button>-->
<!-- <a-button class="ele-btn-icon" @click="openUrl(`/goods/category/:id`)">-->
<!-- <span>商品分类</span>-->
<!-- </a-button>-->
<!-- <a-button class="ele-btn-icon" @click="openUrl(`/shop/apply`)">-->
<!-- <span>入驻申请</span>-->
<!-- </a-button>-->
<!-- <a-button class="ele-btn-icon" @click="openUrl(`/shop/desk`)">-->
<!-- <span>桌号管理</span>-->
<!-- </a-button>-->
<!-- <a-button class="ele-btn-icon" @click="openUrl(`/shop/type`)">-->
<!-- <span>店铺类型</span>-->
<!-- </a-button>-->
</a-space>
</template>
@@ -35,8 +35,8 @@
import { openUrl } from '@/utils/common';
import router from '@/router';
import { getMerchant } from '@/api/shop/merchant';
import merchant from "@/views/shop/merchant/index.vue";
import { getMerchantId } from "@/utils/merchant";
import merchant from '@/views/shop/merchant/index.vue';
import { getMerchantId } from '@/utils/merchant';
const props = withDefaults(
defineProps<{
+2 -2
View File
@@ -127,13 +127,13 @@
align: 'center'
},
{
title: '商户姓名',
title: '姓名',
dataIndex: 'realName',
key: 'realName',
align: 'center'
},
{
title: '商户手机号',
title: '登录账号',
dataIndex: 'phone',
key: 'phone',
align: 'center'
@@ -4,7 +4,7 @@
:width="600"
:visible="visible"
:maskClosable="false"
:title="isUpdate ? '编辑商户职员' : '添加商户职员'"
:title="isUpdate ? '编辑账号' : '添加账号'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
@@ -18,30 +18,34 @@
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="职员名称" name="realName">
<a-form-item label="选择商户" name="merchantId">
<SelectMerchant
:placeholder="`选择商户`"
v-model:value="form.merchantName"
@done="chooseMerchantId"
/>
</a-form-item>
<a-form-item label="选择用户" name="userId">
<SelectUser
:placeholder="`选择用户`"
v-model:value="form.phone"
@done="chooseUserId"
/>
</a-form-item>
<a-form-item label="选择角色" name="roleId">
<SelectRole
:placeholder="`选择角色`"
v-model:value="form.roleName"
@done="chooseRoleId"
/>
</a-form-item>
<a-form-item label="真实名称" name="realName">
<a-input
allow-clear
placeholder="请输入真实姓名"
v-model:value="form.realName"
/>
</a-form-item>
<a-form-item label="登录账号" name="phone">
<a-input
allow-clear
placeholder="请输入手机号码"
:maxlength="11"
:disabled="isUpdate && form.phone"
v-model:value="form.phone"
/>
</a-form-item>
<a-form-item label="密码" name="password" v-if="!isUpdate">
<a-input-password
allow-clear
placeholder="请输入登录密码"
:disabled="isUpdate"
v-model:value="form.password"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
@@ -74,6 +78,9 @@
getRoleIdByMerchant,
getRoleNameByMerchant
} from '@/utils/merchant';
import { User } from '@/api/system/user/model';
import { Role } from '@/api/system/role/model';
import { Merchant } from '@/api/shop/merchant/model';
// 是否是修改
const isUpdate = ref(false);
@@ -191,6 +198,22 @@
]
});
const chooseUserId = (user: User) => {
form.userId = user.userId;
form.realName = user.realName;
form.phone = user.phone;
};
const chooseMerchantId = (data: Merchant) => {
form.merchantId = data.merchantId;
form.merchantName = data.merchantName;
};
const chooseRoleId = (data: Role) => {
form.roleId = data.roleId;
form.roleName = data.roleName;
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
@@ -203,12 +226,12 @@
.then(() => {
loading.value = true;
const formData = {
...form,
merchantId: getMerchantId(),
merchantName: getMerchantName(),
merchantAvatar: getMerchantAvatar(),
roleId: getRoleIdByMerchant(),
roleName: getRoleNameByMerchant()
...form
// merchantId: getMerchantId(),
// merchantName: getMerchantName(),
// merchantAvatar: getMerchantAvatar(),
// roleId: getRoleIdByMerchant(),
// roleName: getRoleNameByMerchant()
};
const saveOrUpdate = isUpdate.value
? updateMerchantAccount
+2 -5
View File
@@ -30,10 +30,7 @@
</template>
<template v-if="column.key === 'action'">
<a-space>
<a-popconfirm
title="确定要移除该门店用户吗?"
@confirm="remove(record)"
>
<a-popconfirm title="确定要移除吗?" @confirm="remove(record)">
<a class="ele-text-danger">移除</a>
</a-popconfirm>
</a-space>
@@ -122,7 +119,7 @@
width: 90
},
{
title: '门店名称',
title: '店铺名称',
dataIndex: 'merchantName',
key: 'merchantName',
align: 'center'