index.vue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840
  1. <template>
  2. <div class="tenant">
  3. <div style="padding: 20px; background: #fff; margin-bottom: 20px">
  4. <el-button type="primary" style="margin-left: 10px" @click="openModal()"
  5. >添加客户</el-button
  6. >
  7. </div>
  8. <byTable
  9. :source="sourceList.data"
  10. :pagination="sourceList.pagination"
  11. :config="config"
  12. :loading="loading"
  13. :selectConfig="selectConfig"
  14. :statConfig="statConfig"
  15. highlight-current-row
  16. @moreSearch="moreSearch"
  17. @get-list="getList"
  18. ref="table"
  19. >
  20. <template #isTop="{ item }">
  21. <div>
  22. <img
  23. style="cursor: pointer; width: 20px; transform: translateY(5px)"
  24. :src="'/img/isTop.png'"
  25. @click="deleteTop(item)"
  26. v-if="item.isTop === 1"
  27. />
  28. <img
  29. style="cursor: pointer; width: 20px; transform: translateY(5px)"
  30. :src="'/img/noTop.png'"
  31. @click="addTop(item)"
  32. v-else
  33. />
  34. </div>
  35. </template>
  36. <template #address="{ item }">
  37. <span>{{ item.countryName }}</span>
  38. <span v-if="item.provinceName"> ,{{ item.provinceName }}</span>
  39. <span v-if="item.cityName"> ,{{ item.cityName }}</span>
  40. </template>
  41. <template #name="{ item }">
  42. <div
  43. style="cursor: pointer; color: #409eff; word-break: break-all"
  44. @click="handleClickName(item)"
  45. >
  46. {{ item.name }}
  47. </div>
  48. </template>
  49. <template #tags="{ item }">
  50. <div style="width: 100%">
  51. <el-tag
  52. style="margin-right: 8px"
  53. type="success"
  54. v-for="(tag, index) in item.tag"
  55. closable
  56. :key="index"
  57. @close="tagClose(tag, item)"
  58. >
  59. {{ dictValueLabel(tag, customerTag) }}
  60. </el-tag>
  61. <template v-if="item.tag.length !== customerTag.length">
  62. <el-select
  63. v-if="item.addTagShow"
  64. v-model="addTag"
  65. style="width: 100%"
  66. @change="
  67. (val) => {
  68. return changeTag(val, item);
  69. }
  70. "
  71. >
  72. <el-option
  73. v-for="tag in customerTag"
  74. :key="tag.value"
  75. :label="tag.label"
  76. :value="tag.value"
  77. :disabled="judgeTagSelect(item.tag, tag.value)"
  78. />
  79. </el-select>
  80. <el-tag
  81. style="cursor: pointer"
  82. type="success"
  83. @click="showSelect(item)"
  84. v-else
  85. >
  86. +
  87. </el-tag>
  88. </template>
  89. </div>
  90. </template>
  91. <template #follow="{ item }">
  92. <div :class="'getWidth' + item.id" style="width: 100%">
  93. <div style="width: 100%; display: flex">
  94. <template
  95. v-if="
  96. item.customerFollowRecordsList &&
  97. item.customerFollowRecordsList.length > 0
  98. "
  99. >
  100. <div
  101. :style="
  102. index > 2
  103. ? 'line-height: 32px; margin-right: 8px; padding: 0 8px; background-color: #eeeeee; border-radius: 4px; cursor: pointer; display: none'
  104. : 'line-height: 32px; margin-right: 8px; padding: 0 8px; background-color: #eeeeee; border-radius: 4px; cursor: pointer'
  105. "
  106. v-for="(record, index) in item.customerFollowRecordsList"
  107. :key="record.id"
  108. >
  109. <el-popover
  110. placement="bottom"
  111. :width="300"
  112. trigger="hover"
  113. @show="recordShow(record)"
  114. >
  115. <template #reference>
  116. <div>
  117. <span v-if="record.date">{{
  118. record.date.substr(0, 10)
  119. }}</span>
  120. <el-icon
  121. style="margin-left: 8px; transform: translateY(2px)"
  122. @click="deleteFollow(record)"
  123. ><DeleteFilled
  124. /></el-icon>
  125. </div>
  126. </template>
  127. <template #default>
  128. <div style="width: 100%">
  129. <div style="color: #909399; margin: 8px 0">
  130. 跟进时间: {{ record.date }}
  131. </div>
  132. <div style="margin: 8px 0">
  133. 跟进人:
  134. {{ dictValueLabel(record.createUser, userList) }}
  135. </div>
  136. <div v-if="record.type == '30'">
  137. <div
  138. style="word-wrap: break-word; margin: 8px 0"
  139. v-html="getStyle(record.content)"
  140. v-if="record.content"
  141. ></div>
  142. <div v-else>跟进记录:</div>
  143. </div>
  144. <div v-else>
  145. <div style="word-wrap: break-word; margin: 8px 0">
  146. {{ getContent(record) }}
  147. </div>
  148. </div>
  149. <div
  150. style="margin: 8px 0; display: flex"
  151. v-if="record.fileList && record.fileList.length > 0"
  152. >
  153. <div style="width: 36px">附件:</div>
  154. <div style="width: calc(100% - 36px)">
  155. <div
  156. v-for="(file, index) in record.fileList"
  157. :key="index"
  158. >
  159. <a
  160. style="color: #409eff; cursor: pointer"
  161. @click="openFile(file.fileUrl)"
  162. >{{ file.fileName }}</a
  163. >
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </template>
  169. </el-popover>
  170. </div>
  171. <div
  172. style="
  173. line-height: 32px;
  174. margin-right: 8px;
  175. padding: 0 8px;
  176. background-color: #eeeeee;
  177. border-radius: 4px;
  178. cursor: pointer;
  179. "
  180. @click="clickMore(item)"
  181. v-if="item.customerFollowRecordsList.length >= 3"
  182. >
  183. 更多
  184. </div>
  185. </template>
  186. </div>
  187. </div>
  188. </template>
  189. </byTable>
  190. <el-dialog
  191. :title="modalType == 'add' ? '新增' : '编辑'"
  192. v-if="dialogVisible"
  193. v-model="dialogVisible"
  194. width="800"
  195. v-loading="loadingOperation"
  196. >
  197. <byForm
  198. :formConfig="formConfig"
  199. :formOption="formOption"
  200. v-model="formData.data"
  201. :rules="rules"
  202. ref="submit"
  203. >
  204. <template #allAddress>
  205. <el-row style="width: 100%">
  206. <el-col :span="8">
  207. <el-form-item prop="countryId">
  208. <el-select
  209. v-model="formData.data.countryId"
  210. placeholder="国家"
  211. filterable
  212. @change="(val) => getCityData(val, '20', true)"
  213. >
  214. <el-option
  215. v-for="item in countryData"
  216. :label="item.chineseName"
  217. :value="item.id"
  218. >
  219. </el-option>
  220. </el-select>
  221. </el-form-item>
  222. </el-col>
  223. <el-col :span="8">
  224. <el-form-item prop="provinceName">
  225. <selectCity
  226. placeholder="省/洲"
  227. @change="(val) => getCityData(val, '30', true)"
  228. addressId="provinceId"
  229. addressName="provinceName"
  230. v-model="formData.data"
  231. :data="provinceData"
  232. >
  233. </selectCity>
  234. </el-form-item>
  235. </el-col>
  236. <el-col :span="8">
  237. <el-form-item prop="cityName">
  238. <selectCity
  239. placeholder="城市"
  240. addressId="cityId"
  241. addressName="cityName"
  242. v-model="formData.data"
  243. :data="cityData"
  244. ></selectCity>
  245. </el-form-item>
  246. </el-col>
  247. </el-row>
  248. <el-row style="margin-top: 20px; width: 100%">
  249. <el-col :span="24">
  250. <el-form-item prop="address">
  251. <el-input v-model="formData.data.address" type="textarea">
  252. </el-input>
  253. </el-form-item>
  254. </el-col>
  255. </el-row>
  256. </template>
  257. <template #person>
  258. <div style="width: 100%">
  259. <el-button type="primary" @click="clickAddPerson">添 加</el-button>
  260. <el-table
  261. :data="formData.data.customerUserList"
  262. style="width: 100%; margin-top: 16px"
  263. >
  264. <el-table-column label="联系人" width="160">
  265. <template #default="{ row, $index }">
  266. <div style="width: 100%">
  267. <el-form-item
  268. :prop="'customerUserList.' + $index + '.name'"
  269. :rules="rules.name2"
  270. :inline-message="true"
  271. >
  272. <el-input v-model="row.name" placeholder="请输入联系人" />
  273. </el-form-item>
  274. </div>
  275. </template>
  276. </el-table-column>
  277. <el-table-column label="电子邮箱">
  278. <template #default="{ row, $index }">
  279. <div style="width: 100%">
  280. <el-form-item
  281. :prop="'customerUserList.' + $index + '.email'"
  282. :rules="rules.email"
  283. :inline-message="true"
  284. >
  285. <el-input
  286. v-model="row.email"
  287. placeholder="请输入电子邮箱"
  288. />
  289. </el-form-item>
  290. </div>
  291. </template>
  292. </el-table-column>
  293. <el-table-column
  294. align="center"
  295. label="操作"
  296. width="120"
  297. fixed="right"
  298. >
  299. <template #default="{ row, $index }">
  300. <el-button
  301. type="primary"
  302. link
  303. @click="clickInformationMore(row, $index)"
  304. >更多</el-button
  305. >
  306. <el-button type="primary" link @click="clickDelete($index)"
  307. >删除</el-button
  308. >
  309. </template>
  310. </el-table-column>
  311. </el-table>
  312. </div>
  313. </template>
  314. </byForm>
  315. <template #footer>
  316. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  317. <el-button
  318. type="primary"
  319. @click="submitForm()"
  320. size="large"
  321. :loading="submitLoading"
  322. >确 定</el-button
  323. >
  324. </template>
  325. </el-dialog>
  326. <el-dialog
  327. title="更多联系方式"
  328. v-if="openPerson"
  329. v-model="openPerson"
  330. width="700"
  331. >
  332. <el-form
  333. :label-position="'top'"
  334. :model="formPerson.data"
  335. :rules="rulesPerson"
  336. ref="person"
  337. >
  338. <el-form-item label="联系人" prop="name">
  339. <el-input v-model="formPerson.data.name" />
  340. </el-form-item>
  341. <el-form-item label="电子邮箱" prop="email">
  342. <el-input v-model="formPerson.data.email" />
  343. </el-form-item>
  344. <el-form-item label="更多联系方式">
  345. <div style="width: 100%">
  346. <el-button type="primary" @click="clickAddMoreInformation"
  347. >添 加</el-button
  348. >
  349. <el-table
  350. :data="formPerson.data.contact"
  351. style="width: 100%; margin-top: 16px"
  352. >
  353. <el-table-column label="类型" width="180">
  354. <template #default="{ row, $index }">
  355. <div style="width: 100%">
  356. <el-form-item
  357. :prop="'contact.' + $index + '.type'"
  358. :rules="rulesPerson.type"
  359. :inline-message="true"
  360. >
  361. <el-select
  362. v-model="row.type"
  363. placeholder="请选择类型"
  364. style="width: 100%"
  365. >
  366. <el-option
  367. v-for="item in contactType"
  368. :key="item.value"
  369. :label="item.label"
  370. :value="item.value"
  371. />
  372. </el-select>
  373. </el-form-item>
  374. </div>
  375. </template>
  376. </el-table-column>
  377. <el-table-column label="联系号码">
  378. <template #default="{ row, $index }">
  379. <div style="width: 100%">
  380. <el-form-item
  381. :prop="'contact.' + $index + '.contactNo'"
  382. :rules="rulesPerson.contactNo"
  383. :inline-message="true"
  384. >
  385. <el-input
  386. v-model="row.contactNo"
  387. placeholder="请输入联系号码"
  388. />
  389. </el-form-item>
  390. </div>
  391. </template>
  392. </el-table-column>
  393. <el-table-column
  394. align="center"
  395. label="操作"
  396. width="120"
  397. fixed="right"
  398. >
  399. <template #default="{ $index }">
  400. <el-button
  401. type="primary"
  402. link
  403. @click="clickInformationDelete($index)"
  404. >删除</el-button
  405. >
  406. </template>
  407. </el-table-column>
  408. </el-table>
  409. </div>
  410. </el-form-item>
  411. </el-form>
  412. <template #footer>
  413. <el-button @click="openPerson = false" size="large">取 消</el-button>
  414. <el-button type="primary" @click="submitPerson()" size="large"
  415. >确 定</el-button
  416. >
  417. </template>
  418. </el-dialog>
  419. <el-dialog
  420. title="分配"
  421. v-if="openAllocation"
  422. v-model="openAllocation"
  423. width="300"
  424. >
  425. <byForm
  426. :formConfig="formConfigAllocation"
  427. :formOption="formOption"
  428. v-model="formAllocation.data"
  429. :rules="rulesAllocation"
  430. ref="allocation"
  431. >
  432. </byForm>
  433. <template #footer>
  434. <el-button @click="openAllocation = false" size="large"
  435. >取 消</el-button
  436. >
  437. <el-button type="primary" @click="submitAllocation()" size="large"
  438. >确 定</el-button
  439. >
  440. </template>
  441. </el-dialog>
  442. <el-dialog
  443. title="添加跟进记录"
  444. v-if="openFollow"
  445. v-model="openFollow"
  446. width="500"
  447. destroy-on-close
  448. >
  449. <byForm
  450. :formConfig="formConfigAFollow"
  451. :formOption="formOption"
  452. v-model="formFollow.data"
  453. :rules="rulesFollow"
  454. ref="follow"
  455. >
  456. <template #fileSlot>
  457. <div style="width: 100%">
  458. <el-upload
  459. v-model:fileList="fileList"
  460. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  461. :data="uploadData"
  462. multiple
  463. :before-upload="uploadFile"
  464. :on-preview="onPreviewFile"
  465. >
  466. <el-button type="primary">文件上传</el-button>
  467. </el-upload>
  468. </div>
  469. </template>
  470. </byForm>
  471. <template #footer>
  472. <el-button @click="openFollow = false" size="large">取 消</el-button>
  473. <el-button type="primary" @click="submitFollow()" size="large"
  474. >确 定</el-button
  475. >
  476. </template>
  477. </el-dialog>
  478. <el-dialog
  479. title="跟进记录"
  480. v-if="openRecordMore"
  481. v-model="openRecordMore"
  482. width="800"
  483. destroy-on-close
  484. >
  485. <div>
  486. <div style="padding: 8px 0">
  487. <el-button type="primary" @click="clickFollowUp(rowData)" plain
  488. >添加跟进记录</el-button
  489. >
  490. </div>
  491. <div style="padding-top: 16px">
  492. <div
  493. v-infinite-scroll="infiniteScroll"
  494. class="infinite-scroll"
  495. :infinite-scroll-disabled="judgeTotal()"
  496. >
  497. <el-timeline>
  498. <el-timeline-item
  499. v-for="(record, index) in recordList"
  500. :key="index"
  501. :timestamp="record.date"
  502. hide-timestamp
  503. >
  504. <div>
  505. <div
  506. style="
  507. padding: 0 0 8px 0;
  508. display: flex;
  509. justify-content: space-between;
  510. "
  511. >
  512. <span>{{
  513. dictValueLabel(record.createUser, userList)
  514. }}</span>
  515. <span>{{ record.date }}</span>
  516. </div>
  517. <div v-if="record.type == '30'">
  518. <div
  519. style="word-wrap: break-word; margin: 8px 0"
  520. v-html="getStyle(record.content)"
  521. v-if="record.content"
  522. ></div>
  523. <div v-else>跟进记录:</div>
  524. </div>
  525. <div v-else>
  526. <div style="word-wrap: break-word; margin: 8px 0">
  527. {{ getContent(record) }}
  528. </div>
  529. </div>
  530. <div
  531. style="margin: 8px 0; display: flex"
  532. v-if="record.fileList && record.fileList.length > 0"
  533. >
  534. <div style="width: 36px">附件:</div>
  535. <div style="width: calc(100% - 36px)">
  536. <div
  537. v-for="(file, index) in record.fileList"
  538. :key="index"
  539. >
  540. <a
  541. style="color: #409eff; cursor: pointer"
  542. @click="openFile(file.fileUrl)"
  543. >{{ file.fileName }}</a
  544. >
  545. </div>
  546. </div>
  547. </div>
  548. </div>
  549. </el-timeline-item>
  550. </el-timeline>
  551. </div>
  552. </div>
  553. </div>
  554. <template #footer>
  555. <el-button @click="openRecordMore = false" size="large"
  556. >关 闭</el-button
  557. >
  558. </template>
  559. </el-dialog>
  560. <el-dialog
  561. title="高级检索"
  562. v-if="openSearch"
  563. v-model="openSearch"
  564. width="600"
  565. :before-close="cancelSearch"
  566. >
  567. <byForm
  568. :formConfig="formSearchConfig"
  569. :formOption="formOption"
  570. v-model="sourceList.pagination"
  571. >
  572. <template #address>
  573. <el-row style="width: 100%">
  574. <el-col :span="8">
  575. <el-form-item prop="countryId">
  576. <el-select
  577. v-model="sourceList.pagination.countryId"
  578. placeholder="国家"
  579. clearable
  580. filterable
  581. @change="(val) => getCitySearchData(val, '20', true)"
  582. >
  583. <el-option
  584. v-for="item in countrySearchData"
  585. :label="item.chineseName"
  586. :value="item.id"
  587. >
  588. </el-option>
  589. </el-select>
  590. </el-form-item>
  591. </el-col>
  592. <el-col :span="8">
  593. <el-form-item prop="provinceName">
  594. <selectCity
  595. placeholder="省/洲"
  596. @change="(val) => getCitySearchData(val, '30', true)"
  597. addressId="provinceId"
  598. addressName="provinceName"
  599. v-model="sourceList.pagination"
  600. :data="provinceSearchData"
  601. >
  602. </selectCity>
  603. </el-form-item>
  604. </el-col>
  605. <el-col :span="8">
  606. <el-form-item prop="cityName">
  607. <selectCity
  608. placeholder="城市"
  609. addressId="cityId"
  610. addressName="cityName"
  611. v-model="sourceList.pagination"
  612. :data="citySearchData"
  613. ></selectCity>
  614. </el-form-item>
  615. </el-col>
  616. </el-row>
  617. </template>
  618. <template #tags>
  619. <div style="width: 100%">
  620. <el-tag
  621. style="margin-right: 8px"
  622. type="info"
  623. v-for="(tag, index) in sourceList.pagination.tags"
  624. closable
  625. :key="index"
  626. @close="tagSearchClose(tag)"
  627. >
  628. {{ dictValueLabel(tag, customerTag) }}
  629. </el-tag>
  630. <template
  631. v-if="sourceList.pagination.tags.length !== customerTag.length"
  632. >
  633. <el-select
  634. v-if="addTagSearchShow"
  635. v-model="addSearchTag"
  636. style="margin-top: 8px"
  637. @change="changeSearchTag"
  638. >
  639. <el-option
  640. v-for="tag in customerTag"
  641. :key="tag.value"
  642. :label="tag.label"
  643. :value="tag.value"
  644. :disabled="
  645. judgeTagSelect(sourceList.pagination.tags, tag.value)
  646. "
  647. />
  648. </el-select>
  649. <el-tag
  650. style="cursor: pointer"
  651. type="info"
  652. @click="addTagSearchShow = true"
  653. v-else
  654. >
  655. +
  656. </el-tag>
  657. </template>
  658. </div>
  659. </template>
  660. </byForm>
  661. <template #footer>
  662. <el-button @click="cancelSearch()" size="large">取 消</el-button>
  663. <el-button type="primary" @click="submitSearch()" size="large"
  664. >确 定</el-button
  665. >
  666. </template>
  667. </el-dialog>
  668. </div>
  669. </template>
  670. <script setup>
  671. import { ElMessage, ElMessageBox } from "element-plus";
  672. import byTable from "@/components/byTable/index";
  673. import byForm from "@/components/byForm/index";
  674. import { computed, ref } from "vue";
  675. import useUserStore from "@/store/modules/user";
  676. import selectCity from "@/components/selectCity/index.vue";
  677. const { proxy } = getCurrentInstance();
  678. const loading = ref(false);
  679. const loadingOperation = ref(false);
  680. const submitLoading = ref(false);
  681. const openPerson = ref(false);
  682. const openAllocation = ref(false);
  683. const customerTag = ref([]);
  684. const customerSource = ref([]);
  685. const customerStatus = ref([]);
  686. const contactType = ref([]);
  687. const userList = ref([]);
  688. const fileList = ref([]);
  689. const uploadData = ref({});
  690. const statisticsType = ref([
  691. {
  692. label: "客户来源统计",
  693. value: 1,
  694. },
  695. {
  696. label: "客户类型统计",
  697. value: 2,
  698. },
  699. {
  700. label: "业务员统计",
  701. value: 3,
  702. },
  703. ]);
  704. const sourceList = ref({
  705. data: [],
  706. pagination: {
  707. total: 0,
  708. pageNum: 1,
  709. pageSize: 10,
  710. keyword: "",
  711. type: "",
  712. source: "",
  713. status: "",
  714. name: "",
  715. countryId: "",
  716. provinceId: "",
  717. cityId: "",
  718. customerCode: "",
  719. userId: "",
  720. tag: "",
  721. tags: [],
  722. },
  723. paginationTwo: {
  724. statisticsType: 1,
  725. type: null,
  726. },
  727. });
  728. const statConfig = computed(() => [
  729. {
  730. label: "客户来源统计",
  731. data: [
  732. {
  733. label: "合计",
  734. num: statisticalData.value.countAmount,
  735. type: 2,
  736. },
  737. ...customerSource.value
  738. .filter((a) => getNum(a.value) > 0)
  739. .map((b) => {
  740. let num = getNum(b.value);
  741. return {
  742. label: b.label,
  743. num,
  744. type: 1,
  745. };
  746. }),
  747. ],
  748. },
  749. {
  750. label: "客户类型统计",
  751. data: [
  752. {
  753. label: "合计",
  754. num: statisticalData.value.countAmount,
  755. type: 2,
  756. },
  757. ...customerStatus.value
  758. .filter((a) => getNum(a.value) > 0)
  759. .map((b) => {
  760. let num = getNum(b.value);
  761. return {
  762. label: b.label,
  763. num,
  764. type: 1,
  765. };
  766. }),
  767. ],
  768. },
  769. {
  770. label: "业务员统计",
  771. data: [
  772. {
  773. label: "合计",
  774. num: statisticalData.value.countAmount,
  775. type: 2,
  776. },
  777. ...userList.value
  778. .filter((a) => getNum(a.value) > 0)
  779. .map((b) => {
  780. let num = getNum(b.value);
  781. return {
  782. label: b.label,
  783. num,
  784. type: 1,
  785. };
  786. }),
  787. ],
  788. },
  789. ]);
  790. const selectConfig = computed(() => {
  791. return [
  792. {
  793. label: "客户状态",
  794. prop: "type",
  795. data: [
  796. {
  797. label: "公海",
  798. value: "0",
  799. },
  800. {
  801. label: "私海",
  802. value: "1",
  803. },
  804. ],
  805. },
  806. {
  807. label: "客户来源",
  808. prop: "source",
  809. data: customerSource.value,
  810. },
  811. {
  812. label: "客户类型",
  813. prop: "status",
  814. data: customerStatus.value,
  815. },
  816. ];
  817. });
  818. const config = computed(() => {
  819. return [
  820. {
  821. attrs: {
  822. label: "",
  823. slot: "isTop",
  824. fixed: "left",
  825. width: 60,
  826. align: "center",
  827. },
  828. },
  829. {
  830. attrs: {
  831. label: "客户名称",
  832. slot: "name",
  833. fixed: "left",
  834. width: 160,
  835. },
  836. },
  837. {
  838. attrs: {
  839. label: "所在城市",
  840. slot: "address",
  841. width: 160,
  842. },
  843. },
  844. {
  845. attrs: {
  846. label: "客户代码",
  847. prop: "customerCode",
  848. width: 120,
  849. },
  850. },
  851. {
  852. attrs: {
  853. label: "客户来源",
  854. prop: "source",
  855. width: 120,
  856. },
  857. render(type) {
  858. return proxy.dictValueLabel(type, customerSource.value);
  859. },
  860. },
  861. {
  862. attrs: {
  863. label: "客户类型",
  864. prop: "status",
  865. width: 120,
  866. },
  867. render(type) {
  868. return proxy.dictValueLabel(type, customerStatus.value);
  869. },
  870. },
  871. {
  872. attrs: {
  873. label: "客户标签",
  874. slot: "tags",
  875. width: 180,
  876. },
  877. },
  878. {
  879. attrs: {
  880. label: "业务员",
  881. prop: "userId",
  882. width: 140,
  883. },
  884. render(type) {
  885. let data = userList.value.filter((item) => item.value == type);
  886. if (data && data.length > 0) {
  887. return data[0].label;
  888. } else {
  889. return "";
  890. }
  891. },
  892. },
  893. {
  894. attrs: {
  895. label: "跟进",
  896. slot: "follow",
  897. "min-width": 440,
  898. },
  899. },
  900. {
  901. attrs: {
  902. label: "操作",
  903. width: 190,
  904. align: "center",
  905. fixed: "right",
  906. },
  907. renderHTML(row) {
  908. return [
  909. {
  910. attrs: {
  911. label: "分配",
  912. type: "primary",
  913. text: true,
  914. },
  915. el: "button",
  916. click() {
  917. formAllocation.data = {
  918. id: row.id,
  919. userId: row.userId,
  920. };
  921. openAllocation.value = true;
  922. },
  923. },
  924. {
  925. attrs: {
  926. label: "跟进",
  927. type: "primary",
  928. text: true,
  929. },
  930. el: "button",
  931. click() {
  932. clickFollowUp(row);
  933. },
  934. },
  935. {
  936. attrs: {
  937. label: "修改",
  938. type: "primary",
  939. text: true,
  940. },
  941. el: "button",
  942. click() {
  943. update(row);
  944. },
  945. },
  946. {
  947. attrs: {
  948. label: "删除",
  949. type: "primary",
  950. text: true,
  951. },
  952. el: "button",
  953. click() {
  954. ElMessageBox.confirm(
  955. "此操作将永久删除该数据, 是否继续?",
  956. "提示",
  957. {
  958. confirmButtonText: "确定",
  959. cancelButtonText: "取消",
  960. type: "warning",
  961. }
  962. ).then(() => {
  963. proxy
  964. .post("/customer/delete", {
  965. id: row.id,
  966. })
  967. .then(() => {
  968. ElMessage({
  969. message: "删除成功",
  970. type: "success",
  971. });
  972. getList();
  973. obtainStatisticalData();
  974. });
  975. });
  976. },
  977. },
  978. ];
  979. },
  980. },
  981. ];
  982. });
  983. const modalType = ref("add");
  984. const dialogVisible = ref(false);
  985. const formData = reactive({
  986. data: {
  987. countryId: "44",
  988. },
  989. });
  990. const openFollow = ref(false);
  991. const formPerson = reactive({
  992. data: {},
  993. });
  994. const formAllocation = reactive({
  995. data: {},
  996. });
  997. const formFollow = reactive({
  998. data: {},
  999. });
  1000. const formOption = reactive({
  1001. inline: true,
  1002. labelWidth: 100,
  1003. itemWidth: 100,
  1004. rules: [],
  1005. });
  1006. const formConfig = computed(() => {
  1007. return [
  1008. {
  1009. type: "input",
  1010. prop: "name",
  1011. label: "客户名称",
  1012. required: true,
  1013. itemWidth: 100,
  1014. itemType: "text",
  1015. },
  1016. {
  1017. type: "slot",
  1018. slotName: "allAddress",
  1019. label: "详细地址",
  1020. },
  1021. {
  1022. type: "input",
  1023. prop: "customerCode",
  1024. label: "客户代码",
  1025. required: true,
  1026. itemWidth: 100,
  1027. itemType: "text",
  1028. },
  1029. {
  1030. type: "select",
  1031. label: "客户来源",
  1032. prop: "source",
  1033. itemWidth: 50,
  1034. data: customerSource.value,
  1035. },
  1036. {
  1037. type: "select",
  1038. label: "客户类型",
  1039. prop: "status",
  1040. itemWidth: 50,
  1041. data: customerStatus.value,
  1042. },
  1043. {
  1044. type: "select",
  1045. label: "业务员",
  1046. prop: "userId",
  1047. itemWidth: 100,
  1048. data: userList.value,
  1049. clearable: true,
  1050. },
  1051. {
  1052. type: "select",
  1053. label: "客户标签",
  1054. prop: "tags",
  1055. itemWidth: 100,
  1056. multiple: true,
  1057. data: customerTag.value,
  1058. style: {
  1059. width: "100%",
  1060. },
  1061. },
  1062. {
  1063. type: "slot",
  1064. slotName: "person",
  1065. label: "客户联系人",
  1066. },
  1067. ];
  1068. });
  1069. const rules = ref({
  1070. name: [{ required: true, message: "请输入客户名称", trigger: "blur" }],
  1071. name2: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  1072. email: [{ required: true, message: "请输入电子邮箱", trigger: "blur" }],
  1073. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  1074. source: [{ required: true, message: "请选择客户来源", trigger: "change" }],
  1075. status: [{ required: true, message: "请选择类型", trigger: "change" }],
  1076. });
  1077. const formConfigAllocation = computed(() => {
  1078. return [
  1079. {
  1080. type: "select",
  1081. label: "业务员",
  1082. prop: "userId",
  1083. itemWidth: 100,
  1084. data: userList.value,
  1085. clearable: true,
  1086. },
  1087. ];
  1088. });
  1089. const rulesAllocation = ref({
  1090. userId: [{ required: true, message: "请选择业务员", trigger: "change" }],
  1091. });
  1092. const formConfigAFollow = computed(() => {
  1093. return [
  1094. {
  1095. type: "date",
  1096. itemType: "datetime",
  1097. label: "跟进时间",
  1098. prop: "date",
  1099. itemWidth: 100,
  1100. },
  1101. {
  1102. type: "input",
  1103. itemType: "textarea",
  1104. label: "跟进内容",
  1105. prop: "content",
  1106. itemWidth: 100,
  1107. },
  1108. {
  1109. type: "slot",
  1110. label: "上传附件",
  1111. prop: "fileList",
  1112. slotName: "fileSlot",
  1113. },
  1114. ];
  1115. });
  1116. const rulesPerson = ref({
  1117. name: [{ required: true, message: "请输入联系人", trigger: "blur" }],
  1118. email: [{ required: true, message: "请输入电子邮箱", trigger: "blur" }],
  1119. type: [{ required: true, message: "请选择类型", trigger: "change" }],
  1120. contactNo: [{ required: true, message: "请输入联系号码", trigger: "blur" }],
  1121. });
  1122. const rulesFollow = ref({
  1123. date: [{ required: true, message: "请选择跟进时间", trigger: "change" }],
  1124. content: [{ required: true, message: "请输入跟进内容", trigger: "blur" }],
  1125. });
  1126. const submit = ref(null);
  1127. const person = ref(null);
  1128. const allocation = ref(null);
  1129. const follow = ref(null);
  1130. const getList = async (req) => {
  1131. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  1132. loading.value = true;
  1133. proxy.post("/customer/page", sourceList.value.pagination).then((res) => {
  1134. res.rows.forEach((x) => {
  1135. x.addTagShow = false;
  1136. if (x.tag) {
  1137. x.tag = x.tag.split(",");
  1138. } else {
  1139. x.tag = [];
  1140. }
  1141. });
  1142. sourceList.value.data = res.rows;
  1143. sourceList.value.pagination.total = res.total;
  1144. setTimeout(() => {
  1145. loading.value = false;
  1146. }, 200);
  1147. });
  1148. };
  1149. const countryData = ref([]);
  1150. const provinceData = ref([]);
  1151. const cityData = ref([]);
  1152. const getCityData = (id, type, isChange) => {
  1153. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  1154. if (type === "20") {
  1155. provinceData.value = res;
  1156. if (isChange) {
  1157. formData.data.provinceId = "";
  1158. formData.data.provinceName = "";
  1159. formData.data.cityId = "";
  1160. formData.data.cityName = "";
  1161. }
  1162. } else if (type === "30") {
  1163. cityData.value = res;
  1164. if (isChange) {
  1165. formData.data.cityId = "";
  1166. formData.data.cityName = "";
  1167. }
  1168. } else {
  1169. countryData.value = res;
  1170. }
  1171. });
  1172. };
  1173. getCityData("0");
  1174. const openModal = () => {
  1175. modalType.value = "add";
  1176. formData.data = {
  1177. countryId: "44",
  1178. tags: [],
  1179. customerUserList: [
  1180. {
  1181. name: "",
  1182. email: "",
  1183. },
  1184. ],
  1185. };
  1186. getCityData(formData.data.countryId, "20");
  1187. loadingOperation.value = false;
  1188. dialogVisible.value = true;
  1189. };
  1190. const clickAddPerson = () => {
  1191. if (
  1192. formData.data.customerUserList &&
  1193. formData.data.customerUserList.length > 0
  1194. ) {
  1195. formData.data.customerUserList.push({
  1196. name: "",
  1197. email: "",
  1198. });
  1199. } else {
  1200. formData.data.customerUserList = [
  1201. {
  1202. name: "",
  1203. email: "",
  1204. },
  1205. ];
  1206. }
  1207. };
  1208. const submitAllocation = () => {
  1209. allocation.value.handleSubmit(() => {
  1210. proxy.post("/customer/CustomerAllocation", formAllocation.data).then(() => {
  1211. ElMessage({
  1212. message: "分配成功",
  1213. type: "success",
  1214. });
  1215. openAllocation.value = false;
  1216. getList();
  1217. obtainStatisticalData();
  1218. });
  1219. });
  1220. };
  1221. const submitFollow = () => {
  1222. follow.value.handleSubmit(() => {
  1223. if (fileList.value && fileList.value.length > 0) {
  1224. formFollow.data.fileList = fileList.value.map((item) => {
  1225. return {
  1226. id: item.raw.id,
  1227. fileName: item.raw.fileName,
  1228. fileUrl: item.raw.fileUrl,
  1229. };
  1230. });
  1231. } else {
  1232. formFollow.data.fileList = [];
  1233. }
  1234. proxy
  1235. .post("/customerFollowRecords/" + modalType.value, formFollow.data)
  1236. .then(
  1237. () => {
  1238. ElMessage({
  1239. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  1240. type: "success",
  1241. });
  1242. openFollow.value = false;
  1243. getList();
  1244. },
  1245. (err) => {
  1246. console.log(err);
  1247. }
  1248. );
  1249. });
  1250. };
  1251. const submitForm = () => {
  1252. submit.value.handleSubmit(() => {
  1253. if (
  1254. formData.data.customerUserList &&
  1255. formData.data.customerUserList.length > 0
  1256. ) {
  1257. formData.data.tag = formData.data.tags.join(",");
  1258. submitLoading.value = true;
  1259. proxy.post("/customer/" + modalType.value, formData.data).then(
  1260. () => {
  1261. ElMessage({
  1262. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  1263. type: "success",
  1264. });
  1265. dialogVisible.value = false;
  1266. submitLoading.value = false;
  1267. getList();
  1268. obtainStatisticalData();
  1269. },
  1270. (err) => {
  1271. console.log(err);
  1272. submitLoading.value = false;
  1273. }
  1274. );
  1275. } else {
  1276. ElMessage("请添加客户联系人");
  1277. }
  1278. });
  1279. };
  1280. const getDict = () => {
  1281. proxy
  1282. .getDictOne([
  1283. "customer_tag",
  1284. "customer_source",
  1285. "customer_status",
  1286. "contact_type",
  1287. ])
  1288. .then((res) => {
  1289. customerTag.value = res["customer_tag"].map((x) => ({
  1290. label: x.dictValue,
  1291. value: x.dictKey,
  1292. }));
  1293. customerSource.value = res["customer_source"].map((x) => ({
  1294. label: x.dictValue,
  1295. value: x.dictKey,
  1296. }));
  1297. customerStatus.value = res["customer_status"].map((x) => ({
  1298. label: x.dictValue,
  1299. value: x.dictKey,
  1300. }));
  1301. contactType.value = res["contact_type"].map((x) => ({
  1302. label: x.dictValue,
  1303. value: x.dictKey,
  1304. }));
  1305. });
  1306. proxy
  1307. .get("/tenantUser/list", {
  1308. pageNum: 1,
  1309. pageSize: 10000,
  1310. tenantId: useUserStore().user.tenantId,
  1311. })
  1312. .then((res) => {
  1313. userList.value = res.rows.map((item) => {
  1314. return {
  1315. label: item.nickName,
  1316. value: item.userId,
  1317. };
  1318. });
  1319. });
  1320. };
  1321. getDict();
  1322. getList();
  1323. const handleClickName = (row) => {
  1324. proxy.$router.push({
  1325. path: "/ERP/customer/portrait",
  1326. query: {
  1327. id: row.id,
  1328. },
  1329. });
  1330. };
  1331. const deleteFollow = (data) => {
  1332. ElMessageBox.confirm("是否确认删除该跟进?", "提示", {
  1333. confirmButtonText: "确定",
  1334. cancelButtonText: "取消",
  1335. type: "warning",
  1336. }).then(() => {
  1337. proxy
  1338. .post("/customerFollowRecords/delete", {
  1339. id: data.id,
  1340. })
  1341. .then(() => {
  1342. ElMessage({
  1343. message: "删除成功",
  1344. type: "success",
  1345. });
  1346. getList();
  1347. });
  1348. });
  1349. };
  1350. const addTag = ref("");
  1351. const judgeTagSelect = (data, val) => {
  1352. if (data && data.length > 0) {
  1353. if (data.includes(val)) {
  1354. return true;
  1355. }
  1356. }
  1357. return false;
  1358. };
  1359. const changeTag = (val, item) => {
  1360. let data = {
  1361. id: item.id,
  1362. tag: JSON.parse(JSON.stringify(item.tag)),
  1363. };
  1364. data.tag.push(val);
  1365. data.tag = data.tag.join(",");
  1366. proxy.post("/customer/editTag", data).then(() => {
  1367. ElMessage({
  1368. message: "添加成功",
  1369. type: "success",
  1370. });
  1371. item.addTagShow = false;
  1372. addTag.value = "";
  1373. getList();
  1374. });
  1375. };
  1376. const tagClose = (val, item) => {
  1377. let data = {
  1378. id: item.id,
  1379. tag: JSON.parse(JSON.stringify(item.tag)),
  1380. };
  1381. data.tag = data.tag.filter((row) => row !== val);
  1382. if (data.tag && data.tag.length > 0) {
  1383. data.tag = data.tag.join(",");
  1384. } else {
  1385. data.tag = "";
  1386. }
  1387. proxy.post("/customer/editTag", data).then(() => {
  1388. ElMessage({
  1389. message: "添加成功",
  1390. type: "success",
  1391. });
  1392. item.addTagShow = false;
  1393. addTag.value = "";
  1394. getList();
  1395. });
  1396. };
  1397. const showSelect = (item) => {
  1398. item.addTagShow = true;
  1399. };
  1400. const clickFollowUp = (item) => {
  1401. formFollow.data = {
  1402. customerId: item.id,
  1403. fileList: [],
  1404. };
  1405. fileList.value = [];
  1406. modalType.value = "add";
  1407. openFollow.value = true;
  1408. openRecordMore.value = false;
  1409. };
  1410. const uploadFile = async (file) => {
  1411. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1412. uploadData.value = res.uploadBody;
  1413. file.id = res.id;
  1414. file.fileName = res.fileName;
  1415. file.fileUrl = res.fileUrl;
  1416. return true;
  1417. };
  1418. const onPreviewFile = (file) => {
  1419. window.open(file.raw.fileUrl, "_blank");
  1420. };
  1421. const getStyle = (val) => {
  1422. if (val) {
  1423. return "跟进记录: " + val.replace(/\n|\r\n/g, "<br>");
  1424. } else {
  1425. return "";
  1426. }
  1427. };
  1428. const getContent = (item) => {
  1429. if (item.type === "10") {
  1430. return "跟进记录: " + "报价单总金额 " + proxy.moneyFormat(item.amount, 2);
  1431. } else if (item.type === "20") {
  1432. return (
  1433. "跟进记录: " +
  1434. "合同总金额 " +
  1435. proxy.moneyFormat(item.amount, 2) +
  1436. ` (${item.contractCode}) `
  1437. );
  1438. }
  1439. };
  1440. const recordShow = (item) => {
  1441. if (
  1442. !(item.fileList && item.fileList.length > 0) &&
  1443. JSON.stringify(item.fileList) !== "[]"
  1444. ) {
  1445. proxy
  1446. .post("/fileInfo/getList", { businessIdList: [item.id] })
  1447. .then((fileObj) => {
  1448. item.fileList = fileObj[item.id] || [];
  1449. });
  1450. }
  1451. };
  1452. const openFile = (path) => {
  1453. window.open(path, "_blank");
  1454. };
  1455. const recordList = ref([]);
  1456. const rowData = ref({});
  1457. const openRecordMore = ref(false);
  1458. const queryParams = ref({
  1459. total: 0,
  1460. pageNum: 1,
  1461. pageSize: 10,
  1462. customerId: "",
  1463. });
  1464. const clickMore = (item) => {
  1465. if (openRecordMore.value === false) {
  1466. queryParams.value.pageNum = 1;
  1467. recordList.value = [];
  1468. rowData.value = item;
  1469. queryParams.value.customerId = item.id;
  1470. }
  1471. proxy.post("/customerFollowRecords/page", queryParams.value).then((res) => {
  1472. recordList.value = recordList.value.concat(res.rows);
  1473. queryParams.value.total = res.total;
  1474. proxy
  1475. .post("/fileInfo/getList", {
  1476. businessIdList: res.rows.map((rows) => rows.id),
  1477. })
  1478. .then((fileObj) => {
  1479. for (let i = 0; i < res.rows.length; i++) {
  1480. recordList.value[
  1481. parseInt(
  1482. i + (queryParams.value.pageNum - 1) * queryParams.value.pageSize
  1483. )
  1484. ].fileList =
  1485. fileObj[
  1486. recordList.value[
  1487. parseInt(
  1488. i +
  1489. (queryParams.value.pageNum - 1) * queryParams.value.pageSize
  1490. )
  1491. ].id
  1492. ] || [];
  1493. }
  1494. });
  1495. });
  1496. openRecordMore.value = true;
  1497. };
  1498. const infiniteScroll = () => {
  1499. queryParams.value.pageNum++;
  1500. clickMore();
  1501. };
  1502. const judgeTotal = () => {
  1503. if (
  1504. queryParams.value.pageNum * queryParams.value.pageSize >=
  1505. queryParams.value.total
  1506. ) {
  1507. return true;
  1508. }
  1509. return false;
  1510. };
  1511. const moreIndex = ref(0);
  1512. const clickInformationMore = (item, index) => {
  1513. moreIndex.value = index;
  1514. if (item.contactJson) {
  1515. item.contact = JSON.parse(item.contactJson);
  1516. } else {
  1517. item.contact = [];
  1518. }
  1519. formPerson.data = proxy.deepClone(item);
  1520. openPerson.value = true;
  1521. };
  1522. const clickDelete = (index) => {
  1523. formData.data.customerUserList.splice(index, 1);
  1524. };
  1525. const clickAddMoreInformation = () => {
  1526. if (formPerson.data.contact && formPerson.data.contact.length > 0) {
  1527. formPerson.data.contact.push({
  1528. type: "",
  1529. contactNo: "",
  1530. });
  1531. } else {
  1532. formPerson.data.contact = [
  1533. {
  1534. type: "",
  1535. contactNo: "",
  1536. },
  1537. ];
  1538. }
  1539. };
  1540. const clickInformationDelete = (index) => {
  1541. formPerson.data.contact.splice(index, 1);
  1542. };
  1543. const submitPerson = () => {
  1544. person.value.validate((valid) => {
  1545. if (valid) {
  1546. formPerson.data.contactJson = JSON.stringify(formPerson.data.contact);
  1547. formData.data.customerUserList[moreIndex.value] = formPerson.data;
  1548. openPerson.value = false;
  1549. }
  1550. });
  1551. };
  1552. const deleteTop = (item) => {
  1553. proxy.post("/customerTop/delete", { customerId: item.id }).then(() => {
  1554. item.isTop = 0;
  1555. });
  1556. };
  1557. const addTop = (item) => {
  1558. proxy.post("/customerTop/add", { customerId: item.id }).then(() => {
  1559. item.isTop = 1;
  1560. });
  1561. };
  1562. const statisticalData = ref({
  1563. countAmount: 0,
  1564. customerList: [],
  1565. });
  1566. const obtainStatisticalData = () => {
  1567. proxy
  1568. .post("/customer/sourceStatistics", sourceList.value.paginationTwo)
  1569. .then((res) => {
  1570. statisticalData.value = res;
  1571. });
  1572. };
  1573. obtainStatisticalData();
  1574. const getNum = (val) => {
  1575. let num = 0;
  1576. if (
  1577. statisticalData.value.customerList &&
  1578. statisticalData.value.customerList.length > 0
  1579. ) {
  1580. statisticalData.value.customerList.map((item) => {
  1581. if (sourceList.value.paginationTwo.statisticsType === 1) {
  1582. if (item.source === val) {
  1583. num = item.count;
  1584. }
  1585. } else if (sourceList.value.paginationTwo.statisticsType === 2) {
  1586. if (item.status === val) {
  1587. num = item.count;
  1588. }
  1589. } else if (sourceList.value.paginationTwo.statisticsType === 3) {
  1590. if (item.userId === val) {
  1591. num = item.count;
  1592. }
  1593. }
  1594. });
  1595. }
  1596. return num;
  1597. };
  1598. const update = (row) => {
  1599. modalType.value = "edit";
  1600. loadingOperation.value = true;
  1601. proxy.post("/customer/detail", { id: row.id }).then((res) => {
  1602. if (res.tag) {
  1603. res.tags = res.tag.split(",");
  1604. } else {
  1605. res.tags = [];
  1606. }
  1607. formData.data = res;
  1608. getCityData(formData.data.countryId, "20");
  1609. if (formData.data.provinceId) {
  1610. getCityData(formData.data.provinceId, "30");
  1611. }
  1612. loadingOperation.value = false;
  1613. dialogVisible.value = true;
  1614. });
  1615. };
  1616. const countrySearchData = ref([]);
  1617. const provinceSearchData = ref([]);
  1618. const citySearchData = ref([]);
  1619. const getCitySearchData = (id, type, isChange) => {
  1620. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  1621. if (type === "20") {
  1622. provinceSearchData.value = res;
  1623. if (isChange) {
  1624. sourceList.value.pagination.provinceId = "";
  1625. sourceList.value.pagination.provinceName = "";
  1626. sourceList.value.pagination.cityId = "";
  1627. sourceList.value.pagination.cityName = "";
  1628. }
  1629. } else if (type === "30") {
  1630. citySearchData.value = res;
  1631. if (isChange) {
  1632. sourceList.value.pagination.cityId = "";
  1633. sourceList.value.pagination.cityName = "";
  1634. }
  1635. } else {
  1636. countrySearchData.value = res;
  1637. }
  1638. });
  1639. };
  1640. getCitySearchData("0");
  1641. const openSearch = ref(false);
  1642. const formSearchConfig = computed(() => {
  1643. return [
  1644. {
  1645. type: "input",
  1646. prop: "name",
  1647. label: "客户名称",
  1648. itemType: "text",
  1649. },
  1650. {
  1651. type: "slot",
  1652. slotName: "address",
  1653. label: "所在城市",
  1654. },
  1655. {
  1656. type: "input",
  1657. prop: "customerCode",
  1658. label: "客户代码",
  1659. itemType: "text",
  1660. },
  1661. {
  1662. type: "select",
  1663. label: "客户来源",
  1664. prop: "source",
  1665. itemWidth: 50,
  1666. data: customerSource.value,
  1667. clearable: true,
  1668. },
  1669. {
  1670. type: "select",
  1671. label: "客户类型",
  1672. prop: "status",
  1673. itemWidth: 50,
  1674. data: customerStatus.value,
  1675. clearable: true,
  1676. },
  1677. {
  1678. type: "select",
  1679. label: "业务员",
  1680. prop: "userId",
  1681. data: userList.value,
  1682. clearable: true,
  1683. },
  1684. {
  1685. type: "slot",
  1686. slotName: "tags",
  1687. label: "客户标签",
  1688. },
  1689. ];
  1690. });
  1691. const addSearchTag = ref("");
  1692. const addTagSearchShow = ref(false);
  1693. let copySearch = ref({});
  1694. const moreSearch = () => {
  1695. if (sourceList.value.pagination.tag) {
  1696. sourceList.value.pagination.tags =
  1697. sourceList.value.pagination.tag.split(",");
  1698. } else {
  1699. sourceList.value.pagination.tags = [];
  1700. }
  1701. addTagSearchShow.value = false;
  1702. copySearch.value = proxy.deepClone(sourceList.value.pagination);
  1703. openSearch.value = true;
  1704. };
  1705. const cancelSearch = () => {
  1706. sourceList.value.pagination = copySearch.value;
  1707. openSearch.value = false;
  1708. };
  1709. const submitSearch = () => {
  1710. if (
  1711. sourceList.value.pagination.tags &&
  1712. sourceList.value.pagination.tags.length > 0
  1713. ) {
  1714. sourceList.value.pagination.tag =
  1715. sourceList.value.pagination.tags.join(",");
  1716. } else {
  1717. sourceList.value.pagination.tag = "";
  1718. }
  1719. openSearch.value = false;
  1720. sourceList.value.pagination.keyword = "";
  1721. sourceList.value.pagination.pageNum = 1;
  1722. getList();
  1723. };
  1724. const tagSearchClose = (val) => {
  1725. sourceList.value.pagination.tags = sourceList.value.pagination.tags.filter(
  1726. (item) => item !== val
  1727. );
  1728. };
  1729. const changeSearchTag = (val) => {
  1730. sourceList.value.pagination.tags.push(val);
  1731. addTagSearchShow.value = false;
  1732. addSearchTag.value = "";
  1733. };
  1734. const table = ref(null);
  1735. onMounted(() => {
  1736. watch(
  1737. () => table.value.statSelectVal,
  1738. (val) => {
  1739. sourceList.value.paginationTwo.statisticsType = val + 1;
  1740. obtainStatisticalData();
  1741. }
  1742. );
  1743. });
  1744. </script>
  1745. <style lang="scss" scoped>
  1746. .tenant {
  1747. padding: 20px;
  1748. }
  1749. .infinite-scroll {
  1750. max-height: calc(89vh - 94px - 70px - 58px - 16px);
  1751. overflow-y: auto;
  1752. &::-webkit-scrollbar {
  1753. width: 0px;
  1754. }
  1755. }
  1756. .by-dropdown {
  1757. position: relative;
  1758. text-align: left;
  1759. height: 32px;
  1760. z-index: 1010;
  1761. padding: 0 10px;
  1762. transition: all 0.5s ease;
  1763. cursor: pointer;
  1764. line-height: 32px;
  1765. .by-dropdown-title {
  1766. font-size: 14px;
  1767. background-color: #fff;
  1768. }
  1769. ul {
  1770. position: absolute;
  1771. left: 0;
  1772. top: 32px;
  1773. padding: 0;
  1774. margin: 0;
  1775. z-index: 1200;
  1776. display: none;
  1777. white-space: nowrap;
  1778. background-color: #fff;
  1779. li {
  1780. list-style: none;
  1781. z-index: 1200;
  1782. font-size: 12px;
  1783. height: 30px;
  1784. padding: 0 10px;
  1785. }
  1786. li:hover {
  1787. background-color: #eff6ff;
  1788. color: #0084ff;
  1789. }
  1790. }
  1791. }
  1792. .by-dropdown::before {
  1793. display: block;
  1794. width: 1px;
  1795. content: " ";
  1796. position: absolute;
  1797. height: 14px;
  1798. top: 8px;
  1799. background-color: #ddd;
  1800. right: 0;
  1801. z-index: 1011;
  1802. }
  1803. .by-dropdown:hover {
  1804. background: #ffffff;
  1805. border-radius: 2px 2px 2px 2px;
  1806. opacity: 1;
  1807. ul {
  1808. background: #ffffff;
  1809. box-shadow: 0px 2px 16px 1px rgba(0, 0, 0, 0.06);
  1810. border-radius: 2px 2px 2px 2px;
  1811. opacity: 1;
  1812. display: block;
  1813. text-align: left;
  1814. }
  1815. }
  1816. .by-dropdown-lists {
  1817. max-height: 50vh;
  1818. overflow-y: auto;
  1819. line-height: 1;
  1820. }
  1821. .statistics-text {
  1822. padding-left: 8px;
  1823. width: 152px;
  1824. overflow: hidden;
  1825. text-overflow: ellipsis;
  1826. white-space: nowrap;
  1827. }
  1828. </style>