|
|
@@ -60,33 +60,55 @@
|
|
|
v-model:limit="queryParams.pageSize" @pagination="getList" />
|
|
|
</el-card>
|
|
|
|
|
|
- <!-- 授权客户对话框(支持多选) -->
|
|
|
- <el-dialog v-model="authDialog.visible" title="授权客户" width="900px" append-to-body>
|
|
|
- <el-form :model="erpQueryParams" ref="erpQueryFormRef" :inline="true" label-width="68px">
|
|
|
- <el-form-item label="客户名称" prop="name">
|
|
|
- <el-input v-model="erpQueryParams.name" placeholder="请输入客户名称" clearable style="width: 240px"
|
|
|
- @keyup.enter="getErpList" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <el-button type="primary" icon="Search" @click="getErpList">搜索</el-button>
|
|
|
- <el-button icon="Refresh" @click="resetErpQuery">重置</el-button>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <el-table v-loading="erpLoading" :data="erpList" @selection-change="handleErpSelectionChange" ref="erpTableRef">
|
|
|
- <el-table-column type="selection" width="50" align="center" />
|
|
|
- <el-table-column label="代码" align="center" prop="num" width="100"
|
|
|
- :formatter="(row: ErpClientVO) => row.num || '-'" />
|
|
|
- <el-table-column label="名称" align="left" prop="name" min-width="180" :show-overflow-tooltip="true"
|
|
|
- :formatter="(row: ErpClientVO) => row.name || '-'" />
|
|
|
- <el-table-column label="客户类型" align="center" prop="clientClass" width="100"
|
|
|
- :formatter="(row: ErpClientVO) => row.clientClass || '-'" />
|
|
|
- <el-table-column label="加入名称" align="center" prop="enterName" width="100"
|
|
|
- :formatter="(row: ErpClientVO) => row.enterName || '-'" />
|
|
|
- <el-table-column label="加入时间" align="center" prop="enterDate" width="170"
|
|
|
- :formatter="(row: ErpClientVO) => row.enterDate || '-'" />
|
|
|
- </el-table>
|
|
|
- <pagination v-show="erpTotal > 0" v-model:page="erpQueryParams.pageNum" v-model:limit="erpQueryParams.pageSize"
|
|
|
- :total="erpTotal" layout="total, prev, pager, next" @pagination="getErpList" />
|
|
|
+ <!-- 授权客户对话框 -->
|
|
|
+ <el-dialog v-model="authDialog.visible" title="授权客户" width="700px" append-to-body @opened="initAuthDialog">
|
|
|
+ <!-- 已选中客户卡片 -->
|
|
|
+ <div class="selected-header">
|
|
|
+ <span class="section-label">已授权客户</span>
|
|
|
+ <span class="selected-count">共 {{ selectedAuthClients.length }} 家</span>
|
|
|
+ </div>
|
|
|
+ <div v-if="selectedAuthClients.length > 0" class="selected-card-grid">
|
|
|
+ <div v-for="(client, idx) in selectedAuthClients" :key="idx" class="selected-client-card">
|
|
|
+ <span class="card-index">{{ idx + 1 }}</span>
|
|
|
+ <span class="card-name">{{ client.name }}</span>
|
|
|
+ <el-icon class="card-remove" @click="removeAuthClient(idx)">
|
|
|
+ <Close />
|
|
|
+ </el-icon>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-empty v-else description="暂无已授权客户" :image-size="40" />
|
|
|
+
|
|
|
+ <el-divider />
|
|
|
+
|
|
|
+ <!-- 搜索区 -->
|
|
|
+ <div class="search-row">
|
|
|
+ <el-input v-model="authSearchKeyword" placeholder="输入客户名称搜索" clearable @keyup.enter="handleAuthSearch"
|
|
|
+ style="flex: 1">
|
|
|
+ <template #append>
|
|
|
+ <el-button :loading="authSearchLoading" icon="Search" @click="handleAuthSearch">搜索</el-button>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 搜索结果 -->
|
|
|
+ <div v-if="authSearchResults.length > 0" class="search-results">
|
|
|
+ <div class="section-label mb-2">搜索结果</div>
|
|
|
+ <div v-for="item in authSearchResults" :key="item.rowId" class="search-result-item"
|
|
|
+ :class="{ disabled: isAuthClientSelected(item.rowId) }" @click="addAuthClient(item)">
|
|
|
+ <div class="result-info">
|
|
|
+ <span class="result-name">{{ item.name }}</span>
|
|
|
+ <span class="result-meta">{{ item.num || '-' }} | {{ item.clientClass || '-' }}</span>
|
|
|
+ </div>
|
|
|
+ <el-icon v-if="isAuthClientSelected(item.rowId)" class="result-check">
|
|
|
+ <CircleCheckFilled />
|
|
|
+ </el-icon>
|
|
|
+ <el-icon v-else class="result-add">
|
|
|
+ <CirclePlus />
|
|
|
+ </el-icon>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-empty v-else-if="authSearched" description="未找到匹配的客户" :image-size="40" />
|
|
|
+
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
<el-button :loading="buttonLoading" type="primary" icon="Check" @click="confirmAuth">确 定</el-button>
|
|
|
@@ -123,7 +145,7 @@
|
|
|
<span class="client-index">{{ idx + 1 }}</span>
|
|
|
<div class="client-info">
|
|
|
<div class="client-row"><span class="client-label">名称</span><span class="client-value">{{ client.name
|
|
|
- }}</span></div>
|
|
|
+ }}</span></div>
|
|
|
<div class="client-row"><span class="client-label">类型</span><span class="client-value">{{
|
|
|
client.clientClass || '-' }}</span></div>
|
|
|
<div class="client-row"><span class="client-label">加入时间</span><span class="client-value">{{
|
|
|
@@ -140,8 +162,8 @@
|
|
|
<script setup name="Customer" lang="ts">
|
|
|
import { listCustomer, getCustomerDetail, authCustomer, changeCustomerStatus } from '@/api/system/customer';
|
|
|
import { CustomerVO, CustomerQuery, CustomerForm, ErpClientBriefVO } from '@/api/system/customer/types';
|
|
|
-import { listErpClient } from '@/api/erp/client';
|
|
|
-import { ErpClientVO, ErpClientQuery } from '@/api/erp/client/types';
|
|
|
+import { searchErpClient } from '@/api/erp/client';
|
|
|
+import { ErpClientVO } from '@/api/erp/client/types';
|
|
|
import { checkPermi } from '@/utils/permission';
|
|
|
|
|
|
/** @Author: Antigravity */
|
|
|
@@ -162,17 +184,11 @@ const authDialog = reactive({
|
|
|
visible: false,
|
|
|
customerId: undefined as string | number | undefined
|
|
|
});
|
|
|
-const erpLoading = ref(false);
|
|
|
-const erpList = ref<ErpClientVO[]>([]);
|
|
|
-const erpTotal = ref(0);
|
|
|
-const erpQueryParams = reactive<ErpClientQuery>({
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 10,
|
|
|
- name: undefined
|
|
|
-});
|
|
|
-const selectedErpClients = ref<ErpClientVO[]>([]);
|
|
|
-const erpTableRef = ref();
|
|
|
-const erpQueryFormRef = ref<ElFormInstance>();
|
|
|
+const authSearchKeyword = ref('');
|
|
|
+const authSearchLoading = ref(false);
|
|
|
+const authSearchResults = ref<ErpClientVO[]>([]);
|
|
|
+const authSearched = ref(false);
|
|
|
+const selectedAuthClients = ref<ErpClientVO[]>([]);
|
|
|
|
|
|
// 详情对话框
|
|
|
const detailDialog = reactive({
|
|
|
@@ -252,40 +268,74 @@ const handleStatusChange = async (row: CustomerVO & { _statusActive: boolean; _s
|
|
|
const handleAuth = (row: CustomerVO) => {
|
|
|
authDialog.customerId = row.id;
|
|
|
authDialog.visible = true;
|
|
|
- selectedErpClients.value = [];
|
|
|
- resetErpQuery();
|
|
|
};
|
|
|
|
|
|
-/** 获取ERP客户列表 */
|
|
|
-const getErpList = async () => {
|
|
|
- erpLoading.value = true;
|
|
|
- const res = await listErpClient(erpQueryParams);
|
|
|
- erpList.value = res.rows;
|
|
|
- erpTotal.value = res.total;
|
|
|
- erpLoading.value = false;
|
|
|
+/** 弹窗打开时初始化 */
|
|
|
+const initAuthDialog = async () => {
|
|
|
+ authSearchKeyword.value = '';
|
|
|
+ authSearchResults.value = [];
|
|
|
+ authSearched.value = false;
|
|
|
+ selectedAuthClients.value = [];
|
|
|
+ if (!authDialog.customerId) return;
|
|
|
+ try {
|
|
|
+ const res = await getCustomerDetail(authDialog.customerId);
|
|
|
+ if (res.data?.authClientList) {
|
|
|
+ selectedAuthClients.value = res.data.authClientList.map(c => ({
|
|
|
+ rowId: c.rowId,
|
|
|
+ name: c.name,
|
|
|
+ num: c.rowId,
|
|
|
+ clientClass: c.clientClass
|
|
|
+ } as ErpClientVO));
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('加载已授权客户失败', e);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
-/** 重置ERP查询 */
|
|
|
-const resetErpQuery = () => {
|
|
|
- erpQueryFormRef.value?.resetFields();
|
|
|
- erpQueryParams.pageNum = 1;
|
|
|
- getErpList();
|
|
|
+/** 搜索ERP客户 */
|
|
|
+const handleAuthSearch = async () => {
|
|
|
+ const keyword = authSearchKeyword.value?.trim();
|
|
|
+ if (!keyword) {
|
|
|
+ proxy?.$modal.msgWarning('请输入客户名称');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ authSearchLoading.value = true;
|
|
|
+ authSearched.value = true;
|
|
|
+ try {
|
|
|
+ const res = await searchErpClient(keyword);
|
|
|
+ authSearchResults.value = res.data || [];
|
|
|
+ } catch (e) {
|
|
|
+ authSearchResults.value = [];
|
|
|
+ } finally {
|
|
|
+ authSearchLoading.value = false;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
-/** ERP客户多选选中 */
|
|
|
-const handleErpSelectionChange = (val: ErpClientVO[]) => {
|
|
|
- selectedErpClients.value = val;
|
|
|
+/** 判断客户是否已选中 */
|
|
|
+const isAuthClientSelected = (rowId: string) => {
|
|
|
+ return selectedAuthClients.value.some(c => c.rowId === rowId);
|
|
|
+};
|
|
|
+
|
|
|
+/** 添加客户到已选列表 */
|
|
|
+const addAuthClient = (client: ErpClientVO) => {
|
|
|
+ if (isAuthClientSelected(client.rowId)) return;
|
|
|
+ selectedAuthClients.value.push({ ...client });
|
|
|
+};
|
|
|
+
|
|
|
+/** 从已选列表移除客户 */
|
|
|
+const removeAuthClient = (idx: number) => {
|
|
|
+ selectedAuthClients.value.splice(idx, 1);
|
|
|
};
|
|
|
|
|
|
/** 确认授权 */
|
|
|
const confirmAuth = async () => {
|
|
|
- if (!selectedErpClients.value || selectedErpClients.value.length === 0) {
|
|
|
+ if (!selectedAuthClients.value || selectedAuthClients.value.length === 0) {
|
|
|
proxy?.$modal.msgError('请至少选择一个ERP客户');
|
|
|
return;
|
|
|
}
|
|
|
buttonLoading.value = true;
|
|
|
try {
|
|
|
- const authClientFRowIDs = selectedErpClients.value.map(c => c.rowId).join(',');
|
|
|
+ const authClientFRowIDs = selectedAuthClients.value.map(c => c.rowId).join(',');
|
|
|
await authCustomer(authDialog.customerId!, authClientFRowIDs);
|
|
|
proxy?.$modal.msgSuccess('授权成功');
|
|
|
authDialog.visible = false;
|
|
|
@@ -314,6 +364,138 @@ onMounted(() => {
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
+/* ========== 授权对话框 ========== */
|
|
|
+.selected-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-bottom: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.section-label {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #303133;
|
|
|
+}
|
|
|
+
|
|
|
+.selected-count {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #909399;
|
|
|
+}
|
|
|
+
|
|
|
+.selected-card-grid {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: repeat(4, 1fr);
|
|
|
+ gap: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.selected-client-card {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 6px;
|
|
|
+ background: #f0f9eb;
|
|
|
+ border: 1px solid #c2e7b0;
|
|
|
+ border-radius: 6px;
|
|
|
+ padding: 6px 10px;
|
|
|
+ font-size: 12px;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+
|
|
|
+.card-index {
|
|
|
+ width: 18px;
|
|
|
+ height: 18px;
|
|
|
+ background: #67C23A;
|
|
|
+ color: #fff;
|
|
|
+ border-radius: 50%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ font-size: 11px;
|
|
|
+ font-weight: 600;
|
|
|
+ flex-shrink: 0;
|
|
|
+}
|
|
|
+
|
|
|
+.card-name {
|
|
|
+ flex: 1;
|
|
|
+ color: #303133;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+.card-remove {
|
|
|
+ color: #909399;
|
|
|
+ cursor: pointer;
|
|
|
+ flex-shrink: 0;
|
|
|
+ font-size: 14px;
|
|
|
+}
|
|
|
+
|
|
|
+.card-remove:hover {
|
|
|
+ color: #F56C6C;
|
|
|
+}
|
|
|
+
|
|
|
+.search-row {
|
|
|
+ display: flex;
|
|
|
+}
|
|
|
+
|
|
|
+.search-results {
|
|
|
+ margin-top: 12px;
|
|
|
+ max-height: 260px;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.search-result-item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 10px 14px;
|
|
|
+ border: 1px solid #ebeef5;
|
|
|
+ border-radius: 6px;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ cursor: pointer;
|
|
|
+ transition: all 0.2s;
|
|
|
+}
|
|
|
+
|
|
|
+.search-result-item:hover {
|
|
|
+ border-color: #409EFF;
|
|
|
+ background: #ecf5ff;
|
|
|
+}
|
|
|
+
|
|
|
+.search-result-item.disabled {
|
|
|
+ opacity: 0.5;
|
|
|
+ cursor: not-allowed;
|
|
|
+ border-color: #c2e7b0;
|
|
|
+ background: #f0f9eb;
|
|
|
+}
|
|
|
+
|
|
|
+.result-info {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 2px;
|
|
|
+}
|
|
|
+
|
|
|
+.result-name {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 500;
|
|
|
+ color: #303133;
|
|
|
+}
|
|
|
+
|
|
|
+.result-meta {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #909399;
|
|
|
+}
|
|
|
+
|
|
|
+.result-add {
|
|
|
+ color: #409EFF;
|
|
|
+ font-size: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.result-check {
|
|
|
+ color: #67C23A;
|
|
|
+ font-size: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+/* ========== 详情弹窗 ========== */
|
|
|
.section-title {
|
|
|
font-size: 14px;
|
|
|
font-weight: 600;
|