From 46e81fa90c8e089a781fdc994b5427b6e57fb311 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期五, 27 三月 2026 14:52:02 +0800
Subject: [PATCH] feat(客户档案): 优化地区路径查找逻辑
---
src/views/basicData/customerFile/index.vue | 1890 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 1,422 insertions(+), 468 deletions(-)
diff --git a/src/views/basicData/customerFile/index.vue b/src/views/basicData/customerFile/index.vue
index 284300d..326f3f9 100644
--- a/src/views/basicData/customerFile/index.vue
+++ b/src/views/basicData/customerFile/index.vue
@@ -1,558 +1,1512 @@
<template>
<div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">瀹㈡埛鍚嶇О锛�</span>
- <el-input
- v-model="searchForm.customerName"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
- >鎼滅储</el-button
- >
+ <div class="customer-split">
+ <div class="left-panel">
+ <div class="left-header">
+ <div class="left-title">鍦板尯</div>
+ <div class="left-actions">
+ <el-button type="primary"
+ size="small"
+ @click="openAddRegionDialog">鏂板</el-button>
+ <el-button size="small"
+ @click="openEditRegionDialog">淇敼</el-button>
+ <el-button type="danger"
+ plain
+ size="small"
+ @click="handleDeleteRegion">鍒犻櫎</el-button>
+ </div>
+ </div>
+
+ <div class="left-search">
+ <el-input v-model="regionKeyword"
+ placeholder="鏌ヨ鍦板尯"
+ clearable
+ :prefix-icon="Search" />
+ </div>
+
+ <div class="left-list">
+ <el-skeleton v-if="regionsLoading"
+ :rows="8"
+ animated />
+ <template v-else>
+ <div class="region-item"
+ :class="{ active: selectedRegionId === 0 }"
+ @click="selectRegion('')">鍏ㄩ儴</div>
+ <el-tree ref="regionTreeRef"
+ :data="regionTreeData"
+ node-key="id"
+ :props="regionTreeProps"
+ :filter-node-method="filterRegionNode"
+ highlight-current
+ default-expand-all
+ :expand-on-click-node="false"
+ @node-click="handleRegionNodeClick" />
+ <div v-if="regionTreeData.length === 0"
+ class="empty-tip">鏆傛棤鍦板尯</div>
+ </template>
+ </div>
</div>
- <div>
- <el-button type="primary" @click="openForm('add')">鏂板瀹㈡埛</el-button>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="info" plain icon="Upload" @click="handleImport"
- >瀵煎叆</el-button
- >
- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+
+ <div class="right-panel">
+ <div class="toolbar-card">
+ <div class="search_form right-search-form">
+ <div class="search-fields">
+ <span class="search_title">瀹㈡埛鍚嶇О锛�</span>
+ <el-input v-model="searchForm.customerName"
+ style="width: 240px;margin-right: 10px"
+ placeholder="璇疯緭鍏�"
+ @change="handleQuery"
+ clearable
+ :prefix-icon="Search" />
+ <span class="search_title">瀹㈡埛鍒嗙被锛�</span>
+ <el-select v-model="searchForm.customerType"
+ placeholder="璇烽�夋嫨"
+ style="width: 240px"
+ clearable
+ @change="handleQuery">
+ <el-option label="闆跺敭瀹㈡埛"
+ value="闆跺敭瀹㈡埛" />
+ <el-option label="杩涢攢鍟嗗鎴�"
+ value="杩涢攢鍟嗗鎴�" />
+ </el-select>
+ <el-button type="primary"
+ @click="handleQuery"
+ style="margin-left: 10px">鎼滅储</el-button>
+ </div>
+ <div class="toolbar-divider"></div>
+ <div class="action-buttons">
+ <el-button type="primary"
+ @click="openForm('add')">鏂板瀹㈡埛</el-button>
+ <el-button @click="handleOut">瀵煎嚭</el-button>
+ <el-button type="info"
+ plain
+ icon="Upload"
+ @click="handleImport">瀵煎叆</el-button>
+ <el-button type="danger"
+ plain
+ @click="handleDelete">鍒犻櫎</el-button>
+ </div>
+ </div>
+ </div>
+ <div class="table_list table-card">
+ <PIMTable rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :page="page"
+ :isSelection="true"
+ @selection-change="handleSelectionChange"
+ :tableLoading="tableLoading"
+ @pagination="pagination"></PIMTable>
+ </div>
</div>
</div>
- <div class="table_list">
- <PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- ></PIMTable>
- </div>
- <el-dialog
- v-model="dialogFormVisible"
- :title="operationType === 'add' ? '鏂板瀹㈡埛淇℃伅' : '缂栬緫瀹㈡埛淇℃伅'"
- width="70%"
- @close="closeDia"
- >
- <el-form
- :model="form"
- label-width="140px"
- label-position="top"
- :rules="rules"
- ref="formRef"
- >
+
+ <el-dialog v-model="addRegionDialogVisible"
+ title="鏂板鍦板尯"
+ width="420px"
+ @close="closeAddRegionDialog">
+ <el-form :model="addRegionForm"
+ label-width="90px">
+ <el-form-item label="涓婄骇鍦板尯">
+ <el-cascader v-model="addRegionForm.parentPath"
+ :options="regionTreeData"
+ :props="regionCascaderProps"
+ clearable
+ filterable
+ placeholder="涓嶉�夊垯涓洪《绾у湴鍖�" />
+ </el-form-item>
+ <el-form-item label="鍦板尯鍚嶇О">
+ <el-input v-model="addRegionForm.regionsName"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary"
+ @click="submitAddRegion">纭</el-button>
+ <el-button @click="closeAddRegionDialog">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ <el-dialog v-model="editRegionDialogVisible"
+ title="淇敼鍦板尯"
+ width="420px"
+ @close="closeEditRegionDialog">
+ <el-form :model="editRegionForm"
+ label-width="90px">
+ <el-form-item label="涓婄骇鍦板尯">
+ <el-input :value="editRegionParentLabel"
+ disabled />
+ </el-form-item>
+ <el-form-item label="鍦板尯鍚嶇О">
+ <el-input v-model="editRegionForm.regionsName"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary"
+ @click="submitEditRegion">纭</el-button>
+ <el-button @click="closeEditRegionDialog">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ <el-dialog v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板瀹㈡埛淇℃伅' : '缂栬緫瀹㈡埛淇℃伅'"
+ width="70%"
+ @close="closeDia">
+ <el-form :model="form"
+ label-width="140px"
+ label-position="top"
+ :rules="rules"
+ ref="formRef">
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="瀹㈡埛鍚嶇О锛�" prop="customerName">
- <el-input
- v-model="form.customerName"
- placeholder="璇疯緭鍏�"
- clearable
- />
+ <el-form-item label="瀹㈡埛鍚嶇О锛�"
+ prop="customerName">
+ <el-input v-model="form.customerName"
+ placeholder="璇疯緭鍏�"
+ clearable />
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item
- label="绾崇◣浜鸿瘑鍒彿锛�"
- prop="taxpayerIdentificationNumber"
- >
- <el-input
- v-model="form.taxpayerIdentificationNumber"
- placeholder="璇疯緭鍏�"
- clearable
- />
+ <el-form-item label="绾崇◣浜鸿瘑鍒彿锛�"
+ prop="taxpayerIdentificationNumber">
+ <el-input v-model="form.taxpayerIdentificationNumber"
+ placeholder="璇疯緭鍏�"
+ clearable />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="鍏徃鍦板潃锛�" prop="companyAddress">
- <el-input
- v-model="form.companyAddress"
- placeholder="璇疯緭鍏�"
- clearable
- />
+ <el-form-item label="瀹㈡埛鍦板尯锛�"
+ prop="regions">
+ <el-cascader v-model="formRegionPath"
+ :options="regionTreeData"
+ :props="regionCascaderProps"
+ clearable
+ filterable
+ style="width: 100%"
+ placeholder="璇烽�夋嫨"
+ @change="handleFormRegionChange" />
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="鍏徃鐢佃瘽锛�" prop="companyPhone">
- <el-input
- v-model="form.companyPhone"
- placeholder="璇疯緭鍏�"
- clearable
- />
+ <el-form-item label="瀹㈡埛鍦板潃锛�"
+ prop="companyAddress">
+ <el-input v-model="form.companyAddress"
+ placeholder="璇疯緭鍏�"
+ clearable />
</el-form-item>
</el-col>
</el-row>
- <el-row :gutter="30" v-for="(contact, index) in formYYs.contactList" :key="index">
+ <el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="鑱旂郴浜猴細" prop="contactPerson">
- <el-input v-model="contact.contactPerson" placeholder="璇疯緭鍏�" clearable />
+ <el-form-item label="瀹㈡埛鐢佃瘽锛�"
+ prop="companyPhone">
+ <el-input v-model="form.companyPhone"
+ placeholder="璇疯緭鍏�"
+ clearable />
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="鑱旂郴鐢佃瘽锛�" prop="contactPhone">
+ <el-form-item label="瀹㈡埛鍒嗙被锛�"
+ prop="customerType">
+ <el-select v-model="form.customerType"
+ placeholder="璇烽�夋嫨"
+ clearable>
+ <el-option label="闆跺敭瀹㈡埛"
+ value="闆跺敭瀹㈡埛" />
+ <el-option label="杩涢攢鍟嗗鎴�"
+ value="杩涢攢鍟嗗鎴�" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="閾惰鍩烘湰鎴凤細"
+ prop="basicBankAccount">
+ <el-input v-model="form.basicBankAccount"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="閾惰璐﹀彿锛�"
+ prop="bankAccount">
+ <el-input v-model="form.bankAccount"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="寮�鎴疯鍙凤細"
+ prop="bankCode">
+ <el-input v-model="form.bankCode"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30"
+ v-for="(contact, index) in formYYs.contactList"
+ :key="index">
+ <el-col :span="12">
+ <el-form-item label="鑱旂郴浜猴細"
+ prop="contactPerson">
+ <el-input v-model="contact.contactPerson"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鑱旂郴鐢佃瘽锛�"
+ prop="contactPhone">
<div style="display: flex; align-items: center;width: 100%;">
- <el-input v-model="contact.contactPhone" placeholder="璇疯緭鍏�" clearable />
- <el-button @click="removeContact(index)" type="danger" circle style="margin-left: 5px;">
- <el-icon><Close /></el-icon>
+ <el-input v-model="contact.contactPhone"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ <el-button @click="removeContact(index)"
+ type="danger"
+ circle
+ style="margin-left: 5px;">
+ <el-icon>
+ <Close />
+ </el-icon>
</el-button>
</div>
</el-form-item>
</el-col>
</el-row>
- <el-button @click="addNewContact" style="margin-bottom: 10px;">+ 鏂板鑱旂郴浜�</el-button>
-
+ <el-button @click="addNewContact"
+ style="margin-bottom: 10px;">+ 鏂板鑱旂郴浜�</el-button>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="閾惰鍩烘湰鎴凤細" prop="basicBankAccount">
- <el-input
- v-model="form.basicBankAccount"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="閾惰璐﹀彿锛�" prop="bankAccount">
- <el-input
- v-model="form.bankAccount"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="寮�鎴疯鍙凤細" prop="bankCode">
- <el-input
- v-model="form.bankCode"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="缁存姢浜猴細" prop="maintainer">
- <el-select
- v-model="form.maintainer"
- placeholder="璇烽�夋嫨"
- clearable
- disabled
- >
- <el-option
- v-for="item in userList"
- :key="item.nickName"
- :label="item.nickName"
- :value="item.nickName"
- />
+ <el-form-item label="缁存姢浜猴細"
+ prop="maintainer">
+ <el-select v-model="form.maintainer"
+ placeholder="璇烽�夋嫨"
+ clearable
+ disabled>
+ <el-option v-for="item in userList"
+ :key="item.nickName"
+ :label="item.nickName"
+ :value="item.nickName" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
- <el-form-item label="缁存姢鏃堕棿锛�" prop="maintenanceTime">
- <el-date-picker
- style="width: 100%"
- v-model="form.maintenanceTime"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- type="date"
- placeholder="璇烽�夋嫨"
- clearable
- disabled
- />
+ <el-form-item label="缁存姢鏃堕棿锛�"
+ prop="maintenanceTime">
+ <el-date-picker style="width: 100%"
+ v-model="form.maintenanceTime"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ type="date"
+ placeholder="璇烽�夋嫨"
+ clearable />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
+ <el-button type="primary"
+ @click="submitForm">纭</el-button>
<el-button @click="closeDia">鍙栨秷</el-button>
</div>
</template>
</el-dialog>
<!-- 鐢ㄦ埛瀵煎叆瀵硅瘽妗� -->
- <el-dialog
- :title="upload.title"
- v-model="upload.open"
- width="400px"
- append-to-body
- >
- <el-upload
- ref="uploadRef"
- :limit="1"
- accept=".xlsx, .xls"
- :headers="upload.headers"
- :action="upload.url + '?updateSupport=' + upload.updateSupport"
- :disabled="upload.isUploading"
- :on-progress="handleFileUploadProgress"
- :on-success="handleFileSuccess"
- :auto-upload="false"
- drag
- >
+ <el-dialog :title="upload.title"
+ v-model="upload.open"
+ width="400px"
+ append-to-body>
+ <el-upload ref="uploadRef"
+ :limit="1"
+ accept=".xlsx, .xls"
+ :headers="upload.headers"
+ :action="upload.url + '?updateSupport=' + upload.updateSupport"
+ :disabled="upload.isUploading"
+ :before-upload="upload.beforeUpload"
+ :on-progress="upload.onProgress"
+ :on-success="upload.onSuccess"
+ :on-error="upload.onError"
+ :on-change="upload.onChange"
+ :auto-upload="false"
+ drag>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
<template #tip>
<div class="el-upload__tip text-center">
<span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
- <el-link
- type="primary"
- :underline="false"
- style="font-size: 12px; vertical-align: baseline"
- @click="importTemplate"
- >涓嬭浇妯℃澘</el-link
- >
+ <el-link type="primary"
+ :underline="false"
+ style="font-size: 12px; vertical-align: baseline"
+ @click="importTemplate">涓嬭浇妯℃澘</el-link>
</div>
</template>
</el-upload>
<template #footer>
<div class="dialog-footer">
- <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+ <el-button type="primary"
+ @click="submitFileForm">纭� 瀹�</el-button>
<el-button @click="upload.open = false">鍙� 娑�</el-button>
</div>
</template>
</el-dialog>
+ <!--
+ 鍥炶鎻愰啋 / 娲借皥杩涘害鍔熻兘锛堝叆鍙e強寮圭獥锛夊凡鎸夐渶姹傛敞閲娿��
+ 濡傞渶鎭㈠锛氭斁寮�鎿嶄綔鍒楀叆鍙� + 鍙栨秷鏈娉ㄩ噴 + 鎭㈠ script 涓浉鍏冲彉閲�/鏂规硶/鎺ュ彛寮曞叆銆�
+ -->
+ <!-- 瀹㈡埛璇︽儏瀵硅瘽妗� -->
+ <el-dialog title="瀹㈡埛璇︽儏"
+ v-model="detailDialogVisible"
+ width="1000px"
+ @close="closeDetailDialog">
+ <!-- 瀹㈡埛鍩烘湰淇℃伅 -->
+ <div class="detail-section">
+ <h3 class="section-title">瀹㈡埛鍩烘湰淇℃伅</h3>
+ <div class="info-display">
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">瀹㈡埛鍚嶇О锛�</span>
+ <span class="info-value">{{ detailForm.customerName }}</span>
+ </div>
+ </el-col>
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">瀹㈡埛鍒嗙被锛�</span>
+ <span class="info-value">{{ detailForm.customerType }}</span>
+ </div>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">绾崇◣浜鸿瘑鍒彿锛�</span>
+ <span class="info-value">{{ detailForm.taxpayerIdentificationNumber }}</span>
+ </div>
+ </el-col>
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">瀹㈡埛鐢佃瘽锛�</span>
+ <span class="info-value">{{ detailForm.companyPhone }}</span>
+ </div>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">瀹㈡埛鍦板尯锛�</span>
+ <span class="info-value">{{ detailForm.regionsName || detailForm.regions }}</span>
+ </div>
+ </el-col>
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">瀹㈡埛鍦板潃锛�</span>
+ <span class="info-value">{{ detailForm.companyAddress }}</span>
+ </div>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">閾惰鍩烘湰鎴凤細</span>
+ <span class="info-value">{{ detailForm.basicBankAccount }}</span>
+ </div>
+ </el-col>
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">閾惰璐﹀彿锛�</span>
+ <span class="info-value">{{ detailForm.bankAccount }}</span>
+ </div>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">寮�鎴疯鍙凤細</span>
+ <span class="info-value">{{ detailForm.bankCode }}</span>
+ </div>
+ </el-col>
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">鑱旂郴浜猴細</span>
+ <span class="info-value">{{ detailForm.contactPerson }}</span>
+ </div>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">鑱旂郴鐢佃瘽锛�</span>
+ <span class="info-value">{{ detailForm.contactPhone }}</span>
+ </div>
+ </el-col>
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">缁存姢浜猴細</span>
+ <span class="info-value">{{ detailForm.maintainer }}</span>
+ </div>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <div class="info-item">
+ <span class="info-label">缁存姢鏃堕棿锛�</span>
+ <span class="info-value">{{ detailForm.maintenanceTime }}</span>
+ </div>
+ </el-col>
+ </el-row>
+ </div>
+ </div>
+ <!--
+ 娲借皥杩涘害璁板綍锛堝惈闄勪欢/淇敼/鍒犻櫎锛夊凡鎸夐渶姹傛暣浣撴敞閲娿��
+ 濡傞渶鎭㈠锛氬彇娑堟湰娈垫敞閲婏紝骞舵仮澶� script 涓浉鍏冲彉閲�/鏂规硶/鎺ュ彛寮曞叆銆�
+ -->
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button @click="closeDetailDialog">鍏抽棴</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ <!-- 闄勪欢绠$悊鍔熻兘宸查殢娲借皥杩涘害鏁翠綋娉ㄩ噴 -->
</div>
</template>
<script setup>
-import { ref } from "vue";
-import { Search } from "@element-plus/icons-vue";
-import {
- addCustomer,
- delCustomer,
- getCustomer,
- listCustomer,
- updateCustomer,
-} from "@/api/basicData/customerFile.js";
-import { ElMessageBox } from "element-plus";
-import { userListNoPage } from "@/api/system/user.js";
-import useUserStore from "@/store/modules/user";
-import { getToken } from "@/utils/auth.js";
-const { proxy } = getCurrentInstance();
-const userStore = useUserStore();
+ import { onMounted, ref, reactive, getCurrentInstance, toRefs, computed, watch } from "vue";
+ import { Search } from "@element-plus/icons-vue";
+ import {
+ addCustomer,
+ delCustomer,
+ getCustomer,
+ listCustomer,
+ listCustomerRegions,
+ addCustomerRegions,
+ updateCustomerRegions,
+ delCustomerRegions,
+ updateCustomer,
+ // addCustomerFollow,
+ // updateCustomerFollow,
+ // delCustomerFollow,
+ // addReturnVisit,
+ // getReturnVisit,
+ } from "@/api/basicData/customerFile.js";
+ import { ElMessageBox } from "element-plus";
+ import { userListNoPage } from "@/api/system/user.js";
+ import useUserStore from "@/store/modules/user";
+ import { getToken } from "@/utils/auth.js";
+ const { proxy } = getCurrentInstance();
+ const userStore = useUserStore();
-const tableColumn = ref([
- {
- label: "瀹㈡埛鍚嶇О",
- prop: "customerName",
- width: 220,
- },
- {
- label: "绾崇◣浜鸿瘑鍒爜",
- prop: "taxpayerIdentificationNumber",
- width: 220,
- },
- {
- label: "鍦板潃鍙婅仈绯绘柟寮�",
- prop: "addressPhone",
- width: 250,
- },
- {
- label: "鑱旂郴浜�",
- prop: "contactPerson",
- },
- {
- label: "鑱旂郴鐢佃瘽",
- prop: "contactPhone",
- width:150
- },
- {
- label: "閾惰鍩烘湰鎴�",
- prop: "basicBankAccount",
- width: 220,
- },
- {
- label: "閾惰璐﹀彿",
- prop: "bankAccount",
- width: 220,
- },
- {
- label: "寮�鎴疯鍙�",
- prop: "bankCode",
- width:220
- },
- {
- label: "缁存姢浜�",
- prop: "maintainer",
- },
- {
- label: "缁存姢鏃堕棿",
- prop: "maintenanceTime",
- width: 100,
- },
- {
- dataType: "action",
- label: "鎿嶄綔",
- align: "center",
- fixed: 'right',
- operation: [
- {
- name: "缂栬緫",
- type: "text",
- clickFun: (row) => {
- openForm("edit", row);
- },
- disabled: (row) => {
- return row.maintainer !== userStore.nickName
- }
- },
- ],
- },
-]);
-const tableData = ref([]);
-const selectedRows = ref([]);
-const userList = ref([]);
-const tableLoading = ref(false);
-const page = reactive({
- current: 1,
- size: 100,
- total: 0,
-});
-const total = ref(0);
+ // 鍥炶鎻愰啋/娲借皥杩涘害鐩稿叧锛堝凡鎸夐渶姹傛暣浣撴敞閲婏級
+ // const reminderDialogVisible = ref(false);
+ // const reminderFormRef = ref();
+ // const currentCustomerId = ref();
+ // const reminderForm = reactive({
+ // customerName: "",
+ // reminderSwitch: false,
+ // reminderContent: "",
+ // reminderTime: "",
+ // });
+ // const reminderRules = {
+ // reminderContent: [
+ // { required: true, message: "璇疯緭鍏ユ彁閱掑唴瀹�", trigger: "blur" },
+ // ],
+ // reminderTime: [
+ // { required: true, message: "璇烽�夋嫨鎻愰啋鏃堕棿", trigger: "change" },
+ // ],
+ // };
+ //
+ // const negotiationDialogVisible = ref(false);
+ // const negotiationFormRef = ref();
+ // const negotiationForm = reactive({
+ // customerName: "",
+ // customerId: "",
+ // followUpMethod: "",
+ // followUpLevel: "",
+ // followUpTime: "",
+ // followerUserName: "",
+ // content: "",
+ // });
+ // const negotiationRules = {
+ // followUpMethod: [
+ // { required: true, message: "璇烽�夋嫨璺熻繘鏂瑰紡", trigger: "change" },
+ // ],
+ // followUpLevel: [
+ // { required: true, message: "璇烽�夋嫨璺熻繘绋嬪害", trigger: "change" },
+ // ],
+ // followUpTime: [
+ // { required: true, message: "璇烽�夋嫨璺熻繘鏃堕棿", trigger: "change" },
+ // ],
+ // content: [{ required: true, message: "璇疯緭鍏ュ唴瀹�", trigger: "blur" }],
+ // };
-// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
-const operationType = ref("");
-const dialogFormVisible = ref(false);
-const formYYs = ref({ // 鍏朵粬瀛楁...
- contactList: [
- {
- contactPerson: "",
- contactPhone: ""
- }
- ]
-});
-const data = reactive({
- searchForm: {
+ // 璇︽儏鐩稿叧
+ const detailDialogVisible = ref(false);
+ const detailForm = reactive({
customerName: "",
- },
- form: {
- customerName: "",
+ regionsName: "",
+ regions: "",
+ customerType: "",
taxpayerIdentificationNumber: "",
- companyAddress: "",
companyPhone: "",
+ companyAddress: "",
+ basicBankAccount: "",
+ bankAccount: "",
+ bankCode: "",
contactPerson: "",
contactPhone: "",
maintainer: "",
maintenanceTime: "",
- basicBankAccount: "",
- bankAccount: "",
- bankCode: "",
- },
- rules: {
- customerName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- taxpayerIdentificationNumber: [
- { required: true, message: "璇疯緭鍏�", trigger: "blur" },
- ],
- companyAddress: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- companyPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- // contactPerson: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- // contactPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- maintainer: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
- maintenanceTime: [
- { required: false, message: "璇烽�夋嫨", trigger: "change" },
- ],
- basicBankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- bankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- bankCode: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- },
-});
-const upload = reactive({
- // 鏄惁鏄剧ず寮瑰嚭灞傦紙瀹㈡埛瀵煎叆锛�
- open: false,
- // 寮瑰嚭灞傛爣棰橈紙瀹㈡埛瀵煎叆锛�
- title: "",
- // 鏄惁绂佺敤涓婁紶
- isUploading: false,
- // 璁剧疆涓婁紶鐨勮姹傚ご閮�
- headers: { Authorization: "Bearer " + getToken() },
- // 涓婁紶鐨勫湴鍧�
- url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData",
-});
-const { searchForm, form, rules } = toRefs(data);
-const addNewContact = () => {
- formYYs.value.contactList.push({
- contactPerson: "",
- contactPhone: ""
});
-};
+ const negotiationRecords = ref([]);
-const removeContact = (index) => {
- if (formYYs.value.contactList.length > 1) {
- formYYs.value.contactList.splice(index, 1);
- }
-};
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-const pagination = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-const getList = () => {
- tableLoading.value = true;
- listCustomer({ ...searchForm.value, ...page }).then((res) => {
- tableLoading.value = false;
- tableData.value = res.records;
- page.total = res.total;
- });
-};
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection;
-};
-/** 鎻愪氦涓婁紶鏂囦欢 */
-function submitFileForm() {
- proxy.$refs["uploadRef"].submit();
-}
-/** 瀵煎叆鎸夐挳鎿嶄綔 */
-function handleImport() {
- upload.title = "瀹㈡埛瀵煎叆";
- upload.open = true;
-}
-// 鎵撳紑寮规
-const openForm = (type, row) => {
- operationType.value = type;
- form.value = {};
- form.value.maintainer = userStore.nickName;
- formYYs.value.contactList = [
+ // 闄勪欢鐩稿叧锛堥殢娲借皥杩涘害鏁翠綋娉ㄩ噴锛�
+ // const attachmentDialogVisible = ref(false);
+ // const attachmentUploadRef = ref();
+ // const currentAttachmentList = ref([]);
+ // const currentFollowRecord = ref({});
+ // const attachmentUploadHeaders = { Authorization: "Bearer " + getToken() };
+ // const getAttachmentUploadUrl = () => {};
+
+ const tableColumn = ref([
{
- contactPerson: "",
- contactPhone: ""
- }
- ];
- form.value.maintenanceTime = getCurrentDate();
- userListNoPage().then((res) => {
- userList.value = res.data;
+ label: "瀹㈡埛鍒嗙被",
+ prop: "customerType",
+ width: 120,
+ },
+ {
+ label: "瀹㈡埛鍚嶇О",
+ prop: "customerName",
+ width: 220,
+ },
+ {
+ label: "瀹㈡埛鍦板尯",
+ prop: "regionsName",
+ width: 120,
+ },
+ {
+ label: "绾崇◣浜鸿瘑鍒爜",
+ prop: "taxpayerIdentificationNumber",
+ width: 220,
+ },
+ {
+ label: "鍦板潃鍙婅仈绯绘柟寮�",
+ prop: "addressPhone",
+ width: 250,
+ },
+ {
+ label: "鑱旂郴浜�",
+ prop: "contactPerson",
+ },
+ {
+ label: "鑱旂郴鐢佃瘽",
+ prop: "contactPhone",
+ width: 150,
+ },
+ {
+ label: "璺熻繘杩涘害",
+ prop: "followUpLevel",
+ width: 120,
+ },
+ {
+ label: "璺熻繘鏃堕棿",
+ prop: "followUpTime",
+ width: 120,
+ },
+ {
+ label: "閾惰鍩烘湰鎴�",
+ prop: "basicBankAccount",
+ width: 220,
+ },
+ {
+ label: "閾惰璐﹀彿",
+ prop: "bankAccount",
+ width: 220,
+ },
+ {
+ label: "寮�鎴疯鍙�",
+ prop: "bankCode",
+ width: 220,
+ },
+ {
+ label: "缁存姢浜�",
+ prop: "maintainer",
+ },
+ {
+ label: "缁存姢鏃堕棿",
+ prop: "maintenanceTime",
+ width: 100,
+ },
+ {
+ dataType: "action",
+ label: "鎿嶄綔",
+ align: "center",
+ fixed: "right",
+ width: 120,
+ operation: [
+ {
+ name: "缂栬緫",
+ type: "text",
+ clickFun: row => {
+ openForm("edit", row);
+ },
+ },
+ // {
+ // name: "娣诲姞娲借皥杩涘害",
+ // type: "text",
+ // clickFun: row => {
+ // openNegotiationDialog(row);
+ // },
+ // },
+ // {
+ // name: "鍥炶鎻愰啋",
+ // type: "text",
+ // clickFun: row => {
+ // openReminderDialog(row);
+ // },
+ // },
+ {
+ name: "璇︽儏",
+ type: "text",
+ clickFun: row => {
+ openDetailDialog(row);
+ },
+ },
+ ],
+ },
+ ]);
+ const tableData = ref([]);
+ const selectedRows = ref([]);
+ const userList = ref([]);
+ const tableLoading = ref(false);
+ const page = reactive({
+ current: 1,
+ size: 100,
+ total: 0,
});
- if (type === "edit") {
- getCustomer(row.id).then((res) => {
- form.value = { ...res.data };
- formYYs.value.contactList = res.data.contactPerson.split(",").map((item, index) => {
- return {
- contactPerson: item,
- contactPhone: res.data.contactPhone.split(",")[index]
- }
- });
+ const total = ref(0);
- });
- }
- dialogFormVisible.value = true;
-};
-// 鎻愪氦琛ㄥ崟
-const submitForm = () => {
- proxy.$refs["formRef"].validate((valid) => {
- if (valid) {
- if (operationType.value === "edit") {
- submitEdit();
- } else {
- submitAdd();
+ // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
+ const operationType = ref("");
+ const dialogFormVisible = ref(false);
+ const formYYs = ref({
+ // 鍏朵粬瀛楁...
+ contactList: [
+ {
+ contactPerson: "",
+ contactPhone: "",
+ },
+ ],
+ });
+ const data = reactive({
+ searchForm: {
+ customerName: "",
+ customerType: "",
+ regions: "",
+ regionsId: "",
+ },
+ form: {
+ customerName: "",
+ taxpayerIdentificationNumber: "",
+ companyAddress: "",
+ regions: "",
+ regionsId: "",
+ regionsld: "",
+ companyPhone: "",
+ contactPerson: "",
+ contactPhone: "",
+ maintainer: "",
+ maintenanceTime: "",
+ basicBankAccount: "",
+ bankAccount: "",
+ bankCode: "",
+ customerType: "",
+ },
+ rules: {
+ customerName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ taxpayerIdentificationNumber: [
+ { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+ ],
+ companyAddress: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ regions: [{ required: true, message: "璇烽�夋嫨瀹㈡埛鍦板尯", trigger: "change" }],
+ companyPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ // contactPerson: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ // contactPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ maintainer: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
+ maintenanceTime: [
+ { required: false, message: "璇烽�夋嫨", trigger: "change" },
+ ],
+ basicBankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ bankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ bankCode: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ customerType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ },
+ });
+ const upload = reactive({
+ // 鏄惁鏄剧ず寮瑰嚭灞傦紙瀹㈡埛瀵煎叆锛�
+ open: false,
+ // 寮瑰嚭灞傛爣棰橈紙瀹㈡埛瀵煎叆锛�
+ title: "",
+ // 鏄惁绂佺敤涓婁紶
+ isUploading: false,
+ // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+ headers: { Authorization: "Bearer " + getToken() },
+ // 涓婁紶鐨勫湴鍧�
+ url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData",
+ // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
+ beforeUpload: file => {
+ console.log("鏂囦欢鍗冲皢涓婁紶", file);
+ // 鍙互鍦ㄦ澶勫仛鏂囦欢绫诲瀷鎴栧ぇ灏忔牎楠�
+ const isValid =
+ file.type ===
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
+ file.name.endsWith(".xlsx") ||
+ file.name.endsWith(".xls");
+ if (!isValid) {
+ proxy.$modal.msgError("鍙兘涓婁紶 Excel 鏂囦欢");
}
+ return isValid;
+ },
+ // 鏂囦欢鐘舵�佹敼鍙樻椂鐨勫洖璋�
+ onChange: (file, fileList) => {
+ console.log("鏂囦欢鐘舵�佹敼鍙�", file, fileList);
+ },
+ // 鏂囦欢涓婁紶鎴愬姛鏃剁殑鍥炶皟
+ onSuccess: (response, file, fileList) => {
+ console.log("涓婁紶鎴愬姛", response, file, fileList);
+ upload.isUploading = false;
+ if (response.code === 200) {
+ proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+ upload.open = false;
+ proxy.$refs["uploadRef"].clearFiles();
+ getList();
+ } else if (response.code === 500) {
+ proxy.$modal.msgError(response.msg);
+ } else {
+ proxy.$modal.msgWarning(response.msg);
+ }
+ },
+ // 鏂囦欢涓婁紶澶辫触鏃剁殑鍥炶皟
+ onError: (error, file, fileList) => {
+ console.error("涓婁紶澶辫触", error, file, fileList);
+ upload.isUploading = false;
+ proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+ },
+ // 鏂囦欢涓婁紶杩涘害鍥炶皟
+ onProgress: (event, file, fileList) => {
+ console.log("涓婁紶涓�...", event.percent);
+ },
+ });
+ const { searchForm, form, rules } = toRefs(data);
+
+ // 宸︿晶鍦板尯鏍�
+ const regionTreeRef = ref();
+ const regionsLoading = ref(false);
+ const regionTreeData = ref([]);
+ const regionKeyword = ref("");
+ const selectedRegionId = ref(0); // 0 琛ㄧず鍏ㄩ儴
+ const selectedRegionNode = ref(null);
+ const formRegionPath = ref([]);
+ const addRegionDialogVisible = ref(false);
+ const editRegionDialogVisible = ref(false);
+ const addRegionForm = reactive({ parentPath: [], regionsName: "" });
+ const editRegionForm = reactive({ id: undefined, parentId: 0, regionsName: "" });
+ const regionTreeProps = { label: "label", children: "children" };
+ const regionCascaderProps = {
+ value: "id",
+ label: "label",
+ children: "children",
+ checkStrictly: true,
+ emitPath: true,
+ };
+ const regionNodeMap = computed(() => {
+ const map = new Map();
+ const walk = list => {
+ (list || []).forEach(node => {
+ map.set(node.id, node);
+ walk(node.children || []);
+ });
+ };
+ walk(regionTreeData.value);
+ return map;
+ });
+ const editRegionParentLabel = computed(() => {
+ if (!editRegionForm.parentId) return "椤剁骇鍦板尯";
+ return regionNodeMap.value.get(editRegionForm.parentId)?.label || "鏈煡";
+ });
+
+ const normalizeRegionTree = list => {
+ return (list || []).map(item => ({
+ ...item,
+ label: item.label || item.regionsName || "",
+ regionsName: item.regionsName || item.label || "",
+ children: normalizeRegionTree(item.children || []),
+ }));
+ };
+
+ const fetchRegions = async () => {
+ regionsLoading.value = true;
+ try {
+ const res = await listCustomerRegions({});
+ const list = res?.data ?? res?.rows ?? res ?? [];
+ regionTreeData.value = Array.isArray(list) ? normalizeRegionTree(list) : [];
+ } catch (e) {
+ console.error("鍦板尯鏌ヨ澶辫触:", e);
+ regionTreeData.value = [];
+ } finally {
+ regionsLoading.value = false;
}
- });
-};
-// 鎻愪氦鏂板
-const submitAdd = () => {
- if(formYYs.value.contactList.length < 1){
- return proxy.$modal.msgWarning("璇疯嚦灏戞坊鍔犱竴涓仈绯讳汉");
- }
- form.value.contactPerson = formYYs.value.contactList.map(item => item.contactPerson).join(",");
- form.value.contactPhone = formYYs.value.contactList.map(item => item.contactPhone).join(",");
- addCustomer(form.value).then((res) => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- getList();
- });
-};
-// 鎻愪氦淇敼
-const submitEdit = () => {
- updateCustomer(form.value).then((res) => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- getList();
- });
-};
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef");
- dialogFormVisible.value = false;
-};
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- proxy.download("/basic/customer/export", {}, "瀹㈡埛妗f.xlsx");
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
+ };
+
+ const filterRegionNode = (value, data) => {
+ if (!value) return true;
+ return (data.label || "").includes(value);
+ };
+
+ const selectRegion = regionName => {
+ selectedRegionId.value = 0;
+ selectedRegionNode.value = null;
+ searchForm.value.regions = regionName || "";
+ searchForm.value.regionsId = "";
+ handleQuery();
+ };
+ const handleRegionNodeClick = data => {
+ selectedRegionId.value = data.id;
+ selectedRegionNode.value = data;
+ searchForm.value.regions = data.regionsName || data.label || "";
+ searchForm.value.regionsId = data.id;
+ handleQuery();
+ };
+
+ const openAddRegionDialog = () => {
+ addRegionForm.parentPath = [];
+ addRegionForm.regionsName = "";
+ addRegionDialogVisible.value = true;
+ };
+ const closeAddRegionDialog = () => {
+ addRegionDialogVisible.value = false;
+ addRegionForm.parentPath = [];
+ addRegionForm.regionsName = "";
+ };
+ const submitAddRegion = async () => {
+ const name = (addRegionForm.regionsName || "").trim();
+ if (!name) return proxy.$modal.msgWarning("璇疯緭鍏ュ湴鍖哄悕绉�");
+ const parentPath = addRegionForm.parentPath || [];
+ const parentId = parentPath.length ? parentPath[parentPath.length - 1] : 0;
+ await addCustomerRegions({ parentId, regionsName: name });
+ proxy.$modal.msgSuccess("鏂板鎴愬姛");
+ await fetchRegions();
+ closeAddRegionDialog();
+ };
+
+ const openEditRegionDialog = () => {
+ if (!selectedRegionNode.value || selectedRegionId.value === 0) {
+ return proxy.$modal.msgWarning("璇峰厛閫夋嫨瑕佷慨鏀圭殑鍦板尯");
+ }
+ editRegionForm.id = selectedRegionNode.value.id;
+ editRegionForm.parentId = selectedRegionNode.value.parentId || 0;
+ editRegionForm.regionsName =
+ selectedRegionNode.value.regionsName || selectedRegionNode.value.label || "";
+ editRegionDialogVisible.value = true;
+ };
+ const closeEditRegionDialog = () => {
+ editRegionDialogVisible.value = false;
+ editRegionForm.id = undefined;
+ editRegionForm.parentId = 0;
+ editRegionForm.regionsName = "";
+ };
+ const submitEditRegion = async () => {
+ const name = (editRegionForm.regionsName || "").trim();
+ if (!name) return proxy.$modal.msgWarning("璇疯緭鍏ュ湴鍖哄悕绉�");
+ await updateCustomerRegions({
+ id: editRegionForm.id,
+ parentId: editRegionForm.parentId,
+ regionsName: name,
});
-};
-// 鍒犻櫎
-const handleDelete = () => {
- let ids = [];
- if (selectedRows.value.length > 0) {
- // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
- const unauthorizedData = selectedRows.value.filter(item => item.maintainer !== userStore.nickName);
- if (unauthorizedData.length > 0) {
- proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
+ proxy.$modal.msgSuccess("淇敼鎴愬姛");
+ await fetchRegions();
+ closeEditRegionDialog();
+ };
+ const handleDeleteRegion = () => {
+ if (!selectedRegionNode.value || selectedRegionId.value === 0) {
+ return proxy.$modal.msgWarning("璇峰厛閫夋嫨瑕佸垹闄ょ殑鍦板尯");
+ }
+ ElMessageBox.confirm("鍒犻櫎鍚庝笉鍙仮澶嶏紝鏄惁缁х画锛�", "鍒犻櫎鍦板尯", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(async () => {
+ await delCustomerRegions(selectedRegionNode.value.id);
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ selectRegion("");
+ await fetchRegions();
+ })
+ .catch(() => {});
+ };
+
+ const handleFormRegionChange = value => {
+ const ids = value || [];
+ if (!ids.length) {
+ form.value.regions = "";
+ form.value.regionsId = "";
+ form.value.regionsld = "";
return;
}
- ids = selectedRows.value.map((item) => item.id);
- } else {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- tableLoading.value = true;
- delCustomer(ids)
- .then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
+ const lastId = ids[ids.length - 1];
+ form.value.regions = regionNodeMap.value.get(lastId)?.regionsName || "";
+ form.value.regionsId = lastId;
+ form.value.regionsld = lastId;
+ };
+ const findRegionPathByName = (tree, targetName, parentPath = []) => {
+ for (const item of tree || []) {
+ const currentPath = [...parentPath, item.id];
+ if ((item.regionsName || item.label) === targetName) {
+ return currentPath;
+ }
+ const childResult = findRegionPathByName(item.children || [], targetName, currentPath);
+ if (childResult.length) return childResult;
+ }
+ return [];
+ };
+ const findRegionPathById = (tree, targetId, parentPath = []) => {
+ if (targetId === undefined || targetId === null || targetId === "") return [];
+ for (const item of tree || []) {
+ const currentPath = [...parentPath, item.id];
+ if (String(item.id) === String(targetId)) {
+ return currentPath;
+ }
+ const childResult = findRegionPathById(item.children || [], targetId, currentPath);
+ if (childResult.length) return childResult;
+ }
+ return [];
+ };
+ const addNewContact = () => {
+ formYYs.value.contactList.push({
+ contactPerson: "",
+ contactPhone: "",
});
-};
+ };
-// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
-function getCurrentDate() {
- const today = new Date();
- const year = today.getFullYear();
- const month = String(today.getMonth() + 1).padStart(2, "0"); // 鏈堜唤浠�0寮�濮�
- const day = String(today.getDate()).padStart(2, "0");
- return `${year}-${month}-${day}`;
-}
+ const removeContact = index => {
+ if (formYYs.value.contactList.length > 1) {
+ formYYs.value.contactList.splice(index, 1);
+ }
+ };
+ // 鏌ヨ鍒楄〃
+ /** 鎼滅储鎸夐挳鎿嶄綔 */
+ const handleQuery = () => {
+ page.current = 1;
+ getList();
+ };
+ const pagination = obj => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+ };
+ const getList = () => {
+ tableLoading.value = true;
+ listCustomer({ ...searchForm.value, ...page }).then(res => {
+ tableLoading.value = false;
+ tableData.value = res.records;
+ page.total = res.total;
+ });
+ };
+ // 琛ㄦ牸閫夋嫨鏁版嵁
+ const handleSelectionChange = selection => {
+ selectedRows.value = selection;
+ };
+ /** 鎻愪氦涓婁紶鏂囦欢 */
+ function submitFileForm() {
+ upload.isUploading = true;
+ proxy.$refs["uploadRef"].submit();
+ }
+ /** 瀵煎叆鎸夐挳鎿嶄綔 */
+ function handleImport() {
+ upload.title = "瀹㈡埛瀵煎叆";
+ upload.open = true;
+ }
+ /** 涓嬭浇妯℃澘 */
+ function importTemplate() {
+ proxy.download("/basic/customer/downloadTemplate", {}, "瀹㈡埛瀵煎叆妯℃澘.xlsx");
+ }
+ // 鎵撳紑寮规
+ const openForm = (type, row) => {
+ operationType.value = type;
+ form.value = {};
+ formRegionPath.value = [];
+ form.value.regionsId = "";
+ form.value.regionsld = "";
+ form.value.maintainer = userStore.nickName;
+ formYYs.value.contactList = [
+ {
+ contactPerson: "",
+ contactPhone: "",
+ },
+ ];
+ form.value.maintenanceTime = getCurrentDate();
+ userListNoPage().then(res => {
+ userList.value = res.data;
+ });
+ if (type === "edit") {
+ getCustomer(row.id).then(res => {
+ form.value = { ...res.data };
+ const regionIdForEdit = form.value.regionsId || form.value.regionsld;
+ formRegionPath.value = findRegionPathById(regionTreeData.value, regionIdForEdit);
+ if (!formRegionPath.value.length) {
+ formRegionPath.value = findRegionPathByName(
+ regionTreeData.value,
+ form.value.regionsName || form.value.regions || ""
+ );
+ }
+ const selectedRegionId =
+ formRegionPath.value.length > 0
+ ? formRegionPath.value[formRegionPath.value.length - 1]
+ : "";
+ if (selectedRegionId && !form.value.regions) {
+ form.value.regions = regionNodeMap.value.get(selectedRegionId)?.regionsName || "";
+ }
+ form.value.regionsId = form.value.regionsId || selectedRegionId;
+ form.value.regionsld = form.value.regionsld || form.value.regionsId || selectedRegionId;
+ formYYs.value.contactList = res.data.contactPerson
+ .split(",")
+ .map((item, index) => {
+ return {
+ contactPerson: item,
+ contactPhone: res.data.contactPhone.split(",")[index],
+ };
+ });
+ });
+ }
+ dialogFormVisible.value = true;
+ };
+ // 鎻愪氦琛ㄥ崟
+ const submitForm = () => {
+ proxy.$refs["formRef"].validate(valid => {
+ if (valid) {
+ if (operationType.value === "edit") {
+ submitEdit();
+ } else {
+ submitAdd();
+ }
+ }
+ });
+ };
+ // 鎻愪氦鏂板
+ const submitAdd = () => {
+ if (formYYs.value.contactList.length < 1) {
+ return proxy.$modal.msgWarning("璇疯嚦灏戞坊鍔犱竴涓仈绯讳汉");
+ }
+ form.value.contactPerson = formYYs.value.contactList
+ .map(item => item.contactPerson)
+ .join(",");
+ form.value.contactPhone = formYYs.value.contactList
+ .map(item => item.contactPhone)
+ .join(",");
+ if (!form.value.regionsId && formRegionPath.value.length) {
+ form.value.regionsId = formRegionPath.value[formRegionPath.value.length - 1];
+ }
+ form.value.regionsld = form.value.regionsId || "";
+ addCustomer(form.value).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ getList();
+ });
+ };
+ // 鎻愪氦淇敼
+ const submitEdit = () => {
+ form.value.contactPerson = formYYs.value.contactList
+ .map(item => item.contactPerson)
+ .join(",");
+ form.value.contactPhone = formYYs.value.contactList
+ .map(item => item.contactPhone)
+ .join(",");
+ if (!form.value.regionsId && formRegionPath.value.length) {
+ form.value.regionsId = formRegionPath.value[formRegionPath.value.length - 1];
+ }
+ form.value.regionsld = form.value.regionsId || "";
+ updateCustomer(form.value).then(res => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ getList();
+ });
+ };
+ // 鍏抽棴寮规
+ const closeDia = () => {
+ proxy.resetForm("formRef");
+ formRegionPath.value = [];
+ dialogFormVisible.value = false;
+ };
+ // 瀵煎嚭
+ const handleOut = () => {
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ proxy.download("/basic/customer/export", {}, "瀹㈡埛妗f.xlsx");
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+ };
+ // 鍒犻櫎
+ const handleDelete = () => {
+ let ids = [];
+ if (selectedRows.value.length > 0) {
+ // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
+ const unauthorizedData = selectedRows.value.filter(
+ item => item.maintainer !== userStore.nickName
+ );
+ if (unauthorizedData.length > 0) {
+ proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
+ return;
+ }
+ ids = selectedRows.value.map(item => item.id);
+ } else {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ tableLoading.value = true;
+ delCustomer(ids)
+ .then(res => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ })
+ .finally(() => {
+ tableLoading.value = false;
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+ };
-getList();
+ /*
+ * 鍥炶鎻愰啋 / 娲借皥杩涘害鍔熻兘锛堝叆鍙e強寮圭獥锛夊凡鎸夐渶姹傛敞閲婏紝浠ヤ笅鏂规硶鏆備笉鍚敤锛�
+ * - openReminderDialog / closeReminderDialog / submitReminderForm
+ * - openNegotiationDialog / closeNegotiationDialog / submitNegotiationForm
+ */
+ // const openReminderDialog = row => {};
+ // const closeReminderDialog = () => {};
+ // const submitReminderForm = () => {};
+ // const openNegotiationDialog = row => {};
+ // const closeNegotiationDialog = () => {};
+ // const submitNegotiationForm = () => {};
+
+ // 鎵撳紑璇︽儏寮圭獥
+ const openDetailDialog = row => {
+ // 璋冪敤getCustomer鎺ュ彛鑾峰彇瀹㈡埛璇︽儏
+ getCustomer(row.id).then(res => {
+ // 濉厖瀹㈡埛鍩烘湰淇℃伅
+ Object.assign(detailForm, res.data);
+
+ // 鑾峰彇娲借皥杩涘害璁板綍
+ negotiationRecords.value = res.data.followUpList || [];
+
+ detailDialogVisible.value = true;
+ });
+ };
+
+ // 鍏抽棴璇︽儏寮圭獥
+ const closeDetailDialog = () => {
+ detailDialogVisible.value = false;
+ };
+
+ /*
+ * 娲借皥杩涘害璁板綍 & 闄勪欢绠$悊鐩稿叧锛堝凡闅忓叆鍙f暣浣撴敞閲婏級
+ * - editNegotiationRecord / deleteNegotiationRecord
+ * - openAttachmentDialog / closeAttachmentDialog / ...闄勪欢鐩稿叧鏂规硶
+ */
+
+ // 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
+ function getCurrentDate() {
+ const today = new Date();
+ const year = today.getFullYear();
+ const month = String(today.getMonth() + 1).padStart(2, "0"); // 鏈堜唤浠�0寮�濮�
+ const day = String(today.getDate()).padStart(2, "0");
+ return `${year}-${month}-${day}`;
+ }
+
+ onMounted(() => {
+ fetchRegions();
+ getList();
+ });
+
+ watch(regionKeyword, value => {
+ regionTreeRef.value?.filter((value || "").trim());
+ });
</script>
-<style scoped lang="scss"></style>
+<style scoped lang="scss">
+ .customer-split {
+ display: flex;
+ gap: 12px;
+ }
+
+ .left-panel {
+ width: 260px;
+ flex: 0 0 260px;
+ background: #fff;
+ border-radius: 6px;
+ border: 1px solid #ebeef5;
+ padding: 12px;
+ height: calc(100vh - 140px);
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ }
+
+ .right-panel {
+ flex: 1;
+ min-width: 0;
+ }
+
+ .toolbar-card {
+ background: #ffffff;
+ border: 1px solid #ebeef5;
+ border-radius: 10px;
+ padding: 14px 16px;
+ margin-bottom: 12px;
+ box-shadow: 0 2px 10px rgba(31, 35, 41, 0.04);
+ }
+
+ .right-search-form {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 12px;
+ flex-wrap: nowrap;
+ }
+
+ .search-fields {
+ display: flex;
+ align-items: center;
+ flex-wrap: nowrap;
+ gap: 0;
+ flex: 1;
+ min-width: 0;
+ }
+
+ .toolbar-divider {
+ width: 1px;
+ align-self: stretch;
+ background: linear-gradient(to bottom, transparent, #e4e7ed 15%, #e4e7ed 85%, transparent);
+ }
+
+ .action-buttons {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+ padding-left: 2px;
+ flex-shrink: 0;
+ }
+
+ .action-buttons :deep(.el-button) {
+ margin-left: 0;
+ min-width: 84px;
+ }
+
+ .table-card {
+ background: #fff;
+ border: 1px solid #ebeef5;
+ border-radius: 10px;
+ padding: 12px;
+ box-shadow: 0 2px 10px rgba(31, 35, 41, 0.03);
+ }
+
+ @media (max-width: 1500px) {
+ .right-search-form {
+ flex-wrap: wrap;
+ }
+
+ .search-fields {
+ flex-wrap: wrap;
+ gap: 8px 0;
+ }
+
+ .toolbar-divider {
+ display: none;
+ }
+
+ .action-buttons {
+ width: 100%;
+ border-top: 1px dashed #e4e7ed;
+ padding-top: 10px;
+ }
+ }
+
+ .left-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 10px;
+ }
+
+ .left-title {
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .left-actions {
+ display: flex;
+ gap: 6px;
+ }
+
+ .left-actions :deep(.el-button) {
+ margin-left: 0;
+ padding: 5px 10px;
+ }
+
+ .left-search {
+ margin-bottom: 10px;
+ }
+
+ .left-list {
+ flex: 1;
+ overflow: auto;
+ padding-right: 4px;
+ }
+
+ .region-item {
+ padding: 8px 10px;
+ border-radius: 6px;
+ cursor: pointer;
+ color: #303133;
+ user-select: none;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+
+ .region-item:hover {
+ background: #f5f7fa;
+ }
+
+ .region-item.active {
+ background: #ecf5ff;
+ color: #409eff;
+ font-weight: 600;
+ }
+
+ .left-list :deep(.el-tree) {
+ background: transparent;
+ }
+
+ .left-list :deep(.el-tree-node__content) {
+ height: 30px;
+ border-radius: 6px;
+ }
+
+ .left-list :deep(.el-tree-node__content:hover) {
+ background: #f5f7fa;
+ }
+
+ .empty-tip {
+ padding: 16px 10px;
+ color: #909399;
+ font-size: 13px;
+ }
+
+ .detail-section {
+ margin-bottom: 20px;
+ padding: 15px;
+ background-color: #f9f9f9;
+ border-radius: 4px;
+ }
+
+ .section-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 15px;
+ }
+
+ .section-title {
+ font-size: 16px;
+ font-weight: bold;
+ margin: 0 0 15px 0;
+ color: #333;
+ }
+
+ .info-display {
+ background-color: #fff;
+ padding: 15px;
+ border-radius: 4px;
+ }
+
+ .info-item {
+ margin-bottom: 12px;
+ display: flex;
+ align-items: flex-start;
+ }
+
+ .info-label {
+ width: 120px;
+ font-weight: 500;
+ color: #606266;
+ margin-right: 10px;
+ }
+
+ .info-value {
+ flex: 1;
+ color: #303133;
+ word-break: break-word;
+ }
+
+ .no-records {
+ text-align: center;
+ padding: 30px;
+ color: #999;
+ font-size: 14px;
+ }
+
+ .attachment-section {
+ .upload-area {
+ margin-bottom: 20px;
+ padding: 20px;
+ background-color: #f9f9f9;
+ border-radius: 4px;
+ border: 1px dashed #d9d9d9;
+
+ .el-upload__tip {
+ margin-top: 10px;
+ color: #909399;
+ }
+ }
+
+ .attachment-list {
+ h4 {
+ margin: 0 0 10px 0;
+ font-size: 14px;
+ color: #606266;
+ }
+ }
+
+ .no-attachment {
+ text-align: center;
+ padding: 40px;
+ color: #909399;
+ font-size: 14px;
+ }
+ }
+</style>
--
Gitblit v1.9.3