index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. <template>
  2. <div class="app-container">
  3. <el-card shadow="never" class="search-card">
  4. <el-form :model="queryParams" ref="queryRef" label-width="110px">
  5. <!-- 第一行 -->
  6. <el-row :gutter="20">
  7. <el-col :span="6">
  8. <el-form-item label="归属公司" prop="belongCompanyId" class="custom-form-item">
  9. <el-select v-model="queryParams.belongCompanyId" placeholder="请选择" clearable style="width: 100%">
  10. <el-option v-for="item in companyOptions" :key="item.id" :label="item.companyName" :value="item.id" />
  11. </el-select>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :span="6">
  15. <el-form-item label="客户编号" prop="customerNo" class="custom-form-item">
  16. <el-input v-model="queryParams.customerNo" placeholder="请输入客户编号" clearable />
  17. </el-form-item>
  18. </el-col>
  19. <el-col :span="6">
  20. <el-form-item label="客户名称" prop="customerName" class="custom-form-item">
  21. <el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable />
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="6">
  25. <el-form-item label="客户等级" prop="customerLevelId" class="custom-form-item">
  26. <el-select v-model="queryParams.customerLevelId" placeholder="请选择" clearable style="width: 100%">
  27. <el-option v-for="item in levelOptions" :key="item.id" :label="item.levelName" :value="item.id" />
  28. </el-select>
  29. </el-form-item>
  30. </el-col>
  31. </el-row>
  32. <!-- 第二行 -->
  33. <el-row :gutter="20" class="mt-15">
  34. <el-col :span="6">
  35. <el-form-item label="行业" prop="industryCategoryId" class="custom-form-item">
  36. <el-select v-model="queryParams.industryCategoryId" placeholder="请选择" clearable style="width: 100%">
  37. <el-option v-for="item in industryOptions" :key="item.id" :label="item.industryCategoryName" :value="item.id" />
  38. </el-select>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="6">
  42. <el-form-item label="业务负责人" prop="salesPersonId" class="custom-form-item">
  43. <el-select v-model="queryParams.salesPersonId" placeholder="请选择" clearable style="width: 100%">
  44. <el-option v-for="item in staffOptions" :key="item.staffId" :label="(item.staffCode ? '(' + item.staffCode + ') ' : '') + item.staffName" :value="item.staffId" />
  45. </el-select>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="6">
  49. <el-form-item label="客服支持" prop="serviceStaffId" class="custom-form-item">
  50. <el-select v-model="queryParams.serviceStaffId" placeholder="请选择" clearable style="width: 100%">
  51. <el-option v-for="item in staffOptions" :key="item.staffId" :label="(item.staffCode ? '(' + item.staffCode + ') ' : '') + item.staffName" :value="item.staffId" />
  52. </el-select>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="6">
  56. <el-form-item label="部门" prop="belongingDepartmentId" class="custom-form-item">
  57. <el-tree-select
  58. v-model="queryParams.belongingDepartmentId"
  59. :data="deptOptions"
  60. :props="{ value: 'deptId', label: 'deptName', children: 'children' }"
  61. value-key="deptId"
  62. placeholder="请选择部门"
  63. check-strictly
  64. clearable
  65. style="width: 100%"
  66. />
  67. </el-form-item>
  68. </el-col> </el-row>
  69. <!-- 第三行 -->
  70. <el-row :gutter="20" class="mt-15">
  71. <el-col :span="6">
  72. <el-form-item label="合作状态" prop="status" class="custom-form-item">
  73. <el-select v-model="queryParams.status" placeholder="请选择" clearable style="width: 100%">
  74. <el-option v-for="item in cooperationOptions" :key="item.value" :label="item.label" :value="item.value" />
  75. </el-select>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="6">
  79. <el-form-item label="企业类型" prop="enterpriseTypeId" class="custom-form-item">
  80. <el-select v-model="queryParams.enterpriseTypeId" placeholder="请选择" clearable style="width: 100%">
  81. <el-option v-for="item in corpTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
  82. </el-select>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="12">
  86. <div class="search-btns-area">
  87. <el-button type="default" icon="Search" @click="handleQuery">搜索</el-button>
  88. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  89. </div>
  90. </el-col>
  91. </el-row>
  92. </el-form>
  93. </el-card>
  94. <el-card shadow="never" class="table-card">
  95. <div class="list-tool-row">
  96. <div class="tabs-left">
  97. <span class="list-main-title">客户信息列表</span>
  98. <div
  99. v-for="tab in tabs"
  100. :key="tab.key"
  101. :class="['tab-nav-item', activeTab === tab.key ? 'active' : '']"
  102. @click="handleTabClick(tab.key)"
  103. >
  104. {{ tab.label }}
  105. <el-badge v-if="tab.badge" :value="tab.badge" :max="99" class="count-badge" />
  106. </div>
  107. </div>
  108. <div class="tools-right">
  109. <el-button type="primary" icon="Back" class="blue-btn" @click="handleReturnHighSeas">退回到客户公海池</el-button>
  110. <el-button type="primary" icon="Switch" class="blue-btn" @click="handleTransferSales">转移业务员</el-button>
  111. <el-button type="primary" icon="UserFilled" class="blue-btn" @click="handleTransferSupport">转移客服人员</el-button>
  112. </div>
  113. </div>
  114. <el-table
  115. v-loading="loading"
  116. :data="dataList"
  117. @selection-change="handleSelectionChange"
  118. border
  119. class="custom-table"
  120. >
  121. <el-table-column type="selection" width="55" align="center" />
  122. <el-table-column label="客户编号" align="center" prop="customerNo" width="100" />
  123. <el-table-column label="客户名称" align="left" min-width="250" show-overflow-tooltip>
  124. <template #default="scope">
  125. <span class="customer-name-text" @click="handleDetail(scope.row)">{{ scope.row.customerName }}</span>
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="归属公司" align="center" prop="companyName" min-width="180" show-overflow-tooltip />
  129. <el-table-column label="行业" align="center" prop="industryName" width="120" />
  130. <el-table-column label="企业类型" align="center" prop="enterpriseTypeName" width="120" />
  131. <el-table-column label="合作等级" align="center" prop="customerLevelName" width="100" />
  132. <el-table-column label="业务负责人" align="center" prop="salesPersonName" width="120" />
  133. <el-table-column label="客服支持" align="center" prop="serviceStaffName" width="120" />
  134. <el-table-column label="部门" align="center" prop="deptName" width="120" show-overflow-tooltip />
  135. <el-table-column label="合作状况" align="center" prop="cooperationName" width="100" />
  136. <el-table-column label="操作" align="center" width="100" fixed="right">
  137. <template #default="scope">
  138. <el-button link type="info" class="op-link detail-link" @click="handleDetail(scope.row)">详情</el-button>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <pagination
  143. v-show="total > 0"
  144. :total="total"
  145. v-model:page="queryParams.pageNum"
  146. v-model:limit="queryParams.pageSize"
  147. layout="total, sizes, prev, pager, next, jumper"
  148. @pagination="getList"
  149. />
  150. </el-card>
  151. <!-- 转移人员弹窗 -->
  152. <el-dialog :title="transferDialog.title" v-model="transferDialog.visible" width="400px" append-to-body>
  153. <el-form ref="transferRef" :model="transferForm" :rules="transferRules" label-width="100px">
  154. <el-form-item label="选择人员:" prop="staffId">
  155. <template #label>
  156. <span style="color: #f56c6c; margin-right: 4px;">*</span>选择人员:
  157. </template>
  158. <el-select v-model="transferForm.staffId" placeholder="请选择" filterable style="width: 100%">
  159. <el-option v-for="item in staffOptions" :key="item.staffId" :label="(item.staffCode ? '(' + item.staffCode + ') ' : '') + item.staffName" :value="item.staffId" />
  160. </el-select>
  161. </el-form-item>
  162. </el-form>
  163. <template #footer>
  164. <div class="dialog-footer">
  165. <el-button @click="transferDialog.visible = false">取 消</el-button>
  166. <el-button type="primary" @click="submitTransfer">确 认</el-button>
  167. </div>
  168. </template>
  169. </el-dialog>
  170. <!-- 客户详情抽屉 -->
  171. <customer-detail ref="detailRef" @success="getList" />
  172. <!-- 子路由出口:用于显示其他可能的子页面 -->
  173. <router-view />
  174. </div>
  175. </template>
  176. <script setup name="CustomerValid">
  177. import { ref, reactive, onMounted, getCurrentInstance, toRefs } from 'vue';
  178. import { useRouter } from 'vue-router';
  179. import { listMineCustomer, listInvolvedCustomer, listAllCustomer, releaseToPool, listCompanyOption, transferSalesPerson, transferServiceStaff } from "@/api/customer/customerPool";
  180. import { listIndustryCategory } from "@/api/customer/industryCategory";
  181. import { listLevel } from "@/api/customer/customerLevel";
  182. import { listComStaff } from "@/api/system/comStaff/index";
  183. import { deptTreeSelect } from "@/api/system/dept";
  184. import { debounce } from 'lodash-es';
  185. import { useUserStore } from "@/store/modules/user";
  186. import CustomerDetail from "./detail.vue";
  187. const proxy = getCurrentInstance().proxy;
  188. const { Q0001: corpTypeOptions, cooperation_status: cooperationOptions } = toRefs(reactive(proxy.useDict("Q0001", "cooperation_status")));
  189. const router = useRouter();
  190. const userStore = useUserStore();
  191. const loading = ref(false);
  192. const total = ref(0);
  193. const dataList = ref([]);
  194. const ids = ref([]);
  195. const detailRef = ref(null);
  196. // 选项数据
  197. const industryOptions = ref([]);
  198. const staffOptions = ref([]);
  199. const companyOptions = ref([]);
  200. const levelOptions = ref([]);
  201. const deptOptions = ref([]);
  202. const activeTab = ref('all');
  203. const tabs = [
  204. { label: '我负责的客户', key: 'mine' },
  205. { label: '我参与的客户', key: 'involved' },
  206. { label: '全部客户', key: 'all' }
  207. ];
  208. const handleTabClick = (key) => {
  209. activeTab.value = key;
  210. queryParams.activeTab = key;
  211. // 重置负责人相关的过滤参数
  212. queryParams.salesPersonId = undefined;
  213. queryParams.serviceStaffId = undefined;
  214. handleQuery();
  215. };
  216. const queryParams = reactive({
  217. pageNum: 1,
  218. pageSize: 10,
  219. belongCompanyId: undefined,
  220. customerNo: undefined,
  221. customerName: undefined,
  222. customerLevelId: undefined,
  223. industryCategoryId: undefined,
  224. salesPersonId: undefined,
  225. serviceStaffId: undefined,
  226. belongingDepartmentId: undefined,
  227. status: undefined,
  228. enterpriseTypeId: undefined,
  229. activeTab: 'all'
  230. });
  231. const getList = () => {
  232. loading.value = true;
  233. let req = null;
  234. if (activeTab.value === 'mine') {
  235. req = listMineCustomer(queryParams);
  236. } else if (activeTab.value === 'involved') {
  237. req = listInvolvedCustomer(queryParams);
  238. } else {
  239. req = listAllCustomer(queryParams);
  240. }
  241. req.then(res => {
  242. dataList.value = res.rows || [];
  243. total.value = res.total || 0;
  244. loading.value = false;
  245. }).catch(() => {
  246. loading.value = false;
  247. });
  248. };
  249. const handleSelectionChange = (selection) => {
  250. ids.value = selection.map(item => item.id);
  251. };
  252. const handleReturnHighSeas = () => {
  253. if (ids.value.length === 0) { proxy.$modal.msgWarning("请选择要操作的数据"); return; }
  254. proxy.$modal.confirm(`是否将选中的${ids.value.length}个客户退回到客户公海池?`).then(() => {
  255. loading.value = true;
  256. // 一次性调用批量接口
  257. releaseToPool(ids.value, "有效客户退回").then(() => {
  258. proxy.$modal.msgSuccess("退回成功");
  259. // 跳转到公海池页面
  260. router.push('/customer/highseas');
  261. }).catch(() => {
  262. loading.value = false;
  263. });
  264. }).catch(() => {});
  265. };
  266. const transferDialog = reactive({
  267. visible: false,
  268. title: '',
  269. type: '' // 'sales' 或 'support'
  270. });
  271. const transferForm = reactive({
  272. staffId: undefined
  273. });
  274. const transferRules = {
  275. staffId: [{ required: true, message: '请选择人员', trigger: 'change' }]
  276. };
  277. const transferRef = ref(null);
  278. const handleTransferSales = () => {
  279. if (ids.value.length === 0) { proxy.$modal.msgWarning("请选择要操作的数据"); return; }
  280. transferDialog.title = '转移业务员';
  281. transferDialog.type = 'sales';
  282. transferForm.staffId = undefined;
  283. if (transferRef.value) transferRef.value.clearValidate();
  284. transferDialog.visible = true;
  285. };
  286. const handleTransferSupport = () => {
  287. if (ids.value.length === 0) { proxy.$modal.msgWarning("请选择要操作的数据"); return; }
  288. transferDialog.title = '转移客服人员';
  289. transferDialog.type = 'support';
  290. transferForm.staffId = undefined;
  291. if (transferRef.value) transferRef.value.clearValidate();
  292. transferDialog.visible = true;
  293. };
  294. const submitTransfer = () => {
  295. transferRef.value.validate(valid => {
  296. if (valid) {
  297. const data = { customerIds: ids.value };
  298. let apiCall = null;
  299. if (transferDialog.type === 'sales') {
  300. data.salesPersonId = transferForm.staffId;
  301. apiCall = transferSalesPerson(data);
  302. } else {
  303. data.serviceStaffId = transferForm.staffId;
  304. apiCall = transferServiceStaff(data);
  305. }
  306. apiCall.then(() => {
  307. proxy.$modal.msgSuccess("转移成功");
  308. transferDialog.visible = false;
  309. getList();
  310. });
  311. }
  312. });
  313. };
  314. const handleQuery = debounce(() => {
  315. queryParams.pageNum = 1;
  316. getList();
  317. }, 300);
  318. const resetQuery = () => {
  319. proxy.resetForm("queryRef");
  320. // 手动重置所有查询参数为初始值,确保重置彻底
  321. Object.keys(queryParams).forEach(key => {
  322. if (key !== 'pageNum' && key !== 'pageSize') {
  323. queryParams[key] = undefined;
  324. }
  325. });
  326. queryParams.pageNum = 1;
  327. getList(); // 重置后直接刷新列表,不再等待防抖
  328. };
  329. const handleDetail = debounce((row) => {
  330. detailRef.value.open(row.id);
  331. }, 200);
  332. const initOptions = async () => {
  333. listCompanyOption().then(res => companyOptions.value = res.data || []);
  334. listIndustryCategory().then(res => industryOptions.value = res.data || res.rows || []);
  335. listLevel().then(res => levelOptions.value = res.rows || []);
  336. listComStaff({ pageSize: 1000 }).then(res => staffOptions.value = res.rows || res.data || []);
  337. deptTreeSelect().then(res => deptOptions.value = proxy.handleTree(res.data, "deptId"));
  338. };
  339. onMounted(() => {
  340. initOptions();
  341. getList();
  342. });
  343. </script>
  344. <style scoped lang="scss">
  345. .app-container {
  346. padding: 24px;
  347. background-color: #f8fafc;
  348. min-height: 100vh;
  349. /* 全局强制取消加粗 */
  350. :deep(*) {
  351. font-weight: 400 !important;
  352. }
  353. }
  354. .search-card {
  355. margin-bottom: 20px;
  356. border-radius: 8px;
  357. border: none;
  358. box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  359. }
  360. .custom-form-item {
  361. margin-bottom: 0px;
  362. :deep(.el-form-item__label) {
  363. font-weight: normal !important;
  364. color: #475569;
  365. padding-right: 12px;
  366. white-space: nowrap !important;
  367. }
  368. :deep(.el-input__wrapper), :deep(.el-select__wrapper) {
  369. box-shadow: 0 0 0 1px #cbd5e1 inset !important;
  370. &:hover, &.is-focus {
  371. box-shadow: 0 0 0 1px #3b82f6 inset !important;
  372. }
  373. }
  374. }
  375. .search-btns-area {
  376. display: flex;
  377. justify-content: flex-start;
  378. align-items: center;
  379. gap: 12px;
  380. padding-left: 20px;
  381. .el-button {
  382. border-radius: 2px;
  383. height: 32px;
  384. padding: 0 15px;
  385. font-size: 14px;
  386. transition: all 0.2s;
  387. }
  388. .el-button--default, .el-button:not(.el-button--primary) {
  389. border: 1px solid #d1d5db !important;
  390. color: #374151 !important;
  391. background-color: #fff;
  392. &:hover {
  393. background-color: #f9fafb;
  394. border-color: #9ca3af !important;
  395. }
  396. }
  397. }
  398. .table-card {
  399. border-radius: 4px;
  400. border: 1px solid #e2e8f0;
  401. box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  402. :deep(.el-card__body) {
  403. padding: 0;
  404. }
  405. }
  406. /* 列表标题栏与工具栏 */
  407. .list-tool-row {
  408. display: flex;
  409. justify-content: space-between;
  410. align-items: center;
  411. padding: 0 20px;
  412. background: #fff;
  413. height: 60px;
  414. border-bottom: 1px solid #f1f5f9;
  415. }
  416. .tabs-left {
  417. display: flex;
  418. gap: 12px;
  419. height: 100%;
  420. align-items: center;
  421. .list-main-title {
  422. font-size: 15px;
  423. font-weight: normal;
  424. color: #1e293b;
  425. margin-right: 20px;
  426. }
  427. .tab-nav-item {
  428. display: flex;
  429. align-items: center;
  430. cursor: pointer;
  431. font-size: 14px;
  432. color: #333;
  433. padding: 6px 16px;
  434. border: 1px solid #e2e8f0;
  435. border-radius: 2px;
  436. transition: all 0.2s;
  437. background-color: #fff;
  438. &.active {
  439. color: #409eff;
  440. font-weight: normal;
  441. border-color: #409eff;
  442. }
  443. &:hover:not(.active) {
  444. border-color: #cbd5e1;
  445. }
  446. }
  447. .count-badge {
  448. margin-left: 5px;
  449. :deep(.el-badge__content) {
  450. background-color: #ef4444;
  451. transform: scale(0.8) translateY(-4px);
  452. }
  453. }
  454. }
  455. .tools-right {
  456. display: flex;
  457. gap: 12px;
  458. .blue-btn {
  459. background-color: #409eff !important;
  460. border-color: #409eff !important;
  461. height: 36px;
  462. padding: 0 16px;
  463. font-size: 14px;
  464. border-radius: 4px;
  465. display: flex;
  466. align-items: center;
  467. gap: 6px;
  468. &:hover {
  469. background-color: #66b1ff !important;
  470. }
  471. }
  472. }
  473. .custom-table {
  474. border-radius: 0;
  475. overflow: hidden;
  476. :deep(th.el-table__cell) {
  477. background-color: #f8fafc !important;
  478. color: #1e293b;
  479. font-size: 13px;
  480. font-weight: normal;
  481. height: 48px;
  482. }
  483. :deep(.el-table__row) {
  484. height: 52px;
  485. td {
  486. font-size: 13px;
  487. color: #334155;
  488. }
  489. }
  490. :deep(.el-table__fixed-right) {
  491. border-left: 1px solid #ebeef5;
  492. height: 100% !important;
  493. }
  494. }
  495. .customer-name-text {
  496. color: #409eff;
  497. cursor: pointer;
  498. font-weight: normal;
  499. &:hover {
  500. color: #66b1ff;
  501. }
  502. }
  503. .op-link {
  504. font-weight: normal;
  505. margin: 0 6px;
  506. font-size: 13px;
  507. }
  508. .detail-link {
  509. color: #909399 !important;
  510. &:hover {
  511. color: #409eff !important;
  512. }
  513. }
  514. .mt-15 {
  515. margin-top: 15px;
  516. }
  517. /* 移除所有文字下划线 */
  518. :deep(*) {
  519. text-decoration: none !important;
  520. }
  521. </style>